#
Junjie
1 天以前 5f3aa14af4f0e0a2ea79240237b39a868ca25900
src/main/java/com/zy/core/network/real/ZyCrnV2RealConnect.java
@@ -141,6 +141,13 @@
                return response;
            }
            boolean commandAreaClearResult = clearCommandArea();
            if (!commandAreaClearResult) {
                News.error("堆垛机命令区清空失败 ===>> [id:{}]", command.getCrnNo());
                response.setMessage("堆垛机命令区清空失败");
                return response;
            }
            short[] array = new short[9];
            array[0] = command.getAckFinish().shortValue();
            array[1] = command.getTaskNo().shortValue();
@@ -228,4 +235,48 @@
        }
        return response;
    }
    private boolean clearCommandArea() throws InterruptedException {
        short[] array = new short[10];
        int clearIdx = 0;
        do {
            OperateResult result = siemensNet.Write("DB100.0", array);
            if (result.IsSuccess) {
                OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20);
                if (resultRead.IsSuccess && isCommandAreaEmpty(resultRead.Content)) {
                    return true;
                }
            }
            clearIdx++;
            Thread.sleep(200);
        } while (clearIdx < 5);
        return false;
    }
    private boolean isCommandAreaEmpty(byte[] content) {
        short ackFinish = siemensNet.getByteTransform().TransInt16(content, 0);
        short taskNo = siemensNet.getByteTransform().TransInt16(content, 2);
        short taskMode = siemensNet.getByteTransform().TransInt16(content, 4);
        short sourcePosX = siemensNet.getByteTransform().TransInt16(content, 6);
        short sourcePosY = siemensNet.getByteTransform().TransInt16(content, 8);
        short sourcePosZ = siemensNet.getByteTransform().TransInt16(content, 10);
        short destinationPosX = siemensNet.getByteTransform().TransInt16(content, 12);
        short destinationPosY = siemensNet.getByteTransform().TransInt16(content, 14);
        short destinationPosZ = siemensNet.getByteTransform().TransInt16(content, 16);
        short confirm = siemensNet.getByteTransform().TransInt16(content, 18);
        return ackFinish == 0
                && taskNo == 0
                && taskMode == 0
                && sourcePosX == 0
                && sourcePosY == 0
                && sourcePosZ == 0
                && destinationPosX == 0
                && destinationPosY == 0
                && destinationPosZ == 0
                && confirm == 0;
    }
}