btm
This commit is contained in:
parent
5f005630f5
commit
be1e0d59d2
39
third_party/can_btm/balise_btm.go
vendored
39
third_party/can_btm/balise_btm.go
vendored
@ -4,30 +4,39 @@ import (
|
||||
"fmt"
|
||||
"joylink.club/bj-rtsts-server/third_party/message"
|
||||
"joylink.club/bj-rtsts-server/third_party/udp"
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/fi"
|
||||
"log/slog"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// btm与canet(网口-CAN口转换器)
|
||||
type btmCanetClient struct {
|
||||
//udp
|
||||
w ecs.World
|
||||
//udp server
|
||||
udpServer udp.UdpServer
|
||||
//udp
|
||||
udpClient udp.UdpClient
|
||||
localUdpPort int
|
||||
//udp client
|
||||
udpClient udp.UdpClient
|
||||
//udp 本地侦听端口
|
||||
localUdpPort int
|
||||
//udp 远程端口
|
||||
remoteUdpPort int
|
||||
remoteIp string
|
||||
trainId string
|
||||
//udp 远程ip
|
||||
remoteIp string
|
||||
//该CANET关联的唯一列车的id
|
||||
trainId string
|
||||
//车载ATP系统当前时间ms
|
||||
atpSystemTime uint32
|
||||
//最近一次车载ATP系统查询帧序号
|
||||
atpReqSn byte
|
||||
//最近一次车载ATP系统查询帧CRC16校验结果
|
||||
atpReqCrc16Check bool
|
||||
}
|
||||
type BtmCanetClient interface {
|
||||
Start()
|
||||
Stop()
|
||||
TrainId() string
|
||||
}
|
||||
type BtmMessageManager interface {
|
||||
BtmRcvAtpReqFrame(trainId string, atpReq *message.AtpRequestFrame)
|
||||
BtmScanBaliseContent(trainId string)
|
||||
}
|
||||
|
||||
func NewBtmCanetClient(trainId string, remoteIp string, remoteUdpPort int, localUdpPort int) BtmCanetClient {
|
||||
return &btmCanetClient{trainId: trainId, remoteIp: remoteIp, remoteUdpPort: remoteUdpPort, localUdpPort: localUdpPort}
|
||||
@ -102,10 +111,18 @@ func (s *btmCanetClient) dealWithAptReq(f *message.CanetFrame) {
|
||||
atpReq := &message.AtpRequestFrame{}
|
||||
if !atpReq.Decode(f) {
|
||||
slog.Warn("CanetFrame解码成AtpRequestFrame失败", "CanetFrame", f.String())
|
||||
return
|
||||
}
|
||||
//处理查询请求
|
||||
slog.Debug(fmt.Sprintf("处理查询请求:%s", atpReq.String()))
|
||||
//todo
|
||||
//
|
||||
s.atpSystemTime = atpReq.Time
|
||||
s.atpReqSn = atpReq.FId.ID4
|
||||
s.atpReqCrc16Check = atpReq.Crc16CheckOk
|
||||
se := fi.TrainBalisePowerAmplifierSwitch(s.w, s.trainId, atpReq.PowerAmplifierTurnOn)
|
||||
if se != nil {
|
||||
slog.Warn(fmt.Sprintf("列车[%s]车载BTM功率放大器开关控制异常[%s]", s.trainId, se.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user