#
luxiaotao1123
2022-01-05 4258c90146916435bdc34492cb9d1dbd7fac82d4
#
3个文件已修改
59 ■■■■ 已修改文件
src/main/java/com/zy/core/enums/CrnTaskModeType.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/command/CrnCommand.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/CrnThread.java 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/CrnTaskModeType.java
@@ -6,9 +6,12 @@
    PAKIN(1),    // 入库
    PAKOUT(2),    // 出库
    LOC_MOVE(3),    // 库位移转
    SITE_MOVE(4),    // 站位移转
    GO_ORIGIN(5),    // 回原点
    CLEAR(7),       // 清错
    X_MOVE(4),    // 站位移转
    Y_MOVE(5),    // 站位移转
    XY_MOVE(6),    // 站位移转
    GO_ORIGIN(7),    // 回原点
    BACK_ORIGIN(8),      // 回反原点
    CLEAR(9),       // 清错
    ;
    public Integer id;
src/main/java/com/zy/core/model/command/CrnCommand.java
@@ -71,6 +71,9 @@
    // 目标巷道
    private Short destinationLane = 0;
    // 任务确认 0:未确认 1:已确认
    private Short command = 0;
    public void setTaskMode(Short taskMode){
        this.taskMode = taskMode;
        this.taskModeType = CrnTaskModeType.get(taskModeType);
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