道岔、信号机状态调整
This commit is contained in:
parent
c9ff61abba
commit
21484afa21
File diff suppressed because it is too large
Load Diff
@ -3,14 +3,16 @@ package message_server
|
|||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"joylink.club/bj-rtsts-server/dto/state_proto"
|
|
||||||
"joylink.club/rtsssimulation/repository/model/proto"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"joylink.club/bj-rtsts-server/dto/state_proto"
|
||||||
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
|
|
||||||
"joylink.club/bj-rtsts-server/dto/data_proto"
|
"joylink.club/bj-rtsts-server/dto/data_proto"
|
||||||
"joylink.club/bj-rtsts-server/message_server/ms_api"
|
"joylink.club/bj-rtsts-server/message_server/ms_api"
|
||||||
"joylink.club/bj-rtsts-server/mqtt"
|
"joylink.club/bj-rtsts-server/mqtt"
|
||||||
|
appcomponent "joylink.club/bj-rtsts-server/ts/simulation/app_component"
|
||||||
"joylink.club/bj-rtsts-server/ts/simulation/wayside/memory"
|
"joylink.club/bj-rtsts-server/ts/simulation/wayside/memory"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
"joylink.club/rtsssimulation/component"
|
||||||
@ -238,6 +240,46 @@ func handlerSignalState(w ecs.World, uid string) (*state_proto.SignalState, erro
|
|||||||
signalState.Aspect = state_proto.Signal_A
|
signalState.Aspect = state_proto.Signal_A
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
signalState.Param = appcomponent.SignalParamType.Get(entry)
|
||||||
|
if entry.HasComponent(component.Signal2XH1ElectronicType) { // 2XH1信号机
|
||||||
|
signal2XH1 := component.Signal2XH1ElectronicType.Get(entry)
|
||||||
|
signalState.RelayStateMap = make(map[string]bool, 3)
|
||||||
|
signalState.RelayStateMap["DDJ"] = component.BitStateType.Get(signal2XH1.Z2XH1_DDJ).Val
|
||||||
|
signalState.RelayStateMap["LXJ"] = component.BitStateType.Get(signal2XH1.Z2XH1_LXJ).Val
|
||||||
|
signalState.RelayStateMap["DJ"] = component.BitStateType.Get(signal2XH1.Z2XH1_DJ).Val
|
||||||
|
} else if entry.HasComponent(component.Signal3XH1ElectronicType) { // 3XH1信号机
|
||||||
|
signal3XH1 := component.Signal3XH1ElectronicType.Get(entry)
|
||||||
|
signalState.RelayStateMap = make(map[string]bool, 6)
|
||||||
|
signalState.RelayStateMap["DDJ"] = component.BitStateType.Get(signal3XH1.Z3XH1_DDJ).Val
|
||||||
|
signalState.RelayStateMap["ZXJ"] = component.BitStateType.Get(signal3XH1.Z3XH1_ZXJ).Val
|
||||||
|
signalState.RelayStateMap["LXJ"] = component.BitStateType.Get(signal3XH1.Z3XH1_LXJ).Val
|
||||||
|
signalState.RelayStateMap["YXJ"] = component.BitStateType.Get(signal3XH1.Z3XH1_YXJ).Val
|
||||||
|
signalState.RelayStateMap["DJ"] = component.BitStateType.Get(signal3XH1.Z3XH1_DJ).Val
|
||||||
|
signalState.RelayStateMap["2DJ"] = component.BitStateType.Get(signal3XH1.Z3XH1_2DJ).Val
|
||||||
|
} else if entry.HasComponent(component.Signal3XH2ElectronicType) { // 3XH2信号机
|
||||||
|
signal3XH2 := component.Signal3XH2ElectronicType.Get(entry)
|
||||||
|
signalState.RelayStateMap = make(map[string]bool, 5)
|
||||||
|
signalState.RelayStateMap["DDJ"] = component.BitStateType.Get(signal3XH2.Z3XH2_DDJ).Val
|
||||||
|
signalState.RelayStateMap["LXJ"] = component.BitStateType.Get(signal3XH2.Z3XH2_LXJ).Val
|
||||||
|
signalState.RelayStateMap["YXJ"] = component.BitStateType.Get(signal3XH2.Z3XH2_YXJ).Val
|
||||||
|
signalState.RelayStateMap["DJ"] = component.BitStateType.Get(signal3XH2.Z3XH2_DJ).Val
|
||||||
|
signalState.RelayStateMap["2DJ"] = component.BitStateType.Get(signal3XH2.Z3XH2_2DJ).Val
|
||||||
|
} else if entry.HasComponent(component.Signal3XH3ElectronicType) { // 3XH3信号机
|
||||||
|
signal3XH3 := component.Signal3XH3ElectronicType.Get(entry)
|
||||||
|
signalState.RelayStateMap = make(map[string]bool, 5)
|
||||||
|
signalState.RelayStateMap["DDJ"] = component.BitStateType.Get(signal3XH3.Z3XH3_DDJ).Val
|
||||||
|
signalState.RelayStateMap["LXJ"] = component.BitStateType.Get(signal3XH3.Z3XH3_LXJ).Val
|
||||||
|
signalState.RelayStateMap["YXJ"] = component.BitStateType.Get(signal3XH3.Z3XH3_YXJ).Val
|
||||||
|
signalState.RelayStateMap["DJ"] = component.BitStateType.Get(signal3XH3.Z3XH3_DJ).Val
|
||||||
|
signalState.RelayStateMap["2DJ"] = component.BitStateType.Get(signal3XH3.Z3XH3_2DJ).Val
|
||||||
|
} else if entry.HasComponent(component.Signal3XH4ElectronicType) { // 3XH4信号机
|
||||||
|
signal3XH4 := component.Signal3XH4ElectronicType.Get(entry)
|
||||||
|
signalState.RelayStateMap = make(map[string]bool, 4)
|
||||||
|
signalState.RelayStateMap["DDJ"] = component.BitStateType.Get(signal3XH4.Z3XH4_DDJ).Val
|
||||||
|
signalState.RelayStateMap["LXJ"] = component.BitStateType.Get(signal3XH4.Z3XH4_LXJ).Val
|
||||||
|
signalState.RelayStateMap["ZXJ"] = component.BitStateType.Get(signal3XH4.Z3XH4_ZXJ).Val
|
||||||
|
signalState.RelayStateMap["DJ"] = component.BitStateType.Get(signal3XH4.Z3XH4_DJ).Val
|
||||||
|
}
|
||||||
return signalState, nil
|
return signalState, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,24 +387,25 @@ func collectTurnoutStates(sim *memory.VerifySimulation, mapId int32) ([]*state_p
|
|||||||
Dw: pos.Dw,
|
Dw: pos.Dw,
|
||||||
Fw: pos.Fw,
|
Fw: pos.Fw,
|
||||||
}
|
}
|
||||||
// 强制(联锁驱动无效)
|
s.Param = appcomponent.PointsParamType.Get(entry)
|
||||||
s.Force = entry.HasComponent(component.TurnoutFaultCiqdType)
|
// // 强制(联锁驱动无效)
|
||||||
// 失表
|
// s.Force = entry.HasComponent(component.TurnoutFaultCiqdType)
|
||||||
s.Sb = entry.HasComponent(component.TurnoutFaultSbType)
|
// // 失表
|
||||||
// 定位失表
|
// s.Sb = entry.HasComponent(component.TurnoutFaultSbType)
|
||||||
s.Dwsb = entry.HasComponent(component.TurnoutFaultDwsbType)
|
// // 定位失表
|
||||||
// 反位失表
|
// s.Dwsb = entry.HasComponent(component.TurnoutFaultDwsbType)
|
||||||
s.Fwsb = entry.HasComponent(component.TurnoutFaultFwsbType)
|
// // 反位失表
|
||||||
jc := false
|
// s.Fwsb = entry.HasComponent(component.TurnoutFaultFwsbType)
|
||||||
zzj := component.TurnoutZzjType.Get(entry)
|
// jc := false
|
||||||
for _, e := range zzj.ZzjList {
|
// zzj := component.TurnoutZzjType.Get(entry)
|
||||||
if e.HasComponent(component.TurnoutFaultJcType) {
|
// for _, e := range zzj.ZzjList {
|
||||||
jc = true
|
// if e.HasComponent(component.TurnoutFaultJcType) {
|
||||||
break
|
// jc = true
|
||||||
}
|
// break
|
||||||
}
|
// }
|
||||||
// 挤岔
|
// }
|
||||||
s.Jc = jc
|
// // 挤岔
|
||||||
|
// s.Jc = jc
|
||||||
if entry.HasComponent(component.Zdj9TwoElectronicType) {
|
if entry.HasComponent(component.Zdj9TwoElectronicType) {
|
||||||
elec := component.Zdj9TwoElectronicType.Get(entry)
|
elec := component.Zdj9TwoElectronicType.Get(entry)
|
||||||
dcj := component.BitStateType.Get(elec.TDC_DCJ)
|
dcj := component.BitStateType.Get(elec.TDC_DCJ)
|
||||||
|
11
ts/simulation/app_component/component.go
Normal file
11
ts/simulation/app_component/component.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package appcomponent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"joylink.club/bj-rtsts-server/dto/request_proto"
|
||||||
|
"joylink.club/ecs"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
PointsParamType = ecs.NewComponentType[request_proto.PointsParam]()
|
||||||
|
SignalParamType = ecs.NewComponentType[request_proto.SignalParam]()
|
||||||
|
)
|
@ -2,9 +2,11 @@ package memory
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"joylink.club/bj-rtsts-server/dto/data_proto"
|
"joylink.club/bj-rtsts-server/dto/data_proto"
|
||||||
"joylink.club/bj-rtsts-server/dto/request_proto"
|
"joylink.club/bj-rtsts-server/dto/request_proto"
|
||||||
|
appcomponent "joylink.club/bj-rtsts-server/ts/simulation/app_component"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
"joylink.club/rtsssimulation/component"
|
||||||
"joylink.club/rtsssimulation/component/component_proto"
|
"joylink.club/rtsssimulation/component/component_proto"
|
||||||
@ -45,6 +47,7 @@ func setSignalParam(world ecs.World, uid string, param *request_proto.SignalPara
|
|||||||
signal_Force := param.Force
|
signal_Force := param.Force
|
||||||
fi.UpdateSignalFaultDS(world, uid, convertSignalDs2Light(param.DsList))
|
fi.UpdateSignalFaultDS(world, uid, convertSignalDs2Light(param.DsList))
|
||||||
return handleEntityState(world, uid, func(e *ecs.Entry) error {
|
return handleEntityState(world, uid, func(e *ecs.Entry) error {
|
||||||
|
e.AddComponent(appcomponent.SignalParamType, unsafe.Pointer(param))
|
||||||
switch signal_Force {
|
switch signal_Force {
|
||||||
case request_proto.Signal_SF_NONE:
|
case request_proto.Signal_SF_NONE:
|
||||||
return setSignalForceNone(world, e)
|
return setSignalForceNone(world, e)
|
||||||
|
@ -2,9 +2,11 @@ package memory
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"joylink.club/bj-rtsts-server/dto/data_proto"
|
"joylink.club/bj-rtsts-server/dto/data_proto"
|
||||||
"joylink.club/bj-rtsts-server/dto/request_proto"
|
"joylink.club/bj-rtsts-server/dto/request_proto"
|
||||||
|
appcomponent "joylink.club/bj-rtsts-server/ts/simulation/app_component"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
"joylink.club/rtsssimulation/component"
|
||||||
"joylink.club/rtsssimulation/entity"
|
"joylink.club/rtsssimulation/entity"
|
||||||
@ -16,14 +18,16 @@ func HandlePointsOperation(simulation *VerifySimulation, req *request_proto.Poin
|
|||||||
// 道岔强制位置
|
// 道岔强制位置
|
||||||
switch req.Operation {
|
switch req.Operation {
|
||||||
case request_proto.Points_SetParams:
|
case request_proto.Points_SetParams:
|
||||||
return setTurnoutForce(simulation.World, uid, request_proto.Points_FP_DW)
|
return setTurnoutParam(simulation.World, uid, req.Param)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("未知的道岔操作:%s", req.Operation)
|
return fmt.Errorf("未知的道岔操作:%s", req.Operation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setTurnoutForce(w ecs.World, uid string, force request_proto.Points_Force) error {
|
func setTurnoutParam(w ecs.World, uid string, param *request_proto.PointsParam) error {
|
||||||
|
force := param.ForcePosition
|
||||||
return handleEntityState(w, uid, func(e *ecs.Entry) error {
|
return handleEntityState(w, uid, func(e *ecs.Entry) error {
|
||||||
|
e.AddComponent(appcomponent.PointsParamType, unsafe.Pointer(param))
|
||||||
if e.HasComponent(component.Zdj9TwoElectronicType) { // ZDJ9双机牵引道岔
|
if e.HasComponent(component.Zdj9TwoElectronicType) { // ZDJ9双机牵引道岔
|
||||||
zdj92 := component.Zdj9TwoElectronicType.Get(e)
|
zdj92 := component.Zdj9TwoElectronicType.Get(e)
|
||||||
switch force {
|
switch force {
|
||||||
|
Loading…
Reference in New Issue
Block a user