Compare commits

..

1 Commits

Author SHA1 Message Date
tiger_zhou
f2762f09dd 项目名称及路径更改 2024-03-13 20:04:21 +08:00
82 changed files with 2566 additions and 4196 deletions

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "jl-ecs"]
path = jl-ecs
url = https://gitea.joylink.club/joylink/jl-ecs.git
url = http://120.46.212.6:3000/joylink/jl-ecs.git

View File

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

View File

@ -9,9 +9,6 @@ var (
BaliseVB = ecs.NewTag() // 主信号应答器
BaliseIB = ecs.NewTag() // 预告应答器
)
var ForceVariableTelegram = ecs.NewTag() //表示可变报文为强制设置并锁定
var BaliseFixedTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器固定报文
var BaliseVariableTelegramType = ecs.NewComponentType[BaliseTelegram]() //应答器可变报文
type BaliseTelegram struct {

View File

@ -2,14 +2,14 @@ package component
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component/component_data"
)
var (
CkmTag = ecs.NewTag()
CkmCircuitType = ecs.NewComponentType[CkmCircuit]()
CkmPslType = ecs.NewComponentType[CkmPsl]()
CkmForceOpenTag = ecs.NewTag()
CkmForceCloseTag = ecs.NewTag()
CkmTag = ecs.NewTag()
CkmMgzTag = ecs.NewTag() //门故障tag
CkmCircuitType = ecs.NewComponentType[CkmCircuit]()
CkmStateType = ecs.NewComponentType[component_data.CkmState]()
)
type CkmCircuit struct {
@ -23,14 +23,3 @@ type CkmCircuit struct {
KMJ *ecs.Entry //开门继电器
GMJ *ecs.Entry //关门继电器
}
func (c *CkmCircuit) RelayList() []*ecs.Entry {
return []*ecs.Entry{c.MKJ, c.MGJ, c.MGZJ, c.MPLJ, c.MMSJ, c.KMJ, c.GMJ}
}
type CkmPsl struct {
KMA *ecs.Entry //开门按钮
GMA *ecs.Entry //关门按钮
MPLA *ecs.Entry //门旁路按钮
MMSA *ecs.Entry //门模式按钮
}

View File

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

View File

@ -0,0 +1,180 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: component/ckm.proto
package component_data
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type CkmState struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Close bool `protobuf:"varint,1,opt,name=close,proto3" json:"close,omitempty"`
Mms bool `protobuf:"varint,2,opt,name=mms,proto3" json:"mms,omitempty"` //门模式true远程false本地
Mgz bool `protobuf:"varint,3,opt,name=mgz,proto3" json:"mgz,omitempty"` //门故障
// 驱动状态(没有继电器时直接操作以下状态)
Km bool `protobuf:"varint,4,opt,name=km,proto3" json:"km,omitempty"` //开门
Gm bool `protobuf:"varint,5,opt,name=gm,proto3" json:"gm,omitempty"` //关门
}
func (x *CkmState) Reset() {
*x = CkmState{}
if protoimpl.UnsafeEnabled {
mi := &file_component_ckm_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CkmState) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CkmState) ProtoMessage() {}
func (x *CkmState) ProtoReflect() protoreflect.Message {
mi := &file_component_ckm_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CkmState.ProtoReflect.Descriptor instead.
func (*CkmState) Descriptor() ([]byte, []int) {
return file_component_ckm_proto_rawDescGZIP(), []int{0}
}
func (x *CkmState) GetClose() bool {
if x != nil {
return x.Close
}
return false
}
func (x *CkmState) GetMms() bool {
if x != nil {
return x.Mms
}
return false
}
func (x *CkmState) GetMgz() bool {
if x != nil {
return x.Mgz
}
return false
}
func (x *CkmState) GetKm() bool {
if x != nil {
return x.Km
}
return false
}
func (x *CkmState) GetGm() bool {
if x != nil {
return x.Gm
}
return false
}
var File_component_ckm_proto protoreflect.FileDescriptor
var file_component_ckm_proto_rawDesc = []byte{
0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6b, 0x6d, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74,
0x22, 0x64, 0x0a, 0x08, 0x43, 0x6b, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05,
0x63, 0x6c, 0x6f, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x6f,
0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52,
0x03, 0x6d, 0x6d, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x67, 0x7a, 0x18, 0x03, 0x20, 0x01, 0x28,
0x08, 0x52, 0x03, 0x6d, 0x67, 0x7a, 0x12, 0x0e, 0x0a, 0x02, 0x6b, 0x6d, 0x18, 0x04, 0x20, 0x01,
0x28, 0x08, 0x52, 0x02, 0x6b, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x67, 0x6d, 0x18, 0x05, 0x20, 0x01,
0x28, 0x08, 0x52, 0x02, 0x67, 0x6d, 0x42, 0x1c, 0x5a, 0x1a, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70,
0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f,
0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_component_ckm_proto_rawDescOnce sync.Once
file_component_ckm_proto_rawDescData = file_component_ckm_proto_rawDesc
)
func file_component_ckm_proto_rawDescGZIP() []byte {
file_component_ckm_proto_rawDescOnce.Do(func() {
file_component_ckm_proto_rawDescData = protoimpl.X.CompressGZIP(file_component_ckm_proto_rawDescData)
})
return file_component_ckm_proto_rawDescData
}
var file_component_ckm_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_component_ckm_proto_goTypes = []interface{}{
(*CkmState)(nil), // 0: component.CkmState
}
var file_component_ckm_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_component_ckm_proto_init() }
func file_component_ckm_proto_init() {
if File_component_ckm_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_component_ckm_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CkmState); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_component_ckm_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_component_ckm_proto_goTypes,
DependencyIndexes: file_component_ckm_proto_depIdxs,
MessageInfos: file_component_ckm_proto_msgTypes,
}.Build()
File_component_ckm_proto = out.File
file_component_ckm_proto_rawDesc = nil
file_component_ckm_proto_goTypes = nil
file_component_ckm_proto_depIdxs = nil
}

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: component/psd.proto
@ -74,9 +74,8 @@ type PsdState struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Close bool `protobuf:"varint,1,opt,name=close,proto3" json:"close,omitempty"`
Obstacle bool `protobuf:"varint,2,opt,name=obstacle,proto3" json:"obstacle,omitempty"` //有障碍物
InterlockRelease bool `protobuf:"varint,3,opt,name=interlockRelease,proto3" json:"interlockRelease,omitempty"` //互锁解除
Close bool `protobuf:"varint,1,opt,name=close,proto3" json:"close,omitempty"`
Obstacle bool `protobuf:"varint,2,opt,name=obstacle,proto3" json:"obstacle,omitempty"`
}
func (x *PsdState) Reset() {
@ -125,13 +124,6 @@ func (x *PsdState) GetObstacle() bool {
return false
}
func (x *PsdState) GetInterlockRelease() bool {
if x != nil {
return x.InterlockRelease
}
return false
}
type Psd struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -254,27 +246,24 @@ var File_component_psd_proto protoreflect.FileDescriptor
var file_component_psd_proto_rawDesc = []byte{
0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x70, 0x73, 0x64, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74,
0x22, 0x68, 0x0a, 0x08, 0x50, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05,
0x22, 0x3c, 0x0a, 0x08, 0x50, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05,
0x63, 0x6c, 0x6f, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x6f,
0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x74, 0x61, 0x63, 0x6c, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x74, 0x61, 0x63, 0x6c, 0x65, 0x12, 0x2a,
0x0a, 0x10, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61,
0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6c,
0x6f, 0x63, 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x22, 0x44, 0x0a, 0x03, 0x50, 0x73,
0x64, 0x22, 0x3d, 0x0a, 0x05, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x6e,
0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x73, 0x64,
0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x10, 0x01, 0x12, 0x11, 0x0a,
0x0d, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x4f, 0x70, 0x65, 0x6e, 0x10, 0x02,
0x22, 0x6c, 0x0a, 0x08, 0x41, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04,
0x67, 0x6d, 0x64, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x67, 0x6d, 0x64, 0x77,
0x12, 0x12, 0x0a, 0x04, 0x6b, 0x6d, 0x64, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04,
0x6b, 0x6d, 0x64, 0x77, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x67, 0x6a, 0x18, 0x03, 0x20, 0x01, 0x28,
0x08, 0x52, 0x03, 0x6d, 0x67, 0x6a, 0x12, 0x10, 0x0a, 0x03, 0x7a, 0x61, 0x77, 0x18, 0x04, 0x20,
0x01, 0x28, 0x08, 0x52, 0x03, 0x7a, 0x61, 0x77, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6f, 0x72, 0x63,
0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x42, 0x1d,
0x5a, 0x1b, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f,
0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x74, 0x61, 0x63, 0x6c, 0x65, 0x22, 0x44,
0x0a, 0x03, 0x50, 0x73, 0x64, 0x22, 0x3d, 0x0a, 0x05, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x0d,
0x0a, 0x09, 0x55, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x10, 0x00, 0x12, 0x12, 0x0a,
0x0e, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x10,
0x01, 0x12, 0x11, 0x0a, 0x0d, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x4f, 0x70,
0x65, 0x6e, 0x10, 0x02, 0x22, 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,
}
var (

View File

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

View File

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

View File

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

View File

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

View File

@ -6,18 +6,22 @@ import (
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 //通过允许
XQJ *ecs.Entry //洗车请求
TWJ1 *ecs.Entry //头部停稳
TWJ2 *ecs.Entry //尾部停稳
TWJ3 *ecs.Entry //中部停稳
TGQJ *ecs.Entry //通过请求
XCJXJ *ecs.Entry //洗车就绪
XCYXJ *ecs.Entry //洗车允许
CFJ1 *ecs.Entry //头部移动允许
CFJ2 *ecs.Entry //尾部移动允许
CFJ3 *ecs.Entry //中部移动允许
JTJ *ecs.Entry //紧急停车
TGYXJ *ecs.Entry //通过允许
}

View File

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

View File

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

View File

@ -47,10 +47,9 @@ func newBaliseEntity(w ecs.World, td *repository.Transponder, worldData *compone
if proto.Transponder_IB == td.BaliseType() || proto.Transponder_VB == td.BaliseType() {
entry.AddComponent(component.BaliseVariableTelegramType)
}
linkPosition := td.LinkPosition()
component.LinkPositionType.SetValue(entry, component_data.LinkPosition{
LinkId: linkPosition.Link().Id(),
Offset: linkPosition.Offset(),
LinkId: td.LinkPosition().Link().Id(),
Offset: td.LinkPosition().Offset(),
})
component.KmType.Set(entry, td.Km())
worldData.EntityMap[uid] = entry

View File

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

View File

@ -1,74 +1,47 @@
package entity
import (
"github.com/yohamta/donburi"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"unsafe"
)
var CkmBaseComponentTypes = []ecs.IComponentType{component.UidType, component.CkmTag, component.FixedPositionTransformType}
var CkmBaseComponentTypes = []ecs.IComponentType{component.UidType, component.CkmTag, component.CkmStateType, component.FixedPositionTransformType}
func LoadCkm(w ecs.World) error {
data := GetWorldData(w)
for _, ckm := range data.Repo.CkmList() {
ckmEntry := 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)
//创建基础entry
entry := w.Entry(w.Create(CkmBaseComponentTypes...))
component.UidType.SetValue(entry, component.Uid{Id: ckm.Id()})
data.EntityMap[ckm.Id()] = entry
//加载电路
if len(ckm.ComponentGroups()) != 0 {
circuit := &component.CkmCircuit{}
entry.AddComponent(component.CkmCircuitType, unsafe.Pointer(circuit))
for _, group := range ckm.ComponentGroups() {
for _, ec := range group.Components() {
relay := ec.(*repository.Relay)
switch ec.Code() {
case "MKJ":
circuit.MKJ = NewRelayEntity(w, relay, data.EntityMap)
case "MGJ":
circuit.MGJ = NewRelayEntity(w, relay, data.EntityMap)
case "MGZJ":
circuit.MGZJ = NewRelayEntity(w, relay, data.EntityMap)
case "MPLJ":
circuit.MPLJ = NewRelayEntity(w, relay, data.EntityMap)
case "MMSJ":
circuit.MMSJ = NewRelayEntity(w, relay, data.EntityMap)
case "KMJ":
circuit.KMJ = NewRelayEntity(w, relay, data.EntityMap)
case "GMJ":
circuit.GMJ = NewRelayEntity(w, relay, data.EntityMap)
}
}
}
}
}
}
// 添加车库门PSL
func addCkmPsl(w ecs.World, psl *repository.CkmPsl, ckmEntry *ecs.Entry, data *component.WorldData) {
ckmPsl := component.CkmPsl{
KMA: NewButtonEntity(w, psl.Kma(), data.EntityMap),
GMA: NewButtonEntity(w, psl.Gma(), data.EntityMap),
MPLA: NewButtonEntity(w, psl.Mpla(), data.EntityMap),
MMSA: NewButtonEntity(w, psl.Mmsa(), data.EntityMap),
}
ckmEntry.AddComponent(component.CkmPslType, unsafe.Pointer(&ckmPsl))
return nil
}

64
entity/fadc_axle.go Normal file
View File

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

View File

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

View File

@ -36,13 +36,8 @@ func Load(w ecs.World, repo *repository.Repository) error {
if err != nil {
return err
}
// 加载物理区段相关实体
err = LoadPhysicalSections(w)
if err != nil {
return err
}
// 加载计轴区段相关实体
err = LoadAxleCountingSections(w)
err = LoadAxlePhysicalSections(w)
if err != nil {
return err
}
@ -61,15 +56,5 @@ func Load(w ecs.World, repo *repository.Repository) error {
if err != nil {
return err
}
//加载轨道电路
err = LoadTrackCircuit(w)
if err != nil {
return err
}
//加载站台(继电器)
err = LoadPlatform(w)
if err != nil {
return err
}
return err
}

View File

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

View File

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

View File

@ -1,11 +1,11 @@
package entity
import (
"strconv"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"regexp"
"strconv"
)
var PsdBaseComponentTypeArr = []ecs.IComponentType{component.PsdTag, component.UidType,
@ -29,7 +29,7 @@ func LoadPsd(w ecs.World) error {
}
func loadPlatformMkxCircuit(world ecs.World, entryMap map[string]*ecs.Entry, pmcMap map[string]*ecs.Entry,
mkx *repository.PsdPsl, mkxEntry *ecs.Entry, psdEntry *ecs.Entry) {
mkx *repository.Mkx, mkxEntry *ecs.Entry, psdEntry *ecs.Entry) {
platformMkx, ok := pmcMap[mkx.Psd().Id()]
if !ok {
platformMkx = NewPlatformMkxEntry(world, entryMap, mkx)
@ -46,26 +46,18 @@ func loadPsdCircuit(world ecs.World, entry *ecs.Entry, psd *repository.Psd, entr
return
}
circuit := &component.PsdCircuit{KMJMap: make(map[int32]*ecs.Entry)}
pattern := regexp.MustCompile("(\\d*).*KMJ") //用来匹配开门继电器的正则表达式
for _, group := range psd.ComponentGroups() {
for _, ec := range group.Components() {
relay := ec.(*repository.Relay)
matches := pattern.FindStringSubmatch(relay.Code())
if len(matches) != 0 { //匹配上了
if matches[1] == "" { //SKMJ/XKMJ
circuit.KMJMap[0] = NewRelayEntity(world, relay, entryMap)
} else {
num, err := strconv.Atoi(matches[1])
if err != nil {
panic(err)
}
circuit.KMJMap[int32(num)] = NewRelayEntity(world, relay, entryMap)
}
continue
}
switch ec.Code() {
case "XGMJ", "SGMJ":
circuit.GMJ = NewRelayEntity(world, relay, entryMap)
case "XKMJ", "SKMJ":
circuit.KMJMap[0] = NewRelayEntity(world, relay, entryMap)
case "4XKMJ", "4SKMJ":
circuit.KMJMap[4] = NewRelayEntity(world, relay, entryMap)
case "8XKMJ", "8SKMJ":
circuit.KMJMap[8] = NewRelayEntity(world, relay, entryMap)
case "XMGJ", "SMGJ":
circuit.MGJ = NewRelayEntity(world, relay, entryMap)
case "XMPLJ", "SMPLJ":
@ -111,7 +103,7 @@ func NewAsdEntry(world ecs.World, worldData *component.WorldData, psdId string,
return entry
}
func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repository.PsdPsl) *ecs.Entry {
func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repository.Mkx) *ecs.Entry {
entry := world.Entry(world.Create(component.UidType, component.MkxType))
worldData.EntityMap[mkx.Id()] = entry
component.UidType.SetValue(entry, component.Uid{Id: mkx.Id()})
@ -157,7 +149,7 @@ func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repositor
return entry
}
func NewPlatformMkxEntry(world ecs.World, entryMap map[string]*ecs.Entry, mkx *repository.PsdPsl) *ecs.Entry {
func NewPlatformMkxEntry(world ecs.World, entryMap map[string]*ecs.Entry, mkx *repository.Mkx) *ecs.Entry {
entry := world.Entry(world.Create(component.PlatformMkxCircuitType))
circuit := &component.PlatformMkxCircuit{}
if pcbj := mkx.Pcbj(); pcbj != nil {

View File

@ -26,13 +26,6 @@ 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
}

View File

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

View File

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

View File

@ -1,13 +1,9 @@
package entity
import (
"errors"
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"strconv"
"strings"
"unsafe"
)
@ -22,10 +18,7 @@ func LoadXcj(w ecs.World) error {
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),
}
circuit := &component.XcjCircuit{}
entry.AddComponent(component.XcjCircuitType, unsafe.Pointer(circuit))
for _, group := range xcj.ComponentGroups() {
for _, ec := range group.Components() {
@ -33,30 +26,28 @@ func LoadXcj(w ecs.World) error {
switch ec.Code() {
case "XQJ":
circuit.XQJ = NewRelayEntity(w, relay, wd.EntityMap)
case "TWJ1":
circuit.TWJ1 = NewRelayEntity(w, relay, wd.EntityMap)
case "TWJ2":
circuit.TWJ2 = NewRelayEntity(w, relay, wd.EntityMap)
case "TWJ3":
circuit.TWJ3 = 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 "CFJ1":
circuit.CFJ1 = NewRelayEntity(w, relay, wd.EntityMap)
case "CFJ2":
circuit.CFJ2 = NewRelayEntity(w, relay, wd.EntityMap)
case "CFJ3":
circuit.CFJ3 = 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)
}
}
}
}

View File

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

View File

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

42
fi/circuit.go Normal file
View File

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

View File

@ -59,3 +59,43 @@ func SwitchKeyGear(w ecs.World, id string, gear int32) error {
})
return result.Err
}
//func SetBypassBtn(w ecs.World, id string, p request_proto.BypassOperationReq_Operation) error {
//
// result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
// wd := entity.GetWorldData(w)
// entry, ok := wd.EntityMap[id]
// if ok {
// state := component.BitStateType.Get(entry)
// state.Bypass.BypassEnable = convertBypassBoolVal(p)
// state.Bypass.OldVal = state.Val
// } else {
// return ecs.NewErrResult(fmt.Errorf("未找到id=%s的按钮", id))
// }
// return ecs.NewOkEmptyResult()
// })
// return result.Err
//}
//func SetBypassSwitchKey(w ecs.World, id string, p request_proto.BypassOperationReq_Operation) error {
// result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
// wd := entity.GetWorldData(w)
// entry, ok := wd.EntityMap[id]
// if ok {
// state := component.GearStateType.Get(entry)
// state.BypassEnable = convertBypassBoolVal(p)
// state.OldVal = state.Val == 0
// } else {
// return ecs.NewErrResult(fmt.Errorf("未找到id=%s的钥匙开关", id))
// }
// return ecs.NewOkEmptyResult()
// })
// return result.Err
//}
//
//func convertBypassBoolVal(p request_proto.BypassOperationReq_Operation) bool {
// val := true
// if p == request_proto.BypassOperationReq_bypass_reset {
// val = false
// }
// return val
//}

View File

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

239
fi/section.go Normal file
View File

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

View File

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

View File

@ -1,47 +1,34 @@
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=
@ -50,16 +37,13 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 h1:estk1glOnSVeJ9tdEZZc5mAMDZk5lNJNyJ6DvrBkTEU=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.1.0 h1:r8Oj8ZA2Xy12/b5KZYj3tuv7NG/fBz3TwQVvpJ9l8Rk=
golang.org/x/image v0.1.0/go.mod h1:iyPr49SD/G/TBxYVB/9RRtGUT5eNbo2u4NamWeQcD5c=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mobile v0.0.0-20220722155234-aaac322e2105/go.mod h1:pe2sM7Uk+2Su1y7u/6Z8KJ24D7lepUjFZbhFOrmDfuQ=
golang.org/x/mobile v0.0.0-20221012134814-c746ac228303 h1:K4fp1rDuJBz0FCPAWzIJwnzwNEM7S6yobdZzMrZ/Zws=
golang.org/x/mobile v0.0.0-20221012134814-c746ac228303/go.mod h1:M32cGdzp91A8Ex9qQtyZinr19EYxzkFqDjW2oyHzTDQ=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@ -87,7 +71,6 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43 h1:OK7RB6t2WQX54srQQYSXMW8dF5C6/8+oA/s5QBmmto4=
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@ -103,7 +86,6 @@ golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098/go.mod h1:LGqMHiF4EqQNHR
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=

View File

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

2
jl-ecs

@ -1 +1 @@
Subproject commit f0a56ea6722b620c8b900efa9f0d626f00af00ad
Subproject commit d25c600f408ce93a3094289311007cf814d062bc

View File

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

View File

@ -0,0 +1,15 @@
syntax = "proto3";
package component;
option go_package = "./component/component_data";
message CkmState {
bool close = 1;
bool mms = 2; //true远程false本地
bool mgz = 3; //
//
bool km = 4; //
bool gm = 5; //
}

View File

@ -6,8 +6,7 @@ option go_package = "./component/component_proto";
message PsdState {
bool close = 1;
bool obstacle = 2; //
bool interlockRelease = 3; //
bool obstacle = 2;
}
message Psd {

View File

@ -30,13 +30,6 @@ message Repository {
repeated Route routes = 23;
repeated Ckm ckms = 24;
repeated Xcj xcjs = 25;
repeated CkmPsl ckmPsls = 26;
repeated Esb esbs = 27;
repeated Spks spkss = 28;
repeated AxleCountingSection axleCountingSections = 29; //
repeated KilometerCalibration kilometerCalibrations = 30; //
repeated StopPosition stopPosition = 31;
//ISCS [300,500]
//ISCS管线
repeated Pipe pipes = 300;
@ -81,15 +74,7 @@ message Repository {
//ISCS气体环境
repeated GasEnvironment gasEnvironments = 320;
}
message StopPosition{
string id = 1;
uint32 linkId = 2;
uint32 linkOffset = 3;
Kilometer km = 4;
string sectionId = 5; //
DevicePort turnoutPort = 6; //
uint32 coachNum = 7;//
}
//
message SignalLayout {
//
@ -109,16 +94,8 @@ message PhysicalSection {
repeated string turnoutIds = 2; //
DevicePort aDevicePort = 3; //A端关联的设备端口
DevicePort bDevicePort = 4;
//uid
repeated string centralizedStation = 5;
repeated ElectronicComponentGroup electronicComponentGroups = 6;
}
//
message AxleCountingSection {
string id = 1;
repeated string axleCountingIds = 2;
repeated TurnoutAndPos turnoutAndPos = 3;
//
string centralizedStation = 5;
}
//
@ -136,11 +113,6 @@ message Turnout {
ZDJ9_Single = 1;
ZDJ9_Double = 2;
}
enum Pos {
Pos_Unknown = 0;
Pos_N = 1; //
Pos_R = 2; //
}
string id = 1;
Kilometer km = 2;
DevicePort aDevicePort = 3;
@ -190,8 +162,6 @@ message Transponder {
bytes fixedTelegram = 5;//
Type type = 6;//
bytes fixedUserTelegram = 7; //
uint32 leuIndex = 8; //LEU的索引
uint32 indexInLeu = 9; //LEU内部的索引
enum Type {
FB = 0; //
WB = 1; //
@ -222,12 +192,6 @@ message DevicePort {
Port port = 3;
}
//
message TurnoutAndPos {
string turnoutId = 1;
Turnout.Pos pos = 2;
}
enum DeviceType {
DeviceType_Unknown = 0;
DeviceType_PhysicalSection = 1;
@ -252,20 +216,13 @@ enum DeviceType {
//
DeviceType_SignalFaultAlarm = 20;
//
DeviceType_Breakers = 21;
DeviceType_Breakers = 21;
//
DeviceType_PowerScreen = 22;
DeviceType_PowerScreen = 22;
//
DeviceType_Route = 23;
DeviceType_Ckm = 24; //
DeviceType_Xcj = 25; //
DeviceType_CkmPsl = 26; //PSL
DeviceType_TrackCircuit = 27; //
DeviceType_LS = 28; //
DeviceType_Esb = 29; //
DeviceType_Spks = 30; //
DeviceTYpe_AxleCountingSection = 31; //
deviceType_Stop_position = 32;
DeviceType_Ckm = 24;
DeviceType_Xcj = 25;
//--------ISCS [300,500]------
//ISCS门磁
@ -431,12 +388,6 @@ message KilometerConvert {
bool sameTrend = 3; //
}
//
message KilometerCalibration {
Kilometer design = 1; //
Kilometer actual = 2; //
}
//
enum Direction {
LEFT = 0;
@ -463,16 +414,10 @@ message Relay {
JYJXC_160_260 = 7;
JZXC_H18 = 8;
}
enum Pos {
Pos_None = 0; //
Pos_Q = 1; //
Pos_H = 2; //
}
string id = 1;
string code = 2;
Model model = 3;
string stationId = 4; // id
Pos defaultPos = 5; //
}
//
@ -548,7 +493,7 @@ message ElectronicGroup {
//
message ElectronicComponent {
string id = 1; // ID
string id= 1; // ID
DeviceType deviceType = 3; //
}
//
@ -573,32 +518,9 @@ message Mkx {
string mplaId = 18; //
string jxtcplaId = 19; //
}
//PSL
message CkmPsl {
string id = 1;
string ckmId = 2;
string gmaId = 3; //
string kmaId = 4; //
string mplaId = 5; //
string mmsaId = 6; //
}
//
message Esb {
string id = 1;
string platformId = 2;
}
//
message Spks {
string id = 1;
string code = 2;
string platformId = 3;
}
//
message Platform {
enum Direction {
enum PlatformDirection {
Unknown = 0;
Up = 1; //
Down = 2; //
@ -607,8 +529,7 @@ message Platform {
string code = 2;
string stationId = 3;
string physicalSectionId = 4;
Direction direction = 5;
repeated ElectronicComponentGroup electronicComponentGroups = 6; //
PlatformDirection direction = 5;
}
//
@ -807,10 +728,10 @@ message Valve{
string code = 2;
//
enum Type{
ElectricControlValve = 0;//
ElectricAirValve = 1;//
CombinationAirValve = 2;//
ElectricButterflyValve = 3;//
ElectricControlValve = 0;//
ElectricAirValve = 1;//
CombinationAirValve = 2;//
ElectricButterflyValve = 3;//
}
Type valveType = 3;//
}
@ -877,6 +798,5 @@ message Ckm {
message Xcj {
string id = 1;
repeated ElectronicComponentGroup electronicComponentGroups = 2;
uint32 numSegments = 3; //
}

View File

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

View File

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

View File

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

View File

@ -1,34 +0,0 @@
package repository
import "joylink.club/rtsssimulation/repository/model/proto"
type CkmPsl struct {
Identity
ckm *Ckm
kma *Button
gma *Button
mpla *Button
mmsa *Button
}
func NewCkmPsl(id string) *CkmPsl {
return &CkmPsl{
Identity: identity{id, proto.DeviceType_DeviceType_CkmPsl},
}
}
func (psl *CkmPsl) Ckm() *Ckm {
return psl.ckm
}
func (psl *CkmPsl) Kma() *Button {
return psl.kma
}
func (psl *CkmPsl) Gma() *Button {
return psl.gma
}
func (psl *CkmPsl) Mpla() *Button {
return psl.mpla
}
func (psl *CkmPsl) Mmsa() *Button {
return psl.mmsa
}

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,29 +0,0 @@
package repository
import (
"joylink.club/rtsssimulation/repository/model/proto"
)
type StopPosition struct {
Identity
dir proto.Platform_Direction
km *proto.Kilometer
linkPosition LinkPosition
coachNum uint32
}
func NewStopPosition(id string, km *proto.Kilometer, coachNum uint32) *StopPosition {
return &StopPosition{
Identity: identity{id, proto.DeviceType_deviceType_Stop_position},
km: km, coachNum: coachNum,
}
}
func (t *StopPosition) bindLinkPosition(position LinkPosition) {
t.linkPosition = position
}
func (t *StopPosition) LinkPosition() LinkPosition {
return t.linkPosition
}
func (t *StopPosition) CoachNum() int32 {
return int32(t.coachNum)
}

View File

@ -1,8 +1,6 @@
package repository
import (
"joylink.club/rtsssimulation/repository/model/proto"
)
import "joylink.club/rtsssimulation/repository/model/proto"
type Transponder struct {
Identity
@ -10,27 +8,21 @@ type Transponder struct {
km *proto.Kilometer
//section *PhysicalSection
//turnoutPort TurnoutPort
linkPosition LinkPosition //此位置是应答器初始位置,当前位置需从应答器实体中获取
linkPosition *LinkPosition //此位置是应答器初始位置,当前位置需从应答器实体中获取
fixedTelegram []byte //应答器固定报文
fixedUserTelegram []byte //应答器固定用户报文
baliseType proto.Transponder_Type //应答器类型
leuIndex uint32 //应答器所属LEU的索引
indexInLeu uint32 //应答器在LEU内的索引
}
func NewTransponder(id string, km *proto.Kilometer, fixedTelegram []byte, fixedUserTelegram []byte,
baliseType proto.Transponder_Type, leuIndex uint32, indexInLeu uint32) *Transponder {
func NewTransponder(id string, km *proto.Kilometer, fixedTelegram []byte, fixedUserTelegram []byte, baliseType proto.Transponder_Type) *Transponder {
return &Transponder{
Identity: identity{id, proto.DeviceType_DeviceType_Transponder},
km: km,
fixedTelegram: fixedTelegram,
fixedUserTelegram: fixedUserTelegram,
baliseType: baliseType,
leuIndex: leuIndex,
indexInLeu: indexInLeu,
}
}
func (t *Transponder) TransponderType() proto.Transponder_Type {
return t.baliseType
}
@ -40,10 +32,11 @@ func (t *Transponder) FixedTelegram() []byte {
func (t *Transponder) FixedUserTelegram() []byte {
return t.fixedUserTelegram
}
func (t *Transponder) bindLinkPosition(position LinkPosition) {
func (t *Transponder) bindLinkPosition(position *LinkPosition) {
t.linkPosition = position
}
func (t *Transponder) LinkPosition() LinkPosition {
func (t *Transponder) LinkPosition() *LinkPosition {
return t.linkPosition
}
@ -54,11 +47,3 @@ func (t *Transponder) Km() *proto.Kilometer {
func (t *Transponder) BaliseType() proto.Transponder_Type {
return t.baliseType
}
func (t *Transponder) LeuIndex() uint32 {
return t.leuIndex
}
func (t *Transponder) IndexInLeu() uint32 {
return t.indexInLeu
}

View File

@ -44,10 +44,6 @@ type Turnout struct {
componentGroups []*ElectronicComponentGroup
}
func (t *Turnout) Km() *proto.Kilometer {
return t.km
}
func NewTurnout(id string, km *proto.Kilometer, switchMachineType proto.Turnout_SwitchMachineType) *Turnout {
return &Turnout{
Identity: identity{id, proto.DeviceType_DeviceType_Turnout},

View File

@ -5,13 +5,11 @@ import "joylink.club/rtsssimulation/repository/model/proto"
type Xcj struct {
Identity
componentGroups []*ElectronicComponentGroup
NumSegments uint32
}
func NewXcj(id string, numSegments uint32) *Xcj {
func NewXcj(id string) *Xcj {
return &Xcj{
Identity: identity{id: id, deviceType: proto.DeviceType_DeviceType_Xcj},
NumSegments: numSegments,
Identity: identity{id: id, deviceType: proto.DeviceType_DeviceType_Xcj},
}
}

View File

@ -30,7 +30,6 @@ func BindSystem(w ecs.World) {
circuit_sys.NewSignalJDXHSystem(),
circuit_sys.NewCkmSys(),
circuit_sys.NewXcjSys(),
circuit_sys.NewTrackCircuitSys(),
device_sys.NewLightSys(),
//屏蔽门
circuit_sys.NewPsdSys(),
@ -39,9 +38,8 @@ func BindSystem(w ecs.World) {
circuit_sys.NewIBPSys(),
device_sys.NewAlarmSys(),
//物理区段
device_sys.NewPhysicalSectionSystem(),
//计轴区段
device_sys.NewAxleCountingSectionSystem(),
device_sys.NewFaDcAxleDeviceSystem(),
device_sys.NewSectionDetectSystem(),
//应答器
device_sys.NewBaliseSystem(),
//电机

View File

@ -15,40 +15,31 @@ type CkmSys struct {
func NewCkmSys() *CkmSys {
return &CkmSys{
query: ecs.NewQuery(filter.Contains(entity.CkmBaseComponentTypes...)),
query: ecs.NewQuery(filter.Contains(entity.PsdBaseComponentTypeArr...)),
}
}
func (p *CkmSys) Update(world ecs.World) {
worldData := entity.GetWorldData(world)
p.query.Each(world, func(entry *ecs.Entry) {
if !entry.HasComponent(component.CkmCircuitType) {
return
}
posCom := component.FixedPositionTransformType.Get(entry)
circuit := component.CkmCircuitType.Get(entry) //目前不考虑没有车库门电路的情况
//车库门PSL
if entry.HasComponent(component.CkmPslType) {
ckmPsl := component.CkmPslType.Get(entry)
component.RelayDriveType.Get(circuit.MPLJ).Td = component.BitStateType.Get(ckmPsl.MPLA).Val //门旁路
component.RelayDriveType.Get(circuit.MMSJ).Td = component.BitStateType.Get(ckmPsl.MMSA).Val //门模式
}
//门开/关继电器及状态
if posCom.Pos == consts.TwoPosMin {
component.RelayDriveType.Get(circuit.MGJ).Td = true
component.RelayDriveType.Get(circuit.MKJ).Td = false
} else {
component.RelayDriveType.Get(circuit.MGJ).Td = false
component.RelayDriveType.Get(circuit.MKJ).Td = true
}
////门故障继电器及状态
//component.RelayDriveType.Get(circuit.MGZJ).Td =
//开/关门继电器驱动状态
if component.BitStateType.Get(circuit.MMSJ).Val {
ckmPsl := component.CkmPslType.Get(entry)
component.RelayDriveType.Get(circuit.KMJ).Td = component.BitStateType.Get(ckmPsl.KMA).Val
component.RelayDriveType.Get(circuit.GMJ).Td = component.BitStateType.Get(ckmPsl.GMA).Val
} else {
state := component.CkmStateType.Get(entry)
if entry.HasComponent(component.CkmCircuitType) {
circuit := component.CkmCircuitType.Get(entry)
//门开/关继电器及状态
if posCom.Pos == consts.TwoPosMin {
component.RelayDriveType.Get(circuit.MGJ).Td = true
component.RelayDriveType.Get(circuit.MKJ).Td = false
state.Close = true
} else {
component.RelayDriveType.Get(circuit.MGJ).Td = false
component.RelayDriveType.Get(circuit.MKJ).Td = true
state.Close = false
}
//门故障继电器及状态
component.RelayDriveType.Get(circuit.MGZJ).Td = entry.HasComponent(component.CkmMgzTag)
state.Mgz = entry.HasComponent(component.CkmMgzTag)
//开/关门继电器驱动状态
kmBit, err := worldData.QueryQdBit(component.UidType.Get(circuit.KMJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.KMJ).Td = kmBit
@ -61,21 +52,21 @@ func (p *CkmSys) Update(world ecs.World) {
} else {
slog.Error(err.Error())
}
}
//强制开门
if entry.HasComponent(component.CkmForceOpenTag) {
posCom.Pos = consts.TwoPosMax
posCom.Speed = 0
return
} else if entry.HasComponent(component.CkmForceCloseTag) {
posCom.Pos = consts.TwoPosMin
posCom.Speed = 0
return
state.Km = component.BitStateType.Get(circuit.KMJ).Val
state.Gm = component.BitStateType.Get(circuit.GMJ).Val
} else {
if posCom.Pos == consts.TwoPosMin {
state.Close = true
} else {
state.Close = false
}
state.Mgz = entry.HasComponent(component.CkmMgzTag)
}
//驱动
if component.BitStateType.Get(circuit.GMJ).Val {
if state.Gm {
posCom.Speed = -component.CalculateTwoPositionAvgSpeed(3*1000, world.Tick())
} else if component.BitStateType.Get(circuit.KMJ).Val {
} else if state.Km {
posCom.Speed = component.CalculateTwoPositionAvgSpeed(3*1000, world.Tick())
}
})

View File

@ -35,11 +35,6 @@ func (p *PsdSys) Update(world ecs.World) {
}
asdList := component.AsdListType.Get(entry)
psdState := component.PsdStateType.Get(entry)
//更新站台门控箱继电器状态
if mkx != nil {
pmc := component.PlatformMkxCircuitType.Get(entry)
mkxBtnDriveRelay(mkx, pmc, psdCircuit)
}
//更新屏蔽门电路及PSC相关状态
if psdCircuit != nil { //有屏蔽门电路
//屏蔽门关门
@ -67,17 +62,14 @@ func (p *PsdSys) Update(world ecs.World) {
p.exciteZAWJ(psdCircuit, asdList)
psdState.Obstacle = component.BitStateType.Get(psdCircuit.ZAWJ).Val
}
//互锁解除
if psdCircuit.MPLJ != nil {
psdState.InterlockRelease = component.BitStateType.Get(psdCircuit.MPLJ).Val
}
} else {
psdState.Close = p.isAllAsdMotorClosed(asdList)
if mkx != nil {
psdState.InterlockRelease = component.BitStateType.Get(mkx.MPL).Val
}
}
//更新站台门控箱继电器状态
if mkx != nil {
pmc := component.PlatformMkxCircuitType.Get(entry)
mkxBtnDriveRelay(mkx, pmc, psdCircuit)
}
//设置滑动门电机通断电状态
repo := entity.GetWorldData(world).Repo
psd := repo.FindPsd(component.UidType.Get(entry).Id)
@ -183,24 +175,18 @@ func (p *PsdSys) driveGMJ(data *component.WorldData, circuit *component.PsdCircu
if err != nil {
return
}
component.RelayDriveType.Get(circuit.GMJ).Td = bit
//bit, err := data.QueryQdBit(component.UidType.Get(circuit.GMJ).Id)
//if err != nil {
// return
//}
//if bit { //驱动
// component.RelayDriveType.Get(circuit.GMJ).Td = true
//} else if component.BitStateType.Get(circuit.GMJ).Val { //判断自保持
// for _, entry := range circuit.KMJMap {
// if component.BitStateType.Get(entry).Val { //无法自保持
// component.RelayDriveType.Get(circuit.GMJ).Td = false
// return
// }
// }
// //自保持
// component.RelayDriveType.Get(circuit.GMJ).Td = true
//}
if bit { //驱动
component.RelayDriveType.Get(circuit.GMJ).Td = true
} else if component.BitStateType.Get(circuit.GMJ).Val { //判断自保持
for _, entry := range circuit.KMJMap {
if component.BitStateType.Get(entry).Val { //无法自保持
component.RelayDriveType.Get(circuit.GMJ).Td = false
return
}
}
//自保持
component.RelayDriveType.Get(circuit.GMJ).Td = true
}
}
func (p *PsdSys) driveKMJ(data *component.WorldData, circuit *component.PsdCircuit, kmj *ecs.Entry) {
@ -208,28 +194,22 @@ func (p *PsdSys) driveKMJ(data *component.WorldData, circuit *component.PsdCircu
if err != nil {
return
}
component.RelayDriveType.Get(kmj).Td = bit
//bit, err := data.QueryQdBit(component.UidType.Get(kmj).Id)
//if err != nil {
// return
//}
//if bit { //驱动
// component.RelayDriveType.Get(kmj).Td = true
//} else if component.BitStateType.Get(kmj).Val { //判断自保持
// if component.BitStateType.Get(circuit.GMJ).Val {
// component.RelayDriveType.Get(kmj).Td = false
// return
// }
// for _, entry := range circuit.KMJMap {
// if entry != kmj && component.BitStateType.Get(entry).Val {
// component.RelayDriveType.Get(kmj).Td = false
// return
// }
// }
// //自保持
// component.RelayDriveType.Get(kmj).Td = true
//}
if bit { //驱动
component.RelayDriveType.Get(kmj).Td = true
} else if component.BitStateType.Get(kmj).Val { //判断自保持
if component.BitStateType.Get(circuit.GMJ).Val {
component.RelayDriveType.Get(kmj).Td = false
return
}
for _, entry := range circuit.KMJMap {
if entry != kmj && component.BitStateType.Get(entry).Val {
component.RelayDriveType.Get(kmj).Td = false
return
}
}
//自保持
component.RelayDriveType.Get(kmj).Td = true
}
}
func (p *PsdSys) driveMGJ(psdCircuit *component.PsdCircuit, asdList *component.AsdList) {

View File

@ -4,7 +4,6 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type Signal2XH1System struct {
@ -21,35 +20,21 @@ func NewSignal2XH1System() *Signal2XH1System {
// Update world 执行
func (s *Signal2XH1System) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
circuit := component.Signal2XH1ElectronicType.Get(entry)
excite2xh1ByCiDrive(circuit, wd)
//lsq := component.Signal2XH1LsqType.Get(entry)
//lsc := component.Signal2XH1LscType.Get(entry)
state := component.Signal2XH1ElectronicType.Get(entry)
lsq := component.Signal2XH1LsqType.Get(entry)
lsc := component.Signal2XH1LscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
Z2XH1_L := lights.GetLightByTag(component.LdTag)
Z2XH1_H := lights.GetLightByTag(component.HdTag)
//s.calculateLsq(circuit, lsq)
s.calculateL(circuit, Z2XH1_L)
s.calculateH(circuit, Z2XH1_H)
s.calculateDJ(circuit, Z2XH1_L, Z2XH1_H)
//s.calculateLsc(circuit, lsc)
s.calculateLsq(state, lsq)
s.calculateL(state, Z2XH1_L)
s.calculateH(state, Z2XH1_H)
s.calculateDJ(state, Z2XH1_L, Z2XH1_H)
s.calculateLsc(state, lsc)
})
}
func excite2xh1ByCiDrive(circuit *component.Signal2XH1Electronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.Z2XH1_DDJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z2XH1_DDJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z2XH1_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z2XH1_LXJ).Td = bit
}
}
// 联锁驱
func (s *Signal2XH1System) calculateLsq(state *component.Signal2XH1Electronic, lsq *component.Signal2XH1Lsq) {
ddj := component.RelayDriveType.Get(state.Z2XH1_DDJ)

View File

@ -4,7 +4,6 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type Signal3XH1System struct {
@ -21,49 +20,25 @@ func NewSignal3XH1System() *Signal3XH1System {
// Update world 执行
func (s *Signal3XH1System) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
circuit := component.Signal3XH1ElectronicType.Get(entry)
excite3xh1ByCiDrive(circuit, wd)
//lsq := component.Signal3XH1LsqType.Get(entry)
//lsc := component.Signal3XH1LscType.Get(entry)
state := component.Signal3XH1ElectronicType.Get(entry)
lsq := component.Signal3XH1LsqType.Get(entry)
lsc := component.Signal3XH1LscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
Z3XH1_L := lights.GetLightByTag(component.LdTag)
Z3XH1_H := lights.GetLightByTag(component.HdTag)
Z3XH1_U := lights.GetLightByTag(component.UdTag)
//s.calculateLsq(circuit, lsq)
s.calculateU(circuit, Z3XH1_U)
s.calculateL(circuit, Z3XH1_L)
s.calculateH(circuit, Z3XH1_H)
s.calculateDJ(circuit, Z3XH1_H, Z3XH1_L, Z3XH1_U)
s.calculate2DJ(circuit, Z3XH1_U)
//s.calculateLsc(circuit, lsc)
//
s.calculateLsq(state, lsq)
s.calculateU(state, Z3XH1_U)
s.calculateL(state, Z3XH1_L)
s.calculateH(state, Z3XH1_H)
s.calculateDJ(state, Z3XH1_H, Z3XH1_L, Z3XH1_U)
s.calculate2DJ(state, Z3XH1_U)
s.calculateLsc(state, lsc)
})
}
func excite3xh1ByCiDrive(circuit *component.Signal3XH1Electronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.Z3XH1_DDJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH1_DDJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH1_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH1_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH1_ZXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH1_ZXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH1_YXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH1_YXJ).Td = bit
}
}
// 联锁驱
func (s *Signal3XH1System) calculateLsq(state *component.Signal3XH1Electronic, lsq *component.Signal3XH1Lsq) {
ddj := component.RelayDriveType.Get(state.Z3XH1_DDJ)

View File

@ -4,7 +4,6 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type Signal3XH2System struct {
@ -21,44 +20,24 @@ func NewSignal3XH2System() *Signal3XH2System {
// Update world 执行
func (s *Signal3XH2System) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
circuit := component.Signal3XH2ElectronicType.Get(entry)
excite3xh2ByCiDrive(circuit, wd)
//lsq := component.Signal3XH2LsqType.Get(entry)
//lsc := component.Signal3XH2LscType.Get(entry)
state := component.Signal3XH2ElectronicType.Get(entry)
lsq := component.Signal3XH2LsqType.Get(entry)
lsc := component.Signal3XH2LscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
Z3XH2_L := lights.GetLightByTag(component.LdTag)
Z3XH2_H := lights.GetLightByTag(component.HdTag)
Z3XH2_U := lights.GetLightByTag(component.UdTag)
//s.calculateLsq(circuit, lsq)
s.calculateU(circuit, Z3XH2_U)
s.calculateL(circuit, Z3XH2_L)
s.calculateH(circuit, Z3XH2_H)
s.calculateDJ(circuit, Z3XH2_L, Z3XH2_H)
s.calculate2DJ(circuit, Z3XH2_U)
//s.calculateLsc(circuit, lsc)
s.calculateLsq(state, lsq)
s.calculateU(state, Z3XH2_U)
s.calculateL(state, Z3XH2_L)
s.calculateH(state, Z3XH2_H)
s.calculateDJ(state, Z3XH2_L, Z3XH2_H)
s.calculate2DJ(state, Z3XH2_U)
s.calculateLsc(state, lsc)
})
}
// 根据联锁驱动给继电器励磁
func excite3xh2ByCiDrive(circuit *component.Signal3XH2Electronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.Z3XH2_DDJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH2_DDJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH2_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH2_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH2_YXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH2_YXJ).Td = bit
}
}
// 联锁驱
func (s *Signal3XH2System) calculateLsq(state *component.Signal3XH2Electronic, lsq *component.Signal3XH2Lsq) {
ddj := component.RelayDriveType.Get(state.Z3XH2_DDJ)

View File

@ -4,7 +4,6 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type Signal3XH3System struct {
@ -21,42 +20,23 @@ func NewSignal3XH3System() *Signal3XH3System {
// Update world 执行
func (s *Signal3XH3System) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
circuit := component.Signal3XH3ElectronicType.Get(entry)
excite3xh3ByCiDrive(circuit, wd)
//lsq := component.Signal3XH3LsqType.Get(entry)
//lsc := component.Signal3XH3LscType.Get(entry)
state := component.Signal3XH3ElectronicType.Get(entry)
lsq := component.Signal3XH3LsqType.Get(entry)
lsc := component.Signal3XH3LscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
Z3XH3_H := lights.GetLightByTag(component.HdTag)
Z3XH3_U := lights.GetLightByTag(component.UdTag)
//s.calculateLsq(circuit, lsq)
s.calculateU(circuit, Z3XH3_U)
s.calculateH(circuit, Z3XH3_H)
s.calculateDJ(circuit, Z3XH3_U, Z3XH3_H)
s.calculate2DJ(circuit, Z3XH3_U)
//s.calculateLsc(circuit, lsc)
//
s.calculateLsq(state, lsq)
s.calculateU(state, Z3XH3_U)
s.calculateH(state, Z3XH3_H)
s.calculateDJ(state, Z3XH3_U, Z3XH3_H)
s.calculate2DJ(state, Z3XH3_U)
s.calculateLsc(state, lsc)
})
}
func excite3xh3ByCiDrive(circuit *component.Signal3XH3Electronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.Z3XH3_DDJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH3_DDJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH3_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH3_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH3_YXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH3_YXJ).Td = bit
}
}
// 联锁驱
func (s *Signal3XH3System) calculateLsq(state *component.Signal3XH3Electronic, lsq *component.Signal3XH3Lsq) {
ddj := component.RelayDriveType.Get(state.Z3XH3_DDJ)

View File

@ -4,7 +4,6 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type Signal3XH4System struct {
@ -21,43 +20,24 @@ func NewSignal3XH4System() *Signal3XH4System {
// Update world 执行
func (s *Signal3XH4System) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
circuit := component.Signal3XH4ElectronicType.Get(entry)
excite3xh4ByCiDrive(circuit, wd)
//lsq := component.Signal3XH4LsqType.Get(entry)
//lsc := component.Signal3XH4LscType.Get(entry)
state := component.Signal3XH4ElectronicType.Get(entry)
lsq := component.Signal3XH4LsqType.Get(entry)
lsc := component.Signal3XH4LscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
Z3XH4_H := lights.GetLightByTag(component.HdTag)
Z3XH4_L := lights.GetLightByTag(component.LdTag)
Z3XH4_U := lights.GetLightByTag(component.UdTag)
//
//s.calculateLsq(circuit, lsq)
s.calculateU(circuit, Z3XH4_U)
s.calculateL(circuit, Z3XH4_L)
s.calculateH(circuit, Z3XH4_H)
s.calculateDJ(circuit, Z3XH4_H, Z3XH4_L, Z3XH4_U)
//s.calculateLsc(circuit, lsc)
s.calculateLsq(state, lsq)
s.calculateU(state, Z3XH4_U)
s.calculateL(state, Z3XH4_L)
s.calculateH(state, Z3XH4_H)
s.calculateDJ(state, Z3XH4_H, Z3XH4_L, Z3XH4_U)
s.calculateLsc(state, lsc)
})
}
func excite3xh4ByCiDrive(circuit *component.Signal3XH4Electronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.Z3XH4_DDJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH4_DDJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH4_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH4_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH4_ZXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH4_ZXJ).Td = bit
}
}
// 联锁驱
func (s *Signal3XH4System) calculateLsq(state *component.Signal3XH4Electronic, lsq *component.Signal3XH4Lsq) {
ddj := component.RelayDriveType.Get(state.Z3XH4_DDJ)

View File

@ -4,7 +4,6 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type SignalDCXHSystem struct {
@ -21,32 +20,23 @@ func NewSignalDCXHSystem() *SignalDCXHSystem {
// Update world 执行
func (s *SignalDCXHSystem) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
circuit := component.SignalDCXHElectronicType.Get(entry)
exciteDcxhByCiDrive(circuit, wd)
//lsq := component.SignalDCXHLsqType.Get(entry)
//lsc := component.SignalDCXHLscType.Get(entry)
state := component.SignalDCXHElectronicType.Get(entry)
lsq := component.SignalDCXHLsqType.Get(entry)
lsc := component.SignalDCXHLscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
DCXH_A := lights.GetLightByTag(component.AdTag)
DCXH_B := lights.GetLightByTag(component.BdTag)
//s.calculateLsq(circuit, lsq)
s.calculateA(circuit, DCXH_A)
s.calculateB(circuit, DCXH_B)
s.calculateDJ(circuit, DCXH_B, DCXH_A)
//s.calculateLsc(circuit, lsc)
//
s.calculateLsq(state, lsq)
s.calculateA(state, DCXH_A)
s.calculateB(state, DCXH_B)
s.calculateDJ(state, DCXH_B, DCXH_A)
s.calculateLsc(state, lsc)
})
}
func exciteDcxhByCiDrive(circuit *component.SignalDCXHElectronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.DCXH_DXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.DCXH_DXJ).Td = bit
}
}
// 联锁驱
func (s *SignalDCXHSystem) calculateLsq(state *component.SignalDCXHElectronic, lsq *component.SignalDCXHLsq) {
dxj := component.RelayDriveType.Get(state.DCXH_DXJ)

View File

@ -4,7 +4,6 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type SignalJCKXHSystem struct {
@ -21,38 +20,24 @@ func NewSignalJCKXHSystem() *SignalJCKXHSystem {
// Update world 执行
func (s *SignalJCKXHSystem) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
circuit := component.SignalJCKXHElectronicType.Get(entry)
exciteJckxhByCiDrive(circuit, wd)
//lsq := component.SignalJCKXHLsqType.Get(entry)
//lsc := component.SignalJCKXHLscType.Get(entry)
state := component.SignalJCKXHElectronicType.Get(entry)
lsq := component.SignalJCKXHLsqType.Get(entry)
lsc := component.SignalJCKXHLscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
JCKXH_H := lights.GetLightByTag(component.HdTag)
JCKXH_B := lights.GetLightByTag(component.BdTag)
JCKXH_U := lights.GetLightByTag(component.UdTag)
//s.calculateLsq(circuit, lsq)
s.calculateU(circuit, JCKXH_U)
s.calculateB(circuit, JCKXH_B)
s.calculateH(circuit, JCKXH_H)
s.calculateDJ(circuit, JCKXH_H, JCKXH_B, JCKXH_U)
//s.calculateLsc(circuit, lsc)
//
s.calculateLsq(state, lsq)
s.calculateU(state, JCKXH_U)
s.calculateB(state, JCKXH_B)
s.calculateH(state, JCKXH_H)
s.calculateDJ(state, JCKXH_H, JCKXH_B, JCKXH_U)
s.calculateLsc(state, lsc)
})
}
func exciteJckxhByCiDrive(circuit *component.SignalJCKXHElectronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.JCKXH_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.JCKXH_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.JCKXH_DXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.JCKXH_DXJ).Td = bit
}
}
// 联锁驱
func (s *SignalJCKXHSystem) calculateLsq(state *component.SignalJCKXHElectronic, lsq *component.SignalJCKXHLsq) {
dxj := component.RelayDriveType.Get(state.JCKXH_DXJ)

View File

@ -4,7 +4,6 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type SignalJDXHSystem struct {
@ -21,39 +20,25 @@ func NewSignalJDXHSystem() *SignalJDXHSystem {
// Update world 执行
func (s *SignalJDXHSystem) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
circuit := component.SignalJDXHElectronicType.Get(entry)
exciteJdxhByCiDrive(circuit, wd)
//lsq := component.SignalJDXHLsqType.Get(entry)
//lsc := component.SignalJDXHLscType.Get(entry)
state := component.SignalJDXHElectronicType.Get(entry)
lsq := component.SignalJDXHLsqType.Get(entry)
lsc := component.SignalJDXHLscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
JDXH_H := lights.GetLightByTag(component.HdTag)
JDXH_L := lights.GetLightByTag(component.LdTag)
JDXH_U := lights.GetLightByTag(component.UdTag)
//s.calculateLsq(circuit, lsq)
s.calculateL(circuit, JDXH_L)
s.calculateU(circuit, JDXH_U)
s.calculateH(circuit, JDXH_H)
s.calculateDJ(circuit, JDXH_L, JDXH_H)
s.calculate2DJ(circuit, JDXH_U)
//s.calculateLsc(circuit, lsc)
//
s.calculateLsq(state, lsq)
s.calculateL(state, JDXH_L)
s.calculateU(state, JDXH_U)
s.calculateH(state, JDXH_H)
s.calculateDJ(state, JDXH_L, JDXH_H)
s.calculate2DJ(state, JDXH_U)
s.calculateLsc(state, lsc)
})
}
func exciteJdxhByCiDrive(circuit *component.SignalJDXHElectronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.JDXH_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.JDXH_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.JDXH_YXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.JDXH_YXJ).Td = bit
}
}
// 联锁驱
func (s *SignalJDXHSystem) calculateLsq(state *component.SignalJDXHElectronic, lsq *component.SignalJDXHLsq) {
lxj := component.RelayDriveType.Get(state.JDXH_LXJ)

View File

@ -1,44 +0,0 @@
package circuit_sys
import (
"github.com/yohamta/donburi"
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
"joylink.club/rtsssimulation/sys/device_sys"
)
type TrackCircuitSys struct {
trainQuery *ecs.Query
query *ecs.Query
}
func NewTrackCircuitSys() *TrackCircuitSys {
return &TrackCircuitSys{
trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)),
query: ecs.NewQuery(filter.Contains(entity.TrackCircuitBaseComponentTypeArr...)),
}
}
func (t *TrackCircuitSys) Update(world ecs.World) {
var withTrainSectionMap = make(map[string]bool)
t.trainQuery.Each(world, func(entry *donburi.Entry) {
trainPos := component.TrainPositionInfoType.Get(entry)
sections := device_sys.DoSearchTrainOccupiedSections(world, trainPos)
for _, sectionId := range sections {
withTrainSectionMap[sectionId] = true
}
})
t.query.Each(world, func(entry *ecs.Entry) {
if !entry.HasComponent(component.TrackCircuitType) {
return
}
gj := component.TrackCircuitType.Get(entry).GJ
if withTrainSectionMap[component.UidType.Get(entry).Id] {
component.RelayDriveType.Get(gj).Td = false
} else {
component.RelayDriveType.Get(gj).Td = true
}
})
}

View File

@ -23,44 +23,40 @@ func (x *XcjSys) Update(w ecs.World) {
circuit := component.XcjCircuitType.Get(entry)
//处理联锁对继电器的驱动
handleDrive(wd, circuit)
//洗车流程驱动继电器
x.process(circuit)
//紧急停车
if entry.HasComponent(component.XcjFaultTag) {
component.RelayDriveType.Get(circuit.JTJ).Td = true
} else {
component.RelayDriveType.Get(circuit.JTJ).Td = false
}
//驱动继电器
x.drive(circuit)
}
})
}
func (x *XcjSys) process(circuit *component.XcjCircuit) {
//初始状态
if !component.BitStateType.Get(circuit.XQJ).Val && !component.BitStateType.Get(circuit.TGQJ).Val {
component.RelayDriveType.Get(circuit.XCJXJ).Td = true
component.RelayDriveType.Get(circuit.XCJXJ).Td = true
component.RelayDriveType.Get(circuit.XCYXJ).Td = false
for _, cfj := range circuit.CFJList {
component.RelayDriveType.Get(cfj).Td = false
}
component.RelayDriveType.Get(circuit.TGYXJ).Td = false
}
//洗车流程
func (x *XcjSys) drive(circuit *component.XcjCircuit) {
if component.BitStateType.Get(circuit.XCJXJ).Val { //洗车就绪
if component.BitStateType.Get(circuit.XQJ).Val { //洗车请求
component.RelayDriveType.Get(circuit.XCYXJ).Td = true
component.RelayDriveType.Get(circuit.XCJXJ).Td = false
}
} else if component.BitStateType.Get(circuit.XCYXJ).Val { //洗车允许
for i, twj := range circuit.TWJList {
if component.BitStateType.Get(twj).Val {
component.RelayDriveType.Get(circuit.CFJList[i]).Td = true
}
if component.BitStateType.Get(circuit.TWJ1).Val {
component.RelayDriveType.Get(circuit.CFJ1).Td = true
}
if component.BitStateType.Get(circuit.TWJ2).Val {
component.RelayDriveType.Get(circuit.CFJ2).Td = true
}
if component.BitStateType.Get(circuit.TWJ3).Val {
component.RelayDriveType.Get(circuit.CFJ3).Td = true
}
if component.BitStateType.Get(circuit.TGQJ).Val {
component.RelayDriveType.Get(circuit.TGYXJ).Td = true
}
} else if component.BitStateType.Get(circuit.TGYXJ).Val { //通过允许
if !component.BitStateType.Get(circuit.XQJ).Val && !component.BitStateType.Get(circuit.TGQJ).Val {
component.RelayDriveType.Get(circuit.XCJXJ).Td = true
component.RelayDriveType.Get(circuit.XCYXJ).Td = false
component.RelayDriveType.Get(circuit.CFJ1).Td = false
component.RelayDriveType.Get(circuit.CFJ2).Td = false
component.RelayDriveType.Get(circuit.CFJ3).Td = false
component.RelayDriveType.Get(circuit.TGYXJ).Td = false
}
}
}
@ -73,14 +69,26 @@ func handleDrive(wd *component.WorldData, circuit *component.XcjCircuit) {
} else {
component.RelayDriveType.Get(circuit.XQJ).Td = XQJBit
}
for _, twj := range circuit.TWJList {
id := component.UidType.Get(twj).Id
twjBit, err := wd.QueryQdBit(id)
if err != nil {
slog.Error(err.Error())
} else {
component.RelayDriveType.Get(twj).Td = twjBit
}
TWJ1Id := component.UidType.Get(circuit.TWJ1).Id
TWJ1Bit, err := wd.QueryQdBit(TWJ1Id)
if err != nil {
slog.Error(err.Error())
} else {
component.RelayDriveType.Get(circuit.TWJ1).Td = TWJ1Bit
}
TWJ2Id := component.UidType.Get(circuit.TWJ2).Id
TWJ2Bit, err := wd.QueryQdBit(TWJ2Id)
if err != nil {
slog.Error(err.Error())
} else {
component.RelayDriveType.Get(circuit.TWJ2).Td = TWJ2Bit
}
TWJ3Id := component.UidType.Get(circuit.TWJ3).Id
TWJ3Bit, err := wd.QueryQdBit(TWJ3Id)
if err != nil {
slog.Error(err.Error())
} else {
component.RelayDriveType.Get(circuit.TWJ3).Td = TWJ3Bit
}
TGQJId := component.UidType.Get(circuit.TGQJ).Id
TGQJBit, err := wd.QueryQdBit(TGQJId)

View File

@ -1,30 +0,0 @@
package device_sys
import (
"github.com/yohamta/donburi"
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type AxleCountingSectionSystem struct {
axleCountingSectionQuery *ecs.Query
}
func NewAxleCountingSectionSystem() *AxleCountingSectionSystem {
return &AxleCountingSectionSystem{
axleCountingSectionQuery: ecs.NewQuery(filter.Contains(entity.AxleCountingSectionBaseComponentTypes...)),
}
}
func (a *AxleCountingSectionSystem) Update(w ecs.World) {
a.axleCountingSectionQuery.Each(w, func(entry *donburi.Entry) {
wd := entity.GetWorldData(w)
uid := component.UidType.Get(entry).Id
section := wd.Repo.FindAxleCountingSection(uid)
physicalSectionEntry := wd.EntityMap[section.PhysicalSection().Id()]
occupied := component.PhysicalSectionManagerType.Get(physicalSectionEntry).Occupied
component.AxleCountingSectionStateType.Get(entry).Occupied = occupied
})
}

View File

@ -1,101 +1,95 @@
package device_sys
//
//import (
// "log/slog"
//
// "joylink.club/ecs"
// "joylink.club/ecs/filter"
// "joylink.club/rtsssimulation/component"
// "joylink.club/rtsssimulation/entity"
//)
//
//// FaDcAxleDeviceSystem FaDc计轴设备管理器系统
//type FaDcAxleDeviceSystem struct {
// query *ecs.Query
//}
//
//func NewFaDcAxleDeviceSystem() *FaDcAxleDeviceSystem {
// return &FaDcAxleDeviceSystem{
// query: ecs.NewQuery(filter.Contains(component.AxleManageDeviceType)),
// }
//}
//func (s *FaDcAxleDeviceSystem) Update(w ecs.World) {
// data := entity.GetWorldData(w)
// s.query.Each(w, func(entry *ecs.Entry) {
// faDcDevice := component.AxleManageDeviceType.Get(entry)
// for axleSectionId, axleRuntime := range faDcDevice.Adrs {
// axleSectionEntry := data.EntityMap[axleSectionId]
// sectionState := component.PhysicalSectionStateType.Get(axleSectionEntry)
// axleDevice := component.AxlePhysicalSectionType.Get(axleSectionEntry)
// //
// sectionFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag)
// s.calculateHf(sectionFault, axleSectionEntry, sectionState, axleDevice, axleRuntime)
// s.calculateDrst(axleSectionEntry, sectionState, axleDevice, axleRuntime)
// s.calculatePdrst(axleSectionEntry, sectionState, axleDevice, axleRuntime)
// s.calculateSectionState(sectionFault, sectionState, axleDevice, axleRuntime)
// if axleSectionEntry.HasComponent(component.PhysicalSectionCircuitType) {
// sectionCircuit := component.PhysicalSectionCircuitType.Get(axleSectionEntry)
// relayDrive := component.RelayDriveType.Get(sectionCircuit.GJ)
// relayDrive.Td = !sectionState.Occ
// }
//
// if "北京_12_酒仙桥_15G" == axleSectionId && false {
// sectionFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag)
// slog.Info(axleSectionId,
// "Drst", axleRuntime.Drst,
// "PDRST", axleRuntime.Pdrst,
// "DoingPdrst", axleRuntime.DoingPdrst,
// "RAC", axleRuntime.Rac,
// "RJO", axleRuntime.Rjo,
// "RJT", axleRuntime.Rjt,
// "SectionFault", sectionFault,
// "Occ", sectionState.Occ,
// "Count", axleDevice.Count,
// "Wave", axleDevice.ShowCountWave())
// }
// }
// })
//}
//
//// 计算计轴区段状态
//func (s *FaDcAxleDeviceSystem) calculateSectionState(sectionFault bool, sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
// sectionState.Occ = axleDevice.Count > 0 || sectionFault
//}
//
//// 计轴直接复位
//func (s *FaDcAxleDeviceSystem) calculateDrst(axleSectionEntry *ecs.Entry, sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
// isFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag)
// if axleRuntime.Drst && !axleRuntime.Rjo && !axleRuntime.Rjt && isFault { //直接复位且没有拒绝原因
// axleDevice.UpdateCount(0)
// axleDevice.ResetCountPulse()
// axleRuntime.DoingPdrst = false
// //清除故障
// if axleSectionEntry.HasComponent(component.AxleSectionFaultTag) {
// axleSectionEntry.RemoveComponent(component.AxleSectionFaultTag)
// }
// }
//}
//
//// 计轴预复位
//func (s *FaDcAxleDeviceSystem) calculatePdrst(axleSectionEntry *ecs.Entry, sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
// isFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag)
// if axleRuntime.Pdrst && !axleRuntime.Rjo && !axleRuntime.Rjt && !axleRuntime.DoingPdrst && isFault { //预复位且没有拒绝原因
// axleDevice.UpdateCount(0)
// axleDevice.ResetCountPulse()
// axleRuntime.DoingPdrst = true
// }
// //压道车通过该计轴区段,完成计轴预复位
// if axleRuntime.DoingPdrst && isFault && axleDevice.IsCount010Pulse() {
// axleRuntime.DoingPdrst = false
// //清除故障
// axleSectionEntry.RemoveComponent(component.AxleSectionFaultTag)
// }
//}
//
//// 复位回复运算
//func (s *FaDcAxleDeviceSystem) calculateHf(sectionFault bool, axleSectionEntry *ecs.Entry, sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
// axleRuntime.Rac = axleRuntime.Drst || axleRuntime.Pdrst
// axleRuntime.Rjo = axleRuntime.Rac && !sectionState.Occ && !axleRuntime.DoingPdrst //空闲拒绝复位(排除预复位过程中)
// axleRuntime.Rjt = false // 技术原因拒绝复位
//}
import (
"log/slog"
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
// FaDcAxleDeviceSystem FaDc计轴设备管理器系统
type FaDcAxleDeviceSystem struct {
query *ecs.Query
}
func NewFaDcAxleDeviceSystem() *FaDcAxleDeviceSystem {
return &FaDcAxleDeviceSystem{
query: ecs.NewQuery(filter.Contains(component.AxleManageDeviceType)),
}
}
func (s *FaDcAxleDeviceSystem) Update(w ecs.World) {
data := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
faDcDevice := component.AxleManageDeviceType.Get(entry)
for axleSectionId, axleRuntime := range faDcDevice.Adrs {
axleSectionEntry := data.EntityMap[axleSectionId]
sectionState := component.PhysicalSectionStateType.Get(axleSectionEntry)
axleDevice := component.AxlePhysicalSectionType.Get(axleSectionEntry)
//
sectionFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag)
s.calculateHf(sectionFault, axleSectionEntry, sectionState, axleDevice, axleRuntime)
s.calculateDrst(axleSectionEntry, sectionState, axleDevice, axleRuntime)
s.calculatePdrst(axleSectionEntry, sectionState, axleDevice, axleRuntime)
s.calculateSectionState(sectionFault, sectionState, axleDevice, axleRuntime)
if "北京_12_酒仙桥_15G" == axleSectionId && false {
sectionFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag)
slog.Info(axleSectionId,
"Drst", axleRuntime.Drst,
"Pdrst", axleRuntime.Pdrst,
"DoingPdrst", axleRuntime.DoingPdrst,
"Rac", axleRuntime.Rac,
"Rjo", axleRuntime.Rjo,
"Rjt", axleRuntime.Rjt,
"SectionFault", sectionFault,
"Occ", sectionState.Occ,
"Count", axleDevice.Count,
"Wave", axleDevice.ShowCountWave())
}
}
})
}
// 计算计轴区段状态
func (s *FaDcAxleDeviceSystem) calculateSectionState(sectionFault bool, sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
sectionState.Occ = axleDevice.Count > 0 || sectionFault
}
// 计轴直接复位
func (s *FaDcAxleDeviceSystem) calculateDrst(axleSectionEntry *ecs.Entry, sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
isFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag)
if axleRuntime.Drst && !axleRuntime.Rjo && !axleRuntime.Rjt && isFault { //直接复位且没有拒绝原因
axleDevice.UpdateCount(0)
axleDevice.ResetCountPulse()
axleRuntime.DoingPdrst = false
//清除故障
if axleSectionEntry.HasComponent(component.AxleSectionFaultTag) {
axleSectionEntry.RemoveComponent(component.AxleSectionFaultTag)
}
}
}
// 计轴预复位
func (s *FaDcAxleDeviceSystem) calculatePdrst(axleSectionEntry *ecs.Entry, sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
isFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag)
if axleRuntime.Pdrst && !axleRuntime.Rjo && !axleRuntime.Rjt && !axleRuntime.DoingPdrst && isFault { //预复位且没有拒绝原因
axleDevice.UpdateCount(0)
axleDevice.ResetCountPulse()
axleRuntime.DoingPdrst = true
}
//压道车通过该计轴区段,完成计轴预复位
if axleRuntime.DoingPdrst && isFault && axleDevice.IsCount010Pulse() {
axleRuntime.DoingPdrst = false
//清除故障
axleSectionEntry.RemoveComponent(component.AxleSectionFaultTag)
}
}
// 复位回复运算
func (s *FaDcAxleDeviceSystem) calculateHf(sectionFault bool, axleSectionEntry *ecs.Entry, sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
axleRuntime.Rac = axleRuntime.Drst || axleRuntime.Pdrst
axleRuntime.Rjo = axleRuntime.Rac && !sectionState.Occ && !axleRuntime.DoingPdrst //空闲拒绝复位(排除预复位过程中)
axleRuntime.Rjt = false // 技术原因拒绝复位
}

View File

@ -1,58 +0,0 @@
package device_sys
import (
"github.com/yohamta/donburi"
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type PhysicalSectionSystem struct {
trainQuery *ecs.Query //简化列车经过计轴时的计轴逻辑,后续有需要了再拆出去
axleSectionQuery *ecs.Query
}
func NewPhysicalSectionSystem() *PhysicalSectionSystem {
return &PhysicalSectionSystem{
trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)),
axleSectionQuery: ecs.NewQuery(filter.Contains(entity.PhysicalSectionBaseComponentTypes...)),
}
}
// Update
// 预复位逻辑:目前仅在区段上无车且占用时,才能成功设置预复位/复位,也就是说,区段会有【强制占用】状态且无车。
// 那么当预复位设置成功之后等待一次区段计数从非0变成0清除预复位和【强制占用】状态
func (s *PhysicalSectionSystem) Update(w ecs.World) {
sectionTrainCountMap := make(map[string]int)
s.trainQuery.Each(w, func(entry *donburi.Entry) {
trainPositionInfo := component.TrainPositionInfoType.Get(entry)
sectionIds := DoSearchTrainOccupiedSections(w, trainPositionInfo)
for _, id := range sectionIds {
sectionTrainCountMap[id]++
}
})
s.axleSectionQuery.Each(w, func(entry *donburi.Entry) {
sectionId := component.UidType.Get(entry).Id
axleManager := component.PhysicalSectionManagerType.Get(entry)
count := axleManager.Count
axleManager.Count = sectionTrainCountMap[sectionId]
//预复位逻辑。
if axleManager.PDRST && count != 0 && axleManager.Count == 0 {
axleManager.PDRST = false
entry.RemoveComponent(component.PhysicalSectionForceOccupied)
}
//区段占用判定
var gj *ecs.Entry
if entry.HasComponent(component.PhysicalSectionCircuitType) {
gj = component.PhysicalSectionCircuitType.Get(entry).GJ
}
occupied := axleManager.Count != 0 || entry.HasComponent(component.PhysicalSectionForceOccupied)
if gj != nil {
component.RelayDriveType.Get(entry).Td = !occupied
axleManager.Occupied = !component.BitStateType.Get(gj).Val
} else {
axleManager.Occupied = occupied
}
})
}

View File

@ -2,68 +2,69 @@ package device_sys
import (
"fmt"
"log/slog"
"strings"
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
"joylink.club/rtsssimulation/repository"
"joylink.club/rtsssimulation/repository/model/proto"
"log/slog"
"strings"
)
//// SectionDetectSystem 区段检测系统
//type SectionDetectSystem struct {
// trainQuery *ecs.Query
// axleCountingSectionQuery *ecs.Query
//}
//
//func NewSectionDetectSystem() *SectionDetectSystem {
// return &SectionDetectSystem{trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)),
// axleCountingSectionQuery: ecs.NewQuery(filter.Contains(component.UidType, component.AxlePhysicalSectionType))}
//}
//func (s *SectionDetectSystem) Update(w ecs.World) {
// //key-sectionId,统计区段上有车的情况
// sectionTrainMap := make(map[string]*trainCount)
// //所有列车
// s.trainQuery.Each(w, func(entry *ecs.Entry) {
// tp := component.TrainPositionInfoType.Get(entry)
// //fmt.Println("============>>>>>>列车位置信息:", tp.ToString())
// trainSectionIds := DoSearchTrainOccupiedSections(w, tp)
// //fmt.Println("============>>>>>>列车所在物理区段:", trainSectionIds)
// for _, sectionId := range trainSectionIds { //车所在区段
// tc, find := sectionTrainMap[sectionId]
// if !find {
// tc = newTrainCount()
// sectionTrainMap[sectionId] = tc
// }
// tc.add()
// }
// })
// //计轴区段
// s.axleCountingSectionQuery.Each(w, func(entry *ecs.Entry) {
// axleSectionId := component.UidType.Get(entry).Id
// axleSection := component.AxlePhysicalSectionType.Get(entry)
// tc, find := sectionTrainMap[axleSectionId]
// if find {
// axleSection.UpdateCount(int(tc.count))
// } else {
// axleSection.UpdateCount(0)
// }
// })
//}
//
//type trainCount struct {
// count int8
//}
//
//func newTrainCount() *trainCount {
// return &trainCount{count: 0}
//}
//func (c *trainCount) add() {
// c.count++
//}
// SectionDetectSystem 区段检测系统
type SectionDetectSystem struct {
trainQuery *ecs.Query
axleSectionQuery *ecs.Query
}
func DoSearchTrainOccupiedSections(w ecs.World, tp *component.TrainPositionInfo) []string {
func NewSectionDetectSystem() *SectionDetectSystem {
return &SectionDetectSystem{trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)),
axleSectionQuery: ecs.NewQuery(filter.Contains(component.UidType, component.AxlePhysicalSectionType))}
}
func (s *SectionDetectSystem) Update(w ecs.World) {
//key-sectionId,统计区段上有车的情况
sectionTrainMap := make(map[string]*trainCount)
//所有列车
s.trainQuery.Each(w, func(entry *ecs.Entry) {
tp := component.TrainPositionInfoType.Get(entry)
//fmt.Println("============>>>>>>列车位置信息:", tp.ToString())
trainSectionIds := s.doSearchTrainOccupiedSections(w, tp)
//fmt.Println("============>>>>>>列车所在物理区段:", trainSectionIds)
for _, sectionId := range trainSectionIds { //车所在区段
tc, find := sectionTrainMap[sectionId]
if !find {
tc = newTrainCount()
sectionTrainMap[sectionId] = tc
}
tc.add()
}
})
//计轴区段
s.axleSectionQuery.Each(w, func(entry *ecs.Entry) {
axleSectionId := component.UidType.Get(entry).Id
axleSection := component.AxlePhysicalSectionType.Get(entry)
tc, find := sectionTrainMap[axleSectionId]
if find {
axleSection.UpdateCount(int(tc.count))
} else {
axleSection.UpdateCount(0)
}
})
}
type trainCount struct {
count int8
}
func newTrainCount() *trainCount {
return &trainCount{count: 0}
}
func (c *trainCount) add() {
c.count++
}
func (s *SectionDetectSystem) doSearchTrainOccupiedSections(w ecs.World, tp *component.TrainPositionInfo) []string {
wd := entity.GetWorldData(w)
curLink := wd.Repo.FindLink(tp.HeadLink)
stp := &stpContext{w: w, trainLen: tp.Len, curLink: curLink, curOffset: tp.HeadLinkOffset, searchDirection: !tp.Up, acLen: 0}
@ -79,7 +80,8 @@ func DoSearchTrainOccupiedSections(w ecs.World, tp *component.TrainPositionInfo)
return stp.trainSections()
}
// /////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
type stpContext struct {
w ecs.World
trainLen int64 //列车长度