This commit is contained in:
tiger_zhou 2023-12-19 16:56:48 +08:00
parent 4c128be8ef
commit 4986080e43
3 changed files with 103 additions and 2 deletions

View File

@ -90,7 +90,6 @@ public class InusedScheduleResponse extends MessageResponse {
planBuild.setLineId(this.lineId); planBuild.setLineId(this.lineId);
planBuild.setDate(DateTimeUtil.epochSecond(this.date)); planBuild.setDate(DateTimeUtil.epochSecond(this.date));
planBuild.setActionId(this.subId.val()); planBuild.setActionId(this.subId.val());
planBuild.setTrainId(this.trainId);
planBuilds.add(planBuild); planBuilds.add(planBuild);
return planBuilds; return planBuilds;
} }

View File

@ -19,7 +19,7 @@ occ:
lineId: 3 lineId: 3
collectorData: false collectorData: false
#故障测试 #故障测试
mock-alert-test: false mock-alert-test: true
#加载历史模拟数据 #加载历史模拟数据
load-mock-history-data: false load-mock-history-data: false
#延时加载告警处理 #延时加载告警处理

View File

@ -0,0 +1,102 @@
package club.joylink.xiannccda.service;
import club.joylink.xiannccda.ats.message.MessageData;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.OccMessageEncoder;
import club.joylink.xiannccda.ats.message.OccMessageManage;
import club.joylink.xiannccda.entity.DeviceAreaConfig;
import club.joylink.xiannccda.mock.message.occ.MockOccServer;
import club.joylink.xiannccda.mock.message.occ.OutHandle;
import club.joylink.xiannccda.repository.impl.DeviceAreaConfigRepository;
import club.joylink.xiannccda.vo.AreaConfigVO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class CacheTest {
@Autowired
private DeviceAreaConfigRepository deviceAreaConfigRepository;
@Autowired
private OccMessageManage occMessageManage;
@Autowired
private OutHandle outHandle;
@Test
public void timeOutTest() throws InterruptedException {
for (var i = 0; i < 17; i++) {
System.out.println("----------------");
new Thread(() -> {
List<DeviceAreaConfig> configs = deviceAreaConfigRepository.list(Wrappers.lambdaQuery(DeviceAreaConfig.class).eq(DeviceAreaConfig::getLineId, 3));
List<AreaConfigVO> listVO = configs.stream().map(AreaConfigVO::new).toList();
}).start();
}
TimeUnit.HOURS.sleep(1);
}
@Test
public void test2() throws InterruptedException {
// MessageData md = MessageId.MESSAGE_POLLING.create();
// this.occServer.write(md);
// TimeUnit.SECONDS.sleep(10);
// this.occServer.disconnect();
/* try {
this.occMessageManage.sendMsg(3, md, true);
} catch (Exception e) {
e.printStackTrace();
}*/
TimeUnit.HOURS.sleep(1);
}
@Test
public void testServer() throws InterruptedException {
this.initClient();
TimeUnit.HOURS.sleep(1);
}
public void initClient() {
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
ServerBootstrap serverBootstrap = new ServerBootstrap();
serverBootstrap.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(outHandle);
pipeline.addLast(new OccMessageEncoder(null));
}
})
.option(ChannelOption.SO_BACKLOG, 128)
.childOption(ChannelOption.SO_KEEPALIVE, true);
try {
ChannelFuture future = serverBootstrap.bind(2603).sync();
if (future.isSuccess()) {
// log.info(String.format("modbus-tcp server start on port [%s]", this.modbusTcpConfig.getPort()));
} else {
// log.error("modbus-tcp server start failed", future.cause());
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}