Merge branch 'test'

This commit is contained in:
joylink_zhangsai 2023-10-31 17:52:11 +08:00
commit b4aa17e028
39 changed files with 6726 additions and 6309 deletions

View File

@ -413,14 +413,6 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
// 生成交路数据
List<MapRoutingDataVO> generateRoutingList = this.routingGenerator.generateAllRouting(deviceMap, errorList);
//站间运行等级生成
// List<MapStationRunLevelVO> generatedStationRunLevelList =
// this.runLevelGenerator.generateRunLevels(
// generateRoutingList, deviceMap, errorList
// );
// 停站时间生成
// List<MapStationParkingTimeVO> parkTimeList = this.parkTimeGenerator.generate(deviceMap, errorList);
//目的地码生成
List<DestinationCodeDefinition> destinationCodeDefinitionList
= generateDestinationCodeDefinition(config, sectionList, stationList);
@ -662,6 +654,8 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
if (!CollectionUtils.isEmpty(routePathList)) {
for (SectionPath sectionPath : routePathList) {
Section lastSection = sectionPath.getLastSection();
//最后一个区段是轨道尽头则认为是单列车进路
boolean singleTrain = lastSection.getNextSection(sectionPath.isRight()) == null;
Signal end = lastSection.getSignalOf(right);
List<RouteOverlap> overlapList = overlapMap.get(end.getCode());
// 根据配置是否有延续保护生成
@ -691,31 +685,31 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
clickEnd = this.queryNearlySignalOf(start, sectionPath);
}
// 构建进路
if (config.isRouteApartByOverlap() && overlapList != null && overlapList.size() > 1) {
if (config.isRouteApartByOverlap() && !CollectionUtils.isEmpty(overlapList)) {
int index = 1;
for (RouteOverlap routeOverlap : overlapList) {
String code = routeCodeGenerator.next();
String name = String.format("%s-%s_%s", start.getName(), endName, index);
Route route = this.buildRoute(code, name, start, end, clickEnd, sectionPath,
routeOverlap, config.isRouteSignalAlwaysGreen(), config.isRouteInterlockDoNotIncludeStandHoldTrain());
Route route = this.buildRoute(code, name, start, end, clickEnd, sectionPath, routeOverlap,
config.isRouteSignalAlwaysGreen(), config.isRouteInterlockDoNotIncludeStandHoldTrain(), singleTrain);
routeList.add(route);
++index;
}
} else if (config.isOverlapSettingByTrigger()) { // 触发建立进路不绑定延续保护
String code = routeCodeGenerator.next();
String name = String.format("%s-%s", start.getName(), endName);
Route route = this.buildRoute(code, name, start, end, clickEnd, sectionPath,
null, config.isRouteSignalAlwaysGreen(), config.isRouteInterlockDoNotIncludeStandHoldTrain());
Route route = this.buildRoute(code, name, start, end, clickEnd, sectionPath, null,
config.isRouteSignalAlwaysGreen(), config.isRouteInterlockDoNotIncludeStandHoldTrain(), singleTrain);
routeList.add(route);
} else {
String code = routeCodeGenerator.next();
String name = String.format("%s-%s", start.getName(), endName);
RouteOverlap overlap = null;
if (!CollectionUtils.isEmpty(overlapList) && overlapList.size() > 0) {
if (!CollectionUtils.isEmpty(overlapList)) {
overlap = overlapList.get(0);
}
Route route = this.buildRoute(code, name, start, end, clickEnd, sectionPath,
overlap, config.isRouteSignalAlwaysGreen(), config.isRouteInterlockDoNotIncludeStandHoldTrain());
Route route = this.buildRoute(code, name, start, end, clickEnd, sectionPath, overlap,
config.isRouteSignalAlwaysGreen(), config.isRouteInterlockDoNotIncludeStandHoldTrain(), singleTrain);
routeList.add(route);
}
}
@ -1425,11 +1419,12 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
* @param routeOverlap
* @param alwaysGreen 进路始端信号是否总是开绿灯
* @param noStandHold
* @param singleTrain
* @return
*/
private Route buildRoute(String code, String name,
Signal start, Signal end, Signal endButton,
SectionPath sectionPath, RouteOverlap routeOverlap, boolean alwaysGreen, boolean noStandHold) {
SectionPath sectionPath, RouteOverlap routeOverlap, boolean alwaysGreen, boolean noStandHold, boolean singleTrain) {
Route route = new Route(code, name);
route.setInterlockStation(start.getInterlockStation());
route.setStart(start);
@ -1438,6 +1433,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
route.setSectionList(sectionPath.getSectionList());
route.setSwitchList(sectionPath.getSwitchList());
route.setOverlap(routeOverlap);
route.setSingleTrain(singleTrain);
SignalModel signalModel = start.getSignalModel();
switch (signalModel) {
case RGY:{
@ -1464,10 +1460,22 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
ars = false;
}
}
RouteOverlap overlap = route.getOverlap();
if (overlap != null && !overlap.isStraight()) { //如果延续保护不是直向没有联锁自动触发
ars = false;
}
for (Section section : route.getSectionList()) {
//进路中的区段类型与进路方向相反说明不是常规运行进路没有联锁自动触发
if (section.isLeftLine() && route.isRight() || section.isRightLine() && !route.isRight()) {
ars = false;
break;
}
}
if (start.isSameDirectionToSection() && end.isSameDirectionToSection() && route.isStraight()) {
// 进路始端终端信号机都是常规运行方向且进路是直向进路则为车队进路
flt = true;
}
route.setArs(ars);
route.setFlt(flt);
// 根据区段设置进路联锁站台相关元素

View File

@ -35,162 +35,163 @@ import java.util.stream.Collectors;
@Service
@Slf4j
public class Training2PublishService {
@Autowired
private PublishedTraining2DAO publishedDao;
@Autowired
private IMapService mapService;
@Transactional(readOnly = true)
public PublishedTraining2 findById(Long id) {
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(id);
List<PublishedTraining2> find = this.publishedDao.selectByExample(example);
return null != find && find.size() > 0 ? find.get(0) : null;
@Autowired
private PublishedTraining2DAO publishedDao;
@Autowired
private IMapService mapService;
@Transactional(readOnly = true)
public PublishedTraining2 findById(Long id) {
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(id);
List<PublishedTraining2> find = this.publishedDao.selectByExample(example);
return null != find && find.size() > 0 ? find.get(0) : null;
}
/**
* 根据组织类型单操作实操标签获取对应的数量
*/
public Long queryCountForLabel(FindCountForQuestionReqVo reqVo) {
if (Objects.isNull(reqVo.getTrainingClient())) {
//单操没有选定客户端不查询数量
return 0L;
}
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria c = this.basicQueryCriteria(example, reqVo.getMapId(), reqVo.getOrgId(), reqVo.getSubType().name().toUpperCase(), Arrays.asList(reqVo.getTags()),
reqVo.getTrainingClient());
return this.publishedDao.countByExample(example);
}
/**
* 根据组织类型单操作实操标签获取对应的数量
*/
public Long queryCountForLabel(FindCountForQuestionReqVo reqVo){
if(Objects.isNull(reqVo.getTrainingClient())){
//单操没有选定客户端不查询数量
return 0L;
}
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria c = this.basicQueryCriteria(example,reqVo.getMapId(),reqVo.getOrgId(),reqVo.getSubType().name().toUpperCase(),Arrays.asList(reqVo.getTags()),reqVo.getTrainingClient());
return this.publishedDao.countByExample(example);
/**
* 根据 组织类型单操作实操 获取标签
*/
public Collection<String> findAllLabel(Long mapId, Long orgId, String type, PaperQType.TrainingClient client) {
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria c = this.basicQueryCriteria(example, mapId, orgId, type, null, client);
List<PublishedTraining2> dataList = this.publishedDao.selectByExample(example);
if (CollectionUtils.isEmpty(dataList)) {
return Collections.emptyList();
}
return dataList.stream().map(PublishedTraining2::getLabelJson).filter(StringUtils::hasText).map(d -> {
List<String> l = JsonUtils.readCollection(d, List.class, String.class);
return l;
}).flatMap(Collection::stream).collect(Collectors.toSet());
}
/**
* 根据 组织类型单操作实操 获取标签
*/
public Collection<String> findAllLabel(Long mapId, Long orgId, String type, PaperQType.TrainingClient client){
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria c = this.basicQueryCriteria(example,mapId,orgId,type,null,client);
List<PublishedTraining2> dataList = this.publishedDao.selectByExample(example);
if(CollectionUtils.isEmpty(dataList)){
return Collections.emptyList();
}
return dataList.stream().map(PublishedTraining2::getLabelJson).filter(StringUtils::hasText).map(d->{
List<String> l = JsonUtils.readCollection(d,List.class,String.class);
return l;
}).flatMap(Collection::stream).collect(Collectors.toSet());
public PublishedTraining2Example.Criteria basicQueryCriteria(PublishedTraining2Example example, Long mapId, Long orgId, String type, List<String> lables, PaperQType.TrainingClient client) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(mapId), "请关联对应的线路");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId), "组织信息不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(type), "查询类型信息不能为空");
PublishedTraining2Example.Criteria criteria = example.createCriteria();
criteria.andMapIdEqualTo(mapId);
criteria.andOrgIdEqualTo(orgId);
criteria.andTypeEqualTo(type);
criteria.andStateEqualTo(BusinessConsts.STATUS_USE_INT);//上架
//查询共享的数据
PublishedTraining2Example.Criteria or = example.or();
or.andSharedEqualTo(BusinessConsts.STATUS_USE_INT);
or.andMapIdEqualTo(mapId);
or.andTypeEqualTo(type);
or.andStateEqualTo(BusinessConsts.STATUS_USE_INT);
if (Objects.nonNull(client)) {
criteria.andClientEqualTo(client.name());
or.andClientEqualTo(client.name());
}
public PublishedTraining2Example.Criteria basicQueryCriteria(PublishedTraining2Example example, Long mapId, Long orgId, String type, List<String> lables, PaperQType.TrainingClient client){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(mapId),"请关联对应的线路");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId),"组织信息不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(type),"查询类型信息不能为空");
PublishedTraining2Example.Criteria criteria = example.createCriteria();
criteria.andMapIdEqualTo(mapId);
criteria.andOrgIdEqualTo(orgId);
criteria.andTypeEqualTo(type);
criteria.andStateEqualTo(BusinessConsts.STATUS_USE_INT);//上架
//查询共享的数据
PublishedTraining2Example.Criteria or = example.or();
or.andSharedEqualTo(BusinessConsts.STATUS_USE_INT);
or.andMapIdEqualTo(mapId);
or.andTypeEqualTo(type);
or.andStateEqualTo(BusinessConsts.STATUS_USE_INT);
if(Objects.nonNull(client)){
criteria.andClientEqualTo(client.name());
or.andClientEqualTo(client.name());
}
// or.andOrgIdNotEqualTo(orgId);
if(!CollectionUtils.isEmpty(lables)){
for (String tag : lables) {
if(StringUtils.hasText(tag)){
criteria.andLabelJsonLike(String.format("%%%s%%", tag));
or.andLabelJsonLike(String.format("%%%s%%", tag));
}
}
if (!CollectionUtils.isEmpty(lables)) {
for (String tag : lables) {
if (StringUtils.hasText(tag)) {
criteria.andLabelJsonLike(String.format("%%%s%%", tag));
or.andLabelJsonLike(String.format("%%%s%%", tag));
}
return criteria;
}
}
return criteria;
}
/**
* 已发布实训分页列表
*/
@Transactional(readOnly = true)
public PageVO<PublishedTraining2InfoRspVo> publishedTrainingsPage(PublishedTraining2InfoPageReqVo req) {
PageHelper.startPage(req.getPageNum(), req.getPageSize());
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria c = example.createCriteria();
if (Objects.nonNull(req.getState())) {
c.andStateEqualTo(req.getState());
}
if (Objects.nonNull(req.getOrgId())) {
c.andOrgIdEqualTo(req.getOrgId());
}
if (Objects.nonNull(req.getMapId())) {
c.andMapIdEqualTo(req.getMapId());
}
if (Objects.nonNull(req.getMapId())) {
c.andMapIdEqualTo(req.getMapId());
}
if (Objects.nonNull(req.getType())) {
c.andTypeEqualTo(req.getType());
}
if (StringUtils.hasText(req.getName())) {
c.andNameLike(String.format("%%%s%%", req.getName()));
}
if (Objects.equals(false, CollectionUtils.isEmpty(req.getLabelLikes()))) {
for (String ll : req.getLabelLikes()) {
c.andLabelJsonLike(String.format("%%%s%%", ll));
}
}
String orderBy = "create_time";
switch (req.getOrderBy()) {
/**
* 已发布实训分页列表
*/
@Transactional(readOnly = true)
public PageVO<PublishedTraining2InfoRspVo> publishedTrainingsPage(PublishedTraining2InfoPageReqVo req) {
PageHelper.startPage(req.getPageNum(), req.getPageSize());
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria c = example.createCriteria();
if (Objects.nonNull(req.getState())) {
c.andStateEqualTo(req.getState());
}
if (Objects.nonNull(req.getOrgId())) {
c.andOrgIdEqualTo(req.getOrgId());
}
if (Objects.nonNull(req.getMapId())) {
c.andMapIdEqualTo(req.getMapId());
}
if (Objects.nonNull(req.getMapId())) {
c.andMapIdEqualTo(req.getMapId());
}
if (Objects.nonNull(req.getType())) {
c.andTypeEqualTo(req.getType());
}
if (StringUtils.hasText(req.getName())) {
c.andNameLike(String.format("%%%s%%", req.getName()));
}
if (Objects.equals(false, CollectionUtils.isEmpty(req.getLabelLikes()))) {
for (String ll : req.getLabelLikes()) {
c.andLabelJsonLike(String.format("%%%s%%", ll));
}
}
String orderBy = "create_time";
switch (req.getOrderBy()) {
// case 1:orderBy="create_time";break;
case 2:
orderBy = "update_time";
break;
case 3:
orderBy = "name";
break;
case 4:
orderBy = "state";
break;
}
if (req.getDesc()) {
example.setOrderByClause(String.format(" %s desc", orderBy));
}
Page<PublishedTraining2> page = (Page<PublishedTraining2>) this.publishedDao.selectByExample(example);
List<PublishedTraining2InfoRspVo> tmpList = Training2Convertor.convertFrom(page.getResult());
return PageVO.convert(page, tmpList);
case 2:
orderBy = "update_time";
break;
case 3:
orderBy = "name";
break;
case 4:
orderBy = "state";
break;
}
if (req.getDesc()) {
example.setOrderByClause(String.format(" %s desc", orderBy));
}
Page<PublishedTraining2> page = (Page<PublishedTraining2>) this.publishedDao.selectByExample(example);
List<PublishedTraining2InfoRspVo> tmpList = Training2Convertor.convertFrom(page.getResult());
/**
* 已发布实训上架
*/
@Transactional(rollbackFor = Exception.class)
public PutOnPublishedTraining2RspVo putOnPublishedTrainings(PutOnPublishedTraining2ReqVo req,LoginUserInfoVO userInfoVO) {
final PutOnPublishedTraining2RspVo rsp = new PutOnPublishedTraining2RspVo();
rsp.setIds(new ArrayList<>());
if(CollectionUtils.isEmpty(req.getIds())){
return rsp;
}
List<Long> newIds = this.pretreatmentFindData(req.getIds(),userInfoVO);
for (Long newId : newIds) {
PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs();
pub.setId(newId);
pub.setState(PublishedTraining2StateEnum.PutOn.getState());
pub.setUpdateTime(LocalDateTime.now());
//
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(pub.getId());
//
int urt = this.publishedDao.updateByExampleSelective(pub, example);
if (urt > 0) {//记录更新成功的
rsp.getIds().add(newId.toString());
}
}
return PageVO.convert(page, tmpList);
}
/**
* 已发布实训上架
*/
@Transactional(rollbackFor = Exception.class)
public PutOnPublishedTraining2RspVo putOnPublishedTrainings(PutOnPublishedTraining2ReqVo req, LoginUserInfoVO userInfoVO) {
final PutOnPublishedTraining2RspVo rsp = new PutOnPublishedTraining2RspVo();
rsp.setIds(new ArrayList<>());
if (CollectionUtils.isEmpty(req.getIds())) {
return rsp;
}
List<Long> newIds = this.pretreatmentFindData(req.getIds(), userInfoVO);
for (Long newId : newIds) {
PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs();
pub.setId(newId);
pub.setState(PublishedTraining2StateEnum.PutOn.getState());
pub.setUpdateTime(LocalDateTime.now());
//
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(pub.getId());
//
int urt = this.publishedDao.updateByExampleSelective(pub, example);
if (urt > 0) {//记录更新成功的
rsp.getIds().add(newId.toString());
}
}
/* req.getIds().forEach(id -> {
PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs();
pub.setId(Long.valueOf(id));
@ -205,116 +206,119 @@ public class Training2PublishService {
rsp.getIds().add(id);
}
});*/
return rsp;
return rsp;
}
public void changeSharedStatus(Long id, Integer shared, LoginUserInfoVO userInfoVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(id), "id信息不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(shared), "未知共享类型");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(shared == BusinessConsts.STATUS_USE_INT || shared == BusinessConsts.STATUS_NOT_USE_INT, "未知共享类型");
}
/**
* 已发布实训下架
*/
@Transactional(rollbackFor = Exception.class)
public PullOffPublishedTraining2RspVo pullOffPublishedTrainings(PullOffPublishedTraining2ReqVo req, LoginUserInfoVO userInfoVO) {
final PullOffPublishedTraining2RspVo rsp = new PullOffPublishedTraining2RspVo();
rsp.setIds(new ArrayList<>());
if (CollectionUtils.isEmpty(req.getIds())) {
return rsp;
}
List<Long> newIds = this.pretreatmentFindData(req.getIds(), userInfoVO);
for (Long newId : newIds) {
PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs();
pub.setId(newId);
pub.setState(PublishedTraining2StateEnum.PullOff.getState());
pub.setUpdateTime(LocalDateTime.now());
//
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(pub.getId());
//
int urt = this.publishedDao.updateByExampleSelective(pub, example);
if (urt > 0) {//记录更新成功的
rsp.getIds().add(newId.toString());
}
}
public void changeSharedStatus(Long id ,Integer shared,LoginUserInfoVO userInfoVO){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(id),"id信息不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(shared),"未知共享类型");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(shared == BusinessConsts.STATUS_USE_INT || shared == BusinessConsts.STATUS_NOT_USE_INT,"未知共享类型");
return rsp;
}
/**
* 删除已发布实训
*/
@Transactional(rollbackFor = Exception.class)
public DeletePublishedTraining2RspVo deletePublishedTrainings(DeletePublishedTraining2ReqVo req, LoginUserInfoVO userInfoVO) {
DeletePublishedTraining2RspVo rsp = new DeletePublishedTraining2RspVo();
rsp.setIds(new ArrayList<>());
if (CollectionUtils.isEmpty(req.getIds())) {
return rsp;
}
/**
* 已发布实训下架
*/
@Transactional(rollbackFor = Exception.class)
public PullOffPublishedTraining2RspVo pullOffPublishedTrainings(PullOffPublishedTraining2ReqVo req,LoginUserInfoVO userInfoVO) {
final PullOffPublishedTraining2RspVo rsp = new PullOffPublishedTraining2RspVo();
rsp.setIds(new ArrayList<>());
if(CollectionUtils.isEmpty(req.getIds())){
return rsp;
}
List<Long> newIds = this.pretreatmentFindData(req.getIds(),userInfoVO);
for (Long newId : newIds) {
PublishedTraining2WithBLOBs pub = new PublishedTraining2WithBLOBs();
pub.setId(newId);
pub.setState(PublishedTraining2StateEnum.PullOff.getState());
pub.setUpdateTime(LocalDateTime.now());
//
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdEqualTo(pub.getId());
//
int urt = this.publishedDao.updateByExampleSelective(pub, example);
if (urt > 0) {//记录更新成功的
rsp.getIds().add(newId.toString());
}
}
return rsp;
List<Long> newIds = this.pretreatmentFindData(req.getIds(), userInfoVO);
for (Long newId : newIds) {
int drt = this.publishedDao.deleteByPrimaryKey(newId);
if (drt > 0) {
rsp.getIds().add(newId.toString());
}
}
/**
* 删除已发布实训
*/
@Transactional(rollbackFor = Exception.class)
public DeletePublishedTraining2RspVo deletePublishedTrainings(DeletePublishedTraining2ReqVo req, LoginUserInfoVO userInfoVO) {
DeletePublishedTraining2RspVo rsp = new DeletePublishedTraining2RspVo();
rsp.setIds(new ArrayList<>());
if(CollectionUtils.isEmpty(req.getIds())){
return rsp;
}
List<Long> newIds = this.pretreatmentFindData(req.getIds(),userInfoVO);
for (Long newId : newIds) {
int drt = this.publishedDao.deleteByPrimaryKey(newId);
if (drt > 0) {
rsp.getIds().add(newId.toString());
}
}
/*req.getIds().forEach(id -> {
int drt = this.publishedDao.deleteByPrimaryKey(Long.valueOf(id));
if (drt > 0) {
rsp.getIds().add(id);
}
});*/
//
return rsp;
}
//
return rsp;
}
private List<Long> pretreatmentFindData(List<String> ids, LoginUserInfoVO userInfoVO){
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria criteria = example.createCriteria();
List<Long> idLong = ids.stream().map(Long::valueOf).collect(Collectors.toList());
criteria.andIdIn(idLong);
List<PublishedTraining2> t2 = this.publishedDao.selectByExample(example);
List<PublishedTraining2> notExeList = t2.stream().filter(d->Objects.equals(d.getOrgId(),userInfoVO.getTopOrgId())).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(notExeList)){
String names = notExeList.stream().map(d->d.getName()).collect(Collectors.joining(","));
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(false,String.format("共享数据[%s]不能删除",names));
}
List<Long> findIds = t2.stream()
.filter(d->Objects.equals(d.getOrgId(),userInfoVO.getTopOrgId()))
.map(d->d.getId()).collect(Collectors.toList());
return findIds;
private List<Long> pretreatmentFindData(List<String> ids, LoginUserInfoVO userInfoVO) {
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria criteria = example.createCriteria();
List<Long> idLong = ids.stream().map(Long::valueOf).collect(Collectors.toList());
criteria.andIdIn(idLong);
List<PublishedTraining2> t2 = this.publishedDao.selectByExample(example);
List<PublishedTraining2> notExeList = t2.stream().filter(d -> Objects.equals(d.getOrgId(), userInfoVO.getTopOrgId()) && !Objects.equals(d.getCreatorId(), userInfoVO.getAccountVO().getId()))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(notExeList)) {
String names = notExeList.stream().map(d -> d.getName()).collect(Collectors.joining(","));
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(false, String.format("共享数据[%s]不能删除", names));
}
private PublishedTraining2Example.Criteria createQueryOrExample(PublishedTraining2Example example , PublishedTrainingListRspVo reqVO,List<Long> mapIdList){
List<Long> findIds = t2.stream()
.filter(d -> Objects.equals(d.getOrgId(), userInfoVO.getTopOrgId()))
.map(d -> d.getId()).collect(Collectors.toList());
return findIds;
}
PublishedTraining2Example.Criteria criteria = example.createCriteria();
private PublishedTraining2Example.Criteria createQueryOrExample(PublishedTraining2Example example, PublishedTrainingListRspVo reqVO, List<Long> mapIdList) {
PublishedTraining2Example.Criteria criteria = example.createCriteria();
// PublishedTraining2Example.Criteria or = example.or();
if (reqVO.getMapId() != null) {
criteria.andMapIdEqualTo(reqVO.getMapId());
}else{
criteria.andMapIdIn(mapIdList);
}
if (reqVO.getType() != null) {
criteria.andTypeEqualTo(reqVO.getType().value());
}
if(StringUtils.hasText(reqVO.getName())){
criteria.andNameLike(String.format("%%%s%%", reqVO.getName()));
}
if(Objects.nonNull(reqVO.getState())){
criteria.andStateEqualTo(reqVO.getState());
}
if(!CollectionUtils.isEmpty(reqVO.getLabels())){
for (String label : reqVO.getLabels()) {
criteria.andLabelJsonLike(String.format("%%%s%%", label));
}
}
if (reqVO.getOrgId() != null) {
criteria.andOrgIdEqualTo(reqVO.getOrgId());
}
return criteria;
if (reqVO.getMapId() != null) {
criteria.andMapIdEqualTo(reqVO.getMapId());
} else {
criteria.andMapIdIn(mapIdList);
}
if (reqVO.getType() != null) {
criteria.andTypeEqualTo(reqVO.getType().value());
}
if (StringUtils.hasText(reqVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", reqVO.getName()));
}
if (Objects.nonNull(reqVO.getState())) {
criteria.andStateEqualTo(reqVO.getState());
}
if (!CollectionUtils.isEmpty(reqVO.getLabels())) {
for (String label : reqVO.getLabels()) {
criteria.andLabelJsonLike(String.format("%%%s%%", label));
}
}
if (reqVO.getOrgId() != null) {
criteria.andOrgIdEqualTo(reqVO.getOrgId());
}
return criteria;
}
/* private PublishedTraining2Example.Criteria createQueryExample(PublishedTraining2Example example ,PublishedTrainingListRspVo reqVO){
PublishedTraining2Example.Criteria criteria = example.createCriteria();
@ -341,175 +345,177 @@ public class Training2PublishService {
return criteria;
}*/
public PageVO<PublishedTraining2InfoRspVo> findTrainingInfoForPage(PublishedTrainingListRspVo reqVO,LoginUserInfoVO userInfoVO,boolean findSharedData){
List<MapVO> mapVOS = this.mapService.listMapsOfUser(userInfoVO);
List<Long> mapIdList = mapVOS.stream().map(d->d.getId()).collect(Collectors.toList());
public PageVO<PublishedTraining2InfoRspVo> findTrainingInfoForPage(PublishedTrainingListRspVo reqVO, LoginUserInfoVO userInfoVO, boolean findSharedData) {
List<MapVO> mapVOS = this.mapService.listMapsOfUser(userInfoVO);
List<Long> mapIdList = mapVOS.stream().map(d -> d.getId()).collect(Collectors.toList());
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria criteria = this.createQueryOrExample(example,reqVO,mapIdList);
if(findSharedData){
PublishedTraining2Example.Criteria or = example.or();
or.andStateEqualTo(BusinessConsts.STATUS_USE_INT).andSharedEqualTo(BusinessConsts.STATUS_USE_INT);
if (reqVO.getType() != null) {
or.andTypeEqualTo(reqVO.getType().value());
}
if(Objects.isNull(reqVO.getMapId())){
or.andMapIdIn(mapIdList);
}else{
or.andMapIdEqualTo(reqVO.getMapId());
}
PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria criteria = this.createQueryOrExample(example, reqVO, mapIdList);
if (findSharedData) {
PublishedTraining2Example.Criteria or = example.or();
or.andStateEqualTo(BusinessConsts.STATUS_USE_INT).andSharedEqualTo(BusinessConsts.STATUS_USE_INT);
if (reqVO.getType() != null) {
or.andTypeEqualTo(reqVO.getType().value());
}
if (Objects.isNull(reqVO.getMapId())) {
or.andMapIdIn(mapIdList);
} else {
or.andMapIdEqualTo(reqVO.getMapId());
}
// if(Objects.nonNull(reqVO.getOrgId())){
// or.andOrgIdNotEqualTo(reqVO.getOrgId());
// }
}
PageHelper.startPage(reqVO.getPageNum(), reqVO.getPageSize());
Page<PublishedTraining2> page = (Page<PublishedTraining2>)this.publishedDao.selectByExample(example);
if(page.isEmpty()){
return PageVO.convert(page,Collections.emptyList());
}
return PageVO.convert(page,Training2Convertor.convertFrom(page.getResult()));
}
PageHelper.startPage(reqVO.getPageNum(), reqVO.getPageSize());
Page<PublishedTraining2> page = (Page<PublishedTraining2>) this.publishedDao.selectByExample(example);
if (page.isEmpty()) {
return PageVO.convert(page, Collections.emptyList());
}
return PageVO.convert(page, Training2Convertor.convertFrom(page.getResult()));
}
/**
* 根据地图ID和类型查询实训列表
*/
public List<PublishedTraining2InfoRspVo> findTrainingInfo(PublishedTrainingListRspVo reqVO,LoginUserInfoVO userInfoVO) {
List<MapVO> mapVOS = this.mapService.listMapsOfUser(userInfoVO);
List<Long> mapIdList = mapVOS.stream().map(d->d.getId()).collect(Collectors.toList());
/**
* 根据地图ID和类型查询实训列表
*/
public List<PublishedTraining2InfoRspVo> findTrainingInfo(PublishedTrainingListRspVo reqVO, LoginUserInfoVO userInfoVO) {
List<MapVO> mapVOS = this.mapService.listMapsOfUser(userInfoVO);
List<Long> mapIdList = mapVOS.stream().map(d -> d.getId()).collect(Collectors.toList());
PublishedTraining2Example example = new PublishedTraining2Example();
this.createQueryOrExample(example,reqVO,mapIdList);
PublishedTraining2Example.Criteria or = example.or();
or.andStateEqualTo(BusinessConsts.STATUS_USE_INT).andSharedEqualTo(BusinessConsts.STATUS_USE_INT);
or.andMapIdEqualTo(reqVO.getMapId());
if (reqVO.getType() != null) {
or.andTypeEqualTo(reqVO.getType().value());
}
PublishedTraining2Example example = new PublishedTraining2Example();
this.createQueryOrExample(example, reqVO, mapIdList);
PublishedTraining2Example.Criteria or = example.or();
or.andStateEqualTo(BusinessConsts.STATUS_USE_INT).andSharedEqualTo(BusinessConsts.STATUS_USE_INT);
or.andMapIdEqualTo(reqVO.getMapId());
if (reqVO.getType() != null) {
or.andTypeEqualTo(reqVO.getType().value());
}
// if(reqVO.getOrgId() !=null){
// or.andOrgIdNotEqualTo(reqVO.getOrgId());
// }
List<PublishedTraining2> list = this.publishedDao.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
return List.of();
} else {
return list.stream().map(Training2Convertor::convertFrom).collect(Collectors.toList());
}
List<PublishedTraining2> list = this.publishedDao.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
return List.of();
} else {
return list.stream().map(Training2Convertor::convertFrom).collect(Collectors.toList());
}
}
/**
* 根据已发布实训的id来查询实现的所有信息
*/
@Transactional(readOnly = true)
public PublishedTraining2DetailRspVo findTrainingAllInfoById(Long trainingId) {
PublishedTraining2WithBLOBs b = this.publishedDao.selectByPrimaryKey(trainingId);
if (null != b) {
PublishedTraining2DetailRspVo rsp = new PublishedTraining2DetailRspVo();
//
rsp.setDescription(b.getDescription());
rsp.setFailureConditionJson(b.getFailureConditionJson());
rsp.setCreateTime(b.getCreateTime());
rsp.setCreatorId(b.getCreatorId());
rsp.setLabelJson(b.getLabelJson());
rsp.setMapId(b.getMapId());
rsp.setName(b.getName());
rsp.setId(b.getId());
rsp.setType(b.getType());
rsp.setBgSceneJson(b.getBgSceneJson());
rsp.setMemberJson(b.getMemberJson());
rsp.setOperaJson(b.getOperaJson());
rsp.setStepJson(b.getStepJson());
rsp.setUpdateTime(b.getUpdateTime());
rsp.setPlayerIdJson(b.getPlayerIdJson());
rsp.setMapLocationJson(b.getMapLocationJson());
rsp.setRunPlanId(b.getRunPlanId());
rsp.setScoringRuleJson(b.getScoringRuleJson());
rsp.setState(b.getState());
rsp.setClient(b.getClient());
//
return rsp;
}
return null;
/**
* 根据已发布实训的id来查询实现的所有信息
*/
@Transactional(readOnly = true)
public PublishedTraining2DetailRspVo findTrainingAllInfoById(Long trainingId) {
PublishedTraining2WithBLOBs b = this.publishedDao.selectByPrimaryKey(trainingId);
if (null != b) {
PublishedTraining2DetailRspVo rsp = new PublishedTraining2DetailRspVo();
//
rsp.setDescription(b.getDescription());
rsp.setFailureConditionJson(b.getFailureConditionJson());
rsp.setCreateTime(b.getCreateTime());
rsp.setCreatorId(b.getCreatorId());
rsp.setLabelJson(b.getLabelJson());
rsp.setMapId(b.getMapId());
rsp.setName(b.getName());
rsp.setId(b.getId());
rsp.setType(b.getType());
rsp.setBgSceneJson(b.getBgSceneJson());
rsp.setMemberJson(b.getMemberJson());
rsp.setOperaJson(b.getOperaJson());
rsp.setStepJson(b.getStepJson());
rsp.setUpdateTime(b.getUpdateTime());
rsp.setPlayerIdJson(b.getPlayerIdJson());
rsp.setMapLocationJson(b.getMapLocationJson());
rsp.setRunPlanId(b.getRunPlanId());
rsp.setScoringRuleJson(b.getScoringRuleJson());
rsp.setState(b.getState());
rsp.setClient(b.getClient());
//
return rsp;
}
return null;
}
/**
* 根据地图ID列表修改生成实训的组织ID
*/
public void updatePublishTrainingOrgIdByMapId(Long orgId, List<Long> mapIdList) {
if (!CollectionUtils.isEmpty(mapIdList)) {
publishedDao.updateTrainingOrgByMapIdList(orgId, mapIdList);
}
/**
* 根据地图ID列表修改生成实训的组织ID
*/
public void updatePublishTrainingOrgIdByMapId(Long orgId, List<Long> mapIdList) {
if (!CollectionUtils.isEmpty(mapIdList)) {
publishedDao.updateTrainingOrgByMapIdList(orgId, mapIdList);
}
}
/**
* 批量更新实训label
*/
public void updateTrainingLabelList(List<PublishedTraining2> publishedTraining2List) {
List<PublishedTraining2> training2List = publishedTraining2List.stream().filter(t -> t.getId() != null).collect(Collectors.toList());
if (CollectionUtils.isEmpty(training2List)) {
return;
}
publishedDao.updateTrainingLabelList(training2List);
/**
* 批量更新实训label
*/
public void updateTrainingLabelList(List<PublishedTraining2> publishedTraining2List) {
List<PublishedTraining2> training2List = publishedTraining2List.stream().filter(t -> t.getId() != null).collect(Collectors.toList());
if (CollectionUtils.isEmpty(training2List)) {
return;
}
publishedDao.updateTrainingLabelList(training2List);
}
/**
* 更新实训label
*/
public void updateTrainingLabel(PublishedTraining2 training2) {
PublishedTraining2WithBLOBs blobs = new PublishedTraining2WithBLOBs();
blobs.setId(training2.getId());
blobs.setLabelJson(training2.getLabelJson());
publishedDao.updateByPrimaryKeySelective(blobs);
}
/**
* 更新实训label
*/
public void updateTrainingLabel(PublishedTraining2 training2) {
PublishedTraining2WithBLOBs blobs = new PublishedTraining2WithBLOBs();
blobs.setId(training2.getId());
blobs.setLabelJson(training2.getLabelJson());
publishedDao.updateByPrimaryKeySelective(blobs);
}
/**
* 导出实训信息
* @param tidList 实训列表
* @return 实训列表
*/
public List<ExportTraining2> exportTraining(List<Long> tidList) {
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdIn(tidList);
List<PublishedTraining2WithBLOBs> training2WithBLOBsList = publishedDao.selectByExampleWithBLOBs(example);
Map<Long, List<PublishedTraining2WithBLOBs>> mapTrainingMap = training2WithBLOBsList.stream().peek(t -> {
t.setId(null);
t.setUpdateTime(null);
t.setCreateTime(null);
}).collect(Collectors.groupingBy(PublishedTraining2WithBLOBs::getMapId));
// 地图基本信息列表
List<MapInfo> mapInfoList = mapService.queryMapInfoList(new ArrayList<>(mapTrainingMap.keySet()));
Map<Long, MapInfo> mapInfoMap = mapInfoList.stream().collect(Collectors.toMap(MapInfo::getId, m -> m, (o,n) -> n));
List<ExportTraining2> exportTraining2List = new ArrayList<>(mapTrainingMap.size());
mapInfoMap.forEach((k, v) -> {
ExportTraining2 exportData = new ExportTraining2();
exportData.setName(v.getName());
exportData.setLineCode(v.getLineCode());
exportData.setList(mapTrainingMap.get(k));
exportTraining2List.add(exportData);
/**
* 导出实训信息
*
* @param tidList 实训列表
* @return 实训列表
*/
public List<ExportTraining2> exportTraining(List<Long> tidList) {
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andIdIn(tidList);
List<PublishedTraining2WithBLOBs> training2WithBLOBsList = publishedDao.selectByExampleWithBLOBs(example);
Map<Long, List<PublishedTraining2WithBLOBs>> mapTrainingMap = training2WithBLOBsList.stream().peek(t -> {
t.setId(null);
t.setUpdateTime(null);
t.setCreateTime(null);
}).collect(Collectors.groupingBy(PublishedTraining2WithBLOBs::getMapId));
// 地图基本信息列表
List<MapInfo> mapInfoList = mapService.queryMapInfoList(new ArrayList<>(mapTrainingMap.keySet()));
Map<Long, MapInfo> mapInfoMap = mapInfoList.stream().collect(Collectors.toMap(MapInfo::getId, m -> m, (o, n) -> n));
List<ExportTraining2> exportTraining2List = new ArrayList<>(mapTrainingMap.size());
mapInfoMap.forEach((k, v) -> {
ExportTraining2 exportData = new ExportTraining2();
exportData.setName(v.getName());
exportData.setLineCode(v.getLineCode());
exportData.setList(mapTrainingMap.get(k));
exportTraining2List.add(exportData);
});
return exportTraining2List;
}
/**
* 导入实训接口
*
* @param trainingList 实训列表
*/
public List<String> importTraining(List<ExportTraining2> trainingList, LoginUserInfoVO userInfoVO) {
List<String> msgList = new ArrayList<>();
trainingList.forEach(t -> {
List<MapInfo> mapInfoList = mapService.queryMapInfo(t.getName(), t.getLineCode());
if (mapInfoList.size() == 1) {
Long mapId = mapInfoList.get(0).getId();
t.getList().forEach(training -> {
training.setMapId(mapId);
training.setCreatorId(userInfoVO.getAccountVO().getId());
training.setCreateTime(LocalDateTime.now());
});
return exportTraining2List;
}
/**
* 导入实训接口
* @param trainingList 实训列表
*/
public List<String> importTraining(List<ExportTraining2> trainingList, LoginUserInfoVO userInfoVO) {
List<String> msgList = new ArrayList<>();
trainingList.forEach(t -> {
List<MapInfo> mapInfoList = mapService.queryMapInfo(t.getName(), t.getLineCode());
if (mapInfoList.size() == 1) {
Long mapId = mapInfoList.get(0).getId();
t.getList().forEach(training -> {
training.setMapId(mapId);
training.setCreatorId(userInfoVO.getAccountVO().getId());
training.setCreateTime(LocalDateTime.now());
});
publishedDao.insertList(t.getList());
msgList.add(String.format("地图【%s】实训信息导入成功", t.getName()));
} else {
msgList.add(String.format("地图【%s】实训信息导入失败", t.getName()));
}
});
return msgList;
}
publishedDao.insertList(t.getList());
msgList.add(String.format("地图【%s】实训信息导入成功", t.getName()));
} else {
msgList.add(String.format("地图【%s】实训信息导入失败", t.getName()));
}
});
return msgList;
}
}

View File

@ -67,6 +67,9 @@ public class OperateMethod {
JsonUtils.getCollectionType(parameter.getType(), actualClass));
} else if (parameter.getType().isEnum()) {
Object o = param.get(parameter.getName());
if (o == null) {
continue;
}
Object[] enumConstants = parameter.getType().getEnumConstants();
for (Object enumConstant : enumConstants) {
if (enumConstant.toString().equals(o.toString())) {

View File

@ -858,6 +858,11 @@ public class Operation {
* 切换ATO操作
*/
Try_Open_Ato(new Label[]{Label.OTHER}, true),
//--------------------------- 特殊操作多是ATS界面上对列车的操作 ---------------------------
/**
* 换端
*/
Special_Change_Head(new Label[]{Label.OTHER}, true),
//--------------------------- 方向杆 ---------------------------
/**
* 方向转换

View File

@ -12,11 +12,10 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.onboard.ATO.service.ATOService;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Objects;
/**
* 司机操作处理
*/
@ -24,59 +23,63 @@ import java.util.Objects;
@Slf4j
public class DriverOperateHandler {
@Autowired
private ATOService ATOService;
@Autowired
private ATOService ATOService;
@Autowired
private ATPService ATPService;
@Autowired
private ATPService ATPService;
@Autowired
private SimulationRobotService simulationRobotService;
@Autowired
private SimulationRobotService simulationRobotService;
@OperateHandlerMapping(type = Operation.Type.Driver_Force_Change)
public void changeTrainForce(Simulation simulation, String groupNumber, Float percent) {
Objects.requireNonNull(percent);
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
ATPService.changeTrainForce(train, percent);
@OperateHandlerMapping(type = Operation.Type.Driver_Force_Change)
public void changeTrainForce(Simulation simulation, String groupNumber, Float percent) {
Objects.requireNonNull(percent);
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
ATPService.changeTrainForce(train, percent);
}
/**
* 紧急制动
*/
@OperateHandlerMapping(type = Operation.Type.Driver_EB)
public void trainEB(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
if (train.isCircuitEB()) {
this.ATPService.cancelCircuitEB(train);
} else {
this.ATPService.triggerCircuitEB(train);
}
}
/**
* 紧急制动
*/
@OperateHandlerMapping(type = Operation.Type.Driver_EB)
public void trainEB(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
if (train.isCircuitEB()) {
this.ATPService.cancelCircuitEB(train);
} else {
this.ATPService.triggerCircuitEB(train);
}
}
/**
* 修改工况手轮档位
*
* @param simulation
* @param groupNumber
* @param gear
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Gear_Change)
public void changeTrainGear(Simulation simulation, String groupNumber,
VirtualRealityTrain.Handwheel gear) {
Objects.requireNonNull(gear);
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
ATPService.changeGear(train, gear);
}
/**
* 修改工况手轮档位
*
* @param simulation
* @param groupNumber
* @param gear
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Gear_Change)
public void changeTrainGear(Simulation simulation, String groupNumber, VirtualRealityTrain.Handwheel gear) {
Objects.requireNonNull(gear);
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
ATPService.changeGear(train, gear);
}
// 场景旧数据反序列化需要
@Deprecated
@OperateHandlerMapping(type = Operation.Type.Driver_Drive_Mode_Change)
public void changeTrainDriveMode(Simulation simulation, String groupNumber, DriveMode driveMode) {
// 场景旧数据反序列化需要
@Deprecated
@OperateHandlerMapping(type = Operation.Type.Driver_Drive_Mode_Change)
public void changeTrainDriveMode(Simulation simulation, String groupNumber, DriveMode driveMode) {
// VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
// switch (driveMode) {
// case AM:
@ -87,182 +90,194 @@ public class DriverOperateHandler {
// break;
// }
// }
}
}
@OperateHandlerMapping(type = Operation.Type.Driver_ATO_Open)
public void openAto(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
ATPService.openATO(train);
}
@OperateHandlerMapping(type = Operation.Type.Driver_ATO_Open)
public void openAto(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
ATPService.openATO(train);
}
@OperateHandlerMapping(type = Operation.Type.Driver_ATP_Change)
public void changeAtpStatus(Simulation simulation, String groupNumber, boolean cutOff) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
if (cutOff) {
this.ATPService.cutOffAtp(train);
} else {
this.ATPService.openAtp(train);
}
@OperateHandlerMapping(type = Operation.Type.Driver_ATP_Change)
public void changeAtpStatus(Simulation simulation, String groupNumber, boolean cutOff) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
if (cutOff) {
this.ATPService.cutOffAtp(train);
} else {
this.ATPService.openAtp(train);
}
}
@OperateHandlerMapping(type = Operation.Type.Driver_Change_Head)
public void changeHead(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
if (train.isStop()) {
this.ATPService.turnDirectionImmediately(train);
}
@OperateHandlerMapping(type = Operation.Type.Driver_Change_Head)
public void changeHead(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
if (train.isStop()) {
this.ATPService.turnDirectionImmediately(train);
}
}
/**
* /关门
*
* @param groupNumber 要开/关门的列车的车组号
* @param right 要开/关右边的门吗
* @param open 要开门吗
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Door_On_Off)
public void onOrOffDoor(Simulation simulation, String groupNumber, Boolean right, Boolean open) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
ATPService.openOrCloseDoor(simulation, train, right, open);
}
/**
* /关门
*
* @param groupNumber 要开/关门的列车的车组号
* @param right 要开/关右边的门吗
* @param open 要开门吗
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Door_On_Off)
public void onOrOffDoor(Simulation simulation, String groupNumber, Boolean right, Boolean open) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
ATPService.openOrCloseDoor(simulation, train, right, open);
}
/**
* 设置门模式
*
* @param groupNumber 车组号
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Door_Mode)
public void setDriverDoorMode(Simulation simulation, String groupNumber,
VirtualRealityTrain.DoorMode doorMode) {
if (Objects.isNull(doorMode)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "门模式不能为空");
}
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
train.setDoorMode(doorMode);
/**
* 设置门模式
*
* @param groupNumber 车组号
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Door_Mode)
public void setDriverDoorMode(Simulation simulation, String groupNumber,
VirtualRealityTrain.DoorMode doorMode) {
if (Objects.isNull(doorMode)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "门模式不能为空");
}
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
train.setDoorMode(doorMode);
}
/**
* 设置门选择
*
* @param groupNumber 车组号
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Door_Selection)
public void setDriverDoorSelection(Simulation simulation, String groupNumber,
VirtualRealityTrain.DoorSelection doorSelection) {
if (Objects.isNull(doorSelection)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "门选择不能为空");
}
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
train.setDoorSelection(doorSelection);
/**
* 设置门选择
*
* @param groupNumber 车组号
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Door_Selection)
public void setDriverDoorSelection(Simulation simulation, String groupNumber,
VirtualRealityTrain.DoorSelection doorSelection) {
if (Objects.isNull(doorSelection)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "门选择不能为空");
}
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
train.setDoorSelection(doorSelection);
}
/**
* 模式升
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Preselection_Mode_Up)
public void beforehandModeUp(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
ATPService.preselectionModeUp(train);
}
/**
* 模式升
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Preselection_Mode_Up)
public void beforehandModeUp(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
ATPService.preselectionModeUp(train);
}
/**
* 模式降
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Preselection_Mode_Down)
public void beforehandModeDown(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
ATPService.preselectionModeDown(train);
}
/**
* 模式降
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Preselection_Mode_Down)
public void beforehandModeDown(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
ATPService.preselectionModeDown(train);
}
/**
* 确认
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Confirm)
public void confirmMessage(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train))
return;
ATPService.confirmMessage(train);
}
/**
* 确认
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Confirm)
public void confirmMessage(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!validate(train)) {
return;
}
ATPService.confirmMessage(train);
}
/**
* 接管列车
*/
@OperateHandlerMapping(type = Operation.Type.Driver_TakeOver)
public void takeOver(Simulation simulation, String groupNumber, Boolean takeOver) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
train.setTakeOver(takeOver);
}
/**
* 接管列车
*/
@OperateHandlerMapping(type = Operation.Type.Driver_TakeOver)
public void takeOver(Simulation simulation, String groupNumber, Boolean takeOver) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
train.setTakeOver(takeOver);
}
/**
* ATS停车
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Stop)
public void stopTrain(Simulation simulation, SimulationMember simulationMember, String groupNumber, Boolean eb) {
simulationRobotService.stopTrain(simulation, simulationMember, groupNumber, eb);
}
/**
* ATS停车
*/
@OperateHandlerMapping(type = Operation.Type.Driver_Stop)
public void stopTrain(Simulation simulation, SimulationMember simulationMember,
String groupNumber, Boolean eb) {
simulationRobotService.stopTrain(simulation, simulationMember, groupNumber, eb);
}
/**
* ATS开关门
*/
@OperateHandlerMapping(type = Operation.Type.Open_Or_Close_Door)
public void openOrCloseDoor(Simulation simulation, String groupNumber) {
ATPService.openOrCloseDoor(simulation, groupNumber);
}
/**
* ATS开关门
*/
@OperateHandlerMapping(type = Operation.Type.Open_Or_Close_Door)
public void openOrCloseDoor(Simulation simulation, String groupNumber) {
ATPService.openOrCloseDoor(simulation, groupNumber);
}
/**
* 回库
*/
@OperateHandlerMapping(type = Operation.Type.Inbound)
public void inbound(Simulation simulation,String groupNumber) {
ATPService.inbound(simulation, groupNumber);
}
/**
* 回库
*/
@OperateHandlerMapping(type = Operation.Type.Inbound)
public void inbound(Simulation simulation, String groupNumber) {
ATPService.inbound(simulation, groupNumber);
}
/**
* ATS修改预选模式
*/
@OperateHandlerMapping(type = Operation.Type.Change_Preselection_Mode)
public void changePreselectionMode(Simulation simulation, String groupNumber
, VirtualRealityTrain.PreselectionMode preselectionMode) {
ATPService.changePreselectionMode(simulation, groupNumber, preselectionMode);
}
/**
* ATS修改预选模式
*/
@OperateHandlerMapping(type = Operation.Type.Change_Preselection_Mode)
public void changePreselectionMode(Simulation simulation, String groupNumber
, VirtualRealityTrain.PreselectionMode preselectionMode) {
ATPService.changePreselectionMode(simulation, groupNumber, preselectionMode);
}
/**
* ATS转NRM模式
*/
@OperateHandlerMapping(type = Operation.Type.Apply_NRM)
public void applyNRM(Simulation simulation, String groupNumber) {
ATPService.applyNRM(simulation, groupNumber);
}
/**
* ATS转NRM模式
*/
@OperateHandlerMapping(type = Operation.Type.Apply_NRM)
public void applyNRM(Simulation simulation, String groupNumber) {
ATPService.applyNRM(simulation, groupNumber);
}
/**
* ATS操作打开 ATO
*/
@OperateHandlerMapping(type = Operation.Type.Try_Open_Ato)
public void tryOpenAto(Simulation simulation, String groupNumber) {
ATPService.openAto(simulation, groupNumber);
}
/**
* ATS操作打开 ATO
*/
@OperateHandlerMapping(type = Operation.Type.Try_Open_Ato)
public void tryOpenAto(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository()
.getVRByCode(groupNumber, VirtualRealityTrain.class);
ATPService.openATO(train);
}
/**
* 校验用户可操作的前提条件
*/
private boolean validate(VirtualRealityTrain train) {
return train.isTakeOver();
}
/**
* 校验用户可操作的前提条件
*/
private boolean validate(VirtualRealityTrain train) {
return train.isTakeOver();
}
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.ATS.operation.handler;
import club.joylink.rtss.exception.BaseException;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler;
@ -13,8 +14,10 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
@Slf4j
@OperateHandler
@ -30,12 +33,40 @@ public class SignalOperateHandler {
* 排列进路
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Set_Route)
public void settingRoute(Simulation simulation, String routeCode) {
public void settingRoute(Simulation simulation, String routeCode) throws InterruptedException {
// Route.CheckFailMessage checkResult = this.ciApiService.routeSettingCheck(simulation, routeCode);
// if (checkResult != null)
// log.info(checkResult.debugStr());
Route.CheckFailMessage checkFailMessage = this.ciApiService.settingRoute(simulation, routeCode);
BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertNull(checkFailMessage, "进路排列失败,被联锁逻辑取消");
//等待进路办理完成
LocalDateTime timeoutTime = simulation.getSystemTime().plusSeconds(20);
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
while (true) {
if (route.getSettedAspect().equals(route.getStart().getAspect()) ||
(route.isGuideSetting() && route.getStart().isGuideAspect())) {
return true;
}
if (simulation.getSystemTime().isAfter(timeoutTime)) {
return false;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
});
try {
Boolean success = future.get();
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(success);
} catch (BaseException be) {
throw be;
} catch (Exception e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception();
}
}
/**

View File

@ -0,0 +1,25 @@
package club.joylink.rtss.simulation.cbtc.ATS.operation.handler;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@OperateHandler
@Slf4j
public class SpecialOperateHandler {
@Autowired
private ATPService atpService;
@OperateHandlerMapping(type = Operation.Type.Special_Change_Head)
public void changeHead(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (train.isStop()) {
this.atpService.turnDirectionImmediately(train);
}
}
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.ATS.operation.handler;
import club.joylink.rtss.exception.BaseException;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.ATP.ground.GroundAtpApiService;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
@ -14,354 +15,353 @@ import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@OperateHandler
@Slf4j
public class SwitchOperateHandler {
@Autowired
private CiApiService ciApiService;
@Autowired
private CiApiService ciApiService;
@Autowired
private AtsSectionService atsSectionService;
@Autowired
private AtsSectionService atsSectionService;
@Autowired
private GroundAtpApiService groundAtpApiService;
@Autowired
private GroundAtpApiService groundAtpApiService;
/**
* 道岔转动
*
* @param simulation
* @param switchCode
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Turn)
public void turn(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertTrue(!aSwitch.isLocked(),
String.format("联锁操作被取消,道岔%s被锁定", aSwitch.getName()));
this.ciApiService.turn(simulation, switchCode);
/**
* 道岔转动
*
* @param simulation
* @param switchCode
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Turn)
public void turn(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertTrue(!aSwitch.isLocked(),
String.format("联锁操作被取消,道岔%s被锁定", aSwitch.getName()));
SwitchIndication pos = this.ciApiService.turn(simulation, switchCode);
waitResult(simulation, aSwitch, pos);
}
/**
* 道岔定操
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Normal_Position)
public void turn2Normal(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
if (!aSwitch.canTurn()) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"道岔锁闭或占用,无法转动");
}
if (aSwitch.isPosN()) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"道岔已经在定位,无需转动");
}
this.ciApiService.turn2NormalPosition(simulation, switchCode);
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (Objects.nonNull(linkedSwitch)) {
this.ciApiService.turn2NormalPosition(simulation, linkedSwitch.getCode());
}
}
}
/**
* 道岔反操
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Reverse_Position)
public void turn2Reverse(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
if (!aSwitch.canTurn()) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"道岔锁闭或占用,无法转动");
}
if (aSwitch.isPosR()) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"道岔已经在反位,无需转动");
}
this.ciApiService.turn2ReversePosition(simulation, switchCode);
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (Objects.nonNull(linkedSwitch)) {
this.ciApiService.turn2ReversePosition(simulation, linkedSwitch.getCode());
}
}
}
/**
* 道岔单锁
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Single_Lock)
public void singleLockSwitch(Simulation simulation, String switchCode) {
ciApiService.singleLockSwitch(simulation, switchCode);
//联动
SimulationDataRepository repository = simulation.getRepository();
if (repository.getConfig().isSwitchSingleLockChain()) {
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (Objects.nonNull(linkedSwitch)) {
this.ciApiService.singleLockSwitch(simulation, linkedSwitch.getCode());
}
}
}
/**
* 道岔单解
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Single_Unlock)
public void singleUnlockSwitch(Simulation simulation, String switchCode) {
ciApiService.singleUnlockSwitch(simulation, switchCode);
SimulationDataRepository repository = simulation.getRepository();
if (repository.getConfig().isSwitchSingleLockChain()) {
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (Objects.nonNull(linkedSwitch)) {
this.ciApiService.singleUnlockSwitch(simulation, linkedSwitch.getCode());
}
}
}
/**
* 道岔初始化封锁
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Initialize_Block)
public void initializeBlock(Simulation simulation, String switchCode) {
ciApiService.initializeBlock(simulation, switchCode);
}
/**
* 道岔封锁l
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Block)
public void blockadeSwitch(Simulation simulation, String switchCode) {
ciApiService.blockadeSwitch(simulation, switchCode);
}
/**
* 道岔解锁l
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Unblock)
public void unblockSwitch(Simulation simulation, String switchCode) {
ciApiService.unblockSwitch(simulation, switchCode);
}
/**
* 道岔区段封锁l
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Section_Block)
public void blockadeSwitchSection(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
ciApiService.blockadeSwitchSection(simulation, aSwitch.getCode());
}
/**
* 道岔区段解封l
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Section_Unblock)
public void unblockSwitchSection(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
ciApiService.unblockSwitchSection(simulation, aSwitch.getCode());
}
/**
* 道岔跟踪切除
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Cut_Off)
public void cutoff(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
this.atsSectionService.cutoff(simulation, aSwitch.getA());
}
/**
* 道岔跟踪激活
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Active)
public void active(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
this.atsSectionService.active(simulation, aSwitch.getA());
}
/**
* 确认计轴有效c
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Confirm_Axis_Valid)
public void confirmAxisValid(Simulation simulation, String switchCode) {
//ZC 系统
log.debug("仿真[{}] : 道岔[{}]确认计轴有效", simulation.getId(), switchCode);
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
this.atsSectionService.confirmAxleValid(simulation, aSwitch.getA());
}
/**
* 设置临时限速/轨区设限
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Set_Limit_Speed)
public void setLimitSpeed(Simulation simulation, String switchCode, String speedLimitValue) {
int limitSpeed;
try {
limitSpeed = Integer.parseInt(speedLimitValue);
} catch (NumberFormatException e) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"速度值必须为数字!");
}
this.groundAtpApiService.setSwitchLimitSpeed(simulation, switchCode, limitSpeed);
}
/**
* 取消临时限速/轨区消限
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Cancel_Limit_Speed)
public void cancelLimitSpeed(Simulation simulation, String switchCode) {
this.groundAtpApiService.cancelSwitchLimitSpeed(simulation, switchCode);
}
/**
* 道岔计轴预复位
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Axle_Pre_Reset)
public void axlePreReset(Simulation simulation, String switchCode) {
ciApiService.switchAxlePreReset(simulation, switchCode);
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
ciApiService.axlePreReset(simulation, aSwitch.getA().getParent().getCode());
}
/**
* 区故解
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Fault_Unlock)
public void switchSectionFaultUnlock(Simulation simulation, String switchCode) {
log.debug("仿真[{}] : 道岔[{}]区故解", simulation.getId(), switchCode);
ciApiService.switchSectionFaultUnlock(simulation, switchCode);
}
/**
* 道岔钩锁
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Hook_Lock)
public void switchHookLock(Simulation simulation, String switchCode, Boolean normal) {
SimulationDataRepository repository = simulation.getRepository();
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
if (normal) {
aSwitch.getVirtualSwitch().setP(SwitchIndication.N);
} else {
aSwitch.getVirtualSwitch().setP(SwitchIndication.R);
}
/**
* 道岔定操
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Normal_Position)
public void turn2Normal(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
if (!aSwitch.canTurn()) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"道岔锁闭或占用,无法转动");
}
if (aSwitch.isPosN()) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"道岔已经在定位,无需转动");
}
this.ciApiService.turn2NormalPosition(simulation, switchCode);
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (Objects.nonNull(linkedSwitch)) {
this.ciApiService.turn2NormalPosition(simulation, linkedSwitch.getCode());
}
}
}
/**
* 道岔反操
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Reverse_Position)
public void turn2Reverse(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
if (!aSwitch.canTurn()) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"道岔锁闭或占用,无法转动");
}
if (aSwitch.isPosR()) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"道岔已经在反位,无需转动");
}
this.ciApiService.turn2ReversePosition(simulation, switchCode);
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (Objects.nonNull(linkedSwitch)) {
this.ciApiService.turn2ReversePosition(simulation, linkedSwitch.getCode());
}
}
}
// /**道岔定操(联动)*/
// @OperateHandlerMapping(type = Operation2.Type.Switch_Turn_NP_Chain)
// public void chainTurn2Normal(Simulation simulation, String switchCode) {
// this.turn2Normal(simulation, switchCode);
// SimulationDataRepository repository = simulation.getRepository();
// Switch aSwitch = repository.getByCode(switchCode, Switch.class);
// Switch linkedSwitch = aSwitch.queryLinkedSwitch();
// if (Objects.nonNull(linkedSwitch)) {
// this.ciApiService.turn2NormalPosition(simulation, linkedSwitch.getCode());
// }
// }
// /**道岔反操(联动)*/
// @OperateHandlerMapping(type = Operation2.Type.Switch_Turn_RP_Chain)
// public void chainTurn2Reverse(Simulation simulation, String switchCode) {
// this.turn2Reverse(simulation, switchCode);
// SimulationDataRepository repository = simulation.getRepository();
// Switch aSwitch = repository.getByCode(switchCode, Switch.class);
// Switch linkedSwitch = aSwitch.queryLinkedSwitch();
// if (Objects.nonNull(linkedSwitch)) {
// this.ciApiService.turn2ReversePosition(simulation, linkedSwitch.getCode());
// }
// }
/**
* 道岔单锁
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Single_Lock)
public void singleLockSwitch(Simulation simulation, String switchCode) {
ciApiService.singleLockSwitch(simulation, switchCode);
//联动
SimulationDataRepository repository = simulation.getRepository();
if (repository.getConfig().isSwitchSingleLockChain()) {
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (Objects.nonNull(linkedSwitch)) {
this.ciApiService.singleLockSwitch(simulation, linkedSwitch.getCode());
}
}
}
/**
* 道岔单解
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Single_Unlock)
public void singleUnlockSwitch(Simulation simulation, String switchCode) {
ciApiService.singleUnlockSwitch(simulation, switchCode);
SimulationDataRepository repository = simulation.getRepository();
if (repository.getConfig().isSwitchSingleLockChain()) {
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (Objects.nonNull(linkedSwitch)) {
this.ciApiService.singleUnlockSwitch(simulation, linkedSwitch.getCode());
}
}
}
// /**道岔单锁(联动)*/
// @OperateHandlerMapping(type =Operation2.Type.Switch_Single_Lock_Chain)
// public void chainSingleLockSwitch(Simulation simulation, String switchCode) {
// SimulationDataRepository repository = simulation.getRepository();
// Switch aSwitch = repository.getByCode(switchCode, Switch.class);
// Switch linkedSwitch = aSwitch.queryLinkedSwitch();
// ciApiService.singleLockSwitch(simulation, switchCode);
// if (Objects.nonNull(linkedSwitch)) {
// this.ciApiService.singleLockSwitch(simulation, linkedSwitch.getCode());
// }
// }
// /**道岔单解(联动)*/
// @OperateHandlerMapping(type =Operation2.Type.Switch_Single_Unlock_Chain)
// public void chainSingleUnlockSwitch(Simulation simulation, String switchCode) {
// SimulationDataRepository repository = simulation.getRepository();
// Switch aSwitch = repository.getByCode(switchCode, Switch.class);
// Switch linkedSwitch = aSwitch.queryLinkedSwitch();
// ciApiService.singleUnlockSwitch(simulation, switchCode);
// if (Objects.nonNull(linkedSwitch)) {
// this.ciApiService.singleUnlockSwitch(simulation, linkedSwitch.getCode());
// }
// }
/**
* 道岔初始化封锁
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Initialize_Block)
public void initializeBlock(Simulation simulation, String switchCode) {
ciApiService.initializeBlock(simulation, switchCode);
}
/**
* 道岔封锁l
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Block)
public void blockadeSwitch(Simulation simulation, String switchCode) {
ciApiService.blockadeSwitch(simulation, switchCode);
}
/**
* 道岔解锁l
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Unblock)
public void unblockSwitch(Simulation simulation, String switchCode) {
ciApiService.unblockSwitch(simulation, switchCode);
}
/**
* 道岔区段封锁l
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Section_Block)
public void blockadeSwitchSection(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
ciApiService.blockadeSwitchSection(simulation, aSwitch.getCode());
}
/**
* 道岔区段解封l
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Section_Unblock)
public void unblockSwitchSection(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
ciApiService.unblockSwitchSection(simulation, aSwitch.getCode());
}
/**
* 道岔跟踪切除
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Cut_Off)
public void cutoff(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
this.atsSectionService.cutoff(simulation, aSwitch.getA());
}
/**
* 道岔跟踪激活
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Active)
public void active(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
this.atsSectionService.active(simulation, aSwitch.getA());
}
/**
* 确认计轴有效c
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Confirm_Axis_Valid)
public void confirmAxisValid(Simulation simulation, String switchCode) {
//ZC 系统
log.debug("仿真[{}] : 道岔[{}]确认计轴有效", simulation.getId(), switchCode);
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
this.atsSectionService.confirmAxleValid(simulation, aSwitch.getA());
}
/**
* 设置临时限速/轨区设限
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Set_Limit_Speed)
public void setLimitSpeed(Simulation simulation, String switchCode, String speedLimitValue) {
int limitSpeed;
try {
limitSpeed = Integer.parseInt(speedLimitValue);
} catch (NumberFormatException e) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "速度值必须为数字!");
}
this.groundAtpApiService.setSwitchLimitSpeed(simulation, switchCode, limitSpeed);
}
/**
* 取消临时限速/轨区消限
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Cancel_Limit_Speed)
public void cancelLimitSpeed(Simulation simulation, String switchCode) {
this.groundAtpApiService.cancelSwitchLimitSpeed(simulation, switchCode);
}
/**
* 道岔计轴预复位
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Axle_Pre_Reset)
public void axlePreReset(Simulation simulation, String switchCode) {
ciApiService.switchAxlePreReset(simulation, switchCode);
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
ciApiService.axlePreReset(simulation, aSwitch.getA().getParent().getCode());
}
/**
* 区故解
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Fault_Unlock)
public void switchSectionFaultUnlock(Simulation simulation, String switchCode) {
log.debug("仿真[{}] : 道岔[{}]区故解", simulation.getId(), switchCode);
ciApiService.switchSectionFaultUnlock(simulation, switchCode);
}
/**
* 道岔钩锁
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Hook_Lock)
public void switchHookLock(Simulation simulation, String switchCode, Boolean normal) {
SimulationDataRepository repository = simulation.getRepository();
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (linkedSwitch != null) {
if (normal) {
aSwitch.getVirtualSwitch().setP(SwitchIndication.N);
linkedSwitch.getVirtualSwitch().setP(SwitchIndication.N);
} else {
aSwitch.getVirtualSwitch().setP(SwitchIndication.R);
linkedSwitch.getVirtualSwitch().setP(SwitchIndication.R);
}
}
}
}
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (linkedSwitch != null) {
if (normal) {
linkedSwitch.getVirtualSwitch().setP(SwitchIndication.N);
} else {
linkedSwitch.getVirtualSwitch().setP(SwitchIndication.R);
}
}
/**
* 强行转岔
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Force_Turn)
public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) {
SwitchIndication pos = ciApiService.switchForceTurn(simulation, switchCode);
waitResult(simulation, simulation.getRepository().getByCode(switchCode, Switch.class), pos);
}
/**
* 挤岔恢复
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Squeeze_Recovery)
public void switchSqueezeRecovery(Simulation simulation, String switchCode) {
ciApiService.switchSqueezeRecovery(simulation, switchCode);
waitResult(simulation, simulation.getRepository().getByCode(switchCode, Switch.class),
SwitchIndication.N, SwitchIndication.R);
}
/**
* 命令泰雷兹
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Command)
public void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve,
Boolean normal) {
ciApiService.switchCommand(simulation, switchCode, auto, reserve, normal);
}
/**
* 道岔分路不良
*
* @param simulation 仿真实体
* @param switchCode 道岔编码
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Defective_Shunting)
public void defectiveShunting(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
List<Section.ShuntingType> shuntingTypeList = Arrays.asList(
Section.ShuntingType.SWITCH_FRONT_SHUNTING,
Section.ShuntingType.FIXED_POSITION_SHUNTING,
Section.ShuntingType.REVERSE_POSITION_SHUNTING);
atsSectionService.defectiveShunting(simulation, aSwitch.getA().getCode(), shuntingTypeList);
}
/**
* 取消道岔分路不良
*
* @param simulation 仿真实体
* @param switchCode 道岔编码
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Cancel_Defective_Shunting)
public void cancelDefectiveShunting(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
atsSectionService.defectiveShunting(simulation, aSwitch.getA().getCode(), new ArrayList<>());
}
/**
* 道岔只要处于{posArr}中任意一个位置就认为操作完成
*/
private static void waitResult(Simulation simulation, Switch aSwitch,
SwitchIndication... posArr) {
//等待转动完成
LocalDateTime timeoutTime = simulation.getSystemTime().plusSeconds(13);
CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
while (true) {
for (SwitchIndication pos : posArr) {
if (Objects.equals(aSwitch.getPos(), pos)) {
return true;
}
if (simulation.getSystemTime().isAfter(timeoutTime)) {
return false;
}
}
try {
Thread.sleep(100);
} catch (Exception e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception();
}
}
});
try {
Boolean success = future.get();
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(success, "道岔转动失败");
} catch (BaseException be) {
throw be;
} catch (Exception e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e);
}
}
/**
* 强行转岔
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Force_Turn)
public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) {
ciApiService.switchForceTurn(simulation, switchCode);
}
/**
* 挤岔恢复
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Squeeze_Recovery)
public void switchSqueezeRecovery(Simulation simulation, String switchCode) {
ciApiService.switchSqueezeRecovery(simulation, switchCode);
}
/**
* 命令泰雷兹
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Command)
public void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve, Boolean normal) {
ciApiService.switchCommand(simulation, switchCode, auto, reserve, normal);
}
/**
* 道岔分路不良
*
* @param simulation 仿真实体
* @param switchCode 道岔编码
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Defective_Shunting)
public void defectiveShunting(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
List<Section.ShuntingType> shuntingTypeList = Arrays.asList(Section.ShuntingType.SWITCH_FRONT_SHUNTING,
Section.ShuntingType.FIXED_POSITION_SHUNTING, Section.ShuntingType.REVERSE_POSITION_SHUNTING);
atsSectionService.defectiveShunting(simulation, aSwitch.getA().getCode(), shuntingTypeList);
}
/**
* 取消道岔分路不良
*
* @param simulation 仿真实体
* @param switchCode 道岔编码
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Cancel_Defective_Shunting)
public void cancelDefectiveShunting(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
atsSectionService.defectiveShunting(simulation, aSwitch.getA().getCode(), new ArrayList<>());
}
}

View File

@ -17,8 +17,6 @@ import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.support.TrainLoadParam2;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
import club.joylink.rtss.simulation.cbtc.data.vo.VirtualRealityTrainVO;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
@ -264,8 +262,9 @@ public class TrainOperateHandler {
* 加载备用车
*/
@OperateHandlerMapping(type = Operation.Type.Train_Load_Spare_Train)
public void loadSpareTrain(Simulation simulation, String groupNumber, String sectionCode, boolean right) {
atsTrainLoadService.loadSpareTrain(simulation, groupNumber, sectionCode, right);
public void loadSpareTrain(Simulation simulation, String groupNumber, String sectionCode, boolean right,
VirtualRealityTrain.PreselectionMode preselectionMode) {
atsTrainLoadService.loadSpareTrain(simulation, groupNumber, sectionCode, right, preselectionMode);
}
/**

View File

@ -203,14 +203,11 @@ public class AtsRouteService {
throw new SimulationException(SimulationExceptionType.Operation_Conflict,
String.format("进路[%s(%s)]自动通过已开启,不能设置自动追踪", route.getName(), route.getCode()));
}
// if (route.isCiControl()) {
// throw new SimulationException(SimulationExceptionType.Operation_Repetition, String.format("进路[%s(%s)]自动追踪/连锁自动触发已开启,无需重复设置", route.getName(), route.getCode()));
// }
});
for (Route route : routeList) {
// route.setAtsControl(false);
if (route.isArs())
if (route.isArs()) {
route.setCiControl(true);
}
}
}
}

View File

@ -7,6 +7,7 @@ import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CI.CiLogic;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.SimulationLifeCycleService;
import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
@ -832,7 +833,8 @@ public class AtsTrainLoadService {
/**
* 在区段上加载指定车组号的列车
*/
public void loadSpareTrain(Simulation simulation, String groupNumber, String sectionCode, boolean right) {
public void loadSpareTrain(Simulation simulation, String groupNumber, String sectionCode, boolean right,
VirtualRealityTrain.PreselectionMode preselectionMode) {
SimulationDataRepository repository = simulation.getRepository();
if (!simulation.getRepository().getConfig().isHandleDepot() && repository.isVrTrainOnline(groupNumber)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
@ -841,7 +843,7 @@ public class AtsTrainLoadService {
// 判断列车是否在派班计划中且后面要上线运行
}
VirtualRealityTrain virtualRealityTrain = repository.getVRByCode(groupNumber, VirtualRealityTrain.class);
trainOnline(simulation, sectionCode, right, repository, virtualRealityTrain);
trainOnline(simulation, sectionCode, right, repository, virtualRealityTrain, preselectionMode);
}
/**
@ -863,7 +865,7 @@ public class AtsTrainLoadService {
VirtualRealityTrain virtualRealityTrain = virtualRealityTrainOptional.get();
// 设置列车车次
virtualRealityTrain.setTripNumber(tripNumber);
trainOnline(simulation, sectionCode, right, repository, virtualRealityTrain);
trainOnline(simulation, sectionCode, right, repository, virtualRealityTrain, null);
}
/**
@ -934,14 +936,15 @@ public class AtsTrainLoadService {
/**
* 列车上线并构建ATS监控列车信息
*
* @param simulation 仿真实体
* @param sectionCode 区段编码
* @param right 运行方向
* @param repository 数据实体
* @param train 列车
* @param simulation 仿真实体
* @param sectionCode 区段编码
* @param right 运行方向
* @param repository 数据实体
* @param train 列车
* @param preselectionMode
*/
private void trainOnline(Simulation simulation, String sectionCode, boolean right, SimulationDataRepository repository
, VirtualRealityTrain train) {
, VirtualRealityTrain train, VirtualRealityTrain.PreselectionMode preselectionMode) {
Section section = repository.getByCode(sectionCode, Section.class);
if (!section.isPhysical()) {
section = section.getParent();
@ -953,13 +956,15 @@ public class AtsTrainLoadService {
boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
// 列车上线并构建ATS监控列车信息
manualTrainOnlineAndSupervise(simulation, train, headPosition, right);
manualTrainOnlineAndSupervise(simulation, train, headPosition, right, preselectionMode);
}
/**
* 人工车上线并监控
*/
private void manualTrainOnlineAndSupervise(Simulation simulation, VirtualRealityTrain train, SectionPosition headPosition, boolean right) {
private void manualTrainOnlineAndSupervise(Simulation simulation, VirtualRealityTrain train,
SectionPosition headPosition, boolean right,
VirtualRealityTrain.PreselectionMode preselectionMode) {
train.initManualTrain(headPosition, right);
SimulationDataRepository repository = simulation.getRepository();
//设置列车预选模式驾驶模式运行级别
@ -974,6 +979,15 @@ public class AtsTrainLoadService {
}
}
if (!repository.getConfig().isHandleDepot()) {
if (preselectionMode != null && !preselectionMode.isHigherThan(train.getPreselectionMode())) {
train.initByPreselectionMode(preselectionMode);
//列车初始为ITC级别如果当时的移动授权不允许移动则会无法移动所以将实际级别降为RM
if (preselectionMode.isMatchTheRunLevel(RunLevel.ITC)) {
train.setDriveMode(DriveMode.RM);
train.setRunLevel(RunLevel.IL);
train.setGear(VirtualRealityTrain.Handwheel.MANUAL);
}
}
TrainInfo trainInfo = TrainInfo.constructManualTrain(train);
trainInfo.tracking(train);
repository.addOnlineTrain(train);

View File

@ -483,14 +483,7 @@ public class AtsTrainService {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(targetPosition, train.debugStr() + "找不到下一个停车点");
param.setThroughSignal(section.getSignalOf(right));
}
} else if (param.isRouteBlockDriver()) { // 进路闭塞行车
Signal signal = section.getSignalOf(right);
Route route = (signal != null) ? signal.getLockedRoute() : section.getRoute();
if (route != null) {
targetPosition = new SectionPosition(route.getLastRouteSection(), route.getLastRouteSection().getStopPointByDirection(train.isRight()));
param.setThroughSignal(signal);
}
}else {
} else {
param.setThroughSignal(null);
param.setThroughSignalAspect(null);
}
@ -506,10 +499,10 @@ public class AtsTrainService {
float len = linkTrain.getLen() + (distance == null ? 0 : distance);
targetPosition = new SectionPosition(targetSection, offset + (len * (right ? -1 : 1)));
}
linkTrain.setRobotDriveParam(linkParamVO);
linkTrain.updateDriveParam(linkParamVO);
}
param.setTargetPosition(targetPosition);
train.setRobotDriveParam(param);
train.updateDriveParam(param);
}

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.CI;
import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication;
import club.joylink.rtss.simulation.cbtc.data.map.ESP;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
@ -65,8 +66,9 @@ public interface CiApiService {
*
* @param simulation
* @param switchCode
* @return
*/
void turn(Simulation simulation, String switchCode);
SwitchIndication turn(Simulation simulation, String switchCode);
/**
* 转动道岔到定位
@ -190,14 +192,6 @@ public interface CiApiService {
*/
void switchSectionFaultUnlock(Simulation simulation, String switchCode);
/**
* 设置自动通过进路
*
* @param simulation
* @param routeCode
*/
void setFleetRoute(Simulation simulation, String routeCode);
/**
* 取消自动通过进路
*
@ -206,22 +200,6 @@ public interface CiApiService {
*/
void cancelFleetRoute(Simulation simulation, String routeCode);
/**
* 设置进路CI自动触发
*
* @param simulation
* @param routeCode
*/
void setCIAutoTriggerRoute(Simulation simulation, String routeCode);
/**
* 取消进路CI自动触发
*
* @param simulation
* @param routeCode
*/
void cancelCIAutoTriggerRoute(Simulation simulation, String routeCode);
/**
* 根据始端信号机查询锁闭进路
*
@ -231,24 +209,6 @@ public interface CiApiService {
*/
Route findLockedRouteByStartSignal(Simulation simulation, String signalCode);
/**
* 根据始端终端信号机查询进路(根据延续保护自动筛选出一条进路)
*
* @param simulation
* @param startSignalCode
* @param endSignalCode
* @return
*/
Route findRouteByStartAndEndSignal(Simulation simulation, String startSignalCode, String endSignalCode);
/**
* 办理引导进路
*
* @param simulation
* @param routeCode
*/
void settingGuideRoute(Simulation simulation, String routeCode);
/**
* 开站台屏蔽门
*
@ -338,8 +298,10 @@ public interface CiApiService {
/**
* 强扳道岔
*
* @return
*/
void switchForceTurn(Simulation simulation, String switchCode);
SwitchIndication switchForceTurn(Simulation simulation, String switchCode);
/**
* 计轴预复位

View File

@ -15,7 +15,6 @@ import club.joylink.rtss.simulation.cbtc.data.map.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Objects;
@ -41,10 +40,11 @@ public class CiLogic {
@Autowired
private AtsStationService atsStationService;
public void runForTrainPosition(Simulation simulation){
public void runForTrainPosition(Simulation simulation) {
// 采集真实设备状态
deviceStatusCollector.collect(simulation);
}
public void run(Simulation simulation) {
// 采集真实设备状态
deviceStatusCollector.collect(simulation);
@ -190,14 +190,15 @@ public class CiLogic {
routeService.routeSettingProcess(simulation, route);
}
if (route.isNormalUnlock()) {
ciService.interlockCheck(simulation, route); //南铁院叶老师提出列车越过始端信号机后灯座应该是红色
routeService.trainUnlockRoute(simulation, route);
}
if (route.isLock()) {
// 进路首区段列车占用进路开始解锁
Section firstLogicSection = route.getFirstLogicSection();
if(route.getStart().isGuideAspect() && firstLogicSection.getAxleCounterSection().isFaultOccupied()) {
if (route.getStart().isGuideAspect() && firstLogicSection.getAxleCounterSection().isFaultOccupied()) {
log.debug(String.format("进路【%s(%s)】引导占用中,列车通过后请人工解锁", route.getName(), route.getCode()));
} else{
} else {
SimulationDataRepository repository = simulation.getRepository();
if (repository.isTrainHeadOccupy(firstLogicSection)) {
trainUnlockStart(simulation, route);
@ -243,7 +244,11 @@ public class CiLogic {
}
}
// 进路延续保护办理判断
if (route.isSettingOverlap()) {
if (config.isOverlapSettingByTrigger()) {
if (route.getOverlap() != null && route.getOverlap().getSignal().isApproachSectionOccupied()) {
ciService.checkAndTrySettingOverlap(simulation, route.getOverlap());
}
} else if (route.isSettingOverlap()) {
ciService.checkAndTrySettingOverlap(simulation, route.getOverlap());
}
}
@ -298,7 +303,7 @@ public class CiLogic {
simulation.addJob(JobName.SECTION_STOP_COUNTDOWN, () -> sectionStopCountDown(simulation), SimulationConstants.CI_LOOP_RATE);
}
public void addJobsForTrainPosition(Simulation simulation){
public void addJobsForTrainPosition(Simulation simulation) {
simulation.addJob(SimulationModule.CI.name(), () -> runForTrainPosition(simulation), SimulationConstants.CI_LOOP_RATE);
// simulation.addJob(JobName.SECTION_STOP_COUNTDOWN, () -> sectionStopCountDown(simulation), SimulationConstants.CI_LOOP_RATE);
}

View File

@ -70,7 +70,7 @@ public class CiService {
* @return
*/
public boolean interlockCheck(Simulation simulation, RouteOverlap overlap) {
if (overlap != null) {
if (!simulation.getRepository().getConfig().isOverlapSettingByTrigger() && overlap != null) {
SectionPath sectionPath = overlap.selectPath();
List<Section> logicList = sectionPath.getLogicList();
if (!CollectionUtils.isEmpty(logicList)) {
@ -147,6 +147,9 @@ public class CiService {
return level;
}
// 进路区段检查
if (simulation.getRepository().getConfig().isRouteCanSetWhenSwitchFault()) {
level = Signal.LEVEL_Guide;
}
boolean right = route.isRight();
List<Section> sectionList = route.getSectionList();
for (Section section : sectionList) {
@ -325,7 +328,8 @@ public class CiService {
}
}
// 延续保护
if (!this.interlockCheck(simulation, route.getOverlap())) {
if (!simulation.getRepository().getConfig().isOverlapSettingByTrigger()
&& !this.interlockCheck(simulation, route.getOverlap())) {
// log.debug("进路[{}]连锁条件检查: 延续保护未锁闭", route.debugStr());
return level;
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation.cbtc.CI.device;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication;
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
import club.joylink.rtss.simulation.cbtc.data.map.SwitchElement;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
@ -74,19 +75,19 @@ public class CiSwitchControlService {
* @param aSwitch
* @return
*/
public boolean forceTurn(Simulation simulation, Switch aSwitch) {
public SwitchIndication forceTurn(Simulation simulation, Switch aSwitch) {
if (!aSwitch.isSectionOccupied()) {
return false;
return null;
}
if (aSwitch.isLocked()) {
return false;
return null;
}
// 设置强扳授权
aSwitch.setForceTurnRemain(120 * 1000);
this.turn(simulation, aSwitch);
SwitchIndication pos = this.turn(simulation, aSwitch);
// 手动释放强扳
aSwitch.setForceTurnRemain(0);
return true;
return pos;
}
/**
@ -96,29 +97,29 @@ public class CiSwitchControlService {
* @param aSwitch
* @return
*/
public boolean turn(Simulation simulation, Switch aSwitch) {
public SwitchIndication turn(Simulation simulation, Switch aSwitch) {
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
boolean isRP;
if (vrSwitch.getCommand() != null) {
isRP = vrSwitch.getCommand().equals(VirtualRealitySwitch.Operation.RP);
} else {
isRP = vrSwitch.isPosR();
}
boolean lastTurnToN = vrSwitch.isLastTurnToN();
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (Objects.nonNull(linkedSwitch)) {
if (isRP) {
this.turn2NormalPosition(simulation, linkedSwitch);
} else {
if (lastTurnToN) {
this.turn2ReversePosition(simulation, linkedSwitch);
} else {
this.turn2NormalPosition(simulation, linkedSwitch);
}
}
}
if (isRP) {
return this.turn2NormalPosition(simulation, aSwitch);
if (lastTurnToN) {
if (this.turn2ReversePosition(simulation, aSwitch)) {
return SwitchIndication.R;
}
} else {
return this.turn2ReversePosition(simulation, aSwitch);
if (this.turn2NormalPosition(simulation, aSwitch)) {
return SwitchIndication.N;
}
}
return null;
}
/**

View File

@ -503,6 +503,7 @@ public class InterlockBuilder2 {
route.setFlt(mapRouteVO.isFlt());
route.setArs(mapRouteVO.isArc());
route.setAspect(mapRouteVO.getAspect());
route.setSingleTrain(mapRouteVO.isSingleTrain());
if (route.getAspect() == null) {
errMsgList.add(String.format("进路%s没有配置信号显示", route.debugStr()));
}

View File

@ -254,10 +254,13 @@ public class MapDeviceBuilder {
private static void buildTrain(RealLineConfigVO realLineConfig, MapGraphDataNewVO graphData, Map<String, MapElement> elementMap, Map<String, VirtualRealityDevice> deviceMap, List<String> errMsgList) {
boolean railway;
boolean manualTrainDefaultStop;
if (realLineConfig != null) {
railway = realLineConfig.isRailway();
manualTrainDefaultStop = realLineConfig.isManualTrainDefaultStop();
} else {
railway = true;
manualTrainDefaultStop = false;
}
List<MapTrainVO> trainList = graphData.getTrainList();
if (CollectionUtils.isEmpty(trainList)) {
@ -266,7 +269,8 @@ public class MapDeviceBuilder {
Map<String, MapTrainModelVO> trainModelMap = graphData.getTrainModelList().stream()
.collect(Collectors.toMap(MapTrainModelVO::getCode, Function.identity()));
trainList.forEach(trainVO -> {
VirtualRealityTrain virtualRealityTrain = new VirtualRealityTrain(trainVO.getGroupNumber(), trainVO.getGroupNumber(), railway);
VirtualRealityTrain virtualRealityTrain = new VirtualRealityTrain(trainVO.getGroupNumber(),
trainVO.getGroupNumber(), railway, manualTrainDefaultStop);
if (Objects.nonNull(deviceMap.get(virtualRealityTrain.getGroupNumber()))) {
errMsgList.add(String.format("车组号为[%s]的列车不唯一",
virtualRealityTrain.getName(), virtualRealityTrain.getGroupNumber()));

View File

@ -7,24 +7,27 @@ public enum DriveMode {
/**
* 列车自动驾驶模式司机监控下的列车自动驾驶
*/
AM("列车自动驾驶模式"),
AM("列车自动驾驶模式", false),
/**
* ATP防护下的人工驾驶模式司机在列车自动防护设备监控下驾驶列车
*/
CM("ATP防护下的人工驾驶模式"),
CM("ATP防护下的人工驾驶模式", true),
/**
* 限制人工驾驶模式地面设备故障或未设置地面信息设备的线路列车按规定限速运行超速时实时制动直至停车
*/
RM("限制人工驾驶模式"),
RM("限制人工驾驶模式", true),
/**
* 无限制人工驾驶模式列车在运行中没有车载ATP的保护司机根据行车调度员的指示按地面信号机的显示或手信号口令指示行车
*/
NRM("无限制人工驾驶模式");
NRM("无限制人工驾驶模式", true);
private final String label;
//是否人工驾驶模式
private final boolean manual;
DriveMode(String label) {
DriveMode(String label, boolean manual) {
this.label = label;
this.manual = manual;
}
public boolean isNotLowerThan(DriveMode driveMode) {

View File

@ -250,6 +250,16 @@ public class MapConfig {
private boolean hasTDCS;
/**
* 道岔失表/挤岔时可以办理进路由远及近锁闭到失表/挤岔处终止并且可以开放引导信号
*/
private boolean routeCanSetWhenSwitchFault;
/**
* 人工驾驶模式CM/RM/NRM下的列车默认是停车等待命令状态
*/
private boolean manualTrainDefaultStop;
private Set<SimulationMember.Type> needConfirmConnectMembers =
Stream.of(DISPATCHER, STATION_SUPERVISOR, MAINTAINER, ELECTRIC_DISPATCHER).collect(Collectors.toSet());
@ -307,6 +317,8 @@ public class MapConfig {
setRailway(configVO.isRailway());
setSignalBolckOptReflectSignal(configVO.isSignalBolckOptReflectSignal());
setSFUCanOnlyApplyForFaultLockSection(configVO.isSFUCanOnlyApplyForFaultLockSection());
setRouteCanSetWhenSwitchFault(configVO.isRouteCanSetWhenSwitchFault());
setManualTrainDefaultStop(configVO.isManualTrainDefaultStop());
}
}

View File

@ -267,4 +267,18 @@ public class RouteOverlap extends MapNamedElement {
public boolean containSwitch(Switch aSwitch) {
return this.selectPath().containSwitch(aSwitch);
}
public boolean isStraight() {
if (CollectionUtils.isEmpty(pathList)) {
return true;
}
for (SectionPath path : pathList) {
for (SwitchElement se : path.getSwitchList()) {
if (!se.isNormal()) {
return false;
}
}
}
return true;
}
}

View File

@ -416,17 +416,18 @@ public class Signal extends DelayUnlockDevice {
}
public void updateApproachLock() {
if (CollectionUtils.isEmpty(approachPathList))
return;
for (SectionPath sectionPath : approachPathList) {
for (Section section : sectionPath.getSectionList()) {
if (section.isOccupied()) {
this.approachLock = true;
return;
}
}
}
this.approachLock = false;
this.approachLock = isApproachSectionOccupied();
// if (CollectionUtils.isEmpty(approachPathList))
// return;
// for (SectionPath sectionPath : approachPathList) {
// for (Section section : sectionPath.getSectionList()) {
// if (section.isOccupied()) {
// this.approachLock = true;
// return;
// }
// }
// }
// this.approachLock = false;
}
public boolean containsApproachAtpSection(List<Section> atpSectionList) {
@ -718,6 +719,20 @@ public class Signal extends DelayUnlockDevice {
return isGuideLevel() || isAtpLevel() || isMainLevel();
}
public boolean isApproachSectionOccupied() {
if (CollectionUtils.isEmpty(this.approachPathList)) {
return false;
}
for (SectionPath sectionPath : this.approachPathList) {
for (Section section : sectionPath.getSectionList()) {
if (section.isOccupied()) {
return true;
}
}
}
return false;
}
/**
* 信号机类型
*/

View File

@ -166,7 +166,6 @@ public class Switch extends DelayUnlockDevice {
this.interlockReserve = false;
this.blockadeInvalid = false;
this.init = false;
this.lastTurnToNormal = null;
this.forceTurnRemain = 0;
}
@ -679,7 +678,11 @@ public class Switch extends DelayUnlockDevice {
Switch aSwitch = (Switch) device;
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
VirtualRealitySwitch.Fault.SQUEEZE.fix(vrSwitch);
vrSwitch.control(VirtualRealitySwitch.Operation.NP);
if (vrSwitch.isLastTurnToN()) {
vrSwitch.control(VirtualRealitySwitch.Operation.RP);
} else {
vrSwitch.control(VirtualRealitySwitch.Operation.NP);
}
}
},

View File

@ -201,6 +201,7 @@ public class SwitchStatus extends DeviceStatus {
}
if (!Objects.equals(this.fault, aSwitch.getFault())) {
this.fault = (Switch.SwitchFault) aSwitch.getFault();
status.setFault(this.fault == null ? null : this.fault.name());
change = true;
}
status.setFault(this.fault != null ? this.fault.name() : null);

View File

@ -19,6 +19,17 @@ public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwi
private Fault fault;
private Operation lastOperation;
@Override
public boolean control(Operation command) {
boolean control = super.control(command);
if (control && command != null) {
this.lastOperation = command;
}
return control;
}
@Override
protected boolean checkConditionBeforeControl(Operation command) {
switch (command) {
@ -83,6 +94,7 @@ public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwi
super.reset();
this.p = SwitchIndication.N;
this.fault = null;
this.lastOperation = Operation.NP;
}
public void apply(boolean normalPosition, boolean reversePosition) {
@ -99,6 +111,11 @@ public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwi
}
}
//最后一次是否是转向定位
public boolean isLastTurnToN() {
return this.lastOperation == Operation.NP;
}
public enum Fault {
SPLIT {
@Override

View File

@ -26,13 +26,14 @@ import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService;
import club.joylink.rtss.vo.client.project.thailand.ThailandSectionConfigVO;
import io.netty.buffer.ByteBuf;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
@Slf4j
@Service
public class NgyTrainServiceImpl implements UDPRealDeviceService {
@ -231,7 +232,7 @@ public class NgyTrainServiceImpl implements UDPRealDeviceService {
if (section.isSwitchAxleCounterSection()) {
section = section.getLogicList().get(0).getRelSwitch().getA();
}
atsTrainLoadService.loadSpareTrain(simulation, groupNumber, section.getCode(), false);
atsTrainLoadService.loadSpareTrain(simulation, groupNumber, section.getCode(), false, null);
}
}

View File

@ -97,7 +97,7 @@ public class SrTrainServiceImpl implements UDPRealDeviceService {
if (section.isSwitchAxleCounterSection()) {
section = section.getLogicList().get(0).getRelSwitch().getA();
}
atsTrainLoadService.loadSpareTrain(simulation, groupNumber, section.getCode(), false);
atsTrainLoadService.loadSpareTrain(simulation, groupNumber, section.getCode(), false, null);
}
}

View File

@ -25,13 +25,14 @@ import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService;
import club.joylink.rtss.vo.client.project.thailand.ThailandSectionConfigVO;
import io.netty.buffer.ByteBuf;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
@Slf4j
@Service
public class ThailandTrainServiceImpl implements UDPRealDeviceService {
@ -200,7 +201,7 @@ public class ThailandTrainServiceImpl implements UDPRealDeviceService {
if (section.isSwitchAxleCounterSection()) {
section = section.getLogicList().get(0).getRelSwitch().getA();
}
atsTrainLoadService.loadSpareTrain(simulation, groupNumber, section.getCode(), false);
atsTrainLoadService.loadSpareTrain(simulation, groupNumber, section.getCode(), false, null);
}
}

View File

@ -3,11 +3,9 @@ package club.joylink.rtss.simulation.cbtc.onboard.ATP;
import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.map.MapConfig;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
@ -41,7 +39,6 @@ public class ATPLogicLoop {
private ApplicationContext applicationContext;
public void run(Simulation simulation) {
// long start = System.currentTimeMillis();
// ATP防护逻辑
List<VirtualRealityTrain> onlineTrain = simulation.getRepository().getOnlineTrainList();
for (VirtualRealityTrain train : onlineTrain) {
@ -59,33 +56,11 @@ public class ATPLogicLoop {
this.driveLogicRun(simulation, train);
}
}
// long end = System.currentTimeMillis();
// System.out.println(String.format("------------ATP防护、检查、消息构建发送逻辑耗时: %s ms", (end-start)));
}
private void driveLogicRun(Simulation simulation, VirtualRealityTrain train) {
// MaService.Ma ma2 = train.getMa2();
// // ITC级别列车停车手动释放操作判断
// if (train.isStop() && train.isITC() && train.isAtoOn() && ma2 != null && !train.isReleased()) {
// Section section = train.getHeadPosition().getSection();
// if (train.isParkingAt()) {
// if (!train.isStandReadyStart() || section.equals(train.getTarget())) {
// return;
// }
// }
// // 对于ITC列车若列车在站台且出站信号机开放且ITC移动授权终点为出站信号机手动进行释放操作
// boolean right = train.isRight();
// Signal signal = section.getSignalOf(right);
// if (signal != null && signal.isMainAspect() &&
// (ma2.getDevice().equals(signal) || (ma2.calculateDistanceToEoa() <= 0))) {
// // 信号机开放前一个ITC-MA的终点就是此信号机 到终点的移动授权距离小于0应该是折返轨情况
// // 手动释放
// log.debug(String.format("ITC列车[%s]站台准备出发,手动释放速度", train.getGroupNumber()));
//// atpService.confirmMessage(train, VirtualRealityTrain.ConfirmationMessage.Confirm_Release_Speed);
// }
// }
if (train.isChangeEnds() && train.isStop()) {
// 列车换端中
this.atpService.changeEndsProgress(train);
@ -112,9 +87,6 @@ public class ATPLogicLoop {
}
this.updateRunningTime(train);
if (train.isStop()) { // 列车停车
// this.sendStopMessage2GroundAtp(simulation, train);
// // 检查列车是否在转换轨
// this.checkOnTransferAndSend2Ats(simulation, train, headPosition, tailPosition);
if (!train.isBreaking() && !train.isRMMode() && !train.isNRMMode()) { // 制动状态
// 施加常规制动防止倒溜
this.atoService.openBreaking(train);

View File

@ -1,5 +1,7 @@
package club.joylink.rtss.simulation.cbtc.robot;
import static club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.ConfirmationMessage.Confirm_Release_Speed;
import club.joylink.rtss.services.psl.IVirtualRealityPslService;
import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService;
import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher;
@ -10,32 +12,46 @@ import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.command.CommandBO;
import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.map.PSD;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
import club.joylink.rtss.simulation.cbtc.data.vr.*;
import club.joylink.rtss.simulation.cbtc.data.vr.StandParkedTrainActivity;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve;
import club.joylink.rtss.simulation.cbtc.onboard.ATO.service.ATOService;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import club.joylink.rtss.simulation.cbtc.training2.Training2;
import club.joylink.rtss.vo.client.operation.DriveParamVO;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
import static club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.ConfirmationMessage.Confirm_Release_Speed;
/**
* 仿真机器人逻辑循环
*/
@ -94,9 +110,7 @@ public class SimulationRobotService {
}
break;
case START:
if (train.isAtoCanOpen()) {
atpService.openATO(train);
}
atpService.openATO(train);
break;
}
}
@ -158,42 +172,77 @@ public class SimulationRobotService {
List<SimulationMember> drivers = simulation.querySimulationMembersOfRole(
SimulationMember.Type.DRIVER);
for (SimulationMember driver : drivers) {
// if (!driver.isRobot())
// continue;
SimulationDataRepository repository = simulation.getRepository();
VirtualRealityTrain train = (VirtualRealityTrain) driver.getDevice();
if (train.isTakeOver() || !repository.isVrTrainOnline(train.getGroupNumber())) { //如果列车被接管或不在线
continue;
}
//判断是否需要转换手轮档位到ATO
robotOpenATOAfterCheck(train);
//准备发车
robotReadyForDeparture(simulation, train);
//机器人驾驶
if (train.isRobotNeedStop()) {
if (train.isStop()) {
train.getRobotDriveParam().setStop(false);
} else {
if (!train.isInTheGear(VirtualRealityTrain.Handwheel.MANUAL)) { //确保当前在手动档位
CommandBO.Step step = CommandBO.buildGearChangeStep(train.getGroupNumber(),
VirtualRealityTrain.Handwheel.MANUAL);
atsOperationDispatcher.execute(simulation, driver, step.getOperationType().name(),
step.getOperationParams());
}
doBreakMax(simulation, train);
}
} else if (train.isRobotNeedRun() && (train.isRMMode()
|| train.isNRMMode())) { //CM应当根据推荐速度驾驶待实现
//机器人人工驾驶
robotManualDrive(simulation, driver, train);
}
}
private void robotManualDrive(Simulation simulation, SimulationMember driver,
VirtualRealityTrain train) {
if (train.isRobotNeedStop()) {
if (train.isStop()) {
train.getRobotDriveParam().setStop(false);
} else {
ensureTrainInTheGear(train, VirtualRealityTrain.Handwheel.MANUAL);
doBreakMax(simulation, train);
}
} else if (train.isRobotNeedRun()) {
if ((train.isRMMode() || train.isNRMMode())) { //RM或NRM
ensureTrainInTheGear(train, VirtualRealityTrain.Handwheel.MANUAL);
VirtualRealityTrain linkTrain = train.getLinkTrain();
if (linkTrain == null) {
Optional<SectionPosition> targetPositionOptional = calculateTargetPosition(simulation,
train);
train);
targetPositionOptional.ifPresent(tp -> robotDrive(simulation, driver, train, tp));
} else {
robotDrive(simulation, driver, train, train.getRobotTargetPosition());
}
} else if (train.isCMMode()) { //CM
ensureTrainInTheGear(train, VirtualRealityTrain.Handwheel.MANUAL);
SpeedCurve speedCurve = train.getMa2().getAtoStopCurve();
atoService.doControlBySpeedCurve(train, speedCurve, speedCurve.getTotalDistance(),
train.getAtoSpeed());
}
}
}
/**
* 在检查通过后开启ATO
*/
private void robotOpenATOAfterCheck(VirtualRealityTrain train) {
//停站时的情况可能比较特殊保险起见停站时不做处理
if (train.isParkingAt()) {
return;
}
//列车的预选模式支持到达AM驾驶模式并且列车的ATO推荐速度大于0
if (train.getPreselectionMode().isNotLowerThanTheDriveMode(DriveMode.AM)
&& train.getAtoSpeed() > 0) {
ensureTrainInTheGear(train, VirtualRealityTrain.Handwheel.ATO);
atpService.openATO(train);
}
}
/**
* 确保列车在指定挡
*/
private void ensureTrainInTheGear(VirtualRealityTrain train, VirtualRealityTrain.Handwheel gear) {
if (!train.isInTheGear(gear)) {
train.setGear(gear);
// CommandBO.Step step = CommandBO.buildGearChangeStep(train.getGroupNumber(), gear);
// atsOperationDispatcher.execute(simulation, driver, step.getOperationType().name(),
// step.getOperationParams()); 机器人驾驶逻辑中有很多操作都不是通过仿真操作执行的所以这里也不需要了吧
}
}
/**
* 计算目标位置
*/
@ -241,10 +290,11 @@ public class SimulationRobotService {
SignalAspect throughAspect = robotDriveParam.getThroughSignalAspect();
Section section = headPosition.getSection();
if (throughSignal != null && !Objects.equals(section, throughSignal.getSection())) { //当车头与要越过的信号机不在同一区段
if (throughSignal != null && !Objects.equals(section,
throughSignal.getSection())) { //当车头与要越过的信号机不在同一区段
throughSignal = null;
throughAspect = null;
robotDriveParam.setThrough(DriveParamVO.NO);
robotDriveParam.setThrough(DriveParamVO.DRIVER_ROUTE_BLOCK);
}
SectionPosition selectedPosition = robotDriveParam.getTargetPosition(); //用户选择的位置
@ -253,14 +303,23 @@ public class SimulationRobotService {
// 车头在正常的站台上
if (section.isNormalStandTrack() && !section.equals(train.getParkSection())) { //正常站台轨且未在此处停过车
// 如果计划停车区段为空或者计划停车区段中有包含当前区段
if (CollectionUtils.isEmpty(plannedParkingSections) || plannedParkingSections.contains(section)) {
if (CollectionUtils.isEmpty(plannedParkingSections) || plannedParkingSections.contains(
section)) {
SectionPosition stopPosition = section.buildStopPointPosition(right);
if (targetPosition == null || stopPosition.isAheadOf(targetPosition, right)) {
// 如果头部位置偏移小于停车点位置偏移目标点为当前停车点
if (headPosition.getOffset() < (section.getStopPointByDirection(right) + SimulationConstants.PARK_POINT_MAX_OFFSET)) { //防止意外开过站后无法发车
targetPosition = stopPosition;
}
SectionPosition maxStopPosition = CalculateService.calculateNextPositionByStartAndLen(
stopPosition,
right, SimulationConstants.PARK_POINT_MAX_OFFSET, true);
if (maxStopPosition.isAheadOf(headPosition, right)) { //未越过最大停车点
targetPosition = stopPosition;
break;
}
// if (targetPosition == null || stopPosition.isAheadOf(targetPosition, right)) {
// CalculateService.calculateNextPositionByStartAndLen(stopPosition, right, SimulationConstants.PARK_POINT_MAX_OFFSET, true)
// // 如果头部位置偏移小于停车点位置偏移目标点为当前停车点
// if (headPosition.getOffset() < (section.getStopPointByDirection(right) + SimulationConstants.PARK_POINT_MAX_OFFSET)) { //防止意外开过站后无法发车
// targetPosition = stopPosition;
// }
// }
}
}
@ -269,11 +328,14 @@ public class SimulationRobotService {
if (signal != null && !signal.isShunting()) { // 信号机不为调车信号机
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
SectionPosition signalPosition = signal.getPosition();
if (vrSignal != null && (i != 0 || signalPosition.isAheadOf(headPosition, right))) { //有实体信号机且列车未越过信号机
if (vrSignal != null && (i != 0 || signalPosition.isAheadOf(headPosition,
right))) { //有实体信号机且列车未越过信号机
if (Objects.equals(vrSignal.getAspect(), signal.getDefaultAspect()) //禁止信号
|| Objects.equals(vrSignal.getAspect(), signal.getGuideAspect())) { //引导信号
if (!Objects.equals(signal, throughSignal) || !Objects.equals(vrSignal.getAspect(), throughAspect)) {
SectionPosition noPassPosition = CalculateService.calculateNextPositionByStartAndLen(signalPosition, !right, 2, true);
if (!Objects.equals(signal, throughSignal) || !Objects.equals(vrSignal.getAspect(),
throughAspect)) {
SectionPosition noPassPosition = CalculateService.calculateNextPositionByStartAndLen(
signalPosition, !right, 2, true);
if (targetPosition == null || noPassPosition.isAheadOf(targetPosition, right)) {
targetPosition = noPassPosition;
}
@ -283,7 +345,8 @@ public class SimulationRobotService {
}
if (targetPosition == null) {
if (selectedPosition != null && section.equals(selectedPosition.getSection())) { //不会有比选定位置更靠前的停车点了
if (selectedPosition != null && section.equals(
selectedPosition.getSection())) { //不会有比选定位置更靠前的停车点了
targetPosition = selectedPosition;
} else {
Section tempSection = section.findNextRunningSectionBaseRealSwitch(right);

View File

@ -17,6 +17,13 @@ import lombok.Setter;
@NoArgsConstructor
public class DriveParamVO {
//----------------- 初始化信息 -----------------
/**
* 转为人工驾驶时默认停车
*/
private boolean defaultStop;
//----------------- 运行信息 -----------------
/**
* 限速值km/h
*/
@ -57,11 +64,10 @@ public class DriveParamVO {
*/
private int through;
public static final int NO = 0;
public static final int DRIVER_ROUTE_BLOCK = 0;
public static final int RED_SIGNAL = 1;
public static final int GUIDE_SIGNAL = 2;
public static final int DRIVER_NEXT_STAND = 3;
public static final int DRIVER_ROUTE_BLOCK = 4;
/**
* 要越过的信号机
@ -108,7 +114,7 @@ public class DriveParamVO {
public void setThrough(int v) {
this.through = v;
if (through == NO) {
if (through == DRIVER_ROUTE_BLOCK) {
throughSignal = null;
throughSignalAspect = null;
}
@ -136,6 +142,7 @@ public class DriveParamVO {
public DriveParamVO cloneParamVO() {
DriveParamVO paramVO = new DriveParamVO();
paramVO.setDefaultStop(defaultStop);
paramVO.setSpeedLimit(speedLimit);
paramVO.setStop(this.stop);
paramVO.setRun(this.run);

View File

@ -235,6 +235,16 @@ public class RealLineConfigVO {
@JsonProperty(value = "SFUCanOnlyApplyForFaultLockSection")
private boolean SFUCanOnlyApplyForFaultLockSection;
/**
* 道岔故障时可以办理进路由远及近锁闭到故障处终止
*/
private boolean routeCanSetWhenSwitchFault;
/**
* 人工驾驶模式CM/RM/NRM下的列车默认是停车等待命令状态
*/
private boolean manualTrainDefaultStop;
public static RealLineConfigVO parseJsonStr(String configData) {
if (StringUtils.hasText(configData)) {
return JsonUtils.read(configData, RealLineConfigVO.class);

View File

@ -210,6 +210,11 @@ public class MapRouteNewVO {
private LinkedHashMap<String, SignalAspect> leaveSectionWithAspectMap;
/**
* 单列车进路
*/
private boolean singleTrain;
public MapRouteNewVO() {
this.routeSectionList = new ArrayList<>();
this.routeSwitchList = new ArrayList<>();
@ -280,6 +285,7 @@ public class MapRouteNewVO {
.collect(Collectors.toMap(entry -> entry.getKey().getCode(), Map.Entry::getValue, (v1, v2) -> v2, LinkedHashMap::new));
vo.setLeaveSectionWithAspectMap(map);
}
vo.setSingleTrain(route.isSingleTrain());
return vo;
}