瀏覽代碼

Merge branch 'master' into master_NX

# Conflicts:
#	gddlly/src/main/java/com/gyee/edge/gddlly/redis/RedisDataService.java
chenminghua 2 年之前
父節點
當前提交
bb884b272d

+ 1 - 0
gddlly/src/main/java/com/gyee/edge/gddlly/Bootstrap.java

@@ -18,6 +18,7 @@ import org.springframework.boot.CommandLineRunner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 
+import java.util.Date;
 import java.util.Map;
 
 @Slf4j

+ 2 - 1
gddlly/src/main/java/com/gyee/edge/gddlly/config/Point.java

@@ -20,6 +20,7 @@ public class Point {
     // 如果value变化,将consumed置为false;
     private boolean consumed;
 
-    private Date lastUpdateTime;
+    //此处赋初始值,主要是为了防止redis中不存在点表中的点,空值引起后续数据转换错误!
+    private Date lastUpdateTime = new Date(0);
 
 }

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

@@ -198,9 +198,10 @@ public class Iec104Session {
             int firstMsgAddr = allPoints.get(0).getPointAddr();
             msg104.setMessageAddress(firstMsgAddr);
         }
-
+       // log.info(allPoints.get(0).getPoint() + allPoints.get(0).getValue());
         for(int i=0;i<allPoints.size();i++) {
             Point point = allPoints.get(i);
+
             if (!isContinous && point.isConsumed())
                 continue;
 
@@ -262,7 +263,6 @@ public class Iec104Session {
     }
 
     private synchronized void sendMessage(Iec104Message msg) {
-
         msg.setSendSeq(sendSeq++);
         log.info("send message:" + msg.getSendSeq() + ", address = " + msg.getMessageAddress()
                 + ",type= " + msg.getTypeIdentifier()) ;

+ 10 - 2
gddlly/src/main/java/com/gyee/edge/gddlly/iec104/handler/Iec104Encoder.java

@@ -22,7 +22,15 @@ public class Iec104Encoder extends MessageToByteEncoder<Iec104Message> {
 	
 	@Override
 	protected void encode(ChannelHandlerContext ctx, Iec104Message msg, ByteBuf out) throws Exception {
-		byte[] bytes = Encoder104.encoder(msg);
+		try {
+			byte[] bytes = Encoder104.encoder(msg);
+			out.writeBytes(bytes);
+		} catch (Exception e) {
+//			log.error(e.getMessage());
+//			e.printStackTrace();
+			throw e;
+		}
+
 //		if(bytes.length > 6) {
 //			short accept = Iec104ThreadLocal.getControlPool().getAccept();
 //			short send = Iec104ThreadLocal.getControlPool().getSend();
@@ -38,7 +46,7 @@ public class Iec104Encoder extends MessageToByteEncoder<Iec104Message> {
 //			log.info(ByteUtil.byteArrayToHexString(bytes));
 //		}
 
-		out.writeBytes(bytes);
+
 	}
 
 }

+ 0 - 3
gddlly/src/main/java/com/gyee/edge/gddlly/redis/RedisDataService.java

@@ -98,9 +98,6 @@ public class RedisDataService {
                     point.setValue(value);
                     point.setLastUpdateTime(new Date(time));
                 }
-
-                if (point.getLastUpdateTime() == null)
-                    point.setLastUpdateTime(new Date(time));
             }
         } catch (Exception e){
             log.error(e.getMessage());