فهرست منبع

消息创建bugfix

songwenbin 2 سال پیش
والد
کامیت
35c7799224

+ 19 - 8
gddlly/src/main/java/com/gyee/edge/gddlly/iec104/Iec104Session.java

@@ -173,21 +173,15 @@ public class Iec104Session {
 
     private boolean sendPoints(ArrayList<Point> allPoints, boolean isContinous, String pointType) {
         List<Point> pointList = new ArrayList<>();
-        Iec104Message msg104 = new Iec104Message();
-        msg104.setAcceptSeq(acceptSeq);
-        msg104.setTransferReason((short)20);
         //每个消息内测点的数量
         int maxPointsPerMessage = 16;
         if ("AI".equals(pointType.toUpperCase())) {
-            msg104.setTypeIdentifier(TypeIdentifierEnum.shortFloatingPointTelemetry); //M_ME_TF_1
             maxPointsPerMessage = iec104Config.getFrameAiMax();
         } else {
-            msg104.setTypeIdentifier(TypeIdentifierEnum.onePointTimeTeleindication); //M_SP_TB_1
             maxPointsPerMessage = iec104Config.getFrameDiMax();
         }
-        //todo: 设置VSQ,可变结构描述限定词
-        msg104.setContinuous(isContinous);
-        msg104.setTerminalAddress(publicAddress);
+
+        Iec104Message msg104 = createNewMessage(isContinous, pointType);
         //消息地址为信息体中第一个元素的地址
         int firstMsgAddr = allPoints.get(0).getPointAddr();
         msg104.setMessageAddress(firstMsgAddr);
@@ -204,7 +198,9 @@ public class Iec104Session {
                 //重置point列表缓存,消息地址,其它内容不变
                 if (i < aiList.size()-1) {
                     pointList = new ArrayList<>();
+                    msg104 = createNewMessage(isContinous,pointType);
                     firstMsgAddr = allPoints.get(i+1).getPointAddr();
+
                     msg104.setMessageAddress(firstMsgAddr);
                 }
             }
@@ -222,4 +218,19 @@ public class Iec104Session {
         return true;
     }
 
+    private Iec104Message createNewMessage(boolean isContinous, String pointType) {
+        Iec104Message msg104 = new Iec104Message();
+        msg104.setAcceptSeq(acceptSeq);
+        msg104.setTransferReason((short)20);
+        if ("AI".equals(pointType.toUpperCase())) {
+            msg104.setTypeIdentifier(TypeIdentifierEnum.shortFloatingPointTelemetry); //M_ME_TF_1
+        } else {
+            msg104.setTypeIdentifier(TypeIdentifierEnum.onePointTimeTeleindication); //M_SP_TB_1
+        }
+        //todo: 设置VSQ,可变结构描述限定词
+        msg104.setContinuous(isContinous);
+        msg104.setTerminalAddress(publicAddress);
+        return msg104;
+    }
+
 }

+ 1 - 0
gddlly/src/main/java/com/gyee/edge/gddlly/iec104/handler/Iec104ServerHandler.java

@@ -36,6 +36,7 @@ public class Iec104ServerHandler extends SimpleChannelInboundHandler<Iec104Messa
 		if (sessionMap.containsKey(sessionId)) {
 			Iec104Session session = sessionMap.get(sessionId);
 			session.stop();
+			Thread.sleep(5000);
 			sessionMap.remove(sessionId);
 		}