自动化立体仓库 - WCS系统
#
luxiaotao1123
2022-01-05 4258c90146916435bdc34492cb9d1dbd7fac82d4
src/main/java/com/zy/core/thread/CrnThread.java
@@ -148,7 +148,9 @@
                if (crnProtocol.getStatusType().equals(CrnStatusType.WAITING)) {
                    log.error("-------------------------------------------第一步、[堆垛机号:{}][工作号:{}]==>> 状态为90,等待确认!!",slave.getId(),crnProtocol.getTaskNo());
                    if (resetFlag) {
                        if (melsecMcNet.Write("D2218", (short) 1).IsSuccess) {
                        CrnCommand crnCommand = new CrnCommand();
                        crnCommand.setAckFinish((short)1);
                        if (write(crnCommand)) {
                            resetFlag = false;
                        }
                    }
@@ -178,23 +180,39 @@
    /**
     * 写入数据
     */
    private void write(CrnCommand command){
    private boolean write(CrnCommand command){
        if (null == command) {
            log.error("堆垛机写入命令为空");
            return;
            return false;
        }
        command.setCrnNo(slave.getId());
        short[] array = new short[10];
        array[0] = command.getStatus();
        array[1] = command.getSourceRow(); // 排
        array[2] = command.getSourceBay(); // 列
        array[3] = command.getSourceLev(); // 层
        array[4] = command.getSourceSta(); // 站号
        array[5] = command.getDestinationPosRow(); // 排
        array[6] = command.getDestinationPosBay(); // 列
        array[7] = command.getDestinationPosLev(); // 层
        array[8] = command.getDestinationSta();  // 目标位置站号
        OperateResult result = melsecMcNet.Write("100", array);
        OperateResult result;
        if (command.getAckFinish() == 0) {
            array[0] = command.getAckFinish();
            array[1] = command.getTaskNo();
            array[2] = command.getTaskMode();
            array[3] = command.getSourcePosX();
            array[4] = command.getSourcePosY();
            array[5] = command.getSourcePosZ();
            array[6] = command.getDestinationPosX();
            array[7] = command.getDestinationPosY();
            array[8] = command.getDestinationPosZ();
            array[9] = command.getCommand();
            result = melsecMcNet.Write("D0", array);
            short[] array0 = new short[1];
            array0[0] = 1;
            result = melsecMcNet.Write("D9", array);
        } else {
        }
        try {
            // 日志记录
@@ -222,11 +240,12 @@
        if (result.IsSuccess) {
            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;
        } else {
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
            log.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            return false;
        }
    }
    @Override