Compare commits

..

No commits in common. "01b0655eb5d4047f381c1a64727790d415ff1277" and "f0a6c534ec7b4b0bb128a435c17ef2b20e481b94" have entirely different histories.

19 changed files with 1328 additions and 1366 deletions

View File

@ -2,13 +2,14 @@ package component
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component/component_data"
)
var (
CkmTag = ecs.NewTag()
CkmStateLossTag = ecs.NewTag() //状态丢失故障tag
CkmCircuitType = ecs.NewComponentType[CkmCircuit]()
CkmPslType = ecs.NewComponentType[CkmPsl]()
CkmTag = ecs.NewTag()
CkmMgzTag = ecs.NewTag() //门故障tag
CkmCircuitType = ecs.NewComponentType[CkmCircuit]()
CkmStateType = ecs.NewComponentType[component_data.CkmState]()
)
type CkmCircuit struct {
@ -22,10 +23,3 @@ type CkmCircuit struct {
KMJ *ecs.Entry //开门继电器
GMJ *ecs.Entry //关门继电器
}
type CkmPsl struct {
KMA *ecs.Entry //开门按钮
GMA *ecs.Entry //关门按钮
MPLA *ecs.Entry //门旁路按钮
MMSA *ecs.Entry //门模式按钮
}

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: component/ci.proto

View File

@ -0,0 +1,180 @@
// 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
}

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: component/common.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: component/equipment.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: component/points.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: component/psd.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: component/signal.proto

View File

@ -1,74 +1,47 @@
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.FixedPositionTransformType}
var CkmBaseComponentTypes = []ecs.IComponentType{component.UidType, component.CkmTag, component.CkmStateType, component.FixedPositionTransformType}
func LoadCkm(w ecs.World) error {
data := GetWorldData(w)
for _, ckm := range data.Repo.CkmList() {
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)
//创建基础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)
}
}
}
}
}
}
// 添加车库门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))
return nil
}

View File

