iscs bas 大系统
This commit is contained in:
parent
8688c7b371
commit
7bb420cffd
@ -46,16 +46,10 @@ func towPipePortsTransPower(
|
|||||||
breakerPortB *repository.PipePort) {
|
breakerPortB *repository.PipePort) {
|
||||||
//断路器A端连接的管线
|
//断路器A端连接的管线
|
||||||
breakerPortAPipeEntry := wd.EntityMap[breakerPortA.Device().Id()]
|
breakerPortAPipeEntry := wd.EntityMap[breakerPortA.Device().Id()]
|
||||||
if !breakerPortAPipeEntry.HasComponent(component.PipeElectricityType) {
|
breakerPortAPipe := perfectPipeElectricity(breakerPortAPipeEntry)
|
||||||
breakerPortAPipeEntry.AddComponent(component.PipeElectricityType)
|
|
||||||
}
|
|
||||||
breakerPortAPipe := component.PipeElectricityType.Get(breakerPortAPipeEntry)
|
|
||||||
//断路器B端连接的管线
|
//断路器B端连接的管线
|
||||||
breakerPortBPipeEntry := wd.EntityMap[breakerPortB.Device().Id()]
|
breakerPortBPipeEntry := wd.EntityMap[breakerPortB.Device().Id()]
|
||||||
if !breakerPortBPipeEntry.HasComponent(component.PipeElectricityType) {
|
breakerPortBPipe := perfectPipeElectricity(breakerPortBPipeEntry)
|
||||||
breakerPortBPipeEntry.AddComponent(component.PipeElectricityType)
|
|
||||||
}
|
|
||||||
breakerPortBPipe := component.PipeElectricityType.Get(breakerPortBPipeEntry)
|
|
||||||
|
|
||||||
//A->B
|
//A->B
|
||||||
for portAPipePsId, portAPipePs := range breakerPortAPipe.Sources { //A
|
for portAPipePsId, portAPipePs := range breakerPortAPipe.Sources { //A
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"joylink.club/rtsssimulation/repository"
|
"joylink.club/rtsssimulation/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 接地
|
||||||
type EarthingDeviceSystem struct {
|
type EarthingDeviceSystem struct {
|
||||||
query *ecs.Query
|
query *ecs.Query
|
||||||
}
|
}
|
||||||
@ -28,10 +29,7 @@ func (s *EarthingDeviceSystem) Update(w ecs.World) {
|
|||||||
edModel := (wd.Repo.FindById(edId)).(*repository.EarthingDevice)
|
edModel := (wd.Repo.FindById(edId)).(*repository.EarthingDevice)
|
||||||
if edModel.PortA != nil {
|
if edModel.PortA != nil {
|
||||||
edPipeEntry := wd.EntityMap[edModel.PortA.Device().Id()]
|
edPipeEntry := wd.EntityMap[edModel.PortA.Device().Id()]
|
||||||
if !edPipeEntry.HasComponent(component.PipeElectricityType) {
|
edPipe := perfectPipeElectricity(edPipeEntry)
|
||||||
edPipeEntry.AddComponent(component.PipeElectricityType)
|
|
||||||
}
|
|
||||||
edPipe := component.PipeElectricityType.Get(edPipeEntry)
|
|
||||||
ed.Voltage = edPipe.U
|
ed.Voltage = edPipe.U
|
||||||
} else {
|
} else {
|
||||||
ed.Voltage = 0 //零电压
|
ed.Voltage = 0 //零电压
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package iscs_sys
|
package iscs_sys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
"joylink.club/rtsssimulation/component"
|
||||||
"joylink.club/rtsssimulation/entity"
|
"joylink.club/rtsssimulation/entity"
|
||||||
"joylink.club/rtsssimulation/repository"
|
"joylink.club/rtsssimulation/repository"
|
||||||
"log/slog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PipeFittingSystem struct {
|
type PipeFittingSystem struct {
|
||||||
@ -20,11 +18,13 @@ func NewPipeFittingSystem() *PipeFittingSystem {
|
|||||||
func (s *PipeFittingSystem) Update(w ecs.World) {
|
func (s *PipeFittingSystem) Update(w ecs.World) {
|
||||||
wd := entity.GetWorldData(w)
|
wd := entity.GetWorldData(w)
|
||||||
for _, pf := range wd.Repo.PipeFittingMap {
|
for _, pf := range wd.Repo.PipeFittingMap {
|
||||||
if s.initPipeFitting(wd, pf) && s.isPipeFittingEle(wd, pf) {
|
if s.isPipeFittingEle(wd, pf) { //管件为电力管件
|
||||||
//筛选出相对电源
|
//筛选出相对电源
|
||||||
pipePsMap := s.findEleSourcePipe(wd, pf)
|
pipePsMap := s.findEleSourcePipe(wd, pf)
|
||||||
//管件连接的管线间电能传递
|
//管件连接的管线间电能传递
|
||||||
s.transEle(wd, pf, pipePsMap)
|
s.transEle(wd, pf, pipePsMap)
|
||||||
|
} else { //流体管件
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,17 +35,15 @@ func (s *PipeFittingSystem) findEleSourcePipe(wd *component.WorldData, pf *repos
|
|||||||
pipePsMap := make(map[string]*component.ElectricitySource)
|
pipePsMap := make(map[string]*component.ElectricitySource)
|
||||||
for _, pipePort := range pf.Ports() {
|
for _, pipePort := range pf.Ports() {
|
||||||
pipeEntry := wd.EntityMap[pipePort.Device().Id()]
|
pipeEntry := wd.EntityMap[pipePort.Device().Id()]
|
||||||
if pipeEntry.HasComponent(component.PipeElectricityType) {
|
powerPipe := perfectPipeElectricity(pipeEntry)
|
||||||
powerPipe := component.PipeElectricityType.Get(pipeEntry)
|
for epId, ep := range powerPipe.Sources {
|
||||||
for epId, ep := range powerPipe.Sources {
|
pipePs, ok := pipePsMap[epId]
|
||||||
pipePs, ok := pipePsMap[epId]
|
if ok {
|
||||||
if ok {
|
if ep.Fresh > pipePs.Fresh {
|
||||||
if ep.Fresh > pipePs.Fresh {
|
|
||||||
pipePsMap[epId] = ep
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pipePsMap[epId] = ep
|
pipePsMap[epId] = ep
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pipePsMap[epId] = ep
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,7 +55,7 @@ func (s *PipeFittingSystem) transEle(wd *component.WorldData, pf *repository.Pip
|
|||||||
for _, pipePort := range pf.Ports() {
|
for _, pipePort := range pf.Ports() {
|
||||||
for pipePsId, pipePs := range pipePsMap { //相对电源
|
for pipePsId, pipePs := range pipePsMap { //相对电源
|
||||||
pipeEntry := wd.EntityMap[pipePort.Device().Id()]
|
pipeEntry := wd.EntityMap[pipePort.Device().Id()]
|
||||||
powerPipe := component.PipeElectricityType.Get(pipeEntry)
|
powerPipe := perfectPipeElectricity(pipeEntry)
|
||||||
pipePortPs, ok := powerPipe.Sources[pipePsId]
|
pipePortPs, ok := powerPipe.Sources[pipePsId]
|
||||||
if ok {
|
if ok {
|
||||||
if pipePs.Fresh > pipePortPs.Fresh {
|
if pipePs.Fresh > pipePortPs.Fresh {
|
||||||
@ -73,7 +71,7 @@ func (s *PipeFittingSystem) transEle(wd *component.WorldData, pf *repository.Pip
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断该管件是否为连接电线
|
// 与管件连接的管线只要有一个为电线则其他的都为电线
|
||||||
func (s *PipeFittingSystem) isPipeFittingEle(wd *component.WorldData, pf *repository.PipeFitting) bool {
|
func (s *PipeFittingSystem) isPipeFittingEle(wd *component.WorldData, pf *repository.PipeFitting) bool {
|
||||||
for _, pipePort := range pf.Ports() {
|
for _, pipePort := range pf.Ports() {
|
||||||
pipeEntry := wd.EntityMap[pipePort.Device().Id()]
|
pipeEntry := wd.EntityMap[pipePort.Device().Id()]
|
||||||
@ -85,57 +83,9 @@ func (s *PipeFittingSystem) isPipeFittingEle(wd *component.WorldData, pf *reposi
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 由于初始的管线是无性质的,现根据管件的某个已有性质的管线来初始化管件其他的管线
|
// 完善电线实体并获取电线状态
|
||||||
func (s *PipeFittingSystem) initPipeFitting(wd *component.WorldData, pf *repository.PipeFitting) bool {
|
func perfectPipeElectricity(pipeEntry *ecs.Entry) *component.PipeElectricity {
|
||||||
pipeMatter := component.PmtNon
|
component.PipeType.Get(pipeEntry).Matter = component.PmtElectricity
|
||||||
for _, pipePort := range pf.Ports() {
|
|
||||||
pipeEntry := wd.EntityMap[pipePort.Device().Id()]
|
|
||||||
pipe := component.PipeType.Get(pipeEntry)
|
|
||||||
if !pipe.Matter.IsNon() {
|
|
||||||
pipeMatter = pipe.Matter
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
if pipeMatter.IsNon() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
//
|
|
||||||
for _, pipePort := range pf.Ports() {
|
|
||||||
pipeEntry := wd.EntityMap[pipePort.Device().Id()]
|
|
||||||
pipe := component.PipeType.Get(pipeEntry)
|
|
||||||
pipe.Matter = pipeMatter
|
|
||||||
switch pipe.Matter {
|
|
||||||
case component.PmtElectricity:
|
|
||||||
{
|
|
||||||
if !pipeEntry.HasComponent(component.PipeElectricityType) {
|
|
||||||
pipeEntry.AddComponent(component.PipeElectricityType)
|
|
||||||
component.PipeElectricityType.Set(pipeEntry, component.NewPipeElectricity())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case component.PmtAir:
|
|
||||||
fallthrough
|
|
||||||
case component.PmtOil:
|
|
||||||
fallthrough
|
|
||||||
case component.PmtSmoke:
|
|
||||||
fallthrough
|
|
||||||
case component.PmtWater:
|
|
||||||
{
|
|
||||||
if !pipeEntry.HasComponent(component.PipeFluidType) {
|
|
||||||
pipeEntry.AddComponent(component.PipeFluidType)
|
|
||||||
component.PipeFluidType.Set(pipeEntry, component.NewPipeFluid())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
slog.Warn(fmt.Sprintf("PipeFittingSystem.initPipeFitting 未处理的管道物质[%d]", pipe.Matter))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// 从电线实体获取电线
|
|
||||||
func getPipeElectricity(pipeEntry *ecs.Entry) *component.PipeElectricity {
|
|
||||||
if !pipeEntry.HasComponent(component.PipeElectricityType) {
|
if !pipeEntry.HasComponent(component.PipeElectricityType) {
|
||||||
pipeEntry.AddComponent(component.PipeElectricityType)
|
pipeEntry.AddComponent(component.PipeElectricityType)
|
||||||
}
|
}
|
||||||
|
@ -39,13 +39,7 @@ func (s *PowerSourceSystem) Update(w ecs.World) {
|
|||||||
|
|
||||||
func (s *PowerSourceSystem) transPower(wd *component.WorldData, pipeId string, ps *component.ElectricitySource, psId string) {
|
func (s *PowerSourceSystem) transPower(wd *component.WorldData, pipeId string, ps *component.ElectricitySource, psId string) {
|
||||||
pipeEntry := wd.EntityMap[pipeId]
|
pipeEntry := wd.EntityMap[pipeId]
|
||||||
if !pipeEntry.HasComponent(component.PipeElectricityType) {
|
|
||||||
pipeEntry.AddComponent(component.PipeElectricityType)
|
|
||||||
component.PipeElectricityType.Set(pipeEntry, component.NewPipeElectricity())
|
|
||||||
}
|
|
||||||
pipe := component.PipeType.Get(pipeEntry)
|
|
||||||
pipe.Matter = component.PmtElectricity
|
|
||||||
//
|
//
|
||||||
powerPipe := component.PipeElectricityType.Get(pipeEntry)
|
powerPipe := perfectPipeElectricity(pipeEntry)
|
||||||
powerPipe.TransPower(psId, ps)
|
powerPipe.TransPower(psId, ps)
|
||||||
}
|
}
|
||||||
|
@ -45,12 +45,12 @@ func (s *RectifierSystem) rectifierTransPower(wd *component.WorldData, entry *ec
|
|||||||
portF := rectifierModel.PortD //直负
|
portF := rectifierModel.PortD //直负
|
||||||
//
|
//
|
||||||
portLPipeEntry := wd.EntityMap[portL.Device().Id()]
|
portLPipeEntry := wd.EntityMap[portL.Device().Id()]
|
||||||
portLPipe := component.PipeElectricityType.Get(portLPipeEntry)
|
portLPipe := perfectPipeElectricity(portLPipeEntry)
|
||||||
//
|
//
|
||||||
portZPipeEntry := wd.EntityMap[portZ.Device().Id()]
|
portZPipeEntry := wd.EntityMap[portZ.Device().Id()]
|
||||||
portZPipe := component.PipeElectricityType.Get(portZPipeEntry)
|
portZPipe := perfectPipeElectricity(portZPipeEntry)
|
||||||
portFPipeEntry := wd.EntityMap[portF.Device().Id()]
|
portFPipeEntry := wd.EntityMap[portF.Device().Id()]
|
||||||
portFPipe := component.PipeElectricityType.Get(portFPipeEntry)
|
portFPipe := perfectPipeElectricity(portFPipeEntry)
|
||||||
//L->Z、F
|
//L->Z、F
|
||||||
for lpsId, lps := range portLPipe.Sources {
|
for lpsId, lps := range portLPipe.Sources {
|
||||||
if lps.Ac {
|
if lps.Ac {
|
||||||
|
@ -37,20 +37,20 @@ func (s *VoltageTransformerSystem) voltageTransformerTransPower(wd *component.Wo
|
|||||||
//
|
//
|
||||||
vtPortA := vtModel.PortA
|
vtPortA := vtModel.PortA
|
||||||
vtPortAEntry := wd.EntityMap[vtPortA.Device().Id()]
|
vtPortAEntry := wd.EntityMap[vtPortA.Device().Id()]
|
||||||
vtPortAPipe := getPipeElectricity(vtPortAEntry) //变压器一次侧连接的管线
|
vtPortAPipe := perfectPipeElectricity(vtPortAEntry) //变压器一次侧连接的管线
|
||||||
//
|
//
|
||||||
var vtPortBPipe *component.PipeElectricity = nil
|
var vtPortBPipe *component.PipeElectricity = nil
|
||||||
if vtModel.PortB != nil {
|
if vtModel.PortB != nil {
|
||||||
vtPortB := vtModel.PortB
|
vtPortB := vtModel.PortB
|
||||||
vtPortBEntry := wd.EntityMap[vtPortB.Device().Id()]
|
vtPortBEntry := wd.EntityMap[vtPortB.Device().Id()]
|
||||||
vtPortBPipe = getPipeElectricity(vtPortBEntry)
|
vtPortBPipe = perfectPipeElectricity(vtPortBEntry)
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
var vtPortCPipe *component.PipeElectricity = nil
|
var vtPortCPipe *component.PipeElectricity = nil
|
||||||
if vtModel.PortC != nil {
|
if vtModel.PortC != nil {
|
||||||
vtPortC := vtModel.PortC
|
vtPortC := vtModel.PortC
|
||||||
vtPortCEntry := wd.EntityMap[vtPortC.Device().Id()]
|
vtPortCEntry := wd.EntityMap[vtPortC.Device().Id()]
|
||||||
vtPortCPipe = getPipeElectricity(vtPortCEntry)
|
vtPortCPipe = perfectPipeElectricity(vtPortCEntry)
|
||||||
}
|
}
|
||||||
//变压比
|
//变压比
|
||||||
rate := float64(vtModel.E2) / float64(vtModel.E1)
|
rate := float64(vtModel.E2) / float64(vtModel.E1)
|
||||||
|
Loading…
Reference in New Issue
Block a user