[补充]11号线联锁通信

This commit is contained in:
thesai 2024-08-07 14:53:56 +08:00
parent 8d19129ec6
commit 86c02883c4
11 changed files with 1453 additions and 1104 deletions

View File

@ -74,8 +74,9 @@ 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"`
Close bool `protobuf:"varint,1,opt,name=close,proto3" json:"close,omitempty"`
Obstacle bool `protobuf:"varint,2,opt,name=obstacle,proto3" json:"obstacle,omitempty"` //有障碍物
InterlockRelease bool `protobuf:"varint,3,opt,name=interlockRelease,proto3" json:"interlockRelease,omitempty"` //互锁解除
}
func (x *PsdState) Reset() {
@ -124,6 +125,13 @@ 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
@ -246,24 +254,27 @@ 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, 0x3c, 0x0a, 0x08, 0x50, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05,
0x22, 0x68, 0x0a, 0x08, 0x50, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05,
0x63, 0x6c, 0x6f, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x6f,
0x73, 0x65, 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, 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, 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,
}
var (

View File

@ -10,7 +10,6 @@ import (
func LoadStations(w ecs.World) error {
data := GetWorldData(w)
stations := data.Repo.StationList()
// 加载零散组合继电器
for _, station := range stations {
err := NewSFAEntity(w, station)
if err != nil {

View File

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

View File

@ -31,6 +31,8 @@ message Repository {
repeated Ckm ckms = 24;
repeated Xcj xcjs = 25;
repeated CkmPsl ckmPsls = 26;
repeated Esb esbs = 27;
repeated Spks spkss = 28;
//ISCS [300,500]
//ISCS管线
repeated Pipe pipes = 300;
@ -220,9 +222,9 @@ enum DeviceType {
//
DeviceType_SignalFaultAlarm = 20;
//
DeviceType_Breakers = 21;
DeviceType_Breakers = 21;
//
DeviceType_PowerScreen = 22;
DeviceType_PowerScreen = 22;
//
DeviceType_Route = 23;
DeviceType_Ckm = 24; //
@ -230,6 +232,8 @@ enum DeviceType {
DeviceType_CkmPsl = 26; //PSL
DeviceType_TrackCircuit = 27; //
DeviceType_LS = 28; //
DeviceType_Esb = 29; //
DeviceType_Spks = 30; //
//--------ISCS [300,500]------
//ISCS门磁
@ -506,7 +510,7 @@ message ElectronicGroup {
//
message ElectronicComponent {
string id= 1; // ID
string id = 1; // ID
DeviceType deviceType = 3; //
}
//
@ -533,7 +537,7 @@ message Mkx {
}
//PSL
message CkmPsl {
string id= 1;
string id = 1;
string ckmId = 2;
string gmaId = 3; //
string kmaId = 4; //
@ -541,9 +545,22 @@ message CkmPsl {
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 PlatformDirection {
enum Direction {
Unknown = 0;
Up = 1; //
Down = 2; //
@ -552,7 +569,7 @@ message Platform {
string code = 2;
string stationId = 3;
string physicalSectionId = 4;
PlatformDirection direction = 5;
Direction direction = 5;
repeated ElectronicComponentGroup electronicComponentGroups = 6; //
}
@ -752,10 +769,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;//
}

16
repository/esb.go Normal file
View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -34,6 +34,8 @@ type Repository struct {
ckmMap map[string]*Ckm
ckmPslMap map[string]*CkmPsl
xcjMap map[string]*Xcj
esbMap map[string]*Esb
spksMap map[string]*Spks
PipeMap map[string]*Pipe //ISCS 管线
PipeFittingMap map[string]*PipeFitting //ISCS 管件
@ -85,6 +87,8 @@ func newRepository(id string, version string) *Repository {
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),
PipeMap: make(map[string]*Pipe), //ISCS 管线
PipeFittingMap: make(map[string]*PipeFitting), //ISCS 管件
@ -483,6 +487,14 @@ func (repo *Repository) FindPlatform(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) ConvertKilometer(km *proto.Kilometer, cs string) (*proto.Kilometer, error) {
if km.CoordinateSystem == cs {
return km, nil

View File

@ -132,7 +132,7 @@ func buildModels(source *proto.Repository, repository *Repository) error {
repository.keyMap[m.Id()] = m
}
for _, protoData := range source.Platforms {
m := NewPlatform(protoData.Id, protoData.Code)
m := NewPlatform(protoData.Id, protoData.Code, protoData.Direction)
repository.platformMap[m.Id()] = m
}
for _, protoData := range source.Ckms {
@ -154,7 +154,12 @@ func buildModels(source *proto.Repository, repository *Repository) error {
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
@ -214,9 +219,87 @@ func buildModelRelationship(source *proto.Repository, repository *Repository) er
return err
}
err = buildCkmPslRelationShip(source, repository)
if err != nil {
return err
}
err = buildEsbRelationship(source, repository)
if err != nil {
return err
}
err = buildSpksRelationship(source, repository)
return err
}
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", 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]

16
repository/spks.go Normal file
View File

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

@ -35,6 +35,11 @@ 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 { //有屏蔽门电路
//屏蔽门关门
@ -62,14 +67,17 @@ 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)