Commit 1eef9f92 顾剑亮

upload

1 个父辈 591a8c30
正在显示 37 个修改的文件 包含 893 行增加475 行删除
......@@ -66,24 +66,25 @@
<Compile Include="Model\MissionState.cs" />
<Compile Include="Model\MiR_API.cs" />
<Compile Include="Job\TakeOldJob.cs" />
<Compile Include="Job\SendNewJob.cs" />
<Compile Include="Job\ChargeJob.cs" />
<Compile Include="Model\AgvInfo.cs" />
<Compile Include="FrmMain.cs">
<Compile Include="Job\StorageJob.cs" />
<Compile Include="UI\FrmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.cs">
<Compile Include="UI\FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<Compile Include="Job\JobStep.cs" />
<Compile Include="Model\JobStep.cs" />
<Compile Include="Model\Job.cs" />
<Compile Include="MoveWashJob.cs" />
<Compile Include="Job\WashPointJob.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Job\StandbyJob.cs" />
<Compile Include="BLL\WebService.cs" />
<Compile Include="Model\SteelWork.cs" />
<EmbeddedResource Include="FrmMain.resx">
<Compile Include="BLL\SteelManage.cs" />
<EmbeddedResource Include="UI\FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
......
......@@ -40,8 +40,11 @@
<add key="FLEET_IP" value="10.85.199.3" />
<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="AGV_BATTERY_MIN" value="60"/>
<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"/>
<add key="Store" value="wash,storage"/>
<add key="4D_AGV" value="25"/>
<add key="4C_AGV" value="32"/>
</appSettings>
</configuration>
\ No newline at end of file
......@@ -14,201 +14,56 @@ namespace AGVControl_Steel
public static Dictionary<string, string> agvMissions;
public static MiR_API mir;
public static BLL.Control control;
public static bool serverOpen;
public static BLL.SteelManage steelManage;
public static System.Configuration.Configuration appConfig;
public static log4net.ILog log;
public static List<SteelWork> oldSteelWork;
public static string[] LINE_NAME_4D;
public static string[] LINE_NAME_4C;
public static string[] STORE_NAME;
public const string WORKSHOP_4D = "4D";
public const string WORKSHOP_4C = "4C";
public const string MISSION_MOVE_4C_4D = "MoveDoor-4C-4D";
public const string MISSION_MOVE_4D_4C = "MoveDoor-4D-4C";
public const string MISSION_CHARGE = "ChargeSteel";
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 const string MISSION_CHARGE_4D = "AutoCharge4D";
public const string MISSION_CHARGE_4C = "AutoCharge4C";
public const string MISSION_STANDBY_4D = "Move4DStandby";
public const string MISSION_STANDBY_4C = "Move4CStandby";
public const string MISSION_MOVE_WASH_4D = "Move4DWash";
public const string MISSION_MOVE_WASH_4C = "Move4CWash";
public const string MISSION_MOVE_STORAGE = "MoveStorage";
public const string MISSION_MOVE_D1 = "MoveSteelD1";
public const string MISSION_MOVE_D2 = "MoveSteelD2";
public const string MISSION_MOVE_D3 = "MoveSteelD3";
public const string MISSION_MOVE_D4 = "MoveSteelD4";
public const string MISSION_MOVE_D5 = "MoveSteelD5";
public const string MISSION_MOVE_D6 = "MoveSteelD6";
public const string MISSION_MOVE_D8 = "MoveSteelD8";
public const string MISSION_MOVE_D9 = "MoveSteelD9";
public const string MISSION_MOVE_D10 = "MoveSteelD10";
public const string MISSION_MOVE_D11 = "MoveSteelD11";
public const string MISSION_MOVE_D12 = "MoveSteelD12";
public const string MISSION_MOVE_D14 = "MoveSteelD14";
public const string MISSION_MOVE_D15 = "MoveSteelD15";
public const string MISSION_MOVE_D16 = "MoveSteelD16";
public const string MISSION_MOVE_C1 = "MoveSteelC1";
public const string MISSION_MOVE_C2 = "MoveSteelC2";
public const string MISSION_MOVE_C3 = "MoveSteelC3";
public const string MISSION_MOVE_C4 = "MoveSteelC4";
public const string MISSION_MOVE_C5 = "MoveSteelC5";
public const string MISSION_MOVE_C6 = "MoveSteelC6";
public const string MISSION_MOVE_C7 = "MoveSteelC7";
public const string MISSION_MOVE_C8 = "MoveSteelC8";
public const string MISSION_MOVE_C9 = "MoveSteelC9";
public const string MISSION_MOVE_C10 = "MoveSteelC10";
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_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 static event AgvChangedEvent AgvChanged;
public static event AgvChangedEvent AgvOnline;
//private static List<SteelWork> newSteelWork = new List<SteelWork>();
/// <summary>
/// Web服务器
/// </summary>
public static class WebService
{
private static System.ServiceModel.Web.WebServiceHost _serviceHost;
/// <summary>
/// 打开服务
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static bool Open(string url)
{
try
{
BLL.WebService service = new BLL.WebService();
_serviceHost = new System.ServiceModel.Web.WebServiceHost(service, new Uri(url));
_serviceHost.Open();
log.Info("Web服务已开启");
return true;
}
catch (Exception ex)
{
log.Error("WebService Open", ex);
return false;
}
}
/// <summary>
/// 关闭服务
/// </summary>
public static void Close()
{
if (_serviceHost != null)
_serviceHost.Close();
log.Info("Web服务已关闭");
}
}
/// <summary>
/// 获取小车的状态
/// </summary>
/// <param name="info"></param>
public static void GetAgvState(ref AgvInfo info)
{
bool rtn = CheckAgvOnline(ref info);
if (!rtn) return;
rtn = mir.Get_State(info.IP, info.Authorization, out int stateID, out string stateText, out int battery, out string missionText);
log.Debug(string.Format("{0}[{1}] Get_State{6} stateID={2}, stateText={3}, battery={4}, missionText={5}", info.Name, info.IP, stateID, stateText, battery, missionText, rtn));
if (rtn)
{
info.StateID = stateID;
info.StateText = stateText;
info.Battery = battery;
info.MissionText = missionText;
string ip = info.IP;
int idx = agvInfos.FindIndex(s => s.IP == ip);
if (idx > -1) AgvChanged?.Invoke(idx);
}
}
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);
if (rtn)
{
if (!info.IsOnline)
{
info.IsOnline = true;
string ip = info.IP;
int idx = agvInfos.FindIndex(s => s.IP == ip);
if (idx > -1) AgvOnline?.Invoke(idx);
rtn = mir.Get_IO_Modules(info.IP, info.Authorization, out string[] guid);
if (rtn) info.IOGuid = guid[0];
}
log.Debug(string.Format("{0}[{1}] 在线", info.Name, info.IP));
}
else
{
if (info.IsOnline)
{
info.IsOnline = false;
string ip = info.IP;
int idx = agvInfos.FindIndex(s => s.IP == ip);
if (idx > -1) AgvOnline?.Invoke(idx);
}
log.Debug(string.Format("{0}[{1}] 脱机", info.Name, info.IP));
}
return rtn;
}
}
}
......@@ -13,6 +13,12 @@ namespace BLL
{
private Timer timerCall;
public delegate void AgvChangedEvent(int agvIndex);
public event AgvChangedEvent AgvChanged;
public event AgvChangedEvent AgvOnline;
/// <summary>
/// 控制类
/// </summary>
......@@ -26,7 +32,7 @@ namespace BLL
/// </summary>
public void Start()
{
timerCall = new Timer(CallProcess, null, 0, 2000);
timerCall = new Timer(CallProcess, null, 0, 3000);
}
/// <summary>
......@@ -38,6 +44,7 @@ namespace BLL
}
private void CallProcess(object obj)
{
for (int i = 0; i < Common.agvInfos.Count; i++)
......@@ -48,17 +55,15 @@ namespace BLL
try
{
info.IsCall = true;
if (!info.IsOnline) continue; //脱机
CheckAgvOnline(ref info);
if (!info.IsOnline) continue; //脱机
GetAgvState(ref info);
if (!info.IsAuto) continue; //手动
if (info.CurrentJob == null)
{
info.CurrentJob = new StandbyJob();
}
else
{
info.CurrentJob = info.CurrentJob.Execute(info);
}
}
catch (Exception ex)
{
......@@ -70,5 +75,68 @@ namespace BLL
}
}
}
/// <summary>
/// 获取小车的状态
/// </summary>
/// <param name="info"></param>
private void GetAgvState(ref AgvInfo info)
{
if (!info.IsOnline) return;
bool rtn = Common.mir.Get_State(info.IP, info.Authorization, out int stateID, out string stateText, out int battery, out string missionText, out System.Drawing.PointF position);
Common.log.Debug(string.Format("{1} GetAgvState[return={0}] stateID={2}, stateText={3}, battery={4}, missionText={5}, position={6}", rtn, info.FullName, stateID, stateText, battery, missionText, position));
if (rtn)
{
info.StateID = stateID;
info.StateText = stateText;
info.Battery = battery;
info.MissionText = missionText;
info.Position = position;
string ip = info.IP;
int idx = Common.agvInfos.FindIndex(s => s.IP == ip);
if (idx > -1) AgvChanged?.Invoke(idx);
}
}
/// <summary>
/// 检查小车是否在线
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
private bool CheckAgvOnline(ref AgvInfo info)
{
bool rtn = Common.mir.CheckIP(info.IP);
if (rtn)
{
if (!info.IsOnline)
{
info.IsOnline = true;
string ip = info.IP;
int idx = Common.agvInfos.FindIndex(s => s.IP == ip);
if (idx > -1) AgvOnline?.Invoke(idx);
rtn = Common.mir.Get_IO_Modules(info.IP, info.Authorization, out string[] guid);
if (rtn) info.IOGuid = guid[0];
}
Common.log.Debug(string.Format("{0}[{1}] 在线", info.Name, info.IP));
}
else
{
if (info.IsOnline)
{
info.IsOnline = false;
string ip = info.IP;
int idx = Common.agvInfos.FindIndex(s => s.IP == ip);
if (idx > -1) AgvOnline?.Invoke(idx);
}
Common.log.Debug(string.Format("{0}[{1}] 脱机", info.Name, info.IP));
}
return rtn;
}
}
}
\ No newline at end of file
using System;
using Model;
using AGVControl_Steel;
using System.Collections.Generic;
namespace BLL
{
public class SteelManage
{
private List<SteelWork> oldSteelWork;
private List<SteelWork> newSteelWork;
public SteelManage()
{
oldSteelWork = new List<SteelWork>();
newSteelWork = new List<SteelWork>();
}
public int OldSteelWorkCount
{
get
{
return oldSteelWork.Count;
}
}
public int NewSteelWorkCount
{
get
{
return newSteelWork.Count;
}
}
public void OldSteelWorkAdd(string from)
{
int index = oldSteelWork.FindIndex(sw => sw.From == from);
if (index == -1)
{
SteelWork sw = new SteelWork() { From = from };
oldSteelWork.Add(sw);
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(Common.PATH_OLD_STEEL_WORK, content, System.Text.Encoding.UTF8);
}
Common.log.Debug("OldSteelWorkAdd(" + from + ") 添加旧钢板任务,保存到" + Common.PATH_OLD_STEEL_WORK);
}
public void OldSteelWorkDel(string from)
{
int index = oldSteelWork.FindIndex(sw => sw.From == from);
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(Common.PATH_OLD_STEEL_WORK, content, System.Text.Encoding.UTF8);
}
Common.log.Debug("OldSteelWorkDel(" + from + ") 旧钢板任务,保存到" + Common.PATH_OLD_STEEL_WORK);
}
public void OldSteelWorkLoad()
{
oldSteelWork = new List<SteelWork>();
if (!System.IO.File.Exists(Common.PATH_OLD_STEEL_WORK)) return;
string[] lines = System.IO.File.ReadAllLines(Common.PATH_OLD_STEEL_WORK, System.Text.Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
string[] arr = lines[i].Split(',');
SteelWork sw = new SteelWork() { From = arr[0], DateTime = Convert.ToDateTime(arr[1]) };
oldSteelWork.Add(sw);
}
Common.log.Debug("OldSteelWorkLoad() 旧钢板任务加载,来自" + Common.PATH_OLD_STEEL_WORK);
}
public bool FindOldSteelWork(string lineName)
{
int idx = oldSteelWork.FindIndex(s => s.From == lineName);
return idx > -1;
}
public void NewSteelWorkAdd(string from, string place)
{
int index = newSteelWork.FindIndex(sw => sw.From == from && sw.Place == place);
if (index == -1)
{
SteelWork sw = new SteelWork() { From = from, Place = place };
newSteelWork.Add(sw);
string[] content = new string[newSteelWork.Count];
for (int i = 0; i < content.Length; i++)
content[i] = newSteelWork[i].From + "," + newSteelWork[i].Place + "," + newSteelWork[i].DateTime.ToString();
System.IO.File.WriteAllLines(Common.PATH_NEW_STEEL_WORK, content, System.Text.Encoding.UTF8);
}
Common.log.Debug("NewSteelWorkAdd(" + from + "," + place + ") 添加新钢板任务,保存到" + Common.PATH_NEW_STEEL_WORK);
}
public void NewSteelWorkLoad()
{
newSteelWork = new List<SteelWork>();
if (!System.IO.File.Exists(Common.PATH_NEW_STEEL_WORK)) return;
string[] lines = System.IO.File.ReadAllLines(Common.PATH_NEW_STEEL_WORK, System.Text.Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
string[] arr = lines[i].Split(',');
SteelWork sw = new SteelWork() { From = arr[0], Place = arr[1], DateTime = Convert.ToDateTime(arr[2]) };
newSteelWork.Add(sw);
}
Common.log.Debug("NewSteelWorkLoad() 新钢板任务加载,来自" + Common.PATH_NEW_STEEL_WORK);
}
public Job GetSteelJob()
{
if (oldSteelWork.Count > 0)
{
return new TakeOldJob();
}
//else if (newSteelWork.Count > 0)
//{
// return new WashPointJob();
// return new StorageJob();
//}
else
return null;
}
}
}
\ No newline at end of file
......@@ -4,11 +4,12 @@ using System.Runtime.Serialization;
using System.ServiceModel.Activation;
using System.IO;
using AGVControl_Steel;
using System;
namespace BLL
namespace Webs
{
[ServiceContract(Name = "Services")]
internal interface IWebService
internal interface IWeb
{
[OperationContract]
[WebGet(UriTemplate = "StealAgv/takeOld?from={from}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
......@@ -28,7 +29,7 @@ namespace BLL
}
[DataContract]
public class Result
internal class Result
{
[DataMember]
public int Code { get; set; }
......@@ -40,30 +41,22 @@ namespace BLL
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single, IncludeExceptionDetailInFaults = true)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class WebService : IWebService
internal class Web : IWeb
{
//public delegate void UpdateLightEvent();
//public event UpdateLightEvent UpdateLight;
public WebService()
public Web()
{
}
public Result TakeOldGet(string from)
{
Common.log.Info("takeOld[GET] from=" + from);
Common.OldSteelWorkAdd(from.ToUpper());
Result res = new Result { Code = 0, Msg = "OK" };
return res;
return TakeOld(from);
}
public Result SendNewGet(string from, string list)
{
Common.log.Info("sendNew[GET] from=" + from + " placeList=" + list);
Result res = new Result { Code = 0, Msg = "OK" };
return res;
return SendNew(from, list);
}
public Result TakeOldPost(Stream info)
......@@ -71,11 +64,8 @@ namespace BLL
StreamReader sr = new StreamReader(info);
string s = sr.ReadToEnd();
Common.log.Info("takeOld[POST] " + s);
s = s.ToUpper().Replace("FROM=", "");
Common.OldSteelWorkAdd(s);
Result res = new Result { Code = 0, Msg = "OK" };
return res;
s = s.ToLower().Replace("from=", "");
return TakeOld(s);
}
public Result SendNewPost(Stream info)
......@@ -84,14 +74,123 @@ namespace BLL
string s = sr.ReadToEnd();
Common.log.Info("sendNew[POST] " + s);
Result res = new Result { Code = 0, Msg = "OK" };
s = s.ToLower();
string[] arr = s.Split('&');
arr[0] = arr[0].Replace("from=", "");
arr[1] = arr[1].Replace("placelist=", "");
return SendNew(arr[0], arr[1]);
}
private Result TakeOld(string from)
{
Result res;
from = from.ToUpper();
int index1 = Array.FindIndex(Common.LINE_NAME_4D, match => match == from);
int index2 = Array.FindIndex(Common.LINE_NAME_4C, match => match == from);
if (index1 == -1 && index2 == -1)
{
res = new Result { Code = -1, Msg = "Not find " + from };
}
else
{
Common.steelManage.OldSteelWorkAdd(from);
res = new Result { Code = 0, Msg = "OK" };
}
return res;
}
private Result SendNew(string from, string list)
{
from = from.ToLower();
int index = Array.FindIndex(Common.STORE_NAME, match => match == from);
if (index == -1)
{
return new Result { Code = -1, Msg = "Not find " + from };
}
else
{
list = list.ToUpper();
if (list == "EMPTYSHELFIN")
{
Common.steelManage.NewSteelWorkAdd(from, list);
return new Result { Code = 0, Msg = "OK" };
}
else if (list == "EMPTYSHELFLEAVE")
{
Common.steelManage.NewSteelWorkAdd(from, list);
return new Result { Code = 0, Msg = "OK" };
}
else
{
string[] arr = list.Split(',');
for (int i = 0; i < arr.Length; i++)
{
int index1 = Array.FindIndex(Common.LINE_NAME_4D, match => match == arr[i]);
int index2 = Array.FindIndex(Common.LINE_NAME_4C, match => match == arr[i]);
if (index1 == -1 && index2 == -1)
return new Result { Code = -2, Msg = "Not find " + arr[i] };
else
Common.steelManage.NewSteelWorkAdd(from, arr[i]);
}
return new Result { Code = 0, Msg = "OK" };
}
}
}
}
/// <summary>
/// Web服务器
/// </summary>
public class WebService
{
private WebServiceHost _serviceHost;
/// <summary>
/// 服务是否打开
/// </summary>
public bool IsOpen { private set; get; }
/// <summary>
/// 打开服务
/// </summary>
/// <param name="url"></param>
public void Open(string url)
{
try
{
Web service = new Web();
_serviceHost = new WebServiceHost(service, new Uri(url));
_serviceHost.Open();
Common.log.Info("Web服务已开启");
IsOpen = true;
}
catch (Exception ex)
{
Common.log.Error("WebService Open", ex);
IsOpen = false;
}
}
/// <summary>
/// 关闭服务
/// </summary>
public void Close()
{
if (_serviceHost != null)
_serviceHost.Close();
Common.log.Info("Web服务已关闭");
}
}
}
......@@ -39,15 +39,14 @@ namespace Model
}
else if (chargeStep.IsEqual(ChargeStep.Charging))
{
Common.GetAgvState(ref info);
if (info.Battery == Common.AGV_BATTERY_MAX)
if (info.Battery == info.BatteryMax)
{
chargeStep.NextStep(ChargeStep.End);
chargeStep.Msg = info.FullName + "电量达到" + Common.AGV_BATTERY_MAX + ",充电工作结束";
chargeStep.Msg = info.FullName + "电量达到" + info.BatteryMax + ",充电工作结束";
}
else if (info.Battery > Common.AGV_BATTERY_MIN)
else if (info.Battery > info.BatteryMin)
{
Job job = Common.GetJob();
Job job = Common.steelManage.GetSteelJob();
if (job != null) return job;
}
}
......@@ -63,36 +62,42 @@ namespace Model
private void None(AgvInfo info)
{
if (info.Place.StartsWith("4C")) //4C车间需要到4D车间充电
if (info.IsSelfWorkshop())
{
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, Common.MISSION_MOVE_4C_4D, out id);
if (info.Workshop == Common.WORKSHOP_4D)
mission = Common.MISSION_CHARGE_4D;
else if (info.Workshop == Common.WORKSHOP_4C)
mission = Common.MISSION_CHARGE_4C;
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, mission, out id);
if (rtn)
{
chargeStep.NextStep(ChargeStep.WaitWorkshopDoor);
chargeStep.Msg = info.FullName + "在4C车间,去充电位,先过4D门";
chargeStep.NextStep(ChargeStep.WaitChargeStation);
chargeStep.Msg = info.FullName + "在" + info.Workshop + "车间,去充电位";
}
else
{
chargeStep.Msg = info.FullName + "发送" + Common.MISSION_MOVE_4C_4D + "任务失败";
chargeStep.Msg = info.FullName + "发送" + mission + "任务失败";
}
}
else if (info.Place.StartsWith("4D"))
else
{
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, Common.MISSION_CHARGE, out id);
if (info.Workshop == Common.WORKSHOP_4D)
mission = Common.MISSION_MOVE_4C_4D;
else if (info.Workshop == Common.WORKSHOP_4C)
mission = Common.MISSION_MOVE_4D_4C;
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, mission, out id);
if (rtn)
{
chargeStep.NextStep(ChargeStep.WaitChargeStation);
chargeStep.Msg = info.FullName + "在4D车间,去充电位";
chargeStep.NextStep(ChargeStep.WaitWorkshopDoor);
chargeStep.Msg = info.FullName + "在" + info.Workshop + "车间,先过车间门";
}
else
{
chargeStep.Msg = info.FullName + "发送" + Common.MISSION_CHARGE + "任务失败";
chargeStep.Msg = info.FullName + "发送" + mission + "任务失败";
}
}
else
{
Common.log.Error(string.Format("ChargeJob Error {0} Place={1}", info.FullName, info.Place));
}
}
private void WaitWorkshopDoor(AgvInfo info)
......@@ -102,15 +107,20 @@ namespace Model
{
if (state == MissionState.Done.ToString())
{
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, Common.MISSION_CHARGE, out id);
if (info.Workshop == Common.WORKSHOP_4D)
mission = Common.MISSION_CHARGE_4D;
else if (info.Workshop == Common.WORKSHOP_4C)
mission = Common.MISSION_CHARGE_4C;
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, mission, out id);
if (rtn)
{
chargeStep.NextStep(ChargeStep.WaitChargeStation);
chargeStep.Msg = info.FullName + "在4D车间,去充电位";
chargeStep.Msg = info.FullName + "在" + info.Workshop + "车间,去充电位";
}
else
{
chargeStep.Msg = info.FullName + "发送" + Common.MISSION_CHARGE + "任务失败";
chargeStep.Msg = info.FullName + "发送" + mission + "任务失败";
}
}
else if (state == MissionState.Aborted.ToString())
......

