/// <summary> /// 放货 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UnloadBtn_Click(object sender, RoutedEventArgs e) { string dev = ""; byte[] order = null; try { if (CBdev.SelectedIndex == -1) { Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info); return; } if (string.IsNullOrEmpty(xlocation.Text.Trim()) || string.IsNullOrEmpty(ylocation.Text.Trim()) || string.IsNullOrEmpty(zlocation.Text.Trim())) { Notice.Show("请填写目的坐标!", "提示", 3, MessageBoxIcon.Info); return; } dev = CBdev.Text; ABC abc = new ABC(dev); if (abc.ActionStatus() == ABC.Run) { Notice.Show("指令发送失败:设备运行中!", "错误", 3, MessageBoxIcon.Error); return; } if (abc.DeviceStatus() == ABC.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } if (!WindowCommon.ConfirmAction("是否进行[放货任务]!!")) { return; } int x = Convert.ToInt32(xlocation.Text.Trim()); int y = Convert.ToInt32(ylocation.Text.Trim()); int z = Convert.ToInt32(zlocation.Text.Trim()); order = ABC._TaskControl(ABC.TaskRelease, abc.ABCNum(), DataControl._mStools.IntToBytes(x), DataControl._mStools.IntToBytes(y), DataControl._mStools.IntToBytes(z)); 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("UnloadBtn_Click()", "行车-放货任务[ABC,指令]", 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("UnloadBtn_Click()", "行车-放货任务[ABC,指令]", dev, DataControl._mStools.BytetToString(order), ex.Message); } }
/// <summary> /// 放货 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UnloadBtn_Click(object sender, RoutedEventArgs e) { try { if (CBdev.SelectedIndex == -1) { Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info); return; } if (string.IsNullOrEmpty(xlocation.Text.Trim()) || string.IsNullOrEmpty(ylocation.Text.Trim()) || string.IsNullOrEmpty(zlocation.Text.Trim())) { Notice.Show("请填写目的坐标!", "提示", 3, MessageBoxIcon.Info); return; } string dev = CBdev.Text; ABC abc = new ABC(dev); if (abc.ActionStatus() == ABC.Run) { Notice.Show("指令发送失败:设备运行中!", "错误", 3, MessageBoxIcon.Error); return; } if (abc.DeviceStatus() == ABC.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } int x = Convert.ToInt32(xlocation.Text.Trim()); int y = Convert.ToInt32(ylocation.Text.Trim()); int z = Convert.ToInt32(zlocation.Text.Trim()); byte[] order = ABC._TaskControl(ABC.TaskRelease, abc.ABCNum(), DataControl._mStools.IntToBytes(x), DataControl._mStools.IntToBytes(y), DataControl._mStools.IntToBytes(z)); 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); } }
public void Update() { if (isconnect != abc.IsAlive()) { ISConnect = abc.IsAlive(); } if (!abc.IsAlive()) { return; } if (actionsta != abc.ActionStatus()) { actionsta = abc.ActionStatus(); ActionStatus = ""; } if (devicesta != abc.DeviceStatus()) { devicesta = abc.DeviceStatus(); DeviceStatus = ""; } if (commandsta != abc.CommandStatus()) { commandsta = abc.CommandStatus(); CommandStatus = ""; } if (des_x_y_z != abc.GetGoodsSite()) { Des_X_Y_Z = abc.GetGoodsSite(); } if (now_task != abc.CurrentTask()) { now_task = abc.CurrentTask(); Now_Task = ""; } if (now_x_y_z != abc.GetCurrentSite()) { Now_X_Y_Z = abc.GetCurrentSite(); } if (finish_task != abc.FinishTask()) { finish_task = abc.FinishTask(); Finish_Task = ""; } if (loadstatus != abc.GoodsStatus()) { loadstatus = abc.GoodsStatus(); LoadStatus = ""; } if (errormsg != abc.ErrorMessage()) { errormsg = abc.ErrorMessage(); ErrorMsg = ""; } if (abc.GetUpdateTime(out string time)) { if (datatime != time) { DataTime = time; } } }
public override void DoWork() { try { // 异常 if (_device.DeviceStatus() == ABC.DeviceError || _device.CommandStatus() == ABC.CommandError) { ISetTaskErr(); // LOG log.LOG(DataControl._mTaskTools.GetLogMessE(ITEM, Order, "设备故障或命令错误.")); return; } #region 调试 if (PublicParam.IsIgnoreABC) //add调试判断 { if (_device.ActionStatus() == ABC.Stop) { // 发送指令 if (_device.ActionStatus() == ABC.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(); // LOG log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order)); } return; } #endregion // 取放货任务 if (ITEM.ITEM_ID == ItemId.行车取货) { // 有货则任务完成 if (_device.GoodsStatus() == ABC.GoodsYes && _device.ActionStatus() == ABC.Stop) { // 完成任务 ISetTaskSuc(); // LOG log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order)); return; } } else if (ITEM.ITEM_ID == ItemId.行车放货) { // 无货则任务完成 if (_device.GoodsStatus() == ABC.GoodsNo && _device.ActionStatus() == ABC.Stop) { // 完成任务 ISetTaskSuc(); // LOG log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order)); return; } } // 定位任务 else { // 当前位置与目的位置一致 视为任务完成 if (_device.GetCurrentSite().Equals(ITEM.LOC_TO)) { // 等待对接 ISetTaskWait(); // LOG log.LOG(DataControl._mTaskTools.GetLogMessW(ITEM, Order)); return; } } // 发送指令 if (_device.ActionStatus() == ABC.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)); } } catch (Exception ex) { // LOG log.LOG(DataControl._mTaskTools.GetLogMessE(ITEM, Order, ex.ToString())); } }