|
|
@ -4,12 +4,11 @@ import com.xydl.cac.entity.IcdFile;
|
|
|
|
import com.xydl.cac.repository.IcdFileRepository;
|
|
|
|
import com.xydl.cac.repository.IcdFileRepository;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PreDestroy;
|
|
|
|
import javax.annotation.PreDestroy;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
@ -20,12 +19,13 @@ public class IecServerService {
|
|
|
|
|
|
|
|
|
|
|
|
IecServer iecServer = new IecServer();
|
|
|
|
IecServer iecServer = new IecServer();
|
|
|
|
|
|
|
|
|
|
|
|
public void startServer() {
|
|
|
|
public void startServer(Integer fileId) {
|
|
|
|
List<IcdFile> icdFileList = fileRepository.findAll();
|
|
|
|
Optional<IcdFile> optional = fileRepository.findById(fileId);
|
|
|
|
if (!CollectionUtils.isEmpty(icdFileList)) {
|
|
|
|
if (optional.isPresent()) {
|
|
|
|
IcdFile icdFile = icdFileList.get(0);
|
|
|
|
IcdFile icdFile = optional.get();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
iecServer.start(icdFile.getXml(), 102);
|
|
|
|
iecServer.start(icdFile.getXml(), 102);
|
|
|
|
|
|
|
|
iecServer.filename = icdFile.getFilename();
|
|
|
|
RealTimeDataService.iecServer = iecServer;
|
|
|
|
RealTimeDataService.iecServer = iecServer;
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("启动IEC61850服务端异常.", e);
|
|
|
|
log.error("启动IEC61850服务端异常.", e);
|
|
|
@ -45,6 +45,7 @@ public class IecServerService {
|
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
|
map.put("port", 102);
|
|
|
|
map.put("port", 102);
|
|
|
|
map.put("started", iecServer.started);
|
|
|
|
map.put("started", iecServer.started);
|
|
|
|
|
|
|
|
map.put("filename", iecServer.filename);
|
|
|
|
return map;
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|