2023-11-09 14:04:36 +08:00
|
|
|
|
package component
|
2023-11-09 14:59:18 +08:00
|
|
|
|
|
2023-11-13 13:53:46 +08:00
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"joylink.club/ecs"
|
|
|
|
|
)
|
2023-11-09 14:59:18 +08:00
|
|
|
|
|
|
|
|
|
// TrainPositionInfo 列车当前位置信息
|
|
|
|
|
type TrainPositionInfo struct {
|
2023-11-10 16:03:33 +08:00
|
|
|
|
//列车头当前运行方向(true偏移量增大/false减小方向)
|
|
|
|
|
//link 由a->b偏移量增大
|
|
|
|
|
Up bool
|
2023-11-10 10:39:41 +08:00
|
|
|
|
//列车长度 mm
|
2023-11-10 16:03:33 +08:00
|
|
|
|
Len int64
|
2023-11-10 10:39:41 +08:00
|
|
|
|
//列车所在轨道link
|
2023-11-10 16:03:33 +08:00
|
|
|
|
HeadLink string
|
2023-11-10 10:39:41 +08:00
|
|
|
|
//列车所在link偏移量(mm)
|
2023-11-10 16:03:33 +08:00
|
|
|
|
HeadLinkOffset int64
|
|
|
|
|
//列车所在轨道link
|
|
|
|
|
TailLink string
|
|
|
|
|
//列车所在link偏移量(mm)
|
|
|
|
|
TailLinkOffset int64
|
2023-11-09 14:59:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-13 13:53:46 +08:00
|
|
|
|
func (t *TrainPositionInfo) ToString() string {
|
|
|
|
|
return fmt.Sprintf("Up=%t len=%d headLink=%s headOff=%d tailLink=%s tailOff=%d", t.Up, t.Len, t.HeadLink, t.HeadLinkOffset, t.TailLink, t.TailLinkOffset)
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-22 13:24:17 +08:00
|
|
|
|
// TrainBtm 列车应答器传输模块
|
|
|
|
|
type TrainBtm struct {
|
2023-11-22 18:11:03 +08:00
|
|
|
|
//应答器计数(每过一个应答器加一,在同一个应答器内不变)
|
|
|
|
|
BaliseCounter int
|
|
|
|
|
//报文计数器(每解出一个应答器报文加一)
|
|
|
|
|
MessageCounter int
|
2023-11-23 10:43:36 +08:00
|
|
|
|
//车载应答器天线功率放大器开关,true-开,false-关
|
|
|
|
|
PowerAmplifierSwitch bool
|
|
|
|
|
//天线此时是否在应答器上方
|
2023-11-22 18:11:03 +08:00
|
|
|
|
AboveBalise bool
|
2023-11-23 10:43:36 +08:00
|
|
|
|
//列车在运行方向顺序扫描到的应答器
|
|
|
|
|
ScannedBalises []*TrainBaliseTelegram
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TrainBaliseTelegram 应答器报文
|
|
|
|
|
type TrainBaliseTelegram struct {
|
|
|
|
|
BaliseId string //应答器ID
|
|
|
|
|
Telegram []byte //一个应答器同一时刻只有一条报文处于激活有效状态
|
2023-11-22 13:24:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-09 14:59:18 +08:00
|
|
|
|
var (
|
|
|
|
|
TrainPositionInfoType = ecs.NewComponentType[TrainPositionInfo]()
|
2023-11-22 18:11:03 +08:00
|
|
|
|
TrainBtmType = ecs.NewComponentType[TrainBtm]()
|
2023-11-09 14:59:18 +08:00
|
|
|
|
)
|