Commit 591a8c30 顾剑亮

upload

1 个父辈 32a70733
正在显示 35 个修改的文件 包含 425 行增加125 行删除
...@@ -63,10 +63,11 @@ ...@@ -63,10 +63,11 @@
<ItemGroup> <ItemGroup>
<Compile Include="BLL\Control.cs" /> <Compile Include="BLL\Control.cs" />
<Compile Include="BLL\Common.cs" /> <Compile Include="BLL\Common.cs" />
<Compile Include="Model\MissionState.cs" />
<Compile Include="Model\MiR_API.cs" /> <Compile Include="Model\MiR_API.cs" />
<Compile Include="Model\job\TakeOldJob.cs" /> <Compile Include="Job\TakeOldJob.cs" />
<Compile Include="Model\job\SendNewJob.cs" /> <Compile Include="Job\SendNewJob.cs" />
<Compile Include="Model\job\ChargeJob.cs" /> <Compile Include="Job\ChargeJob.cs" />
<Compile Include="Model\AgvInfo.cs" /> <Compile Include="Model\AgvInfo.cs" />
<Compile Include="FrmMain.cs"> <Compile Include="FrmMain.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
...@@ -74,12 +75,14 @@ ...@@ -74,12 +75,14 @@
<Compile Include="FrmMain.Designer.cs"> <Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon> <DependentUpon>FrmMain.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Model\job\JobStep.cs" /> <Compile Include="Job\JobStep.cs" />
<Compile Include="Model\job\Job.cs" /> <Compile Include="Model\Job.cs" />
<Compile Include="MoveWashJob.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Model\job\StandbyJob.cs" /> <Compile Include="Job\StandbyJob.cs" />
<Compile Include="BLL\WebService.cs" /> <Compile Include="BLL\WebService.cs" />
<Compile Include="Model\SteelWork.cs" />
<EmbeddedResource Include="FrmMain.resx"> <EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon> <DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
</log4net> </log4net>
<appSettings> <appSettings>
<add key="FLEET_IP" value="10.85.199.3" /> <add key="FLEET_IP" value="10.85.199.3" />
<add key="WebService" value="http://10.85.196.40:8088/"/> <add key="WebService" value="http://10.85.196.40:8089/"/>
<add key="AGV_BATTERY_MAX" value="100"/>
<add key="AGV_BATTERY_MIN" value="30"/>
<add key="4D_Line" value="D1,D2,D3,D4,D5,D6,D8,D9,D10,D11,D12,D14,D15,D16"/>
<add key="4C_Line" value="C1,C2,C3,C4,C5,C6,C7,C8,C9,C10"/>
</appSettings> </appSettings>
</configuration> </configuration>
\ No newline at end of file \ No newline at end of file
using System; using Model;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace AGVControl_Steel namespace AGVControl_Steel
{ {
...@@ -8,39 +10,62 @@ namespace AGVControl_Steel ...@@ -8,39 +10,62 @@ namespace AGVControl_Steel
/// </summary> /// </summary>
public static class Common public static class Common
{ {
public static List<Model.AgvInfo> agvInfos; public static List<AgvInfo> agvInfos;
public static Dictionary<string, string> agvMissions; public static Dictionary<string, string> agvMissions;
public static MiR_API mir;
public static BLL.Control control; public static BLL.Control control;
public static Model.MiR_API mir;
public static BLL.WebService service;
public static bool serverOpen; public static bool serverOpen;
public static System.Configuration.Configuration appConfig; public static System.Configuration.Configuration appConfig;
public static log4net.ILog log; public static log4net.ILog log;
public static List<SteelWork> oldSteelWork;
public static string[] LINE_NAME_4D;
public static string[] LINE_NAME_4C;
public const string MISSION_MOVE_4C_4D = "MoveDoor-4C-4D"; public const string MISSION_MOVE_4C_4D = "MoveDoor-4C-4D";
public const string MISSION_MOVE_4D_4C = "MoveDoor-4D-4C"; public const string MISSION_MOVE_4D_4C = "MoveDoor-4D-4C";
public const string MISSION_CHARGE = "ChargeSteel"; public const string MISSION_CHARGE = "ChargeSteel";
public const string MISSION_MOVE_STANDBY = "MoveStandby"; public const string MISSION_MOVE_STANDBY = "MoveStandby";
/// <summary>
/// AGV最大充电电量
/// </summary>
public static int AGV_BATTERY_MAX;
/// <summary>
/// AGV最低电量,小于此值必须充电
/// </summary>
public static int AGV_BATTERY_MIN;
public static readonly string PATH_AGV_NAME = Environment.CurrentDirectory + "\\Config\\AgvName.csv"; public static readonly string PATH_AGV_NAME = Environment.CurrentDirectory + "\\Config\\AgvName.csv";
public static readonly string PATH_AGV_MISSION = Environment.CurrentDirectory + "\\Config\\AgvMission.csv"; public static readonly string PATH_AGV_MISSION = Environment.CurrentDirectory + "\\Config\\AgvMission.csv";
public static readonly string PATH_NEW_STEEL_WORK = Environment.CurrentDirectory + "\\Config\\NewSteelWork.txt";
public static readonly string PATH_OLD_STEEL_WORK = Environment.CurrentDirectory + "\\Config\\OldSteelWork.txt";
public delegate void AgvChangedEvent(int agvIndex); public delegate void AgvChangedEvent(int agvIndex);
public static event AgvChangedEvent AgvChanged; public static event AgvChangedEvent AgvChanged;
public static event AgvChangedEvent AgvOnline; public static event AgvChangedEvent AgvOnline;
//private static List<SteelWork> newSteelWork = new List<SteelWork>();
/// <summary>
/// Web服务器
/// </summary>
public static class WebService public static class WebService
{ {
private static System.ServiceModel.Web.WebServiceHost _serviceHost; private static System.ServiceModel.Web.WebServiceHost _serviceHost;
/// <summary>
/// 打开服务
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static bool Open(string url) public static bool Open(string url)
{ {
try try
{ {
service = new BLL.WebService(); BLL.WebService service = new BLL.WebService();
_serviceHost = new System.ServiceModel.Web.WebServiceHost(service, new Uri(url)); _serviceHost = new System.ServiceModel.Web.WebServiceHost(service, new Uri(url));
_serviceHost.Open(); _serviceHost.Open();
log.Info("Web服务已开启"); log.Info("Web服务已开启");
...@@ -53,6 +78,9 @@ namespace AGVControl_Steel ...@@ -53,6 +78,9 @@ namespace AGVControl_Steel
} }
} }
/// <summary>
/// 关闭服务
/// </summary>
public static void Close() public static void Close()
{ {
if (_serviceHost != null) if (_serviceHost != null)
...@@ -65,9 +93,9 @@ namespace AGVControl_Steel ...@@ -65,9 +93,9 @@ namespace AGVControl_Steel
/// 获取小车的状态 /// 获取小车的状态
/// </summary> /// </summary>
/// <param name="info"></param> /// <param name="info"></param>
public static void GetAgvState(ref Model.AgvInfo info) public static void GetAgvState(ref AgvInfo info)
{ {
bool rtn = CheckOnline(ref info); bool rtn = CheckAgvOnline(ref info);
if (!rtn) return; if (!rtn) return;
rtn = mir.Get_State(info.IP, info.Authorization, out int stateID, out string stateText, out int battery, out string missionText); rtn = mir.Get_State(info.IP, info.Authorization, out int stateID, out string stateText, out int battery, out string missionText);
...@@ -86,7 +114,73 @@ namespace AGVControl_Steel ...@@ -86,7 +114,73 @@ namespace AGVControl_Steel
} }
} }
private static bool CheckOnline(ref Model.AgvInfo info) public static void OldSteelWorkAdd(string s)
{
int index = oldSteelWork.FindIndex(sw => sw.from == s);
if (index == -1)
{
oldSteelWork.Add(new SteelWork(s));
string[] content = new string[oldSteelWork.Count];
for (int i = 0; i < content.Length; i++)
content[i] = oldSteelWork[i].from + "," + oldSteelWork[i].dateTime.ToString();
System.IO.File.WriteAllLines(PATH_OLD_STEEL_WORK, content, System.Text.Encoding.UTF8);
}
log.Debug("AddOldSteel(" + s + ") 旧钢板任务,保存到" + PATH_OLD_STEEL_WORK);
//mir.Add_Mission_Fleet(agvInfos[1].FleetID, agvInfos[1].Authorization, "MoveSteelD15", out string id);
}
public static void OldSteelWorkDel(string s)
{
int index = oldSteelWork.FindIndex(sw => sw.from == s);
if (index > -1)
{
oldSteelWork.RemoveAt(index);
string[] content = new string[oldSteelWork.Count];
for (int i = 0; i < content.Length; i++)
content[i] = oldSteelWork[i].from + "," + oldSteelWork[i].dateTime.ToString();
System.IO.File.WriteAllLines(PATH_OLD_STEEL_WORK, content, System.Text.Encoding.UTF8);
}
log.Debug("OldSteelWorkDel(" + s + ") 旧钢板任务,保存到" + PATH_OLD_STEEL_WORK);
}
public static void OldSteelWorkLoad()
{
oldSteelWork = new List<SteelWork>();
if (!System.IO.File.Exists(PATH_OLD_STEEL_WORK)) return;
string[] lines = System.IO.File.ReadAllLines(PATH_OLD_STEEL_WORK, System.Text.Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
string[] arr = lines[i].Split(',');
oldSteelWork.Add(new SteelWork(arr[0], arr[1]));
}
log.Debug("OldSteelWorkLoad() 旧钢板任务,来自" + PATH_OLD_STEEL_WORK);
}
public static Job GetJob()
{
if (oldSteelWork.Count > 0)
return new TakeOldJob();
else
return null;
}
/// <summary>
/// 检查小车是否在线
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
private static bool CheckAgvOnline(ref AgvInfo info)
{ {
bool rtn = mir.CheckIP(info.IP); bool rtn = mir.CheckIP(info.IP);
if (rtn) if (rtn)
...@@ -117,39 +211,4 @@ namespace AGVControl_Steel ...@@ -117,39 +211,4 @@ namespace AGVControl_Steel
} }
} }
/// <summary>
/// 任务执行的状态
/// </summary>
public enum MissionState
{
/// <summary>
/// 终止
/// </summary>
Aborted,
/// <summary>
/// 执行中
/// </summary>
Executing,
/// <summary>
/// 已完成
/// </summary>
Done
}
public enum StateID
{
None = 0,
Starting,
ShuttingDown,
Ready,
Pause,
Executing,
Aborted,
Completed,
Docked,
Docking,
EmergencyStop,
ManualControl,
Error
}
} }
...@@ -11,7 +11,7 @@ namespace BLL ...@@ -11,7 +11,7 @@ namespace BLL
internal interface IWebService internal interface IWebService
{ {
[OperationContract] [OperationContract]
[WebGet(UriTemplate = "StealAgv/takeOld?from={place}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] [WebGet(UriTemplate = "StealAgv/takeOld?from={from}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
Result TakeOldGet(string from); Result TakeOldGet(string from);
[OperationContract] [OperationContract]
...@@ -51,21 +51,18 @@ namespace BLL ...@@ -51,21 +51,18 @@ namespace BLL
public Result TakeOldGet(string from) public Result TakeOldGet(string from)
{ {
Common.log.Info("钢网 takeOld[GET] from=" + from); Common.log.Info("takeOld[GET] from=" + from);
Common.OldSteelWorkAdd(from.ToUpper());
Result res = new Result(); Result res = new Result { Code = 0, Msg = "OK" };
res.Code = 0;
res.Msg = "OK";
return res; return res;
} }
public Result SendNewGet(string from, string list) public Result SendNewGet(string from, string list)
{ {
Common.log.Info("钢网 sendNew[GET] from=" + from + " placeList=" + list); Common.log.Info("sendNew[GET] from=" + from + " placeList=" + list);
Result res = new Result(); Result res = new Result { Code = 0, Msg = "OK" };
res.Code = 0;
res.Msg = "OK";
return res; return res;
} }
...@@ -73,11 +70,11 @@ namespace BLL ...@@ -73,11 +70,11 @@ namespace BLL
{ {
StreamReader sr = new StreamReader(info); StreamReader sr = new StreamReader(info);
string s = sr.ReadToEnd(); string s = sr.ReadToEnd();
Common.log.Info("钢网 takeOld[POST] " + s); Common.log.Info("takeOld[POST] " + s);
s = s.ToUpper().Replace("FROM=", "");
Common.OldSteelWorkAdd(s);
Result res = new Result(); Result res = new Result { Code = 0, Msg = "OK" };
res.Code = 0;
res.Msg = "OK";
return res; return res;
} }
...@@ -85,11 +82,9 @@ namespace BLL ...@@ -85,11 +82,9 @@ namespace BLL
{ {
StreamReader sr = new StreamReader(info); StreamReader sr = new StreamReader(info);
string s = sr.ReadToEnd(); string s = sr.ReadToEnd();
Common.log.Info("钢网 sendNew[POST]" + s); Common.log.Info("sendNew[POST] " + s);
Result res = new Result(); Result res = new Result { Code = 0, Msg = "OK" };
res.Code = 0;
res.Msg = "OK";
return res; return res;
} }
......
...@@ -38,8 +38,11 @@ ...@@ -38,8 +38,11 @@
this.Column4 = new System.Windows.Forms.DataGridViewButtonColumn(); this.Column4 = new System.Windows.Forms.DataGridViewButtonColumn();
this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage();
this.LblWeb = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.DgvName)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.DgvName)).BeginInit();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// DgvName // DgvName
...@@ -139,14 +142,38 @@ ...@@ -139,14 +142,38 @@
// //
// tabPage2 // tabPage2
// //
this.tabPage2.Controls.Add(this.button1);
this.tabPage2.Controls.Add(this.LblWeb);
this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2"; this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3); this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(714, 314); this.tabPage2.Size = new System.Drawing.Size(714, 314);
this.tabPage2.TabIndex = 1; this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "tabPage2"; this.tabPage2.Text = "状态";
this.tabPage2.UseVisualStyleBackColor = true; this.tabPage2.UseVisualStyleBackColor = true;
// //
// LblWeb
//
this.LblWeb.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.LblWeb.Location = new System.Drawing.Point(9, 9);
this.LblWeb.Margin = new System.Windows.Forms.Padding(6);
this.LblWeb.Name = "LblWeb";
this.LblWeb.Size = new System.Drawing.Size(120, 25);
this.LblWeb.TabIndex = 0;
this.LblWeb.Text = "WebService";
this.LblWeb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.Location = new System.Drawing.Point(502, 211);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(170, 55);
this.button1.TabIndex = 1;
this.button1.Text = "TEST";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// FrmMain // FrmMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
...@@ -160,6 +187,7 @@ ...@@ -160,6 +187,7 @@
this.Load += new System.EventHandler(this.FrmMain_Load); this.Load += new System.EventHandler(this.FrmMain_Load);
((System.ComponentModel.ISupportInitialize)(this.DgvName)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.DgvName)).EndInit();
this.tabControl1.ResumeLayout(false); this.tabControl1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
...@@ -176,6 +204,8 @@ ...@@ -176,6 +204,8 @@
private System.Windows.Forms.DataGridViewButtonColumn Column4; private System.Windows.Forms.DataGridViewButtonColumn Column4;
private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.Label LblWeb;
private System.Windows.Forms.Button button1;
} }
} }
...@@ -31,6 +31,9 @@ namespace AGVControl_Steel ...@@ -31,6 +31,9 @@ namespace AGVControl_Steel
private void FrmMain_Load(object sender, EventArgs e) private void FrmMain_Load(object sender, EventArgs e)
{ {
Common.serverOpen = Common.WebService.Open(Common.appConfig.AppSettings.Settings["WebService"].Value);
LblWeb.BackColor = Common.serverOpen ? Color.Lime : Color.Red;
for (int i = 0; i < Common.agvInfos.Count; i++) for (int i = 0; i < Common.agvInfos.Count; i++)
{ {
DgvName.Rows.Add(Common.agvInfos[i].ToRow()); DgvName.Rows.Add(Common.agvInfos[i].ToRow());
...@@ -58,5 +61,10 @@ namespace AGVControl_Steel ...@@ -58,5 +61,10 @@ namespace AGVControl_Steel
Common.log.Info("手动修改 " + info.Name + " IsUse=" + info.IsAuto); Common.log.Info("手动修改 " + info.Name + " IsUse=" + info.IsAuto);
} }
} }
private void button1_Click(object sender, EventArgs e)
{
Common.GetJob();
}
} }
} }
...@@ -138,25 +138,4 @@ ...@@ -138,25 +138,4 @@
<metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column7.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>
\ No newline at end of file \ No newline at end of file
...@@ -31,15 +31,25 @@ namespace Model ...@@ -31,15 +31,25 @@ namespace Model
} }
else if (chargeStep.IsEqual(ChargeStep.WaitWorkshopDoor)) else if (chargeStep.IsEqual(ChargeStep.WaitWorkshopDoor))
{ {
WorkshopDoor(info); WaitWorkshopDoor(info);
} }
else if (chargeStep.IsEqual(ChargeStep.WaitChargeStation)) else if (chargeStep.IsEqual(ChargeStep.WaitChargeStation))
{ {
ChargeStation(info); WaitChargeStation(info);
} }
else if (chargeStep.IsEqual(ChargeStep.Charging)) else if (chargeStep.IsEqual(ChargeStep.Charging))
{ {
Charging(info); Common.GetAgvState(ref info);
if (info.Battery == Common.AGV_BATTERY_MAX)
{
chargeStep.NextStep(ChargeStep.End);
chargeStep.Msg = info.FullName + "电量达到" + Common.AGV_BATTERY_MAX + ",充电工作结束";
}
else if (info.Battery > Common.AGV_BATTERY_MIN)
{
Job job = Common.GetJob();
if (job != null) return job;
}
} }
else if (chargeStep.IsEqual(ChargeStep.End)) else if (chargeStep.IsEqual(ChargeStep.End))
{ {
...@@ -85,7 +95,7 @@ namespace Model ...@@ -85,7 +95,7 @@ namespace Model
} }
} }
private void WorkshopDoor(AgvInfo info) private void WaitWorkshopDoor(AgvInfo info)
{ {
rtn = Common.mir.Get_MissionState_Fleet(info.Authorization, id, out string state); rtn = Common.mir.Get_MissionState_Fleet(info.Authorization, id, out string state);
if (rtn) if (rtn)
...@@ -114,7 +124,7 @@ namespace Model ...@@ -114,7 +124,7 @@ namespace Model
} }
} }
private void ChargeStation(AgvInfo info) private void WaitChargeStation(AgvInfo info)
{ {
rtn = Common.mir.Get_Register(info.IP, info.Authorization, 20, out int value); rtn = Common.mir.Get_Register(info.IP, info.Authorization, 20, out int value);
if (rtn) if (rtn)
...@@ -131,20 +141,6 @@ namespace Model ...@@ -131,20 +141,6 @@ namespace Model
} }
} }
private void Charging(AgvInfo info)
{
Common.GetAgvState(ref info);
if (info.Battery == 100)
{
chargeStep.NextStep(ChargeStep.End);
chargeStep.Msg = info.FullName + "电量100%,充电工作结束";
}
else if (info.Battery > 80)
{
}
}
......
...@@ -19,7 +19,7 @@ namespace Model ...@@ -19,7 +19,7 @@ namespace Model
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, Common.MISSION_MOVE_STANDBY, out id); rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, Common.MISSION_MOVE_STANDBY, out id);
if (rtn) if (rtn)
{ {
standbyStep.NextStep(StandbyStep.Standby); standbyStep.NextStep(StandbyStep.WaitStandby);
standbyStep.Msg = info.FullName + "回待机位"; standbyStep.Msg = info.FullName + "回待机位";
} }
else else
...@@ -27,7 +27,7 @@ namespace Model ...@@ -27,7 +27,7 @@ namespace Model
standbyStep.Msg = info.FullName + "发送" + Common.MISSION_MOVE_STANDBY + "任务失败"; standbyStep.Msg = info.FullName + "发送" + Common.MISSION_MOVE_STANDBY + "任务失败";
} }
} }
else if (standbyStep.IsEqual(StandbyStep.Standby)) else if (standbyStep.IsEqual(StandbyStep.WaitStandby))
{ {
rtn = Common.mir.Get_MissionState_Fleet(info.Authorization, id, out string state); rtn = Common.mir.Get_MissionState_Fleet(info.Authorization, id, out string state);
if (rtn) if (rtn)
...@@ -37,6 +37,9 @@ namespace Model ...@@ -37,6 +37,9 @@ namespace Model
standbyStep.NextStep(StandbyStep.End); standbyStep.NextStep(StandbyStep.End);
standbyStep.Msg = info.FullName + "已在待机位"; standbyStep.Msg = info.FullName + "已在待机位";
} }
else if (state == MissionState.Executing.ToString())
{
}
else if (state == MissionState.Aborted.ToString()) else if (state == MissionState.Aborted.ToString())
{ {
standbyStep.Msg = info.FullName + "任务状态" + MissionState.Aborted.ToString(); standbyStep.Msg = info.FullName + "任务状态" + MissionState.Aborted.ToString();
...@@ -49,6 +52,8 @@ namespace Model ...@@ -49,6 +52,8 @@ namespace Model
} }
else if (standbyStep.IsEqual(StandbyStep.End)) else if (standbyStep.IsEqual(StandbyStep.End))
{ {
Job job = Common.GetJob();
if (job != null) return job;
} }
return this; return this;
} }
...@@ -59,7 +64,7 @@ namespace Model ...@@ -59,7 +64,7 @@ namespace Model
private enum StandbyStep private enum StandbyStep
{ {
None, None,
Standby, WaitStandby,
End End
} }
} }
......
using AGVControl_Steel;
namespace Model
{
public class TakeOldJob : Job
{
private string id;
private JobStep<TakeOldStep> takeOldStep;
private int currentCount;
private const int STEEL_COUNT_MAX = 6;
public TakeOldJob()
{
takeOldStep = new JobStep<TakeOldStep>(TakeOldStep.None);
}
public override Job Execute(AgvInfo info)
{
string name;
if (takeOldStep.IsEqual(TakeOldStep.None))
{
currentCount = 0;
takeOldStep.NextStep(TakeOldStep.FindLine);
}
else if (takeOldStep.IsEqual(TakeOldStep.FindLine))
{
if (currentCount == STEEL_COUNT_MAX)
{
return new MoveWashJob();
}
else if (Common.oldSteelWork.Count == 0)
{
return new MoveWashJob();
}
else
{
for (int i = 0; i < Common.LINE_NAME_4D.Length; i++)
{
name = Common.LINE_NAME_4D[i];
int idx = Common.oldSteelWork.FindIndex(s => s.from == name);
if (idx > -1)
{
name = "MoveSteel" + name;
Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, name, out id);
takeOldStep.NextStep(TakeOldStep.MoveLine);
takeOldStep.Msg = info.FullName + "发送任务" + name;
currentCount++;
break;
}
}
}
}
else if (takeOldStep.IsEqual(TakeOldStep.MoveLine))
{
rtn = Common.mir.Get_MissionState_Fleet(info.Authorization, id, out string state);
if (rtn)
{
if (state == MissionState.Done.ToString())
{
takeOldStep.NextStep(TakeOldStep.FindLine);
takeOldStep.Msg = info.FullName + "当前任务完成";
}
else if (state == MissionState.Executing.ToString())
{
}
else if (state == MissionState.Aborted.ToString())
{
takeOldStep.Msg = info.FullName + "任务状态" + MissionState.Aborted.ToString();
}
}
else
{
takeOldStep.Msg = info.FullName + "获取任务状态id[" + id + "]失败";
}
}
return this;
}
private enum TakeOldStep
{
None,
FindLine,
MoveLine
}
}
}

