#1
luxiaotao1123
2021-01-03 fb9405a0482b22cd9411ab3e24163f4fb17a5260
src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -8,7 +8,9 @@
import com.core.common.Arith;
import com.core.common.DateUtils;
import com.core.common.SpringUtils;
import com.zy.asrs.entity.BasCrnOpt;
import com.zy.asrs.entity.BasCrnp;
import com.zy.asrs.service.BasCrnOptService;
import com.zy.asrs.service.BasCrnpService;
import com.zy.core.CrnThread;
import com.zy.core.cache.MessageQueue;
@@ -71,7 +73,7 @@
                        }
                        command.setCrnNo(slave.getId()); // 堆垛机编号
                        command.setTaskNo((short) 0); // 工作号
                        command.setAckFinish((short) 1);  // 任务完成确认位
//                        command.setAckFinish((short) 1);  // 任务完成确认位
                        command.setTaskMode(CrnTaskModeType.NONE); // 任务模式
                        command.setSourcePosX((short)0);     // 源库位排
                        command.setSourcePosY((short)0);     // 源库位列
@@ -95,7 +97,7 @@
    @Override
    public boolean connect() {
        boolean result = false;
        siemensNet = new SiemensS7Net(SiemensPLCS.S300, slave.getIp());
        siemensNet = new SiemensS7Net(SiemensPLCS.S1200, slave.getIp());
        siemensNet.setRack(slave.getRack().byteValue());
        siemensNet.setSlot(slave.getSlot().byteValue());
        OperateResult connect = siemensNet.ConnectServer();
@@ -115,7 +117,7 @@
     * 读取状态
     */
    private void readStatus(){
        OperateResultExOne<byte[]> result = siemensNet.Read("DB8.18", (short) 62);
        OperateResultExOne<byte[]> result = siemensNet.Read("DB11.2", (short) 90);
        if (result.IsSuccess) {
            if (null == crnProtocol) {
                crnProtocol = new CrnProtocol();
@@ -185,18 +187,50 @@
            return false;
        }
        command.setCrnNo(slave.getId());
        short[] array = new short[9];
        array[0] = command.getAckFinish();
        array[1] = command.getTaskNo();
        array[2] = command.getTaskMode();
        short[] array = new short[13];
        if (!command.getTaskModeType().equals(CrnTaskModeType.CLEAR)) {
            array[0] = 5;
        } else {
            array[0] = 7;
        }
        array[1] = command.getSourcePosZ();
        array[2] = command.getSourcePosY();
        array[3] = command.getSourcePosX();
        array[4] = command.getSourcePosY();
        array[5] = command.getSourcePosZ();
        array[4] = command.getDestinationPosZ();
        array[5] = command.getDestinationPosY();
        array[6] = command.getDestinationPosX();
        array[7] = command.getDestinationPosY();
        array[8] = command.getDestinationPosZ();
        OperateResult result = siemensNet.Write("DB8.0", array);
        array[7] = command.getSourceStaNo();
        array[8] = command.getDestinationStaNo();
        array[9] = command.getSourceLane();
        array[10] = command.getDestinationLane();
        array[11] =
        OperateResult result = siemensNet.Write("DB10.0", array);
        if (result.IsSuccess) {
            try {
                // 日志记录
                BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class);
                BasCrnOpt basCrnOpt = new BasCrnOpt(
                        command.getTaskNo().intValue(),    // 任务号
                        command.getCrnNo(),    // 堆垛机[非空]
                        new Date(),    // 下发时间
                        command.getTaskModeType().toString(),    // 模式
                        command.getSourcePosX().intValue(),    // 源排
                        command.getSourcePosY().intValue(),    // 源列
                        command.getSourcePosZ().intValue(),    // 源层
                        null,    // 源站
                        command.getDestinationPosX().intValue(),    // 目标排
                        command.getDestinationPosY().intValue(),    // 目标列
                        command.getDestinationPosZ().intValue(),    // 目标层
                        null,    // 目标站
                        null,    // 响应结果
                        null,    // 修改时间
                        null    // 修改人员
                );
                bean.insert(basCrnOpt);
            } catch (Exception ignore) {}
            log.info("堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
            return true;