umi调整
This commit is contained in:
parent
bd24347708
commit
1fb8a5b7eb
@ -5,11 +5,10 @@ import (
|
|||||||
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/system"
|
"joylink.club/rtsssimulation/system"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateModelStorageEntity 创建模型仓库实体
|
// CreateModelStorageEntity 创建模型仓库实体
|
||||||
func CreateModelStorageEntity(w ecs.World, modelManager umi.IModelManager) *ecs.Entry {
|
func CreateModelStorageEntity(w ecs.World, modelManager system.IModelManager) *ecs.Entry {
|
||||||
e := w.Create(system.ModelStorageComponent)
|
e := w.Create(system.ModelStorageComponent)
|
||||||
system.ModelStorageComponent.Set(e, &system.ModelStorageRef{ModelManager: modelManager})
|
system.ModelStorageComponent.Set(e, &system.ModelStorageRef{ModelManager: modelManager})
|
||||||
return e
|
return e
|
||||||
|
@ -4,11 +4,10 @@ import (
|
|||||||
"github.com/yohamta/donburi"
|
"github.com/yohamta/donburi"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/system"
|
"joylink.club/rtsssimulation/system"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateStationPsdsCircuitEntity 创建车站屏蔽门电路实体
|
// CreateStationPsdsCircuitEntity 创建车站屏蔽门电路实体
|
||||||
func CreateStationPsdsCircuitEntity(w ecs.World, stationId string, psds []umi.IPsdModel) *ecs.Entry {
|
func CreateStationPsdsCircuitEntity(w ecs.World, stationId string, psds []system.IPsdModel) *ecs.Entry {
|
||||||
circuit := w.Create(system.EntityIdentityComponent, system.StationPsdsCircuitStateComponent, system.PsdTagHandlerComponent)
|
circuit := w.Create(system.EntityIdentityComponent, system.StationPsdsCircuitStateComponent, system.PsdTagHandlerComponent)
|
||||||
system.EntityIdentityComponent.Set(circuit, &system.EntityIdentity{Id: stationId})
|
system.EntityIdentityComponent.Set(circuit, &system.EntityIdentity{Id: stationId})
|
||||||
system.StationPsdsCircuitStateComponent.Set(circuit, system.NewStationPsdsCircuitState())
|
system.StationPsdsCircuitStateComponent.Set(circuit, system.NewStationPsdsCircuitState())
|
||||||
@ -40,7 +39,7 @@ func CreateStationPsdsCircuitEntity(w ecs.World, stationId string, psds []umi.IP
|
|||||||
}
|
}
|
||||||
psdEntry := w.Create(cc...)
|
psdEntry := w.Create(cc...)
|
||||||
//
|
//
|
||||||
psdId := psd.(umi.IDeviceModel).Id()
|
psdId := psd.(system.IDeviceModel).Id()
|
||||||
system.EntityIdentityComponent.Set(psdEntry, &system.EntityIdentity{Id: psdId})
|
system.EntityIdentityComponent.Set(psdEntry, &system.EntityIdentity{Id: psdId})
|
||||||
system.PsdStateComponent.Set(psdEntry, system.NewPsdState())
|
system.PsdStateComponent.Set(psdEntry, system.NewPsdState())
|
||||||
system.PercentageDeviceStateComponent.Set(psdEntry, system.NewPercentageDeviceStateL())
|
system.PercentageDeviceStateComponent.Set(psdEntry, system.NewPercentageDeviceStateL())
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
"joylink.club/rtsssimulation/examples/test1/tstorages"
|
"joylink.club/rtsssimulation/examples/test1/tstorages"
|
||||||
"joylink.club/rtsssimulation/simulation"
|
"joylink.club/rtsssimulation/simulation"
|
||||||
"joylink.club/rtsssimulation/system"
|
"joylink.club/rtsssimulation/system"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Test 测试双机ZDJ9道岔
|
// Test 测试双机ZDJ9道岔
|
||||||
@ -90,7 +89,7 @@ func addRelays(modelStorage *tstorages.ModelStorage) {
|
|||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-dbj"))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-dbj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-fbj"))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-fbj"))
|
||||||
}
|
}
|
||||||
func findRelayModel(modelStorage *tstorages.ModelStorage, id string) umi.IDeviceModel {
|
func findRelayModel(modelStorage *tstorages.ModelStorage, id string) system.IDeviceModel {
|
||||||
return modelStorage.FindModelById(id)
|
return modelStorage.FindModelById(id)
|
||||||
}
|
}
|
||||||
func addSwitchs(modelStorage *tstorages.ModelStorage) {
|
func addSwitchs(modelStorage *tstorages.ModelStorage) {
|
||||||
@ -129,7 +128,7 @@ func initComponents(w ecs.World) {
|
|||||||
swState := system.Switch2jZdj9StateComponent.Get(e)
|
swState := system.Switch2jZdj9StateComponent.Get(e)
|
||||||
swMd := system.FindModelStorage(w).FindById(swId).(*tmodel.SwitchModel)
|
swMd := system.FindModelStorage(w).FindById(swId).(*tmodel.SwitchModel)
|
||||||
for _, relay := range swMd.Relays {
|
for _, relay := range swMd.Relays {
|
||||||
relayId := relay.Relay.(umi.IDeviceModel).Id()
|
relayId := relay.Relay.(system.IDeviceModel).Id()
|
||||||
relayEntry := system.FindEntityById(w, relayId)
|
relayEntry := system.FindEntityById(w, relayId)
|
||||||
relayState := system.RelayStateComponent.Get(relayEntry)
|
relayState := system.RelayStateComponent.Get(relayEntry)
|
||||||
relayGroup := relay.RelayGroup
|
relayGroup := relay.RelayGroup
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package tmodel
|
package tmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"joylink.club/rtsssimulation/umi"
|
"joylink.club/rtsssimulation/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 设备模型基础信息
|
// 设备模型基础信息
|
||||||
@ -9,12 +9,12 @@ type DeviceModel struct {
|
|||||||
// 设备id
|
// 设备id
|
||||||
DevId string
|
DevId string
|
||||||
// 设备类型
|
// 设备类型
|
||||||
DevType umi.DeviceType
|
DevType system.DeviceType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (me *DeviceModel) Id() string {
|
func (me *DeviceModel) Id() string {
|
||||||
return me.DevId
|
return me.DevId
|
||||||
}
|
}
|
||||||
func (me *DeviceModel) Type() umi.DeviceType {
|
func (me *DeviceModel) Type() system.DeviceType {
|
||||||
return me.DevType
|
return me.DevType
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@ package tmodel
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"joylink.club/rtsssimulation/repository/model/proto"
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
"joylink.club/rtsssimulation/umi"
|
"joylink.club/rtsssimulation/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 道岔电路系统中的继电器
|
// 道岔电路系统中的继电器
|
||||||
type SwitchRelay struct {
|
type SwitchRelay struct {
|
||||||
//继电器模型
|
//继电器模型
|
||||||
Relay umi.IDeviceModel
|
Relay system.IDeviceModel
|
||||||
//该继电器在该道岔电路系统中的组合类型
|
//该继电器在该道岔电路系统中的组合类型
|
||||||
RelayGroup string
|
RelayGroup string
|
||||||
//该继电器在该道岔电路系统中的功能名称
|
//该继电器在该道岔电路系统中的功能名称
|
||||||
@ -47,7 +47,7 @@ func (me *SwitchModel) FindCircuitRoleById(relayId string) (relayGroup string, r
|
|||||||
// FindRelayModelByCRole 根据继电器具体电路角色来获取继电器设备模型
|
// FindRelayModelByCRole 根据继电器具体电路角色来获取继电器设备模型
|
||||||
// relayGroup-继电器组合类型
|
// relayGroup-继电器组合类型
|
||||||
// relayName-继电器在电路中的名称
|
// relayName-继电器在电路中的名称
|
||||||
func (me *SwitchModel) FindRelayModelByCRole(relayGroup string, relayName string) umi.IDeviceModel {
|
func (me *SwitchModel) FindRelayModelByCRole(relayGroup string, relayName string) system.IDeviceModel {
|
||||||
for _, sr := range me.Relays {
|
for _, sr := range me.Relays {
|
||||||
if sr.RelayGroup == relayGroup && sr.RelayName == relayName {
|
if sr.RelayGroup == relayGroup && sr.RelayName == relayName {
|
||||||
return sr.Relay
|
return sr.Relay
|
||||||
|
@ -2,23 +2,22 @@ package tstorages
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"joylink.club/rtsssimulation/system"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 仿真模型数据定义
|
// 仿真模型数据定义
|
||||||
type ModelData = umi.IDeviceModel
|
type ModelData = system.IDeviceModel
|
||||||
|
|
||||||
// 模型存储、管理仓库
|
// 模型存储、管理仓库
|
||||||
type ModelStorage struct {
|
type ModelStorage struct {
|
||||||
//key-模型id,value-模型指针
|
//key-模型id,value-模型指针
|
||||||
idModelMap map[string]ModelData
|
idModelMap map[string]ModelData
|
||||||
//key-设备类型,value-对应设备类型的所有模型数据的指针列表
|
//key-设备类型,value-对应设备类型的所有模型数据的指针列表
|
||||||
typeModelMap map[umi.DeviceType][]ModelData
|
typeModelMap map[system.DeviceType][]ModelData
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewModelStorage() *ModelStorage {
|
func NewModelStorage() *ModelStorage {
|
||||||
return &ModelStorage{idModelMap: make(map[string]ModelData, 2048), typeModelMap: make(map[umi.DeviceType][]ModelData, 128)}
|
return &ModelStorage{idModelMap: make(map[string]ModelData, 2048), typeModelMap: make(map[system.DeviceType][]ModelData, 128)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加模型数据
|
// 添加模型数据
|
||||||
@ -41,7 +40,7 @@ func (me *ModelStorage) AddModel(m ModelData) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 根据设备类型获取该类型的所有设备数据
|
// 根据设备类型获取该类型的所有设备数据
|
||||||
func (me *ModelStorage) FindModelsByType(deviceType umi.DeviceType) []ModelData {
|
func (me *ModelStorage) FindModelsByType(deviceType system.DeviceType) []ModelData {
|
||||||
models, ok := me.typeModelMap[deviceType]
|
models, ok := me.typeModelMap[deviceType]
|
||||||
if ok {
|
if ok {
|
||||||
return models
|
return models
|
||||||
@ -62,7 +61,7 @@ func (me *ModelStorage) FindModelById(id string) ModelData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 遍历某个类型的所有设备
|
// 遍历某个类型的所有设备
|
||||||
func (me *ModelStorage) ForEachModelsByType(deviceType umi.DeviceType, callback func(md ModelData)) {
|
func (me *ModelStorage) ForEachModelsByType(deviceType system.DeviceType, callback func(md ModelData)) {
|
||||||
mds := me.FindModelsByType(deviceType)
|
mds := me.FindModelsByType(deviceType)
|
||||||
for _, modelData := range mds {
|
for _, modelData := range mds {
|
||||||
callback(modelData)
|
callback(modelData)
|
||||||
|
@ -3,8 +3,7 @@ package tstorages
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"joylink.club/rtsssimulation/repository/model/proto"
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
|
"joylink.club/rtsssimulation/system"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 共享仓库映射
|
// 共享仓库映射
|
||||||
@ -52,7 +51,7 @@ type WorldModelStorage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 根据模型的复合id获取模型数据
|
// 根据模型的复合id获取模型数据
|
||||||
func (me *WorldModelStorage) FindById(id string) umi.IDeviceModel {
|
func (me *WorldModelStorage) FindById(id string) system.IDeviceModel {
|
||||||
md := me.Links.FindModelById(id)
|
md := me.Links.FindModelById(id)
|
||||||
if md != nil {
|
if md != nil {
|
||||||
return md
|
return md
|
||||||
@ -65,7 +64,7 @@ func (me *WorldModelStorage) FindById(id string) umi.IDeviceModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取某类型设备的所有模型数据
|
// 获取某类型设备的所有模型数据
|
||||||
func (me *WorldModelStorage) FindByType(deviceType umi.DeviceType) []umi.IDeviceModel {
|
func (me *WorldModelStorage) FindByType(deviceType system.DeviceType) []system.IDeviceModel {
|
||||||
if proto.DeviceType_DeviceType_Link == deviceType {
|
if proto.DeviceType_DeviceType_Link == deviceType {
|
||||||
return me.Links.FindModelsByType(deviceType)
|
return me.Links.FindModelsByType(deviceType)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 2949aa52e18d5d7eb8281cbba968b4bb22b6e741
|
Subproject commit 4997760ffb1284a7898ab84164671d5e21ec9248
|
@ -21,3 +21,21 @@ func (m identity) Id() string {
|
|||||||
func (m identity) Type() proto.DeviceType {
|
func (m identity) Type() proto.DeviceType {
|
||||||
return m.deviceType
|
return m.deviceType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// IRelayCRole 获取继电器在具体电路中的角色(组合类型、功能名称)
|
||||||
|
// 如信号机3XH-1电路中点灯继电器:组合类型-"3XH-1" 功能名称-"DDJ"
|
||||||
|
// 对应设备电路中有继电器的设备模型须实现该接口
|
||||||
|
type IRelayCRole interface {
|
||||||
|
//FindCircuitRoleById 根据继电器id获取在具体电路中的电路角色
|
||||||
|
//relayId-继电器id
|
||||||
|
//relayGroup-继电器组合类型
|
||||||
|
//relayName-继电器在电路中的名称
|
||||||
|
//find-true找到,false未找到
|
||||||
|
FindCircuitRoleById(relayId string) (relayGroup string, relayName string, find bool)
|
||||||
|
//FindRelayModelByCRole 根据继电器具体电路角色来获取继电器设备模型
|
||||||
|
//relayGroup-继电器组合类型
|
||||||
|
//relayName-继电器在电路中的名称
|
||||||
|
FindRelayModelByCRole(relayGroup string, relayName string) Identity
|
||||||
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package simulation
|
package simulation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"joylink.club/rtsssimulation/system"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// WorldConfig 仿真world配置
|
// WorldConfig 仿真world配置
|
||||||
type WorldConfig struct {
|
type WorldConfig struct {
|
||||||
//模型管理器,接收模型仓库管理器实例的指针
|
//模型管理器,接收模型仓库管理器实例的指针
|
||||||
ModelManager umi.IModelManager
|
ModelManager system.IModelManager
|
||||||
//world 系统
|
//world 系统
|
||||||
Systems []ecs.ISystem
|
Systems []ecs.ISystem
|
||||||
//world tick
|
//world tick
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
package umi
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"joylink.club/rtsssimulation/repository"
|
"joylink.club/rtsssimulation/repository"
|
||||||
"joylink.club/rtsssimulation/repository/model/proto"
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 用户设备模型与仿真底层设备交互定义
|
// system 视角的模型定义
|
||||||
|
|
||||||
type DeviceType = proto.DeviceType
|
type DeviceType = proto.DeviceType
|
||||||
|
|
||||||
|
// IDeviceModel 仿真底层设备模型定义
|
||||||
|
// 用户所有设备模型定义须实现该接口
|
||||||
|
type IDeviceModel = repository.Identity
|
||||||
|
|
||||||
|
// IRelayCRole 获取继电器在具体电路中的角色(组合类型、功能名称)
|
||||||
|
// 如信号机3XH-1电路中点灯继电器:组合类型-"3XH-1" 功能名称-"DDJ"
|
||||||
|
// 对应设备电路中有继电器的设备模型须实现该接口
|
||||||
|
type IRelayCRole = repository.IRelayCRole
|
||||||
|
|
||||||
// IModelManager 模型管理接口
|
// IModelManager 模型管理接口
|
||||||
type IModelManager interface {
|
type IModelManager interface {
|
||||||
//FindById 根据模型的复合id获取模型数据
|
//FindById 根据模型的复合id获取模型数据
|
||||||
@ -21,10 +30,6 @@ type IModelManager interface {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// IDeviceModel 仿真底层设备模型定义
|
|
||||||
// 用户所有设备模型定义须实现该接口
|
|
||||||
type IDeviceModel = repository.Identity
|
|
||||||
|
|
||||||
// IPsdModel 仿真底层屏蔽门模型
|
// IPsdModel 仿真底层屏蔽门模型
|
||||||
// 用户所有屏蔽门模型定义须实现该接口
|
// 用户所有屏蔽门模型定义须实现该接口
|
||||||
type IPsdModel interface {
|
type IPsdModel interface {
|
||||||
@ -41,21 +46,3 @@ type IPsdModel interface {
|
|||||||
//IsX8 true-下行8编组
|
//IsX8 true-下行8编组
|
||||||
IsX8() bool
|
IsX8() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// IRelayCRole 获取继电器在具体电路中的角色(组合类型、功能名称)
|
|
||||||
// 如信号机3XH-1电路中点灯继电器:组合类型-"3XH-1" 功能名称-"DDJ"
|
|
||||||
// 对应设备电路中有继电器的设备模型须实现该接口
|
|
||||||
type IRelayCRole interface {
|
|
||||||
//FindCircuitRoleById 根据继电器id获取在具体电路中的电路角色
|
|
||||||
//relayId-继电器id
|
|
||||||
//relayGroup-继电器组合类型
|
|
||||||
//relayName-继电器在电路中的名称
|
|
||||||
//find-true找到,false未找到
|
|
||||||
FindCircuitRoleById(relayId string) (relayGroup string, relayName string, find bool)
|
|
||||||
//FindRelayModelByCRole 根据继电器具体电路角色来获取继电器设备模型
|
|
||||||
//relayGroup-继电器组合类型
|
|
||||||
//relayName-继电器在电路中的名称
|
|
||||||
FindRelayModelByCRole(relayGroup string, relayName string) IDeviceModel
|
|
||||||
}
|
|
@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Signal2XH1State 电路状态:**信号机2XH-1(红-绿) 出段(场)信号机 或 **出站区间阻挡信号机
|
// Signal2XH1State 电路状态:**信号机2XH-1(红-绿) 出段(场)信号机 或 **出站区间阻挡信号机
|
||||||
@ -72,7 +71,7 @@ var Signal2XH1RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
//根据event来更新Signal2XH1State中对应继电器的状态
|
//根据event来更新Signal2XH1State中对应继电器的状态
|
||||||
signal2XH1Query.Each(w, func(e *ecs.Entry) {
|
signal2XH1Query.Each(w, func(e *ecs.Entry) {
|
||||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||||
roler, ok := signalModel.(umi.IRelayCRole)
|
roler, ok := signalModel.(IRelayCRole)
|
||||||
if ok {
|
if ok {
|
||||||
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||||
if relayGroup == SIGNAL_2XH1 {
|
if relayGroup == SIGNAL_2XH1 {
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 信号机电路继电器组合类型和功能名称常量
|
// 信号机电路继电器组合类型和功能名称常量
|
||||||
@ -98,7 +97,7 @@ var Signal3XH1RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
//根据event来更新Signal3XH1State中对应继电器的状态
|
//根据event来更新Signal3XH1State中对应继电器的状态
|
||||||
signal3XH1Query.Each(w, func(e *ecs.Entry) {
|
signal3XH1Query.Each(w, func(e *ecs.Entry) {
|
||||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||||
roler, ok := signalModel.(umi.IRelayCRole)
|
roler, ok := signalModel.(IRelayCRole)
|
||||||
if ok {
|
if ok {
|
||||||
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||||
if relayGroup == SIGNAL_3XH1 {
|
if relayGroup == SIGNAL_3XH1 {
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Signal3XH2State 电路状态:信号机3XH-2(红-绿-黄) 道岔防护信号机(三显示不封灯、无单黄显示、带引导)
|
// Signal3XH2State 电路状态:信号机3XH-2(红-绿-黄) 道岔防护信号机(三显示不封灯、无单黄显示、带引导)
|
||||||
@ -76,7 +75,7 @@ var Signal3XH2RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
//根据event来更新Signal3XH1State中对应继电器的状态
|
//根据event来更新Signal3XH1State中对应继电器的状态
|
||||||
signal3XH2Query.Each(w, func(e *ecs.Entry) {
|
signal3XH2Query.Each(w, func(e *ecs.Entry) {
|
||||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||||
roler, ok := signalModel.(umi.IRelayCRole)
|
roler, ok := signalModel.(IRelayCRole)
|
||||||
if ok {
|
if ok {
|
||||||
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||||
if relayGroup == SIGNAL_3XH2 {
|
if relayGroup == SIGNAL_3XH2 {
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Signal3XH3State 电路状态:信号机3XH-3(红-绿-黄) 道岔防护信号机(三显示封绿灯、有单黄显示、带引导)
|
// Signal3XH3State 电路状态:信号机3XH-3(红-绿-黄) 道岔防护信号机(三显示封绿灯、有单黄显示、带引导)
|
||||||
@ -72,7 +71,7 @@ var Signal3XH3RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
//根据event来更新Signal3XH3State中对应继电器的状态
|
//根据event来更新Signal3XH3State中对应继电器的状态
|
||||||
signal3XH3Query.Each(w, func(e *ecs.Entry) {
|
signal3XH3Query.Each(w, func(e *ecs.Entry) {
|
||||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||||
roler, ok := signalModel.(umi.IRelayCRole)
|
roler, ok := signalModel.(IRelayCRole)
|
||||||
if ok {
|
if ok {
|
||||||
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||||
if relayGroup == SIGNAL_3XH3 {
|
if relayGroup == SIGNAL_3XH3 {
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Signal3XH4State 电路状态:信号机3XH-4(红-绿-黄) 出站兼道岔防护信号机(三显示不封灯、有单黄显示、无引导)
|
// Signal3XH4State 电路状态:信号机3XH-4(红-绿-黄) 出站兼道岔防护信号机(三显示不封灯、有单黄显示、无引导)
|
||||||
@ -72,7 +71,7 @@ var Signal3XH4RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
//根据event来更新Signal3XH4State中对应继电器的状态
|
//根据event来更新Signal3XH4State中对应继电器的状态
|
||||||
signal3XH4Query.Each(w, func(e *ecs.Entry) {
|
signal3XH4Query.Each(w, func(e *ecs.Entry) {
|
||||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||||
roler, ok := signalModel.(umi.IRelayCRole)
|
roler, ok := signalModel.(IRelayCRole)
|
||||||
if ok {
|
if ok {
|
||||||
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||||
if relayGroup == SIGNAL_3XH4 {
|
if relayGroup == SIGNAL_3XH4 {
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// SignalDCXHState 电路状态:信号机DCXH(蓝-白) 调车信号机
|
// SignalDCXHState 电路状态:信号机DCXH(蓝-白) 调车信号机
|
||||||
@ -62,7 +61,7 @@ var SignalDCXHRelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
//根据event来更新SignalDCXHState中对应继电器的状态
|
//根据event来更新SignalDCXHState中对应继电器的状态
|
||||||
signalDCXHQuery.Each(w, func(e *ecs.Entry) {
|
signalDCXHQuery.Each(w, func(e *ecs.Entry) {
|
||||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||||
roler, ok := signalModel.(umi.IRelayCRole)
|
roler, ok := signalModel.(IRelayCRole)
|
||||||
if ok {
|
if ok {
|
||||||
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||||
if relayGroup == SIGNAL_DCXH {
|
if relayGroup == SIGNAL_DCXH {
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// SignalJCKXHState 电路状态:信号机JCKXH(红-白-黄) 进/出库列车兼调车信号机(三显示不封灯、有单黄显示、无引导)
|
// SignalJCKXHState 电路状态:信号机JCKXH(红-白-黄) 进/出库列车兼调车信号机(三显示不封灯、有单黄显示、无引导)
|
||||||
@ -69,7 +68,7 @@ var SignalJCKXHRelayActionEventProcessor = func(w ecs.World, event sysEvent.Rela
|
|||||||
//根据event来更新SignalJCKXHState中对应继电器的状态
|
//根据event来更新SignalJCKXHState中对应继电器的状态
|
||||||
signalJCKXHQuery.Each(w, func(e *ecs.Entry) {
|
signalJCKXHQuery.Each(w, func(e *ecs.Entry) {
|
||||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||||
roler, ok := signalModel.(umi.IRelayCRole)
|
roler, ok := signalModel.(IRelayCRole)
|
||||||
if ok {
|
if ok {
|
||||||
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||||
if relayGroup == SIGNAL_JCKXH {
|
if relayGroup == SIGNAL_JCKXH {
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// SignalJDXHState 电路状态:信号机JDXH(红-绿-黄) 进段信号机(三显示不封灯、无单黄显示、带引导)
|
// SignalJDXHState 电路状态:信号机JDXH(红-绿-黄) 进段信号机(三显示不封灯、无单黄显示、带引导)
|
||||||
@ -71,7 +70,7 @@ var SignalJDXHRelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
//根据event来更新SignalJDXHState中对应继电器的状态
|
//根据event来更新SignalJDXHState中对应继电器的状态
|
||||||
signalJDXHQuery.Each(w, func(e *ecs.Entry) {
|
signalJDXHQuery.Each(w, func(e *ecs.Entry) {
|
||||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||||
roler, ok := signalModel.(umi.IRelayCRole)
|
roler, ok := signalModel.(IRelayCRole)
|
||||||
if ok {
|
if ok {
|
||||||
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||||
if relayGroup == SIGNAL_JDXH {
|
if relayGroup == SIGNAL_JDXH {
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// --------联锁驱动-----------------
|
// --------联锁驱动-----------------
|
||||||
@ -298,7 +297,7 @@ var Switch2jzdj9RelayActionEventProcessor = func(w ecs.World, event sysEvent.Rel
|
|||||||
log.Println("==>>收到继电器动作事件:id = ", event.Id, " xh = ", event.Xh)
|
log.Println("==>>收到继电器动作事件:id = ", event.Id, " xh = ", event.Xh)
|
||||||
zdj9Query.Each(w, func(e *ecs.Entry) {
|
zdj9Query.Each(w, func(e *ecs.Entry) {
|
||||||
switchModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
switchModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||||
roler, ok := switchModel.(umi.IRelayCRole)
|
roler, ok := switchModel.(IRelayCRole)
|
||||||
if ok {
|
if ok {
|
||||||
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||||
state := Switch2jZdj9StateComponent.Get(e)
|
state := Switch2jZdj9StateComponent.Get(e)
|
||||||
@ -384,9 +383,9 @@ var Switch2jzdj9RelayActionEventProcessor = func(w ecs.World, event sysEvent.Rel
|
|||||||
// 发送继电器需要改变事件
|
// 发送继电器需要改变事件
|
||||||
func (me *Switch2jZdj9System) publishRelayNeedChangeEvent(w ecs.World, switchEntry *ecs.Entry, relayGroup string, relayName string, needXh bool) {
|
func (me *Switch2jZdj9System) publishRelayNeedChangeEvent(w ecs.World, switchEntry *ecs.Entry, relayGroup string, relayName string, needXh bool) {
|
||||||
switchModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(switchEntry).Id)
|
switchModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(switchEntry).Id)
|
||||||
relayRole, _ := switchModel.(umi.IRelayCRole)
|
relayRole, _ := switchModel.(IRelayCRole)
|
||||||
relayModel := relayRole.FindRelayModelByCRole(relayGroup, relayName)
|
relayModel := relayRole.FindRelayModelByCRole(relayGroup, relayName)
|
||||||
sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayModel.(umi.IDeviceModel).Id(), Xh: needXh})
|
sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayModel.(IDeviceModel).Id(), Xh: needXh})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 断相保护电路运算
|
// 断相保护电路运算
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||||
"joylink.club/rtsssimulation/umi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// EntityIdentity 实体身份定义
|
// EntityIdentity 实体身份定义
|
||||||
@ -40,7 +39,7 @@ func QueryEntityById(world ecs.World, q *ecs.Query, id string) *ecs.Entry {
|
|||||||
var modelStorageQuery = ecs.NewQuery(filter.Contains(ModelStorageComponent))
|
var modelStorageQuery = ecs.NewQuery(filter.Contains(ModelStorageComponent))
|
||||||
|
|
||||||
// FindModelStorage 获取模型仓库
|
// FindModelStorage 获取模型仓库
|
||||||
func FindModelStorage(world ecs.World) umi.IModelManager {
|
func FindModelStorage(world ecs.World) IModelManager {
|
||||||
e, _ := modelStorageQuery.First(world)
|
e, _ := modelStorageQuery.First(world)
|
||||||
return ModelStorageComponent.Get(e).ModelManager
|
return ModelStorageComponent.Get(e).ModelManager
|
||||||
}
|
}
|
||||||
@ -74,7 +73,7 @@ var EntityTagHandlerComponent = ecs.NewComponentType[EntityTagHandler]()
|
|||||||
// ModelStorageRef 模型仓库引用
|
// ModelStorageRef 模型仓库引用
|
||||||
// 用于world内使用,查询模型
|
// 用于world内使用,查询模型
|
||||||
type ModelStorageRef struct {
|
type ModelStorageRef struct {
|
||||||
ModelManager umi.IModelManager
|
ModelManager IModelManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// ModelStorageComponent 模型仓库组件
|
// ModelStorageComponent 模型仓库组件
|
||||||
@ -89,9 +88,9 @@ var ModelStorageComponent = ecs.NewComponentType[ModelStorageRef]()
|
|||||||
// xh-true:吸合,false:落下
|
// xh-true:吸合,false:落下
|
||||||
func DriveRelay(w ecs.World, circuitModelId string, relayGroup string, relayName string, xh bool) bool {
|
func DriveRelay(w ecs.World, circuitModelId string, relayGroup string, relayName string, xh bool) bool {
|
||||||
if swModel := FindModelStorage(w).FindById(circuitModelId); swModel != nil {
|
if swModel := FindModelStorage(w).FindById(circuitModelId); swModel != nil {
|
||||||
if roler, isCr := swModel.(umi.IRelayCRole); isCr {
|
if roler, isCr := swModel.(IRelayCRole); isCr {
|
||||||
if relayModel := roler.FindRelayModelByCRole(relayGroup, relayName); relayModel != nil {
|
if relayModel := roler.FindRelayModelByCRole(relayGroup, relayName); relayModel != nil {
|
||||||
if deviceModel, isDm := relayModel.(umi.IDeviceModel); isDm {
|
if deviceModel, isDm := relayModel.(IDeviceModel); isDm {
|
||||||
relayId := deviceModel.Id()
|
relayId := deviceModel.Id()
|
||||||
sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayId, Xh: xh})
|
sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayId, Xh: xh})
|
||||||
return true
|
return true
|
||||||
@ -105,9 +104,9 @@ func DriveRelay(w ecs.World, circuitModelId string, relayGroup string, relayName
|
|||||||
|
|
||||||
func createRelayNeedChangeEvent(w ecs.World, circuitModelId string, relayGroup string, relayName string, xh bool) (*sysEvent.RelayNeedChangeEvent, bool) {
|
func createRelayNeedChangeEvent(w ecs.World, circuitModelId string, relayGroup string, relayName string, xh bool) (*sysEvent.RelayNeedChangeEvent, bool) {
|
||||||
if swModel := FindModelStorage(w).FindById(circuitModelId); swModel != nil {
|
if swModel := FindModelStorage(w).FindById(circuitModelId); swModel != nil {
|
||||||
if roler, isCr := swModel.(umi.IRelayCRole); isCr {
|
if roler, isCr := swModel.(IRelayCRole); isCr {
|
||||||
if relayModel := roler.FindRelayModelByCRole(relayGroup, relayName); relayModel != nil {
|
if relayModel := roler.FindRelayModelByCRole(relayGroup, relayName); relayModel != nil {
|
||||||
if deviceModel, isDm := relayModel.(umi.IDeviceModel); isDm {
|
if deviceModel, isDm := relayModel.(IDeviceModel); isDm {
|
||||||
relayId := deviceModel.Id()
|
relayId := deviceModel.Id()
|
||||||
return &sysEvent.RelayNeedChangeEvent{Id: relayId, Xh: xh}, true
|
return &sysEvent.RelayNeedChangeEvent{Id: relayId, Xh: xh}, true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user