\ No newline at end of file
......@@ -16,16 +16,11 @@ namespace Model
{
if (standbyStep.IsEqual(StandbyStep.None))
{
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, Common.MISSION_MOVE_STANDBY, out id);
if (rtn)
{
standbyStep.NextStep(StandbyStep.WaitStandby);
standbyStep.Msg = info.FullName + "回待机位";
}
else
{
standbyStep.Msg = info.FullName + "发送" + Common.MISSION_MOVE_STANDBY + "任务失败";
}
None(info);
}
else if (standbyStep.IsEqual(StandbyStep.WaitWorkshopDoor))
{
WaitWorkshopDoor(info);
}
else if (standbyStep.IsEqual(StandbyStep.WaitStandby))
{
......@@ -37,9 +32,6 @@ namespace Model
standbyStep.NextStep(StandbyStep.End);
standbyStep.Msg = info.FullName + "已在待机位";
}
else if (state == MissionState.Executing.ToString())
{
}
else if (state == MissionState.Aborted.ToString())
{
standbyStep.Msg = info.FullName + "任务状态" + MissionState.Aborted.ToString();
......@@ -52,8 +44,15 @@ namespace Model
}
else if (standbyStep.IsEqual(StandbyStep.End))
{
Job job = Common.GetJob();
if (job != null) return job;
if (info.Battery <= info.BatteryMin)
{
return new ChargeJob();
}
else
{
Job job = Common.steelManage.GetSteelJob();
if (job != null) return job;
}
}
return this;
}
......@@ -61,9 +60,86 @@ namespace Model
private void None(AgvInfo info)
{
if (info.IsSelfWorkshop())
{
if (info.Workshop == Common.WORKSHOP_4D)
mission = Common.MISSION_STANDBY_4D;
else if (info.Workshop == Common.WORKSHOP_4C)
mission = Common.MISSION_STANDBY_4C;
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, mission, out id);
if (rtn)
{
standbyStep.NextStep(StandbyStep.WaitStandby);
standbyStep.Msg = info.FullName + "回待机位";
}
else
{
standbyStep.Msg = info.FullName + "发送" + Common.MISSION_STANDBY_4D + "任务失败";
}
}
else
{
if (info.Workshop == Common.WORKSHOP_4D)
mission = Common.MISSION_MOVE_4C_4D;
else if (info.Workshop == Common.WORKSHOP_4C)
mission = Common.MISSION_MOVE_4D_4C;
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, mission, out id);
if (rtn)
{
standbyStep.NextStep(StandbyStep.WaitWorkshopDoor);
standbyStep.Msg = info.FullName + "在" + info.Workshop + "车间,先过车间门";
}
else
{
standbyStep.Msg = info.FullName + "发送" + mission + "任务失败";
}
}
}
private void WaitWorkshopDoor(AgvInfo info)
{
rtn = Common.mir.Get_MissionState_Fleet(info.Authorization, id, out string state);
if (rtn)
{
if (state == MissionState.Done.ToString())
{
if (info.Workshop == Common.WORKSHOP_4D)
mission = Common.MISSION_STANDBY_4D;
else if (info.Workshop == Common.WORKSHOP_4C)
mission = Common.MISSION_STANDBY_4C;
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, mission, out id);
if (rtn)
{
standbyStep.NextStep(StandbyStep.WaitStandby);
standbyStep.Msg = info.FullName + "回待机位";
}
else
{
standbyStep.Msg = info.FullName + "发送" + Common.MISSION_STANDBY_4D + "任务失败";
}
}
else if (state == MissionState.Aborted.ToString())
{
standbyStep.Msg = info.FullName + "任务状态" + MissionState.Aborted.ToString();
}
}
else
{
standbyStep.Msg = info.FullName + "获取任务状态id[" + id + "]失败";
}
}
private enum StandbyStep
{
None,
WaitWorkshopDoor,
WaitStandby,
End
}
......
......@@ -2,14 +2,14 @@
namespace Model
{
public class MoveWashJob : Job
public class StorageJob : Job
{
private string id;
private JobStep<MoveWashStep> moveWashStep;
public MoveWashJob()
private JobStep<StorageStep> storageStep;
public StorageJob()
{
moveWashStep = new JobStep<MoveWashStep>(MoveWashStep.None);
storageStep = new JobStep<StorageStep>(StorageStep.None);
}
public override Job Execute(AgvInfo info)
......@@ -17,9 +17,10 @@ namespace Model
throw new System.NotImplementedException();
}
private enum MoveWashStep
private enum StorageStep
{
None
}
}
}
......@@ -6,8 +6,6 @@ namespace Model
{
private string id;
private JobStep<TakeOldStep> takeOldStep;
private int currentCount;
private const int STEEL_COUNT_MAX = 6;
public TakeOldJob()
{
......@@ -16,39 +14,22 @@ namespace Model
public override Job Execute(AgvInfo info)
{
string name;
if (takeOldStep.IsEqual(TakeOldStep.None))
{
currentCount = 0;
info.ClearSteelCount();
takeOldStep.NextStep(TakeOldStep.FindLine);
}
else if (takeOldStep.IsEqual(TakeOldStep.FindLine))
{
if (currentCount == STEEL_COUNT_MAX)
{
return new MoveWashJob();
}
else if (Common.oldSteelWork.Count == 0)
if (info.IsSteelFull())
{
return new MoveWashJob();
return new WashPointJob();
}
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;
}
}
rtn = FindLine(info);
if (!rtn)
return new WashPointJob();
}
}
else if (takeOldStep.IsEqual(TakeOldStep.MoveLine))
......@@ -61,9 +42,6 @@ namespace Model
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();
......@@ -78,11 +56,51 @@ namespace Model
return this;
}
private bool FindLine(AgvInfo info)
{
string name = null;
if (info.Workshop == Common.WORKSHOP_4D)
{
for (int i = 0; i < Common.LINE_NAME_4D.Length; i++)
{
name = Common.LINE_NAME_4D[i];
if (Common.steelManage.FindOldSteelWork(name))
break;
}
}
else if (info.Workshop == Common.WORKSHOP_4C)
{
for (int i = 0; i < Common.LINE_NAME_4C.Length; i++)
{
name = Common.LINE_NAME_4C[i];
if (Common.steelManage.FindOldSteelWork(name))
break;
}
}
if (name == null)
{
return false;
}
else
{
info.Place = name;
name = "MoveSteel" + name;
Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, name, out id);
takeOldStep.NextStep(TakeOldStep.MoveLine);
takeOldStep.Msg = info.FullName + "发送任务" + name;
info.SteelCountAdd();
return true;
}
}
private enum TakeOldStep
{
None,
FindLine,
MoveLine
MoveLine,
MoveWash,
End
}
}
}
using AGVControl_Steel;
namespace Model
{
public class WashPointJob : Job
{
private string id;
private JobStep<WashPointStep> washPointStep;
public WashPointJob()
{
washPointStep = new JobStep<WashPointStep>(WashPointStep.None);
}
public override Job Execute(AgvInfo info)
{
if (washPointStep.IsEqual(WashPointStep.None))
{
if (info.Workshop == Common.WORKSHOP_4D)
mission = Common.MISSION_MOVE_WASH_4D;
else if (info.Workshop == Common.WORKSHOP_4C)
mission = Common.MISSION_MOVE_WASH_4C;
rtn = Common.mir.Add_Mission_Fleet(info.FleetID, info.Authorization, mission, out id);
if (rtn)
{
washPointStep.NextStep(WashPointStep.MoveWash);
washPointStep.Msg = info.FullName + "去"+ info.Workshop + "清洗点";
}
else
{
washPointStep.Msg = info.FullName + "发送" + mission + "任务失败";
}
}
else if (washPointStep.IsEqual(WashPointStep.MoveWash))
{
rtn = Common.mir.Get_MissionState_Fleet(info.Authorization, id, out string state);
if (rtn)
{
if (state == MissionState.Done.ToString())
{
washPointStep.NextStep(WashPointStep.End);
washPointStep.Msg = info.FullName + "已在清洗点";
}
else if (state == MissionState.Aborted.ToString())
{
washPointStep.Msg = info.FullName + "任务状态" + MissionState.Aborted.ToString();
}
}
else
{
washPointStep.Msg = info.FullName + "获取任务状态id[" + id + "]失败";
}
}
else if (washPointStep.IsEqual(WashPointStep.End))
{
return new StandbyJob();
}
return this;
}
private enum WashPointStep
{
None,
MoveWash,
End
}
}
}
using System;
using AGVControl_Steel;
namespace Model
{
......@@ -8,6 +9,11 @@ namespace Model
public class AgvInfo
{
/// <summary>
/// 小车当前已有的钢板数量
/// </summary>
private int currSteelCount = 0;
/// <summary>
/// 小车名称
/// </summary>
public string Name { set; get; } = "";
......@@ -34,10 +40,14 @@ namespace Model
/// </summary>
public string Authorization { set; get; } = "";
/// <summary>
/// 地点
/// 当前位置
/// </summary>
public string Place { set; get; } = "";
/// <summary>
/// 车间
/// </summary>
public string Workshop { set; get; } = "";
/// <summary>
/// 是否自动使用
/// </summary>
public bool IsAuto { set; get; } = false;
......@@ -50,6 +60,18 @@ namespace Model
/// </summary>
public int Battery { set; get; } = 0;
/// <summary>
/// AGV最大充电电量
/// </summary>
public int BatteryMax { set; get; } = 0;
/// <summary>
/// AGV最低电量,小于此值必须充电
/// </summary>
public int BatteryMin { set; get; } = 0;
/// <summary>
/// 小车坐标位置
/// </summary>
public System.Drawing.PointF Position { set; get; }
/// <summary>
/// 任务发送
/// </summary>
public string TaskSend { set; get; } = "";
......@@ -88,9 +110,57 @@ namespace Model
return arr;
}
/// <summary>
/// 是否在自己的车间里面
/// </summary>
/// <returns></returns>
public bool IsSelfWorkshop()
{
if (Position.Y < 55)
{
if (Workshop == Common.WORKSHOP_4D)
return true;
else if (Workshop == Common.WORKSHOP_4C)
return false;
}
else if (Position.Y > 62)
{
if (Workshop == Common.WORKSHOP_4D)
return false;
else if (Workshop == Common.WORKSHOP_4C)
return true;
}
return false;
}
/// <summary>
/// 钢板是否已放满
/// </summary>
/// <returns></returns>
public bool IsSteelFull()
{
if (currSteelCount >= 6)
return true;
else
return false;
}
/// <summary>
/// 钢板数量增加
/// </summary>
public void SteelCountAdd()
{
currSteelCount++;
}
/// <summary>
/// 钢板数量清零
/// </summary>
public void ClearSteelCount()
{
currSteelCount = 0;
}
}
......
......@@ -28,7 +28,7 @@ namespace Model
public abstract Job Execute(AgvInfo info);
internal bool rtn;
internal string mission;
}
}
......@@ -431,17 +431,19 @@ namespace Model
/// <param name="stateText"></param>
/// <param name="battery"></param>
/// <param name="missionText"></param>
/// <param name="position"></param>
/// <returns></returns>
public bool Get_State(string ip, string authorization, out int stateID, out string stateText, out int battery, out string missionText)
public bool Get_State(string ip, string authorization, out int stateID, out string stateText, out int battery, out string missionText, out System.Drawing.PointF position)
{
stateID = -1;
stateText = "";
battery = 0;
missionText = "";
position = new System.Drawing.PointF();
try
{
string url = "http://" + ip + "/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text";
string url = "http://" + ip + "/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text,position";
string json = HttpGet(url, ip, authorization);
if (string.IsNullOrWhiteSpace(json)) return false;
......@@ -452,6 +454,9 @@ namespace Model
stateID = Convert.ToInt32(dic["state_id"].ToString());
stateText = dic["state_text"].ToString();
missionText = dic["mission_text"].ToString();
Dictionary<string, object> tt = (Dictionary<string, object>)dic["position"];
position.X = Convert.ToSingle(tt["x"]);
position.Y = Convert.ToSingle(tt["y"]);
string s = dic["battery_percentage"].ToString();
float f = Convert.ToSingle(s);
battery = Convert.ToInt32(f);
......
......@@ -4,30 +4,16 @@ namespace AGVControl_Steel
{
public class SteelWork
{
public string from { set; get; }
public string placeList { set; get; }
public DateTime dateTime { set; get; }
public string From { set; get; }
public string Place { 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)
public SteelWork()
{
this.from = from;
this.dateTime = Convert.ToDateTime(dateTime);
DateTime = DateTime.Now;
}
}
}
\ No newline at end of file
......@@ -19,12 +19,14 @@ namespace AGVControl_Steel
Common.log = log4net.LogManager.GetLogger("AGVControl_Steel");
Common.log.Info("=====程序开始=====");
ReadConfig();
Common.steelManage = new BLL.SteelManage();
Common.steelManage.OldSteelWorkLoad();
Common.steelManage.NewSteelWorkLoad();
Common.control = new BLL.Control();
Common.mir = new Model.MiR_API { FleetIP = Common.appConfig.AppSettings.Settings["FLEET_IP"].Value, MissionList = Common.agvMissions };
Application.Run(new FrmMain());
Common.WebService.Close();
Common.control.Stop();
Common.log.Info("=====程序结束=====\r\n");
}
......@@ -57,7 +59,9 @@ namespace AGVControl_Steel
Name = str[1],
IP = str[2],
Authorization = str[3],
IsAuto = Convert.ToBoolean(isUse)
IsAuto = Convert.ToBoolean(isUse),
BatteryMax = Convert.ToInt32(Common.appConfig.AppSettings.Settings["AGV_BATTERY_MAX"].Value),
BatteryMin = Convert.ToInt32(Common.appConfig.AppSettings.Settings["AGV_BATTERY_MIN"].Value)
};
Common.agvInfos.Add(info);
}
......@@ -74,11 +78,21 @@ namespace AGVControl_Steel
}
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();
Common.STORE_NAME = Common.appConfig.AppSettings.Settings["Store"].Value.Split(',');
string id = Common.appConfig.AppSettings.Settings["4D_AGV"].Value;
int idx = Common.agvInfos.FindIndex(match => match.FleetID == id);
if (idx > -1) Common.agvInfos[idx].Workshop = Common.WORKSHOP_4D;
id = Common.appConfig.AppSettings.Settings["4C_AGV"].Value;
idx = Common.agvInfos.FindIndex(match => match.FleetID == id);
if (idx > -1) Common.agvInfos[idx].Workshop = Common.WORKSHOP_4C;
}
catch (Exception ex)
......
......@@ -29,6 +29,10 @@
private void InitializeComponent()
{
this.DgvName = new System.Windows.Forms.DataGridView();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.button1 = new System.Windows.Forms.Button();
this.LblWeb = new System.Windows.Forms.Label();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
......@@ -36,10 +40,6 @@
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column4 = new System.Windows.Forms.DataGridViewButtonColumn();
this.tabControl1 = new System.Windows.Forms.TabControl();
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();
this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
......@@ -68,6 +68,52 @@
this.DgvName.TabIndex = 0;
this.DgvName.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DgvName_CellContentClick);
//
// tabControl1
//
this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Location = new System.Drawing.Point(12, 98);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(722, 340);
this.tabControl1.TabIndex = 1;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.button1);
this.tabPage2.Controls.Add(this.LblWeb);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(714, 314);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "状态";
this.tabPage2.UseVisualStyleBackColor = true;
//
// 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);
//
// 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(150, 30);
this.LblWeb.TabIndex = 0;
this.LblWeb.Text = "WebService Close";
this.LblWeb.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// Column1
//
this.Column1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
......@@ -98,7 +144,7 @@
// Column6
//
this.Column6.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Column6.HeaderText = "任务文本";
this.Column6.HeaderText = "任务状态";
this.Column6.Name = "Column6";
this.Column6.ReadOnly = true;
this.Column6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
......@@ -128,52 +174,6 @@
this.Column4.Name = "Column4";
this.Column4.ReadOnly = true;
//
// tabControl1
//
this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Location = new System.Drawing.Point(12, 98);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(722, 340);
this.tabControl1.TabIndex = 1;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.button1);
this.tabPage2.Controls.Add(this.LblWeb);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(714, 314);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "状态";
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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
......@@ -184,6 +184,7 @@
this.Name = "FrmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "钢网AGV调度";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing);
this.Load += new System.EventHandler(this.FrmMain_Load);
((System.ComponentModel.ISupportInitialize)(this.DgvName)).EndInit();
this.tabControl1.ResumeLayout(false);
......@@ -195,6 +196,10 @@
#endregion
private System.Windows.Forms.DataGridView DgvName;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.Label LblWeb;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
......@@ -202,10 +207,6 @@
private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
private System.Windows.Forms.DataGridViewTextBoxColumn Column7;
private System.Windows.Forms.DataGridViewButtonColumn Column4;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.Label LblWeb;
private System.Windows.Forms.Button button1;
}
}
......@@ -13,6 +13,8 @@ namespace AGVControl_Steel
{
public partial class FrmMain : Form
{
private Webs.WebService webService;
public FrmMain()
{
InitializeComponent();
......@@ -31,8 +33,10 @@ namespace AGVControl_Steel
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;
webService = new Webs.WebService();
webService.Open(Common.appConfig.AppSettings.Settings["WebService"].Value);
LblWeb.BackColor = webService.IsOpen ? Color.Lime : Color.Red;
LblWeb.Text = webService.IsOpen ? "WebService Open" : "WebService Close";
for (int i = 0; i < Common.agvInfos.Count; i++)
{
......@@ -41,11 +45,16 @@ namespace AGVControl_Steel
DgvName.Rows[i].HeaderCell.Value = (i + 1).ToString();
}
Common.AgvChanged += Control_AgvChanged;
Common.AgvOnline += Control_AgvOnline;
Common.control.AgvChanged += Control_AgvChanged;
Common.control.AgvOnline += Control_AgvOnline;
Common.control.Start();
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
webService.Close();
}
private void DgvName_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == -1) return;
......@@ -64,7 +73,11 @@ namespace AGVControl_Steel
private void button1_Click(object sender, EventArgs e)
{
Common.GetJob();
//Common.GetJob();
}
}
}
......@@ -40,8 +40,9 @@
<add key="FLEET_IP" value="10.85.199.3" />
<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="AGV_BATTERY_MIN" value="60"/>
<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"/>
<add key="Store" value="wash,storage"/>
</appSettings>
</configuration>
\ No newline at end of file
......@@ -24,51 +24,24 @@
关闭服务
</summary>
</member>
<member name="T:AGVControl_Steel.Common">
<summary>
公共类
</summary>
</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:BLL.Control.GetAgvState(Model.AgvInfo@)">
<summary>
获取小车的状态
</summary>
<param name="info"></param>
</member>
<member name="M:AGVControl_Steel.Common.CheckAgvOnline(Model.AgvInfo@)">
<member name="M:BLL.Control.CheckAgvOnline(Model.AgvInfo@)">
<summary>
检查小车是否在线
</summary>
<param name="info"></param>
<returns></returns>
</member>
<member name="T:AGVControl_Steel.Common">
<summary>
公共类
</summary>
</member>
<member name="T:AGVControl_Steel.MissionState">
<summary>
任务执行的状态
......@@ -221,7 +194,7 @@
<param name="authorization"></param>
<param name="id"></param>
</member>
<member name="M:Model.MiR_API.Get_State(System.String,System.String,System.Int32@,System.String@,System.Int32@,System.String@)">
<member name="M:Model.MiR_API.Get_State(System.String,System.String,System.Int32@,System.String@,System.Int32@,System.String@,System.Drawing.PointF@)">
<summary>
获取当前小车状态
</summary>
......@@ -231,6 +204,7 @@
<param name="stateText"></param>
<param name="battery"></param>
<param name="missionText"></param>
<param name="position"></param>
<returns></returns>
</member>
<member name="M:Model.MiR_API.State_Ready(System.String,System.String)">
......@@ -325,6 +299,11 @@
小车信息
</summary>
</member>
<member name="F:Model.AgvInfo.currSteelCount">
<summary>
小车当前已有的钢板数量
</summary>
</member>
<member name="P:Model.AgvInfo.Name">
<summary>
小车名称
......@@ -352,7 +331,7 @@
</member>
<member name="P:Model.AgvInfo.Place">
<summary>
地点
当前车间位置,4C/4D
</summary>
</member>
<member name="P:Model.AgvInfo.IsAuto">
......@@ -370,6 +349,16 @@
电量百分比
</summary>
</member>
<member name="P:Model.AgvInfo.BatteryMax">
<summary>
AGV最大充电电量
</summary>
</member>
<member name="P:Model.AgvInfo.BatteryMin">
<summary>
AGV最低电量,小于此值必须充电
</summary>
</member>
<member name="P:Model.AgvInfo.TaskSend">
<summary>
任务发送
......@@ -474,5 +463,26 @@
</summary>
<param name="info"></param>
</member>
<member name="T:Webs.WebService">
<summary>
Web服务器
</summary>
</member>
<member name="P:Webs.WebService.IsOpen">
<summary>
服务是否打开
</summary>
</member>
<member name="M:Webs.WebService.Open(System.String)">
<summary>
打开服务
</summary>
<param name="url"></param>
</member>
<member name="M:Webs.WebService.Close">
<summary>
关闭服务
</summary>
</member>
</members>
</doc>
MoveSteelD15,002b3e45-f105-11ea-a03e-94c691a7387d
\ No newline at end of file
MoveSteelC1,
MoveSteelC2,
MoveSteelC3,
MoveSteelC4,
MoveSteelC5,
MoveSteelC6,
MoveSteelC7,
MoveSteelC8,
MoveSteelC9,
MoveSteelC10,
MoveSteelD1,e9ed94bf-f2ac-11ea-8452-94c691a7387d
MoveSteelD2,04e5690f-f2ad-11ea-8452-94c691a7387d
MoveSteelD3,1d3f9b5a-f2ad-11ea-8452-94c691a7387d
MoveSteelD4,55bf620d-f2ad-11ea-8452-94c691a7387d
MoveSteelD5,6c1fe859-f2ad-11ea-8452-94c691a7387d
MoveSteelD6,8498ea0b-f2ad-11ea-8452-94c691a7387d
MoveSteelD8,ba683168-f2ad-11ea-8452-94c691a7387d
MoveSteelD9,de7f8051-f2ad-11ea-8452-94c691a7387d
MoveSteelD10,f81944b7-f2ad-11ea-8452-94c691a7387d
MoveSteelD11,0a0b0df1-f2ae-11ea-8452-94c691a7387d
MoveSteelD12,201e368d-f2ae-11ea-8452-94c691a7387d
MoveSteelD14,445106a1-f2ae-11ea-8452-94c691a7387d
MoveSteelD15,002b3e45-f105-11ea-a03e-94c691a7387d
MoveSteelD16,15a766ac-f2a2-11ea-8452-94c691a7387d
Move4CWash,691e75ab-f2b0-11ea-8452-94c691a7387d
Move4DWash,e52ae766-f2ab-11ea-8452-94c691a7387d
Move4CStandby,2dd387ce-f2b0-11ea-8452-94c691a7387d
Move4DStandby,21ca7ffe-f29e-11ea-8452-94c691a7387d
AutoCharge4C,8ed7b459-f2b0-11ea-8452-94c691a7387d
AutoCharge4D,2f0a31b1-f2ab-11ea-8452-94c691a7387d
MoveDoor-4C-4D,d67f31c8-ca7e-11ea-9a66-94c691a7387d
MoveDoor-4D-4C,fd6e26ac-c1bf-11ea-9a66-94c691a7387d
MoveStorage,418c9064-f2ac-11ea-8452-94c691a7387d
\ No newline at end of file
[2020-09-07 16:02:51,071][1][AGVControl_Steel:20]INFO =====程序开始=====
[2020-09-07 16:02:51,224][1][AGVControl_Steel:64]INFO 读取配置文件 D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\bin\Debug\Config\AgvName.csv
[2020-09-07 16:02:51,225][1][AGVControl_Steel:75]INFO 读取配置文件 D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\bin\Debug\Config\AgvMission.csv
[2020-09-07 16:02:53,814][1][AGVControl_Steel:67]ERROR WebService Open
System.ServiceModel.AddressAccessDeniedException: HTTP 无法注册 URL http://+:8088/。进程不具有此命名空间的访问权限(有关详细信息,请参见 http://go.microsoft.com/fwlink/?LinkId=70353)。 ---> System.Net.HttpListenerException: 拒绝访问。
在 System.Net.HttpListener.AddAllPrefixes()
在 System.Net.HttpListener.Start()
在 System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
--- 内部异常堆栈跟踪的结尾 ---
在 System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
在 System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
在 System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
在 System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
在 AGVControl_Steel.Common.WebService.Open(String url) 位置 D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\BLL\Common.cs:行号 67
[2020-09-01 19:14:29,921][1][AGVControl_Steel:20]INFO =====程序开始=====
[2020-09-01 19:14:29,952][1][AGVControl_Steel:63]INFO 读取配置文件 D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\bin\Debug\Config\AgvName.csv
[2020-09-01 19:14:29,953][1][AGVControl_Steel:38]INFO 读取配置文件 D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl_Steel\AGVControl_Steel\bin\Debug\Config\AgvMission.csv
[2020-09-01 19:14:29,974][5][AGVControl_Steel:114]DEBUG 11号_1762[10.85.199.82] 在线
[2020-09-01 19:14:30,436][5][AGVControl_Steel:84]DEBUG 11号_1762[10.85.199.82] Get_StateTrue stateID=5, stateText=Executing, battery=33, missionText=正在移动至 '4cshelf8'(距离目标 19.899999999999999 米)
[2020-09-01 19:14:30,442][5][AGVControl_Steel:114]DEBUG 13号_1766[10.85.199.84] 在线
[2020-09-01 19:14:30,536][5][AGVControl_Steel:84]DEBUG 13号_1766[10.85.199.84] Get_StateTrue stateID=12, stateText=Error, battery=38, missionText=正在移动至 '4DshelfE'(距离目标 6.9 米)
[2020-09-01 19:14:31,976][4][AGVControl_Steel:114]DEBUG 11号_1762[10.85.199.82] 在线
[2020-09-01 19:14:32,004][4][AGVControl_Steel:84]DEBUG 11号_1762[10.85.199.82] Get_StateTrue stateID=5, stateText=Executing, battery=33, missionText=正在移动至 '4cshelf8'(距离目标 19.399999999999999 米)
[2020-09-01 19:14:32,289][4][AGVControl_Steel:114]DEBUG 13号_1766[10.85.199.84] 在线
[2020-09-01 19:14:32,474][4][AGVControl_Steel:84]DEBUG 13号_1766[10.85.199.84] Get_StateTrue stateID=12, stateText=Error, battery=38, missionText=正在移动至 '4DshelfE'(距离目标 6.9 米)
[2020-09-01 19:14:33,986][7][AGVControl_Steel:114]DEBUG 11号_1762[10.85.199.82] 在线
[2020-09-01 19:14:34,033][7][AGVControl_Steel:84]DEBUG 11号_1762[10.85.199.82] Get_StateTrue stateID=5, stateText=Executing, battery=33, missionText=正在移动至 '4cshelf8'(距离目标 18.699999999999999 米)
[2020-09-01 19:14:34,132][7][AGVControl_Steel:114]DEBUG 13号_1766[10.85.199.84] 在线
[2020-09-01 19:14:34,327][7][AGVControl_Steel:84]DEBUG 13号_1766[10.85.199.84] Get_StateTrue stateID=12, stateText=Error, battery=38, missionText=正在移动至 '4DshelfE'(距离目标 6.9 米)
[2020-09-01 19:14:35,997][4][AGVControl_Steel:114]DEBUG 11号_1762[10.85.199.82] 在线
[2020-09-01 19:14:36,022][4][AGVControl_Steel:84]DEBUG 11号_1762[10.85.199.82] Get_StateTrue stateID=5, stateText=Executing, battery=33, missionText=正在移动至 '4cshelf8'(距离目标 18 米)
[2020-09-01 19:14:36,026][4][AGVControl_Steel:114]DEBUG 13号_1766[10.85.199.84] 在线
[2020-09-01 19:14:36,049][4][AGVControl_Steel:84]DEBUG 13号_1766[10.85.199.84] Get_StateTrue stateID=12, stateText=Error, battery=38, missionText=正在移动至 '4DshelfE'(距离目标 6.9 米)
[2020-09-01 19:14:36,280][1][AGVControl_Steel:28]INFO =====程序结束=====
[2020-09-01 19:14:30,013][5][MiR_API:677]INFO [GET]URL:http://10.85.199.82/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text
[2020-09-01 19:14:30,429][5][MiR_API:699]INFO Return:{ "battery_percentage": 33.0, "mission_text": "\u6b63\u5728\u79fb\u52a8\u81f3 '4cshelf8'\uff08\u8ddd\u79bb\u76ee\u6807 19.899999999999999 \u7c73\uff09", "state_id": 5, "state_text": "Executing", "user_prompt": null}
[2020-09-01 19:14:30,442][5][MiR_API:677]INFO [GET]URL:http://10.85.199.84/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text
[2020-09-01 19:14:30,535][5][MiR_API:699]INFO Return:{ "battery_percentage": 38.400001525878906, "mission_text": "\u6b63\u5728\u79fb\u52a8\u81f3 '4DshelfE'\uff08\u8ddd\u79bb\u76ee\u6807 6.9 \u7c73\uff09", "state_id": 12, "state_text": "Error", "user_prompt": null}
[2020-09-01 19:14:31,976][4][MiR_API:677]INFO [GET]URL:http://10.85.199.82/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text
[2020-09-01 19:14:32,003][4][MiR_API:699]INFO Return:{ "battery_percentage": 33.0, "mission_text": "\u6b63\u5728\u79fb\u52a8\u81f3 '4cshelf8'\uff08\u8ddd\u79bb\u76ee\u6807 19.399999999999999 \u7c73\uff09", "state_id": 5, "state_text": "Executing", "user_prompt": null}
[2020-09-01 19:14:32,289][4][MiR_API:677]INFO [GET]URL:http://10.85.199.84/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text
[2020-09-01 19:14:32,474][4][MiR_API:699]INFO Return:{ "battery_percentage": 38.400001525878906, "mission_text": "\u6b63\u5728\u79fb\u52a8\u81f3 '4DshelfE'\uff08\u8ddd\u79bb\u76ee\u6807 6.9 \u7c73\uff09", "state_id": 12, "state_text": "Error", "user_prompt": null}
[2020-09-01 19:14:33,986][7][MiR_API:677]INFO [GET]URL:http://10.85.199.82/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text
[2020-09-01 19:14:34,033][7][MiR_API:699]INFO Return:{ "battery_percentage": 32.900001525878906, "mission_text": "\u6b63\u5728\u79fb\u52a8\u81f3 '4cshelf8'\uff08\u8ddd\u79bb\u76ee\u6807 18.699999999999999 \u7c73\uff09", "state_id": 5, "state_text": "Executing", "user_prompt": null}
[2020-09-01 19:14:34,132][7][MiR_API:677]INFO [GET]URL:http://10.85.199.84/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text
[2020-09-01 19:14:34,326][7][MiR_API:699]INFO Return:{ "battery_percentage": 38.400001525878906, "mission_text": "\u6b63\u5728\u79fb\u52a8\u81f3 '4DshelfE'\uff08\u8ddd\u79bb\u76ee\u6807 6.9 \u7c73\uff09", "state_id": 12, "state_text": "Error", "user_prompt": null}
[2020-09-01 19:14:35,997][4][MiR_API:677]INFO [GET]URL:http://10.85.199.82/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text
[2020-09-01 19:14:36,022][4][MiR_API:699]INFO Return:{ "battery_percentage": 32.900001525878906, "mission_text": "\u6b63\u5728\u79fb\u52a8\u81f3 '4cshelf8'\uff08\u8ddd\u79bb\u76ee\u6807 18 \u7c73\uff09", "state_id": 5, "state_text": "Executing", "user_prompt": null}
[2020-09-01 19:14:36,026][4][MiR_API:677]INFO [GET]URL:http://10.85.199.84/api/v2.0.0/status?whitelist=state_id,state_text,battery_percentage,mission_text
[2020-09-01 19:14:36,049][4][MiR_API:699]INFO Return:{ "battery_percentage": 38.400001525878906, "mission_text": "\u6b63\u5728\u79fb\u52a8\u81f3 '4DshelfE'\uff08\u8ddd\u79bb\u76ee\u6807 6.9 \u7c73\uff09", "state_id": 12, "state_text": "Error", "user_prompt": null}
22eefbcbb33c48fe4282997d46592caba72e67fe
f5d387375c56a96c8e6b88a603ea5a9491ae11c5
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!