public void Update() { if (isconnect != arf.IsAlive()) { ISConnect = arf.IsAlive(); } if (!arf.IsAlive()) { return; } if (actionsta != arf.ActionStatus()) { actionsta = arf.ActionStatus(); ActionStatus = ""; } if (devicesta != arf.DeviceStatus()) { devicesta = arf.DeviceStatus(); DeviceStatus = ""; } if (commandsta != arf.CommandStatus()) { commandsta = arf.CommandStatus(); CommandStatus = ""; } if (des_x_y_z != arf.Goods1site()) { Des_X_Y_Z = arf.Goods1site(); } if (now_task != arf.CurrentTask()) { now_task = arf.CurrentTask(); Now_Task = ""; } if (now_x_y_z != arf.CurrentSite()) { Now_X_Y_Z = arf.CurrentSite(); } if (finish_task != arf.FinishTask()) { finish_task = arf.FinishTask(); Finish_Task = ""; } if (loadstatus != arf.GoodsStatus()) { loadstatus = arf.GoodsStatus(); LoadStatus = ""; } if (rollerstatus != arf.CurrentStatus()) { rollerstatus = arf.CurrentStatus(); RollerStatus = ""; } if (rollerdirection != arf.RunDirection()) { rollerdirection = arf.RunDirection(); RollerDirection = ""; } if (errormsg != arf.ErrorMessage()) { errormsg = arf.ErrorMessage(); ErrorMsg = ""; } if (arf.GetUpdateTime(out string time)) { if (datatime != time) { DataTime = time; } } }
public override void DoWork() { try { // 异常 if (_device.DeviceStatus() == ARF.DeviceError || _device.CommandStatus() == ARF.CommandError) { ISetTaskErr(); // LOG log.LOG(DataControl._mTaskTools.GetLogMessE(ITEM, Order, "设备故障或命令错误.")); return; } // 对接任务 if (ITEM.ITEM_ID.Substring(0, 2) == "11") { #region 调试 if (PublicParam.IsIgnoreARF) //add调试判断 { if (_device.ActionStatus() == ARF.Stop) { // 发送指令 if (!DataControl._mSocket.SendToClient(ITEM.DEVICE, Order, out string result)) { throw new Exception(result); } DataControl._mSocket.SwithRefresh(ITEM.DEVICE, false); // LOG log.LOG(DataControl._mTaskTools.GetLogMess(ITEM, Order)); } else { Thread.Sleep(5000); // 完成任务 ISetTaskSuc(); // 解锁设备数据状态 DataControl._mTaskTools.DeviceUnLock(ITEM.DEVICE); // LOG log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order)); } return; } #endregion if (!string.IsNullOrEmpty(ITEM.LOC_TO.Trim())) // 目标不为空即最终无货 { // 获取目标设备类型 String typeTo = DataControl._mTaskTools.GetDeviceType(ITEM.LOC_TO); // 摆渡车对接 固定辊台/运输车 switch (typeTo) { case DeviceType.固定辊台: FRT _frt = new FRT(ITEM.LOC_TO); // 固定辊台停止状态 if (_frt.CurrentStatus() == FRT.RollerStop) { // 固定辊台上无货物 if (_frt.GoodsStatus() == FRT.GoodsNoAll) { return; } } else if (_device.GoodsStatus() == ARF.GoodsYesAll && _device.ActionStatus() == ARF.Stop && _frt.GoodsStatus() == FRT.GoodsYesAll && _frt.ActionStatus() == FRT.Stop) { return; // 摆渡车与摆渡车都有货,不启动辊台 } break; case DeviceType.运输车: RGV _rgv = new RGV(ITEM.LOC_TO); // 运输车辊台停止状态 if (_rgv.CurrentStatus() == RGV.RollerStop) { // 运输车辊台上无货物 if (_rgv.GoodsStatus() == RGV.GoodsNoAll) { return; } } else if (_device.GoodsStatus() == ARF.GoodsYesAll && _device.ActionStatus() == ARF.Stop && _rgv.GoodsStatus() == RGV.GoodsYesAll && _rgv.ActionStatus() == RGV.Stop) { return; // 摆渡车与运输车都有货,不启动辊台 } break; default: break; } // 摆渡车无货物 if (_device.GoodsStatus() == ARF.GoodsNoAll && _device.ActionStatus() == ARF.Stop) { // 完成任务 ISetTaskSuc(); // 解锁设备数据状态 DataControl._mTaskTools.DeviceUnLock(ITEM.DEVICE); // LOG log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order)); return; } } else { // 获取目标设备类型 String typeFrom = DataControl._mTaskTools.GetDeviceType(ITEM.LOC_FROM); // 摆渡车对接 固定辊台/运输车 switch (typeFrom) { case DeviceType.固定辊台: FRT _frt = new FRT(ITEM.LOC_FROM); // 固定辊台上无货物,摆渡车辊台上有货物 if (_frt.GoodsStatus() == FRT.GoodsNoAll && _device.GoodsStatus() != ARF.GoodsNoAll && _device.ActionStatus() == ARF.Stop) { // 完成任务 ISetTaskSuc(); // LOG log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order)); return; } else if (_device.GoodsStatus() == ARF.GoodsYesAll && _device.ActionStatus() == ARF.Stop && _frt.GoodsStatus() == FRT.GoodsYesAll && _frt.ActionStatus() == FRT.Stop) { return; // 摆渡车与摆渡车都有货,不启动辊台 } break; case DeviceType.运输车: RGV _rgv = new RGV(ITEM.LOC_FROM); // 运输车辊台上无货物,摆渡车辊台上有货物 if (_rgv.GoodsStatus() == FRT.GoodsNoAll && _device.GoodsStatus() != ARF.GoodsNoAll) { // 完成任务 ISetTaskSuc(); // LOG log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order)); return; } else if (_device.GoodsStatus() == ARF.GoodsYesAll && _device.ActionStatus() == ARF.Stop && _rgv.GoodsStatus() == RGV.GoodsYesAll && _rgv.ActionStatus() == RGV.Stop) { return; // 摆渡车与运输车都有货,不启动辊台 } break; default: break; } } // 发送指令 if (_device.ActionStatus() == ARF.Stop) { if (!DataControl._mSocket.SendToClient(ITEM.DEVICE, Order, out string result)) { throw new Exception(result); } DataControl._mSocket.SwithRefresh(ITEM.DEVICE, false); // LOG log.LOG(DataControl._mTaskTools.GetLogMess(ITEM, Order)); } } // 定位任务 else { // 发送指令 if (_device.ActionStatus() == ARF.Stop) { if (!DataControl._mSocket.SendToClient(ITEM.DEVICE, Order, out string result)) { throw new Exception(result); } DataControl._mSocket.SwithRefresh(ITEM.DEVICE, false); // LOG log.LOG(DataControl._mTaskTools.GetLogMess(ITEM, Order)); } // 当前位置与目的位置一致 视为任务完成 if (_device.CurrentSite() == Convert.ToInt32(ITEM.LOC_TO) && _device.ActionStatus() == ARF.Stop) { // 等待对接 ISetTaskWait(); // LOG log.LOG(DataControl._mTaskTools.GetLogMessW(ITEM, Order)); return; } } } catch (Exception ex) { // LOG log.LOG(DataControl._mTaskTools.GetLogMessE(ITEM, Order, ex.ToString())); } }