Commit 8cdab11f 张东亮

云仓上料机构满时,将点料机满料送到分盘线。避免点料机拥堵

1 个父辈 ebb0ddf4
正在显示 46 个修改的文件 包含 569 行增加585 行删除
......@@ -50,6 +50,21 @@
<conversionPattern value="[%date][%t][%c:%L]%-5p %m%n"/>
</layout>
</appender>
<appender name="RunLog" type="log4net.Appender.RollingFileAppender">
<file value="logs/runLog/RunLog.json"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<param name="MaxSizeRollBackups" value="10" />
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%m%n"/>
</layout>
</appender>
<logger name="RunLog">
<level value="debug"/>
<appender-ref ref="RunLog"/>
</logger>
<logger name="MiR_API">
<level value="Error"/>
<appender-ref ref="MiR_API"/>
......
......@@ -57,13 +57,13 @@ namespace AGVControl
CommonVar.agvInfo[i].StateKanban.Init();
}
for (int i = 0; i < CommonVar.nodeInfo.Count; i++)
for (int i = 0; i < NodeManager.nodeInfo.Count; i++)
{
n = DgvNode.Rows.Add(CommonVar.nodeInfo[i].ToRow());
n = DgvNode.Rows.Add(NodeManager.nodeInfo[i].ToRow());
DgvNode.Rows[n].HeaderCell.Value = (n + 1).ToString();
if (i % 2 == 0)
DgvNode.Rows[n].DefaultCellStyle.BackColor = Color.LightBlue;
if (!CommonVar.nodeInfo[i].Online)
if (!NodeManager.nodeInfo[i].Online)
DgvNode.Rows[n].DefaultCellStyle.ForeColor = Color.Red;
}
}
......@@ -72,9 +72,9 @@ namespace AGVControl
{
Invoke(new Action(() =>
{
for (int i=0;i<CommonVar.nodeInfo.Count;i++)
for (int i=0;i<NodeManager.nodeInfo.Count;i++)
{
DgvNode.Rows[i].SetValues(CommonVar.nodeInfo[i].ToRow());
DgvNode.Rows[i].SetValues(NodeManager.nodeInfo[i].ToRow());
}
DgvNode.Refresh();
}));
......@@ -85,8 +85,8 @@ namespace AGVControl
{
Invoke(new Action(() =>
{
for (int i = 0; i < CommonVar.nodeInfo.Count; i++)
DgvNode.Rows[nodeIndex].DefaultCellStyle.ForeColor = CommonVar.nodeInfo[nodeIndex].Online ? Color.Black : Color.Red;
for (int i = 0; i < NodeManager.nodeInfo.Count; i++)
DgvNode.Rows[i].DefaultCellStyle.ForeColor = NodeManager.nodeInfo[i].Online ? Color.Black : Color.Red;
DgvNode.Refresh();
}));
System.GC.Collect();
......@@ -164,10 +164,10 @@ namespace AGVControl
if (e.ColumnIndex == DgvNode.Columns.Count - 1) //调用
{
CommonVar.nodeInfo[e.RowIndex].IsUse = !CommonVar.nodeInfo[e.RowIndex].IsUse;
DgvNode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = CommonVar.nodeInfo[e.RowIndex].IsUse.ToString();
CommonVar.WriteIni(CommonVar.nodeInfo[e.RowIndex].Name, SettingString.IsUse, CommonVar.nodeInfo[e.RowIndex].IsUse.ToString());
DgvNode.Rows[e.RowIndex].SetValues(CommonVar.nodeInfo[e.RowIndex].ToRow());
NodeManager.nodeInfo[e.RowIndex].IsUse = !NodeManager.nodeInfo[e.RowIndex].IsUse;
DgvNode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = NodeManager.nodeInfo[e.RowIndex].IsUse.ToString();
CommonVar.WriteIni(NodeManager.nodeInfo[e.RowIndex].Name, SettingString.IsUse, NodeManager.nodeInfo[e.RowIndex].IsUse.ToString());
DgvNode.Rows[e.RowIndex].SetValues(NodeManager.nodeInfo[e.RowIndex].ToRow());
}
}
......@@ -189,6 +189,14 @@ namespace AGVControl
lblStandy3.Text = "待机位3:" + CommonVar.Standby.Station[2];
lblStandy4.Text = "待机位4:" + CommonVar.Standby.Station[3];
}));
Invoke(new Action(() =>
{
for (int i = 0; i < NodeManager.nodeInfo.Count; i++)
{
DgvNode.Rows[i].SetValues(NodeManager.nodeInfo[i].ToRow());
}
DgvNode.Refresh();
}));
Application.DoEvents();
InShhow = false;
}
......
......@@ -49,7 +49,8 @@ namespace AGVControl
//添加Init任务
Agv.AssignTask(SettingString.Init);
}
if (Agv.TaskQueue.Count > 0)
Agv.TaskQueue.TryDequeue(out string qq);
CommonVar.Standby.DelOccupyInfo(Agv.Name);
CommonVar.Charge.DelOccupyInfo(Agv.Name);
......
......@@ -99,7 +99,7 @@ namespace AGVControl
CommonVar.showNameMissionName.Add(temp[1], temp[0]);
}
CommonVar.nodeInfo = new List<ClientNode>();
NodeManager.nodeInfo = new List<ClientNode>();
path = CommonVar.CONFIG_PATH + SettingString.FileName_AgvProductionLine;
line = System.IO.File.ReadAllLines(path, Encoding.GetEncoding("gb2312"));
for (int i = 1; i < line.Length; i++)
......@@ -107,7 +107,7 @@ namespace AGVControl
temp = line[i].Split(',');
if (temp.Length != 3) continue;
Boolean.TryParse(CommonVar.ReadIni(temp[0], SettingString.IsUse), out bool isUse);
CommonVar.nodeInfo.Add(new ClientNode(temp[0], temp[1],temp[2], isUse));
NodeManager.nodeInfo.Add(new ClientNode(temp[0], temp[1],temp[2], isUse));
}
//加载任务类型
......
文件属性发生变化
......@@ -117,7 +117,7 @@
// lblTask
//
this.lblTask.Dock = System.Windows.Forms.DockStyle.Left;
this.lblTask.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblTask.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblTask.Image = global::AGV_UI.Properties.Resources.task;
this.lblTask.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lblTask.Location = new System.Drawing.Point(0, 0);
......
文件属性发生变化
文件属性发生变化
文件属性发生变化
文件属性发生变化
文件属性发生变化
文件属性发生变化
文件属性发生变化
文件属性发生变化
文件属性发生变化
......@@ -418,7 +418,7 @@ namespace DeviceLibrary
}
//
/// <summary>
/// 解码 AB 91 123 34 78 97 109 101 34 58 34 BA AB 91 123 34 78 97 109 101 34 58 34 BA
/// 解码
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
......@@ -462,19 +462,19 @@ namespace DeviceLibrary
private void UpdateNode(ClientNode node)
{
int idx = CommonVar.nodeInfo.FindIndex(s => s.Name == node.Name);
int idx = NodeManager.FindNode(node.Name);
if (idx == -1)
{
log.Error(node.Name + " 不存在");
return;
}
if (!CommonVar.nodeInfo[idx].Online)
if (!NodeManager.nodeInfo[idx].Online)
{
CommonVar.nodeInfo[idx].Online = true;
NodeManager.nodeInfo[idx].Online = true;
NodeOnline?.Invoke(idx);
}
if (CommonVar.nodeInfo[idx].CheckNodeStateChanged(node))
if (NodeManager.nodeInfo[idx].CheckNodeStateChanged(node))
{
log.Info("节点状态更新 " + node.StatetText());
NodeChanged?.Invoke(idx);
......@@ -489,9 +489,9 @@ namespace DeviceLibrary
for (int i = 0; i < client.nodeName.Count; i++)
{
int idx = CommonVar.nodeInfo.FindIndex(s => s.Name == client.nodeName[i]);
int idx = NodeManager.FindNode(client.nodeName[i]);
if (idx == -1) continue;
CommonVar.nodeInfo[idx].Offline();
NodeManager.nodeInfo[idx].Offline();
NodeOnline?.Invoke(idx);
}
client.nodeName.Clear();
......
......@@ -15,6 +15,7 @@ namespace DeviceLibrary
public Dictionary<string, string> Station;
public const string AutoCharge1 = "AutoCharge1";
public const string AutoCharge2 = "AutoCharge2";
public const string AutoCharge3 = "AutoCharge3";
/// <summary>
/// 充电最大电量,小于该值或大于等待指定时间去充电
/// </summary>
......@@ -29,6 +30,7 @@ namespace DeviceLibrary
Station = new Dictionary<string, string>();
Station.Add(AutoCharge1, "");
Station.Add(AutoCharge2, "");
Station.Add(AutoCharge3, "");
string s = AppConfigHelper.GetValue(SettingString.ChargeThreshold);
string[] arr = s.Split(',');
BatteryMin = Convert.ToInt32(arr[0]);
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Threading;
......@@ -14,10 +15,6 @@ namespace DeviceLibrary
public static class CommonVar
{
/// <summary>
/// 节点信息
/// </summary>
public static List<ClientNode> nodeInfo;
/// <summary>
/// 任务类型
/// </summary>
public static List<JobType> jobTypeInfo;
......@@ -35,55 +32,46 @@ namespace DeviceLibrary
public static Charge Charge;
public static Standby Standby;
public static string ReadIni(string section, string key)
{
return IniFileHelper.ReadValue(section, key, CONFIG_PATH + SettingString.FileName_tempData);
}
#region 任务日志
static log4net.ILog runLog = log4net.LogManager.GetLogger("RunLog");
static Dictionary<string, RunInfo> runInfoMap = new Dictionary<string, RunInfo>();
public static void WriteIni(string section, string key, string value)
public static void RunLogInfo(RunInfo info)
{
IniFileHelper.WriteValue(section, key, value, CONFIG_PATH + SettingString.FileName_tempData);
}
public static bool GetNodeNameByAliceName(string aliceName, out string nodeName)
if (runInfoMap == null)
return;
if (runInfoMap.Keys.Contains(info.AGVNum))
{
nodeName = "";
int id = nodeInfo.FindIndex(s => s.AliceName.Equals(aliceName));
if (id > -1)
if (!runInfoMap[info.AGVNum].Equals(info))
{
nodeName = nodeInfo[id].Name;
return true;
runLog.Info(info.ToString());
}
}
else
{
return false;
runInfoMap.Add(info.AGVNum, info);
runLog.Info(info.ToString());
}
}
public static bool GetLineNameByNodeName(string nodeName, out string lineName)
public static void ErrorLogRecord(ErrorInfo errorInfo)
{
lineName = "";
int id = nodeInfo.FindIndex(s => s.Name.Equals(nodeName));
if (id > -1)
{
lineName = nodeInfo[id].LineName;
return true;
runLog.Info(errorInfo.ToString());
}
else
#endregion
public static string ReadIni(string section, string key)
{
return false;
}
return IniFileHelper.ReadValue(section, key, CONFIG_PATH + SettingString.FileName_tempData);
}
/// <summary>
/// 查找节点是否存在以及是否调用
/// </summary>
/// <param name="nodeName">节点名称</param>
/// <returns></returns>
public static int FindNode(string nodeName)
public static void WriteIni(string section, string key, string value)
{
int idx = nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.IsUse);
return idx;
IniFileHelper.WriteValue(section, key, value, CONFIG_PATH + SettingString.FileName_tempData);
}
/// <summary>
/// 移动到节点位置
/// </summary>
......@@ -96,13 +84,13 @@ namespace DeviceLibrary
//清除目的地
agv.Place = "";
//执行下一个任务
int i = FindNode(nodeName);
int i = NodeManager.FindNode(nodeName);
bool rtn = agv.AssignTask(SettingString.Move + nodeName);
if (rtn)
{
agv.Place = nodeName;
if (i > -1)
log = string.Format("{0} {1} To Node {2} {3}", agv.Name, SettingString.Move, nodeName,nodeInfo[i].GetState().ToString());
log = string.Format("{0} {1} To Node {2} {3}", agv.Name, SettingString.Move, nodeName, NodeManager.GetState(i).ToString());
else
log = string.Format("{0} {1} To Node {2}", agv.Name, SettingString.Move, nodeName);
LogUtil.info(log);
......@@ -234,6 +222,141 @@ namespace DeviceLibrary
}
}
public class RunInfo
{
/// <summary>
/// AGV编号
/// </summary>
public string AGVNum { get; set; } = "";
/// <summary>
/// 任务名称
/// </summary>
public string TaskName { get; set; } = "";
/// <summary>
/// 目的地
/// </summary>
public string TargetPlace { get; set; } = "";
/// <summary>
/// 任务步骤
/// </summary>
public string TaskStep { get; set; } = "";
/// <summary>
/// 任务内容
/// </summary>
public string MissionInfo { get; set; } = "";
/// <summary>
/// 开始时间
/// </summary>
public string DateTime { get; set; } = "";
/// <summary>
/// 结束时间
/// </summary>
public string EndDateTime { get; set; } = "";
/// <summary>
/// 任务运行时长
/// </summary>
public string TaskRunTime { get; set; } = "";
/// <summary>
/// 类型
/// </summary>
public string Type { get; set; } = "Task";
public RunInfo(string AGVNum, string taskName, string targetPlace, string taskStep, string missionInfo, DateTime startTime)
{
//开始时间 2006-01-02 15:04:05
DateTime = startTime.ToString("yyyy-MM-dd HH:mm:ss");
EndDateTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
this.AGVNum = AGVNum;
MissionInfo = missionInfo;
TaskName = taskName;
TaskRunTime = (System.DateTime.Now - startTime).TotalMinutes.ToString("f2");
TargetPlace = targetPlace;
TaskStep = taskStep;
}
public RunInfo() { }
public override bool Equals(object obj)
{
if (obj is RunInfo)
{
RunInfo info = (RunInfo)obj;
if (this.MissionInfo.Equals(info.MissionInfo))
return true;
this.MissionInfo = info.MissionInfo;
}
return false;
}
public override string ToString()
{
return JsonHelper.SerializeObject(this);
}
}
public class ErrorInfo
{
/// <summary>
/// AGV编号
/// </summary>
public string AGVNum
{
get { return agvname; }
set
{
agvname = value.PadLeft(4, '0');
}
}
private string agvname = "";
/// <summary>
/// 开始时间
/// </summary>
public string DateTime { get; set; } = "";
/// <summary>
/// 结束时间
/// </summary>
public string EndDateTime { get; set; } = "";
/// <summary>
/// 异常信息
/// </summary>
public string ErrorMsg { get; set; } = "";
public string ErrorLastTime { get; set; } = "";
/// <summary>
/// 任务名称
/// </summary>
public string TaskName { get; set; } = "";
/// <summary>
/// AGV的当前任务
/// </summary>
public string AGVMissionName { get; set; } = "";
public string MissionInfo { get; set; } = "";
/// <summary>
/// 目的地
/// </summary>
public string TargetPlace { get; set; } = "";
/// <summary>
/// 类型
/// </summary>
public string Type { get; set; } = "Error";
public ErrorInfo(Agv_Info agv)
{
DateTime = agv.errStartTime.ToString("yyyy-MM-dd HH:mm:ss");
AGVNum = agv.Name;
EndDateTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
ErrorMsg = agv.ErrorMsg;
ErrorLastTime = (System.DateTime.Now - agv.errStartTime).TotalMinutes.ToString("f2");
if (agv.CurJob != null)
{
TaskName = agv.CurJob.JobName;
MissionInfo = agv.CurJob.runInfo;
}
AGVMissionName = agv.CurTaskName;
TargetPlace = agv.Place;
}
public override string ToString()
{
return JsonHelper.SerializeObject(this);
}
}
public static class Window_API
{
......
文件属性发生变化
......@@ -85,13 +85,34 @@ namespace DeviceLibrary
{
if (!CheckOnline(i)) continue;
bool change = false;
if (!CommonVar.agvInfo[i].AllocatingTask && CommonVar.agvInfo[i].IsUse && CommonVar.agvInfo[i].CurJob != null && CommonVar.agvInfo[i].CurTaskID.Equals(-1))
{
if (!MiR_API.Get_Fleet_Mission_Info(CommonVar.agvInfo[i]))
{
CommonVar.agvInfo[i].CurJob.ResendTask(CommonVar.agvInfo[i]);
LogUtil.info($"{CommonVar.agvInfo[i].Name}:Task=-1处理,Fleet无任务,重发任务:{CommonVar.agvInfo[i].CurTaskName}");
}
else
{
LogUtil.info($"{CommonVar.agvInfo[i].Name}:Task=-1处理,Fleet有任务,手动赋值FleetTaskID={CommonVar.agvInfo[i].CurTaskID}");
}
}
MiR_API.Get_Task_State(CommonVar.agvInfo[i], out string stateStr);
Thread.Sleep(50);
//获取AGV状态
rtn = MiR_API.Get_State(CommonVar.agvInfo[i], out eAGVState stateID, out string stateText, out int battery, out string mission_text, out Agv_Info.AgvPosition position);
Thread.Sleep(50);
change = CommonVar.agvInfo[i].SetState(stateID, stateStr, battery, mission_text, position);
if(CommonVar.agvInfo[i].TaskQueue.Count>0 && CommonVar.agvInfo[i].CurTaskID.Equals(-1))
{
if(CommonVar.agvInfo[i].IsCon)
{
if (CommonVar.agvInfo[i].TaskQueue.TryDequeue(out string taskname))
{
CommonVar.agvInfo[i].AssignTask(taskname);
}
}
}
//更新状态stateID.Equals(eAGVState.Executing)
if (change)
{
......
......@@ -50,22 +50,18 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AGVManager.cs" />
<Compile Include="manager\APIManager.cs" />
<Compile Include="AgvServer.cs" />
<Compile Include="bean\Agv_Info.cs" />
<Compile Include="bean\Job.cs" />
<Compile Include="bean\JobParam.cs" />
<Compile Include="bean\JobStep.cs" />
<Compile Include="bean\JobType.cs" />
<Compile Include="bean\jobType\ChargeJobType.cs" />
<Compile Include="bean\jobType\PackingJobType.cs" />
<Compile Include="bean\jobType\ReelStringJobType.cs" />
<Compile Include="bean\jobType\ReturnJobType.cs" />
<Compile Include="bean\job\ChargeJob.cs" />
<Compile Include="bean\job\EnterLeaveShelfJob.cs" />
<Compile Include="bean\job\GetShelfJob.cs" />
<Compile Include="bean\job\PackingJob_GetShelf.cs" />
<Compile Include="bean\job\PackingJob_SendShelf.cs" />
<Compile Include="bean\job\PackingJob_TransferShelf.cs" />
<Compile Include="bean\job\RecycleEmptyShelf.cs" />
<Compile Include="bean\job\SendShelfJob.cs" />
<Compile Include="bean\job\StandyJob.cs" />
......@@ -76,6 +72,7 @@
<Compile Include="Control.cs" />
<Compile Include="DisplayBoard.cs" />
<Compile Include="bean\MiR_API.cs" />
<Compile Include="manager\NodeManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScopeLimit.cs" />
<Compile Include="Standby.cs" />
......
......@@ -40,7 +40,7 @@ namespace DeviceLibrary
{
if (MsgList != null && MsgList.Count > 0)
{
AGVManager.updateDeviceAlarmMsg(MsgList);
APIManager.updateDeviceAlarmMsg(MsgList);
ClearAlram();
}
......
......@@ -36,9 +36,9 @@ namespace DeviceLibrary
"10.85.199.114"
});
this.positions = positions;
threadPoll = new Thread(ScopeDetecting);
threadPoll.IsBackground = true;
threadPoll.Start();
//threadPoll = new Thread(ScopeDetecting);
//threadPoll.IsBackground = true;
//threadPoll.Start();
}
private void ScopeDetecting()
{
......
文件属性发生变化
using Common;
using System;
namespace DeviceLibrary
{
public abstract class Job
......@@ -12,13 +14,13 @@ namespace DeviceLibrary
/// 运行信息
/// </summary>
public abstract string RunInfo { get; }
public string runInfo = "";
/// <summary>
/// 根据任务状态继续执行任务
/// </summary>
public abstract Job Execute(Agv_Info agv);
public int CurTaskID { get; set; } = -1;
public long CurTaskID { get; set; } = -1;
/// <summary>
/// 当前的任务名称(与任务GUID对应)
/// </summary>
......@@ -27,7 +29,19 @@ namespace DeviceLibrary
/// 当前任务的执行状态
/// </summary>
public string CurTaskState { get; set; } = "Wait";
/// <summary>
/// Job开始时间
/// </summary>
public DateTime StartJobTime { get; set; } = DateTime.Now;
/// <summary>
/// Job名称
/// </summary>
public string JobName { get; set; } = "";
protected void RecordRunLog(Agv_Info agv,string JobStep,string runInfo,string targetPlace)
{
CommonVar.RunLogInfo(new RunInfo(agv.Name.PadLeft(4, '0'), JobName, targetPlace, JobStep, runInfo, StartJobTime));
}
/// <summary>
/// 更新任务信息
/// </summary>
......@@ -40,6 +54,8 @@ namespace DeviceLibrary
//CurTaskState = SettingString.Wait;
CurTaskState = CommonVar.GetTakJobState(agv);
}
/// <summary>
/// 任务重发
/// </summary>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class JobParam
{
}
}
......@@ -23,14 +23,14 @@ namespace DeviceLibrary
//不为空,且与上一个消息不一样才打印
if (!value.Equals(msg))
{
LogUtil.info(value);
// LogUtil.info(value);
}
}
msg = value;
}
}
private DateTime startTime = DateTime.Now;
public DateTime startTime = DateTime.Now;
public JobStep(T initStep)
{
......@@ -54,13 +54,11 @@ namespace DeviceLibrary
/// </summary>
/// <param name="timeOutMilliseconds"></param>
/// <returns></returns>
public bool IsTimeOut(int timeOutMilliseconds,out double timeOutValue)
public bool IsTimeOut(int timeOutMilliseconds,out TimeSpan span)
{
timeOutValue = 0;
TimeSpan span = DateTime.Now - startTime;
span = DateTime.Now - startTime;
if (span.TotalMilliseconds > timeOutMilliseconds)
{
timeOutValue = span.TotalSeconds;
return true;
}
return false;
......
......@@ -237,68 +237,170 @@ namespace DeviceLibrary
return false;
}
}
/// <summary>
/// 添加任务到FLEET任务队列
/// </summary>
/// <param name="info"></param>
/// <param name="mission_id"></param>
/// <returns></returns>
public static bool Add_Mission_Fleet(Agv_Info info, string mission_id, bool isRemovePreMission = true)
{
try
{
info.AllocatingTask = true;
info.CurTaskID = -1;
info.CurTaskGUID = "";
info.CurTaskState = SettingString.Wait;
info.TimeStamp = "";
info.CurTaskGUID = mission_id;
var key = CommonVar.agvMission.Where(qq => qq.Value == mission_id).Select(qq => qq.Key);
info.CurTaskName = key.ToList()[0];
info.CurTaskState = SettingString.Wait;
//防止上一个任务已执行但返回失败时,删除任务
Del_Mission(info);
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 8, 0, 0)); // 当地时区
long timeStamp = (long)(DateTime.Now - startTime).TotalSeconds; // 相差秒数
info.TimeStamp = timeStamp.ToString();
string ip = AppConfigHelper.GetValue(SettingString.FLEET);
string url = "http://" + ip + "/api/v2.0.0/mission_scheduler";
string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.Fleet_IP + "}";
//string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.ID + "}";
string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.Fleet_IP + ",\"description\":\"" + $"{info.CurTaskName}-{info.TimeStamp}-{info.Fleet_IP}" + "\"}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
if (string.IsNullOrWhiteSpace(json))
{
info.AllocatingTask = false;
return false;
}
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
if (dic == null)
{
info.AllocatingTask = false;
return false;
}
log.Info("URL: " + url + "\n" + "Return: " + json);
//log.Info("URL: " + url + "\n" + "Return: " + json);
string s = dic["mission_id"].ToString();
string id = dic["id"].ToString();
if (s == mission_id)
{
try
{
info.CurTaskID = Convert.ToInt32(id);
info.CurTaskGUID = mission_id;
info.CurTaskID = Convert.ToInt64(id);
log.Info(string.Format("{0} Add_Mission_Fleet [{1}]", info.Name, key.ToList()[0]));
}
catch
{
log.Info(string.Format("{0} Add_Mission_Fleet [{1}]", info.Name, mission_id));
info.CurTaskName = "";
}
info.AllocatingTask = false;
return true;
}
else
{
info.AllocatingTask = false;
return false;
}
}
catch (Exception ex)
{
log.Error("Add_Mission_Fleet", ex);
info.AllocatingTask = false;
return false;
}
}
/// <summary>
/// 添加任务到FLEET任务队列
/// </summary>
/// <param name="info"></param>
/// <param name="mission_id"></param>
/// <returns></returns>
//public static bool Add_Mission_Fleet(Agv_Info info, string mission_id, bool isRemovePreMission = true)
//{
// try
// {
// info.CurTaskID = -1;
// info.CurTaskGUID = "";
// info.CurTaskState = SettingString.Wait;
// var key = CommonVar.agvMission.Where(qq => qq.Value == mission_id).Select(qq => qq.Key);
// info.CurTaskName = key.ToList()[0];
// //防止上一个任务已执行但返回失败时,删除任务
// Del_Mission(info);
// string ip = AppConfigHelper.GetValue(SettingString.FLEET);
// string url = "http://" + ip + "/api/v2.0.0/mission_scheduler";
// string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.Fleet_IP + "}";
// string json = HttpPost(url, info.IP, info.Authorization, body);
// if (string.IsNullOrWhiteSpace(json)) return false;
// JavaScriptSerializer serializer = new JavaScriptSerializer();
// Dictionary<string, object> dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
// if (dic == null)
// {
// return false;
// }
// log.Info("URL: " + url + "\n" + "Return: " + json);
// string s = dic["mission_id"].ToString();
// string id = dic["id"].ToString();
// if (s == mission_id)
// {
// try
// {
// info.CurTaskID = Convert.ToInt32(id);
// info.CurTaskGUID = mission_id;
// log.Info(string.Format("{0} Add_Mission_Fleet [{1}]", info.Name, key.ToList()[0]));
// }
// catch
// {
// log.Info(string.Format("{0} Add_Mission_Fleet [{1}]", info.Name, mission_id));
// info.CurTaskName = "";
// }
// return true;
// }
// else
// return false;
// }
// catch (Exception ex)
// {
// log.Error("Add_Mission_Fleet", ex);
// return false;
// }
//}
/// <summary>
/// 获取Fleet任务队列
/// </summary>
/// <param name="info"></param>
/// <param name="mission"></param>
/// <returns></returns>
public static bool Get_Fleet_Mission_Info(Agv_Info info)
{
try
{
string ip = AppConfigHelper.GetValue(SettingString.FLEET);
string url = "http://" + ip + "/api/v2.0.0/mission_scheduler/search";
string body = "{\"filters\" : [{\"fieldname\": \"description\", \"operator\": \"LIKE\", \"value\": \"" + info.CurTaskName + "-" + info.TimeStamp + "-" + info.Fleet_IP + "\"}]}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
JavaScriptSerializer serializer = new JavaScriptSerializer();
object[] obj = (object[])serializer.DeserializeObject(json);
if (obj == null) return false;
Dictionary<string, object> dic;
if (obj.Length > 0)
{
dic = (Dictionary<string, object>)obj[0];
info.CurTaskID = long.Parse(dic["id"].ToString());
if (info.CurTaskID == -1)
return false;
if (info.CurJob != null)
info.CurJob.CurTaskID = info.CurTaskID;
return true;
}
return false;
}
catch (Exception ex)
{
log.Error("Get_Mission_Queue", ex);
return false;
}
}
/// <summary>
/// 获取所有任务列表
/// </summary>
/// <param name="info"></param>
......@@ -720,8 +822,7 @@ namespace DeviceLibrary
string s = response.Content;
s = s.Replace("\n", "");
s = s.Replace(" ", "");
if (IsDebug)
log.Debug(string.Format("HttpPost URL: {0}; Body: {1} Return: {2}", url, body, s));
log.Info(string.Format("HttpPost URL: {0}; Body: {1} Return: {2} [StatusCode={3},ResponseStatus={4},]", url, body, s, response.StatusCode, response.ResponseStatus));
return s;
}
......
文件属性发生变化
using Common;
using System;
namespace DeviceLibrary
{
......@@ -14,24 +15,21 @@ namespace DeviceLibrary
public ChargeJob(string agvPlae)
{
this.agvPlace = agvPlae;
StartJobTime = DateTime.Now;
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace = "";
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return string.Format("充电任务:{0}", runInfo); }
get { return string.Format("{0}", runInfo); }
}
private JobStep<CHARGE_STEP> ChargeStep = new JobStep<CHARGE_STEP>(CHARGE_STEP.NONE);
private JobStep<CHARGE_STEP> curJobStep = new JobStep<CHARGE_STEP>(CHARGE_STEP.NONE);
/// <summary>
/// 空车返回执行
......@@ -39,19 +37,21 @@ namespace DeviceLibrary
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
string msg = "";
bool rtn = false;
agv.Msg = RunInfo;
agv.Msg = runInfo;
JobName = "充电任务";
StartJobTime = curJobStep.startTime;
CurTaskState = CommonVar.GetTakJobState(agv);
if (ChargeStep.IsStep(CHARGE_STEP.NONE))
if (curJobStep.IsStep(CHARGE_STEP.NONE))
{
agv.HasError = false;
if (agvPlace.StartsWith(SettingString.C4_Name_Prefix))
{
ChargeStep.ToNextStep(CHARGE_STEP.WAIT_AGV_REACH_3D_DOOR);
curJobStep.ToNextStep(CHARGE_STEP.WAIT_AGV_REACH_3D_DOOR);
runInfo = "电量[" + agv.Battery + "%]小于最大电量[" + CommonVar.Charge.BatteryMax + "%],从当前位置" + agvPlace + "回到充电位,先到3D门";
msg += runInfo;
ChargeStep.Msg = msg;
curJobStep.Msg = msg;
CommonVar.DoorMission(agv, SettingString.DoorCToD);
UpdateJobTaskInfo(agv);
......@@ -63,21 +63,22 @@ namespace DeviceLibrary
{
runInfo = "电量[" + agv.Battery + "%]小于最大电量[" + CommonVar.Charge.BatteryMax + "%],由于充电桩有小车,从当前位置" + agvPlace + "回到待机位";
msg += runInfo;
ChargeStep.Msg = msg;
curJobStep.Msg = msg;
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return new StandyJob(agv.Place);
}
else
{
ChargeStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION);
curJobStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION);
runInfo = "电量[" + agv.Battery + "%]小于最大电量[" + CommonVar.Charge.BatteryMax + "%],从当前位置" + agvPlace + "去到充电位";
msg += runInfo;
ChargeStep.Msg = msg;
curJobStep.Msg = msg;
UpdateJobTaskInfo(agv);
}
}
}
else if (ChargeStep.IsStep(CHARGE_STEP.WAIT_AGV_REACH_3D_DOOR))
else if (curJobStep.IsStep(CHARGE_STEP.WAIT_AGV_REACH_3D_DOOR))
{
if (CommonVar.CheckTaskMoveFinished(agv, SettingString.DoorCToD, CurTaskState))
{
......@@ -85,7 +86,8 @@ namespace DeviceLibrary
{
runInfo = "电量充足[" + agv.Battery + "%],从当前位置" + agvPlace + "去到待机位";
msg += runInfo;
ChargeStep.Msg = msg;
curJobStep.Msg = msg;
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return new StandyJob(agv.Place);
}
else
......@@ -94,40 +96,42 @@ namespace DeviceLibrary
{
runInfo = "电量[" + agv.Battery + "%]小于最大电量[" + CommonVar.Charge.BatteryMax + "%],充电桩有小车,从当前位置" + agvPlace + "回到待机位";
msg += runInfo;
ChargeStep.Msg = msg;
curJobStep.Msg = msg;
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return new StandyJob(agv.Place);
}
else
{
ChargeStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION);
curJobStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION);
runInfo = "电量[" + agv.Battery + "%]小于最大电量[" + CommonVar.Charge.BatteryMax + "%],从当前位置" + agvPlace + "去到充电位";
msg += runInfo;
ChargeStep.Msg = msg;
curJobStep.Msg = msg;
UpdateJobTaskInfo(agv);
}
}
}
}
else if (ChargeStep.IsStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION))
else if (curJobStep.IsStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION))
{
if (CommonVar.CheckTaskFinished(agv, CurTaskName))
{
ChargeStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_OK);
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_OK);
runInfo = "充电任务分配完成,去充电且等待任务";
msg += runInfo;
ChargeStep.Msg = msg;
curJobStep.Msg = msg;
}
}
else if (ChargeStep.IsStep(CHARGE_STEP.WAIT_REACH_CHARGE_OK))
else if (curJobStep.IsStep(CHARGE_STEP.WAIT_REACH_CHARGE_OK))
{
if (agv.Battery > CommonVar.Charge.BatteryMax)
{
runInfo = "充电完成,回待机位";
msg += runInfo;
ChargeStep.Msg = msg;
curJobStep.Msg = msg;
CommonVar.Charge.DelOccupyInfoByAGV(agv);
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return new StandyJob(agv.Place);
}
else if(agv.Battery > CommonVar.Charge.BatteryMin)
......@@ -137,14 +141,15 @@ namespace DeviceLibrary
{
runInfo = "在充电位检测到任务,电量[" + agv.Battery + " %]大于最小电量[" + CommonVar.Charge.BatteryMin + " %],可执行任务";
msg += runInfo;
ChargeStep.Msg = msg;
curJobStep.Msg = msg;
CommonVar.Charge.DelOccupyInfoByAGV(agv);
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return job;
}
}
}
else if (ChargeStep.IsStep(CHARGE_STEP.END))
else if (curJobStep.IsStep(CHARGE_STEP.END))
{
}
return this;
......
using System.Threading.Tasks;
namespace DeviceLibrary
{
/// <summary>
/// 小车进出料类型
/// </summary>
public enum eEnterLeaveType
{
/// <summary>
/// 小车进料
/// </summary>
Enter,
/// <summary>
/// 小车出料
/// </summary>
Leave,
}
/// <summary>
/// 进出料任务
/// </summary>
public class EnterLeaveShelfJob : Job
{
/// <summary>
/// 进出料任务
/// </summary>
/// <param name="curNode">位置点</param>
/// <param name="rfid">RFID</param>
public EnterLeaveShelfJob(ClientNode curNode, eEnterLeaveType type,string rfid="")
{
CurNode = curNode;
RFID = rfid;
ActionType = type;
runInfo = type.Equals(eEnterLeaveType.Enter) ? "小车进料任务:" : "小车出料任务:" +curNode.AliceName+" ";
}
/// <summary>
/// 位置点信息
/// </summary>
public ClientNode CurNode { get; set; }
public string RFID { get; set; }
/// <summary>
/// 动作类型
/// </summary>
public eEnterLeaveType ActionType { get; set; }
private string runInfo;
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return runInfo; }
}
private JobStep<ENTER_LEAVE_SHELF_STEP> EnterLeaveShelfStep = new JobStep<ENTER_LEAVE_SHELF_STEP>(ENTER_LEAVE_SHELF_STEP.NONE);
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name+ " ";
bool rtn = false;
agv.Msg = runInfo;
if (EnterLeaveShelfStep.IsStep(ENTER_LEAVE_SHELF_STEP.NONE))
{
if (ActionType.Equals(eEnterLeaveType.Leave))
{
EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_IN_LINE);
runInfo += "小车链条运行";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
rtn = agv.AssignTask(Common.SettingString.Leave);
UpdateJobTaskInfo(agv);
}
else if(ActionType.Equals(eEnterLeaveType.Enter))
{
EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_OUT_LINE);
runInfo +="小车链条运行";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
rtn = agv.AssignTask(Common.SettingString.Enter);
UpdateJobTaskInfo(agv);
}
}
else if (EnterLeaveShelfStep.IsStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_IN_LINE))
{
CurTaskState = CommonVar.GetTakJobState(agv);
if (CommonVar.CheckEnterOrLeaveFinished(agv, "Leave", CurTaskState))
{
//EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.END);
runInfo+= "料架/料串进入完成 [" + RFID + "]";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
agv.RFID = "";
// return new EmptyAGVBackJob(LineName);
}
else if (EnterLeaveShelfStep.IsTimeOut(60000, out double timeOutValue))
{
runInfo= "料架离开小车超时[" + timeOutValue.ToString("f1") + "秒],请检查料架离开小车的情况";
//msg += runInfo;
//EnterLeaveShelfStep.Msg = msg;
}
}
else if (EnterLeaveShelfStep.IsStep(ENTER_LEAVE_SHELF_STEP.WAIT__SHELF_OUT_LINE))
{
CurTaskState = CommonVar.GetTakJobState(agv);
if (CommonVar.CheckEnterOrLeaveFinished(agv, "Enter", CurTaskState))
{
//EnterLeaveShelfStep.ToNextStep(ENTER_LEAVE_SHELF_STEP.END);
runInfo = "料架/料串出去完成 [" + RFID + "]";
msg += runInfo;
EnterLeaveShelfStep.Msg = msg;
//return new EmptyShelfBackJob(LineName,eShelfType.BigShelf);
}
else if (EnterLeaveShelfStep.IsTimeOut(60000, out double timeOutValue))
{
//链条停止
runInfo= "料架进入小车超时[" + timeOutValue.ToString("f1") + "秒],请检查料架进入小车的情况";
//msg += runInfo;
//EnterLeaveShelfStep.Msg = msg;
}
}
else if (EnterLeaveShelfStep.IsStep(ENTER_LEAVE_SHELF_STEP.END))
{
}
return this;
}
}
/// <summary>
/// AGV进出料
/// </summary>
public enum ENTER_LEAVE_SHELF_STEP
{
/// <summary>
///
/// </summary>
NONE,
/// <summary>
/// 等待料架离开产线
/// </summary>
WAIT__SHELF_OUT_LINE,
/// <summary>
/// 等待料架进入产线
/// </summary>
WAIT__SHELF_IN_LINE,
/// <summary>
/// 进入/离开完成
/// </summary>
END
}
}
using Common;
namespace DeviceLibrary
{
/// <summary>
/// 包装仓任务:将包装料架送往包装仓
/// </summary>
public class PackingJob_SendShelf : Job
{
/// <summary>
/// 将包装料架送往包装仓
/// </summary>
/// <param name="agvPlae">agv当前位置</param>
/// <param name="tarPlace">目的地</param>
/// <param name="mark">标志:出库任务则显示mark;入库任务显示Mark=InStore</param>
public PackingJob_SendShelf(string agvPlae, string tarPlace, string mark,string RFID= "")
{
this.agvPlace = agvPlae;
TargetPlace = tarPlace;
this.mark = mark;
this.RFID = RFID;
if (PackingJobType.IsInStoreMark(mark))
{
}
else
{
//修改mark状态
PackingJobType.ChangeMarkState(mark, eMarkState.Executing);
}
}
/// <summary>
/// 接收任务时,agv的位置
/// </summary>
private string agvPlace = "";
private string RFID = "";
/// <summary>
/// 目的地
/// </summary>
public string TargetPlace { get; private set; }
/// <summary>
/// 标记
/// </summary>
public string mark = "";
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get
{
int t1 = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = CommonVar.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = CommonVar.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("送包装料架任务:{0} [RFID={5}][Mark={2}][目的地={1}][任务名称={3}][任务状态={4}]", runInfo, to, mark,CurTaskName,CurTaskState,RFID);
}
}
private JobStep<EXECUTE_STEP> curJobStep = new JobStep<EXECUTE_STEP>(EXECUTE_STEP.P1_NONE);
/// <summary>
/// 任务执行
/// </summary>
/// <param name="agv"></param>
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = runInfo;
CurTaskState = CommonVar.GetTakJobState(agv);
if (curJobStep.IsStep(EXECUTE_STEP.P1_NONE))
{
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_PACKING_STATION);
runInfo = "收到任务,向包装仓" + TargetPlace + "运行";
msg += runInfo;
curJobStep.Msg = msg;
CommonVar.MoveToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv);
}
else if (curJobStep.IsStep(EXECUTE_STEP.P2_WAIT_REACH_PACKING_STATION))
{
if (CommonVar.CheckTaskMoveFinished(agv, TargetPlace, CurTaskState))
{
if (PackingJobType.IsInStoreMark(mark))
{
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_PACKING_STATION_RESPONSE);
runInfo = "到达包装仓" + TargetPlace + ",并发送到达信号";
msg += runInfo;
curJobStep.Msg = msg;
CommonVar.server.Arrive(TargetPlace, RFID);
}
else
{
curJobStep.ToNextStep(EXECUTE_STEP.P3_CHECK_PACKING_STATION_STATE);
runInfo = "到达包装仓" + TargetPlace;
msg += runInfo;
curJobStep.Msg = msg;
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P3_CHECK_PACKING_STATION_STATE))
{
if (PackingJobType.CheckNodeMark(mark, TargetPlace))
{
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_PACKING_STATION_RESPONSE);
runInfo = "到达包装仓" + TargetPlace + ",并发送到达信号";
msg += runInfo;
curJobStep.Msg = msg;
CommonVar.server.Arrive(TargetPlace, RFID);
}
else
{
if (PackingJobType.IsInStoreMark(mark))
{
runInfo = "包装仓" + TargetPlace + "无入库任务,回收该料架";
msg += runInfo;
curJobStep.Msg = msg;
return new SendShelfJob(TargetPlace,SettingString.A2,RFID);
}
else
{
runInfo = "包装仓" + TargetPlace + "无任务,回收该料架";
msg += runInfo;
curJobStep.Msg = msg;
return new RecycleEmptyShelf(agvPlace, "", true, ShelfType.PackingShelf);
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P4_WAIT_PACKING_STATION_RESPONSE))
{
int i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.MayEnter));
if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P5_WAIT_AGV_DOCK_FINISH);
runInfo = "收到线体对接请求,开始停靠";
msg += runInfo;
curJobStep.Msg = msg;
CommonVar.DockToNode(agv, TargetPlace);
UpdateJobTaskInfo(agv);
}
else if (curJobStep.IsTimeOut(6000, out double timeOutTime))
{
runInfo = string.Format("线体[{0}]允许对接信号[{1}]超时{2}秒", TargetPlace, eNodeStatus.MayEnter, timeOutTime.ToString("f2"));
msg += string.Format("线体[{0}]允许对接信号[{1}]超时", TargetPlace, eNodeStatus.MayEnter);
curJobStep.Msg = msg;
curJobStep.ToNextStep(EXECUTE_STEP.P3_CHECK_PACKING_STATION_STATE);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P5_WAIT_AGV_DOCK_FINISH))
{
if (CommonVar.CheckTaskDockFinished(agv, TargetPlace, CurTaskState))
{
CommonVar.server.Ready(TargetPlace);
curJobStep.ToNextStep(EXECUTE_STEP.P6_WAIT_SHELF_IN_STATION);
runInfo = "停靠包装仓完成,链条运行";
msg += runInfo;
curJobStep.Msg = msg;
rtn = agv.AssignTask(SettingString.Leave);
UpdateJobTaskInfo(agv);
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P6_WAIT_SHELF_IN_STATION))
{
if (CommonVar.CheckEnterOrLeaveFinished(agv, SettingString.Leave, CurTaskState))
{
CommonVar.server.CloseDoor(TargetPlace);
//int i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.FinishEnter));
//if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.P7_END);
runInfo = "包装料架进入包装仓"+TargetPlace+"完成";
msg += runInfo;
curJobStep.Msg = msg;
}
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P7_END))
{
//Job job = CommonVar.control.GetJob(agv);
//if (job != null)
//{
// runInfo = "送料架任务完成,检测到任务,开始执行";
// msg += runInfo;
// curJobStep.Msg = msg;
// return job;
//}
return null;
}
return this;
}
/// <summary>
/// 执行流程
/// </summary>
private enum EXECUTE_STEP
{
/// <summary>
/// 接收到任务
/// </summary>
P1_NONE,
/// <summary>
/// 等待到达包装仓
/// </summary>
P2_WAIT_REACH_PACKING_STATION,
/// <summary>
/// 到达包装仓,再次确认是否有任务,防止该任务被手动出掉
/// </summary>
P3_CHECK_PACKING_STATION_STATE,
/// <summary>
/// 等待包装仓回复
/// </summary>
P4_WAIT_PACKING_STATION_RESPONSE,
/// <summary>
/// 等待AGV停靠完成
/// </summary>
P5_WAIT_AGV_DOCK_FINISH,
/// <summary>
/// 等待料架进入包装仓
/// </summary>
P6_WAIT_SHELF_IN_STATION,
/// <summary>
/// 任务结束
/// </summary>
P7_END
}
}
}

