列车应答器调整

This commit is contained in:
tiger_zhou 2024-08-15 14:54:16 +08:00
parent eae1b8d6df
commit 15c015a9a5
10 changed files with 1049 additions and 1043 deletions

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit ec6c571a37999ad7bab8f613deeb207b202468f0
Subproject commit bc7ca44ffd0a95f8a1ae14b391f93b28b11a452b

View File

@ -53,15 +53,32 @@ type btmCanetClient struct {
baliseDetector *BaliseDetector
}
func (s *btmCanetClient) FindNotSendState(train *state_proto.TrainState) (*state_proto.BTMState, byte, byte, byte) {
func (s *btmCanetClient) FindBaliseResend(train *state_proto.TrainState) (*state_proto.BTMState, byte, byte, byte) {
s.baliseDetector.eqLock.Lock()
defer s.baliseDetector.eqLock.Unlock()
cache := train.BtmBaliseCache
for _, balise := range cache.BaliseList {
slog.Info(fmt.Sprintf("===========%v", len(cache.BaliseList)))
if balise != nil && balise.BaliseId == cache.ResendBaliseId && balise.ResendCount < 3 {
balise.ResendCount++
ndsn := BaliseCounterAdd(cache.Dsn)
cache.Dsn = uint32(ndsn)
return balise, ndsn, byte(cache.BaliseCount), byte(cache.MessageCounter)
}
}
return nil, 0, 0, 0
}
func (s *btmCanetClient) FindBaliseByNotSend(train *state_proto.TrainState) (*state_proto.BTMState, byte, byte, byte) {
s.baliseDetector.eqLock.Lock()
defer s.baliseDetector.eqLock.Unlock()
cache := train.BtmBaliseCache
for _, btmCache := range cache.BaliseList {
if btmCache != nil && !btmCache.IsSend {
ndsn := BaliseCounterAdd(cache.Dsn)
cache.Dsn = uint32(ndsn)
cache.ResendBaliseId = btmCache.BaliseId
return btmCache, ndsn, byte(cache.BaliseCount), byte(cache.MessageCounter)
}
}
@ -86,7 +103,8 @@ type BtmCanetClient interface {
HandleTrainHeadPositionInfo(w ecs.World, vobcBtm *state_proto.VobcBtmState, h *TrainHeadPositionInfo)
HandleTrainHeadPositionInfoForTrain(w ecs.World, train *state_proto.TrainBtmCache, h *TrainHeadPositionInfo)
FindNotSendState(train *state_proto.TrainState) (*state_proto.BTMState, byte, byte, byte)
FindBaliseByNotSend(train *state_proto.TrainState) (*state_proto.BTMState, byte, byte, byte)
FindBaliseResend(train *state_proto.TrainState) (*state_proto.BTMState, byte, byte, byte)
}
var (
@ -121,16 +139,7 @@ func (s *btmCanetClient) HandleTrainHeadPositionInfo(w ecs.World, vobcBtm *state
//slog.Debug(h.String())
wd := entity.GetWorldData(w)
repo := wd.Repo
//s.baliseDetector.detect(wd, repo, h, vobcBtm)
h2 := &TrainHeadPositionInfo{
TrainId: h.TrainId,
Up: h.Up,
Link: h.OldLink,
LinkOffset: h.OldLinkOffset,
Speed: h.Speed,
Acceleration: h.Acceleration}
s.baliseDetector.detect2(wd, repo, h, h2, vobcBtm)
s.baliseDetector.detect(wd, repo, h, vobcBtm)
}
func (s *btmCanetClient) Start(bcm BtmCanetManager) {
s.bcm = bcm

View File

@ -2,6 +2,7 @@ package can_btm
import (
"fmt"
"joylink.club/bj-rtsts-server/const/balise_const"
"joylink.club/bj-rtsts-server/dto/state_proto"
"joylink.club/bj-rtsts-server/third_party/btm_vobc"
"joylink.club/rtsssimulation/component"
@ -11,6 +12,7 @@ import (
"log/slog"
"math"
"sort"
"strings"
"sync"
"time"
)
@ -102,68 +104,11 @@ func (t *BaliseDetector) newDetect(wd *component.WorldData, repo *repository.Rep
}
if len(balises) > 0 {
balise := balises[0]
telegram, utel := t.rcvTelegram(wd, balise.Id())
t.addNewExpectedBalise(balise, btmCache, telegram, utel)
}
}
func (t *BaliseDetector) detect2(wd *component.WorldData, repo *repository.Repository, th, th2 *TrainHeadPositionInfo, vobcBtm *state_proto.VobcBtmState) {
t.tryRebind(th)
//BTM天线中心点运行信息
curAntennaRi := t.createBtmAntennaRunningInfo(wd, repo, th) //目前车头
curAntennaRi2 := t.createBtmAntennaRunningInfo(wd, repo, th2) //上次车头
var startBalises []*repository.Transponder
//startBalises = t.searchBalisesFromBetweenLinkPosition(repo, th.Up, curAntennaRi2.LinkId, th2.LinkOffset, th.LinkOffset)
startBalises = t.searchBalisesFromBetweenLinkPosition(repo, th2.Up, curAntennaRi2.LinkId, curAntennaRi2.LinkOffset, curAntennaRi.LinkOffset)
balises := make([]*repository.Transponder, 0)
for _, balise := range startBalises {
find := false
for _, transponder := range balises {
if transponder.Id() == balise.Id() {
find = true
break
}
}
if !find {
balises = append(balises, balise)
}
}
if len(balises) > 0 {
balise := balises[0]
baliseInfo := &BtmAntennaScanningBaliseInfo{BaliseId: balise.Id(), BaliseType: balise.BaliseType()}
//uuid := uuid2.NewString()
//slog.Info(fmt.Sprintf("uid :%v,baliseId:%v,Distance:%v,up:%v", uuid, balise.Id(), baliseInfo.Distance, curAntennaRi.Up))
telegram, utel := t.rcvTelegram(wd, balise.Id())
if utel != nil && t.addExpectedBalise(baliseInfo) {
t.baliseCounterAdd1() //应答器计数器
if len(telegram) > 0 {
baliseInfo.telegram = utel
baliseInfo.telegram128 = telegram
t.baliseMessageCounterAdd1() //报文计数器
}
}
t.aboveBalise = true
} else {
t.aboveBalise = false
}
/* curAntennaRi2 := t.createBtmAntennaRunningInfo(wd, repo, &TrainHeadPositionInfo{TrainId: th.TrainId,
Up: !th.Up,
Link: th.Link,
LinkOffset: th.LinkOffset,
Speed: th.Speed,
Acceleration: th.Acceleration})
curExpect2 := t.timeScanNearestBalise(curTime, wd, repo, curAntennaRi2)
if curExpect2 != nil && curExpect2.Distance > 20 {
btm_vobc.Default().UpdateTrainLeave(vobcBtm, curExpect2.BaliseId, curTime.UnixMilli())
}*/
}
func (t *BaliseDetector) detect(wd *component.WorldData, repo *repository.Repository, th *TrainHeadPositionInfo, vobcBtm *state_proto.VobcBtmState) {
t.tryRebind(th)
@ -285,13 +230,20 @@ func (t *BaliseDetector) addNewExpectedBalise(balise *repository.Transponder, bt
btmCache.BaliseCount = uint32(bc)
btmCache.MessageCounter = mc
//存入队尾
bl[len(bl)-1] = &state_proto.BTMState{BaliseId: balise.Id(),
btmS := &state_proto.BTMState{BaliseId: balise.Id(),
Telegram: fmt.Sprintf("%x", userTelegram),
Telegram128: fmt.Sprintf("%x", telegram),
Telegram128: fmt.Sprintf("%X", telegram),
Unpack: unpack,
BaliseType: int32(balise.BaliseType().Number()),
AboveBalise: true}
AboveBalise: true, HasData: true}
if userTelegram == nil || len(userTelegram) == 0 {
btmS.Telegram = strings.Repeat("00", balise_const.UserTelegramByteLen)
btmS.Telegram128 = strings.Repeat("00", balise_const.TelegramByteLen)
btmS.HasData = false
}
//存入队尾
bl[len(bl)-1] = btmS
return true
}

View File

@ -73,6 +73,13 @@ type AtpRequestFrame struct {
//IsTrainPcSim bool
}
func (f *AtpRequestFrame) IsResend() bool {
if f.ResendRequest == 2 {
return true
}
return false
}
// NewAtpRequestFrame 创建ATP查询帧
func NewAtpRequestFrame(sn byte) *AtpRequestFrame {
return &AtpRequestFrame{
@ -98,10 +105,16 @@ func (f *AtpRequestFrame) Decode2(cf *BtmHeadFrame) bool {
buf := bytes.NewBuffer(cf.CanData)
if d, err := buf.ReadByte(); err == nil {
f.Speed = uint16(d << 4)
f.ResendRequest = GetBit(d, 5)>>5 | GetBit(d, 4)>>6
rr := byte(0)
rr = setBit(rr, 0, GetBit(d, 4))
rr = setBit(rr, 1, GetBit(d, 5))
f.ResendRequest = rr
f.PowerAmplifierControlledByAtp = true
f.PowerAmplifierTurnOn = true
if rr == 2 {
slog.Error(fmt.Sprintf("获取ATP请求帧数据%b,rr :=%v ,result:%v id1:%v,id2:%v,id3:%v,id4:%v", d, rr, rr, f.FId.ID1, f.FId.ID2, f.FId.ID3, f.FId.ID4))
}
} else {
return false
}

View File

@ -7,7 +7,7 @@ import (
)
// 返回应答器数据帧(数据帧 + timeA+timeB+结束帧)
func CreateBtmAtpDataRspFramesData(statusRsp *BtmHeadFrame, msg []byte, msgPackError bool, msgTimeA uint32, msgTimeB uint32, tkTimeB uint32) ([]byte, bool) {
func CreateBtmAtpDataRspFramesData(statusRsp *BtmHeadFrame, msg []byte, msgPackError, haxBaliseData bool, msgTimeA uint32, msgTimeB uint32, tkTimeB uint32) ([]byte, bool) {
sn := statusRsp.CanId.ID4
//应答器整个是16个数据帧其中报文占13帧timeA,timeB 占2帧最后是结束帧
//数据
@ -33,8 +33,8 @@ func CreateBtmAtpDataRspFramesData(statusRsp *BtmHeadFrame, msg []byte, msgPackE
}
}
}
dtA := createTimeA(sn, DATA_TIME_A_OFFSET, msgTimeA, msgPackError, msg)
dtB := createTimeA(sn, DATA_TIME_B_OFFSET, msgTimeB, msgPackError, msg)
dtA := createTimeA(sn, DATA_TIME_A_OFFSET, msgTimeA, msgPackError, msg, haxBaliseData)
dtB := createTimeA(sn, DATA_TIME_B_OFFSET, msgTimeB, msgPackError, msg, haxBaliseData)
dtACf := dtA.Encode()
dtBCf := dtB.Encode()
@ -56,6 +56,7 @@ func CreateBtmAtpDataRspFramesData(statusRsp *BtmHeadFrame, msg []byte, msgPackE
}
return rt, true
}
func createDataAtpEnd(sn byte, time uint32, statusData, msg, dtAData, dtBData []byte) *BtmDataMessageAtpTimeAndEndFrame {
end := BtmDataMessageEndAtpFrame(sn)
end.Time = time
@ -67,23 +68,27 @@ func createDataAtpEnd(sn byte, time uint32, statusData, msg, dtAData, dtBData []
crc32cData = append(crc32cData, dtBData...)
crc32cData = binary.BigEndian.AppendUint32(crc32cData, end.Time)
end.Crc32 = Can_Crc32(crc32cData)
return end
}
func createTimeA(sn, offset byte, time uint32, msgPackError bool, msg []byte) *BtmDataMessageAtpTimeAndEndFrame {
func createTimeA(sn, offset byte, time uint32, msgPackError bool, msg []byte, hasBaliseData bool) *BtmDataMessageAtpTimeAndEndFrame {
tf := CreateBtmDataMessageTimeAtpFrame(sn, offset)
tf.Time = time
if !msgPackError {
var crcData []byte
crcData = append(crcData, msg...)
crcData = binary.BigEndian.AppendUint32(crcData, time)
if offset == DATA_TIME_A_OFFSET {
tf.Crc32 = Can_Crc32A(crcData) //CRC32A的校验范围是报文+时间戳B
if !hasBaliseData {
tf.Crc32 = 0
} else {
tf.Crc32 = Can_Crc32B(crcData) //CRC32B的校验范围是报文+时间戳B
}
if offset == DATA_TIME_A_OFFSET {
tf.Crc32 = Can_Crc32A(crcData) //CRC32A的校验范围是报文+时间戳B
} else {
tf.Crc32 = Can_Crc32B(crcData) //CRC32B的校验范围是报文+时间戳B
}
}
} else { //BTM解包发生错误则数据帧及CRC32A/B全填“0xFF”
tf.Crc32 = 0xff_ff_ff_ff
}

View File

@ -13,10 +13,10 @@ type TrainPcReciverData struct {
clientKey string
tcpClient *tcp.TcpClient
pcSimManage TrainPcSimManage
trainInit bool
state tpapi.ThirdPartyApiServiceState
speedPlace *message.TrainSpeedPlaceReportMsg
train *state_proto.TrainState
//trainInit bool
state tpapi.ThirdPartyApiServiceState
speedPlace *message.TrainSpeedPlaceReportMsg
train *state_proto.TrainState
}
func (rd *TrainPcReciverData) Name() string {
@ -62,12 +62,12 @@ func (rd *TrainPcReciverData) receiverDataHandle(n int, data []byte) {
//case RECIVE_TRAIN_CREATE_REMOVE:
// pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR:
initResult := rd.pcSimManage.TrainPcSimDigitalOutInfoHandle(train, rd.trainInit, baseMsg.Data)
rd.trainInit = initResult
rd.pcSimManage.TrainPcSimDigitalOutInfoHandle(train, baseMsg.Data)
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR_BACK:
rd.pcSimManage.TrainPcSimDigitalReportHandle(train, baseMsg.Data)
case message.RECIVE_TRAIN_QUERY_STATUS:
rd.pcSimManage.TrainBtmQuery(train, baseMsg.Data)
rd.pcSimManage.TrainBtmQuery2(train, baseMsg.Data)
case message.RECIVE_TRAIN_MOCK_DATA:
rd.pcSimManage.TrainPcSimMockInfo(train, baseMsg.Data)

View File

@ -57,7 +57,7 @@ type TrainPcSimManage interface {
//获取列车模拟量数据
ObtainTrainDigitalMockData(train *state_proto.TrainState) []message.TrainPcSimBaseMessage
// TrainPcSimDigitalOutInfoHandle 4.4.1. 车载输出数字量信息报文内容
TrainPcSimDigitalOutInfoHandle(train *state_proto.TrainState, trainInit bool, data []byte) bool
TrainPcSimDigitalOutInfoHandle(train *state_proto.TrainState, data []byte)
// TrainPcSimDigitalReportHandle 4.4.2. 车载输出数字反馈量信息报文内容
TrainPcSimDigitalReportHandle(train *state_proto.TrainState, data []byte)
FindConnTrain(ct state_proto.TrainConnState_TrainConnType) *state_proto.TrainState
@ -66,7 +66,8 @@ type TrainPcSimManage interface {
//处理列车pc仿真模拟量数据
TrainPcSimMockInfo(train *state_proto.TrainState, data []byte)
// TrainBtmQuery 处理列车btm查询
TrainBtmQuery(train *state_proto.TrainState, data []byte)
TrainBtmQuery2(train *state_proto.TrainState, data []byte)
}
type trainPcSimService struct {
state tpapi.ThirdPartyApiServiceState
@ -207,7 +208,7 @@ func (d *trainPcSimService) newCloseConn(clientKey string) {
rd.tcpClient = nil
rd.train = nil
rd.speedPlace = nil
rd.trainInit = false
//rd.trainInit = false
//d.cancleContextFun()
}
}
@ -228,7 +229,7 @@ func (d *trainPcSimService) initConn(clientKey string) error {
if rd != nil && rd.tcpClient != nil && rd.tcpClient.IsConning() {
return nil
} else {
rd.trainInit = false
//rd.trainInit = false
rd.tcpClient = nil
}
cfg, cfgErr := d.findConfig(clientKey)

View File

@ -52,6 +52,9 @@ func ControlTrainUpdate(s *VerifySimulation, ct *request_proto.TrainControl) {
if !vobc.Tc1Active && !vobc.Tc2Active {
panic(sys_error.New("TC1和TC2都未激活不能搬动牵引制动手柄 "))
}
if vobc.TractionSafetyCircuit {
panic(sys_error.New("牵引切除,不能进行列车控制"))
}
oldTraction := sta.VobcState.TractionForce
oldBrakeForce := sta.VobcState.BrakeForce
isTraction := ct.Handler.Val > 0 //是否制动
@ -487,15 +490,16 @@ func (s *VerifySimulation) FindConnTrain(ct state_proto.TrainConnState_TrainConn
}
// 反馈atp输出数字量数据
func (s *VerifySimulation) reportTrainMockInitMsg(train *state_proto.TrainState, data1, data3 byte, trainInit bool) bool {
func (s *VerifySimulation) reportTrainMockInitMsg(train *state_proto.TrainState, data1, data3 byte) {
vobc := train.VobcState
tcc := train.Tcc
tce := make([]message.TrainPcSimBaseMessage, 0)
tcc.Line12ConnErr = false
initResult := trainInit
//initResult := trainInit
if vobc.Tc1Active || vobc.Tc2Active {
state := message.GetBit(data1, 3)
if trainInit {
//if trainInit {
if vobc.TrainConnInitComplate {
if data1 == 0 {
tcc.Line12ConnErr = true
}
@ -504,19 +508,15 @@ func (s *VerifySimulation) reportTrainMockInitMsg(train *state_proto.TrainState,
ebTce := controlEBBtn(vobc, true, jjzdBtn)
tce = append(tce, ebTce...)
} else if message.GetBit(data1, 0) == 0 {
jjzdBtn := tcc.Buttons[JJZD]
ebTce := controlEBBtn(vobc, 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}})
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.NOT_BREAK, 0}})
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{0x38, 0}})
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.RECIVE_TRAIN_HAND_KEY_CANCLE_FORWARD})
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.RECIVE_TRAIN_HAND_KEY_BACKWARD})
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_TRACTION_CUTED, 1}})
}
} else {
initResult = true
//initResult = false
vobc.TrainConnInitComplate = true
if tcc.LineInitTimeStamp12 <= 0 {
tcc.LineInitTimeStamp12 = time.Now().Add(time.Second * 6).Unix()
}
@ -524,7 +524,8 @@ func (s *VerifySimulation) reportTrainMockInitMsg(train *state_proto.TrainState,
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...)
initResult = false
//initResult = false
vobc.TrainConnInitComplate = false
}
}
@ -535,26 +536,20 @@ func (s *VerifySimulation) reportTrainMockInitMsg(train *state_proto.TrainState,
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_INTEGRITY, 1}})
}
train_pc_sim.Default().SendTrainControlMsg(train, tce)
return initResult
//return initResult
}
// 4.4.1. 车载输出数字量信息报文内容
func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(train *state_proto.TrainState, trainInit bool, data []byte) bool {
/*for i, d := range data {
slog.Info(fmt.Sprintf("atp模拟量分析index:%v ,bin:%2b,trainInit:%v", i, d, trainInit))
}*/
initResult := s.reportTrainMockInitMsg(train, data[4], data[1], trainInit)
func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(train *state_proto.TrainState, data []byte) {
s.reportTrainMockInitMsg(train, data[4], data[1])
vobc := train.VobcState
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.EmergencyBrakingStatus {
train_pc_sim.Default().ResetPlusePlace(train)
}*/
return initResult
//return initResult
}
func trainPcSimDigitalOutInfoHandleCode39_32(d byte, vobc *state_proto.TrainVobcState) {
@ -694,75 +689,63 @@ func (s *VerifySimulation) TrainPcSimMockInfo(train *state_proto.TrainState, dat
}
// 4.4.4. 车载输出BTM查询同步帧报文内容0x04
func (s *VerifySimulation) TrainBtmQuery(train *state_proto.TrainState, data []byte) {
func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []byte) {
ts := time.Now().UnixMilli()
if len(data) < 12 {
slog.Error("列车btm查询报文长度错误:", len(data))
return
}
balise, dsn, bc, mc := can_btm.Default().FindNotSendState(train)
trainAtm := message.NewBtmHeadFrame(data)
atpReq := &message.AtpRequestFrame{}
if !atpReq.Decode2(trainAtm) {
slog.Warn("列车pc驾驶模拟-CanetFrame解码成AtpRequestFrame失败", "CanetFrame", trainAtm.String())
return
}
var balise *state_proto.BTMState
var dsn, bc, mc byte
if atpReq.IsResend() {
balise, dsn, bc, mc = can_btm.Default().FindBaliseResend(train)
} else {
balise, dsn, bc, mc = can_btm.Default().FindBaliseByNotSend(train)
}
cl := clock(atpReq)
btmRepFrame := createBtmStatus(trainAtm.CanId.ID4, balise, atpReq, cl, dsn, bc, mc)
timeSyncF := message.NewBtmTimeSyncCheckFrame(trainAtm.CanId.ID4)
timeSyncF.T2 = cl.BtmTk
timeSyncF.T3 = cl.TkNow()
if balise == nil {
queryData := make([]byte, 0)
queryData = append(queryData, btmRepFrame.EncodeBtmAtp().Encode()...)
queryData = append(queryData, timeSyncF.EncodeBtmAtp().Encode()...)
train_pc_sim.Default().SendBaliseData(train, message.RECIVE_TRAIN_BTM_NOT_DATA, queryData)
} else {
logstr := ""
if atpReq.IsResend() {
logstr = fmt.Sprintf("准备重新发送应答id:%v,接受时间:%v,发送时间:%v , 数据:%v 经过:%v,解报文:%v", balise.BaliseId, ts, time.Now().UnixMilli(), balise.Telegram, bc, mc)
if atpReq.ResendRequest == 2 {
slog.Info(fmt.Sprintf("rrrrrrrrrrrrrrrrr:%v", atpReq.String()))
//重新发送
//if len(train.BtmState.BaliseTelegramForPcSimResend) > 0 {
if len(balise.BaliseTelegramForPcSimResend) > 0 {
slog.Info(fmt.Sprintf("rrrrrrrrrrrrrrrrr111111111:%v", atpReq.String()))
//dd, _ := hex.DecodeString(train.BtmState.BaliseTelegramForPcSimResend)
dd, _ := hex.DecodeString(balise.BaliseTelegramForPcSimResend)
train_pc_sim.Default().SendBaliseData(train, message.RECIVE_TRAIN_BTM_HAS_DATA, dd)
} else if !balise.IsSend {
balise.IsSend = true
logstr = fmt.Sprintf("准备发送应答id:%v,接受时间:%v,发送时间:%v , 数据:%v 经过:%v,解报文:%v", balise.BaliseId, ts, time.Now().UnixMilli(), balise.Telegram, bc, mc)
} else {
slog.Info(fmt.Sprintf("rrrrrrrrrrrrrrrrr2222222222222:%v", atpReq.String()))
timeSyncF := message.NewBtmTimeSyncCheckFrame(trainAtm.CanId.ID4)
return
}
slog.Info(logstr)
aliseData, _ := hex.DecodeString(balise.Telegram)
stateRepFrame := btmRepFrame.EncodeBtmAtp()
statusDataCf, statusDataCfOk := message.CreateBtmAtpDataRspFramesData(stateRepFrame, aliseData, false, balise.HasData, cl.BtmTk, cl.BtmTk, cl.BtmTk)
if statusDataCfOk {
timeSyncF.T2 = cl.BtmTk
timeSyncF.T3 = cl.TkNow()
queryData := make([]byte, 0)
queryData = append(queryData, btmRepFrame.EncodeBtmAtp().Encode()...)
queryData = append(queryData, timeSyncF.Encode().Encode()...)
train_pc_sim.Default().SendBaliseData(train, message.RECIVE_TRAIN_BTM_NOT_DATA, queryData)
}
} else {
timeSyncF := message.NewBtmTimeSyncCheckFrame(trainAtm.CanId.ID4)
timeSyncF.T2 = cl.BtmTk
timeSyncF.T3 = cl.TkNow()
if balise == nil {
//无应答器数据
queryData := make([]byte, 0)
queryData = append(queryData, btmRepFrame.EncodeBtmAtp().Encode()...)
queryData = append(queryData, stateRepFrame.Encode()...)
queryData = append(queryData, timeSyncF.EncodeBtmAtp().Encode()...)
train_pc_sim.Default().SendBaliseData(train, message.RECIVE_TRAIN_BTM_NOT_DATA, queryData)
} else if !balise.IsSend {
balise.IsSend = true
slog.Info(fmt.Sprintf("准备发送应答id:%v,接受时间:%v,发送时间:%v , 数据:%v 经过:%v,解报文:%v", balise.BaliseId, ts, time.Now().UnixMilli(), balise.Telegram, bc, mc))
aliseData, _ := hex.DecodeString(balise.Telegram)
stateRepFrame := btmRepFrame.EncodeBtmAtp()
statusDataCf, statusDataCfOk := message.CreateBtmAtpDataRspFramesData(stateRepFrame, aliseData, false, cl.BtmTk, cl.BtmTk, cl.BtmTk)
if statusDataCfOk {
timeSyncF.T2 = cl.BtmTk
timeSyncF.T3 = cl.TkNow()
queryData := make([]byte, 0)
queryData = append(queryData, stateRepFrame.Encode()...)
queryData = append(queryData, timeSyncF.EncodeBtmAtp().Encode()...)
queryData = append(queryData, statusDataCf...) //数据帧包含结束帧
balise.BaliseTelegramForPcSimResend = fmt.Sprintf("%X", statusDataCf)
train_pc_sim.Default().SendBaliseData(train, message.RECIVE_TRAIN_BTM_HAS_DATA, queryData)
} else {
slog.Error("列车pc仿真 BtmCanetClient应答帧、数据帧编码失败")
}
queryData = append(queryData, statusDataCf...) //数据帧包含结束帧
balise.BaliseTelegramForPcSimResend = fmt.Sprintf("%X", statusDataCf)
train_pc_sim.Default().SendBaliseData(train, message.RECIVE_TRAIN_BTM_HAS_DATA, queryData)
} else {
slog.Error("列车pc仿真 BtmCanetClient应答帧、数据帧编码失败")
}
}
}

View File

@ -156,20 +156,6 @@ func runThirdParty(s *memory.VerifySimulation) error {
func stopThirdParty(s *memory.VerifySimulation) {
// 停止半实物
semi_physical_train.Default().Stop()
// 联锁启动
for _, c := range s.GetRunConfig().Interlocks {
switch c.Line {
case "11":
beijing11.Stop(c.Code)
default:
beijing12.Stop(c)
}
}
//计轴RSSP启动销毁
axleBeijing12.Stop(s)
//obsolete.StopLineAllRsspAxleServices()
// 电机UDP停止
electrical_machinery.Default().Stop()
// 车载BTM停止
can_btm.Default().Stop()
// 联锁驱采Modbus服务停止
@ -184,6 +170,21 @@ func stopThirdParty(s *memory.VerifySimulation) {
btm_vobc.Default().Stop()
// 停止动力学接口功能
dynamics.Default().Stop()
// 联锁启动
for _, c := range s.GetRunConfig().Interlocks {
switch c.Line {
case "11":
beijing11.Stop(c.Code)
default:
beijing12.Stop(c)
}
}
//计轴RSSP启动销毁
axleBeijing12.Stop(s)
//obsolete.StopLineAllRsspAxleServices()
// 电机UDP停止
electrical_machinery.Default().Stop()
}
func createSimulationId(projectId int32) string {