ty130316261 лет назад: 3
Родитель
Сommit
723e4675a5

+ 18 - 7
zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDService.java

@@ -127,7 +127,7 @@ public class DeJuRFIDService implements IService {
         String ipAddress = hardware.getIpAddress();
         if (clientMap.containsKey(ipAddress)) {
             GClient client = clientMap.get(ipAddress);
-            changeGpo(0, client);
+            changeGpo(0, client,0);
             MsgBaseStop msg = new MsgBaseStop();
             // 停止读卡,空闲态
             client.sendSynMsg(msg);
@@ -142,7 +142,16 @@ public class DeJuRFIDService implements IService {
         }
     }
 
-    private void changeGpo(int state, GClient client) {
+    private void changeGpo(int state, GClient client,int delayTime) {
+        MsgAppGetGpiState msgAppGetGpiState=new MsgAppGetGpiState();
+        client.sendSynMsg(msgAppGetGpiState);
+        if (0 == msgAppGetGpiState.getRtCode()) {
+            HashMap<Integer, Integer> gpiState = msgAppGetGpiState.getHpGpiState();
+            log.info("GpiState epc {} successful.",gpiState.get(1));
+        } else {
+            log.error("GpiState epc error.");
+        }
+
         MsgAppSetGpo msgAppSetGpo=new MsgAppSetGpo();
         msgAppSetGpo.setGpo1(state);
         msgAppSetGpo.setGpo2(state);
@@ -151,18 +160,21 @@ public class DeJuRFIDService implements IService {
         String status = state == 1 ? "start" : "stop";
         if (0 == msgAppSetGpo.getRtCode()) {
             log.info("Gpo epc {} successful.",status);
+            if (state==1){
+                stopGpo(client,delayTime);
+            }
         } else {
             log.error("Gpo epc {} error.",status);
         }
     }
 
-    public void stopGpo(GClient client){
+    public void stopGpo(GClient client,int delayTime){
         scheduledExecutorService.schedule(new TimerTask() {
             @Override
             public void run() {
-                changeGpo(0, client);
+                changeGpo(0, client,0);
             }
-        },10, TimeUnit.SECONDS);
+        },delayTime, TimeUnit.SECONDS);
     }
 
     /**
@@ -175,8 +187,7 @@ public class DeJuRFIDService implements IService {
             if (logBaseEpcInfo.getResult() == 0) {
                 log.info("===========》{}",logBaseEpcInfo.getbEpc());
                 //灯带设置
-                changeGpo(1, client);
-                stopGpo(client);
+                changeGpo(1, client,10);
                 InventoryTag tag = new InventoryTag();
                 BeanUtils.copyProperties(logBaseEpcInfo, tag);
                 sendService.send(tag);