This commit is contained in:
xzb 2023-11-06 15:30:57 +08:00
parent 81760f5c89
commit 618af297ae
4 changed files with 10 additions and 5 deletions

View File

@ -52,6 +52,9 @@ type AxleManageDevice struct {
Adrs map[string]*AxleDeviceRuntime //key-sectionId Adrs map[string]*AxleDeviceRuntime //key-sectionId
} }
func (d *AxleManageDevice) FindAdr(sectionId string) *AxleDeviceRuntime {
return d.Adrs[sectionId]
}
func NewAxleManageDevice(centralizedStation string) *AxleManageDevice { func NewAxleManageDevice(centralizedStation string) *AxleManageDevice {
return &AxleManageDevice{CentralizedStation: centralizedStation, Adrs: make(map[string]*AxleDeviceRuntime)} return &AxleManageDevice{CentralizedStation: centralizedStation, Adrs: make(map[string]*AxleDeviceRuntime)}
} }

View File

@ -24,7 +24,10 @@ func LoadAxlePhysicalSections(w ecs.World) error {
if len(strings.TrimSpace(section.CentralizedStation())) == 0 { if len(strings.TrimSpace(section.CentralizedStation())) == 0 {
return fmt.Errorf("区段[%s]未设置所属集中站", section.Id()) 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) amd := component.AxleManageDeviceType.Get(amdEntry)
// //
createAxleSectionEntity(w, section, data) createAxleSectionEntity(w, section, data)

View File

@ -24,8 +24,8 @@ func AxleSectionDrstDrive(w ecs.World, sectionId string, set bool) error {
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]实体不存在", sectionModel.CentralizedStation())) return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]实体不存在", sectionModel.CentralizedStation()))
} }
faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry) faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
axleRuntime, ok := faDcAxleDevice.Adrs[sectionId] axleRuntime := faDcAxleDevice.FindAdr(sectionId)
if !ok { if axleRuntime == nil {
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴设备", sectionModel.CentralizedStation(), sectionId)) return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴设备", sectionModel.CentralizedStation(), sectionId))
} }
axleRuntime.Drst = set axleRuntime.Drst = set

View File

@ -34,7 +34,7 @@ func (s *FaDcAxleDeviceSystem) Update(w ecs.World) {
s.calculateSectionState(sectionState, axleDevice, axleRuntime) s.calculateSectionState(sectionState, axleDevice, axleRuntime)
s.calculateAxleCount(sectionState, axleDevice, axleRuntime) s.calculateAxleCount(sectionState, axleDevice, axleRuntime)
if "北京_12_酒仙桥_12G" == axleSectionId && true { if "北京_12_酒仙桥_12G" == axleSectionId && false {
sectionFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag) sectionFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag)
slog.Info(axleSectionId, slog.Info(axleSectionId,
"Drst", axleRuntime.Drst, "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) { func (s *FaDcAxleDeviceSystem) calculateSectionState(sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
isIdle := axleDevice.Count <= 0 && !axleRuntime.DoingPdrst //区段空闲:区段内车轴数为零且没有预复位 isIdle := axleDevice.Count <= 0 && !axleRuntime.DoingPdrst //区段空闲:区段内车轴数为零且没有预复位
sectionState.Occ = !isIdle sectionState.Occ = !isIdle
} }