2023-12-28 18:17:35 +08:00
|
|
|
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 {
|
|
|
|
Type OccupiedType
|
|
|
|
}
|
|
|
|
|
|
|
|
var OccupiedStatusType = ecs.NewComponentType[OccupiedStatus]() // 占用状态组件
|
|
|
|
|
|
|
|
// 进路锁闭状态
|
|
|
|
type RouteLock struct {
|
|
|
|
Route *ecs.Entry
|
|
|
|
}
|
|
|
|
|
|
|
|
var RouteLockType = ecs.NewComponentType[RouteLock]()
|
|
|
|
|
|
|
|
// 故障锁闭状态
|
|
|
|
type FaultLock struct {
|
|
|
|
Fault any // 故障信息
|
|
|
|
}
|
|
|
|
|
2023-12-29 10:53:36 +08:00
|
|
|
var FaultLockType = ecs.NewComponentType[FaultLock]() // 故障锁闭状态组件
|
2023-12-28 18:17:35 +08:00
|
|
|
|
|
|
|
// 封锁状态
|
|
|
|
type BlockadeStatus struct {
|
|
|
|
}
|
|
|
|
|
2023-12-29 10:53:36 +08:00
|
|
|
var BlockadeStatusType = ecs.NewComponentType[BlockadeStatus]() // 封锁状态组件
|
|
|
|
|
|
|
|
// 解锁状态
|
|
|
|
type UnLockStatus struct {
|
|
|
|
Delay bool // 延迟状态
|
|
|
|
DelayTime time.Duration // 延迟解锁时间
|
|
|
|
TriggerDevice *ecs.Entry // 触发解锁设备
|
|
|
|
}
|
|
|
|
|
|
|
|
var UnLockStatusType = ecs.NewComponentType[UnLockStatus]() // 解锁状态组件
|
|
|
|
|
|
|
|
// 关闭状态
|
|
|
|
type ClosedStatus struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
var ClosedStatusType = ecs.NewComponentType[ClosedStatus]() // 关闭状态组件
|
2023-12-28 18:17:35 +08:00
|
|
|
|
|
|
|
// 站台跳停状态
|
2023-12-29 16:52:16 +08:00
|
|
|
type PlatformSkipStatus struct {
|
2023-12-28 18:17:35 +08:00
|
|
|
AllSkip bool // 全部跳停
|
|
|
|
Trains []*ecs.Entry // 跳停列车
|
|
|
|
}
|
|
|
|
|
2023-12-29 16:52:16 +08:00
|
|
|
var PlatformSkipStatusType = ecs.NewComponentType[PlatformSkipStatus]() // 站台跳停状态
|
2023-12-28 18:17:35 +08:00
|
|
|
|
|
|
|
// 站台停靠发车状态
|
2023-12-29 16:52:16 +08:00
|
|
|
type PlatformParkStatus struct {
|
2023-12-28 18:17:35 +08:00
|
|
|
Park bool // 列车停靠状态
|
|
|
|
ParkTime time.Duration // 停靠时间
|
|
|
|
Depart bool // 列车发车状态
|
|
|
|
}
|
|
|
|
|
2023-12-29 16:52:16 +08:00
|
|
|
var PlatformParkStatusType = ecs.NewComponentType[PlatformParkStatus]() // 站台停靠发车状态
|
2023-12-28 18:17:35 +08:00
|
|
|
|
|
|
|
// 扣车状态
|
2023-12-29 16:52:16 +08:00
|
|
|
type PlatformHoldStatus struct {
|
2023-12-28 18:17:35 +08:00
|
|
|
}
|
|
|
|
|
2023-12-29 16:52:16 +08:00
|
|
|
var PlatformHoldStatusType = ecs.NewComponentType[PlatformHoldStatus]() // 扣车状态组件
|
2023-12-28 18:17:35 +08:00
|
|
|
|
2023-12-29 10:53:36 +08:00
|
|
|
// 信号机状态
|
|
|
|
type SignalStatus struct {
|
|
|
|
ApproachLock bool // 接近锁闭
|
|
|
|
OverlapLock bool // 延续保护锁闭
|
2023-12-28 18:17:35 +08:00
|
|
|
}
|
|
|
|
|
2023-12-29 10:53:36 +08:00
|
|
|
var SignalStatusType = ecs.NewComponentType[SignalStatus]() // 信号机状态组件
|
2023-12-28 18:17:35 +08:00
|
|
|
|
|
|
|
// 进路状态
|
|
|
|
type RouteStatus struct {
|
2023-12-29 10:53:36 +08:00
|
|
|
AtsControl bool // ats自动控制
|
|
|
|
Setting bool // 进路是否排列中
|
|
|
|
Lock bool // 已锁闭
|
2023-12-28 18:17:35 +08:00
|
|
|
}
|
2023-12-29 10:53:36 +08:00
|
|
|
|
|
|
|
var RouteStatusType = ecs.NewComponentType[RouteStatus]() // 进路状态组件
|
|
|
|
|
2023-12-29 16:52:16 +08:00
|
|
|
// 列车运行级别
|
|
|
|
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 // 从a到b为true;从b到a为false
|
|
|
|
}
|
|
|
|
|
|
|
|
var DevicePositionType = ecs.NewComponentType[DevicePosition]()
|
|
|
|
|
|
|
|
// 列车运行状态
|
|
|
|
type TrainRunStatus struct {
|
|
|
|
RunLevel TrainRunLevel // 列车运行级别
|
|
|
|
DriveMode DriveMode // 驾驶模式
|
|
|
|
Speed float32 // 运行速度
|
|
|
|
SpeedMax float32 // 最大速度
|
|
|
|
HeadPosition *DevicePosition // 车头位置
|
|
|
|
TailPosition *DevicePosition // 车尾位置
|
|
|
|
Hold bool // 扣车
|
|
|
|
}
|
|
|
|
|
|
|
|
var TrainRunStatusType = ecs.NewComponentType[TrainRunStatus]() // 列车位置状态组件
|
|
|
|
|
2023-12-29 10:53:36 +08:00
|
|
|
var (
|
2023-12-29 16:52:16 +08:00
|
|
|
TrainSpeedMax float32 = 80 / 3.6
|
2023-12-29 10:53:36 +08:00
|
|
|
)
|