/// <summary> /// 添加任务 /// </summary> /// <param name="task"></param> public void AddTask(string jobid, string taskid, string area, TaskTypeEnum tasktype, DevFlag flag, string takesite, string givesite) { int id = ADS.ID; ADS.PlusID(); string[] take = takesite.Split('-'); string[] give = givesite.Split('-'); TaskAWC t = new TaskAWC() { id = id, jobid = jobid, taskid = taskid, area = area, tasktype = tasktype, flag = flag, takesiteX = int.Parse(take[0]), takesiteY = int.Parse(take[1]), takesiteZ = int.Parse(take[2]), givesiteX = int.Parse(give[0]), givesiteY = int.Parse(give[1]), givesiteZ = int.Parse(give[2]), taskstatus = TaskStatus.init, device = new DevInfoAWC() }; task.Add(t); t.InsertDB(); }
/// <summary> /// 扫码数据处理 /// </summary> /// <param name="devName"></param> /// <param name="code"></param> public void GetCode(string devName, string code) { try { if (!code.StartsWith("@") || code.Split('@').Length != 2) { return; } if (devices.Exists(c => c.devName == devName)) { DevInfoFRT f = devices.Find(c => c.devName == devName); //if (f._.ActionStatus == ActionEnum.运行中 || f._.RollerStatus != RollerStatusEnum.辊台停止) //{ // throw new Exception(string.Format("辊台未停止,不处理扫码.", code)); //} //是否满足任务 if (CommonSQL.GetInTask(code, out string tid)) { if (!string.IsNullOrEmpty(tid)) { if (string.IsNullOrEmpty(f.lockID1)) { // 请求WMS分配 if (ADS.AssignInSite(f.area, tid)) { f.IsLockUnlockNew(f.isLock, tid, f.lockID2); } } else if (string.IsNullOrEmpty(f.lockID2)) { if (tid != f.lockID1) { // 请求WMS分配 if (ADS.AssignInSite(f.area, tid)) { f.IsLockUnlockNew(f.isLock, f.lockID1, tid); } } } } } else { throw new Exception(string.Format("读取二维码[{0}]异常.", code)); } } } catch (Exception ex) { // LOG CommonSQL.LogErr("FRT.DoTaskNew()", "固定辊台作业[设备]", (ex.Message + ex.Source), devName); } }
/// <summary> /// 是否运作设备 /// </summary> private void CheckDev_Click(object sender, RoutedEventArgs e) { if (PublicParam.IsRe) { Notice.Show("处理基础信息后请重启,再开启调度!", "提示", 3, MessageBoxIcon.Info); CheckDev.IsChecked = false; } PublicParam.IsDoTask = (bool)CheckDev.IsChecked; // 终止辊台任务 ADS.StopRoll(); }
/// <summary> /// 初始化任务 /// </summary> public void InitTask(WCS_JOB_DETAIL d, TaskStatus ts) { task.Add(new TaskFRT() { id = d.ID, jobid = d.JOB_ID, area = d.AREA, tasktype = (TaskTypeEnum)d.TASK_TYPE, taskstatus = ts, fromdev = ADS.GetDevTypeEnum(d.DEV_FROM), todev = ADS.GetDevTypeEnum(d.DEV_TO), goodsnum = d.TAKE_NUM, device = string.IsNullOrEmpty(d.DEVICE) ? new DevInfoFRT() : devices.Find(c => c.devName == d.DEVICE) }); }
public WcsWindow() { InitializeComponent(); admin = new ADS(); wcsTabControl.Items.Add(new TabItem() { Header = "概况", Tag = "Home", Content = new W_INDEX() }); CheckIn.IsChecked = PublicParam.IsDoJobIn; CheckOut.IsChecked = PublicParam.IsDoJobOut; CheckDev.IsChecked = PublicParam.IsDoTask; CheckAGV.IsChecked = PublicParam.IsDoJobAGV; }
private void WindowX_Closing(object sender, System.ComponentModel.CancelEventArgs e) { var result = MessageBoxX.Show("是否退出程序", "警告", Application.Current.MainWindow, MessageBoxButton.YesNo, new MessageBoxXConfigurations() { MessageBoxStyle = MessageBoxStyle.Standard, MessageBoxIcon = MessageBoxIcon.Warning }); if (result == MessageBoxResult.Yes || result == MessageBoxResult.OK) { ADS.BeforeClose(); System.Environment.Exit(0); } else { e.Cancel = true; } }
/// <summary> /// 扫码数据处理 /// </summary> /// <param name="devName"></param> /// <param name="code"></param> public void GetCode(string devName, string code) { try { if (!code.StartsWith("@") || code.Split('@').Length != 2) { return; } if (devices.Exists(c => c.devName == devName)) { DevInfoPKL p = devices.Find(c => c.devName == devName); //if (p._.ActionStatus == ActionEnum.运行中) //{ // throw new Exception(string.Format("辊台未停止,不处理扫码.", code)); //} if (p.lockID2 != code) { //是否存在任务 if (!CommonSQL.IsExistsInTask(code)) { // 请求WMS分配 if (ADS.AssignInArea(p.area, code)) { p.IsLockUnlockNew(p.isLock, p.lockID1, code); } } else { throw new Exception(string.Format("读取二维码[{0}]异常.", code)); } } } } catch (Exception ex) { // LOG CommonSQL.LogErr("PKL.DoTaskNew()", "包装线作业[设备]", (ex.Message + ex.Source), devName); } }
void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { if (log == null) { log = new Log("app_error"); } ADS.BeforeClose(); //处理完后,需要将 Handler = true 表示已处理过此异常 e.Handled = true; log.LOG(e.Exception.Message + e.Exception.StackTrace); if (WindowCommon.ConfirmAction("是否重启,发现异常:\n" + e.Exception.Message + e.Exception.StackTrace)) { //////开启新的实例 System.Diagnostics.Process.Start(System.Windows.Forms.Application.ExecutablePath); } //////关闭当前实例 System.Diagnostics.Process.GetCurrentProcess().Kill(); }
private void GetBin_Click(object sender, RoutedEventArgs e) { try { if (DGtask.SelectedItem == null) { return; } if (!WindowCommon.ConfirmAction("是否请求库位分配!!")) { return; } string id = (DGtask.SelectedItem as DataRowView)["任务号"].ToString(); string status = (DGtask.SelectedItem as DataRowView)["任务状态"].ToString(); string type = (DGtask.SelectedItem as DataRowView)["任务类型"].ToString(); if (type == "入库") { // 请求WMS入库分配 if (ADS.AssignInSite("B01", id)) { Notice.Show("完成!请刷新~", "分配", 3, MessageBoxIcon.Success); } else { Notice.Show("失败!", "失败", 3, MessageBoxIcon.Warning); } } else { Notice.Show("该任务不符合分配条件!", "提示", 3, MessageBoxIcon.Info); } Refresh_Click(sender, e); } catch (Exception ex) { Notice.Show(ex.Message, "错误", 3, MessageBoxIcon.Error); } }
/// <summary> /// 添加任务 /// </summary> /// <param name="task"></param> public void AddTask(string jobid, string area, TaskTypeEnum tasktype, int goodsnum, DevType fromdev, DevType todev) { int id = ADS.ID; ADS.PlusID(); TaskPKL t = new TaskPKL() { id = id, jobid = jobid, area = area, tasktype = tasktype, goodsnum = goodsnum, fromdev = fromdev, todev = todev, taskstatus = TaskStatus.init, device = new DevInfoPKL() }; task.Add(t); t.InsertDB(); }
/// <summary> /// 添加任务 /// </summary> /// <param name="task"></param> public void AddTask(string jobid, string area, TaskTypeEnum tasktype, int goodsnum, int takesite, int givesite) { int id = ADS.ID; ADS.PlusID(); TaskARF t = new TaskARF() { id = id, jobid = jobid, area = area, tasktype = tasktype, goodsnum = goodsnum, takesite = takesite, givesite = givesite, taskstatus = TaskStatus.init, device = new DevInfoARF() }; task.Add(t); t.InsertDB(); }
private void RefreshData() { try { DList = ADS.GetDevInfo(); EList = ADS.GetDevError(); if (CommonSQL.GetWcsParam("WCS_SCAN_CODE", out List <WCS_PARAM> info)) { foreach (WCS_PARAM item in info) { bool isOnline = ADS.mSocket.IsConnected(string.Format("{0}-{1}-{2}", "Scan", item.VALUE4, item.VALUE5)); switch (item.VALUE3) { case 1: CBscan1.IsChecked = isOnline; break; case 2: CBscan2.IsChecked = isOnline; break; case 3: CBscan3.IsChecked = isOnline; break; default: break; } } } ShowData(); } catch (Exception ex) { Notice.Show(ex.Message, "异常", 3, MessageBoxIcon.Error); } }
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { //可以记录日志并转向错误bug窗口友好提示用户 if (e.ExceptionObject is System.Exception) { if (log == null) { log = new Log("app_error"); } Exception ex = (System.Exception)e.ExceptionObject; log.LOG(ex.Message + ex.StackTrace); ADS.BeforeClose(); if (WindowCommon.ConfirmAction("是否重启,发现异常:\n" + ex.Message + ex.Source)) { //////开启新的实例 System.Diagnostics.Process.Start(System.Windows.Forms.Application.ExecutablePath); } //////关闭当前实例 System.Diagnostics.Process.GetCurrentProcess().Kill(); } }
/// <summary> /// 检测任务状态 /// </summary> //public void DoTask() //{ // if (task == null || task.Count == 0) return; // foreach (TaskPKL t in task) // { // //if (!t.activie) continue; // if (t.taskstatus == TaskStatus.finish) continue; // if (string.IsNullOrEmpty(t.device.devName)) // { // DevInfoPKL device = FindFreeDevice(t.area); // if (device != null) // { // t.device = device; // t.device.IsLockUnlock(true, t.jobid); // t.UpdateDev(); // } // } // else // { // // 故障&异常 // if (t.device._.CommandStatus == CommandEnum.命令错误 || t.device._.DeviceStatus == DeviceEnum.设备故障) // { // continue; // } // switch (t.taskstatus) // { // case TaskStatus.init: // t.UpdateStatus(TaskStatus.ongivesite); // break; // case TaskStatus.totakesite: // break; // case TaskStatus.ontakesite: // break; // case TaskStatus.taking: // break; // case TaskStatus.taked: // break; // case TaskStatus.togivesite: // break; // case TaskStatus.ongivesite: // // 判断是否启动辊台送货 // if (t.giveready) // { // if (t.device._.GoodsStatus != GoodsEnum.辊台无货 && t.device._.ActionStatus == ActionEnum.停止) // { // t.device.StartGiveRoll(); // } // if (t.device._.CurrentTask == TaskEnum.辊台任务) // { // t.UpdateStatus(TaskStatus.giving); // } // } // else // { // // ? JOB 更新请求 // t.giveready = ADS.JobPartPKL_Give(t.jobid); // } // break; // case TaskStatus.giving: // if (t.device._.GoodsStatus == GoodsEnum.辊台无货) // { // if (t.device._.ActionStatus == ActionEnum.停止) // { // t.UpdateStatus(TaskStatus.gived); // } // else // { // t.device.StopTask(); // } // } // else // { // t.device.StartGiveRoll(); // } // break; // case TaskStatus.gived: // // 解锁设备、完成任务 // t.device.IsLockUnlock(false); // t.device = new DevInfoPKL(); // t.UpdateStatus(TaskStatus.finish); // break; // default: // break; // } // } // } //} public void DoTaskNew() { if (devices == null || devices.Count == 0) { return; } foreach (DevInfoPKL d in devices) { try { bool isCanWork = true; if (!d.isUseful || !ADS.mSocket.IsConnected(d.devName) || d._.CommandStatus == CommandEnum.命令错误 || d._.DeviceStatus == DeviceEnum.设备故障 || string.IsNullOrEmpty(d.lockID2)) { isCanWork = false; //continue; } int aid = 0; if (!d.isLock) { if (!PublicParam.IsDoJobAGV || !isCanWork) { continue; } if (d._.ActionStatus == ActionEnum.停止 && d._.GoodsStatus == GoodsEnum.辊台1有货) { if (string.IsNullOrEmpty(d.lockID1)) { aid = ADS.mNDCControl.IsExistLoad(d.devName); if (aid == 0) { // 没锁定就派车锁定 aid = CommonSQL.GetAGVid(); // NDC 任务是否存在 if (!ADS.mNDCControl.IsExist(aid)) { // ? NDC 生成 AGV 搬运任务 if (!ADS.mNDCControl.AddNDCTask(aid, d.devName, PublicParam.AgvUnLoadArea, out string result)) { // LOG CommonSQL.LogErr("PKL.DoTaskNew()", "AGV生成任务[ID,包装线辊台]", result, aid.ToString(), d.devName); continue; } } } if (aid != 0) { d.IsLockUnlockNew(true, aid.ToString(), d.lockID2); } } else { d.IsLockUnlockNew(true, d.lockID1, d.lockID2); } } } else { if (string.IsNullOrEmpty(d.lockID1)) { if (!isCanWork) { continue; } // 解锁 d.IsLockUnlockNew(false); continue; } else { aid = Convert.ToInt32(d.lockID1); // NDC 任务是否存在 if (!ADS.mNDCControl.IsExist(aid)) { if (!isCanWork) { continue; } // 解锁 d.IsLockUnlockNew(false); continue; } // NDC 任务状态 switch (ADS.mNDCControl.GetStatus(aid)) { case NDCPlcStatus.LoadUnReady: case NDCPlcStatus.LoadReady: if (!isCanWork) { break; } if (d._.ActionStatus == ActionEnum.停止 && d._.GoodsStatus == GoodsEnum.辊台1有货) { // NDC 请求 AGV 启动辊台装货 if (!ADS.mNDCControl.DoLoad(aid, out string result)) { // LOG if (!string.IsNullOrEmpty(result)) { CommonSQL.LogErr("PKL.DoTaskNew()", "AGV辊台装货[ID]", result, aid.ToString()); } } } break; case NDCPlcStatus.Loading: if (!isCanWork) { break; } if (d._.ActionStatus == ActionEnum.停止 && d._.GoodsStatus == GoodsEnum.辊台1有货) { d.StartGiveRoll(); } break; case NDCPlcStatus.Loaded: case NDCPlcStatus.UnloadUnReady: // NDC 任务是否需要重定向 if (!ADS.mNDCControl.IsRedirected(aid) && !string.IsNullOrEmpty(d.lockID2)) { // 获取WMS任务目的区域 string area = ADS.GetInAreaWMS(d.area, d.lockID2, out string tid); string frt = ADS.mFrt.GetRightFRT(area, TaskTypeEnum.入库); if (string.IsNullOrEmpty(area) || string.IsNullOrEmpty(frt)) { break; } // NDC 更新 AGV搬运卸货点 if (!ADS.mNDCControl.DoReDerect(aid, frt, out string result)) { // LOG CommonSQL.LogErr("PKL.DoTaskNew()", "AGV更新卸货点[ID]", result, aid.ToString()); break; } // 更新 CommonSQL.UpdateWms(tid, (int)WmsTaskStatus.待分配); } else { // 解锁 d.IsLockUnlockNew(false); } break; default: if (!isCanWork) { break; } // 解锁 d.IsLockUnlockNew(false); break; } } } } catch (Exception ex) { //if (ex.ToString().Contains("重复")) //{ // MessageBox.Show(d.devName + ex.ToString()); //} // LOG CommonSQL.LogErr("PKL.DoTaskNew()", "包装线作业[设备]", (ex.Message + ex.Source), d.devName); continue; } } }