【修改发送给动力学道岔ID】
This commit is contained in:
parent
9f5dd16c85
commit
125dab8a46
@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
ecsSimulation "joylink.club/rtsssimulation/simulation"
|
||||
|
||||
@ -99,7 +98,7 @@ func CreateSimulation(projectId int32, mapIds []int32) string {
|
||||
}
|
||||
verifySimulation.SimulationId = simulationId
|
||||
//通知动力学
|
||||
lineBaseInfo := buildLineBaseInfo(verifySimulation.Repo)
|
||||
lineBaseInfo := buildLineBaseInfo(verifySimulation)
|
||||
httpCode, _, err := dynamics.SendSimulationStartReq(lineBaseInfo)
|
||||
if httpCode != http.StatusOK || err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DynamicsError, Message: fmt.Sprintf("动力学接口调用失败:[%d][%s]", httpCode, err)})
|
||||
@ -217,7 +216,7 @@ func dynamicsRun(verifySimulation *memory.VerifySimulation) {
|
||||
stateSlice := memory.GetAllTurnoutState(verifySimulation)
|
||||
var turnoutInfoSlice []*dynamics.TurnoutInfo
|
||||
for _, sta := range stateSlice {
|
||||
code64, err := strconv.ParseUint(sta.Id, 10, 16)
|
||||
code64, err := strconv.ParseUint(verifySimulation.GetComIdByUid(sta.Id), 10, 16)
|
||||
if err != nil {
|
||||
zap.S().Error("id转uint16报错", err)
|
||||
}
|
||||
@ -232,9 +231,9 @@ func dynamicsRun(verifySimulation *memory.VerifySimulation) {
|
||||
})
|
||||
}
|
||||
|
||||
func buildLineBaseInfo(repo *repository.Repository) *dynamics.LineBaseInfo {
|
||||
func buildLineBaseInfo(sim *memory.VerifySimulation) *dynamics.LineBaseInfo {
|
||||
info := &dynamics.LineBaseInfo{}
|
||||
for _, model := range repo.LinkList() {
|
||||
for _, model := range sim.Repo.LinkList() {
|
||||
id, _ := strconv.Atoi(model.Id())
|
||||
link := &dynamics.Link{
|
||||
ID: int32(id),
|
||||
@ -242,7 +241,7 @@ func buildLineBaseInfo(repo *repository.Repository) *dynamics.LineBaseInfo {
|
||||
}
|
||||
info.LinkList = append(info.LinkList, link)
|
||||
if model.ARelation() != nil {
|
||||
turnoutId, _ := strconv.Atoi(model.ARelation().Device().Id())
|
||||
turnoutId, _ := strconv.Atoi(sim.GetComIdByUid(model.ARelation().Device().Id()))
|
||||
link.ARelTurnoutId = int32(turnoutId)
|
||||
switch model.ARelation().Port() {
|
||||
case proto.Port_A:
|
||||
@ -254,7 +253,7 @@ func buildLineBaseInfo(repo *repository.Repository) *dynamics.LineBaseInfo {
|
||||
}
|
||||
}
|
||||
if model.BRelation() != nil {
|
||||
turnoutId, _ := strconv.Atoi(model.BRelation().Device().Id())
|
||||
turnoutId, _ := strconv.Atoi(sim.GetComIdByUid(model.BRelation().Device().Id()))
|
||||
link.BRelTurnoutId = int32(turnoutId)
|
||||
switch model.BRelation().Port() {
|
||||
case proto.Port_A:
|
||||
@ -266,8 +265,8 @@ func buildLineBaseInfo(repo *repository.Repository) *dynamics.LineBaseInfo {
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, model := range repo.SlopeList() {
|
||||
id, _ := strconv.Atoi(model.Id())
|
||||
for _, model := range sim.Repo.SlopeList() {
|
||||
id, _ := strconv.Atoi(sim.GetComIdByUid(model.Id()))
|
||||
slope := &dynamics.Slope{
|
||||
ID: int32(id),
|
||||
StartLinkOffset: int32(model.StartLinkPosition().Offset()),
|
||||
@ -280,8 +279,8 @@ func buildLineBaseInfo(repo *repository.Repository) *dynamics.LineBaseInfo {
|
||||
endLinkId, _ := strconv.Atoi(model.EndLinkPosition().Link().Id())
|
||||
slope.EndLinkId = int32(endLinkId)
|
||||
}
|
||||
for _, model := range repo.SectionalCurvatureList() {
|
||||
id, _ := strconv.Atoi(model.Id())
|
||||
for _, model := range sim.Repo.SectionalCurvatureList() {
|
||||
id, _ := strconv.Atoi(sim.GetComIdByUid(model.Id()))
|
||||
curve := &dynamics.Curve{
|
||||
ID: int32(id),
|
||||
StartLinkOffset: int32(model.StartLinkPosition().Offset()),
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
)
|
||||
|
||||
var giUidMap sync.Map
|
||||
@ -167,6 +168,36 @@ func initRelayCabinetUid(graphicData *graphicData.RelayCabinetGraphicStorage) *r
|
||||
return rus
|
||||
}
|
||||
|
||||
// 构建仿真内所有地图UID映射信号布置图ID
|
||||
func buildRepositoryAllUidsMap(mapIds []int32, repo *repository.Repository) map[string]*elementIdStructure {
|
||||
mapLen := len(repo.CheckPointList()) + len(repo.PhysicalSectionList()) + len(repo.SignalList()) +
|
||||
len(repo.TurnoutList()) + len(repo.ResponderList()) + len(repo.SlopeList()) + len(repo.SectionalCurvatureList())
|
||||
allUidMap := make(map[string]*elementIdStructure, mapLen)
|
||||
saveToAllUidMap := func(es map[string]*elementIdStructure) {
|
||||
for _, e := range es {
|
||||
allUidMap[e.Uid] = e
|
||||
}
|
||||
}
|
||||
for _, mid := range mapIds {
|
||||
d, ok := giUidMap.Load(mid)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
u, ok := d.(*stationUidStructure)
|
||||
if ok {
|
||||
saveToAllUidMap(u.AxlePointIds)
|
||||
saveToAllUidMap(u.PhysicalSectionIds)
|
||||
saveToAllUidMap(u.SignalIds)
|
||||
saveToAllUidMap(u.TransponderIds)
|
||||
saveToAllUidMap(u.TurnoutIds)
|
||||
saveToAllUidMap(u.SlopeIds)
|
||||
saveToAllUidMap(u.CurvatureIds)
|
||||
continue
|
||||
}
|
||||
}
|
||||
return allUidMap
|
||||
}
|
||||
|
||||
// 获取地图UID的映射集合
|
||||
func queryUidStructure[T *stationUidStructure | *relayUidStructure](mapId int32) T {
|
||||
uidData, ok := giUidMap.Load(mapId)
|
||||
@ -211,8 +242,11 @@ func QueryMapUidMapByType(mapId int32, m interface{}) map[string]*elementIdStruc
|
||||
// 字段名称
|
||||
fieldName := getFieldNameByType(m)
|
||||
reflectUidMap := reflect.ValueOf(&uidData).Elem()
|
||||
um := reflectUidMap.Elem().FieldByName(fieldName).Interface()
|
||||
uidMap, ok := um.(map[string]*elementIdStructure)
|
||||
um := reflectUidMap.Elem().Elem().FieldByName(fieldName)
|
||||
if !um.CanAddr() {
|
||||
panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "类型不匹配"})
|
||||
}
|
||||
uidMap, ok := um.Interface().(map[string]*elementIdStructure)
|
||||
if !ok {
|
||||
panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "类型不匹配"})
|
||||
}
|
||||
|
@ -120,12 +120,6 @@ func GetAllTrainState(vs *VerifySimulation) []*state.TrainState {
|
||||
return trainArr
|
||||
}
|
||||
|
||||
// 获取地图内的列车信息
|
||||
func GetMapAllTrainState(vs *VerifySimulation, mid string) []*state.TrainState {
|
||||
var trainArr []*state.TrainState
|
||||
return trainArr
|
||||
}
|
||||
|
||||
// 获取变更列车状态并清空
|
||||
func GetUpdatedTrainState(vs *VerifySimulation) []*state.TrainState {
|
||||
changeTrainMap := &vs.Memory.ChangeStatus.TrainStateMap
|
||||
|
@ -31,6 +31,8 @@ type VerifySimulation struct {
|
||||
Repo *repository.Repository
|
||||
//Rtss仿真世界的id
|
||||
WorldId int
|
||||
//设备UID映射
|
||||
uidMap map[string]*elementIdStructure
|
||||
}
|
||||
|
||||
// 轨旁仿真内存模型
|
||||
@ -104,6 +106,8 @@ func CreateSimulation(projectId int32, mapIds []int32) (*VerifySimulation, error
|
||||
// 目前用本地构建状态
|
||||
worldMemory := NewWaysideMemory()
|
||||
initWorldDeviceState(worldMemory.Status, repo)
|
||||
// 构建所有UID映射关系,
|
||||
allUidMap := buildRepositoryAllUidsMap(mapIds, repo)
|
||||
//创建仿真
|
||||
worldId := simulation.CreateSimulation(repo, system.SWITCH_ZDJ9_2, system.RELAY)
|
||||
verifySimulation := &VerifySimulation{
|
||||
@ -112,12 +116,17 @@ func CreateSimulation(projectId int32, mapIds []int32) (*VerifySimulation, error
|
||||
Memory: worldMemory,
|
||||
Repo: repo,
|
||||
WorldId: worldId,
|
||||
uidMap: allUidMap,
|
||||
}
|
||||
return verifySimulation, nil
|
||||
}
|
||||
|
||||
// 获取全量状态
|
||||
func (s *VerifySimulation) GetAllState(mapId int32) *state.PushedDevicesStatus {
|
||||
giType := QueryGiType(mapId)
|
||||
if giType != graphicData.PictureType_StationLayout {
|
||||
return &state.PushedDevicesStatus{All: true}
|
||||
}
|
||||
return &state.PushedDevicesStatus{
|
||||
All: true,
|
||||
AllStatus: &state.AllDevicesStatus{
|
||||
@ -136,6 +145,18 @@ func (s *VerifySimulation) GetSimulationWorld() ecs.World {
|
||||
return ecsSimulation.GetWorld()
|
||||
}
|
||||
|
||||
// 获取仿真世界信息
|
||||
func (s *VerifySimulation) GetComIdByUid(uid string) string {
|
||||
es := s.uidMap
|
||||
if es == nil {
|
||||
panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "无映射信息"})
|
||||
}
|
||||
if es[uid] == nil {
|
||||
panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "无【uid】映射信息"})
|
||||
}
|
||||
return es[uid].CommonId
|
||||
}
|
||||
|
||||
func buildProtoRepository(mapIds []int32) (*proto.Repository, error) {
|
||||
repo := &proto.Repository{}
|
||||
var exceptStationGiMapIds []int32
|
||||
|
Loading…
Reference in New Issue
Block a user