[新增]ecs物理区段增加区段电路组件及逻辑;

[修改]12号线联锁通信服务如果启动失败,则启动参数无法更换bug
This commit is contained in:
thesai 2024-06-21 15:53:16 +08:00
parent cebe83f5c4
commit f94033ca44
7 changed files with 754 additions and 699 deletions

View File

@ -12,6 +12,14 @@ import (
//当CI系统给计轴设备发送计轴直接复零/预复零命令时,连续发送一定时间(具体发送时间调试后确定)的复零/预复零命令。
//当RACRJORJT任意一个不为0时终止发送复零/预复零命令。
var (
PhysicalSectionCircuitType = ecs.NewComponentType[PhysicalSectionCircuit]()
)
type PhysicalSectionCircuit struct {
GJ *ecs.Entry
}
// PhysicalSectionState 物理区段
type PhysicalSectionState struct {
//true-占用false-出清

View File

@ -6,6 +6,7 @@ import (
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"strings"
"unsafe"
)
func newAxleManageDevice(w ecs.World, data *component.WorldData, centralizedStation string) *ecs.Entry {
@ -58,6 +59,16 @@ func createAxleSectionEntity(w ecs.World, axleSection *repository.PhysicalSectio
component.PhysicalSectionStateType.Set(entry, &component.PhysicalSectionState{Occ: false})
component.AxlePhysicalSectionType.Set(entry, component.NewAxlePhysicalSection())
//
for _, group := range axleSection.ComponentGroups() {
for _, ec := range group.Components() {
if ec.Code() == "GJ" {
relay := ec.(*repository.Relay)
gjEntry := NewRelayEntity(w, relay, worldData.EntityMap)
circuit := &component.PhysicalSectionCircuit{GJ: gjEntry}
entry.AddComponent(component.PhysicalSectionCircuitType, unsafe.Pointer(circuit))
}
}
}
worldData.EntityMap[uid] = entry
}
return entry

View File

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

View File

@ -97,6 +97,7 @@ message PhysicalSection {
DevicePort bDevicePort = 4;
//
string centralizedStation = 5;
repeated ElectronicComponentGroup electronicComponentGroups = 6;
}
//

File diff suppressed because it is too large Load Diff

View File

@ -526,26 +526,26 @@ func buildTurnoutPortRelation(repo *Repository, turnout *Turnout, port proto.Por
return err
}
func buildPhysicalSectionRelationShip(source *proto.Repository, repository *Repository) error {
func buildPhysicalSectionRelationShip(source *proto.Repository, repo *Repository) error {
for _, protoData := range source.PhysicalSections {
section := repository.physicalSectionMap[protoData.Id]
section := repo.physicalSectionMap[protoData.Id]
//A端关联
if protoData.ADevicePort != nil {
err := buildSectionPortRelation(repository, section, proto.Port_A, protoData.ADevicePort)
err := buildSectionPortRelation(repo, section, proto.Port_A, protoData.ADevicePort)
if err != nil {
return err
}
}
//B端关联
if protoData.BDevicePort != nil {
err := buildSectionPortRelation(repository, section, proto.Port_B, protoData.BDevicePort)
err := buildSectionPortRelation(repo, section, proto.Port_B, protoData.BDevicePort)
if err != nil {
return err
}
}
//道岔关联
for _, turnoutId := range protoData.TurnoutIds {
turnout := repository.turnoutMap[turnoutId]
turnout := repo.turnoutMap[turnoutId]
if turnout == nil {
return fmt.Errorf("id[%s]的道岔不存在", turnoutId)
}
@ -554,6 +554,21 @@ func buildPhysicalSectionRelationShip(source *proto.Repository, repository *Repo
}
//关联联锁集中站
section.centralizedStation = protoData.CentralizedStation
//关联电子元件
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,
})
}
}
return nil
}

View File

@ -33,6 +33,11 @@ func (s *FaDcAxleDeviceSystem) Update(w ecs.World) {
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)