From 412de346bcca2e223a831dd1c6f423c9be99ce77 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Wed, 11 Oct 2023 17:11:13 +0800 Subject: [PATCH] signal 3xh1 --- component/{signal_3xh1.go => signal.go} | 21 +++++++++++++++++++++ component/signal_2xh1.go | 24 ------------------------ examples/signal_3xh1/main.go | 8 ++------ jl-ecs-go | 2 +- sys/circuit_sys/signal_2xh1.go | 17 +++++------------ sys/circuit_sys/signal_3xh1.go | 12 +++--------- 6 files changed, 32 insertions(+), 52 deletions(-) rename component/{signal_3xh1.go => signal.go} (55%) delete mode 100644 component/signal_2xh1.go diff --git a/component/signal_3xh1.go b/component/signal.go similarity index 55% rename from component/signal_3xh1.go rename to component/signal.go index 3fb2b3a..6eb0268 100644 --- a/component/signal_3xh1.go +++ b/component/signal.go @@ -2,6 +2,27 @@ package component import "joylink.club/ecs" +// Signal2XH1Electronic 电路状态:**信号机2XH-1(红-绿) 出段(场)信号机 或 **出站区间阻挡信号机 +type Signal2XH1Electronic struct { + // 点灯继电器,true-吸合,常态落下表示逻辑点灯 + Z2XH1_DDJ *ecs.Entry + //灯丝继电器,true-吸合 + Z2XH1_DJ *ecs.Entry + //列车信号继电器,true-吸合 + Z2XH1_LXJ *ecs.Entry + //物理绿灯,true-亮 + Z2XH1_L *ecs.Entry + // 物理红灯,true-亮 + Z2XH1_H *ecs.Entry +} + +var ( + //Signal2XH1ElectronicType 2XH1信号机电路组件 + Signal2XH1ElectronicType = ecs.NewComponentType[Signal2XH1Electronic]() +) + +///////////////////////////////////////////////////////////////////////// + // Signal3XH1Electronic 电路状态:信号机3XH-1(红-绿-黄) 道岔防护信号机(三显示不封灯,有单黄显示、带引导) type Signal3XH1Electronic struct { // 点灯继电器,true-吸合,常态落下表示逻辑点灯 diff --git a/component/signal_2xh1.go b/component/signal_2xh1.go deleted file mode 100644 index 480e18c..0000000 --- a/component/signal_2xh1.go +++ /dev/null @@ -1,24 +0,0 @@ -package component - -import ( - "joylink.club/ecs" -) - -// Signal2XH1Electronic 电路状态:**信号机2XH-1(红-绿) 出段(场)信号机 或 **出站区间阻挡信号机 -type Signal2XH1Electronic struct { - // 点灯继电器,true-吸合,常态落下表示逻辑点灯 - Z2XH1_DDJ *ecs.Entry - //灯丝继电器,true-吸合 - Z2XH1_DJ *ecs.Entry - //列车信号继电器,true-吸合 - Z2XH1_LXJ *ecs.Entry - //物理绿灯,true-亮 - Z2XH1_L *ecs.Entry - // 物理红灯,true-亮 - Z2XH1_H *ecs.Entry -} - -var ( - //Signal2XH1ElectronicType 2XH1信号机电路组件 - Signal2XH1ElectronicType = ecs.NewComponentType[Signal2XH1Electronic]() -) diff --git a/examples/signal_3xh1/main.go b/examples/signal_3xh1/main.go index 21c0658..3871c3e 100644 --- a/examples/signal_3xh1/main.go +++ b/examples/signal_3xh1/main.go @@ -10,8 +10,6 @@ import ( "joylink.club/rtsssimulation/fi" "joylink.club/rtsssimulation/repository" "joylink.club/rtsssimulation/repository/model/proto" - "joylink.club/rtsssimulation/sys/circuit_sys" - "joylink.club/rtsssimulation/sys/device_sys" "log" "time" ) @@ -29,10 +27,8 @@ func main() { repo := repository.BuildRepositoryForSignalTest(proto) sim := rtss_simulation.NewSimulation(repo) loadEntities(sim, repo) - sim.SetSpeed(1) + sim.SetSpeed(0.1) sim.AddSystem(sigSys.NewSignalDebugSystem()) - sim.AddSystem(device_sys.NewRelaySys()) - sim.AddSystem(circuit_sys.NewSignal3XH1System()) sim.StartUp() // time.Sleep(1 * time.Second) @@ -48,7 +44,7 @@ func main() { fi.DriveSignal3XH1Yx(sim, IdSignal3XH1) time.Sleep(2 * time.Second) worldLog(sim, "===>>开通列车信号 .....") - fi.DriveSignal3XH1Lx(sim, IdSignal3XH1, true) + fi.DriveSignal3XH1Lx(sim, IdSignal3XH1, false) // time.Sleep(5 * time.Second) sim.Close() diff --git a/jl-ecs-go b/jl-ecs-go index e779734..af60502 160000 --- a/jl-ecs-go +++ b/jl-ecs-go @@ -1 +1 @@ -Subproject commit e7797346722a572814539d9a453789b89ffe6bf4 +Subproject commit af605020f1bccf1f1b2ab5a4ae4966d1c6c9776c diff --git a/sys/circuit_sys/signal_2xh1.go b/sys/circuit_sys/signal_2xh1.go index 9c618c6..f753d74 100644 --- a/sys/circuit_sys/signal_2xh1.go +++ b/sys/circuit_sys/signal_2xh1.go @@ -29,30 +29,23 @@ func (s *Signal2XH1System) calculateL(state *component.Signal2XH1Electronic) { ddj := component.BitStateType.Get(state.Z2XH1_DDJ) lxj := component.BitStateType.Get(state.Z2XH1_LXJ) isL := !ddj.Val && lxj.Val - if driveL.Td != isL { - driveL.Td = isL - } + driveL.Td = isL } func (s *Signal2XH1System) calculateH(state *component.Signal2XH1Electronic) { driveH := component.LightDriveType.Get(state.Z2XH1_H) ddj := component.BitStateType.Get(state.Z2XH1_DDJ) lxj := component.BitStateType.Get(state.Z2XH1_LXJ) isH := !ddj.Val && !lxj.Val - if driveH.Td != isH { - driveH.Td = isH - } + driveH.Td = isH } func (s *Signal2XH1System) calculateDJ(state *component.Signal2XH1Electronic) { ddj := component.BitStateType.Get(state.Z2XH1_DDJ) lxj := component.BitStateType.Get(state.Z2XH1_LXJ) - dj := component.BitStateType.Get(state.Z2XH1_DJ) ld := component.BitStateType.Get(state.Z2XH1_L) hd := component.BitStateType.Get(state.Z2XH1_H) isDJ := !ddj.Val && lxj.Val && ld.Val || !ddj.Val && !lxj.Val && hd.Val //通知继电器进行动作 - if dj.Val != isDJ { - drive := component.RelayDriveType.Get(state.Z2XH1_DJ) - drive.Td = isDJ - drive.Xq = isDJ - } + drive := component.RelayDriveType.Get(state.Z2XH1_DJ) + drive.Td = isDJ + drive.Xq = isDJ } diff --git a/sys/circuit_sys/signal_3xh1.go b/sys/circuit_sys/signal_3xh1.go index 72216b4..e5e0a34 100644 --- a/sys/circuit_sys/signal_3xh1.go +++ b/sys/circuit_sys/signal_3xh1.go @@ -42,9 +42,7 @@ func (s *Signal3XH1System) calculateU(state *component.Signal3XH1Electronic) { //侧向行车信号 isLC := !ddj.Val && lxj.Val && !zxj.Val isU := isY || isLC - if driveU.Td != isU { - driveU.Td = isU - } + driveU.Td = isU } // 绿灯点灯电路 @@ -55,9 +53,7 @@ func (s *Signal3XH1System) calculateL(state *component.Signal3XH1Electronic) { zxj := component.BitStateType.Get(state.Z3XH1_ZXJ) driveL := component.LightDriveType.Get(state.Z3XH1_L) isL := !ddj.Val && lxj.Val && zxj.Val - if driveL.Td != isL { - driveL.Td = isL - } + driveL.Td = isL } // 红灯点灯电路 @@ -67,9 +63,7 @@ func (s *Signal3XH1System) calculateH(state *component.Signal3XH1Electronic) { lxj := component.BitStateType.Get(state.Z3XH1_LXJ) driveH := component.LightDriveType.Get(state.Z3XH1_H) isH := !ddj.Val && !lxj.Val - if driveH.Td != isH { - driveH.Td = isH - } + driveH.Td = isH } // DJ 灯丝继电器电路