namespace AGVControl_Steel
{
/// <summary>
/// 任务执行的状态
/// </summary>
public enum MissionState
{
/// <summary>
/// 终止
/// </summary>
Aborted,
/// <summary>
/// 执行中
/// </summary>
Executing,
/// <summary>
/// 已完成
/// </summary>
Done
}
public enum StateID
{
None = 0,
Starting,
ShuttingDown,
Ready,
Pause,
Executing,
Aborted,
Completed,
Docked,
Docking,
EmergencyStop,
ManualControl,
Error
}
}
\ No newline at end of file \ No newline at end of file
using System;
namespace AGVControl_Steel
{
public class SteelWork
{
public string from { set; get; }
public string placeList { set; get; }
public DateTime dateTime { set; get; }
public SteelWork()
{
}
public SteelWork(string from)
{
this.from = from;
dateTime = DateTime.Now;
}
//public SteelWork(string from, string placeList)
//{
// this.from = from;
// this.placeList = placeList;
//}
public SteelWork(string from, string dateTime)
{
this.from = from;
this.dateTime = Convert.ToDateTime(dateTime);
}
}
}
\ No newline at end of file \ No newline at end of file

\ No newline at end of file \ No newline at end of file
using AGVControl_Steel;
namespace Model
{
public class MoveWashJob : Job
{
private string id;
private JobStep<MoveWashStep> moveWashStep;
public MoveWashJob()
{
moveWashStep = new JobStep<MoveWashStep>(MoveWashStep.None);
}
public override Job Execute(AgvInfo info)
{
throw new System.NotImplementedException();
}
private enum MoveWashStep
{
None
}
}
}
...@@ -21,10 +21,10 @@ namespace AGVControl_Steel ...@@ -21,10 +21,10 @@ namespace AGVControl_Steel
ReadConfig(); ReadConfig();
Common.control = new BLL.Control(); Common.control = new BLL.Control();
Common.mir = new Model.MiR_API { FleetIP = Common.appConfig.AppSettings.Settings["FLEET_IP"].Value, MissionList = Common.agvMissions }; Common.mir = new Model.MiR_API { FleetIP = Common.appConfig.AppSettings.Settings["FLEET_IP"].Value, MissionList = Common.agvMissions };
Common.serverOpen = Common.WebService.Open(Common.appConfig.AppSettings.Settings["WebService"].Value);
Application.Run(new FrmMain()); Application.Run(new FrmMain());
Common.WebService.Close();
Common.control.Stop(); Common.control.Stop();
Common.log.Info("=====程序结束=====\r\n"); Common.log.Info("=====程序结束=====\r\n");
} }
...@@ -63,6 +63,7 @@ namespace AGVControl_Steel ...@@ -63,6 +63,7 @@ namespace AGVControl_Steel
} }
Common.log.Info("读取配置文件 " + Common.PATH_AGV_NAME); Common.log.Info("读取配置文件 " + Common.PATH_AGV_NAME);
//AGV任务ID号
Common.agvMissions = new System.Collections.Generic.Dictionary<string, string>(); Common.agvMissions = new System.Collections.Generic.Dictionary<string, string>();
lines = System.IO.File.ReadAllLines(Common.PATH_AGV_MISSION, System.Text.Encoding.UTF8); lines = System.IO.File.ReadAllLines(Common.PATH_AGV_MISSION, System.Text.Encoding.UTF8);
for (int i = 0; i < lines.Length; i++) for (int i = 0; i < lines.Length; i++)
...@@ -73,6 +74,12 @@ namespace AGVControl_Steel ...@@ -73,6 +74,12 @@ namespace AGVControl_Steel
} }
Common.log.Info("读取配置文件 " + Common.PATH_AGV_MISSION); Common.log.Info("读取配置文件 " + Common.PATH_AGV_MISSION);
Common.AGV_BATTERY_MAX = Convert.ToInt32(Common.appConfig.AppSettings.Settings["AGV_BATTERY_MAX"].Value);
Common.AGV_BATTERY_MIN = Convert.ToInt32(Common.appConfig.AppSettings.Settings["AGV_BATTERY_MIN"].Value);
Common.LINE_NAME_4D = Common.appConfig.AppSettings.Settings["4D_Line"].Value.Split(',');
Common.LINE_NAME_4C = Common.appConfig.AppSettings.Settings["4C_Line"].Value.Split(',');
Common.OldSteelWorkLoad();
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
</log4net> </log4net>
<appSettings> <appSettings>
<add key="FLEET_IP" value="10.85.199.3" /> <add key="FLEET_IP" value="10.85.199.3" />
<add key="WebService" value="http://10.85.196.40:8088/"/> <add key="WebService" value="http://10.85.196.40:8089/"/>
<add key="AGV_BATTERY_MAX" value="100"/>
<add key="AGV_BATTERY_MIN" value="30"/>
<add key="4D_Line" value="D1,D2,D3,D4,D5,D6,D8,D9,D10,D11,D12,D14,D15,D16"/>
<add key="4C_Line" value="C1,C2,C3,C4,C5,C6,C7,C8,C9,C10"/>
</appSettings> </appSettings>
</configuration> </configuration>
\ No newline at end of file \ No newline at end of file
...@@ -29,12 +29,46 @@ ...@@ -29,12 +29,46 @@
公共类 公共类
</summary> </summary>
</member> </member>
<member name="F:AGVControl_Steel.Common.AGV_BATTERY_MAX">
<summary>
AGV最大充电电量
</summary>
</member>
<member name="F:AGVControl_Steel.Common.AGV_BATTERY_MIN">
<summary>
AGV最低电量,小于此值必须充电
</summary>
</member>
<member name="T:AGVControl_Steel.Common.WebService">
<summary>
Web服务器
</summary>
</member>
<member name="M:AGVControl_Steel.Common.WebService.Open(System.String)">
<summary>
打开服务
</summary>
<param name="url"></param>
<returns></returns>
</member>
<member name="M:AGVControl_Steel.Common.WebService.Close">
<summary>
关闭服务
</summary>
</member>
<member name="M:AGVControl_Steel.Common.GetAgvState(Model.AgvInfo@)"> <member name="M:AGVControl_Steel.Common.GetAgvState(Model.AgvInfo@)">
<summary> <summary>
获取小车的状态 获取小车的状态
</summary> </summary>
<param name="info"></param> <param name="info"></param>
</member> </member>
<member name="M:AGVControl_Steel.Common.CheckAgvOnline(Model.AgvInfo@)">
<summary>
检查小车是否在线
</summary>
<param name="info"></param>
<returns></returns>
</member>
<member name="T:AGVControl_Steel.MissionState"> <member name="T:AGVControl_Steel.MissionState">
<summary> <summary>
任务执行的状态 任务执行的状态
......
MoveA1,eec1eed4-2a04-11ea-9c84-94c691a734f1
MoveA2,f68f18db-2f89-11ea-9ee4-94c691a734f1
MoveA3,979d10eb-2f9d-11ea-9ee4-94c691a734f1
MoveA4,df6d991a-2f9d-11ea-9ee4-94c691a734f1
MoveA5,
MoveA6,
MoveDoor-4C-4D,
ChargeSteel,
\ No newline at end of file \ No newline at end of file
MoveSteelD15,002b3e45-f105-11ea-a03e-94c691a7387d
\ No newline at end of file \ No newline at end of file
f043318a8d986121056db453b28d27892cd2232a 22eefbcbb33c48fe4282997d46592caba72e67fe
...@@ -2,7 +2,6 @@ D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Ste ...@@ -2,7 +2,6 @@ D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Ste
D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\bin\Debug\AGVControl_Steel.xml D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\bin\Debug\AGVControl_Steel.xml
D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\bin\Debug\AGVControl_Steel.exe D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\bin\Debug\AGVControl_Steel.exe
D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\bin\Debug\AGVControl_Steel.pdb D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\bin\Debug\AGVControl_Steel.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\obj\Debug\AGVControl_Steel.csprojAssemblyReference.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\obj\Debug\AGVControl_Steel.FrmMain.resources D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\obj\Debug\AGVControl_Steel.FrmMain.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\obj\Debug\AGVControl_Steel.Properties.Resources.resources D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\obj\Debug\AGVControl_Steel.Properties.Resources.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\obj\Debug\AGVControl_Steel.csproj.GenerateResource.cache D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\obj\Debug\AGVControl_Steel.csproj.GenerateResource.cache
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!