列车调整连接12号线车载,静态情况
This commit is contained in:
parent
6ed9aec51a
commit
1166d7ffe5
@ -75,9 +75,15 @@ func initTrainPc() {
|
||||
createOrRemoveTrain()
|
||||
circleSendTrainActive()
|
||||
circleSendTrainMockData()
|
||||
go circleSendTrainSpeedPlace()
|
||||
//go circleSendTrainSpeedPlace()
|
||||
//sendBtm()
|
||||
}
|
||||
|
||||
const (
|
||||
e1 = 0x1e
|
||||
aa = 0x17
|
||||
)
|
||||
|
||||
func createOrRemoveTrain() {
|
||||
msgs := make([]*message.TrainPcSimBaseMessage, 0)
|
||||
//msgs = append(msgs, &message.TrainPcSimBaseMessage{Data: []byte{0x00}, Type: message.RECIVE_TRAIN_CREATE_REMOVE})
|
||||
@ -103,86 +109,15 @@ func circleSendTrainActive() {
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
a1 = 0x26
|
||||
a2 = 0x27
|
||||
a3 = 0x2d
|
||||
a4 = 0x03
|
||||
a5 = 0x1e
|
||||
a6 = 0x16
|
||||
a7 = 0x17
|
||||
a8 = 0x0a
|
||||
a9 = 0x05
|
||||
a10 = 0x08
|
||||
a11 = 0x07
|
||||
a12 = 0x06
|
||||
a13 = 0x09
|
||||
a14 = 0x0f
|
||||
a15 = 0x0e
|
||||
a16 = 0x21
|
||||
a17 = 0x15
|
||||
a18 = 0x1d
|
||||
a19 = 0x14
|
||||
a20 = 0x13
|
||||
a21 = 0x22
|
||||
a22 = 0x28
|
||||
a23 = 0x29
|
||||
a24 = 0x1f
|
||||
a25 = 0x10
|
||||
a26 = 0x0c
|
||||
a27 = 0x04
|
||||
a28 = 0x1e
|
||||
)
|
||||
|
||||
//eb0705c383
|
||||
//eb0805c673
|
||||
//eb0007040172e5
|
||||
//eb600600727e
|
||||
//eb00071e017985
|
||||
//eb00071600bf85
|
||||
//eb00071700be15
|
||||
|
||||
//eb00070a00b745
|
||||
//eb00070500b2b5
|
||||
//eb00070800b625
|
||||
//eb00070700b3d5
|
||||
//eb00070600b245
|
||||
//eb00070900b7b5
|
||||
//eb00070f00b415
|
||||
//eb00070e017445
|
||||
//eb00072600ab85
|
||||
//eb000727016bd5
|
||||
//eb500601b3b1
|
||||
//eb00072100a9b5
|
||||
//eb000715017eb5
|
||||
//eb00071d017975
|
||||
//eb00071400bee5
|
||||
//eb000713017d15
|
||||
//eb000722016885
|
||||
//eb000728016e25
|
||||
//eb000729016fb5
|
||||
//eb00071f017815
|
||||
//eb00071000bc25
|
||||
//eb01190001000000000000000000000000667b6e43026dfd4e
|
||||
//
|
||||
//
|
||||
//eb0405c373
|
||||
//eb000714017f25
|
||||
//eb0905c7e3
|
||||
//eb0705c383
|
||||
//eb00072d00acb5
|
||||
//eb00070300b115
|
||||
|
||||
func circleSendTrainMockData() {
|
||||
msgs := make([]*message.TrainPcSimBaseMessage, 0)
|
||||
msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(0), 1}})
|
||||
|
||||
msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(16), 1}})
|
||||
msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(3), 0}})
|
||||
msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(3), 0}})
|
||||
//msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(16), 1}})
|
||||
//msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(45), 1}})
|
||||
//msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(46), 1}})
|
||||
msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(3), 0}})
|
||||
//msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(3), 0}})
|
||||
msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(16), 1}})
|
||||
msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(45), 1}})
|
||||
msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(46), 1}})
|
||||
/* for i := 3; i <= 50; i++ {
|
||||
if i != 2 {
|
||||
msgs = append(msgs, &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{byte(i), 0}})
|
||||
@ -211,6 +146,11 @@ func circleSendTrainMockData() {
|
||||
time.Sleep(time.Millisecond * 1000)
|
||||
}
|
||||
}
|
||||
func sendBtm() {
|
||||
source := "eb3305d543eb3211000005ea000000010000082b7989eb321100003573000000010000257ce38eeb3211000005d90000000100002731a483eb3211000005c8000000010000322d6b8aeb32110000356200000001000033976df1eb3179000005fb000000010000060390007f8182fd8b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc02edeb31790000358400000001000007b990007f819ac20b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcefe4eb31790000070d00000001000008f690007f8183868b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc72a9eb3179000035950000000100000a3390007f819aca8b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc5487eb31790000071e000000010000279b90007f81838f0b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcddd1eb3179000005fb000000010000060390007f8182fd8b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc02edeb31790000358400000001000007b990007f819ac20b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcefe4eb31790000070d00000001000008f690007f8183868b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc72a9eb3179000035950000000100000a3390007f819aca8b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc5487eb31790000071e000000010000279b90007f81838f0b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcddd1"
|
||||
data, _ := hex.DecodeString(source)
|
||||
trainpcClient.Send(data)
|
||||
}
|
||||
func circleSendTrainSpeedPlace() {
|
||||
for {
|
||||
data := make([]byte, 0)
|
||||
@ -240,9 +180,12 @@ func circleSendTrainSpeedPlace() {
|
||||
}
|
||||
}
|
||||
func trainPcDataHandle(n int, data []byte) {
|
||||
return
|
||||
//hexData := hex.EncodeToString(data[:n])
|
||||
//slog.Info(fmt.Sprintf("列车pc仿真接口长度:%v,实际长度:%v,接受数据:%v", len(data), n, hexData))
|
||||
hexData := hex.EncodeToString(data[:n])
|
||||
slog.Info(fmt.Sprintf("列车pc仿真接口长度:%v,实际长度:%v,接受数据:%v", len(data), n, hexData))
|
||||
//source := "eb3211000005ea000000010000082b7989eb321100003573000000010000257ce38eeb3211000005d90000000100002731a483eb3211000005c8000000010000322d6b8aeb32110000356200000001000033976df1eb3179000005fb000000010000060390007f8182fd8b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc02edeb31790000358400000001000007b990007f819ac20b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcefe4eb31790000070d00000001000008f690007f8183868b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc72a9eb3179000035950000000100000a3390007f819aca8b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc5487eb31790000071e000000010000279b90007f81838f0b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcddd1eb3179000005fb000000010000060390007f8182fd8b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc02edeb31790000358400000001000007b990007f819ac20b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcefe4eb31790000070d00000001000008f690007f8183868b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc72a9eb3179000035950000000100000a3390007f819aca8b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc5487eb31790000071e000000010000279b90007f81838f0b10183280003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcddd1"
|
||||
//data2, _ := hex.DecodeString(source)
|
||||
//trainpcClient.Send(data2)
|
||||
|
||||
}
|
||||
func trainPcConnErr(err error) {
|
||||
|
||||
|
2
third_party/message/can_atp_req.go
vendored
2
third_party/message/can_atp_req.go
vendored
@ -68,6 +68,7 @@ type AtpRequestFrame struct {
|
||||
Crc16 uint16
|
||||
//解码时CRC16校验结果,true-校验通过
|
||||
Crc16CheckOk bool
|
||||
IsTrainPcSim bool
|
||||
}
|
||||
|
||||
// NewAtpRequestFrame 创建ATP查询帧
|
||||
@ -178,6 +179,7 @@ func (f *AtpRequestFrame) Decode(cf *CanetFrame) bool {
|
||||
}
|
||||
func (f *AtpRequestFrame) Encode() *CanetFrame {
|
||||
cf := &CanetFrame{}
|
||||
cf.IsTrainPcSim = f.IsTrainPcSim
|
||||
cf.CanId = f.FId
|
||||
cf.CanLen = 8
|
||||
cf.FF = true
|
||||
|
1
third_party/message/can_btm_status_rsp.go
vendored
1
third_party/message/can_btm_status_rsp.go
vendored
@ -33,6 +33,7 @@ type BtmStatusRspFrame struct {
|
||||
func NewBtmStatusRspFrame(sn byte, isTrainPcSim bool) *BtmStatusRspFrame {
|
||||
return &BtmStatusRspFrame{
|
||||
FId: *NewCanFrameId(CAN_ADDR_RSP_ATP, CAN_ADDR_RSP_BTM, CAN_FRAME_STATUS_RSP, sn),
|
||||
//FId: *NewCanFrameId(0x00, 0x00, 0x05, sn),
|
||||
IsTrainPcSim: isTrainPcSim,
|
||||
}
|
||||
}
|
||||
|
1
third_party/message/can_btm_time_sync_rsp.go
vendored
1
third_party/message/can_btm_time_sync_rsp.go
vendored
@ -21,6 +21,7 @@ type BtmTimeSyncCheckFrame struct {
|
||||
func NewBtmTimeSyncCheckFrame(sn byte, isTrainPcSim bool) *BtmTimeSyncCheckFrame {
|
||||
return &BtmTimeSyncCheckFrame{
|
||||
FId: *NewCanFrameId(CAN_ADDR_RSP_ATP, CAN_ADDR_RSP_BTM, CAN_FRAME_TIME_SYNC_RSP, sn),
|
||||
//FId: *NewCanFrameId(0x00, 0x00, 0x35, sn),
|
||||
IsTrainPcSim: isTrainPcSim,
|
||||
}
|
||||
}
|
||||
|
53
third_party/message/can_net.go
vendored
53
third_party/message/can_net.go
vendored
@ -1,6 +1,8 @@
|
||||
package message
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
@ -21,6 +23,26 @@ func NewCanetFrame(buf []byte, isTrainPcSim bool) *CanetFrame {
|
||||
cf.Decode(buf)
|
||||
return cf
|
||||
}
|
||||
|
||||
func NewCanetFrame2(buf []byte, isTrainPcSim bool) *CanetFrame {
|
||||
cf := &CanetFrame{IsTrainPcSim: isTrainPcSim}
|
||||
cf.Decode2(buf)
|
||||
return cf
|
||||
}
|
||||
func (p *CanetFrame) Encode2() []byte {
|
||||
buf := make([]byte, 0)
|
||||
//CAN 帧ID
|
||||
frameId := uint32(p.CanId.ID1)<<21 | uint32(p.CanId.ID2)<<13 | uint32(p.CanId.ID3)<<5 | uint32(p.CanId.ID4)
|
||||
|
||||
buf = binary.BigEndian.AppendUint32(buf, frameId)
|
||||
//CAN 帧数据
|
||||
if len(p.CanData) != 8 {
|
||||
panic("len(p.CanData)!=8")
|
||||
}
|
||||
buf = append(buf, p.CanData...)
|
||||
return buf
|
||||
}
|
||||
|
||||
func (p *CanetFrame) Encode() []byte {
|
||||
buf := make([]byte, 0)
|
||||
if !p.IsTrainPcSim {
|
||||
@ -39,7 +61,12 @@ func (p *CanetFrame) Encode() []byte {
|
||||
buf = append(buf, p.CanId.ID1)
|
||||
buf = append(buf, p.CanId.ID2)
|
||||
buf = append(buf, p.CanId.ID3)
|
||||
if p.IsTrainPcSim {
|
||||
buf = append(buf, p.CanId.ID4)
|
||||
} else {
|
||||
buf = append(buf, p.CanId.ID4<<3)
|
||||
}
|
||||
|
||||
//CAN 帧数据
|
||||
if len(p.CanData) != 8 {
|
||||
panic("len(p.CanData)!=8")
|
||||
@ -47,19 +74,35 @@ func (p *CanetFrame) Encode() []byte {
|
||||
buf = append(buf, p.CanData...)
|
||||
return buf
|
||||
}
|
||||
func (p *CanetFrame) Decode2(buf []byte) {
|
||||
|
||||
bb := bytes.NewBuffer(buf)
|
||||
var idSource uint32
|
||||
binary.Read(bb, binary.BigEndian, &idSource)
|
||||
data := make([]byte, bb.Len())
|
||||
_, err := bb.Read(data)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
b1 := byte(idSource >> 21)
|
||||
b2 := byte((idSource << 7) >> 13)
|
||||
b3 := byte((idSource << 15) >> 20)
|
||||
b4 := byte(idSource & 0x1f)
|
||||
p.CanId.ID1 = b1
|
||||
p.CanId.ID2 = b2
|
||||
p.CanId.ID3 = b3
|
||||
p.CanId.ID4 = b4
|
||||
p.CanData = data
|
||||
}
|
||||
func (p *CanetFrame) Decode(buf []byte) {
|
||||
|
||||
//
|
||||
if !p.IsTrainPcSim {
|
||||
if len(buf) != 13 {
|
||||
panic("len(buf)!=13")
|
||||
}
|
||||
p.FF = buf[0]&0x80 == 0x80
|
||||
p.RTR = buf[0]&0x40 == 0x40
|
||||
p.CanLen = buf[0] & 0x0f
|
||||
}
|
||||
|
||||
//1 2 3 4
|
||||
p.CanId.ID1 = buf[1]
|
||||
p.CanId.ID2 = buf[2]
|
||||
|
13
third_party/message/train_pc_sim_message.go
vendored
13
third_party/message/train_pc_sim_message.go
vendored
@ -36,6 +36,7 @@ func (tp *TrainPcSimBaseMessage) Encode() []byte {
|
||||
//pack = binary.BigEndian.AppendUint16(pack, uint16(crc.CalculateCRC(crc.CRC16, pack[1:])))
|
||||
return pack
|
||||
}
|
||||
|
||||
func TrainPcSimDecode(data []byte) []*TrainPcSimBaseMessage {
|
||||
|
||||
bms := make([]*TrainPcSimBaseMessage, 0)
|
||||
@ -109,6 +110,15 @@ func IsTrueForByte(d byte) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// 确定、否定是你软件里的概念吧,比如ATP输出量---紧急,我们就认为是低电平有效。即0代表有紧急,1代表无紧急;
|
||||
// 比如ATP的输入量---钥匙,我们认为是高电平有效,即1代表上钥匙,0代表下钥匙。
|
||||
func AtpLowPowerByte(d byte) bool {
|
||||
if d == 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 列车速度位置报告
|
||||
type TrainSpeedPlaceReportMsg struct {
|
||||
//列车id
|
||||
@ -236,7 +246,8 @@ const (
|
||||
TRAIN_LOW_POWER
|
||||
//ATP上电按钮
|
||||
ATP_POWER_ON
|
||||
_
|
||||
//atp切除
|
||||
ATP_CUT
|
||||
//AA自动开关门
|
||||
DOOR_MODE_AA
|
||||
|
||||
|
@ -30,7 +30,7 @@ const (
|
||||
RECIVE_TRAIN_BTM_NOT_DATA = 0x32
|
||||
|
||||
//清空所有预发应答器
|
||||
//recive_train_btn_clear_all_pre_data = 0x33
|
||||
RECIVE_TRAIN_BTN_CLEAR_ALL_PRE_DATA = 0x33
|
||||
//创建/删除列车
|
||||
RECIVE_TRAIN_CREATE_REMOVE = 0x50
|
||||
|
||||
|
2
third_party/train_pc_sim/example/main.go
vendored
2
third_party/train_pc_sim/example/main.go
vendored
@ -168,7 +168,7 @@ func startService(port int) {
|
||||
createServer(port, func(n int, data []byte) {
|
||||
msg := &message.TrainPcSimBaseMessage{}
|
||||
d := data[:n]
|
||||
fmt.Println(fmt.Sprintf("接受数据:%v", hex.EncodeToString(d)))
|
||||
//fmt.Println(fmt.Sprintf("接受数据:%v", hex.EncodeToString(d)))
|
||||
msg.Decode(d)
|
||||
pd := fmt.Sprintf("%X", d)
|
||||
|
||||
|
53
third_party/train_pc_sim/train_pc_receive_handler.go
vendored
Normal file
53
third_party/train_pc_sim/train_pc_receive_handler.go
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
package train_pc_sim
|
||||
|
||||
import (
|
||||
"joylink.club/bj-rtsts-server/dto/state_proto"
|
||||
"joylink.club/bj-rtsts-server/third_party/message"
|
||||
"joylink.club/bj-rtsts-server/third_party/tcp"
|
||||
)
|
||||
|
||||
type trainPcReciverData struct {
|
||||
clientKey string
|
||||
tcpClient *tcp.TcpClient
|
||||
pcSimManage TrainPcSimManage
|
||||
}
|
||||
|
||||
func (rd *trainPcReciverData) receiverDataHandle(n int, data []byte) {
|
||||
|
||||
receiveData := data[:n]
|
||||
|
||||
//hexSourceData := hex.EncodeToString(receiveData)
|
||||
//slog.Info(fmt.Sprintf("接受列车激活端:%v pc仿真接收数据:%v", rd.clientKey, hexSourceData))
|
||||
trainPcMsgs := message.TrainPcSimDecode(receiveData)
|
||||
connType := state_proto.TrainConnState_PC_SIM_A
|
||||
if rd.clientKey == "B" {
|
||||
connType = state_proto.TrainConnState_PC_SIM_B
|
||||
}
|
||||
for _, baseMsg := range trainPcMsgs {
|
||||
//slog.Info(fmt.Sprintf("pc仿真接收数据:%v,类型:%X", hexSourceData, baseMsg.Type))
|
||||
switch baseMsg.Type {
|
||||
//case RECIVE_TRAIN_CREATE_REMOVE:
|
||||
// pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
|
||||
//case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR:
|
||||
// rd.pcSimManage.TrainPcSimDigitalOutInfoHandle(connType, baseMsg.Data)
|
||||
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR_BACK:
|
||||
rd.pcSimManage.TrainPcSimDigitalReportHandle(connType, baseMsg.Data)
|
||||
case message.RECIVE_TRAIN_QUERY_STATUS:
|
||||
rd.pcSimManage.TrainBtmQuery(connType, baseMsg.Data)
|
||||
/*train := rd.pcSimManage.FindConnTrain(connType)
|
||||
mockMsgs := rd.pcSimManage.ObtainTrainDigitalMockData(train)
|
||||
for _, msg := range mockMsgs {
|
||||
err := rd.tcpClient.Send(msg.Encode())
|
||||
if err != nil {
|
||||
slog.Error("查询btm发送模拟量失败 msg:", err.Error(), err)
|
||||
}
|
||||
}*/
|
||||
case message.RECIVE_TRAIN_MOCK_DATA:
|
||||
rd.pcSimManage.TrainPcSimMockInfo(connType, baseMsg.Data)
|
||||
|
||||
//case RECIVE_TRAIN_DOOR_MODE:
|
||||
// pc.trainPcSimManage.TrainDoorModeHandle(baseMsg.Data[0])
|
||||
}
|
||||
}
|
||||
|
||||
}
|
107
third_party/train_pc_sim/train_pc_sim.go
vendored
107
third_party/train_pc_sim/train_pc_sim.go
vendored
@ -35,6 +35,7 @@ type TrainPcSim interface {
|
||||
SendTrainDirection(train *state_proto.TrainState, trainForward, trainBackward bool)
|
||||
//发送应答器信息数据
|
||||
SendBaliseData(train *state_proto.TrainState, msgType byte, data []byte)
|
||||
SendBaliseData2(train *state_proto.TrainState, msgType byte, data []string)
|
||||
//发布列车控制的相关事件
|
||||
PublishTrainControlEvent(train *state_proto.TrainState, events []TrainControlEvent)
|
||||
// CreateOrRemoveSpeedPLace 创建或删除速度位置信息
|
||||
@ -53,7 +54,7 @@ type TrainPcSimManage interface {
|
||||
TrainPcSimDigitalOutInfoHandle(connType state_proto.TrainConnState_TrainConnType, data []byte)
|
||||
// TrainPcSimDigitalReportHandle 4.4.2. 车载输出数字反馈量信息报文内容
|
||||
TrainPcSimDigitalReportHandle(connType state_proto.TrainConnState_TrainConnType, data []byte)
|
||||
|
||||
FindConnTrain(ct state_proto.TrainConnState_TrainConnType) *state_proto.TrainState
|
||||
// TrainPcSimMockInfo 门模式
|
||||
//TrainDoorModeHandle(state byte)
|
||||
//处理列车pc仿真模拟量数据
|
||||
@ -61,48 +62,9 @@ type TrainPcSimManage interface {
|
||||
// TrainBtmQuery 处理列车btm查询
|
||||
TrainBtmQuery(connType state_proto.TrainConnState_TrainConnType, data []byte)
|
||||
}
|
||||
type trainPcReciverData struct {
|
||||
clientKey string
|
||||
tcpClient *tcp.TcpClient
|
||||
pcSimManage TrainPcSimManage
|
||||
}
|
||||
|
||||
func (rd *trainPcReciverData) receiverDataHandle(n int, data []byte) {
|
||||
return
|
||||
//receiveData := data[:n]
|
||||
//
|
||||
//hexSourceData := hex.EncodeToString(receiveData)
|
||||
//
|
||||
//slog.Info(fmt.Sprintf("接受列车激活端:%v pc仿真接收数据:%v", rd.clientKey, hexSourceData))
|
||||
//trainPcMsgs := message.TrainPcSimDecode(receiveData)
|
||||
//connType := state_proto.TrainConnState_PC_SIM_A
|
||||
//if rd.clientKey == "B" {
|
||||
// connType = state_proto.TrainConnState_PC_SIM_B
|
||||
//}
|
||||
//for _, baseMsg := range trainPcMsgs {
|
||||
// slog.Info(fmt.Sprintf("pc仿真接收数据:%v,类型:%v", hexSourceData, baseMsg.Type))
|
||||
// switch baseMsg.Type {
|
||||
// //case RECIVE_TRAIN_CREATE_REMOVE:
|
||||
// // pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
|
||||
// case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR:
|
||||
// rd.pcSimManage.TrainPcSimDigitalOutInfoHandle(connType, baseMsg.Data)
|
||||
// case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR_BACK:
|
||||
// rd.pcSimManage.TrainPcSimDigitalReportHandle(connType, baseMsg.Data)
|
||||
// case message.RECIVE_TRAIN_QUERY_STATUS:
|
||||
// rd.pcSimManage.TrainBtmQuery(connType, baseMsg.Data)
|
||||
// case message.RECIVE_TRAIN_MOCK_DATA:
|
||||
// rd.pcSimManage.TrainPcSimMockInfo(connType, baseMsg.Data)
|
||||
// //case RECIVE_TRAIN_DOOR_MODE:
|
||||
// // pc.trainPcSimManage.TrainDoorModeHandle(baseMsg.Data[0])
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
const Name = "车载pc仿真"
|
||||
|
||||
//const CLIENT_KEY = "clientKey"
|
||||
|
||||
func FindTrainPcSimClientKey(t *state_proto.TrainState) string {
|
||||
if t.ConnState.ConnType == state_proto.TrainConnState_PC_SIM_A {
|
||||
return "A"
|
||||
@ -357,7 +319,7 @@ func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
|
||||
train.PluseCount.PulseCount1 = 0
|
||||
train.PluseCount.PulseCount2 = 0
|
||||
dataCode := bm.Encode()
|
||||
//slog.Info(fmt.Sprintf("发送列车速度位置,列车:%v,发送数据:%v", train.Id, hex.EncodeToString(dataCode)))
|
||||
slog.Info(fmt.Sprintf("发送列车速度位置,列车:%v,s1: %v,s2: %v,c2: %v,c2: %v,发送数据:%v", train.Id, s1, s2, d.speedPlace.PulseCount1, d.speedPlace.PulseCount2, hex.EncodeToString(dataCode)))
|
||||
err := rd.tcpClient.Send(dataCode)
|
||||
if err != nil {
|
||||
slog.Error(fmt.Sprintf("发送列车速度位置失败,列车:%v,发送数据:%v", train.Id, hex.EncodeToString(dataCode)))
|
||||
@ -474,6 +436,21 @@ func (d *trainPcSimService) SendTrainDirection(train *state_proto.TrainState, tr
|
||||
}
|
||||
}
|
||||
}
|
||||
func (d *trainPcSimService) SendBaliseData2(train *state_proto.TrainState, msgType byte, data []string) {
|
||||
for _, hexData := range data {
|
||||
dd, _ := hex.DecodeString(hexData)
|
||||
msg := &message.TrainPcSimBaseMessage{Type: msgType, Data: dd}
|
||||
clientKey := FindTrainPcSimClientKey(train)
|
||||
rd := d.newPcSimclientMap[clientKey]
|
||||
da := msg.Encode()
|
||||
slog.Info(fmt.Sprintf("发送列车PC仿真应答器信息,数据类型:0x%X,数据:%v", msgType, hex.EncodeToString(da)))
|
||||
|
||||
err := rd.tcpClient.Send(da)
|
||||
if err != nil {
|
||||
slog.Info(fmt.Sprintf("发送列车PC仿真应答器信息失败,数据:%v", hex.EncodeToString(da)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *trainPcSimService) SendBaliseData(train *state_proto.TrainState, msgType byte, data []byte) {
|
||||
msg := &message.TrainPcSimBaseMessage{}
|
||||
@ -482,9 +459,8 @@ func (d *trainPcSimService) SendBaliseData(train *state_proto.TrainState, msgTyp
|
||||
clientKey := FindTrainPcSimClientKey(train)
|
||||
rd := d.newPcSimclientMap[clientKey]
|
||||
|
||||
//client := d.pcSimClientMap[clientKey]
|
||||
da := msg.Encode()
|
||||
slog.Info(fmt.Sprintf("发送列车PC仿真应答器信息,数据:%v", hex.EncodeToString(da)))
|
||||
slog.Info(fmt.Sprintf("发送列车PC仿真应答器信息,无应答器:%v,数据:%v", msgType == message.RECIVE_TRAIN_BTM_NOT_DATA, hex.EncodeToString(da)))
|
||||
|
||||
err := rd.tcpClient.Send(da)
|
||||
if err != nil {
|
||||
@ -492,15 +468,6 @@ func (d *trainPcSimService) SendBaliseData(train *state_proto.TrainState, msgTyp
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func (d *trainPcSimService) trainControlEventHandle( event TrainControlEvent) {
|
||||
msg := &message.TrainPcSimBaseMessage{}
|
||||
msg.Type = SENDER_TRAIN_OUTR_INFO
|
||||
data := []byte{event.Command, event.Status}
|
||||
msg.Data = data
|
||||
d.pcSimClient.Send(msg.Encode())
|
||||
}
|
||||
*/
|
||||
func (d *trainPcSimService) PublishTrainControlEvent(train *state_proto.TrainState, events []TrainControlEvent) {
|
||||
if len(events) <= 0 {
|
||||
slog.Warn("发布事件数量为空")
|
||||
@ -527,39 +494,3 @@ func (d *trainPcSimService) PublishTrainControlEvent(train *state_proto.TrainSta
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 接受来自pc仿真的消息
|
||||
/*func (d *trainPcSimService) reivceData(len int, data []byte, properties map[string]interface{}) {
|
||||
clientKey := properties[CLIENT_KEY]
|
||||
ck := fmt.Sprintf("%v", clientKey)
|
||||
if d.pcSimClientMap[ck] == nil {
|
||||
slog.Error(fmt.Sprintf("不存在%v的客户端,数据解析不予处理", ck))
|
||||
return
|
||||
}
|
||||
|
||||
connType := state_proto.TrainConnState_PC_SIM_A
|
||||
if clientKey == "B" {
|
||||
connType = state_proto.TrainConnState_PC_SIM_B
|
||||
}
|
||||
baseMsg := &message.TrainPcSimBaseMessage{}
|
||||
err := baseMsg.Decode(data)
|
||||
if err != nil {
|
||||
slog.Error("车载pc仿真接受数据解析失败 ")
|
||||
return
|
||||
}
|
||||
|
||||
switch baseMsg.Type {
|
||||
//case RECIVE_TRAIN_CREATE_REMOVE:
|
||||
// pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
|
||||
case RECIVE_TRAIN_INTERFACE_CABINET_OUTR:
|
||||
d.trainPcSimManage.TrainPcSimDigitalOutInfoHandle(connType, baseMsg.Data)
|
||||
case RECIVE_TRAIN_INTERFACE_CABINET_OUTR_BACK:
|
||||
d.trainPcSimManage.TrainPcSimDigitalReportHandle(connType, baseMsg.Data)
|
||||
case RECIVE_TRAIN_QUERY_STATUS:
|
||||
d.trainPcSimManage.TrainBtmQuery(connType, baseMsg.Data)
|
||||
case RECIVE_TRAIN_MOCK_DATA:
|
||||
d.trainPcSimManage.TrainPcSimMockInfo(connType, baseMsg.Data)
|
||||
//case RECIVE_TRAIN_DOOR_MODE:
|
||||
// pc.trainPcSimManage.TrainDoorModeHandle(baseMsg.Data[0])
|
||||
}
|
||||
}*/
|
||||
|
@ -74,7 +74,7 @@ func initTrainVobc(trainLoad int64, trainIsUp bool) (*state_proto.TrainVobcState
|
||||
}
|
||||
|
||||
// 初始化列车控制数据
|
||||
func initTrainTcc(vs *VerifySimulation, runDir bool) *state_proto.TrainControlState {
|
||||
func initTrainTcc(vs *VerifySimulation, runDir bool, breaking int32) *state_proto.TrainControlState {
|
||||
var tccGI *data_proto.TccGraphicStorage
|
||||
for _, id := range vs.MapIds {
|
||||
if QueryGiType(id) == data_proto.PictureType_TrainControlCab {
|
||||
@ -92,7 +92,7 @@ func initTrainTcc(vs *VerifySimulation, runDir bool) *state_proto.TrainControlSt
|
||||
}
|
||||
for _, b := range tccGI.TccHandles {
|
||||
if b.Code == QYSB {
|
||||
tcc.PushHandler = &state_proto.TrainControlState_PushHandler{Id: b.Common.Id, Val: 0}
|
||||
tcc.PushHandler = &state_proto.TrainControlState_PushHandler{Id: b.Common.Id, Val: -100}
|
||||
}
|
||||
}
|
||||
ds := make([]*state_proto.TrainControlState_DriverKeySwitch, 0)
|
||||
|
@ -103,7 +103,7 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
|
||||
|
||||
//status.TrainActiveDirection = trainActDir
|
||||
|
||||
status.Tcc = initTrainTcc(vs, status.TrainRunUp)
|
||||
status.Tcc = initTrainTcc(vs, status.TrainRunUp, DEFAULT_BRAKE_FORCE)
|
||||
status.VobcBtm = &state_proto.VobcBtmState{TelegramState: make([]*state_proto.VobcBtmState_TelegramState, 0), History: make(map[uint32]*state_proto.VobcBtmState_VobcBtmHistoryState)}
|
||||
slog.Debug("列车初始化", "trainIndex", trainIndex, "linkId", linkId, "loffset", loffset)
|
||||
linkIdInt, _ := strconv.Atoi(linkId)
|
||||
@ -358,7 +358,7 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
|
||||
sta.DynamicState.Acceleration = info.Acceleration
|
||||
|
||||
sta.DynamicState.Displacement = int32(info.Displacement)
|
||||
pluseCount(sta)
|
||||
pluseCount(sta, info.HeadSpeed1, info.HeadSpeed2, info.TailSpeed1, info.TailSpeed2)
|
||||
return sta
|
||||
}
|
||||
|
||||
@ -414,27 +414,41 @@ func formatSpeedTime(s int32) int32 {
|
||||
//d3, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", s), 64)
|
||||
return int32(math.Abs(math.Round(float64(s))))
|
||||
}
|
||||
func pluseCount(sta *state_proto.TrainState) {
|
||||
func formatSpeedTime2(s int32) uint32 {
|
||||
return uint32(math.Abs(float64(float32(s) / 3.6 / 100 * 1000)))
|
||||
}
|
||||
|
||||
const (
|
||||
aa = 0x79
|
||||
)
|
||||
|
||||
func pluseCount(sta *state_proto.TrainState, h1, h2, t1, t2 float32) {
|
||||
if sta.PluseCount == nil {
|
||||
return
|
||||
}
|
||||
if sta.TrainRunUp {
|
||||
p1 := uint32(formatSpeedTime(sta.DynamicState.HeadSensorSpeed1 * RECEIVE_DYNAMIC_DATA_RATE))
|
||||
p2 := uint32(formatSpeedTime(sta.DynamicState.HeadSensorSpeed2 * RECEIVE_DYNAMIC_DATA_RATE))
|
||||
//p1 := formatSpeedTime2(sta.DynamicState.HeadSensorSpeed1)
|
||||
//p2 := formatSpeedTime2(sta.DynamicState.HeadSensorSpeed2)
|
||||
|
||||
//p1 := uint32(formatSpeedTime(sta.DynamicState.HeadSensorSpeed1 * RECEIVE_DYNAMIC_DATA_RATE))
|
||||
//p2 := uint32(formatSpeedTime(sta.DynamicState.HeadSensorSpeed2 * RECEIVE_DYNAMIC_DATA_RATE))
|
||||
|
||||
if sta.TrainEndsA.SpeedSensorEnableA {
|
||||
sta.PluseCount.PulseCount1 = sta.PluseCount.PulseCount1 + p1
|
||||
sta.PluseCount.PulseCount1 = sta.PluseCount.PulseCount1 + uint32(h1*1000*0.08)
|
||||
}
|
||||
if sta.TrainEndsA.SpeedSensorEnableB {
|
||||
sta.PluseCount.PulseCount2 = sta.PluseCount.PulseCount2 + p2
|
||||
sta.PluseCount.PulseCount2 = sta.PluseCount.PulseCount2 + uint32(h2*1000*0.08)
|
||||
}
|
||||
} else {
|
||||
t1 := uint32(formatSpeedTime(sta.DynamicState.TailSensorSpeed1 * RECEIVE_DYNAMIC_DATA_RATE))
|
||||
t2 := uint32(formatSpeedTime(sta.DynamicState.TailSensorSpeed2 * RECEIVE_DYNAMIC_DATA_RATE))
|
||||
//t1 := uint32(formatSpeedTime(sta.DynamicState.TailSensorSpeed1 * RECEIVE_DYNAMIC_DATA_RATE))
|
||||
//t2 := uint32(formatSpeedTime(sta.DynamicState.TailSensorSpeed2 * RECEIVE_DYNAMIC_DATA_RATE))
|
||||
//t1 := formatSpeedTime2(sta.DynamicState.HeadSensorSpeed1)
|
||||
//t2 := formatSpeedTime2(sta.DynamicState.HeadSensorSpeed2)
|
||||
if sta.TrainEndsB.SpeedSensorEnableA {
|
||||
sta.PluseCount.PulseCount1 = sta.PluseCount.PulseCount1 + t1
|
||||
sta.PluseCount.PulseCount1 = sta.PluseCount.PulseCount1 + uint32(t1*1000*0.08)
|
||||
}
|
||||
if sta.TrainEndsB.SpeedSensorEnableB {
|
||||
sta.PluseCount.PulseCount2 = sta.PluseCount.PulseCount2 + t2
|
||||
sta.PluseCount.PulseCount2 = sta.PluseCount.PulseCount2 + uint32(t2*1000*0.08)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ func trainControlEB(vobc *state_proto.TrainVobcState, tcc *state_proto.TrainCont
|
||||
vobc.EmergencyBrakingStatus = true
|
||||
vobc.TractionForce = 0
|
||||
vobc.BrakeForce = DEFAULT_BRAKE_FORCE
|
||||
|
||||
return []train_pc_sim.TrainControlEvent{{Command: message.OUTER_EMERGENCY_BRAKE, Status: 1}, {Command: message.TRAIN_BRAKE_STATE, Status: 1}} //紧急制动
|
||||
//return []train_pc_sim.TrainControlEvent{{Command: message.CONFIRM, Status: 1}} //紧急制动
|
||||
}
|
||||
|
||||
// 列车方向
|
||||
@ -252,101 +252,12 @@ func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(connType state_proto.T
|
||||
slog.Error("车载输出数字量,,列车未连接车载pc仿真")
|
||||
return
|
||||
}
|
||||
//buf := bytes.NewBuffer(data)
|
||||
vobc := train.VobcState
|
||||
|
||||
//cutTraction, _ := buf.ReadByte() //切牵引
|
||||
//trainDoorOutLed, _ := buf.ReadByte() //车门外指示灯
|
||||
//stopBrakeAppend, _ := buf.ReadByte() //停放制动施加
|
||||
//emergentBrake, _ := buf.ReadByte() //紧急制动
|
||||
//leftOpenDoor, _ := buf.ReadByte() //开左门允许
|
||||
//rightOpenDoor, _ := buf.ReadByte() //开右门允许
|
||||
//closeRightDoor, _ := buf.ReadByte() //关右门
|
||||
//doorAlwaysClosed, _ := buf.ReadByte() //车门保持关闭
|
||||
//localAtpControl, _ := buf.ReadByte() //本端ATP控车
|
||||
//atoMode, _ := buf.ReadByte() //ATO模式
|
||||
//atoTractionCommandOut, _ := buf.ReadByte() //ATO牵引命令输出
|
||||
//atoTractionCommand1, _ := buf.ReadByte() //ATO牵引指令1
|
||||
//atoTractionCommand2, _ := buf.ReadByte() //ATO牵引指令2
|
||||
//atoTractionCommand3, _ := buf.ReadByte() //ATO牵引指令3
|
||||
//atoBrakeCommand, _ := buf.ReadByte() //ATO制动命令输出
|
||||
//skipCommand, _ := buf.ReadByte() //跳跃指令
|
||||
//direction1, _ := buf.ReadByte() //列车方向1
|
||||
//direction2, _ := buf.ReadByte() //列车方向2
|
||||
//atoLazyCommandOut, _ := buf.ReadByte() //ATO惰行命令输出
|
||||
//sleepCommand, _ := buf.ReadByte() //休眠指令
|
||||
//wakeUpCommand, _ := buf.ReadByte() //唤醒指令
|
||||
//toPullTrainLed, _ := buf.ReadByte() //ATO发车指示灯
|
||||
//arLightCommand, _ := buf.ReadByte() //AR灯命令
|
||||
//atoAlwaysBrake, _ := buf.ReadByte() //ATO保持制动
|
||||
//atoOpenLeftDoor, _ := buf.ReadByte() //ATO开左门
|
||||
//atoOpenRightDoor, _ := buf.ReadByte() //ATO开右门
|
||||
//atoCloseLeftDoor, _ := buf.ReadByte() //ATO关左门
|
||||
//ariverActive, _ := buf.ReadByte() //驾驶室激活
|
||||
//noSpeedSigle, _ := buf.ReadByte() //零速信号
|
||||
//famMode, _ := buf.ReadByte() //FAM模式
|
||||
//camMode, _ := buf.ReadByte() //CAM模式
|
||||
//trainStartedLed, _ := buf.ReadByte() //列车启动指示灯
|
||||
//mostUseBrake, _ := buf.ReadByte() //常用制动
|
||||
//splittingOut, _ := buf.ReadByte() //过分相输出
|
||||
//modeRelay, _ := buf.ReadByte() //模式继电器
|
||||
//tractionEffective, _ := buf.ReadByte() //牵引有效
|
||||
//brakeEffective, _ := buf.ReadByte() //制动有效
|
||||
//lifeDoorUsed, _ := buf.ReadByte() //逃生门使能
|
||||
//brakeQuarantine, _ := buf.ReadByte() //制动隔离
|
||||
//stopNotAllBrake, _ := buf.ReadByte() //停放制动缓解
|
||||
|
||||
//vobc.TractionSafetyCircuit = message.IsTrueForByte(cutTraction)
|
||||
//vobc.TrainDoorOutLed = message.IsTrueForByte(trainDoorOutLed) //? 说明暂无此属性
|
||||
//vobc.ParkingBrakeStatus = message.IsTrueForByte(stopBrakeAppend)
|
||||
//vobc.EmergencyBrakingStatus = message.IsTrueForByte(emergentBrake)
|
||||
//vobc.LeftDoorOpenCommand = message.IsTrueForByte(leftOpenDoor)
|
||||
//vobc.RightDoorOpenCommand = message.IsTrueForByte(rightOpenDoor)
|
||||
//vobc.RightDoorCloseCommand = message.IsTrueForByte(closeRightDoor)
|
||||
//vobc.AllDoorClose = message.IsTrueForByte(doorAlwaysClosed)
|
||||
|
||||
//vobc.LocalAtpControl = message.IsTrueForByte(localAtpControl) //?
|
||||
//vobc.Ato = message.IsTrueForByte(atoMode)
|
||||
//vobc.AtoTractionCommandOut = message.IsTrueForByte(atoTractionCommandOut) //?
|
||||
//vobc.AtoTractionCommand1 = message.IsTrueForByte(atoTractionCommand1) //?
|
||||
//vobc.AtoTractionCommand2 = message.IsTrueForByte(atoTractionCommand2) //?
|
||||
//vobc.AtoTractionCommand3 = message.IsTrueForByte(atoTractionCommand3) //?
|
||||
//vobc.AtoBrakeCommand = message.IsTrueForByte(atoBrakeCommand) //?
|
||||
//vobc.JumpStatus = message.IsTrueForByte(skipCommand)
|
||||
|
||||
//vobc.DirectionForward = message.IsTrueForByte(direction1)
|
||||
//vobc.DirectionBackward = message.IsTrueForByte(direction2)
|
||||
//vobc.AtoLazyCommandOut = message.IsTrueForByte(atoLazyCommandOut) //?
|
||||
//vobc.SleepBtn = message.IsTrueForByte(sleepCommand)
|
||||
//vobc.WakeUpBtn = message.IsTrueForByte(wakeUpCommand)
|
||||
//vobc.AtoSendTrainBtn = message.IsTrueForByte(toPullTrainLed)
|
||||
//vobc.TurnbackStatus = message.IsTrueForByte(arLightCommand) //?
|
||||
//vobc.AtoAlwaysBrake = message.IsTrueForByte(atoAlwaysBrake) //?
|
||||
|
||||
//vobc.AtoOpenLeftDoor = message.IsTrueForByte(atoOpenLeftDoor) //?
|
||||
//vobc.AtoOpenRightDoor = message.IsTrueForByte(atoOpenRightDoor) //?
|
||||
//vobc.AtoCloseLeftDoor = message.IsTrueForByte(atoCloseLeftDoor) //?
|
||||
//vobc.Tc1Active = message.IsTrueForByte(ariverActive)
|
||||
//vobc.NoSpeedSigle = message.IsTrueForByte(noSpeedSigle) //?
|
||||
//vobc.Fam = message.IsTrueForByte(famMode)
|
||||
//vobc.Cam = message.IsTrueForByte(camMode)
|
||||
//vobc.TrainStartedLed = message.IsTrueForByte(trainStartedLed) //?
|
||||
|
||||
//vobc.MostUseBrake = message.IsTrueForByte(mostUseBrake) //? //常用制动
|
||||
//vobc.SplittingOut = message.IsTrueForByte(splittingOut) //? //过分相输出
|
||||
//vobc.ModeRelay = message.IsTrueForByte(modeRelay) //? //模式继电器
|
||||
//vobc.TractionEffective = message.IsTrueForByte(tractionEffective) //? //牵引有效
|
||||
//vobc.BrakeEffective = message.IsTrueForByte(brakeEffective) //? //制动有效
|
||||
//vobc.LifeDoorState = message.IsTrueForByte(lifeDoorUsed) //逃生门使能
|
||||
//vobc.BrakeQuarantine = message.IsTrueForByte(brakeQuarantine) //? //制动隔离
|
||||
//vobc.StopNotAllBrake = message.IsTrueForByte(stopNotAllBrake) //? //停放制动缓解
|
||||
trainPcSimDigitalOutInfoHandleCode39_32(data[0], vobc)
|
||||
trainPcSimDigitalOutInfoHandleCode31_24(connType, data[1], vobc)
|
||||
trainPcSimDigitalOutInfoHandleCode39_32(data[4], vobc)
|
||||
trainPcSimDigitalOutInfoHandleCode31_24(connType, data[3], vobc)
|
||||
trainPcSimDigitalOutInfoHandleCode23_16(data[2], vobc)
|
||||
trainPcSimDigitalOutInfoHandleCode15_8(data[3], vobc)
|
||||
trainPcSimDigitalOutInfoHandleCode7_0(data[4], vobc)
|
||||
//cm := &message.TrainControlMsg{TrainId: train.Id, ControlInfo: vobc}
|
||||
//dynamics.Default().SendTrainControl(cm)
|
||||
trainPcSimDigitalOutInfoHandleCode15_8(data[1], vobc)
|
||||
trainPcSimDigitalOutInfoHandleCode7_0(data[0], vobc)
|
||||
}
|
||||
func trainPcSimDigitalOutInfoHandleCode39_32(d byte, vobc *state_proto.TrainVobcState) {
|
||||
vobc.MostUseBrake = message.IsTrueForByte(message.GetBit(d, 0)) //? 常用制动
|
||||
@ -398,10 +309,10 @@ func trainPcSimDigitalOutInfoHandleCode15_8(d byte, vobc *state_proto.TrainVobcS
|
||||
|
||||
}
|
||||
func trainPcSimDigitalOutInfoHandleCode7_0(d byte, vobc *state_proto.TrainVobcState) {
|
||||
vobc.TractionSafetyCircuit = message.IsTrueForByte(message.GetBit(d, 0)) //切牵引
|
||||
vobc.TractionSafetyCircuit = message.AtpLowPowerByte(message.GetBit(d, 0)) //切牵引
|
||||
vobc.TrainDoorOutLed = message.IsTrueForByte(message.GetBit(d, 1)) //? 车门外指示灯
|
||||
vobc.ParkingBrakeStatus = message.IsTrueForByte(message.GetBit(d, 2)) //停放制动施加
|
||||
vobc.EmergencyBrakingStatus = message.IsTrueForByte(message.GetBit(d, 3)) //紧急制动
|
||||
vobc.EmergencyBrakingStatus = message.AtpLowPowerByte(message.GetBit(d, 3)) //紧急制动
|
||||
vobc.LeftDoorOpenCommand = message.IsTrueForByte(message.GetBit(d, 4)) //开左门允许
|
||||
vobc.RightDoorOpenCommand = message.IsTrueForByte(message.GetBit(d, 5)) //开右门允许
|
||||
vobc.RightDoorCloseCommand = message.IsTrueForByte(message.GetBit(d, 6)) //关右门
|
||||
@ -502,8 +413,8 @@ func (s *VerifySimulation) TrainBtmQuery(connType state_proto.TrainConnState_Tra
|
||||
return
|
||||
}
|
||||
|
||||
trainAtm := message.NewCanetFrame(data, true)
|
||||
atpReq := &message.AtpRequestFrame{}
|
||||
trainAtm := message.NewCanetFrame2(data, true)
|
||||
atpReq := &message.AtpRequestFrame{IsTrainPcSim: true}
|
||||
if !atpReq.Decode(trainAtm) {
|
||||
slog.Warn("列车pc驾驶模拟-CanetFrame解码成AtpRequestFrame失败", "CanetFrame", trainAtm.String())
|
||||
return
|
||||
@ -523,18 +434,23 @@ func (s *VerifySimulation) TrainBtmQuery(connType state_proto.TrainConnState_Tra
|
||||
telCount := strings.Count(train.BtmState.Telegram, "00")
|
||||
if telCount >= balise_const.UserTelegramByteLen {
|
||||
//无数据
|
||||
queryData := make([]byte, 0)
|
||||
queryDataStr := make([]string, 0)
|
||||
queryDataStr = append(queryDataStr, hex.EncodeToString(btmRepFrame.Encode().Encode2()))
|
||||
queryDataStr = append(queryDataStr, hex.EncodeToString(timeSyncF.Encode().Encode2()))
|
||||
train_pc_sim.Default().SendBaliseData2(train, message.RECIVE_TRAIN_BTM_NOT_DATA, queryDataStr)
|
||||
|
||||
/* queryData := make([]byte, 0)
|
||||
queryData = append(queryData, btmRepFrame.Encode().Encode()...)
|
||||
queryData = append(queryData, timeSyncF.Encode().Encode()...)
|
||||
train_pc_sim.Default().SendBaliseData(train, message.RECIVE_TRAIN_BTM_NOT_DATA, queryData)
|
||||
train_pc_sim.Default().SendBaliseData(train, message.RECIVE_TRAIN_BTM_NOT_DATA, queryData)*/
|
||||
} else {
|
||||
//有数据
|
||||
aliseData, _ := hex.DecodeString(train.BtmState.Telegram)
|
||||
statusDataCf, statusDataCfOk := message.CreateBtmRspFramesData(btmRepFrame, aliseData, false, cl.TkNow(), cl.TkNow(), cl.TkNow(), true)
|
||||
if statusDataCfOk {
|
||||
queryData := make([]byte, 0)
|
||||
queryData = append(queryData, btmRepFrame.Encode().Encode()...)
|
||||
queryData = append(queryData, timeSyncF.Encode().Encode()...)
|
||||
queryData = append(queryData, btmRepFrame.Encode().Encode2()...)
|
||||
queryData = append(queryData, timeSyncF.Encode().Encode2()...)
|
||||
queryData = append(queryData, statusDataCf...) //数据帧包含结束帧
|
||||
train.BtmState.BaliseTelegramForPcSimResend = fmt.Sprintf("%X", statusDataCf)
|
||||
train_pc_sim.Default().SendBaliseData(train, message.RECIVE_TRAIN_BTM_HAS_DATA, queryData)
|
||||
@ -546,7 +462,7 @@ func (s *VerifySimulation) TrainBtmQuery(connType state_proto.TrainConnState_Tra
|
||||
}
|
||||
|
||||
func createBtmStatus(canIdSn byte, btmState *state_proto.BTMState, atpReq *message.AtpRequestFrame, cl can_btm.BtmClock) *message.BtmStatusRspFrame {
|
||||
statusF := message.NewBtmStatusRspFrame(canIdSn, true)
|
||||
statusF := message.NewBtmStatusRspFrame(canIdSn, atpReq.IsTrainPcSim)
|
||||
//btmStatus := aa(train, atpReq)
|
||||
|
||||
statusF.PowerAmplifierOn = true
|
||||
@ -560,7 +476,9 @@ func createBtmStatus(canIdSn byte, btmState *state_proto.BTMState, atpReq *messa
|
||||
if btmState.AboveBalise {
|
||||
statusF.DetailedCode = 0x07
|
||||
}
|
||||
statusF.Dsn = byte(btmState.DataSerialNumber)
|
||||
dsn := byte(btmState.DataSerialNumber) + 1
|
||||
btmState.DataSerialNumber = uint32(dsn)
|
||||
statusF.Dsn = dsn
|
||||
return statusF
|
||||
}
|
||||
|
||||
@ -576,14 +494,11 @@ func (s *VerifySimulation) ObtainTrainDigitalMockData(train *state_proto.TrainSt
|
||||
if vs.Tc1Active || vs.Tc2Active {
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.KEY_STATE, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //钥匙激活
|
||||
}
|
||||
if tcc.PushHandler.Val == 0 {
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.DIR_ZERO_FORWARD, 0}, Type: message.SENDER_TRAIN_OUTR_INFO}) //手柄零位方向向前
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.TRAIN_BRAKE_STATE, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //手柄零位方向向前
|
||||
}
|
||||
|
||||
if vs.BrakingStatus {
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.TRAIN_BRAKE_STATE, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //列车制动状态
|
||||
}
|
||||
//if tcc.Ebutton.Passed {
|
||||
|
||||
if vs.EmergencyBrakingStatus {
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.OUTER_EMERGENCY_BRAKE, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //紧急制动
|
||||
}
|
||||
@ -599,10 +514,17 @@ func (s *VerifySimulation) ObtainTrainDigitalMockData(train *state_proto.TrainSt
|
||||
}
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.CLOSE_RIGHT_DOOR, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //关右门按钮
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.CLOSE_LEFT_DOOR, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //关左门按钮
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.CONFIRM, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //确认摁钮
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.TRAIN_INTEGRITY, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //列车完整性
|
||||
//msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.LEFT_DOOR_STATE, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //左门状态
|
||||
//msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.RIGHT_DOOR_STATE, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //右门状态
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.DOOR_LOCK_STATE, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //右门状态
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.DOOR_LOCK_STATE, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //车门锁闭状态
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.OBSTACLE_CHECK, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //障碍物检测按钮
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.BRAKE_HEAVY_FAULT, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //制动重故障
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.EMERGENT_HANDLE_DOWN, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //紧急手柄拉下
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.LIFE_DOOR, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //逃生门状态
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{message.ATP_CUT, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //atp切除
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{39, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //非制动
|
||||
//msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{40, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //本端机械钩
|
||||
//msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{41, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}) //对端机械钩
|
||||
msgArr = append(msgArr, message.TrainPcSimBaseMessage{Data: []byte{}, Type: message.RECIVE_TRAIN_BTN_CLEAR_ALL_PRE_DATA}) //清空应答器
|
||||
train.BtmState = nil
|
||||
return msgArr
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user