103 lines
3.2 KiB
Go
103 lines
3.2 KiB
Go
package entities
|
|
|
|
import (
|
|
"joylink.club/ecs"
|
|
"joylink.club/rtsssimulation/deprecated/system"
|
|
)
|
|
|
|
// CreatePsdCircuitEntity 创建车站屏蔽门电路实体
|
|
func CreatePsdCircuitEntity(w ecs.World, psdCircuitId string, psd system.IPsdModel) *ecs.Entry {
|
|
e := w.Create(system.EntityIdentityComponent, system.PsdCircuitStateComponent, system.PsdTagsComponent)
|
|
system.EntityIdentityComponent.Set(e, &system.EntityIdentity{Id: psdCircuitId})
|
|
system.PsdCircuitStateComponent.Set(e, system.NewPsdCircuitState())
|
|
system.PsdTagsComponent.Set(e, system.NewPsdTags())
|
|
//
|
|
type psdCell struct {
|
|
id string
|
|
STag bool //上行侧屏蔽门子门标签
|
|
S4KmUpTag bool //上行侧4编组运行方向上行时屏蔽门子门标签
|
|
S4KmDownTag bool //上行侧4编组运行方向下行时屏蔽门子门标签
|
|
S8KmUpTag bool //上行侧8编组运行方向上行时屏蔽门子门标签
|
|
S8KmDownTag bool //上行侧8编组运行方向下行时屏蔽门子门标签
|
|
XTag bool
|
|
X4KmUpTag bool
|
|
X4KmDownTag bool
|
|
X8KmUpTag bool
|
|
X8KmDownTag bool
|
|
}
|
|
psdCellsMap := make(map[string]*psdCell)
|
|
//
|
|
for _, pc := range psd.FindSPsdCells() {
|
|
cell := &psdCell{id: pc.Id(), STag: true}
|
|
psdCellsMap[cell.id] = cell
|
|
}
|
|
for _, pc := range psd.FindXPsdCells() {
|
|
cell := &psdCell{id: pc.Id(), XTag: true}
|
|
psdCellsMap[cell.id] = cell
|
|
}
|
|
for _, pc := range psd.FindS4KmUpPsdCells() {
|
|
psdCellsMap[pc.Id()].S4KmUpTag = true
|
|
}
|
|
for _, pc := range psd.FindS4KmDownPsdCells() {
|
|
psdCellsMap[pc.Id()].S4KmDownTag = true
|
|
}
|
|
for _, pc := range psd.FindS8KmUpPsdCells() {
|
|
psdCellsMap[pc.Id()].S8KmUpTag = true
|
|
}
|
|
for _, pc := range psd.FindS8KmDownPsdCells() {
|
|
psdCellsMap[pc.Id()].S8KmDownTag = true
|
|
}
|
|
for _, pc := range psd.FindX4KmUpPsdCells() {
|
|
psdCellsMap[pc.Id()].X4KmUpTag = true
|
|
}
|
|
for _, pc := range psd.FindX4KmDownPsdCells() {
|
|
psdCellsMap[pc.Id()].X4KmDownTag = true
|
|
}
|
|
for _, pc := range psd.FindX8KmUpPsdCells() {
|
|
psdCellsMap[pc.Id()].X8KmUpTag = true
|
|
}
|
|
for _, pc := range psd.FindX8KmDownPsdCells() {
|
|
psdCellsMap[pc.Id()].X8KmDownTag = true
|
|
}
|
|
//
|
|
tags := system.PsdTagsComponent.Get(e)
|
|
for cellId, cell := range psdCellsMap {
|
|
cellEntry := w.Create(system.EntityIdentityComponent, system.PsdCellStateComponent, system.PercentageDeviceStateComponent)
|
|
system.EntityIdentityComponent.Set(cellEntry, &system.EntityIdentity{Id: cellId})
|
|
system.PsdCellStateComponent.Set(cellEntry, system.NewPsdCellState())
|
|
system.PercentageDeviceStateComponent.Set(cellEntry, system.NewPercentageDeviceStateL()) //默认关门状态
|
|
if cell.STag {
|
|
cellEntry.AddComponent(tags.STag)
|
|
}
|
|
if cell.S4KmUpTag {
|
|
cellEntry.AddComponent(tags.S4KmUpTag)
|
|
}
|
|
if cell.S4KmDownTag {
|
|
cellEntry.AddComponent(tags.S4KmDownTag)
|
|
}
|
|
if cell.S8KmUpTag {
|
|
cellEntry.AddComponent(tags.S8KmUpTag)
|
|
}
|
|
if cell.S8KmDownTag {
|
|
cellEntry.AddComponent(tags.S8KmDownTag)
|
|
}
|
|
if cell.XTag {
|
|
cellEntry.AddComponent(tags.XTag)
|
|
}
|
|
if cell.X4KmUpTag {
|
|
cellEntry.AddComponent(tags.X4KmUpTag)
|
|
}
|
|
if cell.X4KmDownTag {
|
|
cellEntry.AddComponent(tags.X4KmDownTag)
|
|
}
|
|
if cell.X8KmUpTag {
|
|
cellEntry.AddComponent(tags.X8KmUpTag)
|
|
}
|
|
if cell.X8KmDownTag {
|
|
cellEntry.AddComponent(tags.X8KmDownTag)
|
|
}
|
|
}
|
|
//
|
|
return e
|
|
}
|