From 920d87ad2ca03711af3683237efbb8f7ef5f53ea Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 14 七月 2025 07:53:25 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/thread/impl/ZyForkLiftThread.java |  437 ++++++++++++++++++++++--------------------------------
 1 files changed, 179 insertions(+), 258 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/impl/ZyForkLiftThread.java b/src/main/java/com/zy/core/thread/impl/ZyForkLiftThread.java
index 03ebd42..6840786 100644
--- a/src/main/java/com/zy/core/thread/impl/ZyForkLiftThread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZyForkLiftThread.java
@@ -5,29 +5,18 @@
 import HslCommunication.Profinet.Siemens.SiemensPLCS;
 import HslCommunication.Profinet.Siemens.SiemensS7Net;
 import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.mapper.EntityWrapper;
-import com.core.common.DateUtils;
-import com.core.common.SpringUtils;
-import com.zy.asrs.entity.BasLift;
-import com.zy.asrs.entity.DeviceDataLog;
-import com.zy.asrs.service.BasLiftService;
-import com.zy.asrs.service.DeviceDataLogService;
-import com.zy.asrs.utils.Utils;
-import com.zy.common.ExecuteSupport;
+import com.alibaba.fastjson.JSONObject;
+import com.zy.common.SpringUtils;
+import com.zy.common.utils.DateUtils;
 import com.zy.common.utils.RedisUtil;
 import com.zy.core.News;
-import com.zy.core.action.ForkLiftAction;
-import com.zy.core.action.ShuttleAction;
 import com.zy.core.cache.OutputQueue;
-import com.zy.core.enums.ForkLiftProtocolStatusType;
-import com.zy.core.enums.ForkLiftTaskModeType;
-import com.zy.core.enums.RedisKeyType;
-import com.zy.core.model.CommandResponse;
-import com.zy.core.model.ForkLiftSlave;
-import com.zy.core.model.command.ForkLiftCommand;
-import com.zy.core.model.protocol.ForkLiftProtocol;
-import com.zy.core.model.protocol.ForkLiftStaProtocol;
+import com.zy.core.enums.*;
+import com.zy.core.model.DeviceCommandMsgModel;
+import com.zy.core.model.DeviceMsgModel;
+import com.zy.core.properties.DeviceConfig;
 import com.zy.core.thread.ForkLiftThread;
