2024-07-04 09:26:37 +08:00
|
|
|
|
package train_pc_sim
|
|
|
|
|
|
|
|
|
|
import (
|
2024-07-11 14:58:34 +08:00
|
|
|
|
"encoding/hex"
|
|
|
|
|
"fmt"
|
2024-07-04 09:26:37 +08:00
|
|
|
|
"joylink.club/bj-rtsts-server/dto/state_proto"
|
|
|
|
|
"joylink.club/bj-rtsts-server/third_party/message"
|
|
|
|
|
"joylink.club/bj-rtsts-server/third_party/tcp"
|
2024-07-11 14:58:34 +08:00
|
|
|
|
"log/slog"
|
2024-07-04 09:26:37 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type trainPcReciverData struct {
|
2024-07-15 15:00:33 +08:00
|
|
|
|
clientKey string
|
|
|
|
|
tcpClient *tcp.TcpClient
|
|
|
|
|
pcSimManage TrainPcSimManage
|
|
|
|
|
isSleep bool
|
|
|
|
|
ebCheckIndex uint8
|
|
|
|
|
ebCheckTime int64
|
2024-07-04 09:26:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (rd *trainPcReciverData) receiverDataHandle(n int, data []byte) {
|
2024-07-15 15:00:33 +08:00
|
|
|
|
/*if !rd.isSleep {
|
2024-07-11 14:58:34 +08:00
|
|
|
|
time.Sleep(time.Second * 5)
|
|
|
|
|
rd.isSleep = true
|
2024-07-15 15:00:33 +08:00
|
|
|
|
}*/
|
2024-07-04 09:26:37 +08:00
|
|
|
|
receiveData := data[:n]
|
2024-07-11 14:58:34 +08:00
|
|
|
|
hexSourceData := hex.EncodeToString(receiveData)
|
2024-07-15 15:00:33 +08:00
|
|
|
|
slog.Info(fmt.Sprintf("接受列车激活端:%v pc仿真接收数据:%v", rd.clientKey, hexSourceData))
|
2024-07-04 09:26:37 +08:00
|
|
|
|
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 {
|
2024-07-15 15:00:33 +08:00
|
|
|
|
//slog.Info(fmt.Sprintf("pc仿真接收数据:%v,类型:%X", hexSourceData, baseMsg.Type))
|
2024-07-04 09:26:37 +08:00
|
|
|
|
switch baseMsg.Type {
|
|
|
|
|
//case RECIVE_TRAIN_CREATE_REMOVE:
|
|
|
|
|
// pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
|
2024-07-11 14:58:34 +08:00
|
|
|
|
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR:
|
|
|
|
|
rd.pcSimManage.TrainPcSimDigitalOutInfoHandle(connType, baseMsg.Data)
|
2024-07-04 09:26:37 +08:00
|
|
|
|
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])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|