Compare commits

..

4 Commits

Author SHA1 Message Date
6e15c7548e merge问题修改 2024-02-04 11:24:36 +08:00
61f325bfb3 merge master branch 2024-01-31 17:24:31 +08:00
16dbc3e93e 道岔、联锁驱采卡实体构建重构 2024-01-16 18:08:06 +08:00
9401b15142 组件调整
实体加载调整
继电器、断相保护器、道岔转辙机、道岔、道岔电路等系统调整
继电器、道岔对外接口调整
2024-01-12 18:20:21 +08:00
131 changed files with 6076 additions and 8157 deletions

6
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "jl-ecs"]
path = jl-ecs
url = https://gitea.joylink.club/joylink/jl-ecs.git
[submodule "jl-ecs-go"]
path = jl-ecs-go
url = https://git.code.tencent.com/jl-framework/jl-ecs-go.git

View File

@ -1,11 +0,0 @@
package component
import "joylink.club/ecs"
var (
AxleCountingSectionStateType = ecs.NewComponentType[AxleCountingSectionState]()
)
type AxleCountingSectionState struct {
Occupied bool
}

View File

@ -9,17 +9,9 @@ var (
BaliseVB = ecs.NewTag() // 主信号应答器
BaliseIB = ecs.NewTag() // 预告应答器
)
var ForceVariableTelegram = ecs.NewTag() //表示可变报文为强制设置并锁定
var BaliseFixedTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器固定报文
var BaliseVariableTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器可变报文
type BaliseTelegram struct {
var BaliseFixedTelegramType = ecs.NewComponentType[BaliseState]() //应答器固定报文
var BaliseVariableTelegramType = ecs.NewComponentType[BaliseState]() //应答器可变报文
type BaliseState struct {
Telegram []byte //报文
UserTelegram []byte //用户报文
}
var BaliseWorkStateType = ecs.NewComponentType[BaliseWorkState]() // 工作状态
type BaliseWorkState struct {
Work bool //应答器是否正常工作中目前仅应答器停止发送报文故障会导致为false
}

View File

@ -3,8 +3,48 @@ package component
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component/component_data"
"joylink.club/rtsssimulation/component/relation"
"joylink.club/rtsssimulation/modelrepo/model"
)
var (
CiSysRAMType = ecs.NewComponentType[component_data.CiSysRAM]()
// 联锁驱采码表模型关系组件类型
CiQckModelRelaType = relation.CiQckModelRelaType
// 联锁驱动、采集状态表
CiQckStateType = ecs.NewComponentType[CiQckState]()
)
type CiQckState struct {
*component_data.CiQcState
qbits []bool
cbits []bool
}
func NewCiQckState(qcb model.CiQcb) *CiQckState {
qbits := len(qcb.QD())
cbits := len(qcb.CJ())
qbytes := qbits / 8
if qbits%8 > 0 {
qbytes++
}
cbytes := cbits / 8
if cbits%8 > 0 {
cbytes++
}
s := &CiQckState{
CiQcState: &component_data.CiQcState{
Qbs: make([]byte, qbytes),
Cbs: make([]byte, cbytes),
},
qbits: make([]bool, qbits),
cbits: make([]bool, cbits),
}
return s
}
// 获取驱动位状态
func (s *CiQckState) GetQbitOf(i int) bool {
return s.qbits[i]
}

View File

@ -1,36 +0,0 @@
package component
import (
"joylink.club/ecs"
)
var (
CkmTag = ecs.NewTag()
CkmCircuitType = ecs.NewComponentType[CkmCircuit]()
CkmPslType = ecs.NewComponentType[CkmPsl]()
CkmForceOpenTag = ecs.NewTag()
CkmForceCloseTag = ecs.NewTag()
)
type CkmCircuit struct {
MKJ *ecs.Entry //门开继电器
MGJ *ecs.Entry //门关继电器
MGZJ *ecs.Entry //门故障继电器
MPLJ *ecs.Entry //门旁路继电器
MMSJ *ecs.Entry //门模式继电器(吸合:远程/断开:本地)(初始状态:吸合)
KMJ *ecs.Entry //开门继电器
GMJ *ecs.Entry //关门继电器
}
func (c *CkmCircuit) RelayList() []*ecs.Entry {
return []*ecs.Entry{c.MKJ, c.MGJ, c.MGZJ, c.MPLJ, c.MMSJ, c.KMJ, c.GMJ}
}
type CkmPsl struct {
KMA *ecs.Entry //开门按钮
GMA *ecs.Entry //关门按钮
MPLA *ecs.Entry //门旁路按钮
MMSA *ecs.Entry //门模式按钮
}

View File

