Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
thesai 2024-10-21 14:48:13 +08:00
commit cc71c128cf
11 changed files with 942 additions and 898 deletions

View File

@ -263,6 +263,7 @@ func addTrain(c *gin.Context) {
WheelDiameter: req.WheelDiameter, WheelDiameter: req.WheelDiameter,
Speed: req.TrainSpeed, Speed: req.TrainSpeed,
Show: true, Show: true,
TrainCoachNum: req.TrainCoachNum,
ConnState: &state_proto.TrainConnState{TrainControlMapId: req.TrainControlMapId, Conn: false, ConnType: state_proto.TrainConnState_NONE}, ConnState: &state_proto.TrainConnState{TrainControlMapId: req.TrainControlMapId, Conn: false, ConnType: state_proto.TrainConnState_NONE},
} }
var err *sys_error.BusinessError = memory.AddTrainStateNew(simulation, var err *sys_error.BusinessError = memory.AddTrainStateNew(simulation,

View File

@ -77,6 +77,7 @@ type AddTrainReqDtoNew struct {
TrainMaxAcc float32 `json:"trainMaxAcc" from:"trainMaxAcc"` TrainMaxAcc float32 `json:"trainMaxAcc" from:"trainMaxAcc"`
TrainMaxBrake float32 `json:"trainMaxBrake" from:"trainMaxBrake"` TrainMaxBrake float32 `json:"trainMaxBrake" from:"trainMaxBrake"`
TrainEmergencyBrake float32 `json:"trainEmergencyBrake" from:"trainEmergencyBrake"` TrainEmergencyBrake float32 `json:"trainEmergencyBrake" from:"trainEmergencyBrake"`
TrainCoachNum uint32 `json:"trainCoachNum" from:"trainCoachNum"`
// 场景ID // 场景ID
MapId int32 `json:"mapId" from:"mapId"` MapId int32 `json:"mapId" from:"mapId"`
WheelDiameter int32 `json:"wheelDiameter" from:"wheelDiameter"` WheelDiameter int32 `json:"wheelDiameter" from:"wheelDiameter"`

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit 150aa24307c42916cde8f6fbe629c9d100be8737 Subproject commit 073f5e3156b66343ff283ba3530b4d3d63ca4461

@ -1 +1 @@
Subproject commit 5b0baec461fba33bcb76212ce2b1a19d1b79057f Subproject commit a6293366a132680309a62855d4c4e19546ba3aa8

View File

@ -142,7 +142,7 @@ func (d *dynamics) requestStartSimulation(base *message.LineBaseInfo) error {
} }
url := d.buildUrl("/api/start/") url := d.buildUrl("/api/start/")
data, _ := json.Marshal(base) data, _ := json.Marshal(base)
//fmt.Println(string(data)) slog.Info(string(data))
resp, err := d.httpClient.Post(url, "application/json", bytes.NewBuffer(data)) resp, err := d.httpClient.Post(url, "application/json", bytes.NewBuffer(data))
if err != nil { if err != nil {
return sys_error.New("动力学开始仿真请求发送错误", err) return sys_error.New("动力学开始仿真请求发送错误", err)

View File

@ -9,6 +9,7 @@ type InitTrainInfo struct {
Up bool `json:"up"` Up bool `json:"up"`
//TrainLength uint32 `json:"trainLength"` //TrainLength uint32 `json:"trainLength"`
TrainOperationConfig *TrainOperationConfig `json:"config"` TrainOperationConfig *TrainOperationConfig `json:"config"`
TrainCoachNum uint32 `json:"coachNum"`
} }
// 移除列车请求参数 // 移除列车请求参数
@ -18,15 +19,17 @@ type RemoveTrainReq struct {
// LineBaseInfo 线路基础信息,提供给动力学作为计算依据 // LineBaseInfo 线路基础信息,提供给动力学作为计算依据
type LineBaseInfo struct { type LineBaseInfo struct {
LinkList []*Link `json:"linkList"` LinkList []*Link `json:"linkList"`
SlopeList []*Slope `json:"slopeList"` SlopeList []*Slope `json:"slopeList"`
CurveList []*Curve `json:"curveList"` CurveList []*Curve `json:"curveList"`
StopPosition []*StopPosition `json:"stopPositionList"` //StopPosition []*StopPosition `json:"stopPositionList"`
StopPosition []*StopPosition `json:"stopList"`
} }
type StopPosition struct { type StopPosition struct {
Id int32 `json:"id"` Id int32 `json:"id"`
LinkId int32 `json:"linkId"` LinkId int32 `json:"linkId"`
LinkOffset int32 `json:"linkOffset"` LinkOffset int32 `json:"linkOffset"`
CoachNum int32 `json:"coachNum"`
} }
type Link struct { type Link struct {
ID int32 `json:"id"` ID int32 `json:"id"`

View File

@ -57,6 +57,7 @@ type StationUidStructure struct {
IbpIds map[uint32]*DeviceRelationship IbpIds map[uint32]*DeviceRelationship
CkmIds map[uint32]*DeviceRelationship CkmIds map[uint32]*DeviceRelationship
XcjIds map[uint32]*DeviceRelationship XcjIds map[uint32]*DeviceRelationship
StopPoint map[uint32]*DeviceRelationship
} }
type RelayUidStructure struct { type RelayUidStructure struct {
@ -270,6 +271,7 @@ func initStationUid(data *data_proto.RtssGraphicStorage) *StationUidStructure {
IbpIds: make(map[uint32]*DeviceRelationship, len(data.IbpBoxs)), IbpIds: make(map[uint32]*DeviceRelationship, len(data.IbpBoxs)),
CkmIds: make(map[uint32]*DeviceRelationship, len(data.GarageDoors)), CkmIds: make(map[uint32]*DeviceRelationship, len(data.GarageDoors)),
XcjIds: make(map[uint32]*DeviceRelationship, len(data.CarWashings)), XcjIds: make(map[uint32]*DeviceRelationship, len(data.CarWashings)),
StopPoint: make(map[uint32]*DeviceRelationship, len(data.StopPositions)),
} }
city, lineId, _ := getUIdPrefix(data.UniqueIdPrefix) city, lineId, _ := getUIdPrefix(data.UniqueIdPrefix)
// 处理车站信息 // 处理车站信息
@ -291,6 +293,19 @@ func initStationUid(data *data_proto.RtssGraphicStorage) *StationUidStructure {
} }
} }
} }
// 初始停车点信息
for _, a := range data.StopPositions {
eid := GetMapElementId(a.Common)
code := getMapELementCode(eid, a.Code)
uid := strconv.Itoa(int(eid))
gus.StopPoint[eid] = &DeviceRelationship{
CommonId: eid,
Code: code,
//Uid: BuildUid(city, lineId, strconv.Itoa(int(eid))),
Uid: uid,
//CentralizedStations: gus.StationIds[platform.RefStationId].GetCentralizedStations(),
}
}
// 初始化计轴信息 // 初始化计轴信息
for _, a := range data.AxleCountings { for _, a := range data.AxleCountings {
eid := GetMapElementId(a.Common) eid := GetMapElementId(a.Common)

View File

@ -118,6 +118,7 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
LinkOffset: uint32(loffset), LinkOffset: uint32(loffset),
Speed: status.Speed / 3.6, Speed: status.Speed / 3.6,
Up: status.Up, Up: status.Up,
TrainCoachNum: status.TrainCoachNum,
TrainOperationConfig: CreateMsgTrainConfig(int(trainIndex), status.TrainLength, configTrainData), TrainOperationConfig: CreateMsgTrainConfig(int(trainIndex), status.TrainLength, configTrainData),
}) })
if err != nil { if err != nil {
@ -320,7 +321,7 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
//pointTO 指的是是否ab或是否到岔心 //pointTO 指的是是否ab或是否到岔心
_, pointTo := QueryDirectionAndABByDevice(vs.Repo, id, port, info.Up) _, pointTo := QueryDirectionAndABByDevice(vs.Repo, id, port, info.Up)
//slog.Debug("处理动力学转换后的消息", "number", info.Number, "up", info.Up, "Link", info.Link, "车头位置", id, "偏移", offset, "是否上行", true, "是否ab", pointTo, "t1Dir:", info.TrainActToMax, "t2Dir:", info.TrainActToMin) //slog.Info("处理动力学转换后的消息", "number", info.Number, "up", info.Up, "Link", info.Link, "link位置", info.LinkOffset, "outlink位置", outLinkOffset, "车头位置", id, "偏移", offset, "是否上行", true, "是否ab", pointTo, "t1Dir:", info.TrainActToMax, "t2Dir:", info.TrainActToMin, "acc", info.Acceleration)
trainHeadActUp := true trainHeadActUp := true
if info.TrainActToMax || info.TrainActToMin { if info.TrainActToMax || info.TrainActToMin {
if info.TrainActToMin { if info.TrainActToMin {

View File

@ -376,7 +376,7 @@ func (s *VerifySimulation) GetDynamicsRunRepository() *message.LineBaseInfo {
id, _ := strconv.Atoi(sp.Id()) id, _ := strconv.Atoi(sp.Id())
linkId, _ := strconv.Atoi(sp.LinkPosition().Link().Id()) linkId, _ := strconv.Atoi(sp.LinkPosition().Link().Id())
linkOffset := sp.LinkPosition().Offset() linkOffset := sp.LinkPosition().Offset()
d := &message.StopPosition{Id: int32(id), LinkId: int32(linkId), LinkOffset: int32(linkOffset)} d := &message.StopPosition{Id: int32(id), LinkId: int32(linkId), LinkOffset: int32(linkOffset), CoachNum: sp.CoachNum()}
info.StopPosition = append(info.StopPosition, d) info.StopPosition = append(info.StopPosition, d)
} }
return info return info
@ -472,13 +472,14 @@ func (s *VerifySimulation) CollectInterlockRelayInfo(code string) *message.Inter
// 获取列车可用连接半实物类型 // 获取列车可用连接半实物类型
func (s *VerifySimulation) FindTrainConnTypes() []dto.TrainConnTypeConfigDto { func (s *VerifySimulation) FindTrainConnTypes() []dto.TrainConnTypeConfigDto {
typeConfig := make([]dto.TrainConnTypeConfigDto, 0) typeConfig := make([]dto.TrainConnTypeConfigDto, 0)
if /*s.runConfig.Vobc.Open &&*/ s.runConfig.Vobc.Ip != "" { if /*s.runConfig.Vobc.Open &&*/ s.runConfig.Vobc.Ip != "" && s.runConfig.Vobc.Open {
typeConfig = append(typeConfig, dto.TrainConnTypeConfigDto{TypeName: "半实物vobc", ConnType: state_proto.TrainConnState_VOBC}) typeConfig = append(typeConfig, dto.TrainConnTypeConfigDto{TypeName: "半实物vobc", ConnType: state_proto.TrainConnState_VOBC})
} }
for _, pcSim := range s.runConfig.PcSimConfigs { for _, pcSim := range s.runConfig.PcSimConfigs {
if pcSim.Open {
typeConfig = append(typeConfig, dto.TrainConnTypeConfigDto{TypeName: pcSim.ConfigName, ConnType: state_proto.TrainConnState_PC_SIM}) typeConfig = append(typeConfig, dto.TrainConnTypeConfigDto{TypeName: pcSim.ConfigName, ConnType: state_proto.TrainConnState_PC_SIM})
}
} }
/* if s.runConfig.PcSimConfig.Open { /* if s.runConfig.PcSimConfig.Open {
typeConfig = append(typeConfig, dto.TrainConnTypeConfigDto{ConnType: state_proto.TrainConnState_PC_SIM}) typeConfig = append(typeConfig, dto.TrainConnTypeConfigDto{ConnType: state_proto.TrainConnState_PC_SIM})
@ -1125,17 +1126,7 @@ func fillProtoRepository(repo *proto.Repository, storage *data_proto.RtssGraphic
} }
repo.CheckPoints = append(repo.CheckPoints, cp) repo.CheckPoints = append(repo.CheckPoints, cp)
} }
//列车停车点
for _, sp := range storage.StopPositions {
id := GetMapElementId(sp.Common)
psp := &proto.StopPosition{Id: id, Km: convertKm(sp.KilometerSystem)}
switch sp.GetRefDev().DeviceType {
case data_proto.RelatedRef_Section:
psp.SectionId = uidsMap.PhysicalSectionIds[sp.GetRefDev().Id].Uid
}
repo.StopPosition = append(repo.StopPosition, psp)
}
//物理区段 //物理区段
for _, data := range storage.Section { for _, data := range storage.Section {
var turnoutUids []string var turnoutUids []string
@ -1165,6 +1156,27 @@ func fillProtoRepository(repo *proto.Repository, storage *data_proto.RtssGraphic
} }
repo.PhysicalSections = append(repo.PhysicalSections, physicalSection) repo.PhysicalSections = append(repo.PhysicalSections, physicalSection)
} }
//列车停车点
for _, sp := range storage.StopPositions {
//id := GetMapElementId(sp.Common)
psp := &proto.StopPosition{
Id: uidsMap.StopPoint[GetMapElementId(sp.Common)].Uid,
Km: convertKm(sp.KilometerSystem)}
var coachNum uint32 = 4
if sp.CoachNum == data_proto.StopPosition_Six {
coachNum = 6
} else if sp.CoachNum == data_proto.StopPosition_Four {
coachNum = 4
} else if sp.CoachNum == data_proto.StopPosition_Eight {
coachNum = 8
}
psp.CoachNum = coachNum
switch sp.RefDev.DeviceType {
case data_proto.RelatedRef_Section:
psp.SectionId = uidsMap.PhysicalSectionIds[sp.RefDev.Id].Uid
}
repo.StopPosition = append(repo.StopPosition, psp)
}
//计轴区段 //计轴区段
for _, data := range storage.AxleCountingSections { for _, data := range storage.AxleCountingSections {
var axleCountingIds []string var axleCountingIds []string

View File

@ -530,7 +530,7 @@ func trainAtoControlTractionAndBrake(train *state_proto.TrainState) {
{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.NOT_BREAK, notBreak}}, {Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.NOT_BREAK, notBreak}},
} }
slog.Info(fmt.Sprintf("列车 id:%v,ato:%v,AtoLevle:%v,牵引:%v,制动:%v,牵引力:%v,制动力%v", train.Id, vs.Ato, vs.AtoStepLevel, vs.AtoTractionCommandOut, vs.AtoBrakeCommand, vs.TractionForce, vs.BrakeForce)) //slog.Info(fmt.Sprintf("列车 id:%v,ato:%v,AtoLevle:%v,牵引:%v,制动:%v,牵引力:%v,制动力%v", train.Id, vs.Ato, vs.AtoStepLevel, vs.AtoTractionCommandOut, vs.AtoBrakeCommand, vs.TractionForce, vs.BrakeForce))
train_pc_sim.Default().SendTrainControlMsg2(train, msg, train.TrainPort) train_pc_sim.Default().SendTrainControlMsg2(train, msg, train.TrainPort)
} }