This commit is contained in:
weizhihong 2023-10-24 17:58:36 +08:00
commit f1b9e1502f
3 changed files with 37 additions and 21 deletions

View File

@ -49,13 +49,26 @@ type AxleSectionRuntime struct {
//true-压道车进入计轴区段
CountTrainInPulse bool
//计轴区段内车轴数
Count int16
//Count变化前的数据
CountLast int16
count int16
}
func (s *AxleSectionRuntime) UpdateCountAndPulse(count int16) {
if !s.CountTrainInPulse {
s.CountTrainInPulse = s.count <= 0 && count > 0
}
if !s.CountTrainOutPulse {
s.CountTrainOutPulse = s.count > 0 && count <= 0
}
s.count = count
}
func (s *AxleSectionRuntime) Count() int16 {
return s.count
}
func (s *AxleSectionRuntime) SetCount(count int16) {
s.count = count
}
func NewAxleSectionRuntime() *AxleSectionRuntime {
return &AxleSectionRuntime{DoingPdrst: false, CountTrainInPulse: false, CountTrainOutPulse: false, Count: 0, CountLast: 0}
return &AxleSectionRuntime{DoingPdrst: false, CountTrainInPulse: false, CountTrainOutPulse: false, count: 0}
}
var (

View File

@ -13,7 +13,7 @@ func DriveAxleSectionTrainIn(w ecs.World, axleSectionId string) {
sectionEntry, ok := wd.EntityMap[axleSectionId]
if ok {
rt := component.AxleSectionRuntimeType.Get(sectionEntry)
rt.Count = 1
rt.UpdateCountAndPulse(1)
}
})
}
@ -25,7 +25,7 @@ func DriveAxleSectionTrainOut(w ecs.World, axleSectionId string) {
sectionEntry, ok := wd.EntityMap[axleSectionId]
if ok {
rt := component.AxleSectionRuntimeType.Get(sectionEntry)
rt.Count = 0
rt.UpdateCountAndPulse(0)
}
})
}

View File

@ -22,7 +22,19 @@ func (s *AxleSectionSystem) Update(w ecs.World) {
s.calculateDrst(entry)
s.calculatePdrst(entry)
s.calculateSectionState(entry)
s.calculateHf(entry)
s.calculateAxleCount(entry)
/*
{
if component.UidType.Get(entry).Id == "北京_12_酒仙桥_6G" {
state := component.AxleSectionStateType.Get(entry)
device := component.AxleSectionDeviceType.Get(entry)
rt := component.AxleSectionRuntimeType.Get(entry)
fmt.Printf("===>>计轴区段(北京_12_酒仙桥_6G): Clr=%t, Occ=%t, Drst=%t, Pdrst=%t, Rac=%t, Rjo=%t, Rjt=%t, Count=%d Pdrsting=%t\n",
state.Clr, state.Occ, device.Drst, device.Pdrst, device.Rac, device.Rjo, device.Rjt, rt.Count(), rt.DoingPdrst)
}
}
*/
})
}
@ -38,7 +50,7 @@ func (s *AxleSectionSystem) calculateAxleCount(entry *donburi.Entry) {
func (s *AxleSectionSystem) calculateSectionState(entry *donburi.Entry) {
state := component.AxleSectionStateType.Get(entry)
rt := component.AxleSectionRuntimeType.Get(entry)
isIdle := rt.Count <= 0 && !rt.DoingPdrst //区段空闲:区段内车轴数为零且没有预复位
isIdle := rt.Count() <= 0 && !rt.DoingPdrst //区段空闲:区段内车轴数为零且没有预复位
state.Clr = isIdle
state.Occ = !isIdle
}
@ -48,8 +60,7 @@ func (s *AxleSectionSystem) calculateDrst(entry *donburi.Entry) {
device := component.AxleSectionDeviceType.Get(entry)
rt := component.AxleSectionRuntimeType.Get(entry)
if device.Drst && !device.Rjo && !device.Rjt { //直接复位且没有拒绝原因
rt.Count = 0
rt.CountLast = 0
rt.SetCount(0)
rt.DoingPdrst = false
rt.CountTrainOutPulse = false
rt.CountTrainInPulse = false
@ -61,20 +72,11 @@ func (s *AxleSectionSystem) calculatePdrst(entry *donburi.Entry) {
device := component.AxleSectionDeviceType.Get(entry)
rt := component.AxleSectionRuntimeType.Get(entry)
if device.Pdrst && !device.Rjo && !device.Rjt && !rt.DoingPdrst { //预复位且没有拒绝原因
rt.Count = 0
rt.CountLast = 0
rt.SetCount(0)
rt.DoingPdrst = true
rt.CountTrainOutPulse = false
rt.CountTrainInPulse = false
}
//压道车计算
if !rt.CountTrainInPulse { //计算压道车进入该计轴区段
rt.CountTrainInPulse = rt.CountLast <= 0 && rt.Count > 0
}
if !rt.CountTrainOutPulse { //计算压道车离开该计轴区段
rt.CountTrainOutPulse = rt.CountLast > 0 && rt.Count <= 0
}
rt.CountLast = rt.Count
//压道车通过该计轴区段,完成计轴预复位
if rt.CountTrainInPulse && rt.CountTrainOutPulse {
rt.DoingPdrst = false
@ -85,7 +87,8 @@ func (s *AxleSectionSystem) calculatePdrst(entry *donburi.Entry) {
func (s *AxleSectionSystem) calculateHf(entry *donburi.Entry) {
device := component.AxleSectionDeviceType.Get(entry)
state := component.AxleSectionStateType.Get(entry)
rt := component.AxleSectionRuntimeType.Get(entry)
device.Rac = device.Drst || device.Pdrst
device.Rjo = state.Clr && !state.Occ //空闲拒绝复位
device.Rjt = false // 技术原因拒绝复位
device.Rjo = device.Rac && state.Clr && !state.Occ && !rt.DoingPdrst //空闲拒绝复位(排除预复位过程中)
device.Rjt = false // 技术原因拒绝复位
}