From 01d9b274dc2045a8d120daee9bac687b905749f3 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Thu, 28 Sep 2023 11:32:02 +0800 Subject: [PATCH] psd --- examples/test1/sjzdj9/main.go | 1 + system/psd_system.go | 68 +++++++++++++++++++++++++++++++++++ system/system.go | 4 +-- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/examples/test1/sjzdj9/main.go b/examples/test1/sjzdj9/main.go index cf21134..3bed4f8 100644 --- a/examples/test1/sjzdj9/main.go +++ b/examples/test1/sjzdj9/main.go @@ -16,6 +16,7 @@ import ( // Test 测试双机ZDJ9道岔 func Test() { + system.XXDebug = true //模型仓库 modelStorage := tstorages.NewModelStorage() addRelays(modelStorage) diff --git a/system/psd_system.go b/system/psd_system.go index f6ddd67..e7c9c05 100644 --- a/system/psd_system.go +++ b/system/psd_system.go @@ -6,6 +6,74 @@ import ( sysEvent "joylink.club/rtsssimulation/system/event" ) +// PsdDriveXGMJ 联锁驱动XGMJ +func PsdDriveXGMJ(w ecs.World, psdCircuitId string, lsDrive bool) bool { + psdEntry := FindEntityById(w, psdCircuitId) + if psdEntry == nil { + return false + } + psdState := PsdCircuitStateComponent.Get(psdEntry) + psdState.XGMLs = lsDrive + return true +} + +// PsdDriveSGMJ 联锁驱动SGMJ +func PsdDriveSGMJ(w ecs.World, psdCircuitId string, lsDrive bool) bool { + psdEntry := FindEntityById(w, psdCircuitId) + if psdEntry == nil { + return false + } + psdState := PsdCircuitStateComponent.Get(psdEntry) + psdState.SGMLs = lsDrive + return true +} + +// PsdDrive4XKMJ 联锁驱动4XKMJ +func PsdDrive4XKMJ(w ecs.World, psdCircuitId string, lsDrive bool) bool { + psdEntry := FindEntityById(w, psdCircuitId) + if psdEntry == nil { + return false + } + psdState := PsdCircuitStateComponent.Get(psdEntry) + psdState.G4XKMLs = lsDrive + return true +} + +// PsdDrive4SKMJ 联锁驱动4SKMJ +func PsdDrive4SKMJ(w ecs.World, psdCircuitId string, lsDrive bool) bool { + psdEntry := FindEntityById(w, psdCircuitId) + if psdEntry == nil { + return false + } + psdState := PsdCircuitStateComponent.Get(psdEntry) + psdState.G4SKMLs = lsDrive + return true +} + +// PsdDrive8XKMJ 联锁驱动8XKMJ +func PsdDrive8XKMJ(w ecs.World, psdCircuitId string, lsDrive bool) bool { + psdEntry := FindEntityById(w, psdCircuitId) + if psdEntry == nil { + return false + } + psdState := PsdCircuitStateComponent.Get(psdEntry) + psdState.G8XKMLs = lsDrive + return true +} + +// PsdDrive8SKMJ 联锁驱动8SKMJ +func PsdDrive8SKMJ(w ecs.World, psdCircuitId string, lsDrive bool) bool { + psdEntry := FindEntityById(w, psdCircuitId) + if psdEntry == nil { + return false + } + psdState := PsdCircuitStateComponent.Get(psdEntry) + psdState.G8SKMLs = lsDrive + return true +} + +////////////////////////////////////////////////////////////// + // PsdCircuitState 站台门控制电路状态,Psd为车站所有屏蔽门子门的集合 // 旁路继电器的工作原理是,当电路中的电流超过预定的阈值时,旁路继电器会自动断开电路,从而防止电路发生短路或过载等故障。 type PsdCircuitState struct { diff --git a/system/system.go b/system/system.go index c5734df..93995a9 100644 --- a/system/system.go +++ b/system/system.go @@ -40,11 +40,11 @@ func QueryEntityById(world ecs.World, q *ecs.Query, id string) *ecs.Entry { var modelStorageQuery = ecs.NewQuery(filter.Contains(ModelStorageComponent)) // 测试用 -var xXDebug = true +var XXDebug = false // FindModelStorage 获取模型仓库 func FindModelStorage(world ecs.World) IModelManager { - if xXDebug { + if XXDebug { e, _ := modelStorageQuery.First(world) return ModelStorageComponent.Get(e).ModelManager } else {