道岔、信号机状态调整

This commit is contained in:
walker 2024-01-18 14:11:47 +08:00
parent c9ff61abba
commit 21484afa21
5 changed files with 679 additions and 619 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,14 +3,16 @@ package message_server
import (
"encoding/hex"
"fmt"
"joylink.club/bj-rtsts-server/dto/state_proto"
"joylink.club/rtsssimulation/repository/model/proto"
"strings"
"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/message_server/ms_api"
"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/ecs"
"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.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
}
@ -345,24 +387,25 @@ func collectTurnoutStates(sim *memory.VerifySimulation, mapId int32) ([]*state_p
Dw: pos.Dw,
Fw: pos.Fw,
}
// 强制(联锁驱动无效)
s.Force = entry.HasComponent(component.TurnoutFaultCiqdType)
// 失表
s.Sb = entry.HasComponent(component.TurnoutFaultSbType)
// 定位失表
s.Dwsb = entry.HasComponent(component.TurnoutFaultDwsbType)
// 反位失表
s.Fwsb = entry.HasComponent(component.TurnoutFaultFwsbType)
jc := false
zzj := component.TurnoutZzjType.Get(entry)
for _, e := range zzj.ZzjList {
if e.HasComponent(component.TurnoutFaultJcType) {
jc = true
break
}
}
// 挤岔
s.Jc = jc
s.Param = appcomponent.PointsParamType.Get(entry)
// // 强制(联锁驱动无效)
// s.Force = entry.HasComponent(component.TurnoutFaultCiqdType)
// // 失表
// s.Sb = entry.HasComponent(component.TurnoutFaultSbType)
// // 定位失表
// s.Dwsb = entry.HasComponent(component.TurnoutFaultDwsbType)
// // 反位失表
// s.Fwsb = entry.HasComponent(component.TurnoutFaultFwsbType)
// jc := false
// zzj := component.TurnoutZzjType.Get(entry)
// for _, e := range zzj.ZzjList {
// if e.HasComponent(component.TurnoutFaultJcType) {
// jc = true
// break
// }
// }
// // 挤岔
// s.Jc = jc
if entry.HasComponent(component.Zdj9TwoElectronicType) {
elec := component.Zdj9TwoElectronicType.Get(entry)
dcj := component.BitStateType.Get(elec.TDC_DCJ)

View 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]()
)

View File

@ -2,9 +2,11 @@ package memory
import (
"fmt"
"unsafe"
"joylink.club/bj-rtsts-server/dto/data_proto"
"joylink.club/bj-rtsts-server/dto/request_proto"
appcomponent "joylink.club/bj-rtsts-server/ts/simulation/app_component"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"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
fi.UpdateSignalFaultDS(world, uid, convertSignalDs2Light(param.DsList))
return handleEntityState(world, uid, func(e *ecs.Entry) error {
e.AddComponent(appcomponent.SignalParamType, unsafe.Pointer(param))
switch signal_Force {
case request_proto.Signal_SF_NONE:
return setSignalForceNone(world, e)

View File

@ -2,9 +2,11 @@ package memory
import (
"fmt"
"unsafe"
"joylink.club/bj-rtsts-server/dto/data_proto"
"joylink.club/bj-rtsts-server/dto/request_proto"
appcomponent "joylink.club/bj-rtsts-server/ts/simulation/app_component"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
@ -16,14 +18,16 @@ func HandlePointsOperation(simulation *VerifySimulation, req *request_proto.Poin
// 道岔强制位置
switch req.Operation {
case request_proto.Points_SetParams:
return setTurnoutForce(simulation.World, uid, request_proto.Points_FP_DW)
return setTurnoutParam(simulation.World, uid, req.Param)
default:
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 {
e.AddComponent(appcomponent.PointsParamType, unsafe.Pointer(param))
if e.HasComponent(component.Zdj9TwoElectronicType) { // ZDJ9双机牵引道岔
zdj92 := component.Zdj9TwoElectronicType.Get(e)
switch force {