rts-sim-testing-service/third_party/train_pc_sim/train_pc_receive_handler.go

54 lines
1.8 KiB
Go
Raw Normal View History

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])
}
}
}