diff --git a/src/main/java/com/xydl/cac/controller/IecServerController.java b/src/main/java/com/xydl/cac/controller/IecServerController.java index a95a7db..88f6a7f 100644 --- a/src/main/java/com/xydl/cac/controller/IecServerController.java +++ b/src/main/java/com/xydl/cac/controller/IecServerController.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.util.HashMap; @RestController @Api(tags = {"Iec服务端接口"}) @@ -33,4 +34,11 @@ public class IecServerController extends BasicController { iecServerService.stop(); return Response.success("OK"); } + + @GetMapping("status") + @ApiOperation("查看IEC服务端状态") + public Response> status() throws Exception { + HashMap map = iecServerService.status(); + return Response.success(map); + } } diff --git a/src/main/java/com/xydl/cac/iec/IecServer.java b/src/main/java/com/xydl/cac/iec/IecServer.java index bfef48d..48d0163 100644 --- a/src/main/java/com/xydl/cac/iec/IecServer.java +++ b/src/main/java/com/xydl/cac/iec/IecServer.java @@ -21,13 +21,13 @@ public class IecServer extends Thread implements ServerEventListener { serverSap.startListening(this); serversServerModel = serverSap.getModelCopy(); this.start(); - log.info("已启动IEC服务端."); + log.info("已启动IEC61850服务端."); } public void close() { if (serverSap != null) { serverSap.stop(); - log.info("已停止IEC服务端."); + log.info("已停止IEC61850服务端."); } } diff --git a/src/main/java/com/xydl/cac/iec/IecServerService.java b/src/main/java/com/xydl/cac/iec/IecServerService.java index 99a2f61..b1bdeab 100644 --- a/src/main/java/com/xydl/cac/iec/IecServerService.java +++ b/src/main/java/com/xydl/cac/iec/IecServerService.java @@ -8,6 +8,7 @@ import org.springframework.util.CollectionUtils; import javax.annotation.PreDestroy; import javax.annotation.Resource; +import java.util.HashMap; import java.util.List; @Service @@ -28,7 +29,7 @@ public class IecServerService { iecServer.startServer(icdFile.getXml(), 102); started = true; } catch (Exception e) { - log.error("启动IEC服务端异常.", e); + log.error("启动IEC61850服务端异常.", e); } } } @@ -41,4 +42,11 @@ public class IecServerService { started = false; } } + + public HashMap status() { + HashMap map = new HashMap<>(); + map.put("port", 102); + map.put("started", started); + return map; + } }