Beispiel #1
0
        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;
                }
            }
        }
Beispiel #2
0
        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()));
            }
        }