列车pc仿真调整

This commit is contained in:
tiger_zhou 2024-05-08 10:00:53 +08:00
parent a298e11da2
commit 7ed8fcbed7
3 changed files with 20 additions and 5 deletions

View File

@ -29,6 +29,7 @@ func (r *TrainControlMsg) Encode() []byte {
if !r.FromVobc {
ls := r.ControlInfo.LifeSignal
r.ControlInfo.LifeSignal = ls + 1
r.ControlInfo.UpdateTime = time.Now().UnixMilli()
}
//data := make([]byte, 0)
//data = binary.BigEndian.AppendUint16(data, uint16(r.ControlInfo.LifeSignal))

View File

@ -6,6 +6,14 @@ import (
"joylink.club/bj-rtsts-server/third_party/message"
)
const (
SKQYS1 = "SKQYS1" //驾驶端1
SKQYS2 = "SKQYS2" //驾驶端2
JJZD = "JJZD" //紧急停车
QHFXKZ = "QHFXKZ" //驾驶方向
QYSB = "QYSB" //牵引制动手柄
)
// 获取列车控制图形数据
func findTrainTccGraphicData(vs *VerifySimulation) *data_proto.TccGraphicStorage {
var tccGI *data_proto.TccGraphicStorage
@ -52,7 +60,7 @@ func findTrainTccGraphicDataHandler(tccG *data_proto.TccGraphicStorage, id uint3
}
// 初始化列车控制数据
func initTrainTcc(vs *VerifySimulation) *state_proto.TrainControlState {
func initTrainTcc(vs *VerifySimulation, runDir bool) *state_proto.TrainControlState {
var tccGI *data_proto.TccGraphicStorage
for _, id := range vs.MapIds {
if QueryGiType(id) == data_proto.PictureType_TrainControlCab {
@ -64,12 +72,12 @@ func initTrainTcc(vs *VerifySimulation) *state_proto.TrainControlState {
tcc := &state_proto.TrainControlState{}
if tccGI != nil {
for _, b := range tccGI.TccButtons {
if b.Code == "JJZD" {
if b.Code == JJZD {
tcc.Ebutton = &state_proto.TrainControlState_EmergentButton{Id: b.Common.Id, Passed: false}
}
}
for _, b := range tccGI.TccHandles {
if b.Code == "QYSB" {
if b.Code == QYSB {
tcc.PushHandler = &state_proto.TrainControlState_PushHandler{Id: b.Common.Id, Val: 0}
}
}
@ -77,7 +85,9 @@ func initTrainTcc(vs *VerifySimulation) *state_proto.TrainControlState {
for _, b := range tccGI.TccKeys {
if b.GetType() == data_proto.TccKey_driverControllerActivationClint {
val := false
if b.Code == "SKQYS1" {
if b.Code == SKQYS1 && runDir {
val = true
} else if b.Code == SKQYS2 && !runDir {
val = true
}
ds = append(ds, &state_proto.TrainControlState_DriverKeySwitch{Id: b.Common.Id, Val: val})

View File

@ -99,8 +99,12 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
tl = DEFULAT_TRAIN_LOAD
}
status.VobcState = &state_proto.TrainVobcState{Tc1Active: true, TrainLoad: int64(tl), BrakingStatus: true, BrakeForce: DEFAULT_BRAKE_FORCE, DirectionForward: true}
if !status.RunDirection {
status.VobcState.Tc1Active = false
status.VobcState.Tc2Active = true
status.Tcc = initTrainTcc(vs)
}
status.Tcc = initTrainTcc(vs, status.RunDirection)
slog.Debug("列车初始化", "trainIndex", trainIndex, "linkId", linkId, "loffset", loffset)
linkIdInt, _ := strconv.Atoi(linkId)