lty
6 天以前 0b6c8b7687ff593d254cfcacacf72a75bfdf11ca
src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -39,6 +39,10 @@
    private CrnProtocol crnProtocol;
    private boolean resetFlag = false;
    public Long sign = System.currentTimeMillis();
    public boolean isRunning = true;
    /**
     * 堆垛机是否在回原点运动中标记
     */
@@ -52,7 +56,7 @@
    @SuppressWarnings("InfiniteLoopStatement")
    public void run() {
        this.connect();
        while (true) {
        while (isRunning) {
            try {
                int step = 1;
                Task task = MessageQueue.poll(SlaveType.Crn, slave.getId());
@@ -93,7 +97,8 @@
            } catch (Exception e) {
//                e.printStackTrace();
            }
//            System.out.println("第"+slave.getId()+"个堆垛机线程运行一轮:"+(System.currentTimeMillis()-sign));
            sign = System.currentTimeMillis();
        }
    }
@@ -237,7 +242,7 @@
        }
//        convertRow(command);
        command.setCrnNo(slave.getId());
        short[] array = new short[10];
        short[] array = new short[12];
        array[0] = command.getAckFinish();
        array[1] = command.getTaskNo();
        array[2] = command.getTaskMode();
@@ -247,15 +252,18 @@
        array[6] = command.getDestinationPosX();
        array[7] = command.getDestinationPosY();
        array[8] = command.getDestinationPosZ();
//        array[9] = command.getSourceStaNo();
//        array[10] = command.getDestinationStaNo();
        array[9] = command.getCommand();
        array[9] = command.getSourceStaNo();
        array[10] = command.getDestinationStaNo();
        array[11] = command.getCommand();
        OperateResult result = siemensNet.Write("DB100.0", array);
        if (command.getAckFinish() == 0) {
        if(!result.IsSuccess){
            return false;
        }
        if (command.getAckFinish().intValue() == 0) {
            short commandFinish = 1;
            Thread.sleep(100L);
            result = siemensNet.Write("DB100.18", commandFinish);
            result = siemensNet.Write("DB100.22", commandFinish);
        }
        try {
@@ -268,12 +276,12 @@
                    command.getTaskModeType().toString(),    // 模式
                    command.getSourcePosX().intValue(),    // 源排
                    command.getSourcePosY().intValue(),    // 源列
                    command.getSourcePosZ().intValue(),    // 源层
                    null,    // 源站
                    command.getSourceStaNo().intValue(),    // 源层
                    command.getDestinationPosZ().intValue(),    // 源站
                    command.getDestinationPosX().intValue(),    // 目标排
                    command.getDestinationPosY().intValue(),    // 目标列
                    command.getDestinationPosZ().intValue(),    // 目标层
                    null,    // 目标站
                    command.getDestinationStaNo().intValue(),    // 目标站
                    null,    // 响应结果
                    null,    // 修改时间
                    null    // 修改人员
@@ -415,4 +423,9 @@
    }
    // 提供一个方法来停止线程
    public void requestStop() {
        isRunning = false;
    }
}