From 618af297ae8eac4c39a2dc1d6371f4db4b956008 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Mon, 6 Nov 2023 15:30:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E8=BD=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/physical_section.go | 3 +++ entity/fadc_axle.go | 5 ++++- fi/section.go | 4 ++-- sys/device_sys/fadc_axle_device.go | 3 +-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/component/physical_section.go b/component/physical_section.go index 80e1372..30c0003 100644 --- a/component/physical_section.go +++ b/component/physical_section.go @@ -52,6 +52,9 @@ type AxleManageDevice struct { 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)} } diff --git a/entity/fadc_axle.go b/entity/fadc_axle.go index 43ef38e..f8e2bd1 100644 --- a/entity/fadc_axle.go +++ b/entity/fadc_axle.go @@ -24,7 +24,10 @@ func LoadAxlePhysicalSections(w ecs.World) error { if len(strings.TrimSpace(section.CentralizedStation())) == 0 { return fmt.Errorf("区段[%s]未设置所属集中站", section.Id()) } - amdEntry := newAxleManageDevice(w, data, section.CentralizedStation()) + amdEntry := FindAxleManageDevice(data, section.CentralizedStation()) + if amdEntry == nil { + amdEntry = newAxleManageDevice(w, data, section.CentralizedStation()) + } amd := component.AxleManageDeviceType.Get(amdEntry) // createAxleSectionEntity(w, section, data) diff --git a/fi/section.go b/fi/section.go index fea5f75..f02fc46 100644 --- a/fi/section.go +++ b/fi/section.go @@ -24,8 +24,8 @@ func AxleSectionDrstDrive(w ecs.World, sectionId string, set bool) error { return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]实体不存在", sectionModel.CentralizedStation())) } faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry) - axleRuntime, ok := faDcAxleDevice.Adrs[sectionId] - if !ok { + axleRuntime := faDcAxleDevice.FindAdr(sectionId) + if axleRuntime == nil { return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴设备", sectionModel.CentralizedStation(), sectionId)) } axleRuntime.Drst = set diff --git a/sys/device_sys/fadc_axle_device.go b/sys/device_sys/fadc_axle_device.go index 564c8c3..5a935c9 100644 --- a/sys/device_sys/fadc_axle_device.go +++ b/sys/device_sys/fadc_axle_device.go @@ -34,7 +34,7 @@ func (s *FaDcAxleDeviceSystem) Update(w ecs.World) { s.calculateSectionState(sectionState, axleDevice, axleRuntime) s.calculateAxleCount(sectionState, axleDevice, axleRuntime) - if "北京_12_酒仙桥_12G" == axleSectionId && true { + if "北京_12_酒仙桥_12G" == axleSectionId && false { sectionFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag) slog.Info(axleSectionId, "Drst", axleRuntime.Drst, @@ -61,7 +61,6 @@ func (s *FaDcAxleDeviceSystem) calculateAxleCount(sectionState *component.Physic // 计算计轴区段状态 func (s *FaDcAxleDeviceSystem) calculateSectionState(sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) { - isIdle := axleDevice.Count <= 0 && !axleRuntime.DoingPdrst //区段空闲:区段内车轴数为零且没有预复位 sectionState.Occ = !isIdle }