列车激活方向调整
This commit is contained in:
parent
37799cd2c9
commit
11a14b2ef6
@ -239,15 +239,20 @@ func addTrain(c *gin.Context) {
|
||||
if req.TrainId < 0 || req.TrainId >= 255 {
|
||||
panic(sys_error.New("列车编号不能小于0,大于255"))
|
||||
}
|
||||
if req.TrainSpeed < 0 || req.TrainSpeed > 90 {
|
||||
panic(sys_error.New("列车编号不能小于0,大于255"))
|
||||
}
|
||||
rsp := &state_proto.TrainState{
|
||||
Id: fmt.Sprintf("%v", req.TrainId),
|
||||
HeadDeviceId: req.Id,
|
||||
HeadOffset: req.HeadOffset,
|
||||
DevicePort: req.DevicePort,
|
||||
RunDirection: req.RunDirection,
|
||||
Id: fmt.Sprintf("%v", req.TrainId),
|
||||
HeadDeviceId: req.Id,
|
||||
HeadOffset: req.HeadOffset,
|
||||
DevicePort: req.DevicePort,
|
||||
TrainRunUp: req.RunDirection,
|
||||
//RunDirection: req.RunDirection,
|
||||
TrainLength: req.TrainLength,
|
||||
WheelDiameter: req.WheelDiameter,
|
||||
Speed: req.TrainSpeed,
|
||||
Show: true,
|
||||
ConnState: &state_proto.TrainConnState{TrainControlMapId: req.TrainControlMapId, Conn: false, ConnType: state_proto.TrainConnState_NONE},
|
||||
}
|
||||
var err *sys_error.BusinessError = memory.AddTrainStateNew(simulation,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -443,20 +443,20 @@ func collectTrainStates(vs *memory.VerifySimulation) ([]*state_proto.TrainMapSta
|
||||
|
||||
func convertTrainState(v *state_proto.TrainState) *state_proto.TrainMapState {
|
||||
t := &state_proto.TrainMapState{
|
||||
Id: v.Id,
|
||||
Up: v.Up,
|
||||
InitialSpeed: v.Speed,
|
||||
TrainLength: v.TrainLength,
|
||||
Show: v.Show,
|
||||
HeadDeviceId: v.HeadDeviceId,
|
||||
HeadOffset: v.HeadOffset,
|
||||
DevicePort: v.DevicePort,
|
||||
PointTo: v.PointTo,
|
||||
RunDirection: v.RunDirection,
|
||||
HeadDirection: v.HeadDirection,
|
||||
TrainKilometer: v.TrainKilometer,
|
||||
ControlDelayTime: v.ControlDelayTime,
|
||||
WheelDiameter: v.WheelDiameter,
|
||||
Id: v.Id,
|
||||
Up: v.Up,
|
||||
InitialSpeed: v.Speed,
|
||||
TrainLength: v.TrainLength,
|
||||
Show: v.Show,
|
||||
HeadDeviceId: v.HeadDeviceId,
|
||||
HeadOffset: v.HeadOffset,
|
||||
DevicePort: v.DevicePort,
|
||||
DriftTo: v.DriftTo,
|
||||
TrainRunUp: v.TrainRunUp,
|
||||
TrainActiveDirection: v.TrainActiveDirection,
|
||||
TrainKilometer: v.TrainKilometer,
|
||||
ControlDelayTime: v.ControlDelayTime,
|
||||
WheelDiameter: v.WheelDiameter,
|
||||
// 动力学
|
||||
DynamicHeartbeat: v.DynamicState.Heartbeat,
|
||||
HeadLinkId: v.DynamicState.HeadLinkId,
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 6d3ff5644ebaad3ed1e7e6c03fcfb0f9a3427af0
|
||||
Subproject commit aac1484a6f64cc43146cabd89784b92c933a0298
|
2
third_party/dynamics/dynamics.go
vendored
2
third_party/dynamics/dynamics.go
vendored
@ -133,6 +133,7 @@ func (d *dynamics) requestStartSimulation(base *message.LineBaseInfo) error {
|
||||
}
|
||||
url := d.buildUrl("/api/start/")
|
||||
data, _ := json.Marshal(base)
|
||||
fmt.Println(string(data))
|
||||
resp, err := d.httpClient.Post(url, "application/json", bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return sys_error.New("动力学开始仿真请求发送错误", err)
|
||||
@ -171,6 +172,7 @@ func (d *dynamics) RequestAddTrain(info *message.InitTrainInfo) error {
|
||||
}
|
||||
url := d.buildUrl("/api/aerodynamics/init/train/")
|
||||
data, _ := json.Marshal(info)
|
||||
fmt.Println(string(data))
|
||||
resp, err := d.httpClient.Post(url, "application/json", bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return fmt.Errorf("动力学添加列车请求异常: %v", err)
|
||||
|
19
third_party/message/dynamics.go
vendored
19
third_party/message/dynamics.go
vendored
@ -77,7 +77,9 @@ type DynamicsTrainInfo struct {
|
||||
//此次计算所使用的半实物消息的生命信号
|
||||
VobcLifeSignal uint16
|
||||
//位移(mm)
|
||||
Displacement uint16
|
||||
Displacement uint16
|
||||
TrainActToMax bool
|
||||
TrainActToMin bool
|
||||
}
|
||||
|
||||
// 解析动力学的列车信息
|
||||
@ -89,8 +91,19 @@ func (t *DynamicsTrainInfo) Decode(buf []byte) error {
|
||||
t.LinkOffset = binary.BigEndian.Uint32(buf[8:12])
|
||||
t.Slope = binary.BigEndian.Uint16(buf[12:14])
|
||||
b := buf[14]
|
||||
t.UpSlope = (b & (1 << 7)) != 0
|
||||
t.Up = (b & (1 << 6)) != 0
|
||||
t.UpSlope = IsTrueForByte(GetBit(b, 7))
|
||||
t.Up = IsTrueForByte(GetBit(b, 6))
|
||||
t.TrainActToMax = IsTrueForByte(GetBit(b, 4))
|
||||
t.TrainActToMin = IsTrueForByte(GetBit(b, 5))
|
||||
|
||||
//t.UpSlope = (b & (1 << 7)) != 0
|
||||
//t.Up = (b & (1 << 6)) != 0
|
||||
//t.TrainActToMax = (b & (1 << 5)) != 0
|
||||
//t.TrainActToMin = (b & (1 << 4)) != 0
|
||||
|
||||
//t.TrainActToMax = (b & (1 << 4)) != 0
|
||||
//t.TrainActToMin = (b & (1 << 5)) != 0
|
||||
|
||||
t.TotalResistance = int32(binary.BigEndian.Uint32(buf[16:20]))
|
||||
t.AirResistance = int32(binary.BigEndian.Uint32(buf[20:24]))
|
||||
t.SlopeResistance = int32(binary.BigEndian.Uint32(buf[24:28]))
|
||||
|
2
third_party/train_pc_sim/train_pc_sim.go
vendored
2
third_party/train_pc_sim/train_pc_sim.go
vendored
@ -186,7 +186,7 @@ func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
|
||||
|
||||
s1, s2 := train.PluseCount.PulseCount1, train.PluseCount.PulseCount2
|
||||
d.speedPlace.ParsePulseCount1(s1, s2)
|
||||
data := d.speedPlace.Encode(train.RunDirection, s1, s2)
|
||||
data := d.speedPlace.Encode(train.TrainRunUp, s1, s2)
|
||||
bm := &message.TrainPcSimBaseMessage{Type: SENDER_TRAIN_LOCATION_INFO, Data: data}
|
||||
train.PluseCount.PulseCount1 = 0
|
||||
train.PluseCount.PulseCount2 = 0
|
||||
|
@ -59,6 +59,20 @@ func findTrainTccGraphicDataHandler(tccG *data_proto.TccGraphicStorage, id uint3
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func initTrainVobc(trainLoad int64, trainIsUp bool) (*state_proto.TrainVobcState, uint32) {
|
||||
vobc := &state_proto.TrainVobcState{TrainLoad: int64(trainLoad), BrakingStatus: true, BrakeForce: DEFAULT_BRAKE_FORCE, DirectionForward: true}
|
||||
var trainActDir uint32 = 0
|
||||
if trainIsUp {
|
||||
vobc.Tc1Active = true
|
||||
trainActDir = 1
|
||||
} else {
|
||||
//vobc.Tc1Active = true
|
||||
vobc.Tc2Active = true
|
||||
trainActDir = 2
|
||||
}
|
||||
return vobc, trainActDir
|
||||
}
|
||||
|
||||
// 初始化列车控制数据
|
||||
func initTrainTcc(vs *VerifySimulation, runDir bool) *state_proto.TrainControlState {
|
||||
var tccGI *data_proto.TccGraphicStorage
|
||||
|
@ -50,11 +50,6 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
|
||||
return sys_error.New(fmt.Sprintf("列车【%s】已存在", status.Id))
|
||||
}
|
||||
}
|
||||
//tcc := createTrainControl(vs)
|
||||
//status.Tcc = tcc
|
||||
|
||||
// 显示状态
|
||||
status.Show = true
|
||||
//向动力学发送初始化请求
|
||||
trainIndex, _ := strconv.ParseUint(status.Id, 10, 16)
|
||||
slog.Debug("添加列车", "trainIndex", trainIndex, "HeadDeviceId", status.HeadDeviceId, "HeadOffset", status.HeadOffset)
|
||||
@ -65,12 +60,16 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
|
||||
} else {
|
||||
uid = QueryUidByMidAndComId(mapId, status.HeadDeviceId, &data_proto.Turnout{})
|
||||
}
|
||||
|
||||
// 车头所在link、link上的偏移
|
||||
linkId, loffset := QueryLinkAndOffsetByDevice(vs.Repo, uid, status.DevicePort, status.HeadOffset)
|
||||
// link上的运行方向、设备上的运行方向
|
||||
up, pointTo := QueryUpAndABByDevice(vs.Repo, uid, status.DevicePort, status.RunDirection)
|
||||
up, pointTo := QueryUpAndABByDevice(vs.Repo, uid, status.DevicePort, status.TrainRunUp)
|
||||
//up, pointTo, _ = QueryDirectionAndABByDevice(vs.Repo, uid, status.DevicePort, status.TrainRunUp)
|
||||
//fmt.Println(up2, pointTo2)
|
||||
|
||||
// 车头所在公里标
|
||||
kilometer := CalcTrainKilometer(vs.Repo, uid, status.DevicePort, status.RunDirection, status.HeadOffset)
|
||||
kilometer := CalcTrainKilometer(vs.Repo, uid, status.DevicePort, status.TrainRunUp, status.HeadOffset)
|
||||
// 车尾相对车头link的偏移量
|
||||
calctailOffset := calcTrailTailOffset(loffset, status.TrainLength, up)
|
||||
// 车尾位置
|
||||
@ -79,7 +78,7 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
|
||||
panic(sys_error.New("添加列车失败,列车车尾占用位置计算出错", e1))
|
||||
}
|
||||
status.Up = up
|
||||
status.PointTo = pointTo
|
||||
status.DriftTo = pointTo
|
||||
status.TrainKilometer = kilometer.Value
|
||||
|
||||
status.DynamicState = &state_proto.TrainDynamicState{
|
||||
@ -87,7 +86,8 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
|
||||
HeadLinkOffset: loffset,
|
||||
TailLinkId: tailLink,
|
||||
TailLinkOffset: tailLOffset,
|
||||
RunningUp: up,
|
||||
RunningUp: status.Up,
|
||||
//RunningUp: status.TrainRunUp,
|
||||
}
|
||||
status.TailDeviceId = vs.GetComIdByUid(tailDeviceId)
|
||||
status.TailOffset = tailDeviceOffset
|
||||
@ -98,24 +98,23 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
|
||||
if tl <= 0 {
|
||||
tl = DEFULAT_TRAIN_LOAD
|
||||
}
|
||||
status.VobcState = &state_proto.TrainVobcState{TrainLoad: int64(tl), BrakingStatus: true, BrakeForce: DEFAULT_BRAKE_FORCE, DirectionForward: true}
|
||||
//status.VobcState.HistoryDir = request_proto.TrainControl_FORWARD
|
||||
|
||||
if status.RunDirection {
|
||||
status.VobcState.Tc1Active = true
|
||||
} else {
|
||||
status.VobcState.Tc2Active = true
|
||||
}
|
||||
status.Tcc = initTrainTcc(vs, status.RunDirection)
|
||||
vobc, _ := initTrainVobc(int64(tl), status.TrainRunUp)
|
||||
status.VobcState = vobc
|
||||
|
||||
//status.TrainActiveDirection = trainActDir
|
||||
|
||||
status.Tcc = initTrainTcc(vs, status.TrainRunUp)
|
||||
|
||||
slog.Debug("列车初始化", "trainIndex", trainIndex, "linkId", linkId, "loffset", loffset)
|
||||
linkIdInt, _ := strconv.Atoi(linkId)
|
||||
err := dynamics.Default().RequestAddTrain(&message.InitTrainInfo{
|
||||
TrainIndex: uint16(trainIndex),
|
||||
LinkIndex: uint16(linkIdInt),
|
||||
LinkOffset: uint32(loffset),
|
||||
Speed: status.Speed / 3.6,
|
||||
Up: status.Up,
|
||||
TrainIndex: uint16(trainIndex),
|
||||
LinkIndex: uint16(linkIdInt),
|
||||
LinkOffset: uint32(loffset),
|
||||
Speed: status.Speed / 3.6,
|
||||
Up: status.Up,
|
||||
//Up: status.TrainRunUp,
|
||||
TrainOperationConfig: CreateMsgTrainConfig(int(trainIndex), status.TrainLength, configTrainData),
|
||||
})
|
||||
if err != nil {
|
||||
@ -296,58 +295,42 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
|
||||
sta.ControlDelayTime = (int64(sta.VobcState.LifeSignal)-int64(info.VobcLifeSignal))*20 + delayTime
|
||||
//slog.Debug("收到动力学原始消息", "Number", info.Number, "Link", info.Link, "LinkOffset", info.LinkOffset)
|
||||
inLinkId, inLinkOffset := strconv.Itoa(int(info.Link)), int64(info.LinkOffset)
|
||||
|
||||
outLinkId, id, port, outLinkOffset, offset, kilometer, e1 := CalcInitializeLink(vs, inLinkId, inLinkOffset, info.Up)
|
||||
if e1 != nil {
|
||||
panic(sys_error.New("动力学传输数据:列车车头位置计算出错", e1))
|
||||
}
|
||||
//runDirection 指定的是link方向
|
||||
//pointTO 指的是是否ab,或是否到岔心
|
||||
runDirection, pointTo := QueryDirectionAndABByDevice(vs.Repo, id, port, info.Up)
|
||||
//slog.Debug("处理动力学转换后的消息", "number", info.Number, "Link", info.Link, "车头位置", id, "偏移", Offset, "是否上行", runDirection, "是否ab", pointTo)
|
||||
|
||||
slog.Debug("处理动力学转换后的消息", "number", info.Number, "up", info.Up, "Link", info.Link, "车头位置", id, "偏移", offset, "是否上行", runDirection, "是否ab", pointTo, "t1Dir:", info.TrainActToMax, "t2Dir:", info.TrainActToMin)
|
||||
trainHeadActUp := true
|
||||
if info.TrainActToMax || info.TrainActToMin {
|
||||
if info.TrainActToMin {
|
||||
trainHeadActUp = false
|
||||
}
|
||||
}
|
||||
// 车尾相对车头link的偏移量
|
||||
calctailOffset := calcTrailTailOffset(outLinkOffset, int64(info.Len), info.Up)
|
||||
//calctailOffset := calcTrailTailOffset(outLinkOffset, int64(info.Len), info.Up)
|
||||
calctailOffset := calcTrailTailOffset(outLinkOffset, int64(info.Len), trainHeadActUp)
|
||||
tailLinkId, tailDeviceId, tailDevicePort, tailLinkOffset, tailOffset, _, e2 := CalcInitializeLink(vs, outLinkId, calctailOffset, !info.Up)
|
||||
if e2 != nil {
|
||||
panic(sys_error.New("动力学传输数据:列车车尾位置计算出错", e2))
|
||||
}
|
||||
//slog.Debug("车尾位置", tailDeviceId, "偏移", tailDeviceOffset, "所在设备端", tailDevicePort)
|
||||
// 更新BTM中列车位置信息
|
||||
can_btm.Default().HandleTrainHeadPositionInfo(vs.World, &fi.TrainHeadPositionInfo{
|
||||
TrainId: trainId,
|
||||
Up: info.Up,
|
||||
Link: outLinkId,
|
||||
LinkOffset: outLinkOffset,
|
||||
Speed: info.Speed,
|
||||
Acceleration: info.Acceleration,
|
||||
})
|
||||
state := can_btm.Default().GetState()
|
||||
sta.BtmState = &state
|
||||
updateTrainBtmPosition(vs, info, sta, outLinkId, outLinkOffset)
|
||||
// 修改world中的列车位置
|
||||
fi.UpdateTrainPositionFromDynamics(vs.World, fi.TrainPositionInfo{
|
||||
TrainId: trainId,
|
||||
Up: info.Up,
|
||||
Len: info.Len,
|
||||
HeadLink: outLinkId,
|
||||
HeadLinkOffset: uint32(outLinkOffset),
|
||||
TailLink: tailLinkId,
|
||||
TailLinkOffset: uint32(tailLinkOffset),
|
||||
})
|
||||
handleTrainPositionFromDynamic(vs, info, sta, outLinkId, outLinkOffset, tailLinkId, tailLinkOffset)
|
||||
//修改列车激活方向
|
||||
updateTrainActiveDirFromDynamic(vs, info, sta, id, port, trainHeadActUp)
|
||||
|
||||
sta.HeadDeviceId = vs.GetComIdByUid(id)
|
||||
sta.DevicePort = port
|
||||
sta.HeadOffset = offset
|
||||
sta.PointTo = pointTo
|
||||
sta.DriftTo = pointTo
|
||||
sta.TrainKilometer = kilometer.Value
|
||||
sta.RunDirection = runDirection
|
||||
//判定车头方向
|
||||
sta.HeadDirection = runDirection
|
||||
if sta.VobcState != nil {
|
||||
if sta.VobcState.DirectionForward {
|
||||
sta.HeadDirection = runDirection
|
||||
} else if sta.VobcState.DirectionBackward {
|
||||
sta.HeadDirection = !runDirection
|
||||
}
|
||||
}
|
||||
if info.Speed < 0 {
|
||||
sta.RunDirection = !sta.RunDirection
|
||||
}
|
||||
|
||||
sta.TailDeviceId = vs.GetComIdByUid(tailDeviceId)
|
||||
sta.TailOffset = tailOffset
|
||||
sta.TailDevicePort = tailDevicePort
|
||||
@ -379,6 +362,47 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
|
||||
return sta
|
||||
}
|
||||
|
||||
func updateTrainActiveDirFromDynamic(vs *VerifySimulation, info *message.DynamicsTrainInfo, sta *state_proto.TrainState, id, port string, trainHeadActUp bool) {
|
||||
sta.TrainActiveDirection = 0
|
||||
if info.TrainActToMax || info.TrainActToMin {
|
||||
_, pointTo2 := QueryDirectionAndABByDevice(vs.Repo, id, port, trainHeadActUp)
|
||||
pt := pointTo2
|
||||
if pt {
|
||||
sta.TrainActiveDirection = 1
|
||||
} else {
|
||||
sta.TrainActiveDirection = 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 根据列车位置修改列车应答器
|
||||
func updateTrainBtmPosition(vs *VerifySimulation, info *message.DynamicsTrainInfo, sta *state_proto.TrainState, outLinkId string, outLinkOffset int64) {
|
||||
// 更新BTM中列车位置信息
|
||||
can_btm.Default().HandleTrainHeadPositionInfo(vs.World, &fi.TrainHeadPositionInfo{
|
||||
TrainId: sta.Id,
|
||||
Up: info.Up,
|
||||
Link: outLinkId,
|
||||
LinkOffset: outLinkOffset,
|
||||
Speed: info.Speed,
|
||||
Acceleration: info.Acceleration,
|
||||
})
|
||||
state := can_btm.Default().GetState()
|
||||
sta.BtmState = &state
|
||||
}
|
||||
|
||||
// 根据动力学修改列车位置
|
||||
func handleTrainPositionFromDynamic(vs *VerifySimulation, info *message.DynamicsTrainInfo, sta *state_proto.TrainState, outLinkId string, outLinkOffset int64, tailLinkId string, tailLinkOffset int64) {
|
||||
fi.UpdateTrainPositionFromDynamics(vs.World, fi.TrainPositionInfo{
|
||||
TrainId: sta.Id,
|
||||
Up: info.Up,
|
||||
Len: info.Len,
|
||||
HeadLink: outLinkId,
|
||||
HeadLinkOffset: uint32(outLinkOffset),
|
||||
TailLink: tailLinkId,
|
||||
TailLinkOffset: uint32(tailLinkOffset),
|
||||
})
|
||||
}
|
||||
|
||||
// 接受动力学时间15毫米
|
||||
const RECEIVE_DYNAMIC_DATA_RATE = 15
|
||||
|
||||
@ -390,7 +414,7 @@ func pluseCount(sta *state_proto.TrainState) {
|
||||
if sta.PluseCount == nil {
|
||||
return
|
||||
}
|
||||
if sta.RunDirection {
|
||||
if sta.TrainRunUp {
|
||||
p1 := uint32(formatSpeedTime(sta.DynamicState.HeadSensorSpeed1 * RECEIVE_DYNAMIC_DATA_RATE))
|
||||
p2 := uint32(formatSpeedTime(sta.DynamicState.HeadSensorSpeed2 * RECEIVE_DYNAMIC_DATA_RATE))
|
||||
if sta.TrainEndsA.SpeedSensorEnableA {
|
||||
|
@ -41,7 +41,7 @@ func ControlTrainUpdate(s *VerifySimulation, ct *request_proto.TrainControl) {
|
||||
if ct.ControlType == request_proto.TrainControl_EMERGENT_BUTTON {
|
||||
tce = trainControlEB(vobc, tcc, ct.Button, ct.DeviceId, tccGraphicData)
|
||||
} else if ct.ControlType == request_proto.TrainControl_DRIVER_KEY_SWITCH {
|
||||
tce = trainControlDriverKey(sta.DynamicState.Speed, vobc, tcc, ct.DriverKey, ct.DeviceId, tccGraphicData)
|
||||
tce = trainControlDriverKey(sta, ct.DriverKey, ct.DeviceId, tccGraphicData)
|
||||
train_pc_sim.Default().SendDriverActive(sta.ConnState, sta.VobcState)
|
||||
} else if ct.ControlType == request_proto.TrainControl_DIRECTION_KEY_SWITCH {
|
||||
tce = trainControlDirKey(sta.DynamicState.Speed, vobc, tcc, ct.DirKey, ct.DeviceId, tccGraphicData)
|
||||
@ -142,15 +142,17 @@ func trainControlDirKey(trainSpeed int32, vobc *state_proto.TrainVobcState, tcc
|
||||
}
|
||||
|
||||
// 列车驾驶端激活
|
||||
func trainControlDriverKey(trainSpeed int32, vobc *state_proto.TrainVobcState, tcc *state_proto.TrainControlState, request *request_proto.TrainControl_DriverKeySwitch, deviceId uint32, tccGraphic *data_proto.TccGraphicStorage) []train_pc_sim.TrainControlEvent {
|
||||
func trainControlDriverKey(train *state_proto.TrainState, request *request_proto.TrainControl_DriverKeySwitch, deviceId uint32, tccGraphic *data_proto.TccGraphicStorage) []train_pc_sim.TrainControlEvent {
|
||||
obj, find := findTrainTccGraphicDataKey(tccGraphic, deviceId)
|
||||
if !find {
|
||||
slog.Error("未找到对应的驾驶端激活设备deviceId:", deviceId)
|
||||
return nil
|
||||
}
|
||||
if trainSpeed != 0 {
|
||||
if train.DynamicState.Speed != 0 {
|
||||
panic(sys_error.New("因列车未停稳,不支持此操作"))
|
||||
}
|
||||
vobc := train.VobcState
|
||||
tcc := train.Tcc
|
||||
if obj.Code == SKQYS1 {
|
||||
vobc.Tc1Active = request.Val
|
||||
} else if obj.Code == SKQYS2 {
|
||||
@ -164,6 +166,14 @@ func trainControlDriverKey(trainSpeed int32, vobc *state_proto.TrainVobcState, t
|
||||
}
|
||||
panic(sys_error.New("驾驶端不能同时激活"))
|
||||
}
|
||||
train.TrainActiveDirection = 0
|
||||
if vobc.Tc1Active {
|
||||
//train.TrainActiveDirection = 1
|
||||
train.TrainRunUp = true
|
||||
} else if vobc.Tc2Active {
|
||||
//train.TrainActiveDirection = 2
|
||||
train.TrainRunUp = false
|
||||
}
|
||||
var addNew = true
|
||||
for _, k := range tcc.DriverKey {
|
||||
if k.Id == deviceId {
|
||||
|
Loading…
Reference in New Issue
Block a user