package train_pc_sim import ( "encoding/hex" "fmt" "joylink.club/bj-rtsts-server/dto/state_proto" "joylink.club/bj-rtsts-server/third_party/message" "joylink.club/bj-rtsts-server/third_party/tcp" "log/slog" ) type trainPcReciverData struct { clientKey string tcpClient *tcp.TcpClient pcSimManage TrainPcSimManage isSleep bool ebCheckIndex uint8 ebCheckTime int64 } func (rd *trainPcReciverData) receiverDataHandle(n int, data []byte) { /*if !rd.isSleep { time.Sleep(time.Second * 5) rd.isSleep = true }*/ 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) case message.RECIVE_TRAIN_MOCK_DATA: rd.pcSimManage.TrainPcSimMockInfo(connType, baseMsg.Data) //case RECIVE_TRAIN_DOOR_MODE: // pc.trainPcSimManage.TrainDoorModeHandle(baseMsg.Data[0]) } } }