打开61850服务
This commit is contained in:
parent
5aa90c2fcc
commit
51bcf3edc0
@ -61,30 +61,30 @@ public class IEC104ClientRunner implements ApplicationRunner {
|
|||||||
GatewayDevice::getIpAddr, GatewayDevice::getIecAddr);
|
GatewayDevice::getIpAddr, GatewayDevice::getIecAddr);
|
||||||
queryWrapper.orderByAsc(GatewayDevice::getDeviceCode);
|
queryWrapper.orderByAsc(GatewayDevice::getDeviceCode);
|
||||||
List<GatewayDevice> list = gatewayDeviceMapper.selectList(queryWrapper);
|
List<GatewayDevice> list = gatewayDeviceMapper.selectList(queryWrapper);
|
||||||
// if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
// for (GatewayDevice gatewayDevice : list) {
|
for (GatewayDevice gatewayDevice : list) {
|
||||||
// Iec104Config iec104Config = new Iec104Config();
|
Iec104Config iec104Config = new Iec104Config();
|
||||||
// iec104Config.setFrameAmountMax((short) 10);
|
iec104Config.setFrameAmountMax((short) 10);
|
||||||
// short terminnalAddress = gatewayDevice.getIecAddr().shortValue();
|
short terminnalAddress = gatewayDevice.getIecAddr().shortValue();
|
||||||
// //通讯网关机地址
|
//通讯网关机地址
|
||||||
// iec104Config.setTerminnalAddress(terminnalAddress);
|
iec104Config.setTerminnalAddress(terminnalAddress);
|
||||||
// iec104Config.setSlaveCode(gatewayDevice.getDeviceCode());
|
iec104Config.setSlaveCode(gatewayDevice.getDeviceCode());
|
||||||
// iec104Config.setSlaveIP(gatewayDevice.getIpAddr());
|
iec104Config.setSlaveIP(gatewayDevice.getIpAddr());
|
||||||
// OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
||||||
// threadPool.execute(() -> {
|
threadPool.execute(() -> {
|
||||||
// Iec104Master iec104server = Iec104MasterFactory.createTcpClientMaster(iec104Config.getSlaveIP(),
|
Iec104Master iec104server = Iec104MasterFactory.createTcpClientMaster(iec104Config.getSlaveIP(),
|
||||||
// 2404);
|
2404);
|
||||||
// try {
|
try {
|
||||||
// iec104server.setDataHandler(new MasterSysDataHandler()).setConfig(iec104Config).run();
|
iec104server.setDataHandler(new MasterSysDataHandler()).setConfig(iec104Config).run();
|
||||||
//
|
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// log.error(String.format("%s-对应的终端连接失败!", iec104Config.getSlaveIP()));
|
log.error(String.format("%s-对应的终端连接失败!", iec104Config.getSlaveIP()));
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// threadPool.shutdown();
|
threadPool.shutdown();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,26 +60,26 @@ public class ControlManageUtil {
|
|||||||
* 启动S发送S确认帧 的任务
|
* 启动S发送S确认帧 的任务
|
||||||
*/
|
*/
|
||||||
public void startSendFrameTask() {
|
public void startSendFrameTask() {
|
||||||
// OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
||||||
// threadPool.execute(() -> {
|
threadPool.execute(() -> {
|
||||||
// while (true) {
|
while (true) {
|
||||||
// try {
|
try {
|
||||||
// synchronized (sendSframeLock) {
|
synchronized (sendSframeLock) {
|
||||||
// if (frameAmount >= frameAmountMax) {
|
if (frameAmount >= frameAmountMax) {
|
||||||
// // 查过最大帧 的数量就要发送一个确认帧出去
|
// 查过最大帧 的数量就要发送一个确认帧出去
|
||||||
// byte[] control = Iec104Util.getScontrol(accept);
|
byte[] control = Iec104Util.getScontrol(accept);
|
||||||
// MessageDetail ruleDetail104 = new MessageDetail(control);
|
MessageDetail ruleDetail104 = new MessageDetail(control);
|
||||||
// ctx.channel().writeAndFlush(Encoder104.encoder(ruleDetail104));
|
ctx.channel().writeAndFlush(Encoder104.encoder(ruleDetail104));
|
||||||
// frameAmount = 0;
|
frameAmount = 0;
|
||||||
// }
|
}
|
||||||
// sendSframeLock.wait();
|
sendSframeLock.wait();
|
||||||
// }
|
}
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// LOGGER.error("Exception caught", e);
|
LOGGER.error("Exception caught", e);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// threadPool.shutdown();
|
threadPool.shutdown();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,22 +72,22 @@ public class ScheduledTaskPool {
|
|||||||
* @Description: 发送测试帧
|
* @Description: 发送测试帧
|
||||||
*/
|
*/
|
||||||
private void sendTestFrame() {
|
private void sendTestFrame() {
|
||||||
// OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
||||||
// threadPool.execute(() -> {
|
threadPool.execute(() -> {
|
||||||
// try {
|
try {
|
||||||
// BootNettyClientChannel channel = BootNettyClientChannelCache.get(ctx.channel().id().asShortText());
|
BootNettyClientChannel channel = BootNettyClientChannelCache.get(ctx.channel().id().asShortText());
|
||||||
// if(ObjUtil.isNotEmpty(channel )){
|
if(ObjUtil.isNotEmpty(channel )){
|
||||||
// String slaveIp = channel .getCode();
|
String slaveIp = channel .getCode();
|
||||||
// LOGGER.info(String.format("向从站[%s]发送测试链路指令!",slaveIp ));
|
LOGGER.info(String.format("向从站[%s]发送测试链路指令!",slaveIp ));
|
||||||
// ctx.channel().writeAndFlush(BasicInstruction104.TESTFR);
|
ctx.channel().writeAndFlush(BasicInstruction104.TESTFR);
|
||||||
// //对时指令
|
//对时指令
|
||||||
// ctx.channel().writeAndFlush(BasicInstruction104.getTimeScale104());
|
ctx.channel().writeAndFlush(BasicInstruction104.getTimeScale104());
|
||||||
// }
|
}
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// LOGGER.error("Exception caught", e);
|
LOGGER.error("Exception caught", e);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// threadPool.shutdown();
|
threadPool.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -101,21 +101,21 @@ public class ScheduledTaskPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendGeneralCall() {
|
private void sendGeneralCall() {
|
||||||
// OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
||||||
// threadPool.execute(() -> {
|
threadPool.execute(() -> {
|
||||||
// try {
|
try {
|
||||||
// BootNettyClientChannel channel = BootNettyClientChannelCache.get(ctx.channel().id().asShortText());
|
BootNettyClientChannel channel = BootNettyClientChannelCache.get(ctx.channel().id().asShortText());
|
||||||
// if (ObjUtil.isNotEmpty(channel)) {
|
if (ObjUtil.isNotEmpty(channel)) {
|
||||||
// String slaveIp = channel.getCode();
|
String slaveIp = channel.getCode();
|
||||||
// MessageDetail messageDetail = BasicInstruction104.getGeneralCallRuleDetail104();
|
MessageDetail messageDetail = BasicInstruction104.getGeneralCallRuleDetail104();
|
||||||
// LOGGER.info(String.format("向从站[%s]发送总召唤指令[%s]!", slaveIp, messageDetail.getHexString()));
|
LOGGER.info(String.format("向从站[%s]发送总召唤指令[%s]!", slaveIp, messageDetail.getHexString()));
|
||||||
// ctx.channel().writeAndFlush(messageDetail);
|
ctx.channel().writeAndFlush(messageDetail);
|
||||||
// }
|
}
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// LOGGER.error("Exception caught", e);
|
LOGGER.error("Exception caught", e);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// threadPool.shutdown();
|
threadPool.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopSendCommandTask() {
|
public void stopSendCommandTask() {
|
||||||
|
@ -49,17 +49,17 @@ public class Iec104ClientHandler extends SimpleChannelInboundHandler<MessageDeta
|
|||||||
BootNettyClientChannelCache.remove(ctx.channel().id().asShortText());
|
BootNettyClientChannelCache.remove(ctx.channel().id().asShortText());
|
||||||
BootNettyClientChannelCache.save(ctx.channel().id().asShortText(),Channel);
|
BootNettyClientChannelCache.save(ctx.channel().id().asShortText(),Channel);
|
||||||
|
|
||||||
// if (dataHandler != null) {
|
if (dataHandler != null) {
|
||||||
// OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
||||||
// threadPool.execute(() -> {
|
threadPool.execute(() -> {
|
||||||
// try {
|
try {
|
||||||
// dataHandler.handlerAdded(new ChannelHandlerImpl(ctx));
|
dataHandler.handlerAdded(new ChannelHandlerImpl(ctx));
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// LOGGER.error("Exception caught", e);
|
LOGGER.error("Exception caught", e);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// threadPool.shutdown();
|
threadPool.shutdown();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -76,18 +76,18 @@ public class Iec104ClientHandler extends SimpleChannelInboundHandler<MessageDeta
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelRead0(ChannelHandlerContext ctx, MessageDetail ruleDetail104) throws IOException {
|
public void channelRead0(ChannelHandlerContext ctx, MessageDetail ruleDetail104) throws IOException {
|
||||||
// if (dataHandler != null) {
|
if (dataHandler != null) {
|
||||||
// OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
||||||
// threadPool.execute(() -> {
|
threadPool.execute(() -> {
|
||||||
// try {
|
try {
|
||||||
// dataHandler.channelRead(new ChannelHandlerImpl(ctx), ruleDetail104);
|
dataHandler.channelRead(new ChannelHandlerImpl(ctx), ruleDetail104);
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// // TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
// LOGGER.error("Exception caught", e);
|
LOGGER.error("Exception caught", e);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// threadPool.shutdown();
|
threadPool.shutdown();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,17 +40,17 @@ public class Iec104TcpSlaveHandler extends SimpleChannelInboundHandler<MessageDe
|
|||||||
* 启动
|
* 启动
|
||||||
*/
|
*/
|
||||||
Iec104ThreadLocal.getControlPool().startSendFrameTask();
|
Iec104ThreadLocal.getControlPool().startSendFrameTask();
|
||||||
// if (dataHandler != null) {
|
if (dataHandler != null) {
|
||||||
// OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
||||||
// threadPool.execute(() -> {
|
threadPool.execute(() -> {
|
||||||
// try {
|
try {
|
||||||
// dataHandler.handlerAdded(new ChannelHandlerImpl(ctx));
|
dataHandler.handlerAdded(new ChannelHandlerImpl(ctx));
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// LOGGER.error("Exception caught", e);
|
LOGGER.error("Exception caught", e);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// threadPool.shutdown();
|
threadPool.shutdown();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,18 +65,18 @@ public class Iec104TcpSlaveHandler extends SimpleChannelInboundHandler<MessageDe
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void channelRead0(ChannelHandlerContext ctx, MessageDetail ruleDetail104) throws Exception {
|
protected void channelRead0(ChannelHandlerContext ctx, MessageDetail ruleDetail104) throws Exception {
|
||||||
// if (dataHandler != null) {
|
if (dataHandler != null) {
|
||||||
//
|
|
||||||
// OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
||||||
// threadPool.execute(() -> {
|
threadPool.execute(() -> {
|
||||||
// try {
|
try {
|
||||||
// dataHandler.channelRead(new ChannelHandlerImpl(ctx), ruleDetail104);
|
dataHandler.channelRead(new ChannelHandlerImpl(ctx), ruleDetail104);
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// LOGGER.error("Exception caught", e);
|
LOGGER.error("Exception caught", e);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// threadPool.shutdown();
|
threadPool.shutdown();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,10 +45,10 @@ public class IEC61850ClientRunner implements ApplicationRunner {
|
|||||||
queryWrapper.orderByAsc(GatewayDevice::getDeviceCode);
|
queryWrapper.orderByAsc(GatewayDevice::getDeviceCode);
|
||||||
List<GatewayDevice> list = gatewayDeviceMapper.selectList(queryWrapper);
|
List<GatewayDevice> list = gatewayDeviceMapper.selectList(queryWrapper);
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
// for (GatewayDevice systemDevice : list) {
|
for (GatewayDevice systemDevice : list) {
|
||||||
// OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
||||||
// threadPool.execute(() -> iec61850Service.connect(systemDevice));
|
threadPool.execute(() -> iec61850Service.connect(systemDevice));
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package com.yfd.platform.modules.algorithm.service.impl;
|
package com.yfd.platform.modules.algorithm.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.net.NetUtil;
|
import cn.hutool.core.net.NetUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
|
import com.yfd.platform.modules.algorithm.domain.*;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmClassComponent;
|
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmDevice;
|
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmParams;
|
|
||||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmClassMapper;
|
import com.yfd.platform.modules.algorithm.mapper.AlgorithmClassMapper;
|
||||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmDeviceMapper;
|
import com.yfd.platform.modules.algorithm.mapper.AlgorithmDeviceMapper;
|
||||||
|
import com.yfd.platform.modules.algorithm.mapper.AlgorithmLogsMapper;
|
||||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmParamsMapper;
|
import com.yfd.platform.modules.algorithm.mapper.AlgorithmParamsMapper;
|
||||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmParamsService;
|
import com.yfd.platform.modules.algorithm.service.IAlgorithmParamsService;
|
||||||
|
import com.yfd.platform.modules.basedata.domain.SubstationComponent;
|
||||||
|
import com.yfd.platform.modules.basedata.mapper.SubstationComponentMapper;
|
||||||
import com.yfd.platform.utils.HttpRESTfulUtils;
|
import com.yfd.platform.utils.HttpRESTfulUtils;
|
||||||
import com.yfd.platform.utils.StringUtils;
|
import com.yfd.platform.utils.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -20,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -43,6 +45,13 @@ public class AlgorithmParamsServiceImpl extends ServiceImpl<AlgorithmParamsMappe
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AlgorithmDeviceMapper algorithmDeviceMapper;
|
private AlgorithmDeviceMapper algorithmDeviceMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SubstationComponentMapper substationComponentMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AlgorithmLogsMapper algorithmLogsMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private HttpRESTfulUtils httpRESTfulUtils;
|
private HttpRESTfulUtils httpRESTfulUtils;
|
||||||
|
|
||||||
@ -136,6 +145,17 @@ public class AlgorithmParamsServiceImpl extends ServiceImpl<AlgorithmParamsMappe
|
|||||||
param.put("param", senData);
|
param.put("param", senData);
|
||||||
JSONObject jsonObject = httpRESTfulUtils.sendHttpUrlPost("json", serviceAddress, "", param, null);
|
JSONObject jsonObject = httpRESTfulUtils.sendHttpUrlPost("json", serviceAddress, "", param, null);
|
||||||
String desc = algorithmDeviceMapper.getReturnDesc(componentId);
|
String desc = algorithmDeviceMapper.getReturnDesc(componentId);
|
||||||
|
SubstationComponent substationComponent = substationComponentMapper.selectById(componentId);
|
||||||
|
if (substationComponent != null) {
|
||||||
|
AlgorithmLogs algorithmLogs = BeanUtil.copyProperties(substationComponent, AlgorithmLogs.class);
|
||||||
|
algorithmLogs.setAlgorithmId(id);
|
||||||
|
algorithmLogs.setParamsValue(senData.toString());
|
||||||
|
if (jsonObject.containsKey("result")) {
|
||||||
|
algorithmLogs.setAnalysisResult(jsonObject.getString("result"));
|
||||||
|
}
|
||||||
|
algorithmLogs.setAnalysisTime(LocalDateTime.now());
|
||||||
|
algorithmLogsMapper.insert(algorithmLogs);
|
||||||
|
}
|
||||||
jsonObject.put("mapList", mapList);
|
jsonObject.put("mapList", mapList);
|
||||||
jsonObject.put("desc", desc);
|
jsonObject.put("desc", desc);
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
|
@ -167,17 +167,17 @@ public class GatewayDeviceServiceImpl extends ServiceImpl<GatewayDeviceMapper, G
|
|||||||
log.error("Exception caught", e);
|
log.error("Exception caught", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Runnable runnable = () -> {
|
Runnable runnable = () -> {
|
||||||
// Iec104Master iec104server = Iec104MasterFactory.createTcpClientMaster(iec104Config.getSlaveIP(), 2404);
|
Iec104Master iec104server = Iec104MasterFactory.createTcpClientMaster(iec104Config.getSlaveIP(), 2404);
|
||||||
// try {
|
try {
|
||||||
// iec104server.setDataHandler(new MasterSysDataHandler()).setConfig(iec104Config).run();
|
iec104server.setDataHandler(new MasterSysDataHandler()).setConfig(iec104Config).run();
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// EventLoopGroupManager.shutdownEventLoopGroup(ip);
|
EventLoopGroupManager.shutdownEventLoopGroup(ip);
|
||||||
// log.error(String.format("%s-对应的终端连接失败!", iec104Config.getSlaveIP()));
|
log.error(String.format("%s-对应的终端连接失败!", iec104Config.getSlaveIP()));
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
// OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
OptimizedThreadPool threadPool = OptimizedThreadPool.getInstance();
|
||||||
// threadPool.execute(runnable);
|
threadPool.execute(runnable);
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user