状态清空
This commit is contained in:
@@ -349,8 +349,28 @@ public class SocketFreqConverterDevService {
|
||||
}
|
||||
|
||||
public void cleanup(String devTag) {
|
||||
String currentUserId = this.userId;
|
||||
FormalTestManager.freqConverterDevStep = null;
|
||||
FormalTestManager.isRemoveSocket = true;
|
||||
SocketManager.removeUser(devTag);
|
||||
clearStateIfStopped(currentUserId);
|
||||
this.userId = null;
|
||||
this.monitorId = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果设备已停止,则清除共享的运行时状态
|
||||
* @param currentUserId 当前用户ID
|
||||
*/
|
||||
private void clearStateIfStopped(String currentUserId) {
|
||||
if (StrUtil.isBlank(currentUserId)) {
|
||||
FormalTestManager.clearFreqConverterRuntimeState();
|
||||
return;
|
||||
}
|
||||
String freqConverterTag = currentUserId + CnSocketUtil.FREQ_CONVERTER_TAG;
|
||||
// 避免过早把 freqConverterTableSuffix 等全局值清掉,造成变频器无法使用全局变量
|
||||
if (!SocketManager.isChannelActive(freqConverterTag)) {
|
||||
FormalTestManager.clearFreqConverterRuntimeState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.njcn.gather.detection.pojo.dto.FreqConverterRespDTO;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||
@@ -168,11 +169,15 @@ public class SocketFreqConverterService {
|
||||
}
|
||||
|
||||
public void cleanup(String converterChannelTag) {
|
||||
String currentUserId = this.userId;
|
||||
clearScheduleTask();
|
||||
FormalTestManager.freqConverterStep = null;
|
||||
// FormalTestManager.stopFlag = false;
|
||||
FormalTestManager.isRemoveSocket = true;
|
||||
SocketManager.removeUser(converterChannelTag);
|
||||
updateCurrentTestStatus();
|
||||
clearStateIfStopped(currentUserId);
|
||||
this.userId = null;
|
||||
}
|
||||
|
||||
private void handleInitSerial(String converterChannelTag, FreqConverterRespDTO respDTO) {
|
||||
@@ -253,6 +258,28 @@ public class SocketFreqConverterService {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCurrentTestStatus() {
|
||||
if (StrUtil.isNotBlank(FormalTestManager.currentFreqConverterId)) {
|
||||
pqFreqConverterConfigService.updateTestStatus(FormalTestManager.currentFreqConverterId, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果变频器已停止,则清除共享的运行时状态
|
||||
* @param currentUserId 当前用户ID
|
||||
*/
|
||||
private void clearStateIfStopped(String currentUserId) {
|
||||
if (StrUtil.isBlank(currentUserId)) {
|
||||
FormalTestManager.clearFreqConverterRuntimeState();
|
||||
return;
|
||||
}
|
||||
String devTag = currentUserId + CnSocketUtil.DEV_TAG;
|
||||
// 避免过早把 freqConverterTableSuffix 等全局值清掉,造成设备无法使用全局变量
|
||||
if (!SocketManager.isChannelActive(devTag)) {
|
||||
FormalTestManager.clearFreqConverterRuntimeState();
|
||||
}
|
||||
}
|
||||
|
||||
private void consumePendingDipTasks(FreqConverterStatus freqConverterStatus) {
|
||||
if (FormalTestManager.pendingDipTaskMap.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -226,6 +226,17 @@ public class FormalTestManager {
|
||||
*/
|
||||
public static boolean isXu;
|
||||
|
||||
/**
|
||||
* 清理变频器耐受实验运行态数据
|
||||
*/
|
||||
public static void clearFreqConverterRuntimeState() {
|
||||
freqConverterStep = null;
|
||||
freqConverterDevStep = null;
|
||||
currentFreqConverterId = null;
|
||||
freqConverterTableSuffix = null;
|
||||
pendingDipTaskMap.clear();
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class PendingDipTask {
|
||||
private PqDipData pqDipData;
|
||||
|
||||
Reference in New Issue
Block a user