修改道岔挤岔状态采集问题

添加git子模块jl-iot
This commit is contained in:
walker 2023-12-11 13:13:56 +08:00
parent 3c19601247
commit 999d3b2767
5 changed files with 105 additions and 106 deletions

3
.gitmodules vendored
View File

@ -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

View File

@ -2,6 +2,7 @@ go 1.21
use (
.
./jl-iot
./rtss_simulation
./rtss_simulation/jl-ecs-go
)

1
jl-iot Submodule

@ -0,0 +1 @@
Subproject commit 8878ed03ce070065e3711d3ecd03efe8f87f2344

View File

@ -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)

View File

@ -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:
}
})
}
}
// }
// })
// }
// }