/// <summary> /// 终止任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TerminateBtn_Click(object sender, RoutedEventArgs e) { try { if (CBdev.SelectedIndex == -1) { Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info); return; } string dev = CBdev.Text; RGV rgv = new RGV(dev); if (rgv.DeviceStatus() == RGV.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } byte[] order = RGV._StopTask(rgv.RGVNum()); if (!DataControl._mSocket.SendToClient(dev, order, out string result)) { Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error); return; } Notice.Show("终止任务 指令发送成功!", "成功", 3, MessageBoxIcon.Success); DataControl._mSocket.SwithRefresh(dev, true); } catch (Exception ex) { Notice.Show("指令发送失败:" + ex.ToString(), "错误", 3, MessageBoxIcon.Error); } }
/// <summary> /// 定位任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LocateBtn_Click(object sender, RoutedEventArgs e) { string dev = ""; byte[] order = null; try { if (CBdev.SelectedIndex == -1) { Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info); return; } if (string.IsNullOrEmpty(location.Text.Trim())) { Notice.Show("请填写目的坐标!", "提示", 3, MessageBoxIcon.Info); return; } dev = CBdev.Text; RGV rgv = new RGV(dev); if (rgv.ActionStatus() == RGV.Run) { Notice.Show("指令发送失败:设备运行中!", "错误", 3, MessageBoxIcon.Error); return; } if (rgv.DeviceStatus() == RGV.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } if (!WindowCommon.ConfirmAction("是否进行[定位任务]!!")) { return; } int loc = Convert.ToInt32(location.Text.Trim()); order = RGV._Position(rgv.RGVNum(), DataControl._mStools.IntToBytes(loc)); DataControl._mSocket.SwithRefresh(dev, false); if (!DataControl._mSocket.SendToClient(dev, order, out string result)) { DataControl._mSocket.SwithRefresh(dev, true); Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error); // LOG DataControl._mTaskTools.RecordTaskErrLog("LocateBtn_Click()", "运输车-定位任务[RGV,指令]", dev, DataControl._mStools.BytetToString(order), result.ToString()); return; } Notice.Show("定位任务 指令发送成功!", "成功", 3, MessageBoxIcon.Success); } catch (Exception ex) { Notice.Show("指令发送失败:" + ex.Message, "错误", 3, MessageBoxIcon.Error); // LOG DataControl._mTaskTools.RecordTaskErrLog("LocateBtn_Click()", "运输车-定位任务[RGV,指令]", dev, DataControl._mStools.BytetToString(order), ex.Message); } }
/// <summary> /// 定位任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LocateBtn_Click(object sender, RoutedEventArgs e) { try { if (CBdev.SelectedIndex == -1) { Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info); return; } if (string.IsNullOrEmpty(location.Text.Trim())) { Notice.Show("请填写目的坐标!", "提示", 3, MessageBoxIcon.Info); return; } string dev = CBdev.Text; RGV rgv = new RGV(dev); if (rgv.ActionStatus() == RGV.Run) { Notice.Show("指令发送失败:设备运行中!", "错误", 3, MessageBoxIcon.Error); return; } if (rgv.DeviceStatus() == RGV.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } int loc = Convert.ToInt32(location.Text.Trim()); byte[] order = RGV._Position(rgv.RGVNum(), DataControl._mStools.IntToBytes(loc)); if (!DataControl._mSocket.SendToClient(dev, order, out string result)) { Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error); return; } Notice.Show("定位任务 指令发送成功!", "成功", 3, MessageBoxIcon.Success); DataControl._mSocket.SwithRefresh(dev, false); } catch (Exception ex) { Notice.Show("指令发送失败:" + ex.ToString(), "错误", 3, MessageBoxIcon.Error); } }
/// <summary> /// 终止任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TerminateBtn_Click(object sender, RoutedEventArgs e) { string dev = ""; byte[] order = null; try { if (CBdev.SelectedIndex == -1) { Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info); return; } dev = CBdev.Text; RGV rgv = new RGV(dev); if (rgv.DeviceStatus() == RGV.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } order = RGV._StopTask(rgv.RGVNum()); if (!DataControl._mSocket.SendToClient(dev, order, out string result)) { Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error); // LOG DataControl._mTaskTools.RecordTaskErrLog("TerminateBtn_Click()", "运输车-终止任务[RGV,指令]", dev, DataControl._mStools.BytetToString(order), result.ToString()); return; } Notice.Show("终止任务 指令发送成功!", "成功", 3, MessageBoxIcon.Success); DataControl._mSocket.SwithRefresh(dev, true); } catch (Exception ex) { Notice.Show("指令发送失败:" + ex.Message, "错误", 3, MessageBoxIcon.Error); // LOG DataControl._mTaskTools.RecordTaskErrLog("TerminateBtn_Click()", "运输车-终止任务[RGV,指令]", dev, DataControl._mStools.BytetToString(order), ex.Message); } }
/// <summary> /// 启动辊台 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BTNrun_Click(object sender, EventArgs e) { try { if (CBdev.SelectedIndex == -1) { Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info); return; } string dev = CBdev.Text; RGV rgv = new RGV(dev); if (rgv.ActionStatus() == RGV.Run) { Notice.Show("指令发送失败:设备运行中!", "错误", 3, MessageBoxIcon.Error); return; } if (rgv.DeviceStatus() == RGV.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } // 方式 byte site1 = RGV.RollerRun1; if (CBsite1.SelectedValue.ToString() == "启动2#辊台") { site1 = RGV.RollerRun2; } if (CBsite1.SelectedValue.ToString() == "启动全部辊台") { site1 = RGV.RollerRunAll; } // 方向 byte site2 = RGV.RunFront; if (CBsite2.SelectedValue.ToString() == "反向启动") { site2 = RGV.RunObverse; } // 类型 byte site3 = RGV.GoodsReceive; if (CBsite3.SelectedValue.ToString() == "送货") { site3 = RGV.GoodsDeliver; } // 数量 byte site4 = RGV.GoodsQty1; if (CBsite4.SelectedValue.ToString() == "货物数量2") { site4 = RGV.GoodsQty2; } byte[] order = RGV._RollerControl(rgv.RGVNum(), site1, site2, site3, site4); if (!DataControl._mSocket.SendToClient(dev, order, out string result)) { Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error); return; } Notice.Show("启动辊台 指令发送成功!", "成功", 3, MessageBoxIcon.Success); DataControl._mSocket.SwithRefresh(dev, false); } catch (Exception ex) { Notice.Show("指令发送失败:" + ex.ToString(), "错误", 3, MessageBoxIcon.Error); } }
/// <summary> /// 运输车复位 /// </summary> /// <param name="dev"></param> /// <param name="mes"></param> public void ResetLoc_RGV(List <WCS_CONFIG_DEVICE> dev, out string mes) { try { // 运输车待命点1 int loc1 = Convert.ToInt32(DataControl._mStools.GetValueByKey("StandbyR1")); // 运输车待命点2 int loc2 = Convert.ToInt32(DataControl._mStools.GetValueByKey("StandbyR2")); // 获取当前摆渡车资讯 RGV a1 = new RGV(dev[0].DEVICE); RGV a2 = new RGV(dev[1].DEVICE); // 定位任务指令 byte[] order1; byte[] order2; // 任务明细 WCS_TASK_ITEM item1; WCS_TASK_ITEM item2; if (a1.GetCurrentSite() < a2.GetCurrentSite()) { // 定位任务指令 order1 = RGV._Position(a1.RGVNum(), DataControl._mStools.IntToBytes(loc1)); order2 = RGV._Position(a2.RGVNum(), DataControl._mStools.IntToBytes(loc2)); // 任务明细 item1 = new WCS_TASK_ITEM() { ITEM_ID = ItemId.运输车复位1, ID = 3, DEVICE = dev[0].DEVICE, LOC_TO = loc1.ToString() }; item2 = new WCS_TASK_ITEM() { ITEM_ID = ItemId.运输车复位2, ID = 4, DEVICE = dev[1].DEVICE, LOC_TO = loc2.ToString() }; } else { // 定位任务指令 order1 = RGV._Position(a1.RGVNum(), DataControl._mStools.IntToBytes(loc2)); order2 = RGV._Position(a2.RGVNum(), DataControl._mStools.IntToBytes(loc1)); // 任务明细 item1 = new WCS_TASK_ITEM() { ITEM_ID = ItemId.运输车复位2, ID = 3, DEVICE = dev[0].DEVICE, LOC_TO = loc2.ToString() }; item2 = new WCS_TASK_ITEM() { ITEM_ID = ItemId.运输车复位1, ID = 4, DEVICE = dev[1].DEVICE, LOC_TO = loc1.ToString() }; } // 加入任务作业链表 mes = null; if (dev[0].FLAG == DeviceFlag.空闲) { DataControl._mTaskControler.StartTask(new RGVTack(item1, DeviceType.运输车, order1)); } else { mes = dev[0].DEVICE + " 运输车目前无法操作复位任务; \r"; } if (dev[1].FLAG == DeviceFlag.空闲) { DataControl._mTaskControler.StartTask(new ARFTack(item2, DeviceType.运输车, order2)); } else { mes = mes + dev[1].DEVICE + " 运输车目前无法操作复位任务; \r"; } } catch (Exception ex) { throw ex; } }
/// <summary> /// 启动辊台 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BTNrun_Click(object sender, EventArgs e) { string dev = ""; byte[] order = null; try { if (CBdev.SelectedIndex == -1) { Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info); return; } dev = CBdev.Text; RGV rgv = new RGV(dev); if (rgv.ActionStatus() == RGV.Run) { Notice.Show("指令发送失败:设备运行中!", "错误", 3, MessageBoxIcon.Error); return; } if (rgv.DeviceStatus() == RGV.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } if (!WindowCommon.ConfirmAction("是否确定[启动滚筒任务]!!")) { return; } // 方式 byte site1 = RGV.RollerRun1; if (CBsite1.SelectedValue.ToString() == "启动2#辊台") { site1 = RGV.RollerRun2; } if (CBsite1.SelectedValue.ToString() == "启动全部辊台") { site1 = RGV.RollerRunAll; } // 方向 byte site2 = RGV.RunFront; if (CBsite2.SelectedValue.ToString() == "反向启动") { site2 = RGV.RunObverse; } // 类型 byte site3 = RGV.GoodsReceive; if (CBsite3.SelectedValue.ToString() == "送货") { site3 = RGV.GoodsDeliver; } // 数量 byte site4 = RGV.GoodsQty1; if (CBsite4.SelectedValue.ToString() == "货物数量2") { site4 = RGV.GoodsQty2; } order = RGV._RollerControl(rgv.RGVNum(), site1, site2, site3, site4); DataControl._mSocket.SwithRefresh(dev, false); if (!DataControl._mSocket.SendToClient(dev, order, out string result)) { DataControl._mSocket.SwithRefresh(dev, true); Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error); // LOG DataControl._mTaskTools.RecordTaskErrLog("BTNrun_Click()", "运输车-启动辊台任务[RGV,指令]", dev, DataControl._mStools.BytetToString(order), result.ToString()); return; } Notice.Show("启动辊台 指令发送成功!", "成功", 3, MessageBoxIcon.Success); } catch (Exception ex) { Notice.Show("指令发送失败:" + ex.Message, "错误", 3, MessageBoxIcon.Error); // LOG DataControl._mTaskTools.RecordTaskErrLog("BTNrun_Click()", "运输车-启动辊台任务[RGV,指令]", dev, DataControl._mStools.BytetToString(order), ex.Message); } }