应答器实体
This commit is contained in:
parent
6b33879525
commit
2a3ba5a2a7
@ -236,7 +236,9 @@ func (repo *Repository) FindModel(deviceId string, deviceType proto.DeviceType)
|
||||
func (repo *Repository) FindLink(id string) *Link {
|
||||
return repo.linkMap[id]
|
||||
}
|
||||
|
||||
func (repo *Repository) FindTransponder(id string) *Transponder {
|
||||
return repo.responderMap[id]
|
||||
}
|
||||
func (repo *Repository) FindTurnout(id string) *Turnout {
|
||||
return repo.turnoutMap[id]
|
||||
}
|
||||
|
@ -37,5 +37,7 @@ func BindSystem(w ecs.World) {
|
||||
//物理区段
|
||||
device_sys.NewFaDcAxleDeviceSystem(),
|
||||
device_sys.NewSectionDetectSystem(),
|
||||
//应答器
|
||||
device_sys.NewBaliseSystem(),
|
||||
)
|
||||
}
|
||||
|
41
sys/device_sys/balise.go
Normal file
41
sys/device_sys/balise.go
Normal file
@ -0,0 +1,41 @@
|
||||
package device_sys
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
)
|
||||
|
||||
type BaliseSystem struct {
|
||||
baliseQuery *ecs.Query
|
||||
}
|
||||
|
||||
func NewBaliseSystem() *BaliseSystem {
|
||||
return &BaliseSystem{baliseQuery: ecs.NewQuery(filter.Contains(component.UidType, component.BaliseStateType))}
|
||||
}
|
||||
func (s *BaliseSystem) Update(w ecs.World) {
|
||||
s.baliseQuery.Each(w, func(entry *ecs.Entry) {
|
||||
baliseState := component.BaliseStateType.Get(entry)
|
||||
baliseState.ValidTelegram = s.findValidTelegram(w, entry)
|
||||
})
|
||||
}
|
||||
|
||||
// 获取应答器有效报文
|
||||
func (s *BaliseSystem) findValidTelegram(w ecs.World, entry *ecs.Entry) []byte {
|
||||
wd := entity.GetWorldData(w)
|
||||
id := component.UidType.Get(entry).Id
|
||||
if entry.HasComponent(component.BaliseFB) {
|
||||
baliseModel := wd.Repo.FindTransponder(id)
|
||||
return baliseModel.FixedTelegram()
|
||||
} else if entry.HasComponent(component.BaliseDB) {
|
||||
|
||||
} else if entry.HasComponent(component.BaliseIB) {
|
||||
|
||||
} else if entry.HasComponent(component.BaliseVB) {
|
||||
|
||||
} else if entry.HasComponent(component.BaliseWB) {
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user