using Common;
using System;
namespace DeviceLibrary
{
......@@ -32,6 +33,8 @@ namespace DeviceLibrary
TargetPlace = tarPlace;
shelfType = type;
this.hasLoad = hasLoad;
JobName = "回收空料架任务";
StartJobTime = DateTime.Now;
}
/// <summary>
/// 车上有负载
......@@ -53,7 +56,6 @@ namespace DeviceLibrary
/// 回收料架处
/// </summary>
public string RecycleStation = "";
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
......@@ -61,16 +63,16 @@ namespace DeviceLibrary
{
get
{
int t1 = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
int t1 = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = CommonVar.nodeInfo[t1].AliceName;
from = NodeManager.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
int t2 = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = CommonVar.nodeInfo[t2].AliceName;
to = NodeManager.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("回收空料架任务:{0} [ShelfType={1}][任务名称={2}][任务状态={3}]", runInfo, shelfType.ToString(),CurTaskName,CurTaskState);
......@@ -88,11 +90,12 @@ namespace DeviceLibrary
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = runInfo;
StartJobTime = curJobStep.startTime;
CurTaskState = CommonVar.GetTakJobState(agv);
if (curJobStep.IsStep(EXECUTE_STEP.R1_NONE))
{
if(hasLoad)
agv.HasError = false;
if (hasLoad)
{
if (FindRecycleStation())
{
......@@ -141,6 +144,7 @@ namespace DeviceLibrary
{
if (CommonVar.CheckTaskMoveFinished(agv, TargetPlace, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
curJobStep.ToNextStep(EXECUTE_STEP.R3_WAIT_LINE_RESPONSE);
runInfo = "到达空料架处"+TargetPlace+",向线体发送出料请求";
msg += runInfo;
......@@ -150,7 +154,7 @@ namespace DeviceLibrary
}
else if (curJobStep.IsStep(EXECUTE_STEP.R3_WAIT_LINE_RESPONSE))
{
//int i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.MayLeave));
//int i = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.MayLeave));
//if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.R4_WAIT_SHELF_IN_AGV);
......@@ -171,6 +175,7 @@ namespace DeviceLibrary
{
if (CommonVar.CheckEnterOrLeaveFinished(agv, SettingString.Enter, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
CommonVar.server.CloseDoor(TargetPlace);
if (FindRecycleStation())
{
......@@ -197,6 +202,7 @@ namespace DeviceLibrary
{
if (CommonVar.CheckTaskMoveFinished(agv, RecycleStation, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
curJobStep.ToNextStep(EXECUTE_STEP.R6_WAIT_RECYCLE_STATION_RESPONSE);
runInfo = "到达"+TargetPlace+",发送入料请求";
msg += runInfo;
......@@ -206,7 +212,7 @@ namespace DeviceLibrary
}
else if (curJobStep.IsStep(EXECUTE_STEP.R6_WAIT_RECYCLE_STATION_RESPONSE))
{
//int i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(RecycleStation) && s.StateEquals(eNodeStatus.MayEnter));
//int i = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(RecycleStation) && s.StateEquals(eNodeStatus.MayEnter));
//if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.R7_WAIT_SHELF_IN_LINE);
......@@ -227,8 +233,9 @@ namespace DeviceLibrary
{
if (CommonVar.CheckEnterOrLeaveFinished(agv, SettingString.Leave, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
CommonVar.server.CloseDoor(RecycleStation);
//int i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(RecycleStation) && s.StateEquals(eNodeStatus.FinishEnter));
//int i = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(RecycleStation) && s.StateEquals(eNodeStatus.FinishEnter));
//if (i > -1)
{
curJobStep.ToNextStep(EXECUTE_STEP.R9_END);
......@@ -242,6 +249,7 @@ namespace DeviceLibrary
{
if (CommonVar.CheckTaskMoveFinished(agv, SettingString.Standby, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
if (FindRecycleStation())
{
curJobStep.ToNextStep(EXECUTE_STEP.R5_WAIT_REACH_RECYCLE_STATION);
......@@ -263,6 +271,7 @@ namespace DeviceLibrary
// curJobStep.Msg = msg;
// return job;
//}
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
return null;
}
return this;
......@@ -276,24 +285,24 @@ namespace DeviceLibrary
{
if(shelfType.Equals(ShelfType.ReelString))
{
int i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.T4_1) && s.StateEquals(eNodeStatus.NeedEnter));
if(i==-1) i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.D1) && s.StateEquals(eNodeStatus.NeedEnter));
if (i == -1) i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A2) && s.StateEquals(eNodeStatus.NeedEnter));
int i = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.T4_1) && s.StateEquals(eNodeStatus.NeedEnter));
if(i==-1) i = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.D1) && s.StateEquals(eNodeStatus.NeedEnter));
if (i == -1) i = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A2) && s.StateEquals(eNodeStatus.NeedEnter));
if(i>-1)
{
RecycleStation = CommonVar.nodeInfo[i].Name;
RecycleStation = NodeManager.nodeInfo[i].Name;
return true;
}
}
else if(shelfType.Equals(ShelfType.PackingShelf))
{
int i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A3) && s.StateEquals(eNodeStatus.NeedEnter));
if (i == -1) i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A2) && s.StateEquals(eNodeStatus.NeedEnter));
if (i == -1) i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A8) && s.StateEquals(eNodeStatus.NeedEnter));
int i = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A3) && s.StateEquals(eNodeStatus.NeedEnter));
if (i == -1) i = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A2) && s.StateEquals(eNodeStatus.NeedEnter));
if (i == -1) i = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(SettingString.A8) && s.StateEquals(eNodeStatus.NeedEnter));
if (i > -1)
{
RecycleStation = CommonVar.nodeInfo[i].Name;
RecycleStation = NodeManager.nodeInfo[i].Name;
return true;
}
}
......
using Common;
using System;
namespace DeviceLibrary
{
......@@ -17,6 +18,8 @@ namespace DeviceLibrary
this.agvPlace = agvPlae;
TargetPlace = tarPlace;
this.RFID = RFID;
StartJobTime = DateTime.Now;
JobName = "送料串任务";
}
......@@ -30,7 +33,7 @@ namespace DeviceLibrary
/// 目的地
/// </summary>
public string TargetPlace { get; private set; }
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
......@@ -38,16 +41,16 @@ namespace DeviceLibrary
{
get
{
int t1 = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
int t1 = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = CommonVar.nodeInfo[t1].AliceName;
from = NodeManager.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
int t2 = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = CommonVar.nodeInfo[t2].AliceName;
to = NodeManager.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("送料串任务[RFID={4}]:{0} [目的地={1}][任务名称={2}][任务状态={3}]", runInfo, to, CurTaskName, CurTaskState, RFID);
......@@ -58,19 +61,19 @@ namespace DeviceLibrary
private string GetShowInfo()
{
int t1 = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
int t1 = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(agvPlace));
string from = "";
if (t1 > -1)
from = CommonVar.nodeInfo[t1].AliceName;
from = NodeManager.nodeInfo[t1].AliceName;
else
from = agvPlace;
int t2 = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
int t2 = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));
string to = "";
if (t2 > -1)
to = CommonVar.nodeInfo[t2].AliceName;
to = NodeManager.nodeInfo[t2].AliceName;
else
to = TargetPlace;
return string.Format("送料串任务: {0} [{1}->{2}]", runInfo, from, to);
return string.Format("{0} [{1}->{2}]", runInfo, from, to);
}
/// <summary>
/// 任务执行
......@@ -82,9 +85,11 @@ namespace DeviceLibrary
bool rtn = false;
agv.Msg = GetShowInfo();
agv.RFID = RFID;
StartJobTime = curJobStep.startTime;
CurTaskState = CommonVar.GetTakJobState(agv);
if (curJobStep.IsStep(EXECUTE_STEP.P1_NONE))
{
agv.HasError = false;
if (!agvPlace.StartsWith(SettingString.C4_Name_Prefix) && TargetPlace.StartsWith(SettingString.C4_Name_Prefix))//D C
{
curJobStep.ToNextStep(EXECUTE_STEP.P3_WAIT_REACH_4C_DOOR);
......@@ -118,6 +123,7 @@ namespace DeviceLibrary
{
if (CommonVar.CheckTaskMoveFinished(agv, TargetPlace, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
curJobStep.ToNextStep(EXECUTE_STEP.P4_WAIT_STATION_RESPONSE);
runInfo = "到达" + TargetPlace + ",并发送进料请求";
msg += runInfo;
......@@ -129,6 +135,7 @@ namespace DeviceLibrary
{
if (CommonVar.CheckTaskMoveFinished(agv, SettingString.DoorCToD, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_STATION);
runInfo = "到达3D门,去料架处" + TargetPlace;
msg += runInfo;
......@@ -142,6 +149,7 @@ namespace DeviceLibrary
{
if (CommonVar.CheckTaskMoveFinished(agv, SettingString.DoorDToC, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
curJobStep.ToNextStep(EXECUTE_STEP.P2_WAIT_REACH_STATION);
runInfo = "到达3C门,去料架处" + TargetPlace;
msg += runInfo;
......@@ -153,7 +161,7 @@ namespace DeviceLibrary
}
else if (curJobStep.IsStep(EXECUTE_STEP.P4_WAIT_STATION_RESPONSE))
{
int i = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));//&& s.StateEquals(eNodeStatus.MayEnter)
int i = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(TargetPlace));//&& s.StateEquals(eNodeStatus.MayEnter)
if (i > -1)
{
//curJobStep.ToNextStep(EXECUTE_STEP.P5_WAIT_SHELF_IN_STATION);
......@@ -174,38 +182,47 @@ namespace DeviceLibrary
}
else if (curJobStep.IsStep(EXECUTE_STEP.P5_WAIT_SHELF_IN_STATION))
{
int idx = CommonVar.nodeInfo.FindIndex(s=>s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.FinishEnter));
int idx = NodeManager.nodeInfo.FindIndex(s=>s.Name.Equals(TargetPlace) && s.StateEquals(eNodeStatus.FinishEnter));
if(idx>-1)
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
curJobStep.ToNextStep(EXECUTE_STEP.P6_TURN_DIRECTION);
runInfo = "料架进入" + TargetPlace + "完成";
agv.HasError = false;
msg += runInfo;
curJobStep.Msg = msg;
}
else if (curJobStep.IsTimeOut(60000, out double timeOutTime))
else if (curJobStep.IsTimeOut(60000, out TimeSpan timeSpan))
{
runInfo = string.Format("等待线体[{0}]进料完成信号[FinishEnter]超时{1}秒", TargetPlace, timeOutTime.ToString("f2"));
msg += string.Format("等待线体[{0}]进料完成信号[FinishEnter]超时", TargetPlace);
runInfo = string.Format("等待线体[{0}]进料完成信号[FinishEnter]超时", TargetPlace);
msg += runInfo;
curJobStep.Msg = msg;
agv.HasError = true;
agv.SetErrorMsg($"等待线体[{TargetPlace}]进料完成信号[FinishEnter]超时", timeSpan.TotalMinutes.ToString("f2"));
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P6_TURN_DIRECTION))
{
if (CommonVar.CheckEnterOrLeaveFinished(agv, SettingString.Leave, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
curJobStep.ToNextStep(EXECUTE_STEP.P7_END);
runInfo = "AGV在" + TargetPlace + "出料完成,开始转向";
agv.HasError = false;
msg += runInfo;
curJobStep.Msg = msg;
CommonVar.server.CloseDoor(TargetPlace);
//rtn = agv.AssignTask(SettingString.Turn);
//UpdateJobTaskInfo(agv);
}
else if (curJobStep.IsTimeOut(60000, out double timeOutTime))
else if (curJobStep.IsTimeOut(60000, out TimeSpan timeSpan))
{
runInfo = string.Format("线体[{0}]出料超时{1}秒,请检查料架情况", TargetPlace, timeOutTime.ToString("f2"));
msg += string.Format("线体[{0}]出料超时,请检查料架情况", TargetPlace);
runInfo = string.Format("线体[{0}]出料超时,请检查料架情况", TargetPlace);
msg += runInfo;
curJobStep.Msg = msg;
agv.HasError = true;
agv.SetErrorMsg($"线体[{TargetPlace}]出料超时,请检查料架情况", timeSpan.TotalMinutes.ToString("f2"));
}
}
else if (curJobStep.IsStep(EXECUTE_STEP.P7_END))
......@@ -217,6 +234,7 @@ namespace DeviceLibrary
runInfo = "AGV在" + TargetPlace + "转向完成,去退料线出口取一个料串回点料机";
msg += runInfo;
curJobStep.Msg = msg;
RecordRunLog(agv, curJobStep.CurStep(), runInfo, TargetPlace);
return new GetShelfJob(TargetPlace, SettingString.D24_Out, "B#", true);
}
else
......@@ -241,6 +259,7 @@ namespace DeviceLibrary
runInfo = "AGV在" + TargetPlace + "转向完成";
msg += runInfo;
curJobStep.Msg = msg;
RecordRunLog(agv, curJobStep.CurStep(), runInfo,TargetPlace);
return null;
}
}
......
using Common;
using System;
namespace DeviceLibrary
{
......@@ -14,6 +15,8 @@ namespace DeviceLibrary
public StandyJob(string agvPlae)
{
this.agvPlace = agvPlae;
StartJobTime = DateTime.Now;
JobName = "待机任务";
}
......@@ -22,7 +25,6 @@ namespace DeviceLibrary
/// </summary>
private string agvPlace = "";
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
......@@ -41,11 +43,12 @@ namespace DeviceLibrary
{
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = RunInfo;
agv.Msg = runInfo;
StartJobTime = curJobStep.startTime;
CurTaskState = CommonVar.GetTakJobState(agv);
if (curJobStep.IsStep(EXECUTE_STEP.NONE))
{
agv.HasError = false;
if (agvPlace.Equals(SettingString.Standby))//在待机位不操作
{
curJobStep.ToNextStep(EXECUTE_STEP.END);
......@@ -80,6 +83,7 @@ namespace DeviceLibrary
{
if (CommonVar.CheckTaskMoveFinished(agv, SettingString.DoorCToD, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, SettingString.DoorCToD);
curJobStep.ToNextStep(EXECUTE_STEP.WAIT_REACH_STANDBY);
runInfo = "从4D门回到待机位";
msg += runInfo;
......@@ -93,6 +97,7 @@ namespace DeviceLibrary
{
if (CommonVar.CheckTaskMoveFinished(agv, SettingString.Standby, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, SettingString.Standby);
curJobStep.ToNextStep(EXECUTE_STEP.END);
runInfo = "到达待机位";
msg += runInfo;
......@@ -107,6 +112,7 @@ namespace DeviceLibrary
runInfo = "在待机位检测到任务,执行任务";
msg += runInfo;
curJobStep.Msg = msg;
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return job;
}
}
......
......@@ -62,7 +62,7 @@ namespace DeviceLibrary
}
}
//检查紧急出料入口需要空料串
if (FindNeedEnterMission(currentAgv, SettingString.T4_1))//FindNeedEnterMission(currentAgv, SettingString.T4_1,ClientLevel.Middle,false) ||
if (FindNeedEnterMission(currentAgv, SettingString.T4_1,ClientLevel.Middle,false))//FindNeedEnterMission(currentAgv, SettingString.T4_1,ClientLevel.Middle,false) ||
//FindNeedEnterMission(currentAgv, SettingString.T4_1, ClientLevel.High, false)
{
......@@ -186,6 +186,14 @@ namespace DeviceLibrary
return new GetShelfJob(currentAgv.Place, SettingString.A9, rfid, true);
}
}
if (FindNeedLeaveMission(currentAgv, SettingString.D2, out rfid))
{
if(FindNeedEnterMission(currentAgv, SettingString.A8))
{
LogUtil.info(string.Format("{0} 任务生成:Place={1},rfid={2},点料机满料出口满,上料机构满,出到分盘线", currentAgv.Name, SettingString.D2, rfid));
return new GetShelfJob(currentAgv.Place, SettingString.D2, rfid, true);
}
}
}
......@@ -196,25 +204,25 @@ namespace DeviceLibrary
public static bool FindNeedLeave(Agv_Info agv, string nodeName, out string RFID, string RFID_Prefix = "")
{
int nodeIdx = CommonVar.FindNode(nodeName);
int nodeIdx = NodeManager.FindNode(nodeName);
RFID = "";
if (nodeIdx > -1)
{
if (RFID_Prefix.Equals(""))
{
nodeIdx = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedLeave));
nodeIdx = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedLeave));
}
else if (RFID_Prefix.Trim().Length == 1)
{
nodeIdx = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedLeave) && s.RFID.StartsWith(RFID_Prefix));
nodeIdx = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedLeave) && s.RFID.StartsWith(RFID_Prefix));
}
else
{
nodeIdx = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedLeave));
nodeIdx = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedLeave));
}
if (nodeIdx > -1)
{
RFID = CommonVar.nodeInfo[nodeIdx].RFID;
RFID = NodeManager.nodeInfo[nodeIdx].RFID;
return true;
}
}
......@@ -226,13 +234,13 @@ namespace DeviceLibrary
}
public static bool FindNeedEnter(Agv_Info agv, string nodeName, ClientLevel level= ClientLevel.Low, bool ignoreLevel = true)
{
int nodeIdx = CommonVar.FindNode(nodeName);
int nodeIdx = NodeManager.FindNode(nodeName);
if (nodeIdx > -1)
{
if (ignoreLevel)
nodeIdx = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedEnter));
nodeIdx = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedEnter));
else
nodeIdx = CommonVar.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedEnter)&& s.Level.Equals(level));
nodeIdx = NodeManager.nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.StateEquals(eNodeStatus.NeedEnter)&& s.Level.Equals(level));
if (nodeIdx > -1)
return true;
}
......
......@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace DeviceLibrary
{
public class AGVManager
public class APIManager
{
private static log4net.ILog log = log4net.LogManager.GetLogger("AGVManager");
/// <summary>
......@@ -96,7 +96,7 @@ namespace DeviceLibrary
string nodes="";
foreach (ShelfLockData item in serverResult.data)
{
CommonVar.GetNodeNameByAliceName(item.cid,out string nodeName);
NodeManager.FindNameBy(item.cid,out string nodeName);
int resInt = shelfLockNodeNames.FindIndex(s=>s !=null && s.Equals(nodeName));
if(resInt==-1)
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class NodeManager
{
/// <summary>
/// 节点信息
/// </summary>
public static List<ClientNode> nodeInfo;
public static void InitNodes()
{
nodeInfo = new List<ClientNode>();
}
public static void FindNameBy(string alicename, out string nodename)
{
nodename = "";
int id = nodeInfo.FindIndex(s => s.AliceName.Equals(alicename));
if (id > -1)
{
nodename = nodeInfo[id].Name;
}
}
/// <summary>
/// 查找节点是否存在以及是否调用
/// </summary>
/// <param name="nodeName">节点名称</param>
/// <returns></returns>
public static int FindNode(string nodeName)
{
int idx = nodeInfo.FindIndex(s => s.Name.Equals(nodeName) && s.IsUse);
return idx;
}
public static Node GetNodeBy(int i)
{
if (i > -1)
return nodeInfo[i];
return null;
}
public static eNodeStatus? GetState(int i)
{
return GetNodeBy(i)?.GetState();
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!