|
@@ -9,7 +9,7 @@ import com.gyee.edge.gddlly.iec104.protocol.TypeIdentifierEnum;
|
|
|
import com.gyee.edge.gddlly.iec104.protocol.UControlEnum;
|
|
|
import com.gyee.edge.gddlly.redis.RedisDataService;
|
|
|
import com.gyee.edge.gddlly.utils.SpringContextUtil;
|
|
|
-import io.netty.channel.*;
|
|
|
+import io.netty.channel.ChannelHandlerContext;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.net.InetSocketAddress;
|
|
@@ -38,6 +38,8 @@ public class Iec104Session {
|
|
|
|
|
|
private ArrayList<Point> aiList;
|
|
|
private ArrayList<Point> diList;
|
|
|
+ private ArrayList<String> aiKeys;
|
|
|
+ private ArrayList<String> diKeys;
|
|
|
|
|
|
public Iec104Session(ChannelHandlerContext ctx) {
|
|
|
channelHandlerContext = ctx;
|
|
@@ -86,7 +88,7 @@ public class Iec104Session {
|
|
|
response = BasicInstruction104.createSysMessage(UControlEnum.STOPDT_YES);
|
|
|
break;
|
|
|
default:
|
|
|
- break;
|
|
|
+ return;
|
|
|
}
|
|
|
if (response != null)
|
|
|
sendMessage2(response);
|
|
@@ -99,9 +101,15 @@ public class Iec104Session {
|
|
|
//acceptSeq = (short)(request.getSendSeq() + 1);
|
|
|
if (request.getTypeIdentifier() == TypeIdentifierEnum.generalCall) {
|
|
|
// 总召唤命令
|
|
|
- publicAddress = request.getTerminalAddress();
|
|
|
- aiList = pointService.getAiList().get((int)publicAddress);
|
|
|
- diList = pointService.getDiList().get((int)publicAddress);
|
|
|
+ short newAddress = request.getTerminalAddress();
|
|
|
+ if (publicAddress != newAddress) {
|
|
|
+ publicAddress = request.getTerminalAddress();
|
|
|
+ aiList = (ArrayList<Point>)pointService.getAiList().get((int)publicAddress).clone();
|
|
|
+ diList = (ArrayList<Point>)pointService.getDiList().get((int)publicAddress).clone();
|
|
|
+ aiKeys = pointService.getAiKeys((int)publicAddress);
|
|
|
+ diKeys = pointService.getDiKeys((int)publicAddress);
|
|
|
+ }
|
|
|
+
|
|
|
if (TransferReason.ACTIVATE == TransferReason.valueOf(request.getTransferReason())) {
|
|
|
state = SessionState.CALL_ALL;
|
|
|
sendMessage(BasicInstruction104.getYesGeneralCallRuleDetail104(acceptSeq, sendSeq));
|
|
@@ -163,7 +171,7 @@ public class Iec104Session {
|
|
|
while(isRunning) {
|
|
|
//todo: 从redis读取数据,发送到客户端
|
|
|
//1、从redis读取数据,填充aiMap、diMap中,point的value,consumed,lastUpdateTime;
|
|
|
- if (redisService.readRedisData(publicAddress,"AI")) {
|
|
|
+ if (redisService.readRedisData(aiKeys, aiList)) {
|
|
|
if (state == SessionState.CALL_ALL) {
|
|
|
//2、如果SessionState.CALL_ALL, 全量传输遥测点
|
|
|
sendPoints(aiList, true, "AI");
|
|
@@ -175,7 +183,7 @@ public class Iec104Session {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (redisService.readRedisData(publicAddress,"DI")) {
|
|
|
+ if (redisService.readRedisData(diKeys,diList)) {
|
|
|
if (state == SessionState.CALL_ALL) {
|
|
|
//2、如果SessionState.CALL_ALL, 全量传输遥测点
|
|
|
sendPoints(diList, true, "DI");
|