+import com.zy.core.utils.DeviceMsgUtils;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 
@@ -38,43 +27,40 @@
 @SuppressWarnings("all")
 public class ZyForkLiftThread implements ForkLiftThread {
 
-    private ForkLiftSlave slave;
-    private ForkLiftProtocol forkLiftProtocol;
+    private DeviceConfig deviceConfig;
     private RedisUtil redisUtil;
     private SiemensS7Net siemensS7Net;
-    private List<ForkLiftStaProtocol> forkLiftStaProtocols = new ArrayList<>();
+    private boolean connect = false;
 
-    public ZyForkLiftThread(ForkLiftSlave slave, RedisUtil redisUtil) {
-        this.slave = slave;
+    public ZyForkLiftThread(DeviceConfig deviceConfig, RedisUtil redisUtil) {
+        this.deviceConfig = deviceConfig;
         this.redisUtil = redisUtil;
-        //鍒濆鍖栫珯鐐�
-        for (ForkLiftSlave.Sta sta : this.slave.getSta()) {
-            ForkLiftStaProtocol forkLiftStaProtocol = new ForkLiftStaProtocol();
-            forkLiftStaProtocol.setStaNo(sta.getStaNo());//绔欑偣鍙�
-            forkLiftStaProtocol.setLev(sta.getLev());//绔欑偣妤煎眰
-            String locNo = Utils.getLocNo(this.slave.getStaRow(), this.slave.getStaBay(), sta.getLev());
-            forkLiftStaProtocol.setLocNo(locNo);//绔欑偣搴撲綅鍙�
-            forkLiftStaProtocol.setLiftNo(sta.getLiftNo());//鎻愬崌鏈哄彿
-            forkLiftStaProtocols.add(forkLiftStaProtocol);
-        }
     }
 
     @Override
     public boolean connect() {
+        if (deviceConfig.getFake()) {
+            this.connect = true;
+            OutputQueue.FORKLIFT.offer(MessageFormat.format( "銆恵0}銆戣揣鍙夋彁鍗囨満杩炴帴鎴愬姛 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort(), 0, 0));
+            News.info("銆恵}銆戣揣鍙夋彁鍗囨満杩炴帴鎴愬姛 ===>> [id:{}] [ip:{}] [port:{}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
+            return true;
+        }
+
         boolean result = false;
-        siemensS7Net = new SiemensS7Net(SiemensPLCS.S1500, slave.getIp());
-        siemensS7Net.setRack(slave.getRack().byteValue());
-        siemensS7Net.setSlot(slave.getSlot().byteValue());
+        siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, deviceConfig.getIp());
+        siemensS7Net.setRack(Integer.valueOf(0).byteValue());
+        siemensS7Net.setSlot(Integer.valueOf(0).byteValue());
         OperateResult connect = siemensS7Net.ConnectServer();
         if(connect.IsSuccess){
             result = true;
-            OutputQueue.DEVP.offer(MessageFormat.format( "銆恵0}銆戣揣鍙夋彁鍗囨満杩炴帴鎴愬姛 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
-            News.info("璐у弶鎻愬崌鏈鸿繛鎺ユ垚鍔� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+            OutputQueue.FORKLIFT.offer(MessageFormat.format( "銆恵0}銆戣揣鍙夋彁鍗囨満杩炴帴鎴愬姛 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort(), 0, 0));
+            News.info("銆恵}銆戣揣鍙夋彁鍗囨満杩炴帴鎴愬姛 ===>> [id:{}] [ip:{}] [port:{}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
         } else {
-            OutputQueue.DEVP.offer(MessageFormat.format( "銆恵0}銆戣揣鍙夋彁鍗囨満杩炴帴澶辫触锛侊紒锛� ===>> [id:{1}] [ip:{2}] [port:{3}]  [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
-            News.error("璐у弶鎻愬崌鏈鸿繛鎺ュけ璐ワ紒锛侊紒 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+            OutputQueue.FORKLIFT.offer(MessageFormat.format( "銆恵0}銆戣揣鍙夋彁鍗囨満杩炴帴澶辫触锛侊紒锛� ===>> [id:{1}] [ip:{2}] [port:{3}]  [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort(), 0, 0));
+            News.error("銆恵}銆戣揣鍙夋彁鍗囨満杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
         }
         // siemensS7Net.ConnectClose();
+        this.connect = result;
         return result;
     }
 
@@ -85,262 +71,197 @@
 
     @Override
     public void run() {
-        News.info("{}鍙疯揣鍙夋彁鍗囨満绾跨▼鍚姩", slave.getId());
+        News.info("{}鍙疯揣鍙夋彁鍗囨満绾跨▼鍚姩", deviceConfig.getDeviceNo());
         this.connect();
         while (true) {
             try {
-                read();
+                DeviceMsgUtils deviceMsgUtils = null;
+                try {
+                    deviceMsgUtils = SpringUtils.getBean(DeviceMsgUtils.class);
+                }catch (Exception e){}
+                if (deviceMsgUtils == null) {
+                    continue;
+                }
+                DeviceCommandMsgModel deviceCommandMsg = deviceMsgUtils.getDeviceCommandMsg(SlaveType.ForkLift, deviceConfig.getDeviceNo());
+                if (deviceCommandMsg == null) {
+                    continue;
+                }
+                executeCommand(deviceCommandMsg, deviceMsgUtils);
+
                 Thread.sleep(200);
-                execute();
             } catch (Exception e) {
                 e.printStackTrace();
             }
         }
     }
 
-    private void execute() {
-        ForkLiftAction forkLiftAction = SpringUtils.getBean(ForkLiftAction.class);
-        if (forkLiftAction == null) {
+    private void executeCommand(DeviceCommandMsgModel deviceCommandMsg, DeviceMsgUtils deviceMsgUtils) {
+        if (deviceConfig.getFake()) {
+            redisUtil.set(RedisKeyType.FAKE_DEVICE_FORK_LIFT_COMMAND_MSG_KEY.key + deviceConfig.getDeviceNo(), deviceCommandMsg, 60 * 60);
             return;
         }
 
-        Object object = redisUtil.get(RedisKeyType.FORK_LIFT_FLAG.key + slave.getId());
-        if (object == null) {
-            return;
-        }
+        String command = JSON.toJSONString(deviceCommandMsg.getCommand());
+        JSONObject commandObj = JSON.parseObject(command);
 
-        Integer taskNo = Integer.valueOf(String.valueOf(object));
-        if (taskNo != 0) {
-            //瀛樺湪浠诲姟闇�瑕佹墽琛�
-            boolean result = forkLiftAction.executeWork(slave.getId(), taskNo);
-        }
-    }
+        HashMap<String, Object> resultData = new HashMap<>();
+        resultData.put("result", "false");
 
-    private void read() {
-        try {
-            readStatus();
+        String deviceMsgType = "command";
+        OperateResult result = null;
+        OperateResult result2 = null;
+        if (commandObj.getInteger("mode") == 3) {
+            //鍙栨斁璐�
+            short[] array = new short[4];
+            array[0] = commandObj.getShort("taskNO");//浠诲姟鍙�
+            array[1] = commandObj.getShort("mode");//浠诲姟妯″紡
+            array[2] = commandObj.getShort("pick");//鍙栬揣鏁版嵁
+            array[3] = commandObj.getShort("put");//鏀捐揣鏁版嵁
+            resultData.put("commandData", array);
 
-            //鎻愬崌鏈哄浜庤繍琛岀姸鎬侊紝灏嗘爣璁扮疆涓簍rue
-            if (forkLiftProtocol.getProtocolStatusType().equals(ForkLiftProtocolStatusType.PICK_UP)
-                    || forkLiftProtocol.getProtocolStatusType().equals(ForkLiftProtocolStatusType.PUT_DOWN)
-                    || forkLiftProtocol.getProtocolStatusType().equals(ForkLiftProtocolStatusType.WAITING)) {
-                forkLiftProtocol.setPakMk(true);
-            }
-        } catch (Exception e) {
-            OutputQueue.FORKLIFT.offer(MessageFormat.format("銆恵0}銆戣鍙栨彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
-        }
-    }
-
-    private void readStatus() {
-        try {
-            //鑾峰彇鎻愬崌鏈烘暟鎹�
-            OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB101.0", (short) 32);
-            if (result1.IsSuccess) {
-                if (null == forkLiftProtocol) {
-                    forkLiftProtocol = new ForkLiftProtocol();
-                    forkLiftProtocol.setLiftNo(slave.getId());
-                    forkLiftProtocol.setProtocolStatus(ForkLiftProtocolStatusType.NONE);
-
-                    InnerForkLiftExtend innerForkLiftExtend = new InnerForkLiftExtend();
+            result = siemensS7Net.Write("DB103.0", array);
+            if (result.IsSuccess) {
+                result2 = siemensS7Net.Write("DB103.8", (short) 1);
+                if (result2.IsSuccess) {
+                    resultData.put("result", "success");
                 }
+            }
+        } else if (commandObj.getInteger("mode") == 4) {
+            //灏忚溅鎹㈠眰
+            short[] array = new short[4];
+            array[0] = commandObj.getShort("taskNO");//浠诲姟鍙�
+            array[1] = commandObj.getShort("mode");//浠诲姟妯″紡
+            array[2] = commandObj.getShort("pick");//鍙栬揣鏁版嵁
+            array[3] = commandObj.getShort("put");//鏀捐揣鏁版嵁
+            resultData.put("commandData", array);
 
-                //----------璇诲彇鎻愬崌鏈虹姸鎬�-----------
+            result = siemensS7Net.Write("DB103.0", array);
+            if (result.IsSuccess) {
+                result2 = siemensS7Net.Write("DB103.8", (short) 1);
+                if (result2.IsSuccess) {
+                    resultData.put("result", "success");
+                }
+            }
+        } else if (commandObj.getInteger("mode") == 5) {
+            //鎻愬崌鏈虹Щ鍔�
+            short[] array = new short[4];
+            array[0] = commandObj.getShort("taskNO");//浠诲姟鍙�
+            array[1] = commandObj.getShort("mode");//浠诲姟妯″紡
+            array[2] = commandObj.getShort("pick");//鍙栬揣鏁版嵁
+            array[3] = commandObj.getShort("put");//鏀捐揣鏁版嵁
+            resultData.put("commandData", array);
+
+            result = siemensS7Net.Write("DB103.0", array);
+            if (result.IsSuccess) {
+                result2 = siemensS7Net.Write("DB103.8", (short) 1);
+                if (result2.IsSuccess) {
+                    resultData.put("result", "success");
+                }
+            }
+        } else if (commandObj.getInteger("mode") == 9996) {
+            //澶嶄綅
+            short[] array = new short[1];
+            array[0] = 1;
+            resultData.put("commandData", array);
+
+            result = siemensS7Net.Write("DB103.10", array);
+            if (result.IsSuccess) {
+                resultData.put("result", "success");
+            }
+        } else if (commandObj.getInteger("mode") == 9997) {
+            //鍒囨崲鍏ュ簱妯″紡
+            short[] array = new short[1];
+            array[0] = 1;
+            resultData.put("commandData", array);
+
+            result = siemensS7Net.Write("DB103.12", array);
+            if (result.IsSuccess) {
+                resultData.put("result", "success");
+            }
+        } else if (commandObj.getInteger("mode") == 9998) {
+            //鍒囨崲鍑哄簱妯″紡
+            short[] array = new short[1];
+            array[0] = 2;
+            resultData.put("commandData", array);
+
+            result = siemensS7Net.Write("DB103.12", array);
+            if (result.IsSuccess) {
+                resultData.put("result", "success");
+            }
+        } else if (commandObj.getInteger("mode") == 9999) {
+            //璇诲彇鐘舵��
+            JSONObject device = new JSONObject();
+
+            OperateResultExOne<byte[]> readResult1 = siemensS7Net.Read("DB101.0", (short) 18);
+            if (readResult1.IsSuccess) {
                 //妯″紡
-                forkLiftProtocol.setModel((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 0));
+                device.put("model", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 0));
                 //PLC浠诲姟鍙�
-                forkLiftProtocol.setWrkNo((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 4));
+                device.put("wrkNo", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 2));
                 //浠诲姟鐘舵��
-                forkLiftProtocol.setProtocolStatus((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 8));
+                device.put("protocolStatus", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 4));
                 //浠诲姟妯″紡
-                forkLiftProtocol.setModel((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 12));
+                device.put("taskMode", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 6));
                 //鍙栬揣鏁版嵁
-                forkLiftProtocol.setPick((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 16));
+                device.put("pick", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 8));
                 //鏀捐揣鏁版嵁
-                forkLiftProtocol.setPut((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 20));
+                device.put("put", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 10));
                 //鍑哄叆搴撴ā寮�
-                forkLiftProtocol.setIOMode((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 24));
+                device.put("iOMode", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 12));
                 //鏁呴殰鐮�
-                forkLiftProtocol.setErrorCode((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 28));
+                device.put("errorCode", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 14));
+                //灞�
+                device.put("lev", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 16));
 
-                //************琛ュ厖鎵╁睍瀛楁*************
-                InnerForkLiftExtend forkLiftExtend = (InnerForkLiftExtend) forkLiftProtocol.getExtend();
-                forkLiftProtocol.setExtend(forkLiftExtend);
-
-            }else {
-                OutputQueue.FORKLIFT.offer(MessageFormat.format("銆恵0}銆憑1}璇诲彇璐у弶鎻愬崌鏈虹姸鎬佷俊鎭け璐�", DateUtils.convert(new Date()), slave.getId()));
+                resultData.put("deviceStatus", device);
             }
 
-            if (System.currentTimeMillis() - forkLiftProtocol.getDeviceDataLog() > 1000 * 5) {
-                //閲囬泦鏃堕棿瓒呰繃5s锛屼繚瀛樹竴娆℃暟鎹褰�
-                //淇濆瓨鏁版嵁璁板綍
-                DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class);
-                DeviceDataLog deviceDataLog = new DeviceDataLog();
-                deviceDataLog.setOriginData(Base64.getEncoder().encodeToString(result1.Content));
-                deviceDataLog.setWcsData(JSON.toJSONString(forkLiftProtocol));
-                deviceDataLog.setType("forkLift");
-                deviceDataLog.setDeviceNo(forkLiftProtocol.getLiftNo());
-                deviceDataLog.setCreateTime(new Date());
-                deviceDataLogService.insert(deviceDataLog);
-
-                //鏇存柊閲囬泦鏃堕棿
-                forkLiftProtocol.setDeviceDataLog(System.currentTimeMillis());
+            //绔欑偣涓暟
+            int staCount = 4;
+            //璇诲彇鎵樼洏鏁版嵁
+            List<Integer> trayList = new ArrayList<>();
+            OperateResultExOne<byte[]> readResult2 = siemensS7Net.Read("DB102.0", (short) (staCount * 2));
+            if(readResult2.IsSuccess) {
+                for (int i = 0; i < staCount; i++) {
+                    short val = siemensS7Net.getByteTransform().TransInt16(readResult2.Content, i * 2);
+                    trayList.add((int) val);
+                }
             }
 
-            //灏嗘彁鍗囨満鐘舵�佷繚瀛樿嚦鏁版嵁搴�
-            BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class);
-            BasLift basLift = basLiftService.selectOne(new EntityWrapper<BasLift>()
-                    .eq("lift_no", slave.getId()));
-            if (basLift == null) {
-                basLift = new BasLift();
-                //鎻愬崌鏈哄彿
-                basLift.setLiftNo(forkLiftProtocol.getLiftNo());
-                basLift.setStatus(1);
-                basLiftService.insert(basLift);
-            }
-            //浠诲姟鍙�
-            basLift.setWrkNo(forkLiftProtocol.getTaskNo());
-            //淇敼鏃堕棿
-            basLift.setUpdateTime(new Date());
-            //璁惧鐘舵��
-            basLift.setDeviceStatus(JSON.toJSONString(forkLiftProtocol));
-            if (basLiftService.updateById(basLift)) {
-                OutputQueue.FORKLIFT.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), forkLiftProtocol.getLiftNo()));
+            //璇诲彇灏忚溅鏁版嵁
+            OperateResultExOne<byte[]> readResult3 = siemensS7Net.Read("DB102.50", (short) (staCount * 2));
+            List<Integer> carList = new ArrayList<>();
+            if(readResult3.IsSuccess) {
+                for (int i = 0; i < staCount; i++) {
+                    short val = siemensS7Net.getByteTransform().TransInt16(readResult3.Content, i * 2);
+                    carList.add((int) val);
+                }
             }
 
-        } catch (Exception e) {
-            OutputQueue.FORKLIFT.offer(MessageFormat.format("銆恵0}銆戣鍙栬揣鍙夋彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
-        }
-    }
+            device.put("trayList", trayList);
+            device.put("carList", carList);
 
-    @Override
-    public ForkLiftProtocol getStatus(boolean clone) {
-        if (this.forkLiftProtocol == null) {
-            return null;
-        }
-        return clone ? this.forkLiftProtocol.clone() : this.forkLiftProtocol;
-    }
-
-    @Override
-    public List<ForkLiftStaProtocol> getForkLiftStaProtocols() {
-        return this.forkLiftStaProtocols;
-    }
-
-    @Override
-    public ForkLiftProtocol getStatus() {
-        return getStatus(true);
-    }
-
-    @Override
-    public CommandResponse pickAndPut(ForkLiftCommand command) {
-        CommandResponse response = new CommandResponse(false);
-
-        short[] array = new short[4];
-        array[0] = command.getTaskNo();//浠诲姟鍙�
-        array[1] = command.getMode();//浠诲姟妯″紡
-        array[2] = command.getPick();//鍙栬揣鏁版嵁
-        array[3] = command.getPut();//鏀捐揣鏁版嵁
-        OperateResult result = siemensS7Net.Write("DB103.0", array);
-        if (result.IsSuccess) {
-            OperateResult result2 = siemensS7Net.Write("DB103.16", command.getConfirm());
-            if (result2.IsSuccess) {
-                response.setResult(true);
-            }
-        }
-        return response;
-    }
-
-    @Override
-    public CommandResponse shuttleSwitch(ForkLiftCommand command) {
-        CommandResponse response = new CommandResponse(false);
-
-        short[] array = new short[4];
-        array[0] = command.getTaskNo();//浠诲姟鍙�
-        array[1] = command.getMode();//浠诲姟妯″紡
-        array[2] = command.getPick();//鍙栬揣鏁版嵁
-        array[3] = command.getPut();//鏀捐揣鏁版嵁
-        OperateResult result = siemensS7Net.Write("DB103.0", array);
-        if (result.IsSuccess) {
-            OperateResult result2 = siemensS7Net.Write("DB103.16", command.getConfirm());
-            if (result2.IsSuccess) {
-                response.setResult(true);
-            }
-        }
-        return response;
-    }
-
-    @Override
-    public CommandResponse reset(ForkLiftCommand command) {
-        CommandResponse response = new CommandResponse(false);
-        return response;
-    }
-
-    @Override
-    public boolean isIdle() {
-        if (this.forkLiftProtocol.getTaskNo() == null
-                || this.forkLiftProtocol.getProtocolStatus() == null
-        ) {
-            return false;
+            deviceMsgType = "status";
         }
 
-        boolean res = this.forkLiftProtocol.getProtocolStatus() == ForkLiftProtocolStatusType.IDLE.id
-                && this.forkLiftProtocol.getTaskNo() == 0;
-        return res;
+        resultData.put("commandResult1", JSON.toJSONString(result));
+        resultData.put("commandResult2", JSON.toJSONString(result2));
+
+        if (deviceMsgType.equals("command")) {
+            log.info("鏀跺埌Rcs ForkLift Command Data: {}", JSON.toJSONString(deviceCommandMsg));
+        }
+        DeviceMsgModel deviceMsgModel = new DeviceMsgModel();
+        deviceMsgModel.setDeviceId(deviceConfig.getDeviceNo());
+        deviceMsgModel.setDeviceMsgType(deviceMsgType);
+        deviceMsgModel.setDeviceMsg(JSON.toJSONString(resultData));
+        deviceMsgModel.setDeviceOriginMsg(JSON.toJSONString(resultData));
+        deviceMsgModel.setResultKey(deviceCommandMsg.getResultKey());
+        deviceMsgUtils.sendDeviceMsg(SlaveType.ForkLift, deviceConfig.getDeviceNo(), deviceMsgModel);
     }
 
     @Override
-    public boolean isDeviceIdle() {
-        return false;
-    }
-
-    @Override
-    public boolean isDeviceIdle(ExecuteSupport support) {
-        return false;
-    }
-
-    @Override
-    public boolean setProtocolStatus(ForkLiftProtocolStatusType status) {
-        return false;
-    }
-
-    @Override
-    public boolean setSyncTaskNo(Integer taskNo) {
-        this.forkLiftProtocol.setSyncTaskNo(taskNo);
-        return true;
-    }
-
-    @Override
-    public int generateDeviceTaskNo(int taskNo, ForkLiftTaskModeType type) {
-        return taskNo;
-    }
-
-    @Override
-    public List<ForkLiftCommand> getPickAndPutCommand(Integer taskNo, Integer pick, Integer put) {
-        List<ForkLiftCommand> commands = new ArrayList<>();
-        ForkLiftCommand command = new ForkLiftCommand();
-        command.setLiftNo(slave.getId());
-        command.setTaskNo(taskNo.shortValue());
-        command.setMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue());
-        command.setPick(pick.shortValue());
-        command.setPut(put.shortValue());
-        command.setConfirm((short) 1);
-
-        commands.add(command);
-        return commands;
-    }
-
-    @Override
-    public List<ForkLiftCommand> getShuttleSwitchCommand(Integer taskNo, Integer originLev, Integer targetLev) {
-        List<ForkLiftCommand> commands = new ArrayList<>();
-        ForkLiftCommand command = new ForkLiftCommand();
-        command.setLiftNo(slave.getId());
-        command.setTaskNo(taskNo.shortValue());
-        command.setMode(ForkLiftTaskModeType.SHUTTLE_SWITCH.id.shortValue());
-        command.setPick(originLev.shortValue());
-        command.setPut(targetLev.shortValue());
-        command.setConfirm((short) 1);
-
-        commands.add(command);
-        return commands;
+    public DeviceConfig getDeviceConfig() {
+        return this.deviceConfig;
     }
 
     /**

--
Gitblit v1.9.1