自动化立体仓库 - WCS系统
#
luxiaotao1123
2020-08-11 b2658337c8b37a745415e672074c86f43ca09d5e
src/main/java/com/zy/core/thread/CrnThread.java
@@ -28,6 +28,7 @@
    public CrnThread(CrnSlave slave) {
        this.slave = slave;
        this.connect();
    }
    @Override
@@ -43,10 +44,11 @@
                switch (step) {
                    // 读数据
                    case 1:
                        readStatus();   // 读取状态
                        readStatus();
                        break;
                    // 写入数据
                    case 2:
                        CrnCommand command = (CrnCommand) task.getData();
                        write((CrnCommand) task.getData());
                        break;
                    case 3:
                        break;
@@ -85,7 +87,7 @@
     * 读取状态
     */
    private void readStatus(){
        OperateResultExOne<byte[]> result = siemensNet.Read("DB8.18", (short) 10);
        OperateResultExOne<byte[]> result = siemensNet.Read("DB8.18", (short) 46);
        if (result.IsSuccess) {
            if (null == crnProtocol) {
                crnProtocol = new CrnProtocol();
@@ -118,8 +120,28 @@
    /**
     * 写入数据
     */
    private void write(){
    private void write(CrnCommand command){
        if (null == command) {
            log.error("堆垛机写入命令为空");
            return;
        }
        command.setCrnNo(slave.getId());
        short[] array = new short[9];
        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();
        OperateResult result = siemensNet.Write("DB8.0", array);
        if (result.IsSuccess) {
            readStatus();
        } else {
            log.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
        }
    }
    @Override