Commit b8cdb476 张东亮

佳世达3楼产线AGV程序

1 个父辈 c0fb8714
......@@ -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);
......
......@@ -108,7 +108,7 @@ namespace DeviceLibrary
//}
foreach (string item in Station.Keys)
{
if (Station[item].Equals(""))
if (Station[item].Equals("") || Station[item].Equals(agv.Name))
{
return true;
}
......@@ -128,9 +128,10 @@ namespace DeviceLibrary
agv.Place = "";
lock(loc)
{
LogUtil.info($"{agv.Name} 准备充电,充电桩情况:{Station.Values.ToArray()}");
foreach (string chargeStation in Station.Keys)
{
if (Station[chargeStation].Equals(""))
if (Station[chargeStation].Equals("") || Station[chargeStation].Equals(agv.Name))
{
rtn = MissionSys.AssignMission(agv, chargeStation);
if (rtn)
......
......@@ -132,6 +132,33 @@ namespace DeviceLibrary
{
if (!CheckOnline(i)) continue;
bool change = false;
if (!AGVManager.agvInfo[i].AllocatingTask && AGVManager.agvInfo[i].IsUse && AGVManager.agvInfo[i].CurJob != null && AGVManager.agvInfo[i].CurTaskID.Equals(-1))
{
if(AGVManager.agvInfo[i].UseFleet)
{
if (!MiR_API.Get_Fleet_Mission_Info(AGVManager.agvInfo[i]))
{
AGVManager.agvInfo[i].CurJob.ResendTask(AGVManager.agvInfo[i]);
LogUtil.info($"{AGVManager.agvInfo[i].Name}:Task=-1处理,Fleet无任务,重发任务:{AGVManager.agvInfo[i].CurTarName}");
}
else
{
LogUtil.info($"{AGVManager.agvInfo[i].Name}:Task=-1处理,Fleet有任务,手动赋值FleetTaskID={AGVManager.agvInfo[i].CurTaskID}");
}
}
else
{
if (!MiR_API.Get_Mission_Info(AGVManager.agvInfo[i]))
{
AGVManager.agvInfo[i].CurJob.ResendTask(AGVManager.agvInfo[i]);
LogUtil.info($"{AGVManager.agvInfo[i].Name}:Task=-1处理,Fleet无任务,重发任务:{AGVManager.agvInfo[i].CurTarName}");
}
else
{
LogUtil.info($"{AGVManager.agvInfo[i].Name}:Task=-1处理,Fleet有任务,手动赋值FleetTaskID={AGVManager.agvInfo[i].CurTaskID}");
}
}
}
MiR_API.Get_Task_State(AGVManager.agvInfo[i], out string taskStateStr);
Thread.Sleep(50);
//获取AGV状态
......
......@@ -128,7 +128,7 @@ namespace DeviceLibrary
LogUtil.info(string.Format("{0} Add_Mission [{1}] Fail", agv.Name, taskName));
}
}
agv.StateKanban.SetCurTask(MissionSys.GetAliceNameByTaskName(taskName));
agv.StateKanban.SetCurTask(MissionSys.GetAliceNameByTaskName(taskName)+"\r\n"+agv.CurTaskID);
}
return rtn;
}
......
......@@ -128,8 +128,15 @@ namespace DeviceLibrary
/// <summary>
/// 当前任务的ID号
/// </summary>
public int CurTaskID { get; set; } = -1;
public long CurTaskID { get; set; } = -1;
/// <summary>
/// 任务时间戳
/// </summary>
public string TimeStamp { get; set; } = "";
/// <summary>
/// 正在分配任务
/// </summary>
public bool AllocatingTask = false;
public string CurTaskState { get; set; } = "";
/// <summary>
/// 当前任务目的地名
......@@ -412,6 +419,7 @@ namespace DeviceLibrary
if (!isAlarm && StandTimeOut)
{
isAlarm = true;
SetErrorMsg("在" + PlaceAliceName + "停留超时", (DateTime.Now - StandStartTime).TotalMinutes.ToString("f2"));
msglist.Add(new AlarmMsg(Name, "lineAgv." + Name + ".Msg", "在" + PlaceAliceName + "停留超时" + (DateTime.Now - StandStartTime).TotalMinutes.ToString("f2") + "分钟"));
}
else if (!isAlarm && HasError)
......
......@@ -20,7 +20,7 @@ namespace DeviceLibrary
/// </summary>
public abstract Job Execute(Agv_Info agv);
public int CurTaskID { get; set; } = -1;
public long CurTaskID { get; set; } = -1;
/// <summary>
/// 当前的任务目的地(与任务GUID对应)
......
......@@ -29,7 +29,7 @@ namespace DeviceLibrary
}
}
private DateTime startTime = DateTime.Now;
public DateTime startTime = DateTime.Now;
public JobStep(T initStep)
{
......
......@@ -231,9 +231,12 @@ namespace DeviceLibrary
//删除上一任务
Del_Mission(info);
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(2021, 1, 1, 8, 0, 0)); // 当地时区
long timeStamp = (long)(DateTime.Now - startTime).TotalSeconds; // 相差秒数
info.TimeStamp = timeStamp.ToString();
string url = "http://" + info.IP + "/api/v2.0.0/mission_queue";
string body = "{\"mission_id\":\"" + mission_id + "\"}";
//string body = "{\"mission_id\":\"" + mission_id + "\"}";
string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.ID + ",\"description\":\"" + $"{info.CurTarName}-{info.TimeStamp}-{info.ID}" + "\"}";
string json = HttpPost(url, info.IP, info.Authorization, body);
if (string.IsNullOrWhiteSpace(json)) return false;
......@@ -283,23 +286,32 @@ namespace DeviceLibrary
{
try
{
info.AllocatingTask = true;
info.CurTaskID = -1;
info.CurTaskGUID = "";
info.CurTaskGUID = mission_id;
info.CurTaskState = SettingString.Wait;
//防止上一个任务已执行但返回失败时,删除任务
Del_Mission(info);
Del_Mission(info);
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(2021, 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.ID + "}";
// string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.ID + "}";
string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.ID + ",\"description\":\"" + $"{info.CurTarName}-{info.TimeStamp}-{info.ID}" + "\"}";
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;
}
......@@ -311,20 +323,24 @@ namespace DeviceLibrary
try
{
info.CurTaskID = Convert.ToInt32(id);
info.CurTaskGUID = mission_id;
}
catch
{
log.Info(string.Format("{0} Add_Mission_Fleet [{1}]", info.Name, mission_id));
info.CurTarName = "";
log.Error(string.Format("{0} Add_Mission_Fleet [{1}]", info.Name, mission_id));
}
info.AllocatingTask = false;
return true;
}
else
{
info.AllocatingTask = false;
return false;
}
}
catch (Exception ex)
{
info.AllocatingTask = false;
log.Error("Add_Mission_Fleet", ex);
return false;
}
......@@ -366,6 +382,82 @@ namespace DeviceLibrary
}
/// <summary>
/// 获取AGV任务队列
/// </summary>
/// <param name="info"></param>
/// <param name="mission"></param>
/// <returns></returns>
public static bool Get_Mission_Info(Agv_Info info)
{
try
{
string url = "http://" + info.IP + "/api/v2.0.0/missions/search";
string body = "{\"filters\" : [{\"fieldname\": \"description\", \"operator\": \"LIKE\", \"value\": \"" + info.CurTarName + "-" + info.TimeStamp + "-" + info.ID + "\"}]}";
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", 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.CurTarName + "-" + info.TimeStamp + "-" + info.ID + "\"}]}";
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>
/// 获取当前任务队列guid
/// </summary>
/// <param name="info"></param>
......@@ -678,7 +770,7 @@ namespace DeviceLibrary
ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{
log.Error("Ping " + ip + " 请求没有响应");
//log.Error("Ping " + ip + " 请求没有响应");
return false;
}
return true;
......@@ -725,7 +817,7 @@ namespace DeviceLibrary
string s = response.Content;
s = s.Replace("\n", "");
s = s.Replace(" ", "");
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;
}
......
......@@ -14,7 +14,6 @@ namespace DeviceLibrary
public ChargeJob(string agvPlae)
{
this.agvPlace = agvPlae;
JobName = "充电任务";
}
......@@ -40,7 +39,9 @@ namespace DeviceLibrary
public override Job Execute(Agv_Info agv)
{
string msg = string.Format("{0} 充电任务: ", agv.Name);
//bool rtn = false;
agv.Msg = "";
StartJobTime = curJobStep.startTime;
JobName = "充电任务";
CurTaskState = MissionSys.GetTakJobState(agv);
if (curJobStep.IsStep(CHARGE_STEP.NONE))
{
......@@ -134,6 +135,8 @@ namespace DeviceLibrary
{
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorAirOut, CurTaskState))
{
JobName = "待机任务";
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(CHARGE_STEP.WAIT_AGV_REACH_ROOMD_DOOR);
runInfo = string.Format("电量充足{0}%,从当前位置{1}回到待机位,先过{2}门",agv.Battery, agvPlace,SettingString.RoomC_Name);
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -146,8 +149,11 @@ namespace DeviceLibrary
{
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorCToD, CurTaskState))
{
if (agv.Battery >AGVManager.Charge.BatteryMax)
{
JobName = "待机任务";
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(CHARGE_STEP.WAIT_REACH_STANDBY);
runInfo = "电量充足" + agv.Battery + "%,从当前位置" + agvPlace + "回到待机位";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -159,6 +165,8 @@ namespace DeviceLibrary
{
if (!AGVManager.Charge.StartCharge(agv))
{
JobName = "待机任务";
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(CHARGE_STEP.WAIT_REACH_STANDBY);
runInfo = "电量" + agv.Battery + "%小于最大电量" + AGVManager.Charge.BatteryMax + "%,充电桩有小车,从当前位置" + agvPlace + "回到待机位";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -169,6 +177,7 @@ namespace DeviceLibrary
}
else
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(CHARGE_STEP.WAIT_REACH_CHARGE_STATION);
runInfo = "电量" + agv.Battery + "%小于最大电量" + AGVManager.Charge.BatteryMax + "%,从当前位置" + agvPlace + "回到充电位";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -222,6 +231,7 @@ namespace DeviceLibrary
{
if (agv.Battery >= AGVManager.Charge.BatteryMax)
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(CHARGE_STEP.END);
runInfo = "充电完成";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -248,6 +258,7 @@ namespace DeviceLibrary
{
if (MissionSys.CheckTaskFinished(agv, SettingString.Standby, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(CHARGE_STEP.END);
runInfo = "充电完成,到达待机位";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -257,6 +268,7 @@ namespace DeviceLibrary
else if (curJobStep.IsStep(CHARGE_STEP.END))
{
runInfo = "等待任务";
JobName = "待机任务";
Job job = AGVManager.control.GetJob(agv);
if (job != null && !(job is ChargeJob))
{
......@@ -267,16 +279,17 @@ namespace DeviceLibrary
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return job;
}
else if (job == null && agv.Battery < AGVManager.Charge.BatteryMax / 2)
else if (job != null && job is ChargeJob && agv.Battery < AGVManager.Charge.BatteryMax / 2 && AGVManager.Charge.HasEmptyChargeStation(agv))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(CHARGE_STEP.NONE);
runInfo = "在待机位暂无任务,且当前电量小于" + AGVManager.Charge.BatteryMax / 2 + "%,去充电位";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
curJobStep.Msg = msg;
AGVManager.Charge.DelOccupyInfo(agv);
return job;
}
}
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return this;
}
......
......@@ -51,6 +51,7 @@ namespace DeviceLibrary
{
string msg = string.Format("{0} 返回任务: ", agv.Name);
//bool rtn = false;
StartJobTime = curJobStep.startTime;
CurTaskState = MissionSys.GetTakJobState(agv);
if (curJobStep.IsStep(EMPTY_AGV_BACK_STEP.NONE))
{
......@@ -204,6 +205,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorAirOut, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(EMPTY_AGV_BACK_STEP.WAIT_AGV_REACH_RoomD_DOOR);
runInfo = string.Format("从产线{0}回待机位,先过{1}门", agvPlace, SettingString.RoomC_Name);
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -235,7 +237,6 @@ namespace DeviceLibrary
}
}
}
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return this;
}
/// <summary>
......
......@@ -58,6 +58,7 @@ namespace DeviceLibrary
string msg = string.Format("{0} 空料架[{1}]返回: ", agv.Name, shelfType.ToString());
//bool rtn = false;
//runInfo = "空料架返回:";
StartJobTime = curJobStep.startTime;
if (curJobStep.IsStep(EMPTY_SHELF_BACK_STEP.NONE))
{
if (AGVManager.CheckIsInAirDoor(EmptyShelfPlace))//C车间风淋门
......@@ -110,6 +111,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorAirOut, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(EMPTY_SHELF_BACK_STEP.WAIT_AGV_REACH_DOOR);
runInfo = string.Format("出风淋门,前往{0}门",SettingString.RoomD_Name);
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -123,6 +125,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorCToD, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
if (AGVManager.CheckA5A6State(agv, shelfType, out string nodeName))
{
EmptyShelfTargetPlace = nodeName;
......@@ -150,6 +153,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (AGVManager.CheckA5A6State(agv, shelfType, out string nodeName))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
EmptyShelfTargetPlace = nodeName;
curJobStep.ToNextStep(EMPTY_SHELF_BACK_STEP.WAIT_AGV_REACH_A5A6);
runInfo = "待机位检测到双层线需要料架,送往双层线 " + EmptyShelfTargetPlace;
......@@ -164,6 +168,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, EmptyShelfTargetPlace, CurTaskState) && EmptyShelfTargetPlace.StartsWith(SettingString.DoubleLine_Name_Prefix))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(EMPTY_SHELF_BACK_STEP.WAIT_DOUBLE_LINE_RESPONSE);
runInfo = "AGV到达 " + EmptyShelfTargetPlace + ",并发送入料架请求[ReadyEnter]";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -179,6 +184,7 @@ namespace DeviceLibrary
{
if (!agv.CurTarName.Equals(SettingString.Leave))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(EMPTY_SHELF_BACK_STEP.WAIT__EMPTY_SHELF_IN_DOUBLE_LINE);
runInfo = "收到双层线入料架请求[ReadyEnter]的响应 " + EmptyShelfTargetPlace + "入料架,小车链条运行";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -241,7 +247,6 @@ namespace DeviceLibrary
else if (curJobStep.IsStep(EMPTY_SHELF_BACK_STEP.END))
{
}
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return this;
}
......
......@@ -64,6 +64,7 @@ namespace DeviceLibrary
//bool rtn = false;
//if (!CurTaskID.Equals(-1) && Common.mir.Get_Task_State(CurTaskID, out string st))
// CurTaskState = st;
//StartJobTime = curJobStep.startTime;
if (jobStep.IsStep(ENTER_LEAVE_SHELF_STEP.NONE))
{
if (ActionType.Equals(eEnterLeaveType.Leave))
......
......@@ -52,6 +52,7 @@ namespace DeviceLibrary
{
string msg = string.Format("{0} 回收空料架[RFID={1}]: ", agv.Name, RFID);
//bool rtn = false;
StartJobTime = curJobStep.startTime;
int nodeIdx = AGVManager.FindNode(EmptyShelfPlace);
if (curJobStep.IsStep(TAKE_EMPTY_STEP.NONE))
{
......@@ -237,6 +238,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorDToC, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
if (AGVManager.CheckRoomCTarget(agv, EmptyShelfPlace))//被占用
{
curJobStep.ToNextStep(TAKE_EMPTY_STEP.WAIT_REACH_TEMP_PLACE);
......@@ -272,6 +274,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.C4_STANDBY1, CurTaskState) || MissionSys.CheckTaskFinished(agv, SettingString.C4_STANDBY2, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
if (!AGVManager.CheckRoomCTarget(agv, EmptyShelfPlace))//未占用
{
curJobStep.ToNextStep(TAKE_EMPTY_STEP.ASSIGN_AGV_TASK);
......@@ -287,6 +290,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorCToD, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(TAKE_EMPTY_STEP.ASSIGN_AGV_TASK);
runInfo = "开始执行回收空料架任务[" + agvPlae + "->" + EmptyShelfPlace + "]" + "[RFID=" + RFID + "]";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(), runInfo);
......@@ -298,6 +302,7 @@ namespace DeviceLibrary
if (nodeIdx > -1)
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(TAKE_EMPTY_STEP.WAIT_AGV_START_TASK);
runInfo = "AGV 添加任务:移动到" + EmptyShelfPlace + "[RFID=" + RFID + "]";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(), runInfo);
......@@ -317,6 +322,7 @@ namespace DeviceLibrary
{
if (agv.CurTaskState.Equals(SettingString.Executing))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(TAKE_EMPTY_STEP.WAIT_REACH_PLACE);
runInfo = "AGV开始向目的地[" + EmptyShelfPlace + "]移动" + "[RFID=" + RFID + "]";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(), runInfo);
......@@ -337,6 +343,7 @@ namespace DeviceLibrary
//}
//else
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(TAKE_EMPTY_STEP.WAIT_LINE_RESPONSE);
runInfo = "AGV到达 " + EmptyShelfPlace + " 向产线发送出料架请求[ReadyLeave]" + "[RFID=" + RFID + "]";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(), runInfo);
......@@ -371,6 +378,7 @@ namespace DeviceLibrary
agv.HasError = false;
if (!agv.CurTarName.Equals("Enter"))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(TAKE_EMPTY_STEP.WAIT_TAKE_EMPTY_SHELF);
runInfo = "收到产线出料请求[ReadyLeave]的响应 " + EmptyShelfPlace + "出料架,小车链条运行" + "[RFID=" + RFID + "]";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(), runInfo);
......@@ -429,7 +437,6 @@ namespace DeviceLibrary
{
}
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return this;
}
......
......@@ -50,6 +50,7 @@ namespace DeviceLibrary
public override Job Execute(Agv_Info agv)
{
string msg = string.Format("{0} 接满料任务: ", agv.Name);
StartJobTime = curJobStep.startTime;
//bool rtn = false;
if (curJobStep.IsStep(GO_FULL_SHELF_STATION_STEP.NONE))
{
......@@ -65,6 +66,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.CheckShelf, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
if (agv.IsExistShelf)
{
curJobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.END);
......@@ -121,6 +123,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorAirOut, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_AGV_REACH_DOOR);
runInfo = string.Format("过风淋门,向{0}门运行,再到双层线入料口{1}", SettingString.RoomD_Name,FullShelfStationPlace);
msg += string.Format("[{0}] {1}", curJobStep.CurStep(), runInfo);
......@@ -135,6 +138,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorCToD, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_AGV_REACH_A6);
runInfo = string.Format("到达{0}门,准备运动到双层线入料口{1}", SettingString.RoomD_Name, FullShelfStationPlace);
msg += string.Format("[{0}] {1}", curJobStep.CurStep(), runInfo);
......@@ -149,6 +153,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, FullShelfStationPlace, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
ClientNode node = AGVManager.nodeInfo.Find(s => s.Name.Equals(SettingString.A6)
&& (s.StateEquals(eNodeStatus.NeedLeave) || s.StateEquals(eNodeStatus.NeedEnterLeave)) && !s.RFID.StartsWith("0"));
if (node != null && node.Name.Equals(SettingString.A6))
......@@ -196,6 +201,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.Standby, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.END);
runInfo = "到达待机位";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(), runInfo);
......@@ -218,6 +224,7 @@ namespace DeviceLibrary
agv.HasError = false;
if (!agv.CurTarName.Equals("Enter"))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT__FULL_SHELF_IN_AGV);
runInfo = "收到双层线出料架请求[ReadyLeave]的响应 " + FullShelfStationPlace + "出料架,小车链条运行";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(), runInfo);
......@@ -241,6 +248,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.Enter, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
agv.HasError = false;
//GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.END);
runInfo = FullShelfStationPlace + "满料架进入小车完成";
......@@ -260,7 +268,6 @@ namespace DeviceLibrary
}
}
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return this;
}
......
......@@ -54,6 +54,7 @@ namespace DeviceLibrary
string msg = string.Format("{0} 送满料任务[RFID={1}]: ", agv.Name,RFID);
//bool rtn = false;
agv.RFID = RFID;
StartJobTime = curJobStep.startTime;
if (curJobStep.IsStep(SEND_FULL_SHELF_STEP.NONE))
{
HttpManager.AgvRemoveRfid(RFID);
......@@ -82,6 +83,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorDToC, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
if (AGVManager.CheckRoomCTarget(agv, FullShelfPlace))//被占用
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_REACH_TEMP_PLACE);
......@@ -120,7 +122,8 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorAirIn, CurTaskState))
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
runInfo = "送往[" + FullShelfPlace + "]";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
curJobStep.Msg = msg;
......@@ -133,6 +136,7 @@ namespace DeviceLibrary
CurTaskState = MissionSys.GetTakJobState(agv);
if (MissionSys.CheckTaskFinished(agv, SettingString.C4_STANDBY1, CurTaskState) || MissionSys.CheckTaskFinished(agv, SettingString.C4_STANDBY2, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
if (!AGVManager.CheckRoomCTarget(agv, FullShelfPlace))//未占用
{
if (AGVManager.CheckIsInAirDoor(FullShelfPlace))
......@@ -168,6 +172,7 @@ namespace DeviceLibrary
// SendFullShelfStep.Msg = msg;
// return new EnterLeaveShelfJob(FullShelfPlace, eEnterLeaveType.Leave);
//}
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
if (IsIgnoreBigShelf)
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_LINE_RESPONSE);
......@@ -203,6 +208,7 @@ namespace DeviceLibrary
System.Threading.Thread.Sleep(50);
if (HttpManager.GetRackBy(RFID, out string lineName) || (input != null && input[0]))
{
runInfo = "大料架在" + FullShelfPlace + "移库完成[" + agv.BoxDestInfo + "]";
agv.BoxDestInfo = "";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -221,6 +227,7 @@ namespace DeviceLibrary
{
if (!agv.CurTarName.Equals(SettingString.Leave))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT__SHELF_IN_LINE);
runInfo = "收到产线入料架请求[ReadyEnter]的响应 " + FullShelfPlace + "入料架,小车链条运行";
msg += string.Format("[{0}] {1}", curJobStep.CurStep(),runInfo);
......@@ -282,7 +289,6 @@ namespace DeviceLibrary
//{
//}
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return this;
}
......
......@@ -43,7 +43,7 @@ namespace DeviceLibrary
string msg = agv.Name + " ";
bool rtn = false;
agv.Msg = "";
StartJobTime = curJobStep.startTime;
CurTaskState = MissionSys.GetTakJobState(agv);
if (curJobStep.IsStep(EXECUTE_STEP.NONE))
{
......@@ -81,6 +81,7 @@ namespace DeviceLibrary
{
if (MissionSys.CheckTaskFinished(agv, SettingString.DoorCToD, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(EXECUTE_STEP.WAIT_REACH_STANDBY);
runInfo = "从"+SettingString.RoomD_Name+"门回到待机位";
msg += runInfo;
......@@ -94,6 +95,7 @@ namespace DeviceLibrary
{
if (MissionSys.CheckTaskFinished(agv, SettingString.Standby, CurTaskState))
{
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
curJobStep.ToNextStep(EXECUTE_STEP.END);
runInfo = "到达待机位";
msg += runInfo;
......@@ -112,7 +114,7 @@ namespace DeviceLibrary
return job;
}
}
RecordRunLog(agv, curJobStep.CurStep(), runInfo, agv.Place);
return this;
}
......
......@@ -236,7 +236,7 @@ namespace DeviceLibrary
{
int tarIdx = nodeInfo.FindIndex(s => s.Name == SettingString.A5
&& (s.StateEquals(eNodeStatus.NeedD) || s.StateEquals(eNodeStatus.NeedEnter)) && s.IsUse);
if (tarIdx >-1)
if (tarIdx > -1)
{
tarIdx = agvInfo.FindIndex(s => !s.IP.Equals(agv.IP) && s.CurJob != null && s.CurJob is EmptyShelfBackJob
&& ((((EmptyShelfBackJob)s.CurJob).EmptyShelfTargetPlace) != null) && ((EmptyShelfBackJob)s.CurJob).EmptyShelfTargetPlace.Equals(SettingString.A5));
......@@ -456,7 +456,7 @@ namespace DeviceLibrary
if (emptyAGVbACK)
{
//双层线是否需要小料架
if (CheckA5A6State(agv, eShelfType.SmallShelf,out string nodename))
if (CheckA5A6State(agv, eShelfType.SmallShelf, out string nodename))
{
//4C车间寻找
......@@ -693,13 +693,13 @@ namespace DeviceLibrary
{
if (clientNode.Name.Equals(SettingString.RoomCFeederOut) || clientNode.Name.Equals(SettingString.RoomDFeederOut))
{
warnMsg = string.Format("线体[{0}]外侧料架[{1}]未解绑,已解绑料架:{2}", clientNode.AliceName, clientNode.RFID, string.Join(",",unlockManager.GetUnlockRfids(clientNode.Name).ToArray()));
warnMsg = string.Format("线体[{0}]外侧料架[{1}]未解绑,已解绑料架:{2}", clientNode.AliceName, clientNode.RFID, string.Join(",", unlockManager.GetUnlockRfids(clientNode.Name).ToArray()));
log.Debug(warnMsg);
}
else
{
string res = HttpManager.GetRFIDs(clientNode.LineName);
warnMsg = string.Format("线体[{0}]外侧料架[{1}]未解绑,已解绑料架:{2}", clientNode.AliceName, clientNode.RFID, string.Join(",",unlockManager.GetUnlockRfids(clientNode.Name).ToArray()));
warnMsg = string.Format("线体[{0}]外侧料架[{1}]未解绑,已解绑料架:{2}", clientNode.AliceName, clientNode.RFID, string.Join(",", unlockManager.GetUnlockRfids(clientNode.Name).ToArray()));
log.Debug(warnMsg);
}
return false;
......@@ -717,7 +717,7 @@ namespace DeviceLibrary
public static bool UpdateStationState(ClientNode clientNode)
{
if (unlockManager.GetUnlockCnt(clientNode.Name) >0 && !unlockManager.GetUnlockRfids(clientNode.Name).Contains(clientNode.RFID))
if (unlockManager.GetUnlockCnt(clientNode.Name) > 0 && !unlockManager.GetUnlockRfids(clientNode.Name).Contains(clientNode.RFID))
{
if (clientNode.Name.Equals(SettingString.RoomCFeederOut) || clientNode.Name.Equals(SettingString.RoomDFeederOut))
{
......@@ -860,7 +860,7 @@ namespace DeviceLibrary
}
}
public class RunInfo
public class RunInfo
{
/// <summary>
/// AGV编号
......@@ -934,7 +934,15 @@ namespace DeviceLibrary
/// <summary>
/// AGV编号
/// </summary>
public string AGVNum { get; set; } = "";
public string AGVNum
{
get { return agvname; }
set
{
agvname = value.PadLeft(4, '0');
}
}
private string agvname = "";
/// <summary>
/// 开始时间
/// </summary>
......@@ -973,7 +981,7 @@ namespace DeviceLibrary
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)
if (agv.CurJob != null)
{
TaskName = agv.CurJob.JobName;
MissionInfo = agv.CurJob.runInfo;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!