diff --git a/component/train.go b/component/train.go index 7a5a77f..0c70316 100644 --- a/component/train.go +++ b/component/train.go @@ -6,6 +6,14 @@ import "joylink.club/ecs" type TrainPositionInfo struct { //列车所占的物理区段 SectionIds []string + //列车长度 mm + Len uint32 + //列车所在轨道link + Link uint8 + //列车所在link偏移量(mm) + LinkOffset uint32 + //列车当前运行方向(偏移量增大/减小方向) + Up bool } var ( diff --git a/fi/train.go b/fi/train.go index 8fec61b..39ac709 100644 --- a/fi/train.go +++ b/fi/train.go @@ -49,3 +49,28 @@ func UpdateTrainFromDynamics(w ecs.World, trainId string, sectionIds []string) e }) return result.Err } + +// UpdateTrainPositionFromDynamics 更新列车所在的物理区段 +func UpdateTrainPositionFromDynamics(w ecs.World, tpi TrainPositionInfo) error { + result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { + return ecs.NewOkEmptyResult() + }) + return result.Err +} + +type TrainPositionInfo struct { + //列车id + TrainId string + //列车头当前运行方向(true偏移量增大/false减小方向) + Up bool + //列车长度 mm + Len uint32 + //列车所在轨道link + HeadLink uint8 + //列车所在link偏移量(mm) + HeadLinkOffset uint32 + //列车所在轨道link + TailLink uint8 + //列车所在link偏移量(mm) + TailLinkOffset uint32 +} diff --git a/sys/bind.go b/sys/bind.go index 6574b46..d0b2505 100644 --- a/sys/bind.go +++ b/sys/bind.go @@ -36,6 +36,6 @@ func BindSystem(w ecs.World) { device_sys.NewAlarmSys(), //物理区段 device_sys.NewFaDcAxleDeviceSystem(), - device_sys.NewTrainSectionSystem(), + device_sys.NewSectionDetectSystem(), ) } diff --git a/sys/device_sys/train.go b/sys/device_sys/section_detection.to.go similarity index 79% rename from sys/device_sys/train.go rename to sys/device_sys/section_detection.to.go index f72c488..b7fd8f1 100644 --- a/sys/device_sys/train.go +++ b/sys/device_sys/section_detection.to.go @@ -7,17 +7,17 @@ import ( "joylink.club/rtsssimulation/component" ) -// TrainSectionSystem 列车所在区段更新系统 -type TrainSectionSystem struct { +// SectionDetectSystem 区段检测系统 +type SectionDetectSystem struct { trainQuery *ecs.Query axleSectionQuery *ecs.Query } -func NewTrainSectionSystem() *TrainSectionSystem { - return &TrainSectionSystem{trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)), +func NewSectionDetectSystem() *SectionDetectSystem { + return &SectionDetectSystem{trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)), axleSectionQuery: ecs.NewQuery(filter.Contains(component.UidType, component.AxlePhysicalSectionType))} } -func (s *TrainSectionSystem) Update(w ecs.World) { +func (s *SectionDetectSystem) Update(w ecs.World) { //key-sectionId,统计区段上有车的情况 sectionTrainMap := make(map[string]*trainCount) //所有列车