@ -11,15 +11,9 @@ var (
UidType = ecs.NewComponentType[Uid]()
// 固定位置转换组件类型
FixedPositionTransformType = ecs.NewComponentType[FixedPositionTransform]()
// 电机状态组件类型
MotorStateType = ecs.NewComponentType[component_data.MotorState]()
BitStateType = ecs.NewComponentType[BitState]()
)
/*type Bypass struct {
BypassEnable bool // 摁钮,钥匙 是否旁路
OldVal bool //摁钮旁路旧值
}*/
BitStateType = ecs.NewComponentType[BitState]()
)
// 唯一ID组件
type Uid struct {
@ -50,7 +44,6 @@ func CalculateTwoPositionAvgSpeed(t int, tick int) int32 {
// 仅有两状态的组件
type BitState struct {
//Bypass
Val bool
}

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

@ -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
@ -20,200 +20,20 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// 电机
type MotorState struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// 是否通电
PowerUp bool `protobuf:"varint,1,opt,name=powerUp,proto3" json:"powerUp,omitempty"`
// 是否正转
Forward bool `protobuf:"varint,2,opt,name=forward,proto3" json:"forward,omitempty"`
}
func (x *MotorState) Reset() {
*x = MotorState{}
if protoimpl.UnsafeEnabled {
mi := &file_component_common_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *MotorState) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*MotorState) ProtoMessage() {}
func (x *MotorState) ProtoReflect() protoreflect.Message {
mi := &file_component_common_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 MotorState.ProtoReflect.Descriptor instead.
func (*MotorState) Descriptor() ([]byte, []int) {
return file_component_common_proto_rawDescGZIP(), []int{0}
}
func (x *MotorState) GetPowerUp() bool {
if x != nil {
return x.PowerUp
}
return false
}
func (x *MotorState) GetForward() bool {
if x != nil {
return x.Forward
}
return false
}
// 无极继电器和偏极继电器稳态为落下,也就是后接点(8组采集接点中的1,3接点,1为中接点),吸气为前接点1,2接点
// 有极继电器是定位反位双稳态(有永久磁钢),前接点为定位,后接点为反位
// 有极继电器对于道岔中的2DQJ,励磁接点1,2接通为反位;3,4接通为定位
// 定义继电器状态时false表示落下/反位/后接点,true表示吸起/定位/前接点
// 缓动继电器:指从通电或断电起,至接点转接止所需时间在0.3s以上的继电器。可分为缓放继电器(如无极缓放继电器等)和缓吸继电器(如热力继电器和时间继电器等)。
// 偏极继电器:只有通过规定方向的电流时,才吸起
// 继电器状态
type RelayState struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// 是否通电
PowerUp bool `protobuf:"varint,1,opt,name=powerUp,proto3" json:"powerUp,omitempty"`
// 是否励磁到前接点
Qq bool `protobuf:"varint,2,opt,name=qq,proto3" json:"qq,omitempty"`
// 是否在前接点位置
Q bool `protobuf:"varint,3,opt,name=q,proto3" json:"q,omitempty"`
}
func (x *RelayState) Reset() {
*x = RelayState{}
if protoimpl.UnsafeEnabled {
mi := &file_component_common_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RelayState) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RelayState) ProtoMessage() {}
func (x *RelayState) ProtoReflect() protoreflect.Message {
mi := &file_component_common_proto_msgTypes[1]
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 RelayState.ProtoReflect.Descriptor instead.
func (*RelayState) Descriptor() ([]byte, []int) {
return file_component_common_proto_rawDescGZIP(), []int{1}
}
func (x *RelayState) GetPowerUp() bool {
if x != nil {
return x.PowerUp
}
return false
}
func (x *RelayState) GetQq() bool {
if x != nil {
return x.Qq
}
return false
}
func (x *RelayState) GetQ() bool {
if x != nil {
return x.Q
}
return false
}
// 开关类设备状态
type SwitchState struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// 是否按下(按钮式开关true表示按下,旋钮开关true非常态位)
Pressed bool `protobuf:"varint,2,opt,name=pressed,proto3" json:"pressed,omitempty"`
}
func (x *SwitchState) Reset() {
*x = SwitchState{}
if protoimpl.UnsafeEnabled {
mi := &file_component_common_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SwitchState) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SwitchState) ProtoMessage() {}
func (x *SwitchState) ProtoReflect() protoreflect.Message {
mi := &file_component_common_proto_msgTypes[2]
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 SwitchState.ProtoReflect.Descriptor instead.
func (*SwitchState) Descriptor() ([]byte, []int) {
return file_component_common_proto_rawDescGZIP(), []int{2}
}
func (x *SwitchState) GetPressed() bool {
if x != nil {
return x.Pressed
}
return false
}
// 固定位置转换组件
type FixedPositionTransform struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Pos int32 `protobuf:"varint,1,opt,name=pos,proto3" json:"pos,omitempty"` // 当前位置,[0, 10000]
Pos int32 `protobuf:"varint,1,opt,name=pos,proto3" json:"pos,omitempty"` // 当前位置百分比,[0, 100]
Speed int32 `protobuf:"varint,2,opt,name=speed,proto3" json:"speed,omitempty"`
}
func (x *FixedPositionTransform) Reset() {
*x = FixedPositionTransform{}
if protoimpl.UnsafeEnabled {
mi := &file_component_common_proto_msgTypes[3]
mi := &file_component_common_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -226,7 +46,7 @@ func (x *FixedPositionTransform) String() string {
func (*FixedPositionTransform) ProtoMessage() {}
func (x *FixedPositionTransform) ProtoReflect() protoreflect.Message {
mi := &file_component_common_proto_msgTypes[3]
mi := &file_component_common_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -239,7 +59,7 @@ func (x *FixedPositionTransform) ProtoReflect() protoreflect.Message {
// Deprecated: Use FixedPositionTransform.ProtoReflect.Descriptor instead.
func (*FixedPositionTransform) Descriptor() ([]byte, []int) {
return file_component_common_proto_rawDescGZIP(), []int{3}
return file_component_common_proto_rawDescGZIP(), []int{0}
}
func (x *FixedPositionTransform) GetPos() int32 {
@ -256,54 +76,6 @@ func (x *FixedPositionTransform) GetSpeed() int32 {
return 0
}
// 开关状态组件
type BitState struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Val bool `protobuf:"varint,1,opt,name=val,proto3" json:"val,omitempty"`
}
func (x *BitState) Reset() {
*x = BitState{}
if protoimpl.UnsafeEnabled {
mi := &file_component_common_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BitState) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BitState) ProtoMessage() {}
func (x *BitState) ProtoReflect() protoreflect.Message {
mi := &file_component_common_proto_msgTypes[4]
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 BitState.ProtoReflect.Descriptor instead.
func (*BitState) Descriptor() ([]byte, []int) {
return file_component_common_proto_rawDescGZIP(), []int{4}
}
func (x *BitState) GetVal() bool {
if x != nil {
return x.Val
}
return false
}
// 计数/计时组件
type Counter struct {
state protoimpl.MessageState
@ -317,7 +89,7 @@ type Counter struct {
func (x *Counter) Reset() {
*x = Counter{}
if protoimpl.UnsafeEnabled {
mi := &file_component_common_proto_msgTypes[5]
mi := &file_component_common_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -330,7 +102,7 @@ func (x *Counter) String() string {
func (*Counter) ProtoMessage() {}
func (x *Counter) ProtoReflect() protoreflect.Message {
mi := &file_component_common_proto_msgTypes[5]
mi := &file_component_common_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -343,7 +115,7 @@ func (x *Counter) ProtoReflect() protoreflect.Message {
// Deprecated: Use Counter.ProtoReflect.Descriptor instead.
func (*Counter) Descriptor() ([]byte, []int) {
return file_component_common_proto_rawDescGZIP(), []int{5}
return file_component_common_proto_rawDescGZIP(), []int{1}
}
func (x *Counter) GetVal() int32 {
@ -360,6 +132,62 @@ func (x *Counter) GetStep() int32 {
return 0
}
// 倒数/倒计时组件
type CounterDown struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Val int32 `protobuf:"varint,1,opt,name=val,proto3" json:"val,omitempty"`
Step int32 `protobuf:"varint,2,opt,name=step,proto3" json:"step,omitempty"`
}
func (x *CounterDown) Reset() {
*x = CounterDown{}
if protoimpl.UnsafeEnabled {
mi := &file_component_common_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CounterDown) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CounterDown) ProtoMessage() {}
func (x *CounterDown) ProtoReflect() protoreflect.Message {
mi := &file_component_common_proto_msgTypes[2]
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 CounterDown.ProtoReflect.Descriptor instead.
func (*CounterDown) Descriptor() ([]byte, []int) {
return file_component_common_proto_rawDescGZIP(), []int{2}
}
func (x *CounterDown) GetVal() int32 {
if x != nil {
return x.Val
}
return 0
}
func (x *CounterDown) GetStep() int32 {
if x != nil {
return x.Step
}
return 0
}
// Link位置
type LinkPosition struct {
state protoimpl.MessageState
@ -375,7 +203,7 @@ type LinkPosition struct {
func (x *LinkPosition) Reset() {
*x = LinkPosition{}
if protoimpl.UnsafeEnabled {
mi := &file_component_common_proto_msgTypes[6]
mi := &file_component_common_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -388,7 +216,7 @@ func (x *LinkPosition) String() string {
func (*LinkPosition) ProtoMessage() {}
func (x *LinkPosition) ProtoReflect() protoreflect.Message {
mi := &file_component_common_proto_msgTypes[6]
mi := &file_component_common_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -401,7 +229,7 @@ func (x *LinkPosition) ProtoReflect() protoreflect.Message {
// Deprecated: Use LinkPosition.ProtoReflect.Descriptor instead.
func (*LinkPosition) Descriptor() ([]byte, []int) {
return file_component_common_proto_rawDescGZIP(), []int{6}
return file_component_common_proto_rawDescGZIP(), []int{3}
}
func (x *LinkPosition) GetLinkId() string {
@ -418,97 +246,29 @@ func (x *LinkPosition) GetOffset() int64 {
return 0
}
// 倒数/倒计时组件
type CounterDown struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Val int32 `protobuf:"varint,1,opt,name=val,proto3" json:"val,omitempty"`
Step int32 `protobuf:"varint,2,opt,name=step,proto3" json:"step,omitempty"`
}
func (x *CounterDown) Reset() {
*x = CounterDown{}
if protoimpl.UnsafeEnabled {
mi := &file_component_common_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CounterDown) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CounterDown) ProtoMessage() {}
func (x *CounterDown) ProtoReflect() protoreflect.Message {
mi := &file_component_common_proto_msgTypes[7]
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 CounterDown.ProtoReflect.Descriptor instead.
func (*CounterDown) Descriptor() ([]byte, []int) {
return file_component_common_proto_rawDescGZIP(), []int{7}
}
func (x *CounterDown) GetVal() int32 {
if x != nil {
return x.Val
}
return 0
}
func (x *CounterDown) GetStep() int32 {
if x != nil {
return x.Step
}
return 0
}
var File_component_common_proto protoreflect.FileDescriptor
var file_component_common_proto_rawDesc = []byte{
0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e,
0x65, 0x6e, 0x74, 0x22, 0x40, 0x0a, 0x0a, 0x4d, 0x6f, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74,
0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18, 0x01, 0x20, 0x01,
0x28, 0x08, 0x52, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x66,
0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x66, 0x6f,
0x72, 0x77, 0x61, 0x72, 0x64, 0x22, 0x44, 0x0a, 0x0a, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x53, 0x74,
0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18, 0x01,
0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x0e, 0x0a,
0x02, 0x71, 0x71, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x71, 0x71, 0x12, 0x0c, 0x0a,
0x01, 0x71, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x01, 0x71, 0x22, 0x27, 0x0a, 0x0b, 0x53,
0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72,
0x65, 0x73, 0x73, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x72, 0x65,
0x73, 0x73, 0x65, 0x64, 0x22, 0x40, 0x0a, 0x16, 0x46, 0x69, 0x78, 0x65, 0x64, 0x50, 0x6f, 0x73,
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x10,
0x0a, 0x03, 0x70, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x70, 0x6f, 0x73,
0x12, 0x14, 0x0a, 0x05, 0x73, 0x70, 0x65, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
0x05, 0x73, 0x70, 0x65, 0x65, 0x64, 0x22, 0x1c, 0x0a, 0x08, 0x42, 0x69, 0x74, 0x53, 0x74, 0x61,
0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
0x03, 0x76, 0x61, 0x6c, 0x22, 0x2f, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12,
0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76, 0x61,
0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
0x04, 0x73, 0x74, 0x65, 0x70, 0x22, 0x3e, 0x0a, 0x0c, 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x6f, 0x73,
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x69, 0x6e, 0x6b, 0x49, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x69, 0x6e, 0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a,
0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f,
0x66, 0x66, 0x73, 0x65, 0x74, 0x22, 0x33, 0x0a, 0x0b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72,
0x44, 0x6f, 0x77, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28,
0x05, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18, 0x02,
0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x65, 0x70, 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,
0x65, 0x6e, 0x74, 0x22, 0x40, 0x0a, 0x16, 0x46, 0x69, 0x78, 0x65, 0x64, 0x50, 0x6f, 0x73, 0x69,
0x74, 0x69, 0x6f, 0x6e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x10, 0x0a,
0x03, 0x70, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x70, 0x6f, 0x73, 0x12,
0x14, 0x0a, 0x05, 0x73, 0x70, 0x65, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05,
0x73, 0x70, 0x65, 0x65, 0x64, 0x22, 0x2f, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72,
0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76,
0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05,
0x52, 0x04, 0x73, 0x74, 0x65, 0x70, 0x22, 0x33, 0x0a, 0x0b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65,
0x72, 0x44, 0x6f, 0x77, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01,
0x28, 0x05, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18,
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x65, 0x70, 0x22, 0x3e, 0x0a, 0x0c, 0x4c,
0x69, 0x6e, 0x6b, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6c,
0x69, 0x6e, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x69, 0x6e,
0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20,
0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 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 (
@ -523,16 +283,12 @@ func file_component_common_proto_rawDescGZIP() []byte {
return file_component_common_proto_rawDescData
}
var file_component_common_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_component_common_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_component_common_proto_goTypes = []interface{}{
(*MotorState)(nil), // 0: component.MotorState
(*RelayState)(nil), // 1: component.RelayState
(*SwitchState)(nil), // 2: component.SwitchState
(*FixedPositionTransform)(nil), // 3: component.FixedPositionTransform
(*BitState)(nil), // 4: component.BitState
(*Counter)(nil), // 5: component.Counter
(*LinkPosition)(nil), // 6: component.LinkPosition
(*CounterDown)(nil), // 7: component.CounterDown
(*FixedPositionTransform)(nil), // 0: component.FixedPositionTransform
(*Counter)(nil), // 1: component.Counter
(*CounterDown)(nil), // 2: component.CounterDown
(*LinkPosition)(nil), // 3: component.LinkPosition
}
var file_component_common_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
@ -549,42 +305,6 @@ func file_component_common_proto_init() {
}
if !protoimpl.UnsafeEnabled {
file_component_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MotorState); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_component_common_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RelayState); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_component_common_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SwitchState); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_component_common_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FixedPositionTransform); i {
case 0:
return &v.state
@ -596,19 +316,7 @@ func file_component_common_proto_init() {
return nil
}
}
file_component_common_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BitState); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_component_common_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
file_component_common_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Counter); i {
case 0:
return &v.state
@ -620,8 +328,8 @@ func file_component_common_proto_init() {
return nil
}
}
file_component_common_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LinkPosition); i {
file_component_common_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CounterDown); i {
case 0:
return &v.state
case 1:
@ -632,8 +340,8 @@ func file_component_common_proto_init() {
return nil
}
}
file_component_common_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CounterDown); i {
file_component_common_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LinkPosition); i {
case 0:
return &v.state
case 1:
@ -651,7 +359,7 @@ func file_component_common_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_component_common_proto_rawDesc,
NumEnums: 0,
NumMessages: 8,
NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},

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
@ -20,6 +20,79 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// 无极继电器和偏极继电器稳态为落下,也就是后接点(8组采集接点中的1,3接点,1为中接点),吸气为前接点1,2接点
// 有极继电器是定位反位双稳态(有永久磁钢),前接点为定位,后接点为反位
// 有极继电器对于道岔中的2DQJ,励磁接点1,2接通为反位;3,4接通为定位
// 定义继电器状态时false表示落下/反位/后接点,true表示吸起/定位/前接点
// 缓动继电器:指从通电或断电起,至接点转接止所需时间在0.3s以上的继电器。可分为缓放继电器(如无极缓放继电器等)和缓吸继电器(如热力继电器和时间继电器等)。
// 偏极继电器:只有通过规定方向的电流时,才吸起
// 继电器状态
type RelayState struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// 是否通电
PowerUp bool `protobuf:"varint,1,opt,name=powerUp,proto3" json:"powerUp,omitempty"`
// 是否励磁到前接点位
ExcQw bool `protobuf:"varint,2,opt,name=excQw,proto3" json:"excQw,omitempty"`
// 是否在前接点位置
Q bool `protobuf:"varint,3,opt,name=q,proto3" json:"q,omitempty"`
}
func (x *RelayState) Reset() {
*x = RelayState{}
if protoimpl.UnsafeEnabled {
mi := &file_component_equipment_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RelayState) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RelayState) ProtoMessage() {}
func (x *RelayState) ProtoReflect() protoreflect.Message {
mi := &file_component_equipment_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 RelayState.ProtoReflect.Descriptor instead.
func (*RelayState) Descriptor() ([]byte, []int) {
return file_component_equipment_proto_rawDescGZIP(), []int{0}
}
func (x *RelayState) GetPowerUp() bool {
if x != nil {
return x.PowerUp
}
return false
}
func (x *RelayState) GetExcQw() bool {
if x != nil {
return x.ExcQw
}
return false
}
func (x *RelayState) GetQ() bool {
if x != nil {
return x.Q
}
return false
}
// 继电器强制故障(强制在某个位置)
type RelayFaultForce struct {
state protoimpl.MessageState
@ -32,7 +105,7 @@ type RelayFaultForce struct {
func (x *RelayFaultForce) Reset() {
*x = RelayFaultForce{}
if protoimpl.UnsafeEnabled {
mi := &file_component_equipment_proto_msgTypes[0]
mi := &file_component_equipment_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -45,7 +118,7 @@ func (x *RelayFaultForce) String() string {
func (*RelayFaultForce) ProtoMessage() {}
func (x *RelayFaultForce) ProtoReflect() protoreflect.Message {
mi := &file_component_equipment_proto_msgTypes[0]
mi := &file_component_equipment_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -58,7 +131,7 @@ func (x *RelayFaultForce) ProtoReflect() protoreflect.Message {
// Deprecated: Use RelayFaultForce.ProtoReflect.Descriptor instead.
func (*RelayFaultForce) Descriptor() ([]byte, []int) {
return file_component_equipment_proto_rawDescGZIP(), []int{0}
return file_component_equipment_proto_rawDescGZIP(), []int{1}
}
func (x *RelayFaultForce) GetQ() bool {
@ -68,16 +141,143 @@ func (x *RelayFaultForce) GetQ() bool {
return false
}
// 断相保护器状态
type DbqState struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
PowerUp bool `protobuf:"varint,1,opt,name=powerUp,proto3" json:"powerUp,omitempty"` // 是否通电
SwOn bool `protobuf:"varint,2,opt,name=swOn,proto3" json:"swOn,omitempty"` // 电子开关是否打开
}
func (x *DbqState) Reset() {
*x = DbqState{}
if protoimpl.UnsafeEnabled {
mi := &file_component_equipment_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DbqState) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DbqState) ProtoMessage() {}
func (x *DbqState) ProtoReflect() protoreflect.Message {
mi := &file_component_equipment_proto_msgTypes[2]
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 DbqState.ProtoReflect.Descriptor instead.
func (*DbqState) Descriptor() ([]byte, []int) {
return file_component_equipment_proto_rawDescGZIP(), []int{2}
}
func (x *DbqState) GetPowerUp() bool {
if x != nil {
return x.PowerUp
}
return false
}
func (x *DbqState) GetSwOn() bool {
if x != nil {
return x.SwOn
}
return false
}
// 电机
type MotorState struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// 是否通电
PowerUp bool `protobuf:"varint,1,opt,name=powerUp,proto3" json:"powerUp,omitempty"`
// 是否正转
Forward bool `protobuf:"varint,2,opt,name=forward,proto3" json:"forward,omitempty"`
}
func (x *MotorState) Reset() {
*x = MotorState{}
if protoimpl.UnsafeEnabled {
mi := &file_component_equipment_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *MotorState) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*MotorState) ProtoMessage() {}
func (x *MotorState) ProtoReflect() protoreflect.Message {
mi := &file_component_equipment_proto_msgTypes[3]
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 MotorState.ProtoReflect.Descriptor instead.
func (*MotorState) Descriptor() ([]byte, []int) {
return file_component_equipment_proto_rawDescGZIP(), []int{3}
}
func (x *MotorState) GetPowerUp() bool {
if x != nil {
return x.PowerUp
}
return false
}
func (x *MotorState) GetForward() bool {
if x != nil {
return x.Forward
}
return false
}
var File_component_equipment_proto protoreflect.FileDescriptor
var file_component_equipment_proto_rawDesc = []byte{
0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x65, 0x71, 0x75, 0x69,
0x70, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d,
0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x22, 0x1f, 0x0a, 0x0f, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x46,
0x61, 0x75, 0x6c, 0x74, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x71, 0x18, 0x01,
0x20, 0x01, 0x28, 0x08, 0x52, 0x01, 0x71, 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,
0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x22, 0x4a, 0x0a, 0x0a, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x53,
0x74, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18,
0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x14,
0x0a, 0x05, 0x65, 0x78, 0x63, 0x51, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x65,
0x78, 0x63, 0x51, 0x77, 0x12, 0x0c, 0x0a, 0x01, 0x71, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52,
0x01, 0x71, 0x22, 0x1f, 0x0a, 0x0f, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x46, 0x61, 0x75, 0x6c, 0x74,
0x46, 0x6f, 0x72, 0x63, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
0x52, 0x01, 0x71, 0x22, 0x38, 0x0a, 0x08, 0x44, 0x62, 0x71, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12,
0x18, 0x0a, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
0x52, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x77, 0x4f,
0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x73, 0x77, 0x4f, 0x6e, 0x22, 0x40, 0x0a,
0x0a, 0x4d, 0x6f, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70,
0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x6f,
0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64,
0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 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 (
@ -92,9 +292,12 @@ func file_component_equipment_proto_rawDescGZIP() []byte {
return file_component_equipment_proto_rawDescData
}
var file_component_equipment_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_component_equipment_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_component_equipment_proto_goTypes = []interface{}{
(*RelayFaultForce)(nil), // 0: component.RelayFaultForce
(*RelayState)(nil), // 0: component.RelayState
(*RelayFaultForce)(nil), // 1: component.RelayFaultForce
(*DbqState)(nil), // 2: component.DbqState
(*MotorState)(nil), // 3: component.MotorState
}
var file_component_equipment_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
@ -111,6 +314,18 @@ func file_component_equipment_proto_init() {
}
if !protoimpl.UnsafeEnabled {
file_component_equipment_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RelayState); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_component_equipment_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RelayFaultForce); i {
case 0:
return &v.state
@ -122,6 +337,30 @@ func file_component_equipment_proto_init() {
return nil
}
}
file_component_equipment_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DbqState); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_component_equipment_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MotorState); 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{
@ -129,7 +368,7 @@ func file_component_equipment_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_component_equipment_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},

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
@ -81,6 +81,59 @@ func (Points_Fault) EnumDescriptor() ([]byte, []int) {
return file_component_points_proto_rawDescGZIP(), []int{2, 0}
}
// 道岔失表故障类型
type PointsFaultSb_Type int32
const (
// 失表
PointsFaultSb_ALL PointsFaultSb_Type = 0
// 定位失表
PointsFaultSb_DW PointsFaultSb_Type = 1
// 反位失表
PointsFaultSb_FW PointsFaultSb_Type = 2
)
// Enum value maps for PointsFaultSb_Type.
var (
PointsFaultSb_Type_name = map[int32]string{
0: "ALL",
1: "DW",
2: "FW",
}
PointsFaultSb_Type_value = map[string]int32{
"ALL": 0,
"DW": 1,
"FW": 2,
}
)
func (x PointsFaultSb_Type) Enum() *PointsFaultSb_Type {
p := new(PointsFaultSb_Type)
*p = x
return p
}
func (x PointsFaultSb_Type) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (PointsFaultSb_Type) Descriptor() protoreflect.EnumDescriptor {
return file_component_points_proto_enumTypes[1].Descriptor()
}
func (PointsFaultSb_Type) Type() protoreflect.EnumType {
return &file_component_points_proto_enumTypes[1]
}
func (x PointsFaultSb_Type) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use PointsFaultSb_Type.Descriptor instead.
func (PointsFaultSb_Type) EnumDescriptor() ([]byte, []int) {
return file_component_points_proto_rawDescGZIP(), []int{3, 0}
}
// 道岔转辙机自动开闭器状态
// 自动开闭器接点位置,默认定位接通1/3排反位接通2/4排
// 由定位转反位1DQJ和1DQJF励磁吸起,2DQJ在反位——即落下,三相电路导通,电机开始反转,转辙机将第3排接点接通第4排,到位锁闭后,转辙机的自动开闭器拉簧将第1排接点拉到第2排,接点到2排后,三相电路断路
@ -91,9 +144,9 @@ type PointsZzjKbqState struct {
unknownFields protoimpl.UnknownFields
// 接点在1/2排的位置,false-接点在1排,true-接点在2排
Jd13 bool `protobuf:"varint,1,opt,name=jd13,proto3" json:"jd13,omitempty"`
Jd12 bool `protobuf:"varint,1,opt,name=jd12,proto3" json:"jd12,omitempty"`
// 接点在3/4排的位置,false-接点在3排,true-接点在4排
Jd24 bool `protobuf:"varint,2,opt,name=jd24,proto3" json:"jd24,omitempty"`
Jd34 bool `protobuf:"varint,2,opt,name=jd34,proto3" json:"jd34,omitempty"`
}
func (x *PointsZzjKbqState) Reset() {
@ -128,16 +181,16 @@ func (*PointsZzjKbqState) Descriptor() ([]byte, []int) {
return file_component_points_proto_rawDescGZIP(), []int{0}
}
func (x *PointsZzjKbqState) GetJd13() bool {
func (x *PointsZzjKbqState) GetJd12() bool {
if x != nil {
return x.Jd13
return x.Jd12
}
return false
}
func (x *PointsZzjKbqState) GetJd24() bool {
func (x *PointsZzjKbqState) GetJd34() bool {
if x != nil {
return x.Jd24
return x.Jd34
}
return false
}
@ -258,14 +311,16 @@ func (*Points) Descriptor() ([]byte, []int) {
}
// 道岔失表故障
type PointsFaultSB struct {
type PointsFaultSb struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type PointsFaultSb_Type `protobuf:"varint,1,opt,name=type,proto3,enum=component.PointsFaultSb_Type" json:"type,omitempty"` // 失表类型
}
func (x *PointsFaultSB) Reset() {
*x = PointsFaultSB{}
func (x *PointsFaultSb) Reset() {
*x = PointsFaultSb{}
if protoimpl.UnsafeEnabled {
mi := &file_component_points_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -273,13 +328,13 @@ func (x *PointsFaultSB) Reset() {
}
}
func (x *PointsFaultSB) String() string {
func (x *PointsFaultSb) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PointsFaultSB) ProtoMessage() {}
func (*PointsFaultSb) ProtoMessage() {}
func (x *PointsFaultSB) ProtoReflect() protoreflect.Message {
func (x *PointsFaultSb) ProtoReflect() protoreflect.Message {
mi := &file_component_points_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -291,87 +346,16 @@ func (x *PointsFaultSB) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use PointsFaultSB.ProtoReflect.Descriptor instead.
func (*PointsFaultSB) Descriptor() ([]byte, []int) {
// Deprecated: Use PointsFaultSb.ProtoReflect.Descriptor instead.
func (*PointsFaultSb) Descriptor() ([]byte, []int) {
return file_component_points_proto_rawDescGZIP(), []int{3}
}
// 道岔定位失表故障
type PointsFaultDwsb struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *PointsFaultDwsb) Reset() {
*x = PointsFaultDwsb{}
if protoimpl.UnsafeEnabled {
mi := &file_component_points_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
func (x *PointsFaultSb) GetType() PointsFaultSb_Type {
if x != nil {
return x.Type
}
}
func (x *PointsFaultDwsb) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PointsFaultDwsb) ProtoMessage() {}
func (x *PointsFaultDwsb) ProtoReflect() protoreflect.Message {
mi := &file_component_points_proto_msgTypes[4]
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 PointsFaultDwsb.ProtoReflect.Descriptor instead.
func (*PointsFaultDwsb) Descriptor() ([]byte, []int) {
return file_component_points_proto_rawDescGZIP(), []int{4}
}
// 道岔反位失表故障
type PointsFaultFwsb struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *PointsFaultFwsb) Reset() {
*x = PointsFaultFwsb{}
if protoimpl.UnsafeEnabled {
mi := &file_component_points_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PointsFaultFwsb) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PointsFaultFwsb) ProtoMessage() {}
func (x *PointsFaultFwsb) ProtoReflect() protoreflect.Message {
mi := &file_component_points_proto_msgTypes[5]
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 PointsFaultFwsb.ProtoReflect.Descriptor instead.
func (*PointsFaultFwsb) Descriptor() ([]byte, []int) {
return file_component_points_proto_rawDescGZIP(), []int{5}
return PointsFaultSb_ALL
}
// 道岔挤岔故障
@ -384,7 +368,7 @@ type PointsFaultJc struct {
func (x *PointsFaultJc) Reset() {
*x = PointsFaultJc{}
if protoimpl.UnsafeEnabled {
mi := &file_component_points_proto_msgTypes[6]
mi := &file_component_points_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -397,7 +381,7 @@ func (x *PointsFaultJc) String() string {
func (*PointsFaultJc) ProtoMessage() {}
func (x *PointsFaultJc) ProtoReflect() protoreflect.Message {
mi := &file_component_points_proto_msgTypes[6]
mi := &file_component_points_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -410,7 +394,7 @@ func (x *PointsFaultJc) ProtoReflect() protoreflect.Message {
// Deprecated: Use PointsFaultJc.ProtoReflect.Descriptor instead.
func (*PointsFaultJc) Descriptor() ([]byte, []int) {
return file_component_points_proto_rawDescGZIP(), []int{6}
return file_component_points_proto_rawDescGZIP(), []int{4}
}
// 道岔联锁无法驱动故障
@ -423,7 +407,7 @@ type PointsFaultCiqd struct {
func (x *PointsFaultCiqd) Reset() {
*x = PointsFaultCiqd{}
if protoimpl.UnsafeEnabled {
mi := &file_component_points_proto_msgTypes[7]
mi := &file_component_points_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -436,7 +420,7 @@ func (x *PointsFaultCiqd) String() string {
func (*PointsFaultCiqd) ProtoMessage() {}
func (x *PointsFaultCiqd) ProtoReflect() protoreflect.Message {
mi := &file_component_points_proto_msgTypes[7]
mi := &file_component_points_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -449,7 +433,7 @@ func (x *PointsFaultCiqd) ProtoReflect() protoreflect.Message {
// Deprecated: Use PointsFaultCiqd.ProtoReflect.Descriptor instead.
func (*PointsFaultCiqd) Descriptor() ([]byte, []int) {
return file_component_points_proto_rawDescGZIP(), []int{7}
return file_component_points_proto_rawDescGZIP(), []int{5}
}
var File_component_points_proto protoreflect.FileDescriptor
@ -458,9 +442,9 @@ var file_component_points_proto_rawDesc = []byte{
0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x70, 0x6f, 0x69, 0x6e,
0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e,
0x65, 0x6e, 0x74, 0x22, 0x3b, 0x0a, 0x11, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x5a, 0x7a, 0x6a,
0x4b, 0x62, 0x71, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6a, 0x64, 0x31, 0x33,
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6a, 0x64, 0x31, 0x33, 0x12, 0x12, 0x0a, 0x04,
0x6a, 0x64, 0x32, 0x34, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6a, 0x64, 0x32, 0x34,
0x4b, 0x62, 0x71, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6a, 0x64, 0x31, 0x32,
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6a, 0x64, 0x31, 0x32, 0x12, 0x12, 0x0a, 0x04,
0x6a, 0x64, 0x33, 0x34, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6a, 0x64, 0x33, 0x34,
0x22, 0x50, 0x0a, 0x0e, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69,
0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x64, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02,
0x64, 0x77, 0x12, 0x0e, 0x0a, 0x02, 0x66, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02,
@ -470,15 +454,18 @@ var file_component_points_proto_rawDesc = []byte{
0x46, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x06, 0x0a, 0x02, 0x53, 0x42, 0x10, 0x00, 0x12, 0x08, 0x0a,
0x04, 0x44, 0x57, 0x53, 0x42, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x57, 0x53, 0x42, 0x10,
0x02, 0x12, 0x06, 0x0a, 0x02, 0x4a, 0x43, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x49, 0x51,
0x44, 0x10, 0x04, 0x22, 0x0f, 0x0a, 0x0d, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75,
0x6c, 0x74, 0x53, 0x42, 0x22, 0x11, 0x0a, 0x0f, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61,
0x75, 0x6c, 0x74, 0x44, 0x77, 0x73, 0x62, 0x22, 0x11, 0x0a, 0x0f, 0x50, 0x6f, 0x69, 0x6e, 0x74,
0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x46, 0x77, 0x73, 0x62, 0x22, 0x0f, 0x0a, 0x0d, 0x50, 0x6f,
0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x4a, 0x63, 0x22, 0x11, 0x0a, 0x0f, 0x50,
0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x69, 0x71, 0x64, 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,
0x44, 0x10, 0x04, 0x22, 0x63, 0x0a, 0x0d, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75,
0x6c, 0x74, 0x53, 0x62, 0x12, 0x31, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x50,
0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x62, 0x2e, 0x54, 0x79, 0x70,
0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x1f, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12,
0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x00, 0x12, 0x06, 0x0a, 0x02, 0x44, 0x57, 0x10, 0x01,
0x12, 0x06, 0x0a, 0x02, 0x46, 0x57, 0x10, 0x02, 0x22, 0x0f, 0x0a, 0x0d, 0x50, 0x6f, 0x69, 0x6e,
0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x4a, 0x63, 0x22, 0x11, 0x0a, 0x0f, 0x50, 0x6f, 0x69,
0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x69, 0x71, 0x64, 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 (
@ -493,25 +480,25 @@ func file_component_points_proto_rawDescGZIP() []byte {
return file_component_points_proto_rawDescData
}
var file_component_points_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_component_points_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_component_points_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_component_points_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_component_points_proto_goTypes = []interface{}{
(Points_Fault)(0), // 0: component.Points.Fault
(*PointsZzjKbqState)(nil), // 1: component.PointsZzjKbqState
(*PointsPosition)(nil), // 2: component.PointsPosition
(*Points)(nil), // 3: component.Points
(*PointsFaultSB)(nil), // 4: component.PointsFaultSB
(*PointsFaultDwsb)(nil), // 5: component.PointsFaultDwsb
(*PointsFaultFwsb)(nil), // 6: component.PointsFaultFwsb
(*PointsFaultJc)(nil), // 7: component.PointsFaultJc
(*PointsFaultCiqd)(nil), // 8: component.PointsFaultCiqd
(PointsFaultSb_Type)(0), // 1: component.PointsFaultSb.Type
(*PointsZzjKbqState)(nil), // 2: component.PointsZzjKbqState
(*PointsPosition)(nil), // 3: component.PointsPosition
(*Points)(nil), // 4: component.Points
(*PointsFaultSb)(nil), // 5: component.PointsFaultSb
(*PointsFaultJc)(nil), // 6: component.PointsFaultJc
(*PointsFaultCiqd)(nil), // 7: component.PointsFaultCiqd
}
var file_component_points_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
1, // 0: component.PointsFaultSb.type:type_name -> component.PointsFaultSb.Type
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_component_points_proto_init() }
@ -557,7 +544,7 @@ func file_component_points_proto_init() {
}
}
file_component_points_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PointsFaultSB); i {
switch v := v.(*PointsFaultSb); i {
case 0:
return &v.state
case 1:
@ -569,30 +556,6 @@ func file_component_points_proto_init() {
}
}
file_component_points_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PointsFaultDwsb); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_component_points_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PointsFaultFwsb); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_component_points_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PointsFaultJc); i {
case 0:
return &v.state
@ -604,7 +567,7 @@ func file_component_points_proto_init() {
return nil
}
}
file_component_points_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
file_component_points_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PointsFaultCiqd); i {
case 0:
return &v.state
@ -622,8 +585,8 @@ func file_component_points_proto_init() {
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_component_points_proto_rawDesc,
NumEnums: 1,
NumMessages: 8,
NumEnums: 2,
NumMessages: 6,
NumExtensions: 0,
NumServices: 0,
},

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
@ -74,9 +74,8 @@ type PsdState struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Close bool `protobuf:"varint,1,opt,name=close,proto3" json:"close,omitempty"`
Obstacle bool `protobuf:"varint,2,opt,name=obstacle,proto3" json:"obstacle,omitempty"` //有障碍物
InterlockRelease bool `protobuf:"varint,3,opt,name=interlockRelease,proto3" json:"interlockRelease,omitempty"` //互锁解除
Close bool `protobuf:"varint,1,opt,name=close,proto3" json:"close,omitempty"`
Obstacle bool `protobuf:"varint,2,opt,name=obstacle,proto3" json:"obstacle,omitempty"`
}
func (x *PsdState) Reset() {
@ -125,13 +124,6 @@ func (x *PsdState) GetObstacle() bool {
return false
}
func (x *PsdState) GetInterlockRelease() bool {
if x != nil {
return x.InterlockRelease
}
return false
}
type Psd struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -175,11 +167,9 @@ type AsdState struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Gmdw bool `protobuf:"varint,1,opt,name=gmdw,proto3" json:"gmdw,omitempty"` //关门到位(实际位置)
Kmdw bool `protobuf:"varint,2,opt,name=kmdw,proto3" json:"kmdw,omitempty"` //开门到位(实际位置)
Mgj bool `protobuf:"varint,3,opt,name=mgj,proto3" json:"mgj,omitempty"` //门关继电器
Zaw bool `protobuf:"varint,4,opt,name=zaw,proto3" json:"zaw,omitempty"` //有障碍物
Force bool `protobuf:"varint,5,opt,name=force,proto3" json:"force,omitempty"` //强制开/关门
Gmdw bool `protobuf:"varint,1,opt,name=gmdw,proto3" json:"gmdw,omitempty"` //关门到位(实际位置)
Kmdw bool `protobuf:"varint,2,opt,name=kmdw,proto3" json:"kmdw,omitempty"` //开门到位(实际位置)
Mgj bool `protobuf:"varint,3,opt,name=mgj,proto3" json:"mgj,omitempty"` //门关继电器
}
func (x *AsdState) Reset() {
@ -235,46 +225,27 @@ func (x *AsdState) GetMgj() bool {
return false
}
func (x *AsdState) GetZaw() bool {
if x != nil {
return x.Zaw
}
return false
}
func (x *AsdState) GetForce() bool {
if x != nil {
return x.Force
}
return false
}
var File_component_psd_proto protoreflect.FileDescriptor
var file_component_psd_proto_rawDesc = []byte{
0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x70, 0x73, 0x64, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74,
0x22, 0x68, 0x0a, 0x08, 0x50, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05,
0x22, 0x3c, 0x0a, 0x08, 0x50, 0x73, 0x64, 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, 0x1a, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x74, 0x61, 0x63, 0x6c, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x74, 0x61, 0x63, 0x6c, 0x65, 0x12, 0x2a,
0x0a, 0x10, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61,
0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6c,
0x6f, 0x63, 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x22, 0x44, 0x0a, 0x03, 0x50, 0x73,
0x64, 0x22, 0x3d, 0x0a, 0x05, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x6e,
0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x73, 0x64,
0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x10, 0x01, 0x12, 0x11, 0x0a,
0x0d, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x4f, 0x70, 0x65, 0x6e, 0x10, 0x02,
0x22, 0x6c, 0x0a, 0x08, 0x41, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04,
0x67, 0x6d, 0x64, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x67, 0x6d, 0x64, 0x77,
0x12, 0x12, 0x0a, 0x04, 0x6b, 0x6d, 0x64, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04,
0x6b, 0x6d, 0x64, 0x77, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x67, 0x6a, 0x18, 0x03, 0x20, 0x01, 0x28,
0x08, 0x52, 0x03, 0x6d, 0x67, 0x6a, 0x12, 0x10, 0x0a, 0x03, 0x7a, 0x61, 0x77, 0x18, 0x04, 0x20,
0x01, 0x28, 0x08, 0x52, 0x03, 0x7a, 0x61, 0x77, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6f, 0x72, 0x63,
0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x42, 0x1d,
0x5a, 0x1b, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f,
0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x74, 0x61, 0x63, 0x6c, 0x65, 0x22, 0x44,
0x0a, 0x03, 0x50, 0x73, 0x64, 0x22, 0x3d, 0x0a, 0x05, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x0d,
0x0a, 0x09, 0x55, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x10, 0x00, 0x12, 0x12, 0x0a,
0x0e, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x10,
0x01, 0x12, 0x11, 0x0a, 0x0d, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x4f, 0x70,
0x65, 0x6e, 0x10, 0x02, 0x22, 0x44, 0x0a, 0x08, 0x41, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65,
0x12, 0x12, 0x0a, 0x04, 0x67, 0x6d, 0x64, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04,
0x67, 0x6d, 0x64, 0x77, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x6d, 0x64, 0x77, 0x18, 0x02, 0x20, 0x01,
0x28, 0x08, 0x52, 0x04, 0x6b, 0x6d, 0x64, 0x77, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x67, 0x6a, 0x18,
0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x6d, 0x67, 0x6a, 0x42, 0x1d, 0x5a, 0x1b, 0x2e, 0x2f,
0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e,
0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var (

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,14 +1,24 @@
package component
import "joylink.club/ecs"
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component/component_data"
"joylink.club/rtsssimulation/component/relation"
)
// 断相保护器标签
var DBQTag = ecs.NewTag()
var (
DBQTag = ecs.NewTag()
// 断相保护器模型数据引用组件类型
DbqModelRelaType = relation.DbqModelRelaType
// 断相保护器状态组件类型
DbqStateType = ecs.NewComponentType[component_data.DbqState]()
)
// 断相保护器控制请求组件
type DBQState struct {
Td bool // 是否通电true通电
Dzkg bool // 电子开关状态true: 开
}
// // 断相保护器控制请求组件
// type DBQState struct {
// Td bool // 是否通电true通电
// Dzkg bool // 电子开关状态true: 开
// }
var DBQStateType = ecs.NewComponentType[DBQState]()
// var DBQStateType = ecs.NewComponentType[DBQState]()

View File

@ -1,20 +1,11 @@
package component
import (
"unsafe"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component/component_data"
)
var (
RelayFaultForceType = ecs.NewComponentType[component_data.RelayFaultForce]()
// 电机状态组件类型
MotorStateType = ecs.NewComponentType[component_data.MotorState]()
)
func AddOrUpdateRelayFaultForce(entry *ecs.Entry, q bool) {
if entry.HasComponent(RelayFaultForceType) {
entry.SetComponent(RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q}))
} else {
entry.AddComponent(RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q}))
}
}

View File

@ -45,7 +45,6 @@ var AlarmDriveType = ecs.NewComponentType[AlarmDrive]()
// 挡位组件
type GearState struct {
//Bypass
Val int32
}

View File

@ -1,27 +1,105 @@
package component
import "joylink.club/ecs"
import (
"fmt"
"joylink.club/ecs"
)
//计轴设备,管理联锁集中站内的所有计轴区段
//计轴直接复位:计轴的轮对计数清零,区段转换为空闲状态
//计轴预复位:将计轴的轮对计数清零,但是区段不会立即变成空闲区段,而是处于一种“占用”状态,在压道车通过之后确认区段空闲且计轴正常后,区段转换为空闲状态
//
//当CI系统给计轴设备发送计轴直接复零/预复零命令时,连续发送一定时间(具体发送时间调试后确定)的复零/预复零命令。
//当RACRJORJT任意一个不为0时终止发送复零/预复零命令。
// PhysicalSectionState 物理区段
type PhysicalSectionState struct {
//true-占用false-出清
Occ bool
}
// AxlePhysicalSection 计轴物理区段
type AxlePhysicalSection struct {
//计轴区段内车轴数
Count int
//记录Count变化波形
countPulse uint8
}
type AxleDeviceRuntime struct {
//true-计轴复位反馈,表示计轴设备已收到CI系统发送的直接复零/预复零命令。
Rac bool
//true-运营原因拒绝计轴复位,如区段空闲时下发复位命令;或车轮压住传感器时收到复位命令。
Rjo bool
//true-技术原因拒绝计轴复位,主要指计轴相关设备故障时收到复位命令如车轮传感器的导线断开、AEB之间的通信故障等
Rjt bool
//true-计轴直接复位
//计轴的轮对计数清零,区段转换为空闲状态
Drst bool
//true-计轴预复位
//将计轴的轮对计数清零,但是区段不会立即变成空闲区段,而是处于一种“占用”状态,在压道车通过之后确认区段空闲且计轴正常后,区段转换为空闲状态
Pdrst bool
//true-计轴系统正在执行直接预复位操作
DoingPdrst bool
}
func NewAxleDeviceRuntime() *AxleDeviceRuntime {
return &AxleDeviceRuntime{}
}
// AxleManageDevice 计轴管理设备
type AxleManageDevice struct {
CentralizedStation string //所属集中站
Adrs map[string]*AxleDeviceRuntime //key-sectionId
}
func (d *AxleManageDevice) FindAdr(sectionId string) *AxleDeviceRuntime {
return d.Adrs[sectionId]
}
func NewAxleManageDevice(centralizedStation string) *AxleManageDevice {
return &AxleManageDevice{CentralizedStation: centralizedStation, Adrs: make(map[string]*AxleDeviceRuntime)}
}
var (
PhysicalSectionTag = ecs.NewTag()
PhysicalSectionCircuitType = ecs.NewComponentType[PhysicalSectionCircuit]()
PhysicalSectionManagerType = ecs.NewComponentType[PhysicalSectionManager]()
PhysicalSectionStateType = ecs.NewComponentType[PhysicalSectionState]()
AxlePhysicalSectionType = ecs.NewComponentType[AxlePhysicalSection]()
AxleSectionFaultTag = ecs.NewTag()
AxleManageDeviceType = ecs.NewComponentType[AxleManageDevice]()
)
var PhysicalSectionForceOccupied = ecs.NewTag() //区段强制占用(故障占用)
// PhysicalSectionManager 计轴管理器。我自己起的名字,计轴逻辑的载体
type PhysicalSectionManager struct {
Count int //轴数(简化版)。目前此轴数计数只与区段上有无列车有关,故障占用等状态不会影响此计数
Occupied bool //占用
/////////////////////////////AxlePhysicalSection/////////////////////////////////
PDRST bool //预复位
//RAC bool //计轴复位反馈。主要指计轴设备发送给CI系统的直接复零/预复零命令反馈表示计轴设备已收到CI系统发送的直接复零/预复零命令。
//RJO bool //运营原因拒绝直接复位/预复位。如区段空闲时下发复位命令;或车轮压住传感器时收到复位命令。
//RJT bool //技术原因拒绝直接复位/预复位。主要指计轴相关设备故障时收到复位命令如车轮传感器的导线断开、AEB之间的通信故障等。
func NewAxlePhysicalSection() *AxlePhysicalSection {
return &AxlePhysicalSection{Count: 0, countPulse: 0}
}
func (c *AxlePhysicalSection) UpdateCount(count int) {
cp := to1(c.Count)
np := to1(count)
//
if cp != np {
c.countPulse <<= 1
if np > 0 {
c.countPulse |= np
}
}
c.Count = count
}
func (c *AxlePhysicalSection) ResetCountPulse() {
c.countPulse = 0x00
}
func (c *AxlePhysicalSection) ShowCountWave() string {
return fmt.Sprintf("%08b", c.countPulse)
}
// PhysicalSectionCircuit 计轴区段电路
type PhysicalSectionCircuit struct {
GJ *ecs.Entry
// IsCount010Pulse true-车进入计轴区段后出清计轴区段
func (c *AxlePhysicalSection) IsCount010Pulse() bool {
return c.countPulse&0x01 == 0 && c.countPulse&0x02 > 0 && c.countPulse&0x04 == 0
}
// 归1
func to1(c int) uint8 {
if c > 0 {
return 0x01
} else {
return 0x00
}
}

View File

@ -20,3 +20,28 @@ var (
// 道岔位置组件类型
PointsPositionType = ecs.NewComponentType[component_data.PointsPosition]()
)
var (
// 失表故障
PointsFaultSbType = ecs.NewComponentType[PointsFaultSb]()
// 挤岔故障
PointsFaultJcType = ecs.NewComponentType[component_data.PointsFaultJc]()
// 联锁无法驱动故障
PointsFaultCiqdType = ecs.NewComponentType[component_data.PointsFaultCiqd]()
)
type PointsFaultSb struct {
component_data.PointsFaultSb
}
func (f *PointsFaultSb) IsAllSB() bool {
return f.Type == component_data.PointsFaultSb_ALL
}
func (f *PointsFaultSb) IsDW() bool {
return f.Type == component_data.PointsFaultSb_DW
}
func (f *PointsFaultSb) IsFW() bool {
return f.Type == component_data.PointsFaultSb_FW
}

View File

@ -79,25 +79,15 @@ type PlatformMkxCircuit struct {
PCBJ *ecs.Entry
POBJ *ecs.Entry
PABJ *ecs.Entry
WRZFJ *ecs.Entry
QKQRJ *ecs.Entry
}
var MkxType = ecs.NewComponentType[Mkx]()
type Mkx struct {
PCB *ecs.Entry
PCBPL *ecs.Entry
POB *ecs.Entry
POBPL *ecs.Entry
PAB *ecs.Entry
PABPL *ecs.Entry
WRZF *ecs.Entry
WRZFPL *ecs.Entry
QKQR *ecs.Entry
QKQRPL *ecs.Entry
MPL *ecs.Entry
JXTCPL *ecs.Entry
PCB *ecs.Entry
POB *ecs.Entry
PAB *ecs.Entry
MPL *ecs.Entry
}
var PscType = ecs.NewComponentType[Psc]()
@ -107,8 +97,14 @@ type Psc struct {
//InterlockKM8 bool
InterlockKmGroup map[int32]bool //开门编组。k-编组 v-设置开门
InterlockGM bool
InterlockMPL bool
//MkxKM bool 门控箱控制继电器->联锁采集继电器状态->联锁驱动屏蔽门控制继电器
//MkxGM bool
//MkxPL bool
MkxKM bool
MkxGM bool
MkxPL bool
QDTC bool
TZTC bool
//ZAW bool
JXTCPL bool
}

24
component/relation/ci.go Normal file
View File

@ -0,0 +1,24 @@
package relation
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/modelrepo/model"
)
var (
CiQckModelRelaType = ecs.NewComponentType[CiQckModelRela]()
)
type CiQckModelRela struct {
// 所属集中站
Station model.EcStation
// 驱采码表
M model.CiQcb
}
func NewCiQckModelRela(station model.EcStation) *CiQckModelRela {
return &CiQckModelRela{
Station: station,
M: station.GetCiQcb(),
}
}

View File

@ -0,0 +1,22 @@
package relation
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/modelrepo/model"
)
var (
// 继电器模型数据引用组件类型
RelayModelRelaType = ecs.NewComponentType[RelayModelRela]()
// 断相保护器模型数据引用组件类型
DbqModelRelaType = ecs.NewComponentType[DbqModelRela]()
)
// 道岔模型数据引用
type RelayModelRela struct {
M model.Relay
}
type DbqModelRela struct {
M model.Dbq
}

View File

@ -85,6 +85,9 @@ type Zdj9TwoElectronic struct {
TDFJ2_DBQ *ecs.Entry // 断相保护器
TDFJ2_DBJ *ecs.Entry // 定位表示继电器
TDFJ2_FBJ *ecs.Entry // 反位表示继电器
// 联锁驱采卡
CiQck *ecs.Entry // 联锁驱采卡
}
// 检查空引用,返回空引用字段名称
@ -156,6 +159,10 @@ func (te *Zdj9TwoElectronic) CheckNilReference() []string {
if te.TDFJ2_FBJ == nil {
nils = append(nils, "TDFJ2_FBJ")
}
if te.CiQck == nil {
nils = append(nils, "CiQck")
}
return nils
}

View File

@ -1,31 +1,43 @@
package component
import "joylink.club/ecs"
import (
"unsafe"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component/component_data"
"joylink.club/rtsssimulation/component/relation"
)
// 标签
var (
// 继电器
RelayTag = ecs.NewTag()
// 无极继电器
WjRelayTag = ecs.NewTag()
// // 偏极继电器
// PjRelayTag = ecs.NewTag()
// 有极
YjRelayTag = ecs.NewTag()
// 缓放继电器
HfRelayTag = ecs.NewTag()
// 继电器模型数据关系组件类型
RelayModelRelaType = relation.RelayModelRelaType
// 继电器状态组件
RelayStateType = ecs.NewComponentType[component_data.RelayState]()
// 继电器故障强制组件
RelayFaultForceType = ecs.NewComponentType[component_data.RelayFaultForce]()
)
// 无极继电器和偏极继电器稳态为落下,也就是后接点(8组采集接点中的1,3接点1为中接点)吸气为前接点1,2接点
// 有极继电器是定位反位双稳态(有永久磁钢),前接点为定位,后接点为反位
// 有极继电器对于道岔中的2DQJ励磁接点12接通为反位34接通为定位
// 定义继电器状态时false表示落下/反位/后接点true表示吸起/定位/前接点
// 缓动继电器指从通电或断电起至接点转接止所需时间在0.3s以上的继电器。可分为缓放继电器(如无极缓放继电器等)和缓吸继电器(如热力继电器和时间继电器等)。
// 偏极继电器:只有通过规定方向的电流时,才吸起
// 继电器驱动组件
type RelayDrive struct {
Td bool // 是否通电
Xq bool // 是否驱动到吸起位置true驱动吸起,false:驱动落下(此状态只对有极继电器有效)
func AddOrUpdateRelayFaultForce(entry *ecs.Entry, q bool) {
if entry.HasComponent(RelayFaultForceType) {
entry.SetComponent(RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q}))
} else {
entry.AddComponent(RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q}))
}
}
var RelayDriveType = ecs.NewComponentType[RelayDrive]()
// // 无极继电器和偏极继电器稳态为落下,也就是后接点(8组采集接点中的1,3接点1为中接点)吸气为前接点1,2接点
// // 有极继电器是定位反位双稳态(有永久磁钢),前接点为定位,后接点为反位
// // 有极继电器对于道岔中的2DQJ励磁接点12接通为反位34接通为定位
// // 定义继电器状态时false表示落下/反位/后接点true表示吸起/定位/前接点
// // 缓动继电器指从通电或断电起至接点转接止所需时间在0.3s以上的继电器。可分为缓放继电器(如无极缓放继电器等)和缓吸继电器(如热力继电器和时间继电器等)。
// // 偏极继电器:只有通过规定方向的电流时,才吸起
// // 继电器驱动组件
// type RelayDrive struct {
// Td bool // 是否通电
// Xq bool // 是否驱动到吸起位置true驱动吸起,false:驱动落下(此状态只对有极继电器有效)
// }
// var RelayDriveType = ecs.NewComponentType[RelayDrive]()

View File

@ -12,24 +12,37 @@ var EntityUidIndexType = ecs.NewComponentType[EntityUidIndex]()
// 只索引具有uid且不会销毁的实体
type EntityUidIndex struct {
mu sync.RWMutex
entityMap map[string]ecs.Entity
entityMap map[string]*ecs.Entry
}
func (idx *EntityUidIndex) Add(uid string, entity ecs.Entity) {
func (idx *EntityUidIndex) Add(uid string, entity *ecs.Entry) {
idx.mu.Lock()
defer idx.mu.Unlock()
idx.entityMap[uid] = entity
}
func (idx *EntityUidIndex) Get(uid string) ecs.Entity {
func (idx *EntityUidIndex) Get(uid string) *ecs.Entry {
idx.mu.RLock()
defer idx.mu.RUnlock()
return idx.entityMap[uid]
}
func (idx *EntityUidIndex) Has(uid string) bool {
idx.mu.RLock()
defer idx.mu.RUnlock()
_, ok := idx.entityMap[uid]
return ok
}
func (idx *EntityUidIndex) Remove(uid string) {
idx.mu.Lock()
defer idx.mu.Unlock()
delete(idx.entityMap, uid)
}
func loadUidEntityIndex(w ecs.World) {
entry := w.Entry(w.Create(EntityUidIndexType))
EntityUidIndexType.Set(entry, &EntityUidIndex{
entityMap: make(map[string]ecs.Entity, 512),
entityMap: make(map[string]*ecs.Entry, 512),
})
}

View File

@ -13,9 +13,6 @@ func LoadSingletons(w ecs.World, r modelrepo.Repo) {
loadUidEntityIndex(w)
}
type Singleton struct {
}
var worldRepoQuery = ecs.NewQuery(filter.Contains(WorldRepoType))
var worldTimeQuery = ecs.NewQuery(filter.Contains(WorldTimeType))
var uidEntityIndexQuery = ecs.NewQuery(filter.Contains(EntityUidIndexType))
@ -23,7 +20,7 @@ var uidEntityIndexQuery = ecs.NewQuery(filter.Contains(EntityUidIndexType))
func GetWorldTime(w ecs.World) *WorldTime {
entry, _ := worldTimeQuery.First(w)
if entry == nil {
panic("不存在世界时间组件")
panic("不存在世界时间单例组件")
}
return WorldTimeType.Get(entry)
}
@ -31,7 +28,7 @@ func GetWorldTime(w ecs.World) *WorldTime {
func GetWorldRepo(w ecs.World) *WorldRepo {
entry, _ := worldRepoQuery.First(w)
if entry == nil {
panic("不存在世界数据组件")
panic("不存在世界数据单例组件")
}
return WorldRepoType.Get(entry)
}
@ -39,7 +36,7 @@ func GetWorldRepo(w ecs.World) *WorldRepo {
func GetEntityUidIndex(w ecs.World) *EntityUidIndex {
entry, _ := uidEntityIndexQuery.First(w)
if entry == nil {
panic("不存在UidEntityIndex组件")
panic("不存在实体Uid索引单例组件")
}
return EntityUidIndexType.Get(entry)
}

View File

@ -1,11 +0,0 @@
package component
import "joylink.club/ecs"
var (
TrackCircuitType = ecs.NewComponentType[TrackCircuit]()
)
type TrackCircuit struct {
GJ *ecs.Entry
}

View File

@ -12,7 +12,6 @@ type TrainPositionInfo struct {
Up bool
//列车长度 mm
Len int64
//列车所在轨道link
HeadLink string
//列车所在link偏移量mm
@ -21,15 +20,6 @@ type TrainPositionInfo struct {
TailLink string
//列车所在link偏移量mm
TailLinkOffset int64
//车头所在物理区段
HeadSectionId string
//车头所在物理区段偏移量
HeadSectionOffset uint32
//车尾所在物理区段
TailSectionId string
//车尾所在物理区段偏移量
TailSectionOffset uint32
}
func (t *TrainPositionInfo) ToString() string {

View File

@ -1,12 +1,7 @@
package component
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component/component_proto"
)
// 道岔标签
var TurnoutTag = ecs.NewTag()
// var TurnoutTag = ecs.NewTag()
// // 道岔的实际位置
// type TurnoutPosition struct {
@ -17,273 +12,273 @@ var TurnoutTag = ecs.NewTag()
// Fb bool // 反位表示(表示位置)
// }
// 实际道岔的实际位置组件类型
var TurnoutPositionType = ecs.NewComponentType[component_proto.TurnoutPosition]()
// // 实际道岔的实际位置组件类型
// var TurnoutPositionType = ecs.NewComponentType[component_proto.TurnoutPosition]()
var (
// 失表故障
TurnoutFaultSbType = ecs.NewComponentType[component_proto.TurnoutFaultSB]()
// 定位失表故障
TurnoutFaultDwsbType = ecs.NewComponentType[component_proto.TurnoutFaultDwsb]()
// 反位失表故障
TurnoutFaultFwsbType = ecs.NewComponentType[component_proto.TurnoutFaultFwsb]()
// 挤岔故障类型
TurnoutFaultJcType = ecs.NewComponentType[component_proto.TurnoutFaultJc]()
// 联锁无法驱动故障
TurnoutFaultCiqdType = ecs.NewComponentType[component_proto.TurnoutFaultCiqd]()
)
// var (
// // 失表故障
// TurnoutFaultSbType = ecs.NewComponentType[component_proto.TurnoutFaultSB]()
// // 定位失表故障
// TurnoutFaultDwsbType = ecs.NewComponentType[component_proto.TurnoutFaultDwsb]()
// // 反位失表故障
// TurnoutFaultFwsbType = ecs.NewComponentType[component_proto.TurnoutFaultFwsb]()
// // 挤岔故障类型
// TurnoutFaultJcType = ecs.NewComponentType[component_proto.TurnoutFaultJc]()
// // 联锁无法驱动故障
// TurnoutFaultCiqdType = ecs.NewComponentType[component_proto.TurnoutFaultCiqd]()
// )
// 根据道岔故障枚举获取道岔故障组件类型
func GetTurnoutFaultType(fault component_proto.Turnout_Fault) ecs.IComponentType {
switch fault {
case component_proto.Turnout_SB:
return TurnoutFaultSbType
case component_proto.Turnout_DWSB:
return TurnoutFaultDwsbType
case component_proto.Turnout_FWSB:
return TurnoutFaultFwsbType
case component_proto.Turnout_JC:
return TurnoutFaultJcType
}
return nil
}
// ZDJ9单机电路元器件
type Zdj9OneElectronic struct {
TDC_YCJ *ecs.Entry // 运行操作继电器
TDC_DCJ *ecs.Entry // 定操继电器
TDC_FCJ *ecs.Entry // 反操继电器
TDFJ_BB *ecs.Entry // 道岔表示变压器
TDFJ_1DQJ *ecs.Entry // 一启动继电器
TDFJ_BHJ *ecs.Entry // 保护继电器
TDFJ_2DQJ *ecs.Entry // 二启动继电器
TDFJ_1DQJF *ecs.Entry // 一启动复示继电器
TDFJ_DBQ *ecs.Entry // 断相保护器
TDFJ_DBJ *ecs.Entry // 定位表示继电器
TDFJ_FBJ *ecs.Entry // 反位表示继电器
TDFJ_R1 *ecs.Entry // 电阻
}
// ZDJ9单机电路元器件组件类型
var Zdj9OneElectronicType = ecs.NewComponentType[Zdj9OneElectronic]()
// ZDJ9双机电路元器件
type Zdj9TwoElectronic struct {
TDC_DCJ *ecs.Entry // 定操继电器
TDC_FCJ *ecs.Entry // 反操继电器
TDC_YCJ *ecs.Entry // 允许操作继电器
TDC_ZDBJ *ecs.Entry // 总定表继电器
TDC_ZFBJ *ecs.Entry // 总反表继电器
// 一机
TDFJ1_1DQJ *ecs.Entry // 一启动继电器
TDFJ1_BHJ *ecs.Entry // 保护继电器
TDFJ1_2DQJ *ecs.Entry // 二启动继电器
TDFJ1_1DQJF *ecs.Entry // 一启动复示继电器
TDFJ1_DBQ *ecs.Entry // 断相保护器
TDFJ1_DBJ *ecs.Entry // 定位表示继电器
TDFJ1_FBJ *ecs.Entry // 反位表示继电器
TDFJ1_QDJ *ecs.Entry // 切断继电器
TDFJ1_ZBHJ *ecs.Entry // 总保护继电器
TDFJ1_QDJ_Remain int // 切断继电器保持电路保持剩余时间
// 二机
TDFJ2_1DQJ *ecs.Entry // 一启动继电器
TDFJ2_BHJ *ecs.Entry // 保护继电器
TDFJ2_2DQJ *ecs.Entry // 二启动继电器
TDFJ2_1DQJF *ecs.Entry // 一启动复示继电器
TDFJ2_DBQ *ecs.Entry // 断相保护器
TDFJ2_DBJ *ecs.Entry // 定位表示继电器
TDFJ2_FBJ *ecs.Entry // 反位表示继电器
}
// 检查空引用,返回空引用字段名称
func (te *Zdj9TwoElectronic) CheckNilReference() []string {
var nils []string = make([]string, 0)
if te.TDC_DCJ == nil {
nils = append(nils, "TDC_DCJ")
}
if te.TDC_FCJ == nil {
nils = append(nils, "TDC_FCJ")
}
if te.TDC_YCJ == nil {
nils = append(nils, "TDC_YCJ")
}
if te.TDC_ZDBJ == nil {
nils = append(nils, "TDC_ZDBJ")
}
if te.TDC_ZFBJ == nil {
nils = append(nils, "TDC_ZFBJ")
}
// 一机
if te.TDFJ1_1DQJ == nil {
nils = append(nils, "TDFJ1_1DQJ")
}
if te.TDFJ1_BHJ == nil {
nils = append(nils, "TDFJ1_BHJ")
}
if te.TDFJ1_2DQJ == nil {
nils = append(nils, "TDFJ1_2DQJ")
}
if te.TDFJ1_1DQJF == nil {
nils = append(nils, "TDFJ1_1DQJF")
}
if te.TDFJ1_DBQ == nil {
nils = append(nils, "TDFJ1_DBQ")
}
if te.TDFJ1_DBJ == nil {
nils = append(nils, "TDFJ1_DBJ")
}
if te.TDFJ1_FBJ == nil {
nils = append(nils, "TDFJ1_FBJ")
}
if te.TDFJ1_QDJ == nil {
nils = append(nils, "TDFJ1_QDJ")
}
if te.TDFJ1_ZBHJ == nil {
nils = append(nils, "TDFJ1_ZBHJ")
}
// 二机
if te.TDFJ2_1DQJ == nil {
nils = append(nils, "TDFJ2_1DQJ")
}
if te.TDFJ2_BHJ == nil {
nils = append(nils, "TDFJ2_BHJ")
}
if te.TDFJ2_2DQJ == nil {
nils = append(nils, "TDFJ2_2DQJ")
}
if te.TDFJ2_1DQJF == nil {
nils = append(nils, "TDFJ2_1DQJF")
}
if te.TDFJ2_DBQ == nil {
nils = append(nils, "TDFJ2_DBQ")
}
if te.TDFJ2_DBJ == nil {
nils = append(nils, "TDFJ2_DBJ")
}
if te.TDFJ2_FBJ == nil {
nils = append(nils, "TDFJ2_FBJ")
}
return nils
}
// 是否有空引用
func (te *Zdj9TwoElectronic) HasNilReference() bool {
nils := te.CheckNilReference()
return len(nils) > 0
}
// // ZDJ9双机驱动状态组件
// type Zdj9TwoDrive struct {
// // 定操继电器驱动
// DCJ bool
// // 反操继电器驱动
// FCJ bool
// // 允操继电器驱动
// YCJ bool
// // 根据道岔故障枚举获取道岔故障组件类型
// func GetTurnoutFaultType(fault component_proto.Turnout_Fault) ecs.IComponentType {
// switch fault {
// case component_proto.Turnout_SB:
// return TurnoutFaultSbType
// case component_proto.Turnout_DWSB:
// return TurnoutFaultDwsbType
// case component_proto.Turnout_FWSB:
// return TurnoutFaultFwsbType
// case component_proto.Turnout_JC:
// return TurnoutFaultJcType
// }
// return nil
// }
// // ZDJ9双机采集状态组件
// type Zdj9TwoCollect struct {
// // 总定表继电器吸起采集
// TDC_ZDBJ_XQ bool
// // 总反表继电器吸起采集
// TDC_ZFBJ_XQ bool
// // 允操继电器吸起采集
// TDC_YCJ_XQ bool
// // 总定表继电器和总反表继电器都落下采集
// TDC_ZDBJ_ZFBJ_LX bool
// // 1机定表继电器吸起采集
// TDFJ1_DBJ_XQ bool
// // 1机反表继电器吸起采集
// TDFJ1_FBJ_XQ bool
// // 2机定表继电器吸起采集
// TDFJ2_DBJ_XQ bool
// // 2机反表继电器吸起采集
// TDFJ2_FBJ_XQ bool
// // ZDJ9单机电路元器件
// type Zdj9OneElectronic struct {
// TDC_YCJ *ecs.Entry // 运行操作继电器
// TDC_DCJ *ecs.Entry // 定操继电器
// TDC_FCJ *ecs.Entry // 反操继电器
// TDFJ_BB *ecs.Entry // 道岔表示变压器
// TDFJ_1DQJ *ecs.Entry // 一启动继电器
// TDFJ_BHJ *ecs.Entry // 保护继电器
// TDFJ_2DQJ *ecs.Entry // 二启动继电器
// TDFJ_1DQJF *ecs.Entry // 一启动复示继电器
// TDFJ_DBQ *ecs.Entry // 断相保护器
// TDFJ_DBJ *ecs.Entry // 定位表示继电器
// TDFJ_FBJ *ecs.Entry // 反位表示继电器
// TDFJ_R1 *ecs.Entry // 电阻
// }
var (
// ZDJ9双机电路元器件组件类型
// Zdj9TwoElectronicType = ecs.NewComponentType[Zdj9TwoElectronic]()
// // ZDJ9双机驱动状态组件类型
// Zdj9TwoDriveType = ecs.NewComponentType[Zdj9TwoDrive]()
// // ZDJ9双机采集状态组件类型
// Zdj9TwoCollectType = ecs.NewComponentType[Zdj9TwoCollect]()
)
// // ZDJ9单机电路元器件组件类型
// var Zdj9OneElectronicType = ecs.NewComponentType[Zdj9OneElectronic]()
// 转辙机状态
type ZzjState struct {
// 自动开闭器接点位置默认定位接通1/3排反位接通2/4排
// 由定位转反位1DQJ和1DQJF励磁吸起2DQJ在反位——即落下三相电路导通电机开始反转转辙机将第3排接点接通第4排到位锁闭后转辙机的自动开闭器拉簧将第1排接点拉到第2排接点到2排后三相电路断路
// 由反位转定位1DQJ和1DQJF励磁吸起2DQJ在定位——即吸起三相电路导通电机开始正转转辙机将第2排接点接通第1排到位锁闭后转辙机的自动开闭器拉簧将第4排接点拉到第3排接点到3排后三相电路断路
JD12 bool // 接点在1/2排的位置false-接点在1排true-接点在2排
JD34 bool // 接点在3/4排的位置false-接点在3排true-接点在4排
// // ZDJ9双机电路元器件
// type Zdj9TwoElectronic struct {
// TDC_DCJ *ecs.Entry // 定操继电器
// TDC_FCJ *ecs.Entry // 反操继电器
// TDC_YCJ *ecs.Entry // 允许操作继电器
// TDC_ZDBJ *ecs.Entry // 总定表继电器
// TDC_ZFBJ *ecs.Entry // 总反表继电器
Td bool // 是否通电
Dw bool // 是否转动到定位
}
// // 一机
// TDFJ1_1DQJ *ecs.Entry // 一启动继电器
// TDFJ1_BHJ *ecs.Entry // 保护继电器
// TDFJ1_2DQJ *ecs.Entry // 二启动继电器
// TDFJ1_1DQJF *ecs.Entry // 一启动复示继电器
// TDFJ1_DBQ *ecs.Entry // 断相保护器
// TDFJ1_DBJ *ecs.Entry // 定位表示继电器
// TDFJ1_FBJ *ecs.Entry // 反位表示继电器
// TDFJ1_QDJ *ecs.Entry // 切断继电器
// TDFJ1_ZBHJ *ecs.Entry // 总保护继电器
// 转辙机状态
var ZzjStateType = ecs.NewComponentType[ZzjState]()
// TDFJ1_QDJ_Remain int // 切断继电器保持电路保持剩余时间
// 道岔的转辙机引用
type TurnoutZzj struct {
ZzjList []*ecs.Entry
}
// // 二机
// TDFJ2_1DQJ *ecs.Entry // 一启动继电器
// TDFJ2_BHJ *ecs.Entry // 保护继电器
// TDFJ2_2DQJ *ecs.Entry // 二启动继电器
// TDFJ2_1DQJF *ecs.Entry // 一启动复示继电器
// TDFJ2_DBQ *ecs.Entry // 断相保护器
// TDFJ2_DBJ *ecs.Entry // 定位表示继电器
// TDFJ2_FBJ *ecs.Entry // 反位表示继电器
// }
func (tz *TurnoutZzj) GetZzj1() *ecs.Entry {
len := len(tz.ZzjList)
if len > 0 {
return tz.ZzjList[0]
}
panic("道岔没有转辙机一")
}
// // 检查空引用,返回空引用字段名称
// func (te *Zdj9TwoElectronic) CheckNilReference() []string {
// var nils []string = make([]string, 0)
// if te.TDC_DCJ == nil {
// nils = append(nils, "TDC_DCJ")
// }
// if te.TDC_FCJ == nil {
// nils = append(nils, "TDC_FCJ")
// }
// if te.TDC_YCJ == nil {
// nils = append(nils, "TDC_YCJ")
// }
// if te.TDC_ZDBJ == nil {
// nils = append(nils, "TDC_ZDBJ")
// }
// if te.TDC_ZFBJ == nil {
// nils = append(nils, "TDC_ZFBJ")
// }
// // 一机
// if te.TDFJ1_1DQJ == nil {
// nils = append(nils, "TDFJ1_1DQJ")
// }
// if te.TDFJ1_BHJ == nil {
// nils = append(nils, "TDFJ1_BHJ")
// }
// if te.TDFJ1_2DQJ == nil {
// nils = append(nils, "TDFJ1_2DQJ")
// }
// if te.TDFJ1_1DQJF == nil {
// nils = append(nils, "TDFJ1_1DQJF")
// }
// if te.TDFJ1_DBQ == nil {
// nils = append(nils, "TDFJ1_DBQ")
// }
// if te.TDFJ1_DBJ == nil {
// nils = append(nils, "TDFJ1_DBJ")
// }
// if te.TDFJ1_FBJ == nil {
// nils = append(nils, "TDFJ1_FBJ")
// }
// if te.TDFJ1_QDJ == nil {
// nils = append(nils, "TDFJ1_QDJ")
// }
// if te.TDFJ1_ZBHJ == nil {
// nils = append(nils, "TDFJ1_ZBHJ")
// }
func (tz *TurnoutZzj) GetZzj2() *ecs.Entry {
len := len(tz.ZzjList)
if len > 1 {
return tz.ZzjList[1]
}
panic("道岔没有转辙机二")
}
// // 二机
// if te.TDFJ2_1DQJ == nil {
// nils = append(nils, "TDFJ2_1DQJ")
// }
// if te.TDFJ2_BHJ == nil {
// nils = append(nils, "TDFJ2_BHJ")
// }
// if te.TDFJ2_2DQJ == nil {
// nils = append(nils, "TDFJ2_2DQJ")
// }
// if te.TDFJ2_1DQJF == nil {
// nils = append(nils, "TDFJ2_1DQJF")
// }
// if te.TDFJ2_DBQ == nil {
// nils = append(nils, "TDFJ2_DBQ")
// }
// if te.TDFJ2_DBJ == nil {
// nils = append(nils, "TDFJ2_DBJ")
// }
// if te.TDFJ2_FBJ == nil {
// nils = append(nils, "TDFJ2_FBJ")
// }
// return nils
// }
var TurnoutZzjType = ecs.NewComponentType[TurnoutZzj]()
// // 是否有空引用
// func (te *Zdj9TwoElectronic) HasNilReference() bool {
// nils := te.CheckNilReference()
// return len(nils) > 0
// }
func GetTurnoutZzj1(entry *ecs.Entry) *ecs.Entry {
if entry.HasComponent(TurnoutZzjType) {
zzjs := TurnoutZzjType.Get(entry)
return zzjs.GetZzj1()
}
panic("道岔没有转辙机引用组件")
}
// // // ZDJ9双机驱动状态组件
// // type Zdj9TwoDrive struct {
// // // 定操继电器驱动
// // DCJ bool
// // // 反操继电器驱动
// // FCJ bool
// // // 允操继电器驱动
// // YCJ bool
// // }
func GetTurnoutZzj1State(entry *ecs.Entry) *ZzjState {
if entry.HasComponent(TurnoutZzjType) {
zzjs := TurnoutZzjType.Get(entry)
zzj := zzjs.GetZzj1()
return ZzjStateType.Get(zzj)
}
panic("道岔没有转辙机引用组件")
}
// // // ZDJ9双机采集状态组件
// // type Zdj9TwoCollect struct {
// // // 总定表继电器吸起采集
// // TDC_ZDBJ_XQ bool
// // // 总反表继电器吸起采集
// // TDC_ZFBJ_XQ bool
// // // 允操继电器吸起采集
// // TDC_YCJ_XQ bool
// // // 总定表继电器和总反表继电器都落下采集
// // TDC_ZDBJ_ZFBJ_LX bool
// // // 1机定表继电器吸起采集
// // TDFJ1_DBJ_XQ bool
// // // 1机反表继电器吸起采集
// // TDFJ1_FBJ_XQ bool
// // // 2机定表继电器吸起采集
// // TDFJ2_DBJ_XQ bool
// // // 2机反表继电器吸起采集
// // TDFJ2_FBJ_XQ bool
// // }
func GetTurnoutZzj2(entry *ecs.Entry) *ecs.Entry {
if entry.HasComponent(TurnoutZzjType) {
zzjs := TurnoutZzjType.Get(entry)
return zzjs.GetZzj2()
}
panic("道岔没有转辙机引用组件")
}
// var (
// // ZDJ9双机电路元器件组件类型
// // Zdj9TwoElectronicType = ecs.NewComponentType[Zdj9TwoElectronic]()
// // // ZDJ9双机驱动状态组件类型
// // Zdj9TwoDriveType = ecs.NewComponentType[Zdj9TwoDrive]()
// // // ZDJ9双机采集状态组件类型
// // Zdj9TwoCollectType = ecs.NewComponentType[Zdj9TwoCollect]()
// )
func GetTurnoutZzj2State(entry *ecs.Entry) *ZzjState {
if entry.HasComponent(TurnoutZzjType) {
zzjs := TurnoutZzjType.Get(entry)
zzj := zzjs.GetZzj2()
return ZzjStateType.Get(zzj)
}
panic("道岔没有转辙机引用组件")
}
// // 转辙机状态
// type ZzjState struct {
// // 自动开闭器接点位置默认定位接通1/3排反位接通2/4排
// // 由定位转反位1DQJ和1DQJF励磁吸起2DQJ在反位——即落下三相电路导通电机开始反转转辙机将第3排接点接通第4排到位锁闭后转辙机的自动开闭器拉簧将第1排接点拉到第2排接点到2排后三相电路断路
// // 由反位转定位1DQJ和1DQJF励磁吸起2DQJ在定位——即吸起三相电路导通电机开始正转转辙机将第2排接点接通第1排到位锁闭后转辙机的自动开闭器拉簧将第4排接点拉到第3排接点到3排后三相电路断路
// JD12 bool // 接点在1/2排的位置false-接点在1排true-接点在2排
// JD34 bool // 接点在3/4排的位置false-接点在3排true-接点在4排
// Td bool // 是否通电
// Dw bool // 是否转动到定位
// }
// // 转辙机状态
// var ZzjStateType = ecs.NewComponentType[ZzjState]()
// // 道岔的转辙机引用
// type TurnoutZzj struct {
// ZzjList []*ecs.Entry
// }
// func (tz *TurnoutZzj) GetZzj1() *ecs.Entry {
// len := len(tz.ZzjList)
// if len > 0 {
// return tz.ZzjList[0]
// }
// panic("道岔没有转辙机一")
// }
// func (tz *TurnoutZzj) GetZzj2() *ecs.Entry {
// len := len(tz.ZzjList)
// if len > 1 {
// return tz.ZzjList[1]
// }
// panic("道岔没有转辙机二")
// }
// var TurnoutZzjType = ecs.NewComponentType[TurnoutZzj]()
// func GetTurnoutZzj1(entry *ecs.Entry) *ecs.Entry {
// if entry.HasComponent(TurnoutZzjType) {
// zzjs := TurnoutZzjType.Get(entry)
// return zzjs.GetZzj1()
// }
// panic("道岔没有转辙机引用组件")
// }
// func GetTurnoutZzj1State(entry *ecs.Entry) *ZzjState {
// if entry.HasComponent(TurnoutZzjType) {
// zzjs := TurnoutZzjType.Get(entry)
// zzj := zzjs.GetZzj1()
// return ZzjStateType.Get(zzj)
// }
// panic("道岔没有转辙机引用组件")
// }
// func GetTurnoutZzj2(entry *ecs.Entry) *ecs.Entry {
// if entry.HasComponent(TurnoutZzjType) {
// zzjs := TurnoutZzjType.Get(entry)
// return zzjs.GetZzj2()
// }
// panic("道岔没有转辙机引用组件")
// }
// func GetTurnoutZzj2State(entry *ecs.Entry) *ZzjState {
// if entry.HasComponent(TurnoutZzjType) {
// zzjs := TurnoutZzjType.Get(entry)
// zzj := zzjs.GetZzj2()
// return ZzjStateType.Get(zzj)
// }
// panic("道岔没有转辙机引用组件")
// }

View File

@ -1,23 +0,0 @@
package component
import (
"joylink.club/ecs"
)
var (
XcjTag = ecs.NewTag()
XcjFaultTag = ecs.NewTag()
XcjCircuitType = ecs.NewComponentType[XcjCircuit]()
)
type XcjCircuit struct {
//联锁驱动的继电器
XQJ *ecs.Entry //洗车请求
TWJList []*ecs.Entry //停稳继电器
TGQJ *ecs.Entry //通过请求
XCJXJ *ecs.Entry //洗车就绪
XCYXJ *ecs.Entry //洗车允许
CFJList []*ecs.Entry //移动允许继电器
JTJ *ecs.Entry //紧急停车
TGYXJ *ecs.Entry //通过允许
}

View File

@ -12,7 +12,7 @@ func GetBitOfBytes(bs []byte, bitIndex int) bool {
panic(fmt.Errorf("从字节数组获取位值错误,位索引超出字节数组范围: 数组len=%d,位索引=%d", len(bs), bitIndex))
}
by := bs[bi]
v := byte(1 << i)
v := byte(1 << (7 - i))
return (by & v) == v
}

View File

@ -1,20 +0,0 @@
package entity
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
)
var AxleCountingSectionBaseComponentTypes = []ecs.IComponentType{component.UidType, component.AxleCountingSectionStateType}
// LoadPhysicalSections 加载计轴区段
func LoadAxleCountingSections(w ecs.World) error {
wd := GetWorldData(w)
sections := wd.Repo.AxleCountingSectionList()
for _, section := range sections {
entry := w.Entry(w.Create(AxleCountingSectionBaseComponentTypes...))
component.UidType.SetValue(entry, component.Uid{Id: section.Id()})
wd.EntityMap[section.Id()] = entry
}
return nil
}

View File

@ -8,9 +8,6 @@ import (
"joylink.club/rtsssimulation/repository/model/proto"
)
var BaliseBaseComponentTypeArr = []ecs.IComponentType{component.UidType, component.BaliseFixedTelegramType,
component.LinkPositionType, component.KmType, component.BaliseWorkStateType}
// LoadBalises 加载应答器实体
func LoadBalises(w ecs.World) error {
data := GetWorldData(w)
@ -32,25 +29,22 @@ func LoadBalises(w ecs.World) error {
}
return nil
}
func newBaliseEntity(w ecs.World, td *repository.Transponder, worldData *component.WorldData) *ecs.Entry {
uid := td.Id()
entry, ok := worldData.EntityMap[uid]
if !ok {
entry = w.Entry(w.Create(BaliseBaseComponentTypeArr...))
entry = w.Entry(w.Create(component.UidType, component.BaliseFixedTelegramType, component.LinkPositionType, component.KmType))
component.UidType.SetValue(entry, component.Uid{Id: uid})
component.BaliseWorkStateType.SetValue(entry, component.BaliseWorkState{Work: true})
component.BaliseFixedTelegramType.Set(entry, &component.BaliseTelegram{
component.BaliseFixedTelegramType.Set(entry, &component.BaliseState{
Telegram: td.FixedTelegram(),
UserTelegram: td.FixedUserTelegram(),
})
if proto.Transponder_IB == td.BaliseType() || proto.Transponder_VB == td.BaliseType() {
entry.AddComponent(component.BaliseVariableTelegramType)
}
linkPosition := td.LinkPosition()
component.LinkPositionType.SetValue(entry, component_data.LinkPosition{
LinkId: linkPosition.Link().Id(),
Offset: linkPosition.Offset(),
LinkId: td.LinkPosition().Link().Id(),
Offset: td.LinkPosition().Offset(),
})
component.KmType.Set(entry, td.Km())
worldData.EntityMap[uid] = entry

View File

@ -108,27 +108,3 @@ func NewDYPEntity(w ecs.World, station *repository.Station) error {
}
return nil
}
// NewLsEntity 创建零散继电器实体
func NewLsEntity(w ecs.World, station *repository.Station) error {
data := GetWorldData(w)
repo := data.Repo
for _, ecc := range station.DeviceEcc() {
if ecc.DeviceType != proto.DeviceType_DeviceType_LS {
continue
}
for _, eg := range ecc.Egs {
if eg.Code != "LS" {
continue
}
for _, componentId := range eg.ComponentIds {
relay := repo.FindById(componentId)
if relay == nil {
return fmt.Errorf("零散继电器实体构建错误: 找不到id=%s的继电器", componentId)
}
NewRelayEntity(w, relay.(*repository.Relay), data.EntityMap)
}
}
}
return nil
}

38
entity/ci_qck.go Normal file
View File

@ -0,0 +1,38 @@
package entity
import (
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/component/relation"
"joylink.club/rtsssimulation/component/singleton"
"joylink.club/rtsssimulation/modelrepo/model"
)
// 加载联锁驱采卡实体
func loadCiQck(w ecs.World, station model.EcStation) (*ecs.Entry, error) {
// 检查驱采表相关继电器是否存在
qcb := station.GetCiQcb()
if qcb == nil {
return nil, nil
}
uidIdx := singleton.GetEntityUidIndex(w)
for _, v := range qcb.QD() {
if !uidIdx.Has(v) {
return nil, fmt.Errorf("加载联锁驱采卡实体失败,车站'%s'的驱采表指定的驱动继电器'%s'不存在", station.Name(), v)
}
}
for _, cc := range qcb.CJ() {
for _, ccp := range cc.CjPos() {
if !uidIdx.Has(ccp.RelayId()) {
return nil, fmt.Errorf("加载联锁驱采卡实体失败,车站'%s'的驱采表指定的采集继电器'%s'不存在", station.Name(), ccp.RelayId())
}
}
}
// 加载联锁驱采卡实体
entry := w.Entry(w.Create(component.CiQckModelRelaType, component.CiQckStateType))
component.CiQckModelRelaType.Set(entry, relation.NewCiQckModelRela(station))
component.CiQckStateType.Set(entry, component.NewCiQckState(qcb))
return entry, nil
}

View File

@ -1,74 +0,0 @@
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}
func LoadCkm(w ecs.World) error {
data := GetWorldData(w)
for _, ckm := range data.Repo.CkmList() {
ckmEntry := newCkmEntry(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 newCkmEntry(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)
}
}
}
}
}
// 添加车库门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))
}

View File

@ -9,7 +9,9 @@ import (
func NewDBQEntity(w ecs.World, uid string, entityMap map[string]*ecs.Entry) *ecs.Entry {
entry, ok := entityMap[uid]
if !ok {
entry = w.Entry(w.Create(component.DBQTag, component.UidType, component.DBQStateType, component.CounterType))
entry = w.Entry(w.Create(component.DBQTag, component.UidType,
// component.DBQStateType,
component.CounterType))
component.UidType.SetValue(entry, component.Uid{Id: uid})
entityMap[uid] = entry
}

31
entity/elec.go Normal file
View File

@ -0,0 +1,31 @@
package entity
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/component/relation"
"joylink.club/rtsssimulation/component/singleton"
"joylink.club/rtsssimulation/modelrepo/model"
)
// 电子元件相关实体创建
// 创建断相保护器实体
func NewDbq(w ecs.World, dbq model.Dbq) *ecs.Entry {
uid := dbq.Uid().Id()
re := w.Entry(w.Create(component.DBQTag, component.UidType, component.DbqModelRelaType, component.DbqStateType, component.CounterType))
component.UidType.Set(re, &component.Uid{Id: uid})
component.DbqModelRelaType.Set(re, &relation.DbqModelRela{M: dbq})
singleton.GetEntityUidIndex(w).Add(uid, re)
return re
}
// 创建继电器实体
func NewRelay(w ecs.World, r model.Relay) *ecs.Entry {
uid := r.Uid().Id()
re := w.Entry(w.Create(component.RelayTag, component.UidType, component.RelayModelRelaType, component.RelayStateType))
component.UidType.Set(re, &component.Uid{Id: uid})
component.RelayModelRelaType.Set(re, &relation.RelayModelRela{M: r})
singleton.GetEntityUidIndex(w).Add(uid, re)
return re
}

64
entity/fadc_axle.go Normal file
View File

@ -0,0 +1,64 @@
package entity
import (
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"strings"
)
func newAxleManageDevice(w ecs.World, data *component.WorldData, centralizedStation string) *ecs.Entry {
entry := w.Entry(w.Create(component.AxleManageDeviceType))
component.AxleManageDeviceType.Set(entry, component.NewAxleManageDevice(centralizedStation))
data.AxleManageDeviceEntities = append(data.AxleManageDeviceEntities, entry)
return entry
}
// LoadAxlePhysicalSections 加载计轴区段
func LoadAxlePhysicalSections(w ecs.World) error {
data := GetWorldData(w)
sections := data.Repo.PhysicalSectionList()
for _, section := range sections {
if is, se := section.IsAxleSection(); se == nil && is {
if len(strings.TrimSpace(section.CentralizedStation())) == 0 {
return fmt.Errorf("区段[%s]未设置所属集中站", section.Id())
}
amdEntry := FindAxleManageDevice(data, section.CentralizedStation())
if amdEntry == nil {
amdEntry = newAxleManageDevice(w, data, section.CentralizedStation())
}
amd := component.AxleManageDeviceType.Get(amdEntry)
//
createAxleSectionEntity(w, section, data)
//
amd.Adrs[section.Id()] = component.NewAxleDeviceRuntime()
}
}
return nil
}
func FindAxleManageDevice(data *component.WorldData, centralizedStation string) *ecs.Entry {
for _, entry := range data.AxleManageDeviceEntities {
amd := component.AxleManageDeviceType.Get(entry)
if amd != nil && amd.CentralizedStation == centralizedStation {
return entry
}
}
return nil
}
// 计轴区段实体
func createAxleSectionEntity(w ecs.World, axleSection *repository.PhysicalSection, worldData *component.WorldData) *ecs.Entry {
uid := axleSection.Id()
entry, ok := worldData.EntityMap[uid]
if !ok {
entry = w.Entry(w.Create(component.UidType, component.PhysicalSectionStateType, component.AxlePhysicalSectionType))
//
component.UidType.SetValue(entry, component.Uid{Id: uid})
component.PhysicalSectionStateType.Set(entry, &component.PhysicalSectionState{Occ: false})
component.AxlePhysicalSectionType.Set(entry, component.NewAxlePhysicalSection())
//
worldData.EntityMap[uid] = entry
}
return entry
}

View File

@ -195,16 +195,13 @@ func LoadEMPEntity(w ecs.World, entry *ecs.Entry, datas []*repository.Electronic
}
}
if emp.Alarm == nil || emp.QBA == nil || emp.SDA == nil {
slog.Warn("EMP组合缺少元素将不添加EMP电路组件")
return nil
return fmt.Errorf("EMP组合初始化出错,请检查IBP地图组合数据")
}
for code, e := range emp.EMPJMap {
if e.EMPFA_BTN == nil || e.EMPD == nil || len(e.EMP_BTNS) == 0 {
slog.Warn(fmt.Sprintf("组合[%s]还原按钮未关联,请检查IBP地图组合数据", code))
return nil
return fmt.Errorf("组合[%s]还原按钮未关联,请检查IBP地图组合数据", code)
} else if e.EMPJ == nil {
slog.Warn(fmt.Sprintf("组合[%s]继电器未关联,请检查继电器地图组合数据", code))
return nil
return fmt.Errorf("组合[%s]继电器未关联,请检查继电器地图组合数据", code)
}
}
entry.AddComponent(component.EmpElectronicType, unsafe.Pointer(emp))

View File

@ -17,10 +17,10 @@ func Load(w ecs.World, repo *repository.Repository) error {
return err
}
// 加载道岔相关实体
err = LoadTurnouts(w)
if err != nil {
return err
}
// err = LoadTurnouts(w)
// if err != nil {
// return err
// }
// 加载信号机相关实体
err = LoadSignals(w)
if err != nil {
@ -36,13 +36,8 @@ func Load(w ecs.World, repo *repository.Repository) error {
if err != nil {
return err
}
// 加载物理区段相关实体
err = LoadPhysicalSections(w)
if err != nil {
return err
}
// 加载计轴区段相关实体
err = LoadAxleCountingSections(w)
err = LoadAxlePhysicalSections(w)
if err != nil {
return err
}
@ -51,25 +46,6 @@ func Load(w ecs.World, repo *repository.Repository) error {
if err != nil {
return err
}
// 加载车库门
err = LoadCkm(w)
if err != nil {
return err
}
//加载洗车机
err = LoadXcj(w)
if err != nil {
return err
}
//加载轨道电路
err = LoadTrackCircuit(w)
if err != nil {
return err
}
//加载站台(继电器)
err = LoadPlatform(w)
if err != nil {
return err
}
//
return err
}

View File

@ -4,24 +4,43 @@ import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component/singleton"
"joylink.club/rtsssimulation/modelrepo"
"joylink.club/rtsssimulation/modelrepo/model"
)
// 加载城轨仿真实体
func Loading(w ecs.World, repo modelrepo.Repo) error {
singleton.LoadSingletons(w, repo)
for _, s := range repo.GetEcses() {
// 加载道岔实体
loadTurnouts(w, s.GetTurnouts())
err := loadTrackside(w, repo)
if err != nil {
return err
}
return nil
}
func loadTurnouts(w ecs.World, points []model.Points) {
for _, p := range points {
switch p.GetTractionType() {
case model.PTT_ZDJ9_2:
// 加载轨旁设备实体
func loadTrackside(w ecs.World, repo modelrepo.Repo) error {
for _, s := range repo.GetEcses() {
// 加载道岔
for _, p := range s.GetTurnouts() {
NewPoints(w, p)
}
// 加载继电器
for _, r := range s.GetRelays() {
NewRelay(w, r)
}
// 加载断相保护器
for _, d := range s.GetDbqs() {
NewDbq(w, d)
}
// 加载联锁驱采卡
qckEntry, err := loadCiQck(w, s)
if err != nil {
return err
}
// 加载道岔电路和联锁驱采卡实体关联组件
err = buildEcStationPointsEccRela(w, s, qckEntry)
if err != nil {
return err
}
}
return nil
}

View File

@ -1,34 +0,0 @@
package entity
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"unsafe"
)
var PhysicalSectionBaseComponentTypes = []ecs.IComponentType{component.UidType, component.PhysicalSectionTag, component.PhysicalSectionManagerType}
// LoadPhysicalSections 加载计轴区段
func LoadPhysicalSections(w ecs.World) error {
wd := GetWorldData(w)
sections := wd.Repo.PhysicalSectionList()
for _, section := range sections {
if is, err := section.IsAxleSection(); err == nil && is {
entry := w.Entry(w.Create(PhysicalSectionBaseComponentTypes...))
component.UidType.SetValue(entry, component.Uid{Id: section.Id()})
for _, group := range section.ComponentGroups() {
for _, ec := range group.Components() {
if ec.Code() == "GJ" {
relay := ec.(*repository.Relay)
gjEntry := NewRelayEntity(w, relay, wd.EntityMap)
circuit := &component.PhysicalSectionCircuit{GJ: gjEntry}
entry.AddComponent(component.PhysicalSectionCircuitType, unsafe.Pointer(circuit))
}
}
}
wd.EntityMap[section.Id()] = entry
}
}
return nil
}

View File

@ -1,22 +0,0 @@
package entity
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/repository"
)
func LoadPlatform(w ecs.World) error {
wd := GetWorldData(w)
for _, platform := range wd.Repo.PlatformList() {
for _, group := range platform.ComponentGroups() {
for _, component := range group.Components() {
relay, ok := component.(*repository.Relay)
if !ok {
continue
}
NewRelayEntity(w, relay, wd.EntityMap)
}
}
}
return nil
}

View File

@ -2,35 +2,175 @@ package entity
import (
"fmt"
"unsafe"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/component/relation"
"joylink.club/rtsssimulation/component/singleton"
"joylink.club/rtsssimulation/modelrepo/model"
)
func NewPoints(w ecs.World, p model.Points) *ecs.Entry {
id := p.Uid().Id()
// 创建道岔实体
e := w.Entry(w.Create(component.UidType, component.TurnoutTag, component.PointsModelRelaType, component.PointsZzjRelaType,
pe := w.Entry(w.Create(component.UidType, component.PointsTag, component.PointsModelRelaType, component.PointsZzjRelaType,
component.PointsPositionType))
c := p.GetZzjCount()
if c <= 0 {
panic(fmt.Errorf("道岔转辙机数量必须大于0。id=%s, zzjCount=%d", id, c))
}
// 创建转辙机实体
entities := w.CreateMany(c, component.PointsZzjRelaType, component.PointsZzjKbqStateType, component.FixedPositionTransformType)
entities := w.CreateMany(c, component.PointsZzjRelaType, component.MotorStateType, component.PointsZzjKbqStateType, component.FixedPositionTransformType)
pzr := &relation.PointsZzjRela{
Points: e,
Points: pe,
}
// 关系状态初始化
component.UidType.Set(e, &component.Uid{Id: id})
component.PointsModelRelaType.Set(e, &relation.PointsModelRela{M: p})
component.PointsZzjRelaType.Set(e, pzr)
component.UidType.Set(pe, &component.Uid{Id: id})
component.PointsModelRelaType.Set(pe, &relation.PointsModelRela{M: p})
component.PointsZzjRelaType.Set(pe, pzr)
for _, ez := range entities {
zzj := w.Entry(ez)
pzr.Zzjs = append(pzr.Zzjs, zzj)
component.PointsZzjRelaType.Set(zzj, pzr)
}
return e
singleton.GetEntityUidIndex(w).Add(id, pe)
return pe
}
const (
ZDJ9_2_CT_TDC = "TDC"
ZDJ9_2_TDC_DCJ = "DCJ"
ZDJ9_2_TDC_FCJ = "FCJ"
ZDJ9_2_TDC_YCJ = "YCJ"
ZDJ9_2_TDC_ZDBJ = "ZDBJ"
ZDJ9_2_TDC_ZFBJ = "ZFBJ"
ZDJ9_2_CT_TDFJ1 = "TDFJ1"
ZDJ9_2_TDFJ1_1DQJ = "1DQJ"
ZDJ9_2_TDFJ1_1DQJF = "1DQJF"
ZDJ9_2_TDFJ1_2DQJ = "2DQJ"
ZDJ9_2_TDFJ1_BHJ = "BHJ"
ZDJ9_2_TDFJ1_DBJ = "DBJ"
ZDJ9_2_TDFJ1_FBJ = "FBJ"
ZDJ9_2_TDFJ1_QDJ = "QDJ"
ZDJ9_2_TDFJ1_ZBHJ = "ZBHJ"
ZDJ9_2_TDFJ1_DBQ = "DBQ"
ZDJ9_2_CT_TDFJ2 = "TDFJ2"
ZDJ9_2_TDFJ2_1DQJ = "1DQJ"
ZDJ9_2_TDFJ2_1DQJF = "1DQJF"
ZDJ9_2_TDFJ2_2DQJ = "2DQJ"
ZDJ9_2_TDFJ2_BHJ = "BHJ"
ZDJ9_2_TDFJ2_DBJ = "DBJ"
ZDJ9_2_TDFJ2_FBJ = "FBJ"
ZDJ9_2_TDFJ2_DBQ = "DBQ"
)
// 构建道岔电子元件关系
func buildEcStationPointsEccRela(w ecs.World, s model.EcStation, qckEntry *ecs.Entry) error {
deccs := s.GetCiDeccs()
eui := singleton.GetEntityUidIndex(w)
for _, decc := range deccs {
if decc.IsPoints() {
pe := eui.Get(decc.Duid())
if pe == nil {
return fmt.Errorf("车站'%s'不存在道岔'%s'", s.Name(), decc.Duid())
}
eccs := decc.Eccs()
pm := component.PointsModelRelaType.Get(pe).M
if pm.IsZdj9_1() {
return fmt.Errorf("ZDJ9单机牵引电路未实现")
} else if pm.IsZdj9_2() { // ZDJ9双机牵引电路元件引用组件构建
pelec := &relation.Zdj9TwoElectronic{CiQck: qckEntry}
for _, ecc := range eccs {
switch ecc.Code() {
case ZDJ9_2_CT_TDC:
for _, ec := range ecc.Ecs() {
ee := eui.Get(ec.Uid().Id())
if ee == nil {
return fmt.Errorf("车站'%s'不存在电子元件'%s'", s.Name(), ec.Uid().Id())
}
switch ec.Code() {
case ZDJ9_2_TDC_DCJ:
pelec.TDC_DCJ = ee
case ZDJ9_2_TDC_FCJ:
pelec.TDC_FCJ = ee
case ZDJ9_2_TDC_YCJ:
pelec.TDC_YCJ = ee
case ZDJ9_2_TDC_ZDBJ:
pelec.TDC_ZDBJ = ee
case ZDJ9_2_TDC_ZFBJ:
pelec.TDC_ZFBJ = ee
default:
return fmt.Errorf("组合类型'%s'内未知的ZDJ9双机电路元器件编号: '%s'", ZDJ9_2_CT_TDC, ec.Code())
}
}
case ZDJ9_2_CT_TDFJ1:
for _, ec := range ecc.Ecs() {
ee := eui.Get(ec.Uid().Id())
if ee == nil {
return fmt.Errorf("车站'%s'不存在电子元件'%s'", s.Name(), ec.Uid().Id())
}
switch ec.Code() {
case ZDJ9_2_TDFJ1_1DQJ:
pelec.TDFJ1_1DQJ = ee
case ZDJ9_2_TDFJ1_1DQJF:
pelec.TDFJ1_1DQJF = ee
case ZDJ9_2_TDFJ1_2DQJ:
pelec.TDFJ1_2DQJ = ee
case ZDJ9_2_TDFJ1_BHJ:
pelec.TDFJ1_BHJ = ee
case ZDJ9_2_TDFJ1_DBJ:
pelec.TDFJ1_DBJ = ee
case ZDJ9_2_TDFJ1_FBJ:
pelec.TDFJ1_FBJ = ee
case ZDJ9_2_TDFJ1_DBQ:
pelec.TDFJ1_DBQ = ee
case ZDJ9_2_TDFJ1_QDJ:
pelec.TDFJ1_QDJ = ee
case ZDJ9_2_TDFJ1_ZBHJ:
pelec.TDFJ1_ZBHJ = ee
default:
return fmt.Errorf("组合类型'%s'内未知的ZDJ9双机电路元器件编号: '%s'", ZDJ9_2_CT_TDFJ1, ec.Code())
}
}
case ZDJ9_2_CT_TDFJ2:
for _, ec := range ecc.Ecs() {
ee := eui.Get(ec.Uid().Id())
if ee == nil {
return fmt.Errorf("车站'%s'不存在电子元件'%s'", s.Name(), ec.Uid().Id())
}
switch ec.Code() {
case ZDJ9_2_TDFJ2_1DQJ:
pelec.TDFJ2_1DQJ = ee
case ZDJ9_2_TDFJ2_1DQJF:
pelec.TDFJ2_1DQJF = ee
case ZDJ9_2_TDFJ2_2DQJ:
pelec.TDFJ2_2DQJ = ee
case ZDJ9_2_TDFJ2_BHJ:
pelec.TDFJ2_BHJ = ee
case ZDJ9_2_TDFJ2_DBJ:
pelec.TDFJ2_DBJ = ee
case ZDJ9_2_TDFJ2_FBJ:
pelec.TDFJ2_FBJ = ee
case ZDJ9_2_TDFJ2_DBQ:
pelec.TDFJ2_DBQ = ee
default:
return fmt.Errorf("组合类型'%s'内未知的ZDJ9双机电路元器件编号: '%s'", ZDJ9_2_CT_TDFJ2, ec.Code())
}
}
default:
return fmt.Errorf("未知的ZDJ9双机电路元器件组合类型: '%s'", ecc.Code())
}
}
nils := pelec.CheckNilReference()
if len(nils) > 0 {
return fmt.Errorf("车站'%s'的道岔'%s'电路电子元件存在空引用: %v", s.Name(), pm.Uid().Id(), nils)
}
pe.AddComponent(component.Zdj9TwoElectronicType, unsafe.Pointer(pelec))
} else {
return fmt.Errorf("未知的道岔牵引类型")
}
}
}
return nil
}

View File

@ -1,11 +1,11 @@
package entity
import (
"strconv"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"regexp"
"strconv"
)
var PsdBaseComponentTypeArr = []ecs.IComponentType{component.PsdTag, component.UidType,
@ -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)
@ -46,26 +46,18 @@ func loadPsdCircuit(world ecs.World, entry *ecs.Entry, psd *repository.Psd, entr
return
}
circuit := &component.PsdCircuit{KMJMap: make(map[int32]*ecs.Entry)}
pattern := regexp.MustCompile("(\\d*).*KMJ") //用来匹配开门继电器的正则表达式
for _, group := range psd.ComponentGroups() {
for _, ec := range group.Components() {
relay := ec.(*repository.Relay)
matches := pattern.FindStringSubmatch(relay.Code())
if len(matches) != 0 { //匹配上了
if matches[1] == "" { //SKMJ/XKMJ
circuit.KMJMap[0] = NewRelayEntity(world, relay, entryMap)
} else {
num, err := strconv.Atoi(matches[1])
if err != nil {
panic(err)
}
circuit.KMJMap[int32(num)] = NewRelayEntity(world, relay, entryMap)
}
continue
}
switch ec.Code() {
case "XGMJ", "SGMJ":
circuit.GMJ = NewRelayEntity(world, relay, entryMap)
case "XKMJ", "SKMJ":
circuit.KMJMap[0] = NewRelayEntity(world, relay, entryMap)
case "4XKMJ", "4SKMJ":
circuit.KMJMap[4] = NewRelayEntity(world, relay, entryMap)
case "8XKMJ", "8SKMJ":
circuit.KMJMap[8] = NewRelayEntity(world, relay, entryMap)
case "XMGJ", "SMGJ":
circuit.MGJ = NewRelayEntity(world, relay, entryMap)
case "XMPLJ", "SMPLJ":
@ -111,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()})
@ -120,44 +112,19 @@ func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repositor
if pcb := mkx.Pcb(); pcb != nil {
mkxComponent.PCB = NewButtonEntity(world, pcb, worldData.EntityMap)
}
if pcbpl := mkx.Pcbpl(); pcbpl != nil {
mkxComponent.PCBPL = NewButtonEntity(world, pcbpl, worldData.EntityMap)
}
if pob := mkx.Pob(); pob != nil {
mkxComponent.POB = NewButtonEntity(world, pob, worldData.EntityMap)
}
if pobpl := mkx.Pobpl(); pobpl != nil {
mkxComponent.POBPL = NewButtonEntity(world, pobpl, worldData.EntityMap)
}
if pab := mkx.Pab(); pab != nil {
mkxComponent.PAB = NewButtonEntity(world, pab, worldData.EntityMap)
}
if pabpl := mkx.Pabpl(); pabpl != nil {
mkxComponent.PABPL = NewButtonEntity(world, pabpl, worldData.EntityMap)
}
if wrzf := mkx.Wrzf(); wrzf != nil {
mkxComponent.WRZF = NewButtonEntity(world, wrzf, worldData.EntityMap)
}
if wrzfpl := mkx.Wrzfpl(); wrzfpl != nil {
mkxComponent.WRZFPL = NewButtonEntity(world, wrzfpl, worldData.EntityMap)
}
if qkqr := mkx.Qkqr(); qkqr != nil {
mkxComponent.QKQR = NewButtonEntity(world, qkqr, worldData.EntityMap)
}
if qkqrpl := mkx.Qkqrpl(); qkqrpl != nil {
mkxComponent.QKQRPL = NewButtonEntity(world, qkqrpl, worldData.EntityMap)
}
if mpl := mkx.Mpl(); mpl != nil {
mkxComponent.MPL = NewButtonEntity(world, mpl, worldData.EntityMap)
}
if jxtcpl := mkx.Jxtcpl(); jxtcpl != nil {
mkxComponent.JXTCPL = NewButtonEntity(world, jxtcpl, worldData.EntityMap)
}
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 {
@ -169,12 +136,6 @@ func NewPlatformMkxEntry(world ecs.World, entryMap map[string]*ecs.Entry, mkx *r
if pabj := mkx.Pabj(); pabj != nil {
circuit.PABJ = NewRelayEntity(world, pabj, entryMap)
}
if wrzfj := mkx.Wrzfj(); wrzfj != nil {
circuit.WRZFJ = NewRelayEntity(world, wrzfj, entryMap)
}
if qkqrj := mkx.Qkqrj(); qkqrj != nil {
circuit.QKQRJ = NewRelayEntity(world, qkqrj, entryMap)
}
component.PlatformMkxCircuitType.Set(entry, circuit)
return entry
}

View File

@ -1,38 +1,28 @@
package entity
import (
"strings"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"joylink.club/rtsssimulation/repository/model/proto"
)
// 创建继电器实体
func NewRelayEntity(w ecs.World, relay *repository.Relay, entityMap map[string]*ecs.Entry) *ecs.Entry {
uid := relay.Id()
model := proto.Relay_Model_name[int32(relay.Model())]
// model := proto.Relay_Model_name[int32(relay.Model())]
entry, ok := entityMap[uid]
if !ok {
entry = w.Entry(w.Create(component.RelayTag, component.UidType, component.RelayDriveType, component.BitStateType))
entry = w.Entry(w.Create(component.RelayTag, component.UidType, component.BitStateType))
component.UidType.SetValue(entry, component.Uid{Id: uid})
if strings.Contains(model, "Y") { // 有极继电器
entry.AddComponent(component.YjRelayTag)
} else if strings.Contains(model, "W") || strings.Contains(model, "Z") || strings.Contains(model, "P") { // 无极继电器
entry.AddComponent(component.WjRelayTag)
}
if strings.Contains(model, "H") { // 缓放继电器
entry.AddComponent(component.HfRelayTag)
}
// if strings.Contains(model, "Y") { // 有极继电器
// entry.AddComponent(component.YjRelayTag)
// } else if strings.Contains(model, "W") || strings.Contains(model, "Z") || strings.Contains(model, "P") { // 无极继电器
// entry.AddComponent(component.WjRelayTag)
// }
// if strings.Contains(model, "H") { // 缓放继电器
// entry.AddComponent(component.HfRelayTag)
// }
entityMap[uid] = entry
//设置继电器初始状态
switch relay.DefaultPos() {
case proto.Relay_Pos_Q:
component.RelayDriveType.Get(entry).Td = true
case proto.Relay_Pos_H:
component.RelayDriveType.Get(entry).Td = false
}
}
return entry
}

View File

@ -10,6 +10,7 @@ import (
func LoadStations(w ecs.World) error {
data := GetWorldData(w)
stations := data.Repo.StationList()
// 加载零散组合继电器
for _, station := range stations {
err := NewSFAEntity(w, station)
if err != nil {
@ -23,10 +24,6 @@ func LoadStations(w ecs.World) error {
if err != nil {
return err
}
err = NewLsEntity(w, station)
if err != nil {
return err
}
entry := NewStationEntity(w, station.Id(), data)
err = LoadSPKEntity(w, entry, station.SpksComponents(), data) // 人员防护
if err != nil {

View File

@ -1,51 +0,0 @@
package entity
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"unsafe"
)
var TrackCircuitBaseComponentTypeArr = []ecs.IComponentType{component.UidType, component.TrackCircuitType}
func LoadTrackCircuit(w ecs.World) error {
data := GetWorldData(w)
for _, trackCircuit := range data.Repo.PhysicalSectionList() {
isAxleSection, err := trackCircuit.IsAxleSection()
if isAxleSection || err != nil {
continue
}
trackCircuitEntry := newTrackCircuitEntry(w, trackCircuit, data)
addTrackCircuit(w, trackCircuit, trackCircuitEntry, data)
}
return nil
}
func newTrackCircuitEntry(w ecs.World, section *repository.PhysicalSection, data *component.WorldData) *ecs.Entry {
uid := section.Id()
entry, ok := data.EntityMap[uid]
if !ok {
entry = w.Entry(w.Create(TrackCircuitBaseComponentTypeArr...))
component.UidType.SetValue(entry, component.Uid{Id: uid})
data.EntityMap[uid] = entry
}
return entry
}
func addTrackCircuit(w ecs.World, circuit *repository.PhysicalSection, entry *ecs.Entry, data *component.WorldData) {
if len(circuit.ComponentGroups()) == 0 {
return
}
trackCircuit := component.TrackCircuit{}
entry.AddComponent(component.TrackCircuitType, unsafe.Pointer(&trackCircuit))
for _, group := range circuit.ComponentGroups() {
for _, ec := range group.Components() {
relay := ec.(*repository.Relay)
switch ec.Code() {
case "GJ":
trackCircuit.GJ = NewRelayEntity(w, relay, data.EntityMap)
}
}
}
}

View File

@ -1,152 +1,152 @@
package entity
import (
"fmt"
"strings"
"unsafe"
// import (
// "fmt"
// "strings"
// "unsafe"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"joylink.club/rtsssimulation/repository/model/proto"
)
// "joylink.club/ecs"
// "joylink.club/rtsssimulation/component"
// "joylink.club/rtsssimulation/repository"
// "joylink.club/rtsssimulation/repository/model/proto"
// )
// 新建道岔实体
func NewTurnoutEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry {
entry, ok := worldData.EntityMap[uid]
if !ok {
entry = w.Entry(w.Create(component.TurnoutTag, component.UidType, component.TurnoutPositionType))
component.UidType.SetValue(entry, component.Uid{Id: uid})
worldData.EntityMap[uid] = entry
}
return entry
}
// // 新建道岔实体
// func NewTurnoutEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry {
// entry, ok := worldData.EntityMap[uid]
// if !ok {
// entry = w.Entry(w.Create(component.TurnoutTag, component.UidType, component.TurnoutPositionType))
// component.UidType.SetValue(entry, component.Uid{Id: uid})
// worldData.EntityMap[uid] = entry
// }
// return entry
// }
// 加载道岔实体
func LoadTurnouts(w ecs.World) error {
data := GetWorldData(w)
turnouts := data.Repo.TurnoutList()
for _, turnout := range turnouts {
entry := NewTurnoutEntity(w, turnout.Id(), data)
var err error
switch turnout.SwitchMachineType() {
case proto.Turnout_ZDJ9_Single:
err = LoadTurnoutZdj9One(w, turnout, entry)
case proto.Turnout_ZDJ9_Double:
err = LoadTurnoutZdj9Two(w, turnout, entry, data.EntityMap)
default:
return fmt.Errorf("id=%s的道岔没有转辙机型号数据", turnout.Id())
}
if err != nil {
return err
}
}
return nil
}
// // 加载道岔实体
// func LoadTurnouts(w ecs.World) error {
// data := GetWorldData(w)
// turnouts := data.Repo.TurnoutList()
// for _, turnout := range turnouts {
// entry := NewTurnoutEntity(w, turnout.Id(), data)
// var err error
// switch turnout.SwitchMachineType() {
// case proto.Turnout_ZDJ9_Single:
// err = LoadTurnoutZdj9One(w, turnout, entry)
// case proto.Turnout_ZDJ9_Double:
// err = LoadTurnoutZdj9Two(w, turnout, entry, data.EntityMap)
// default:
// return fmt.Errorf("id=%s的道岔没有转辙机型号数据", turnout.Id())
// }
// if err != nil {
// return err
// }
// }
// return nil
// }
// 加载道岔ZDJ9单机转辙机
func LoadTurnoutZdj9One(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry) error {
panic("道岔ZDJ9单机转辙机加载未实现")
}
// // 加载道岔ZDJ9单机转辙机
// func LoadTurnoutZdj9One(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry) error {
// panic("道岔ZDJ9单机转辙机加载未实现")
// }
// 加载道岔ZDJ9双机转辙机
func LoadTurnoutZdj9Two(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry, entityMap map[string]*ecs.Entry) error {
// 加载转辙机
entrys := ecs.Entries(w, w.CreateMany(2, component.ZzjStateType, component.FixedPositionTransformType))
// 给道岔添加转辙机引用组件
entry.AddComponent(component.TurnoutZzjType, unsafe.Pointer(&component.TurnoutZzj{
ZzjList: entrys,
}))
// // 加载道岔ZDJ9双机转辙机
// func LoadTurnoutZdj9Two(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry, entityMap map[string]*ecs.Entry) error {
// // 加载转辙机
// entrys := ecs.Entries(w, w.CreateMany(2, component.ZzjStateType, component.FixedPositionTransformType))
// // 给道岔添加转辙机引用组件
// entry.AddComponent(component.TurnoutZzjType, unsafe.Pointer(&component.TurnoutZzj{
// ZzjList: entrys,
// }))
// 继电器组合电路
groups := turnout.RelayGroups()
size := len(groups)
if size == 3 { // 有继电器组合,加载继电器实体和电路相关组件
zdj9TwoElectronic := &component.Zdj9TwoElectronic{}
for _, group := range groups {
elecs := group.Components()
if group.Code() == "TDC" {
for _, elec := range elecs {
relay := elec.(*repository.Relay)
if relay.Code() == "DCJ" {
zdj9TwoElectronic.TDC_DCJ = NewRelayEntity(w, relay, entityMap)
} else if relay.Code() == "FCJ" {
zdj9TwoElectronic.TDC_FCJ = NewRelayEntity(w, relay, entityMap)
} else if relay.Code() == "YCJ" {
zdj9TwoElectronic.TDC_YCJ = NewRelayEntity(w, relay, entityMap)
} else if relay.Code() == "ZDBJ" {
zdj9TwoElectronic.TDC_ZDBJ = NewRelayEntity(w, relay, entityMap)
} else if relay.Code() == "ZFBJ" {
zdj9TwoElectronic.TDC_ZFBJ = NewRelayEntity(w, relay, entityMap)
} else {
return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), relay.Code())
}
}
} else if group.Code() == "TDFJ1" {
for _, elec := range elecs {
// TODO:数据修复后删除
if elec.Code() == "" {
continue
}
if elec.Code() == "1DQJ" {
zdj9TwoElectronic.TDFJ1_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "BHJ" {
zdj9TwoElectronic.TDFJ1_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "2DQJ" {
zdj9TwoElectronic.TDFJ1_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "1DQJF" {
zdj9TwoElectronic.TDFJ1_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "DBQ" { // 断相保护器
zdj9TwoElectronic.TDFJ1_DBQ = NewDBQEntity(w, elec.Id(), entityMap)
} else if elec.Code() == "DBJ" {
zdj9TwoElectronic.TDFJ1_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "FBJ" {
zdj9TwoElectronic.TDFJ1_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "QDJ" {
zdj9TwoElectronic.TDFJ1_QDJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "ZBHJ" {
zdj9TwoElectronic.TDFJ1_ZBHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else {
return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code())
}
}
} else if group.Code() == "TDFJ2" {
for _, elec := range elecs {
// TODO:数据修复后删除
if elec.Code() == "" {
continue
}
if elec.Code() == "1DQJ" {
zdj9TwoElectronic.TDFJ2_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "BHJ" {
zdj9TwoElectronic.TDFJ2_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "2DQJ" {
zdj9TwoElectronic.TDFJ2_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "1DQJF" {
zdj9TwoElectronic.TDFJ2_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "DBQ" { // 断相保护器
zdj9TwoElectronic.TDFJ2_DBQ = NewDBQEntity(w, elec.Id(), entityMap)
} else if elec.Code() == "DBJ" {
zdj9TwoElectronic.TDFJ2_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else if elec.Code() == "FBJ" {
zdj9TwoElectronic.TDFJ2_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
} else {
return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code())
}
}
} else {
return fmt.Errorf("未知的道岔[%s]组合类型:%s", turnout.Id(), group.Code())
}
}
nils := zdj9TwoElectronic.CheckNilReference()
if len(nils) > 0 {
return fmt.Errorf("道岔[%s]ZDJ9双机继电器组合数据异常,缺失:[%s]", turnout.Id(), strings.Join(nils, ","))
} else {
// 给道岔添加电路组件
entry.AddComponent(component.Zdj9TwoElectronicType, unsafe.Pointer(zdj9TwoElectronic))
}
} else if size > 0 && size < 3 {
return fmt.Errorf("id=[%s]的道岔是ZDJ9双机牵引,继电器组合类型应为3个,现有%d个", turnout.Id(), size)
}
return nil
}
// // 继电器组合电路
// groups := turnout.RelayGroups()
// size := len(groups)
// if size == 3 { // 有继电器组合,加载继电器实体和电路相关组件
// zdj9TwoElectronic := &component.Zdj9TwoElectronic{}
// for _, group := range groups {
// elecs := group.Components()
// if group.Code() == "TDC" {
// for _, elec := range elecs {
// relay := elec.(*repository.Relay)
// if relay.Code() == "DCJ" {
// zdj9TwoElectronic.TDC_DCJ = NewRelayEntity(w, relay, entityMap)
// } else if relay.Code() == "FCJ" {
// zdj9TwoElectronic.TDC_FCJ = NewRelayEntity(w, relay, entityMap)
// } else if relay.Code() == "YCJ" {
// zdj9TwoElectronic.TDC_YCJ = NewRelayEntity(w, relay, entityMap)
// } else if relay.Code() == "ZDBJ" {
// zdj9TwoElectronic.TDC_ZDBJ = NewRelayEntity(w, relay, entityMap)
// } else if relay.Code() == "ZFBJ" {
// zdj9TwoElectronic.TDC_ZFBJ = NewRelayEntity(w, relay, entityMap)
// } else {
// return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), relay.Code())
// }
// }
// } else if group.Code() == "TDFJ1" {
// for _, elec := range elecs {
// // TODO:数据修复后删除
// if elec.Code() == "" {
// continue
// }
// if elec.Code() == "1DQJ" {
// zdj9TwoElectronic.TDFJ1_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "BHJ" {
// zdj9TwoElectronic.TDFJ1_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "2DQJ" {
// zdj9TwoElectronic.TDFJ1_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "1DQJF" {
// zdj9TwoElectronic.TDFJ1_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "DBQ" { // 断相保护器
// zdj9TwoElectronic.TDFJ1_DBQ = NewDBQEntity(w, elec.Id(), entityMap)
// } else if elec.Code() == "DBJ" {
// zdj9TwoElectronic.TDFJ1_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "FBJ" {
// zdj9TwoElectronic.TDFJ1_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "QDJ" {
// zdj9TwoElectronic.TDFJ1_QDJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "ZBHJ" {
// zdj9TwoElectronic.TDFJ1_ZBHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else {
// return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code())
// }
// }
// } else if group.Code() == "TDFJ2" {
// for _, elec := range elecs {
// // TODO:数据修复后删除
// if elec.Code() == "" {
// continue
// }
// if elec.Code() == "1DQJ" {
// zdj9TwoElectronic.TDFJ2_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "BHJ" {
// zdj9TwoElectronic.TDFJ2_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "2DQJ" {
// zdj9TwoElectronic.TDFJ2_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "1DQJF" {
// zdj9TwoElectronic.TDFJ2_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "DBQ" { // 断相保护器
// zdj9TwoElectronic.TDFJ2_DBQ = NewDBQEntity(w, elec.Id(), entityMap)
// } else if elec.Code() == "DBJ" {
// zdj9TwoElectronic.TDFJ2_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else if elec.Code() == "FBJ" {
// zdj9TwoElectronic.TDFJ2_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
// } else {
// return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code())
// }
// }
// } else {
// return fmt.Errorf("未知的道岔[%s]组合类型:%s", turnout.Id(), group.Code())
// }
// }
// nils := zdj9TwoElectronic.CheckNilReference()
// if len(nils) > 0 {
// return fmt.Errorf("道岔[%s]ZDJ9双机继电器组合数据异常,缺失:[%s]", turnout.Id(), strings.Join(nils, ","))
// } else {
// // 给道岔添加电路组件
// entry.AddComponent(component.Zdj9TwoElectronicType, unsafe.Pointer(zdj9TwoElectronic))
// }
// } else if size > 0 && size < 3 {
// return fmt.Errorf("id=[%s]的道岔是ZDJ9双机牵引,继电器组合类型应为3个,现有%d个", turnout.Id(), size)
// }
// return nil
// }

View File

@ -1,66 +0,0 @@
package entity
import (
"errors"
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"strconv"
"strings"
"unsafe"
)
var XcjBaseComponentTypes = []ecs.IComponentType{component.UidType, component.XcjTag}
func LoadXcj(w ecs.World) error {
wd := GetWorldData(w)
for _, xcj := range wd.Repo.XcjList() {
//创建基础entry
entry := w.Entry(w.Create(XcjBaseComponentTypes...))
component.UidType.SetValue(entry, component.Uid{Id: xcj.Id()})
wd.EntityMap[xcj.Id()] = entry
//加载电路
if len(xcj.ComponentGroups()) != 0 {
circuit := &component.XcjCircuit{
TWJList: make([]*ecs.Entry, xcj.NumSegments),
CFJList: make([]*ecs.Entry, xcj.NumSegments),
}
entry.AddComponent(component.XcjCircuitType, unsafe.Pointer(circuit))
for _, group := range xcj.ComponentGroups() {
for _, ec := range group.Components() {
relay := ec.(*repository.Relay)
switch ec.Code() {
case "XQJ":
circuit.XQJ = NewRelayEntity(w, relay, wd.EntityMap)
case "TGQJ":
circuit.TGQJ = NewRelayEntity(w, relay, wd.EntityMap)
case "XCJXJ":
circuit.XCJXJ = NewRelayEntity(w, relay, wd.EntityMap)
case "XCYXJ":
circuit.XCYXJ = NewRelayEntity(w, relay, wd.EntityMap)
case "JTJ":
circuit.JTJ = NewRelayEntity(w, relay, wd.EntityMap)
case "TGYXJ":
circuit.TGYXJ = NewRelayEntity(w, relay, wd.EntityMap)
default:
if strings.Contains(ec.Code(), "TWJ") {
index, err := strconv.Atoi(ec.Code()[3:])
if err != nil {
return errors.New(fmt.Sprintf("洗车机继电器[%s]编号异常", ec.Code()))
}
circuit.TWJList[index-1] = NewRelayEntity(w, relay, wd.EntityMap)
} else if strings.Contains(ec.Code(), "CFJ") {
index, err := strconv.Atoi(ec.Code()[3:])
if err != nil {
return errors.New(fmt.Sprintf("洗车机继电器[%s]编号异常", ec.Code()))
}
circuit.CFJList[index-1] = NewRelayEntity(w, relay, wd.EntityMap)
}
}
}
}
}
}
return nil
}

View File

@ -0,0 +1,77 @@
package main
import (
"log/slog"
"os"
"time"
"joylink.club/ecs"
rtss_simulation "joylink.club/rtsssimulation"
"joylink.club/rtsssimulation/consts"
"joylink.club/rtsssimulation/entity"
"joylink.club/rtsssimulation/examples/signal_2xh1/sigSys"
"joylink.club/rtsssimulation/fi"
"joylink.club/rtsssimulation/repository"
"joylink.club/rtsssimulation/repository/model/proto"
)
const (
IdSignal2XH1 = "signal_2xh1-1"
)
// 信号机测试
func main() {
//
logConfig := &slog.HandlerOptions{AddSource: false, Level: slog.LevelDebug}
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, logConfig)))
//
proto := &proto.Repository{}
proto.Id = "test-for-signal"
proto.Version = "v1.0"
addProtoSignal2XH1(proto)
repo := repository.BuildRepositoryForSignalTest(proto)
sim, _ := rtss_simulation.NewSimulation(repo)
loadEntities(sim, repo)
sim.SetSpeed(0.1)
sim.AddSystem(sigSys.NewSignalDebugSystem())
sim.StartUp()
//
time.Sleep(1 * time.Second)
slog.Debug("灭灯 .....")
fi.DriveSignal2XH1Dd(sim, IdSignal2XH1, false) //灭灯
time.Sleep(2 * time.Second)
slog.Debug("亮灯 .....")
fi.DriveSignal2XH1Dd(sim, IdSignal2XH1, true) //亮灯
time.Sleep(2 * time.Second)
slog.Debug("开通列车信号 .....")
fi.DriveSignal2XH1Lx(sim, IdSignal2XH1) //开通列车信号
time.Sleep(3 * time.Second)
slog.Debug("开通禁止信号 .....")
fi.DriveSignal2XH1Non(sim, IdSignal2XH1) //开通禁止信号
//
time.Sleep(3 * time.Second)
sim.Close()
}
func addProtoSignal2XH1(r *proto.Repository) {
//相关继电器
r.Relays = append(r.Relays, &proto.Relay{Id: "2xh1-ddj", Code: consts.SIGNAL_DDJ, Model: proto.Relay_JWXC_1700})
r.Relays = append(r.Relays, &proto.Relay{Id: "2xh1-dj", Code: consts.SIGNAL_DJ, Model: proto.Relay_JZXC_H18})
r.Relays = append(r.Relays, &proto.Relay{Id: "2xh1-lxj", Code: consts.SIGNAL_LXJ, Model: proto.Relay_JWXC_1700})
//
signal := &proto.Signal{}
signal.Id = IdSignal2XH1
signal.Km = &proto.Kilometer{}
//
group := &proto.ElectronicComponentGroup{Code: consts.SIGNAL_2XH1, ComponentIds: []string{"2xh1-ddj", "2xh1-dj", "2xh1-lxj"}}
//
signal.ElectronicComponentGroups = append(signal.ElectronicComponentGroups, group)
r.Signals = append(r.Signals, signal)
}
func loadEntities(w ecs.World, repo *repository.Repository) {
// 初始化世界数据单例组件
entity.LoadWorldData(w, repo)
//
if le := entity.LoadSignals(w); le != nil {
slog.Error(le.Error())
}
}

View File

@ -2,9 +2,16 @@ package main
import (
"fmt"
"log/slog"
"os"
"time"
"joylink.club/ecs"
rtss_simulation "joylink.club/rtsssimulation"
"joylink.club/rtsssimulation/consts"
"joylink.club/rtsssimulation/entity"
"joylink.club/rtsssimulation/examples/signal_3xh1/sigSys"
"joylink.club/rtsssimulation/fi"
"joylink.club/rtsssimulation/repository"
"joylink.club/rtsssimulation/repository/model/proto"
)
@ -15,37 +22,37 @@ const (
// 信号机测试
func main() {
/* logConfig := &slog.HandlerOptions{AddSource: false, Level: slog.LevelDebug}
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, logConfig)))
//
proto := &proto.Repository{}
proto.Id = "test-for-signal"
proto.Version = "v1.0"
addProtoSignal3XH1(proto)
repo := repository.BuildRepositoryForSignalTest(proto)
sim, _ := rtss_simulation.NewSimulation(repo)
loadEntities(sim, repo)
sim.SetSpeed(1)
sim.AddSystem(sigSys.NewSignalDebugSystem())
sim.StartUp()
//
time.Sleep(1 * time.Second)
slog.Debug("灭灯 .....")
fi.DriveSignal3XH1Dd(sim, IdSignal3XH1, false)
//
time.Sleep(1 * time.Second)
slog.Debug("亮灯 .....")
fi.DriveSignal3XH1Dd(sim, IdSignal3XH1, true)
//
time.Sleep(2 * time.Second)
slog.Debug("开通引导信号 .....")
fi.DriveSignal3XH1Yx(sim, IdSignal3XH1)
time.Sleep(2 * time.Second)
slog.Debug("开通列车信号 .....")
fi.DriveSignal3XH1Lx(sim, IdSignal3XH1, false)
//
time.Sleep(5 * time.Second)
sim.Close()*/
logConfig := &slog.HandlerOptions{AddSource: false, Level: slog.LevelDebug}
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, logConfig)))
//
proto := &proto.Repository{}
proto.Id = "test-for-signal"
proto.Version = "v1.0"
addProtoSignal3XH1(proto)
repo := repository.BuildRepositoryForSignalTest(proto)
sim, _ := rtss_simulation.NewSimulation(repo)
loadEntities(sim, repo)
sim.SetSpeed(1)
sim.AddSystem(sigSys.NewSignalDebugSystem())
sim.StartUp()
//
time.Sleep(1 * time.Second)
slog.Debug("灭灯 .....")
fi.DriveSignal3XH1Dd(sim, IdSignal3XH1, false)
//
time.Sleep(1 * time.Second)
slog.Debug("亮灯 .....")
fi.DriveSignal3XH1Dd(sim, IdSignal3XH1, true)
//
time.Sleep(2 * time.Second)
slog.Debug("开通引导信号 .....")
fi.DriveSignal3XH1Yx(sim, IdSignal3XH1)
time.Sleep(2 * time.Second)
slog.Debug("开通列车信号 .....")
fi.DriveSignal3XH1Lx(sim, IdSignal3XH1, false)
//
time.Sleep(5 * time.Second)
sim.Close()
}
func addProtoSignal3XH1(r *proto.Repository) {
//相关继电器

View File

@ -1,66 +0,0 @@
package fi
import (
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
// BaliseUpdateFixedTelegram 更新固定报文
func BaliseUpdateFixedTelegram(w ecs.World, id string, telegram []byte, userTelegram []byte) error {
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
baliseFixedTelegram := component.BaliseFixedTelegramType.Get(entry)
baliseFixedTelegram.Telegram = telegram
baliseFixedTelegram.UserTelegram = userTelegram
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的应答器", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
// BaliseUpdateVariableTelegram 更新可变报文
func BaliseUpdateVariableTelegram(w ecs.World, id string, telegram []byte, userTelegram []byte, force bool) error {
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
if entry.HasComponent(component.BaliseVariableTelegramType) {
if force {
entry.AddComponent(component.ForceVariableTelegram)
} else if entry.HasComponent(component.ForceVariableTelegram) {
return ecs.NewOkEmptyResult()
}
baliseVariableTelegram := component.BaliseVariableTelegramType.Get(entry)
baliseVariableTelegram.Telegram = telegram
baliseVariableTelegram.UserTelegram = userTelegram
} else {
ecs.NewErrResult(fmt.Errorf("应答器[%s]无可变报文组件", id))
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到应答器[%s]", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
// BaliseCancelForceVariableTelegram 取消强制可变报文
func BaliseCancelForceVariableTelegram(w ecs.World, id string) error {
request := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
if entry.HasComponent(component.ForceVariableTelegram) {
entry.RemoveComponent(component.ForceVariableTelegram)
}
}
return ecs.NewOkEmptyResult()
})
return request.Err
}

42
fi/circuit.go Normal file
View File

@ -0,0 +1,42 @@
package fi
import (
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
// 采集继电器吸起电路状态
func CollectXQCircuitState(w ecs.World, id string) bool {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
state := component.BitStateType.Get(entry)
return state.Val
} else {
fmt.Printf("未找到id=%s的继电器\n", id)
}
return false
}
// 采集继电器落下电路状态
func CollectLXCircuitState(w ecs.World, id string) bool {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
state := component.BitStateType.Get(entry)
return !state.Val
} else {
fmt.Printf("未找到id=%s的继电器\n", id)
}
return false
}
// 驱动电路状态修改
// x,y:二维数组的索引
// state : 32位的bool数组
func DriveCircuitStateChange(w ecs.World, x, y int, state bool) {
}

25
fi/common.go Normal file
View File

@ -0,0 +1,25 @@
package fi
import (
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/entity"
)
func updateEntity(w ecs.World, id string, entityName string, updateHandle func(entry *ecs.Entry) error) error {
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
err := updateHandle(entry)
if err != nil {
return ecs.NewErrResult(err)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的%s", id, entityName))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}

View File

@ -2,7 +2,6 @@ package fi
import (
"fmt"
//"joylink.club/bj-rtsts-server/dto/request_proto"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
@ -17,7 +16,6 @@ func PressDownButton(w ecs.World, id string) error {
if ok {
state := component.BitStateType.Get(entry)
state.Val = true
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的按钮", id))
}
@ -34,7 +32,6 @@ func PressUpButton(w ecs.World, id string) error {
if ok {
state := component.BitStateType.Get(entry)
state.Val = false
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的按钮", id))
}
@ -51,7 +48,6 @@ func SwitchKeyGear(w ecs.World, id string, gear int32) error {
if ok {
state := component.GearStateType.Get(entry)
state.Val = gear
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的钥匙开关", id))
}

View File

@ -1,120 +0,0 @@
package fi
import (
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
"strings"
)
// PhysicalSectionFaultOccDrive 区段故障占用设置
func PhysicalSectionFaultOccDrive(w ecs.World, sectionId string, set bool) error {
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
sectionModel := wd.Repo.FindPhysicalSection(sectionId)
if sectionModel == nil {
return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
}
//
sectionEntry := wd.EntityMap[sectionId]
if sectionEntry == nil {
return ecs.NewErrResult(fmt.Errorf("区段[%s]实体不存在", sectionId))
}
if set { //计轴故障设置
if !sectionEntry.HasComponent(component.PhysicalSectionForceOccupied) {
sectionEntry.AddComponent(component.PhysicalSectionForceOccupied)
}
} else { //计轴故障取消
if sectionEntry.HasComponent(component.PhysicalSectionForceOccupied) {
sectionEntry.RemoveComponent(component.PhysicalSectionForceOccupied)
}
}
return ecs.NewOkEmptyResult()
})
return r.Err
}
// PhysicalSectionDrstDrive 直接复位
func PhysicalSectionDrstDrive(w ecs.World, sectionId string) (*PhysicalSectionState, error) {
r := <-ecs.Request[*PhysicalSectionState](w, func() ecs.Result[*PhysicalSectionState] {
wd := entity.GetWorldData(w)
entry := wd.EntityMap[sectionId]
if entry == nil {
return ecs.NewResult[*PhysicalSectionState](nil, fmt.Errorf("区段[%s]实体不存在", sectionId))
}
axleManager := component.PhysicalSectionManagerType.Get(entry)
state := &PhysicalSectionState{}
if axleManager.Count != 0 {
state.Rjo = true
} else {
entry.RemoveComponent(component.PhysicalSectionForceOccupied)
state.Rac = true
}
return ecs.NewOkResult(state)
})
return r.Val, r.Err
}
// PhysicalSectionPdrstDrive 预复位
func PhysicalSectionPdrstDrive(w ecs.World, sectionId string) (*PhysicalSectionState, error) {
r := <-ecs.Request[*PhysicalSectionState](w, func() ecs.Result[*PhysicalSectionState] {
wd := entity.GetWorldData(w)
entry := wd.EntityMap[sectionId]
if entry == nil {
return ecs.NewResult[*PhysicalSectionState](nil, fmt.Errorf("区段[%s]实体不存在", sectionId))
}
axleManager := component.PhysicalSectionManagerType.Get(entry)
state := &PhysicalSectionState{}
if axleManager.Count != 0 {
state.Rjo = true
} else {
state.Rac = true
}
return ecs.NewOkResult(state)
})
return r.Val, r.Err
}
// FindPhysicalSectionsStatus 获取物理区段的相关状态
func FindPhysicalSectionsStatus(w ecs.World, sectionIds []string) ([]*PhysicalSectionState, error) {
r := <-ecs.Request[[]*PhysicalSectionState](w, func() ecs.Result[[]*PhysicalSectionState] {
wd := entity.GetWorldData(w)
var msg []*PhysicalSectionState
var esb = strings.Builder{} //收集未找到的区段的id
for _, sectionId := range sectionIds {
entry := wd.EntityMap[sectionId]
if entry == nil {
esb.WriteString(fmt.Sprintf("%s,", sectionId))
continue
}
axleManager := component.PhysicalSectionManagerType.Get(entry)
msg = append(msg, &PhysicalSectionState{
Id: sectionId,
Clr: !axleManager.Occupied,
Occ: axleManager.Occupied,
})
}
if esb.Len() > 0 {
return ecs.NewResult(msg, fmt.Errorf("区段非物理区段或物理区段状态不存在:[%s]", esb.String()))
} else {
return ecs.NewResult(msg, nil)
}
})
return r.Val, r.Err
}
type PhysicalSectionState struct {
//uid
Id string
//0-bit7 区段出清
Clr bool
//0-bit6 区段占用
Occ bool
//1-bit6 区段复位反馈
Rac bool
//1-bit5 运营原因拒绝计轴复位
Rjo bool
//1-bit4 技术原因拒绝计轴复位
Rjt bool
}

View File

@ -2,9 +2,11 @@ package fi
import (
"fmt"
"unsafe"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/component/component_data"
"joylink.club/rtsssimulation/component/component_proto"
"joylink.club/rtsssimulation/entity"
)
@ -214,3 +216,53 @@ func forceTurnout(w ecs.World, id string, pos ForceTurnoutPos) error {
})
return result.Err
}
// 设置道岔强制定位
func SetPointsForceDw(w ecs.World, id string) error {
return updateEntity(w, id, "道岔", func(entry *ecs.Entry) error {
if entry.HasComponent(component.PointsFaultJcType) {
return fmt.Errorf("道岔挤岔,不能强制定位")
}
if entry.HasComponent(component.PointsFaultSbType) {
sbf := component.PointsFaultSbType.Get(entry)
if sbf.IsAllSB() || sbf.IsDW() {
return fmt.Errorf("道岔定位失表,不能强制定位")
}
}
entry.AddComponent(component.PointsFaultCiqdType)
return nil
})
}
// 设置道岔失表故障
func SetPointsFaultSb(w ecs.World, id string, t component_data.PointsFaultSb_Type) error {
return updateEntity(w, id, "道岔", func(entry *ecs.Entry) error {
entry.AddComponent(component.PointsFaultSbType, unsafe.Pointer(&component_data.PointsFaultSb{Type: t}))
return nil
})
}
// 取消道岔失表故障
func CancelPointsFaultSb(w ecs.World, id string) error {
return updateEntity(w, id, "道岔", func(entry *ecs.Entry) error {
entry.RemoveComponent(component.PointsFaultSbType)
return nil
})
}
// 设置道岔挤岔故障
func SetPointsFaultJc(w ecs.World, id string) error {
return updateEntity(w, id, "道岔", func(entry *ecs.Entry) error {
entry.AddComponent(component.PointsFaultJcType, unsafe.Pointer(&component_data.PointsFaultJc{}))
return nil
})
}
// 取消道岔挤岔故障
func CancelPointsFaultJc(w ecs.World, id string) error {
return updateEntity(w, id, "道岔", func(entry *ecs.Entry) error {
entry.RemoveComponent(component.PointsFaultJcType)
return nil
})
}

353
fi/psd.go Normal file
View File

@ -0,0 +1,353 @@
package fi
import (
"errors"
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/component/component_proto"
"joylink.club/rtsssimulation/entity"
)
func SetInterlockKm(world ecs.World, psdId string, group int32) error {
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(world)
entry, ok := wd.EntityMap[psdId]
if ok {
err := setInterlockKm(wd, entry, group)
if err != nil {
return ecs.NewErrResult(err)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", psdId))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
func CancelInterlockKm(world ecs.World, id string, group int32) error {
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(world)
entry, ok := wd.EntityMap[id]
if ok {
err := cancelInterlockKm(wd, entry, group)
if err != nil {
return ecs.NewErrResult(err)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
func SetInterlockGm(world ecs.World, id string) error {
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(world)
entry, ok := wd.EntityMap[id]
if ok {
err := setInterlockGm(wd, entry)
if err != nil {
return ecs.NewErrResult(err)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
func CancelInterlockGm(world ecs.World, id string) error {
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(world)
entry, ok := wd.EntityMap[id]
if ok {
err := cancelInterlockGm(wd, entry)
if err != nil {
return ecs.NewErrResult(err)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
func SetPsdFault(world ecs.World, id string, fault component_proto.Psd_Fault, asdCodes []int32) error {
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(world)
psdEntry, ok := wd.EntityMap[id]
if !ok {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
}
tag, err := component.GetAsdFaultTag(fault)
if err != nil {
return ecs.NewErrResult(err)
}
asdList := component.AsdListType.Get(psdEntry).List
for _, code := range asdCodes {
asdEntry := asdList[int(code-1)]
asdEntry.AddComponent(tag)
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
func CancelPsdFault(world ecs.World, id string, fault component_proto.Psd_Fault, asdCodes []int32) error {
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(world)
psdEntry, ok := wd.EntityMap[id]
if !ok {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
}
tag, err := component.GetAsdFaultTag(fault)
if err != nil {
return ecs.NewErrResult(err)
}
asdList := component.AsdListType.Get(psdEntry).List
for _, code := range asdCodes {
asdEntry := asdList[int(code-1)]
asdEntry.RemoveComponent(tag)
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
func SetQDTC(world ecs.World, id string) error {
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(world)
entry, ok := wd.EntityMap[id]
if ok {
err := setQDTC(wd, entry)
if err != nil {
return ecs.NewErrResult(err)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
func CancelQDTC(world ecs.World, id string) error {
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(world)
entry, ok := wd.EntityMap[id]
if ok {
err := cancelQDTC(wd, entry)
if err != nil {
return ecs.NewErrResult(err)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
func SetTZTC(world ecs.World, id string) error {
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(world)
entry, ok := wd.EntityMap[id]
if ok {
err := setTZTC(wd, entry)
if err != nil {
return ecs.NewErrResult(err)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
func CancelTZTC(world ecs.World, id string) error {
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(world)
entry, ok := wd.EntityMap[id]
if ok {
err := cancelTZTC(wd, entry)
if err != nil {
return ecs.NewErrResult(err)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
func cancelTZTC(wd *component.WorldData, psdEntry *ecs.Entry) error {
if psdEntry.HasComponent(component.PsdCircuitType) {
circuit := component.PsdCircuitType.Get(psdEntry)
return wd.SetQdBit(component.UidType.Get(circuit.TZTCJ).Id, false)
} else {
psc := component.PscType.Get(psdEntry)
psc.TZTC = false
}
return nil
}
func setTZTC(wd *component.WorldData, psdEntry *ecs.Entry) error {
if psdEntry.HasComponent(component.PsdCircuitType) {
circuit := component.PsdCircuitType.Get(psdEntry)
return wd.SetQdBits([]*component.QdBitParam{
component.NewQdBitParam(component.UidType.Get(circuit.QDTCJ).Id, false),
component.NewQdBitParam(component.UidType.Get(circuit.TZTCJ).Id, true),
})
} else {
psc := component.PscType.Get(psdEntry)
psc.QDTC = false
psc.TZTC = true
}
return nil
}
func cancelQDTC(wd *component.WorldData, psdEntry *ecs.Entry) error {
if psdEntry.HasComponent(component.PsdCircuitType) {
circuit := component.PsdCircuitType.Get(psdEntry)
return wd.SetQdBit(component.UidType.Get(circuit.QDTCJ).Id, false)
} else {
psc := component.PscType.Get(psdEntry)
psc.QDTC = false
}
return nil
}
func setQDTC(wd *component.WorldData, psdEntry *ecs.Entry) error {
if psdEntry.HasComponent(component.PsdCircuitType) {
circuit := component.PsdCircuitType.Get(psdEntry)
return wd.SetQdBits([]*component.QdBitParam{
component.NewQdBitParam(component.UidType.Get(circuit.QDTCJ).Id, true),
component.NewQdBitParam(component.UidType.Get(circuit.TZTCJ).Id, false),
})
} else {
psc := component.PscType.Get(psdEntry)
psc.QDTC = true
psc.TZTC = false
}
return nil
}
// 设置联锁开门
func setInterlockKm(wd *component.WorldData, psdEntry *ecs.Entry, group int32) error {
if psdEntry.HasComponent(component.PsdCircuitType) { //有联锁区段电路
circuit := component.PsdCircuitType.Get(psdEntry)
if circuit.KMJMap[0] != nil { //0编组意味着屏蔽门仅有一个开门继电器
return setRelayDriveKm(wd, circuit, 0)
} else {
kmj := circuit.KMJMap[group]
if kmj == nil {
id := component.UidType.Get(psdEntry).Id
return errors.New(fmt.Sprintf("屏蔽门[id:%s]不支持[%d]编组操作", id, group))
}
return setRelayDriveKm(wd, circuit, group)
}
} else {
psc := component.PscType.Get(psdEntry)
psc.InterlockKmGroup[group] = true
}
return nil
}
// 取消联锁开门
func cancelInterlockKm(wd *component.WorldData, psdEntry *ecs.Entry, group int32) error {
if psdEntry.HasComponent(component.PsdCircuitType) { //有联锁区段电路
circuit := component.PsdCircuitType.Get(psdEntry)
if circuit.KMJMap[0] != nil { //0编组意味着屏蔽门仅有一个开门继电器
return cancelRelayDriveKm(wd, circuit, 0)
} else {
kmj := circuit.KMJMap[group]
if kmj == nil {
id := component.UidType.Get(psdEntry).Id
return errors.New(fmt.Sprintf("屏蔽门[id:%s]不支持[%d]编组操作", id, group))
}
return cancelRelayDriveKm(wd, circuit, group)
}
} else {
psc := component.PscType.Get(psdEntry)
psc.InterlockKmGroup[group] = false
}
return nil
}
// 设置联锁关门
func setInterlockGm(wd *component.WorldData, psdEntry *ecs.Entry) error {
if psdEntry.HasComponent(component.PsdCircuitType) { //有联锁区段电路
circuit := component.PsdCircuitType.Get(psdEntry)
return setRelayDriveGm(wd, circuit)
} else {
psc := component.PscType.Get(psdEntry)
for i, _ := range psc.InterlockKmGroup {
psc.InterlockKmGroup[i] = false
}
psc.InterlockGM = true
}
return nil
}
// 取消联锁关门
func cancelInterlockGm(wd *component.WorldData, psdEntry *ecs.Entry) error {
if psdEntry.HasComponent(component.PsdCircuitType) { //有联锁区段电路
circuit := component.PsdCircuitType.Get(psdEntry)
return cancelRelayDriveGm(wd, circuit)
} else {
psc := component.PscType.Get(psdEntry)
psc.InterlockGM = false
}
return nil
}
// 设置继电器驱动开门
func setRelayDriveKm(wd *component.WorldData, circuit *component.PsdCircuit, group int32) error {
var params []*component.QdBitParam
params = append(params, component.NewQdBitParam(component.UidType.Get(circuit.GMJ).Id, false))
for g, entry := range circuit.KMJMap {
if g == group {
params = append(params, component.NewQdBitParam(component.UidType.Get(entry).Id, true))
} else {
params = append(params, component.NewQdBitParam(component.UidType.Get(entry).Id, false))
}
}
return wd.SetQdBits(params)
}
// 取消继电器驱动开门
func cancelRelayDriveKm(wd *component.WorldData, circuit *component.PsdCircuit, group int32) error {
var params []*component.QdBitParam
for _, entry := range circuit.KMJMap {
params = append(params, component.NewQdBitParam(component.UidType.Get(entry).Id, false))
}
return wd.SetQdBits(params)
}
// 设置继电器驱动关门
func setRelayDriveGm(wd *component.WorldData, circuit *component.PsdCircuit) error {
var params []*component.QdBitParam
params = append(params, component.NewQdBitParam(component.UidType.Get(circuit.GMJ).Id, true))
for _, entry := range circuit.KMJMap {
params = append(params, component.NewQdBitParam(component.UidType.Get(entry).Id, false))
}
return wd.SetQdBits(params)
}
// 取消继电器驱动关门
func cancelRelayDriveGm(wd *component.WorldData, circuit *component.PsdCircuit) error {
var params []*component.QdBitParam
params = append(params, component.NewQdBitParam(component.UidType.Get(circuit.GMJ).Id, false))
return wd.SetQdBits(params)
}

View File

@ -1,96 +1,27 @@
package fi
import (
"fmt"
"unsafe"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
"joylink.club/rtsssimulation/component/component_data"
)
// 继电器功能接口
// 控制有极继电器励磁
// id - 继电器uid
// td - 是否通电励磁
// xq - 是否到吸起位置(有极继电器)
func driveYjRelay(w ecs.World, entry *ecs.Entry, td bool, xq bool) {
rd := component.RelayDriveType.Get(entry)
rd.Td = td
rd.Xq = xq
}
// 控制无极继电器励磁
// id - 继电器uid
// td - 是否通电励磁
// xq - 是否到吸起位置(有极继电器)
func driveWjRelay(w ecs.World, entry *ecs.Entry, td bool) {
rd := component.RelayDriveType.Get(entry)
rd.Td = td
}
// 驱动继电器到吸起位置
func DriveRelayUp(w ecs.World, id string) error {
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
if entry.HasComponent(component.YjRelayTag) {
driveYjRelay(w, entry, true, true)
} else {
driveWjRelay(w, entry, true)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的继电器", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
// 驱动继电器到落下位置
func DriveRelayDown(w ecs.World, id string) error {
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
if entry.HasComponent(component.YjRelayTag) {
driveYjRelay(w, entry, true, false)
} else {
driveWjRelay(w, entry, false)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的继电器", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}
// 设置继电器强制故障
func SetRelayFaultForce(w ecs.World, id string, q bool) error {
return updateRelayFault(w, id, func(entry *ecs.Entry) {
component.AddOrUpdateRelayFaultForce(entry, q)
return updateEntity(w, id, "继电器", func(entry *ecs.Entry) error {
entry.AddComponent(component.RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q}))
return nil
})
}
// 取消继电器强制故障
func CancelRelayFaultForce(w ecs.World, id string) error {
return updateRelayFault(w, id, func(entry *ecs.Entry) {
return updateEntity(w, id, "继电器", func(entry *ecs.Entry) error {
entry.RemoveComponent(component.RelayFaultForceType)
return nil
})
}
func updateRelayFault(w ecs.World, id string, faultHandle func(entry *ecs.Entry)) error {
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
faultHandle(entry)
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的继电器", id))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}

239
fi/section.go Normal file
View File

@ -0,0 +1,239 @@
package fi
import (
"fmt"
"strings"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
// AxleSectionDrstDrive 计轴直接复位操作
//
// set : true-设置false-取消
func AxleSectionDrstDrive(w ecs.World, sectionId string, set bool) error {
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
//
sectionModel := wd.Repo.FindPhysicalSection(sectionId)
if sectionModel == nil {
return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
}
// if set {
// axleSectionEntry := wd.EntityMap[sectionId]
// if !axleSectionEntry.HasComponent(component.AxleSectionFaultTag) {
// return ecs.NewErrResult(fmt.Errorf("区段[%s]非故障占用,无法进行复位操作", sectionId))
// }
// }
//
faDcAxleDeviceEntry := entity.FindAxleManageDevice(wd, sectionModel.CentralizedStation())
if faDcAxleDeviceEntry == nil {
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]实体不存在", sectionModel.CentralizedStation()))
}
faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
axleRuntime := faDcAxleDevice.FindAdr(sectionId)
if axleRuntime == nil {
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴设备", sectionModel.CentralizedStation(), sectionId))
}
axleRuntime.Drst = set
//
return ecs.NewOkEmptyResult()
})
return r.Err
}
// AxleSectionPdrstDrive 计轴预复位操作
//
// set : true-设置false-取消
func AxleSectionPdrstDrive(w ecs.World, sectionId string, set bool) error {
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
sectionModel := wd.Repo.FindPhysicalSection(sectionId)
if sectionModel == nil {
return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
}
// if set {
// axleSectionEntry := wd.EntityMap[sectionId]
// if !axleSectionEntry.HasComponent(component.AxleSectionFaultTag) {
// return ecs.NewErrResult(fmt.Errorf("区段[%s]非故障占用,无法进行复位操作", sectionId))
// }
// }
//
faDcAxleDeviceEntry := entity.FindAxleManageDevice(wd, sectionModel.CentralizedStation())
if faDcAxleDeviceEntry == nil {
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]实体不存在", sectionModel.CentralizedStation()))
}
faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
axleRuntime, ok := faDcAxleDevice.Adrs[sectionId]
if !ok {
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴设备", sectionModel.CentralizedStation(), sectionId))
}
axleRuntime.Pdrst = set
//
return ecs.NewOkEmptyResult()
})
return r.Err
}
// AxleSectionFaultOccDrive 区段故障占用设置
//
// set : true - 设置故障占用false - 取消故障占用
func AxleSectionFaultOccDrive(w ecs.World, sectionId string, set bool) error {
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
sectionModel := wd.Repo.FindPhysicalSection(sectionId)
if sectionModel == nil {
return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
}
//
sectionEntry := wd.EntityMap[sectionId]
if sectionEntry == nil {
return ecs.NewErrResult(fmt.Errorf("区段[%s]实体不存在", sectionId))
}
if set { //计轴故障设置
if !sectionEntry.HasComponent(component.AxleSectionFaultTag) {
sectionEntry.AddComponent(component.AxleSectionFaultTag)
}
} else { //计轴故障取消
if sectionEntry.HasComponent(component.AxleSectionFaultTag) {
sectionEntry.RemoveComponent(component.AxleSectionFaultTag)
}
}
//
return ecs.NewOkEmptyResult()
})
return r.Err
}
// AxleSectionTrainDrive 计轴区段内车进入出清设置
//
// trainIn : true - 计轴区段内有车false-计轴区段出清
func AxleSectionTrainDrive(w ecs.World, sectionId string, trainIn bool) error {
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
sectionModel := wd.Repo.FindPhysicalSection(sectionId)
if sectionModel == nil {
return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
}
//
sectionEntry := wd.EntityMap[sectionId]
if sectionEntry == nil {
return ecs.NewErrResult(fmt.Errorf("区段[%s]实体不存在", sectionId))
}
axleDevice := component.AxlePhysicalSectionType.Get(sectionEntry)
if trainIn {
axleDevice.UpdateCount(1)
} else {
axleDevice.UpdateCount(0)
}
//
return ecs.NewOkEmptyResult()
})
return r.Err
}
// FindAxleSectionsStatus 获取计轴区段的相关状态
func FindAxleSectionsStatus(w ecs.World, sectionIds []string) ([]*AxleSectionState, error) {
r := <-ecs.Request[[]*AxleSectionState](w, func() ecs.Result[[]*AxleSectionState] {
wd := entity.GetWorldData(w)
var msg []*AxleSectionState
var esb = strings.Builder{} //收集未找到的区段的id
for _, sectionId := range sectionIds {
find := false
sectionModel := wd.Repo.FindPhysicalSection(sectionId)
if sectionModel != nil {
faDcAxleDeviceEntry := entity.FindAxleManageDevice(wd, sectionModel.CentralizedStation())
if faDcAxleDeviceEntry != nil {
faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
axleDevice := faDcAxleDevice.FindAdr(sectionId)
if axleDevice != nil {
sectionEntry, _ := entity.GetEntityByUid(w, sectionId)
if sectionEntry != nil {
if sectionEntry.HasComponent(component.AxlePhysicalSectionType) { //计轴物理区段实体
as := &AxleSectionState{}
state := component.PhysicalSectionStateType.Get(sectionEntry)
as.Id = component.UidType.Get(sectionEntry).Id
as.Clr = !state.Occ
as.Occ = state.Occ
as.Rac = axleDevice.Rac
as.Rjt = axleDevice.Rjt
as.Rjo = axleDevice.Rjo
//
msg = append(msg, as)
find = true
}
}
}
}
}
//
if !find {
esb.WriteString(fmt.Sprintf("%s,", sectionId))
}
} //for
if esb.Len() > 0 {
return ecs.NewResult(msg, fmt.Errorf("区段非计轴区段或计轴区段状态不存在:[%s]", esb.String()))
} else {
return ecs.NewResult(msg, nil)
}
})
return r.Val, r.Err
}
type AxleSectionState struct {
//uid
Id string
//0-bit7 计轴出清
Clr bool
//0-bit6 计轴占用
Occ bool
//1-bit6 计轴复位反馈
Rac bool
//1-bit5 运营原因拒绝计轴复位
Rjo bool
//1-bit4 技术原因拒绝计轴复位
Rjt bool
}
// AxleSectionRstDrive 复位(直接复位、预复位)
func AxleSectionRstDrive(w ecs.World, cmds []*AxleSectionCmd) error {
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
var esb = strings.Builder{} //收集未找到的区段的id
find := false
for _, cmd := range cmds {
sectionId := cmd.SectionId
sectionModel := wd.Repo.FindPhysicalSection(sectionId)
if sectionModel != nil {
faDcAxleDeviceEntry := entity.FindAxleManageDevice(wd, sectionModel.CentralizedStation())
if faDcAxleDeviceEntry != nil {
faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
axleRuntime := faDcAxleDevice.FindAdr(sectionId)
if axleRuntime != nil {
axleRuntime.Pdrst = cmd.Pdrst
axleRuntime.Drst = cmd.Drst
find = true
}
}
}
if !find {
esb.WriteString(fmt.Sprintf("%s,", sectionId))
}
} //for
if esb.Len() > 0 {
return ecs.NewErrResult(fmt.Errorf("计轴区段复位操作,失败列表[%s]", esb.String()))
} else {
return ecs.NewOkEmptyResult()
}
})
return r.Err
}
type AxleSectionCmd struct {
SectionId string
Drst bool
Pdrst bool
}

View File

@ -99,18 +99,6 @@ type TrainHeadPositionInfo struct {
Speed float32
//加速度(m/s^2)
Acceleration float32
//列车上一次所在轨道link
OldLink string
//列车上一次车头位置信息
OldLinkOffset int64
TailUp bool
TailLink string
//列车上一次车头位置信息
TailLinkOffset int64
OldTailLink string
//列车上一次车头位置信息
OldTailLinkOffset int64
IsLine12 bool
}
func (t *TrainHeadPositionInfo) String() string {

4
go.mod
View File

@ -4,11 +4,11 @@ go 1.21
require (
github.com/stretchr/testify v1.8.4
google.golang.org/protobuf v1.32.0
google.golang.org/protobuf v1.31.0
joylink.club/ecs v0.0.1
)
replace joylink.club/ecs => ./jl-ecs
replace joylink.club/ecs => ./jl-ecs-go
require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect

7
go.sum
View File

@ -1,5 +1,7 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@ -9,7 +11,10 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZV
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/yohamta/donburi v1.3.9 h1:sYAPaelSnxmoTGjgH9ZlYt4pUKrnwvAv4YGXxLZCK6E=
github.com/yohamta/donburi v1.3.9/go.mod h1:5QkyraUjkzbMVTD2b8jaPFy1Uwjm/zdFN1c1lZGaezg=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

View File

@ -2,5 +2,5 @@ go 1.21
use (
.
./jl-ecs
./jl-ecs-go
)

View File

@ -1,42 +1,31 @@
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ebitengine/purego v0.0.0-20220905075623-aeed57cda744/go.mod h1:Eh8I3yvknDYZeCuXH9kRNaPuHEwvXDCk378o9xszmHg=
github.com/ebitengine/purego v0.1.0 h1:vAEo1FvmbjA050QKsbDbcHj03hhMMvh0fmr9LSehpnU=
github.com/ebitengine/purego v0.1.0/go.mod h1:Eh8I3yvknDYZeCuXH9kRNaPuHEwvXDCk378o9xszmHg=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220806181222-55e207c401ad h1:kX51IjbsJPCvzV9jUoVQG9GEUqIq5hjfYzXTqQ52Rh8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220806181222-55e207c401ad/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/hajimehoshi/bitmapfont/v2 v2.2.2/go.mod h1:Ua/x9Dkz7M9CU4zr1VHWOqGwjKdXbOTRsH7lWfb1Co0=
github.com/hajimehoshi/ebiten/v2 v2.4.13 h1:ZZ5y+bFkAbUeD2WGquHF+xSbg83SIbcsxCwEVeZgHWM=
github.com/hajimehoshi/ebiten/v2 v2.4.13/go.mod h1:BZcqCU4XHmScUi+lsKexocWcf4offMFwfp8dVGIB/G4=
github.com/hajimehoshi/file2byteslice v0.0.0-20210813153925-5340248a8f41/go.mod h1:CqqAHp7Dk/AqQiwuhV1yT2334qbA/tFWQW0MD2dGqUE=
github.com/hajimehoshi/file2byteslice v1.0.0 h1:ljd5KTennqyJ4vG9i/5jS8MD1prof97vlH5JOdtw3WU=
github.com/hajimehoshi/file2byteslice v1.0.0/go.mod h1:CqqAHp7Dk/AqQiwuhV1yT2334qbA/tFWQW0MD2dGqUE=
github.com/hajimehoshi/go-mp3 v0.3.3/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
github.com/hajimehoshi/oto/v2 v2.3.1/go.mod h1:seWLbgHH7AyUMYKfKYT9pg7PhUu9/SisyJvNTT+ASQo=
github.com/jakecoffman/cp v1.2.1/go.mod h1:JjY/Fp6d8E1CHnu74gWNnU0+b9VzEdUVPoJxg2PsTQg=
github.com/jezek/xgb v1.0.1 h1:YUGhxps0aR7J2Xplbs23OHnV1mWaxFVcOl9b+1RQkt8=
github.com/jezek/xgb v1.0.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
github.com/jfreymuth/oggvorbis v1.0.4/go.mod h1:1U4pqWmghcoVsCJJ4fRBKv9peUJMBHixthRlBeD6uII=
github.com/jfreymuth/vorbis v1.0.2/go.mod h1:DoftRo4AznKnShRl1GxiTFCseHr4zR9BN3TWXyuzrqQ=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
@ -50,16 +39,13 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 h1:estk1glOnSVeJ9tdEZZc5mAMDZk5lNJNyJ6DvrBkTEU=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.1.0 h1:r8Oj8ZA2Xy12/b5KZYj3tuv7NG/fBz3TwQVvpJ9l8Rk=
golang.org/x/image v0.1.0/go.mod h1:iyPr49SD/G/TBxYVB/9RRtGUT5eNbo2u4NamWeQcD5c=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mobile v0.0.0-20220722155234-aaac322e2105/go.mod h1:pe2sM7Uk+2Su1y7u/6Z8KJ24D7lepUjFZbhFOrmDfuQ=
golang.org/x/mobile v0.0.0-20221012134814-c746ac228303 h1:K4fp1rDuJBz0FCPAWzIJwnzwNEM7S6yobdZzMrZ/Zws=
golang.org/x/mobile v0.0.0-20221012134814-c746ac228303/go.mod h1:M32cGdzp91A8Ex9qQtyZinr19EYxzkFqDjW2oyHzTDQ=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@ -87,7 +73,6 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43 h1:OK7RB6t2WQX54srQQYSXMW8dF5C6/8+oA/s5QBmmto4=
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@ -103,9 +88,6 @@ golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098/go.mod h1:LGqMHiF4EqQNHR
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -10,7 +10,7 @@ import (
const (
// 仿真循环间隔单位ms
RtssSimulationTick = 10
RtssSimulationTick = 20
)
// 初始化仿真

1
jl-ecs

@ -1 +0,0 @@
Subproject commit f0a56ea6722b620c8b900efa9f0d626f00af00ad

1
jl-ecs-go Submodule

@ -0,0 +1 @@
Subproject commit 9c5dde7b2ec28c555488eee7dec81bb1f612c443

View File

@ -1,22 +1,43 @@
package model
// 电子元件
type Ec interface {
Model
// 编号
Code() string
}
// 开关
type PowerSwitch interface {
Model
// 编号
Code()
Ec
}
// 信号状态表示灯
type Lamp interface {
Model
// 编号
Code()
Ec
}
// 蜂鸣器/报警电铃
type Buzzer interface {
Model
// 编号
Code()
Ec
}
// 继电器
type Relay interface {
Ec
// 是否无极继电器
IsWj() bool
// 是否有极继电器
IsYj() bool
// 是否偏极继电器
IsPj() bool
// 是否缓放继电器
IsHf() bool
// 获取缓放时间,单位ms
GetHfTime() int
}
// 断相保护器
type Dbq interface {
Ec
}

View File

@ -13,22 +13,12 @@ const (
)
// 道岔端口
type Turnout_Port int
type Points_Port int
const (
TPort_A Turnout_Port = 1
TPort_B Turnout_Port = 2
TPort_C Turnout_Port = 3
)
// 道岔牵引类型
type PointsTractionType int
const (
// ZDJ9单机牵引
PTT_ZDJ9_1 PointsTractionType = 1
// ZDJ9双机牵引
PTT_ZDJ9_2 PointsTractionType = 2
TPort_A Points_Port = 1
TPort_B Points_Port = 2
TPort_C Points_Port = 3
)
// 道岔
@ -40,8 +30,10 @@ type Points interface {
GetBLinkPort() *LinkPort
// 获取C方向连接的link端口
GetCLinkPort() *LinkPort
// 获取牵引类型
GetTractionType() PointsTractionType
// 是否为ZDJ9单机牵引道岔
IsZdj9_1() bool
// 是否为ZDJ9双机牵引道岔
IsZdj9_2() bool
// 获取转辙机数量
GetZzjCount() int
}

View File

@ -1,32 +0,0 @@
package model
// 继电器位置
type Relay_Position int
const (
// 继电器位置-后(表示落下/反位)
RelayPos_H Relay_Position = 0
// 继电器位置-前(表示吸起/定位)
RelayPos_Q Relay_Position = 1
)
// 继电器型号
type Relay_Model int
const (
RelayModel_JPXC_1000 Relay_Model = 1
RelayModel_JPXC_1700 Relay_Model = 2
RelayModel_JWJXC_480 Relay_Model = 3
RelayModel_JWJXC_H125_80 Relay_Model = 4
RelayModel_JWXC_1700 Relay_Model = 5
RelayModel_JWXC_H340 Relay_Model = 6
RelayModel_JYJXC_160_260 Relay_Model = 7
RelayModel_JZXC_H18 Relay_Model = 8
)
// 继电器
type Relay interface {
Model
Code()
Model() Relay_Model
}

View File

@ -22,27 +22,52 @@ type EcStation interface {
GetPsds() []Psd
// 获取所有物理检测区段
GetPhysicalSections() []PhysicalSection
// 获取所有继电器
GetRelays() []Relay
// 获取所有断相保护器
GetDbqs() []Dbq
// 获取联锁驱采表
GetCiQCTable()
GetCiQcb() CiQcb
// 获取联锁设备电子元件组合
GetCiDeccs() []CiDecc
}
// 联锁设备电子元件组合
type CiDecc interface {
// 是否道岔设备组合
IsPoints() bool
// 是否信号机设备组合
IsSignal() bool
// 设备uid
Duid() string
// 电子元件组合
Eccs() []Ecc
}
type Ecc interface {
// 组合类型编号
Code() string
// 组合关联的电子元件id
Ecs() []Ec
}
// 联锁驱采表
type CiQCTable interface {
type CiQcb interface {
// 驱动码位表(每一位所驱动的继电器uid)
QD() []string
// 采集码位表(每一位所采集的继电器位置)
CJ() []CiCJ
CJ() []CiCj
}
// 联锁采集
type CiCJ interface {
CjPos() []CiCJPos
type CiCj interface {
CjPos() []CiCjPos
}
// 联锁采集继电器位置
type CiCJPos interface {
type CiCjPos interface {
// 继电器uid
RelayId() string
// 继电器位置
Pos() Relay_Position
// 继电器位置,true:前位/吸起/定位,false:后位/落下/反位
Pos() bool
}

View File

@ -23,13 +23,18 @@ type Turnout struct {
cdLink *Link
}
// GetZzjCount implements model.Points.
func (*Turnout) GetZzjCount() int {
// IsZdj9_1 implements model.Points.
func (*Turnout) IsZdj9_1() bool {
panic("unimplemented")
}
// GetTractionType implements model.Turnout.
func (t *Turnout) GetTractionType() model.PointsTractionType {
// IsZdj9_2 implements model.Points.
func (*Turnout) IsZdj9_2() bool {
panic("unimplemented")
}
// GetZzjCount implements model.Points.
func (*Turnout) GetZzjCount() int {
panic("unimplemented")
}

View File

@ -31,3 +31,20 @@ func (s *PhysicalSection) Type() model.ModelType {
func (s *PhysicalSection) Code() string {
return s.code
}
type LogicalSection struct {
uid string
code string
}
func (s *LogicalSection) Uid() string {
return s.uid
}
func (s *LogicalSection) Type() model.ModelType {
return model.ModelType_Section
}
func (s *LogicalSection) Code() string {
return s.code
}

View File

@ -19,7 +19,7 @@ var goOutDir string = "./"
func main() {
//先安装以下插件
//go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.33.0
//go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
args := os.Args
if len(args) >= 2 {
switch {

View File

@ -4,53 +4,24 @@ package component;
option go_package = "./component/component_data";
//
message MotorState {
//
bool powerUp = 1;
//
bool forward = 2;
}
// (81,3,1),1,2
// ,,
// 2DQJ,1,2;3,4
// false表示落下//,true表示吸起//
// ,0.3s以上的继电器()()
// ,
//
message RelayState {
//
bool powerUp = 1;
//
bool qq = 2;
//
bool q = 3;
}
//
message SwitchState {
// (true表示按下,true非常态位)
bool pressed = 2;
}
//
message FixedPositionTransform {
int32 pos = 1; // ,[0, 10000]
int32 pos = 1; // ,[0, 100]
int32 speed = 2;
}
//
message BitState {
bool val = 1;
}
// /
message Counter {
int32 val = 1;
int32 step = 2;
}
// /
message CounterDown {
int32 val = 1;
int32 step = 2;
}
// Link位置
message LinkPosition{
//Link的ID
@ -58,9 +29,3 @@ message LinkPosition{
//Link的偏移量
int64 offset = 2;
}
// /
message CounterDown {
int32 val = 1;
int32 step = 2;
}

View File

@ -3,7 +3,37 @@ syntax = "proto3";
package component;
option go_package = "./component/component_data";
// (81,3,1),1,2
// ,,
// 2DQJ,1,2;3,4
// false表示落下//,true表示吸起//
// ,0.3s以上的继电器()()
// ,
//
message RelayState {
//
bool powerUp = 1;
//
bool excQw = 2;
//
bool q = 3;
}
// ()
message RelayFaultForce {
bool q = 1; // ()
}
//
message DbqState {
bool powerUp = 1; //
bool swOn = 2; //
}
//
message MotorState {
//
bool powerUp = 1;
//
bool forward = 2;
}

View File

@ -10,9 +10,9 @@ option go_package = "./component/component_data";
// 1DQJ和1DQJF励磁吸起,2DQJ在定位,,,21,,43,3,
message PointsZzjKbqState {
// 1/2,false-1,true-2
bool jd13 = 1;
bool jd12 = 1;
// 3/4,false-3,true-4
bool jd24 = 2;
bool jd34 = 2;
}
//
@ -44,16 +44,17 @@ message Points {
}
}
//
message PointsFaultSB {
}
//
message PointsFaultDwsb {
}
//
message PointsFaultFwsb {
message PointsFaultSb {
//
enum Type {
//
ALL = 0;
//
DW = 1;
//
FW = 2;
}
Type type = 1; //
}
//
message PointsFaultJc {

View File

@ -6,8 +6,7 @@ option go_package = "./component/component_proto";
message PsdState {
bool close = 1;
bool obstacle = 2; //
bool interlockRelease = 3; //
bool obstacle = 2;
}
message Psd {
@ -23,6 +22,4 @@ message AsdState {
bool kmdw = 2; //
bool mgj = 3; //
bool zaw = 4; //
bool force = 5; ///
}

View File

@ -28,15 +28,6 @@ message Repository {
repeated Key Keys = 21;
repeated CentralizedStationRef CentralizedStationRefs = 22;
repeated Route routes = 23;
repeated Ckm ckms = 24;
repeated Xcj xcjs = 25;
repeated CkmPsl ckmPsls = 26;
repeated Esb esbs = 27;
repeated Spks spkss = 28;
repeated AxleCountingSection axleCountingSections = 29; //
repeated KilometerCalibration kilometerCalibrations = 30; //
repeated StopPosition stopPosition = 31;
//ISCS [300,500]
//ISCS管线
repeated Pipe pipes = 300;
@ -81,15 +72,7 @@ message Repository {
//ISCS气体环境
repeated GasEnvironment gasEnvironments = 320;
}
message StopPosition{
string id = 1;
uint32 linkId = 2;
uint32 linkOffset = 3;
Kilometer km = 4;
string sectionId = 5; //
DevicePort turnoutPort = 6; //
uint32 coachNum = 7;//
}
//
message SignalLayout {
//
@ -109,16 +92,8 @@ message PhysicalSection {
repeated string turnoutIds = 2; //
DevicePort aDevicePort = 3; //A端关联的设备端口
DevicePort bDevicePort = 4;
//uid
repeated string centralizedStation = 5;
repeated ElectronicComponentGroup electronicComponentGroups = 6;
}
//
message AxleCountingSection {
string id = 1;
repeated string axleCountingIds = 2;
repeated TurnoutAndPos turnoutAndPos = 3;
//
string centralizedStation = 5;
}
//
@ -136,11 +111,6 @@ message Turnout {
ZDJ9_Single = 1;
ZDJ9_Double = 2;
}
enum Pos {
Pos_Unknown = 0;
Pos_N = 1; //
Pos_R = 2; //
}
string id = 1;
Kilometer km = 2;
DevicePort aDevicePort = 3;
@ -190,8 +160,6 @@ message Transponder {
bytes fixedTelegram = 5;//
Type type = 6;//
bytes fixedUserTelegram = 7; //
uint32 leuIndex = 8; //LEU的索引
uint32 indexInLeu = 9; //LEU内部的索引
enum Type {
FB = 0; //
WB = 1; //
@ -222,12 +190,6 @@ message DevicePort {
Port port = 3;
}
//
message TurnoutAndPos {
string turnoutId = 1;
Turnout.Pos pos = 2;
}
enum DeviceType {
DeviceType_Unknown = 0;
DeviceType_PhysicalSection = 1;
@ -252,20 +214,11 @@ enum DeviceType {
//
DeviceType_SignalFaultAlarm = 20;
//
DeviceType_Breakers = 21;
DeviceType_Breakers = 21;
//
DeviceType_PowerScreen = 22;
DeviceType_PowerScreen = 22;
//
DeviceType_Route = 23;
DeviceType_Ckm = 24; //
DeviceType_Xcj = 25; //
DeviceType_CkmPsl = 26; //PSL
DeviceType_TrackCircuit = 27; //
DeviceType_LS = 28; //
DeviceType_Esb = 29; //
DeviceType_Spks = 30; //
DeviceTYpe_AxleCountingSection = 31; //
deviceType_Stop_position = 32;
//--------ISCS [300,500]------
//ISCS门磁
@ -431,12 +384,6 @@ message KilometerConvert {
bool sameTrend = 3; //
}
//
message KilometerCalibration {
Kilometer design = 1; //
Kilometer actual = 2; //
}
//
enum Direction {
LEFT = 0;
@ -463,16 +410,10 @@ message Relay {
JYJXC_160_260 = 7;
JZXC_H18 = 8;
}
enum Pos {
Pos_None = 0; //
Pos_Q = 1; //
Pos_H = 2; //
}
string id = 1;
string code = 2;
Model model = 3;
string stationId = 4; // id
Pos defaultPos = 5; //
}
//
@ -548,57 +489,23 @@ message ElectronicGroup {
//
message ElectronicComponent {
string id = 1; // ID
string id= 1; // ID
DeviceType deviceType = 3; //
}
//
message Mkx {
string id = 1;
string psdId = 2;
string pcbaId = 3; //
string pcbplaId = 4; //
string pcbjId = 5; //
string pobaId = 6; //
string pobplaId = 7; //
string pobjId = 8; //
string pabaId = 9; //
string pabplaId = 10; //
string pabjId = 11; //
string wrzfaId = 12; //
string wrzfplaId = 13; //
string wrzfjId = 14; //
string qkqraId = 15; //
string qkqrplaId = 16; //
string qkqrjId = 17; //
string mplaId = 18; //
string jxtcplaId = 19; //
string pcbButtonId = 3;
string pobButtonId = 4;
string pabButtonId = 5;
string pcbjId = 6;
string pobjId = 7;
string pabjId = 8;
}
//PSL
message CkmPsl {
string id = 1;
string ckmId = 2;
string gmaId = 3; //
string kmaId = 4; //
string mplaId = 5; //
string mmsaId = 6; //
}
//
message Esb {
string id = 1;
string platformId = 2;
}
//
message Spks {
string id = 1;
string code = 2;
string platformId = 3;
}
//
message Platform {
enum Direction {
enum PlatformDirection {
Unknown = 0;
Up = 1; //
Down = 2; //
@ -607,8 +514,7 @@ message Platform {
string code = 2;
string stationId = 3;
string physicalSectionId = 4;
Direction direction = 5;
repeated ElectronicComponentGroup electronicComponentGroups = 6; //
PlatformDirection direction = 5;
}
//
@ -807,10 +713,10 @@ message Valve{
string code = 2;
//
enum Type{
ElectricControlValve = 0;//
ElectricAirValve = 1;//
CombinationAirValve = 2;//
ElectricButterflyValve = 3;//
ElectricControlValve = 0;//
ElectricAirValve = 1;//
CombinationAirValve = 2;//
ElectricButterflyValve = 3;//
}
Type valveType = 3;//
}
@ -867,16 +773,3 @@ message GasEnvironment{
string code = 2;
}
//
message Ckm {
string id = 1;
repeated ElectronicComponentGroup electronicComponentGroups = 2;
}
//
message Xcj {
string id = 1;
repeated ElectronicComponentGroup electronicComponentGroups = 2;
uint32 numSegments = 3; //
}

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,29 +0,0 @@
package repository
import "joylink.club/rtsssimulation/repository/model/proto"
type AxleCountingSection struct {
Identity
//axleCountingList []CheckPoint //暂时用不上,先不要了
turnoutAndPosList []*proto.TurnoutAndPos
physicalSection *PhysicalSection
}
func NewAxleCountingSection(id string, turnoutAndPosList []*proto.TurnoutAndPos) *AxleCountingSection {
return &AxleCountingSection{
Identity: identity{
id: id,
deviceType: proto.DeviceType_DeviceTYpe_AxleCountingSection,
},
turnoutAndPosList: turnoutAndPosList,
}
}
func (a *AxleCountingSection) TurnoutAndPosList() []*proto.TurnoutAndPos {
return a.turnoutAndPosList
}
func (a *AxleCountingSection) PhysicalSection() *PhysicalSection {
return a.physicalSection
}

View File

@ -9,7 +9,7 @@ type CheckPoint struct {
km *proto.Kilometer
pointType proto.CheckPointType //检测点类型
devicePorts []DevicePort //检测点关联的设备及其端口
linkPosition LinkPosition
linkPosition *LinkPosition
}
func NewCheckPoint(id string, km *proto.Kilometer, pointType proto.CheckPointType) *CheckPoint {
@ -20,14 +20,10 @@ func NewCheckPoint(id string, km *proto.Kilometer, pointType proto.CheckPointTyp
}
}
func (c *CheckPoint) LinkPosition() LinkPosition {
return c.linkPosition
}
func (c *CheckPoint) bindDevicePort(devicePort DevicePort) {
c.devicePorts = append(c.devicePorts, devicePort)
}
func (c *CheckPoint) bindLinkPosition(position LinkPosition) {
func (c *CheckPoint) bindLinkPosition(position *LinkPosition) {
c.linkPosition = position
}

View File

@ -1,18 +0,0 @@
package repository
import "joylink.club/rtsssimulation/repository/model/proto"
type Ckm struct {
Identity
componentGroups []*ElectronicComponentGroup
}
func NewCkm(id string) *Ckm {
return &Ckm{
Identity: identity{id, proto.DeviceType_DeviceType_Ckm},
}
}
func (p *Ckm) ComponentGroups() []*ElectronicComponentGroup {
return p.componentGroups
}

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

@ -11,23 +11,21 @@ type IGroupedElectronicComponent interface {
// Relay 继电器
type Relay struct {
Identity
code string
model proto.Relay_Model
defaultPos proto.Relay_Pos
code string
model proto.Relay_Model
// 所属车站
station *Station
}
func newRelay(id string, code string, model proto.Relay_Model, defaultPos proto.Relay_Pos, s *Station) *Relay {
func newRelay(id string, code string, model proto.Relay_Model, s *Station) *Relay {
return &Relay{
Identity: identity{
id: id,
deviceType: proto.DeviceType_DeviceType_Relay,
},
code: code,
model: model,
defaultPos: defaultPos,
station: s,
code: code,
model: model,
station: s,
}
}
@ -39,10 +37,6 @@ func (r *Relay) Model() proto.Relay_Model {
return r.model
}
func (r *Relay) DefaultPos() proto.Relay_Pos {
return r.defaultPos
}
// ElectronicComponentGroup 电子元件组合
type ElectronicComponentGroup struct {
code string

View File

@ -1,16 +0,0 @@
package repository
// Esb 紧急停车系统。目前内部属性仅作为和第三方联锁通信时,获取紧急停车系统状态的便捷途径
type Esb struct {
Identity
plaId string //旁路按钮ID
relayId string //紧急停车继电器ID
}
func (e *Esb) PlaId() string {
return e.plaId
}
func (e *Esb) RelayId() string {
return e.relayId
}

View File

@ -1,7 +1,6 @@
package repository
import (
"fmt"
"joylink.club/rtsssimulation/repository/model/proto"
)
@ -18,8 +17,8 @@ type Link struct {
aKm *proto.Kilometer
bKm *proto.Kilometer
//按偏移量小到大排序的、此Link上的模型非区段边界检测点、应答器、信号机
devices []LinkPositionDevice
//Link上的模型非区段边界检测点、应答器、信号机
devices []Identity
////Link关联的模型包含LinkNode
//devicePositions []*DeviceLinkPosition
@ -59,7 +58,7 @@ func (l *Link) BRelation() *TurnoutPort {
return l.bRelation
}
func (l *Link) Devices() []LinkPositionDevice {
func (l *Link) Devices() []Identity {
return l.devices
}
@ -102,7 +101,7 @@ func (l *Link) bindKm(km *proto.Kilometer, port proto.Port) {
}
}
func (l *Link) bindDevices(devices ...LinkPositionDevice) {
func (l *Link) bindDevices(devices ...Identity) {
for _, device := range devices {
l.devices = append(l.devices, device)
}
@ -138,18 +137,14 @@ type LinkPosition struct {
func NewLinkPosition(link *Link, offset int64) *LinkPosition {
return &LinkPosition{link: link, offset: offset}
}
func (l LinkPosition) Link() *Link {
func (l *LinkPosition) Link() *Link {
return l.link
}
func (l LinkPosition) Offset() int64 {
func (l *LinkPosition) Offset() int64 {
return l.offset
}
func (l LinkPosition) String() string {
return fmt.Sprintf("[LinkPosition:{%s-%d]", l.link.Id(), l.offset)
}
// link端口
type LinkPort struct {
link *Link

56
repository/mkx.go Normal file
View File

@ -0,0 +1,56 @@
package repository
import "joylink.club/rtsssimulation/repository/model/proto"
type Mkx struct {
Identity
psd *Psd
pcb *Button
pob *Button
pab *Button
mpl *Button
pcbj *Relay
pobj *Relay
pabj *Relay
}
func NewMkx(id string) *Mkx {
return &Mkx{
Identity: identity{
id: id,
deviceType: proto.DeviceType_DeviceType_Mkx,
},
}
}
func (m *Mkx) Psd() *Psd {
return m.psd
}
func (m *Mkx) Pcb() *Button {
return m.pcb
}
func (m *Mkx) Pob() *Button {
return m.pob
}
func (m *Mkx) Pab() *Button {
return m.pab
}
func (m *Mkx) Mpl() *Button {
return m.mpl
}
func (m *Mkx) Pcbj() *Relay {
return m.pcbj
}
func (m *Mkx) Pobj() *Relay {
return m.pobj
}
func (m *Mkx) Pabj() *Relay {
return m.pabj
}

View File

@ -22,13 +22,6 @@ func (m identity) Type() proto.DeviceType {
return m.deviceType
}
// LinkPositionDevice 有link位置的设备
type LinkPositionDevice interface {
Identity
LinkPosition() LinkPosition
bindLinkPosition(position LinkPosition)
}
//////////////////////////system中使用///////////////////////////////////
// IRelayCRole 获取继电器在具体电路中的角色(组合类型、功能名称)

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ import (
"joylink.club/rtsssimulation/util/number"
)
// PhysicalSection 物理区段
// 物理区段
type PhysicalSection struct {
Identity
@ -33,18 +33,11 @@ type PhysicalSection struct {
//在Link上的区间start小于end
linkRanges []*LinkRange
//物理区段所属集中站uid
centralizedStation []*Station
//物理区段所属集中站
centralizedStation string
// 所属站台
platform *Platform
//电子元件
componentGroups []*ElectronicComponentGroup
}
func (p *PhysicalSection) ComponentGroups() []*ElectronicComponentGroup {
return p.componentGroups
}
func NewPhysicalSection(id string) *PhysicalSection {
@ -61,44 +54,44 @@ func (p *PhysicalSection) bindLinkRange(link *Link, one int64, two int64) {
})
}
func (p *PhysicalSection) PortNum() int {
func (s *PhysicalSection) PortNum() int {
return 2
}
func (p *PhysicalSection) ALinkPosition() *LinkPosition {
return p.aLinkPosition
func (s *PhysicalSection) ALinkPosition() *LinkPosition {
return s.aLinkPosition
}
func (p *PhysicalSection) BLinkPosition() *LinkPosition {
return p.bLinkPosition
func (s *PhysicalSection) BLinkPosition() *LinkPosition {
return s.bLinkPosition
}
func (p *PhysicalSection) ARelation() DevicePort {
return p.aRelation
func (s *PhysicalSection) ARelation() DevicePort {
return s.aRelation
}
func (p *PhysicalSection) BRelation() DevicePort {
return p.bRelation
func (s *PhysicalSection) BRelation() DevicePort {
return s.bRelation
}
func (p *PhysicalSection) AKilometer() *proto.Kilometer {
return p.aKm
func (s *PhysicalSection) AKilometer() *proto.Kilometer {
return s.aKm
}
func (p *PhysicalSection) BKilometer() *proto.Kilometer {
return p.bKm
func (s *PhysicalSection) BKilometer() *proto.Kilometer {
return s.bKm
}
// IsAxleSection 判断是否为计轴区段
func (p *PhysicalSection) IsAxleSection() (bool, error) {
if len(p.checkPoints) > 0 {
func (s *PhysicalSection) IsAxleSection() (bool, error) {
if len(s.checkPoints) > 0 {
axleCount := 0
for _, cp := range p.checkPoints {
for _, cp := range s.checkPoints {
if cp.pointType == proto.CheckPointType_AxleCounter {
axleCount++
}
}
if axleCount == len(p.checkPoints) {
if axleCount == len(s.checkPoints) {
return true, nil
} else if axleCount == 0 {
return false, nil
@ -109,10 +102,10 @@ func (p *PhysicalSection) IsAxleSection() (bool, error) {
return false, fmt.Errorf("物理区段没有检测点")
}
}
func (p *PhysicalSection) CentralizedStation() []*Station {
return p.centralizedStation
func (s *PhysicalSection) CentralizedStation() string {
return s.centralizedStation
}
func (p *PhysicalSection) bindDevicePort(port proto.Port, devicePort DevicePort) error {
func (s *PhysicalSection) bindDevicePort(port proto.Port, devicePort DevicePort) error {
_, isSectionPort := devicePort.(*PhysicalSectionPort)
_, isTurnoutPort := devicePort.(*TurnoutPort)
if !isSectionPort && !isTurnoutPort {
@ -120,9 +113,9 @@ func (p *PhysicalSection) bindDevicePort(port proto.Port, devicePort DevicePort)
}
switch port {
case proto.Port_A:
p.aRelation = devicePort
s.aRelation = devicePort
case proto.Port_B:
p.bRelation = devicePort
s.bRelation = devicePort
default:
return fmt.Errorf("物理区段无端口[%s]", port)
}
@ -130,15 +123,15 @@ func (p *PhysicalSection) bindDevicePort(port proto.Port, devicePort DevicePort)
}
// 绑定区段边界公里标。(仅限非道岔物理区段调用)
func (p *PhysicalSection) bindBoundaryKm(km *proto.Kilometer, port proto.Port) error {
func (s *PhysicalSection) bindBoundaryKm(km *proto.Kilometer, port proto.Port) error {
if km == nil || (km.CoordinateSystem == "" && km.Value == 0) {
return nil
}
switch port {
case proto.Port_A:
p.aKm = km
s.aKm = km
case proto.Port_B:
p.bKm = km
s.bKm = km
default:
return fmt.Errorf("区段无端口[%s]", port)
}
@ -146,56 +139,56 @@ func (p *PhysicalSection) bindBoundaryKm(km *proto.Kilometer, port proto.Port) e
}
// 道岔物理区段绑定道岔
func (p *PhysicalSection) bindTurnouts(turnouts ...*Turnout) {
func (s *PhysicalSection) bindTurnouts(turnouts ...*Turnout) {
for _, turnout := range turnouts {
p.turnouts = append(p.turnouts, turnout)
s.turnouts = append(s.turnouts, turnout)
for _, cp := range turnout.checkPoints() {
p.bindDevices(cp)
s.bindDevices(cp)
}
}
}
func (p *PhysicalSection) bindDevices(devices ...Identity) {
func (s *PhysicalSection) bindDevices(devices ...Identity) {
for _, device := range devices {
p.devices = append(p.devices, device)
s.devices = append(s.devices, device)
cp, ok := device.(*CheckPoint)
if ok {
p.checkPoints = append(p.checkPoints, cp)
s.checkPoints = append(s.checkPoints, cp)
}
}
}
func (p *PhysicalSection) findOtherDevicePort(port proto.Port) DevicePort {
func (s *PhysicalSection) findOtherDevicePort(port proto.Port) DevicePort {
switch port {
case proto.Port_A:
return p.bRelation
return s.bRelation
case proto.Port_B:
return p.aRelation
return s.aRelation
}
return nil
}
func (p *PhysicalSection) findOtherBoundaryKmByPort(port proto.Port) *proto.Kilometer {
func (s *PhysicalSection) findOtherBoundaryKmByPort(port proto.Port) *proto.Kilometer {
switch port {
case proto.Port_A:
return p.bKm
return s.bKm
case proto.Port_B:
return p.aKm
return s.aKm
}
return nil
}
func (p *PhysicalSection) findBoundaryKmByPort(port proto.Port) *proto.Kilometer {
func (s *PhysicalSection) findBoundaryKmByPort(port proto.Port) *proto.Kilometer {
switch port {
case proto.Port_A:
return p.aKm
return s.aKm
case proto.Port_B:
return p.bKm
return s.bKm
}
return nil
}
func (p *PhysicalSection) LinkRanges() []*LinkRange {
return p.linkRanges
func (s *PhysicalSection) LinkRanges() []*LinkRange {
return s.linkRanges
}
func (p *PhysicalSection) Platform() *Platform {

View File

@ -4,21 +4,18 @@ import "joylink.club/rtsssimulation/repository/model/proto"
type Platform struct {
Identity
code string
dir proto.Platform_Direction
station *Station
section *PhysicalSection
componentGroups []*ElectronicComponentGroup
code string
station *Station
section *PhysicalSection
}
func NewPlatform(id string, code string, dir proto.Platform_Direction) *Platform {
func NewPlatform(id string, code string) *Platform {
return &Platform{
Identity: identity{
id: id,
deviceType: proto.DeviceType_DeviceType_Platform,
},
code: code,
dir: dir,
}
}
@ -33,7 +30,3 @@ func (p *Platform) Station() *Station {
func (p *Platform) Section() *PhysicalSection {
return p.section
}
func (p *Platform) ComponentGroups() []*ElectronicComponentGroup {
return p.componentGroups
}

View File

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

View File

@ -8,38 +8,29 @@ import (
)
type Repository struct {
id string
version string
coordinate *MapCoordinate // 基准坐标系类型,在列车画图时统一坐标系
physicalSectionMap map[string]*PhysicalSection
axleCountingSectionMap map[string]*AxleCountingSection
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
esbMap map[string]*Esb
spksMap map[string]*Spks
kilometerCalibrationMap map[string][]*proto.KilometerCalibration //从大到小排序
StopPosition map[string]*StopPosition
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
PipeMap map[string]*Pipe //ISCS 管线
PipeFittingMap map[string]*PipeFitting //ISCS 管件
CircuitBreakerMap map[string]*CircuitBreaker //ISCS 断路器
@ -65,37 +56,28 @@ type Repository struct {
func newRepository(id string, version string) *Repository {
return &Repository{
id: id,
version: version,
physicalSectionMap: make(map[string]*PhysicalSection),
axleCountingSectionMap: make(map[string]*AxleCountingSection),
checkPointMap: make(map[string]*CheckPoint),
turnoutMap: make(map[string]*Turnout),
signalMap: make(map[string]*Signal),
responderMap: make(map[string]*Transponder),
slopeMap: make(map[string]*Slope),
sectionalCurvatureMap: make(map[string]*SectionalCurvature),
kilometerConvertMap: make(map[string]*proto.KilometerConvert),
relayMap: make(map[string]*Relay),
phaseFailureProtectorMap: make(map[string]*PhaseFailureProtector),
linkMap: make(map[string]*Link),
buttonMap: make(map[string]*Button),
psdMap: make(map[string]*Psd),
lightMap: make(map[string]*Light),
alarmMap: make(map[string]*Alarm),
stationMap: make(map[string]*Station),
psdPslMap: make(map[string]*PsdPsl),
keyMap: make(map[string]*Key),
platformMap: make(map[string]*Platform),
centralizedMap: make(map[string]*proto.CentralizedStationRef),
ckmMap: make(map[string]*Ckm),
ckmPslMap: make(map[string]*CkmPsl),
xcjMap: make(map[string]*Xcj),
esbMap: make(map[string]*Esb),
spksMap: make(map[string]*Spks),
kilometerCalibrationMap: make(map[string][]*proto.KilometerCalibration),
StopPosition: make(map[string]*StopPosition),
id: id,
version: version,
physicalSectionMap: make(map[string]*PhysicalSection),
checkPointMap: make(map[string]*CheckPoint),
turnoutMap: make(map[string]*Turnout),
signalMap: make(map[string]*Signal),
responderMap: make(map[string]*Transponder),
slopeMap: make(map[string]*Slope),
sectionalCurvatureMap: make(map[string]*SectionalCurvature),
kilometerConvertMap: make(map[string]*proto.KilometerConvert),
relayMap: make(map[string]*Relay),
phaseFailureProtectorMap: make(map[string]*PhaseFailureProtector),
linkMap: make(map[string]*Link),
buttonMap: make(map[string]*Button),
psdMap: make(map[string]*Psd),
lightMap: make(map[string]*Light),
alarmMap: make(map[string]*Alarm),
stationMap: make(map[string]*Station),
mkxMap: make(map[string]*Mkx),
keyMap: make(map[string]*Key),
platformMap: make(map[string]*Platform),
centralizedMap: make(map[string]*proto.CentralizedStationRef),
PipeMap: make(map[string]*Pipe), //ISCS 管线
PipeFittingMap: make(map[string]*PipeFitting), //ISCS 管件
CircuitBreakerMap: make(map[string]*CircuitBreaker), //ISCS 断路器
@ -222,13 +204,6 @@ func (repo *Repository) PhysicalSectionList() []*PhysicalSection {
}
return list
}
func (repo *Repository) AxleCountingSectionList() []*AxleCountingSection {
var list []*AxleCountingSection
for _, model := range repo.axleCountingSectionMap {
list = append(list, model)
}
return list
}
func (repo *Repository) CheckPointList() []*CheckPoint {
var list []*CheckPoint
for _, model := range repo.checkPointMap {
@ -316,9 +291,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
@ -347,54 +322,6 @@ func (repo *Repository) CiQcList() []*proto.CentralizedStationRef {
}
return list
}
func (repo *Repository) CkmList() []*Ckm {
var list []*Ckm
for _, model := range repo.ckmMap {
list = append(list, model)
}
return list
}
func (repo *Repository) XcjList() []*Xcj {
var list []*Xcj
for _, model := range repo.xcjMap {
list = append(list, model)
}
return list
}
func (repo *Repository) CkmPslList() []*CkmPsl {
var list []*CkmPsl
for _, model := range repo.ckmPslMap {
list = append(list, model)
}
return list
}
func (repo *Repository) PlatformList() []*Platform {
var list []*Platform
for _, model := range repo.platformMap {
list = append(list, model)
}
return list
}
func (repo *Repository) CentralizedStationRefList() []*proto.CentralizedStationRef {
var list []*proto.CentralizedStationRef
for _, model := range repo.centralizedMap {
list = append(list, model)
}
return list
}
func (repo *Repository) TransponderList() []*Transponder {
var list []*Transponder
for _, model := range repo.responderMap {
list = append(list, model)
}
return list
}
func (repo *Repository) GetCentralizedStationRef(centralizedStationId string) *proto.CentralizedStationRef {
return repo.centralizedMap[centralizedStationId]
}
@ -479,14 +406,6 @@ func (repo *Repository) FindPhysicalSection(id string) *PhysicalSection {
return repo.physicalSectionMap[id]
}
func (repo *Repository) FindAxleCountingSection(id string) *AxleCountingSection {
return repo.axleCountingSectionMap[id]
}
func (repo *Repository) FindRelay(id string) *Relay {
return repo.relayMap[id]
}
func (repo *Repository) FindStationByStationName(name string) *Station {
for _, s := range repo.StationList() {
if s.code == name {
@ -500,16 +419,12 @@ func (repo *Repository) FindPsd(id string) *Psd {
return repo.psdMap[id]
}
func (repo *Repository) FindPlatform(id string) *Platform {
func (repo *Repository) FindPlatfrom(id string) *Platform {
return repo.platformMap[id]
}
func (repo *Repository) FindEsb(id string) *Esb {
return repo.esbMap[id]
}
func (repo *Repository) FindSpks(id string) *Spks {
return repo.spksMap[id]
func (repo *Repository) AddPhysicalSection(section *PhysicalSection) {
repo.physicalSectionMap[section.Id()] = section
}
func (repo *Repository) ConvertKilometer(km *proto.Kilometer, cs string) (*proto.Kilometer, error) {
@ -584,7 +499,7 @@ func (repo *Repository) generateCoordinateInfo(coordinateSystem string) error {
return nil
}
func (repo *Repository) GetCoordinateInfo() *MapCoordinate {
func (repo Repository) GetCoordinateInfo() *MapCoordinate {
return repo.coordinate
}

View File

@ -0,0 +1,17 @@
package repository
import (
"fmt"
"joylink.club/rtsssimulation/repository/model/proto"
)
//测试
func BuildRepositoryForSignalTest(source *proto.Repository) *Repository {
repository := newRepository(source.Id, source.Version)
buildModels(source, repository)
if err := buildSignalRelationShip(source, repository); err != nil {
fmt.Println("===>>buildSignalRelationShip error : ", err.Error())
}
return repository
}

View File

@ -75,16 +75,5 @@ func baseCheck(source *proto.Repository) []string {
errMsg = append(errMsg, fmt.Sprintf("应答器[%s]缺少关联的区段或道岔", transponder.Id))
}
}
//停车点
for _, sp := range source.StopPosition {
if uidMap[sp.Id] {
errMsg = append(errMsg, fmt.Sprintf("uid[%s]重复", sp.Id))
continue
}
uidMap[sp.Id] = true
if sp.Km == nil || sp.Km.CoordinateSystem == "" {
errMsg = append(errMsg, fmt.Sprintf("停车点[%s]公里标数据错误", sp.Id))
}
}
return errMsg
}

View File

@ -3,13 +3,13 @@ package repository
import (
"errors"
"fmt"
"joylink.club/rtsssimulation/repository/model/proto"
"joylink.club/rtsssimulation/util/number"
"log/slog"
"math"
"sort"
"strconv"
"strings"
"joylink.club/rtsssimulation/repository/model/proto"
"joylink.club/rtsssimulation/util/number"
)
var repositoryMap = make(map[string]*Repository)
@ -55,10 +55,6 @@ func buildModels(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.KilometerConverts {
repository.addKilometerConvert(protoData)
}
err := buildKilometerCalibration(source, repository)
if err != nil {
return err
}
for _, protoData := range source.Stations {
m := NewStation(protoData.Id, protoData.Code)
_, ok := repository.stationMap[m.Id()]
@ -67,53 +63,31 @@ func buildModels(source *proto.Repository, repository *Repository) error {
}
repository.stationMap[m.Id()] = m
}
for _, protoData := range source.PhysicalSections {
m := NewPhysicalSection(protoData.Id)
repository.physicalSectionMap[m.Id()] = m
}
for _, protoData := range source.AxleCountingSections {
m := NewAxleCountingSection(protoData.Id, protoData.TurnoutAndPos)
repository.axleCountingSectionMap[m.Id()] = m
}
for _, protoData := range source.CheckPoints {
calibrationKilometer(protoData.Km, repository)
m := NewCheckPoint(protoData.Id, protoData.Km, protoData.Type)
repository.checkPointMap[m.Id()] = m
}
for _, protoData := range source.Turnouts {
calibrationKilometer(protoData.Km, repository)
m := NewTurnout(protoData.Id, protoData.Km, protoData.SwitchMachineType)
repository.turnoutMap[m.Id()] = m
}
for _, protoData := range source.Signals {
calibrationKilometer(protoData.Km, repository)
m := NewSignal(protoData.Id, protoData.Km, protoData.Code, protoData.Model)
repository.signalMap[m.Id()] = m
}
for _, protoData := range source.Transponders {
calibrationKilometer(protoData.Km, repository)
m := NewTransponder(protoData.Id, protoData.Km, protoData.FixedTelegram, protoData.FixedUserTelegram,
protoData.Type, protoData.LeuIndex, protoData.IndexInLeu)
m := NewTransponder(protoData.Id, protoData.Km, protoData.FixedTelegram, protoData.FixedUserTelegram, protoData.Type)
repository.responderMap[m.Id()] = m
}
for _, sp := range source.StopPosition {
calibrationKilometer(sp.Km, repository)
t := NewStopPosition(sp.Id, sp.Km, sp.CoachNum)
repository.StopPosition[t.Id()] = t
}
for _, protoData := range source.Slopes {
for _, km := range protoData.Kms {
calibrationKilometer(km, repository)
}
m := NewSlope(protoData.Id, protoData.Kms, protoData.Degree)
repository.slopeMap[m.Id()] = m
}
for _, protoData := range source.SectionalCurvatures {
for _, km := range protoData.Kms {
calibrationKilometer(km, repository)
}
m := NewSectionalCurvature(protoData.Id, protoData.Kms, protoData.Radius)
repository.sectionalCurvatureMap[m.Id()] = m
}
@ -122,7 +96,7 @@ func buildModels(source *proto.Repository, repository *Repository) error {
if !ok {
return fmt.Errorf("id=%s的继电器所属车站不存在,车站id=%s", protoData.Id, protoData.StationId)
}
m := newRelay(protoData.Id, protoData.Code, protoData.Model, protoData.DefaultPos, s)
m := newRelay(protoData.Id, protoData.Code, protoData.Model, s)
repository.relayMap[m.Id()] = m
}
for _, protoData := range source.PhaseFailureProtectors {
@ -149,44 +123,26 @@ 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)
repository.keyMap[m.Id()] = m
}
for _, protoData := range source.Platforms {
m := NewPlatform(protoData.Id, protoData.Code, protoData.Direction)
m := NewPlatform(protoData.Id, protoData.Code)
repository.platformMap[m.Id()] = m
}
for _, protoData := range source.Ckms {
m := NewCkm(protoData.Id)
repository.ckmMap[m.Id()] = m
}
for _, protoData := range source.Xcjs {
m := NewXcj(protoData.Id, protoData.NumSegments)
repository.xcjMap[m.Id()] = m
}
for _, protoData := range source.CkmPsls {
m := NewCkmPsl(protoData.Id)
repository.ckmPslMap[m.Id()] = m
}
err = repository.generateCoordinateInfo(source.MainCoordinateSystem)
err := repository.generateCoordinateInfo(source.MainCoordinateSystem)
if err != nil {
return err
}
for _, protoData := range source.CentralizedStationRefs {
repository.centralizedMap[protoData.StationId] = protoData
}
for _, protoData := range source.Esbs {
repository.esbMap[protoData.Id] = &Esb{Identity: identity{id: protoData.Id, deviceType: proto.DeviceType_DeviceType_Esb}}
}
for _, protoData := range source.Spkss {
repository.spksMap[protoData.Id] = &Spks{Identity: identity{id: protoData.Id, deviceType: proto.DeviceType_DeviceType_Spks}}
}
//
err = buildIscsModels(source, repository)
//
return err
}
@ -200,10 +156,6 @@ func buildModelRelationship(source *proto.Repository, repository *Repository) er
if err != nil {
return err
}
err = buildAxleCountingSectionRelationShip(source, repository)
if err != nil {
return err
}
err = buildTurnoutRelationShip(source, repository)
if err != nil {
return err
@ -240,213 +192,9 @@ func buildModelRelationship(source *proto.Repository, repository *Repository) er
if err != nil {
return err
}
err = buildCkmRelationShip(source, repository)
if err != nil {
return err
}
err = buildXcjRelationShip(source, repository)
if err != nil {
return err
}
err = buildCkmPslRelationShip(source, repository)
if err != nil {
return err
}
err = buildEsbRelationship(source, repository)
if err != nil {
return err
}
err = buildSpksRelationship(source, repository)
buildStopPositionRelationShip(source, repository)
return err
}
func calibrationKilometer(km *proto.Kilometer, repository *Repository) {
params := repository.kilometerCalibrationMap[km.CoordinateSystem+km.Direction.String()]
for _, param := range params {
if param.Design.Value <= km.Value {
km.Value += param.Actual.Value - param.Design.Value
break
}
}
}
func buildKilometerCalibration(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.KilometerCalibrations {
key := protoData.Design.CoordinateSystem + protoData.Design.Direction.String()
repository.kilometerCalibrationMap[key] = append(repository.kilometerCalibrationMap[key], protoData)
}
for _, calibrations := range repository.kilometerCalibrationMap {
sort.Slice(calibrations, func(i, j int) bool {
return calibrations[i].Design.Value > calibrations[j].Design.Value
})
}
return nil
}
func buildAxleCountingSectionRelationShip(source *proto.Repository, repository *Repository) error {
turnout_physicalSection_map := make(map[string]*PhysicalSection)
for _, physicalSection := range repository.physicalSectionMap {
for _, turnout := range physicalSection.turnouts {
turnout_physicalSection_map[turnout.Id()] = physicalSection
}
}
for _, protoData := range source.AxleCountingSections {
axleCountingSection := repository.axleCountingSectionMap[protoData.Id]
if len(protoData.TurnoutAndPos) != 0 {
axleCountingSection.physicalSection = turnout_physicalSection_map[protoData.TurnoutAndPos[0].TurnoutId]
} else {
commonPhysicalSectionMap := make(map[*PhysicalSection]int)
for _, axleCountingId := range protoData.AxleCountingIds {
for _, dp := range repository.checkPointMap[axleCountingId].devicePorts {
physicalSection, ok := dp.Device().(*PhysicalSection)
if ok {
commonPhysicalSectionMap[physicalSection]++
}
}
}
for physicalSection, i := range commonPhysicalSectionMap {
if i > 1 {
axleCountingSection.physicalSection = physicalSection
break
}
}
if axleCountingSection.physicalSection == nil { //轨道尽头的区段
for section, _ := range commonPhysicalSectionMap {
if len(section.checkPoints) == 1 {
axleCountingSection.physicalSection = section
break
}
}
}
}
if axleCountingSection.physicalSection == nil {
return fmt.Errorf("计轴区段[%s]找不到对应的物理区段", protoData.Id)
}
}
return nil
}
func buildSpksRelationship(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.Spkss {
platform := repository.platformMap[protoData.PlatformId]
var num byte
if len(protoData.Code) > 4 { //暂时默认Code为SPKS+数字SPKS1、SPKS3等
num = protoData.Code[4] //这一位应该是数字
}
var plajCode string
var relayCode string
switch platform.dir {
case proto.Platform_Up:
plajCode = "SPKSSPLAJ"
relayCode = fmt.Sprintf("SPKSS%cJ", num)
case proto.Platform_Down:
plajCode = "SPKSXPLAJ"
relayCode = fmt.Sprintf("SPKSX%cJ", num)
default:
panic(fmt.Sprintf("未知的站台方向:%s", platform.dir))
}
spks := repository.spksMap[protoData.Id]
station := platform.station
for _, component := range station.spksComponents {
if component.Code() == plajCode && component.Type() == proto.DeviceType_DeviceType_Relay {
spks.plaId = component.Id()
}
if component.Code() == relayCode && component.Type() == proto.DeviceType_DeviceType_Relay {
spks.relayId = component.Id()
}
}
if spks.plaId == "" || spks.relayId == "" {
return fmt.Errorf("SPKS[%s]未找到对应的旁路继电器或状态继电器", protoData.Id)
}
}
return nil
}
func buildEsbRelationship(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.Esbs {
platform := repository.platformMap[protoData.PlatformId]
var plaCode string
var relayCode string
switch platform.dir {
case proto.Platform_Up:
plaCode = "SEMPFA"
relayCode = "SEMPJ"
case proto.Platform_Down:
plaCode = "XEMPFA"
relayCode = "XEMPJ"
default:
panic(fmt.Sprintf("站台[%s]的方向[%s]不正确", platform.Id(), platform.dir))
}
esb := repository.esbMap[protoData.Id]
station := platform.station
for _, group := range station.empGroups {
for _, component := range group.components {
if component.Code() == plaCode && component.Type() == proto.DeviceType_DeviceType_Button {
esb.plaId = component.Id()
}
if component.Code() == relayCode && component.Type() == proto.DeviceType_DeviceType_Relay {
esb.relayId = component.Id()
}
}
}
if esb.plaId == "" || esb.relayId == "" {
return fmt.Errorf("ESB[%s]未找到对应的旁路按钮或继电器", protoData.Id)
}
}
return nil
}
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]
for _, group := range protoData.ElectronicComponentGroups {
var components []IGroupedElectronicComponent
for _, id := range group.GetComponentIds() {
if relay := repo.relayMap[id]; relay != nil {
components = append(components, relay)
}
}
ckm.componentGroups = append(ckm.componentGroups, &ElectronicComponentGroup{
code: group.Code,
components: components,
})
}
}
return nil
}
func buildCkmRelationShip(source *proto.Repository, repo *Repository) error {
for _, protoData := range source.Xcjs {
xcj := repo.xcjMap[protoData.Id]
for _, group := range protoData.ElectronicComponentGroups {
var components []IGroupedElectronicComponent
for _, id := range group.GetComponentIds() {
if relay := repo.relayMap[id]; relay != nil {
components = append(components, relay)
}
}
xcj.componentGroups = append(xcj.componentGroups, &ElectronicComponentGroup{
code: group.Code,
components: components,
})
}
}
return nil
}
func buildPlatformRelationShip(source *proto.Repository, repo *Repository) error {
for _, protoData := range source.Platforms {
platform := repo.platformMap[protoData.Id]
@ -455,18 +203,6 @@ func buildPlatformRelationShip(source *proto.Repository, repo *Repository) error
return fmt.Errorf("站台[id:%s]关联的车站[id:%s]不存在", platform.Id(), protoData.StationId)
}
platform.station = station
for _, group := range protoData.ElectronicComponentGroups {
var components []IGroupedElectronicComponent
for _, id := range group.GetComponentIds() {
if relay := repo.relayMap[id]; relay != nil {
components = append(components, relay)
}
}
platform.componentGroups = append(platform.componentGroups, &ElectronicComponentGroup{
code: group.Code,
components: components,
})
}
}
return nil
}
@ -480,25 +216,14 @@ 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.psd = repo.psdMap[protoData.PsdId]
mkx.pcb = repo.buttonMap[protoData.PcbaId]
mkx.pcbpl = repo.buttonMap[protoData.PcbplaId]
mkx.pcbj = repo.relayMap[protoData.PcbjId]
mkx.pob = repo.buttonMap[protoData.PobaId]
mkx.pobpl = repo.buttonMap[protoData.PobplaId]
mkx.pobj = repo.relayMap[protoData.PobjId]
mkx.pab = repo.buttonMap[protoData.PabaId]
mkx.pabpl = repo.buttonMap[protoData.PabplaId]
mkx.pabj = repo.relayMap[protoData.PabjId]
mkx.wrzf = repo.buttonMap[protoData.WrzfaId]
mkx.wrzfpl = repo.buttonMap[protoData.WrzfplaId]
mkx.wrzfj = repo.relayMap[protoData.WrzfjId]
mkx.qkqr = repo.buttonMap[protoData.QkqraId]
mkx.qkqrpl = repo.buttonMap[protoData.QkqrplaId]
mkx.qkqrj = repo.relayMap[protoData.QkqrjId]
mkx.mpl = repo.buttonMap[protoData.MplaId]
mkx.jxtcpl = repo.buttonMap[protoData.JxtcplaId]
mkx := repo.mkxMap[protoData.Id]
mkx.psd = repo.psdMap[protoData.GetPsdId()]
mkx.pcb = repo.buttonMap[protoData.GetPcbButtonId()]
mkx.pob = repo.buttonMap[protoData.GetPobButtonId()]
mkx.pab = repo.buttonMap[protoData.GetPabButtonId()]
mkx.pcbj = repo.relayMap[protoData.GetPcbjId()]
mkx.pobj = repo.relayMap[protoData.GetPobjId()]
mkx.pabj = repo.relayMap[protoData.GetPabjId()]
}
return nil
}
@ -633,15 +358,7 @@ func buildResponderRelationShip(source *proto.Repository, repository *Repository
}
return nil
}
func buildStopPositionRelationShip(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.StopPosition {
responder := repository.StopPosition[protoData.Id]
if protoData.SectionId != "" {
repository.physicalSectionMap[protoData.SectionId].bindDevices(responder)
}
}
return nil
}
func buildSignalRelationShip(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.Signals {
signal := repository.signalMap[protoData.Id]
@ -727,26 +444,26 @@ func buildTurnoutPortRelation(repo *Repository, turnout *Turnout, port proto.Por
return err
}
func buildPhysicalSectionRelationShip(source *proto.Repository, repo *Repository) error {
func buildPhysicalSectionRelationShip(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.PhysicalSections {
section := repo.physicalSectionMap[protoData.Id]
section := repository.physicalSectionMap[protoData.Id]
//A端关联
if protoData.ADevicePort != nil {
err := buildSectionPortRelation(repo, section, proto.Port_A, protoData.ADevicePort)
err := buildSectionPortRelation(repository, section, proto.Port_A, protoData.ADevicePort)
if err != nil {
return err
}
}
//B端关联
if protoData.BDevicePort != nil {
err := buildSectionPortRelation(repo, section, proto.Port_B, protoData.BDevicePort)
err := buildSectionPortRelation(repository, section, proto.Port_B, protoData.BDevicePort)
if err != nil {
return err
}
}
//道岔关联
for _, turnoutId := range protoData.TurnoutIds {
turnout := repo.turnoutMap[turnoutId]
turnout := repository.turnoutMap[turnoutId]
if turnout == nil {
return fmt.Errorf("id[%s]的道岔不存在", turnoutId)
}
@ -754,24 +471,7 @@ func buildPhysicalSectionRelationShip(source *proto.Repository, repo *Repository
turnout.section = section
}
//关联联锁集中站
for _, stationId := range protoData.CentralizedStation {
section.centralizedStation = append(section.centralizedStation, repo.stationMap[stationId])
}
//关联电子元件
for _, group := range protoData.ElectronicComponentGroups {
var components []IGroupedElectronicComponent
for _, id := range group.GetComponentIds() {
if relay := repo.relayMap[id]; relay != nil {
components = append(components, relay)
} else if pfp := repo.phaseFailureProtectorMap[id]; pfp != nil {
components = append(components, pfp)
}
}
section.componentGroups = append(section.componentGroups, &ElectronicComponentGroup{
code: group.Code,
components: components,
})
}
section.centralizedStation = protoData.CentralizedStation
}
return nil
}
@ -878,18 +578,6 @@ func buildLinksAndRelate(repo *Repository) error {
return nil
}
/*func stopPositionRelateLink(repo *Repository) {
for _, curvature := range repo {
start, end, err := calculateLinkSegment(repo, curvature.kms[0], curvature.kms[1])
if err != nil {
return err
}
curvature.bindStartLinkPosition(start)
curvature.bindEndLinkPosition(end)
}
return nil
}*/
func buildLinks(repo *Repository) error {
visitedTurnoutPortMap := make(map[string]bool)
allTurnouts := repo.TurnoutList()
@ -945,7 +633,6 @@ func findEndTurnoutPortOrEndKm(repo *Repository, link *Link, startTp *TurnoutPor
var currentDp DevicePort = startTp
devices := startTp.turnout.findDevicesByPort(startTp.port)
for {
//遍历设备并构建、关联其在Link上的位置
err = relateDevicesAndLink(repo, link, baseKm, visitedModelMap, devices...)
if err != nil {
@ -967,10 +654,7 @@ func findEndTurnoutPortOrEndKm(repo *Repository, link *Link, startTp *TurnoutPor
if nextDp == nil {
endKm = turnout.findBoundaryKmByPort(currentDp.Port())
}
//case proto.DeviceType_deviceType_Stop_position:
// turnout := currentDp.Device().(*StopPosition)
}
//根据下一个端口设备的信息决定是否结束循环
if nextDp == nil {
break
@ -1039,14 +723,9 @@ func buildTurnoutPortKey(tp *TurnoutPort) string {
func relateDevicesAndLink(repo *Repository, link *Link, startKm *proto.Kilometer, visitedModelMap map[string]bool, devices ...Identity) error {
for _, device := range devices {
if visitedModelMap[device.Id()] {
continue
}
linkPositionDevice, ok := device.(LinkPositionDevice)
if !ok {
return fmt.Errorf("device [%s:%s] not implements LinkPositionDevice", device.Id(), device.Type().String())
}
km := findModelKm(device)
if km == nil || km.CoordinateSystem == "" {
continue
@ -1056,12 +735,19 @@ func relateDevicesAndLink(repo *Repository, link *Link, startKm *proto.Kilometer
return err
}
offset := int64(math.Abs(float64(convertedKm.Value - startKm.Value)))
linkPosition := LinkPosition{
linkPosition := &LinkPosition{
link: link,
offset: offset,
}
linkPositionDevice.bindLinkPosition(linkPosition)
link.bindDevices(linkPositionDevice)
switch device.Type() {
case proto.DeviceType_DeviceType_CheckPoint:
device.(*CheckPoint).bindLinkPosition(linkPosition)
case proto.DeviceType_DeviceType_Signal:
device.(*Signal).bindLinkPosition(linkPosition)
case proto.DeviceType_DeviceType_Transponder:
device.(*Transponder).bindLinkPosition(linkPosition)
}
link.bindDevices(device)
}
return nil
}
@ -1111,10 +797,7 @@ func findModelKm(model Identity) *proto.Kilometer {
return model.(*CheckPoint).km
case proto.DeviceType_DeviceType_Turnout:
return model.(*Turnout).km
case proto.DeviceType_deviceType_Stop_position:
return model.(*StopPosition).km
}
return nil
}

View File

@ -8,7 +8,7 @@ type Signal struct {
km *proto.Kilometer
//section *PhysicalSection
//turnoutPort TurnoutPort
linkPosition LinkPosition
linkPosition *LinkPosition
//信号机电路系统电子元器件
componentGroups []*ElectronicComponentGroup
model proto.Signal_Model
@ -23,21 +23,23 @@ func NewSignal(id string, km *proto.Kilometer, code string, model proto.Signal_M
}
}
func (s *Signal) bindLinkPosition(position *LinkPosition) {
s.linkPosition = position
}
// func (s *Signal) bindSection(section *PhysicalSection) {
// s.section = section
// }
//
// func (s *Signal) bindTurnoutPort(tp TurnoutPort) {
// s.turnoutPort = tp
// }
func (s *Signal) RelayGroups() []*ElectronicComponentGroup {
return s.componentGroups
}
func (s *Signal) Code() string {
return s.code
}
func (s *Signal) Model() proto.Signal_Model {
return s.model
}
func (s *Signal) LinkPosition() LinkPosition {
return s.linkPosition
}
func (s *Signal) bindLinkPosition(position LinkPosition) {
s.linkPosition = position
}

View File

@ -1,16 +0,0 @@
package repository
// Spks 人员防护系统。目前内部属性仅作为和第三方联锁通信时获取SPKS系统状态的便捷途径
type Spks struct {
Identity
plaId string //SPKS旁路按钮ID
relayId string //SPKS继电器ID
}
func (s *Spks) PlaId() string {
return s.plaId
}
func (s *Spks) Relay() string {
return s.relayId
}

Some files were not shown because too many files have changed in this diff Show More