上饶沙盘(除列车)
This commit is contained in:
parent
fd9a54f816
commit
b445b59290
@ -32,6 +32,8 @@ public enum ProjectDeviceType {
|
|||||||
DCU,
|
DCU,
|
||||||
/** UDP下位机 */
|
/** UDP下位机 */
|
||||||
UDP_LOW,
|
UDP_LOW,
|
||||||
|
/** UDP客户端 */
|
||||||
|
UDP_CLIENT,
|
||||||
/* -----------plc device end---------- */
|
/* -----------plc device end---------- */
|
||||||
|
|
||||||
/* -----------client device start---------- */
|
/* -----------client device start---------- */
|
||||||
@ -76,6 +78,7 @@ public enum ProjectDeviceType {
|
|||||||
SWITCH,
|
SWITCH,
|
||||||
SIGNAL,
|
SIGNAL,
|
||||||
DCU,
|
DCU,
|
||||||
UDP_LOW);
|
UDP_LOW,
|
||||||
|
UDP_CLIENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,9 +237,9 @@ public class DeviceController {
|
|||||||
this.deviceService.addOrUpdateRichorDeviceConfig(accountVO);
|
this.deviceService.addOrUpdateRichorDeviceConfig(accountVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/sr/addOrUpdate")
|
@PostMapping("/sr/addOrUpdate/{mapId}")
|
||||||
public void addOrUpdateSrDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
|
public void addOrUpdateSrDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
|
||||||
AccountVO accountVO) {
|
AccountVO accountVO, @PathVariable Long mapId) {
|
||||||
this.deviceService.addOrUpdateSrDeviceConfig(accountVO);
|
this.deviceService.addOrUpdateSrDeviceConfig(accountVO, mapId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,11 @@ import club.joylink.rtss.vo.client.PageVO;
|
|||||||
import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO;
|
import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO;
|
||||||
import club.joylink.rtss.vo.map.query.MapRouteFlankProtectionQueryVO;
|
import club.joylink.rtss.vo.map.query.MapRouteFlankProtectionQueryVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface DraftMapFlankProtectionService {
|
public interface DraftMapFlankProtectionService {
|
||||||
|
List<MapRouteFlankProtectionNewVO> queryAll(long mapId);
|
||||||
|
|
||||||
void create(MapRouteFlankProtectionNewVO flankProtectionNewVO);
|
void create(MapRouteFlankProtectionNewVO flankProtectionNewVO);
|
||||||
|
|
||||||
PageVO<MapRouteFlankProtectionNewVO> pagingQueryFlankProtections(Long mapId, MapRouteFlankProtectionQueryVO queryVO);
|
PageVO<MapRouteFlankProtectionNewVO> pagingQueryFlankProtections(Long mapId, MapRouteFlankProtectionQueryVO queryVO);
|
||||||
|
@ -14,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class DraftMapFlankProtectionServiceImpl implements DraftMapFlankProtectionService {
|
public class DraftMapFlankProtectionServiceImpl implements DraftMapFlankProtectionService {
|
||||||
@ -21,6 +23,14 @@ public class DraftMapFlankProtectionServiceImpl implements DraftMapFlankProtecti
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DraftMapRouteFlankProtectionDAO draftMapRouteFlankProtectionDAO;
|
private DraftMapRouteFlankProtectionDAO draftMapRouteFlankProtectionDAO;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MapRouteFlankProtectionNewVO> queryAll(long mapId) {
|
||||||
|
DraftMapRouteFlankProtectionExample example = new DraftMapRouteFlankProtectionExample();
|
||||||
|
example.createCriteria().andMapIdEqualTo(mapId);
|
||||||
|
List<DraftMapRouteFlankProtection> list = draftMapRouteFlankProtectionDAO.selectByExampleWithBLOBs(example);
|
||||||
|
return MapRouteFlankProtectionNewVO.convert2VOList(list);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(MapRouteFlankProtectionNewVO flankProtectionNewVO) {
|
public void create(MapRouteFlankProtectionNewVO flankProtectionNewVO) {
|
||||||
// 编号/名称查重
|
// 编号/名称查重
|
||||||
|
@ -1,16 +1,7 @@
|
|||||||
package club.joylink.rtss.services.draftData;
|
package club.joylink.rtss.services.draftData;
|
||||||
|
|
||||||
import club.joylink.rtss.vo.map.*;
|
import club.joylink.rtss.vo.map.MapVO;
|
||||||
import club.joylink.rtss.vo.map.logic.MapAutoReentryVO;
|
import club.joylink.rtss.vo.map.logic.*;
|
||||||
import club.joylink.rtss.vo.map.logic.MapAutoSignalNewVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapDestinationCodeDefinitionVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapOverlapVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapRouteNewVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapRoutingDataVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -22,6 +13,11 @@ public interface DraftMapService {
|
|||||||
*/
|
*/
|
||||||
MapVO getDraftMapData(Long mapId);
|
MapVO getDraftMapData(Long mapId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取草稿地图的数据(包含逻辑数据)
|
||||||
|
*/
|
||||||
|
MapVO getDraftMapDataDetail(long mapId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清理旧的联锁数据,并保存新联锁数据
|
* 清理旧的联锁数据,并保存新联锁数据
|
||||||
* @param mapId
|
* @param mapId
|
||||||
|
@ -3,17 +3,9 @@ package club.joylink.rtss.services.draftData;
|
|||||||
import club.joylink.rtss.dao.*;
|
import club.joylink.rtss.dao.*;
|
||||||
import club.joylink.rtss.entity.*;
|
import club.joylink.rtss.entity.*;
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
import club.joylink.rtss.vo.map.*;
|
import club.joylink.rtss.vo.map.MapLogicDataNewVO;
|
||||||
import club.joylink.rtss.vo.map.logic.MapAutoReentryVO;
|
import club.joylink.rtss.vo.map.MapVO;
|
||||||
import club.joylink.rtss.vo.map.logic.MapAutoSignalNewVO;
|
import club.joylink.rtss.vo.map.logic.*;
|
||||||
import club.joylink.rtss.vo.map.logic.MapDestinationCodeDefinitionVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapOverlapVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapRouteNewVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapRoutingDataVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -46,6 +38,21 @@ public class DraftMapServiceImpl implements DraftMapService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DraftMapParkingTimeDAO draftMapParkingTimeDAO;
|
private DraftMapParkingTimeDAO draftMapParkingTimeDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DraftMapRouteService draftMapRouteService;
|
||||||
|
@Autowired
|
||||||
|
private RunLevelService runLevelService;
|
||||||
|
@Autowired
|
||||||
|
private ParkTimeService parkTimeService;
|
||||||
|
@Autowired
|
||||||
|
private DraftMapOverrunService draftMapOverrunService;
|
||||||
|
@Autowired
|
||||||
|
private DraftMapOverlapService draftMapOverlapService;
|
||||||
|
@Autowired
|
||||||
|
private DraftMapFlankProtectionService draftMapFlankProtectionService;
|
||||||
|
@Autowired
|
||||||
|
private DraftMapSignalApproachSectionService draftMapSignalApproachSectionService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MapVO getDraftMapData(Long mapId) {
|
public MapVO getDraftMapData(Long mapId) {
|
||||||
DraftMapWithBLOBs draftMap = this.draftMapDAO.selectByPrimaryKey(mapId);
|
DraftMapWithBLOBs draftMap = this.draftMapDAO.selectByPrimaryKey(mapId);
|
||||||
@ -53,6 +60,25 @@ public class DraftMapServiceImpl implements DraftMapService {
|
|||||||
return mapVO;
|
return mapVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MapVO getDraftMapDataDetail(long mapId) {
|
||||||
|
MapVO map = getDraftMapData(mapId);
|
||||||
|
MapLogicDataNewVO logicDataNew = new MapLogicDataNewVO();
|
||||||
|
logicDataNew.setRouteList(draftMapRouteService.queryAllRoutes(mapId));
|
||||||
|
logicDataNew.setRunLevelList(runLevelService.queryAll(mapId));
|
||||||
|
logicDataNew.setParkingTimeList(parkTimeService.queryAll(mapId));
|
||||||
|
logicDataNew.setOverrunList(draftMapOverrunService.queryAll(mapId));
|
||||||
|
logicDataNew.setOverlapList(draftMapOverlapService.queryAll(mapId));
|
||||||
|
logicDataNew.setFlankProtectionList(draftMapFlankProtectionService.queryAll(mapId));
|
||||||
|
// logicDataNew.setDestinationCodeDefinitionList(); 后续补上
|
||||||
|
// logicDataNew.setAutoSignalList(); 待补
|
||||||
|
// logicDataNew.setAutoReentryList(); 待补
|
||||||
|
// logicDataNew.setRoutingList(); 待补
|
||||||
|
logicDataNew.setSignalApproachSectionList(draftMapSignalApproachSectionService.queryAll(mapId));
|
||||||
|
map.setLogicDataNew(logicDataNew);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void cleanAndSaveCiData(Long mapId,
|
public void cleanAndSaveCiData(Long mapId,
|
||||||
|
@ -8,11 +8,10 @@ import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
|||||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
|
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
|
||||||
import club.joylink.rtss.vo.map.logic.MapRoutingDataVO;
|
|
||||||
import club.joylink.rtss.vo.map.MapRoutingSectionNewVO;
|
import club.joylink.rtss.vo.map.MapRoutingSectionNewVO;
|
||||||
import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO;
|
|
||||||
import club.joylink.rtss.vo.map.MapVO;
|
import club.joylink.rtss.vo.map.MapVO;
|
||||||
|
import club.joylink.rtss.vo.map.logic.MapRoutingDataVO;
|
||||||
|
import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -78,10 +77,10 @@ public class RunLevelService {
|
|||||||
|
|
||||||
public List<MapStationRunLevelVO> generate(Long mapId) {
|
public List<MapStationRunLevelVO> generate(Long mapId) {
|
||||||
// 先校验地图基础数据
|
// 先校验地图基础数据
|
||||||
MapVO mapVO = this.draftMapService.getDraftMapData(mapId);
|
MapVO mapVO = this.draftMapService.getDraftMapDataDetail(mapId);
|
||||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildBasicMapData(mapVO);
|
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapData(mapVO);
|
||||||
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
|
// BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
|
||||||
String.format("地图基础数据有错误: %s", JsonUtils.writeValueAsString(buildResult.getErrMsgList())));
|
// String.format("地图基础数据有错误: %s", JsonUtils.writeValueAsString(buildResult.getErrMsgList())));
|
||||||
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
|
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
|
||||||
List<MapRoutingDataVO> routingDataVOList = this.draftMapService.queryRoutings(mapId);
|
List<MapRoutingDataVO> routingDataVOList = this.draftMapService.queryRoutings(mapId);
|
||||||
List<MapStationRunLevelVO> runLevelVOList = this.generateRunLevels(routingDataVOList, deviceMap);
|
List<MapStationRunLevelVO> runLevelVOList = this.generateRunLevels(routingDataVOList, deviceMap);
|
||||||
|
@ -182,5 +182,5 @@ public interface DeviceService {
|
|||||||
|
|
||||||
void addOrUpdateRichorDeviceConfig(AccountVO accountVO);
|
void addOrUpdateRichorDeviceConfig(AccountVO accountVO);
|
||||||
|
|
||||||
void addOrUpdateSrDeviceConfig(AccountVO accountVO);
|
void addOrUpdateSrDeviceConfig(AccountVO accountVO, Long mapId);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import club.joylink.rtss.dao.ProjectDeviceDAO;
|
|||||||
import club.joylink.rtss.entity.ProjectDevice;
|
import club.joylink.rtss.entity.ProjectDevice;
|
||||||
import club.joylink.rtss.entity.ProjectDeviceExample;
|
import club.joylink.rtss.entity.ProjectDeviceExample;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
|
import club.joylink.rtss.services.IMapService;
|
||||||
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
import club.joylink.rtss.vo.AccountVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||||
import club.joylink.rtss.vo.client.PageVO;
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
@ -17,7 +19,15 @@ import club.joylink.rtss.vo.client.project.richor.ZjdPsdConfigVO;
|
|||||||
import club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO;
|
import club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO;
|
||||||
import club.joylink.rtss.vo.client.project.sdy.SdyPsdConfigVO;
|
import club.joylink.rtss.vo.client.project.sdy.SdyPsdConfigVO;
|
||||||
import club.joylink.rtss.vo.client.project.sdy.SdyPslConfigVO;
|
import club.joylink.rtss.vo.client.project.sdy.SdyPslConfigVO;
|
||||||
|
import club.joylink.rtss.vo.client.project.sr.SrSectionConfigVO;
|
||||||
|
import club.joylink.rtss.vo.client.project.sr.SrSignalConfigVO;
|
||||||
|
import club.joylink.rtss.vo.client.project.sr.SrSwitchConfigVO;
|
||||||
import club.joylink.rtss.vo.client.project.xty.XtyPsdConfigVO;
|
import club.joylink.rtss.vo.client.project.xty.XtyPsdConfigVO;
|
||||||
|
import club.joylink.rtss.vo.map.MapGraphDataNewVO;
|
||||||
|
import club.joylink.rtss.vo.map.MapVO;
|
||||||
|
import club.joylink.rtss.vo.map.graph.MapSectionNewVO;
|
||||||
|
import club.joylink.rtss.vo.map.graph.MapSignalNewVO;
|
||||||
|
import club.joylink.rtss.vo.map.graph.MapSwitchVO;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -37,6 +47,9 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ProjectDeviceDAO projectDeviceDAO;
|
private ProjectDeviceDAO projectDeviceDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMapService iMapService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO,
|
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO,
|
||||||
LoginUserInfoVO userLoginInfo) {
|
LoginUserInfoVO userLoginInfo) {
|
||||||
@ -398,32 +411,91 @@ public class DeviceServiceImpl implements DeviceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOrUpdateSrDeviceConfig(AccountVO accountVO) {
|
public void addOrUpdateSrDeviceConfig(AccountVO accountVO, Long mapId) {
|
||||||
// 删除旧配置
|
// 删除旧配置
|
||||||
ProjectDeviceExample example = new ProjectDeviceExample();
|
ProjectDeviceExample example = new ProjectDeviceExample();
|
||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
.andProjectCodeEqualTo(Project.RICHOR_JOINT.name())
|
.andProjectCodeEqualTo(Project.SR_SANDBOX.name())
|
||||||
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream()
|
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream()
|
||||||
.map(Enum::name).collect(Collectors.toList()));
|
.map(Enum::name).collect(Collectors.toList()));
|
||||||
this.projectDeviceDAO.deleteByExample(example);
|
this.projectDeviceDAO.deleteByExample(example);
|
||||||
// // 保存新配置
|
// 保存新配置
|
||||||
// List<ProjectDevice> list = this.buildSrProjectDevices(accountVO);
|
List<ProjectDevice> list = this.buildSrProjectDevices(accountVO, mapId);
|
||||||
// for (ProjectDevice projectDevice : list) {
|
for (ProjectDevice projectDevice : list) {
|
||||||
// this.projectDeviceDAO.insert(projectDevice);
|
this.projectDeviceDAO.insert(projectDevice);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private List<ProjectDevice> buildSrProjectDevices(AccountVO accountVO) {
|
private List<ProjectDevice> buildSrProjectDevices(AccountVO accountVO, long mapId) {
|
||||||
// LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
// List<ProjectDevice> list = new ArrayList<>();
|
List<ProjectDevice> list = new ArrayList<>();
|
||||||
// //UDP下位机
|
//UDP下位机
|
||||||
// ProjectDevice udp = new ProjectDevice();
|
ProjectDevice udp = new ProjectDevice();
|
||||||
// udp.setProjectCode(Project.SR_SANDBOX.name());
|
udp.setProjectCode(Project.SR_SANDBOX.name());
|
||||||
// udp.setCode("sr-udp");
|
udp.setCode("sr-udp");
|
||||||
// udp.setType(ProjectDeviceType.UDP_LOW.name());
|
udp.setType(ProjectDeviceType.UDP_LOW.name());
|
||||||
// udp.setCreator(accountVO.getId());
|
udp.setCreator(accountVO.getId());
|
||||||
// udp.setCreateTime(now);
|
udp.setCreateTime(now);
|
||||||
// }
|
UDPLowConfigVO udpConfigVO = new UDPLowConfigVO("", 10086);
|
||||||
|
udp.setConfig(udpConfigVO.toJson());
|
||||||
|
list.add(udp);
|
||||||
|
//UDP客户端
|
||||||
|
ProjectDevice udpClient = new ProjectDevice();
|
||||||
|
udpClient.setProjectCode(Project.SR_SANDBOX.name());
|
||||||
|
udpClient.setCode("sr-udp-client");
|
||||||
|
udpClient.setType(ProjectDeviceType.UDP_CLIENT.name());
|
||||||
|
udpClient.setCreator(accountVO.getId());
|
||||||
|
udpClient.setCreateTime(now);
|
||||||
|
UDPClientConfigVO udpClientConfigVO = new UDPClientConfigVO("192.168.8.109", 10000);
|
||||||
|
udpClient.setConfig(JsonUtils.writeValueAsString(udpClientConfigVO));
|
||||||
|
list.add(udpClient);
|
||||||
|
/*-------------------- 地图设备 --------------------*/
|
||||||
|
MapVO map = iMapService.getMapDetail(mapId);
|
||||||
|
MapGraphDataNewVO graphDataNew = map.getGraphDataNew();
|
||||||
|
//信号机
|
||||||
|
for (MapSignalNewVO mapSignalNewVO : graphDataNew.getSignalList()) {
|
||||||
|
if (StringUtils.hasText(mapSignalNewVO.getSrCode())) {
|
||||||
|
ProjectDevice signal = new ProjectDevice();
|
||||||
|
signal.setProjectCode(Project.SR_SANDBOX.name());
|
||||||
|
signal.setCode("sr-signal-" + mapSignalNewVO.getCode());
|
||||||
|
signal.setType(ProjectDeviceType.SIGNAL.name());
|
||||||
|
signal.setCreator(accountVO.getId());
|
||||||
|
signal.setCreateTime(now);
|
||||||
|
SrSignalConfigVO configVO = new SrSignalConfigVO(mapSignalNewVO.getCode(), mapSignalNewVO.getSrCode());
|
||||||
|
signal.setConfig(JsonUtils.writeValueAsString(configVO));
|
||||||
|
list.add(signal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//道岔
|
||||||
|
for (MapSwitchVO mapSwitchVO : graphDataNew.getSwitchList()) {
|
||||||
|
if (StringUtils.hasText(mapSwitchVO.getSrCode())) {
|
||||||
|
ProjectDevice aSwitch = new ProjectDevice();
|
||||||
|
aSwitch.setProjectCode(Project.SR_SANDBOX.name());
|
||||||
|
aSwitch.setCode("sr-switch-" + mapSwitchVO.getCode());
|
||||||
|
aSwitch.setType(ProjectDeviceType.SWITCH.name());
|
||||||
|
aSwitch.setCreator(accountVO.getId());
|
||||||
|
aSwitch.setCreateTime(now);
|
||||||
|
SrSwitchConfigVO configVO = new SrSwitchConfigVO(mapSwitchVO.getCode(), mapSwitchVO.getSrCode());
|
||||||
|
aSwitch.setConfig(JsonUtils.writeValueAsString(configVO));
|
||||||
|
list.add(aSwitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//区段
|
||||||
|
for (MapSectionNewVO mapSectionNewVO : graphDataNew.getSectionList()) {
|
||||||
|
if (StringUtils.hasText(mapSectionNewVO.getSrCode())) {
|
||||||
|
ProjectDevice section = new ProjectDevice();
|
||||||
|
section.setProjectCode(Project.SR_SANDBOX.name());
|
||||||
|
section.setCode("sr-section-" + mapSectionNewVO.getCode());
|
||||||
|
section.setType(ProjectDeviceType.SECTION.name());
|
||||||
|
section.setCreator(accountVO.getId());
|
||||||
|
section.setCreateTime(now);
|
||||||
|
SrSectionConfigVO configVO = new SrSectionConfigVO(mapSectionNewVO.getCode(), mapSectionNewVO.getSrCode());
|
||||||
|
section.setConfig(JsonUtils.writeValueAsString(configVO));
|
||||||
|
list.add(section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
private List<ProjectDevice> buildZjdProjectDevices(AccountVO accountVO) {
|
private List<ProjectDevice> buildZjdProjectDevices(AccountVO accountVO) {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
@ -19,8 +19,8 @@ import club.joylink.rtss.vo.client.runplan.PlanTripNumberVO;
|
|||||||
import club.joylink.rtss.vo.client.runplan.RunPlanEChartsDataVO;
|
import club.joylink.rtss.vo.client.runplan.RunPlanEChartsDataVO;
|
||||||
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
|
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
|
||||||
import club.joylink.rtss.vo.client.simulationv1.*;
|
import club.joylink.rtss.vo.client.simulationv1.*;
|
||||||
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
|
|
||||||
import club.joylink.rtss.vo.map.MapVO;
|
import club.joylink.rtss.vo.map.MapVO;
|
||||||
|
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
@ -280,4 +280,6 @@ public interface GroupSimulationService {
|
|||||||
void confirmHasPermission(AccountVO accountVO, Long mapId, String prdType);
|
void confirmHasPermission(AccountVO accountVO, Long mapId, String prdType);
|
||||||
|
|
||||||
boolean hasPermission(AccountVO accountVO, Long mapId, String prdType);
|
boolean hasPermission(AccountVO accountVO, Long mapId, String prdType);
|
||||||
|
|
||||||
|
List<Simulation> querySimulations();
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,8 @@ import club.joylink.rtss.vo.client.script.ScriptVO;
|
|||||||
import club.joylink.rtss.vo.client.simulationv1.*;
|
import club.joylink.rtss.vo.client.simulationv1.*;
|
||||||
import club.joylink.rtss.vo.client.training.TrainingNewVO;
|
import club.joylink.rtss.vo.client.training.TrainingNewVO;
|
||||||
import club.joylink.rtss.vo.client.userPermission.UserPermissionVO;
|
import club.joylink.rtss.vo.client.userPermission.UserPermissionVO;
|
||||||
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
|
|
||||||
import club.joylink.rtss.vo.map.MapVO;
|
import club.joylink.rtss.vo.map.MapVO;
|
||||||
|
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
|
||||||
import club.joylink.rtss.websocket.StompMessageService;
|
import club.joylink.rtss.websocket.StompMessageService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -1073,6 +1073,11 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Simulation> querySimulations() {
|
||||||
|
return groupSimulationCache.queryAllSimulation();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isThirdAccountHasPermission(AccountVO accountVO, List<UserPermissionVO> ups, Long mapId, String prdType) {
|
private boolean isThirdAccountHasPermission(AccountVO accountVO, List<UserPermissionVO> ups, Long mapId, String prdType) {
|
||||||
if (accountVO.isThirdChildAccount()) {
|
if (accountVO.isThirdChildAccount()) {
|
||||||
List<LoginUserInfoVO> loginInfos = this.loginSessionManager.getAllLoginUserInfos();
|
List<LoginUserInfoVO> loginInfos = this.loginSessionManager.getAllLoginUserInfos();
|
||||||
|
@ -17,6 +17,10 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1Ps
|
|||||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdIbpConfig;
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdIbpConfig;
|
||||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPslConfig;
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPslConfig;
|
||||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig;
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.Sr.SrSectionConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.Sr.SrSignalConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.Sr.SrSwitchConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceThread;
|
||||||
import club.joylink.rtss.simulation.cbtc.event.SimulationUserEnterEvent;
|
import club.joylink.rtss.simulation.cbtc.event.SimulationUserEnterEvent;
|
||||||
import club.joylink.rtss.simulation.cbtc.member.MemberManager;
|
import club.joylink.rtss.simulation.cbtc.member.MemberManager;
|
||||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
@ -63,6 +67,9 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SimulationRealDeviceThread simulationRealDeviceThread;
|
private SimulationRealDeviceThread simulationRealDeviceThread;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UDPRealDeviceThread udpRealDeviceThread;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Simulation createSimulation(LoginUserInfoVO loginUserInfo) {
|
public Simulation createSimulation(LoginUserInfoVO loginUserInfo) {
|
||||||
Project project = loginUserInfo.getProject();
|
Project project = loginUserInfo.getProject();
|
||||||
@ -100,6 +107,7 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
|
|||||||
simulation.setRealDeviceList(realDeviceList);
|
simulation.setRealDeviceList(realDeviceList);
|
||||||
if (!CollectionUtils.isEmpty(realDeviceList)) {
|
if (!CollectionUtils.isEmpty(realDeviceList)) {
|
||||||
simulationRealDeviceThread.addJobs(simulation);
|
simulationRealDeviceThread.addJobs(simulation);
|
||||||
|
udpRealDeviceThread.addJobs(simulation);
|
||||||
}
|
}
|
||||||
for (RealDeviceConfig realDevice : realDeviceList) {
|
for (RealDeviceConfig realDevice : realDeviceList) {
|
||||||
if (ProjectDeviceType.PLC_GATEWAY.equals(realDevice.getDeviceType())) {
|
if (ProjectDeviceType.PLC_GATEWAY.equals(realDevice.getDeviceType())) {
|
||||||
@ -145,6 +153,16 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
|
|||||||
return ((ZjdPslConfig) config).getConfigVO().getPslCode();
|
return ((ZjdPslConfig) config).getConfigVO().getPslCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case SR_SANDBOX: {
|
||||||
|
switch (config.getDeviceType()) {
|
||||||
|
case SIGNAL:
|
||||||
|
return ((SrSignalConfig) config).getConfigVO().getVrCode();
|
||||||
|
case SECTION:
|
||||||
|
return ((SrSectionConfig) config).getConfigVO().getVrCode();
|
||||||
|
case SWITCH:
|
||||||
|
return ((SrSwitchConfig) config).getConfigVO().getVrCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
|||||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
|
import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
|
||||||
import club.joylink.rtss.simulation.cbtc.script.ScriptBO;
|
import club.joylink.rtss.simulation.cbtc.script.ScriptBO;
|
||||||
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
|
|
||||||
import club.joylink.rtss.simulation.vo.SimulationInfoVO;
|
import club.joylink.rtss.simulation.vo.SimulationInfoVO;
|
||||||
import club.joylink.rtss.vo.AccountVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.client.fault.FaultRuleVO;
|
import club.joylink.rtss.vo.client.fault.FaultRuleVO;
|
||||||
@ -329,6 +328,27 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RealDeviceConfig queryOneRealDevice(ProjectDeviceType type) {
|
||||||
|
if (!CollectionUtils.isEmpty(realDeviceList)) {
|
||||||
|
for (RealDeviceConfig config : realDeviceList) {
|
||||||
|
if (Objects.equals(type, config.getDeviceType())) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RealDeviceConfig> queryAllRealDevice(ProjectDeviceType type) {
|
||||||
|
if (CollectionUtils.isEmpty(realDeviceList)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
return realDeviceList.stream()
|
||||||
|
.filter(config -> Objects.equals(config.getDeviceType(), type))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void pushModbusFuture(DeviceQueryFuture future) {
|
public void pushModbusFuture(DeviceQueryFuture future) {
|
||||||
this.deviceQueryFutureQueue.add(future);
|
this.deviceQueryFutureQueue.add(future);
|
||||||
}
|
}
|
||||||
@ -652,5 +672,6 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
|
|||||||
String commandExecuteRun = "commandExecuteRun";
|
String commandExecuteRun = "commandExecuteRun";
|
||||||
String pslStatus = "pslStatus";
|
String pslStatus = "pslStatus";
|
||||||
String ibpJob = "ibpJob";
|
String ibpJob = "ibpJob";
|
||||||
|
String udpRealDevice = "udpRealDevice";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -700,8 +700,8 @@ public class CalculateService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (iter > iterTimes) {
|
if (iter > iterTimes) {
|
||||||
warnList.add(String.format("进路路径[%s]未找到:迭代100次,最后区段为[%s]",
|
warnList.add(String.format("进路路径[%s]未找到:迭代[%s]次,最后区段为[%s]",
|
||||||
routePath.debugStr(), routePath.getLastSection().debugStr()));
|
routePath.debugStr(), iterTimes, routePath.getLastSection().debugStr()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Section end = routePath.getEnd();
|
Section end = routePath.getEnd();
|
||||||
|
@ -63,7 +63,8 @@ public class VirtualRealitySignal extends ControllableVrDevice<SignalAspect> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.aspect = command;
|
// this.aspect = command;
|
||||||
|
this.aspect = SignalAspect.R;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Fault {
|
public enum Fault {
|
||||||
|
@ -65,6 +65,19 @@ public class SimulationRealDeviceConnectManager {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SECTION: {
|
||||||
|
VirtualRealityDevice vrDevice = simulation.getRepository().getVRByCode(deviceCode);
|
||||||
|
if (MapElement.DeviceType.AXLE_COUNTER.equals(vrDevice.getDeviceType())) {
|
||||||
|
typeEqual = true;
|
||||||
|
MapNamedElement old = realDevice.getMapElement();
|
||||||
|
if (Objects.nonNull(old)) {
|
||||||
|
((VirtualRealitySectionAxleCounter) old).updateRealDevice(null);
|
||||||
|
}
|
||||||
|
vrDevice.updateRealDevice(realDevice);
|
||||||
|
realDevice.connect(vrDevice);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case PSC:
|
case PSC:
|
||||||
case PSD: {
|
case PSD: {
|
||||||
VirtualRealityDevice vrDevice = simulation.getRepository().getVRByCode(deviceCode);
|
VirtualRealityDevice vrDevice = simulation.getRepository().getVRByCode(deviceCode);
|
||||||
|
@ -50,12 +50,6 @@ public class ZjdIbpServiceImpl implements RealDeviceService {
|
|||||||
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), false, channel);
|
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), false, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
int addr = 2;
|
|
||||||
int bit = 9;
|
|
||||||
System.out.println((addr + 1) * 16 + (bit + 8) % 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
|
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
|
||||||
PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
|
PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.device.real.udp.Sr;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||||
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
|
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
|
||||||
|
import club.joylink.rtss.vo.client.project.sr.SrSectionConfigVO;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class SrSectionConfig extends RealDeviceConfig {
|
||||||
|
private SrSectionConfigVO configVO;
|
||||||
|
|
||||||
|
public SrSectionConfig(ProjectDeviceVO projectDevice) {
|
||||||
|
super(projectDevice);
|
||||||
|
if (Objects.nonNull(projectDevice.getConfig())) {
|
||||||
|
this.configVO = JsonUtils.read(projectDevice.getConfig(), SrSectionConfigVO.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.device.real.udp.Sr;
|
||||||
|
|
||||||
|
import club.joylink.rtss.constants.ProjectDeviceType;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClientConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SrSectionServiceImpl implements UDPRealDeviceService {
|
||||||
|
@Override
|
||||||
|
public boolean isMatch(RealDeviceConfig realDevice) {
|
||||||
|
return realDevice instanceof UDPClientConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void control(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Simulation simulation, UDPLowConfig udpConfig, RealDeviceConfig realDevice) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Simulation simulation, ByteBuf msg) {
|
||||||
|
byte[] data = new byte[msg.readableBytes()];
|
||||||
|
if (data.length < 4)
|
||||||
|
return;
|
||||||
|
msg.readBytes(data);
|
||||||
|
if (Byte.toUnsignedInt(data[1]) != 137)
|
||||||
|
return;
|
||||||
|
Map<String, VirtualRealitySectionAxleCounter> map = simulation.queryAllRealDevice(ProjectDeviceType.SECTION).stream()
|
||||||
|
.map(config -> (SrSectionConfig) config)
|
||||||
|
.collect(Collectors.toMap(config -> config.getConfigVO().getSandboxCode(),
|
||||||
|
config -> (VirtualRealitySectionAxleCounter) config.getMapElement()));
|
||||||
|
for (int i = 3, dataLength = data.length; i < dataLength; i+=2) {
|
||||||
|
int code = Byte.toUnsignedInt(data[i - 1]);
|
||||||
|
VirtualRealitySectionAxleCounter axle = map.get(String.valueOf(code));
|
||||||
|
if (axle != null) {
|
||||||
|
int n = Byte.toUnsignedInt(data[i]);
|
||||||
|
if (n == 170) {
|
||||||
|
axle.setOccupy(true);
|
||||||
|
} else if (n == 85) {
|
||||||
|
axle.setOccupy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.device.real.udp.Sr;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||||
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
|
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
|
||||||
|
import club.joylink.rtss.vo.client.project.sr.SrSignalConfigVO;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class SrSignalConfig extends RealDeviceConfig {
|
||||||
|
private SrSignalConfigVO configVO;
|
||||||
|
|
||||||
|
public SrSignalConfig(ProjectDeviceVO projectDevice) {
|
||||||
|
super(projectDevice);
|
||||||
|
if (Objects.nonNull(projectDevice.getConfig())) {
|
||||||
|
this.configVO = JsonUtils.read(projectDevice.getConfig(), SrSignalConfigVO.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,131 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.device.real.udp.Sr;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClient;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SrSignalServiceImpl implements UDPRealDeviceService {
|
||||||
|
@Autowired
|
||||||
|
private UDPClient udpClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMatch(RealDeviceConfig realDevice) {
|
||||||
|
return realDevice instanceof SrSignalConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void control(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
|
||||||
|
SrSignalConfig config = (SrSignalConfig) realDevice;
|
||||||
|
//控制vr设备
|
||||||
|
VirtualRealitySignal vrSignal = (VirtualRealitySignal) realDevice.getMapElement();
|
||||||
|
SignalAspect aspect = vrSignal.getAspect();
|
||||||
|
SignalAspect command = vrSignal.getCommand();
|
||||||
|
if (Objects.equals(aspect, command)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (vrSignal.getRemain() > 0) {
|
||||||
|
vrSignal.turning(SimulationConstants.VRD_LOOP_RATE);
|
||||||
|
}
|
||||||
|
//控制沙盘设备
|
||||||
|
aspect = vrSignal.getAspect();
|
||||||
|
if (aspect == null || udpLowConfig == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
byte[] data = buildData(aspect, config);
|
||||||
|
if (data == null)
|
||||||
|
return;
|
||||||
|
udpClient.write(udpLowConfig.getAddr(), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Simulation simulation, UDPLowConfig udpConfig, RealDeviceConfig realDevice) {
|
||||||
|
SrSignalConfig config = (SrSignalConfig) realDevice;
|
||||||
|
VirtualRealitySignal vrSignal = (VirtualRealitySignal) config.getMapElement();
|
||||||
|
byte[] data = buildData(vrSignal.getAspect(), config);
|
||||||
|
udpClient.write(udpConfig.getAddr(), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Simulation simulation, ByteBuf msg) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] buildData(SignalAspect aspect, SrSignalConfig config) {
|
||||||
|
if (aspect == null)
|
||||||
|
return null;
|
||||||
|
byte[] data = new byte[5];
|
||||||
|
data[1] = (byte) 203;
|
||||||
|
data[2] = (byte) Integer.parseInt(config.getConfigVO().getSandboxCode());
|
||||||
|
switch (aspect) {
|
||||||
|
case No:
|
||||||
|
case R:
|
||||||
|
case RF:
|
||||||
|
data[3] = (byte) 0;
|
||||||
|
break;
|
||||||
|
case G:
|
||||||
|
case GF:
|
||||||
|
data[3] = (byte) 1;
|
||||||
|
break;
|
||||||
|
case Y:
|
||||||
|
case YF:
|
||||||
|
data[3] = (byte) 2;
|
||||||
|
break;
|
||||||
|
case W:
|
||||||
|
case WF:
|
||||||
|
data[3] = (byte) 6;
|
||||||
|
break;
|
||||||
|
case B:
|
||||||
|
data[3] = (byte) 7;
|
||||||
|
break;
|
||||||
|
case GG:
|
||||||
|
data[3] = (byte) 5;
|
||||||
|
break;
|
||||||
|
case GY:
|
||||||
|
data[3] = (byte) 4;
|
||||||
|
break;
|
||||||
|
case YY:
|
||||||
|
data[3] = (byte) 3;
|
||||||
|
break;
|
||||||
|
case RY:
|
||||||
|
case RW:
|
||||||
|
return null;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
switch (aspect) {
|
||||||
|
case No:
|
||||||
|
case R:
|
||||||
|
case G:
|
||||||
|
case Y:
|
||||||
|
case W:
|
||||||
|
case B:
|
||||||
|
case RY:
|
||||||
|
case RW:
|
||||||
|
case GG:
|
||||||
|
case GY:
|
||||||
|
case YY:
|
||||||
|
data[4] = (byte) 0;
|
||||||
|
break;
|
||||||
|
case RF:
|
||||||
|
case YF:
|
||||||
|
case GF:
|
||||||
|
case WF:
|
||||||
|
data[4] = (byte) 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Unexpected value: " + aspect);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.device.real.udp.Sr;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||||
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
|
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
|
||||||
|
import club.joylink.rtss.vo.client.project.sr.SrSwitchConfigVO;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class SrSwitchConfig extends RealDeviceConfig {
|
||||||
|
private SrSwitchConfigVO configVO;
|
||||||
|
|
||||||
|
public SrSwitchConfig(ProjectDeviceVO projectDevice) {
|
||||||
|
super(projectDevice);
|
||||||
|
if (Objects.nonNull(projectDevice.getConfig())) {
|
||||||
|
this.configVO = JsonUtils.read(projectDevice.getConfig(), SrSwitchConfigVO.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.device.real.udp.Sr;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClient;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceService;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SrSwitchServiceImpl implements UDPRealDeviceService {
|
||||||
|
@Autowired
|
||||||
|
private UDPClient udpClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMatch(RealDeviceConfig realDevice) {
|
||||||
|
return realDevice instanceof SrSwitchConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void control(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
|
||||||
|
SrSwitchConfig config = (SrSwitchConfig) realDevice;
|
||||||
|
//控制vr设备
|
||||||
|
VirtualRealitySwitch vrSwitch = (VirtualRealitySwitch) realDevice.getMapElement();
|
||||||
|
if (vrSwitch.getRemain() > 0) {
|
||||||
|
vrSwitch.turning(SimulationConstants.VRD_LOOP_RATE);
|
||||||
|
}
|
||||||
|
//控制沙盘设备
|
||||||
|
SwitchIndication p = vrSwitch.getP();
|
||||||
|
if (p == null || udpLowConfig == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
byte[] data = buildData(p, config);
|
||||||
|
if (data == null)
|
||||||
|
return;
|
||||||
|
udpClient.write(udpLowConfig.getAddr(), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Simulation simulation, UDPLowConfig udpConfig, RealDeviceConfig realDevice) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Simulation simulation, ByteBuf msg) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] buildData(SwitchIndication p, SrSwitchConfig config) {
|
||||||
|
if (p == null)
|
||||||
|
return null;
|
||||||
|
byte[] data = new byte[4];
|
||||||
|
data[1] = (byte) 208;
|
||||||
|
data[2] = (byte) Integer.parseInt(config.getConfigVO().getSandboxCode());
|
||||||
|
switch (p) {
|
||||||
|
case N:
|
||||||
|
data[3] = (byte) 0;
|
||||||
|
break;
|
||||||
|
case R:
|
||||||
|
data[3] = (byte) 1;
|
||||||
|
break;
|
||||||
|
case NO:
|
||||||
|
case EX:
|
||||||
|
return null;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Unexpected value: " + p);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,8 @@ public class UDPClient implements ApplicationRunner {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UDPConfig udpConfig;
|
private UDPConfig udpConfig;
|
||||||
|
|
||||||
|
private Channel channel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
this.start();
|
this.start();
|
||||||
@ -43,21 +45,32 @@ public class UDPClient implements ApplicationRunner {
|
|||||||
});
|
});
|
||||||
ChannelFuture future = bootstrap.bind(udpConfig.getClientPort()).sync();
|
ChannelFuture future = bootstrap.bind(udpConfig.getClientPort()).sync();
|
||||||
Channel channel = future.channel();
|
Channel channel = future.channel();
|
||||||
byte[] bytes = new byte[]{(byte)127, (byte)0, (byte)0, (byte)1};
|
this.channel = channel;
|
||||||
|
if(future.isSuccess()) {
|
||||||
|
log.info(String.format("udp client start on port [%s]", this.udpConfig.getClientPort()));
|
||||||
|
} else {
|
||||||
|
log.error("udp server start failed", future.cause());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(byte[] ip, int port, byte[] msg) {
|
||||||
try {
|
try {
|
||||||
InetAddress inetAddress = InetAddress.getByAddress(bytes);
|
if (channel != null && channel.isWritable()) {
|
||||||
InetSocketAddress addr = new InetSocketAddress(inetAddress, 9999);
|
InetAddress inetAddress = InetAddress.getByAddress(ip);
|
||||||
ByteBuf byteBuf = Unpooled.copiedBuffer("主动发送消息".getBytes());
|
InetSocketAddress addr = new InetSocketAddress(inetAddress, port);
|
||||||
DatagramPacket data = new DatagramPacket(byteBuf, addr);
|
write(addr, msg);
|
||||||
channel.writeAndFlush(data);
|
|
||||||
if(future.isSuccess()) {
|
|
||||||
log.info(String.format("udp client start on port [%s]", this.udpConfig.getClientPort()));
|
|
||||||
} else {
|
|
||||||
log.error("udp server start failed", future.cause());
|
|
||||||
}
|
}
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void write(InetSocketAddress addr, byte[] msg) {
|
||||||
|
if (channel != null && channel.isWritable() && addr != null) {
|
||||||
|
ByteBuf byteBuf = Unpooled.copiedBuffer(msg);
|
||||||
|
DatagramPacket data = new DatagramPacket(byteBuf, addr);
|
||||||
|
channel.writeAndFlush(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.device.real.udp;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||||
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
|
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
|
||||||
|
import club.joylink.rtss.vo.client.project.UDPClientConfigVO;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class UDPClientConfig extends RealDeviceConfig {
|
||||||
|
private UDPClientConfigVO configVO;
|
||||||
|
|
||||||
|
public UDPClientConfig(ProjectDeviceVO projectDevice) {
|
||||||
|
super(projectDevice);
|
||||||
|
if (StringUtils.hasText(projectDevice.getConfig())) {
|
||||||
|
this.configVO = JsonUtils.read(projectDevice.getConfig(), UDPClientConfigVO.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.device.real.udp;
|
||||||
|
|
||||||
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||||
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
|
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
|
||||||
|
import club.joylink.rtss.vo.client.project.UDPLowConfigVO;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class UDPLowConfig extends RealDeviceConfig {
|
||||||
|
private UDPLowConfigVO configVO;
|
||||||
|
|
||||||
|
private byte[] ip;
|
||||||
|
|
||||||
|
private Integer port;
|
||||||
|
|
||||||
|
private InetSocketAddress addr;
|
||||||
|
|
||||||
|
public UDPLowConfig(ProjectDeviceVO projectDevice) {
|
||||||
|
super(projectDevice);
|
||||||
|
if (StringUtils.hasText(projectDevice.getConfig())) {
|
||||||
|
this.configVO = JsonUtils.read(projectDevice.getConfig(), UDPLowConfigVO.class);
|
||||||
|
String ipStr = configVO.getIp();
|
||||||
|
if (StringUtils.hasText(ipStr)) {
|
||||||
|
String[] split = ipStr.split("\\.");
|
||||||
|
BusinessExceptionAssertEnum.DATA_ERROR.assertEquals(split.length, 4);
|
||||||
|
ip = new byte[4];
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
ip[i] = (byte) Integer.parseInt(split[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.port = configVO.getPort();
|
||||||
|
//构建地址
|
||||||
|
if (ip != null && port != null) {
|
||||||
|
try {
|
||||||
|
InetAddress inetAddress = InetAddress.getByAddress(ip);
|
||||||
|
addr = new InetSocketAddress(inetAddress, port);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.device.real.udp;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
public interface UDPRealDeviceService {
|
||||||
|
boolean isMatch(RealDeviceConfig realDevice);
|
||||||
|
|
||||||
|
void control(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice);
|
||||||
|
|
||||||
|
void init(Simulation simulation, UDPLowConfig udpConfig, RealDeviceConfig realDevice);
|
||||||
|
|
||||||
|
void handle(Simulation simulation, ByteBuf msg);
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.device.real.udp;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class UDPRealDeviceServiceManager implements ApplicationContextAware {
|
||||||
|
private List<UDPRealDeviceService> serviceList;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
Map<String, UDPRealDeviceService> deviceServiceMap = applicationContext.getBeansOfType(UDPRealDeviceService.class);
|
||||||
|
this.serviceList = new ArrayList<>(deviceServiceMap.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UDPRealDeviceService> getServiceList() {
|
||||||
|
return this.serviceList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.device.real.udp;
|
||||||
|
|
||||||
|
import club.joylink.rtss.constants.ProjectDeviceType;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.PlcGateway;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.event.SimulationResetEvent;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class UDPRealDeviceThread {
|
||||||
|
@Autowired
|
||||||
|
private UDPRealDeviceServiceManager udpRealDeviceServiceManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GroupSimulationService groupSimulationService;
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
public void simulationReset(SimulationResetEvent event) {
|
||||||
|
Simulation simulation = event.getSimulation();
|
||||||
|
List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList();
|
||||||
|
if (CollectionUtils.isEmpty(realDeviceList))
|
||||||
|
return;
|
||||||
|
UDPLowConfig udpConfig = (UDPLowConfig) simulation.queryOneRealDevice(ProjectDeviceType.UDP_LOW);
|
||||||
|
if (udpConfig == null)
|
||||||
|
return;
|
||||||
|
for (RealDeviceConfig realDevice : realDeviceList) {
|
||||||
|
if (realDevice instanceof PlcGateway) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (UDPRealDeviceService realDeviceService : this.udpRealDeviceServiceManager.getServiceList()) {
|
||||||
|
if (realDeviceService.isMatch(realDevice)) {
|
||||||
|
realDeviceService.init(simulation, udpConfig, realDevice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(Simulation simulation) {
|
||||||
|
List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList();
|
||||||
|
if (CollectionUtils.isEmpty(realDeviceList))
|
||||||
|
return;
|
||||||
|
List<UDPRealDeviceService> serviceList = udpRealDeviceServiceManager.getServiceList();
|
||||||
|
if (CollectionUtils.isEmpty(serviceList))
|
||||||
|
return;
|
||||||
|
UDPLowConfig udpLowConfig = null;
|
||||||
|
for (RealDeviceConfig realDeviceConfig : realDeviceList) {
|
||||||
|
if (ProjectDeviceType.UDP_LOW.equals(realDeviceConfig.getDeviceType())) {
|
||||||
|
udpLowConfig = (UDPLowConfig) realDeviceConfig;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (RealDeviceConfig config : realDeviceList) {
|
||||||
|
for (UDPRealDeviceService service : serviceList) {
|
||||||
|
if (service.isMatch(config)) {
|
||||||
|
service.control(simulation, udpLowConfig, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleData(String ip, int port, ByteBuf data) {
|
||||||
|
List<Simulation> simulations = groupSimulationService.querySimulations();
|
||||||
|
for (Simulation simulation : simulations) {
|
||||||
|
List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList();
|
||||||
|
if (CollectionUtils.isEmpty(realDeviceList))
|
||||||
|
continue;
|
||||||
|
UDPClientConfig udpClientConfig = (UDPClientConfig) simulation.queryOneRealDevice(ProjectDeviceType.UDP_CLIENT);
|
||||||
|
if (udpClientConfig != null && Objects.equals(ip, udpClientConfig.getConfigVO().getIp())
|
||||||
|
&& Objects.equals(port, udpClientConfig.getConfigVO().getPort())) {
|
||||||
|
for (UDPRealDeviceService udpRealDeviceService : this.udpRealDeviceServiceManager.getServiceList()) {
|
||||||
|
if (udpRealDeviceService.isMatch(udpClientConfig)) {
|
||||||
|
udpRealDeviceService.handle(simulation, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addJobs(Simulation simulation) {
|
||||||
|
simulation.addFixedRateJob(Simulation.JobName.udpRealDevice,
|
||||||
|
() -> this.run(simulation), SimulationConstants.VRD_LOOP_RATE);
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +1,29 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.device.real.udp.handler;
|
package club.joylink.rtss.simulation.cbtc.device.real.udp.handler;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceThread;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import io.netty.channel.socket.DatagramPacket;
|
import io.netty.channel.socket.DatagramPacket;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.net.InetSocketAddress;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class UDPMessageHandler extends SimpleChannelInboundHandler<DatagramPacket> {
|
public class UDPMessageHandler extends SimpleChannelInboundHandler<DatagramPacket> {
|
||||||
|
@Autowired
|
||||||
|
private UDPRealDeviceThread udpRealDeviceThread;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket datagramPacket) {
|
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket datagramPacket) {
|
||||||
System.out.println("收到消息:" + datagramPacket.content().toString(StandardCharsets.UTF_8));
|
InetSocketAddress sender = datagramPacket.sender();
|
||||||
ByteBuf byteBuf = Unpooled.copiedBuffer("hi".getBytes());
|
String ip = sender.getHostString();
|
||||||
ctx.writeAndFlush(new DatagramPacket(byteBuf, datagramPacket.sender()));
|
int port = sender.getPort();
|
||||||
|
ByteBuf content = datagramPacket.content();
|
||||||
|
udpRealDeviceThread.handleData(ip, port, content);
|
||||||
|
// System.out.println("收到消息:" + datagramPacket.content().toString(StandardCharsets.UTF_8));
|
||||||
|
// ByteBuf byteBuf = Unpooled.copiedBuffer("hi".getBytes());
|
||||||
|
// ctx.writeAndFlush(new DatagramPacket(byteBuf, datagramPacket.sender()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ public class VRDeviceLogicLoop {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新列车实际占压的计轴区段
|
* 更新列车实际占压的计轴区段
|
||||||
* @param simulation
|
|
||||||
*/
|
*/
|
||||||
public void updateTrainOccupySection(Simulation simulation) {
|
public void updateTrainOccupySection(Simulation simulation) {
|
||||||
SimulationDataRepository repository = simulation.getRepository();
|
SimulationDataRepository repository = simulation.getRepository();
|
||||||
@ -63,20 +62,24 @@ public class VRDeviceLogicLoop {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新区段占用状态
|
* 更新区段占用状态
|
||||||
* @param oldOccupyList
|
|
||||||
* @param occupySectionList
|
|
||||||
* @param right
|
|
||||||
*/
|
*/
|
||||||
private void updateAxleCounterOccupied(List<Section> oldOccupyList,
|
private void updateAxleCounterOccupied(List<Section> oldOccupyList,
|
||||||
List<Section> occupySectionList, boolean right) {
|
List<Section> occupySectionList, boolean right) {
|
||||||
// 非占用区段出清
|
// 非占用区段出清
|
||||||
if (!CollectionUtils.isEmpty(oldOccupyList)) { // 筛选出已经出清的区段,更新为非占用状态
|
if (!CollectionUtils.isEmpty(oldOccupyList)) { // 筛选出已经出清的区段,更新为非占用状态
|
||||||
oldOccupyList.removeAll(occupySectionList);
|
oldOccupyList.removeAll(occupySectionList);
|
||||||
oldOccupyList.forEach(section ->
|
oldOccupyList.forEach(section -> {
|
||||||
section.getVirtualAxleCounter().clear());
|
if (!section.getVirtualAxleCounter().isConnectReal()) {
|
||||||
|
section.getVirtualAxleCounter().clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// 所有计轴区段计轴占用——即非通信车占用
|
// 所有计轴区段计轴占用——即非通信车占用
|
||||||
occupySectionList.forEach(section -> section.getVirtualAxleCounter().occupied(right));
|
occupySectionList.forEach(section -> {
|
||||||
|
if (!section.getVirtualAxleCounter().isConnectReal()) {
|
||||||
|
section.getVirtualAxleCounter().occupied(right);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addJobs(Simulation simulation) {
|
public void addJobs(Simulation simulation) {
|
||||||
|
@ -15,6 +15,11 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPslConf
|
|||||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPsdConfig;
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPsdConfig;
|
||||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPslConfig;
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPslConfig;
|
||||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig;
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.Sr.SrSectionConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.Sr.SrSignalConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.Sr.SrSwitchConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClientConfig;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -110,12 +115,39 @@ public class ProjectDeviceVO {
|
|||||||
case RICHOR_JOINT: {
|
case RICHOR_JOINT: {
|
||||||
return zjdDeviceConfigConvert(voList);
|
return zjdDeviceConfigConvert(voList);
|
||||||
}
|
}
|
||||||
|
case SR_SANDBOX: {
|
||||||
|
return srSandboxDeviceConfigConvert(voList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<RealDeviceConfig> srSandboxDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||||
|
List<RealDeviceConfig> list = new ArrayList<>();
|
||||||
|
for (ProjectDeviceVO deviceVO : voList) {
|
||||||
|
switch (deviceVO.getType()) {
|
||||||
|
case UDP_LOW:
|
||||||
|
list.add(new UDPLowConfig(deviceVO));
|
||||||
|
break;
|
||||||
|
case UDP_CLIENT:
|
||||||
|
list.add(new UDPClientConfig(deviceVO));
|
||||||
|
break;
|
||||||
|
case SIGNAL:
|
||||||
|
list.add(new SrSignalConfig(deviceVO));
|
||||||
|
break;
|
||||||
|
case SECTION:
|
||||||
|
list.add(new SrSectionConfig(deviceVO));
|
||||||
|
break;
|
||||||
|
case SWITCH:
|
||||||
|
list.add(new SrSwitchConfig(deviceVO));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
private static List<RealDeviceConfig> zjdDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
private static List<RealDeviceConfig> zjdDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||||
List<RealDeviceConfig> list = new ArrayList<>();
|
List<RealDeviceConfig> list = new ArrayList<>();
|
||||||
for (ProjectDeviceVO deviceVO : voList) {
|
for (ProjectDeviceVO deviceVO : voList) {
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package club.joylink.rtss.vo.client.project;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UDPClientConfigVO {
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
private Integer port;
|
||||||
|
|
||||||
|
public UDPClientConfigVO(String ip, Integer port) {
|
||||||
|
this.ip = ip;
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package club.joylink.rtss.vo.client.project;
|
||||||
|
|
||||||
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UDP下位机配置
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UDPLowConfigVO {
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
private Integer port;
|
||||||
|
|
||||||
|
public UDPLowConfigVO(String ip, Integer port) {
|
||||||
|
this.ip = ip;
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toJson() {
|
||||||
|
return JsonUtils.writeValueAsString(this);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
package club.joylink.rtss.vo.client.project;
|
|
||||||
|
|
||||||
public class UdpLowConfigVO {
|
|
||||||
|
|
||||||
}
|
|
@ -1,8 +1,6 @@
|
|||||||
package club.joylink.rtss.vo.client.project.gzb;
|
package club.joylink.rtss.vo.client.project.gzb;
|
||||||
|
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
|
||||||
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package club.joylink.rtss.vo.client.project.gzb;
|
package club.joylink.rtss.vo.client.project.gzb;
|
||||||
|
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
|
||||||
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package club.joylink.rtss.vo.client.project.sdy;
|
package club.joylink.rtss.vo.client.project.sdy;
|
||||||
|
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
|
||||||
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package club.joylink.rtss.vo.client.project.sdy;
|
package club.joylink.rtss.vo.client.project.sdy;
|
||||||
|
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
|
||||||
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package club.joylink.rtss.vo.client.project.sr;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SrSectionConfigVO {
|
||||||
|
private String vrCode;
|
||||||
|
|
||||||
|
private String sandboxCode;
|
||||||
|
|
||||||
|
public SrSectionConfigVO(String vrCode, String sandboxCode) {
|
||||||
|
this.vrCode = vrCode;
|
||||||
|
this.sandboxCode = sandboxCode;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package club.joylink.rtss.vo.client.project.sr;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SrSignalConfigVO {
|
||||||
|
private String vrCode;
|
||||||
|
|
||||||
|
private String sandboxCode;
|
||||||
|
|
||||||
|
public SrSignalConfigVO(String vrCode, String sandboxCode) {
|
||||||
|
this.vrCode = vrCode;
|
||||||
|
this.sandboxCode = sandboxCode;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package club.joylink.rtss.vo.client.project.sr;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SrSwitchConfigVO {
|
||||||
|
private String vrCode;
|
||||||
|
|
||||||
|
private String sandboxCode;
|
||||||
|
|
||||||
|
public SrSwitchConfigVO(String vrCode, String sandboxCode) {
|
||||||
|
this.vrCode = vrCode;
|
||||||
|
this.sandboxCode = sandboxCode;
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,7 @@
|
|||||||
package club.joylink.rtss.vo.client.project.xty;
|
package club.joylink.rtss.vo.client.project.xty;
|
||||||
|
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
|
||||||
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
Loading…
Reference in New Issue
Block a user