Merge branch 'master' of https://git.code.tencent.com/jl-framework/rtss_simulation
This commit is contained in:
commit
207535402e
@ -1 +1 @@
|
||||
Subproject commit 200352eb58f1704a741d367e3c8afd02ae492b58
|
||||
Subproject commit 4997760ffb1284a7898ab84164671d5e21ec9248
|
@ -37,7 +37,7 @@ type PsdCircuitState struct {
|
||||
// PsdCellState 车站屏蔽门子门
|
||||
type PsdCellState struct {
|
||||
//屏蔽门打开的百分比,则0-完全关闭,100-完全打开
|
||||
Rate int
|
||||
Rate int8
|
||||
//关门操作被激活
|
||||
actClosing bool
|
||||
//开门操作被激活
|
||||
@ -59,8 +59,8 @@ type PsdTags struct {
|
||||
queryMap map[EntityTag]*ecs.Query
|
||||
}
|
||||
|
||||
// PsdCellsQuery 屏蔽门子门查询
|
||||
func (me *PsdTags) PsdCellsQuery(tag EntityTag) *ecs.Query {
|
||||
// 屏蔽门子门查询
|
||||
func (me *PsdTags) psdCellsQuery(tag EntityTag) *ecs.Query {
|
||||
if query, ok := me.queryMap[tag]; !ok {
|
||||
query = ecs.NewQuery(filter.Contains(tag))
|
||||
me.queryMap[tag] = query
|
||||
@ -92,6 +92,8 @@ var (
|
||||
PsdCircuitStateComponent = ecs.NewComponentType[PsdCircuitState]()
|
||||
PsdCellStateComponent = ecs.NewComponentType[PsdCellState]()
|
||||
PsdTagsComponent = ecs.NewComponentType[PsdTags]()
|
||||
psdCircuitQuery = ecs.NewQuery(filter.Contains(PsdCircuitStateComponent))
|
||||
psdCellQuery = ecs.NewQuery(filter.Contains(PsdCellStateComponent))
|
||||
)
|
||||
|
||||
// OpenCode 开门码
|
||||
@ -103,6 +105,10 @@ const (
|
||||
OpenCodeUp //运行方向为上行的开门码
|
||||
OpenCodeDown //运行方向为下行的开门码
|
||||
)
|
||||
const (
|
||||
PsdCellRateClosed int8 = 0
|
||||
PsdCellRateOpened int8 = 100
|
||||
)
|
||||
|
||||
// PSD组合类型和继电器功能名称
|
||||
const (
|
||||
@ -121,5 +127,197 @@ const (
|
||||
|
||||
// Update world 执行
|
||||
func (me *PsdsCircuitSystem) Update(w ecs.World) {
|
||||
|
||||
//
|
||||
psdCellQuery.Each(w, func(cellEntry *ecs.Entry) {
|
||||
me.calculateCellMove(w, cellEntry)
|
||||
})
|
||||
//
|
||||
psdCircuitQuery.Each(w, func(psdCircuitEntry *ecs.Entry) {
|
||||
me.calculateSMG(w, psdCircuitEntry)
|
||||
me.calculateXMG(w, psdCircuitEntry)
|
||||
me.calculateSGM(w, psdCircuitEntry)
|
||||
me.calculateXGM(w, psdCircuitEntry)
|
||||
me.calculate4SKM(w, psdCircuitEntry)
|
||||
me.calculate4XKM(w, psdCircuitEntry)
|
||||
me.calculate8SKM(w, psdCircuitEntry)
|
||||
me.calculate8XKM(w, psdCircuitEntry)
|
||||
})
|
||||
}
|
||||
|
||||
// 屏蔽门子门移动运算,暂定门从全关到全开耗时2000ms,则v=50/ms
|
||||
func (me *PsdsCircuitSystem) calculateCellMove(w ecs.World, cellEntry *ecs.Entry) {
|
||||
move := PercentageDeviceStateComponent.Get(cellEntry)
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
cell.Rate = move.GetRate()
|
||||
if cell.actOpening {
|
||||
move.V = 50
|
||||
if cell.Rate >= PsdCellRateOpened { //开门到位
|
||||
move.V = 0
|
||||
}
|
||||
}
|
||||
if cell.actClosing {
|
||||
move.V = -50
|
||||
if cell.Rate <= PsdCellRateClosed { //关门到位
|
||||
move.V = 0
|
||||
}
|
||||
}
|
||||
if !cell.actOpening && !cell.actClosing {
|
||||
move.V = 0
|
||||
}
|
||||
}
|
||||
|
||||
// 车站上行侧所有屏蔽门子门关运算
|
||||
func (me *PsdsCircuitSystem) calculateSMG(w ecs.World, psdCircuitEntry *ecs.Entry) {
|
||||
tags := PsdTagsComponent.Get(psdCircuitEntry)
|
||||
isSMG := true
|
||||
tags.psdCellsQuery(tags.STag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
if isSMG {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
isSMG = cell.Rate <= PsdCellRateClosed
|
||||
}
|
||||
})
|
||||
PsdCircuitStateComponent.Get(psdCircuitEntry).SMGJ = isSMG
|
||||
}
|
||||
|
||||
// 车站下行侧所有屏蔽门子门关运算
|
||||
func (me *PsdsCircuitSystem) calculateXMG(w ecs.World, psdCircuitEntry *ecs.Entry) {
|
||||
tags := PsdTagsComponent.Get(psdCircuitEntry)
|
||||
isXMG := true
|
||||
tags.psdCellsQuery(tags.XTag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
if isXMG {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
isXMG = cell.Rate <= PsdCellRateClosed
|
||||
}
|
||||
})
|
||||
PsdCircuitStateComponent.Get(psdCircuitEntry).XMGJ = isXMG
|
||||
}
|
||||
|
||||
// 车站上行侧关门操作运算
|
||||
func (me *PsdsCircuitSystem) calculateSGM(w ecs.World, psdCircuitEntry *ecs.Entry) {
|
||||
psd := PsdCircuitStateComponent.Get(psdCircuitEntry)
|
||||
if psd.SGMJ && !psd.G4SKMJ && !psd.G8SKMJ {
|
||||
tags := PsdTagsComponent.Get(psdCircuitEntry)
|
||||
tags.psdCellsQuery(tags.STag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
cell.actClosing = cell.Rate > PsdCellRateClosed
|
||||
cell.actOpening = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 车站下行侧关门操作运算
|
||||
func (me *PsdsCircuitSystem) calculateXGM(w ecs.World, psdCircuitEntry *ecs.Entry) {
|
||||
psd := PsdCircuitStateComponent.Get(psdCircuitEntry)
|
||||
if psd.XGMJ && !psd.G4XKMJ && !psd.G8XKMJ {
|
||||
tags := PsdTagsComponent.Get(psdCircuitEntry)
|
||||
tags.psdCellsQuery(tags.XTag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
cell.actClosing = cell.Rate > PsdCellRateClosed
|
||||
cell.actOpening = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 车站上行侧4编组开门操作运算
|
||||
func (me *PsdsCircuitSystem) calculate4SKM(w ecs.World, psdCircuitEntry *ecs.Entry) {
|
||||
psd := PsdCircuitStateComponent.Get(psdCircuitEntry)
|
||||
if psd.G4SKMJ && !psd.G8SKMJ && !psd.SGMJ && psd.SOpenCode != OpenCodeNon {
|
||||
tags := PsdTagsComponent.Get(psdCircuitEntry)
|
||||
switch {
|
||||
case psd.SOpenCode == OpenCodeUp:
|
||||
{
|
||||
tags.psdCellsQuery(tags.S4KmUpTag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
cell.actClosing = false
|
||||
cell.actOpening = cell.Rate < PsdCellRateOpened
|
||||
})
|
||||
}
|
||||
case psd.SOpenCode == OpenCodeDown:
|
||||
{
|
||||
tags.psdCellsQuery(tags.S4KmDownTag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
cell.actClosing = false
|
||||
cell.actOpening = cell.Rate < PsdCellRateOpened
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 车站下行侧4编组开门操作运算
|
||||
func (me *PsdsCircuitSystem) calculate4XKM(w ecs.World, psdCircuitEntry *ecs.Entry) {
|
||||
psd := PsdCircuitStateComponent.Get(psdCircuitEntry)
|
||||
if psd.G4XKMJ && !psd.G8XKMJ && !psd.XGMJ && psd.XOpenCode != OpenCodeNon {
|
||||
tags := PsdTagsComponent.Get(psdCircuitEntry)
|
||||
switch {
|
||||
case psd.XOpenCode == OpenCodeUp:
|
||||
{
|
||||
tags.psdCellsQuery(tags.X4KmUpTag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
cell.actClosing = false
|
||||
cell.actOpening = cell.Rate < PsdCellRateOpened
|
||||
})
|
||||
}
|
||||
case psd.XOpenCode == OpenCodeDown:
|
||||
{
|
||||
tags.psdCellsQuery(tags.X4KmDownTag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
cell.actClosing = false
|
||||
cell.actOpening = cell.Rate < PsdCellRateOpened
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 车站上行侧8编组开门操作运算
|
||||
func (me *PsdsCircuitSystem) calculate8SKM(w ecs.World, psdCircuitEntry *ecs.Entry) {
|
||||
psd := PsdCircuitStateComponent.Get(psdCircuitEntry)
|
||||
if !psd.G4SKMJ && psd.G8SKMJ && !psd.SGMJ && psd.SOpenCode != OpenCodeNon {
|
||||
tags := PsdTagsComponent.Get(psdCircuitEntry)
|
||||
switch {
|
||||
case psd.SOpenCode == OpenCodeUp:
|
||||
{
|
||||
tags.psdCellsQuery(tags.S8KmUpTag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
cell.actClosing = false
|
||||
cell.actOpening = cell.Rate < PsdCellRateOpened
|
||||
})
|
||||
}
|
||||
case psd.SOpenCode == OpenCodeDown:
|
||||
{
|
||||
tags.psdCellsQuery(tags.S8KmDownTag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
cell.actClosing = false
|
||||
cell.actOpening = cell.Rate < PsdCellRateOpened
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 车站下行侧8编组开门操作运算
|
||||
func (me *PsdsCircuitSystem) calculate8XKM(w ecs.World, psdCircuitEntry *ecs.Entry) {
|
||||
psd := PsdCircuitStateComponent.Get(psdCircuitEntry)
|
||||
if !psd.G4XKMJ && psd.G8XKMJ && !psd.XGMJ && psd.XOpenCode != OpenCodeNon {
|
||||
tags := PsdTagsComponent.Get(psdCircuitEntry)
|
||||
switch {
|
||||
case psd.XOpenCode == OpenCodeUp:
|
||||
{
|
||||
tags.psdCellsQuery(tags.X8KmUpTag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
cell.actClosing = false
|
||||
cell.actOpening = cell.Rate < PsdCellRateOpened
|
||||
})
|
||||
}
|
||||
case psd.XOpenCode == OpenCodeDown:
|
||||
{
|
||||
tags.psdCellsQuery(tags.X8KmDownTag).Each(w, func(cellEntry *ecs.Entry) {
|
||||
cell := PsdCellStateComponent.Get(cellEntry)
|
||||
cell.actClosing = false
|
||||
cell.actOpening = cell.Rate < PsdCellRateOpened
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user