日志调整及现场测试
This commit is contained in:
parent
bff5c61cf4
commit
bec948357a
@ -194,7 +194,7 @@ type VehiclePCSimConfig struct {
|
||||
Open bool `json:"open" description:"是否开启"`
|
||||
PcSimIp string `json:"pcSimIp" description:"pc仿真平台通信ip"`
|
||||
PcSimPort uint32 `json:"pcSimPort" description:"pc仿真平台通信端口"`
|
||||
LocalTestingPort uint32 `json:"localTestingPort" description:"本地测试端口"`
|
||||
//LocalTestingPort uint32 `json:"localTestingPort" description:"本地测试端口"`
|
||||
}
|
||||
|
||||
// CheckAddress 检测目标源地址目的地址是否在配置中
|
||||
|
7
third_party/train_pc_sim/train_pc_sim.go
vendored
7
third_party/train_pc_sim/train_pc_sim.go
vendored
@ -143,7 +143,6 @@ type trainPcSimService struct {
|
||||
func (d *trainPcSimService) readError(err error) {
|
||||
slog.Error("连接车载pc仿真tcp服务断开", err)
|
||||
d.updateState(tpapi.ThirdPartyState_Broken)
|
||||
|
||||
}
|
||||
func (d *trainPcSimService) newCloseAllConn() {
|
||||
for _, rd := range d.newPcSimclientMap {
|
||||
@ -323,13 +322,17 @@ func (d *trainPcSimService) CreateOrRemoveSpeedPLace(train *state_proto.TrainSta
|
||||
}
|
||||
func (d *trainPcSimService) CreateOrRemoveTrain(train *state_proto.TrainState, msgType byte, data []byte) error {
|
||||
clientKey := FindTrainPcSimClientKey(train)
|
||||
log := "删除列车"
|
||||
if msgType == RECIVE_TRAIN_CREATE_REMOVE && data[0] == 0x01 {
|
||||
log = "创建列车"
|
||||
d.initConn(clientKey)
|
||||
}
|
||||
msg := &message.TrainPcSimBaseMessage{Data: data, Type: uint16(msgType)}
|
||||
rd := d.newPcSimclientMap[clientKey]
|
||||
if rd != nil {
|
||||
err := rd.tcpClient.Send(msg.Encode())
|
||||
sd := msg.Encode()
|
||||
slog.Info(fmt.Sprintf("%v-列车号:%v,发送数据:%v", log, train.Id, hex.EncodeToString(sd)))
|
||||
err := rd.tcpClient.Send(sd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ func TrainConnTypeUpdate(vs *VerifySimulation, ct *dto.TrainConnThirdDto) {
|
||||
train.ConnState.Conn = true
|
||||
train.ConnState.ConnType = ct.ConnType
|
||||
if ct.ConnType == state_proto.TrainConnState_PC_SIM_A || ct.ConnType == state_proto.TrainConnState_PC_SIM_B {
|
||||
err := TrainPcSimConnOrRemoveHandle(train)
|
||||
err := TrainPcSimConnOrRemoveHandle(train, true)
|
||||
if err != nil {
|
||||
train.ConnState.Conn = false
|
||||
train.ConnState.ConnType = state_proto.TrainConnState_NONE
|
||||
@ -184,7 +184,7 @@ func TrainUnConn(vs *VerifySimulation, trainId string) {
|
||||
panic(sys_error.New(fmt.Sprintf("列车【%s】不存在", trainId)))
|
||||
}
|
||||
train := data.(*state_proto.TrainState)
|
||||
err := TrainPcSimConnOrRemoveHandle(train)
|
||||
err := TrainPcSimConnOrRemoveHandle(train, false)
|
||||
if err != nil {
|
||||
panic(sys_error.New("未连接车载PC仿真,无法断开连接"))
|
||||
}
|
||||
@ -462,7 +462,7 @@ func removeTrain(vs *VerifySimulation, trainId string, train *state_proto.TrainS
|
||||
}
|
||||
if train.ConnState.Conn {
|
||||
train.ConnState.Conn = false
|
||||
err = TrainPcSimConnOrRemoveHandle(train)
|
||||
err = TrainPcSimConnOrRemoveHandle(train, false)
|
||||
if err != nil {
|
||||
train.ConnState.Conn = true
|
||||
return err
|
||||
|
@ -458,15 +458,14 @@ func (s *VerifySimulation) TrainPcSimDigitalReportHandle(connType state_proto.Tr
|
||||
}
|
||||
|
||||
// 创建/删除列车
|
||||
func TrainPcSimConnOrRemoveHandle(train *state_proto.TrainState) error {
|
||||
func TrainPcSimConnOrRemoveHandle(train *state_proto.TrainState, create bool) error {
|
||||
|
||||
var data byte = 0x01
|
||||
if train.ConnState.Conn == false {
|
||||
data = 0x00
|
||||
var data byte = 0x00
|
||||
if create {
|
||||
data = 0x01
|
||||
}
|
||||
connState := train.ConnState
|
||||
if connState.ConnType == state_proto.TrainConnState_PC_SIM_A || connState.ConnType == state_proto.TrainConnState_PC_SIM_B {
|
||||
|
||||
crErr := train_pc_sim.Default().CreateOrRemoveTrain(train, train_pc_sim.RECIVE_TRAIN_CREATE_REMOVE, []byte{data})
|
||||
if crErr != nil {
|
||||
return crErr
|
||||
|
Loading…
Reference in New Issue
Block a user