From 84ce75a3d2a716db425468c3134565904ad77aa9 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Wed, 15 Nov 2023 13:20:44 +0800 Subject: [PATCH] rssp axle test --- fi/section.go | 16 +++++++++--- sys/device_sys/fadc_axle_device.go | 41 +++++++++++++++++------------- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/fi/section.go b/fi/section.go index d596ceb..f7cbc78 100644 --- a/fi/section.go +++ b/fi/section.go @@ -14,10 +14,17 @@ import ( 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()) @@ -46,6 +53,12 @@ func AxleSectionPdrstDrive(w ecs.World, sectionId string, set bool) error { 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()) @@ -79,17 +92,14 @@ func AxleSectionFaultOccDrive(w ecs.World, sectionId string, set bool) error { if sectionEntry == nil { return ecs.NewErrResult(fmt.Errorf("区段[%s]实体不存在", sectionId)) } - axleDevice := component.AxlePhysicalSectionType.Get(sectionEntry) if set { //计轴故障设置 if !sectionEntry.HasComponent(component.AxleSectionFaultTag) { sectionEntry.AddComponent(component.AxleSectionFaultTag) } - axleDevice.UpdateCount(1) } else { //计轴故障取消 if sectionEntry.HasComponent(component.AxleSectionFaultTag) { sectionEntry.RemoveComponent(component.AxleSectionFaultTag) } - axleDevice.UpdateCount(0) } // return ecs.NewOkEmptyResult() diff --git a/sys/device_sys/fadc_axle_device.go b/sys/device_sys/fadc_axle_device.go index a22ed7c..3e1526f 100644 --- a/sys/device_sys/fadc_axle_device.go +++ b/sys/device_sys/fadc_axle_device.go @@ -28,12 +28,13 @@ func (s *FaDcAxleDeviceSystem) Update(w ecs.World) { sectionState := component.PhysicalSectionStateType.Get(axleSectionEntry) axleDevice := component.AxlePhysicalSectionType.Get(axleSectionEntry) // - s.calculateHf(axleSectionEntry, sectionState, axleDevice, axleRuntime) - s.calculateDrst(sectionState, axleDevice, axleRuntime) - s.calculatePdrst(sectionState, axleDevice, axleRuntime) - s.calculateSectionState(sectionState, axleDevice, axleRuntime) + 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_酒仙桥_12G" == axleSectionId && false { + if "北京_12_酒仙桥_15G" == axleSectionId && false { sectionFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag) slog.Info(axleSectionId, "Drst", axleRuntime.Drst, @@ -52,39 +53,43 @@ func (s *FaDcAxleDeviceSystem) Update(w ecs.World) { } // 计算计轴区段状态 -func (s *FaDcAxleDeviceSystem) calculateSectionState(sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) { - isIdle := axleDevice.Count <= 0 && !axleRuntime.DoingPdrst //区段空闲:区段内车轴数为零且没有预复位 - sectionState.Occ = !isIdle +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(sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) { - - if axleRuntime.Drst && !axleRuntime.Rjo && !axleRuntime.Rjt { //直接复位且没有拒绝原因 +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(sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) { - - if axleRuntime.Pdrst && !axleRuntime.Rjo && !axleRuntime.Rjt && !axleRuntime.DoingPdrst { //预复位且没有拒绝原因 +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 axleDevice.IsCount010Pulse() { + if axleRuntime.DoingPdrst && isFault && axleDevice.IsCount010Pulse() { axleRuntime.DoingPdrst = false + //清除故障 + axleSectionEntry.RemoveComponent(component.AxleSectionFaultTag) } } // 复位回复运算 -func (s *FaDcAxleDeviceSystem) calculateHf(axleSectionEntry *ecs.Entry, sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) { - sectionFault := axleSectionEntry.HasComponent(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 = axleRuntime.Rac && sectionFault // 技术原因拒绝复位 + axleRuntime.Rjt = false // 技术原因拒绝复位 }