/// <summary> /// 安排进行行车作业 /// </summary> /// <returns></returns> public void LockAWC(string area, DevFlag df, TaskTypeEnum tt, string lockid) { try { if (devices.Exists(c => c.area == area && c.flag == DevFlag.参考)) { DevInfoAWC a = devices.Find(c => c.area == area && !c.isLock && c.isUseful && c.flag == DevFlag.参考); if (ADS.mSocket.IsConnected(a.devName) && string.IsNullOrEmpty(a.lockID) && a._.CommandStatus == CommandEnum.命令正常 && a._.GoodsStatus == AwcGoodsEnum.无货 && a._.DeviceStatus == DeviceEnum.设备正常 && a._.ActionStatus == ActionEnum.停止) { a.IsLockUnlockNew(tt, false, lockid); } } else { if (devices.Exists(c => c.area == area && !c.isLock && c.isUseful && c.flag == df)) { DevInfoAWC a = devices.Find(c => c.area == area && !c.isLock && c.isUseful && c.flag == df); if (ADS.mSocket.IsConnected(a.devName) && string.IsNullOrEmpty(a.lockID) && a._.CommandStatus == CommandEnum.命令正常 && a._.GoodsStatus == AwcGoodsEnum.无货 && a._.DeviceStatus == DeviceEnum.设备正常 && a._.ActionStatus == ActionEnum.停止) { a.IsLockUnlockNew(tt, false, lockid); } } } } catch (Exception ex) { throw ex; } }
/// <summary> /// 添加行车信息 /// </summary> private void AddAwc(DevInfoAWC awc) { if (!devices.Exists(c => c.devName == awc.devName)) { devices.Add(awc); } }
/// <summary> /// 是否能进行行车作业 /// </summary> /// <returns></returns> public bool IsOk(string area, DevFlag df) { try { bool res = false; if (devices.Exists(c => c.area == area && c.flag == DevFlag.参考)) { DevInfoAWC a = devices.Find(c => c.area == area && !c.isLock && c.isUseful && c.flag == DevFlag.参考); if (ADS.mSocket.IsConnected(a.devName) && string.IsNullOrEmpty(a.lockID) && a._.CommandStatus == CommandEnum.命令正常 && a._.GoodsStatus == AwcGoodsEnum.无货 && a._.DeviceStatus == DeviceEnum.设备正常 && a._.ActionStatus == ActionEnum.停止) { res = true; } } else { if (devices.Exists(c => c.area == area && !c.isLock && c.isUseful && c.flag == df)) { DevInfoAWC a = devices.Find(c => c.area == area && !c.isLock && c.isUseful && c.flag == df); if (ADS.mSocket.IsConnected(a.devName) && string.IsNullOrEmpty(a.lockID) && a._.CommandStatus == CommandEnum.命令正常 && a._.GoodsStatus == AwcGoodsEnum.无货 && a._.DeviceStatus == DeviceEnum.设备正常 && a._.ActionStatus == ActionEnum.停止) { res = true; } } } return(res); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取 X轴值距离 /// </summary> private int GetDisXByFlag(int x, DevFlag flag) { DevInfoAWC awc = devices.Find(c => c.flag == flag); if (awc == null) { return(999999); } return(Math.Abs(awc._.CurrentSiteX - x)); }
/// <summary> /// 添加所有行车信息 /// </summary> private void AddAllAwc() { List <WCS_CONFIG_DEVICE> list = CommonSQL.GetDevInfo(DeviceType.行车); if (list == null || list.Count == 0) { return; } foreach (WCS_CONFIG_DEVICE d in list) { AddAwc(new DevInfoAWC() { devName = d.DEVICE, area = d.AREA, taskType = (TaskTypeEnum)d.TASK_TYPE, isLock = d.IS_LOCK == 1 ? true : false, isUseful = d.IS_USEFUL == 1 ? true : false, lockID = d.LOCK_ID1, flag = (DevFlag)d.FLAG, gapX = d.GAP_X, gapY = d.GAP_Y, gapZ = d.GAP_Z, limitX = d.LIMIT_X, limitY = d.LIMIT_Y, _ = new DeviceAWC() }); ADS.mSocket.AddClient(d.DEVICE, d.IP, d.PORT, DevInfoAWC.GetDataOrder()); if (d.IS_USEFUL == 0) { ADS.mSocket.UpdateUserful(d.DEVICE, false); } } foreach (AreaDistance a in ADS.mDis.distances) { ChangeFlag(a.area); } }
/// <summary> /// 是否抵达取货点 /// </summary> /// <returns></returns> public bool IsInTakeSite(string area, DevFlag df, string loc) { try { bool res = false; if (string.IsNullOrEmpty(loc)) { return(res); } if (devices.Exists(c => c.area == area && !c.isLock && c.isUseful && c.flag == df)) { DevInfoAWC a = devices.Find(c => c.area == area && !c.isLock && c.isUseful && c.flag == df); if (ADS.mSocket.IsConnected(a.devName) && a._.CommandStatus == CommandEnum.命令正常 && a._.DeviceStatus == DeviceEnum.设备正常 && a._.ActionStatus == ActionEnum.停止) { int x = Convert.ToInt32(loc.Split('-')[0]) + a.gapX; int y = Convert.ToInt32(loc.Split('-')[1]) + a.gapY; // |接货点 - 当前坐标| <= 允许范围 if (Math.Abs(x - a._.CurrentSiteX) <= a.limitX && Math.Abs(y - a._.CurrentSiteY) <= a.limitY) { res = true; } else { if (IsSafeDis(a.area, df, a._.CurrentSiteX - a.gapX, x - a.gapX)) { a.ToSite(x, y); } } } } return(res); } catch (Exception ex) { throw ex; } }
/// <summary> /// 是否能取消行车出库任务 /// </summary> /// <returns></returns> public bool IsCanDelOut(string tid) { try { bool res = true; if (devices.Exists(c => c.lockID == tid)) { DevInfoAWC a = devices.Find(c => c.lockID == tid); if (a._.ActionStatus == ActionEnum.停止) { if (a.isLock || a._.GoodsStatus == AwcGoodsEnum.货) { res = false; } } else { if (a.isLock || a._.GoodsStatus == AwcGoodsEnum.货 || a._.CurrentTask != AwcTaskEnum.取货任务) { res = false; } } // 清任务 if (res) { if (ADS.mRgv.IsUnlock(tid)) { a.StopTask(); a.IsLockUnlockNew(TaskTypeEnum.无, false); } } } return(res); } catch (Exception ex) { throw ex; } }
/// <summary> /// 行车间是否安全距离 /// </summary> /// <param name="area"></param> /// <param name="df"></param> /// <param name="tx"></param> /// <returns></returns> public bool IsSafeDis(string area, DevFlag df, int cx, int tx) { try { bool res = false; switch (df) { case DevFlag.参考: res = true; break; case DevFlag.靠近入库口: case DevFlag.远离入库口: df = df == DevFlag.远离入库口 ? DevFlag.靠近入库口 : DevFlag.远离入库口; if (devices.Exists(c => c.area == area && c.flag == df)) { DevInfoAWC a = devices.Find(c => c.area == area && c.flag == df); if (a.isUseful) { if (ADS.mSocket.IsConnected(a.devName) && a._.CommandStatus == CommandEnum.命令正常 && a._.DeviceStatus == DeviceEnum.设备正常) { int disOK = 6000; int dis = ADS.mDis.GetAwcSafeDis(a.area); if (dis == 0) { throw new Exception("无对应行车安全距离!"); } tx = tx + a.gapX; if (Math.Abs(tx - a._.CurrentSiteX) >= disOK) { res = true; } else { if (a._.ActionStatus == ActionEnum.停止) { if (string.IsNullOrEmpty(a.lockID)) { a.ToSite(df == DevFlag.靠近入库口 ? (tx - dis) : (tx + dis), a._.CurrentSiteY); } } else { if (a._.CurrentTask == AwcTaskEnum.定位任务 && string.IsNullOrEmpty(a.lockID)) { cx = cx + a.gapX; if (Math.Abs(cx - a._.CurrentSiteX) >= disOK) { res = true; } else { a.ToSite(df == DevFlag.靠近入库口 ? (tx - dis) : (tx + dis), a._.CurrentSiteY); } } } } } } else { res = true; } } break; default: break; } return(res); } catch (Exception ex) { throw ex; } }
public void Update() { bool con = ADS.mSocket.IsConnected(DevName); DevInfoAWC awc = ADS.mAwc.devices.Find(c => c.devName == DevName); if (isconnect != con) { IsConnected = con; } if (isUseful != awc.isUseful) { IsUseful = awc.isUseful; } if (!con) { return; } if (actionsta != awc._.ActionStatus) { ActionStatus = awc._.ActionStatus; } if (devicesta != awc._.DeviceStatus) { DeviceStatus = awc._.DeviceStatus; } if (commandsta != awc._.CommandStatus) { CommandStatus = awc._.CommandStatus; } if (currenttask != awc._.CurrentTask) { CurrentTask = awc._.CurrentTask; } if (finishtask != awc._.FinishTask) { FinishTask = awc._.FinishTask; } if (x != awc._.CurrentSiteX) { CurrentSiteX = awc._.CurrentSiteX; } if (y != awc._.CurrentSiteY) { CurrentSiteY = awc._.CurrentSiteY; } if (z != awc._.CurrentSiteZ) { CurrentSiteZ = awc._.CurrentSiteZ; } if (goodstatus != awc._.GoodsStatus) { GoodsStatus = awc._.GoodsStatus; } if (errormsg != awc._.ErrorMessage) { ErrorMessage = awc._.ErrorMessage; } UpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (wmsloc != awc.lockLocWMS) { WMSloc = awc.lockLocWMS; } }