2023-10-26 16:41:18 +08:00
|
|
|
package message_server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-02-18 10:06:58 +08:00
|
|
|
"joylink.club/bj-rtsts-server/sys_error"
|
2024-01-30 13:20:37 +08:00
|
|
|
"log/slog"
|
2024-01-18 16:33:27 +08:00
|
|
|
"reflect"
|
2024-01-30 13:20:37 +08:00
|
|
|
"runtime/debug"
|
2023-11-06 17:15:00 +08:00
|
|
|
"strings"
|
2023-10-26 16:41:18 +08:00
|
|
|
"time"
|
|
|
|
|
2024-01-18 17:20:14 +08:00
|
|
|
"joylink.club/bj-rtsts-server/dto/request_proto"
|
2024-01-18 14:11:47 +08:00
|
|
|
"joylink.club/bj-rtsts-server/dto/state_proto"
|
|
|
|
"joylink.club/rtsssimulation/repository/model/proto"
|
|
|
|
|
2024-01-11 10:24:56 +08:00
|
|
|
"joylink.club/bj-rtsts-server/dto/data_proto"
|
2023-10-26 16:41:18 +08:00
|
|
|
"joylink.club/bj-rtsts-server/message_server/ms_api"
|
2023-12-20 10:37:54 +08:00
|
|
|
"joylink.club/bj-rtsts-server/mqtt"
|
2024-01-18 14:11:47 +08:00
|
|
|
appcomponent "joylink.club/bj-rtsts-server/ts/simulation/app_component"
|
2023-10-26 17:16:07 +08:00
|
|
|
"joylink.club/bj-rtsts-server/ts/simulation/wayside/memory"
|
2023-10-26 16:41:18 +08:00
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
"joylink.club/rtsssimulation/entity"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 信号平面布置图消息服务
|
|
|
|
|
2023-12-20 10:37:54 +08:00
|
|
|
func NewSfpMs(vs *memory.VerifySimulation, mapId int32) ms_api.MsgTask {
|
2023-12-26 13:27:09 +08:00
|
|
|
return ms_api.NewScheduleTask(fmt.Sprintf("信号平面布置图[%d]状态", mapId), func() error {
|
2023-12-20 10:37:54 +08:00
|
|
|
turnoutStates, err := collectTurnoutStates(vs, mapId)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
signalStates, err := collectSignalStates(vs.World, mapId)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
buttonStates, err := collectStationButtonStates(vs.World, mapId)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
psdStates, err := collectPsdStates(vs.World, mapId)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
sectionStates, err := collectSectionStates(vs.World, mapId)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
platformStates, err := collectPlatformStates(vs.World, mapId)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
trainState, err := collectTrainStates(vs)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-01-10 14:06:01 +08:00
|
|
|
baliseStates, err := collectBaliseStates(vs.World, mapId)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-01-11 10:24:56 +08:00
|
|
|
ststes := &state_proto.PushedDevicesStatus{
|
2023-12-20 10:37:54 +08:00
|
|
|
All: true,
|
2024-01-11 10:24:56 +08:00
|
|
|
AllStatus: &state_proto.AllDevicesStatus{
|
2023-12-20 10:37:54 +08:00
|
|
|
TrainState: trainState,
|
|
|
|
SwitchState: turnoutStates,
|
|
|
|
SignalState: signalStates,
|
|
|
|
ButtonState: buttonStates,
|
|
|
|
PsdState: psdStates,
|
|
|
|
SectionState: sectionStates,
|
|
|
|
PlatformState: platformStates,
|
2024-01-10 14:06:01 +08:00
|
|
|
BaliseState: baliseStates,
|
2023-12-20 10:37:54 +08:00
|
|
|
},
|
|
|
|
}
|
2024-02-18 10:06:58 +08:00
|
|
|
err = mqtt.GetMsgClient().PubSfpState(vs.SimulationId, mapId, ststes)
|
|
|
|
if err != nil {
|
|
|
|
return sys_error.New("发送状态消息异常", err)
|
|
|
|
}
|
2023-12-20 10:37:54 +08:00
|
|
|
return nil
|
2024-02-04 17:07:36 +08:00
|
|
|
}, 1000*time.Millisecond)
|
2023-10-26 17:48:43 +08:00
|
|
|
}
|
|
|
|
|
2024-01-10 14:06:01 +08:00
|
|
|
// 收集应答器状态
|
2024-01-11 10:24:56 +08:00
|
|
|
func collectBaliseStates(world ecs.World, mapId int32) ([]*state_proto.BaliseState, error) {
|
2024-01-10 14:06:01 +08:00
|
|
|
uidStructure := memory.QueryUidStructure[*memory.StationUidStructure](mapId)
|
2024-01-11 10:24:56 +08:00
|
|
|
var transponderStates []*state_proto.BaliseState
|
2024-01-10 14:06:01 +08:00
|
|
|
for id, structure := range uidStructure.TransponderIds {
|
|
|
|
entry, ok := entity.GetEntityByUid(world, structure.Uid)
|
|
|
|
if ok {
|
2024-01-22 11:06:30 +08:00
|
|
|
baliseFixedTelegram := component.BaliseFixedTelegramType.Get(entry)
|
2024-02-06 09:30:58 +08:00
|
|
|
baliseWorkState := component.BaliseWorkStateType.Get(entry)
|
2024-01-11 10:24:56 +08:00
|
|
|
baliseState := &state_proto.BaliseState{
|
2024-01-22 11:06:30 +08:00
|
|
|
Id: id,
|
|
|
|
FixedTelegram: fmt.Sprintf("%X", baliseFixedTelegram.Telegram),
|
|
|
|
FixedUserTelegram: fmt.Sprintf("%X", baliseFixedTelegram.UserTelegram),
|
2024-02-06 09:30:58 +08:00
|
|
|
Work: baliseWorkState.Work,
|
2024-01-10 14:06:01 +08:00
|
|
|
}
|
2024-01-24 17:45:16 +08:00
|
|
|
if entry.HasComponent(component.BaliseVariableTelegramType) {
|
|
|
|
baliseVariableTelegram := component.BaliseVariableTelegramType.Get(entry)
|
|
|
|
baliseState.VariableTelegram = fmt.Sprintf("%X", baliseVariableTelegram.Telegram)
|
|
|
|
baliseState.VariableUserTelegram = fmt.Sprintf("%X", baliseVariableTelegram.UserTelegram)
|
|
|
|
}
|
2024-01-10 14:06:01 +08:00
|
|
|
transponderStates = append(transponderStates, baliseState)
|
|
|
|
km := component.KmType.Get(entry)
|
2024-01-11 10:24:56 +08:00
|
|
|
baliseState.Km = &data_proto.KilometerSystem{
|
2024-01-10 14:06:01 +08:00
|
|
|
Kilometer: km.Value,
|
|
|
|
CoordinateSystem: km.CoordinateSystem,
|
|
|
|
}
|
|
|
|
if km.Direction == proto.Direction_LEFT {
|
2024-01-11 10:24:56 +08:00
|
|
|
baliseState.Km.Direction = data_proto.KilometerSystem_LEFT
|
2024-01-10 14:06:01 +08:00
|
|
|
} else if km.Direction == proto.Direction_RIGHT {
|
2024-01-11 10:24:56 +08:00
|
|
|
baliseState.Km.Direction = data_proto.KilometerSystem_RIGHT
|
2024-01-10 14:06:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return transponderStates, nil
|
|
|
|
}
|
|
|
|
|
2023-10-26 16:41:18 +08:00
|
|
|
// 收集屏蔽门状态
|
2024-01-11 10:24:56 +08:00
|
|
|
func collectPsdStates(world ecs.World, mapId int32) ([]*state_proto.PsdState, error) {
|
2023-12-20 10:37:54 +08:00
|
|
|
uidStructure := memory.QueryUidStructure[*memory.StationUidStructure](mapId)
|
2024-01-11 10:24:56 +08:00
|
|
|
data := memory.QueryGiData[*data_proto.RtssGraphicStorage](mapId)
|
|
|
|
var psdStateArr []*state_proto.PsdState
|
2023-10-27 14:57:37 +08:00
|
|
|
for _, door := range data.ScreenDoors {
|
2023-12-13 15:05:42 +08:00
|
|
|
did := memory.GetMapElementId(door.Common)
|
|
|
|
uid := uidStructure.PsdIds[did].Uid
|
2023-10-27 14:57:37 +08:00
|
|
|
psdEntry, ok := entity.GetEntityByUid(world, uid)
|
|
|
|
if ok {
|
2023-11-03 10:41:53 +08:00
|
|
|
list := component.AsdListType.Get(psdEntry).List
|
2024-01-11 10:24:56 +08:00
|
|
|
asdStates := make([]*state_proto.AsdState, len(list))
|
2023-11-03 10:41:53 +08:00
|
|
|
for i, asdEntry := range list {
|
|
|
|
asdState := component.AsdStateType.Get(asdEntry)
|
2024-01-11 10:24:56 +08:00
|
|
|
asdStates[i] = &state_proto.AsdState{
|
2023-11-06 10:53:06 +08:00
|
|
|
Code: int32(i + 1),
|
2023-11-03 10:41:53 +08:00
|
|
|
Kmdw: asdState.Kmdw,
|
|
|
|
Gmdw: asdState.Gmdw,
|
|
|
|
Mgj: asdState.Mgj,
|
2024-02-18 10:06:58 +08:00
|
|
|
Zaw: asdState.Zaw,
|
2023-11-01 16:52:08 +08:00
|
|
|
}
|
2023-10-27 14:57:37 +08:00
|
|
|
}
|
2024-01-24 09:59:29 +08:00
|
|
|
var param *request_proto.PsdParam
|
|
|
|
if psdEntry.HasComponent(appcomponent.PsdParamType) {
|
|
|
|
param = appcomponent.PsdParamType.Get(psdEntry)
|
|
|
|
} else {
|
|
|
|
param = &request_proto.PsdParam{}
|
|
|
|
}
|
2024-01-11 10:24:56 +08:00
|
|
|
psdStateArr = append(psdStateArr, &state_proto.PsdState{
|
2023-12-13 15:05:42 +08:00
|
|
|
Id: did,
|
2023-11-03 10:41:53 +08:00
|
|
|
AsdStates: asdStates,
|
|
|
|
Mgj: component.PsdStateType.Get(psdEntry).Close,
|
2024-01-24 09:59:29 +08:00
|
|
|
Param: param,
|
2024-02-18 10:06:58 +08:00
|
|
|
Zaw: component.PsdStateType.Get(psdEntry).Obstacle,
|
2023-10-27 14:57:37 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return psdStateArr, nil
|
|
|
|
}
|
|
|
|
|
2023-10-26 16:41:18 +08:00
|
|
|
// 收集区段状态
|
2024-01-11 10:24:56 +08:00
|
|
|
func collectSectionStates(world ecs.World, mapId int32) ([]*state_proto.SectionState, error) {
|
|
|
|
uidMap := memory.QueryMapUidMapByType(mapId, &data_proto.Section{})
|
|
|
|
var sectionArr []*state_proto.SectionState
|
2023-10-27 14:57:37 +08:00
|
|
|
for _, u := range uidMap {
|
2023-12-20 10:37:54 +08:00
|
|
|
s := handlerSectionState(world, u.Uid)
|
2023-10-27 14:57:37 +08:00
|
|
|
if s == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
s.Id = u.CommonId
|
|
|
|
sectionArr = append(sectionArr, s)
|
|
|
|
}
|
|
|
|
return sectionArr, nil
|
|
|
|
}
|
|
|
|
|
2024-01-11 10:24:56 +08:00
|
|
|
func handlerSectionState(w ecs.World, uid string) *state_proto.SectionState {
|
2023-10-27 14:57:37 +08:00
|
|
|
entry, ok := entity.GetEntityByUid(w, uid)
|
|
|
|
if !ok {
|
|
|
|
//fmt.Printf("id=%s的信号机不存在", uid)
|
|
|
|
return nil
|
|
|
|
}
|
2023-11-06 14:35:33 +08:00
|
|
|
if entry.HasComponent(component.PhysicalSectionStateType) { //计轴区段
|
2024-01-11 10:24:56 +08:00
|
|
|
sectionState := &state_proto.SectionState{}
|
2023-11-06 14:35:33 +08:00
|
|
|
axleState := component.PhysicalSectionStateType.Get(entry)
|
2023-10-27 14:57:37 +08:00
|
|
|
sectionState.Occupied = axleState.Occ
|
2023-11-06 14:35:33 +08:00
|
|
|
sectionState.AxleFault = entry.HasComponent(component.AxleSectionFaultTag)
|
2024-01-23 09:37:31 +08:00
|
|
|
|
|
|
|
wd := entity.GetWorldData(w)
|
|
|
|
sectionModel := wd.Repo.FindPhysicalSection(uid)
|
|
|
|
faDcAxleDeviceEntry := entity.FindAxleManageDevice(wd, sectionModel.CentralizedStation())
|
|
|
|
if faDcAxleDeviceEntry != nil {
|
|
|
|
faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
|
|
|
|
axleRuntime := faDcAxleDevice.FindAdr(uid)
|
|
|
|
if axleRuntime != nil {
|
|
|
|
sectionState.AxleDrst = axleRuntime.Drst
|
|
|
|
sectionState.AxlePdrst = axleRuntime.Pdrst
|
|
|
|
}
|
|
|
|
}
|
2023-10-27 14:57:37 +08:00
|
|
|
return sectionState
|
|
|
|
}
|
|
|
|
return nil
|
2023-10-26 16:41:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 收集车站按钮状态
|
2024-01-11 10:24:56 +08:00
|
|
|
func collectStationButtonStates(world ecs.World, mapId int32) ([]*state_proto.ButtonState, error) {
|
2023-10-26 16:41:18 +08:00
|
|
|
// 获取地图上的按钮状态
|
2024-01-11 10:24:56 +08:00
|
|
|
uidMap := memory.QueryMapUidMapByType(mapId, &data_proto.EsbButton{})
|
|
|
|
var btnStateArr []*state_proto.ButtonState
|
2023-10-26 16:41:18 +08:00
|
|
|
for _, u := range uidMap {
|
2023-12-20 10:37:54 +08:00
|
|
|
entry, ok := entity.GetEntityByUid(world, u.Uid)
|
2023-10-26 16:41:18 +08:00
|
|
|
if !ok {
|
2023-12-20 10:37:54 +08:00
|
|
|
return nil, fmt.Errorf("ESB按钮实体不存在: World id=%d, uid=%s", world.Id(), u.Uid)
|
2023-10-26 16:41:18 +08:00
|
|
|
}
|
|
|
|
if entry.HasComponent(component.ButtonTag) { // 按钮
|
|
|
|
bit := component.BitStateType.Get(entry)
|
2024-02-06 10:49:46 +08:00
|
|
|
btnStateArr = append(btnStateArr, &state_proto.ButtonState{ /*Bypass: bit.BypassEnable,*/ Id: u.CommonId, Down: bit.Val})
|
2023-10-26 16:41:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return btnStateArr, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// 收集信号机状态
|
2024-01-11 10:24:56 +08:00
|
|
|
func collectSignalStates(world ecs.World, mapId int32) ([]*state_proto.SignalState, error) {
|
|
|
|
uidMap := memory.QueryMapUidMapByType(mapId, &data_proto.Signal{})
|
|
|
|
var signalArr []*state_proto.SignalState
|
2023-10-26 16:41:18 +08:00
|
|
|
for _, u := range uidMap {
|
2023-12-20 10:37:54 +08:00
|
|
|
s, err := handlerSignalState(world, u.Uid)
|
2023-10-26 16:41:18 +08:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
s.Id = u.CommonId
|
|
|
|
signalArr = append(signalArr, s)
|
|
|
|
}
|
|
|
|
return signalArr, nil
|
|
|
|
}
|
|
|
|
|
2024-01-11 10:24:56 +08:00
|
|
|
func handlerSignalState(w ecs.World, uid string) (*state_proto.SignalState, error) {
|
2023-10-26 16:41:18 +08:00
|
|
|
entry, ok := entity.GetEntityByUid(w, uid)
|
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("信号机不存在: World id=%d, 信号机id=%s", w.Id(), uid)
|
|
|
|
}
|
|
|
|
if !entry.HasComponent(component.SignalLightsType) { //信号机灯列表
|
|
|
|
return nil, fmt.Errorf("信号机没有SignalLights组件: World id=%d, 信号机id=%s", w.Id(), uid)
|
|
|
|
}
|
2024-01-11 10:24:56 +08:00
|
|
|
signalState := &state_proto.SignalState{}
|
2023-10-26 16:41:18 +08:00
|
|
|
lights := component.SignalLightsType.Get(entry)
|
|
|
|
isL := false
|
|
|
|
isH := false
|
|
|
|
isU := false
|
|
|
|
isA := false
|
|
|
|
isB := false
|
|
|
|
for _, light := range lights.Lights {
|
|
|
|
switch {
|
|
|
|
case light.HasComponent(component.LdTag):
|
|
|
|
isL = component.BitStateType.Get(light).Val
|
|
|
|
case light.HasComponent(component.HdTag):
|
|
|
|
isH = component.BitStateType.Get(light).Val
|
|
|
|
case light.HasComponent(component.UdTag):
|
|
|
|
isU = component.BitStateType.Get(light).Val
|
|
|
|
case light.HasComponent(component.BdTag):
|
|
|
|
isB = component.BitStateType.Get(light).Val
|
|
|
|
case light.HasComponent(component.AdTag):
|
|
|
|
isA = component.BitStateType.Get(light).Val
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if isH && isU {
|
2024-01-11 10:24:56 +08:00
|
|
|
signalState.Aspect = state_proto.Signal_HU
|
2023-10-26 16:41:18 +08:00
|
|
|
} else {
|
|
|
|
switch {
|
|
|
|
case isL:
|
2024-01-11 10:24:56 +08:00
|
|
|
signalState.Aspect = state_proto.Signal_L
|
2023-10-26 16:41:18 +08:00
|
|
|
case isH:
|
2024-01-11 10:24:56 +08:00
|
|
|
signalState.Aspect = state_proto.Signal_H
|
2023-10-26 16:41:18 +08:00
|
|
|
case isU:
|
2024-01-11 10:24:56 +08:00
|
|
|
signalState.Aspect = state_proto.Signal_U
|
2023-10-26 16:41:18 +08:00
|
|
|
case isB:
|
2024-01-11 10:24:56 +08:00
|
|
|
signalState.Aspect = state_proto.Signal_B
|
2023-10-26 16:41:18 +08:00
|
|
|
case isA:
|
2024-01-11 10:24:56 +08:00
|
|
|
signalState.Aspect = state_proto.Signal_A
|
2023-10-26 16:41:18 +08:00
|
|
|
}
|
|
|
|
}
|
2024-01-18 14:54:39 +08:00
|
|
|
if entry.HasComponent(appcomponent.SignalParamType) {
|
|
|
|
signalState.Param = appcomponent.SignalParamType.Get(entry)
|
2024-01-18 17:20:14 +08:00
|
|
|
} else {
|
|
|
|
signalState.Param = &request_proto.SignalParam{}
|
2024-01-18 14:54:39 +08:00
|
|
|
}
|
2024-01-18 14:11:47 +08:00
|
|
|
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
|
|
|
|
}
|
2023-10-26 16:41:18 +08:00
|
|
|
return signalState, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// 收集列车状态
|
2024-01-11 10:24:56 +08:00
|
|
|
func collectTrainStates(vs *memory.VerifySimulation) ([]*state_proto.TrainMapState, error) {
|
2023-12-20 10:37:54 +08:00
|
|
|
allTrainMap := &vs.Memory.Status.TrainStateMap
|
2024-01-11 10:24:56 +08:00
|
|
|
var trainArr []*state_proto.TrainMapState
|
2023-10-26 16:41:18 +08:00
|
|
|
allTrainMap.Range(func(_, v any) bool {
|
2024-01-11 10:24:56 +08:00
|
|
|
trainArr = append(trainArr, convertTrainState(v.(*state_proto.TrainState)))
|
2023-10-26 16:41:18 +08:00
|
|
|
return true
|
|
|
|
})
|
|
|
|
return trainArr, nil
|
|
|
|
}
|
|
|
|
|
2024-01-11 10:24:56 +08:00
|
|
|
func convertTrainState(v *state_proto.TrainState) *state_proto.TrainMapState {
|
|
|
|
t := &state_proto.TrainMapState{
|
2023-12-15 09:48:42 +08:00
|
|
|
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,
|
|
|
|
// 动力学
|
|
|
|
DynamicHeartbeat: v.DynamicState.Heartbeat,
|
|
|
|
HeadLinkId: v.DynamicState.HeadLinkId,
|
|
|
|
HeadLinkOffset: v.DynamicState.HeadLinkOffset,
|
|
|
|
TailLinkId: v.DynamicState.TailLinkId,
|
|
|
|
TailLinkOffset: v.DynamicState.TailLinkOffset,
|
|
|
|
OccupiedLinkIndex: v.DynamicState.OccupiedLinkIndex,
|
|
|
|
Slope: v.DynamicState.Slope,
|
|
|
|
Upslope: v.DynamicState.Upslope,
|
|
|
|
RunningUp: v.DynamicState.RunningUp,
|
|
|
|
RunningResistanceSum: v.DynamicState.RunningResistanceSum,
|
|
|
|
AirResistance: v.DynamicState.AirResistance,
|
|
|
|
RampResistance: v.DynamicState.RampResistance,
|
|
|
|
CurveResistance: v.DynamicState.CurveResistance,
|
|
|
|
Speed: v.DynamicState.Speed,
|
|
|
|
HeadSensorSpeed1: v.DynamicState.HeadSensorSpeed1,
|
|
|
|
HeadSensorSpeed2: v.DynamicState.HeadSensorSpeed2,
|
|
|
|
TailSensorSpeed1: v.DynamicState.TailSensorSpeed1,
|
|
|
|
TailSensorSpeed2: v.DynamicState.TailSensorSpeed2,
|
|
|
|
HeadRadarSpeed: v.DynamicState.HeadRadarSpeed,
|
|
|
|
TailRadarSpeed: v.DynamicState.TailRadarSpeed,
|
|
|
|
DynamicInterruption: v.DynamicState.UdpInterruption,
|
|
|
|
Acceleration: v.DynamicState.Acceleration,
|
2024-01-26 17:57:35 +08:00
|
|
|
Displacement: v.DynamicState.Displacement,
|
2023-12-15 09:48:42 +08:00
|
|
|
// 半实物
|
|
|
|
VobcLifeSignal: v.VobcState.LifeSignal,
|
|
|
|
Tc1Active: v.VobcState.Tc1Active,
|
|
|
|
Tc2Active: v.VobcState.Tc2Active,
|
|
|
|
DirectionForward: v.VobcState.DirectionForward,
|
|
|
|
DirectionBackward: v.VobcState.DirectionBackward,
|
|
|
|
TractionStatus: v.VobcState.TractionStatus,
|
|
|
|
BrakingStatus: v.VobcState.BrakingStatus,
|
|
|
|
EmergencyBrakingStatus: v.VobcState.EmergencyBrakingStatus,
|
|
|
|
TurnbackStatus: v.VobcState.TurnbackStatus,
|
|
|
|
JumpStatus: v.VobcState.JumpStatus,
|
|
|
|
Ato: v.VobcState.Ato,
|
|
|
|
Fam: v.VobcState.Fam,
|
|
|
|
Cam: v.VobcState.Cam,
|
|
|
|
TractionSafetyCircuit: v.VobcState.TractionSafetyCircuit,
|
|
|
|
ParkingBrakeStatus: v.VobcState.ParkingBrakeStatus,
|
|
|
|
MaintainBrakeStatus: v.VobcState.MaintainBrakeStatus,
|
|
|
|
TractionForce: v.VobcState.TractionForce,
|
|
|
|
BrakeForce: v.VobcState.BrakeForce,
|
|
|
|
TrainLoad: v.VobcState.TrainLoad,
|
|
|
|
LeftDoorOpenCommand: v.VobcState.LeftDoorOpenCommand,
|
|
|
|
RightDoorOpenCommand: v.VobcState.RightDoorOpenCommand,
|
|
|
|
LeftDoorCloseCommand: v.VobcState.LeftDoorCloseCommand,
|
|
|
|
RightDoorCloseCommand: v.VobcState.RightDoorCloseCommand,
|
|
|
|
AllDoorClose: v.VobcState.AllDoorClose,
|
|
|
|
VobcInterruption: v.VobcState.UdpInterruption,
|
2024-01-30 13:52:07 +08:00
|
|
|
TrainEndsA: &state_proto.TrainEndsStateMqtt{},
|
|
|
|
TrainEndsB: &state_proto.TrainEndsStateMqtt{},
|
|
|
|
TrainDynamicConfig: &state_proto.TrainDynamicConfigMqtt{},
|
2024-02-06 18:00:39 +08:00
|
|
|
TailDeviceId: v.TailDeviceId,
|
|
|
|
TailOffset: v.TailOffset,
|
2024-02-06 16:52:39 +08:00
|
|
|
BtmState: v.BtmState,
|
2023-12-15 09:48:42 +08:00
|
|
|
}
|
2024-01-30 13:52:07 +08:00
|
|
|
convertDynamicConfig(v.TrainDynamicConfig, t.TrainDynamicConfig)
|
|
|
|
convertDynamicConfig(v.TrainEndsA, t.TrainEndsA)
|
|
|
|
convertDynamicConfig(v.TrainEndsB, t.TrainEndsB)
|
|
|
|
|
2023-12-15 09:48:42 +08:00
|
|
|
return t
|
|
|
|
}
|
2024-01-30 13:52:07 +08:00
|
|
|
func convertDynamicConfig(config, dest interface{}) {
|
2024-01-18 16:33:27 +08:00
|
|
|
configType := reflect.TypeOf(config).Elem()
|
|
|
|
for index := 0; index < configType.NumField(); index++ {
|
|
|
|
field := configType.Field(index)
|
|
|
|
if field.IsExported() {
|
|
|
|
fieldName := field.Name
|
2024-01-30 13:20:37 +08:00
|
|
|
setVal(config, dest, fieldName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-18 16:33:27 +08:00
|
|
|
|
2024-01-30 13:52:07 +08:00
|
|
|
/*func convertDynamicConfig(config *common_proto.TrainDynamicConfig, dest *state_proto.TrainDynamicConfigMqtt) {
|
|
|
|
configType := reflect.TypeOf(config).Elem()
|
|
|
|
for index := 0; index < configType.NumField(); index++ {
|
|
|
|
field := configType.Field(index)
|
|
|
|
if field.IsExported() {
|
|
|
|
fieldName := field.Name
|
|
|
|
setVal(config, dest, fieldName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
2024-01-30 13:20:37 +08:00
|
|
|
func setVal(source, dest interface{}, fieldName string) {
|
|
|
|
destVal := reflect.ValueOf(dest).Elem().FieldByName(fieldName)
|
|
|
|
sourceType := reflect.ValueOf(source).Elem().FieldByName(fieldName)
|
|
|
|
sourceData := sourceType.Interface()
|
|
|
|
defer func() {
|
|
|
|
err := recover()
|
|
|
|
if err != nil {
|
|
|
|
slog.Error(fieldName, "赋值失败,源数据类型", sourceType.Kind().String(), "目标数据类型:", destVal.Kind().String(), " 异常错误提示:", err)
|
|
|
|
debug.PrintStack()
|
2024-01-18 16:33:27 +08:00
|
|
|
}
|
2024-01-30 13:20:37 +08:00
|
|
|
}()
|
|
|
|
|
|
|
|
if destVal.Kind() == reflect.String {
|
|
|
|
destVal.Set(reflect.ValueOf(fmt.Sprintf("%v", sourceData)))
|
|
|
|
} else {
|
|
|
|
destVal.Set(reflect.ValueOf(sourceData))
|
2024-01-18 16:33:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-30 13:52:07 +08:00
|
|
|
/*
|
|
|
|
func convertEnds(ends *common_proto.TrainEndsState) *state_proto.TrainEndsStateMqtt {
|
|
|
|
return &state_proto.TrainEndsStateMqtt{SpeedSensorEnableA: ends.SpeedSensorEnableA,
|
|
|
|
SpeedSensorEnableB: ends.SpeedSensorEnableB,
|
|
|
|
RadarEnable: ends.RadarEnable,
|
|
|
|
RadarCheckSpeedDiff: floatToString(ends.RadarCheckSpeedDiff),
|
|
|
|
RadarCheckTime: ends.RadarCheckTime,
|
|
|
|
AccEnable: ends.AccEnable,
|
|
|
|
AccCheckSpeedDiff: floatToString(ends.AccCheckSpeedDiff),
|
|
|
|
AccCheckTime: ends.AccCheckTime,
|
|
|
|
}
|
2024-01-26 17:57:35 +08:00
|
|
|
}
|
2024-01-30 13:52:07 +08:00
|
|
|
*/
|
2024-01-18 16:33:27 +08:00
|
|
|
|
2023-10-26 16:41:18 +08:00
|
|
|
// 收集道岔状态
|
2024-01-11 10:24:56 +08:00
|
|
|
func collectTurnoutStates(sim *memory.VerifySimulation, mapId int32) ([]*state_proto.SwitchState, error) {
|
|
|
|
uidMap := memory.QueryMapUidMapByType(mapId, &data_proto.Turnout{})
|
2023-11-09 18:13:32 +08:00
|
|
|
wd := entity.GetWorldData(sim.World)
|
2024-01-11 10:24:56 +08:00
|
|
|
var switchArr []*state_proto.SwitchState
|
2023-10-26 16:41:18 +08:00
|
|
|
for _, u := range uidMap {
|
2023-11-09 18:13:32 +08:00
|
|
|
entry, ok := entity.GetEntityByUid(sim.World, u.Uid)
|
2023-10-26 16:41:18 +08:00
|
|
|
if !ok {
|
2023-11-09 18:13:32 +08:00
|
|
|
return nil, fmt.Errorf("道岔不存在: World id=%d,道岔id=%s", sim.World.Id(), u.Uid)
|
2023-10-26 16:41:18 +08:00
|
|
|
}
|
|
|
|
if !entry.HasComponent(component.TurnoutPositionType) {
|
2023-11-09 18:13:32 +08:00
|
|
|
return nil, fmt.Errorf("道岔没有TurnoutPosition组件: World id=%d,道岔id=%s", sim.World.Id(), u.Uid)
|
2023-10-26 16:41:18 +08:00
|
|
|
}
|
|
|
|
pos := component.TurnoutPositionType.Get(entry)
|
2024-01-11 10:24:56 +08:00
|
|
|
s := &state_proto.SwitchState{
|
2023-10-26 16:41:18 +08:00
|
|
|
Id: u.CommonId,
|
|
|
|
Normal: pos.Db,
|
|
|
|
Reverse: pos.Fb,
|
|
|
|
Dw: pos.Dw,
|
|
|
|
Fw: pos.Fw,
|
|
|
|
}
|
2024-01-18 14:54:39 +08:00
|
|
|
if entry.HasComponent(appcomponent.PointsParamType) {
|
|
|
|
s.Param = appcomponent.PointsParamType.Get(entry)
|
2024-01-18 17:20:14 +08:00
|
|
|
} else {
|
|
|
|
s.Param = &request_proto.PointsParam{}
|
2024-01-18 14:54:39 +08:00
|
|
|
}
|
2024-01-18 14:11:47 +08:00
|
|
|
// // 强制(联锁驱动无效)
|
|
|
|
// 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
|
2023-11-03 17:27:37 +08:00
|
|
|
if entry.HasComponent(component.Zdj9TwoElectronicType) {
|
|
|
|
elec := component.Zdj9TwoElectronicType.Get(entry)
|
|
|
|
dcj := component.BitStateType.Get(elec.TDC_DCJ)
|
|
|
|
s.Dc = dcj.Val
|
|
|
|
qdc, err := wd.QueryQdBit(component.UidType.Get(elec.TDC_DCJ).Id)
|
|
|
|
if err == nil {
|
|
|
|
s.Qdc = qdc
|
|
|
|
}
|
|
|
|
fcj := component.BitStateType.Get(elec.TDC_FCJ)
|
|
|
|
s.Fc = fcj.Val
|
|
|
|
qfc, err := wd.QueryQdBit(component.UidType.Get(elec.TDC_FCJ).Id)
|
|
|
|
if err == nil {
|
|
|
|
s.Qfc = qfc
|
|
|
|
}
|
|
|
|
ycj := component.BitStateType.Get(elec.TDC_YCJ)
|
|
|
|
s.Yc = ycj.Val
|
|
|
|
qyc, err := wd.QueryQdBit(component.UidType.Get(elec.TDC_YCJ).Id)
|
|
|
|
if err == nil {
|
|
|
|
s.Qyc = qyc
|
|
|
|
}
|
|
|
|
}
|
2023-11-09 18:13:32 +08:00
|
|
|
// 查看道岔是否被占用
|
|
|
|
turnout := sim.Repo.FindTurnout(u.Uid)
|
|
|
|
if turnout == nil {
|
|
|
|
return nil, fmt.Errorf("道岔不存在: World id=%d,道岔id=%s", sim.World.Id(), u.Uid)
|
|
|
|
}
|
|
|
|
if turnout.GetPhysicalSection() == nil {
|
|
|
|
return nil, fmt.Errorf("道岔关联的物理区段不存在: World id=%d,道岔id=%s", sim.World.Id(), u.Uid)
|
|
|
|
}
|
|
|
|
sectionState := handlerSectionState(sim.World, turnout.GetPhysicalSection().Id())
|
|
|
|
s.Occupied = sectionState.Occupied
|
2023-10-26 16:41:18 +08:00
|
|
|
switchArr = append(switchArr, s)
|
|
|
|
}
|
|
|
|
return switchArr, nil
|
|
|
|
}
|
2023-11-02 16:37:57 +08:00
|
|
|
|
2023-11-06 17:15:00 +08:00
|
|
|
// 收集站台状态
|
2024-01-11 10:24:56 +08:00
|
|
|
func collectPlatformStates(world ecs.World, mapId int32) ([]*state_proto.PlatformState, error) {
|
|
|
|
var states []*state_proto.PlatformState
|
|
|
|
mapData := memory.QueryGiData[*data_proto.RtssGraphicStorage](mapId)
|
2023-12-20 10:37:54 +08:00
|
|
|
uidsMap := memory.QueryUidStructure[*memory.StationUidStructure](mapId)
|
2023-11-07 09:22:46 +08:00
|
|
|
platformScreenDoorMap := wrapScreenDoorToPlatform(mapData)
|
2023-11-06 17:15:00 +08:00
|
|
|
for _, platform := range mapData.Platforms {
|
2023-12-13 15:05:42 +08:00
|
|
|
pid := memory.GetMapElementId(platform.Common)
|
2023-11-06 17:15:00 +08:00
|
|
|
stationCommonId := platform.RefStationId
|
2023-12-14 13:04:48 +08:00
|
|
|
if stationCommonId == 0 {
|
2023-12-13 15:05:42 +08:00
|
|
|
return nil, fmt.Errorf("站台没有绑定车站:id=%v", pid)
|
2023-11-02 16:37:57 +08:00
|
|
|
}
|
2023-11-06 17:15:00 +08:00
|
|
|
uidInfo := uidsMap.StationIds[stationCommonId]
|
|
|
|
if uidInfo == nil {
|
2023-12-14 13:04:48 +08:00
|
|
|
return nil, fmt.Errorf("车站实体不存在uid映射:id=%v", stationCommonId)
|
2023-11-02 16:37:57 +08:00
|
|
|
}
|
2023-12-20 10:37:54 +08:00
|
|
|
entry, ok := entity.GetEntityByUid(world, uidInfo.Uid)
|
2023-11-06 14:30:09 +08:00
|
|
|
if !ok {
|
2023-12-20 10:37:54 +08:00
|
|
|
return nil, fmt.Errorf("车站实体不存在: World id=%d, uid=%s", world.Id(), uidInfo.Uid)
|
2023-11-06 14:30:09 +08:00
|
|
|
}
|
2024-01-11 10:24:56 +08:00
|
|
|
sta := &state_proto.PlatformState{Id: pid}
|
2023-11-06 17:15:00 +08:00
|
|
|
isX := strings.Contains(platform.Code, "下行站台") //下行站台
|
2023-12-06 17:02:35 +08:00
|
|
|
if entry.HasComponent(component.EmpElectronicType) { // 紧急停车继电器
|
2023-11-06 14:30:09 +08:00
|
|
|
empElectronic := component.EmpElectronicType.Get(entry)
|
2023-12-06 17:02:35 +08:00
|
|
|
deviceElectronic := empElectronic.EMPJMap[platform.GetRefEsbRelayCode()]
|
|
|
|
if deviceElectronic != nil {
|
|
|
|
sta.Empj = getRelayXqVal(deviceElectronic.EMPJ)
|
2023-11-06 17:15:00 +08:00
|
|
|
}
|
2023-11-06 14:30:09 +08:00
|
|
|
}
|
2023-12-06 17:02:35 +08:00
|
|
|
if entry.HasComponent(component.SpkElectronicType) { // SPKS继电器
|
2023-11-06 17:15:00 +08:00
|
|
|
spkElectronic := component.SpkElectronicType.Get(entry)
|
|
|
|
if isX {
|
2024-01-29 14:42:12 +08:00
|
|
|
if spkElectronic.SPKSXPLAJ != nil {
|
|
|
|
sta.SpksState = append(sta.SpksState, &state_proto.ReplyState{Code: "SPKSX旁路", Xh: getRelayXqVal(spkElectronic.SPKSXPLAJ)})
|
|
|
|
}
|
|
|
|
if spkElectronic.SPKSX1J != nil {
|
|
|
|
sta.SpksState = append(sta.SpksState, &state_proto.ReplyState{Code: "SPKS1", Xh: getRelayXqVal(spkElectronic.SPKSX1J)})
|
|
|
|
}
|
|
|
|
if spkElectronic.SPKSX3J != nil {
|
|
|
|
sta.SpksState = append(sta.SpksState, &state_proto.ReplyState{Code: "SPKS3", Xh: getRelayXqVal(spkElectronic.SPKSX3J)})
|
|
|
|
}
|
2023-11-06 17:15:00 +08:00
|
|
|
} else {
|
2024-01-29 14:42:12 +08:00
|
|
|
if spkElectronic.SPKSSPLAJ != nil {
|
|
|
|
sta.SpksState = append(sta.SpksState, &state_proto.ReplyState{Code: "SPKSS旁路", Xh: getRelayXqVal(spkElectronic.SPKSSPLAJ)})
|
|
|
|
}
|
|
|
|
if spkElectronic.SPKSS2J != nil {
|
|
|
|
sta.SpksState = append(sta.SpksState, &state_proto.ReplyState{Code: "SPKS2", Xh: getRelayXqVal(spkElectronic.SPKSS2J)})
|
|
|
|
}
|
|
|
|
if spkElectronic.SPKSS4J != nil {
|
|
|
|
sta.SpksState = append(sta.SpksState, &state_proto.ReplyState{Code: "SPKS4", Xh: getRelayXqVal(spkElectronic.SPKSS4J)})
|
|
|
|
}
|
2023-11-07 09:22:46 +08:00
|
|
|
}
|
|
|
|
}
|
2023-12-13 15:05:42 +08:00
|
|
|
psdId := platformScreenDoorMap[pid]
|
2023-12-14 13:04:48 +08:00
|
|
|
if psdId != 0 {
|
2023-11-08 11:27:42 +08:00
|
|
|
psdUid, ok := uidsMap.PsdIds[psdId]
|
|
|
|
if !ok {
|
|
|
|
continue
|
|
|
|
}
|
2023-12-20 10:37:54 +08:00
|
|
|
psdEntry, ok := entity.GetEntityByUid(world, psdUid.Uid)
|
2023-11-08 11:27:42 +08:00
|
|
|
if !ok {
|
2023-12-20 10:37:54 +08:00
|
|
|
return nil, fmt.Errorf("屏蔽门实体不存在: World id=%d, uid=%s", world.Id(), psdUid.Uid)
|
2023-11-08 11:27:42 +08:00
|
|
|
}
|
|
|
|
if psdEntry.HasComponent(component.PlatformMkxCircuitType) {
|
|
|
|
mkxCircuit := component.PlatformMkxCircuitType.Get(psdEntry)
|
2024-01-11 10:24:56 +08:00
|
|
|
mkxj := &state_proto.MkxJState{Code: psdUid.Code}
|
2023-11-08 11:27:42 +08:00
|
|
|
if mkxCircuit.PABJ != nil {
|
2024-01-11 10:24:56 +08:00
|
|
|
mkxj.ReplyState = append(mkxj.ReplyState, &state_proto.ReplyState{Code: "站台确认继电器", Xh: getRelayXqVal(mkxCircuit.PABJ)})
|
2023-11-07 09:22:46 +08:00
|
|
|
}
|
2023-11-08 11:27:42 +08:00
|
|
|
if mkxCircuit.PCBJ != nil {
|
2024-01-11 10:24:56 +08:00
|
|
|
mkxj.ReplyState = append(mkxj.ReplyState, &state_proto.ReplyState{Code: "站台关门继电器", Xh: getRelayXqVal(mkxCircuit.PCBJ)})
|
2023-11-07 09:22:46 +08:00
|
|
|
}
|
2023-11-08 11:27:42 +08:00
|
|
|
if mkxCircuit.POBJ != nil {
|
2024-01-11 10:24:56 +08:00
|
|
|
mkxj.ReplyState = append(mkxj.ReplyState, &state_proto.ReplyState{Code: "站台开门继电器", Xh: getRelayXqVal(mkxCircuit.POBJ)})
|
2023-11-07 09:22:46 +08:00
|
|
|
}
|
2023-11-08 11:27:42 +08:00
|
|
|
sta.MkxJState = mkxj
|
2023-11-06 17:15:00 +08:00
|
|
|
}
|
2023-11-08 11:27:42 +08:00
|
|
|
|
2023-11-06 17:15:00 +08:00
|
|
|
}
|
|
|
|
states = append(states, sta)
|
2023-11-06 14:30:09 +08:00
|
|
|
}
|
|
|
|
return states, nil
|
|
|
|
}
|
|
|
|
|
2023-11-07 09:22:46 +08:00
|
|
|
// 将屏蔽门关联到站台
|
2024-01-11 10:24:56 +08:00
|
|
|
func wrapScreenDoorToPlatform(mapData *data_proto.RtssGraphicStorage) map[uint32]uint32 {
|
2023-12-14 13:04:48 +08:00
|
|
|
platformMap := make(map[uint32]uint32, len(mapData.Platforms))
|
2023-11-07 09:22:46 +08:00
|
|
|
for _, s := range mapData.ScreenDoors {
|
2023-12-13 15:05:42 +08:00
|
|
|
platformMap[s.RefPlatformId] = memory.GetMapElementId(s.Common)
|
2023-11-07 09:22:46 +08:00
|
|
|
}
|
|
|
|
return platformMap
|
|
|
|
}
|
|
|
|
|
2023-11-02 18:00:18 +08:00
|
|
|
// 获取继电器吸起状态
|
|
|
|
func getRelayXqVal(entry *ecs.Entry) bool {
|
|
|
|
relay := component.BitStateType.Get(entry)
|
|
|
|
return relay.Val
|
|
|
|
}
|