Compare commits
135 Commits
Author | SHA1 | Date | |
---|---|---|---|
88b24dff65 | |||
b7bc9bdb1f | |||
|
073f5e3156 | ||
|
2f7e505437 | ||
|
150aa24307 | ||
|
ef7ff5459c | ||
|
91f3fdb23d | ||
f1feee09cc | |||
|
693576459c | ||
a94fdb12f7 | |||
99ebcb04e5 | |||
1f0a114c8d | |||
12df28cc37 | |||
73e7f83cfa | |||
51702238da | |||
ae5ee2729e | |||
efa7d1655e | |||
86c02883c4 | |||
|
5f95106870 | ||
8d19129ec6 | |||
3182e867c1 | |||
8c6bfb2aee | |||
ef7e469175 | |||
181dd9951b | |||
c5f139267a | |||
f94033ca44 | |||
|
cebe83f5c4 | ||
468cc78964 | |||
a613ac109b | |||
90003ec942 | |||
8ccd46aa6c | |||
4371dad391 | |||
cf942ab318 | |||
cf783364fe | |||
6d5457f706 | |||
e1913b8f43 | |||
33ed496dcd | |||
01b0655eb5 | |||
d63be32ad5 | |||
f0a6c534ec | |||
21ca336b0c | |||
|
88b5ea8c77 | ||
|
ab72ff8e00 | ||
|
b6fbaf7272 | ||
|
ecb43fa7a3 | ||
285f0a1d49 | |||
39be7b4bfa | |||
669fa31625 | |||
09122cf458 | |||
|
568b3cc4a7 | ||
7694e09223 | |||
7ec4eb44e4 | |||
aaeb3236a8 | |||
b624eeb3d8 | |||
5086c8732a | |||
4ee6f05b62 | |||
|
814f68154d | ||
|
25e65d2229 | ||
778a991b75 | |||
|
29325f98db | ||
|
4adeaedd5a | ||
b54224351f | |||
2cc7564772 | |||
7372a5fa72 | |||
247003d00b | |||
2879914757 | |||
fa7211d7bd | |||
d94a8335dc | |||
ba95c8bdef | |||
896db9e6e9 | |||
f90563f821 | |||
8cd0f61fb0 | |||
a6e451e33f | |||
0203bbcefa | |||
|
79484bea97 | ||
655a0712af | |||
0316b398d5 | |||
ef48c7ba0b | |||
e8c0d58799 | |||
972bac0561 | |||
3f5b459460 | |||
a9ea711f00 | |||
|
cf5fa3210b | ||
|
f215374f9b | ||
|
d443ee3c41 | ||
a4c17218f7 | |||
|
9b16941d2f | ||
|
7bb420cffd | ||
|
1c2ce2d9a9 | ||
|
8688c7b371 | ||
|
7a4ad7d1bb | ||
4dc5c17a89 | |||
7751d9d926 | |||
|
3cb6678a19 | ||
|
b6f9a0af22 | ||
|
3c0fc2293b | ||
|
f1897c75d8 | ||
|
c166adfaa1 | ||
|
4f91be427e | ||
80585dbf7a | |||
2282ad9f56 | |||
|
2803f32329 | ||
|
5c169edfbc | ||
|
27bd611893 | ||
|
c9e89e2b02 | ||
|
5d66ac7bb5 | ||
c4bc8c640f | |||
50b588ca15 | |||
375d0a86a3 | |||
|
8a938a451c | ||
|
b8a4b0d16e | ||
2bff91955a | |||
fea4eae8d1 | |||
|
556ed6e2d6 | ||
|
2dfe213742 | ||
e64d27df67 | |||
7b80d6e736 | |||
3b4a017b3d | |||
1e71d51feb | |||
|
411a5e0157 | ||
|
f0b6cd1b71 | ||
|
a922cf8133 | ||
75723b31e6 | |||
1101edd1d3 | |||
|
ead7947345 | ||
|
d9a9349cb7 | ||
|
312300e8ba | ||
07248c0fec | |||
90829bbd41 | |||
|
6f52757c5d | ||
|
19a231c95b | ||
|
7deeabe23e | ||
|
2b27052092 | ||
|
721824c2f7 | ||
|
94d06677e7 |
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,3 +1,3 @@
|
||||
[submodule "jl-ecs-go"]
|
||||
path = jl-ecs-go
|
||||
url = https://git.code.tencent.com/jl-framework/jl-ecs-go.git
|
||||
[submodule "jl-ecs"]
|
||||
path = jl-ecs
|
||||
url = https://gitea.joylink.club/joylink/jl-ecs.git
|
||||
|
11
component/axle_counting_section.go
Normal file
11
component/axle_counting_section.go
Normal file
@ -0,0 +1,11 @@
|
||||
package component
|
||||
|
||||
import "joylink.club/ecs"
|
||||
|
||||
var (
|
||||
AxleCountingSectionStateType = ecs.NewComponentType[AxleCountingSectionState]()
|
||||
)
|
||||
|
||||
type AxleCountingSectionState struct {
|
||||
Occupied bool
|
||||
}
|
@ -2,15 +2,24 @@ package component
|
||||
|
||||
import "joylink.club/ecs"
|
||||
|
||||
type BaliseState struct {
|
||||
ValidTelegram []byte //当前一条有效报文
|
||||
var (
|
||||
BaliseFB = ecs.NewTag() // 固定应答器
|
||||
BaliseWB = ecs.NewTag() // 轮径校正应答器
|
||||
BaliseDB = ecs.NewTag() // 休眠唤醒应答器
|
||||
BaliseVB = ecs.NewTag() // 主信号应答器
|
||||
BaliseIB = ecs.NewTag() // 预告应答器
|
||||
)
|
||||
|
||||
var ForceVariableTelegram = ecs.NewTag() //表示可变报文为强制设置并锁定
|
||||
|
||||
var BaliseFixedTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器固定报文
|
||||
var BaliseVariableTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器可变报文
|
||||
type BaliseTelegram struct {
|
||||
Telegram []byte //报文
|
||||
UserTelegram []byte //用户报文
|
||||
}
|
||||
|
||||
var (
|
||||
BaliseFB = ecs.NewTag() // 固定应答器
|
||||
BaliseWB = ecs.NewTag() // 轮径校正应答器
|
||||
BaliseDB = ecs.NewTag() // 休眠唤醒应答器
|
||||
BaliseVB = ecs.NewTag() // 主信号应答器
|
||||
BaliseIB = ecs.NewTag() // 预告应答器
|
||||
BaliseStateType = ecs.NewComponentType[BaliseState]()
|
||||
)
|
||||
var BaliseWorkStateType = ecs.NewComponentType[BaliseWorkState]() // 工作状态
|
||||
type BaliseWorkState struct {
|
||||
Work bool //应答器是否正常工作中(目前仅应答器停止发送报文故障会导致为false)
|
||||
}
|
||||
|
151
component/cbtc_atp_ground.go
Normal file
151
component/cbtc_atp_ground.go
Normal file
@ -0,0 +1,151 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"joylink.club/ecs"
|
||||
)
|
||||
|
||||
// 控制模式
|
||||
type ControlMode uint8
|
||||
|
||||
const (
|
||||
ControlMode_None ControlMode = iota // 交出未被接收
|
||||
ControlMode_Center // 中控
|
||||
ControlMode_Local // 站控/自律站控
|
||||
ControlMode_Emergency // 紧急站控
|
||||
ControlMode_Interlock // 联锁控/非常站控
|
||||
)
|
||||
|
||||
// 控制模式
|
||||
type ControlState struct {
|
||||
Model ControlMode // 当前控制模式
|
||||
}
|
||||
|
||||
var ControlStateType = ecs.NewComponentType[ControlState]() // 控制模式
|
||||
|
||||
// 限速组件
|
||||
type SpeedLimit struct {
|
||||
Val float32 // 限速值
|
||||
}
|
||||
|
||||
var SpeedLimitType = ecs.NewComponentType[SpeedLimit]() // 限速组件
|
||||
|
||||
// 占用类型
|
||||
type OccupiedType uint8
|
||||
|
||||
const (
|
||||
Occupied_Ct OccupiedType = iota // 通信车占用
|
||||
Occupied_Nct // 非通信车占用
|
||||
Occupied_Fault // 故障占用
|
||||
)
|
||||
|
||||
// 占用状态
|
||||
type OccupiedStatus struct {
|
||||
Types []OccupiedType // 占用状态
|
||||
}
|
||||
|
||||
var OccupiedStatusType = ecs.NewComponentType[OccupiedStatus]() // 占用状态组件
|
||||
|
||||
// 进路锁闭状态
|
||||
type RouteLock struct {
|
||||
Route *ecs.Entry
|
||||
}
|
||||
|
||||
var RouteLockType = ecs.NewComponentType[RouteLock]()
|
||||
|
||||
// 故障锁闭状态
|
||||
type FaultLock struct {
|
||||
Fault any // 故障信息
|
||||
}
|
||||
|
||||
var FaultLockType = ecs.NewComponentType[FaultLock]() // 故障锁闭状态组件
|
||||
|
||||
// 封锁状态
|
||||
type BlockadeStatus struct {
|
||||
}
|
||||
|
||||
var BlockadeStatusType = ecs.NewComponentType[BlockadeStatus]() // 封锁状态组件
|
||||
|
||||
// 解锁状态
|
||||
type UnLockStatus struct {
|
||||
Delay bool // 延迟状态
|
||||
DelayTime time.Duration // 延迟解锁时间
|
||||
}
|
||||
|
||||
var UnLockStatusType = ecs.NewComponentType[UnLockStatus]() // 解锁状态组件
|
||||
|
||||
// 关闭状态
|
||||
type ClosedStatus struct {
|
||||
}
|
||||
|
||||
var ClosedStatusType = ecs.NewComponentType[ClosedStatus]() // 关闭状态组件
|
||||
|
||||
// 站台跳停状态
|
||||
type PlatformSkipStatus struct {
|
||||
AllSkip bool // 全部跳停
|
||||
Trains []*ecs.Entry // 跳停列车
|
||||
}
|
||||
|
||||
var PlatformSkipStatusType = ecs.NewComponentType[PlatformSkipStatus]() // 站台跳停状态
|
||||
|
||||
// 站台停靠发车状态
|
||||
type PlatformParkStatus struct {
|
||||
Park bool // 列车停靠状态
|
||||
ParkTime time.Duration // 停靠时间
|
||||
Depart bool // 列车发车状态
|
||||
}
|
||||
|
||||
var PlatformParkStatusType = ecs.NewComponentType[PlatformParkStatus]() // 站台停靠发车状态
|
||||
|
||||
// 扣车状态
|
||||
type PlatformHoldStatus struct {
|
||||
}
|
||||
|
||||
var PlatformHoldStatusType = ecs.NewComponentType[PlatformHoldStatus]() // 扣车状态组件
|
||||
|
||||
// 信号机状态
|
||||
type SignalStatus struct {
|
||||
ApproachLock bool // 接近锁闭
|
||||
OverlapLock bool // 延续保护锁闭
|
||||
}
|
||||
|
||||
var SignalStatusType = ecs.NewComponentType[SignalStatus]() // 信号机状态组件
|
||||
|
||||
// 进路状态
|
||||
type RouteStatus struct {
|
||||
AtsControl bool // ats自动控制
|
||||
Setting bool // 进路是否排列中
|
||||
Lock bool // 已锁闭
|
||||
Setable bool // 是否可排列
|
||||
}
|
||||
|
||||
var RouteStatusType = ecs.NewComponentType[RouteStatus]() // 进路状态组件
|
||||
|
||||
// 列车运行级别
|
||||
type TrainRunLevel uint8
|
||||
|
||||
const (
|
||||
TrainRunLevel_CBTC TrainRunLevel = iota // cbtc级别
|
||||
TrainRunLevel_ITC // 点式通信
|
||||
TrainRunLevel_IL // 联锁级
|
||||
)
|
||||
|
||||
// 列车运行模式
|
||||
type DriveMode uint8
|
||||
|
||||
const (
|
||||
DriveMode_AM DriveMode = iota // 列车自动驾驶模式
|
||||
DriveMode_CM // ATP防护下的人工驾驶模式
|
||||
DriveMode_RM // 限制人工驾驶模式
|
||||
DriveMode_NRM // 无限制人工驾驶模式
|
||||
)
|
||||
|
||||
// 位置:目标位置、占用位置
|
||||
type DevicePosition struct {
|
||||
Device *ecs.Entry // 设备
|
||||
Offset int64 // 在设备上的相对a位置偏移
|
||||
Direction bool // 上下行
|
||||
}
|
||||
|
||||
var DevicePositionType = ecs.NewComponentType[DevicePosition]()
|
10
component/ci.go
Normal file
10
component/ci.go
Normal file
@ -0,0 +1,10 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component/component_data"
|
||||
)
|
||||
|
||||
var (
|
||||
CiSysRAMType = ecs.NewComponentType[component_data.CiSysRAM]()
|
||||
)
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component/component_proto"
|
||||
"joylink.club/rtsssimulation/component/component_data"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
)
|
||||
|
||||
@ -55,7 +55,7 @@ func (qc *CiQcTable) QueryQdIndex(uid string) (int, bool) {
|
||||
}
|
||||
|
||||
type CiQcState struct {
|
||||
component_proto.CiQcState
|
||||
component_data.CiQcState
|
||||
}
|
||||
|
||||
func NewCiQcState(qlen int, clen int) *CiQcState {
|
||||
@ -68,7 +68,7 @@ func NewCiQcState(qlen int, clen int) *CiQcState {
|
||||
cbl++
|
||||
}
|
||||
return &CiQcState{
|
||||
component_proto.CiQcState{
|
||||
component_data.CiQcState{
|
||||
Qbs: make([]byte, qbl),
|
||||
Cbs: make([]byte, cbl),
|
||||
},
|
||||
|
36
component/ckm.go
Normal file
36
component/ckm.go
Normal file
@ -0,0 +1,36 @@
|
||||
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 //门模式按钮
|
||||
}
|
@ -2,47 +2,58 @@ package component
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component/component_proto"
|
||||
"joylink.club/rtsssimulation/component/component_data"
|
||||
"joylink.club/rtsssimulation/consts"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
)
|
||||
|
||||
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 //摁钮旁路旧值
|
||||
}*/
|
||||
|
||||
// 唯一ID组件
|
||||
type Uid struct {
|
||||
Id string
|
||||
}
|
||||
|
||||
var UidType = ecs.NewComponentType[Uid]()
|
||||
|
||||
// 两个稳态位置转换组件
|
||||
// type TwoPositionTransform struct {
|
||||
// Pos int // 当前位置百分比,[0, 10000],两位小数
|
||||
// Speed int
|
||||
// }
|
||||
|
||||
type TwoPositionTransform struct {
|
||||
component_proto.TwoPositionTransform
|
||||
type FixedPositionTransform struct {
|
||||
component_data.FixedPositionTransform
|
||||
}
|
||||
|
||||
// 当前位置百分比值
|
||||
func (tp *TwoPositionTransform) Percentage() float32 {
|
||||
func (tp *FixedPositionTransform) Percentage() float32 {
|
||||
return float32(tp.Pos) / consts.TwoPosMax
|
||||
}
|
||||
|
||||
var TwoPositionTransformType = ecs.NewComponentType[TwoPositionTransform]()
|
||||
|
||||
// 计算两位置动作的平均速度
|
||||
// 总时间t和tick的单位都应该是ms
|
||||
// t - 总时间,tick - 执行间隔
|
||||
func CalculateTwoPositionAvgSpeed(t int, tick int) int32 {
|
||||
return int32(consts.TwoPosMax / (t / tick))
|
||||
}
|
||||
|
||||
// 仅有两状态的组件
|
||||
type BitState struct {
|
||||
//Bypass
|
||||
Val bool
|
||||
}
|
||||
|
||||
var BitStateType = ecs.NewComponentType[BitState]()
|
||||
|
||||
// 倒数/倒计时组件
|
||||
type CounterDown struct {
|
||||
Val int // 当前值
|
||||
@ -58,3 +69,6 @@ type Counter struct {
|
||||
}
|
||||
|
||||
var CounterType = ecs.NewComponentType[Counter]()
|
||||
|
||||
var LinkPositionType = ecs.NewComponentType[component_data.LinkPosition]()
|
||||
var KmType = ecs.NewComponentType[proto.Kilometer]()
|
||||
|
1305
component/component_data/ci.pb.go
Normal file
1305
component/component_data/ci.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
666
component/component_data/common.pb.go
Normal file
666
component/component_data/common.pb.go
Normal file
@ -0,0 +1,666 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: component/common.proto
|
||||
|
||||
package component_data
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 电机
|
||||
type 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]
|
||||
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]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *FixedPositionTransform) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*FixedPositionTransform) ProtoMessage() {}
|
||||
|
||||
func (x *FixedPositionTransform) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_component_common_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 FixedPositionTransform.ProtoReflect.Descriptor instead.
|
||||
func (*FixedPositionTransform) Descriptor() ([]byte, []int) {
|
||||
return file_component_common_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *FixedPositionTransform) GetPos() int32 {
|
||||
if x != nil {
|
||||
return x.Pos
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *FixedPositionTransform) GetSpeed() int32 {
|
||||
if x != nil {
|
||||
return x.Speed
|
||||
}
|
||||
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
|
||||
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 *Counter) Reset() {
|
||||
*x = Counter{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_common_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Counter) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Counter) ProtoMessage() {}
|
||||
|
||||
func (x *Counter) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_component_common_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 Counter.ProtoReflect.Descriptor instead.
|
||||
func (*Counter) Descriptor() ([]byte, []int) {
|
||||
return file_component_common_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *Counter) GetVal() int32 {
|
||||
if x != nil {
|
||||
return x.Val
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Counter) GetStep() int32 {
|
||||
if x != nil {
|
||||
return x.Step
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Link位置
|
||||
type LinkPosition struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Link的ID
|
||||
LinkId string `protobuf:"bytes,1,opt,name=linkId,proto3" json:"linkId,omitempty"`
|
||||
// Link的偏移量
|
||||
Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
|
||||
}
|
||||
|
||||
func (x *LinkPosition) Reset() {
|
||||
*x = LinkPosition{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_common_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *LinkPosition) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*LinkPosition) ProtoMessage() {}
|
||||
|
||||
func (x *LinkPosition) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_component_common_proto_msgTypes[6]
|
||||
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 LinkPosition.ProtoReflect.Descriptor instead.
|
||||
func (*LinkPosition) Descriptor() ([]byte, []int) {
|
||||
return file_component_common_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *LinkPosition) GetLinkId() string {
|
||||
if x != nil {
|
||||
return x.LinkId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *LinkPosition) GetOffset() int64 {
|
||||
if x != nil {
|
||||
return x.Offset
|
||||
}
|
||||
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,
|
||||
}
|
||||
|
||||
var (
|
||||
file_component_common_proto_rawDescOnce sync.Once
|
||||
file_component_common_proto_rawDescData = file_component_common_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_component_common_proto_rawDescGZIP() []byte {
|
||||
file_component_common_proto_rawDescOnce.Do(func() {
|
||||
file_component_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_component_common_proto_rawDescData)
|
||||
})
|
||||
return file_component_common_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_component_common_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
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
|
||||
}
|
||||
var file_component_common_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_component_common_proto_init() }
|
||||
func file_component_common_proto_init() {
|
||||
if File_component_common_proto != nil {
|
||||
return
|
||||
}
|
||||
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
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
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{} {
|
||||
switch v := v.(*Counter); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_component_common_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*LinkPosition); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_component_common_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CounterDown); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_component_common_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_component_common_proto_goTypes,
|
||||
DependencyIndexes: file_component_common_proto_depIdxs,
|
||||
MessageInfos: file_component_common_proto_msgTypes,
|
||||
}.Build()
|
||||
File_component_common_proto = out.File
|
||||
file_component_common_proto_rawDesc = nil
|
||||
file_component_common_proto_goTypes = nil
|
||||
file_component_common_proto_depIdxs = nil
|
||||
}
|
144
component/component_data/equipment.pb.go
Normal file
144
component/component_data/equipment.pb.go
Normal file
@ -0,0 +1,144 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: component/equipment.proto
|
||||
|
||||
package component_data
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 继电器强制故障(强制在某个位置)
|
||||
type RelayFaultForce struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Q bool `protobuf:"varint,1,opt,name=q,proto3" json:"q,omitempty"` // 是否强制到前接点(吸起)位置
|
||||
}
|
||||
|
||||
func (x *RelayFaultForce) Reset() {
|
||||
*x = RelayFaultForce{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_equipment_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *RelayFaultForce) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RelayFaultForce) ProtoMessage() {}
|
||||
|
||||
func (x *RelayFaultForce) 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 RelayFaultForce.ProtoReflect.Descriptor instead.
|
||||
func (*RelayFaultForce) Descriptor() ([]byte, []int) {
|
||||
return file_component_equipment_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *RelayFaultForce) GetQ() bool {
|
||||
if x != nil {
|
||||
return x.Q
|
||||
}
|
||||
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,
|
||||
}
|
||||
|
||||
var (
|
||||
file_component_equipment_proto_rawDescOnce sync.Once
|
||||
file_component_equipment_proto_rawDescData = file_component_equipment_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_component_equipment_proto_rawDescGZIP() []byte {
|
||||
file_component_equipment_proto_rawDescOnce.Do(func() {
|
||||
file_component_equipment_proto_rawDescData = protoimpl.X.CompressGZIP(file_component_equipment_proto_rawDescData)
|
||||
})
|
||||
return file_component_equipment_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_component_equipment_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_component_equipment_proto_goTypes = []interface{}{
|
||||
(*RelayFaultForce)(nil), // 0: component.RelayFaultForce
|
||||
}
|
||||
var file_component_equipment_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_component_equipment_proto_init() }
|
||||
func file_component_equipment_proto_init() {
|
||||
if File_component_equipment_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_component_equipment_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*RelayFaultForce); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_component_equipment_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_component_equipment_proto_goTypes,
|
||||
DependencyIndexes: file_component_equipment_proto_depIdxs,
|
||||
MessageInfos: file_component_equipment_proto_msgTypes,
|
||||
}.Build()
|
||||
File_component_equipment_proto = out.File
|
||||
file_component_equipment_proto_rawDesc = nil
|
||||
file_component_equipment_proto_goTypes = nil
|
||||
file_component_equipment_proto_depIdxs = nil
|
||||
}
|
639
component/component_data/points.pb.go
Normal file
639
component/component_data/points.pb.go
Normal file
@ -0,0 +1,639 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: component/points.proto
|
||||
|
||||
package component_data
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 道岔故障
|
||||
type Points_Fault int32
|
||||
|
||||
const (
|
||||
// 失表
|
||||
Points_SB Points_Fault = 0
|
||||
// 定位失表
|
||||
Points_DWSB Points_Fault = 1
|
||||
// 反位失表
|
||||
Points_FWSB Points_Fault = 2
|
||||
// 挤岔
|
||||
Points_JC Points_Fault = 3
|
||||
// 联锁无法驱动故障
|
||||
Points_CIQD Points_Fault = 4
|
||||
)
|
||||
|
||||
// Enum value maps for Points_Fault.
|
||||
var (
|
||||
Points_Fault_name = map[int32]string{
|
||||
0: "SB",
|
||||
1: "DWSB",
|
||||
2: "FWSB",
|
||||
3: "JC",
|
||||
4: "CIQD",
|
||||
}
|
||||
Points_Fault_value = map[string]int32{
|
||||
"SB": 0,
|
||||
"DWSB": 1,
|
||||
"FWSB": 2,
|
||||
"JC": 3,
|
||||
"CIQD": 4,
|
||||
}
|
||||
)
|
||||
|
||||
func (x Points_Fault) Enum() *Points_Fault {
|
||||
p := new(Points_Fault)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x Points_Fault) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (Points_Fault) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_component_points_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (Points_Fault) Type() protoreflect.EnumType {
|
||||
return &file_component_points_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x Points_Fault) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Points_Fault.Descriptor instead.
|
||||
func (Points_Fault) EnumDescriptor() ([]byte, []int) {
|
||||
return file_component_points_proto_rawDescGZIP(), []int{2, 0}
|
||||
}
|
||||
|
||||
// 道岔转辙机自动开闭器状态
|
||||
// 自动开闭器接点位置,默认定位接通1/3排,反位接通2/4排
|
||||
// 由定位转反位(1DQJ和1DQJF励磁吸起,2DQJ在反位——即落下),三相电路导通,电机开始反转,转辙机将第3排接点接通第4排,到位锁闭后,转辙机的自动开闭器拉簧将第1排接点拉到第2排,接点到2排后,三相电路断路
|
||||
// 由反位转定位(1DQJ和1DQJF励磁吸起,2DQJ在定位——即吸起),三相电路导通,电机开始正转,转辙机将第2排接点接通第1排,到位锁闭后,转辙机的自动开闭器拉簧将第4排接点拉到第3排,接点到3排后,三相电路断路
|
||||
type PointsZzjKbqState struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// 接点在1/2排的位置,false-接点在1排,true-接点在2排
|
||||
Jd13 bool `protobuf:"varint,1,opt,name=jd13,proto3" json:"jd13,omitempty"`
|
||||
// 接点在3/4排的位置,false-接点在3排,true-接点在4排
|
||||
Jd24 bool `protobuf:"varint,2,opt,name=jd24,proto3" json:"jd24,omitempty"`
|
||||
}
|
||||
|
||||
func (x *PointsZzjKbqState) Reset() {
|
||||
*x = PointsZzjKbqState{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_points_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *PointsZzjKbqState) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PointsZzjKbqState) ProtoMessage() {}
|
||||
|
||||
func (x *PointsZzjKbqState) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_component_points_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 PointsZzjKbqState.ProtoReflect.Descriptor instead.
|
||||
func (*PointsZzjKbqState) Descriptor() ([]byte, []int) {
|
||||
return file_component_points_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *PointsZzjKbqState) GetJd13() bool {
|
||||
if x != nil {
|
||||
return x.Jd13
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *PointsZzjKbqState) GetJd24() bool {
|
||||
if x != nil {
|
||||
return x.Jd24
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 道岔位置状态表示组件
|
||||
type PointsPosition struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// 是否定位(实际位置)
|
||||
Dw bool `protobuf:"varint,1,opt,name=dw,proto3" json:"dw,omitempty"`
|
||||
// 是否反位(实际位置)
|
||||
Fw bool `protobuf:"varint,2,opt,name=fw,proto3" json:"fw,omitempty"`
|
||||
// 定表
|
||||
Db bool `protobuf:"varint,3,opt,name=db,proto3" json:"db,omitempty"`
|
||||
// 反表
|
||||
Fb bool `protobuf:"varint,4,opt,name=fb,proto3" json:"fb,omitempty"`
|
||||
}
|
||||
|
||||
func (x *PointsPosition) Reset() {
|
||||
*x = PointsPosition{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_points_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *PointsPosition) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PointsPosition) ProtoMessage() {}
|
||||
|
||||
func (x *PointsPosition) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_component_points_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 PointsPosition.ProtoReflect.Descriptor instead.
|
||||
func (*PointsPosition) Descriptor() ([]byte, []int) {
|
||||
return file_component_points_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *PointsPosition) GetDw() bool {
|
||||
if x != nil {
|
||||
return x.Dw
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *PointsPosition) GetFw() bool {
|
||||
if x != nil {
|
||||
return x.Fw
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *PointsPosition) GetDb() bool {
|
||||
if x != nil {
|
||||
return x.Db
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *PointsPosition) GetFb() bool {
|
||||
if x != nil {
|
||||
return x.Fb
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 道岔
|
||||
type Points struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *Points) Reset() {
|
||||
*x = Points{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_points_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Points) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Points) ProtoMessage() {}
|
||||
|
||||
func (x *Points) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_component_points_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 Points.ProtoReflect.Descriptor instead.
|
||||
func (*Points) Descriptor() ([]byte, []int) {
|
||||
return file_component_points_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
// 道岔失表故障
|
||||
type PointsFaultSB struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *PointsFaultSB) Reset() {
|
||||
*x = PointsFaultSB{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_points_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *PointsFaultSB) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PointsFaultSB) ProtoMessage() {}
|
||||
|
||||
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))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// 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 *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}
|
||||
}
|
||||
|
||||
// 道岔挤岔故障
|
||||
type PointsFaultJc struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *PointsFaultJc) Reset() {
|
||||
*x = PointsFaultJc{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_points_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *PointsFaultJc) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PointsFaultJc) ProtoMessage() {}
|
||||
|
||||
func (x *PointsFaultJc) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_component_points_proto_msgTypes[6]
|
||||
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 PointsFaultJc.ProtoReflect.Descriptor instead.
|
||||
func (*PointsFaultJc) Descriptor() ([]byte, []int) {
|
||||
return file_component_points_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
// 道岔联锁无法驱动故障
|
||||
type PointsFaultCiqd struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *PointsFaultCiqd) Reset() {
|
||||
*x = PointsFaultCiqd{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_points_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *PointsFaultCiqd) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PointsFaultCiqd) ProtoMessage() {}
|
||||
|
||||
func (x *PointsFaultCiqd) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_component_points_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 PointsFaultCiqd.ProtoReflect.Descriptor instead.
|
||||
func (*PointsFaultCiqd) Descriptor() ([]byte, []int) {
|
||||
return file_component_points_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
var File_component_points_proto protoreflect.FileDescriptor
|
||||
|
||||
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,
|
||||
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,
|
||||
0x66, 0x77, 0x12, 0x0e, 0x0a, 0x02, 0x64, 0x62, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02,
|
||||
0x64, 0x62, 0x12, 0x0e, 0x0a, 0x02, 0x66, 0x62, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02,
|
||||
0x66, 0x62, 0x22, 0x3f, 0x0a, 0x06, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x22, 0x35, 0x0a, 0x05,
|
||||
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,
|
||||
}
|
||||
|
||||
var (
|
||||
file_component_points_proto_rawDescOnce sync.Once
|
||||
file_component_points_proto_rawDescData = file_component_points_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_component_points_proto_rawDescGZIP() []byte {
|
||||
file_component_points_proto_rawDescOnce.Do(func() {
|
||||
file_component_points_proto_rawDescData = protoimpl.X.CompressGZIP(file_component_points_proto_rawDescData)
|
||||
})
|
||||
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_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
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
func init() { file_component_points_proto_init() }
|
||||
func file_component_points_proto_init() {
|
||||
if File_component_points_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_component_points_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*PointsZzjKbqState); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_component_points_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*PointsPosition); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_component_points_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Points); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_component_points_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*PointsFaultSB); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
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
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_component_points_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*PointsFaultCiqd); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_component_points_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_component_points_proto_goTypes,
|
||||
DependencyIndexes: file_component_points_proto_depIdxs,
|
||||
EnumInfos: file_component_points_proto_enumTypes,
|
||||
MessageInfos: file_component_points_proto_msgTypes,
|
||||
}.Build()
|
||||
File_component_points_proto = out.File
|
||||
file_component_points_proto_rawDesc = nil
|
||||
file_component_points_proto_goTypes = nil
|
||||
file_component_points_proto_depIdxs = nil
|
||||
}
|
@ -1,155 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc v4.23.1
|
||||
// source: component/ci.proto
|
||||
|
||||
package component_proto
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 联锁驱动、采集状态表
|
||||
type CiQcState struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// 驱动bit表
|
||||
Qbs []byte `protobuf:"bytes,1,opt,name=qbs,proto3" json:"qbs,omitempty"`
|
||||
// 采集bit表
|
||||
Cbs []byte `protobuf:"bytes,2,opt,name=cbs,proto3" json:"cbs,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CiQcState) Reset() {
|
||||
*x = CiQcState{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_ci_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CiQcState) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CiQcState) ProtoMessage() {}
|
||||
|
||||
func (x *CiQcState) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_component_ci_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 CiQcState.ProtoReflect.Descriptor instead.
|
||||
func (*CiQcState) Descriptor() ([]byte, []int) {
|
||||
return file_component_ci_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *CiQcState) GetQbs() []byte {
|
||||
if x != nil {
|
||||
return x.Qbs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *CiQcState) GetCbs() []byte {
|
||||
if x != nil {
|
||||
return x.Cbs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_component_ci_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_component_ci_proto_rawDesc = []byte{
|
||||
0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x69, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x22,
|
||||
0x2f, 0x0a, 0x09, 0x43, 0x69, 0x51, 0x63, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03,
|
||||
0x71, 0x62, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x71, 0x62, 0x73, 0x12, 0x10,
|
||||
0x0a, 0x03, 0x63, 0x62, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x63, 0x62, 0x73,
|
||||
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 (
|
||||
file_component_ci_proto_rawDescOnce sync.Once
|
||||
file_component_ci_proto_rawDescData = file_component_ci_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_component_ci_proto_rawDescGZIP() []byte {
|
||||
file_component_ci_proto_rawDescOnce.Do(func() {
|
||||
file_component_ci_proto_rawDescData = protoimpl.X.CompressGZIP(file_component_ci_proto_rawDescData)
|
||||
})
|
||||
return file_component_ci_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_component_ci_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_component_ci_proto_goTypes = []interface{}{
|
||||
(*CiQcState)(nil), // 0: component.CiQcState
|
||||
}
|
||||
var file_component_ci_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_component_ci_proto_init() }
|
||||
func file_component_ci_proto_init() {
|
||||
if File_component_ci_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_component_ci_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CiQcState); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_component_ci_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_component_ci_proto_goTypes,
|
||||
DependencyIndexes: file_component_ci_proto_depIdxs,
|
||||
MessageInfos: file_component_ci_proto_msgTypes,
|
||||
}.Build()
|
||||
File_component_ci_proto = out.File
|
||||
file_component_ci_proto_rawDesc = nil
|
||||
file_component_ci_proto_goTypes = nil
|
||||
file_component_ci_proto_depIdxs = nil
|
||||
}
|
@ -1,361 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc v4.23.1
|
||||
// source: component/common.proto
|
||||
|
||||
package component_proto
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 两个稳态位置转换组件
|
||||
type TwoPositionTransform struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Pos int32 `protobuf:"varint,1,opt,name=pos,proto3" json:"pos,omitempty"` // 当前位置百分比,[0, 10000],两位小数
|
||||
Speed int32 `protobuf:"varint,2,opt,name=speed,proto3" json:"speed,omitempty"`
|
||||
}
|
||||
|
||||
func (x *TwoPositionTransform) Reset() {
|
||||
*x = TwoPositionTransform{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_common_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *TwoPositionTransform) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*TwoPositionTransform) ProtoMessage() {}
|
||||
|
||||
func (x *TwoPositionTransform) 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 TwoPositionTransform.ProtoReflect.Descriptor instead.
|
||||
func (*TwoPositionTransform) Descriptor() ([]byte, []int) {
|
||||
return file_component_common_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *TwoPositionTransform) GetPos() int32 {
|
||||
if x != nil {
|
||||
return x.Pos
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *TwoPositionTransform) GetSpeed() int32 {
|
||||
if x != nil {
|
||||
return x.Speed
|
||||
}
|
||||
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[1]
|
||||
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[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 BitState.ProtoReflect.Descriptor instead.
|
||||
func (*BitState) Descriptor() ([]byte, []int) {
|
||||
return file_component_common_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *BitState) GetVal() bool {
|
||||
if x != nil {
|
||||
return x.Val
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 计数/计时组件
|
||||
type Counter 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 *Counter) Reset() {
|
||||
*x = Counter{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_component_common_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Counter) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Counter) ProtoMessage() {}
|
||||
|
||||
func (x *Counter) 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 Counter.ProtoReflect.Descriptor instead.
|
||||
func (*Counter) Descriptor() ([]byte, []int) {
|
||||
return file_component_common_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Counter) GetVal() int32 {
|
||||
if x != nil {
|
||||
return x.Val
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Counter) GetStep() int32 {
|
||||
if x != nil {
|
||||
return x.Step
|
||||
}
|
||||
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[3]
|
||||
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[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 CounterDown.ProtoReflect.Descriptor instead.
|
||||
func (*CounterDown) Descriptor() ([]byte, []int) {
|
||||
return file_component_common_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
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, 0x3e, 0x0a, 0x14, 0x54, 0x77, 0x6f, 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, 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, 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 (
|
||||
file_component_common_proto_rawDescOnce sync.Once
|
||||
file_component_common_proto_rawDescData = file_component_common_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_component_common_proto_rawDescGZIP() []byte {
|
||||
file_component_common_proto_rawDescOnce.Do(func() {
|
||||
file_component_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_component_common_proto_rawDescData)
|
||||
})
|
||||
return file_component_common_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_component_common_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_component_common_proto_goTypes = []interface{}{
|
||||
(*TwoPositionTransform)(nil), // 0: component.TwoPositionTransform
|
||||
(*BitState)(nil), // 1: component.BitState
|
||||
(*Counter)(nil), // 2: component.Counter
|
||||
(*CounterDown)(nil), // 3: component.CounterDown
|
||||
}
|
||||
var file_component_common_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_component_common_proto_init() }
|
||||
func file_component_common_proto_init() {
|
||||
if File_component_common_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_component_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*TwoPositionTransform); 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.(*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[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Counter); 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.(*CounterDown); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_component_common_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_component_common_proto_goTypes,
|
||||
DependencyIndexes: file_component_common_proto_depIdxs,
|
||||
MessageInfos: file_component_common_proto_msgTypes,
|
||||
}.Build()
|
||||
File_component_common_proto = out.File
|
||||
file_component_common_proto_rawDesc = nil
|
||||
file_component_common_proto_goTypes = nil
|
||||
file_component_common_proto_depIdxs = nil
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: component/psd.proto
|
||||
|
||||
@ -74,7 +74,9 @@ type PsdState struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Close bool `protobuf:"varint,1,opt,name=close,proto3" json:"close,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"` //有障碍物
|
||||
InterlockRelease bool `protobuf:"varint,3,opt,name=interlockRelease,proto3" json:"interlockRelease,omitempty"` //互锁解除
|
||||
}
|
||||
|
||||
func (x *PsdState) Reset() {
|
||||
@ -116,6 +118,20 @@ func (x *PsdState) GetClose() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *PsdState) GetObstacle() bool {
|
||||
if x != nil {
|
||||
return x.Obstacle
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *PsdState) GetInterlockRelease() bool {
|
||||
if x != nil {
|
||||
return x.InterlockRelease
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type Psd struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -159,9 +175,11 @@ 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"` //门关继电器
|
||||
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"` //强制开/关门
|
||||
}
|
||||
|
||||
func (x *AsdState) Reset() {
|
||||
@ -217,22 +235,43 @@ 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, 0x20, 0x0a, 0x08, 0x50, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05,
|
||||
0x22, 0x68, 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, 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,
|
||||
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,
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v4.23.1
|
||||
// source: component/signal.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: component/turnout.proto
|
||||
|
||||
|
20
component/equipment.go
Normal file
20
component/equipment.go
Normal file
@ -0,0 +1,20 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component/component_data"
|
||||
)
|
||||
|
||||
var (
|
||||
RelayFaultForceType = ecs.NewComponentType[component_data.RelayFaultForce]()
|
||||
)
|
||||
|
||||
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}))
|
||||
}
|
||||
}
|
@ -45,6 +45,7 @@ var AlarmDriveType = ecs.NewComponentType[AlarmDrive]()
|
||||
|
||||
// 挡位组件
|
||||
type GearState struct {
|
||||
//Bypass
|
||||
Val int32
|
||||
}
|
||||
|
||||
|
@ -5,13 +5,8 @@ import "joylink.club/ecs"
|
||||
// AirConditioning 空调
|
||||
type AirConditioning struct {
|
||||
Running bool //true-运行正常;false-停止
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
AirConditioningType = ecs.NewComponentType[AirConditioning]() //空调
|
||||
|
||||
CombinationAirConditionerTag = ecs.NewTag() //组合式空调
|
||||
AirConditioningGroupTag = ecs.NewTag() //空调群控系统
|
||||
AirConditionerTag = ecs.NewTag() //空调器
|
||||
)
|
||||
|
@ -8,7 +8,5 @@ type AirPavilion struct {
|
||||
}
|
||||
|
||||
var (
|
||||
AirPavilionType = ecs.NewComponentType[AirPavilion]() //风亭
|
||||
ExhaustPavilionTag = ecs.NewTag() //排风亭
|
||||
AirSupplyPavilionTag = ecs.NewTag() //送风亭
|
||||
AirPavilionType = ecs.NewComponentType[AirPavilion]() //风亭
|
||||
)
|
||||
|
@ -2,38 +2,18 @@ package component
|
||||
|
||||
import "joylink.club/ecs"
|
||||
|
||||
// FanDevice 风机设备
|
||||
// 正转即顺时针转-排风;反转即逆时针转-进风
|
||||
type FanDevice struct {
|
||||
Speed uint16 //风机转速,r/min
|
||||
Forward bool //true-正转;false-反转
|
||||
}
|
||||
|
||||
// FanFcUnit 风机变频器
|
||||
type FanFcUnit struct {
|
||||
Fc bool //true-变频器已开启
|
||||
}
|
||||
|
||||
// FanBypassUnit 风机旁路装置
|
||||
type FanBypassUnit struct {
|
||||
Bypass bool //true-风机旁路已开启
|
||||
}
|
||||
|
||||
// FanSoftStartUnit 风机软启装置
|
||||
type FanSoftStartUnit struct {
|
||||
SoftStart bool //true-风机软启已开启
|
||||
}
|
||||
|
||||
// FanHighLowSpeedMode 风机双速模式控制
|
||||
type FanHighLowSpeedMode struct {
|
||||
HighMode bool //true-风机高速模式;false-风机低速模式
|
||||
}
|
||||
|
||||
var (
|
||||
FanDeviceType = ecs.NewComponentType[FanDevice]() //风机设备
|
||||
FanFcUnitType = ecs.NewComponentType[FanFcUnit]() //风机变频装置
|
||||
FanBypassUnitType = ecs.NewComponentType[FanBypassUnit]() //风机旁路装置
|
||||
FanSoftStartUnitType = ecs.NewComponentType[FanSoftStartUnit]() //风机软启装置
|
||||
FanHighLowSpeedModeType = ecs.NewComponentType[FanHighLowSpeedMode]() //风机双速模式控制
|
||||
|
||||
CommonFanTag = ecs.NewTag() //一般风机
|
||||
|
@ -1,11 +0,0 @@
|
||||
package component
|
||||
|
||||
import "joylink.club/ecs"
|
||||
|
||||
// GasMixingChamber 混合室静压箱
|
||||
type GasMixingChamber struct {
|
||||
}
|
||||
|
||||
var (
|
||||
GasMixingChamberType = ecs.NewComponentType[GasMixingChamber]()
|
||||
)
|
134
component/iscs_bas_pipe.go
Normal file
134
component/iscs_bas_pipe.go
Normal file
@ -0,0 +1,134 @@
|
||||
package component
|
||||
|
||||
import "joylink.club/ecs"
|
||||
|
||||
///////////////////////////////////////////
|
||||
//组合空调柜AHU-A01 二通阀MOV-A01
|
||||
//回排风机RAF-A01 风阀MDD-A03
|
||||
//排烟风机SEF-A01 风阀MDD-A04
|
||||
//排风阀MDA-A02
|
||||
//回风阀MDA-A03
|
||||
//小新风阀MDA-A01
|
||||
//空调柜MDD-A02
|
||||
//防烟防火SFD-A01
|
||||
|
||||
// PipeMatter 管线中传输的物质类型
|
||||
type PipeMatter uint8
|
||||
|
||||
const (
|
||||
PmtNon PipeMatter = iota //未知或没有
|
||||
PmtWater
|
||||
PmtElectricity //电
|
||||
PmtAir //正常空气
|
||||
PmtSmoke //含有有害烟的空气(如火灾时的烟气)
|
||||
PmtOil //油
|
||||
)
|
||||
|
||||
func (m *PipeMatter) IsNon() bool {
|
||||
return *m == PmtNon
|
||||
}
|
||||
func (m *PipeMatter) IsEle() bool {
|
||||
return *m == PmtElectricity
|
||||
}
|
||||
|
||||
// PipeDirection 管线中物质传输方向定义
|
||||
type PipeDirection uint8
|
||||
|
||||
const (
|
||||
PdNon PipeDirection = iota //无方向
|
||||
PdAb //方向A=>B
|
||||
PdBa //方向B=>A
|
||||
)
|
||||
|
||||
func (d *PipeDirection) IsAb() bool {
|
||||
return *d == PdAb
|
||||
}
|
||||
func (d *PipeDirection) IsBa() bool {
|
||||
return *d == PdBa
|
||||
}
|
||||
func (d *PipeDirection) IsNon() bool {
|
||||
return *d == PdNon
|
||||
}
|
||||
|
||||
// Pipe 管线一般状态定义
|
||||
type Pipe struct {
|
||||
Matter PipeMatter //管线中物质类型
|
||||
Direction PipeDirection //管线中物质运动方向
|
||||
}
|
||||
|
||||
// PipeElectricity 电线(三相交流,一般单相交流,直流)
|
||||
// 如果是三相电,则简化认为每相电压电流一样
|
||||
type PipeElectricity struct {
|
||||
U uint32 //电压
|
||||
I uint32 //电流
|
||||
Sx bool //true-三相交流电,此时Ac无效;false-一般单相电,此时Ua Ia Ac有效
|
||||
Ac bool //true-交流;false-直流
|
||||
Sources map[string]*ElectricitySource //key-电源实体id,value-电源投影
|
||||
}
|
||||
|
||||
func NewPipeElectricity() *PipeElectricity {
|
||||
return &PipeElectricity{Sources: make(map[string]*ElectricitySource)}
|
||||
}
|
||||
func (p *PipeElectricity) FromElectricitySource(es *ElectricitySource) {
|
||||
p.U = es.U
|
||||
p.Sx = es.Sx
|
||||
p.Ac = es.Ac
|
||||
}
|
||||
func (p *PipeElectricity) TransPower(powerSourceId string, power *ElectricitySource) {
|
||||
ep, ok := p.Sources[powerSourceId]
|
||||
if ok {
|
||||
*ep = *power
|
||||
ep.Fresh -= 1
|
||||
} else {
|
||||
p.Sources[powerSourceId] = &ElectricitySource{}
|
||||
*p.Sources[powerSourceId] = *power
|
||||
p.Sources[powerSourceId].Fresh -= 1
|
||||
}
|
||||
}
|
||||
|
||||
// ElectricitySource 电源(三相交流,一般单相交流,直流)
|
||||
type ElectricitySource struct {
|
||||
Fresh int64 //该电力值更新的时间戳
|
||||
U uint32 //电压
|
||||
I uint32 //电流
|
||||
Sx bool //true-三相交流电,此时Ac无效;false-一般单相电,此时Ua Ia Ac有效
|
||||
Ac bool //true-交流;false-直流
|
||||
}
|
||||
|
||||
func NewElectricitySource() *ElectricitySource {
|
||||
return &ElectricitySource{}
|
||||
}
|
||||
|
||||
// SetOut0 设置0输出
|
||||
func (s *ElectricitySource) SetOut0() {
|
||||
s.U = 0
|
||||
s.I = 0
|
||||
}
|
||||
|
||||
// PipeFluid 流体(液体气体)管线
|
||||
type PipeFluid struct {
|
||||
T float32 //温度
|
||||
}
|
||||
|
||||
func NewPipeFluid() *PipeFluid {
|
||||
return &PipeFluid{}
|
||||
}
|
||||
|
||||
var (
|
||||
PipeType = ecs.NewComponentType[Pipe]() //电线
|
||||
PipeElectricityType = ecs.NewComponentType[PipeElectricity]() //电线电力
|
||||
PipeFluidType = ecs.NewComponentType[PipeFluid]() //管线流体
|
||||
ElectricitySourceType = ecs.NewComponentType[ElectricitySource]() //电源
|
||||
|
||||
)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// FluidDriver 流体驱动器
|
||||
type FluidDriver struct {
|
||||
On bool //true-输出流体驱动力;false-未输出流体驱动力
|
||||
}
|
||||
|
||||
var (
|
||||
FluidDriverType = ecs.NewComponentType[FluidDriver]() //流体驱动器
|
||||
)
|
16
component/iscs_bas_plenum_chamber.go
Normal file
16
component/iscs_bas_plenum_chamber.go
Normal file
@ -0,0 +1,16 @@
|
||||
package component
|
||||
|
||||
import "joylink.club/ecs"
|
||||
|
||||
// GasMixingChamber 混合室静压箱
|
||||
//
|
||||
// 送风系统中的配件
|
||||
// 显然静压箱起到了增加静压的作用。静压箱的设计原则:静压箱的作用是为各分支管路提供均匀的压力,
|
||||
// 从理论上说静压箱内部静压处处相等(这时静压箱容积要做得非常大,就是说静压箱内部流速处处为零)在实际工程中这是不可能的,
|
||||
// 一般箱内风速可控制在2m/s以下,或相对于进出风管风速有大大下降即可。
|
||||
type GasMixingChamber struct {
|
||||
}
|
||||
|
||||
var (
|
||||
GasMixingChamberType = ecs.NewComponentType[GasMixingChamber]()
|
||||
)
|
@ -11,11 +11,15 @@ type Valve struct {
|
||||
Moving bool //true-正在动作
|
||||
OpenRate uint8 //开度,0-100%
|
||||
}
|
||||
type ValveController struct {
|
||||
TargetOpenRate uint8 //目标开度,0-100%
|
||||
}
|
||||
|
||||
var (
|
||||
ValveType = ecs.NewComponentType[Valve]() //阀门(开关)
|
||||
ElectricControlValveTag = ecs.NewTag() //电动调节阀
|
||||
ElectricAirValveTag = ecs.NewTag() //电动风阀标签
|
||||
CombinationAirValveTag = ecs.NewTag() //组合式风阀
|
||||
ElectricButterflyValveTag = ecs.NewTag() //电动蝶阀
|
||||
ValveControllerType = ecs.NewComponentType[ValveController]()
|
||||
ElectricControlValveTag = ecs.NewTag() //电动调节阀
|
||||
ElectricAirValveTag = ecs.NewTag() //电动风阀
|
||||
CombinationAirValveTag = ecs.NewTag() //组合式风阀
|
||||
ElectricButterflyValveTag = ecs.NewTag() //电动蝶阀
|
||||
)
|
||||
|
@ -102,32 +102,6 @@ type EarthingDevice struct {
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// PowerPipe 电力母线
|
||||
type PowerPipe struct {
|
||||
Voltage uint32 //母线当前电压
|
||||
Ac bool //true-交流电;false-直流电
|
||||
Sources map[string]*ElePower //key-电源PowerSource实体id
|
||||
}
|
||||
|
||||
func (p *PowerPipe) TransPower(powerSourceId string, power *ElePower) {
|
||||
ep, ok := p.Sources[powerSourceId]
|
||||
if ok {
|
||||
*ep = *power
|
||||
ep.Fresh -= 1
|
||||
} else {
|
||||
p.Sources[powerSourceId] = &ElePower{}
|
||||
*p.Sources[powerSourceId] = *power
|
||||
p.Sources[powerSourceId].Fresh -= 1
|
||||
}
|
||||
}
|
||||
|
||||
// ElePower 传输中的电力
|
||||
type ElePower struct {
|
||||
Fresh int64 //该电力值更新的时间戳
|
||||
Voltage uint32 //电压
|
||||
Ac bool //true-交流电;false-直流电
|
||||
}
|
||||
|
||||
// PscadaVoltageLevel 电力母线当前电压等级定义
|
||||
type PscadaVoltageLevel uint8
|
||||
|
||||
@ -139,12 +113,6 @@ const (
|
||||
PscadaVoltageDc1500V //1500V直流
|
||||
)
|
||||
|
||||
// PowerSource 电源(国家电网)
|
||||
type PowerSource struct {
|
||||
Voltage uint32 //电压
|
||||
Ac bool //true-交流电;false-直流电
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var (
|
||||
@ -156,8 +124,6 @@ var (
|
||||
LightningArresterType = ecs.NewComponentType[LightningArrester]() //避雷器
|
||||
RectifierType = ecs.NewComponentType[Rectifier]() //整流器
|
||||
VoltageTransformerType = ecs.NewComponentType[VoltageTransformer]() //变压器
|
||||
PowerPipeType = ecs.NewComponentType[PowerPipe]() //电力母线
|
||||
PowerSourceType = ecs.NewComponentType[PowerSource]() //电源
|
||||
EarthingDeviceType = ecs.NewComponentType[EarthingDevice]() //接地装置
|
||||
)
|
||||
|
||||
|
51
component/motor.go
Normal file
51
component/motor.go
Normal file
@ -0,0 +1,51 @@
|
||||
package component
|
||||
|
||||
import "joylink.club/ecs"
|
||||
|
||||
// Motor 电机、马达
|
||||
type Motor struct {
|
||||
Speed float32 //电机转速,r/min
|
||||
Forward bool //true-正转;false-反转
|
||||
Ms MotorSwitch //电机开关
|
||||
}
|
||||
|
||||
func (m *Motor) RunningForward() bool {
|
||||
return m.Forward && m.Speed > 0
|
||||
}
|
||||
func (m *Motor) RunningReverse() bool {
|
||||
return !m.Forward && m.Speed > 0
|
||||
}
|
||||
|
||||
// MotorFc 电机变频器
|
||||
// 电机转速与变频器频率关系 计算公式:n=60f/p(其中n是同步转速,f是频率,P是磁极对数)
|
||||
// 变频器的额定输出频率一般为0-100HZ
|
||||
type MotorFc struct {
|
||||
F uint16 //变频器频率(0-100HZ)
|
||||
}
|
||||
|
||||
// MotorSwitch 电机电源开关定义
|
||||
type MotorSwitch uint8
|
||||
|
||||
const (
|
||||
MsOff MotorSwitch = iota //关闭
|
||||
MsOnForward //正转
|
||||
MsOnReverse //反转
|
||||
)
|
||||
|
||||
func (f *MotorSwitch) Off() bool {
|
||||
return *f == MsOff
|
||||
}
|
||||
func (f *MotorSwitch) OnForward() bool {
|
||||
return *f == MsOnForward
|
||||
}
|
||||
func (f *MotorSwitch) OnReverse() bool {
|
||||
return *f == MsOnReverse
|
||||
}
|
||||
func (f *MotorSwitch) On() bool {
|
||||
return *f == MsOnReverse || *f == MsOnForward
|
||||
}
|
||||
|
||||
var (
|
||||
MotorType = ecs.NewComponentType[Motor]() //电机马达
|
||||
MotorFcType = ecs.NewComponentType[MotorFc]() //电机变频器
|
||||
)
|
@ -1,105 +1,27 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"joylink.club/ecs"
|
||||
)
|
||||
|
||||
//计轴设备,管理联锁集中站内的所有计轴区段
|
||||
//计轴直接复位:计轴的轮对计数清零,区段转换为空闲状态
|
||||
//计轴预复位:将计轴的轮对计数清零,但是区段不会立即变成空闲区段,而是处于一种“占用”状态,在压道车通过之后确认区段空闲且计轴正常后,区段转换为空闲状态
|
||||
//
|
||||
//当CI系统给计轴设备发送计轴直接复零/预复零命令时,连续发送一定时间(具体发送时间调试后确定)的复零/预复零命令。
|
||||
//当RAC,RJO,RJT任意一个不为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)}
|
||||
}
|
||||
import "joylink.club/ecs"
|
||||
|
||||
var (
|
||||
PhysicalSectionStateType = ecs.NewComponentType[PhysicalSectionState]()
|
||||
AxlePhysicalSectionType = ecs.NewComponentType[AxlePhysicalSection]()
|
||||
AxleSectionFaultTag = ecs.NewTag()
|
||||
AxleManageDeviceType = ecs.NewComponentType[AxleManageDevice]()
|
||||
PhysicalSectionTag = ecs.NewTag()
|
||||
PhysicalSectionCircuitType = ecs.NewComponentType[PhysicalSectionCircuit]()
|
||||
PhysicalSectionManagerType = ecs.NewComponentType[PhysicalSectionManager]()
|
||||
)
|
||||
var PhysicalSectionForceOccupied = ecs.NewTag() //区段强制占用(故障占用)
|
||||
|
||||
/////////////////////////////AxlePhysicalSection/////////////////////////////////
|
||||
// PhysicalSectionManager 计轴管理器。我自己起的名字,计轴逻辑的载体
|
||||
type PhysicalSectionManager struct {
|
||||
Count int //轴数(简化版)。目前此轴数计数只与区段上有无列车有关,故障占用等状态不会影响此计数
|
||||
Occupied bool //占用
|
||||
|
||||
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)
|
||||
PDRST bool //预复位
|
||||
|
||||
//RAC bool //计轴复位反馈。主要指计轴设备发送给CI系统的直接复零/预复零命令反馈,表示计轴设备已收到CI系统发送的直接复零/预复零命令。
|
||||
//RJO bool //运营原因拒绝直接复位/预复位。如区段空闲时下发复位命令;或车轮压住传感器时收到复位命令。
|
||||
//RJT bool //技术原因拒绝直接复位/预复位。主要指计轴相关设备故障时收到复位命令,如车轮传感器的导线断开、AEB之间的通信故障等。
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
// PhysicalSectionCircuit 计轴区段电路
|
||||
type PhysicalSectionCircuit struct {
|
||||
GJ *ecs.Entry
|
||||
}
|
||||
|
22
component/points.go
Normal file
22
component/points.go
Normal file
@ -0,0 +1,22 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component/component_data"
|
||||
"joylink.club/rtsssimulation/component/relation"
|
||||
)
|
||||
|
||||
var (
|
||||
// 道岔标签
|
||||
PointsTag = ecs.NewTag()
|
||||
// 道岔模型数据引用组件类型
|
||||
PointsModelRelaType = relation.PointsModelRelaType
|
||||
// 道岔转辙机关系组件类型
|
||||
PointsZzjRelaType = relation.PointsZzjRelaType
|
||||
// 道岔ZDJ9双机电路元器件组件类型
|
||||
Zdj9TwoElectronicType = relation.Zdj9TwoElectronicType
|
||||
// 道岔转辙机自动开闭器状态组件类型
|
||||
PointsZzjKbqStateType = ecs.NewComponentType[component_data.PointsZzjKbqState]()
|
||||
// 道岔位置组件类型
|
||||
PointsPositionType = ecs.NewComponentType[component_data.PointsPosition]()
|
||||
)
|
@ -65,6 +65,12 @@ type AsdMotorState struct {
|
||||
|
||||
var AsdStateType = ecs.NewComponentType[component_proto.AsdState]()
|
||||
|
||||
// AsdForceType ture强制开门 false强制关门
|
||||
var AsdForceType = ecs.NewComponentType[BitState]()
|
||||
|
||||
// AsdHasObstacleTag 滑动门有障碍物
|
||||
var AsdHasObstacleTag = ecs.NewTag()
|
||||
|
||||
var PlatformMkxCircuitType = ecs.NewComponentType[PlatformMkxCircuit]()
|
||||
|
||||
// PlatformMkxCircuit 站台门控箱电路
|
||||
@ -73,15 +79,25 @@ 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
|
||||
POB *ecs.Entry
|
||||
PAB *ecs.Entry
|
||||
MPL *ecs.Entry
|
||||
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
|
||||
}
|
||||
|
||||
var PscType = ecs.NewComponentType[Psc]()
|
||||
@ -91,14 +107,8 @@ type Psc struct {
|
||||
//InterlockKM8 bool
|
||||
InterlockKmGroup map[int32]bool //开门编组。k-编组 v-设置开门
|
||||
InterlockGM bool
|
||||
InterlockMPL bool
|
||||
|
||||
MkxKM bool
|
||||
MkxGM bool
|
||||
MkxPL bool
|
||||
|
||||
QDTC bool
|
||||
TZTC bool
|
||||
ZAW bool
|
||||
JXTCPL bool
|
||||
//MkxKM bool 门控箱控制继电器->联锁采集继电器状态->联锁驱动屏蔽门控制继电器
|
||||
//MkxGM bool
|
||||
//MkxPL bool
|
||||
}
|
||||
|
166
component/relation/points.go
Normal file
166
component/relation/points.go
Normal file
@ -0,0 +1,166 @@
|
||||
package relation
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/modelrepo/model"
|
||||
)
|
||||
|
||||
var (
|
||||
// 道岔模型数据引用组件类型
|
||||
PointsModelRelaType = ecs.NewComponentType[PointsModelRela]()
|
||||
// 道岔转辙机关系组件类型
|
||||
PointsZzjRelaType = ecs.NewComponentType[PointsZzjRela]()
|
||||
// ZDJ9双机电路元器件组件类型
|
||||
Zdj9TwoElectronicType = ecs.NewComponentType[Zdj9TwoElectronic]()
|
||||
)
|
||||
|
||||
// 道岔模型数据引用
|
||||
type PointsModelRela struct {
|
||||
M model.Points
|
||||
}
|
||||
|
||||
func NewPointsModelRela(m model.Points) *PointsModelRela {
|
||||
return &PointsModelRela{
|
||||
M: m,
|
||||
}
|
||||
}
|
||||
|
||||
// 道岔转辙机关系组件
|
||||
type PointsZzjRela struct {
|
||||
Points *ecs.Entry
|
||||
Zzjs []*ecs.Entry
|
||||
}
|
||||
|
||||
func NewPointsZzjRela(t *ecs.Entry, zzjs ...*ecs.Entry) *PointsZzjRela {
|
||||
return &PointsZzjRela{
|
||||
Points: t,
|
||||
Zzjs: zzjs,
|
||||
}
|
||||
}
|
||||
|
||||
// 获取转辙机一,若没有则panic
|
||||
func (tz *PointsZzjRela) GetZzj1() *ecs.Entry {
|
||||
len := len(tz.Zzjs)
|
||||
if len > 0 {
|
||||
return tz.Zzjs[0]
|
||||
}
|
||||
panic("道岔没有转辙机一")
|
||||
}
|
||||
|
||||
// 获取转辙机二,若没有则panic
|
||||
func (tz *PointsZzjRela) GetZzj2() *ecs.Entry {
|
||||
len := len(tz.Zzjs)
|
||||
if len > 1 {
|
||||
return tz.Zzjs[1]
|
||||
}
|
||||
panic("道岔没有转辙机二")
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
35
component/singleton/entity_uid_index.go
Normal file
35
component/singleton/entity_uid_index.go
Normal file
@ -0,0 +1,35 @@
|
||||
package singleton
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"joylink.club/ecs"
|
||||
)
|
||||
|
||||
var EntityUidIndexType = ecs.NewComponentType[EntityUidIndex]()
|
||||
|
||||
// 对象实体Uid索引
|
||||
// 只索引具有uid且不会销毁的实体
|
||||
type EntityUidIndex struct {
|
||||
mu sync.RWMutex
|
||||
entityMap map[string]ecs.Entity
|
||||
}
|
||||
|
||||
func (idx *EntityUidIndex) Add(uid string, entity ecs.Entity) {
|
||||
idx.mu.Lock()
|
||||
defer idx.mu.Unlock()
|
||||
idx.entityMap[uid] = entity
|
||||
}
|
||||
|
||||
func (idx *EntityUidIndex) Get(uid string) ecs.Entity {
|
||||
idx.mu.RLock()
|
||||
defer idx.mu.RUnlock()
|
||||
return 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),
|
||||
})
|
||||
}
|
45
component/singleton/load.go
Normal file
45
component/singleton/load.go
Normal file
@ -0,0 +1,45 @@
|
||||
package singleton
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/modelrepo"
|
||||
)
|
||||
|
||||
// 加载并初始化单例组件
|
||||
func LoadSingletons(w ecs.World, r modelrepo.Repo) {
|
||||
loadWorldRepo(w, r)
|
||||
LoadWorldTime(w)
|
||||
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))
|
||||
|
||||
func GetWorldTime(w ecs.World) *WorldTime {
|
||||
entry, _ := worldTimeQuery.First(w)
|
||||
if entry == nil {
|
||||
panic("不存在世界时间组件")
|
||||
}
|
||||
return WorldTimeType.Get(entry)
|
||||
}
|
||||
|
||||
func GetWorldRepo(w ecs.World) *WorldRepo {
|
||||
entry, _ := worldRepoQuery.First(w)
|
||||
if entry == nil {
|
||||
panic("不存在世界数据组件")
|
||||
}
|
||||
return WorldRepoType.Get(entry)
|
||||
}
|
||||
|
||||
func GetEntityUidIndex(w ecs.World) *EntityUidIndex {
|
||||
entry, _ := uidEntityIndexQuery.First(w)
|
||||
if entry == nil {
|
||||
panic("不存在UidEntityIndex组件")
|
||||
}
|
||||
return EntityUidIndexType.Get(entry)
|
||||
}
|
19
component/singleton/repo.go
Normal file
19
component/singleton/repo.go
Normal file
@ -0,0 +1,19 @@
|
||||
package singleton
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/modelrepo"
|
||||
)
|
||||
|
||||
var WorldRepoType = ecs.NewComponentType[WorldRepo]()
|
||||
|
||||
type WorldRepo struct {
|
||||
r modelrepo.Repo
|
||||
}
|
||||
|
||||
func loadWorldRepo(w ecs.World, r modelrepo.Repo) {
|
||||
entry := w.Entry(w.Create(WorldRepoType))
|
||||
WorldRepoType.Set(entry, &WorldRepo{
|
||||
r: r,
|
||||
})
|
||||
}
|
37
component/singleton/world_time.go
Normal file
37
component/singleton/world_time.go
Normal file
@ -0,0 +1,37 @@
|
||||
package singleton
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"joylink.club/ecs"
|
||||
)
|
||||
|
||||
var WorldTimeType = ecs.NewComponentType[WorldTime]()
|
||||
|
||||
type WorldTime struct {
|
||||
time int64
|
||||
}
|
||||
|
||||
func (w *WorldTime) SetTime(t time.Time) {
|
||||
w.time = t.UnixMilli()
|
||||
}
|
||||
|
||||
// 增加时间
|
||||
func (w *WorldTime) Run(ms int) {
|
||||
w.time += int64(ms)
|
||||
}
|
||||
|
||||
// 获取时间
|
||||
func (w *WorldTime) GetTime() time.Time {
|
||||
return time.UnixMilli(w.time)
|
||||
}
|
||||
|
||||
// 获取时间戳ms
|
||||
func (w *WorldTime) GetMilli() int64 {
|
||||
return w.time
|
||||
}
|
||||
|
||||
func LoadWorldTime(w ecs.World) {
|
||||
entry := w.Entry(w.Create(WorldTimeType))
|
||||
WorldTimeType.Set(entry, &WorldTime{time: time.Now().UnixMilli()})
|
||||
}
|
11
component/track_circuit.go
Normal file
11
component/track_circuit.go
Normal file
@ -0,0 +1,11 @@
|
||||
package component
|
||||
|
||||
import "joylink.club/ecs"
|
||||
|
||||
var (
|
||||
TrackCircuitType = ecs.NewComponentType[TrackCircuit]()
|
||||
)
|
||||
|
||||
type TrackCircuit struct {
|
||||
GJ *ecs.Entry
|
||||
}
|
@ -12,6 +12,7 @@ type TrainPositionInfo struct {
|
||||
Up bool
|
||||
//列车长度 mm
|
||||
Len int64
|
||||
|
||||
//列车所在轨道link
|
||||
HeadLink string
|
||||
//列车所在link偏移量(mm)
|
||||
@ -20,6 +21,15 @@ type TrainPositionInfo struct {
|
||||
TailLink string
|
||||
//列车所在link偏移量(mm)
|
||||
TailLinkOffset int64
|
||||
|
||||
//车头所在物理区段
|
||||
HeadSectionId string
|
||||
//车头所在物理区段偏移量
|
||||
HeadSectionOffset uint32
|
||||
//车尾所在物理区段
|
||||
TailSectionId string
|
||||
//车尾所在物理区段偏移量
|
||||
TailSectionOffset uint32
|
||||
}
|
||||
|
||||
func (t *TrainPositionInfo) ToString() string {
|
||||
|
@ -208,12 +208,12 @@ func (te *Zdj9TwoElectronic) HasNilReference() bool {
|
||||
// }
|
||||
|
||||
var (
|
||||
// ZDJ9双机电路元器件组件类型
|
||||
Zdj9TwoElectronicType = ecs.NewComponentType[Zdj9TwoElectronic]()
|
||||
// // ZDJ9双机驱动状态组件类型
|
||||
// Zdj9TwoDriveType = ecs.NewComponentType[Zdj9TwoDrive]()
|
||||
// // ZDJ9双机采集状态组件类型
|
||||
// Zdj9TwoCollectType = ecs.NewComponentType[Zdj9TwoCollect]()
|
||||
// ZDJ9双机电路元器件组件类型
|
||||
// Zdj9TwoElectronicType = ecs.NewComponentType[Zdj9TwoElectronic]()
|
||||
// // ZDJ9双机驱动状态组件类型
|
||||
// Zdj9TwoDriveType = ecs.NewComponentType[Zdj9TwoDrive]()
|
||||
// // ZDJ9双机采集状态组件类型
|
||||
// Zdj9TwoCollectType = ecs.NewComponentType[Zdj9TwoCollect]()
|
||||
)
|
||||
|
||||
// 转辙机状态
|
||||
|
23
component/xcj.go
Normal file
23
component/xcj.go
Normal file
@ -0,0 +1,23 @@
|
||||
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 //通过允许
|
||||
}
|
@ -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 << (7 - i))
|
||||
v := byte(1 << i)
|
||||
return (by & v) == v
|
||||
}
|
||||
|
||||
@ -28,9 +28,9 @@ func SetBitOfBytes(bs []byte, bitIndex int, v bool) []byte {
|
||||
}
|
||||
by := bs[bi]
|
||||
if v {
|
||||
by |= (1 << (7 - i))
|
||||
by |= (1 << i)
|
||||
} else {
|
||||
by &= ((1 << (7 - i)) ^ byte(0xff))
|
||||
by &= ((1 << i) ^ byte(0xff))
|
||||
}
|
||||
bs[bi] = by
|
||||
return bs
|
||||
|
20
entity/axle_counting_section.go
Normal file
20
entity/axle_counting_section.go
Normal file
@ -0,0 +1,20 @@
|
||||
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
|
||||
}
|
@ -3,10 +3,14 @@ package entity
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/component/component_data"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"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)
|
||||
@ -28,13 +32,27 @@ 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(component.UidType, component.BaliseStateType))
|
||||
entry = w.Entry(w.Create(BaliseBaseComponentTypeArr...))
|
||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||
component.BaliseStateType.Set(entry, &component.BaliseState{})
|
||||
component.BaliseWorkStateType.SetValue(entry, component.BaliseWorkState{Work: true})
|
||||
component.BaliseFixedTelegramType.Set(entry, &component.BaliseTelegram{
|
||||
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(),
|
||||
})
|
||||
component.KmType.Set(entry, td.Km())
|
||||
worldData.EntityMap[uid] = entry
|
||||
}
|
||||
return entry
|
||||
|
@ -108,3 +108,27 @@ 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
|
||||
}
|
||||
|
74
entity/ckm.go
Normal file
74
entity/ckm.go
Normal file
@ -0,0 +1,74 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/yohamta/donburi"
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var CkmBaseComponentTypes = []ecs.IComponentType{component.UidType, component.CkmTag, component.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))
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
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
|
||||
}
|
@ -195,13 +195,16 @@ func LoadEMPEntity(w ecs.World, entry *ecs.Entry, datas []*repository.Electronic
|
||||
}
|
||||
}
|
||||
if emp.Alarm == nil || emp.QBA == nil || emp.SDA == nil {
|
||||
return fmt.Errorf("EMP组合初始化出错,请检查IBP地图组合数据")
|
||||
slog.Warn("EMP组合缺少元素,将不添加EMP电路组件")
|
||||
return nil
|
||||
}
|
||||
for code, e := range emp.EMPJMap {
|
||||
if e.EMPFA_BTN == nil || e.EMPD == nil || len(e.EMP_BTNS) == 0 {
|
||||
return fmt.Errorf("组合[%s]还原按钮未关联,请检查IBP地图组合数据", code)
|
||||
slog.Warn(fmt.Sprintf("组合[%s]还原按钮未关联,请检查IBP地图组合数据", code))
|
||||
return nil
|
||||
} else if e.EMPJ == nil {
|
||||
return fmt.Errorf("组合[%s]继电器未关联,请检查继电器地图组合数据", code)
|
||||
slog.Warn(fmt.Sprintf("组合[%s]继电器未关联,请检查继电器地图组合数据", code))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
entry.AddComponent(component.EmpElectronicType, unsafe.Pointer(emp))
|
||||
|
@ -2,12 +2,14 @@ package entity
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component/singleton"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
)
|
||||
|
||||
// 仿真实体加载
|
||||
func Load(w ecs.World, repo *repository.Repository) error {
|
||||
// 初始化世界数据单例组件
|
||||
singleton.LoadWorldTime(w)
|
||||
LoadWorldData(w, repo)
|
||||
// 加载联锁驱采卡相关实体
|
||||
err := LoadCiQC(w)
|
||||
@ -34,8 +36,13 @@ func Load(w ecs.World, repo *repository.Repository) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 加载物理区段相关实体
|
||||
err = LoadPhysicalSections(w)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 加载计轴区段相关实体
|
||||
err = LoadAxlePhysicalSections(w)
|
||||
err = LoadAxleCountingSections(w)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -44,6 +51,25 @@ 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
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package entity
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/component/component_data"
|
||||
"joylink.club/rtsssimulation/consts"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
)
|
||||
|
||||
@ -11,7 +13,7 @@ func NewWireCabinetEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.WireCabinetType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.WireCabinetType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -23,7 +25,7 @@ func NewNetworkSwitchEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.NetworkSwitchType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.NetworkSwitchType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.NetworkSwitchType.Set(e, &component.NetworkSwitch{Normal: true})
|
||||
wd.EntityMap[id] = e
|
||||
@ -32,18 +34,11 @@ func NewNetworkSwitchEntity(w ecs.World, id string) *ecs.Entry {
|
||||
}
|
||||
|
||||
// NewAirPavilionEntity 创建风亭实体
|
||||
func NewAirPavilionEntity(w ecs.World, id string, apType proto.AirPavilion_Type) *ecs.Entry {
|
||||
func NewAirPavilionEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.AirPavilionType))
|
||||
//
|
||||
switch apType {
|
||||
case proto.AirPavilion_ExhaustPavilion:
|
||||
e.AddComponent(component.ExhaustPavilionTag)
|
||||
case proto.AirPavilion_AirSupplyPavilion:
|
||||
e.AddComponent(component.AirSupplyPavilionTag)
|
||||
}
|
||||
e = w.Entry(w.Create(component.UidType, component.AirPavilionType))
|
||||
//
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.AirPavilionType.Set(e, &component.AirPavilion{Normal: true})
|
||||
@ -57,9 +52,11 @@ func NewValveEntity(w ecs.World, id string, valveType proto.Valve_Type) *ecs.Ent
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.ValveType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.ValveType, component.ValveControllerType, component.FixedPositionTransformType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.ValveType.Set(e, &component.Valve{OpenRate: 100, Closed: false, Opened: true, Moving: false})
|
||||
//默认全关位置
|
||||
component.FixedPositionTransformType.Set(e, &component.FixedPositionTransform{FixedPositionTransform: component_data.FixedPositionTransform{Pos: consts.TwoPosMin}})
|
||||
component.ValveControllerType.Set(e, &component.ValveController{TargetOpenRate: 0})
|
||||
//
|
||||
switch valveType {
|
||||
case proto.Valve_ElectricControlValve:
|
||||
@ -82,22 +79,31 @@ func NewGasMixingChamberEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.GasMixingChamberType))
|
||||
e = w.Entry(w.Create(component.UidType, component.GasMixingChamberType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// NewCombinationAirConditionerEntity 创建组合式空调实体
|
||||
// NewCombinationAirConditionerEntity 创建组合式空调(变频)实体
|
||||
func NewCombinationAirConditionerEntity(w ecs.World, id string) *ecs.Entry {
|
||||
return newAirConditioningEntity(w, id, component.CombinationAirConditionerTag)
|
||||
}
|
||||
func newAirConditioningEntity(w ecs.World, id string, tag *ecs.ComponentType[struct{}]) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.AirConditioningType, component.DeviceExceptionType, tag))
|
||||
e = w.Entry(w.Create(component.UidType, component.MotorType, component.MotorFcType, component.FluidDriverType, component.AirConditioningType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// NewAirConditionerEntity 创建空调实体
|
||||
func NewAirConditionerEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e = w.Entry(w.Create(component.UidType, component.MotorType, component.AirConditioningType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -109,7 +115,7 @@ func NewPurificationDeviceEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.PurificationDeviceType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.PurificationDeviceType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -121,7 +127,7 @@ func NewAirCurtainEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.AirCurtainType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.AirCurtainType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -133,7 +139,7 @@ func NewGasEnvironmentEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.GasEnvironmentType))
|
||||
e = w.Entry(w.Create(component.UidType, component.GasEnvironmentType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -145,8 +151,9 @@ func NewFanEntity(w ecs.World, id string, fanType proto.Fan_Type) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.FanDeviceType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.MotorType, component.FluidDriverType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.MotorType.Set(e, &component.Motor{Speed: 0, Forward: true, Ms: component.MsOff})
|
||||
//
|
||||
switch fanType {
|
||||
case proto.Fan_CommonFan:
|
||||
@ -155,13 +162,12 @@ func NewFanEntity(w ecs.World, id string, fanType proto.Fan_Type) *ecs.Entry {
|
||||
}
|
||||
case proto.Fan_FcBypassFan:
|
||||
{
|
||||
e.AddComponent(component.FanFcUnitType)
|
||||
e.AddComponent(component.MotorFcType)
|
||||
e.AddComponent(component.FanBypassUnitType)
|
||||
e.AddComponent(component.FcBypassFanTag)
|
||||
}
|
||||
case proto.Fan_SoftStartFan:
|
||||
{
|
||||
e.AddComponent(component.FanSoftStartUnitType)
|
||||
e.AddComponent(component.SoftStartFanTag)
|
||||
}
|
||||
case proto.Fan_HighLowSpeedFan:
|
||||
|
@ -103,27 +103,6 @@ func NewEvacuationTypeFireRollerShutterEntity(w ecs.World, id string) *ecs.Entry
|
||||
return entry
|
||||
}
|
||||
|
||||
// NewFirePumpEntity 创建消防泵实体
|
||||
func NewFirePumpEntity(w ecs.World, id string) *ecs.Entry {
|
||||
entry := NewWaterPumpEntity(w, id)
|
||||
entry.AddComponent(component.FirePumpTag)
|
||||
return entry
|
||||
}
|
||||
|
||||
// NewSprayPumpEntity 创建喷淋泵实体
|
||||
func NewSprayPumpEntity(w ecs.World, id string) *ecs.Entry {
|
||||
entry := NewWaterPumpEntity(w, id)
|
||||
entry.AddComponent(component.SprayPumpTag)
|
||||
return entry
|
||||
}
|
||||
|
||||
// NewStabilizedPressurePumpEntity 创建稳压泵实体
|
||||
func NewStabilizedPressurePumpEntity(w ecs.World, id string) *ecs.Entry {
|
||||
entry := NewWaterPumpEntity(w, id)
|
||||
entry.AddComponent(component.StabilizedPressurePumpTag)
|
||||
return entry
|
||||
}
|
||||
|
||||
// NewFasAcsEntity 创建火警ACS联动实体
|
||||
func NewFasAcsEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
@ -160,20 +139,6 @@ func NewWaterFlowIndicatorEntity(w ecs.World, id string) *ecs.Entry {
|
||||
return e
|
||||
}
|
||||
|
||||
// NewSignalButterflyValveEntity 创建信号蝶阀实体
|
||||
func NewSignalButterflyValveEntity(w ecs.World, id string) *ecs.Entry {
|
||||
entry := NewElectricControlValveEntity(w, id)
|
||||
entry.AddComponent(component.SignalButterflyValveTag)
|
||||
return entry
|
||||
}
|
||||
|
||||
// NewPressureSwitchEntity 压力开关是与电器开关相结合的装置,当到达预先设定的流体压力时,开关接点动作
|
||||
func NewPressureSwitchEntity(w ecs.World, id string) *ecs.Entry {
|
||||
entry := NewElectricControlValveEntity(w, id)
|
||||
entry.AddComponent(component.PressureSwitchTag)
|
||||
return entry
|
||||
}
|
||||
|
||||
// NewNonFirePowerSourceEntity 创建非消防电源实体
|
||||
func NewNonFirePowerSourceEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
|
@ -2,7 +2,6 @@ package entity
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
)
|
||||
|
||||
// LoadIscs 加载ISCS相关设备实体
|
||||
@ -10,10 +9,7 @@ func LoadIscs(w ecs.World) error {
|
||||
data := GetWorldData(w)
|
||||
//电力母线实体
|
||||
for _, pipe := range data.Repo.PipeMap {
|
||||
switch pipe.PipeType {
|
||||
case proto.Pipe_ElectricPower:
|
||||
NewPowerPipeEntity(w, pipe.Id())
|
||||
}
|
||||
NewPipeEntity(w, pipe.Id())
|
||||
}
|
||||
//断路器
|
||||
for _, circuitBreaker := range data.Repo.CircuitBreakerMap {
|
||||
@ -41,7 +37,7 @@ func LoadIscs(w ecs.World) error {
|
||||
}
|
||||
//电源
|
||||
for _, ps := range data.Repo.PowerSourceMap {
|
||||
NewPowerSourceEntity(w, ps.Id(), ps.Ac, ps.Voltage)
|
||||
NewPowerSourceEntity(w, ps.Id())
|
||||
}
|
||||
//避雷器
|
||||
for _, la := range data.Repo.LightningArresterMap {
|
||||
@ -61,7 +57,7 @@ func LoadIscs(w ecs.World) error {
|
||||
}
|
||||
//风亭(排风亭、送风亭)
|
||||
for _, ap := range data.Repo.AirPavilionMap {
|
||||
NewAirPavilionEntity(w, ap.Id(), ap.PavilionType)
|
||||
NewAirPavilionEntity(w, ap.Id())
|
||||
}
|
||||
//阀门
|
||||
for _, valve := range data.Repo.ValveMap {
|
||||
@ -84,7 +80,7 @@ func LoadIscs(w ecs.World) error {
|
||||
NewAirCurtainEntity(w, ac.Id())
|
||||
}
|
||||
//气体环境
|
||||
for _, gasEnv := range data.Repo.GasEnvironmentMap {
|
||||
for _, gasEnv := range data.Repo.EnvironmentMap {
|
||||
NewGasEnvironmentEntity(w, gasEnv.Id())
|
||||
}
|
||||
//风机
|
||||
|
@ -12,7 +12,7 @@ func NewCircuitBreakerEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.CircuitBreakerType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.CircuitBreakerType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -24,7 +24,7 @@ func NewThreePositionSwitchEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.ThreePositionSwitchType.Set(e, &component.ThreePositionSwitch{Position: component.StpOpened})
|
||||
wd.EntityMap[id] = e
|
||||
@ -37,7 +37,7 @@ func NewHandcartSwitchEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.HandcartSwitchType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.HandcartSwitchType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.HandcartSwitchType.Set(e, &component.HandcartSwitch{Position: component.HpOpened})
|
||||
wd.EntityMap[id] = e
|
||||
@ -50,7 +50,7 @@ func NewRectifierEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.RectifierType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.RectifierType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -62,7 +62,7 @@ func NewDisconnectorEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.DisconnectorType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.DisconnectorType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -74,7 +74,7 @@ func NewLightningArresterEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.LightningArresterType))
|
||||
e = w.Entry(w.Create(component.UidType, component.LightningArresterType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.LightningArresterType.Set(e, &component.LightningArrester{Normal: true})
|
||||
wd.EntityMap[id] = e
|
||||
@ -87,7 +87,7 @@ func NewEarthingDeviceEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.EarthingDeviceType))
|
||||
e = w.Entry(w.Create(component.UidType, component.EarthingDeviceType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.EarthingDeviceType.Set(e, &component.EarthingDevice{Voltage: 0})
|
||||
wd.EntityMap[id] = e
|
||||
@ -100,34 +100,30 @@ func NewVoltageTransformerEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.VoltageTransformerType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.VoltageTransformerType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// NewPowerPipeEntity 创建PSCADA电力母线实体
|
||||
func NewPowerPipeEntity(w ecs.World, id string) *ecs.Entry {
|
||||
func NewPipeEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.PowerPipeType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.PowerPipeType.Set(e, &component.PowerPipe{Sources: make(map[string]*component.ElePower)})
|
||||
e = w.Entry(w.Create(component.UidType, component.PipeType))
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// NewPowerSourceEntity 创建PSCADA电源实体
|
||||
func NewPowerSourceEntity(w ecs.World, id string, ac bool, voltage uint32) *ecs.Entry {
|
||||
func NewPowerSourceEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.PowerSourceType))
|
||||
e = w.Entry(w.Create(component.UidType, component.ElectricitySourceType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.PowerSourceType.Set(e, &component.PowerSource{Ac: ac, Voltage: voltage})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
return e
|
||||
|
27
entity/loader.go
Normal file
27
entity/loader.go
Normal file
@ -0,0 +1,27 @@
|
||||
package entity
|
||||
|
||||
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())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadTurnouts(w ecs.World, points []model.Points) {
|
||||
for _, p := range points {
|
||||
switch p.GetTractionType() {
|
||||
case model.PTT_ZDJ9_2:
|
||||
|
||||
}
|
||||
}
|
||||
}
|
34
entity/physical_section.go
Normal file
34
entity/physical_section.go
Normal file
@ -0,0 +1,34 @@
|
||||
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
|
||||
}
|
22
entity/platform.go
Normal file
22
entity/platform.go
Normal file
@ -0,0 +1,22 @@
|
||||
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
|
||||
}
|
36
entity/points.go
Normal file
36
entity/points.go
Normal file
@ -0,0 +1,36 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/component/relation"
|
||||
"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,
|
||||
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)
|
||||
pzr := &relation.PointsZzjRela{
|
||||
Points: e,
|
||||
}
|
||||
// 关系状态初始化
|
||||
component.UidType.Set(e, &component.Uid{Id: id})
|
||||
component.PointsModelRelaType.Set(e, &relation.PointsModelRela{M: p})
|
||||
component.PointsZzjRelaType.Set(e, pzr)
|
||||
for _, ez := range entities {
|
||||
zzj := w.Entry(ez)
|
||||
pzr.Zzjs = append(pzr.Zzjs, zzj)
|
||||
component.PointsZzjRelaType.Set(zzj, pzr)
|
||||
}
|
||||
return e
|
||||
}
|
@ -4,13 +4,14 @@ import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"regexp"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var PsdBaseComponentTypeArr = []ecs.IComponentType{component.PsdTag, component.UidType,
|
||||
component.PsdStateType, component.AsdListType, component.PscType}
|
||||
var AsdBaseComponentTypeArr = []ecs.IComponentType{component.AsdTag, component.UidType,
|
||||
component.AsdMotorStateType, component.TwoPositionTransformType, component.AsdStateType}
|
||||
component.AsdMotorStateType, component.FixedPositionTransformType, component.AsdStateType}
|
||||
|
||||
func LoadPsd(w ecs.World) error {
|
||||
data := GetWorldData(w)
|
||||
@ -28,7 +29,7 @@ func LoadPsd(w ecs.World) error {
|
||||
}
|
||||
|
||||
func loadPlatformMkxCircuit(world ecs.World, entryMap map[string]*ecs.Entry, pmcMap map[string]*ecs.Entry,
|
||||
mkx *repository.Mkx, mkxEntry *ecs.Entry, psdEntry *ecs.Entry) {
|
||||
mkx *repository.PsdPsl, mkxEntry *ecs.Entry, psdEntry *ecs.Entry) {
|
||||
platformMkx, ok := pmcMap[mkx.Psd().Id()]
|
||||
if !ok {
|
||||
platformMkx = NewPlatformMkxEntry(world, entryMap, mkx)
|
||||
@ -45,18 +46,26 @@ 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":
|
||||
@ -102,7 +111,7 @@ func NewAsdEntry(world ecs.World, worldData *component.WorldData, psdId string,
|
||||
return entry
|
||||
}
|
||||
|
||||
func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repository.Mkx) *ecs.Entry {
|
||||
func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repository.PsdPsl) *ecs.Entry {
|
||||
entry := world.Entry(world.Create(component.UidType, component.MkxType))
|
||||
worldData.EntityMap[mkx.Id()] = entry
|
||||
component.UidType.SetValue(entry, component.Uid{Id: mkx.Id()})
|
||||
@ -111,19 +120,44 @@ 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.Mkx) *ecs.Entry {
|
||||
func NewPlatformMkxEntry(world ecs.World, entryMap map[string]*ecs.Entry, mkx *repository.PsdPsl) *ecs.Entry {
|
||||
entry := world.Entry(world.Create(component.PlatformMkxCircuitType))
|
||||
circuit := &component.PlatformMkxCircuit{}
|
||||
if pcbj := mkx.Pcbj(); pcbj != nil {
|
||||
@ -135,6 +169,12 @@ 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
|
||||
}
|
||||
|
@ -26,6 +26,13 @@ func NewRelayEntity(w ecs.World, relay *repository.Relay, entityMap map[string]*
|
||||
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
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ 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 {
|
||||
@ -24,6 +23,10 @@ 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 {
|
||||
|
51
entity/track_circuit.go
Normal file
51
entity/track_circuit.go
Normal file
@ -0,0 +1,51 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -52,7 +52,7 @@ func LoadTurnoutZdj9One(w ecs.World, turnout *repository.Turnout, entry *ecs.Ent
|
||||
// 加载道岔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.TwoPositionTransformType))
|
||||
entrys := ecs.Entries(w, w.CreateMany(2, component.ZzjStateType, component.FixedPositionTransformType))
|
||||
// 给道岔添加转辙机引用组件
|
||||
entry.AddComponent(component.TurnoutZzjType, unsafe.Pointer(&component.TurnoutZzj{
|
||||
ZzjList: entrys,
|
||||
|
66
entity/xcj.go
Normal file
66
entity/xcj.go
Normal file
@ -0,0 +1,66 @@
|
||||
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
|
||||
}
|
@ -1,6 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
"joylink.club/rtsssimulation/fi"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
"joylink.club/rtsssimulation/sys"
|
||||
"time"
|
||||
|
||||
rtss_simulation "joylink.club/rtsssimulation"
|
||||
@ -8,6 +13,43 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
protoRepo := &proto.Repository{}
|
||||
protoRepo.Id = "1"
|
||||
protoRepo.Version = "V1"
|
||||
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan1", FanType: proto.Fan_CommonFan})
|
||||
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan2", FanType: proto.Fan_FcBypassFan})
|
||||
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan3", FanType: proto.Fan_SoftStartFan})
|
||||
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan4", FanType: proto.Fan_HighLowSpeedFan})
|
||||
//
|
||||
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve1", ValveType: proto.Valve_ElectricControlValve})
|
||||
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve2", ValveType: proto.Valve_ElectricAirValve})
|
||||
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve3", ValveType: proto.Valve_CombinationAirValve})
|
||||
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve4", ValveType: proto.Valve_ElectricButterflyValve})
|
||||
//
|
||||
repo, _ := repository.BuildRepository(protoRepo)
|
||||
sim, _ := newIscsSimulation(repo)
|
||||
sim.StartUp()
|
||||
time.Sleep(2 * time.Second)
|
||||
fi.ValveOperate(sim, "valve1", 100)
|
||||
time.Sleep(5 * time.Second)
|
||||
fi.ValveOperate(sim, "valve1", 1)
|
||||
time.Sleep(4 * time.Second)
|
||||
sim.Close()
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
func newIscsSimulation(repo *repository.Repository) (ecs.World, error) {
|
||||
w := ecs.NewWorld(100)
|
||||
sys.BindSystem(w)
|
||||
//
|
||||
// 初始化世界数据单例组件
|
||||
entity.LoadWorldData(w, repo)
|
||||
err := entity.LoadIscs(w)
|
||||
return w, err
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
|
||||
func main1() {
|
||||
sim, _ := rtss_simulation.NewSimulation(&repository.Repository{})
|
||||
sim.StartUp()
|
||||
sim.SetSpeed(2)
|
||||
|
@ -1,77 +0,0 @@
|
||||
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())
|
||||
}
|
||||
}
|
@ -2,16 +2,9 @@ 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"
|
||||
)
|
||||
@ -22,37 +15,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) {
|
||||
//相关继电器
|
||||
|
66
fi/balise.go
Normal file
66
fi/balise.go
Normal file
@ -0,0 +1,66 @@
|
||||
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
|
||||
}
|
@ -2,6 +2,7 @@ package fi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
//"joylink.club/bj-rtsts-server/dto/request_proto"
|
||||
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
@ -16,6 +17,7 @@ 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))
|
||||
}
|
||||
@ -32,6 +34,7 @@ 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))
|
||||
}
|
||||
@ -48,6 +51,7 @@ 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))
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
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) {
|
||||
|
||||
}
|
151
fi/iscs_bas.go
151
fi/iscs_bas.go
@ -2,16 +2,21 @@ package fi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/consts"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
)
|
||||
|
||||
// CommonFanOperate 一般风机控制,如排烟风机、正压送风机、射流风机、普通风机、硬线风机
|
||||
// ValveOperate 阀门操作
|
||||
//
|
||||
// power : 风机电源,大于0接通正转相序电源,小于0接通反转相序电源,等于0关闭电源
|
||||
func CommonFanOperate(w ecs.World, deviceId string, power int) error {
|
||||
// deviceId 阀门id;
|
||||
// openRate 阀门打开百分比值,0-全关,100-全开;
|
||||
func ValveOperate(w ecs.World, deviceId string, openRate uint8) error {
|
||||
if openRate < 0 || openRate > 100 {
|
||||
return fmt.Errorf("阀门打开百分比值[%d]不在范围[0,100]内", openRate)
|
||||
}
|
||||
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(w)
|
||||
deviceEntry, ok := wd.EntityMap[deviceId]
|
||||
@ -19,120 +24,10 @@ func CommonFanOperate(w ecs.World, deviceId string, power int) error {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
|
||||
}
|
||||
//
|
||||
if !deviceEntry.HasComponent(component.FanType) {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是风机", deviceId))
|
||||
}
|
||||
//
|
||||
fan := component.FanType.Get(deviceEntry)
|
||||
fan.Power = power
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return r.Err
|
||||
}
|
||||
|
||||
// SoftBypassFanOperate 如软启风机、隧道风机
|
||||
func SoftBypassFanOperate(w ecs.World, deviceId string, power int, softStart bool, bypass bool) error {
|
||||
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(w)
|
||||
deviceEntry, ok := wd.EntityMap[deviceId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
|
||||
}
|
||||
//
|
||||
if !deviceEntry.HasComponent(component.FanType) {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是风机", deviceId))
|
||||
}
|
||||
//
|
||||
fan := component.FanType.Get(deviceEntry)
|
||||
fan.Bypass = bypass
|
||||
fan.SoftStart = softStart
|
||||
fan.Power = power
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return r.Err
|
||||
}
|
||||
|
||||
// FcBypassFanOperate (变频、旁路)回排风机
|
||||
func FcBypassFanOperate(w ecs.World, deviceId string, power int, fc bool, bypass bool) error {
|
||||
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(w)
|
||||
deviceEntry, ok := wd.EntityMap[deviceId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
|
||||
}
|
||||
//
|
||||
if !deviceEntry.HasComponent(component.FanType) {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是风机", deviceId))
|
||||
}
|
||||
//
|
||||
fan := component.FanType.Get(deviceEntry)
|
||||
fan.Bypass = bypass
|
||||
fan.Fc = fc
|
||||
fan.Power = power
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return r.Err
|
||||
}
|
||||
|
||||
// TwoSpeedFanOperate 双速风机,转速模式设置
|
||||
//
|
||||
// highSpeedMode-true高速模式,false-低速模式
|
||||
func TwoSpeedFanOperate(w ecs.World, deviceId string, power int, highSpeedMode bool) error {
|
||||
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(w)
|
||||
deviceEntry, ok := wd.EntityMap[deviceId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
|
||||
}
|
||||
//
|
||||
if !(deviceEntry.HasComponent(component.FanType) && deviceEntry.HasComponent(component.TwoSpeedFanTag)) {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是双速风机", deviceId))
|
||||
}
|
||||
//
|
||||
fan := component.FanType.Get(deviceEntry)
|
||||
fan.Power = power
|
||||
//
|
||||
deviceEntry.RemoveComponent(component.HighSpeedModeFanTag)
|
||||
deviceEntry.RemoveComponent(component.LowSpeedModeFanTag)
|
||||
if highSpeedMode {
|
||||
deviceEntry.AddComponent(component.HighSpeedModeFanTag)
|
||||
} else {
|
||||
deviceEntry.AddComponent(component.LowSpeedModeFanTag)
|
||||
}
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return r.Err
|
||||
}
|
||||
|
||||
// FanExceptionOperate 风机异常设置(故障、异常、通信中断)
|
||||
func FanExceptionOperate(w ecs.World, deviceId string, opt DeviceExceptionOptEnum) error {
|
||||
return DeviceExceptionOperate(w, deviceId, opt)
|
||||
}
|
||||
|
||||
// ElectricControlValveOperate 电动调节阀操作
|
||||
//
|
||||
// optOpen : true-触发开阀;false-触发关阀
|
||||
func ElectricControlValveOperate(w ecs.World, deviceId string, optOpen bool) error {
|
||||
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(w)
|
||||
deviceEntry, ok := wd.EntityMap[deviceId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
|
||||
}
|
||||
//
|
||||
if !(deviceEntry.HasComponent(component.ElectricControlValveType) && deviceEntry.HasComponent(component.TwoPositionTransformType)) {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是电动调节阀", deviceId))
|
||||
}
|
||||
tps := component.TwoPositionTransformType.Get(deviceEntry) //最小表示全关,最大表示全开
|
||||
if optOpen {
|
||||
tps.Speed = component.CalculateTwoPositionAvgSpeed(component.ElectricControlValveOperationTime, w.Tick())
|
||||
} else {
|
||||
tps.Speed = -component.CalculateTwoPositionAvgSpeed(component.ElectricControlValveOperationTime, w.Tick())
|
||||
if !(deviceEntry.HasComponent(component.ValveType) && deviceEntry.HasComponent(component.ValveControllerType) && deviceEntry.HasComponent(component.FixedPositionTransformType)) {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是阀门", deviceId))
|
||||
}
|
||||
component.ValveControllerType.Get(deviceEntry).TargetOpenRate = openRate
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
@ -302,30 +197,6 @@ func WaterClosedContainerOperate(w ecs.World, deviceId string, optRun bool) erro
|
||||
return r.Err
|
||||
}
|
||||
|
||||
// BypassValveSwitchOperate 旁通阀开关操作
|
||||
//
|
||||
// openRate 旁通阀开关打开百分比[0,100]
|
||||
func BypassValveSwitchOperate(w ecs.World, deviceId string, openRate uint8) error {
|
||||
if openRate < 0 || openRate > 100 {
|
||||
return fmt.Errorf("旁通阀开关打开百分比值须在[0,100]范围内")
|
||||
}
|
||||
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(w)
|
||||
deviceEntry, ok := wd.EntityMap[deviceId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
|
||||
}
|
||||
//
|
||||
if !(deviceEntry.HasComponent(component.ControlValveType) && deviceEntry.HasComponent(component.BypassValveSwitchTag)) {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是旁通阀开关", deviceId))
|
||||
}
|
||||
component.ControlValveType.Get(deviceEntry).OpenRate = openRate
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return r.Err
|
||||
}
|
||||
|
||||
// CivilDefenseDoorOperate 封闭式水容器(如冷却塔、水处理器)
|
||||
//
|
||||
// optOpen : true-开门;false-关门
|
||||
|
62
fi/motor.go
Normal file
62
fi/motor.go
Normal file
@ -0,0 +1,62 @@
|
||||
package fi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
)
|
||||
|
||||
// FiMotorSwitch 电机电源开关定义
|
||||
type FiMotorSwitch uint8
|
||||
|
||||
const (
|
||||
FiMsOff FiMotorSwitch = iota //关闭电源
|
||||
FiMsOnForward //正转电源
|
||||
FiMsOnReverse //反转电源
|
||||
)
|
||||
|
||||
// MotorOperate 电机操作
|
||||
//
|
||||
// deviceId 电机id;
|
||||
// fiMs 电机电源;
|
||||
// fc 电机如果有变频器,设置频率;
|
||||
func MotorOperate(w ecs.World, deviceId string, fiMs FiMotorSwitch, fc uint16) error {
|
||||
if fc < 0 || fc > 100 {
|
||||
return fmt.Errorf("设置变频器频率[%d]不在[0,100]范围内", fc)
|
||||
}
|
||||
ms, e := func(fiMs FiMotorSwitch) (component.MotorSwitch, error) {
|
||||
switch fiMs {
|
||||
case FiMsOff:
|
||||
return component.MsOff, nil
|
||||
case FiMsOnForward:
|
||||
return component.MsOnForward, nil
|
||||
case FiMsOnReverse:
|
||||
return component.MsOnReverse, nil
|
||||
default:
|
||||
return 0, fmt.Errorf("参数fiMs[%d]无法映射到component.MotorSwitch", fiMs)
|
||||
}
|
||||
}(fiMs)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(w)
|
||||
deviceEntry, ok := wd.EntityMap[deviceId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
|
||||
}
|
||||
//
|
||||
if !deviceEntry.HasComponent(component.MotorType) {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是电机", deviceId))
|
||||
}
|
||||
motor := component.MotorType.Get(deviceEntry)
|
||||
motor.Ms = ms
|
||||
if deviceEntry.HasComponent(component.MotorFcType) { //变频电机
|
||||
component.MotorFcType.Get(deviceEntry).F = fc
|
||||
}
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return r.Err
|
||||
}
|
120
fi/physical_section.go
Normal file
120
fi/physical_section.go
Normal file
@ -0,0 +1,120 @@
|
||||
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
|
||||
}
|
353
fi/psd.go
353
fi/psd.go
@ -1,353 +0,0 @@
|
||||
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)
|
||||
}
|
28
fi/relay.go
28
fi/relay.go
@ -66,3 +66,31 @@ func DriveRelayDown(w ecs.World, id string) error {
|
||||
})
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
// 取消继电器强制故障
|
||||
func CancelRelayFaultForce(w ecs.World, id string) error {
|
||||
return updateRelayFault(w, id, func(entry *ecs.Entry) {
|
||||
entry.RemoveComponent(component.RelayFaultForceType)
|
||||
})
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
238
fi/section.go
238
fi/section.go
@ -1,238 +0,0 @@
|
||||
package fi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
26
fi/signal.go
26
fi/signal.go
@ -2,6 +2,7 @@ package fi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/component/component_proto"
|
||||
@ -44,6 +45,31 @@ func UpdateSignalLightFault(w ecs.World, signalId string, light component_proto.
|
||||
return r.Err
|
||||
}
|
||||
|
||||
// 更新信号机灯丝断丝故障
|
||||
func UpdateSignalFaultDS(w ecs.World, uid string, light []component_proto.Light_Color) error {
|
||||
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(w)
|
||||
signalEntry, ok := wd.EntityMap[uid]
|
||||
if ok {
|
||||
lights := component.SignalLightsType.Get(signalEntry)
|
||||
// 先清除所有故障
|
||||
for _, e := range lights.Lights {
|
||||
e.RemoveComponent(component.LightFaultDsType)
|
||||
}
|
||||
// 设置故障
|
||||
for _, light := range light {
|
||||
lightEntry := component.SignalLightsType.Get(signalEntry).GetLightByColor(light)
|
||||
if lightEntry == nil {
|
||||
return ecs.NewErrResult(fmt.Errorf("信号机[%s]没有色灯[%d]", uid, light))
|
||||
}
|
||||
lightEntry.AddComponent(component.LightFaultDsType)
|
||||
}
|
||||
}
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return r.Err
|
||||
}
|
||||
|
||||
// SignalLightDrive 当没有电路时,直接驱动信号机灯位上的灯
|
||||
// ldLights : 需要亮的灯;当为空时则信号机所有色灯灭灯
|
||||
func SignalLightDrive(w ecs.World, signalId string, ldLights ...component_proto.Light_Color) error {
|
||||
|
12
fi/train.go
12
fi/train.go
@ -99,6 +99,18 @@ 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 {
|
||||
|
15
go.mod
15
go.mod
@ -3,18 +3,19 @@ module joylink.club/rtsssimulation
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/stretchr/testify v1.8.3
|
||||
google.golang.org/protobuf v1.31.0
|
||||
github.com/stretchr/testify v1.8.4
|
||||
google.golang.org/protobuf v1.32.0
|
||||
joylink.club/ecs v0.0.1
|
||||
)
|
||||
|
||||
replace joylink.club/ecs => ./jl-ecs-go
|
||||
replace joylink.club/ecs => ./jl-ecs
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/yohamta/donburi v1.3.9 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
26
go.sum
26
go.sum
@ -1,26 +1,16 @@
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
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.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
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=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
||||
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
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=
|
||||
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=
|
||||
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/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=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
27
go.work.sum
27
go.work.sum
@ -1,28 +1,47 @@
|
||||
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=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
|
||||
@ -31,13 +50,16 @@ 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=
|
||||
@ -65,6 +87,7 @@ 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=
|
||||
@ -80,5 +103,9 @@ 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=
|
||||
|
16
init.go
16
init.go
@ -3,13 +3,14 @@ package rtss_simulation
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
"joylink.club/rtsssimulation/modelrepo"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/sys"
|
||||
)
|
||||
|
||||
const (
|
||||
// 仿真循环间隔,单位ms
|
||||
RtssSimulationTick = 20
|
||||
RtssSimulationTick = 10
|
||||
)
|
||||
|
||||
// 初始化仿真
|
||||
@ -19,3 +20,16 @@ func NewSimulation(repo *repository.Repository) (ecs.World, error) {
|
||||
err := entity.Load(w, repo)
|
||||
return w, err
|
||||
}
|
||||
|
||||
// 加载城轨仿真
|
||||
func LoadCgSimulation(repo modelrepo.Repo) (ecs.World, error) {
|
||||
w := ecs.NewWorld(RtssSimulationTick)
|
||||
// 加载组件实体
|
||||
err := entity.Loading(w, repo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 加载系统
|
||||
sys.BindSystem(w)
|
||||
return w, err
|
||||
}
|
||||
|
1
jl-ecs
Submodule
1
jl-ecs
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit f0a56ea6722b620c8b900efa9f0d626f00af00ad
|
@ -1 +0,0 @@
|
||||
Subproject commit bd947baa4edadb6b7bd059f6e324fb20f8171f8f
|
23
modelrepo/check_test.go
Normal file
23
modelrepo/check_test.go
Normal file
@ -0,0 +1,23 @@
|
||||
package modelrepo
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestIsFieldEmpty(t *testing.T) {
|
||||
tests := []struct {
|
||||
give any
|
||||
want bool
|
||||
}{
|
||||
{give: nil, want: true},
|
||||
{give: "", want: true},
|
||||
{give: 0, want: true},
|
||||
{give: []string{}, want: true},
|
||||
{give: map[string]string{}, want: true},
|
||||
{give: []int{}, want: true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
if got := isFieldEmpty(tt.give); got != tt.want {
|
||||
t.Errorf("IsFieldEmpty(%v) = %v, want = %v", tt.give, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
4060
modelrepo/dto/cg_repo.pb.go
Normal file
4060
modelrepo/dto/cg_repo.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
25
modelrepo/error_record.go
Normal file
25
modelrepo/error_record.go
Normal file
@ -0,0 +1,25 @@
|
||||
package modelrepo
|
||||
|
||||
// 构建错误记录
|
||||
type ErrorRecord struct {
|
||||
// 告警信息
|
||||
Warns []string
|
||||
// 错误信息
|
||||
Errs []string
|
||||
}
|
||||
|
||||
func NewErrorRecord() *ErrorRecord {
|
||||
return &ErrorRecord{}
|
||||
}
|
||||
|
||||
func (r *ErrorRecord) AddError(err string) {
|
||||
r.Errs = append(r.Errs, err)
|
||||
}
|
||||
|
||||
func (r *ErrorRecord) HasError() bool {
|
||||
return len(r.Errs) > 0
|
||||
}
|
||||
|
||||
func (r *ErrorRecord) AddWarn(warn string) {
|
||||
r.Warns = append(r.Warns, warn)
|
||||
}
|
468
modelrepo/idmapping_build.go
Normal file
468
modelrepo/idmapping_build.go
Normal file
@ -0,0 +1,468 @@
|
||||
package modelrepo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"joylink.club/rtsssimulation/modelrepo/dto"
|
||||
)
|
||||
|
||||
// 城轨uid
|
||||
type CgUid struct {
|
||||
// 城市
|
||||
city string
|
||||
// 线路
|
||||
line string
|
||||
// 设备编号
|
||||
codes []string
|
||||
// codestr
|
||||
codestr string
|
||||
// uid
|
||||
idstr string
|
||||
}
|
||||
|
||||
func NewCgUid(city string, line string, codes ...string) *CgUid {
|
||||
if city == "" || line == "" {
|
||||
panic(fmt.Errorf("创建城轨uid错误: 城市、线路、车站不能为空 city=%s, line=%s", city, line))
|
||||
}
|
||||
l := len(codes)
|
||||
if l == 0 {
|
||||
panic(fmt.Errorf("创建城轨uid错误: codes不能为空"))
|
||||
}
|
||||
codestr := strings.Join(codes, "_")
|
||||
elems := []string{city, line, codestr}
|
||||
uid := strings.Join(elems, "_")
|
||||
return &CgUid{
|
||||
city: city,
|
||||
line: line,
|
||||
codes: codes,
|
||||
codestr: codestr,
|
||||
idstr: uid,
|
||||
}
|
||||
}
|
||||
|
||||
func (u *CgUid) Id() string {
|
||||
return u.idstr
|
||||
}
|
||||
|
||||
func (u *CgUid) Code() string {
|
||||
return u.codestr
|
||||
}
|
||||
|
||||
type idMap struct {
|
||||
// 数据id
|
||||
Did string
|
||||
// 元素id
|
||||
Eid uint32
|
||||
// 唯一id
|
||||
Uid *CgUid
|
||||
}
|
||||
|
||||
func NewIdMap(did string, eid uint32, uid *CgUid) *idMap {
|
||||
return &idMap{
|
||||
Did: did,
|
||||
Eid: eid,
|
||||
Uid: uid,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *idMap) DeId() string {
|
||||
return DeID(m.Did, m.Eid)
|
||||
}
|
||||
func (m *idMap) Debug() string {
|
||||
return fmt.Sprintf("{数据id=%s, 元素id=%v, uid=%s}", m.Did, m.Eid, m.Uid.Id())
|
||||
}
|
||||
|
||||
// 数据元素id key生成
|
||||
// did - 数据id
|
||||
// eid - 元素id
|
||||
func DeID(did string, eid uint32) string {
|
||||
return fmt.Sprintf("%s_%v", did, eid)
|
||||
}
|
||||
|
||||
// id映射表
|
||||
type IdMapping struct {
|
||||
// 数据元素id映射
|
||||
deidMap map[string]*idMap
|
||||
// uid映射(只存储最初的idMap,实际中一个uid可能对应多个数据元素id)
|
||||
uidMap map[string]*idMap
|
||||
}
|
||||
|
||||
func (m *IdMapping) queryByDeId(deid string) *idMap {
|
||||
return m.deidMap[deid]
|
||||
}
|
||||
|
||||
func (m *IdMapping) queryByDidAndEid(did string, eid uint32) *idMap {
|
||||
id := DeID(did, eid)
|
||||
return m.deidMap[id]
|
||||
}
|
||||
|
||||
func (m *IdMapping) add(idmap *idMap) {
|
||||
if idmap == nil {
|
||||
panic(fmt.Errorf("添加id映射表错误: idmap不能为空"))
|
||||
}
|
||||
m.deidMap[idmap.DeId()] = idmap
|
||||
}
|
||||
|
||||
func (m *IdMapping) checkUidAndAdd(idmap *idMap) (existed *idMap, uidExisted bool) {
|
||||
if idmap == nil {
|
||||
panic(fmt.Errorf("添加id映射表错误: idmap不能为空"))
|
||||
}
|
||||
m.deidMap[idmap.DeId()] = idmap
|
||||
existed, ok := m.uidMap[idmap.Uid.Id()]
|
||||
if ok {
|
||||
uidExisted = true
|
||||
} else {
|
||||
m.uidMap[idmap.Uid.Id()] = idmap
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 构建城轨id映射
|
||||
func BuildIdMapping(msgs *dto.CgRepo, errRecord *ErrorRecord) *IdMapping {
|
||||
if msgs == nil {
|
||||
errRecord.AddError("构建城轨id映射表错误: 未关联任何数据")
|
||||
return nil
|
||||
}
|
||||
idMapping := &IdMapping{
|
||||
deidMap: make(map[string]*idMap),
|
||||
uidMap: make(map[string]*idMap),
|
||||
}
|
||||
lineSet := make(map[string]struct{})
|
||||
for _, l := range msgs.Lines {
|
||||
if _, ok := lineSet[l.City+l.LineId]; ok {
|
||||
errRecord.AddError(fmt.Sprintf("构建城轨id映射表错误: 线路重复:%s_%s", l.City, l.LineId))
|
||||
return nil
|
||||
}
|
||||
lineSet[l.City+l.LineId] = struct{}{}
|
||||
}
|
||||
for _, line := range msgs.Lines {
|
||||
buildXhbz(idMapping, line, errRecord)
|
||||
if errRecord.HasError() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return idMapping
|
||||
}
|
||||
|
||||
// 构建信号布置数据id映射
|
||||
func buildXhbz(idMapping *IdMapping, line *dto.Line, errRecord *ErrorRecord) {
|
||||
xhbz := line.Xhbz
|
||||
if xhbz == nil {
|
||||
errRecord.AddError("构建城轨id映射表错误: 信号布置数据为空")
|
||||
return
|
||||
}
|
||||
city := line.City // 城市
|
||||
lineId := line.LineId // 线路id
|
||||
did := xhbz.Id // 数据id
|
||||
errPrefix := "信号布置数据错误"
|
||||
// 车站uid
|
||||
for _, station := range xhbz.Stations {
|
||||
eid := station.Id
|
||||
if checkFieldEmpty(did, eid, station.Name, errPrefix, "车站名称", errRecord) {
|
||||
continue
|
||||
}
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, station.Name))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 车站站台uid
|
||||
for _, p := range xhbz.Platforms {
|
||||
eid := p.Id
|
||||
if checkFieldEmpty(did, eid, p.Code, errPrefix, "站台编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, p.StationId, errPrefix, "站台关联车站", errRecord) {
|
||||
continue
|
||||
}
|
||||
stationIdm := idMapping.queryByDidAndEid(did, p.StationId)
|
||||
if checkRelationNil(did, eid, p.StationId, stationIdm, errPrefix, "站台关联车站", errRecord) {
|
||||
continue
|
||||
}
|
||||
// 站台code: 车站名称_站台编号
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, stationIdm.Uid.Code(), p.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 屏蔽门uid
|
||||
for _, p := range xhbz.Psds {
|
||||
eid := p.Id
|
||||
if checkFieldEmpty(did, eid, p.Code, errPrefix, "屏蔽门编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, p.PlatformId, errPrefix, "屏蔽门关联站台", errRecord) {
|
||||
continue
|
||||
}
|
||||
relIdMap := idMapping.queryByDidAndEid(did, p.PlatformId)
|
||||
if checkRelationNil(did, eid, p.PlatformId, relIdMap, errPrefix, "屏蔽门关联站台", errRecord) {
|
||||
continue
|
||||
}
|
||||
// 屏蔽门code: 站台编号_屏蔽门编号
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, relIdMap.Uid.Code(), p.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 物理区段
|
||||
for _, ps := range xhbz.Sections {
|
||||
eid := ps.Id
|
||||
if checkFieldEmpty(did, eid, ps.Code, errPrefix, "物理区段编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, ps.EcsId, errPrefix, "物理区段关联集中站", errRecord) {
|
||||
continue
|
||||
}
|
||||
relIdMap := idMapping.queryByDidAndEid(did, ps.EcsId)
|
||||
if checkRelationNil(did, eid, ps.EcsId, relIdMap, errPrefix, "物理区段关联集中站", errRecord) {
|
||||
continue
|
||||
}
|
||||
// 物理区段code: 集中站名称_物理区段编号
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, relIdMap.Uid.Code(), ps.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 道岔uid
|
||||
for _, t := range xhbz.Turnouts {
|
||||
eid := t.Id
|
||||
if checkFieldEmpty(did, eid, t.Code, errPrefix, "道岔编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, t.EcsId, errPrefix, "道岔关联集中站", errRecord) {
|
||||
continue
|
||||
}
|
||||
relIdMap := idMapping.queryByDidAndEid(did, t.EcsId)
|
||||
if checkRelationNil(did, eid, t.EcsId, relIdMap, errPrefix, "道岔关联集中站", errRecord) {
|
||||
continue
|
||||
}
|
||||
// 道岔code: 集中站名称_道岔编号
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, relIdMap.Uid.Code(), t.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 区段分界点uid
|
||||
for _, c := range xhbz.DevidingPoints {
|
||||
eid := c.Id
|
||||
if checkFieldEmpty(did, eid, c.Code, errPrefix, "区段分界点编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, c.EcsIds, errPrefix, "区段分界点关联集中站", errRecord) {
|
||||
continue
|
||||
}
|
||||
ecsErr := false
|
||||
for _, v := range c.EcsIds {
|
||||
relIdMap := idMapping.queryByDidAndEid(did, v)
|
||||
if checkRelationNil(did, eid, v, relIdMap, errPrefix, "区段分界点关联集中站", errRecord) {
|
||||
ecsErr = true
|
||||
continue
|
||||
}
|
||||
}
|
||||
if ecsErr {
|
||||
continue
|
||||
}
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, c.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 信号机uid
|
||||
for _, s := range xhbz.Signals {
|
||||
eid := s.Id
|
||||
if checkFieldEmpty(did, eid, s.Code, errPrefix, "信号机编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, s.EcsId, errPrefix, "信号机关联集中站", errRecord) {
|
||||
continue
|
||||
}
|
||||
relIdMap := idMapping.queryByDidAndEid(did, s.EcsId)
|
||||
if checkRelationNil(did, eid, s.EcsId, relIdMap, errPrefix, "信号机关联集中站", errRecord) {
|
||||
continue
|
||||
}
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, relIdMap.Uid.Code(), s.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 应答器uid
|
||||
for _, b := range xhbz.Balises {
|
||||
eid := b.Id
|
||||
if checkFieldEmpty(did, eid, b.Code, errPrefix, "应答器编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, b.EcsId, errPrefix, "应答器关联集中站", errRecord) {
|
||||
continue
|
||||
}
|
||||
relIdMap := idMapping.queryByDidAndEid(did, b.EcsId)
|
||||
if checkRelationNil(did, eid, b.EcsId, relIdMap, errPrefix, "应答器关联集中站", errRecord) {
|
||||
continue
|
||||
}
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, relIdMap.Uid.Code(), b.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 停车点
|
||||
for _, ps := range xhbz.ParkingSpots {
|
||||
idmap := NewIdMap(did, ps.Id, NewCgUid(city, lineId, did, strconv.Itoa(int(ps.Id))))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 坡度
|
||||
for _, v := range xhbz.Pds {
|
||||
idmap := NewIdMap(did, v.Id, NewCgUid(city, lineId, did, strconv.Itoa(int(v.Id))))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 曲度
|
||||
for _, v := range xhbz.Qds {
|
||||
idmap := NewIdMap(did, v.Id, NewCgUid(city, lineId, did, strconv.Itoa(int(v.Id))))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 紧急停车按钮
|
||||
for _, v := range xhbz.Emps {
|
||||
eid := v.Id
|
||||
if checkFieldEmpty(did, eid, v.Code, errPrefix, "紧急停车按钮编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, v.PlatformId, errPrefix, "紧急停车按钮关联站台", errRecord) {
|
||||
continue
|
||||
}
|
||||
relIdMap := idMapping.queryByDidAndEid(did, v.PlatformId)
|
||||
if checkRelationNil(did, eid, v.PlatformId, relIdMap, errPrefix, "紧急停车按钮关联站台", errRecord) {
|
||||
continue
|
||||
}
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, relIdMap.Uid.Code(), v.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 停车倒计时器
|
||||
for _, v := range xhbz.Tdts {
|
||||
eid := v.Id
|
||||
if checkFieldEmpty(did, eid, v.Code, errPrefix, "停车倒计时器编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, v.PlatformId, errPrefix, "停车倒计时器关联站台", errRecord) {
|
||||
continue
|
||||
}
|
||||
relIdMap := idMapping.queryByDidAndEid(did, v.PlatformId)
|
||||
if checkRelationNil(did, eid, v.PlatformId, relIdMap, errPrefix, "停车倒计时器关联站台", errRecord) {
|
||||
continue
|
||||
}
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, relIdMap.Uid.Code(), v.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 门控箱
|
||||
for _, v := range xhbz.Mkxs {
|
||||
eid := v.Id
|
||||
if checkFieldEmpty(did, eid, v.Code, errPrefix, "门控箱编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, v.PsdId, errPrefix, "门控箱关联屏蔽门", errRecord) {
|
||||
continue
|
||||
}
|
||||
relIdMap := idMapping.queryByDidAndEid(did, v.PsdId)
|
||||
if checkRelationNil(did, eid, v.PsdId, relIdMap, errPrefix, "门控箱关联屏蔽门", errRecord) {
|
||||
continue
|
||||
}
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, relIdMap.Uid.Code(), v.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// PSL
|
||||
for _, v := range xhbz.Psls {
|
||||
eid := v.Id
|
||||
if checkFieldEmpty(did, eid, v.Code, errPrefix, "PSL编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, v.PsdId, errPrefix, "PSL关联屏蔽门", errRecord) {
|
||||
continue
|
||||
}
|
||||
relIdMap := idMapping.queryByDidAndEid(did, v.PsdId)
|
||||
if checkRelationNil(did, eid, v.PsdId, relIdMap, errPrefix, "PSL关联屏蔽门", errRecord) {
|
||||
continue
|
||||
}
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, relIdMap.Uid.Code(), v.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// SPKS
|
||||
for _, v := range xhbz.Spks {
|
||||
eid := v.Id
|
||||
if checkFieldEmpty(did, eid, v.Code, errPrefix, "SPKS编号", errRecord) {
|
||||
continue
|
||||
}
|
||||
if checkFieldEmpty(did, eid, v.PlatformId, errPrefix, "SPKS关联站台", errRecord) {
|
||||
continue
|
||||
}
|
||||
relIdMap := idMapping.queryByDidAndEid(did, v.PlatformId)
|
||||
if checkRelationNil(did, eid, v.PlatformId, relIdMap, errPrefix, "SPKS关联站台", errRecord) {
|
||||
continue
|
||||
}
|
||||
idmap := NewIdMap(did, eid, NewCgUid(city, lineId, relIdMap.Uid.Code(), v.Code))
|
||||
if checkRepeatOrAddIdMap(idmap, idMapping, errPrefix, errRecord) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func checkRelationNil(did string, eid uint32, relId uint32, relIdMap *idMap, prefix string, relTip string, errRecord *ErrorRecord) bool {
|
||||
if relIdMap == nil {
|
||||
errRecord.AddError(fmt.Sprintf("%s: %s不存在, 数据id=%s 数据元素id=%v 关联id=%v", prefix, relTip, did, eid, relId))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查字段是否为空
|
||||
func checkFieldEmpty(did string, eid uint32, field any, prefix string, tip string, errRecord *ErrorRecord) bool {
|
||||
if isFieldEmpty(field) {
|
||||
errRecord.AddError(fmt.Sprintf("%s: %s不能为空, 数据id=%s 数据元素id=%v ", prefix, tip, did, eid))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isFieldEmpty(field any) bool {
|
||||
if field == nil {
|
||||
return true
|
||||
}
|
||||
vf := reflect.ValueOf(field)
|
||||
switch vf.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
|
||||
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
|
||||
reflect.Float32, reflect.Float64:
|
||||
return field == 0
|
||||
case reflect.String:
|
||||
return field == ""
|
||||
case reflect.Slice, reflect.Map:
|
||||
return vf.Len() == 0
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 数据uid/deid重复检查
|
||||
func checkRepeatOrAddIdMap(idm *idMap, idMapping *IdMapping, prefix string, errRecord *ErrorRecord) (repeated bool) {
|
||||
if old := idMapping.queryByDeId(idm.DeId()); old != nil {
|
||||
errRecord.AddError(fmt.Sprintf("%s,数据元素重复: 数据1=%s 数据2=%s,", prefix, old.Debug(), idm.Debug()))
|
||||
repeated = true
|
||||
} else if old, _ := idMapping.checkUidAndAdd(idm); old != nil {
|
||||
errRecord.AddError(fmt.Sprintf("%s,数据重复: 数据1=%s 数据2=%s,", prefix, old.Debug(), idm.Debug()))
|
||||
repeated = true
|
||||
}
|
||||
return
|
||||
}
|
57
modelrepo/manage.go
Normal file
57
modelrepo/manage.go
Normal file
@ -0,0 +1,57 @@
|
||||
package modelrepo
|
||||
|
||||
import "sync"
|
||||
|
||||
// Repo管理
|
||||
type repoManager struct {
|
||||
repoMap map[string]Repo
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
var defaultManager = &repoManager{
|
||||
repoMap: make(map[string]Repo),
|
||||
}
|
||||
|
||||
// 获取Repo
|
||||
func GetRepo(id string) Repo {
|
||||
manager := defaultManager
|
||||
manager.lock.Lock()
|
||||
defer manager.lock.Unlock()
|
||||
r, ok := manager.repoMap[id]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// 保存Repo
|
||||
func SaveRepo(r Repo) {
|
||||
manager := defaultManager
|
||||
manager.lock.Lock()
|
||||
defer manager.lock.Unlock()
|
||||
manager.repoMap[r.Id()] = r
|
||||
}
|
||||
|
||||
// 移除Repo
|
||||
func RemoveRepo(id string) {
|
||||
manager := defaultManager
|
||||
manager.lock.Lock()
|
||||
defer manager.lock.Unlock()
|
||||
delete(manager.repoMap, id)
|
||||
}
|
||||
|
||||
// 获取或构建Repo,若存在则返回已存在的,若不存在则构建保存并返回
|
||||
func GetOrBuildRepo(id string, builder func() (Repo, error)) (Repo, error) {
|
||||
r := GetRepo(id)
|
||||
if r == nil {
|
||||
// 构建模型Repo
|
||||
r, err := builder()
|
||||
// 构建出错直接返回
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 保存
|
||||
SaveRepo(r)
|
||||
}
|
||||
return r, nil
|
||||
}
|
34
modelrepo/model/common.go
Normal file
34
modelrepo/model/common.go
Normal file
@ -0,0 +1,34 @@
|
||||
package model
|
||||
|
||||
type ModelType string
|
||||
|
||||
const (
|
||||
// 车站
|
||||
ModelType_Station ModelType = "Station"
|
||||
// 站台
|
||||
ModelType_Stand ModelType = "Stand"
|
||||
// 屏蔽门
|
||||
ModelType_PSD ModelType = "PSD"
|
||||
// Link
|
||||
ModelType_Link ModelType = "Link"
|
||||
// 区段
|
||||
ModelType_Section ModelType = "Section"
|
||||
// 道岔
|
||||
ModelType_Turnout ModelType = "Turnout"
|
||||
// 信号机
|
||||
ModelType_Signal ModelType = "Signal"
|
||||
// 应答器
|
||||
ModelType_Balise ModelType = "Balise"
|
||||
)
|
||||
|
||||
type Uid interface {
|
||||
Id() string
|
||||
}
|
||||
|
||||
// 模型接口
|
||||
type Model interface {
|
||||
// Unique id,唯一id
|
||||
Uid() Uid
|
||||
// 模型类型
|
||||
Type() ModelType
|
||||
}
|
22
modelrepo/model/elec_comp.go
Normal file
22
modelrepo/model/elec_comp.go
Normal file
@ -0,0 +1,22 @@
|
||||
package model
|
||||
|
||||
// 开关
|
||||
type PowerSwitch interface {
|
||||
Model
|
||||
// 编号
|
||||
Code()
|
||||
}
|
||||
|
||||
// 信号状态表示灯
|
||||
type Lamp interface {
|
||||
Model
|
||||
// 编号
|
||||
Code()
|
||||
}
|
||||
|
||||
// 蜂鸣器/报警电铃
|
||||
type Buzzer interface {
|
||||
Model
|
||||
// 编号
|
||||
Code()
|
||||
}
|
12
modelrepo/model/ibp.go
Normal file
12
modelrepo/model/ibp.go
Normal file
@ -0,0 +1,12 @@
|
||||
package model
|
||||
|
||||
// IBP盘(综合后备盘)
|
||||
type Ibp interface {
|
||||
Model
|
||||
// 获取所有开关
|
||||
GetPowerSwitches() []PowerSwitch
|
||||
// 获取所有信号状态表示灯
|
||||
GetLamps() []Lamp
|
||||
// 获取所有蜂鸣器
|
||||
GetBuzzer() []Buzzer
|
||||
}
|
141
modelrepo/model/link.go
Normal file
141
modelrepo/model/link.go
Normal file
@ -0,0 +1,141 @@
|
||||
package model
|
||||
|
||||
import "log/slog"
|
||||
|
||||
// link端口
|
||||
type Link_Port int
|
||||
|
||||
const (
|
||||
LinkPort_A Link_Port = -1
|
||||
LinkPort_B Link_Port = 1
|
||||
)
|
||||
|
||||
// Link
|
||||
type Link interface {
|
||||
Model
|
||||
// Link总长度
|
||||
GetLength() int64
|
||||
// 获取端口A关联的道岔
|
||||
GetPaTurnout() Points
|
||||
// 获取端口B关联的道岔
|
||||
GetPbTurnout() Points
|
||||
// 下一个link及端口
|
||||
// port - 当前link端口
|
||||
// tpos - 当前道岔位置
|
||||
Next(port Link_Port, tpos PointsPosition) *LinkPort
|
||||
}
|
||||
|
||||
type LinkPort struct {
|
||||
link Link
|
||||
port Link_Port
|
||||
}
|
||||
|
||||
func NewLinkPort(link Link, port Link_Port) *LinkPort {
|
||||
return &LinkPort{
|
||||
link: link,
|
||||
port: port,
|
||||
}
|
||||
}
|
||||
|
||||
// link偏移位置
|
||||
// 默认linkA端口偏移为0,从A到B为增大,从B到A为减小
|
||||
type LinkOffset struct {
|
||||
link Link
|
||||
offset int64 // 偏移坐标,link相当于一个一维坐标系,以端口A为原点
|
||||
}
|
||||
|
||||
// 创建link偏移位置,若offset超出link长度则返回nil
|
||||
func NewLinkOffset(link Link, offset int64) *LinkOffset {
|
||||
if offset < 0 || offset > link.GetLength() {
|
||||
return nil
|
||||
}
|
||||
return &LinkOffset{
|
||||
link: link,
|
||||
offset: offset,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LinkOffset) Link() Link {
|
||||
return l.link
|
||||
}
|
||||
func (l *LinkOffset) Offset() int64 {
|
||||
return l.offset
|
||||
}
|
||||
|
||||
// link偏移范围
|
||||
type LinkRange struct {
|
||||
link Link
|
||||
start int64
|
||||
end int64
|
||||
}
|
||||
|
||||
func NewLinkRange(link Link, a int64, b int64) *LinkRange {
|
||||
if a < 0 || a > link.GetLength() {
|
||||
slog.Error("创建link偏移范围失败: 超出link长度范围", slog.Int64("a", a))
|
||||
return nil
|
||||
} else if b < 0 || b > link.GetLength() {
|
||||
slog.Error("创建link偏移范围失败: 超出link长度范围", slog.Int64("b", b))
|
||||
return nil
|
||||
}
|
||||
var start int64
|
||||
var end int64
|
||||
if a > b {
|
||||
start = b
|
||||
end = a
|
||||
} else {
|
||||
start = a
|
||||
end = b
|
||||
}
|
||||
return &LinkRange{
|
||||
link: link,
|
||||
start: start,
|
||||
end: end,
|
||||
}
|
||||
}
|
||||
|
||||
// 是否相交
|
||||
func (l *LinkRange) IsIntersect(other *LinkRange) bool {
|
||||
if l.link != other.link {
|
||||
return false
|
||||
}
|
||||
if l.start > other.end || other.start > l.end {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 是否相交
|
||||
func (l *LinkRange) IsIntersect2(a, b int64) bool {
|
||||
var start int64
|
||||
var end int64
|
||||
if a > b {
|
||||
start = b
|
||||
end = a
|
||||
} else {
|
||||
start = a
|
||||
end = b
|
||||
}
|
||||
if start > l.end || end < l.start {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 是否在范围内
|
||||
func (l *LinkRange) IsInRange(lo *LinkOffset) bool {
|
||||
if lo.link != l.link {
|
||||
return false
|
||||
}
|
||||
if lo.offset < l.start || lo.offset > l.end {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 偏移坐标是否在范围内
|
||||
func (l *LinkRange) IsInRange2(offset int64) bool {
|
||||
if offset < l.start || offset > l.end {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
6
modelrepo/model/psd.go
Normal file
6
modelrepo/model/psd.go
Normal file
@ -0,0 +1,6 @@
|
||||
package model
|
||||
|
||||
// 站台屏蔽门
|
||||
type Psd interface {
|
||||
Model
|
||||
}
|
32
modelrepo/model/relay.go
Normal file
32
modelrepo/model/relay.go
Normal file
@ -0,0 +1,32 @@
|
||||
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
|
||||
}
|
21
modelrepo/model/section.go
Normal file
21
modelrepo/model/section.go
Normal file
@ -0,0 +1,21 @@
|
||||
package model
|
||||
|
||||
type Section interface {
|
||||
Model
|
||||
Code() string
|
||||
// 所在Link范围
|
||||
LinkRanges() []*LinkRange
|
||||
}
|
||||
|
||||
// 物理区段(实际检测区段)
|
||||
type PhysicalSection interface {
|
||||
Section
|
||||
LogicalSections() []LogicalSection
|
||||
}
|
||||
|
||||
// 逻辑区段
|
||||
type LogicalSection interface {
|
||||
Section
|
||||
// 物理区段
|
||||
Parent() PhysicalSection
|
||||
}
|
6
modelrepo/model/signal.go
Normal file
6
modelrepo/model/signal.go
Normal file
@ -0,0 +1,6 @@
|
||||
package model
|
||||
|
||||
// 信号机
|
||||
type Signal interface {
|
||||
Model
|
||||
}
|
48
modelrepo/model/station.go
Normal file
48
modelrepo/model/station.go
Normal file
@ -0,0 +1,48 @@
|
||||
package model
|
||||
|
||||
// 车站
|
||||
type Station interface {
|
||||
Model
|
||||
// 车站名
|
||||
Name() string
|
||||
// 是否设备集中站
|
||||
IsEcs() bool
|
||||
// 获取IBP
|
||||
GetIbp() Ibp
|
||||
}
|
||||
|
||||
// 设备集中站(Equipment centralized station)
|
||||
type EcStation interface {
|
||||
Station
|
||||
// 获取所有道岔
|
||||
GetTurnouts() []Points
|
||||
// 获取所有信号机
|
||||
GetSignals() []Signal
|
||||
// 获取所有站台屏蔽门
|
||||
GetPsds() []Psd
|
||||
// 获取所有物理检测区段
|
||||
GetPhysicalSections() []PhysicalSection
|
||||
// 获取联锁驱采表
|
||||
GetCiQCTable()
|
||||
}
|
||||
|
||||
// 联锁驱采表
|
||||
type CiQCTable interface {
|
||||
// 驱动码位表(每一位所驱动的继电器uid)
|
||||
QD() []string
|
||||
// 采集码位表(每一位所采集的继电器位置)
|
||||
CJ() []CiCJ
|
||||
}
|
||||
|
||||
// 联锁采集
|
||||
type CiCJ interface {
|
||||
CjPos() []CiCJPos
|
||||
}
|
||||
|
||||
// 联锁采集继电器位置
|
||||
type CiCJPos interface {
|
||||
// 继电器uid
|
||||
RelayId() string
|
||||
// 继电器位置
|
||||
Pos() Relay_Position
|
||||
}
|
47
modelrepo/model/turnout.go
Normal file
47
modelrepo/model/turnout.go
Normal file
@ -0,0 +1,47 @@
|
||||
package model
|
||||
|
||||
// 道岔位置
|
||||
type PointsPosition int
|
||||
|
||||
const (
|
||||
// 失表
|
||||
TPos_Lost PointsPosition = 0
|
||||
// 定位
|
||||
TPos_DW PointsPosition = 1
|
||||
// 反位
|
||||
TPos_FW PointsPosition = 2
|
||||
)
|
||||
|
||||
// 道岔端口
|
||||
type Turnout_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
|
||||
)
|
||||
|
||||
// 道岔
|
||||
type Points interface {
|
||||
Model
|
||||
// 获取A方向连接的link端口
|
||||
GetALinkPort() *LinkPort
|
||||
// 获取B方向连接的link端口
|
||||
GetBLinkPort() *LinkPort
|
||||
// 获取C方向连接的link端口
|
||||
GetCLinkPort() *LinkPort
|
||||
// 获取牵引类型
|
||||
GetTractionType() PointsTractionType
|
||||
// 获取转辙机数量
|
||||
GetZzjCount() int
|
||||
}
|
72
modelrepo/model_impl/link.go
Normal file
72
modelrepo/model_impl/link.go
Normal file
@ -0,0 +1,72 @@
|
||||
package modelimpl
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
|
||||
"joylink.club/rtsssimulation/modelrepo/dto"
|
||||
"joylink.club/rtsssimulation/modelrepo/model"
|
||||
)
|
||||
|
||||
// link生成uid基础值
|
||||
var link_uid_base = atomic.Uint32{}
|
||||
|
||||
var _link model.Link = (*Link)(nil)
|
||||
|
||||
// 轨道链路
|
||||
type Link struct {
|
||||
uid model.Uid
|
||||
PaTurnout *Turnout // A端关联道岔,可能为nil
|
||||
PbTurnout *Turnout // B端关联道岔,可能为nil
|
||||
PaGlb dto.GLB // A端公里标
|
||||
PbGlb dto.GLB // B端公里标
|
||||
Length int64 // 长度
|
||||
Models []model.Model // 关联的模型,从A到B排序
|
||||
Sections []*PhysicalSection // 关联的物理区段(包含道岔物理区段),从A到B排序
|
||||
}
|
||||
|
||||
// GetLength implements model.Link.
|
||||
func (l *Link) GetLength() int64 {
|
||||
return l.Length
|
||||
}
|
||||
|
||||
// GetPaTurnout implements model.Link.
|
||||
func (l *Link) GetPaTurnout() model.Points {
|
||||
return l.PaTurnout
|
||||
}
|
||||
|
||||
// GetPbTurnout implements model.Link.
|
||||
func (l *Link) GetPbTurnout() model.Points {
|
||||
return l.PbTurnout
|
||||
}
|
||||
|
||||
// Next implements model.Link.
|
||||
func (*Link) Next(port model.Link_Port, tpos model.PointsPosition) *model.LinkPort {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
// Type implements model.Link.
|
||||
func (l *Link) Type() model.ModelType {
|
||||
return model.ModelType_Link
|
||||
}
|
||||
|
||||
// Uid implements model.Link.
|
||||
func (l *Link) Uid() model.Uid {
|
||||
return l.uid
|
||||
}
|
||||
|
||||
func NewLink() *Link {
|
||||
return &Link{}
|
||||
}
|
||||
|
||||
// link偏移
|
||||
type LinkOffset struct {
|
||||
link *Link
|
||||
offset int64
|
||||
}
|
||||
|
||||
// link偏移范围
|
||||
type LinkRange struct {
|
||||
link *Link
|
||||
start int64
|
||||
end int64
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user