umi 使用repository中model接口
This commit is contained in:
parent
64eb0c10ba
commit
1986b616ca
@ -40,7 +40,7 @@ func CreateStationPsdsCircuitEntity(w ecs.World, stationId string, psds []umi.IP
|
|||||||
}
|
}
|
||||||
psdEntry := w.Create(cc...)
|
psdEntry := w.Create(cc...)
|
||||||
//
|
//
|
||||||
psdId := psd.(umi.IDeviceModel).GetId()
|
psdId := psd.(umi.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())
|
||||||
|
@ -2,6 +2,7 @@ package sjzdj9
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/yohamta/donburi/filter"
|
"github.com/yohamta/donburi/filter"
|
||||||
@ -56,38 +57,38 @@ func Test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addEntities(w ecs.World, modelStorage *tstorages.ModelStorage) {
|
func addEntities(w ecs.World, modelStorage *tstorages.ModelStorage) {
|
||||||
modelStorage.ForEachModelsByType(umi.Switch, func(md tstorages.ModelData) {
|
modelStorage.ForEachModelsByType(proto.DeviceType_DeviceType_Turnout, func(md tstorages.ModelData) {
|
||||||
entities.CreateSwitch2jzdj9Entity(w, md.GetId())
|
entities.CreateSwitch2jzdj9Entity(w, md.Id())
|
||||||
})
|
})
|
||||||
modelStorage.ForEachModelsByType(umi.Relay, func(md tstorages.ModelData) {
|
modelStorage.ForEachModelsByType(proto.DeviceType_DeviceType_Relay, func(md tstorages.ModelData) {
|
||||||
entities.CreateRelayEntity(w, md.GetId())
|
entities.CreateRelayEntity(w, md.Id())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
func addRelays(modelStorage *tstorages.ModelStorage) {
|
func addRelays(modelStorage *tstorages.ModelStorage) {
|
||||||
//道岔sw1,双机zdj9
|
//道岔sw1,双机zdj9
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-dcj", umi.JWXC_1700))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-dcj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-fcj", umi.JWXC_1700))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-fcj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-ycj", umi.JWXC_1700))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-ycj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-zdbj", umi.JPXC_1000))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-zdbj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-zfbj", umi.JPXC_1000))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-zfbj"))
|
||||||
|
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-1dqj", umi.JWJXC_H125_80))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-1dqj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-bhj", umi.JWXC_1700))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-bhj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-2dqj", umi.JYJXC_160_260))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-2dqj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-1dqjf", umi.JWJXC_480))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-1dqjf"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-dbj", umi.JPXC_1000))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-dbj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-fbj", umi.JPXC_1000))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-fbj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-qdj", umi.JWXC_1700))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-qdj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-zbhj", umi.JWXC_1700))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j1-zbhj"))
|
||||||
|
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-1dqj", umi.JWJXC_H125_80))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-1dqj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-bhj", umi.JWXC_1700))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-bhj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-2dqj", umi.JYJXC_160_260))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-2dqj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-1dqjf", umi.JWJXC_480))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-1dqjf"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-dbj", umi.JPXC_1000))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-dbj"))
|
||||||
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-fbj", umi.JPXC_1000))
|
modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-fbj"))
|
||||||
}
|
}
|
||||||
func findRelayModel(modelStorage *tstorages.ModelStorage, id string) umi.IDeviceModel {
|
func findRelayModel(modelStorage *tstorages.ModelStorage, id string) umi.IDeviceModel {
|
||||||
return modelStorage.FindModelById(id)
|
return modelStorage.FindModelById(id)
|
||||||
@ -128,7 +129,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).GetId()
|
relayId := relay.Relay.(umi.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
|
||||||
|
@ -7,17 +7,14 @@ import (
|
|||||||
// 设备模型基础信息
|
// 设备模型基础信息
|
||||||
type DeviceModel struct {
|
type DeviceModel struct {
|
||||||
// 设备id
|
// 设备id
|
||||||
Id string
|
DevId string
|
||||||
// 设备类型
|
// 设备类型
|
||||||
Type umi.DeviceType
|
DevType umi.DeviceType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (me *DeviceModel) GetId() string {
|
func (me *DeviceModel) Id() string {
|
||||||
return me.Id
|
return me.DevId
|
||||||
}
|
}
|
||||||
func (me *DeviceModel) IsSame(other umi.IDeviceModel) bool {
|
func (me *DeviceModel) Type() umi.DeviceType {
|
||||||
return me.Id == other.GetId()
|
return me.DevType
|
||||||
}
|
|
||||||
func (me *DeviceModel) GetType() umi.DeviceType {
|
|
||||||
return me.Type
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,12 @@
|
|||||||
package tmodel
|
package tmodel
|
||||||
|
|
||||||
import "joylink.club/rtsssimulation/umi"
|
import "joylink.club/rtsssimulation/repository/model/proto"
|
||||||
|
|
||||||
// 继电器模型
|
// 继电器模型
|
||||||
type RelayModel struct {
|
type RelayModel struct {
|
||||||
DeviceModel
|
DeviceModel
|
||||||
RelayType umi.RelayType
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRelayModel(id string, relayType umi.RelayType) *RelayModel {
|
func NewRelayModel(id string) *RelayModel {
|
||||||
return &RelayModel{DeviceModel: DeviceModel{Id: id, Type: umi.Relay}, RelayType: relayType}
|
return &RelayModel{DeviceModel: DeviceModel{DevId: id, DevType: proto.DeviceType_DeviceType_Relay}}
|
||||||
}
|
|
||||||
|
|
||||||
//该继电器类型
|
|
||||||
func (me *RelayModel) JType() umi.RelayType {
|
|
||||||
return me.RelayType
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package tmodel
|
package tmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
"joylink.club/rtsssimulation/umi"
|
"joylink.club/rtsssimulation/umi"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ type SwitchModel struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewSwitchModel(id string) *SwitchModel {
|
func NewSwitchModel(id string) *SwitchModel {
|
||||||
return &SwitchModel{DeviceModel: DeviceModel{Id: id, Type: umi.Switch}}
|
return &SwitchModel{DeviceModel: DeviceModel{DevId: id, DevType: proto.DeviceType_DeviceType_Turnout}}
|
||||||
}
|
}
|
||||||
func (me *SwitchModel) AddRelay(relay *SwitchRelay) {
|
func (me *SwitchModel) AddRelay(relay *SwitchRelay) {
|
||||||
me.Relays = append(me.Relays, *relay)
|
me.Relays = append(me.Relays, *relay)
|
||||||
@ -35,7 +36,7 @@ func (me *SwitchModel) AddRelay(relay *SwitchRelay) {
|
|||||||
// find-true找到,false未找到
|
// find-true找到,false未找到
|
||||||
func (me *SwitchModel) FindCircuitRoleById(relayId string) (relayGroup string, relayName string, find bool) {
|
func (me *SwitchModel) FindCircuitRoleById(relayId string) (relayGroup string, relayName string, find bool) {
|
||||||
for _, sr := range me.Relays {
|
for _, sr := range me.Relays {
|
||||||
id := sr.Relay.GetId()
|
id := sr.Relay.Id()
|
||||||
if id == relayId {
|
if id == relayId {
|
||||||
return sr.RelayGroup, sr.RelayName, true
|
return sr.RelayGroup, sr.RelayName, true
|
||||||
}
|
}
|
||||||
|
@ -24,17 +24,17 @@ func NewModelStorage() *ModelStorage {
|
|||||||
// 添加模型数据
|
// 添加模型数据
|
||||||
// m 为具体模型数据的指针
|
// m 为具体模型数据的指针
|
||||||
func (me *ModelStorage) AddModel(m ModelData) error {
|
func (me *ModelStorage) AddModel(m ModelData) error {
|
||||||
_, ok := me.idModelMap[m.GetId()]
|
_, ok := me.idModelMap[m.Id()]
|
||||||
if ok {
|
if ok {
|
||||||
return fmt.Errorf("模型[%s]已经存在", m.GetId())
|
return fmt.Errorf("模型[%s]已经存在", m.Id())
|
||||||
} else {
|
} else {
|
||||||
me.idModelMap[m.GetId()] = m
|
me.idModelMap[m.Id()] = m
|
||||||
//
|
//
|
||||||
_, mdOk := me.typeModelMap[m.GetType()]
|
_, mdOk := me.typeModelMap[m.Type()]
|
||||||
if !mdOk {
|
if !mdOk {
|
||||||
me.typeModelMap[m.GetType()] = make([]ModelData, 0, 512)
|
me.typeModelMap[m.Type()] = make([]ModelData, 0, 512)
|
||||||
}
|
}
|
||||||
me.typeModelMap[m.GetType()] = append(me.typeModelMap[m.GetType()], m)
|
me.typeModelMap[m.Type()] = append(me.typeModelMap[m.Type()], m)
|
||||||
//
|
//
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package tstorages
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
|
|
||||||
"joylink.club/rtsssimulation/umi"
|
"joylink.club/rtsssimulation/umi"
|
||||||
)
|
)
|
||||||
@ -65,7 +66,7 @@ func (me *WorldModelStorage) FindById(id string) umi.IDeviceModel {
|
|||||||
|
|
||||||
// 获取某类型设备的所有模型数据
|
// 获取某类型设备的所有模型数据
|
||||||
func (me *WorldModelStorage) FindByType(deviceType umi.DeviceType) []umi.IDeviceModel {
|
func (me *WorldModelStorage) FindByType(deviceType umi.DeviceType) []umi.IDeviceModel {
|
||||||
if umi.Link == deviceType {
|
if proto.DeviceType_DeviceType_Link == deviceType {
|
||||||
return me.Links.FindModelsByType(deviceType)
|
return me.Links.FindModelsByType(deviceType)
|
||||||
} else {
|
} else {
|
||||||
return me.Share.FindModelsByType(deviceType)
|
return me.Share.FindModelsByType(deviceType)
|
||||||
|
@ -97,6 +97,7 @@ enum DeviceType {
|
|||||||
DeviceType_SectionalCurvature = 7;
|
DeviceType_SectionalCurvature = 7;
|
||||||
DeviceType_Link = 8;
|
DeviceType_Link = 8;
|
||||||
DeviceType_LinkNode = 9;
|
DeviceType_LinkNode = 9;
|
||||||
|
DeviceType_Relay = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Port {
|
enum Port {
|
||||||
|
@ -33,6 +33,7 @@ const (
|
|||||||
DeviceType_DeviceType_SectionalCurvature DeviceType = 7
|
DeviceType_DeviceType_SectionalCurvature DeviceType = 7
|
||||||
DeviceType_DeviceType_Link DeviceType = 8
|
DeviceType_DeviceType_Link DeviceType = 8
|
||||||
DeviceType_DeviceType_LinkNode DeviceType = 9
|
DeviceType_DeviceType_LinkNode DeviceType = 9
|
||||||
|
DeviceType_DeviceType_Relay DeviceType = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for DeviceType.
|
// Enum value maps for DeviceType.
|
||||||
@ -48,6 +49,7 @@ var (
|
|||||||
7: "DeviceType_SectionalCurvature",
|
7: "DeviceType_SectionalCurvature",
|
||||||
8: "DeviceType_Link",
|
8: "DeviceType_Link",
|
||||||
9: "DeviceType_LinkNode",
|
9: "DeviceType_LinkNode",
|
||||||
|
10: "DeviceType_Relay",
|
||||||
}
|
}
|
||||||
DeviceType_value = map[string]int32{
|
DeviceType_value = map[string]int32{
|
||||||
"DeviceType_Unknown": 0,
|
"DeviceType_Unknown": 0,
|
||||||
@ -60,6 +62,7 @@ var (
|
|||||||
"DeviceType_SectionalCurvature": 7,
|
"DeviceType_SectionalCurvature": 7,
|
||||||
"DeviceType_Link": 8,
|
"DeviceType_Link": 8,
|
||||||
"DeviceType_LinkNode": 9,
|
"DeviceType_LinkNode": 9,
|
||||||
|
"DeviceType_Relay": 10,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1358,7 +1361,7 @@ var file_model_proto_rawDesc = []byte{
|
|||||||
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e,
|
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e,
|
||||||
0x52, 0x65, 0x6c, 0x61, 0x79, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
|
0x52, 0x65, 0x6c, 0x61, 0x79, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
|
||||||
0x22, 0x13, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x6e, 0x6b, 0x6e,
|
0x22, 0x13, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x6e, 0x6b, 0x6e,
|
||||||
0x6f, 0x77, 0x6e, 0x10, 0x00, 0x2a, 0x91, 0x02, 0x0a, 0x0a, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65,
|
0x6f, 0x77, 0x6e, 0x10, 0x00, 0x2a, 0xa7, 0x02, 0x0a, 0x0a, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65,
|
||||||
0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79,
|
0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79,
|
||||||
0x70, 0x65, 0x5f, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x1a,
|
0x70, 0x65, 0x5f, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x1a,
|
||||||
0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x50, 0x68, 0x79, 0x73, 0x69,
|
0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x50, 0x68, 0x79, 0x73, 0x69,
|
||||||
@ -1375,18 +1378,20 @@ var file_model_proto_rawDesc = []byte{
|
|||||||
0x43, 0x75, 0x72, 0x76, 0x61, 0x74, 0x75, 0x72, 0x65, 0x10, 0x07, 0x12, 0x13, 0x0a, 0x0f, 0x44,
|
0x43, 0x75, 0x72, 0x76, 0x61, 0x74, 0x75, 0x72, 0x65, 0x10, 0x07, 0x12, 0x13, 0x0a, 0x0f, 0x44,
|
||||||
0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4c, 0x69, 0x6e, 0x6b, 0x10, 0x08,
|
0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4c, 0x69, 0x6e, 0x6b, 0x10, 0x08,
|
||||||
0x12, 0x17, 0x0a, 0x13, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4c,
|
0x12, 0x17, 0x0a, 0x13, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4c,
|
||||||
0x69, 0x6e, 0x6b, 0x4e, 0x6f, 0x64, 0x65, 0x10, 0x09, 0x2a, 0x25, 0x0a, 0x04, 0x50, 0x6f, 0x72,
|
0x69, 0x6e, 0x6b, 0x4e, 0x6f, 0x64, 0x65, 0x10, 0x09, 0x12, 0x14, 0x0a, 0x10, 0x44, 0x65, 0x76,
|
||||||
0x74, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x05, 0x0a, 0x01, 0x41,
|
0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x10, 0x0a, 0x2a,
|
||||||
0x10, 0x01, 0x12, 0x05, 0x0a, 0x01, 0x42, 0x10, 0x02, 0x12, 0x05, 0x0a, 0x01, 0x43, 0x10, 0x03,
|
0x25, 0x0a, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10,
|
||||||
0x2a, 0x20, 0x0a, 0x09, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x08, 0x0a,
|
0x00, 0x12, 0x05, 0x0a, 0x01, 0x41, 0x10, 0x01, 0x12, 0x05, 0x0a, 0x01, 0x42, 0x10, 0x02, 0x12,
|
||||||
0x04, 0x4c, 0x45, 0x46, 0x54, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x52, 0x49, 0x47, 0x48, 0x54,
|
0x05, 0x0a, 0x01, 0x43, 0x10, 0x03, 0x2a, 0x20, 0x0a, 0x09, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74,
|
||||||
0x10, 0x01, 0x2a, 0x43, 0x0a, 0x0e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x6f, 0x69, 0x6e, 0x74,
|
0x69, 0x6f, 0x6e, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x45, 0x46, 0x54, 0x10, 0x00, 0x12, 0x09, 0x0a,
|
||||||
0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x42, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79,
|
0x05, 0x52, 0x49, 0x47, 0x48, 0x54, 0x10, 0x01, 0x2a, 0x43, 0x0a, 0x0e, 0x43, 0x68, 0x65, 0x63,
|
||||||
0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x41, 0x78, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65,
|
0x6b, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x42, 0x6f,
|
||||||
0x72, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x64,
|
0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x41, 0x78, 0x6c, 0x65,
|
||||||
0x4a, 0x6f, 0x69, 0x6e, 0x74, 0x10, 0x02, 0x42, 0x1a, 0x5a, 0x18, 0x2e, 0x2f, 0x72, 0x65, 0x70,
|
0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x6e, 0x73,
|
||||||
0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x70, 0x72,
|
0x75, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x69, 0x6e, 0x74, 0x10, 0x02, 0x42, 0x1a, 0x5a,
|
||||||
0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x18, 0x2e, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x6d, 0x6f,
|
||||||
|
0x64, 0x65, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
|
0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -85,10 +85,10 @@ var Signal2XH1RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
case SIGNAL_LXJ:
|
case SIGNAL_LXJ:
|
||||||
state.LXJ = event.Xh
|
state.LXJ = event.Xh
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("Signal2XH1的模型[%s]中继电器功能名称[%s]无法识别", signalModel.GetId(), relayName))
|
panic(fmt.Sprintf("Signal2XH1的模型[%s]中继电器功能名称[%s]无法识别", signalModel.Id(), relayName))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic(fmt.Sprintf("Signal2XH1的模型[%s]中继电器组合类型[%s]无法识别", signalModel.GetId(), relayGroup))
|
panic(fmt.Sprintf("Signal2XH1的模型[%s]中继电器组合类型[%s]无法识别", signalModel.Id(), relayGroup))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -117,10 +117,10 @@ var Signal3XH1RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
case SIGNAL_ZXJ:
|
case SIGNAL_ZXJ:
|
||||||
state.ZXJ = event.Xh
|
state.ZXJ = event.Xh
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("Signal3XH1的模型[%s]中继电器功能名称[%s]无法识别", signalModel.GetId(), relayName))
|
panic(fmt.Sprintf("Signal3XH1的模型[%s]中继电器功能名称[%s]无法识别", signalModel.Id(), relayName))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic(fmt.Sprintf("Signal3XH1的模型[%s]中继电器组合类型[%s]无法识别", signalModel.GetId(), relayGroup))
|
panic(fmt.Sprintf("Signal3XH1的模型[%s]中继电器组合类型[%s]无法识别", signalModel.Id(), relayGroup))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -93,10 +93,10 @@ var Signal3XH2RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
case SIGNAL_YXJ:
|
case SIGNAL_YXJ:
|
||||||
state.YXJ = event.Xh
|
state.YXJ = event.Xh
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("Signal3XH2的模型[%s]中继电器功能名称[%s]无法识别", signalModel.GetId(), relayName))
|
panic(fmt.Sprintf("Signal3XH2的模型[%s]中继电器功能名称[%s]无法识别", signalModel.Id(), relayName))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic(fmt.Sprintf("Signal3XH2的模型[%s]中继电器组合类型[%s]无法识别", signalModel.GetId(), relayGroup))
|
panic(fmt.Sprintf("Signal3XH2的模型[%s]中继电器组合类型[%s]无法识别", signalModel.Id(), relayGroup))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -89,10 +89,10 @@ var Signal3XH3RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
case SIGNAL_YXJ:
|
case SIGNAL_YXJ:
|
||||||
state.YXJ = event.Xh
|
state.YXJ = event.Xh
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("Signal3XH3的模型[%s]中继电器功能名称[%s]无法识别", signalModel.GetId(), relayName))
|
panic(fmt.Sprintf("Signal3XH3的模型[%s]中继电器功能名称[%s]无法识别", signalModel.Id(), relayName))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic(fmt.Sprintf("Signal3XH3的模型[%s]中继电器组合类型[%s]无法识别", signalModel.GetId(), relayGroup))
|
panic(fmt.Sprintf("Signal3XH3的模型[%s]中继电器组合类型[%s]无法识别", signalModel.Id(), relayGroup))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,10 +87,10 @@ var Signal3XH4RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
case SIGNAL_ZXJ:
|
case SIGNAL_ZXJ:
|
||||||
state.ZXJ = event.Xh
|
state.ZXJ = event.Xh
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("Signal3XH4的模型[%s]中继电器功能名称[%s]无法识别", signalModel.GetId(), relayName))
|
panic(fmt.Sprintf("Signal3XH4的模型[%s]中继电器功能名称[%s]无法识别", signalModel.Id(), relayName))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic(fmt.Sprintf("Signal3XH4的模型[%s]中继电器组合类型[%s]无法识别", signalModel.GetId(), relayGroup))
|
panic(fmt.Sprintf("Signal3XH4的模型[%s]中继电器组合类型[%s]无法识别", signalModel.Id(), relayGroup))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -73,10 +73,10 @@ var SignalDCXHRelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
case SIGNAL_DXJ:
|
case SIGNAL_DXJ:
|
||||||
state.DXJ = event.Xh
|
state.DXJ = event.Xh
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("SignalDCXH的模型[%s]中继电器功能名称[%s]无法识别", signalModel.GetId(), relayName))
|
panic(fmt.Sprintf("SignalDCXH的模型[%s]中继电器功能名称[%s]无法识别", signalModel.Id(), relayName))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic(fmt.Sprintf("SignalDCXH的模型[%s]中继电器组合类型[%s]无法识别", signalModel.GetId(), relayGroup))
|
panic(fmt.Sprintf("SignalDCXH的模型[%s]中继电器组合类型[%s]无法识别", signalModel.Id(), relayGroup))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,10 +82,10 @@ var SignalJCKXHRelayActionEventProcessor = func(w ecs.World, event sysEvent.Rela
|
|||||||
case SIGNAL_LXJ:
|
case SIGNAL_LXJ:
|
||||||
state.LXJ = event.Xh
|
state.LXJ = event.Xh
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("SignalJCKXH的模型[%s]中继电器功能名称[%s]无法识别", signalModel.GetId(), relayName))
|
panic(fmt.Sprintf("SignalJCKXH的模型[%s]中继电器功能名称[%s]无法识别", signalModel.Id(), relayName))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic(fmt.Sprintf("SignalJCKXH的模型[%s]中继电器组合类型[%s]无法识别", signalModel.GetId(), relayGroup))
|
panic(fmt.Sprintf("SignalJCKXH的模型[%s]中继电器组合类型[%s]无法识别", signalModel.Id(), relayGroup))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -86,10 +86,10 @@ var SignalJDXHRelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
|||||||
case SIGNAL_YXJ:
|
case SIGNAL_YXJ:
|
||||||
state.YXJ = event.Xh
|
state.YXJ = event.Xh
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("SignalJDXH的模型[%s]中继电器功能名称[%s]无法识别", signalModel.GetId(), relayName))
|
panic(fmt.Sprintf("SignalJDXH的模型[%s]中继电器功能名称[%s]无法识别", signalModel.Id(), relayName))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic(fmt.Sprintf("SignalJDXH的模型[%s]中继电器组合类型[%s]无法识别", signalModel.GetId(), relayGroup))
|
panic(fmt.Sprintf("SignalJDXH的模型[%s]中继电器组合类型[%s]无法识别", signalModel.Id(), relayGroup))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -317,7 +317,7 @@ var Switch2jzdj9RelayActionEventProcessor = func(w ecs.World, event sysEvent.Rel
|
|||||||
case SJZDJ9_ZFBJ:
|
case SJZDJ9_ZFBJ:
|
||||||
state.ZFBJ = event.Xh
|
state.ZFBJ = event.Xh
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器功能名称[%s]无法识别", switchModel.GetId(), relayName))
|
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器功能名称[%s]无法识别", switchModel.Id(), relayName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case SJZDJ9_TDFJ1:
|
case SJZDJ9_TDFJ1:
|
||||||
@ -344,7 +344,7 @@ var Switch2jzdj9RelayActionEventProcessor = func(w ecs.World, event sysEvent.Rel
|
|||||||
case SJZDJ9_ZBHJ:
|
case SJZDJ9_ZBHJ:
|
||||||
state.J1_ZBHJ = event.Xh
|
state.J1_ZBHJ = event.Xh
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器功能名称[%s]无法识别", switchModel.GetId(), relayName))
|
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器功能名称[%s]无法识别", switchModel.Id(), relayName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case SJZDJ9_TDFJ2:
|
case SJZDJ9_TDFJ2:
|
||||||
@ -367,11 +367,11 @@ var Switch2jzdj9RelayActionEventProcessor = func(w ecs.World, event sysEvent.Rel
|
|||||||
case SJZDJ9_FBJ:
|
case SJZDJ9_FBJ:
|
||||||
state.J2_FBJ = event.Xh
|
state.J2_FBJ = event.Xh
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器功能名称[%s]无法识别", switchModel.GetId(), relayName))
|
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器功能名称[%s]无法识别", switchModel.Id(), relayName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器组合类型[%s]无法识别", switchModel.GetId(), relayGroup))
|
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器组合类型[%s]无法识别", switchModel.Id(), relayGroup))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -386,7 +386,7 @@ func (me *Switch2jZdj9System) publishRelayNeedChangeEvent(w ecs.World, switchEnt
|
|||||||
switchModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(switchEntry).Id)
|
switchModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(switchEntry).Id)
|
||||||
relayRole, _ := switchModel.(umi.IRelayCRole)
|
relayRole, _ := switchModel.(umi.IRelayCRole)
|
||||||
relayModel := relayRole.FindRelayModelByCRole(relayGroup, relayName)
|
relayModel := relayRole.FindRelayModelByCRole(relayGroup, relayName)
|
||||||
sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayModel.(umi.IDeviceModel).GetId(), Xh: needXh})
|
sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayModel.(umi.IDeviceModel).Id(), Xh: needXh})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 断相保护电路运算
|
// 断相保护电路运算
|
||||||
|
@ -92,7 +92,7 @@ func DriveRelay(w ecs.World, circuitModelId string, relayGroup string, relayName
|
|||||||
if roler, isCr := swModel.(umi.IRelayCRole); isCr {
|
if roler, isCr := swModel.(umi.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.(umi.IDeviceModel); isDm {
|
||||||
relayId := deviceModel.GetId()
|
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
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ func createRelayNeedChangeEvent(w ecs.World, circuitModelId string, relayGroup s
|
|||||||
if roler, isCr := swModel.(umi.IRelayCRole); isCr {
|
if roler, isCr := swModel.(umi.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.(umi.IDeviceModel); isDm {
|
||||||
relayId := deviceModel.GetId()
|
relayId := deviceModel.Id()
|
||||||
return &sysEvent.RelayNeedChangeEvent{Id: relayId, Xh: xh}, true
|
return &sysEvent.RelayNeedChangeEvent{Id: relayId, Xh: xh}, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
package umi
|
package umi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"joylink.club/rtsssimulation/repository"
|
||||||
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
|
)
|
||||||
|
|
||||||
// 用户设备模型与仿真底层设备交互定义
|
// 用户设备模型与仿真底层设备交互定义
|
||||||
|
|
||||||
|
type DeviceType = proto.DeviceType
|
||||||
|
|
||||||
// IModelManager 模型管理接口
|
// IModelManager 模型管理接口
|
||||||
type IModelManager interface {
|
type IModelManager interface {
|
||||||
//FindById 根据模型的复合id获取模型数据
|
//FindById 根据模型的复合id获取模型数据
|
||||||
@ -12,37 +19,11 @@ type IModelManager interface {
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// PortEnum 端口定义,如轨道、区段、道岔的端口
|
|
||||||
type PortEnum = int8
|
|
||||||
|
|
||||||
// 具体端口枚举
|
|
||||||
const (
|
|
||||||
A PortEnum = iota
|
|
||||||
B
|
|
||||||
C
|
|
||||||
)
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// DeviceType 设备类型枚举
|
|
||||||
type DeviceType = int16
|
|
||||||
|
|
||||||
const (
|
|
||||||
Any DeviceType = iota
|
|
||||||
Link
|
|
||||||
Switch
|
|
||||||
Signal
|
|
||||||
Relay //继电器设备
|
|
||||||
)
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// IDeviceModel 仿真底层设备模型定义
|
// IDeviceModel 仿真底层设备模型定义
|
||||||
// 用户所有设备模型定义须实现该接口
|
// 用户所有设备模型定义须实现该接口
|
||||||
type IDeviceModel interface {
|
type IDeviceModel = repository.Identity
|
||||||
GetId() string
|
|
||||||
GetType() DeviceType
|
|
||||||
}
|
|
||||||
|
|
||||||
// IPsdModel 仿真底层屏蔽门模型
|
// IPsdModel 仿真底层屏蔽门模型
|
||||||
// 用户所有屏蔽门模型定义须实现该接口
|
// 用户所有屏蔽门模型定义须实现该接口
|
||||||
@ -63,33 +44,6 @@ type IPsdModel interface {
|
|||||||
|
|
||||||
// //////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// RelayType 继电器类型定义
|
|
||||||
type RelayType = int8
|
|
||||||
|
|
||||||
// 继电器型号枚举
|
|
||||||
const (
|
|
||||||
//无极缓放继电器
|
|
||||||
JWXC_1700 RelayType = iota + 1
|
|
||||||
//
|
|
||||||
JWXC_H340
|
|
||||||
//偏极继电器是为了鉴别信号电路中的电流极性而设计
|
|
||||||
//继电器在磁路中增加一个偏极磁钢,使衔铁受永磁力的作用而偏于落下位置。衔铁的吸起与线圈中的电流的极性有关,
|
|
||||||
//通过线圈的电流为规定的方向时,衔铁才吸起,而电流的方向相反时,衔铁保持不动。
|
|
||||||
//它只具有一种稳定状态,即衔铁靠电磁力吸起后,断电即落下,始终偏向落下的定位状态
|
|
||||||
JPXC_1000
|
|
||||||
//无极加强缓放继电器
|
|
||||||
JWJXC_H125_80
|
|
||||||
//有极加强继电器
|
|
||||||
//根据线圈中电流极性不同具有 定位和反位 两种稳定状态,这两种稳定状态当线圈中电流消失时仍能继续保持;
|
|
||||||
//在线圈中通以规定极性的电流时,继电器吸起,断电后仍保持在吸起位置;通以反方向电流时,继电器打落,断电后保持在打落位置;
|
|
||||||
//断电保持由磁路系统中的一块长条形永久磁铁取代了大部分轭铁来实现即断电保持当前状态
|
|
||||||
JYJXC_160_260
|
|
||||||
//无极继电器
|
|
||||||
JWJXC_480
|
|
||||||
//整流式缓放继电器
|
|
||||||
JZXC_H18
|
|
||||||
)
|
|
||||||
|
|
||||||
// IRelayCRole 获取继电器在具体电路中的角色(组合类型、功能名称)
|
// IRelayCRole 获取继电器在具体电路中的角色(组合类型、功能名称)
|
||||||
// 如信号机3XH-1电路中点灯继电器:组合类型-"3XH-1" 功能名称-"DDJ"
|
// 如信号机3XH-1电路中点灯继电器:组合类型-"3XH-1" 功能名称-"DDJ"
|
||||||
// 对应设备电路中有继电器的设备模型须实现该接口
|
// 对应设备电路中有继电器的设备模型须实现该接口
|
||||||
|
Loading…
Reference in New Issue
Block a user