From 35fac40cfc0d636479bde094391e6f237b3116d4 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期三, 29 十一月 2023 15:29:58 +0800 Subject: [PATCH] #指令更新 --- src/main/java/com/zy/core/thread/SiemensCrnThread.java | 69 +++++++++++++++++++++++----------- 1 files changed, 47 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java index e63f0ce..caaad60 100644 --- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java +++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java @@ -392,7 +392,7 @@ } command.setCrnNo(slave.getId()); - short[] array = new short[12]; + short[] array = new short[10]; if (Cools.isEmpty(command.getAckFinish())) { array[0] = 5; } else { @@ -413,7 +413,7 @@ // }else { array[4] = command.getSourcePosX(); // } - array[5] = command.getDestinationPosY(); + array[5] = command.getSourcePosY(); array[6] = command.getDestinationPosZ(); // if (rowOne.contains(command.getDestinationPosX())){ @@ -429,9 +429,7 @@ // } array[8] = command.getDestinationPosY(); array[9] = command.getCommand(); - if (!Cools.isEmpty(command.getAuto())){ - array[10] = command.getAuto(); - } + // 浣滀笟淇℃伅 @@ -476,22 +474,24 @@ CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class); CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); CommandInfo commandInfo = commandInfoService.selectById(command.getCommandId()); - CommandInfoLog commandInfoLog = new CommandInfoLog(); - if (commandInfo != null) { - commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); - commandInfoLog.setId(null); - }else { - Date now = new Date(); - commandInfoLog.setCommand(JSON.toJSONString(command)); - commandInfoLog.setCommandStatus(3); - commandInfoLog.setStartTime(now); - commandInfoLog.setExecuteTime(now); - commandInfoLog.setCompleteTime(now); - commandInfoLog.setDevice(SlaveType.Devp.toString()); - commandInfoLog.setWrkNo(9999); - commandInfoLog.setTaskNo("9999"); - commandInfoLog.setCommandDesc("鎵嬪姩鍛戒护"); - } + CommandInfoLog commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); + commandInfoLog.setId(null); +// CommandInfoLog commandInfoLog = new CommandInfoLog(); +// if (commandInfo != null) { +// commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); +// commandInfoLog.setId(null); +// }else { +// Date now = new Date(); +// commandInfoLog.setCommand(JSON.toJSONString(command)); +// commandInfoLog.setCommandStatus(3); +// commandInfoLog.setStartTime(now); +// commandInfoLog.setExecuteTime(now); +// commandInfoLog.setCompleteTime(now); +// commandInfoLog.setDevice(SlaveType.Devp.toString()); +// commandInfoLog.setWrkNo(9999); +// commandInfoLog.setTaskNo("9999"); +// commandInfoLog.setCommandDesc("鎵嬪姩鍛戒护"); +// } if (result.IsSuccess) { @@ -501,6 +501,13 @@ //鏇存柊鎸囦护鏃ュ織 commandInfoLog.setDeviceLog("鎸囦护涓嬪彂鎴愬姛"); commandInfoLogService.insert(commandInfoLog); + + //绾跨▼鏆傚瓨鎸囦护ID + crnProtocol.setCommandId(command.getCommandId()); + + //鏇存柊鎸囦护鐘舵�� + commandInfo.setCommandStatus(CommandStatusType.EXECUTE.id);//鎵ц涓� + commandInfoService.updateById(commandInfo); //鏇存柊浠诲姟姝ュ簭 TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class); @@ -527,9 +534,27 @@ log.error("鍫嗗灈鏈哄啓鍏ュ懡浠や负绌�"); return false; } + OperateResult result = new OperateResult(); short[] array = new short[1]; array[0] = command.getAuto(); - OperateResult result = siemensNet.Write("DB100.20", array); + if(command.getAuto() !=0){ + array[0] = command.getAuto(); + result = siemensNet.Write("DB103.0", array); + }else if (command.getOnlineWrk1() != 0){ + array[0] = command.getOnlineWrk1(); + result = siemensNet.Write("DB103.2", array); + }else if (command.getOnlineWrk2() !=0){ + array[0] = command.getOnlineWrk2(); + result = siemensNet.Write("DB103.4", array); + }else if (command.getOnlineWrk3() != 0){ + array[0] = command.getOnlineWrk3(); + result = siemensNet.Write("DB103.6", array); + }else if (command.getOnlineWrk4() != 0){ + array[0] = command.getOnlineWrk4(); + result = siemensNet.Write("DB103.8", array); + } + + //鏇存柊鍛戒护鏃ュ織 CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class); -- Gitblit v1.9.1