btm
This commit is contained in:
parent
1d016f6fab
commit
64ef4069be
45
fi/train.go
45
fi/train.go
@ -56,6 +56,51 @@ func UpdateTrainPositionFromDynamics(w ecs.World, tpi TrainPositionInfo) error {
|
|||||||
return result.Err
|
return result.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TrainBalisePowerAmplifierSwitch 车载应答器天线功率放大器开关控制
|
||||||
|
func TrainBalisePowerAmplifierSwitch(w ecs.World, trainId string, turnOn bool) error {
|
||||||
|
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||||
|
wd := entity.GetWorldData(w)
|
||||||
|
te, find := wd.EntityMap[trainId]
|
||||||
|
if find {
|
||||||
|
train := component.TrainBtmType.Get(te)
|
||||||
|
train.PowerAmplifierSwitch = turnOn
|
||||||
|
return ecs.NewOkEmptyResult()
|
||||||
|
} else {
|
||||||
|
return ecs.NewErrResult(fmt.Errorf("列车[%s]实体不存在", trainId))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return result.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindTrainBaliseBtmStatus 获取车载BTM的相关状态信息
|
||||||
|
func FindTrainBaliseBtmStatus(w ecs.World, trainId string) ecs.Result[*TrainBaliseBtmStatus] {
|
||||||
|
result := <-ecs.Request[*TrainBaliseBtmStatus](w, func() ecs.Result[*TrainBaliseBtmStatus] {
|
||||||
|
wd := entity.GetWorldData(w)
|
||||||
|
te, find := wd.EntityMap[trainId]
|
||||||
|
if find {
|
||||||
|
btm := component.TrainBtmType.Get(te)
|
||||||
|
btmStatus := &TrainBaliseBtmStatus{
|
||||||
|
PowerAmplifierOn: btm.PowerAmplifierSwitch,
|
||||||
|
PowerAmplifierFault: false,
|
||||||
|
AboveBalise: btm.AboveBalise,
|
||||||
|
AntennaFault: false,
|
||||||
|
}
|
||||||
|
return ecs.NewOkResult(btmStatus)
|
||||||
|
} else {
|
||||||
|
return ecs.NewResult[*TrainBaliseBtmStatus](nil, fmt.Errorf("列车[%s]实体不存在", trainId))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// /////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
type TrainBaliseBtmStatus struct {
|
||||||
|
PowerAmplifierOn bool //BTM功率放大器是否开启
|
||||||
|
PowerAmplifierFault bool //BTM功率放大器是否有故障
|
||||||
|
AntennaFault bool //BTM应答器天线是否有故障
|
||||||
|
AboveBalise bool //BTM当前是否在应答器上方
|
||||||
|
}
|
||||||
|
|
||||||
type TrainPositionInfo struct {
|
type TrainPositionInfo struct {
|
||||||
//列车id
|
//列车id
|
||||||
TrainId string
|
TrainId string
|
||||||
|
@ -28,16 +28,18 @@ func (s *BaliseDetectSystem) Update(w ecs.World) {
|
|||||||
//所有列车
|
//所有列车
|
||||||
//列车速度80KM/H时,222mm/10ms
|
//列车速度80KM/H时,222mm/10ms
|
||||||
s.trainQuery.Each(w, func(entry *ecs.Entry) {
|
s.trainQuery.Each(w, func(entry *ecs.Entry) {
|
||||||
tp := component.TrainPositionInfoType.Get(entry)
|
|
||||||
btm := component.TrainBtmType.Get(entry)
|
btm := component.TrainBtmType.Get(entry)
|
||||||
detectedBalise := s.detect(wd, tp, balises)
|
if btm.PowerAmplifierSwitch { //车载应答器天线功率放大器开启
|
||||||
//列车应答器天线扫描到应答器,获取应答器报文发送给BTM
|
tp := component.TrainPositionInfoType.Get(entry)
|
||||||
tbt := s.findBaliseTelegram(wd, detectedBalise)
|
detectedBalise := s.detect(wd, tp, balises)
|
||||||
var detectedBaliseId string
|
//列车应答器天线扫描到应答器,获取应答器报文发送给BTM
|
||||||
if detectedBalise != nil {
|
tbt := s.findBaliseTelegram(wd, detectedBalise)
|
||||||
detectedBaliseId = detectedBalise.Id()
|
var detectedBaliseId string
|
||||||
|
if detectedBalise != nil {
|
||||||
|
detectedBaliseId = detectedBalise.Id()
|
||||||
|
}
|
||||||
|
btm.Scanning(detectedBalise != nil, detectedBaliseId, tbt)
|
||||||
}
|
}
|
||||||
btm.Scanning(detectedBalise != nil, detectedBaliseId, tbt)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user