计轴
This commit is contained in:
parent
dfe96a977c
commit
846b48ee20
@ -12,54 +12,20 @@ import (
|
||||
//当CI系统给计轴设备发送计轴直接复零/预复零命令时,连续发送一定时间(具体发送时间调试后确定)的复零/预复零命令。
|
||||
//当RAC,RJO,RJT任意一个不为0时,终止发送复零/预复零命令。
|
||||
|
||||
// AxleSection 计轴物理区段状态
|
||||
type AxleSection struct {
|
||||
// PhysicalSectionState 物理区段
|
||||
type PhysicalSectionState struct {
|
||||
//true-占用,false-出清
|
||||
Occ bool
|
||||
}
|
||||
|
||||
// AxleSectionFault 计轴区段故障
|
||||
type AxleSectionFault struct {
|
||||
//true-设置区段故障占用,false-取消区段故障占用
|
||||
SectionFault bool
|
||||
}
|
||||
|
||||
// AxleCounter 计轴区段计轴器
|
||||
type AxleCounter struct {
|
||||
// AxlePhysicalSection 计轴物理区段
|
||||
type AxlePhysicalSection struct {
|
||||
//计轴区段内车轴数
|
||||
Count int
|
||||
//记录Count变化波形
|
||||
countPulse uint8
|
||||
}
|
||||
|
||||
func NewAxleCounter() *AxleCounter {
|
||||
return &AxleCounter{Count: 0, countPulse: 0}
|
||||
}
|
||||
func (c *AxleCounter) UpdateCount(count int) {
|
||||
cp := to1(c.Count)
|
||||
np := to1(count)
|
||||
//
|
||||
if cp != np {
|
||||
c.countPulse <<= 1
|
||||
if np > 0 {
|
||||
c.countPulse |= np
|
||||
}
|
||||
}
|
||||
c.Count = count
|
||||
}
|
||||
func (c *AxleCounter) ResetCountPulse() {
|
||||
c.countPulse = 0x00
|
||||
}
|
||||
func (c *AxleCounter) ShowCountWave() string {
|
||||
return fmt.Sprintf("%08b", c.countPulse)
|
||||
}
|
||||
|
||||
// IsCount010Pulse true-车进入计轴区段后出清计轴区段
|
||||
func (c *AxleCounter) IsCount010Pulse() bool {
|
||||
return c.countPulse&0x01 == 0 && c.countPulse&0x02 > 0 && c.countPulse&0x04 == 0
|
||||
}
|
||||
|
||||
type AxleCounterRuntime struct {
|
||||
type AxleDeviceRuntime struct {
|
||||
//true-计轴复位反馈,表示计轴设备已收到CI系统发送的直接复零/预复零命令。
|
||||
Rac bool
|
||||
//true-运营原因拒绝计轴复位,如区段空闲时下发复位命令;或车轮压住传感器时收到复位命令。
|
||||
@ -76,34 +42,56 @@ type AxleCounterRuntime struct {
|
||||
DoingPdrst bool
|
||||
}
|
||||
|
||||
// FaDcAxleDevice 车站计轴管理设备
|
||||
type FaDcAxleDevice struct {
|
||||
//区段计轴器列表,实体(AxleCounterType,AxleCounterRuntimeType,AxleSectionFlag)
|
||||
Counters []*ecs.Entry
|
||||
//计轴区段实体列表,实体(AxleSectionType,AxleSectionFaultType)
|
||||
Sections []*ecs.Entry
|
||||
//key-section id ,value-counter
|
||||
CounterMap map[string]*ecs.Entry
|
||||
func NewAxleDeviceRuntime() *AxleDeviceRuntime {
|
||||
return &AxleDeviceRuntime{}
|
||||
}
|
||||
|
||||
func (f *FaDcAxleDevice) AddAxleSection(counter *ecs.Entry, section *ecs.Entry) {
|
||||
f.Counters = append(f.Counters, counter)
|
||||
f.Sections = append(f.Sections, section)
|
||||
f.CounterMap[AxleSectionFlag.Get(counter).Id] = counter
|
||||
// AxleManageDevice 计轴管理设备
|
||||
type AxleManageDevice struct {
|
||||
CentralizedStation string //所属集中站
|
||||
Adrs map[string]*AxleDeviceRuntime //key-sectionId
|
||||
}
|
||||
func (f *FaDcAxleDevice) GetAxleCounterEntry(sectionId string) *ecs.Entry {
|
||||
return f.CounterMap[sectionId]
|
||||
|
||||
func NewAxleManageDevice(centralizedStation string) *AxleManageDevice {
|
||||
return &AxleManageDevice{CentralizedStation: centralizedStation, Adrs: make(map[string]*AxleDeviceRuntime)}
|
||||
}
|
||||
|
||||
var (
|
||||
FaDcAxleDeviceType = ecs.NewComponentType[FaDcAxleDevice]()
|
||||
AxleSectionFaultType = ecs.NewComponentType[AxleSectionFault]()
|
||||
AxleSectionType = ecs.NewComponentType[AxleSection]()
|
||||
AxleCounterType = ecs.NewComponentType[AxleCounter]()
|
||||
AxleCounterRuntimeType = ecs.NewComponentType[AxleCounterRuntime]()
|
||||
AxleSectionFlag = ecs.NewComponentType[Uid]() //计轴区段id
|
||||
PhysicalSectionStateType = ecs.NewComponentType[PhysicalSectionState]()
|
||||
AxlePhysicalSectionType = ecs.NewComponentType[AxlePhysicalSection]()
|
||||
AxleSectionFaultTag = ecs.NewTag()
|
||||
AxleManageDeviceType = ecs.NewComponentType[AxleManageDevice]()
|
||||
)
|
||||
|
||||
/////////////////////////////AxlePhysicalSection/////////////////////////////////
|
||||
|
||||
func NewAxlePhysicalSection() *AxlePhysicalSection {
|
||||
return &AxlePhysicalSection{Count: 0, countPulse: 0}
|
||||
}
|
||||
func (c *AxlePhysicalSection) UpdateCount(count int) {
|
||||
cp := to1(c.Count)
|
||||
np := to1(count)
|
||||
//
|
||||
if cp != np {
|
||||
c.countPulse <<= 1
|
||||
if np > 0 {
|
||||
c.countPulse |= np
|
||||
}
|
||||
}
|
||||
c.Count = count
|
||||
}
|
||||
func (c *AxlePhysicalSection) ResetCountPulse() {
|
||||
c.countPulse = 0x00
|
||||
}
|
||||
func (c *AxlePhysicalSection) ShowCountWave() string {
|
||||
return fmt.Sprintf("%08b", c.countPulse)
|
||||
}
|
||||
|
||||
// IsCount010Pulse true-车进入计轴区段后出清计轴区段
|
||||
func (c *AxlePhysicalSection) IsCount010Pulse() bool {
|
||||
return c.countPulse&0x01 == 0 && c.countPulse&0x02 > 0 && c.countPulse&0x04 == 0
|
||||
}
|
||||
|
||||
// 归1
|
||||
func to1(c int) uint8 {
|
||||
if c > 0 {
|
@ -21,6 +21,8 @@ type WorldData struct {
|
||||
EntityMap map[string]*ecs.Entry
|
||||
// 联锁驱采卡实体
|
||||
CiQcEntities []*ecs.Entry
|
||||
// 集中站计轴管理设备实体
|
||||
AxleManageDeviceEntities []*ecs.Entry
|
||||
}
|
||||
|
||||
// 是否在驱动码表中
|
||||
|
@ -8,6 +8,13 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func newAxleManageDevice(w ecs.World, data *component.WorldData, centralizedStation string) *ecs.Entry {
|
||||
entry := w.Entry(w.Create(component.AxleManageDeviceType))
|
||||
component.AxleManageDeviceType.Set(entry, component.NewAxleManageDevice(centralizedStation))
|
||||
data.AxleManageDeviceEntities = append(data.AxleManageDeviceEntities, entry)
|
||||
return entry
|
||||
}
|
||||
|
||||
// LoadAxlePhysicalSections 加载计轴区段
|
||||
func LoadAxlePhysicalSections(w ecs.World) error {
|
||||
data := GetWorldData(w)
|
||||
@ -17,35 +24,24 @@ func LoadAxlePhysicalSections(w ecs.World) error {
|
||||
if len(strings.TrimSpace(section.CentralizedStation())) == 0 {
|
||||
return fmt.Errorf("区段[%s]未设置所属集中站", section.Id())
|
||||
}
|
||||
//fmt.Println("=====>>>>>计轴区段:", section.Id())
|
||||
fadcDeviceId := CreateFaDcAxleDeviceId(section.CentralizedStation())
|
||||
fadcDeviceEntry, find := data.EntityMap[fadcDeviceId]
|
||||
if !find {
|
||||
fadcDeviceEntry = createFadcDeviceEntity(w, section, data)
|
||||
data.EntityMap[fadcDeviceId] = fadcDeviceEntry
|
||||
}
|
||||
fadcDevice := component.FaDcAxleDeviceType.Get(fadcDeviceEntry)
|
||||
counter := createAxleCounterEntity(w, section, data)
|
||||
axleSec := createAxleSectionEntity(w, section, data)
|
||||
fadcDevice.AddAxleSection(counter, axleSec)
|
||||
amdEntry := newAxleManageDevice(w, data, section.CentralizedStation())
|
||||
amd := component.AxleManageDeviceType.Get(amdEntry)
|
||||
//
|
||||
createAxleSectionEntity(w, section, data)
|
||||
//
|
||||
amd.Adrs[section.Id()] = component.NewAxleDeviceRuntime()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 联锁集中站计轴管理设备实体
|
||||
func createFadcDeviceEntity(w ecs.World, axleSection *repository.PhysicalSection, worldData *component.WorldData) *ecs.Entry {
|
||||
uid := CreateFaDcAxleDeviceId(axleSection.CentralizedStation())
|
||||
entry, ok := worldData.EntityMap[uid]
|
||||
if !ok {
|
||||
entry = w.Entry(w.Create(component.UidType, component.FaDcAxleDeviceType))
|
||||
//
|
||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||
component.FaDcAxleDeviceType.Set(entry, &component.FaDcAxleDevice{CounterMap: make(map[string]*ecs.Entry)})
|
||||
//
|
||||
worldData.EntityMap[uid] = entry
|
||||
func FindAxleManageDevice(data *component.WorldData, centralizedStation string) *ecs.Entry {
|
||||
for _, entry := range data.AxleManageDeviceEntities {
|
||||
amd := component.AxleManageDeviceType.Get(entry)
|
||||
if amd != nil && amd.CentralizedStation == centralizedStation {
|
||||
return entry
|
||||
}
|
||||
}
|
||||
return entry
|
||||
return nil
|
||||
}
|
||||
|
||||
// 计轴区段实体
|
||||
@ -53,27 +49,13 @@ func createAxleSectionEntity(w ecs.World, axleSection *repository.PhysicalSectio
|
||||
uid := axleSection.Id()
|
||||
entry, ok := worldData.EntityMap[uid]
|
||||
if !ok {
|
||||
entry = w.Entry(w.Create(component.UidType, component.AxleSectionType, component.AxleSectionFaultType))
|
||||
entry = w.Entry(w.Create(component.UidType, component.PhysicalSectionStateType, component.AxlePhysicalSectionType))
|
||||
//
|
||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||
component.AxleSectionType.Set(entry, &component.AxleSection{Occ: false})
|
||||
component.AxleSectionFaultType.Set(entry, &component.AxleSectionFault{SectionFault: false})
|
||||
component.PhysicalSectionStateType.Set(entry, &component.PhysicalSectionState{Occ: false})
|
||||
component.AxlePhysicalSectionType.Set(entry, component.NewAxlePhysicalSection())
|
||||
//
|
||||
worldData.EntityMap[uid] = entry
|
||||
}
|
||||
return entry
|
||||
}
|
||||
|
||||
// 计轴器实体
|
||||
func createAxleCounterEntity(w ecs.World, axleSection *repository.PhysicalSection, worldData *component.WorldData) *ecs.Entry {
|
||||
entry := w.Entry(w.Create(component.AxleCounterType, component.AxleCounterRuntimeType, component.AxleSectionFlag))
|
||||
component.AxleCounterType.Set(entry, component.NewAxleCounter())
|
||||
component.AxleCounterRuntimeType.Set(entry, &component.AxleCounterRuntime{Rac: false, Rjo: false, Rjt: false, Drst: false, Pdrst: false, DoingPdrst: false})
|
||||
component.AxleSectionFlag.SetValue(entry, component.Uid{Id: axleSection.Id()})
|
||||
return entry
|
||||
}
|
||||
|
||||
// CreateFaDcAxleDeviceId 设备集中站计轴管理设备id(通过联锁集中站centralizedStation来构建)
|
||||
func CreateFaDcAxleDeviceId(centralizedStation string) string {
|
||||
return fmt.Sprintf("fadc-axle-device-%s", centralizedStation)
|
||||
}
|
||||
|
@ -18,17 +18,16 @@ func AxleSectionDrstDrive(w ecs.World, sectionId string, set bool) error {
|
||||
return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
|
||||
}
|
||||
//
|
||||
faDcAxleDeviceId := entity.CreateFaDcAxleDeviceId(sectionModel.CentralizedStation())
|
||||
faDcAxleDeviceEntry, ok := wd.EntityMap[faDcAxleDeviceId]
|
||||
faDcAxleDeviceEntry := entity.FindAxleManageDevice(wd, sectionModel.CentralizedStation())
|
||||
|
||||
if faDcAxleDeviceEntry == nil {
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]实体不存在", sectionModel.CentralizedStation()))
|
||||
}
|
||||
faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
|
||||
axleRuntime, ok := faDcAxleDevice.Adrs[sectionId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]不存实体", faDcAxleDeviceId))
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴设备", sectionModel.CentralizedStation(), sectionId))
|
||||
}
|
||||
//
|
||||
axleCounterEntry := component.FaDcAxleDeviceType.Get(faDcAxleDeviceEntry).GetAxleCounterEntry(sectionId)
|
||||
if axleCounterEntry == nil {
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴器实体", faDcAxleDeviceId, sectionId))
|
||||
}
|
||||
axleRuntime := component.AxleCounterRuntimeType.Get(axleCounterEntry)
|
||||
axleRuntime.Drst = set
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
@ -47,17 +46,16 @@ func AxleSectionPdrstDrive(w ecs.World, sectionId string, set bool) error {
|
||||
return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
|
||||
}
|
||||
//
|
||||
faDcAxleDeviceId := entity.CreateFaDcAxleDeviceId(sectionModel.CentralizedStation())
|
||||
faDcAxleDeviceEntry, ok := wd.EntityMap[faDcAxleDeviceId]
|
||||
faDcAxleDeviceEntry := entity.FindAxleManageDevice(wd, sectionModel.CentralizedStation())
|
||||
|
||||
if faDcAxleDeviceEntry == nil {
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]实体不存在", sectionModel.CentralizedStation()))
|
||||
}
|
||||
faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
|
||||
axleRuntime, ok := faDcAxleDevice.Adrs[sectionId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]不存实体", faDcAxleDeviceId))
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴设备", sectionModel.CentralizedStation(), sectionId))
|
||||
}
|
||||
//
|
||||
axleCounterEntry := component.FaDcAxleDeviceType.Get(faDcAxleDeviceEntry).GetAxleCounterEntry(sectionId)
|
||||
if axleCounterEntry == nil {
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴器实体", faDcAxleDeviceId, sectionId))
|
||||
}
|
||||
axleRuntime := component.AxleCounterRuntimeType.Get(axleCounterEntry)
|
||||
axleRuntime.Pdrst = set
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
@ -76,26 +74,21 @@ func AxleSectionFaultOccDrive(w ecs.World, sectionId string, set bool) error {
|
||||
return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
|
||||
}
|
||||
//
|
||||
faDcAxleDeviceId := entity.CreateFaDcAxleDeviceId(sectionModel.CentralizedStation())
|
||||
faDcAxleDeviceEntry, ok := wd.EntityMap[faDcAxleDeviceId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]不存实体", faDcAxleDeviceId))
|
||||
sectionEntry := wd.EntityMap[sectionId]
|
||||
if sectionEntry == nil {
|
||||
return ecs.NewErrResult(fmt.Errorf("区段[%s]实体不存在", sectionId))
|
||||
}
|
||||
//
|
||||
axleCounterEntry := component.FaDcAxleDeviceType.Get(faDcAxleDeviceEntry).GetAxleCounterEntry(sectionId)
|
||||
axleCounter := component.AxleCounterType.Get(axleCounterEntry)
|
||||
//
|
||||
sectionEntry, ok := wd.EntityMap[sectionId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴区段[%s]不存实体", sectionId))
|
||||
}
|
||||
sectionFault := component.AxleSectionFaultType.Get(sectionEntry)
|
||||
//计轴故障设置
|
||||
sectionFault.SectionFault = set
|
||||
if set {
|
||||
axleCounter.UpdateCount(1)
|
||||
} else {
|
||||
axleCounter.UpdateCount(0)
|
||||
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()
|
||||
@ -114,21 +107,15 @@ func AxleSectionTrainDrive(w ecs.World, sectionId string, trainIn bool) error {
|
||||
return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
|
||||
}
|
||||
//
|
||||
faDcAxleDeviceId := entity.CreateFaDcAxleDeviceId(sectionModel.CentralizedStation())
|
||||
faDcAxleDeviceEntry, ok := wd.EntityMap[faDcAxleDeviceId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]不存实体", faDcAxleDeviceId))
|
||||
sectionEntry := wd.EntityMap[sectionId]
|
||||
if sectionEntry == nil {
|
||||
return ecs.NewErrResult(fmt.Errorf("区段[%s]实体不存在", sectionId))
|
||||
}
|
||||
//
|
||||
axleCounterEntry := component.FaDcAxleDeviceType.Get(faDcAxleDeviceEntry).GetAxleCounterEntry(sectionId)
|
||||
if axleCounterEntry == nil {
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴器实体", faDcAxleDeviceId, sectionId))
|
||||
}
|
||||
axleCounter := component.AxleCounterType.Get(axleCounterEntry)
|
||||
axleDevice := component.AxlePhysicalSectionType.Get(sectionEntry)
|
||||
if trainIn {
|
||||
axleCounter.UpdateCount(1)
|
||||
axleDevice.UpdateCount(1)
|
||||
} else {
|
||||
axleCounter.UpdateCount(0)
|
||||
axleDevice.UpdateCount(0)
|
||||
}
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
@ -15,92 +16,84 @@ type FaDcAxleDeviceSystem struct {
|
||||
|
||||
func NewFaDcAxleDeviceSystem() *FaDcAxleDeviceSystem {
|
||||
return &FaDcAxleDeviceSystem{
|
||||
query: ecs.NewQuery(filter.Contains(component.FaDcAxleDeviceType)),
|
||||
query: ecs.NewQuery(filter.Contains(component.AxleManageDeviceType)),
|
||||
}
|
||||
}
|
||||
func (s *FaDcAxleDeviceSystem) Update(w ecs.World) {
|
||||
data := entity.GetWorldData(w)
|
||||
s.query.Each(w, func(entry *donburi.Entry) {
|
||||
faDcDevice := component.FaDcAxleDeviceType.Get(entry)
|
||||
for _, axleSectionEntry := range faDcDevice.Sections {
|
||||
axleSectionId := component.UidType.Get(axleSectionEntry).Id
|
||||
axleCounterEntry := faDcDevice.CounterMap[axleSectionId]
|
||||
faDcDevice := component.AxleManageDeviceType.Get(entry)
|
||||
for axleSectionId, axleRuntime := range faDcDevice.Adrs {
|
||||
axleSectionEntry := data.EntityMap[axleSectionId]
|
||||
sectionState := component.PhysicalSectionStateType.Get(axleSectionEntry)
|
||||
axleDevice := component.AxlePhysicalSectionType.Get(axleSectionEntry)
|
||||
//
|
||||
s.calculateHf(axleCounterEntry, axleSectionEntry)
|
||||
s.calculateDrst(axleCounterEntry)
|
||||
s.calculatePdrst(axleCounterEntry)
|
||||
s.calculateSectionState(axleCounterEntry, axleSectionEntry)
|
||||
s.calculateAxleCount(axleCounterEntry, axleSectionEntry)
|
||||
s.calculateHf(axleSectionEntry, sectionState, axleDevice, axleRuntime)
|
||||
s.calculateDrst(sectionState, axleDevice, axleRuntime)
|
||||
s.calculatePdrst(sectionState, axleDevice, axleRuntime)
|
||||
s.calculateSectionState(sectionState, axleDevice, axleRuntime)
|
||||
s.calculateAxleCount(sectionState, axleDevice, axleRuntime)
|
||||
|
||||
if "北京_12_酒仙桥_12G" == axleSectionId && false {
|
||||
section := component.AxleSectionType.Get(axleSectionEntry)
|
||||
counter := component.AxleCounterType.Get(axleCounterEntry)
|
||||
counterRt := component.AxleCounterRuntimeType.Get(axleCounterEntry)
|
||||
sectionFault := component.AxleSectionFaultType.Get(axleSectionEntry)
|
||||
if "北京_12_酒仙桥_12G" == axleSectionId && true {
|
||||
sectionFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag)
|
||||
slog.Info(axleSectionId,
|
||||
"Drst", counterRt.Drst,
|
||||
"Pdrst", counterRt.Pdrst,
|
||||
"DoingPdrst", counterRt.DoingPdrst,
|
||||
"Rac", counterRt.Rac,
|
||||
"Rjo", counterRt.Rjo,
|
||||
"Rjt", counterRt.Rjt,
|
||||
"SectionFault", sectionFault.SectionFault,
|
||||
"Occ", section.Occ,
|
||||
"Count", counter.Count,
|
||||
"Wave", counter.ShowCountWave())
|
||||
"Drst", axleRuntime.Drst,
|
||||
"Pdrst", axleRuntime.Pdrst,
|
||||
"DoingPdrst", axleRuntime.DoingPdrst,
|
||||
"Rac", axleRuntime.Rac,
|
||||
"Rjo", axleRuntime.Rjo,
|
||||
"Rjt", axleRuntime.Rjt,
|
||||
"SectionFault", sectionFault,
|
||||
"Occ", sectionState.Occ,
|
||||
"Count", axleDevice.Count,
|
||||
"Wave", axleDevice.ShowCountWave())
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 计算计轴区段内车轴数
|
||||
// 目前通过查看有哪些车在该计轴区段内实现,定性
|
||||
func (s *FaDcAxleDeviceSystem) calculateAxleCount(axleCounterEntry *donburi.Entry, axleSectionEntry *donburi.Entry) {
|
||||
func (s *FaDcAxleDeviceSystem) calculateAxleCount(sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
|
||||
//检查该区段内有没有车
|
||||
// ...todo
|
||||
}
|
||||
|
||||
// 计算计轴区段状态
|
||||
func (s *FaDcAxleDeviceSystem) calculateSectionState(axleCounterEntry *donburi.Entry, axleSectionEntry *donburi.Entry) {
|
||||
section := component.AxleSectionType.Get(axleSectionEntry)
|
||||
counter := component.AxleCounterType.Get(axleCounterEntry)
|
||||
counterRt := component.AxleCounterRuntimeType.Get(axleCounterEntry)
|
||||
isIdle := counter.Count <= 0 && !counterRt.DoingPdrst //区段空闲:区段内车轴数为零且没有预复位
|
||||
section.Occ = !isIdle
|
||||
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) calculateDrst(axleCounterEntry *donburi.Entry) {
|
||||
counter := component.AxleCounterType.Get(axleCounterEntry)
|
||||
counterRt := component.AxleCounterRuntimeType.Get(axleCounterEntry)
|
||||
if counterRt.Drst && !counterRt.Rjo && !counterRt.Rjt { //直接复位且没有拒绝原因
|
||||
counter.UpdateCount(0)
|
||||
counter.ResetCountPulse()
|
||||
counterRt.DoingPdrst = false
|
||||
func (s *FaDcAxleDeviceSystem) calculateDrst(sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
|
||||
|
||||
if axleRuntime.Drst && !axleRuntime.Rjo && !axleRuntime.Rjt { //直接复位且没有拒绝原因
|
||||
axleDevice.UpdateCount(0)
|
||||
axleDevice.ResetCountPulse()
|
||||
axleRuntime.DoingPdrst = false
|
||||
}
|
||||
}
|
||||
|
||||
// 计轴预复位
|
||||
func (s *FaDcAxleDeviceSystem) calculatePdrst(axleCounterEntry *donburi.Entry) {
|
||||
counter := component.AxleCounterType.Get(axleCounterEntry)
|
||||
counterRt := component.AxleCounterRuntimeType.Get(axleCounterEntry)
|
||||
if counterRt.Pdrst && !counterRt.Rjo && !counterRt.Rjt && !counterRt.DoingPdrst { //预复位且没有拒绝原因
|
||||
counter.UpdateCount(0)
|
||||
counter.ResetCountPulse()
|
||||
counterRt.DoingPdrst = true
|
||||
func (s *FaDcAxleDeviceSystem) calculatePdrst(sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
|
||||
|
||||
if axleRuntime.Pdrst && !axleRuntime.Rjo && !axleRuntime.Rjt && !axleRuntime.DoingPdrst { //预复位且没有拒绝原因
|
||||
axleDevice.UpdateCount(0)
|
||||
axleDevice.ResetCountPulse()
|
||||
axleRuntime.DoingPdrst = true
|
||||
}
|
||||
//压道车通过该计轴区段,完成计轴预复位
|
||||
if counter.IsCount010Pulse() {
|
||||
counterRt.DoingPdrst = false
|
||||
if axleDevice.IsCount010Pulse() {
|
||||
axleRuntime.DoingPdrst = false
|
||||
}
|
||||
}
|
||||
|
||||
// 复位回复运算
|
||||
func (s *FaDcAxleDeviceSystem) calculateHf(axleCounterEntry *donburi.Entry, axleSectionEntry *donburi.Entry) {
|
||||
section := component.AxleSectionType.Get(axleSectionEntry)
|
||||
sectionFault := component.AxleSectionFaultType.Get(axleSectionEntry)
|
||||
counterRt := component.AxleCounterRuntimeType.Get(axleCounterEntry)
|
||||
counterRt.Rac = counterRt.Drst || counterRt.Pdrst
|
||||
counterRt.Rjo = counterRt.Rac && !section.Occ && !counterRt.DoingPdrst //空闲拒绝复位(排除预复位过程中)
|
||||
counterRt.Rjt = counterRt.Rac && sectionFault.SectionFault // 技术原因拒绝复位
|
||||
func (s *FaDcAxleDeviceSystem) calculateHf(axleSectionEntry *ecs.Entry, sectionState *component.PhysicalSectionState, axleDevice *component.AxlePhysicalSection, axleRuntime *component.AxleDeviceRuntime) {
|
||||
sectionFault := axleSectionEntry.HasComponent(component.AxleSectionFaultTag)
|
||||
axleRuntime.Rac = axleRuntime.Drst || axleRuntime.Pdrst
|
||||
axleRuntime.Rjo = axleRuntime.Rac && !sectionState.Occ && !axleRuntime.DoingPdrst //空闲拒绝复位(排除预复位过程中)
|
||||
axleRuntime.Rjt = axleRuntime.Rac && sectionFault // 技术原因拒绝复位
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user