双机zdj9道岔联锁驱动电路实现
This commit is contained in:
parent
738e10bb25
commit
44ef5bfa6d
@ -2,7 +2,6 @@ package sjzdj9
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||
"time"
|
||||
|
||||
"github.com/yohamta/donburi/filter"
|
||||
@ -26,7 +25,7 @@ func Test() {
|
||||
worldConfig := simulation.WorldConfig{
|
||||
ModelManager: worldStorage,
|
||||
Systems: []ecs.ISystem{system.NewSwitch2jZdj9System(), system.NewRelaySystem(), system.NewDebugSystem()},
|
||||
Tick: 100,
|
||||
Tick: 200,
|
||||
InitTime: time.Now(),
|
||||
}
|
||||
world := simulation.InitializeWorld(&worldConfig)
|
||||
@ -40,19 +39,19 @@ func Test() {
|
||||
//
|
||||
world.StartUp()
|
||||
time.Sleep(1 * time.Second)
|
||||
//反操
|
||||
sysEvent.RelayNeedChangeEventBus.PublishOutWorld(world, &sysEvent.RelayNeedChangeEvent{Id: "sw1-sjzdj9-ycj", Xh: true})
|
||||
sysEvent.RelayNeedChangeEventBus.PublishOutWorld(world, &sysEvent.RelayNeedChangeEvent{Id: "sw1-sjzdj9-fcj", Xh: true})
|
||||
//联锁驱动反操
|
||||
system.Switch2jZdj9DriveYc(world, "sw1", true)
|
||||
system.Switch2jZdj9DriveFc(world, "sw1", true)
|
||||
//
|
||||
time.Sleep(8 * time.Second)
|
||||
sysEvent.RelayNeedChangeEventBus.PublishOutWorld(world, &sysEvent.RelayNeedChangeEvent{Id: "sw1-sjzdj9-ycj", Xh: false})
|
||||
sysEvent.RelayNeedChangeEventBus.PublishOutWorld(world, &sysEvent.RelayNeedChangeEvent{Id: "sw1-sjzdj9-fcj", Xh: false})
|
||||
time.Sleep(12 * time.Second)
|
||||
system.Switch2jZdj9DriveYc(world, "sw1", false)
|
||||
system.Switch2jZdj9DriveFc(world, "sw1", false)
|
||||
time.Sleep(1 * time.Second)
|
||||
//定操
|
||||
sysEvent.RelayNeedChangeEventBus.PublishOutWorld(world, &sysEvent.RelayNeedChangeEvent{Id: "sw1-sjzdj9-ycj", Xh: true})
|
||||
sysEvent.RelayNeedChangeEventBus.PublishOutWorld(world, &sysEvent.RelayNeedChangeEvent{Id: "sw1-sjzdj9-dcj", Xh: true})
|
||||
//联锁驱动定操
|
||||
system.Switch2jZdj9DriveYc(world, "sw1", true)
|
||||
system.Switch2jZdj9DriveDc(world, "sw1", true)
|
||||
//
|
||||
time.Sleep(8 * time.Second)
|
||||
time.Sleep(12 * time.Second)
|
||||
world.Close()
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,43 @@ import (
|
||||
"joylink.club/rtsssimulation/umi"
|
||||
)
|
||||
|
||||
// --------联锁采集---------------
|
||||
|
||||
// Switch2jZdj9CjState 双机ZDJ9联锁采集电路状态
|
||||
type Switch2jZdj9CjState struct {
|
||||
ZdbjQ bool //采集总定表继电器前接点
|
||||
ZfbjQ bool //采集总反表继电器前接点
|
||||
YcjQ bool //采集允许操作继电器前接点
|
||||
ZdbjHAndZfbjH bool //失表采集:采集总定表继电器后接点和总反表继电器后接点,结果与处理
|
||||
J1DbjQ bool //采集j1定表继电器前接点
|
||||
J1FbjQ bool //采集j1反表继电器前接点
|
||||
J2DbjQ bool //采集j2定表继电器前接点
|
||||
J2FbjQ bool //采集j2反表继电器前接点
|
||||
}
|
||||
|
||||
func NewSwitch2jZdj9CjState() *Switch2jZdj9CjState {
|
||||
return &Switch2jZdj9CjState{}
|
||||
}
|
||||
|
||||
// --------联锁驱动-----------------
|
||||
|
||||
// Switch2jZdj9DriveYc 联锁驱动YCJ
|
||||
func Switch2jZdj9DriveYc(w ecs.World, switchId string, xh bool) bool {
|
||||
return DriveRelay(w, switchId, SJZDJ9_TDC, SJZDJ9_YCJ, xh)
|
||||
}
|
||||
|
||||
// Switch2jZdj9DriveFc 联锁驱动FCJ
|
||||
func Switch2jZdj9DriveFc(w ecs.World, switchId string, xh bool) bool {
|
||||
return DriveRelay(w, switchId, SJZDJ9_TDC, SJZDJ9_FCJ, xh)
|
||||
}
|
||||
|
||||
// Switch2jZdj9DriveDc 联锁驱动DCJ
|
||||
func Switch2jZdj9DriveDc(w ecs.World, switchId string, xh bool) bool {
|
||||
return DriveRelay(w, switchId, SJZDJ9_TDC, SJZDJ9_DCJ, xh)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
// Switch2jZdj9State 双机ZDJ9道岔电路系统状态定义
|
||||
// 继电器: true-吸合;false-未吸合
|
||||
type Switch2jZdj9State struct {
|
||||
@ -100,22 +137,6 @@ type Switch2jZdj9State struct {
|
||||
J2_Traction int8
|
||||
}
|
||||
|
||||
// Switch2jZdj9CjState 双机ZDJ9联锁采集电路状态
|
||||
type Switch2jZdj9CjState struct {
|
||||
ZdbjQ bool //采集总定表继电器前接点
|
||||
ZfbjQ bool //采集总反表继电器前接点
|
||||
YcjQ bool //采集允许操作继电器前接点
|
||||
ZdbjHAndZfbjH bool //失表采集:采集总定表继电器后接点和总反表继电器后接点,结果与处理
|
||||
J1DbjQ bool //采集j1定表继电器前接点
|
||||
J1FbjQ bool //采集j1反表继电器前接点
|
||||
J2DbjQ bool //采集j2定表继电器前接点
|
||||
J2FbjQ bool //采集j2反表继电器前接点
|
||||
}
|
||||
|
||||
func NewSwitch2jZdj9CjState() *Switch2jZdj9CjState {
|
||||
return &Switch2jZdj9CjState{}
|
||||
}
|
||||
|
||||
// NewSwitch2jZdj9State 创建ZDJ9道岔状态并初始化
|
||||
func NewSwitch2jZdj9State() *Switch2jZdj9State {
|
||||
return &Switch2jZdj9State{
|
||||
|
@ -2,10 +2,10 @@ package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/yohamta/donburi/component"
|
||||
"github.com/yohamta/donburi/filter"
|
||||
"joylink.club/ecs"
|
||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||
"joylink.club/rtsssimulation/umi"
|
||||
)
|
||||
|
||||
@ -51,7 +51,7 @@ func simpleRecover() {
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
// 实体标签
|
||||
// EntityTag 实体标签
|
||||
type EntityTag = component.IComponentType
|
||||
|
||||
type EntityTagHandler struct {
|
||||
@ -60,11 +60,34 @@ type EntityTagHandler struct {
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
// 模型仓库引用
|
||||
// ModelStorageRef 模型仓库引用
|
||||
// 用于world内使用,查询模型
|
||||
type ModelStorageRef struct {
|
||||
ModelManager umi.IModelManager
|
||||
}
|
||||
|
||||
// 模型仓库组件
|
||||
// ModelStorageComponent 模型仓库组件
|
||||
var ModelStorageComponent = ecs.NewComponentType[ModelStorageRef]()
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
// DriveRelay 驱动继电器
|
||||
// circuitModelId-如道岔模型id
|
||||
// relayGroup-继电器组合类型
|
||||
// relayName-继电器功能名称
|
||||
// xh-true:吸合,false:落下
|
||||
func DriveRelay(w ecs.World, circuitModelId string, relayGroup string, relayName string, xh bool) bool {
|
||||
if swModel := FindModelStorage(w).FindById(circuitModelId); swModel != nil {
|
||||
if roler, isCr := swModel.(umi.IRelayCRole); isCr {
|
||||
if relayModel := roler.FindRelayModelByCRole(relayGroup, relayName); relayModel != nil {
|
||||
if deviceModel, isDm := relayModel.(umi.IDeviceModel); isDm {
|
||||
relayId := deviceModel.GetId()
|
||||
sysEvent.RelayNeedChangeEventBus.PublishOutWorld(w, &sysEvent.RelayNeedChangeEvent{Id: relayId, Xh: xh})
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user