@ -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.PsdPsl, mkxEntry *ecs.Entry, psdEntry *ecs.Entry) {
mkx *repository.Mkx, 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.PsdPsl) *ecs.Entry {
func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repository.Mkx) *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.PsdPsl) *ecs.Entry {
func NewPlatformMkxEntry(world ecs.World, entryMap map[string]*ecs.Entry, mkx *repository.Mkx) *ecs.Entry {
entry := world.Entry(world.Create(component.PlatformMkxCircuitType))
circuit := &component.PlatformMkxCircuit{}
if pcbj := mkx.Pcbj(); pcbj != nil {

View File

@ -0,0 +1,15 @@
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; //
}

View File

@ -30,7 +30,6 @@ 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;
@ -222,9 +221,8 @@ enum DeviceType {
DeviceType_PowerScreen = 22;
//
DeviceType_Route = 23;
DeviceType_Ckm = 24; //
DeviceType_Xcj = 25; //
DeviceType_CkmPsl = 26; //PSL
DeviceType_Ckm = 24;
DeviceType_Xcj = 25;
//--------ISCS [300,500]------
//ISCS门磁
@ -520,16 +518,6 @@ 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 {

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: cg_repo.proto

View File

@ -1,34 +0,0 @@
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
}

View File

@ -2,7 +2,7 @@ package repository
import "joylink.club/rtsssimulation/repository/model/proto"
type PsdPsl struct {
type Mkx struct {
Identity
psd *Psd
@ -25,8 +25,8 @@ type PsdPsl struct {
jxtcpl *Button
}
func NewPsdPsl(id string) *PsdPsl {
return &PsdPsl{
func NewMkx(id string) *Mkx {
return &Mkx{
Identity: identity{
id: id,
deviceType: proto.DeviceType_DeviceType_Mkx,
@ -34,74 +34,74 @@ func NewPsdPsl(id string) *PsdPsl {
}
}
func (m *PsdPsl) Psd() *Psd {
func (m *Mkx) Psd() *Psd {
return m.psd
}
func (m *PsdPsl) Pcb() *Button {
func (m *Mkx) Pcb() *Button {
return m.pcb
}
func (m *PsdPsl) Pcbpl() *Button {
func (m *Mkx) Pcbpl() *Button {
return m.pcbpl
}
func (m *PsdPsl) Pcbj() *Relay {
func (m *Mkx) Pcbj() *Relay {
return m.pcbj
}
func (m *PsdPsl) Pob() *Button {
func (m *Mkx) Pob() *Button {
return m.pob
}
func (m *PsdPsl) Pobpl() *Button {
func (m *Mkx) Pobpl() *Button {
return m.pobpl
}
func (m *PsdPsl) Pobj() *Relay {
func (m *Mkx) Pobj() *Relay {
return m.pobj
}
func (m *PsdPsl) Pab() *Button {
func (m *Mkx) Pab() *Button {
return m.pab
}
func (m *PsdPsl) Pabpl() *Button {
func (m *Mkx) Pabpl() *Button {
return m.pabpl
}
func (m *PsdPsl) Pabj() *Relay {
func (m *Mkx) Pabj() *Relay {
return m.pabj
}
func (m *PsdPsl) Wrzf() *Button {
func (m *Mkx) Wrzf() *Button {
return m.wrzf
}
func (m *PsdPsl) Wrzfpl() *Button {
func (m *Mkx) Wrzfpl() *Button {
return m.wrzfpl
}
func (m *PsdPsl) Wrzfj() *Relay {
func (m *Mkx) Wrzfj() *Relay {
return m.wrzfj
}
func (m *PsdPsl) Qkqr() *Button {
func (m *Mkx) Qkqr() *Button {
return m.qkqr
}
func (m *PsdPsl) Qkqrpl() *Button {
func (m *Mkx) Qkqrpl() *Button {
return m.qkqrpl
}
func (m *PsdPsl) Qkqrj() *Relay {
func (m *Mkx) Qkqrj() *Relay {
return m.qkqrj
}
func (m *PsdPsl) Mpl() *Button {
func (m *Mkx) Mpl() *Button {
return m.mpl
}
func (m *PsdPsl) Jxtcpl() *Button {
func (m *Mkx) Jxtcpl() *Button {
return m.jxtcpl
}

File diff suppressed because it is too large Load Diff

View File

@ -8,33 +8,31 @@ 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
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
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
PipeMap map[string]*Pipe //ISCS 管线
PipeFittingMap map[string]*PipeFitting //ISCS 管件
CircuitBreakerMap map[string]*CircuitBreaker //ISCS 断路器
@ -78,7 +76,7 @@ func newRepository(id string, version string) *Repository {
lightMap: make(map[string]*Light),
alarmMap: make(map[string]*Alarm),
stationMap: make(map[string]*Station),
psdPslMap: make(map[string]*PsdPsl),
mkxMap: make(map[string]*Mkx),
keyMap: make(map[string]*Key),
platformMap: make(map[string]*Platform),
centralizedMap: make(map[string]*proto.CentralizedStationRef),
@ -295,9 +293,9 @@ func (repo *Repository) PsdList() []*Psd {
}
return list
}
func (repo *Repository) MkxList() []*PsdPsl {
var list []*PsdPsl
for _, model := range repo.psdPslMap {
func (repo *Repository) MkxList() []*Mkx {
var list []*Mkx
for _, model := range repo.mkxMap {
list = append(list, model)
}
return list
@ -342,14 +340,6 @@ 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]
}

View File

@ -123,8 +123,8 @@ func buildModels(source *proto.Repository, repository *Repository) error {
repository.alarmMap[m.Id()] = m
}
for _, protoData := range source.Mkxs {
m := NewPsdPsl(protoData.Id)
repository.psdPslMap[m.Id()] = m
m := NewMkx(protoData.Id)
repository.mkxMap[m.Id()] = m
}
for _, protoData := range source.Keys {
m := NewKey(protoData.Id, protoData.Code, protoData.Gear)
@ -142,10 +142,6 @@ 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
@ -212,22 +208,9 @@ 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]
@ -287,7 +270,7 @@ func buildCentralizedStationRelationShip(source *proto.Repository, repo *Reposit
}
func buildMkxRelationShip(source *proto.Repository, repo *Repository) error {
for _, protoData := range source.Mkxs {
mkx := repo.psdPslMap[protoData.Id]
mkx := repo.mkxMap[protoData.Id]
mkx.psd = repo.psdMap[protoData.PsdId]
mkx.pcb = repo.buttonMap[protoData.PcbaId]
mkx.pcbpl = repo.buttonMap[protoData.PcbplaId]

View File

@ -22,31 +22,24 @@ 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)
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 {
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)
//开/关门继电器驱动状态
kmBit, err := worldData.QueryQdBit(component.UidType.Get(circuit.KMJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.KMJ).Td = kmBit
@ -59,15 +52,21 @@ 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 {
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 posCom.Pos == consts.TwoPosMin {
state.Close = true
} else {
state.Close = false
}
state.Mgz = entry.HasComponent(component.CkmMgzTag)
}
//驱动
if component.BitStateType.Get(circuit.GMJ).Val {
if state.Gm {
posCom.Speed = -component.CalculateTwoPositionAvgSpeed(3*1000, world.Tick())
} else if component.BitStateType.Get(circuit.KMJ).Val {
} else if state.Km {
posCom.Speed = component.CalculateTwoPositionAvgSpeed(3*1000, world.Tick())
}
})