自动化立体仓库 - WCS系统
Junjie
2023-03-31 87c4efe93e6fe31a9c989b4aa5cc0c8f559b845d
src/main/java/com/zy/core/thread/SteThread.java
@@ -11,12 +11,16 @@
import com.core.exception.CoolException;
import com.zy.asrs.entity.BasSte;
import com.zy.asrs.entity.BasSteOpt;
import com.zy.asrs.entity.WrkCharge;
import com.zy.asrs.service.BasSteOptService;
import com.zy.asrs.service.BasSteService;
import com.zy.common.model.enums.WrkChargeType;
import com.zy.core.DevpThread;
import com.zy.core.News;
import com.zy.core.ThreadHandler;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.enums.SteStatusType;
import com.zy.core.model.SteSlave;
@@ -175,9 +179,77 @@
                steProtocol.setCrnStopRun(siemensS7Net.getByteTransform().TransInt16(result.Content, 38));
                steProtocol.setCrnStopFork(siemensS7Net.getByteTransform().TransInt16(result.Content, 40));
                steProtocol.setCrnAllowRun(siemensS7Net.getByteTransform().TransInt16(result.Content, 42));
                steProtocol.setChargeStatus(siemensS7Net.getByteTransform().TransInt16(result.Content, 44));
//                steProtocol.setCrnAllowRun(siemensS7Net.getByteTransform().TransInt16(result.Content, 44));
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1);
                if (!devpThread.charge0 || devpThread.charge1){
                    steProtocol.setChargeStatus((short)1);
                }else {
                    steProtocol.setChargeStatus((short)0);
                }
                OutputQueue.STE.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId()));
                //读取穿梭车设备信息,提供查询
                OperateResultExOne<byte[]> result1 = siemensS7Net.Read("V732", (short) 16);
                if (result1.IsSuccess) {
                    boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, 0, 15);
                    steProtocol.setLiftErr(status[0]);
                    steProtocol.setInFetchErr(status[2]);
                    steProtocol.setOutFetchErr(status[3]);
                    steProtocol.setAntiErr(status[4]);
                    steProtocol.setLiftSwitchErr(status[5]);
                    steProtocol.setTrackErr(status[6]);
                    steProtocol.setTimeoutErr(status[7]);
                    steProtocol.setConnectErr(status[8]);
                    steProtocol.setEmergencyErr(status[9]);
                    steProtocol.setTaskTypeErr(status[10]);
                    steProtocol.setTaskNoErr(status[11]);
                    steProtocol.setNewTaskErr(status[12]);
                    steProtocol.setErrTaskErr(status[13]);
                    steProtocol.setStopErr(status[14]);
                    steProtocol.setOfflineTaskErr(status[15]);
                    steProtocol.setStartTaskErr(status[16]);
                    steProtocol.setVoltageTaskErr(status[17]);
                    steProtocol.setDevpErr(status[63]);
                    steProtocol.setOnline(status[64]);
                    steProtocol.setNotOnTrack(status[65]);
                    steProtocol.setLowVoltage(status[66]);
                    steProtocol.setElectricityLoss(status[67]);
                    steProtocol.setForcedTravel(status[68]);
                    steProtocol.setDemoMode(status[69]);
                    steProtocol.setBrushConnect(status[70]);
//                    if (status[70]){
//                        steProtocol.setChargeStatus((short)1);
//                    }
                    steProtocol.setTaskManualForbid(status[71]);
                    steProtocol.setOnlineManualForbid(status[72]);
                    steProtocol.setDevpEmergency(status[73]);
                    steProtocol.setTaskInterrupt(status[74]);
                    steProtocol.setTaskClear(status[75]);
                    steProtocol.setTaskConfirmTimeout(status[76]);
                    steProtocol.setTaskWithCharge(status[77]);
                    steProtocol.setPakInTask(status[96]);
                    steProtocol.setPakOutTask(status[97]);
                    steProtocol.setPakMoveTask(status[98]);
                    steProtocol.setGoHpTask(status[99]);
                    steProtocol.setGoOHpTask(status[100]);
                    steProtocol.setGoHpAvoid(status[101]);
                    steProtocol.setGoOHpAvoid(status[102]);
                    steProtocol.setPakInEmpty(status[104]);
                    steProtocol.setPakInFinish(status[105]);
                    steProtocol.setPakOutEmpty(status[106]);
                    steProtocol.setPakOutFinish(status[107]);
                    steProtocol.setGoHpAvoidFinish(status[108]);
                    steProtocol.setGoOHpAvoidFinish(status[109]);
                    steProtocol.setGoHpAvoidErr(status[110]);
                    steProtocol.setGoOHpAvoidErr(status[111]);
                    steProtocol.setAutoMode(status[112]);
                    steProtocol.setVoltageLow(status[113]);
                }
                // 复位信号
                if (steProtocol.getWaiting()) {
@@ -189,7 +261,6 @@
                        }
                    }
                }
                // 根据实时信息更新数据库
                BasSteService service = SpringUtils.getBean(BasSteService.class);
@@ -228,10 +299,40 @@
            News.error("穿梭车写入命令为空");
            return false;
        }
        //判断小车是否在充电
        SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1);
        if (devpThread.charge1){
            // led 异常显示
            LedThread ledThread1 = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
            LedThread ledThread2 = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
            LedThread ledThread3 = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
            if (ledThread1 != null && ledThread2 != null && ledThread3 != null) {
                MessageQueue.offer(SlaveType.Led, 1, new Task(3, "穿梭车正在充电"));
                MessageQueue.offer(SlaveType.Led, 2, new Task(3, "穿梭车正在充电"));
                MessageQueue.offer(SlaveType.Led, 3, new Task(3, "穿梭车正在充电"));
            }
            News.error("穿梭车正在充电");
            return false;
        }else if (!devpThread.charge0){
            // led 异常显示
            LedThread ledThread1 = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
            LedThread ledThread2 = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
            LedThread ledThread3 = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
            if (ledThread1 != null && ledThread2 != null && ledThread3 != null) {
                MessageQueue.offer(SlaveType.Led, 1, new Task(3, "穿梭车可能在离线充电,检查电控柜穿梭车是否充电桩在线"));
                MessageQueue.offer(SlaveType.Led, 2, new Task(3, "穿梭车可能在离线充电,检查电控柜穿梭车是否充电桩在线"));
                MessageQueue.offer(SlaveType.Led, 3, new Task(3, "穿梭车可能在离线充电,检查电控柜穿梭车是否充电桩在线"));
            }
            News.error("穿梭车可能在离线充电,检查电控柜穿梭车是否充电桩在线");
            return false;
        }
        command.setSteNo(slave.getId());
        OperateResult result = null;
        // 开始任务
        if (!command.getComplete()) {
            //组织任务前,先清空写任务确认位,以及任务完成确认位
            siemensS7Net.Write("V2000.0", false);
            siemensS7Net.Write("V2000.1", false);
            // 1.任务号
            OperateResult result0 = siemensS7Net.Write("V998", command.getTaskNo().shortValue());
            try {