Compare commits
2 Commits
f0a6c534ec
...
01b0655eb5
Author | SHA1 | Date | |
---|---|---|---|
01b0655eb5 | |||
d63be32ad5 |
@ -2,14 +2,13 @@ package component
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component/component_data"
|
||||
)
|
||||
|
||||
var (
|
||||
CkmTag = ecs.NewTag()
|
||||
CkmMgzTag = ecs.NewTag() //门故障tag
|
||||
CkmCircuitType = ecs.NewComponentType[CkmCircuit]()
|
||||
CkmStateType = ecs.NewComponentType[component_data.CkmState]()
|
||||
CkmTag = ecs.NewTag()
|
||||
CkmStateLossTag = ecs.NewTag() //状态丢失故障tag
|
||||
CkmCircuitType = ecs.NewComponentType[CkmCircuit]()
|
||||
CkmPslType = ecs.NewComponentType[CkmPsl]()
|
||||
)
|
||||
|
||||
type CkmCircuit struct {
|
||||
@ -23,3 +22,10 @@ type CkmCircuit struct {
|
||||
KMJ *ecs.Entry //开门继电器
|
||||
GMJ *ecs.Entry //关门继电器
|
||||
}
|
||||
|
||||
type CkmPsl struct {
|
||||
KMA *ecs.Entry //开门按钮
|
||||
GMA *ecs.Entry //关门按钮
|
||||
MPLA *ecs.Entry //门旁路按钮
|
||||
MMSA *ecs.Entry //门模式按钮
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: component/ci.proto
|
||||
|
||||
|
@ -1,180 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc v4.23.1
|
||||
// source: component/ckm.proto
|
||||
|
||||
package component_data
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type CkmState struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Close bool `protobuf:"varint,1,opt,name=close,proto3" json:"close,omitempty"`
|
||||
Mms bool `protobuf:"varint,2,opt,name=mms,proto3" json:"mms,omitempty"` //门模式(true远程,false本地)
|
||||
Mgz bool `protobuf:"varint,3,opt,name=mgz,proto3" json:"mgz,omitempty"` //门故障
|
||||
// 驱动状态(没有继电器时直接操作以下状态)
|
||||
Km bool `protobuf:"varint,4,opt,name=km,proto3" json:"km,omitempty"` //开门
|
||||
Gm bool `protobuf:"varint,5,opt,name=gm,proto3" json:"gm,omitempty"` //关门
|
||||
}
|
||||
|
||||
func (x *CkmState) Reset() {
|
||||
*x = CkmState{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_ckm_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CkmState) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CkmState) ProtoMessage() {}
|
||||
|
||||
func (x *CkmState) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_component_ckm_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CkmState.ProtoReflect.Descriptor instead.
|
||||
func (*CkmState) Descriptor() ([]byte, []int) {
|
||||
return file_component_ckm_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *CkmState) GetClose() bool {
|
||||
if x != nil {
|
||||
return x.Close
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *CkmState) GetMms() bool {
|
||||
if x != nil {
|
||||
return x.Mms
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *CkmState) GetMgz() bool {
|
||||
if x != nil {
|
||||
return x.Mgz
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *CkmState) GetKm() bool {
|
||||
if x != nil {
|
||||
return x.Km
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *CkmState) GetGm() bool {
|
||||
if x != nil {
|
||||
return x.Gm
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var File_component_ckm_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_component_ckm_proto_rawDesc = []byte{
|
||||
0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6b, 0x6d, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74,
|
||||
0x22, 0x64, 0x0a, 0x08, 0x43, 0x6b, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05,
|
||||
0x63, 0x6c, 0x6f, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x6f,
|
||||
0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52,
|
||||
0x03, 0x6d, 0x6d, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x67, 0x7a, 0x18, 0x03, 0x20, 0x01, 0x28,
|
||||
0x08, 0x52, 0x03, 0x6d, 0x67, 0x7a, 0x12, 0x0e, 0x0a, 0x02, 0x6b, 0x6d, 0x18, 0x04, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x02, 0x6b, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x67, 0x6d, 0x18, 0x05, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x02, 0x67, 0x6d, 0x42, 0x1c, 0x5a, 0x1a, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70,
|
||||
0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f,
|
||||
0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_component_ckm_proto_rawDescOnce sync.Once
|
||||
file_component_ckm_proto_rawDescData = file_component_ckm_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_component_ckm_proto_rawDescGZIP() []byte {
|
||||
file_component_ckm_proto_rawDescOnce.Do(func() {
|
||||
file_component_ckm_proto_rawDescData = protoimpl.X.CompressGZIP(file_component_ckm_proto_rawDescData)
|
||||
})
|
||||
return file_component_ckm_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_component_ckm_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_component_ckm_proto_goTypes = []interface{}{
|
||||
(*CkmState)(nil), // 0: component.CkmState
|
||||
}
|
||||
var file_component_ckm_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_component_ckm_proto_init() }
|
||||
func file_component_ckm_proto_init() {
|
||||
if File_component_ckm_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_component_ckm_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CkmState); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_component_ckm_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_component_ckm_proto_goTypes,
|
||||
DependencyIndexes: file_component_ckm_proto_depIdxs,
|
||||
MessageInfos: file_component_ckm_proto_msgTypes,
|
||||
}.Build()
|
||||
File_component_ckm_proto = out.File
|
||||
file_component_ckm_proto_rawDesc = nil
|
||||
file_component_ckm_proto_goTypes = nil
|
||||
file_component_ckm_proto_depIdxs = nil
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: component/common.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: component/equipment.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: component/points.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: component/psd.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: component/signal.proto
|
||||
|
||||
|
@ -1,47 +1,74 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/yohamta/donburi"
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var CkmBaseComponentTypes = []ecs.IComponentType{component.UidType, component.CkmTag, component.CkmStateType, component.FixedPositionTransformType}
|
||||
var CkmBaseComponentTypes = []ecs.IComponentType{component.UidType, component.CkmTag, component.FixedPositionTransformType}
|
||||
|
||||
func LoadCkm(w ecs.World) error {
|
||||
data := GetWorldData(w)
|
||||
for _, ckm := range data.Repo.CkmList() {
|
||||
//创建基础entry
|
||||
entry := w.Entry(w.Create(CkmBaseComponentTypes...))
|
||||
component.UidType.SetValue(entry, component.Uid{Id: ckm.Id()})
|
||||
data.EntityMap[ckm.Id()] = entry
|
||||
//加载电路
|
||||
if len(ckm.ComponentGroups()) != 0 {
|
||||
circuit := &component.CkmCircuit{}
|
||||
entry.AddComponent(component.CkmCircuitType, unsafe.Pointer(circuit))
|
||||
for _, group := range ckm.ComponentGroups() {
|
||||
for _, ec := range group.Components() {
|
||||
relay := ec.(*repository.Relay)
|
||||
switch ec.Code() {
|
||||
case "MKJ":
|
||||
circuit.MKJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "MGJ":
|
||||
circuit.MGJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "MGZJ":
|
||||
circuit.MGZJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "MPLJ":
|
||||
circuit.MPLJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "MMSJ":
|
||||
circuit.MMSJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "KMJ":
|
||||
circuit.KMJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "GMJ":
|
||||
circuit.GMJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
}
|
||||
ckmEntry := buildBaseEntry(w, ckm, data)
|
||||
addCkmCircuit(w, ckm, ckmEntry, data)
|
||||
}
|
||||
for _, psl := range data.Repo.CkmPslList() {
|
||||
ckmEntry := data.EntityMap[psl.Ckm().Id()]
|
||||
addCkmPsl(w, psl, ckmEntry, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 构建基础镜像
|
||||
func buildBaseEntry(w ecs.World, ckm *repository.Ckm, data *component.WorldData) *donburi.Entry {
|
||||
//创建基础entry
|
||||
entry := w.Entry(w.Create(CkmBaseComponentTypes...))
|
||||
component.UidType.SetValue(entry, component.Uid{Id: ckm.Id()})
|
||||
data.EntityMap[ckm.Id()] = entry
|
||||
return entry
|
||||
}
|
||||
|
||||
// 添加车库门电路
|
||||
func addCkmCircuit(w ecs.World, ckm *repository.Ckm, ckmEntry *donburi.Entry, data *component.WorldData) {
|
||||
//加载电路
|
||||
if len(ckm.ComponentGroups()) != 0 {
|
||||
circuit := &component.CkmCircuit{}
|
||||
ckmEntry.AddComponent(component.CkmCircuitType, unsafe.Pointer(circuit))
|
||||
for _, group := range ckm.ComponentGroups() {
|
||||
for _, ec := range group.Components() {
|
||||
relay := ec.(*repository.Relay)
|
||||
switch ec.Code() {
|
||||
case "MKJ":
|
||||
circuit.MKJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "MGJ":
|
||||
circuit.MGJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "MGZJ":
|
||||
circuit.MGZJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "MPLJ":
|
||||
circuit.MPLJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "MMSJ":
|
||||
circuit.MMSJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "KMJ":
|
||||
circuit.KMJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
case "GMJ":
|
||||
circuit.GMJ = NewRelayEntity(w, relay, data.EntityMap)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 添加车库门PSL
|
||||
func addCkmPsl(w ecs.World, psl *repository.CkmPsl, ckmEntry *ecs.Entry, data *component.WorldData) {
|
||||
ckmPsl := component.CkmPsl{
|
||||
KMA: NewButtonEntity(w, psl.Kma(), data.EntityMap),
|
||||
GMA: NewButtonEntity(w, psl.Gma(), data.EntityMap),
|
||||
MPLA: NewButtonEntity(w, psl.Mpla(), data.EntityMap),
|
||||
MMSA: NewButtonEntity(w, psl.Mmsa(), data.EntityMap),
|
||||
}
|
||||
ckmEntry.AddComponent(component.CkmPslType, unsafe.Pointer(&ckmPsl))
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ func LoadPsd(w ecs.World) error {
|
||||
}
|
||||
|
||||
func loadPlatformMkxCircuit(world ecs.World, entryMap map[string]*ecs.Entry, pmcMap map[string]*ecs.Entry,
|
||||
mkx *repository.Mkx, mkxEntry *ecs.Entry, psdEntry *ecs.Entry) {
|
||||
mkx *repository.PsdPsl, mkxEntry *ecs.Entry, psdEntry *ecs.Entry) {
|
||||
platformMkx, ok := pmcMap[mkx.Psd().Id()]
|
||||
if !ok {
|
||||
platformMkx = NewPlatformMkxEntry(world, entryMap, mkx)
|
||||
@ -103,7 +103,7 @@ func NewAsdEntry(world ecs.World, worldData *component.WorldData, psdId string,
|
||||
return entry
|
||||
}
|
||||
|
||||
func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repository.Mkx) *ecs.Entry {
|
||||
func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repository.PsdPsl) *ecs.Entry {
|
||||
entry := world.Entry(world.Create(component.UidType, component.MkxType))
|
||||
worldData.EntityMap[mkx.Id()] = entry
|
||||
component.UidType.SetValue(entry, component.Uid{Id: mkx.Id()})
|
||||
@ -149,7 +149,7 @@ func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repositor
|
||||
return entry
|
||||
}
|
||||
|
||||
func NewPlatformMkxEntry(world ecs.World, entryMap map[string]*ecs.Entry, mkx *repository.Mkx) *ecs.Entry {
|
||||
func NewPlatformMkxEntry(world ecs.World, entryMap map[string]*ecs.Entry, mkx *repository.PsdPsl) *ecs.Entry {
|
||||
entry := world.Entry(world.Create(component.PlatformMkxCircuitType))
|
||||
circuit := &component.PlatformMkxCircuit{}
|
||||
if pcbj := mkx.Pcbj(); pcbj != nil {
|
||||
|
@ -1,15 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package component;
|
||||
|
||||
option go_package = "./component/component_data";
|
||||
|
||||
message CkmState {
|
||||
bool close = 1;
|
||||
bool mms = 2; //门模式(true远程,false本地)
|
||||
bool mgz = 3; //门故障
|
||||
|
||||
//驱动状态(没有继电器时直接操作以下状态)
|
||||
bool km = 4; //开门
|
||||
bool gm = 5; //关门
|
||||
}
|
@ -30,6 +30,7 @@ message Repository {
|
||||
repeated Route routes = 23;
|
||||
repeated Ckm ckms = 24;
|
||||
repeated Xcj xcjs = 25;
|
||||
repeated CkmPsl ckmPsls = 26;
|
||||
//ISCS 编号[300,500]
|
||||
//ISCS管线
|
||||
repeated Pipe pipes = 300;
|
||||
@ -221,8 +222,9 @@ enum DeviceType {
|
||||
DeviceType_PowerScreen = 22;
|
||||
// 进路
|
||||
DeviceType_Route = 23;
|
||||
DeviceType_Ckm = 24;
|
||||
DeviceType_Xcj = 25;
|
||||
DeviceType_Ckm = 24; //车库门
|
||||
DeviceType_Xcj = 25; //洗车机
|
||||
DeviceType_CkmPsl = 26; //车库门PSL
|
||||
//--------ISCS 编号[300,500]------
|
||||
|
||||
//ISCS门磁
|
||||
@ -518,6 +520,16 @@ message Mkx {
|
||||
string mplaId = 18; //互锁接触按钮
|
||||
string jxtcplaId = 19; //间隙探测旁路按钮
|
||||
}
|
||||
//车库门PSL
|
||||
message CkmPsl {
|
||||
string id= 1;
|
||||
string ckmId = 2;
|
||||
string gmaId = 3; //关门按钮
|
||||
string kmaId = 4; //开门按钮
|
||||
string mplaId = 5; //门旁路按钮
|
||||
string mmsaId = 6; //门模式按钮
|
||||
}
|
||||
|
||||
//站台
|
||||
message Platform {
|
||||
enum PlatformDirection {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: cg_repo.proto
|
||||
|
||||
|
34
repository/ckm_psl.go
Normal file
34
repository/ckm_psl.go
Normal file
@ -0,0 +1,34 @@
|
||||
package repository
|
||||
|
||||
import "joylink.club/rtsssimulation/repository/model/proto"
|
||||
|
||||
type CkmPsl struct {
|
||||
Identity
|
||||
ckm *Ckm
|
||||
kma *Button
|
||||
gma *Button
|
||||
mpla *Button
|
||||
mmsa *Button
|
||||
}
|
||||
|
||||
func NewCkmPsl(id string) *CkmPsl {
|
||||
return &CkmPsl{
|
||||
Identity: identity{id, proto.DeviceType_DeviceType_CkmPsl},
|
||||
}
|
||||
}
|
||||
|
||||
func (psl *CkmPsl) Ckm() *Ckm {
|
||||
return psl.ckm
|
||||
}
|
||||
func (psl *CkmPsl) Kma() *Button {
|
||||
return psl.kma
|
||||
}
|
||||
func (psl *CkmPsl) Gma() *Button {
|
||||
return psl.gma
|
||||
}
|
||||
func (psl *CkmPsl) Mpla() *Button {
|
||||
return psl.mpla
|
||||
}
|
||||
func (psl *CkmPsl) Mmsa() *Button {
|
||||
return psl.mmsa
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@ package repository
|
||||
|
||||
import "joylink.club/rtsssimulation/repository/model/proto"
|
||||
|
||||
type Mkx struct {
|
||||
type PsdPsl struct {
|
||||
Identity
|
||||
psd *Psd
|
||||
|
||||
@ -25,8 +25,8 @@ type Mkx struct {
|
||||
jxtcpl *Button
|
||||
}
|
||||
|
||||
func NewMkx(id string) *Mkx {
|
||||
return &Mkx{
|
||||
func NewPsdPsl(id string) *PsdPsl {
|
||||
return &PsdPsl{
|
||||
Identity: identity{
|
||||
id: id,
|
||||
deviceType: proto.DeviceType_DeviceType_Mkx,
|
||||
@ -34,74 +34,74 @@ func NewMkx(id string) *Mkx {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Mkx) Psd() *Psd {
|
||||
func (m *PsdPsl) Psd() *Psd {
|
||||
return m.psd
|
||||
}
|
||||
|
||||
func (m *Mkx) Pcb() *Button {
|
||||
func (m *PsdPsl) Pcb() *Button {
|
||||
return m.pcb
|
||||
}
|
||||
|
||||
func (m *Mkx) Pcbpl() *Button {
|
||||
func (m *PsdPsl) Pcbpl() *Button {
|
||||
return m.pcbpl
|
||||
}
|
||||
|
||||
func (m *Mkx) Pcbj() *Relay {
|
||||
func (m *PsdPsl) Pcbj() *Relay {
|
||||
return m.pcbj
|
||||
}
|
||||
|
||||
func (m *Mkx) Pob() *Button {
|
||||
func (m *PsdPsl) Pob() *Button {
|
||||
return m.pob
|
||||
}
|
||||
|
||||
func (m *Mkx) Pobpl() *Button {
|
||||
func (m *PsdPsl) Pobpl() *Button {
|
||||
return m.pobpl
|
||||
}
|
||||
|
||||
func (m *Mkx) Pobj() *Relay {
|
||||
func (m *PsdPsl) Pobj() *Relay {
|
||||
return m.pobj
|
||||
}
|
||||
|
||||
func (m *Mkx) Pab() *Button {
|
||||
func (m *PsdPsl) Pab() *Button {
|
||||
return m.pab
|
||||
}
|
||||
|
||||
func (m *Mkx) Pabpl() *Button {
|
||||
func (m *PsdPsl) Pabpl() *Button {
|
||||
return m.pabpl
|
||||
}
|
||||
|
||||
func (m *Mkx) Pabj() *Relay {
|
||||
func (m *PsdPsl) Pabj() *Relay {
|
||||
return m.pabj
|
||||
}
|
||||
|
||||
func (m *Mkx) Wrzf() *Button {
|
||||
func (m *PsdPsl) Wrzf() *Button {
|
||||
return m.wrzf
|
||||
}
|
||||
|
||||
func (m *Mkx) Wrzfpl() *Button {
|
||||
func (m *PsdPsl) Wrzfpl() *Button {
|
||||
return m.wrzfpl
|
||||
}
|
||||
|
||||
func (m *Mkx) Wrzfj() *Relay {
|
||||
func (m *PsdPsl) Wrzfj() *Relay {
|
||||
return m.wrzfj
|
||||
}
|
||||
|
||||
func (m *Mkx) Qkqr() *Button {
|
||||
func (m *PsdPsl) Qkqr() *Button {
|
||||
return m.qkqr
|
||||
}
|
||||
|
||||
func (m *Mkx) Qkqrpl() *Button {
|
||||
func (m *PsdPsl) Qkqrpl() *Button {
|
||||
return m.qkqrpl
|
||||
}
|
||||
|
||||
func (m *Mkx) Qkqrj() *Relay {
|
||||
func (m *PsdPsl) Qkqrj() *Relay {
|
||||
return m.qkqrj
|
||||
}
|
||||
|
||||
func (m *Mkx) Mpl() *Button {
|
||||
func (m *PsdPsl) Mpl() *Button {
|
||||
return m.mpl
|
||||
}
|
||||
|
||||
func (m *Mkx) Jxtcpl() *Button {
|
||||
func (m *PsdPsl) Jxtcpl() *Button {
|
||||
return m.jxtcpl
|
||||
}
|
@ -8,31 +8,33 @@ import (
|
||||
)
|
||||
|
||||
type Repository struct {
|
||||
id string
|
||||
version string
|
||||
coordinate *MapCoordinate // 基准坐标系类型,在列车画图时统一坐标系
|
||||
physicalSectionMap map[string]*PhysicalSection
|
||||
checkPointMap map[string]*CheckPoint
|
||||
turnoutMap map[string]*Turnout
|
||||
signalMap map[string]*Signal
|
||||
responderMap map[string]*Transponder
|
||||
slopeMap map[string]*Slope
|
||||
sectionalCurvatureMap map[string]*SectionalCurvature
|
||||
kilometerConvertMap map[string]*proto.KilometerConvert
|
||||
relayMap map[string]*Relay
|
||||
phaseFailureProtectorMap map[string]*PhaseFailureProtector
|
||||
buttonMap map[string]*Button
|
||||
psdMap map[string]*Psd
|
||||
lightMap map[string]*Light
|
||||
alarmMap map[string]*Alarm
|
||||
stationMap map[string]*Station
|
||||
mkxMap map[string]*Mkx
|
||||
keyMap map[string]*Key
|
||||
linkMap map[string]*Link
|
||||
platformMap map[string]*Platform
|
||||
centralizedMap map[string]*proto.CentralizedStationRef
|
||||
ckmMap map[string]*Ckm
|
||||
xcjMap map[string]*Xcj
|
||||
id string
|
||||
version string
|
||||
coordinate *MapCoordinate // 基准坐标系类型,在列车画图时统一坐标系
|
||||
physicalSectionMap map[string]*PhysicalSection
|
||||
checkPointMap map[string]*CheckPoint
|
||||
turnoutMap map[string]*Turnout
|
||||
signalMap map[string]*Signal
|
||||
responderMap map[string]*Transponder
|
||||
slopeMap map[string]*Slope
|
||||
sectionalCurvatureMap map[string]*SectionalCurvature
|
||||
kilometerConvertMap map[string]*proto.KilometerConvert
|
||||
relayMap map[string]*Relay
|
||||
phaseFailureProtectorMap map[string]*PhaseFailureProtector
|
||||
buttonMap map[string]*Button
|
||||
psdMap map[string]*Psd
|
||||
lightMap map[string]*Light
|
||||
alarmMap map[string]*Alarm
|
||||
stationMap map[string]*Station
|
||||
psdPslMap map[string]*PsdPsl
|
||||
keyMap map[string]*Key
|
||||
linkMap map[string]*Link
|
||||
platformMap map[string]*Platform
|
||||
centralizedMap map[string]*proto.CentralizedStationRef
|
||||
ckmMap map[string]*Ckm
|
||||
ckmPslMap map[string]*CkmPsl
|
||||
xcjMap map[string]*Xcj
|
||||
|
||||
PipeMap map[string]*Pipe //ISCS 管线
|
||||
PipeFittingMap map[string]*PipeFitting //ISCS 管件
|
||||
CircuitBreakerMap map[string]*CircuitBreaker //ISCS 断路器
|
||||
@ -76,7 +78,7 @@ func newRepository(id string, version string) *Repository {
|
||||
lightMap: make(map[string]*Light),
|
||||
alarmMap: make(map[string]*Alarm),
|
||||
stationMap: make(map[string]*Station),
|
||||
mkxMap: make(map[string]*Mkx),
|
||||
psdPslMap: make(map[string]*PsdPsl),
|
||||
keyMap: make(map[string]*Key),
|
||||
platformMap: make(map[string]*Platform),
|
||||
centralizedMap: make(map[string]*proto.CentralizedStationRef),
|
||||
@ -293,9 +295,9 @@ func (repo *Repository) PsdList() []*Psd {
|
||||
}
|
||||
return list
|
||||
}
|
||||
func (repo *Repository) MkxList() []*Mkx {
|
||||
var list []*Mkx
|
||||
for _, model := range repo.mkxMap {
|
||||
func (repo *Repository) MkxList() []*PsdPsl {
|
||||
var list []*PsdPsl
|
||||
for _, model := range repo.psdPslMap {
|
||||
list = append(list, model)
|
||||
}
|
||||
return list
|
||||
@ -340,6 +342,14 @@ func (repo *Repository) XcjList() []*Xcj {
|
||||
return list
|
||||
}
|
||||
|
||||
func (repo *Repository) CkmPslList() []*CkmPsl {
|
||||
var list []*CkmPsl
|
||||
for _, model := range repo.ckmPslMap {
|
||||
list = append(list, model)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
func (repo *Repository) GetCentralizedStationRef(centralizedStationId string) *proto.CentralizedStationRef {
|
||||
return repo.centralizedMap[centralizedStationId]
|
||||
}
|
||||
|
@ -123,8 +123,8 @@ func buildModels(source *proto.Repository, repository *Repository) error {
|
||||
repository.alarmMap[m.Id()] = m
|
||||
}
|
||||
for _, protoData := range source.Mkxs {
|
||||
m := NewMkx(protoData.Id)
|
||||
repository.mkxMap[m.Id()] = m
|
||||
m := NewPsdPsl(protoData.Id)
|
||||
repository.psdPslMap[m.Id()] = m
|
||||
}
|
||||
for _, protoData := range source.Keys {
|
||||
m := NewKey(protoData.Id, protoData.Code, protoData.Gear)
|
||||
@ -142,6 +142,10 @@ func buildModels(source *proto.Repository, repository *Repository) error {
|
||||
m := NewXcj(protoData.Id)
|
||||
repository.xcjMap[m.Id()] = m
|
||||
}
|
||||
for _, protoData := range source.CkmPsls {
|
||||
m := NewCkmPsl(protoData.Id)
|
||||
repository.ckmPslMap[m.Id()] = m
|
||||
}
|
||||
err := repository.generateCoordinateInfo(source.MainCoordinateSystem)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -208,9 +212,22 @@ func buildModelRelationship(source *proto.Repository, repository *Repository) er
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = buildCkmPslRelationShip(source, repository)
|
||||
return err
|
||||
}
|
||||
|
||||
func buildCkmPslRelationShip(source *proto.Repository, repository *Repository) error {
|
||||
for _, protoData := range source.CkmPsls {
|
||||
psl := repository.ckmPslMap[protoData.Id]
|
||||
psl.ckm = repository.ckmMap[protoData.CkmId]
|
||||
psl.gma = repository.buttonMap[protoData.GmaId]
|
||||
psl.kma = repository.buttonMap[protoData.KmaId]
|
||||
psl.mpla = repository.buttonMap[protoData.MplaId]
|
||||
psl.mmsa = repository.buttonMap[protoData.MmsaId]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildXcjRelationShip(source *proto.Repository, repo *Repository) error {
|
||||
for _, protoData := range source.Ckms {
|
||||
ckm := repo.ckmMap[protoData.Id]
|
||||
@ -270,7 +287,7 @@ func buildCentralizedStationRelationShip(source *proto.Repository, repo *Reposit
|
||||
}
|
||||
func buildMkxRelationShip(source *proto.Repository, repo *Repository) error {
|
||||
for _, protoData := range source.Mkxs {
|
||||
mkx := repo.mkxMap[protoData.Id]
|
||||
mkx := repo.psdPslMap[protoData.Id]
|
||||
mkx.psd = repo.psdMap[protoData.PsdId]
|
||||
mkx.pcb = repo.buttonMap[protoData.PcbaId]
|
||||
mkx.pcbpl = repo.buttonMap[protoData.PcbplaId]
|
||||
|
@ -22,24 +22,31 @@ func NewCkmSys() *CkmSys {
|
||||
func (p *CkmSys) Update(world ecs.World) {
|
||||
worldData := entity.GetWorldData(world)
|
||||
p.query.Each(world, func(entry *ecs.Entry) {
|
||||
//车库门故障(状态丢失)
|
||||
if entry.HasComponent(component.CkmStateLossTag) {
|
||||
return
|
||||
}
|
||||
posCom := component.FixedPositionTransformType.Get(entry)
|
||||
state := component.CkmStateType.Get(entry)
|
||||
if entry.HasComponent(component.CkmCircuitType) {
|
||||
circuit := component.CkmCircuitType.Get(entry)
|
||||
//门开/关继电器及状态
|
||||
if posCom.Pos == consts.TwoPosMin {
|
||||
component.RelayDriveType.Get(circuit.MGJ).Td = true
|
||||
component.RelayDriveType.Get(circuit.MKJ).Td = false
|
||||
state.Close = true
|
||||
} else {
|
||||
component.RelayDriveType.Get(circuit.MGJ).Td = false
|
||||
component.RelayDriveType.Get(circuit.MKJ).Td = true
|
||||
state.Close = false
|
||||
}
|
||||
//门故障继电器及状态
|
||||
component.RelayDriveType.Get(circuit.MGZJ).Td = entry.HasComponent(component.CkmMgzTag)
|
||||
state.Mgz = entry.HasComponent(component.CkmMgzTag)
|
||||
//开/关门继电器驱动状态
|
||||
remote := true //是否远程模式
|
||||
circuit := component.CkmCircuitType.Get(entry) //目前不考虑没有车库门电路的情况
|
||||
//车库门PSL
|
||||
if entry.HasComponent(component.CkmPslType) {
|
||||
ckmPsl := component.CkmPslType.Get(entry)
|
||||
component.RelayDriveType.Get(circuit.MPLJ).Td = component.BitStateType.Get(ckmPsl.MPLA).Val
|
||||
remote = component.BitStateType.Get(ckmPsl.MMSA).Val
|
||||
}
|
||||
//门开/关继电器及状态
|
||||
if posCom.Pos == consts.TwoPosMin {
|
||||
component.RelayDriveType.Get(circuit.MGJ).Td = true
|
||||
component.RelayDriveType.Get(circuit.MKJ).Td = false
|
||||
} else {
|
||||
component.RelayDriveType.Get(circuit.MGJ).Td = false
|
||||
component.RelayDriveType.Get(circuit.MKJ).Td = true
|
||||
}
|
||||
//门故障继电器及状态
|
||||
component.RelayDriveType.Get(circuit.MGZJ).Td = entry.HasComponent(component.CkmStateLossTag)
|
||||
//开/关门继电器驱动状态
|
||||
if remote {
|
||||
kmBit, err := worldData.QueryQdBit(component.UidType.Get(circuit.KMJ).Id)
|
||||
if err == nil {
|
||||
component.RelayDriveType.Get(circuit.KMJ).Td = kmBit
|
||||
@ -52,21 +59,15 @@ func (p *CkmSys) Update(world ecs.World) {
|
||||
} else {
|
||||
slog.Error(err.Error())
|
||||
}
|
||||
|
||||
state.Km = component.BitStateType.Get(circuit.KMJ).Val
|
||||
state.Gm = component.BitStateType.Get(circuit.GMJ).Val
|
||||
} else {
|
||||
if posCom.Pos == consts.TwoPosMin {
|
||||
state.Close = true
|
||||
} else {
|
||||
state.Close = false
|
||||
}
|
||||
state.Mgz = entry.HasComponent(component.CkmMgzTag)
|
||||
ckmPsl := component.CkmPslType.Get(entry)
|
||||
component.RelayDriveType.Get(circuit.KMJ).Td = component.BitStateType.Get(ckmPsl.KMA).Val
|
||||
component.RelayDriveType.Get(circuit.GMJ).Td = component.BitStateType.Get(ckmPsl.GMA).Val
|
||||
}
|
||||
//驱动
|
||||
if state.Gm {
|
||||
if component.BitStateType.Get(circuit.GMJ).Val {
|
||||
posCom.Speed = -component.CalculateTwoPositionAvgSpeed(3*1000, world.Tick())
|
||||
} else if state.Km {
|
||||
} else if component.BitStateType.Get(circuit.KMJ).Val {
|
||||
posCom.Speed = component.CalculateTwoPositionAvgSpeed(3*1000, world.Tick())
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user