|
@@ -25,7 +25,10 @@ public class Iec102Client {
|
|
private EventLoopGroup group;
|
|
private EventLoopGroup group;
|
|
private Bootstrap bootstrap;
|
|
private Bootstrap bootstrap;
|
|
private boolean connected = false;
|
|
private boolean connected = false;
|
|
- private Date lastActiveTime;
|
|
|
|
|
|
+ private long lastActiveTime;
|
|
|
|
+ private long lastCallUserDataTime;
|
|
|
|
+
|
|
|
|
+ private boolean isCallLongFile = false;
|
|
|
|
|
|
private ForcastService forcastService = SpringContextUtil.getBean(ForcastService.class);
|
|
private ForcastService forcastService = SpringContextUtil.getBean(ForcastService.class);
|
|
|
|
|
|
@@ -122,6 +125,7 @@ public class Iec102Client {
|
|
}
|
|
}
|
|
// Iec102Message msg23 = BasicInstruction102.createFixFrameMessage(BasicInstruction102.M_USERDATA2);
|
|
// Iec102Message msg23 = BasicInstruction102.createFixFrameMessage(BasicInstruction102.M_USERDATA2);
|
|
sendMessage(iec102Message);
|
|
sendMessage(iec102Message);
|
|
|
|
+ lastCallUserDataTime = new Date().getTime();
|
|
}
|
|
}
|
|
|
|
|
|
public void close() {
|
|
public void close() {
|
|
@@ -132,7 +136,7 @@ public class Iec102Client {
|
|
public void processMessage(Iec102Message response) {
|
|
public void processMessage(Iec102Message response) {
|
|
if (response == null)
|
|
if (response == null)
|
|
return;
|
|
return;
|
|
- lastActiveTime = new Date();
|
|
|
|
|
|
+ lastActiveTime = new Date().getTime();
|
|
|
|
|
|
try {
|
|
try {
|
|
if (Iec102FrameType.Fixed == response.getFrameType()) {
|
|
if (Iec102FrameType.Fixed == response.getFrameType()) {
|
|
@@ -150,12 +154,14 @@ public class Iec102Client {
|
|
log.info("收到用户消息,文件名:" + iMsg.getDataFile());
|
|
log.info("收到用户消息,文件名:" + iMsg.getDataFile());
|
|
|
|
|
|
if (0x08 == response.getCOT()) {
|
|
if (0x08 == response.getCOT()) {
|
|
|
|
+ isCallLongFile = true;
|
|
//再次发送召唤消息
|
|
//再次发送召唤消息
|
|
callUserData(iMsg.getFrameCnt());
|
|
callUserData(iMsg.getFrameCnt());
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
if (0x07 == response.getCOT()) {
|
|
if (0x07 == response.getCOT()) {
|
|
|
|
+ isCallLongFile = false;
|
|
log.info("文件内容:" + iMsg.getDataContentString());
|
|
log.info("文件内容:" + iMsg.getDataContentString());
|
|
|
|
|
|
//解析光功率预测文件
|
|
//解析光功率预测文件
|
|
@@ -165,10 +171,14 @@ public class Iec102Client {
|
|
forcastService.putForcastModel(forcastModel);
|
|
forcastService.putForcastModel(forcastModel);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //todo: 对控制位的逻辑实现有待进一步分析、理解和实现
|
|
|
|
+ //发送文件传输结束确认消息
|
|
if (iMsg.getFrameCnt() > 1) {
|
|
if (iMsg.getFrameCnt() > 1) {
|
|
- //todo: 发送文件传输结束确认消息
|
|
|
|
Iec102Message fileEndMsg = BasicInstruction102.createFileEndMessage(iMsg.getFrameCnt(), iMsg.getDataContent().length);
|
|
Iec102Message fileEndMsg = BasicInstruction102.createFileEndMessage(iMsg.getFrameCnt(), iMsg.getDataContent().length);
|
|
sendMessage(fileEndMsg);
|
|
sendMessage(fileEndMsg);
|
|
|
|
+ } else {
|
|
|
|
+ Iec102Message fileEndMsg = BasicInstruction102.createFileEndMessage(2, iMsg.getDataContent().length);
|
|
|
|
+ sendMessage(fileEndMsg);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -232,4 +242,16 @@ public class Iec102Client {
|
|
} catch (Exception e) {}
|
|
} catch (Exception e) {}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public boolean isCallLongFile() {
|
|
|
|
+ return isCallLongFile;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public long getLastCallUserDataTime() {
|
|
|
|
+ return lastCallUserDataTime;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public long getLastActiveTime() {
|
|
|
|
+ return lastActiveTime;
|
|
|
|
+ }
|
|
}
|
|
}
|