Commit 3851a2eb 张东亮

合并分支 '软件退出后,重启软件继续动作' 到 'master'

0224

查看合并请求 !1
2 个父辈 fac119ae 5c416acb
正在显示 47 个修改的文件 包含 920 行增加384 行删除
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
<!--云仓服务器端口--> <!--云仓服务器端口-->
<add key="http.server" value="http://10.85.199.25/myproject/" /> <add key="http.server" value="http://10.85.199.25/myproject/" />
<!--ITS智能物流系统服务端口--> <!--ITS智能物流系统服务端口-->
<add key="ITS_UpdateLine" value="http://127.0.0.1:8888" /> <add key="ITS_UpdateLine" value="http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/" />
<!--电梯控制系统系统服务端口--> <!--电梯控制系统系统服务端口-->
<add key="Lift_Server" value="http://127.0.0.1:8888/lift/" /> <add key="Lift_Server" value="http://127.0.0.1:8887/lift/" />
<!--日志配置文件名--> <!--日志配置文件名-->
<add key="log4net_configname" value="log4net.config" /> <add key="log4net_configname" value="log4net.config" />
<!--agv配置文件名--> <!--agv配置文件名-->
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
<add key="WaitTimeout" value="5" /> <add key="WaitTimeout" value="5" />
<!--停留超时异常上报时间(分钟)--> <!--停留超时异常上报时间(分钟)-->
<add key="StandTimeout" value="6" /> <add key="StandTimeout" value="6" />
<!--Agv上下文信息文件名-->
<add key="FileName_AgvContext" value="AgvContext.json" />
</appSettings> </appSettings>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
this.tabControlManual = new System.Windows.Forms.TabControl(); this.tabControlManual = new System.Windows.Forms.TabControl();
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.lblShow = new System.Windows.Forms.Label();
this.tableLayoutPanel3.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout(); this.tabPage2.SuspendLayout();
...@@ -168,7 +169,6 @@ ...@@ -168,7 +169,6 @@
this.DgvNode.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.DgvNode.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.DgvNode.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells; this.DgvNode.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.DgvNode.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.DgvNode.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.DgvNode.Dock = System.Windows.Forms.DockStyle.Fill;
this.DgvNode.Location = new System.Drawing.Point(3, 3); this.DgvNode.Location = new System.Drawing.Point(3, 3);
this.DgvNode.MultiSelect = false; this.DgvNode.MultiSelect = false;
this.DgvNode.Name = "DgvNode"; this.DgvNode.Name = "DgvNode";
...@@ -177,7 +177,7 @@ ...@@ -177,7 +177,7 @@
this.DgvNode.RowHeadersVisible = false; this.DgvNode.RowHeadersVisible = false;
this.DgvNode.RowHeadersWidth = 50; this.DgvNode.RowHeadersWidth = 50;
this.DgvNode.RowTemplate.Height = 23; this.DgvNode.RowTemplate.Height = 23;
this.DgvNode.Size = new System.Drawing.Size(1189, 335); this.DgvNode.Size = new System.Drawing.Size(1189, 298);
this.DgvNode.TabIndex = 1; this.DgvNode.TabIndex = 1;
this.DgvNode.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DgvNode_CellClick); this.DgvNode.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DgvNode_CellClick);
// //
...@@ -262,6 +262,7 @@ ...@@ -262,6 +262,7 @@
// //
// tabPage3 // tabPage3
// //
this.tabPage3.Controls.Add(this.lblShow);
this.tabPage3.Controls.Add(this.label12); this.tabPage3.Controls.Add(this.label12);
this.tabPage3.Controls.Add(this.groupBox2); this.tabPage3.Controls.Add(this.groupBox2);
this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Location = new System.Drawing.Point(4, 22);
...@@ -329,6 +330,15 @@ ...@@ -329,6 +330,15 @@
this.flowLayoutPanel1.Size = new System.Drawing.Size(1205, 346); this.flowLayoutPanel1.Size = new System.Drawing.Size(1205, 346);
this.flowLayoutPanel1.TabIndex = 0; this.flowLayoutPanel1.TabIndex = 0;
// //
// lblShow
//
this.lblShow.Dock = System.Windows.Forms.DockStyle.Left;
this.lblShow.Location = new System.Drawing.Point(253, 3);
this.lblShow.Name = "lblShow";
this.lblShow.Size = new System.Drawing.Size(420, 341);
this.lblShow.TabIndex = 47;
this.lblShow.Text = resources.GetString("lblShow.Text");
//
// FrmMain // FrmMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
...@@ -383,6 +393,7 @@ ...@@ -383,6 +393,7 @@
private System.Windows.Forms.GroupBox grpUnlock; private System.Windows.Forms.GroupBox grpUnlock;
private System.Windows.Forms.TableLayoutPanel tblLayoutUnlock; private System.Windows.Forms.TableLayoutPanel tblLayoutUnlock;
private System.Windows.Forms.DataGridView dgvInfos; private System.Windows.Forms.DataGridView dgvInfos;
private System.Windows.Forms.Label lblShow;
} }
} }
...@@ -28,7 +28,7 @@ namespace AGVControl ...@@ -28,7 +28,7 @@ namespace AGVControl
InitializeComponent(); InitializeComponent();
showTimer = new System.Timers.Timer(); showTimer = new System.Timers.Timer();
showTimer.Interval = 5000; showTimer.Interval = 5000;
//showTimer.Enabled = true; CheckForIllegalCrossThreadCalls = false;
showTimer.AutoReset = true; showTimer.AutoReset = true;
showTimer.Elapsed += ShowTimer_Elapsed; showTimer.Elapsed += ShowTimer_Elapsed;
showTimer.Start(); showTimer.Start();
...@@ -155,7 +155,7 @@ namespace AGVControl ...@@ -155,7 +155,7 @@ namespace AGVControl
Invoke(new Action(() => Invoke(new Action(() =>
{ {
lblShow.Text = DeviceLibrary.HttpManager.Agvtransinfo;
})); }));
......
...@@ -117,6 +117,9 @@ ...@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="lblShow.Text" xml:space="preserve">
<value>[2021-12-28 16:17:29,631][162][HttpManager:282]ERROR AgvReportState fail[http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/UpdateAgvtransinfo]:[[{"agvNum":"2号车","workshop":"4D","battery":0,"position":{"Point":{"IsEmpty":true,"X":0.0,"Y":0.0},"orientation":0.0},"state":null,"missionId":null,"remark":null,"curTarget":null,"statusTxt":""},{"agvNum":"7号车","workshop":"4D","battery":0,"position":{"Point":{"IsEmpty":true,"X":0.0,"Y":0.0},"orientation":0.0},"state":null,"missionId":null,"remark":null,"curTarget":null,"statusTxt":""},{"agvNum":"17号车","workshop":"3D","battery":0,"position":{"Point":{"IsEmpty":true,"X":0.0,"Y":0.0},"orientation":0.0},"state":null,"missionId":null,"remark":null,"curTarget":null,"statusTxt":""}]][]</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
......
...@@ -81,6 +81,16 @@ namespace AGVControl ...@@ -81,6 +81,16 @@ namespace AGVControl
if (!isIni) return; if (!isIni) return;
this.Invoke(new Action(() => this.Invoke(new Action(() =>
{ {
if (!chkBxAuto.Checked && !Agv.JobContext.MissionId.Equals(""))
{
if(MessageBox.Show($"正在执行任务[{Agv.JobContext.MissionId}],切到手动后该任务无法继续执行,确定切到手动状态?", "警告",MessageBoxButtons.YesNo).Equals(
DialogResult.No))
{
chkBxAuto.Checked = true;
return;
}
LogUtil.info($"人员切换到手动,{Agv.Name}当前执行的任务为{Agv.JobContext.MissionId}");
}
btnReSendTask.Enabled = chkBxAuto.Checked; btnReSendTask.Enabled = chkBxAuto.Checked;
btnAssignTask.Enabled = !chkBxAuto.Checked; btnAssignTask.Enabled = !chkBxAuto.Checked;
cmbBxMission.Enabled = !chkBxAuto.Checked; cmbBxMission.Enabled = !chkBxAuto.Checked;
...@@ -95,7 +105,7 @@ namespace AGVControl ...@@ -95,7 +105,7 @@ namespace AGVControl
{ {
if (Agv.CurJob != null && Agv.CurJob.JobParam != null && Agv.CurJob.JobParam.GetMissionInfo() != null) if (Agv.CurJob != null && Agv.CurJob.JobParam != null && Agv.CurJob.JobParam.GetMissionInfo() != null)
{ {
DeviceLibrary.manager.MissionManager.SetMissionState(Agv.CurJob.JobParam.GetMissionInfo(), DeviceLibrary.service.model.MissionState.中止); DeviceLibrary.manager.MissionManager.SetMissionState(Agv.CurJob.JobParam.GetMissionInfo().missionId, DeviceLibrary.service.model.MissionState.中止,out string msg);
LogUtil.info($"取消自动任务,当前任务信息是:{Common.JsonHelper.SerializeObject(Agv.CurJob.JobParam.GetMissionInfo())}"); LogUtil.info($"取消自动任务,当前任务信息是:{Common.JsonHelper.SerializeObject(Agv.CurJob.JobParam.GetMissionInfo())}");
} }
} }
...@@ -104,7 +114,7 @@ namespace AGVControl ...@@ -104,7 +114,7 @@ namespace AGVControl
Agv.CurJob = null; Agv.CurJob = null;
//MiR_API.Del_Mission(Agv); //MiR_API.Del_Mission(Agv);
//添加Init任务 //添加Init任务
AgvTaskManager.AssignMission(Agv, SettingString.Init); AgvTaskManager.AssignMission(Agv, $"{SettingString.Init}");
} }
} }
......
...@@ -45,14 +45,14 @@ namespace AGVControl ...@@ -45,14 +45,14 @@ namespace AGVControl
LogUtil.info("=====程序开始====="); LogUtil.info("=====程序开始=====");
NodeManager.InitNodesInfos(); NodeManager.InitNodesInfos();
IOManager.Start(); IOManager.Start();
AGVManager.Init(); DeviceLibrary.manager.MissionManager.InitMission();
ChargePileManager.Init(); ChargePileManager.Init();
AGVManager.Init();
AGVManager.control = new DeviceLibrary.Control(); AGVManager.control = new DeviceLibrary.Control();
AGVManager.control.Start(); AGVManager.control.Start();
AGVManager.server = new AgvServer(); AGVManager.server = new AgvServer();
AGVManager.server.Start(); AGVManager.server.Start();
DeviceLibrary.manager.MissionManager.InitMission();
DeviceLibrary.manager.MissionManager.Open(); DeviceLibrary.manager.MissionManager.Open();
Application.Run(new FrmMain()); Application.Run(new FrmMain());
......
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<configSections> <configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections> </configSections>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup> </startup>
<log4net> <log4net>
<appender name="AgvServer" type="log4net.Appender.RollingFileAppender"> <appender name="AgvServer" type="log4net.Appender.RollingFileAppender">
<file value="logs/AgvServer/AgvServer.log"/> <file value="logs/AgvServer/AgvServer.log"/>
<param name="Encoding" value="UTF-8"/> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/> <appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30"/> <param name="MaxSizeRollBackups" value="30"/>
<rollingStyle value="Date"/> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/> <conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout> </layout>
</appender> </appender>
<appender name="HttpManager" type="log4net.Appender.RollingFileAppender"> <appender name="HttpManager" type="log4net.Appender.RollingFileAppender">
<file value="logs/HttpManager/HttpManager.log"/> <file value="logs/HttpManager/HttpManager.log"/>
<param name="Encoding" value="UTF-8"/> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/> <appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30"/> <param name="MaxSizeRollBackups" value="30"/>
<rollingStyle value="Date"/> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/> <conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout> </layout>
</appender> </appender>
<appender name="AGVDispatch" type="log4net.Appender.RollingFileAppender"> <appender name="AGVDispatch" type="log4net.Appender.RollingFileAppender">
<file value="logs/AGVDispatch/AGVDispatch.log"/> <file value="logs/AGVDispatch/AGVDispatch.log"/>
<param name="Encoding" value="UTF-8"/> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/> <appendToFile value="true"/>
<rollingStyle value="Date"/> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/> <conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout> </layout>
</appender> </appender>
<appender name="WebService" type="log4net.Appender.RollingFileAppender"> <appender name="WebService" type="log4net.Appender.RollingFileAppender">
<file value="logs/WebService/Records.log"/> <file value="logs/WebService/Records.log"/>
<param name="Encoding" value="UTF-8"/> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/> <appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30"/> <param name="MaxSizeRollBackups" value="30"/>
<!-- 切割最多文件数 --> <!-- 切割最多文件数 -->
<param name="MaximumFileSize" value="50MB"/> <param name="MaximumFileSize" value="50MB"/>
<!-- 每个文件的大小 --> <!-- 每个文件的大小 -->
<param name="RollingStyle" value="Size"/> <param name="RollingStyle" value="Size"/>
<!--param name="StaticLogFileName" value="true"/--> <!--param name="StaticLogFileName" value="true"/-->
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date]%-5p %m%n"/> <conversionPattern value="[%date]%-5p %m%n"/>
</layout> </layout>
</appender> </appender>
<appender name="RunLog" type="log4net.Appender.RollingFileAppender"> <appender name="RunLog" type="log4net.Appender.RollingFileAppender">
<file value="logs/runLog/RunLog.json"/> <file value="logs/runLog/RunLog.json"/>
<param name="Encoding" value="UTF-8"/> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/> <appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30" /> <param name="MaxSizeRollBackups" value="30" />
<rollingStyle value="Date"/> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%m%n"/> <conversionPattern value="%m%n"/>
</layout> </layout>
</appender> </appender>
<appender name="MiR_API" type="log4net.Appender.RollingFileAppender"> <appender name="MiR_API" type="log4net.Appender.RollingFileAppender">
<file value="logs/MiR_API/MiR_API.log"/> <file value="logs/MiR_API/MiR_API.log"/>
<param name="Encoding" value="UTF-8"/> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/> <appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30" /> <param name="MaxSizeRollBackups" value="30" />
<rollingStyle value="Date"/> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%m%n"/> <conversionPattern value="%m%n"/>
</layout> </layout>
</appender> </appender>
<appender name="MissionManager" type="log4net.Appender.RollingFileAppender"> <appender name="MissionManager" type="log4net.Appender.RollingFileAppender">
<file value="logs/MissionManager/MissionManager.log"/> <file value="logs/MissionManager/MissionManager.log"/>
<param name="Encoding" value="UTF-8"/> <param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/> <appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="30" /> <param name="MaxSizeRollBackups" value="30" />
<rollingStyle value="Date"/> <rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/> <datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%m%n"/> <conversionPattern value="%m%n"/>
</layout> </layout>
</appender> </appender>
<logger name="MissionManager"> <logger name="MissionManager">
<level value="info"/> <level value="info"/>
<appender-ref ref="MissionManager"/> <appender-ref ref="MissionManager"/>
</logger> </logger>
<logger name="MiR_API"> <logger name="MiR_API">
<level value="info"/> <level value="info"/>
<appender-ref ref="MiR_API"/> <appender-ref ref="MiR_API"/>
</logger> </logger>
<logger name="RunLog"> <logger name="RunLog">
<level value="Info"/> <level value="Info"/>
<appender-ref ref="RunLog"/> <appender-ref ref="RunLog"/>
</logger> </logger>
<logger name="WebService"> <logger name="WebService">
<level value="Info"/> <level value="Info"/>
<appender-ref ref="WebService"/> <appender-ref ref="WebService"/>
</logger> </logger>
<logger name="AgvServer"> <logger name="AgvServer">
<level value="Info"/> <level value="Info"/>
<appender-ref ref="AgvServer"/> <appender-ref ref="AgvServer"/>
</logger> </logger>
<logger name="HttpManager"> <logger name="HttpManager">
<level value="Info"/> <level value="Info"/>
<appender-ref ref="HttpManager"/> <appender-ref ref="HttpManager"/>
</logger> </logger>
<root name="AGVDispatch"> <logger name="AGVDispatch">
<level value="info"/> <level value="info"/>
<appender-ref ref="AGVDispatch"/> <appender-ref ref="AGVDispatch"/>
</root> </logger>
</log4net> </log4net>
</configuration> </configuration>
\ No newline at end of file \ No newline at end of file
...@@ -16,7 +16,6 @@ namespace Common ...@@ -16,7 +16,6 @@ namespace Common
public const string PutShelfOn = "PutShelfOn"; public const string PutShelfOn = "PutShelfOn";
public const string TakeShelfOff = "TakeShelfOff"; public const string TakeShelfOff = "TakeShelfOff";
public const string Temp1 = "Temp1"; public const string Temp1 = "Temp1";
public const string Temp2 = "Temp2";
public const string DoorAirOut = "DoorAirOut"; public const string DoorAirOut = "DoorAirOut";
public const string AutoCharge = "AutoCharge"; public const string AutoCharge = "AutoCharge";
public const string PlaySound = "PlaySound"; public const string PlaySound = "PlaySound";
...@@ -40,6 +39,7 @@ namespace Common ...@@ -40,6 +39,7 @@ namespace Common
public const string File_AgvTaskInfo = "File_AgvTaskInfo"; public const string File_AgvTaskInfo = "File_AgvTaskInfo";
public const string File_NodeInfo = "File_NodeInfo"; public const string File_NodeInfo = "File_NodeInfo";
public const string FileName_Missions = "Missions.json"; public const string FileName_Missions = "Missions.json";
public const string FileName_AgvContext = "FileName_AgvContext";
public const string IsUse = "IsUse"; public const string IsUse = "IsUse";
public const string RFID = "RFID"; public const string RFID = "RFID";
public const string Warehouse = "JIGStorage"; public const string Warehouse = "JIGStorage";
......
...@@ -132,7 +132,7 @@ namespace Common ...@@ -132,7 +132,7 @@ namespace Common
try try
{ {
var wc = new MyWebClient(5000); var wc = new MyWebClient(10000);
if (string.IsNullOrEmpty(wc.Headers["Content-Type"])) if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8"); wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
wc.Encoding = encoding; wc.Encoding = encoding;
......
...@@ -37,7 +37,7 @@ namespace DeviceLibrary.manager ...@@ -37,7 +37,7 @@ namespace DeviceLibrary.manager
XmlNodeList xnl0 = xe.ChildNodes; XmlNodeList xnl0 = xe.ChildNodes;
agv_Info.Name = xnl0.Item(0).InnerText; agv_Info.Name = xnl0.Item(0).InnerText;
agv_Info.JobContext.Name = agv_Info.Name;
XmlNodeList xnlScope = xnl0.Item(1).ChildNodes; XmlNodeList xnlScope = xnl0.Item(1).ChildNodes;
agv_Info.Scope = new bean.agv.Scope(); agv_Info.Scope = new bean.agv.Scope();
agv_Info.Scope.Workshop = xnlScope.Item(0).InnerText; agv_Info.Scope.Workshop = xnlScope.Item(0).InnerText;
...@@ -100,7 +100,7 @@ namespace DeviceLibrary.manager ...@@ -100,7 +100,7 @@ namespace DeviceLibrary.manager
node.Id = int.Parse(xe.GetAttribute("id")); node.Id = int.Parse(xe.GetAttribute("id"));
// 得到节点的所有子节点 // 得到节点的所有子节点
XmlNodeList xnl0 = xe.ChildNodes; XmlNodeList xnl0 = xe.ChildNodes;
node.IP = xnl0.Item(0).InnerText; node.IP = xnl0.Item(0).InnerText.Trim();
node.Name = xnl0.Item(1).InnerText; node.Name = xnl0.Item(1).InnerText;
node.IsUse = bool.Parse(xnl0.Item(2).InnerText); node.IsUse = bool.Parse(xnl0.Item(2).InnerText);
node.AliceName = xnl0.Item(3).InnerText; node.AliceName = xnl0.Item(3).InnerText;
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<agvs> <agvs>
<agv id="20" ip="10.85.199.68"> <agv id="20" ip="192.168.101.75">
<name>2号车</name> <name>2号车</name>
<!--职责范围--> <!--职责范围-->
<Scope> <Scope>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
</Scope> </Scope>
<!--是否自动--> <!--是否自动-->
<Auto>False</Auto> <Auto>False</Auto>
<UseFleet>true</UseFleet> <UseFleet>false</UseFleet>
<FleetIp>10.85.199.3</FleetIp> <FleetIp>10.85.199.3</FleetIp>
<Authorization>Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==</Authorization> <Authorization>Basic ZGlzdHJpYnV0b3I6NjJmMmYwZjFlZmYxMGQzMTUyYzk1ZjZmMDU5NjU3NmU0ODJiYjhlNDQ4MDY0MzNmNGNmOTI5NzkyODM0YjAxNA==</Authorization>
<IO_GUIDs> <IO_GUIDs>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<fixed>true</fixed> <fixed>true</fixed>
<!--固定充电桩为true,取第一个;false则判断所有agv.填写AGV编号--> <!--固定充电桩为true,取第一个;false则判断所有agv.填写AGV编号-->
<agvs> <agvs>
<agv>49</agv> <agv>10.85.199.68</agv>
</agvs> </agvs>
</pile> </pile>
</piles> </piles>
......
...@@ -30,7 +30,7 @@ namespace DeviceLibrary ...@@ -30,7 +30,7 @@ namespace DeviceLibrary
{ {
AgvCallTimer = new System.Timers.Timer AgvCallTimer = new System.Timers.Timer
{ {
Interval = 500, Interval = 300,
AutoReset = true, AutoReset = true,
Enabled = false Enabled = false
}; };
...@@ -86,34 +86,34 @@ namespace DeviceLibrary ...@@ -86,34 +86,34 @@ namespace DeviceLibrary
bool rtn; bool rtn;
if (AgvStateInProcess) return; if (AgvStateInProcess) return;
AgvStateInProcess = true; AgvStateInProcess = true;
//List<AlarmMsg> msglist = new List<AlarmMsg>();
for (int i = 0; i < AGVManager.agvInfo.Count; i++) for (int i = 0; i < AGVManager.agvInfo.Count; i++)
{ {
AgvInfo agv = AGVManager.agvInfo[i];
try try
{ {
AGVManager.agvInfo[i].SetKanban(); agv.SetKanban();
if (!CheckOnline(i)) continue; if (!CheckOnline(i)) continue;
bool change = false; bool change = false;
if (!AGVManager.agvInfo[i].TaskRunState.IsAllocatingTask && AGVManager.agvInfo[i].Auto && AGVManager.agvInfo[i].CurJob != null && AGVManager.agvInfo[i].TaskRunState.TaskID.Equals(-1)) if (!agv.TaskRunState.IsAllocatingTask && agv.Auto && agv.CurJob != null && agv.TaskRunState.TaskID.Equals(-1))
{ {
if (!MiR_API.Get_MissionByDescrp(AGVManager.agvInfo[i])) if (!MiR_API.Get_MissionByDescrp(agv))
{ {
AGVManager.agvInfo[i].CurJob.ResendTask(AGVManager.agvInfo[i]); agv.CurJob.ResendTask(agv);
log.Info($"{AGVManager.agvInfo[i].Name}:Task=-1处理,Fleet无任务,重发任务:{AGVManager.agvInfo[i].TaskRunState.Task.Name}"); log.Info($"{agv.Name}:Task=-1处理,Fleet无任务,重发任务:{agv.TaskRunState.Task.Name}");
} }
else else
{ {
log.Info($"{AGVManager.agvInfo[i].Name}:Task=-1处理,Fleet有任务,自动赋值FleetTaskID={AGVManager.agvInfo[i].TaskRunState.TaskID}"); log.Info($"{agv.Name}:Task=-1处理,Fleet有任务,自动赋值FleetTaskID={agv.TaskRunState.TaskID}");
} }
} }
MiR_API.Get_Task_State(AGVManager.agvInfo[i]); MiR_API.Get_Task_State(agv);
Thread.Sleep(50); Thread.Sleep(50);
MiR_API.Get_IO_Status(AGVManager.agvInfo[i]); MiR_API.Get_IO_Status(agv);
//获取AGV状态 //获取AGV状态
rtn = MiR_API.Get_State(AGVManager.agvInfo[i], out eAGVState stateID, out string stateText, out int battery, out string mission_text, out AgvInfo.MirPosition position); rtn = MiR_API.Get_State(agv, out eAGVState stateID, out string stateText, out int battery, out string mission_text, out AgvInfo.MirPosition position);
Thread.Sleep(50); Thread.Sleep(50);
if (rtn) change = AGVManager.agvInfo[i].SetState(stateID, battery, mission_text, position); if (rtn) change = agv.SetState(stateID, battery, mission_text, position);
// if (change) // if (change)
{ {
...@@ -122,7 +122,7 @@ namespace DeviceLibrary ...@@ -122,7 +122,7 @@ namespace DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
log.Error("AgvStateTimer_" + AGVManager.agvInfo[i].Name + ex.Message + ex.StackTrace); log.Error("AgvStateTimer_" + agv.Name + ex.Message + ex.StackTrace);
} }
} }
manager.UploadManager.UploadAgvState(); manager.UploadManager.UploadAgvState();
...@@ -165,7 +165,7 @@ namespace DeviceLibrary ...@@ -165,7 +165,7 @@ namespace DeviceLibrary
if (!AGVManager.agvInfo[i].Auto) continue; //AGV是否可用 if (!AGVManager.agvInfo[i].Auto) continue; //AGV是否可用
//Ready,Pause,Executing,Error //Ready,Pause,Executing,Error
if(AGVManager.agvInfo[i].StateID.Equals(eAGVState.Pause)) if (AGVManager.agvInfo[i].StateID.Equals(eAGVState.Pause))
{ {
MiR_API.State_Ready(AGVManager.agvInfo[i]); MiR_API.State_Ready(AGVManager.agvInfo[i]);
continue; continue;
...@@ -175,10 +175,10 @@ namespace DeviceLibrary ...@@ -175,10 +175,10 @@ namespace DeviceLibrary
MiR_API.Clear_Error(AGVManager.agvInfo[i]); MiR_API.Clear_Error(AGVManager.agvInfo[i]);
continue; continue;
} }
if (!AGVManager.agvInfo[i].StateID.Equals(eAGVState.Ready) if (!AGVManager.agvInfo[i].StateID.Equals(eAGVState.Ready)
&& !AGVManager.agvInfo[i].StateID.Equals(eAGVState.Executing) && !AGVManager.agvInfo[i].StateID.Equals(eAGVState.None)) && !AGVManager.agvInfo[i].StateID.Equals(eAGVState.Executing) && !AGVManager.agvInfo[i].StateID.Equals(eAGVState.None))
{ {
log.Warn(string.Format("{0}不能调用 StateID={1}", AGVManager.agvInfo[i].Name, AGVManager.agvInfo[i].StateID.ToString())); //log.Warn(string.Format("{0}不能调用 StateID={1}", AGVManager.agvInfo[i].Name, AGVManager.agvInfo[i].StateID.ToString()));
continue; continue;
} }
if (agv.TaskRunState.DeWaitTaskQueue(out AgvTask task)) if (agv.TaskRunState.DeWaitTaskQueue(out AgvTask task))
...@@ -212,7 +212,43 @@ namespace DeviceLibrary ...@@ -212,7 +212,43 @@ namespace DeviceLibrary
log.Error("AgvCall " + ex.Message + ex.StackTrace); log.Error("AgvCall " + ex.Message + ex.StackTrace);
} }
} }
try
{
foreach (string item in AGVManager.sysClients)
{
List<AgvInfo> agvs = AGVManager.agvInfo.FindAll(s => s.Client.Equals(item) && s.IsCon.Equals(true) && s.Auto
&& s.Scope != null && s.Scope.Remark != null && s.JobContext != null && s.JobContext.MissionId.Equals(""));
if (agvs != null && agvs.Count > 0)
{
foreach (AgvInfo agv in agvs)
{
string[] lifts = agv.Scope.Remark.Split(',');
foreach (string eleva in lifts)
{
lift.LiftContext.UpdateStatus(new lift.ClientStatus() { hasIdleAgv = true, liftId = eleva, sourceClient = item });
}
}
}
else
{
agvs = AGVManager.agvInfo.FindAll(s => s.Client.Equals(item));
foreach (AgvInfo agv in agvs)
{
string[] lifts = agv.Scope.Remark.Split(',');
foreach (string eleva in lifts)
{
lift.LiftContext.UpdateStatus(new lift.ClientStatus() { hasIdleAgv = false, liftId = eleva, sourceClient = item });
}
}
}
}
}
catch (Exception ex)
{
LogUtil.error("UpdateStatus " + ex.StackTrace);
}
AgvCallInProcess = false; AgvCallInProcess = false;
} }
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\AGVDispatch\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath> <HintPath>..\AGVDispatch\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" />
<Reference Include="RestSharp"> <Reference Include="RestSharp">
<HintPath>.\RestSharp.dll</HintPath> <HintPath>.\RestSharp.dll</HintPath>
</Reference> </Reference>
...@@ -60,21 +61,23 @@ ...@@ -60,21 +61,23 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="bean\agv\Agv_Info.cs" /> <Compile Include="bean\agv\Agv_Info.cs" />
<Compile Include="bean\agv\JobContext.cs" />
<Compile Include="bean\agv\Scope.cs" /> <Compile Include="bean\agv\Scope.cs" />
<Compile Include="bean\ChargePiles.cs" /> <Compile Include="bean\ChargePiles.cs" />
<Compile Include="bean\jobType\LineToLineJobType.cs" /> <Compile Include="bean\jobType\LineToLineJobType.cs" />
<Compile Include="bean\jobType\StoreToLinesWithBackJobType.cs" /> <Compile Include="bean\jobType\RecoveryJobType.cs" />
<Compile Include="bean\jobType\LineOneToManyJobType.cs" />
<Compile Include="bean\job\ChargeJob.cs" /> <Compile Include="bean\job\ChargeJob.cs" />
<Compile Include="bean\job\StoreToLinesWithBackJob.cs" /> <Compile Include="bean\job\LineOneToManyJob.cs" />
<Compile Include="bean\job\LineToLineJob.cs" /> <Compile Include="bean\job\LineToLineJob.cs" />
<Compile Include="bean\job\SendToLinesWithBackJob.cs" /> <Compile Include="bean\job\LiftToLinesJob.cs" />
<Compile Include="bean\job\F1LiftToStoreJob.cs" /> <Compile Include="bean\job\F1LiftToStoreJob.cs" />
<Compile Include="bean\job\F1StoreToLiftJob.cs" /> <Compile Include="bean\job\F1StoreToLiftJob.cs" />
<Compile Include="bean\JobParam.cs" /> <Compile Include="bean\JobParam.cs" />
<Compile Include="bean\jobType\F1LiftToStoreJobType.cs" /> <Compile Include="bean\jobType\F1LiftToStoreJobType.cs" />
<Compile Include="bean\jobType\F1StoreToLiftJobType.cs" /> <Compile Include="bean\jobType\F1StoreToLiftJobType.cs" />
<Compile Include="bean\TaskRunState.cs" /> <Compile Include="bean\TaskRunState.cs" />
<Compile Include="bean\jobType\SendToLinesWithBackJobType.cs" /> <Compile Include="bean\jobType\LiftToLinesJobType.cs" />
<Compile Include="bean\job\StandyJob.cs" /> <Compile Include="bean\job\StandyJob.cs" />
<Compile Include="bean\Task.cs" /> <Compile Include="bean\Task.cs" />
<Compile Include="bean\Node.cs" /> <Compile Include="bean\Node.cs" />
......
...@@ -44,11 +44,11 @@ namespace DeviceLibrary.bean ...@@ -44,11 +44,11 @@ namespace DeviceLibrary.bean
} }
public List<ChargePile> GetChargePilesByAgv(AgvInfo agv) public List<ChargePile> GetChargePilesByAgv(AgvInfo agv)
{ {
return chargePiles.FindAll(s => s.Agvs.Contains(agv.ID)); return chargePiles.FindAll(s => s.Agvs.Contains(agv.IP));
} }
public ChargePile GetChargePileByAgv(AgvInfo agv) public ChargePile GetChargePileByAgv(AgvInfo agv)
{ {
return chargePiles.Find(s => s.Agvs.Contains(agv.ID)); return chargePiles.Find(s => s.Agvs.Contains(agv.IP));
} }
} }
public class ChargePile public class ChargePile
...@@ -94,14 +94,14 @@ namespace DeviceLibrary.bean ...@@ -94,14 +94,14 @@ namespace DeviceLibrary.bean
{ {
if (Fixed) if (Fixed)
{ {
if (agv.ID.Equals(Agvs[0])) if (agv.IP.Equals(Agvs[0]))
return true; return true;
else else
return false; return false;
} }
else //多个agv共享充电桩 else //多个agv共享充电桩
{ {
if (Agvs.Contains(agv.ID)) if (Agvs.Contains(agv.IP))
return Occupied; return Occupied;
else else
return false; return false;
......
...@@ -11,6 +11,7 @@ namespace DeviceLibrary ...@@ -11,6 +11,7 @@ namespace DeviceLibrary
public class JobStep<T> where T : Enum public class JobStep<T> where T : Enum
{ {
private T step; private T step;
private T preStep;
private string msg = ""; private string msg = "";
public string Msg public string Msg
{ {
...@@ -22,7 +23,8 @@ namespace DeviceLibrary ...@@ -22,7 +23,8 @@ namespace DeviceLibrary
//不为空,且与上一个消息不一样才打印 //不为空,且与上一个消息不一样才打印
if (!value.Equals(msg)) if (!value.Equals(msg))
{ {
LogUtil.info(value); AGVManager.SaveAgvContextInfo(step.ToString());
LogUtil.info(string.Format("[{0}]{1}",step,value));
} }
} }
msg = value; msg = value;
...@@ -35,6 +37,7 @@ namespace DeviceLibrary ...@@ -35,6 +37,7 @@ namespace DeviceLibrary
public JobStep(T initStep) public JobStep(T initStep)
{ {
this.step = initStep; this.step = initStep;
this.preStep = initStep;
this.msg = ""; this.msg = "";
} }
...@@ -54,7 +57,7 @@ namespace DeviceLibrary ...@@ -54,7 +57,7 @@ namespace DeviceLibrary
/// </summary> /// </summary>
/// <param name="timeOutMiniutes"></param> /// <param name="timeOutMiniutes"></param>
/// <returns></returns> /// <returns></returns>
public bool IsTimeOut(int timeOutMiniutes, out double timeOutValue) public bool IsTimeOut(double timeOutMiniutes, out double timeOutValue)
{ {
TimeSpan span = DateTime.Now - startTime; TimeSpan span = DateTime.Now - startTime;
timeOutValue = span.TotalMinutes; timeOutValue = span.TotalMinutes;
...@@ -72,6 +75,7 @@ namespace DeviceLibrary ...@@ -72,6 +75,7 @@ namespace DeviceLibrary
public void ToNextStep(T nextStep) public void ToNextStep(T nextStep)
{ {
AGVManager.RunLogInfo(StepRunInfo); AGVManager.RunLogInfo(StepRunInfo);
preStep = step;
step = nextStep; step = nextStep;
startTime = DateTime.Now; startTime = DateTime.Now;
} }
...@@ -80,7 +84,10 @@ namespace DeviceLibrary ...@@ -80,7 +84,10 @@ namespace DeviceLibrary
{ {
return step.ToString(); return step.ToString();
} }
public string PreStep()
{
return preStep.ToString();
}
public void EndJob() public void EndJob()
{ {
AGVManager.RunLogInfo(StepRunInfo); AGVManager.RunLogInfo(StepRunInfo);
......
...@@ -40,6 +40,7 @@ namespace DeviceLibrary ...@@ -40,6 +40,7 @@ namespace DeviceLibrary
else else
return IOManager.GetDI(IP); return IOManager.GetDI(IP);
} }
set { }
} }
/// <summary> /// <summary>
/// 是否可调用 /// 是否可调用
...@@ -256,17 +257,25 @@ namespace DeviceLibrary ...@@ -256,17 +257,25 @@ namespace DeviceLibrary
{ {
get get
{ {
if (CanConfirm) //if (CanConfirm)
{ {
if (IP.Equals("")) if (IP.Equals(""))
return false; return false;
else else
return IOManager.GetDI(IP, 0); {
} bool rtn= IOManager.GetDI(IP, 0);
else if (rtn)
{ IOManager.WriteDO(IP, 0, 1);
return false; else
IOManager.WriteDO(IP,0,0);
return rtn;
}
} }
//else
//{
// return false;
//}
} }
} }
/// <summary> /// <summary>
...@@ -294,7 +303,7 @@ namespace DeviceLibrary ...@@ -294,7 +303,7 @@ namespace DeviceLibrary
} }
} }
private bool apiconfirmSig = false; private bool apiconfirmSig = false;
public bool CanConfirm { get; private set; } public bool CanConfirm { get; private set; } = true;
public ExtendEquip(string ip) public ExtendEquip(string ip)
{ {
IP = ip; IP = ip;
...@@ -309,7 +318,8 @@ namespace DeviceLibrary ...@@ -309,7 +318,8 @@ namespace DeviceLibrary
} }
public void Reset() public void Reset()
{ {
CanConfirm = false; apiconfirmSig = false;
IOManager.WriteDO(IP, 0, 0);
} }
} }
/// <summary> /// <summary>
......
...@@ -81,18 +81,12 @@ namespace DeviceLibrary.bean ...@@ -81,18 +81,12 @@ namespace DeviceLibrary.bean
S1F_StoreToLift_05_04_EnterLift, S1F_StoreToLift_05_04_EnterLift,
S1F_StoreToLift_05_05_PutShelfOn, S1F_StoreToLift_05_05_PutShelfOn,
S1F_StoreToLift_05_06_LeaveLift, S1F_StoreToLift_05_06_LeaveLift,
S1F_StoreToLift_05_07_ToTemp2, S1F_StoreToLift_05_07_CloseDoor,
S1F_StoreToLift_05_08_TakeShelfOffAtTemp2, S1F_StoreToLift_05_08_ToStore,
S1F_StoreToLift_05_09_ToTemp1, S1F_StoreToLift_05_09_TakeShelfOff,
S1F_StoreToLift_05_10_PutTemp1ShelfOn, S1F_StoreToLift_05_10_ToTemp1,
S1F_StoreToLift_05_11_ToLift, S1F_StoreToLift_05_11_PutTemp1ShelfOn,
S1F_StoreToLift_05_12_EnterLift, S1F_StoreToLift_05_12_ToLift,
S1F_StoreToLift_05_13_TakeShelfOffAtLift,
S1F_StoreToLift_05_14_LeaveLift,
S1F_StoreToLift_05_15_ToTemp2,
S1F_StoreToLift_05_16_PutTemp2ShelfOn,
S1F_StoreToLift_05_17_ToStore,
S1F_StoreToLift_05_18_TakeShelfOff,
#endregion #endregion
#region 电梯内无料车 #region 电梯内无料车
...@@ -159,55 +153,8 @@ namespace DeviceLibrary.bean ...@@ -159,55 +153,8 @@ namespace DeviceLibrary.bean
#region 电梯内有料车 #region 电梯内有料车
SD_LiftToLine_14_01_ToTemp1, SD_LiftToLine_14_01_ToTemp1,
/// <summary> SD_LiftToLine_14_02_WaitLiftIdle,
/// 电梯内有料车,将待送的料车放到临时点1 SD_LiftToLine_14_03_RequestLift,
/// </summary>
SD_LiftToLine_14_02_TakeShelfOffAtTemp1,
/// <summary>
/// 电梯内有料车,去电梯口
/// </summary>
SD_LiftToLine_14_03_ToLift,
SD_LiftToLine_14_04_EnterLift,
/// <summary>
/// 电梯内有料车,提取电梯内的料车
/// </summary>
SD_LiftToLine_14_05_PutLiftShelfOn,
/// <summary>
/// 电梯内有料车,离开电梯
/// </summary>
SD_LiftToLine_14_06_LeaveLift,
SD_LiftToLine_14_07_ToTemp2,
/// <summary>
/// 电梯内有料车,将电梯内的料车卸到临时点2
/// </summary>
SD_LiftToLine_14_08_TakeShelfOffAtTemp2,
SD_LiftToLine_14_09_ToTemp1,
/// <summary>
/// 电梯内有料车,提取临时点1的料车
/// </summary>
SD_LiftToLine_14_10_PutTemp1ShelfOn,
/// <summary>
/// 电梯内有料车,去电梯口
/// </summary>
SD_LiftToLine_14_11_ToLift,
SD_LiftToLine_14_12_EnterLift,
/// <summary>
/// 电梯内有料车,将料车放到电梯内
/// </summary>
SD_LiftToLine_14_13_TakeShelfOffAtLift,
/// <summary>
/// 电梯内有料车,离开电梯
/// </summary>
SD_LiftToLine_14_14_LeaveLift,
/// <summary>
/// 电梯内有料车,关闭电梯门
/// </summary>
SD_LiftToLine_14_15_CloseLiftDoor,
SD_LiftToLine_14_16_ToTemp2,
/// <summary>
/// 电梯内有料车,将临时点2的料车提取,线体目的地参数填充,准备去线体SD_LiftToLine_06_ToLine
/// </summary>
SD_LiftToLine_14_17_PutTemp2ShelfOn,
#endregion #endregion
#region 电梯内无料车 #region 电梯内无料车
...@@ -225,7 +172,10 @@ namespace DeviceLibrary.bean ...@@ -225,7 +172,10 @@ namespace DeviceLibrary.bean
/// </summary> /// </summary>
SD_LiftToLine_14_04_CloseLiftDoor, SD_LiftToLine_14_04_CloseLiftDoor,
#endregion #endregion
/// <summary>
/// 料车无需返回,直接结束
/// </summary>
SD_LiftToLine_15_TakeShelfOff,
#endregion #endregion
#region 车间里线体到线体运送,到目的地卸料车 #region 车间里线体到线体运送,到目的地卸料车
...@@ -242,48 +192,52 @@ namespace DeviceLibrary.bean ...@@ -242,48 +192,52 @@ namespace DeviceLibrary.bean
/// </summary> /// </summary>
SD_LineToLine_03_ToLine, SD_LineToLine_03_ToLine,
/// <summary> /// <summary>
/// 到达线体,上报位置 /// 等待确认
/// </summary>
SD_LineToLine_04_WaitConfirm,
/// <summary>
/// 返回起点
/// </summary> /// </summary>
SD_LineToLine_04_UpdateLocation, SD_LineToLine_05_BackToSrcLine,
/// <summary> /// <summary>
/// 放下料架 /// 放下料架
/// </summary> /// </summary>
SD_LineToLine_05_TakeShelfOff, SD_LineToLine_06_TakeShelfOff,
#endregion #endregion
#region 车间里库房到多线体运送 #region 同车间单线体到多线体运送
/// <summary> /// <summary>
/// 去取料车位置 /// 去取料车位置
/// </summary> /// </summary>
SD_StoreToLine_01_ToPickUpPosition, SD_Line_OneToMany_01_ToPickUpPosition,
/// <summary> /// <summary>
/// 顶起料车 /// 顶起料车
/// </summary> /// </summary>
SD_StoreToLine_02_PutShelfOn, SD_Line_OneToMany_02_PutShelfOn,
/// <summary> /// <summary>
/// 去线体 /// 去线体
/// </summary> /// </summary>
SD_StoreToLine_03_ToLine, SD_Line_OneToMany_03_ToLine,
/// <summary> /// <summary>
/// 到达线体,上报位置 /// 到达线体,上报位置
/// </summary> /// </summary>
SD_StoreToLine_04_UpdateLocation, SD_Line_OneToMany_04_UpdateLocation,
/// <summary> /// <summary>
/// 等待确认 /// 等待确认
/// </summary> /// </summary>
SD_StoreToLine_05_WaitConfirm, SD_Line_OneToMany_05_WaitConfirm,
/// <summary> /// <summary>
/// 检查下一线体 /// 检查下一线体
/// </summary> /// </summary>
SD_StoreToLine_06_CheckNextLine, SD_Line_OneToMany_06_CheckNextLine,
/// <summary> /// <summary>
/// 返回至取料位置 /// 返回至取料位置
/// </summary> /// </summary>
SD_StoreToLine_07_BackToPickUpPosition, SD_Line_OneToMany_07_BackToPickUpPosition,
/// <summary> /// <summary>
/// 放下料车 /// 放下料车
/// </summary> /// </summary>
SD_StoreToLine_08_TakeShelfOff, SD_Line_OnToMany_08_TakeShelfOff,
#endregion #endregion
/// <summary> /// <summary>
......
...@@ -19,7 +19,7 @@ namespace DeviceLibrary ...@@ -19,7 +19,7 @@ namespace DeviceLibrary
/// <summary> /// <summary>
/// 任务名称 /// 任务名称
/// </summary> /// </summary>
public string Name { set; get; } public string Name { set; get; } = "";
/// <summary> /// <summary>
/// 任务别名 /// 任务别名
/// </summary> /// </summary>
......
...@@ -32,7 +32,7 @@ namespace DeviceLibrary ...@@ -32,7 +32,7 @@ namespace DeviceLibrary
/// <summary> /// <summary>
/// 等待任务执行队列 /// 等待任务执行队列
/// </summary> /// </summary>
public ConcurrentQueue<AgvTask> WaitExecuteTask = new ConcurrentQueue<AgvTask>(); ConcurrentQueue<AgvTask> WaitExecuteTask= new ConcurrentQueue<AgvTask>();
/// <summary> /// <summary>
/// 任务状态 /// 任务状态
/// </summary> /// </summary>
...@@ -71,6 +71,10 @@ namespace DeviceLibrary ...@@ -71,6 +71,10 @@ namespace DeviceLibrary
return; return;
WaitExecuteTask.Enqueue(task); WaitExecuteTask.Enqueue(task);
} }
public bool CheckTaskExist(AgvTask agvTask)
{
return WaitExecuteTask.Any(s => s.Name.Equals(agvTask.Name));
}
public bool DeWaitTaskQueue(out AgvTask task) public bool DeWaitTaskQueue(out AgvTask task)
{ {
task = null; task = null;
......
...@@ -9,6 +9,7 @@ using System.Xml; ...@@ -9,6 +9,7 @@ using System.Xml;
using Common; using Common;
using DeviceLibrary.bean.agv; using DeviceLibrary.bean.agv;
using DeviceLibrary.manager; using DeviceLibrary.manager;
using Newtonsoft.Json;
namespace DeviceLibrary namespace DeviceLibrary
{ {
...@@ -40,7 +41,7 @@ namespace DeviceLibrary ...@@ -40,7 +41,7 @@ namespace DeviceLibrary
public string Client { get { public string Client { get {
if (Scope != null) if (Scope != null)
{ {
return $"{Common.AppConfigHelper.GetValue(SettingString.AppIdentity)}-{Scope.Workshop}-{Name}"; return $"{Common.AppConfigHelper.GetValue(SettingString.AppIdentity)}-{Scope.Workshop}";
} }
else return Name; else return Name;
} } } }
...@@ -130,7 +131,10 @@ namespace DeviceLibrary ...@@ -130,7 +131,10 @@ namespace DeviceLibrary
/// 当前任务 /// 当前任务
/// </summary> /// </summary>
public Job CurJob { get; set; } public Job CurJob { get; set; }
/// <summary>
/// 任务上下文信息
/// </summary>
public JobContext JobContext { get; set; }
/// <summary> /// <summary>
/// 使用Fleet发任务 /// 使用Fleet发任务
/// </summary> /// </summary>
...@@ -231,6 +235,7 @@ namespace DeviceLibrary ...@@ -231,6 +235,7 @@ namespace DeviceLibrary
/// 停在同一处超时 /// 停在同一处超时
/// </summary> /// </summary>
public bool StandTimeOut { get; set; } = false; public bool StandTimeOut { get; set; } = false;
[JsonIgnore]
public AGV_UI.Status StateKanban; public AGV_UI.Status StateKanban;
public AgvInfo(string id, string name, string ip, string authorization, bool isUse) public AgvInfo(string id, string name, string ip, string authorization, bool isUse)
{ {
...@@ -255,6 +260,7 @@ namespace DeviceLibrary ...@@ -255,6 +260,7 @@ namespace DeviceLibrary
StateKanban = new AGV_UI.Status(RunInfos); StateKanban = new AGV_UI.Status(RunInfos);
IOStatus = new List<IOInfo>(); IOStatus = new List<IOInfo>();
TaskRunState = new TaskRunState(); TaskRunState = new TaskRunState();
JobContext = new JobContext();
} }
public List<string> RunInfos; public List<string> RunInfos;
DateTime IoStartTime = DateTime.MaxValue; DateTime IoStartTime = DateTime.MaxValue;
...@@ -534,6 +540,13 @@ namespace DeviceLibrary ...@@ -534,6 +540,13 @@ namespace DeviceLibrary
LogUtil.error(Name + "上报小车信息失败" + ex.Message + ex.StackTrace); LogUtil.error(Name + "上报小车信息失败" + ex.Message + ex.StackTrace);
} }
} }
public void SetJobContext(JobContext jobContext)
{
if(!JobContext.Equals(jobContext))
{
JobContext = jobContext;
}
}
} }
public class IOInfo public class IOInfo
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary.bean.agv
{
/// <summary>
/// 任务上下文
/// </summary>
public class JobContext
{
/// <summary>
/// Agv名称
/// </summary>
public string Name { get; set; } = "";
/// <summary>
/// 任务id
/// </summary>
public string MissionId { get; set; } = "";
/// <summary>
/// job全称
/// </summary>
public string JobFullName { get; set; } = "";
/// <summary>
/// 当前步骤
/// </summary>
public string JobStep { get; set; } = "";
/// <summary>
/// 任务参数
/// </summary>
public JobParam JobParam { get; set; } = new JobParam(null);
/// <summary>
/// 任务
/// </summary>
public AgvTask AgvTask { get; set; } = new AgvTask();
public override bool Equals(object obj)
{
JobContext jobContext = obj as JobContext;
if (jobContext == null) return false;
else
{
if(MissionId.Equals(jobContext.MissionId) && JobFullName.Equals(jobContext.JobFullName)&&
JobStep.Equals(jobContext.JobStep) && AgvTask.Name.Equals(jobContext.AgvTask.Name))
{
return true;
}
else
{
return false;
}
}
}
}
}
...@@ -15,6 +15,7 @@ namespace DeviceLibrary ...@@ -15,6 +15,7 @@ namespace DeviceLibrary
{ {
JobName = "充电任务"; JobName = "充电任务";
} }
public ChargeJob() : base() { JobName = "充电任务"; }
int BatteryMax = ChargePileManager.GetChargePiles().BatteryMax; int BatteryMax = ChargePileManager.GetChargePiles().BatteryMax;
int BatteryMin = ChargePileManager.GetChargePiles().BatteryMin; int BatteryMin = ChargePileManager.GetChargePiles().BatteryMin;
/// <summary> /// <summary>
...@@ -23,6 +24,14 @@ namespace DeviceLibrary ...@@ -23,6 +24,14 @@ namespace DeviceLibrary
/// <param name="agv"></param> /// <param name="agv"></param>
public override Job Run(AgvInfo agv) public override Job Run(AgvInfo agv)
{ {
agv.SetJobContext(new bean.agv.JobContext()
{
AgvTask = agv.TaskRunState.Task,
JobFullName = this.ToString(),
JobStep = JobRunStep.PreStep(),
Name = agv.Name,
JobParam = JobParam
}) ;
if (JobRunStep.IsStep(RunStep.NONE)) if (JobRunStep.IsStep(RunStep.NONE))
{ {
...@@ -85,7 +94,7 @@ namespace DeviceLibrary ...@@ -85,7 +94,7 @@ namespace DeviceLibrary
runInfo = "充电完成"; runInfo = "充电完成";
JobRunStep.Msg = runInfo; JobRunStep.Msg = runInfo;
JobRunStep.EndJob(); JobRunStep.EndJob();
return new StandyJob(new JobParam(JobParam.SrcNode.ToCopy())); return new StandyJob(new JobParam(agv.Place));
} }
else if (agv.Battery >= ChargePileManager.GetChargePiles().BatteryMin) else if (agv.Battery >= ChargePileManager.GetChargePiles().BatteryMin)
{ {
......
...@@ -14,8 +14,21 @@ namespace DeviceLibrary.bean.job ...@@ -14,8 +14,21 @@ namespace DeviceLibrary.bean.job
public F1LiftToStoreJob(JobParam jobParam) : base(jobParam) public F1LiftToStoreJob(JobParam jobParam) : base(jobParam)
{ {
} }
public F1LiftToStoreJob() : base()
{
}
public override Job Run(AgvInfo agv) public override Job Run(AgvInfo agv)
{ {
agv.SetJobContext(new bean.agv.JobContext()
{
MissionId = JobParam.GetMissionInfo().missionId,
AgvTask = agv.TaskRunState.Task,
JobFullName = this.ToString(),
JobStep = JobRunStep.PreStep(),
Name = agv.Name,
JobParam = JobParam
});
if (JobRunStep.IsStep(RunStep.NONE)) if (JobRunStep.IsStep(RunStep.NONE))
{ {
JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_01_ToLift); JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_01_ToLift);
...@@ -28,30 +41,34 @@ namespace DeviceLibrary.bean.job ...@@ -28,30 +41,34 @@ namespace DeviceLibrary.bean.job
if (agv.TaskRunState.CheckTaskFinished(agv.Name)) if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{ {
JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_02_01_WaitLiftDoorOpen); JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_02_01_WaitLiftDoorOpen);
//上报状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"到达{ JobParam.SrcNode.Name }"));
runInfo = $"到达{JobParam.SrcNode.AliceName},等待门开启"; runInfo = $"到达{JobParam.SrcNode.AliceName},等待门开启";
JobRunStep.Msg = runInfo; JobRunStep.Msg = runInfo;
} }
} }
else if (JobRunStep.IsStep(RunStep.S1F_LiftToStore_02_01_WaitLiftDoorOpen)) else if (JobRunStep.IsStep(RunStep.S1F_LiftToStore_02_01_WaitLiftDoorOpen))
{ {
if (lift.LiftContext.IsDoorOpen(JobParam.SrcNode.Name,JobParam.GetMissionInfo().destinationFloor)) if (lift.LiftContext.IsDoorOpen(JobParam.SrcNode.Name, JobParam.GetMissionInfo().destinationFloor))
{ {
JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_02_02_EnterLift); JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_02_02_EnterLift);
runInfo = $"{JobParam.SrcNode.AliceName}门已开启,去取料点"; runInfo = $"{JobParam.SrcNode.AliceName}门已开启,去取料点";
JobRunStep.Msg = runInfo;
//任务状态变更 //任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.返回电梯到达, out string msg); MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.返回电梯到达, out string msg);
AllocateTask(agv,$"{JobParam.SrcNode.Name}_{SettingString.PutShelfOn}"); AllocateTask(agv, $"{JobParam.SrcNode.Name}_{SettingString.PutShelfOn}");
JobRunStep.Msg = runInfo;
} }
} }
else if(JobRunStep.IsStep(RunStep.S1F_LiftToStore_02_02_EnterLift)) else if (JobRunStep.IsStep(RunStep.S1F_LiftToStore_02_02_EnterLift))
{ {
if (agv.TaskRunState.CheckTaskFinished(agv.Name)) if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{ {
JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_03_PutShelfOn); JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_03_PutShelfOn);
runInfo = $"到达{JobParam.SrcNode.AliceName}取料点,开始取料车"; runInfo = $"到达{JobParam.SrcNode.AliceName}取料点,开始取料车";
JobRunStep.Msg = runInfo; JobRunStep.Msg = runInfo;
AllocateTask(agv,SettingString.PutShelfOn); AllocateTask(agv, SettingString.PutShelfOn);
} }
} }
else if (JobRunStep.IsStep(RunStep.S1F_LiftToStore_03_PutShelfOn)) else if (JobRunStep.IsStep(RunStep.S1F_LiftToStore_03_PutShelfOn))
...@@ -59,8 +76,12 @@ namespace DeviceLibrary.bean.job ...@@ -59,8 +76,12 @@ namespace DeviceLibrary.bean.job
if (agv.TaskRunState.CheckTaskFinished(agv.Name)) if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{ {
JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_04_LeaveLift); JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_04_LeaveLift);
//上报状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"电梯取车"));
runInfo = $"在{JobParam.SrcNode.AliceName}取料车完成,准备离开"; runInfo = $"在{JobParam.SrcNode.AliceName}取料车完成,准备离开";
JobRunStep.Msg = runInfo; JobRunStep.Msg = runInfo;
AllocateTask(agv, $"{SettingString.Leave}_{JobParam.SrcNode.Name}"); AllocateTask(agv, $"{SettingString.Leave}_{JobParam.SrcNode.Name}");
} }
} }
...@@ -69,28 +90,32 @@ namespace DeviceLibrary.bean.job ...@@ -69,28 +90,32 @@ namespace DeviceLibrary.bean.job
if (agv.TaskRunState.CheckTaskFinished(agv.Name)) if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{ {
JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_05_CloseLiftDoor); JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_05_CloseLiftDoor);
runInfo = $"离开{JobParam.SrcNode.AliceName},关闭电梯门"; //关门
bool rtn = lift.LiftContext.AGVLeave(JobParam.SrcNode.Name, agv);
runInfo = $"离开{JobParam.SrcNode.AliceName},关闭电梯门:{rtn}";
//任务状态变更 //任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.返回离开电梯, out string msg); MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.返回离开电梯, out string msg);
JobRunStep.Msg = runInfo; JobRunStep.Msg = runInfo;
//关门
lift.LiftContext.CloseDoor(JobParam.SrcNode.Name,agv);
} }
} }
else if (JobRunStep.IsStep(RunStep.S1F_LiftToStore_05_CloseLiftDoor)) else if (JobRunStep.IsStep(RunStep.S1F_LiftToStore_05_CloseLiftDoor))
{ {
JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_06_ToStore); JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_06_ToStore);
runInfo = $"关闭{JobParam.SrcNode.AliceName}门完成,去{JobParam.CurTargetNode.AliceName}放料点"; runInfo = $"关闭{JobParam.SrcNode.AliceName}门完成,去{JobParam.CurTargetNode.AliceName}放料点";
JobRunStep.Msg = runInfo;
//任务状态变更 //任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.返回起始地, out string msg); MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.返回起始地, out string msg);
AllocateTask(agv, $"{JobParam.CurTargetNode.Name}_{SettingString.TakeShelfOff}"); AllocateTask(agv, $"{JobParam.CurTargetNode.Name}_{SettingString.TakeShelfOff}");
JobRunStep.Msg = runInfo;
} }
else if (JobRunStep.IsStep(RunStep.S1F_LiftToStore_06_ToStore)) else if (JobRunStep.IsStep(RunStep.S1F_LiftToStore_06_ToStore))
{ {
if (agv.TaskRunState.CheckTaskFinished(agv.Name)) if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{ {
JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_07_TakeShelfOff); JobRunStep.ToNextStep(RunStep.S1F_LiftToStore_07_TakeShelfOff);
//上报状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"到达{ JobParam.CurTargetNode.Name }"));
runInfo = $"到达{JobParam.CurTargetNode.AliceName}放料点,卸下料车"; runInfo = $"到达{JobParam.CurTargetNode.AliceName}放料点,卸下料车";
JobRunStep.Msg = runInfo; JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.TakeShelfOff); AllocateTask(agv, SettingString.TakeShelfOff);
...@@ -105,6 +130,10 @@ namespace DeviceLibrary.bean.job ...@@ -105,6 +130,10 @@ namespace DeviceLibrary.bean.job
//任务状态变更 //任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.完成, out string msg); MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.完成, out string msg);
JobRunStep.Msg = runInfo; JobRunStep.Msg = runInfo;
//上报状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"还车"));
} }
} }
else if (JobRunStep.IsStep(RunStep.END)) else if (JobRunStep.IsStep(RunStep.END))
......
...@@ -13,7 +13,8 @@ namespace DeviceLibrary ...@@ -13,7 +13,8 @@ namespace DeviceLibrary
if (jobParam != null && jobParam.GetMissionInfo() != null) if (jobParam != null && jobParam.GetMissionInfo() != null)
JobName = jobParam.GetMissionInfo().JobName; JobName = jobParam.GetMissionInfo().JobName;
} }
public JobParam JobParam { get; private set; } public Job() { }
public JobParam JobParam { get; set; }
public JobStep<RunStep> JobRunStep = new JobStep<RunStep>(RunStep.NONE); public JobStep<RunStep> JobRunStep = new JobStep<RunStep>(RunStep.NONE);
/// <summary> /// <summary>
...@@ -76,8 +77,8 @@ namespace DeviceLibrary ...@@ -76,8 +77,8 @@ namespace DeviceLibrary
} }
protected void AllocateStandbyTask(AgvInfo agv) protected void AllocateStandbyTask(AgvInfo agv)
{ {
Task = AgvTaskManager.GetTaskByName(SettingString.Standby, agv); Task = AgvTaskManager.GetTaskByName($"{SettingString.Standby}", agv);
AgvTaskManager.AssignMission(agv, SettingString.Standby); AgvTaskManager.AssignMission(agv, $"{SettingString.Standby}");
} }
/// <summary> /// <summary>
/// 设置PLC值 /// 设置PLC值
...@@ -122,7 +123,7 @@ namespace DeviceLibrary ...@@ -122,7 +123,7 @@ namespace DeviceLibrary
public bool ResendTask(AgvInfo agv) public bool ResendTask(AgvInfo agv)
{ {
bool rtn = false; bool rtn = false;
if (!agv.TaskRunState.Task.Equals(Task))//agv运行的任务与Job任务不同 if (!Task.Equals(agv.TaskRunState.Task))//agv运行的任务与Job任务不同
{ {
rtn = AgvTaskManager.AssignMission(agv, Task.Name); rtn = AgvTaskManager.AssignMission(agv, Task.Name);
if (rtn) if (rtn)
...@@ -152,6 +153,22 @@ namespace DeviceLibrary ...@@ -152,6 +153,22 @@ namespace DeviceLibrary
} }
return false; return false;
} }
/// <summary>
/// 是否需要确认
/// </summary>
/// <returns></returns>
protected bool NeedConfirm()
{
if(JobParam.GetMissionInfo()!=null)
{
service.model.ProjectType type = JobParam.GetMissionInfo().projectType;
if(type.Equals(service.model.ProjectType.空台车领用) || type.Equals(service.model.ProjectType.空台车归还))
{
return false;
}
}
return true;
}
} }
} }
using Common;  using Common;
using DeviceLibrary.manager; using DeviceLibrary.manager;
namespace DeviceLibrary.bean.job namespace DeviceLibrary.bean.job
...@@ -14,6 +14,10 @@ namespace DeviceLibrary.bean.job ...@@ -14,6 +14,10 @@ namespace DeviceLibrary.bean.job
public LineToLineJob(JobParam jobParam) : base(jobParam) public LineToLineJob(JobParam jobParam) : base(jobParam)
{ {
} }
public LineToLineJob() : base()
{
}
lift.LiftStatus liftStatus; lift.LiftStatus liftStatus;
public override Job Run(AgvInfo agv) public override Job Run(AgvInfo agv)
{ {
...@@ -21,16 +25,21 @@ namespace DeviceLibrary.bean.job ...@@ -21,16 +25,21 @@ namespace DeviceLibrary.bean.job
{ {
JobRunStep.ToNextStep(RunStep.SD_LineToLine_01_ToPickUpPosition); JobRunStep.ToNextStep(RunStep.SD_LineToLine_01_ToPickUpPosition);
runInfo = $"{JobName}开始:去{JobParam.SrcNode.AliceName}的取料点"; runInfo = $"{JobName}开始:去{JobParam.SrcNode.AliceName}的取料点";
JobRunStep.Msg = runInfo;
//任务状态变更 //任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.接料, out string msg); MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.接料, out string msg);
AllocateTask(agv, $"{JobParam.SrcNode.Name}_{SettingString.PutShelfOn}"); AllocateTask(agv, $"{JobParam.SrcNode.Name}_{SettingString.PutShelfOn}");
JobRunStep.Msg = runInfo;
} }
else if (JobRunStep.IsStep(RunStep.SD_LineToLine_01_ToPickUpPosition)) else if (JobRunStep.IsStep(RunStep.SD_LineToLine_01_ToPickUpPosition))
{ {
if (agv.TaskRunState.CheckTaskFinished(agv.Name)) if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{ {
JobRunStep.ToNextStep(RunStep.SD_LineToLine_02_PutShelfOn); JobRunStep.ToNextStep(RunStep.SD_LineToLine_02_PutShelfOn);
//上报运输状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"到达{ JobParam.SrcNode.Name }"));
runInfo = $"到达{JobParam.SrcNode.AliceName}的取料点,准备拾取料车"; runInfo = $"到达{JobParam.SrcNode.AliceName}的取料点,准备拾取料车";
JobRunStep.Msg = runInfo; JobRunStep.Msg = runInfo;
AllocateTask(agv, $"{SettingString.PutShelfOn}"); AllocateTask(agv, $"{SettingString.PutShelfOn}");
...@@ -41,39 +50,106 @@ namespace DeviceLibrary.bean.job ...@@ -41,39 +50,106 @@ namespace DeviceLibrary.bean.job
if (agv.TaskRunState.CheckTaskFinished(agv.Name)) if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{ {
JobRunStep.ToNextStep(RunStep.SD_LineToLine_03_ToLine); JobRunStep.ToNextStep(RunStep.SD_LineToLine_03_ToLine);
//上报位置
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"取车"));
runInfo = $"在{JobParam.SrcNode.AliceName}拾取料车完成,准备去线体{JobParam.CurTargetNode.Name}的放料点"; runInfo = $"在{JobParam.SrcNode.AliceName}拾取料车完成,准备去线体{JobParam.CurTargetNode.Name}的放料点";
JobRunStep.Msg = runInfo;
//任务状态变更 //任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.送料, out string msg); MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.送料, out string msg);
AllocateTask(agv, $"{JobParam.CurTargetNode.Name}_{SettingString.TakeShelfOff}"); AllocateTask(agv, $"{JobParam.CurTargetNode.Name}_{SettingString.TakeShelfOff}");
JobRunStep.Msg = runInfo;
} }
} }
else if (JobRunStep.IsStep(RunStep.SD_LineToLine_03_ToLine)) else if (JobRunStep.IsStep(RunStep.SD_LineToLine_03_ToLine))
{ {
if (agv.TaskRunState.CheckTaskFinished(agv.Name)) if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{ {
JobRunStep.ToNextStep(RunStep.SD_LineToLine_04_UpdateLocation); JobRunStep.ToNextStep(RunStep.SD_LineToLine_04_WaitConfirm);
runInfo = $"到达{JobParam.CurTargetNode.AliceName}的放料点,上报位置"; //确认按钮生效
JobRunStep.Msg = runInfo; JobParam.CurTargetNode.ExtendEquip.AllowConfirm();
//上报位置 //上报运输状态
manager.UploadManager.UploadPosition(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId, manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto, service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"到达{ JobParam.CurTargetNode.Name }")); $"到达{ JobParam.CurTargetNode.Name }"));
System.Threading.Thread.Sleep(2000);
runInfo = $"到达{JobParam.CurTargetNode.AliceName}的放料点";
JobRunStep.Msg = runInfo;
} }
} }
else if (JobRunStep.IsStep(RunStep.SD_LineToLine_04_UpdateLocation)) else if (JobRunStep.IsStep(RunStep.SD_LineToLine_04_WaitConfirm))
{ {
JobRunStep.ToNextStep(RunStep.SD_LineToLine_05_TakeShelfOff); if (OpManager.WaitConfirm.Line(JobParam.CurTargetNode))
runInfo = $"将料车在{JobParam.CurTargetNode.AliceName}卸下"; {
JobRunStep.Msg = runInfo; manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
AllocateTask(agv,$"{SettingString.TakeShelfOff}"); service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.agvButton,
$"卸货{ JobParam.CurTargetNode.Name }"));
if (JobParam.GetMissionInfo() != null && JobParam.GetMissionInfo().needBack)
{
JobRunStep.ToNextStep(RunStep.SD_LineToLine_05_BackToSrcLine);
runInfo = $"{JobParam.CurTargetNode.AliceName}的人员确认完成,准备返回{JobParam.SrcNode.AliceName}";
AllocateTask(agv, $"{JobParam.SrcNode.Name}_{SettingString.TakeShelfOff}");
//任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.返回起始地, out string msg);
JobRunStep.Msg = runInfo;
}
else if(JobParam.GetMissionInfo() != null && !JobParam.GetMissionInfo().needBack)
{
JobRunStep.ToNextStep(RunStep.SD_LineToLine_06_TakeShelfOff);
runInfo = $"将料车在{JobParam.CurTargetNode.AliceName}卸下";
JobRunStep.Msg = runInfo;
AllocateTask(agv, $"{SettingString.TakeShelfOff}");
}
else
{
LogUtil.error(JobParam.GetMissionInfo().ToString());
}
//关闭按钮确认
JobParam.CurTargetNode.ExtendEquip.Reset();
}
else if (JobRunStep.IsTimeOut(WaitTimeOut, out double timeoutval))
{
//报警,$"等待{JobParam.CurTargetNode.AliceName}的人员确认超时{timeoutval}分"
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.error, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.agvButton,
$"等待{ JobParam.CurTargetNode.Name }确认超时{timeoutval}分"));
}
} }
else if (JobRunStep.IsStep(RunStep.SD_LineToLine_05_TakeShelfOff)) else if (JobRunStep.IsStep(RunStep.SD_LineToLine_05_BackToSrcLine))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.SD_LineToLine_06_TakeShelfOff);
//上报运输状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"到达{ JobParam.SrcNode.Name }"));
runInfo = $"到达{JobParam.SrcNode.AliceName}并将料车卸下";
JobRunStep.Msg = runInfo;
AllocateTask(agv, $"{SettingString.TakeShelfOff}");
}
}
else if (JobRunStep.IsStep(RunStep.SD_LineToLine_06_TakeShelfOff))
{ {
if (agv.TaskRunState.CheckTaskFinished(agv.Name)) if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{ {
JobRunStep.ToNextStep(RunStep.END); JobRunStep.ToNextStep(RunStep.END);
if (JobParam.GetMissionInfo() != null && JobParam.GetMissionInfo().needBack)
{
//上报运输状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"还车"));
}
else if (JobParam.GetMissionInfo() != null && !JobParam.GetMissionInfo().needBack)
{
//上报运输状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"卸车"));
}
//任务状态变更 //任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.完成, out string msg); MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.完成, out string msg);
runInfo = $"料车在{JobParam.CurTargetNode.AliceName}卸下完成,任务结束"; runInfo = $"料车在{JobParam.CurTargetNode.AliceName}卸下完成,任务结束";
...@@ -85,6 +161,15 @@ namespace DeviceLibrary.bean.job ...@@ -85,6 +161,15 @@ namespace DeviceLibrary.bean.job
JobRunStep.EndJob(); JobRunStep.EndJob();
return null; return null;
} }
agv.SetJobContext(new bean.agv.JobContext()
{
MissionId = JobParam.GetMissionInfo().missionId,
AgvTask = agv.TaskRunState.Task,
JobFullName = this.ToString(),
JobStep = JobRunStep.PreStep(),
Name = agv.Name,
JobParam = JobParam
});
return this; return this;
} }
} }
......
...@@ -16,8 +16,10 @@ namespace DeviceLibrary ...@@ -16,8 +16,10 @@ namespace DeviceLibrary
{ {
JobName = "待机任务"; JobName = "待机任务";
} }
int BatteryMax = ChargePileManager.GetChargePiles().BatteryMax; public StandyJob():base()
int BatteryMin = ChargePileManager.GetChargePiles().BatteryMin; {
JobName = "待机任务";
}
int BatteryMid = ChargePileManager.GetChargePiles().BatteryMiddle; int BatteryMid = ChargePileManager.GetChargePiles().BatteryMiddle;
/// <summary> /// <summary>
/// 待机任务 /// 待机任务
...@@ -25,6 +27,14 @@ namespace DeviceLibrary ...@@ -25,6 +27,14 @@ namespace DeviceLibrary
/// <param name="agv"></param> /// <param name="agv"></param>
public override Job Run(AgvInfo agv) public override Job Run(AgvInfo agv)
{ {
agv.SetJobContext(new bean.agv.JobContext()
{
AgvTask = agv.TaskRunState.Task,
JobFullName = this.ToString(),
JobStep = JobRunStep.PreStep(),
Name = agv.Name,
JobParam=JobParam
});
if (JobRunStep.IsStep(RunStep.NONE)) if (JobRunStep.IsStep(RunStep.NONE))
{ {
{ {
...@@ -33,7 +43,7 @@ namespace DeviceLibrary ...@@ -33,7 +43,7 @@ namespace DeviceLibrary
JobRunStep.ToNextStep(RunStep.STANDBY_WAIT_REACH_STANDBY); JobRunStep.ToNextStep(RunStep.STANDBY_WAIT_REACH_STANDBY);
runInfo = "从" + JobParam.SrcNode + "回到待机位"; runInfo = "从" + JobParam.SrcNode + "回到待机位";
JobRunStep.Msg = runInfo; JobRunStep.Msg = runInfo;
AllocateStandbyTask(agv); AllocateStandbyTask(agv);
} }
} }
...@@ -43,7 +53,7 @@ namespace DeviceLibrary ...@@ -43,7 +53,7 @@ namespace DeviceLibrary
//if (agv.TaskRunState.CheckTaskFinished(agv.Name)) //if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{ {
JobRunStep.ToNextStep(RunStep.END); JobRunStep.ToNextStep(RunStep.END);
// runInfo = "到达待机位"; // runInfo = "到达待机位";
//JobRunStep.Msg = runInfo; //JobRunStep.Msg = runInfo;
} }
} }
......
...@@ -9,9 +9,9 @@ using DeviceLibrary.bean.job; ...@@ -9,9 +9,9 @@ using DeviceLibrary.bean.job;
namespace DeviceLibrary namespace DeviceLibrary
{ {
/// <summary> /// <summary>
/// 将料车从电梯送到多条线并空车返回任务 /// 从电梯送到多条线体任务
/// </summary> /// </summary>
public class SendToLinesWithBackJobType : JobType public class LiftToLinesJobType : JobType
{ {
/// <summary> /// <summary>
...@@ -31,7 +31,8 @@ namespace DeviceLibrary ...@@ -31,7 +31,8 @@ namespace DeviceLibrary
if (missionInfo != null) if (missionInfo != null)
{ {
Node src = manager.NodeManager.GetNode(liftname, NodeType.Lift); Node src = manager.NodeManager.GetNode(liftname, NodeType.Lift);
string[] dests = lift.destinationPoint.Split(','); string[] destTmp = lift.destinationPoint.Split(',');
string[] dests = destTmp.Distinct().ToArray();
Node dest = manager.NodeManager.GetNode(dests.Length > 1 ? dests[0] : lift.destinationPoint, NodeType.Node); Node dest = manager.NodeManager.GetNode(dests.Length > 1 ? dests[0] : lift.destinationPoint, NodeType.Node);
JobParam jobParam = new JobParam(src, dest, null, missionInfo); JobParam jobParam = new JobParam(src, dest, null, missionInfo);
if(dests.Length>1) if(dests.Length>1)
...@@ -49,7 +50,7 @@ namespace DeviceLibrary ...@@ -49,7 +50,7 @@ namespace DeviceLibrary
} }
} }
return new SendToLinesWithBackJob(jobParam); return new LiftToLinesJob(jobParam);
} }
} }
} }
......
using Common; using Common;
using DeviceLibrary.bean.job; using DeviceLibrary.bean.job;
using System.Linq;
namespace DeviceLibrary.bean.jobType namespace DeviceLibrary.bean.jobType
{ {
public class StoreToLinesWithBackJobType : JobType /// <summary>
/// 获取一对多线体的任务
/// </summary>
public class LineOneToManyJobType : JobType
{ {
public override Job GetNewJob(AgvInfo agv) public override Job GetNewJob(AgvInfo agv)
{ {
...@@ -11,12 +14,21 @@ namespace DeviceLibrary.bean.jobType ...@@ -11,12 +14,21 @@ namespace DeviceLibrary.bean.jobType
return null; return null;
else if (!agv.Scope.Floor.Equals(1)) else if (!agv.Scope.Floor.Equals(1))
{ {
service.model.MissionInfo missionInfo = manager.MissionManager.GetStoreToLinesMission(agv); service.model.MissionInfo missionInfo = null;
missionInfo = manager.MissionManager.GetLineToLineMission(agv);
if (missionInfo == null)
missionInfo = manager.MissionManager.GetStoreToLinesMission(agv);
if (missionInfo != null) if (missionInfo != null)
{ {
Node src = manager.NodeManager.GetNode(missionInfo.sourcePoint, NodeType.Node); Node src = manager.NodeManager.GetNode(missionInfo.sourcePoint, NodeType.Node);
string[] dests = missionInfo.destinationPoint.Split(','); string[] destTmp = missionInfo.destinationPoint.Split(',');
Node dest = manager.NodeManager.GetNode(dests.Length > 1 ? dests[0] : missionInfo.destinationPoint, NodeType.Node); string[] dests = destTmp.Distinct().ToArray();
Node dest = manager.NodeManager.GetNode(dests.Length > 0 ? dests[0] : dests[0], NodeType.Node);
if(dest == null)
{
LogUtil.error($"无法生成任务,因不存在的节点:{dest}");
return null;
}
JobParam jobParam = new JobParam(src, dest, null, missionInfo); JobParam jobParam = new JobParam(src, dest, null, missionInfo);
if (dests.Length > 1) if (dests.Length > 1)
{ {
...@@ -33,7 +45,7 @@ namespace DeviceLibrary.bean.jobType ...@@ -33,7 +45,7 @@ namespace DeviceLibrary.bean.jobType
} }
} }
return new StoreToLinesWithBackJob(jobParam); return new LineOneToManyJob(jobParam);
} }
} }
return null; return null;
......
 
using Common;
using DeviceLibrary.bean.job; using DeviceLibrary.bean.job;
using System.Collections.Generic;
using System.Linq;
namespace DeviceLibrary.bean.jobType namespace DeviceLibrary.bean.jobType
{ {
public class LineToLineJobType:JobType public class LineToLineJobType:JobType
...@@ -14,8 +17,27 @@ namespace DeviceLibrary.bean.jobType ...@@ -14,8 +17,27 @@ namespace DeviceLibrary.bean.jobType
if (missionInfo != null) if (missionInfo != null)
{ {
Node src = manager.NodeManager.GetNode(missionInfo.sourcePoint, NodeType.Node); Node src = manager.NodeManager.GetNode(missionInfo.sourcePoint, NodeType.Node);
Node dest = manager.NodeManager.GetNode(missionInfo.destinationPoint, NodeType.Node); //Node dest = manager.NodeManager.GetNode(missionInfo.destinationPoint, NodeType.Node);
//JobParam jobParam = new JobParam(src, dest, null, missionInfo);
List<string> destTmp = new List<string>(missionInfo.destinationPoint.Split(','));
string[] dests = destTmp.Distinct().ToArray();
Node dest = manager.NodeManager.GetNode(dests.Length > 1 ? dests[0] : dests[0], NodeType.Node);
JobParam jobParam = new JobParam(src, dest, null, missionInfo); JobParam jobParam = new JobParam(src, dest, null, missionInfo);
if (dests.Length > 1)
{
for (int i = 1; i < dests.Length; i++)
{
Node node = manager.NodeManager.GetNode(dests[i], NodeType.Node);
if (node != null)
jobParam.TargetNodes.Add(node);
else
{
LogUtil.error($"无法生成任务,因不存在的节点:{dests[i]}");
return null;
}
}
}
return new LineToLineJob(jobParam); return new LineToLineJob(jobParam);
} }
} }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary.bean.jobType
{
public class RecoveryJobType : JobType
{
public override Job GetNewJob(AgvInfo agv)
{
if (agv.JobContext.MissionId.Equals(""))
{
return null;
}
else
{
service.model.MissionInfo missionInfo = manager.MissionManager.GetMission(agv.JobContext.MissionId);
if (missionInfo != null)
{
Type type = Type.GetType(agv.JobContext.JobFullName); // 通过类名获取同名类
Job job = (Job)System.Activator.CreateInstance(type);
job.JobParam= agv.JobContext.JobParam;
job.JobParam.SetMissionInfo(missionInfo);
job.Task = agv.JobContext.AgvTask;
job.JobRunStep.ToNextStep((RunStep)Enum.Parse(typeof(RunStep), agv.JobContext.JobStep));
return job;
}
}
return null;
}
}
}
...@@ -19,14 +19,14 @@ namespace DeviceLibrary.lift ...@@ -19,14 +19,14 @@ namespace DeviceLibrary.lift
{ {
lifts.Add(item, new LiftStatus()); lifts.Add(item, new LiftStatus());
} }
Common.LogUtil.info($"加载电梯信息完成:{string.Join(",",names)}"); Common.LogUtil.info($"加载电梯信息完成:{string.Join(",", names)}");
} }
/// <summary> /// <summary>
/// 电梯是否开门 /// 电梯是否开门
/// </summary> /// </summary>
/// <param name="liftId"></param> /// <param name="liftId"></param>
/// <returns></returns> /// <returns></returns>
public static bool IsDoorOpen(string liftId,int floor) public static bool IsDoorOpen(string liftId, int floor)
{ {
LiftStatus liftStatus = GetLiftStatus(liftId); LiftStatus liftStatus = GetLiftStatus(liftId);
if (liftStatus.door.Equals("opened") && liftStatus.floor.Equals(floor)) if (liftStatus.door.Equals("opened") && liftStatus.floor.Equals(floor))
...@@ -37,58 +37,112 @@ namespace DeviceLibrary.lift ...@@ -37,58 +37,112 @@ namespace DeviceLibrary.lift
/// 电梯关门 /// 电梯关门
/// </summary> /// </summary>
/// <param name="liftId"></param> /// <param name="liftId"></param>
public static void CloseDoor(string liftId,AgvInfo agvInfo) //public static void CloseDoor(string liftId,AgvInfo agvInfo)
{ //{
bool rtn= HttpManager.CloseDoor(new service.model.DoorInfo() { liftId=liftId,sourceClient=agvInfo.Client,sourceFloor=agvInfo.Scope.Floor}); // bool rtn= HttpManager.CloseDoor(new service.model.DoorInfo() { liftId=liftId,sourceClient=agvInfo.Client,sourceFloor=agvInfo.Scope.Floor});
Common.LogUtil.info($"{agvInfo.Name} 关门 {rtn}"); // Common.LogUtil.info($"{agvInfo.Name} 关门 {rtn}");
} //}
/// <summary> /// <summary>
/// 请求使用电梯 /// 请求使用电梯
/// </summary> /// </summary>
/// <param name="liftId"></param> /// <param name="liftId"></param>
/// <param name="missionInfo"></param> /// <param name="missionInfo"></param>
/// <param name="isback">是否是返回</param> /// <param name="isback">是否是返回</param>
public static void Request(string liftId,service.model.MissionInfo missionInfo,bool isback=false) public static bool Request(service.model.MissionInfo missionInfo, AgvInfo agvInfo, bool isback = false)
{ {
service.model.SendInInfo info; service.model.SendInInfo info;
if(isback) bool rtn=false;
if (isback)//返回
{ {
info = new service.model.SendInInfo() { }; if (!AGVManager.GetsysClientBy(missionInfo.sourceFloor, missionInfo.liftName, out string destclient))
{
Common.LogUtil.error($"请求电梯失败,因目的系统标识获取失败:floor={agvInfo.Scope.Floor},lift={missionInfo.liftName}");
return false;
}
info = new service.model.SendInInfo()
{
destinationFloor = missionInfo.sourceFloor,
destinationPoint = missionInfo.sourcePoint,
destinationClient = destclient,
sourceFloor = missionInfo.destinationFloor,
sourceClient = agvInfo.Client
};
rtn= HttpManager.RequestSendIn(info);
if (rtn)
HttpManager.AGVCall(new service.model.DoorInfo { liftId= missionInfo.liftName, sourceClient=agvInfo.Client, sourceFloor=missionInfo.destinationFloor});
} }
else else
{ {
info = new service.model.SendInInfo() { }; if (!AGVManager.GetsysClientBy(missionInfo.destinationFloor, missionInfo.liftName, out string destclient))
{
Common.LogUtil.error($"请求电梯失败,因目的系统标识获取失败:floor={agvInfo.Scope.Floor},lift={missionInfo.liftName}");
return false;
}
info = new service.model.SendInInfo()
{
sourceClient = agvInfo.Client,
sourceFloor = missionInfo.sourceFloor,
sourcePoint = missionInfo.sourcePoint,
destinationClient = destclient,
destinationFloor = missionInfo.destinationFloor,
destinationPoint = missionInfo.destinationPoint,
};
rtn = HttpManager.RequestSendIn(info);
if (rtn)
HttpManager.AGVCall(new service.model.DoorInfo { liftId = missionInfo.liftName, sourceClient = agvInfo.Client, sourceFloor = missionInfo.sourceFloor });
} }
HttpManager.RequestSendIn(info); return rtn;
} }
public static void SwitchControl(string liftId, service.model.MissionInfo missionInfo) /// <summary>
/// AGV离开
/// </summary>
/// <param name="liftId"></param>
/// <param name="agvInfo"></param>
/// <returns></returns>
public static bool AGVLeave(string liftId, AgvInfo agvInfo)
{ {
bool rtn = HttpManager.AGVLeave(new service.model.DoorInfo() { liftId = liftId, sourceClient = agvInfo.Client, sourceFloor = agvInfo.Scope.Floor });
Common.LogUtil.info($"{agvInfo.Name} 离开 {rtn}");
return rtn;
} }
/// <summary> /// <summary>
/// 电梯开门 /// AGV呼叫
/// </summary> /// </summary>
/// <param name="liftId"></param> /// <param name="liftId"></param>
public static void OpenDoor(string liftId,AgvInfo agvInfo) /// <param name="agvInfo"></param>
/// <returns></returns>
public static bool AGVCall(string liftId, AgvInfo agvInfo)
{ {
bool rtn = HttpManager.OpenDoor(new service.model.DoorInfo() { liftId = liftId, sourceClient = agvInfo.Client, sourceFloor = agvInfo.Scope.Floor }); bool rtn = HttpManager.AGVCall(new service.model.DoorInfo() { liftId = liftId, sourceClient = agvInfo.Client, sourceFloor = agvInfo.Scope.Floor });
Common.LogUtil.info($"{agvInfo.Name} 开门 {rtn}"); Common.LogUtil.info($"{agvInfo.Name} 呼叫 {rtn}");
return rtn;
} }
/// <summary> /// <summary>
/// 运行到指定楼层 /// 检查离开信号发送情况
/// </summary> /// </summary>
/// <param name="liftId"></param> /// <param name="liftId"></param>
/// <param name="floor"></param> /// <returns></returns>
public static void RunTo(string liftId,int floor) public static bool CheckAgvLeaveSig(string liftId)
{ {
if (!lifts[liftId].door.Equals("opened"))
return true;
return false;
} }
/// <summary> /// <summary>
/// 运行到指定楼层
/// </summary>
/// <param name="liftId"></param>
/// <param name="floor"></param>
//public static void RunTo(string liftId,int floor)
//{
//}
/// <summary>
/// 有架子需要离开电梯 /// 有架子需要离开电梯
/// </summary> /// </summary>
/// <param name="liftId"></param> /// <param name="liftId"></param>
/// <returns></returns> /// <returns></returns>
public static bool HasShelfNeedLeave(string liftId,string client,out LiftStatus liftStatus) public static bool HasShelfNeedLeave(string liftId, string client, out LiftStatus liftStatus)
{ {
liftStatus = GetLiftStatus(liftId); liftStatus = GetLiftStatus(liftId);
if (liftStatus.destinationClient.Equals(client)) if (liftStatus.destinationClient.Equals(client))
...@@ -101,7 +155,7 @@ namespace DeviceLibrary.lift ...@@ -101,7 +155,7 @@ namespace DeviceLibrary.lift
/// <param name="liftId"></param> /// <param name="liftId"></param>
/// <param name="missionId"></param> /// <param name="missionId"></param>
/// <returns></returns> /// <returns></returns>
public static bool CheckIfRequestOk(string liftId,service.model.MissionInfo mission) public static bool CheckIfRequestOk(string liftId, service.model.MissionInfo mission)
{ {
LiftStatus liftStatus = GetLiftStatus(liftId); LiftStatus liftStatus = GetLiftStatus(liftId);
if (liftStatus.missionId.Equals(mission.missionId)) if (liftStatus.missionId.Equals(mission.missionId))
...@@ -126,19 +180,19 @@ namespace DeviceLibrary.lift ...@@ -126,19 +180,19 @@ namespace DeviceLibrary.lift
{ {
return lifts.Keys.ToArray(); return lifts.Keys.ToArray();
} }
static void UpdateStatus(ClientStatus status) public static void UpdateStatus(ClientStatus status)
{ {
try try
{ {
LiftStatus lift = HttpManager.UpdateStatusToLift(status); LiftStatus lift = HttpManager.UpdateStatusToLift(status);
if(lift!=null) if (lift != null)
{ {
lifts[status.liftId] = lift; lifts[status.liftId] = lift;
} }
} }
catch(Exception e) catch (Exception e)
{ {
Common.LogUtil.error($"上报状态给电梯失败:{status.ToString()}",e); Common.LogUtil.error($"上报状态给电梯失败:{status.ToString()}", e);
} }
} }
......
文件属性发生变化
...@@ -9,6 +9,7 @@ using System.Threading; ...@@ -9,6 +9,7 @@ using System.Threading;
using DeviceLibrary.bean.jobType; using DeviceLibrary.bean.jobType;
using Common; using Common;
using DeviceLibrary.manager; using DeviceLibrary.manager;
using DeviceLibrary.bean.agv;
using static DeviceLibrary.AgvInfo; using static DeviceLibrary.AgvInfo;
namespace DeviceLibrary namespace DeviceLibrary
...@@ -26,6 +27,7 @@ namespace DeviceLibrary ...@@ -26,6 +27,7 @@ namespace DeviceLibrary
public static Control control; public static Control control;
public static List<JobType> jobTypes; public static List<JobType> jobTypes;
public static readonly string CONFIG_PATH = AppDomain.CurrentDomain.BaseDirectory + "Config\\"; public static readonly string CONFIG_PATH = AppDomain.CurrentDomain.BaseDirectory + "Config\\";
public static List<string> sysClients = new List<string>();
#region 任务日志 #region 任务日志
static log4net.ILog runLog = log4net.LogManager.GetLogger("RunLog"); static log4net.ILog runLog = log4net.LogManager.GetLogger("RunLog");
static Dictionary<string, RunInfo> runInfoMap = new Dictionary<string, RunInfo>(); static Dictionary<string, RunInfo> runInfoMap = new Dictionary<string, RunInfo>();
...@@ -59,22 +61,142 @@ namespace DeviceLibrary ...@@ -59,22 +61,142 @@ namespace DeviceLibrary
public static void Init() public static void Init()
{ {
jobTypes = new List<JobType>(); jobTypes = new List<JobType>();
jobTypes.Add(new SendToLinesWithBackJobType()); jobTypes.Add(new LiftToLinesJobType());
jobTypes.Add(new F1LiftToStoreJobType()); jobTypes.Add(new F1LiftToStoreJobType());
jobTypes.Add(new F1StoreToLiftJobType()); jobTypes.Add(new F1StoreToLiftJobType());
jobTypes.Add(new LineToLineJobType()); //jobTypes.Add(new LineToLineJobType());
jobTypes.Add(new StoreToLinesWithBackJobType()); jobTypes.Add(new LineOneToManyJobType());
jobTypes.Add(new ChargeJobType()); jobTypes.Add(new ChargeJobType());
InitAgv(); InitAgv();
//任务加载 //任务加载
AgvTaskManager.InitAgvTask(); AgvTaskManager.InitAgvTask();
} }
/// <summary>
/// 获取任务系统标识
/// </summary>
/// <param name="floor"></param>
/// <param name="liftId"></param>
/// <param name="client"></param>
/// <returns></returns>
public static bool GetsysClientBy(int floor,string liftId,out string client)
{
client = "";
AgvInfo agv = agvInfo.Find(s=>s.Scope.Floor.Equals(floor)&& s.Scope.Remark.Split(',').Contains(liftId));
if (agv == null)
return false;
else
{
client = agv.Client;
return true;
}
}
static void InitAgv() static void InitAgv()
{ {
agvInfo = new List<AgvInfo>(); agvInfo = new List<AgvInfo>();
XmlConfigOperation.LoadAgvInfos(agvInfo); XmlConfigOperation.LoadAgvInfos(agvInfo);
ReadAgvContextInfo(agvInfo);
foreach (AgvInfo item in agvInfo)
{
if (!sysClients.Contains(item.Client))
sysClients.Add(item.Client);
}
}
static object writeobj = new object();
public static void SaveAgvContextInfo(string step)
{
string filePath = CONFIG_PATH + AppConfigHelper.GetValue(SettingString.FileName_AgvContext);
if(Monitor.TryEnter(writeobj,500))
{
try
{
List<JobContext> context = new List<JobContext>();
foreach (AgvInfo item in agvInfo)
{
context.Add(item.JobContext);
}
string json = JsonHelper.SerializeObject(context);
if (File.Exists(filePath))
{
if (true)
{
string backUpPath = filePath + ".back";
File.Copy(filePath, backUpPath, true);
}
File.Delete(filePath);
}
File.WriteAllText(filePath, json);
LogUtil.info("保存Agv上下文信息到[" + filePath + $"]:{json}");
}
catch (Exception ex)
{
LogUtil.error("保存Agv上下文信息到[" + filePath + "]失败:", ex);
}
finally
{
Monitor.Exit(writeobj);
}
}
else
{
LogUtil.error("SaveAgvContextInfo timeout:"+step);
}
}
static void ReadAgvContextInfo(List<AgvInfo> agvInfos)
{
string filePath = CONFIG_PATH + AppConfigHelper.GetValue(SettingString.FileName_AgvContext);
List<JobContext> agvs =new List<JobContext>();
try
{
string json = "";
bool configchanged = false;
if (File.Exists(filePath))
{
json=File.ReadAllText(filePath);
if(!string.IsNullOrEmpty(json))
{
agvs = JsonHelper.DeserializeJsonToList<JobContext>(json);
if(agvs ==null)
{
return;
}
else
{
foreach (AgvInfo agv in agvInfos)
{
JobContext info = agvs.Find(s => agv.Name.Equals(s.Name));
if (info == null)
{
LogUtil.info($"{agv.Name}配置文件发生变化,不使用Agv上下文信息");
configchanged = true;
break;
}
}
if(!configchanged)
{
bean.jobType.RecoveryJobType recoveryJobType = new RecoveryJobType();
foreach (AgvInfo agv in agvInfos)
{
JobContext info = agvs.Find(s => s.Name.Equals(agv.Name));
if (info != null)
{
agv.SetJobContext(info);
agv.CurJob = recoveryJobType.GetNewJob(agv);
}
}
LogUtil.info("读取并使用Agv上下文信息[" + filePath + "]:"+json);
}
}
}
}
}
catch (Exception ex)
{
LogUtil.error("读取Agv上下文信息[" + filePath + "]失败:", ex);
}
} }
} }
......
...@@ -43,7 +43,7 @@ namespace DeviceLibrary ...@@ -43,7 +43,7 @@ namespace DeviceLibrary
{ {
comboBox.Items.Add(mission); comboBox.Items.Add(mission);
} }
comboBox.SelectedItem = GetTaskByName(SettingString.Init, agv); comboBox.SelectedItem = GetTaskByName($"{SettingString.Init}", agv);
} }
/// <summary> /// <summary>
/// 根据id获取任务 /// 根据id获取任务
...@@ -89,10 +89,10 @@ namespace DeviceLibrary ...@@ -89,10 +89,10 @@ namespace DeviceLibrary
{ {
bool rtn = false; bool rtn = false;
AgvTask task = GetTaskByName(taskname, agv); AgvTask task = GetTaskByName(taskname, agv);
Node node=null; Node node = null;
if (taskname.Equals(SettingString.Standby)) if (taskname.Contains($"{SettingString.Standby}"))
{ {
node = new Node() { Name = SettingString.Standby, AliceName = "待机位", Type = NodeType.Standby}; node = new Node() { Name = $"{agv.Name}{SettingString.Standby}", AliceName = $"{agv.Name}待机位", Type = NodeType.Standby };
} }
else else
{ {
...@@ -114,8 +114,11 @@ namespace DeviceLibrary ...@@ -114,8 +114,11 @@ namespace DeviceLibrary
if (!agv.IsCon) if (!agv.IsCon)
{ {
agv.TaskRunState.ResetInfo(); agv.TaskRunState.ResetInfo();
agv.TaskRunState.EnWaitTaskQueue(task); if (agv.TaskRunState.CheckTaskExist(task))
LogUtil.info(string.Format("{0} 离线,任务{1}加入等待队列 ", agv.Name, task.AliceName)); {
agv.TaskRunState.EnWaitTaskQueue(task);
LogUtil.info(string.Format("{0} 离线,[{1}]加入任务等待队列 ", agv.Name, task.AliceName));
}
return false; return false;
} }
if (agv.UseFleet) if (agv.UseFleet)
...@@ -124,11 +127,11 @@ namespace DeviceLibrary ...@@ -124,11 +127,11 @@ namespace DeviceLibrary
MiR_API.State_Ready(agv); MiR_API.State_Ready(agv);
if (rtn) if (rtn)
{ {
LogUtil.info(string.Format("{0} Add_Mission_Fleet {1} Success", agv.Name, agv.TaskRunState.ToTaskInfo())); LogUtil.info(string.Format("{0} Add_Mission_Fleet[{1}]Success", agv.Name, agv.TaskRunState.ToTaskInfo()));
} }
else else
{ {
LogUtil.info(string.Format("{0} Add_Mission_Fleet {1} Fail", agv.Name, agv.TaskRunState.ToTaskInfo())); LogUtil.info(string.Format("{0} Add_Mission_Fleet[{1}]Fail", agv.Name, agv.TaskRunState.ToTaskInfo()));
} }
} }
else else
...@@ -137,23 +140,29 @@ namespace DeviceLibrary ...@@ -137,23 +140,29 @@ namespace DeviceLibrary
MiR_API.State_Ready(agv); MiR_API.State_Ready(agv);
if (rtn) if (rtn)
{ {
LogUtil.info(string.Format("{0} Add_Mission {1} Success", agv.Name, agv.TaskRunState.ToTaskInfo())); LogUtil.info(string.Format("{0} Add_Mission[{1}]Success", agv.Name, agv.TaskRunState.ToTaskInfo()));
} }
else else
{ {
LogUtil.info(string.Format("{0} Add_Mission {1} Fail", agv.Name, agv.TaskRunState.ToTaskInfo())); LogUtil.info(string.Format("{0} Add_Mission[{1}]Fail", agv.Name, agv.TaskRunState.ToTaskInfo()));
} }
} }
agv.StateKanban.SetCurTask(agv.TaskRunState.ToTaskShowInfo()); agv.StateKanban.SetCurTask(agv.TaskRunState.ToTaskShowInfo());
if (!rtn) if (!rtn)
agv.TaskRunState.EnWaitTaskQueue(task); {
if (agv.TaskRunState.CheckTaskExist(task))
{
agv.TaskRunState.EnWaitTaskQueue(task);
LogUtil.info(string.Format("{0} 发送失败,[{1}]加入任务等待队列 ", agv.Name, task.AliceName));
}
}
} }
return rtn; return rtn;
} }
public static bool AssignMission(AgvInfo agv, DeviceLibrary.bean.ChargePile chargePile, AgvTask task) public static bool AssignMission(AgvInfo agv, DeviceLibrary.bean.ChargePile chargePile, AgvTask task)
{ {
bool rtn = false; bool rtn = false;
Node node = new Node() { Name = chargePile.Name, AliceName = chargePile.AliceName, Type = NodeType.AutoCharge}; Node node = new Node() { Name = chargePile.Name, AliceName = chargePile.AliceName, Type = NodeType.AutoCharge };
if (task != null) if (task != null)
{ {
agv.TaskRunState.Task = task; agv.TaskRunState.Task = task;
...@@ -162,8 +171,11 @@ namespace DeviceLibrary ...@@ -162,8 +171,11 @@ namespace DeviceLibrary
if (!agv.IsCon) if (!agv.IsCon)
{ {
agv.TaskRunState.ResetInfo(); agv.TaskRunState.ResetInfo();
agv.TaskRunState.EnWaitTaskQueue(task); if (agv.TaskRunState.CheckTaskExist(task))
LogUtil.info(string.Format("{0} 离线,任务{1}加入等待队列 ", agv.Name, task.AliceName)); {
agv.TaskRunState.EnWaitTaskQueue(task);
LogUtil.info(string.Format("{0} 离线,[{1}]加入任务等待队列 ", agv.Name, task.AliceName));
}
return false; return false;
} }
if (agv.UseFleet) if (agv.UseFleet)
...@@ -172,11 +184,11 @@ namespace DeviceLibrary ...@@ -172,11 +184,11 @@ namespace DeviceLibrary
MiR_API.State_Ready(agv); MiR_API.State_Ready(agv);
if (rtn) if (rtn)
{ {
LogUtil.info(string.Format("{0} Add_Mission_Fleet {1} Success", agv.Name, agv.TaskRunState.ToTaskInfo())); LogUtil.info(string.Format("{0} Add_Mission_Fleet[{1}]Success", agv.Name, agv.TaskRunState.ToTaskInfo()));
} }
else else
{ {
LogUtil.info(string.Format("{0} Add_Mission_Fleet {1} Fail", agv.Name, agv.TaskRunState.ToTaskInfo())); LogUtil.info(string.Format("{0} Add_Mission_Fleet[{1}]Fail", agv.Name, agv.TaskRunState.ToTaskInfo()));
} }
} }
else else
...@@ -185,16 +197,22 @@ namespace DeviceLibrary ...@@ -185,16 +197,22 @@ namespace DeviceLibrary
MiR_API.State_Ready(agv); MiR_API.State_Ready(agv);
if (rtn) if (rtn)
{ {
LogUtil.info(string.Format("{0} Add_Mission {1} Success", agv.Name, agv.TaskRunState.ToTaskInfo())); LogUtil.info(string.Format("{0} Add_Mission[{1}]Success", agv.Name, agv.TaskRunState.ToTaskInfo()));
} }
else else
{ {
LogUtil.info(string.Format("{0} Add_Mission {1} Fail", agv.Name, agv.TaskRunState.ToTaskInfo())); LogUtil.info(string.Format("{0} Add_Mission[{1}]Fail", agv.Name, agv.TaskRunState.ToTaskInfo()));
} }
} }
agv.StateKanban.SetCurTask(agv.TaskRunState.ToTaskShowInfo()); agv.StateKanban.SetCurTask(agv.TaskRunState.ToTaskShowInfo());
if (!rtn) if (!rtn)
agv.TaskRunState.EnWaitTaskQueue(task); {
if (agv.TaskRunState.CheckTaskExist(task))
{
agv.TaskRunState.EnWaitTaskQueue(task);
LogUtil.info(string.Format("{0} 发送失败,[{1}]加入任务等待队列 ", agv.Name, task.AliceName));
}
}
} }
return rtn; return rtn;
} }
...@@ -212,7 +230,7 @@ namespace DeviceLibrary ...@@ -212,7 +230,7 @@ namespace DeviceLibrary
{ {
MiR_API.Del_Mission(agv); MiR_API.Del_Mission(agv);
} }
LogUtil.info(string.Format("{0} DelMission [{1}] OK", agv.Name, agv.TaskRunState.ToTaskInfo())); LogUtil.info(string.Format("{0} DelMission[{1}]OK", agv.Name, agv.TaskRunState.ToTaskInfo()));
} }
} }
......
...@@ -17,32 +17,8 @@ namespace DeviceLibrary ...@@ -17,32 +17,8 @@ namespace DeviceLibrary
{ {
ChargePiles = new ChargePiles(); ChargePiles = new ChargePiles();
manager.XmlConfigOperation.LoadChargePileInfos(ChargePiles); manager.XmlConfigOperation.LoadChargePileInfos(ChargePiles);
CheckPileDulp();
} }
/// <summary>
/// 检查是否存在一台agv占用多个充电桩
/// </summary>
public static void CheckPileDulp()
{
List<ChargePile> cps;
foreach (AgvInfo item in AGVManager.agvInfo)
{
cps = ChargePiles.GetChargePilesByAgv(item);
if (cps != null && cps.Count > 1)
{
foreach (ChargePile cp in cps)
{
if (cp.Fixed)
{
System.Windows.Forms.MessageBox.Show($"{item.Name} 有固定充电桩 {cp.AliceName},不允许在其他充电桩上配置该车,请检查配置文件{"chargeinfos.xml"}", "警告");
return;
}
}
}
}
}
public static ChargePiles GetChargePiles() public static ChargePiles GetChargePiles()
{ {
return ChargePiles; return ChargePiles;
...@@ -55,7 +31,7 @@ namespace DeviceLibrary ...@@ -55,7 +31,7 @@ namespace DeviceLibrary
/// <returns>充电任务结果</returns> /// <returns>充电任务结果</returns>
public static bool HasEmpty(AgvInfo agv, out ChargePile charge) public static bool HasEmpty(AgvInfo agv, out ChargePile charge)
{ {
charge=null; charge = null;
lock (loc) lock (loc)
{ {
...@@ -82,10 +58,10 @@ namespace DeviceLibrary ...@@ -82,10 +58,10 @@ namespace DeviceLibrary
} }
public static void StopCharge(AgvInfo agv) public static void StopCharge(AgvInfo agv)
{ {
List<ChargePile> cps = ChargePiles.GetChargePilesByAgv(agv); List<ChargePile> cps = ChargePiles.GetChargePilesByAgv(agv);
foreach (ChargePile item in cps) foreach (ChargePile item in cps)
{ {
if(agv.Equals(item.OccupiedAgv)) if (agv.Equals(item.OccupiedAgv))
{ {
item.DelOccupy(agv); item.DelOccupy(agv);
agv.IsInCharge = false; agv.IsInCharge = false;
...@@ -97,7 +73,7 @@ namespace DeviceLibrary ...@@ -97,7 +73,7 @@ namespace DeviceLibrary
{ {
bool isRandom = true; bool isRandom = true;
ChargePile cp = ChargePiles.GetChargePileByAgv(agv); ChargePile cp = ChargePiles.GetChargePileByAgv(agv);
if(cp !=null) if (cp != null)
{ {
isRandom = !cp.Fixed; isRandom = !cp.Fixed;
} }
......
...@@ -23,6 +23,10 @@ namespace DeviceLibrary.manager ...@@ -23,6 +23,10 @@ namespace DeviceLibrary.manager
{ {
KPIOServer.StopServer(); KPIOServer.StopServer();
} }
public static void WriteDO(string ip,int idx,int value)
{
KPIOServer.WriteDO(ip, idx, value);
}
public static string GetDI(string ip) public static string GetDI(string ip)
{ {
try try
......
...@@ -31,22 +31,35 @@ namespace DeviceLibrary.manager ...@@ -31,22 +31,35 @@ namespace DeviceLibrary.manager
battery = item.Battery, battery = item.Battery,
position = item.Position, position = item.Position,
/// <summary>
/// 当前状态:执行任务/归位中/充电中/故障中
/// </summary>
state = item.StateID.ToString(),
curTarget = item.Place.Name, curTarget = item.Place.Name,
statusTxt = item.MissionText statusTxt = item.MissionText
}; };
if (item.CurJob != null && item.CurJob.JobParam != null && item.CurJob.JobParam.GetMissionInfo() != null) if (item.CurJob != null && item.CurJob.JobParam != null && item.CurJob.JobParam.GetMissionInfo() != null)
{ {
agvState.state = "执行任务";
agvState.missionId = item.CurJob.JobParam.GetMissionInfo().missionId; agvState.missionId = item.CurJob.JobParam.GetMissionInfo().missionId;
agvState.remark = item.CurJob.JobParam.GetMissionInfo().Remark; agvState.remark = item.CurJob.JobParam.GetMissionInfo().Remark;
} }
else
{
if(item.StateID.Equals(eAGVState.Error) || item.StateID.Equals(eAGVState.EmergencyStop))
{
agvState.state = "故障中";
}
else if(item.CurJob!=null && item.CurJob is StandyJob)
{
agvState.state = "归位中";
}
else if (item.CurJob != null && item.CurJob is ChargeJob)
{
agvState.state = "充电中";
}
}
agvStates.Add(agvState); agvStates.Add(agvState);
} }
string txt = Common.JsonHelper.SerializeObject(agvStates); string txt = Common.JsonHelper.SerializeObject(agvStates);
Common.LogUtil.debug(txt); HttpManager.AgvReportState(txt);
//Common.LogUtil.debug($"输出所有Agv信息:{txt}");
} }
finally finally
{ {
...@@ -60,14 +73,18 @@ namespace DeviceLibrary.manager ...@@ -60,14 +73,18 @@ namespace DeviceLibrary.manager
/// 运输状态上报 /// 运输状态上报
/// </summary> /// </summary>
/// <param name="transportStatus"></param> /// <param name="transportStatus"></param>
public static void UploadPosition(service.model.TransportStatus transportStatus) public static void UploadTransportStatus(service.model.TransportStatus transportStatus)
{ {
try try
{ {
string txt = Common.JsonHelper.SerializeObject(transportStatus); string txt = Common.JsonHelper.SerializeObject(transportStatus);
Common.LogUtil.info(txt); //Common.LogUtil.info($"运输状态上报{txt}");
HttpManager.UpdateAGVtranstask(txt);
System.Threading.Thread.Sleep(2000);
}
catch(Exception ex) {
Common.LogUtil.error($"UploadTransportStatus:{Common.JsonHelper.SerializeObject(transportStatus)}",ex);
} }
catch { }
} }
#endregion #endregion
} }
......
...@@ -106,12 +106,25 @@ namespace DeviceLibrary ...@@ -106,12 +106,25 @@ namespace DeviceLibrary
if (missionInfo.State.Equals(MissionState.创建)) if (missionInfo.State.Equals(MissionState.创建))
{ {
MissionManager.SetMissionState(missionInfo, MissionState.取消); MissionManager.SetMissionState(missionInfo, MissionState.取消);
MissionManager.DeleteById(deleteMission.missionId);
} }
else else
{ {
MissionManager.SetMissionState(missionInfo, MissionState.中止); AgvInfo agvInfo=AGVManager.agvInfo.Find(k=>k.JobContext.MissionId == deleteMission.missionId);
if(agvInfo == null)
{
MissionManager.SetMissionState(missionInfo, MissionState.中止);
MissionManager.DeleteById(deleteMission.missionId);
}
else
{
result.code = -1;
result.msg = $"已执行该任务,无法取消:{deleteMission.missionId}";
Log.Error(result.msg);
}
} }
MissionManager.DeleteById(deleteMission.missionId);
} }
} }
......
...@@ -9,7 +9,7 @@ using static DeviceLibrary.AgvInfo; ...@@ -9,7 +9,7 @@ using static DeviceLibrary.AgvInfo;
namespace DeviceLibrary.service.model namespace DeviceLibrary.service.model
{ {
/// <summary> /// <summary>
/// Agv状态 /// 上报Agv状态
/// </summary> /// </summary>
public class AgvState public class AgvState
{ {
......
...@@ -22,7 +22,8 @@ namespace DeviceLibrary.service.model ...@@ -22,7 +22,8 @@ namespace DeviceLibrary.service.model
/// <summary> /// <summary>
/// 优先级。3最高,1最低 /// 优先级。3最高,1最低
/// </summary> /// </summary>
public int Priority { get; set; } = 1; //public int Priority { get; set; } = 1;
/// <summary> /// <summary>
/// 是否可合并 /// 是否可合并
/// </summary> /// </summary>
...@@ -128,7 +129,7 @@ namespace DeviceLibrary.service.model ...@@ -128,7 +129,7 @@ namespace DeviceLibrary.service.model
} }
public string Remark { get; set; } public string Remark { get; set; }
public string JobName { get { return string.Format("{0}->{1} {2}任务", sourceWorkshop, destinationWorkshop, projectType.ToString()); } } public string JobName { get { return string.Format("[{0}->{1} {2}任务]", sourceWorkshop, destinationWorkshop, projectType.ToString()); } }
} }
public enum MissionState public enum MissionState
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!