计轴rssp 集成

This commit is contained in:
xzb 2023-11-10 10:39:41 +08:00
parent d0ad082218
commit 68c0252ec7
4 changed files with 39 additions and 6 deletions

View File

@ -6,6 +6,14 @@ import "joylink.club/ecs"
type TrainPositionInfo struct { type TrainPositionInfo struct {
//列车所占的物理区段 //列车所占的物理区段
SectionIds []string SectionIds []string
//列车长度 mm
Len uint32
//列车所在轨道link
Link uint8
//列车所在link偏移量mm
LinkOffset uint32
//列车当前运行方向(偏移量增大/减小方向)
Up bool
} }
var ( var (

View File

@ -49,3 +49,28 @@ func UpdateTrainFromDynamics(w ecs.World, trainId string, sectionIds []string) e
}) })
return result.Err 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
}

View File

@ -36,6 +36,6 @@ func BindSystem(w ecs.World) {
device_sys.NewAlarmSys(), device_sys.NewAlarmSys(),
//物理区段 //物理区段
device_sys.NewFaDcAxleDeviceSystem(), device_sys.NewFaDcAxleDeviceSystem(),
device_sys.NewTrainSectionSystem(), device_sys.NewSectionDetectSystem(),
) )
} }

View File

@ -7,17 +7,17 @@ import (
"joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/component"
) )
// TrainSectionSystem 列车所在区段更新系统 // SectionDetectSystem 区段检测系统
type TrainSectionSystem struct { type SectionDetectSystem struct {
trainQuery *ecs.Query trainQuery *ecs.Query
axleSectionQuery *ecs.Query axleSectionQuery *ecs.Query
} }
func NewTrainSectionSystem() *TrainSectionSystem { func NewSectionDetectSystem() *SectionDetectSystem {
return &TrainSectionSystem{trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)), return &SectionDetectSystem{trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)),
axleSectionQuery: ecs.NewQuery(filter.Contains(component.UidType, component.AxlePhysicalSectionType))} 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,统计区段上有车的情况 //key-sectionId,统计区段上有车的情况
sectionTrainMap := make(map[string]*trainCount) sectionTrainMap := make(map[string]*trainCount)
//所有列车 //所有列车