From 999d3b2767afec6792487038aea4f78b3047c483 Mon Sep 17 00:00:00 2001 From: walker Date: Mon, 11 Dec 2023 13:13:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=81=93=E5=B2=94=E6=8C=A4?= =?UTF-8?q?=E5=B2=94=E7=8A=B6=E6=80=81=E9=87=87=E9=9B=86=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0git=E5=AD=90=E6=A8=A1=E5=9D=97jl-iot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 + go.work | 1 + jl-iot | 1 + message_server/sfp_ms.go | 10 +- .../wayside/memory/wayside_memory_psd_test.go | 196 ++++++++---------- 5 files changed, 105 insertions(+), 106 deletions(-) create mode 160000 jl-iot diff --git a/.gitmodules b/.gitmodules index 978e0a5..bdb3e53 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "rtss_simulation"] path = rtss_simulation url = https://git.code.tencent.com/jl-framework/rtss_simulation.git +[submodule "jl-iot"] + path = jl-iot + url = https://git.code.tencent.com/jl-framework/jl-iot.git diff --git a/go.work b/go.work index b1a4583..955379e 100644 --- a/go.work +++ b/go.work @@ -2,6 +2,7 @@ go 1.21 use ( . + ./jl-iot ./rtss_simulation ./rtss_simulation/jl-ecs-go ) diff --git a/jl-iot b/jl-iot new file mode 160000 index 0000000..8878ed0 --- /dev/null +++ b/jl-iot @@ -0,0 +1 @@ +Subproject commit 8878ed03ce070065e3711d3ecd03efe8f87f2344 diff --git a/message_server/sfp_ms.go b/message_server/sfp_ms.go index c0f759f..b149333 100644 --- a/message_server/sfp_ms.go +++ b/message_server/sfp_ms.go @@ -277,8 +277,16 @@ func (ms *SfpMs) collectTurnoutStates() ([]*state.SwitchState, error) { 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 = entry.HasComponent(component.TurnoutFaultJcType) + s.Jc = jc if entry.HasComponent(component.Zdj9TwoElectronicType) { elec := component.Zdj9TwoElectronicType.Get(entry) dcj := component.BitStateType.Get(elec.TDC_DCJ) diff --git a/ts/simulation/wayside/memory/wayside_memory_psd_test.go b/ts/simulation/wayside/memory/wayside_memory_psd_test.go index 71b02cd..8a63cd5 100644 --- a/ts/simulation/wayside/memory/wayside_memory_psd_test.go +++ b/ts/simulation/wayside/memory/wayside_memory_psd_test.go @@ -1,112 +1,98 @@ package memory_test -import ( - "fmt" - "testing" - "time" +// // 暂时不可用,循环引用导致无法通过函数获取仿真,没想到解决办法 +// func TestHandlePsdOperation(t *testing.T) { +// simInfo := ts.ListAllSimulations()[0] +// simId := simInfo.SimulationId +// var mapId int32 +// for _, id := range simInfo.MapIds { +// if memory.QueryGiType(id) == graphicData.PictureType_StationLayout { +// mapId = id +// } +// } +// if mapId == 0 { +// fmt.Println("无信号布置图") +// return +// } +// data := memory.QueryGiData[*graphicData.RtssGraphicStorage](mapId) +// deviceId := data.ScreenDoors[0].Common.Id - "joylink.club/bj-rtsts-server/dto/request_proto" - "joylink.club/bj-rtsts-server/ts" - "joylink.club/bj-rtsts-server/ts/protos/graphicData" - "joylink.club/bj-rtsts-server/ts/simulation/wayside/memory" - "joylink.club/rtsssimulation/component" - "joylink.club/rtsssimulation/consts" - "joylink.club/rtsssimulation/entity" -) +// simulation := ts.FindSimulation(simId) +// wantErr := false +// uid := memory.QueryUidByMidAndComId(mapId, deviceId, &graphicData.Turnout{}) +// entry, _ := entity.GetEntityByUid(simulation.World, uid) +// asdList := component.AsdListType.Get(entry) +// psdModel := entity.GetWorldData(simulation.World).Repo.FindPsd(uid) -// 暂时不可用,循环引用导致无法通过函数获取仿真,没想到解决办法 -func TestHandlePsdOperation(t *testing.T) { - simInfo := ts.ListAllSimulations()[0] - simId := simInfo.SimulationId - var mapId int32 - for _, id := range simInfo.MapIds { - if memory.QueryGiType(id) == graphicData.PictureType_StationLayout { - mapId = id - } - } - if mapId == 0 { - fmt.Println("无信号布置图") - return - } - data := memory.QueryGiData[*graphicData.RtssGraphicStorage](mapId) - deviceId := data.ScreenDoors[0].Common.Id +// for key, value := range request_proto.Psd_Operation_value { +// name := fmt.Sprintf("执行操作:%s", key) +// req := &request_proto.PsdOperationReq{ +// SimulationId: "", +// MapId: mapId, +// DeviceId: deviceId, +// Operation: request_proto.Psd_Operation(value), +// } +// t.Run(name, func(t *testing.T) { +// if err := memory.HandlePsdOperation(simulation, req); (err != nil) != wantErr { +// t.Errorf("HandlePsdOperation() error = %v, wantErr %v", err, wantErr) +// } +// tick := time.Tick(5 * time.Second) +// <-tick +// switch req.Operation { +// case request_proto.Psd_Km4: +// group := psdModel.FindAsdGroup(4) +// for i, asd := range asdList.List { +// pos := component.TwoPositionTransformType.Get(asd).Pos +// if int32(i) < group.Start || int32(i) > group.End { +// if pos != consts.TwoPosMin { +// t.Errorf("4编组开门操作[编号:%d]的滑动门位置[%d]不正确", i, pos) +// } +// } else { +// if pos != consts.TwoPosMax { +// t.Errorf(fmt.Sprintf("4编组开门操作[编号:%d]的滑动门位置[%d]不正确", i, pos)) +// } +// } +// } +// case request_proto.Psd_CancelKm4: +// if component.PscType.Get(entry).InterlockKM4 == true { +// t.Errorf("取消4编组开门失败") +// } +// case request_proto.Psd_Km8: +// group := psdModel.FindAsdGroup(8) +// for i, asd := range asdList.List { +// pos := component.TwoPositionTransformType.Get(asd).Pos +// if int32(i) < group.Start || int32(i) > group.End { +// if pos != consts.TwoPosMin { +// t.Errorf("8编组开门操作[编号:%d]的滑动门位置[%d]不正确", i, pos) +// } +// } else { +// if pos != consts.TwoPosMax { +// t.Errorf("8编组开门操作[编号:%d]的滑动门位置[%d]不正确", i, pos) +// } +// } +// } +// case request_proto.Psd_CancelKm8: +// if component.PscType.Get(entry).InterlockKM8 == true { +// t.Errorf("取消8编组开门失败") +// } +// case request_proto.Psd_Gm: +// for i, asd := range asdList.List { +// pos := component.TwoPositionTransformType.Get(asd).Pos +// if pos != consts.TwoPosMin { +// t.Errorf("4编组开门操作[编号:%d]的滑动门位置[%d]不正确", i, pos) +// } +// } +// case request_proto.Psd_CancelGm: +// if component.PscType.Get(entry).InterlockGM == true { +// t.Errorf("取消关门失败") +// } +// case request_proto.Psd_ForceKm4: - simulation := ts.FindSimulation(simId) - wantErr := false - uid := memory.QueryUidByMidAndComId(mapId, deviceId, &graphicData.Turnout{}) - entry, _ := entity.GetEntityByUid(simulation.World, uid) - asdList := component.AsdListType.Get(entry) - psdModel := entity.GetWorldData(simulation.World).Repo.FindPsd(uid) +// case request_proto.Psd_ForceKm8: - for key, value := range request_proto.Psd_Operation_value { - name := fmt.Sprintf("执行操作:%s", key) - req := &request_proto.PsdOperationReq{ - SimulationId: "", - MapId: mapId, - DeviceId: deviceId, - Operation: request_proto.Psd_Operation(value), - } - t.Run(name, func(t *testing.T) { - if err := memory.HandlePsdOperation(simulation, req); (err != nil) != wantErr { - t.Errorf("HandlePsdOperation() error = %v, wantErr %v", err, wantErr) - } - tick := time.Tick(5 * time.Second) - <-tick - switch req.Operation { - case request_proto.Psd_Km4: - group := psdModel.FindAsdGroup(4) - for i, asd := range asdList.List { - pos := component.TwoPositionTransformType.Get(asd).Pos - if int32(i) < group.Start || int32(i) > group.End { - if pos != consts.TwoPosMin { - t.Errorf("4编组开门操作[编号:%d]的滑动门位置[%d]不正确", i, pos) - } - } else { - if pos != consts.TwoPosMax { - t.Errorf(fmt.Sprintf("4编组开门操作[编号:%d]的滑动门位置[%d]不正确", i, pos)) - } - } - } - case request_proto.Psd_CancelKm4: - if component.PscType.Get(entry).InterlockKM4 == true { - t.Errorf("取消4编组开门失败") - } - case request_proto.Psd_Km8: - group := psdModel.FindAsdGroup(8) - for i, asd := range asdList.List { - pos := component.TwoPositionTransformType.Get(asd).Pos - if int32(i) < group.Start || int32(i) > group.End { - if pos != consts.TwoPosMin { - t.Errorf("8编组开门操作[编号:%d]的滑动门位置[%d]不正确", i, pos) - } - } else { - if pos != consts.TwoPosMax { - t.Errorf("8编组开门操作[编号:%d]的滑动门位置[%d]不正确", i, pos) - } - } - } - case request_proto.Psd_CancelKm8: - if component.PscType.Get(entry).InterlockKM8 == true { - t.Errorf("取消8编组开门失败") - } - case request_proto.Psd_Gm: - for i, asd := range asdList.List { - pos := component.TwoPositionTransformType.Get(asd).Pos - if pos != consts.TwoPosMin { - t.Errorf("4编组开门操作[编号:%d]的滑动门位置[%d]不正确", i, pos) - } - } - case request_proto.Psd_CancelGm: - if component.PscType.Get(entry).InterlockGM == true { - t.Errorf("取消关门失败") - } - case request_proto.Psd_ForceKm4: +// case request_proto.Psd_ForceGm: - case request_proto.Psd_ForceKm8: - - case request_proto.Psd_ForceGm: - - } - }) - } -} +// } +// }) +// } +// }