feat: 增加61850服务端启停查看功能

iec104
huangfeng 8 months ago
parent c52bb82375
commit e1248945a5

@ -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<HashMap<String, Object>> status() throws Exception {
HashMap<String, Object> map = iecServerService.status();
return Response.success(map);
}
}

@ -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服务端.");
}
}

@ -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<String, Object> status() {
HashMap<String, Object> map = new HashMap<>();
map.put("port", 102);
map.put("started", started);
return map;
}
}

Loading…
Cancel
Save