日志调整及现场测试

This commit is contained in:
tiger_zhou 2024-06-13 14:16:52 +08:00
parent bff5c61cf4
commit bec948357a
4 changed files with 19 additions and 17 deletions

View File

@ -190,11 +190,11 @@ type VehiclePCSimConfig2 struct {
}
type VehiclePCSimConfig struct {
TrainEnds bool `json:"trainEnds" description:"列车端点A?"`
Open bool `json:"open" description:"是否开启"`
PcSimIp string `json:"pcSimIp" description:"pc仿真平台通信ip"`
PcSimPort uint32 `json:"pcSimPort" description:"pc仿真平台通信端口"`
LocalTestingPort uint32 `json:"localTestingPort" description:"本地测试端口"`
TrainEnds bool `json:"trainEnds" description:"列车端点A?"`
Open bool `json:"open" description:"是否开启"`
PcSimIp string `json:"pcSimIp" description:"pc仿真平台通信ip"`
PcSimPort uint32 `json:"pcSimPort" description:"pc仿真平台通信端口"`
//LocalTestingPort uint32 `json:"localTestingPort" description:"本地测试端口"`
}
// CheckAddress 检测目标源地址目的地址是否在配置中

View File

@ -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
}
@ -407,11 +410,11 @@ func (d *trainPcSimService) SendDriverActive(train *state_proto.TrainState) {
}
}
da := msg.Encode()
slog.Info("发送驾驶激活 列车", train.Id, "数据", hex.EncodeToString(da))
slog.Info("发送驾驶激活列车", train.Id, "数据", hex.EncodeToString(da))
err := rd.tcpClient.Send(da)
//err := client.Send(da)
if err != nil {
slog.Error("发送驾驶激活 列车", train.Id, "数据", hex.EncodeToString(da), err)
slog.Error("发送驾驶激活列车", train.Id, "数据", hex.EncodeToString(da), err)
}
}
func (d *trainPcSimService) SendHandleSwitch(oldTraction, oldBrakeForce int64, tractionState bool, train *state_proto.TrainState) {

View File

@ -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

View File

@ -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