集成
This commit is contained in:
parent
b0990a4179
commit
e065eabe64
@ -1 +1 @@
|
||||
Subproject commit 200352eb58f1704a741d367e3c8afd02ae492b58
|
||||
Subproject commit 4997760ffb1284a7898ab84164671d5e21ec9248
|
@ -44,8 +44,6 @@ type IRelayCRole interface {
|
||||
type IModelManager interface {
|
||||
//FindById 根据模型的复合id获取模型数据
|
||||
FindById(id string) Identity
|
||||
//FindByType 获取某类型设备的所有模型数据
|
||||
FindByType(deviceType proto.DeviceType) []Identity
|
||||
}
|
||||
|
||||
// IPsdModel 仿真底层屏蔽门模型
|
||||
|
@ -39,6 +39,20 @@ func newRepository(id string, version string) *Repository {
|
||||
}
|
||||
}
|
||||
|
||||
// FindById 根据模型的复合id获取模型数据
|
||||
func (repo *Repository) FindById(id string) Identity {
|
||||
if md, ok := repo.turnoutMap[id]; ok {
|
||||
return md
|
||||
}
|
||||
if md, ok := repo.signalMap[id]; ok {
|
||||
return md
|
||||
}
|
||||
if md, ok := repo.relayMap[id]; ok {
|
||||
return md
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *Repository) PhysicalSectionList() []*PhysicalSection {
|
||||
var list []*PhysicalSection
|
||||
for _, model := range repo.physicalSectionMap {
|
||||
|
@ -3,7 +3,6 @@ package repository
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
)
|
||||
|
||||
@ -53,6 +52,39 @@ func NewTurnout(id string, km *proto.Kilometer, switchMachineType proto.Turnout_
|
||||
}
|
||||
}
|
||||
|
||||
// FindCircuitRoleById 根据继电器id获取在具体电路中的电路角色
|
||||
// relayId-继电器id
|
||||
// relayGroup-继电器组合类型
|
||||
// relayName-继电器在电路中的名称
|
||||
// find-true找到,false未找到
|
||||
func (t *Turnout) FindCircuitRoleById(relayId string) (relayGroup string, relayName string, find bool) {
|
||||
if t.relayGroups != nil {
|
||||
for _, rg := range t.relayGroups {
|
||||
for _, relay := range rg.relays {
|
||||
if relayId == relay.Id() {
|
||||
return rg.code, relay.code, true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", "", false
|
||||
}
|
||||
|
||||
// FindRelayModelByCRole 根据继电器具体电路角色来获取继电器设备模型
|
||||
// relayGroup-继电器组合类型
|
||||
// relayName-继电器在电路中的名称
|
||||
func (t *Turnout) FindRelayModelByCRole(relayGroup string, relayName string) Identity {
|
||||
if t.relayGroups != nil {
|
||||
for _, rg := range t.relayGroups {
|
||||
for _, relay := range rg.relays {
|
||||
if rg.code == relayGroup && relay.code == relayName {
|
||||
return relay
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (t *Turnout) PortNum() int {
|
||||
return 3
|
||||
}
|
||||
|
27
system/button_system.go
Normal file
27
system/button_system.go
Normal file
@ -0,0 +1,27 @@
|
||||
package system
|
||||
|
||||
import "joylink.club/ecs"
|
||||
|
||||
// ButtonState 广义按钮状态
|
||||
// 广义按钮在电路中作用为开关,至于是pressed接通电路还是released接通电路,要看具体电路
|
||||
type ButtonState struct {
|
||||
//true-pressed,false-released
|
||||
Pos bool
|
||||
}
|
||||
|
||||
// AutoReleaseState 广义按钮为自复位按钮时的自复位状态
|
||||
type AutoReleaseState struct {
|
||||
//true-自复位按钮,false-非自复位按钮
|
||||
enable bool
|
||||
//自复位剩余时间,ms
|
||||
releaseTime int64
|
||||
}
|
||||
|
||||
func NewButtonState() *ButtonState {
|
||||
return &ButtonState{false}
|
||||
}
|
||||
|
||||
var (
|
||||
ButtonStateComponent = ecs.NewComponentType[ButtonState]()
|
||||
AutoReleaseStateComponent = ecs.NewComponentType[AutoReleaseState]()
|
||||
)
|
6
system/spks_system.go
Normal file
6
system/spks_system.go
Normal file
@ -0,0 +1,6 @@
|
||||
package system
|
||||
|
||||
//车站人员防护开关电路
|
||||
|
||||
type SpksCircuitState struct {
|
||||
}
|
@ -2,6 +2,7 @@ package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"joylink.club/rtsssimulation/simulation"
|
||||
|
||||
"github.com/yohamta/donburi/component"
|
||||
"github.com/yohamta/donburi/filter"
|
||||
@ -38,10 +39,17 @@ func QueryEntityById(world ecs.World, q *ecs.Query, id string) *ecs.Entry {
|
||||
|
||||
var modelStorageQuery = ecs.NewQuery(filter.Contains(ModelStorageComponent))
|
||||
|
||||
// 测试用
|
||||
var xXDebug = false
|
||||
|
||||
// FindModelStorage 获取模型仓库
|
||||
func FindModelStorage(world ecs.World) IModelManager {
|
||||
if xXDebug {
|
||||
e, _ := modelStorageQuery.First(world)
|
||||
return ModelStorageComponent.Get(e).ModelManager
|
||||
} else {
|
||||
return simulation.FindSimulation(world.Id()).GetRepo()
|
||||
}
|
||||
}
|
||||
|
||||
// 捕获panic并恢复执行
|
||||
|
Loading…
Reference in New Issue
Block a user