Compare commits
No commits in common. "9809df4b27c488c19c8f5aed045860c4a507e56a" and "3d66efe8f4c6ce997f1da40d0399054457e6de10" have entirely different histories.
9809df4b27
...
3d66efe8f4
@ -161,15 +161,11 @@ type VehiclePCSimConfig2 struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type VehiclePCSimConfig struct {
|
type VehiclePCSimConfig struct {
|
||||||
Open bool `json:"open" description:"是否开启"`
|
|
||||||
//TrainEnds bool `json:"trainEnds" description:"列车端点A?"`
|
//TrainEnds bool `json:"trainEnds" description:"列车端点A?"`
|
||||||
ConfigName string `json:"configName" description:"连接名称"`
|
ConfigName string `json:"configName" description:"连接名称"`
|
||||||
OpenA bool `json:"openA" description:"是否开启A端"`
|
Open bool `json:"open" description:"是否开启"`
|
||||||
APcSimIp string `json:"apcSimIp" description:"pc仿真平台通信ip A端"`
|
PcSimIp string `json:"pcSimIp" description:"pc仿真平台通信ip"`
|
||||||
APcSimPort uint32 `json:"apcSimPort" description:"pc仿真平台通信端口A端"`
|
PcSimPort uint32 `json:"pcSimPort" description:"pc仿真平台通信端口"`
|
||||||
OpenB bool `json:"openB" description:"是否开启B端"`
|
|
||||||
BPcSimIp string `json:"bpcSimIp" description:"pc仿真平台通信ip B端"`
|
|
||||||
BPcSimPort uint32 `json:"bpcSimPort" description:"pc仿真平台通信端口B端"`
|
|
||||||
//LocalTestingPort uint32 `json:"localTestingPort" description:"本地测试端口"`
|
//LocalTestingPort uint32 `json:"localTestingPort" description:"本地测试端口"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ server:
|
|||||||
# 数据源
|
# 数据源
|
||||||
datasource:
|
datasource:
|
||||||
# 数据库访问url
|
# 数据库访问url
|
||||||
dsn: root:root@tcp(127.0.0.1:3306)/bj-rtss?charset=utf8mb4&parseTime=true&loc=UTC
|
# dsn: root:root@tcp(127.0.0.1:3306)/bj-rtss?charset=utf8mb4&parseTime=true&loc=UTC
|
||||||
# dsn: root:joylink0503@tcp(192.168.33.233:3306)/bj-rtss?charset=utf8mb4&parseTime=true&loc=UTC
|
dsn: root:joylink0503@tcp(192.168.33.233:3306)/bj-rtss?charset=utf8mb4&parseTime=true&loc=UTC
|
||||||
|
|
||||||
# 日志配置
|
# 日志配置
|
||||||
logging:
|
logging:
|
||||||
@ -33,7 +33,7 @@ logging:
|
|||||||
# 消息配置
|
# 消息配置
|
||||||
messaging:
|
messaging:
|
||||||
mqtt:
|
mqtt:
|
||||||
address: tcp://127.0.0.1:1883
|
# address: tcp://127.0.0.1:1883
|
||||||
# address: tcp://192.168.33.233:1883
|
address: tcp://192.168.33.233:1883
|
||||||
username: rtsts_service
|
username: rtsts_service
|
||||||
password: joylink@0503
|
password: joylink@0503
|
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
|||||||
Subproject commit ef7ff5459cde3eced121d1908b192ee586a47c97
|
Subproject commit f1feee09ccf3d267278789299f09dbd8eb159d8b
|
@ -1 +1 @@
|
|||||||
Subproject commit 0a0de33fd10ea2ddca55ca9d3cc8acad971e4449
|
Subproject commit 3d7da35731be5af7bb126c276b4f9486c1f68e3a
|
@ -45,7 +45,7 @@ func checkRunConfig(jsonConfigStr string) *sys_error.BusinessError {
|
|||||||
checkSameMap := make(map[string]bool)
|
checkSameMap := make(map[string]bool)
|
||||||
for _, simConfig := range configMap.PcSimConfigs {
|
for _, simConfig := range configMap.PcSimConfigs {
|
||||||
if simConfig.ConfigName == "" || len(strings.TrimSpace(simConfig.ConfigName)) == 0 {
|
if simConfig.ConfigName == "" || len(strings.TrimSpace(simConfig.ConfigName)) == 0 {
|
||||||
return sys_error.New(fmt.Sprintf("车载运行配置名称不能为空 "), err)
|
return sys_error.New(fmt.Sprintf("车载运行配置名称不能为空 配置ip:%v,端口%v", simConfig.PcSimIp, simConfig.PcSimPort), err)
|
||||||
}
|
}
|
||||||
if checkSameMap[simConfig.ConfigName] {
|
if checkSameMap[simConfig.ConfigName] {
|
||||||
return sys_error.New(fmt.Sprintf("车载运行配置重复的名称:%v", simConfig.ConfigName), err)
|
return sys_error.New(fmt.Sprintf("车载运行配置重复的名称:%v", simConfig.ConfigName), err)
|
||||||
|
15
third_party/can_btm/balise_btm.go
vendored
15
third_party/can_btm/balise_btm.go
vendored
@ -68,7 +68,7 @@ type BtmCanetClient interface {
|
|||||||
Stop()
|
Stop()
|
||||||
//HandleTrainHeadPositionInfo 处理收到列车位置信息
|
//HandleTrainHeadPositionInfo 处理收到列车位置信息
|
||||||
HandleTrainHeadPositionInfo(w ecs.World, h *TrainHeadPositionInfo)
|
HandleTrainHeadPositionInfo(w ecs.World, h *TrainHeadPositionInfo)
|
||||||
HandleTrainHeadPositionInfoForTrain(w ecs.World, train *state_proto.TrainState, h *TrainHeadPositionInfo)
|
HandleTrainHeadPositionInfoForTrain(w ecs.World, train *state_proto.TrainBtmCache, h *TrainHeadPositionInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -84,7 +84,7 @@ func Default() BtmCanetClient {
|
|||||||
}
|
}
|
||||||
return btmClient
|
return btmClient
|
||||||
}
|
}
|
||||||
func (s *btmCanetClient) HandleTrainHeadPositionInfoForTrain(w ecs.World, train *state_proto.TrainState, h *TrainHeadPositionInfo) {
|
func (s *btmCanetClient) HandleTrainHeadPositionInfoForTrain(w ecs.World, btmCache *state_proto.TrainBtmCache, h *TrainHeadPositionInfo) {
|
||||||
wd := entity.GetWorldData(w)
|
wd := entity.GetWorldData(w)
|
||||||
repo := wd.Repo
|
repo := wd.Repo
|
||||||
h2 := &TrainHeadPositionInfo{
|
h2 := &TrainHeadPositionInfo{
|
||||||
@ -94,15 +94,8 @@ func (s *btmCanetClient) HandleTrainHeadPositionInfoForTrain(w ecs.World, train
|
|||||||
LinkOffset: h.OldLinkOffset,
|
LinkOffset: h.OldLinkOffset,
|
||||||
Speed: h.Speed,
|
Speed: h.Speed,
|
||||||
Acceleration: h.Acceleration}
|
Acceleration: h.Acceleration}
|
||||||
s.baliseDetector.newDetect(wd, repo, h, h2, train.BtmBaliseCacheA, h.IsLine12, false, "11")
|
s.baliseDetector.newDetect(wd, repo, h, h2, btmCache, h.IsLine12)
|
||||||
h.Up = h.TailUp
|
//s.baliseDetector.detect2(wd, repo, h, h2, vobcBtm)
|
||||||
h.Link = h.TailLink
|
|
||||||
h.LinkOffset = h.TailLinkOffset
|
|
||||||
h2.Up = h.TailUp
|
|
||||||
h2.Link = h.OldTailLink
|
|
||||||
h2.LinkOffset = h.OldTailLinkOffset
|
|
||||||
s.baliseDetector.newDetect(wd, repo, h, h2, train.BtmBaliseCacheB, h.IsLine12, false, "222")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleTrainHeadPositionInfo 处理来自动力学的列车位置信息
|
// HandleTrainHeadPositionInfo 处理来自动力学的列车位置信息
|
||||||
|
18
third_party/can_btm/balise_detection.go
vendored
18
third_party/can_btm/balise_detection.go
vendored
@ -77,7 +77,7 @@ func (t *BaliseDetector) tryRebind(th *TrainHeadPositionInfo) {
|
|||||||
//slog.Debug(fmt.Sprintf("列车[%s]与CAN-BTM绑定", t.trianId))
|
//slog.Debug(fmt.Sprintf("列车[%s]与CAN-BTM绑定", t.trianId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (t *BaliseDetector) newDetect(wd *component.WorldData, repo *repository.Repository, th, th2 *TrainHeadPositionInfo, btmCache *state_proto.TrainBtmCache, isLine12, show bool, id string) {
|
func (t *BaliseDetector) newDetect(wd *component.WorldData, repo *repository.Repository, th, th2 *TrainHeadPositionInfo, btmCache *state_proto.TrainBtmCache, isLine12 bool) {
|
||||||
//BTM天线中心点运行信息
|
//BTM天线中心点运行信息
|
||||||
curAntennaRi := t.createBtmAntennaRunningInfo(wd, repo, th) //目前车头
|
curAntennaRi := t.createBtmAntennaRunningInfo(wd, repo, th) //目前车头
|
||||||
curAntennaRi2 := t.createBtmAntennaRunningInfo(wd, repo, th2) //上次车头
|
curAntennaRi2 := t.createBtmAntennaRunningInfo(wd, repo, th2) //上次车头
|
||||||
@ -103,15 +103,7 @@ func (t *BaliseDetector) newDetect(wd *component.WorldData, repo *repository.Rep
|
|||||||
if len(balises) > 0 {
|
if len(balises) > 0 {
|
||||||
balise := balises[0]
|
balise := balises[0]
|
||||||
telegram, utel := t.rcvTelegram(wd, balise.Id())
|
telegram, utel := t.rcvTelegram(wd, balise.Id())
|
||||||
/*if show {
|
AddNewExpectedBalise(balise, btmCache, telegram, utel, isLine12)
|
||||||
slog.Info(fmt.Sprintf("%v --------------------id:%v ,offset:%v, up: %v,linkeId:%v ,headoffset:%v,tailOffset:%v", id, balise.Id(), balise.LinkPosition().Offset(), th.Up, curAntennaRi.LinkId, curAntennaRi.LinkOffset, curAntennaRi2.LinkOffset))
|
|
||||||
}*/
|
|
||||||
if AddNewExpectedBalise(balise, btmCache, telegram, utel, isLine12) {
|
|
||||||
if show {
|
|
||||||
slog.Info(fmt.Sprintf("%v +++++++++++++id:%v ,offset:%v, up: %v,linkeId:%v ,headoffset:%v,tailOffset:%v", id, balise.Id(), balise.LinkPosition().Offset(), th.Up, curAntennaRi.LinkId, curAntennaRi.LinkOffset, curAntennaRi2.LinkOffset))
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -187,7 +179,7 @@ func (t *BaliseDetector) rcvTelegram(wd *component.WorldData, baliseId string) (
|
|||||||
if !workedState.Work {
|
if !workedState.Work {
|
||||||
return fixBalise.Telegram, fixBalise.UserTelegram
|
return fixBalise.Telegram, fixBalise.UserTelegram
|
||||||
} else if baliseVar.UserTelegram == nil || len(baliseVar.UserTelegram) == 0 {
|
} else if baliseVar.UserTelegram == nil || len(baliseVar.UserTelegram) == 0 {
|
||||||
//slog.Warn(fmt.Sprintf("BTM天线未接受到应答器可变报文,即将使用对应的固定报文, baliseId: %v", baliseId))
|
slog.Warn(fmt.Sprintf("BTM天线未接受到应答器可变报文,即将使用对应的固定报文, baliseId: %v", baliseId))
|
||||||
return fixBalise.Telegram, fixBalise.UserTelegram
|
return fixBalise.Telegram, fixBalise.UserTelegram
|
||||||
} else {
|
} else {
|
||||||
return baliseVar.Telegram, baliseVar.UserTelegram
|
return baliseVar.Telegram, baliseVar.UserTelegram
|
||||||
@ -195,10 +187,10 @@ func (t *BaliseDetector) rcvTelegram(wd *component.WorldData, baliseId string) (
|
|||||||
} else if workedState.Work {
|
} else if workedState.Work {
|
||||||
return fixBalise.Telegram, fixBalise.UserTelegram
|
return fixBalise.Telegram, fixBalise.UserTelegram
|
||||||
} else {
|
} else {
|
||||||
//slog.Warn(fmt.Sprintf("BTM天线未接受到应答器报文,应答器未工作 baliseId: %v", baliseId))
|
slog.Warn(fmt.Sprintf("BTM天线未接受到应答器报文,应答器未工作 baliseId: %v", baliseId))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//slog.Warn(fmt.Sprintf("BTM天线接收应答器报文,未找到 baliseId: %v", baliseId))
|
slog.Warn(fmt.Sprintf("BTM天线接收应答器报文,未找到 baliseId: %v", baliseId))
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
28
third_party/can_btm/train_balise_cache.go
vendored
28
third_party/can_btm/train_balise_cache.go
vendored
@ -58,56 +58,56 @@ func AddNewExpectedBalise(balise *repository.Transponder, btmCache *state_proto.
|
|||||||
|
|
||||||
// HandleTrainHeadPositionInfoForTrain 处理列车位置信息
|
// HandleTrainHeadPositionInfoForTrain 处理列车位置信息
|
||||||
// 参数1: 参数2:发送序列号,参数3:应答器计数(每过一个应答器加一,在同一个应答器内不变),参数4:报文计数器 (每解出一个报文加一)(0~255)
|
// 参数1: 参数2:发送序列号,参数3:应答器计数(每过一个应答器加一,在同一个应答器内不变),参数4:报文计数器 (每解出一个报文加一)(0~255)
|
||||||
func FindBaliseResend(cache *state_proto.TrainBtmCache, isLine12 bool) (*state_proto.BTMState, byte, byte, byte) {
|
func FindBaliseResend(train *state_proto.TrainState) (*state_proto.BTMState, byte, byte, byte) {
|
||||||
baliseLock.Lock()
|
baliseLock.Lock()
|
||||||
defer baliseLock.Unlock()
|
defer baliseLock.Unlock()
|
||||||
|
cache := train.BtmBaliseCache
|
||||||
for _, balise := range cache.BaliseList {
|
for _, balise := range cache.BaliseList {
|
||||||
if balise != nil && balise.BaliseId == cache.ResendBaliseId && balise.ResendCount < 3 {
|
if balise != nil && balise.BaliseId == cache.ResendBaliseId && balise.ResendCount < 3 {
|
||||||
balise.ResendCount++
|
balise.ResendCount++
|
||||||
ndsn := BaliseCounterAdd(cache.Dsn, isLine12)
|
ndsn := BaliseCounterAdd(cache.Dsn, IsLine12(train))
|
||||||
cache.Dsn = uint32(ndsn)
|
cache.Dsn = uint32(ndsn)
|
||||||
return balise, ndsn, byte(cache.BaliseCount), byte(cache.MessageCounter)
|
return balise, ndsn, byte(cache.BaliseCount), byte(cache.MessageCounter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ndsn := BaliseCounterAdd(cache.Dsn, isLine12)
|
ndsn := BaliseCounterAdd(cache.Dsn, IsLine12(train))
|
||||||
return nil, ndsn, 0, 0
|
return nil, ndsn, 0, 0
|
||||||
}
|
}
|
||||||
|
func FindBaliseByNotSend(train *state_proto.TrainState) (*state_proto.BTMState, byte, byte, byte) {
|
||||||
func FindBaliseByNotSend(cache *state_proto.TrainBtmCache, isLine12 bool) (*state_proto.BTMState, byte, byte, byte) {
|
|
||||||
baliseLock.Lock()
|
baliseLock.Lock()
|
||||||
defer baliseLock.Unlock()
|
defer baliseLock.Unlock()
|
||||||
|
cache := train.BtmBaliseCache
|
||||||
for _, btmCache := range cache.BaliseList {
|
for _, btmCache := range cache.BaliseList {
|
||||||
if btmCache != nil && !btmCache.IsSend {
|
if btmCache != nil && !btmCache.IsSend {
|
||||||
ndsn := BaliseCounterAdd(cache.Dsn, isLine12)
|
ndsn := BaliseCounterAdd(cache.Dsn, IsLine12(train))
|
||||||
cache.Dsn = uint32(ndsn)
|
cache.Dsn = uint32(ndsn)
|
||||||
cache.ResendBaliseId = btmCache.BaliseId
|
cache.ResendBaliseId = btmCache.BaliseId
|
||||||
return btmCache, ndsn, byte(cache.BaliseCount), byte(cache.MessageCounter)
|
return btmCache, ndsn, byte(cache.BaliseCount), byte(cache.MessageCounter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ndsn := BaliseCounterAdd(cache.Dsn, isLine12)
|
ndsn := BaliseCounterAdd(cache.Dsn, IsLine12(train))
|
||||||
return nil, ndsn, 0, 0
|
return nil, ndsn, 0, 0
|
||||||
}
|
}
|
||||||
func ClearBalise(train *state_proto.TrainState) {
|
func ClearBalise(train *state_proto.TrainState) {
|
||||||
baliseLock.Lock()
|
baliseLock.Lock()
|
||||||
defer baliseLock.Unlock()
|
defer baliseLock.Unlock()
|
||||||
train.BtmBaliseCacheA.BaliseList = make([]*state_proto.BTMState, 3)
|
train.BtmBaliseCache.BaliseList = make([]*state_proto.BTMState, 3)
|
||||||
train.BtmBaliseCacheB.BaliseList = make([]*state_proto.BTMState, 3)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 11号线根据序列号查询
|
// 11号线根据序列号查询
|
||||||
func FindBaliseByMessageSerial(cache *state_proto.TrainBtmCache, isLine12 bool, ms byte) (*state_proto.BTMState, byte, bool) {
|
func FindBaliseByMessageSerial(train *state_proto.TrainState, ms byte) (*state_proto.BTMState, byte, bool) {
|
||||||
baliseLock.Lock()
|
baliseLock.Lock()
|
||||||
defer baliseLock.Unlock()
|
defer baliseLock.Unlock()
|
||||||
|
cache := train.BtmBaliseCache
|
||||||
|
|
||||||
for _, btmCache := range cache.BaliseList {
|
for _, btmCache := range cache.BaliseList {
|
||||||
if btmCache != nil {
|
if btmCache != nil {
|
||||||
if btmCache.BaliseId == cache.ResendBaliseId {
|
if btmCache.BaliseId == cache.ResendBaliseId {
|
||||||
if byte(btmCache.PackageDataSN) == ms {
|
if byte(btmCache.PackageDataSN) == ms {
|
||||||
bt, dsn, _, _ := FindBaliseByNotSend(cache, isLine12)
|
bt, dsn, _, _ := FindBaliseByNotSend(train)
|
||||||
return bt, dsn, true
|
return bt, dsn, true
|
||||||
} else {
|
} else {
|
||||||
ndsn := BaliseCounterAdd(cache.Dsn, isLine12)
|
ndsn := BaliseCounterAdd(cache.Dsn, IsLine12(train))
|
||||||
cache.Dsn = uint32(ndsn)
|
cache.Dsn = uint32(ndsn)
|
||||||
return btmCache, ndsn, false
|
return btmCache, ndsn, false
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ func FindBaliseByMessageSerial(cache *state_proto.TrainBtmCache, isLine12 bool,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bt, dsn, _, _ := FindBaliseByNotSend(cache, isLine12)
|
bt, dsn, _, _ := FindBaliseByNotSend(train)
|
||||||
return bt, dsn, true
|
return bt, dsn, true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
5
third_party/message/train_pc_sim_message.go
vendored
5
third_party/message/train_pc_sim_message.go
vendored
@ -122,7 +122,7 @@ func AtpLowPowerByte(d byte) bool {
|
|||||||
// 列车速度位置报告
|
// 列车速度位置报告
|
||||||
type TrainSpeedPlaceReportMsg struct {
|
type TrainSpeedPlaceReportMsg struct {
|
||||||
PulseCount1 float32
|
PulseCount1 float32
|
||||||
//PulseCount2 float32
|
PulseCount2 float32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tp *TrainSpeedPlaceReportMsg) Encode(runDir uint16, s1, runRange uint32) []byte {
|
func (tp *TrainSpeedPlaceReportMsg) Encode(runDir uint16, s1, runRange uint32) []byte {
|
||||||
@ -255,7 +255,4 @@ const (
|
|||||||
DOOR_MODE_MM
|
DOOR_MODE_MM
|
||||||
_
|
_
|
||||||
NOT_BREAK
|
NOT_BREAK
|
||||||
//aa = 0x2e
|
|
||||||
//bb = 0x2f
|
|
||||||
cc = 0x2d
|
|
||||||
)
|
)
|
||||||
|
4
third_party/semi_physical_train/btm_vobc.go
vendored
4
third_party/semi_physical_train/btm_vobc.go
vendored
@ -164,11 +164,11 @@ func (b *BtmVobcClient) requestFramePackets(requestId string, req *message.BtmVo
|
|||||||
|
|
||||||
if req.FrameStatus == message.REQ_FRAME_STATUS_ERROR {
|
if req.FrameStatus == message.REQ_FRAME_STATUS_ERROR {
|
||||||
//抢答器错误,重新发送
|
//抢答器错误,重新发送
|
||||||
btmState, dsn, _, _ = can_btm.FindBaliseResend(train.BtmBaliseCacheA, false)
|
btmState, dsn, _, _ = can_btm.FindBaliseResend(train)
|
||||||
} else {
|
} else {
|
||||||
//判断 报文序列号与之前发送的 是否一致,不一致
|
//判断 报文序列号与之前发送的 是否一致,不一致
|
||||||
//如果一致返回新的应答器,如果不一致返回之前发送的应答器,如果不一致并且没有找到之前发送的应答器,则返回新应答器
|
//如果一致返回新的应答器,如果不一致返回之前发送的应答器,如果不一致并且没有找到之前发送的应答器,则返回新应答器
|
||||||
btmState, dsn, matcher = can_btm.FindBaliseByMessageSerial(train.BtmBaliseCacheA, false, req.MessageSerial)
|
btmState, dsn, matcher = can_btm.FindBaliseByMessageSerial(train, req.MessageSerial)
|
||||||
if matcher {
|
if matcher {
|
||||||
if btmState != nil {
|
if btmState != nil {
|
||||||
//正常应答
|
//正常应答
|
||||||
|
4
third_party/tcp/tcp_client.go
vendored
4
third_party/tcp/tcp_client.go
vendored
@ -88,7 +88,3 @@ func (c *TcpClient) Send(data []byte) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TcpClient) RemoteInfo() net.Addr {
|
|
||||||
return c.conn.RemoteAddr()
|
|
||||||
}
|
|
||||||
|
4
third_party/third_party.go
vendored
4
third_party/third_party.go
vendored
@ -46,9 +46,7 @@ func GetRunningServiceStates() *state_proto.SimulationThirdPartyApiService {
|
|||||||
trueServices := tpas.FindAppendApiService()
|
trueServices := tpas.FindAppendApiService()
|
||||||
if trueServices != nil && len(trueServices) > 0 {
|
if trueServices != nil && len(trueServices) > 0 {
|
||||||
for _, trueService := range trueServices {
|
for _, trueService := range trueServices {
|
||||||
if trueService != nil {
|
collectServiceState(ss, trueService)
|
||||||
collectServiceState(ss, trueService)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package train_pc_sim
|
package train_pc_sim
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"joylink.club/bj-rtsts-server/dto/state_proto"
|
"joylink.club/bj-rtsts-server/dto/state_proto"
|
||||||
"joylink.club/bj-rtsts-server/third_party/message"
|
"joylink.club/bj-rtsts-server/third_party/message"
|
||||||
"joylink.club/bj-rtsts-server/third_party/tcp"
|
"joylink.club/bj-rtsts-server/third_party/tcp"
|
||||||
@ -14,11 +13,10 @@ type TrainPcReciverData struct {
|
|||||||
clientKey string
|
clientKey string
|
||||||
tcpClient *tcp.TcpClient
|
tcpClient *tcp.TcpClient
|
||||||
pcSimManage TrainPcSimManage
|
pcSimManage TrainPcSimManage
|
||||||
state tpapi.ThirdPartyApiServiceState
|
//trainInit bool
|
||||||
speedPlace *message.TrainSpeedPlaceReportMsg
|
state tpapi.ThirdPartyApiServiceState
|
||||||
train *state_proto.TrainState
|
speedPlace *message.TrainSpeedPlaceReportMsg
|
||||||
success bool
|
train *state_proto.TrainState
|
||||||
aPort bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rd *TrainPcReciverData) Name() string {
|
func (rd *TrainPcReciverData) Name() string {
|
||||||
@ -37,19 +35,17 @@ func (d *TrainPcReciverData) readError(err error) {
|
|||||||
slog.Error("连接车载pc仿真tcp服务断开", err)
|
slog.Error("连接车载pc仿真tcp服务断开", err)
|
||||||
d.updateState(tpapi.ThirdPartyState_Broken)
|
d.updateState(tpapi.ThirdPartyState_Broken)
|
||||||
d.tcpClient = nil
|
d.tcpClient = nil
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
func (d *TrainPcReciverData) ServiceDesc() string {
|
func (d *TrainPcReciverData) ServiceDesc() string {
|
||||||
if d.aPort {
|
return d.clientKey
|
||||||
return fmt.Sprintf("%v-A端", d.clientKey)
|
|
||||||
} else {
|
|
||||||
return fmt.Sprintf("%v-B端", d.clientKey)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rd *TrainPcReciverData) receiverDataHandle(n int, data []byte) {
|
func (rd *TrainPcReciverData) receiverDataHandle(n int, data []byte) {
|
||||||
|
|
||||||
|
receiveData := data[:n]
|
||||||
|
|
||||||
|
trainPcMsgs := message.TrainPcSimDecode(receiveData)
|
||||||
train := rd.train
|
train := rd.train
|
||||||
//vs := train.VobcState
|
|
||||||
if train == nil {
|
if train == nil {
|
||||||
slog.Error("车载输出数字量,未找到连接车载pc仿真的列车")
|
slog.Error("车载输出数字量,未找到连接车载pc仿真的列车")
|
||||||
return
|
return
|
||||||
@ -58,20 +54,15 @@ func (rd *TrainPcReciverData) receiverDataHandle(n int, data []byte) {
|
|||||||
slog.Error("车载输出数字量,,列车未连接车载pc仿真")
|
slog.Error("车载输出数字量,,列车未连接车载pc仿真")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//a := rd.tcpClient.RemoteInfo()
|
//hexSourceData := hex.EncodeToString(receiveData)
|
||||||
//slog.Info(fmt.Sprintf("nw:%v ,add:%v", a.Network(), a.String()), rd.aPort)
|
//slog.Info(fmt.Sprintf("接受列车激活端:%v pc仿真接收数据:%v", rd.clientKey, hexSourceData))
|
||||||
//slog.Info(fmt.Sprintf("接受atp信息 列车:%v 列车端口:%v ,钥匙1:%v,钥匙2:%v", train.Id, rd.aPort, train.VobcState.Tc1Active, train.VobcState.Tc2Active))
|
|
||||||
receiveData := data[:n]
|
|
||||||
trainPcMsgs := message.TrainPcSimDecode(receiveData)
|
|
||||||
|
|
||||||
for _, baseMsg := range trainPcMsgs {
|
for _, baseMsg := range trainPcMsgs {
|
||||||
|
//slog.Info(fmt.Sprintf("pc仿真接收数据:%v,类型:%X", hexSourceData, baseMsg.Type))
|
||||||
switch baseMsg.Type {
|
switch baseMsg.Type {
|
||||||
//case RECIVE_TRAIN_CREATE_REMOVE:
|
//case RECIVE_TRAIN_CREATE_REMOVE:
|
||||||
// pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
|
// pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
|
||||||
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR:
|
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR:
|
||||||
|
rd.pcSimManage.TrainPcSimDigitalOutInfoHandle(train, baseMsg.Data)
|
||||||
rd.pcSimManage.TrainPcSimDigitalOutInfoHandle(rd.aPort, rd.tcpClient, train, baseMsg.Data)
|
|
||||||
|
|
||||||
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR_BACK:
|
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR_BACK:
|
||||||
rd.pcSimManage.TrainPcSimDigitalReportHandle(train, baseMsg.Data)
|
rd.pcSimManage.TrainPcSimDigitalReportHandle(train, baseMsg.Data)
|
||||||
|
277
third_party/train_pc_sim/train_pc_sim.go
vendored
277
third_party/train_pc_sim/train_pc_sim.go
vendored
@ -16,10 +16,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
//type TrainControlEvent struct {
|
type TrainControlEvent struct {
|
||||||
// Type byte
|
Type byte
|
||||||
// Data []byte
|
Data []byte
|
||||||
//}
|
}
|
||||||
|
|
||||||
//var FireTrainControlEventType = ecs.NewEventType[TrainControlEvent]()
|
//var FireTrainControlEventType = ecs.NewEventType[TrainControlEvent]()
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ type TrainPcSim interface {
|
|||||||
//发布列车控制的相关事件
|
//发布列车控制的相关事件
|
||||||
//PublishTrainControlEvent(train *state_proto.TrainState, events []TrainControlEvent)
|
//PublishTrainControlEvent(train *state_proto.TrainState, events []TrainControlEvent)
|
||||||
|
|
||||||
SendTrainControlMsg(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage, aport bool)
|
SendTrainControlMsg(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage)
|
||||||
// CreateOrRemoveSpeedPLace 创建或删除速度位置信息
|
// CreateOrRemoveSpeedPLace 创建或删除速度位置信息
|
||||||
//CreateOrRemoveSpeedPLace(train *state_proto.TrainState)
|
//CreateOrRemoveSpeedPLace(train *state_proto.TrainState)
|
||||||
// CreateOrRemoveTrain 创建或删除列车
|
// CreateOrRemoveTrain 创建或删除列车
|
||||||
@ -57,7 +57,7 @@ type TrainPcSimManage interface {
|
|||||||
//获取列车模拟量数据
|
//获取列车模拟量数据
|
||||||
ObtainTrainDigitalMockData(train *state_proto.TrainState) []message.TrainPcSimBaseMessage
|
ObtainTrainDigitalMockData(train *state_proto.TrainState) []message.TrainPcSimBaseMessage
|
||||||
// TrainPcSimDigitalOutInfoHandle 4.4.1. 车载输出数字量信息报文内容
|
// TrainPcSimDigitalOutInfoHandle 4.4.1. 车载输出数字量信息报文内容
|
||||||
TrainPcSimDigitalOutInfoHandle(aport bool, client *tcp.TcpClient, train *state_proto.TrainState, data []byte) bool
|
TrainPcSimDigitalOutInfoHandle(train *state_proto.TrainState, data []byte)
|
||||||
// TrainPcSimDigitalReportHandle 4.4.2. 车载输出数字反馈量信息报文内容
|
// TrainPcSimDigitalReportHandle 4.4.2. 车载输出数字反馈量信息报文内容
|
||||||
TrainPcSimDigitalReportHandle(train *state_proto.TrainState, data []byte)
|
TrainPcSimDigitalReportHandle(train *state_proto.TrainState, data []byte)
|
||||||
FindConnTrain(ct state_proto.TrainConnState_TrainConnType) *state_proto.TrainState
|
FindConnTrain(ct state_proto.TrainConnState_TrainConnType) *state_proto.TrainState
|
||||||
@ -70,15 +70,12 @@ type TrainPcSimManage interface {
|
|||||||
TrainBtmQuery2(train *state_proto.TrainState, data []byte)
|
TrainBtmQuery2(train *state_proto.TrainState, data []byte)
|
||||||
}
|
}
|
||||||
type trainPcSimService struct {
|
type trainPcSimService struct {
|
||||||
state tpapi.ThirdPartyApiServiceState
|
state tpapi.ThirdPartyApiServiceState
|
||||||
//newPcSimclientMap map[string]*TrainPcReciverData
|
newPcSimclientMap map[string]*TrainPcReciverData
|
||||||
|
cancleContextFun context.CancelFunc
|
||||||
newPcSimclientMap3 map[string][]*TrainPcReciverData
|
context context.Context
|
||||||
|
trainPcSimManage TrainPcSimManage
|
||||||
cancleContextFun context.CancelFunc
|
configs []config.VehiclePCSimConfig
|
||||||
context context.Context
|
|
||||||
trainPcSimManage TrainPcSimManage
|
|
||||||
configs []config.VehiclePCSimConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -116,40 +113,17 @@ func (d *trainPcSimService) ServiceDesc() string {
|
|||||||
func FindTrainPcSimClientKey2(t *state_proto.TrainState) string {
|
func FindTrainPcSimClientKey2(t *state_proto.TrainState) string {
|
||||||
return t.ConnState.TypeName
|
return t.ConnState.TypeName
|
||||||
}
|
}
|
||||||
func (d *trainPcSimService) findTrainConnForPort(sta *state_proto.TrainState, aport bool) (*TrainPcReciverData, error) {
|
|
||||||
rds := d.newPcSimclientMap3[sta.ConnState.TypeName]
|
|
||||||
if rds == nil {
|
|
||||||
return nil, fmt.Errorf("")
|
|
||||||
}
|
|
||||||
for _, rd := range rds {
|
|
||||||
if rd.aPort == aport {
|
|
||||||
return rd, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("")
|
|
||||||
}
|
|
||||||
func (d *trainPcSimService) findTrainConn(sta *state_proto.TrainState) (*TrainPcReciverData, error) {
|
func (d *trainPcSimService) findTrainConn(sta *state_proto.TrainState) (*TrainPcReciverData, error) {
|
||||||
rds := d.newPcSimclientMap3[sta.ConnState.TypeName]
|
trainPcReciver := d.newPcSimclientMap[sta.ConnState.TypeName]
|
||||||
if rds == nil {
|
if trainPcReciver == nil {
|
||||||
return nil, fmt.Errorf("")
|
return nil, fmt.Errorf("")
|
||||||
}
|
}
|
||||||
if sta.VobcState.Tc1Active {
|
return trainPcReciver, nil
|
||||||
return rds[0], nil
|
|
||||||
} else {
|
|
||||||
return rds[1], nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
func (d *trainPcSimService) findTrainAllConn(sta *state_proto.TrainState) []*TrainPcReciverData {
|
|
||||||
rds := d.newPcSimclientMap3[sta.ConnState.TypeName]
|
|
||||||
return rds
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *trainPcSimService) findAllThirdPartState() []tpapi.ThirdPartyApiService {
|
func (d *trainPcSimService) findAllThirdPartState() []tpapi.ThirdPartyApiService {
|
||||||
services := make([]tpapi.ThirdPartyApiService, 0)
|
services := make([]tpapi.ThirdPartyApiService, 0)
|
||||||
for _, data := range d.newPcSimclientMap3 {
|
for _, data := range d.newPcSimclientMap {
|
||||||
for _, rd := range data {
|
services = append(services, data)
|
||||||
services = append(services, rd)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return services
|
return services
|
||||||
}
|
}
|
||||||
@ -187,12 +161,10 @@ func (d *trainPcSimService) TrainPluseCount(sta *state_proto.TrainState, h1, h2,
|
|||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
if sd, err := d.findTrainConn(sta); err == nil {
|
||||||
for _, sd := range d.findTrainAllConn(sta) {
|
sd.speedPlace.PulseCount1 += sta.DynamicState.Displacement
|
||||||
if sd.speedPlace != nil {
|
//sd.speedPlace.PulseCount1 += float32(uint32(h1 * 10))
|
||||||
|
sd.speedPlace.PulseCount2 = sd.speedPlace.PulseCount1
|
||||||
sd.speedPlace.PulseCount1 += sta.DynamicState.Displacement
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if sta.TrainRunUp {
|
if sta.TrainRunUp {
|
||||||
if sta.TrainEndsA.SpeedSensorEnableA {
|
if sta.TrainEndsA.SpeedSensorEnableA {
|
||||||
@ -230,22 +202,15 @@ func (d *trainPcSimService) newCloseAllConn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *trainPcSimService) newCloseConn(clientKey string) {
|
func (d *trainPcSimService) newCloseConn(clientKey string) {
|
||||||
rds := d.newPcSimclientMap3[clientKey]
|
rd := d.newPcSimclientMap[clientKey]
|
||||||
if rds != nil {
|
|
||||||
for _, rd := range rds {
|
|
||||||
rd.tcpClient.Close()
|
|
||||||
rd.tcpClient = nil
|
|
||||||
rd.train = nil
|
|
||||||
rd.speedPlace = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*rd := d.newPcSimclientMap[clientKey]
|
|
||||||
if rd != nil {
|
if rd != nil {
|
||||||
rd.tcpClient.Close()
|
rd.tcpClient.Close()
|
||||||
rd.tcpClient = nil
|
rd.tcpClient = nil
|
||||||
rd.train = nil
|
rd.train = nil
|
||||||
rd.speedPlace = nil
|
rd.speedPlace = nil
|
||||||
}*/
|
//rd.trainInit = false
|
||||||
|
//d.cancleContextFun()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *trainPcSimService) findConfig(configName string) (*config.VehiclePCSimConfig, error) {
|
func (d *trainPcSimService) findConfig(configName string) (*config.VehiclePCSimConfig, error) {
|
||||||
@ -258,47 +223,30 @@ func (d *trainPcSimService) findConfig(configName string) (*config.VehiclePCSimC
|
|||||||
return nil, fmt.Errorf("未找到对应的车载pc连接配置")
|
return nil, fmt.Errorf("未找到对应的车载pc连接配置")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *trainPcSimService) initConn2(clientKey string) error {
|
func (d *trainPcSimService) initConn(clientKey string) error {
|
||||||
|
|
||||||
rds := d.newPcSimclientMap3[clientKey]
|
rd := d.newPcSimclientMap[clientKey]
|
||||||
rd1 := rds[0]
|
|
||||||
rd2 := rds[1]
|
|
||||||
cfg, cfgErr := d.findConfig(clientKey)
|
|
||||||
if cfgErr != nil {
|
|
||||||
return sys_error.New(fmt.Sprintf("没找到对应的配置信息 key:%v", clientKey), cfgErr)
|
|
||||||
}
|
|
||||||
if !cfg.OpenB && !cfg.OpenA {
|
|
||||||
return sys_error.New(fmt.Sprintf("配置:%v A,B端配置均为打开", clientKey))
|
|
||||||
}
|
|
||||||
e1 := d.connServer(cfg.OpenA, cfg.APcSimIp, cfg.APcSimPort, rd1)
|
|
||||||
if e1 != nil {
|
|
||||||
return sys_error.New(fmt.Sprintf("配置:%v 端口A连接失败", clientKey))
|
|
||||||
}
|
|
||||||
e2 := d.connServer(cfg.OpenB, cfg.BPcSimIp, cfg.BPcSimPort, rd2)
|
|
||||||
if e2 != nil {
|
|
||||||
return sys_error.New(fmt.Sprintf("配置:%v 端口B连接失败", clientKey))
|
|
||||||
}
|
|
||||||
rd1.aPort = true
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *trainPcSimService) connServer(open bool, ip string, port uint32, rd *TrainPcReciverData) *sys_error.BusinessError {
|
|
||||||
if rd != nil && rd.tcpClient != nil && rd.tcpClient.IsConning() {
|
if rd != nil && rd.tcpClient != nil && rd.tcpClient.IsConning() {
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
|
//rd.trainInit = false
|
||||||
rd.tcpClient = nil
|
rd.tcpClient = nil
|
||||||
}
|
}
|
||||||
if !open {
|
cfg, cfgErr := d.findConfig(clientKey)
|
||||||
rd.success = false
|
if cfgErr != nil {
|
||||||
return nil
|
errMsg := fmt.Sprintf("没找到对应的配置信息 key:%v", clientKey)
|
||||||
|
//slog.Error(errMsg, cfgErr.Error())
|
||||||
|
rd.updateState(tpapi.ThirdPartyState_Broken)
|
||||||
|
return sys_error.New(errMsg, cfgErr)
|
||||||
}
|
}
|
||||||
addr := fmt.Sprintf("%v:%v", ip, port)
|
addr := fmt.Sprintf("%v:%v", cfg.PcSimIp, cfg.PcSimPort)
|
||||||
//slog.Info(addr, "连接.,...")
|
|
||||||
client2, err := tcp.StartTcpClient(addr, rd.receiverDataHandle, rd.readError)
|
client2, err := tcp.StartTcpClient(addr, rd.receiverDataHandle, rd.readError)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
connErrMsg := fmt.Sprintf("车载pc连接失败 clientKey:%v", clientKey)
|
||||||
|
//slog.Error(connErrMsg, err.Error())
|
||||||
rd.updateState(tpapi.ThirdPartyState_Broken)
|
rd.updateState(tpapi.ThirdPartyState_Broken)
|
||||||
|
return sys_error.New(connErrMsg, err)
|
||||||
} else {
|
} else {
|
||||||
rd.success = true
|
|
||||||
rd.tcpClient = client2
|
rd.tcpClient = client2
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -307,8 +255,7 @@ func (d *trainPcSimService) connServer(open bool, ip string, port uint32, rd *Tr
|
|||||||
func (d *trainPcSimService) Start(pcSimManage TrainPcSimManage) {
|
func (d *trainPcSimService) Start(pcSimManage TrainPcSimManage) {
|
||||||
|
|
||||||
configs := pcSimManage.GetTrainPcSimConfig()
|
configs := pcSimManage.GetTrainPcSimConfig()
|
||||||
//d.newPcSimclientMap = make(map[string]*TrainPcReciverData)
|
d.newPcSimclientMap = make(map[string]*TrainPcReciverData)
|
||||||
d.newPcSimclientMap3 = make(map[string][]*TrainPcReciverData)
|
|
||||||
if len(configs) <= 0 {
|
if len(configs) <= 0 {
|
||||||
slog.Info("车载pc仿真配置未开启")
|
slog.Info("车载pc仿真配置未开启")
|
||||||
return
|
return
|
||||||
@ -319,16 +266,9 @@ func (d *trainPcSimService) Start(pcSimManage TrainPcSimManage) {
|
|||||||
closedCount++
|
closedCount++
|
||||||
} else {
|
} else {
|
||||||
ck := c.ConfigName
|
ck := c.ConfigName
|
||||||
pcReceivers := make([]*TrainPcReciverData, 2)
|
pcReciver := &TrainPcReciverData{clientKey: ck, pcSimManage: pcSimManage}
|
||||||
for i := 0; i < 2; i++ {
|
pcReciver.updateState(tpapi.ThirdPartyState_Closed)
|
||||||
ss := fmt.Sprintf("%v%v", c.ConfigName, i)
|
d.newPcSimclientMap[ck] = pcReciver
|
||||||
pcReciver := &TrainPcReciverData{clientKey: ss, pcSimManage: pcSimManage}
|
|
||||||
pcReciver.updateState(tpapi.ThirdPartyState_Closed)
|
|
||||||
pcReceivers[i] = pcReciver
|
|
||||||
}
|
|
||||||
d.newPcSimclientMap3[ck] = pcReceivers
|
|
||||||
//d.newPcSimclientMap[ck] = pcReciver
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if closedCount == len(configs) {
|
if closedCount == len(configs) {
|
||||||
@ -345,11 +285,8 @@ func (d *trainPcSimService) Start(pcSimManage TrainPcSimManage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *trainPcSimService) Stop() {
|
func (d *trainPcSimService) Stop() {
|
||||||
|
for _, data := range d.newPcSimclientMap {
|
||||||
for _, rds := range d.newPcSimclientMap3 {
|
data.updateState(tpapi.ThirdPartyState_Closed)
|
||||||
for _, rd := range rds {
|
|
||||||
rd.updateState(tpapi.ThirdPartyState_Closed)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if d.cancleContextFun != nil {
|
if d.cancleContextFun != nil {
|
||||||
d.cancleContextFun()
|
d.cancleContextFun()
|
||||||
@ -360,7 +297,7 @@ func (d *trainPcSimService) Stop() {
|
|||||||
|
|
||||||
func (d *trainPcSimService) CreateOrRemoveTrain(train *state_proto.TrainState, isCreate bool) error {
|
func (d *trainPcSimService) CreateOrRemoveTrain(train *state_proto.TrainState, isCreate bool) error {
|
||||||
clientKey := FindTrainPcSimClientKey2(train)
|
clientKey := FindTrainPcSimClientKey2(train)
|
||||||
err := d.initConn2(clientKey)
|
err := d.initConn(clientKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.newCloseConn(clientKey)
|
d.newCloseConn(clientKey)
|
||||||
return err
|
return err
|
||||||
@ -370,23 +307,16 @@ func (d *trainPcSimService) CreateOrRemoveTrain(train *state_proto.TrainState, i
|
|||||||
data[0] = message.FLAG_CAMMAND_CREATE_TRAIN
|
data[0] = message.FLAG_CAMMAND_CREATE_TRAIN
|
||||||
}
|
}
|
||||||
msg := &message.TrainPcSimBaseMessage{Data: data, Type: message.RECIVE_TRAIN_CREATE_REMOVE}
|
msg := &message.TrainPcSimBaseMessage{Data: data, Type: message.RECIVE_TRAIN_CREATE_REMOVE}
|
||||||
rds := d.newPcSimclientMap3[clientKey]
|
rd := d.newPcSimclientMap[clientKey]
|
||||||
if rds != nil {
|
if rd != nil {
|
||||||
for index, rd := range rds {
|
initTrainErr := d.initTrain(rd, train, isCreate, msg)
|
||||||
if rd != nil && rd.success {
|
if !isCreate {
|
||||||
slog.Info(fmt.Sprintf("index%v---rd client:%v clientnil :%v", index, rd.tcpClient, rd.tcpClient == nil))
|
d.newCloseConn(clientKey)
|
||||||
initTrainErr := d.initTrain(rd, train, isCreate, msg)
|
}
|
||||||
if !isCreate {
|
if initTrainErr != nil {
|
||||||
d.newCloseConn(clientKey)
|
return initTrainErr
|
||||||
}
|
|
||||||
if initTrainErr != nil {
|
|
||||||
return initTrainErr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (d *trainPcSimService) initTrain(rd *TrainPcReciverData, train *state_proto.TrainState, isCreate bool, trains *message.TrainPcSimBaseMessage) error {
|
func (d *trainPcSimService) initTrain(rd *TrainPcReciverData, train *state_proto.TrainState, isCreate bool, trains *message.TrainPcSimBaseMessage) error {
|
||||||
@ -396,21 +326,17 @@ func (d *trainPcSimService) initTrain(rd *TrainPcReciverData, train *state_proto
|
|||||||
train.PluseCount = &state_proto.SensorSpeedPulseCount{}
|
train.PluseCount = &state_proto.SensorSpeedPulseCount{}
|
||||||
rd.train = train
|
rd.train = train
|
||||||
tcc := train.Tcc
|
tcc := train.Tcc
|
||||||
tcc.LineInitTimeStamp12PortA = 0
|
tcc.LineInitTimeStamp12 = 0
|
||||||
tcc.LineInitTimeStamp12PortB = 0
|
tcc.Line12ConnErr = false
|
||||||
tcc.Line12ConnErrPortA = false
|
|
||||||
tcc.Line12ConnErrPortB = false
|
|
||||||
//tcc.LineInitTimeStamp12 = 0
|
|
||||||
//tcc.Line12ConnErr = false
|
|
||||||
if isCreate {
|
if isCreate {
|
||||||
tmpMsgs := d.trainPcSimManage.ObtainTrainDigitalMockData(train)
|
tmpMsgs := d.trainPcSimManage.ObtainTrainDigitalMockData(train)
|
||||||
msgs = append(msgs, tmpMsgs...)
|
msgs = append(msgs, tmpMsgs...)
|
||||||
msgs = append(msgs, message.TrainPcSimBaseMessage{Data: []byte{0x00}, Type: message.RECIVE_TRAIN_DOOR_MODE}) //门模式
|
msgs = append(msgs, message.TrainPcSimBaseMessage{Data: []byte{0x00}, Type: message.RECIVE_TRAIN_DOOR_MODE}) //门模式
|
||||||
msgs = append(msgs, message.TrainPcSimBaseMessage{Data: []byte{}, Type: message.RECIVE_TRAIN_BTN_CLEAR_ALL_PRE_DATA}) //清空应答器
|
msgs = append(msgs, message.TrainPcSimBaseMessage{Data: []byte{}, Type: message.RECIVE_TRAIN_BTN_CLEAR_ALL_PRE_DATA}) //清空应答器
|
||||||
msgs = append(msgs, message.TrainPcSimBaseMessage{Data: []byte{}, Type: message.SENDER_TRAIN_TC_ACTIVE}) //清空应答器
|
|
||||||
} else {
|
} else {
|
||||||
train.VobcState.Tc1Active = false
|
train.VobcState.Tc1Active = false
|
||||||
train.VobcState.Tc2Active = false
|
train.VobcState.Tc2Active = false
|
||||||
|
|
||||||
for _, key := range tcc.DriverKey {
|
for _, key := range tcc.DriverKey {
|
||||||
key.Val = false
|
key.Val = false
|
||||||
}
|
}
|
||||||
@ -431,52 +357,47 @@ func (d *trainPcSimService) initTrain(rd *TrainPcReciverData, train *state_proto
|
|||||||
|
|
||||||
// 依据文档80ms发送列车速度位置
|
// 依据文档80ms发送列车速度位置
|
||||||
func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
|
func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
|
||||||
for range time.Tick(time.Millisecond * 80) {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
trains := d.trainPcSimManage.GetConnTrain2()
|
trains := d.trainPcSimManage.GetConnTrain2()
|
||||||
for _, train := range trains {
|
for _, train := range trains {
|
||||||
if train.ConnState.Conn && train.PluseCount != nil {
|
if train.ConnState.Conn && train.PluseCount != nil {
|
||||||
trainClients := d.newPcSimclientMap3[train.ConnState.TypeName]
|
trainClient, trainDataErr := d.findTrainConn(train)
|
||||||
for _, trainClient := range trainClients {
|
if trainDataErr != nil {
|
||||||
if trainClient.success {
|
slog.Error(fmt.Sprintf("pc仿真速度位置未找到对应的列车 id:%v", train.Id))
|
||||||
if trainClient.speedPlace == nil || trainClient.tcpClient == nil {
|
continue
|
||||||
slog.Error(fmt.Sprintf("pc仿真速度位置脉冲对象为空 列车id:%v", train.Id))
|
}
|
||||||
continue
|
if trainClient.speedPlace == nil {
|
||||||
}
|
slog.Error(fmt.Sprintf("pc仿真速度位置脉冲对象为空 列车id:%v", train.Id))
|
||||||
connState := tpapi.ThirdPartyState_Normal
|
continue
|
||||||
if trainClient.aPort && train.Tcc.Line12ConnErrPortA {
|
|
||||||
connState = tpapi.ThirdPartyState_Broken
|
|
||||||
} else if trainClient.aPort == false && train.Tcc.Line12ConnErrPortB {
|
|
||||||
connState = tpapi.ThirdPartyState_Broken
|
|
||||||
}
|
|
||||||
/*if train.Tcc.Line12ConnErr {
|
|
||||||
connState = tpapi.ThirdPartyState_Broken
|
|
||||||
}*/
|
|
||||||
trainClient.updateState(connState)
|
|
||||||
s1, speed := d.pluseSpeed(train)
|
|
||||||
runDir := uint16(2)
|
|
||||||
if train.VobcState.DirectionForward {
|
|
||||||
runDir = 1
|
|
||||||
}
|
|
||||||
disPluse := pluseCountSpeed(train.WheelDiameter, trainClient.speedPlace.PulseCount1)
|
|
||||||
data := trainClient.speedPlace.Encode(runDir, s1, disPluse)
|
|
||||||
bm := &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_LOCATION_INFO, Data: data}
|
|
||||||
dataCode := bm.Encode()
|
|
||||||
slog.Info(fmt.Sprintf("发送列车速度位置,列车:%v,A端:%v,列车速度:%v,计数脉冲: %v,累计里程: %v ,发送数据:%v", train.Id, trainClient.aPort, speed, s1, trainClient.speedPlace.PulseCount1, hex.EncodeToString(dataCode)), trainClient.aPort)
|
|
||||||
err := trainClient.tcpClient.Send(dataCode)
|
|
||||||
if err != nil {
|
|
||||||
slog.Error(fmt.Sprintf("发送列车速度位置失败,列车:%v,发送数据:%v", train.Id, hex.EncodeToString(dataCode)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connState := tpapi.ThirdPartyState_Normal
|
||||||
|
if train.Tcc.Line12ConnErr {
|
||||||
|
connState = tpapi.ThirdPartyState_Broken
|
||||||
|
}
|
||||||
|
trainClient.updateState(connState)
|
||||||
|
s1, speed := d.pluseSpeed(train)
|
||||||
|
runDir := uint16(2)
|
||||||
|
if train.VobcState.DirectionForward {
|
||||||
|
runDir = 1
|
||||||
|
}
|
||||||
|
disPluse := pluseCountSpeed(train.WheelDiameter, trainClient.speedPlace.PulseCount1)
|
||||||
|
data := trainClient.speedPlace.Encode(runDir, s1, disPluse)
|
||||||
|
bm := &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_LOCATION_INFO, Data: data}
|
||||||
|
dataCode := bm.Encode()
|
||||||
|
slog.Info(fmt.Sprintf("发送列车速度位置,列车:%v,列车速度:%v,计数脉冲: %v,累计里程: %v ,发送数据:%v", train.Id, speed, s1, trainClient.speedPlace.PulseCount1, hex.EncodeToString(dataCode)))
|
||||||
|
err := trainClient.tcpClient.Send(dataCode)
|
||||||
|
if err != nil {
|
||||||
|
slog.Error(fmt.Sprintf("发送列车速度位置失败,列车:%v,发送数据:%v", train.Id, hex.EncodeToString(dataCode)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
time.Sleep(time.Millisecond * 80)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,30 +408,21 @@ func (d *trainPcSimService) SendDriverActive(train *state_proto.TrainState) {
|
|||||||
slog.Error(fmt.Sprintf("发送驾驶激活,未找到对应的列车连接,列车id:%v", train.Id))
|
slog.Error(fmt.Sprintf("发送驾驶激活,未找到对应的列车连接,列车id:%v", train.Id))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
vobc := train.VobcState
|
vobc := train.VobcState
|
||||||
|
|
||||||
msg := &message.TrainPcSimBaseMessage{}
|
msg := &message.TrainPcSimBaseMessage{}
|
||||||
/*if train.TrainRunUp {
|
if train.TrainRunUp {
|
||||||
if vobc.Tc1Active {
|
if vobc.Tc1Active {
|
||||||
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
|
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
|
||||||
} else if vobc.Tc1Active == false {
|
} else if vobc.Tc1Active == false {
|
||||||
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
|
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
|
||||||
}
|
}
|
||||||
} else if !train.TrainRunUp {
|
} else if !train.TrainRunUp {
|
||||||
if vobc.Tc1Active {
|
|
||||||
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
|
|
||||||
} else if vobc.Tc1Active == false {
|
|
||||||
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
if trainClient.aPort {
|
|
||||||
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
|
|
||||||
if vobc.Tc1Active {
|
|
||||||
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
|
|
||||||
if vobc.Tc2Active {
|
if vobc.Tc2Active {
|
||||||
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
|
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
|
||||||
|
} else if vobc.Tc2Active == false {
|
||||||
|
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msgs := make([]byte, 0)
|
msgs := make([]byte, 0)
|
||||||
@ -523,7 +435,7 @@ func (d *trainPcSimService) SendDriverActive(train *state_proto.TrainState) {
|
|||||||
}
|
}
|
||||||
msgs = append(msgs, msg.Encode()...)
|
msgs = append(msgs, msg.Encode()...)
|
||||||
hexData := hex.EncodeToString(msgs)
|
hexData := hex.EncodeToString(msgs)
|
||||||
slog.Info(fmt.Sprintf("发送驾驶激活列车id:%v,数据:%v", train.Id, hexData), trainClient.aPort)
|
//slog.Info(fmt.Sprintf("发送驾驶激活列车id:%v,数据:%v", train.Id, hexData))
|
||||||
err := trainClient.tcpClient.Send(msgs)
|
err := trainClient.tcpClient.Send(msgs)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -617,12 +529,11 @@ func (d *trainPcSimService) SendBaliseData(train *state_proto.TrainState, msgTyp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *trainPcSimService) SendTrainControlMsg(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage, aport bool) {
|
func (d *trainPcSimService) SendTrainControlMsg(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage) {
|
||||||
if len(baseMessage) <= 0 {
|
if len(baseMessage) <= 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//trainClient, trainDataErr := d.findTrainConn(train)
|
trainClient, trainDataErr := d.findTrainConn(train)
|
||||||
trainClient, trainDataErr := d.findTrainConnForPort(train, aport)
|
|
||||||
if trainDataErr != nil {
|
if trainDataErr != nil {
|
||||||
slog.Error(fmt.Sprintf("发送列车控制信息失败,无连接,列车Id:%v", train.Id))
|
slog.Error(fmt.Sprintf("发送列车控制信息失败,无连接,列车Id:%v", train.Id))
|
||||||
return
|
return
|
||||||
@ -630,7 +541,7 @@ func (d *trainPcSimService) SendTrainControlMsg(train *state_proto.TrainState, b
|
|||||||
|
|
||||||
for _, msg := range baseMessage {
|
for _, msg := range baseMessage {
|
||||||
dd := msg.Encode()
|
dd := msg.Encode()
|
||||||
slog.Info(fmt.Sprintf("发送操控列车控制信息:%x", dd), aport)
|
//slog.Info(fmt.Sprintf("发送列车控制信息:%x", dd))
|
||||||
d.sendData(trainClient.tcpClient, dd)
|
d.sendData(trainClient.tcpClient, dd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,6 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
|
|||||||
calctailOffset := calcTrailTailOffset(loffset, status.TrainLength, up)
|
calctailOffset := calcTrailTailOffset(loffset, status.TrainLength, up)
|
||||||
// 车尾位置
|
// 车尾位置
|
||||||
tailLink, tailDeviceId, tailDevicePort, tailLOffset, tailDeviceOffset, _, e1 := CalcInitializeLink(vs, linkId, calctailOffset, up)
|
tailLink, tailDeviceId, tailDevicePort, tailLOffset, tailDeviceOffset, _, e1 := CalcInitializeLink(vs, linkId, calctailOffset, up)
|
||||||
|
|
||||||
if e1 != nil {
|
if e1 != nil {
|
||||||
panic(sys_error.New("添加列车失败,列车车尾占用位置计算出错", e1))
|
panic(sys_error.New("添加列车失败,列车车尾占用位置计算出错", e1))
|
||||||
}
|
}
|
||||||
@ -96,8 +95,7 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
|
|||||||
status.TailDeviceId = vs.GetComIdByUid(tailDeviceId)
|
status.TailDeviceId = vs.GetComIdByUid(tailDeviceId)
|
||||||
status.TailOffset = tailDeviceOffset
|
status.TailOffset = tailDeviceOffset
|
||||||
status.TailDevicePort = tailDevicePort
|
status.TailDevicePort = tailDevicePort
|
||||||
status.BtmBaliseCacheA = &state_proto.TrainBtmCache{BaliseList: make([]*state_proto.BTMState, 3)}
|
status.BtmBaliseCache = &state_proto.TrainBtmCache{BaliseList: make([]*state_proto.BTMState, 3)}
|
||||||
status.BtmBaliseCacheB = &state_proto.TrainBtmCache{BaliseList: make([]*state_proto.BTMState, 3)}
|
|
||||||
|
|
||||||
//初始化列车参数状态
|
//初始化列车参数状态
|
||||||
createOrUpdateStateDynamicConfig(status, configTrainData, trainEndsA, trainEndsB)
|
createOrUpdateStateDynamicConfig(status, configTrainData, trainEndsA, trainEndsB)
|
||||||
@ -170,10 +168,7 @@ func TrainConnTypeUpdate(vs *VerifySimulation, ct *dto.TrainConnThirdDto) {
|
|||||||
train.ConnState.ConnType = ct.ConnType
|
train.ConnState.ConnType = ct.ConnType
|
||||||
train.ConnState.TypeName = ct.TypeName
|
train.ConnState.TypeName = ct.TypeName
|
||||||
if ct.ConnType == state_proto.TrainConnState_PC_SIM {
|
if ct.ConnType == state_proto.TrainConnState_PC_SIM {
|
||||||
//train.Tcc.LineInitTimeStamp12 = 0
|
train.Tcc.LineInitTimeStamp12 = 0
|
||||||
train.Tcc.LineInitTimeStamp12PortA = 0
|
|
||||||
train.Tcc.LineInitTimeStamp12PortB = 0
|
|
||||||
|
|
||||||
err := TrainPcSimConnOrRemoveHandle(train, true)
|
err := TrainPcSimConnOrRemoveHandle(train, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
train.ConnState.Conn = false
|
train.ConnState.Conn = false
|
||||||
@ -329,8 +324,6 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
|
|||||||
//calctailOffset := calcTrailTailOffset(outLinkOffset, int64(info.Len), info.Up)
|
//calctailOffset := calcTrailTailOffset(outLinkOffset, int64(info.Len), info.Up)
|
||||||
calctailOffset := calcTrailTailOffset(outLinkOffset, int64(info.Len), trainHeadActUp)
|
calctailOffset := calcTrailTailOffset(outLinkOffset, int64(info.Len), trainHeadActUp)
|
||||||
tailLinkId, tailDeviceId, tailDevicePort, tailLinkOffset, tailOffset, _, e2 := CalcInitializeLink(vs, outLinkId, calctailOffset, !info.Up)
|
tailLinkId, tailDeviceId, tailDevicePort, tailLinkOffset, tailOffset, _, e2 := CalcInitializeLink(vs, outLinkId, calctailOffset, !info.Up)
|
||||||
|
|
||||||
tailUp, _ := QueryUpAndABByDevice(vs.Repo, tailDeviceId, tailDevicePort, sta.TrainRunUp)
|
|
||||||
if e2 != nil {
|
if e2 != nil {
|
||||||
panic(sys_error.New("动力学传输数据:列车车尾位置计算出错", e2))
|
panic(sys_error.New("动力学传输数据:列车车尾位置计算出错", e2))
|
||||||
}
|
}
|
||||||
@ -343,12 +336,8 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
|
|||||||
sta.OldLinkOffset = outLinkOffset
|
sta.OldLinkOffset = outLinkOffset
|
||||||
sta.OldLink = outLinkId
|
sta.OldLink = outLinkId
|
||||||
}
|
}
|
||||||
if sta.OldTailLinkOffset == 0 {
|
|
||||||
sta.OldTailLinkOffset = tailLinkOffset
|
|
||||||
sta.OldTailLink = tailLinkId
|
|
||||||
}
|
|
||||||
|
|
||||||
updateTrainBtmPosition(vs, info, sta, outLinkId, outLinkOffset, tailUp, tailLinkId, tailLinkOffset)
|
updateTrainBtmPosition(vs, info, sta, outLinkId, outLinkOffset)
|
||||||
//slog.Info(fmt.Sprintf("动力学,当前速度(米/秒):%v,加速度:%v,位移距离:%v", info.Speed, info.Acceleration, info.Displacement))
|
//slog.Info(fmt.Sprintf("动力学,当前速度(米/秒):%v,加速度:%v,位移距离:%v", info.Speed, info.Acceleration, info.Displacement))
|
||||||
if sta.OldLink != outLinkId {
|
if sta.OldLink != outLinkId {
|
||||||
sta.OldLink = outLinkId
|
sta.OldLink = outLinkId
|
||||||
@ -410,25 +399,34 @@ func updateTrainActiveDirFromDynamic(vs *VerifySimulation, info *message.Dynamic
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 根据列车位置修改列车应答器
|
// 根据列车位置修改列车应答器
|
||||||
func updateTrainBtmPosition(vs *VerifySimulation, info *message.DynamicsTrainInfo, sta *state_proto.TrainState, outLinkId string, outLinkOffset int64, tailUp bool, tailLinkId string, tailLinkOffset int64) {
|
func updateTrainBtmPosition(vs *VerifySimulation, info *message.DynamicsTrainInfo, sta *state_proto.TrainState, outLinkId string, outLinkOffset int64) {
|
||||||
// 更新BTM中列车位置信息
|
// 更新BTM中列车位置信息
|
||||||
//isup := sta.TrainActiveDirection == 1
|
//isup := sta.TrainActiveDirection == 1
|
||||||
can_btm.Default().HandleTrainHeadPositionInfoForTrain(vs.World, sta, &fi.TrainHeadPositionInfo{
|
can_btm.Default().HandleTrainHeadPositionInfoForTrain(vs.World, sta.BtmBaliseCache, &fi.TrainHeadPositionInfo{
|
||||||
TrainId: sta.Id,
|
TrainId: sta.Id,
|
||||||
Up: info.Up,
|
Up: info.Up,
|
||||||
Link: outLinkId,
|
Link: outLinkId,
|
||||||
LinkOffset: outLinkOffset,
|
LinkOffset: outLinkOffset,
|
||||||
Speed: info.Speed,
|
Speed: info.Speed,
|
||||||
Acceleration: info.Acceleration,
|
Acceleration: info.Acceleration,
|
||||||
OldLinkOffset: sta.OldLinkOffset,
|
OldLinkOffset: sta.OldLinkOffset,
|
||||||
OldLink: sta.OldLink,
|
OldLink: sta.OldLink,
|
||||||
TailUp: tailUp,
|
IsLine12: can_btm.IsLine12(sta),
|
||||||
TailLink: tailLinkId,
|
|
||||||
TailLinkOffset: tailLinkOffset,
|
|
||||||
OldTailLink: sta.OldTailLink,
|
|
||||||
OldTailLinkOffset: sta.OldTailLinkOffset,
|
|
||||||
IsLine12: can_btm.IsLine12(sta),
|
|
||||||
})
|
})
|
||||||
|
/*can_btm.Default().HandleTrainHeadPositionInfo(vs.World, sta.VobcBtm, &fi.TrainHeadPositionInfo{
|
||||||
|
TrainId: sta.Id,
|
||||||
|
Up: info.Up,
|
||||||
|
Link: outLinkId,
|
||||||
|
LinkOffset: outLinkOffset,
|
||||||
|
Speed: info.Speed,
|
||||||
|
Acceleration: info.Acceleration,
|
||||||
|
OldLinkOffset: sta.OldLinkOffset,
|
||||||
|
OldLink: sta.OldLink,
|
||||||
|
})*/
|
||||||
|
/* state := can_btm.Default().GetState()
|
||||||
|
if sta.BtmState == nil || sta.BtmState.BaliseId != state.BaliseId {
|
||||||
|
sta.BtmState = &state
|
||||||
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,10 +265,8 @@ func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainIn
|
|||||||
// 更新列车状态
|
// 更新列车状态
|
||||||
trainState := UpdateTrainStateByDynamics(s, trainId, info)
|
trainState := UpdateTrainStateByDynamics(s, trainId, info)
|
||||||
vs := train.VobcState
|
vs := train.VobcState
|
||||||
|
|
||||||
if vs.Ato {
|
if vs.Ato {
|
||||||
|
trainAtoControlTractionAndBrake(train)
|
||||||
trainAtoControlTractionAndBrake(train, true)
|
|
||||||
var msgs []message.TrainPcSimBaseMessage
|
var msgs []message.TrainPcSimBaseMessage
|
||||||
if vs.AtoOpenRightDoor || vs.AtoOpenLeftDoor {
|
if vs.AtoOpenRightDoor || vs.AtoOpenLeftDoor {
|
||||||
btn := train.Tcc.Buttons[KZM]
|
btn := train.Tcc.Buttons[KZM]
|
||||||
@ -283,7 +281,7 @@ func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainIn
|
|||||||
}
|
}
|
||||||
msgs = controlDoorCloseBtn(train.VobcState, true, btn, vs.AtoOpenLeftDoor, false)
|
msgs = controlDoorCloseBtn(train.VobcState, true, btn, vs.AtoOpenLeftDoor, false)
|
||||||
}
|
}
|
||||||
train_pc_sim.Default().SendTrainControlMsg(train, msgs, false)
|
train_pc_sim.Default().SendTrainControlMsg(train, msgs)
|
||||||
|
|
||||||
} else if vs.TractionStatus {
|
} else if vs.TractionStatus {
|
||||||
f := trainTractionPower(train.TrainLoad, train.Tcc.PushHandler.Val, trainState.DynamicState.Speed, train.TrainMaxAcc, train.TrainMaxSpeed)
|
f := trainTractionPower(train.TrainLoad, train.Tcc.PushHandler.Val, trainState.DynamicState.Speed, train.TrainMaxAcc, train.TrainMaxSpeed)
|
||||||
|
@ -12,11 +12,9 @@ import (
|
|||||||
"joylink.club/bj-rtsts-server/third_party/can_btm"
|
"joylink.club/bj-rtsts-server/third_party/can_btm"
|
||||||
"joylink.club/bj-rtsts-server/third_party/electrical_machinery"
|
"joylink.club/bj-rtsts-server/third_party/electrical_machinery"
|
||||||
"joylink.club/bj-rtsts-server/third_party/message"
|
"joylink.club/bj-rtsts-server/third_party/message"
|
||||||
"joylink.club/bj-rtsts-server/third_party/tcp"
|
|
||||||
train_pc_sim "joylink.club/bj-rtsts-server/third_party/train_pc_sim"
|
train_pc_sim "joylink.club/bj-rtsts-server/third_party/train_pc_sim"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -39,16 +37,13 @@ func ControlTrainUpdate(s *VerifySimulation, ct *request_proto.TrainControl) {
|
|||||||
sta := data.(*state_proto.TrainState)
|
sta := data.(*state_proto.TrainState)
|
||||||
vobc := sta.VobcState
|
vobc := sta.VobcState
|
||||||
tcc := sta.Tcc
|
tcc := sta.Tcc
|
||||||
if ct.ControlType != request_proto.TrainControl_DRIVER_KEY_SWITCH && vobc.Tc1Active == false && vobc.Tc2Active == false {
|
|
||||||
panic(sys_error.New("请先上驾驶端钥匙"))
|
|
||||||
}
|
|
||||||
|
|
||||||
var baseMsg []message.TrainPcSimBaseMessage = nil
|
var baseMsg []message.TrainPcSimBaseMessage = nil
|
||||||
if ct.ControlType == request_proto.TrainControl_EMERGENT_BUTTON {
|
if ct.ControlType == request_proto.TrainControl_EMERGENT_BUTTON {
|
||||||
baseMsg = trainControlButton(sta, ct.DeviceId, ct.ControlButton.Active, tccGraphicData)
|
baseMsg = trainControlButton(sta, ct.DeviceId, ct.ControlButton.Active, tccGraphicData)
|
||||||
} else if ct.ControlType == request_proto.TrainControl_DRIVER_KEY_SWITCH {
|
} else if ct.ControlType == request_proto.TrainControl_DRIVER_KEY_SWITCH {
|
||||||
baseMsg = trainControlDriverKey(sta, ct.DriverKey, ct.DeviceId, tccGraphicData)
|
baseMsg = trainControlDriverKey(sta, ct.DriverKey, ct.DeviceId, tccGraphicData)
|
||||||
//train_pc_sim.Default().SendDriverActive(sta)
|
train_pc_sim.Default().SendDriverActive(sta)
|
||||||
} else if ct.ControlType == request_proto.TrainControl_DIRECTION_KEY_SWITCH {
|
} else if ct.ControlType == request_proto.TrainControl_DIRECTION_KEY_SWITCH {
|
||||||
baseMsg = trainControlDirKey(sta.DynamicState.Speed, vobc, tcc, ct.SwitchKey, ct.DeviceId, tccGraphicData)
|
baseMsg = trainControlDirKey(sta.DynamicState.Speed, vobc, tcc, ct.SwitchKey, ct.DeviceId, tccGraphicData)
|
||||||
//此处先注释,根据现场调试情况 2024-4-16
|
//此处先注释,根据现场调试情况 2024-4-16
|
||||||
@ -81,16 +76,7 @@ func ControlTrainUpdate(s *VerifySimulation, ct *request_proto.TrainControl) {
|
|||||||
vobc.TractionForce = 0
|
vobc.TractionForce = 0
|
||||||
}
|
}
|
||||||
if sta.ConnState.Conn && (sta.ConnState.ConnType == state_proto.TrainConnState_PC_SIM) && baseMsg != nil {
|
if sta.ConnState.Conn && (sta.ConnState.ConnType == state_proto.TrainConnState_PC_SIM) && baseMsg != nil {
|
||||||
if sta.TrainPort == state_proto.TrainState_PORT_A {
|
train_pc_sim.Default().SendTrainControlMsg(sta, baseMsg)
|
||||||
train_pc_sim.Default().SendTrainControlMsg(sta, baseMsg, true)
|
|
||||||
} else if sta.TrainPort == state_proto.TrainState_PORT_B {
|
|
||||||
train_pc_sim.Default().SendTrainControlMsg(sta, baseMsg, false)
|
|
||||||
}
|
|
||||||
if vobc.Tc1Active == false && vobc.Tc2Active == false {
|
|
||||||
sta.TrainPort = state_proto.TrainState_PORT_NONE
|
|
||||||
}
|
|
||||||
//train_pc_sim.Default().SendTrainControlMsg(sta, baseMsg, aPort)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +96,10 @@ func trainControlButton(train *state_proto.TrainState, deviceId uint32, active b
|
|||||||
return controlAtpBtn(vobc, active, btn)
|
return controlAtpBtn(vobc, active, btn)
|
||||||
case KZM, KYM: //开左门按钮
|
case KZM, KYM: //开左门按钮
|
||||||
return controlDoorOpenBtn(vobc, active, btn, graphicBtn.Code == KZM, true)
|
return controlDoorOpenBtn(vobc, active, btn, graphicBtn.Code == KZM, true)
|
||||||
|
|
||||||
case GZM, GYM: //关左门按钮
|
case GZM, GYM: //关左门按钮
|
||||||
return controlDoorCloseBtn(vobc, active, btn, graphicBtn.Code == GZM, true)
|
return controlDoorCloseBtn(vobc, active, btn, graphicBtn.Code == GZM, true)
|
||||||
|
|
||||||
case ZF: //折返按钮
|
case ZF: //折返按钮
|
||||||
return controlReverseBtn(vobc, active, btn)
|
return controlReverseBtn(vobc, active, btn)
|
||||||
case QZMYX: //强制门允许
|
case QZMYX: //强制门允许
|
||||||
@ -399,10 +387,8 @@ func trainControlDriverKey(train *state_proto.TrainState, request *request_proto
|
|||||||
tcc := train.Tcc
|
tcc := train.Tcc
|
||||||
if obj.Code == SKQYS1 {
|
if obj.Code == SKQYS1 {
|
||||||
vobc.Tc1Active = request.Val
|
vobc.Tc1Active = request.Val
|
||||||
train.TrainPort = state_proto.TrainState_PORT_A
|
|
||||||
} else if obj.Code == SKQYS2 {
|
} else if obj.Code == SKQYS2 {
|
||||||
vobc.Tc2Active = request.Val
|
vobc.Tc2Active = request.Val
|
||||||
train.TrainPort = state_proto.TrainState_PORT_B
|
|
||||||
}
|
}
|
||||||
if vobc.Tc1Active && vobc.Tc2Active {
|
if vobc.Tc1Active && vobc.Tc2Active {
|
||||||
if obj.Code == SKQYS1 {
|
if obj.Code == SKQYS1 {
|
||||||
@ -424,16 +410,7 @@ func trainControlDriverKey(train *state_proto.TrainState, request *request_proto
|
|||||||
if addNew {
|
if addNew {
|
||||||
tcc.DriverKey = append(tcc.DriverKey, &state_proto.TrainControlState_DriverKeySwitch{Id: deviceId, Val: request.Val})
|
tcc.DriverKey = append(tcc.DriverKey, &state_proto.TrainControlState_DriverKeySwitch{Id: deviceId, Val: request.Val})
|
||||||
}
|
}
|
||||||
tce := make([]message.TrainPcSimBaseMessage, 0)
|
return []message.TrainPcSimBaseMessage{{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.KEY_STATE, message.IsTrue(request.Val)}}}
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.KEY_STATE, message.IsTrue(request.Val)}})
|
|
||||||
if request.Val {
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_TC_ACTIVE})
|
|
||||||
} else {
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_TC_NOT_ACTIVE})
|
|
||||||
}
|
|
||||||
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, message.IsTrue(request.Val)}})
|
|
||||||
|
|
||||||
return tce
|
|
||||||
|
|
||||||
}
|
}
|
||||||
func trainDoorModeChangeHandle(vobc *state_proto.TrainVobcState, tcc *state_proto.TrainControlState, request *request_proto.TrainControl_SwitchKeyChange, deviceId uint32, tccGraphic *data_proto.TccGraphicStorage) []message.TrainPcSimBaseMessage {
|
func trainDoorModeChangeHandle(vobc *state_proto.TrainVobcState, tcc *state_proto.TrainControlState, request *request_proto.TrainControl_SwitchKeyChange, deviceId uint32, tccGraphic *data_proto.TccGraphicStorage) []message.TrainPcSimBaseMessage {
|
||||||
@ -504,7 +481,7 @@ func trainTractionPowerAtoStepLevel(trainLoad int32, speedKM int32, stepLevel in
|
|||||||
f := float64(m) * (acc * (1 - speedM/sp))
|
f := float64(m) * (acc * (1 - speedM/sp))
|
||||||
return int64(f)
|
return int64(f)
|
||||||
}
|
}
|
||||||
func trainAtoControlTractionAndBrake(train *state_proto.TrainState, aport bool) {
|
func trainAtoControlTractionAndBrake(train *state_proto.TrainState) {
|
||||||
vs := train.VobcState
|
vs := train.VobcState
|
||||||
vs.TractionStatus = false
|
vs.TractionStatus = false
|
||||||
vs.TractionForce = 0
|
vs.TractionForce = 0
|
||||||
@ -535,7 +512,7 @@ func trainAtoControlTractionAndBrake(train *state_proto.TrainState, aport bool)
|
|||||||
{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.NOT_BREAK, notBreak}},
|
{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.NOT_BREAK, notBreak}},
|
||||||
}
|
}
|
||||||
slog.Info(fmt.Sprintf("列车 id:%v,ato:%v,AtoLevle:%v,牵引:%v,制动:%v,牵引力:%v,制动力%v", train.Id, vs.Ato, vs.AtoStepLevel, vs.AtoTractionCommandOut, vs.AtoBrakeCommand, vs.TractionForce, vs.BrakeForce))
|
slog.Info(fmt.Sprintf("列车 id:%v,ato:%v,AtoLevle:%v,牵引:%v,制动:%v,牵引力:%v,制动力%v", train.Id, vs.Ato, vs.AtoStepLevel, vs.AtoTractionCommandOut, vs.AtoBrakeCommand, vs.TractionForce, vs.BrakeForce))
|
||||||
train_pc_sim.Default().SendTrainControlMsg(train, msg, aport)
|
train_pc_sim.Default().SendTrainControlMsg(train, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 列车牵引控制
|
// 列车牵引控制
|
||||||
@ -630,26 +607,18 @@ func (s *VerifySimulation) FindConnTrain(ct state_proto.TrainConnState_TrainConn
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 反馈atp输出数字量数据
|
// 反馈atp输出数字量数据
|
||||||
func (s *VerifySimulation) reportTrainMockInitMsg(aport bool, client *tcp.TcpClient, train *state_proto.TrainState, data1, data3 byte) {
|
func (s *VerifySimulation) reportTrainMockInitMsg(train *state_proto.TrainState, data1, data3 byte) {
|
||||||
vobc := train.VobcState
|
vobc := train.VobcState
|
||||||
tcc := train.Tcc
|
tcc := train.Tcc
|
||||||
tce := make([]message.TrainPcSimBaseMessage, 0)
|
tce := make([]message.TrainPcSimBaseMessage, 0)
|
||||||
initTimeStamp := tcc.LineInitTimeStamp12PortA
|
tcc.Line12ConnErr = false
|
||||||
connErr := tcc.Line12ConnErrPortA
|
//initResult := trainInit
|
||||||
initConn := tcc.TrainConnInitComplatePortA
|
|
||||||
if vobc.Tc2Active {
|
|
||||||
initTimeStamp = tcc.LineInitTimeStamp12PortB
|
|
||||||
connErr = tcc.Line12ConnErrPortB
|
|
||||||
initConn = tcc.TrainConnInitComplatePortB
|
|
||||||
}
|
|
||||||
|
|
||||||
//tcc.Line12ConnErr = false
|
|
||||||
if vobc.Tc1Active || vobc.Tc2Active {
|
if vobc.Tc1Active || vobc.Tc2Active {
|
||||||
state := message.GetBit(data1, 3)
|
state := message.GetBit(data1, 3)
|
||||||
if /* vobc.TrainConnInitComplate*/ initConn {
|
//if trainInit {
|
||||||
|
if vobc.TrainConnInitComplate {
|
||||||
if data1 == 0 {
|
if data1 == 0 {
|
||||||
//tcc.Line12ConnErr = true
|
tcc.Line12ConnErr = true
|
||||||
connErr = true
|
|
||||||
}
|
}
|
||||||
if state == 0 {
|
if state == 0 {
|
||||||
jjzdBtn := tcc.Buttons[JJZD]
|
jjzdBtn := tcc.Buttons[JJZD]
|
||||||
@ -661,127 +630,36 @@ func (s *VerifySimulation) reportTrainMockInitMsg(aport bool, client *tcp.TcpCli
|
|||||||
tce = append(tce, ebTce...)
|
tce = append(tce, ebTce...)
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_TRACTION_CUTED, 1}})
|
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_TRACTION_CUTED, 1}})
|
||||||
} else {
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
initConn = true
|
//initResult = false
|
||||||
if initTimeStamp <= 0 {
|
vobc.TrainConnInitComplate = true
|
||||||
initTimeStamp = time.Now().Add(time.Second * 6).Unix()
|
if tcc.LineInitTimeStamp12 <= 0 {
|
||||||
|
tcc.LineInitTimeStamp12 = time.Now().Add(time.Second * 6).Unix()
|
||||||
}
|
}
|
||||||
if initTimeStamp > time.Now().Unix() {
|
if tcc.LineInitTimeStamp12 > time.Now().Unix() {
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
|
||||||
initData := s.ObtainTrainDigitalMockDataForStatus(train)
|
|
||||||
tce = append(tce, initData...)
|
|
||||||
if aport {
|
|
||||||
tcc.ActiveTrainA = true
|
|
||||||
} else {
|
|
||||||
tcc.ActiveTrainB = true
|
|
||||||
}
|
|
||||||
initConn = false
|
|
||||||
}
|
|
||||||
/*if vobc.LineInitTimeStamp12 <= 0 {
|
|
||||||
vobc.LineInitTimeStamp12 = time.Now().Add(time.Second * 6).Unix()
|
|
||||||
}*/
|
|
||||||
/*if tcc.LineInitTimeStamp12 > time.Now().Unix() {
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
||||||
initData := s.ObtainTrainDigitalMockDataForStatus(train)
|
initData := s.ObtainTrainDigitalMockDataForStatus(train)
|
||||||
tce = append(tce, initData...)
|
tce = append(tce, initData...)
|
||||||
|
//initResult = false
|
||||||
vobc.TrainConnInitComplate = false
|
vobc.TrainConnInitComplate = false
|
||||||
}*/
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
if vobc.Tc1Active {
|
|
||||||
tcc.LineInitTimeStamp12PortA = initTimeStamp
|
|
||||||
tcc.Line12ConnErrPortB = connErr
|
|
||||||
tcc.TrainConnInitComplatePortA = initConn
|
|
||||||
} else if vobc.Tc2Active {
|
|
||||||
tcc.LineInitTimeStamp12PortA = initTimeStamp
|
|
||||||
tcc.Line12ConnErrPortB = connErr
|
|
||||||
tcc.TrainConnInitComplatePortB = initConn
|
|
||||||
}
|
|
||||||
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, 1}})
|
|
||||||
//驾驶室激活反馈
|
//驾驶室激活反馈
|
||||||
if message.GetBit(data3, 3) == 0 {
|
if message.GetBit(data3, 3) == 0 {
|
||||||
act := byte(0)
|
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, 1}})
|
||||||
if vobc.Tc1Active || vobc.Tc2Active {
|
|
||||||
act = 1
|
|
||||||
}
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, act}})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_INTEGRITY, 1}})
|
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_INTEGRITY, 1}})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
train_pc_sim.Default().SendTrainControlMsg(train, tce)
|
||||||
//train_pc_sim.Default().SendTrainControlMsg(train, tce)
|
|
||||||
//return initResult
|
//return initResult
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *VerifySimulation) reportTrainMockInitMsg2(aport, act, initConn bool, initTimeStamp int64, train *state_proto.TrainState, data1, data3 byte) (int64, bool, bool, []message.TrainPcSimBaseMessage) {
|
|
||||||
|
|
||||||
tcc := train.Tcc
|
|
||||||
tce := make([]message.TrainPcSimBaseMessage, 0)
|
|
||||||
connErr := false
|
|
||||||
state := message.GetBit(data1, 3)
|
|
||||||
//slog.Info(fmt.Sprintf("act:%v ,t1:%v ,a1 :%v,t2:%v,a2:%v,init:%v,ts:%v", act, train.VobcState.Tc1Active, tcc.ActiveTrainA, train.VobcState.Tc2Active, tcc.ActiveTrainB, initConn, initTimeStamp), aport)
|
|
||||||
|
|
||||||
if message.GetBit(data3, 3) == 0 {
|
|
||||||
actt := byte(0)
|
|
||||||
if act {
|
|
||||||
actt = 1
|
|
||||||
}
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, actt}})
|
|
||||||
}
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_INTEGRITY, 1}})
|
|
||||||
|
|
||||||
if act == false {
|
|
||||||
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
|
||||||
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_INTEGRITY, 1}})
|
|
||||||
return initTimeStamp, initConn, false, tce
|
|
||||||
}
|
|
||||||
if initConn {
|
|
||||||
if data1 == 0 {
|
|
||||||
connErr = true
|
|
||||||
}
|
|
||||||
if state == 0 {
|
|
||||||
slog.Info("列车紧急制动%v", aport)
|
|
||||||
jjzdBtn := tcc.Buttons[JJZD]
|
|
||||||
ebTce := controlEBBtn(train, true, jjzdBtn)
|
|
||||||
tce = append(tce, ebTce...)
|
|
||||||
} else if message.GetBit(data1, 0) == 0 {
|
|
||||||
slog.Info(fmt.Sprintf("列车紧切牵引%v ,state :%v", aport, state))
|
|
||||||
jjzdBtn := tcc.Buttons[JJZD]
|
|
||||||
ebTce := controlEBBtn(train, true, jjzdBtn)
|
|
||||||
tce = append(tce, ebTce...)
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_TRACTION_CUTED, 1}})
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
initConn = true
|
|
||||||
if initTimeStamp <= 0 {
|
|
||||||
initTimeStamp = time.Now().Add(time.Second * 6).Unix()
|
|
||||||
}
|
|
||||||
if initTimeStamp > time.Now().Unix() {
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
|
||||||
initData := s.ObtainTrainDigitalMockDataForStatus(train)
|
|
||||||
tce = append(tce, initData...)
|
|
||||||
if aport {
|
|
||||||
tcc.ActiveTrainA = true
|
|
||||||
} else if aport == false {
|
|
||||||
tcc.ActiveTrainB = true
|
|
||||||
}
|
|
||||||
initConn = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return initTimeStamp, initConn, connErr, tce
|
|
||||||
}
|
|
||||||
func trainAtoLevel(at3, at2, at1 bool) state_proto.TrainVobcState_AtoStepLevel {
|
func trainAtoLevel(at3, at2, at1 bool) state_proto.TrainVobcState_AtoStepLevel {
|
||||||
switch {
|
switch {
|
||||||
case at3 == false && at2 == false && at1 == true:
|
case at3 == false && at2 == false && at1 == true:
|
||||||
return state_proto.TrainVobcState_ATO_STEP_LEVEL_1
|
return state_proto.TrainVobcState_ATO_STEP_LEVEL_1
|
||||||
|
|
||||||
case at3 == false && at2 == true && at1 == true:
|
case at3 == false && at2 == true && at1 == true:
|
||||||
return state_proto.TrainVobcState_ATO_STEP_LEVEL_2
|
return state_proto.TrainVobcState_ATO_STEP_LEVEL_2
|
||||||
case at3 == false && at2 == true && at1 == false:
|
case at3 == false && at2 == true && at1 == false:
|
||||||
@ -798,84 +676,31 @@ func trainAtoLevel(at3, at2, at1 bool) state_proto.TrainVobcState_AtoStepLevel {
|
|||||||
return state_proto.TrainVobcState_ATO_STEP_LEVEL_NONE
|
return state_proto.TrainVobcState_ATO_STEP_LEVEL_NONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (s *VerifySimulation) shuziliang(aport bool, client *tcp.TcpClient, baseMessage []message.TrainPcSimBaseMessage) {
|
|
||||||
for _, msg := range baseMessage {
|
|
||||||
dd := msg.Encode()
|
|
||||||
slog.Info(fmt.Sprintf("发送列车控制信息:%x", dd), aport)
|
|
||||||
client.Send(dd)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4.4.1. 车载输出数字量信息报文内容
|
// 4.4.1. 车载输出数字量信息报文内容
|
||||||
func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(aport bool, client *tcp.TcpClient, train *state_proto.TrainState, data []byte) bool {
|
func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(train *state_proto.TrainState, data []byte) {
|
||||||
|
/* slog.Info("开始接受atp输出模拟量==============")
|
||||||
|
for i, d := range data {
|
||||||
|
|
||||||
|
dd := &strings.Builder{}
|
||||||
|
for j := 0; j < 8; j++ {
|
||||||
|
dd.WriteString(fmt.Sprintf(" bit%v val:%v , ", j, message.GetBit(d, uint(j))))
|
||||||
|
}
|
||||||
|
slog.Info(fmt.Sprintf("接受atp模拟量id:%v,data:%b,bits:%v", i, d, dd.String()))
|
||||||
|
|
||||||
dd := &strings.Builder{}
|
|
||||||
//slog.Info("开始接受atp输出模拟量==============%v", aport)
|
|
||||||
/* for i, d := range data {
|
|
||||||
for j := 0; j < 8; j++ {
|
|
||||||
dd.WriteString(fmt.Sprintf(" bit%v val:%v , ", j, message.GetBit(d, uint(j))))
|
|
||||||
}
|
}
|
||||||
slog.Info(fmt.Sprintf("接受atp模拟量id:%v,data:%b,bits:%v", i, d, dd.String()))
|
slog.Info("结束接受atp输出模拟量eeeeeeeeeeeeeeeeee")*/
|
||||||
}*/
|
s.reportTrainMockInitMsg(train, data[4], data[1])
|
||||||
d := data[4]
|
|
||||||
for j := 0; j < 8; j++ {
|
|
||||||
dd.WriteString(fmt.Sprintf(" bit%v val:%v , ", j, message.GetBit(d, uint(j))))
|
|
||||||
}
|
|
||||||
//slog.Info(fmt.Sprintf("%v", dd.String()), aport)
|
|
||||||
//slog.Info("结束接受atp输出模拟量eeeeeeeeeeeeeeeeee", aport)
|
|
||||||
|
|
||||||
//s.reportTrainMockInitMsg(aport, client, train, data[4], data[1])
|
|
||||||
vobc := train.VobcState
|
vobc := train.VobcState
|
||||||
|
trainPcSimDigitalOutInfoHandleCode7_0(data[4], vobc)
|
||||||
if aport {
|
trainPcSimDigitalOutInfoHandleCode15_8(data[3], vobc)
|
||||||
ts, initConn, connErr, tce := s.reportTrainMockInitMsg2(aport, vobc.Tc1Active, train.Tcc.TrainConnInitComplatePortA, train.Tcc.LineInitTimeStamp12PortA, train, data[4], data[1])
|
trainPcSimDigitalOutInfoHandleCode23_16(data[2], vobc)
|
||||||
if train.Tcc.ActiveTrainA {
|
trainPcSimDigitalOutInfoHandleCode31_24(data[1], vobc)
|
||||||
train.Tcc.LineInitTimeStamp12PortA = ts
|
trainPcSimDigitalOutInfoHandleCode39_32(data[0], vobc)
|
||||||
train.Tcc.TrainConnInitComplatePortA = initConn
|
if vobc.Ato {
|
||||||
train.Tcc.Line12ConnErrPortA = connErr
|
vobc.AtoStepLevel = trainAtoLevel(vobc.AtoTractionCommand3, vobc.AtoTractionCommand2, vobc.AtoTractionCommand1)
|
||||||
//slog.Info("发送数字量")
|
|
||||||
s.shuziliang(aport, client, tce)
|
|
||||||
}
|
|
||||||
/* if initConn {
|
|
||||||
train.Tcc.TrainConnInitComplatePortB = initConn
|
|
||||||
train.Tcc.LineInitTimeStamp12PortB = ts
|
|
||||||
}
|
|
||||||
if train.Tcc.ActiveTrainA {
|
|
||||||
train.Tcc.ActiveTrainB = train.Tcc.ActiveTrainA
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if train.VobcState.Tc1Active {
|
|
||||||
trainPcSimDigitalOutInfoHandleCode7_0(data[4], vobc)
|
|
||||||
trainPcSimDigitalOutInfoHandleCode15_8(data[3], vobc)
|
|
||||||
trainPcSimDigitalOutInfoHandleCode23_16(data[2], vobc)
|
|
||||||
trainPcSimDigitalOutInfoHandleCode31_24(data[1], vobc)
|
|
||||||
trainPcSimDigitalOutInfoHandleCode39_32(data[0], vobc)
|
|
||||||
if vobc.Ato {
|
|
||||||
vobc.AtoStepLevel = trainAtoLevel(vobc.AtoTractionCommand3, vobc.AtoTractionCommand2, vobc.AtoTractionCommand1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ts, initConn, connErr, tce := s.reportTrainMockInitMsg2(aport, vobc.Tc2Active, train.Tcc.TrainConnInitComplatePortB, train.Tcc.LineInitTimeStamp12PortB, train, data[4], data[1])
|
|
||||||
if train.Tcc.ActiveTrainB {
|
|
||||||
train.Tcc.LineInitTimeStamp12PortB = ts
|
|
||||||
train.Tcc.TrainConnInitComplatePortB = initConn
|
|
||||||
train.Tcc.Line12ConnErrPortB = connErr
|
|
||||||
s.shuziliang(aport, client, tce)
|
|
||||||
}
|
|
||||||
if train.VobcState.Tc2Active {
|
|
||||||
trainPcSimDigitalOutInfoHandleCode7_0(data[4], vobc)
|
|
||||||
trainPcSimDigitalOutInfoHandleCode15_8(data[3], vobc)
|
|
||||||
trainPcSimDigitalOutInfoHandleCode23_16(data[2], vobc)
|
|
||||||
trainPcSimDigitalOutInfoHandleCode31_24(data[1], vobc)
|
|
||||||
trainPcSimDigitalOutInfoHandleCode39_32(data[0], vobc)
|
|
||||||
if vobc.Ato {
|
|
||||||
vobc.AtoStepLevel = trainAtoLevel(vobc.AtoTractionCommand3, vobc.AtoTractionCommand2, vobc.AtoTractionCommand1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//return initResult
|
||||||
return true
|
|
||||||
|
|
||||||
}
|
}
|
||||||
func trainPcSimDigitalOutInfoHandleCode39_32(d byte, vobc *state_proto.TrainVobcState) {
|
func trainPcSimDigitalOutInfoHandleCode39_32(d byte, vobc *state_proto.TrainVobcState) {
|
||||||
@ -1031,14 +856,10 @@ func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []
|
|||||||
}
|
}
|
||||||
var balise *state_proto.BTMState
|
var balise *state_proto.BTMState
|
||||||
var dsn, bc, mc byte
|
var dsn, bc, mc byte
|
||||||
btmCache := train.BtmBaliseCacheA
|
|
||||||
if train.VobcState.Tc2Active {
|
|
||||||
btmCache = train.BtmBaliseCacheB
|
|
||||||
}
|
|
||||||
if atpReq.IsResend() {
|
if atpReq.IsResend() {
|
||||||
balise, dsn, bc, mc = can_btm.FindBaliseResend(btmCache, true)
|
balise, dsn, bc, mc = can_btm.FindBaliseResend(train)
|
||||||
} else {
|
} else {
|
||||||
balise, dsn, bc, mc = can_btm.FindBaliseByNotSend(btmCache, true)
|
balise, dsn, bc, mc = can_btm.FindBaliseByNotSend(train)
|
||||||
}
|
}
|
||||||
cl := clock(atpReq)
|
cl := clock(atpReq)
|
||||||
btmRepFrame := createBtmStatus(trainAtm.CanId.ID4, balise, atpReq, cl, dsn, bc, mc)
|
btmRepFrame := createBtmStatus(trainAtm.CanId.ID4, balise, atpReq, cl, dsn, bc, mc)
|
||||||
@ -1108,11 +929,11 @@ func (s *VerifySimulation) ObtainTrainDigitalMockDataForStatus(train *state_prot
|
|||||||
vs := train.VobcState
|
vs := train.VobcState
|
||||||
|
|
||||||
if vs.Tc1Active || vs.Tc2Active {
|
if vs.Tc1Active || vs.Tc2Active {
|
||||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.KEY_STATE, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //钥匙激活
|
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.KEY_STATE, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //钥匙激活
|
||||||
//msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.DRIVER_ACTIVE_REPORT, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //列车完整性
|
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.DRIVER_ACTIVE_REPORT, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //列车完整性
|
||||||
} /* else {
|
} else {
|
||||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.DRIVER_ACTIVE_REPORT, 0}, Type: message.SENDER_TRAIN_OUTR_INFO}) //列车完整性
|
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.DRIVER_ACTIVE_REPORT, 0}, Type: message.SENDER_TRAIN_OUTR_INFO}) //列车完整性
|
||||||
}*/
|
}
|
||||||
if vs.BrakeForce == 0 {
|
if vs.BrakeForce == 0 {
|
||||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.HANDLE_TO_ZERO, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //列车制动状态
|
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.HANDLE_TO_ZERO, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //列车制动状态
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user