iscs pscada 一次图 电力传递实现
This commit is contained in:
parent
648c8c4554
commit
b4fbfaad78
@ -284,12 +284,13 @@ func (p *DisconnectorPort) Device() PortedDevice {
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
// VoltageTransformer 变压器模型
|
||||
// 一次侧端口A,二次侧端口B或C
|
||||
// 一次侧端口A,二次侧端口B为L火线端口,二次侧端口C如果存在则为N零线端口
|
||||
// 通过标定电动势计算变压比
|
||||
type VoltageTransformer struct {
|
||||
Identity
|
||||
Code string
|
||||
E1 uint32 //一次侧电动势,单位V
|
||||
E2 uint32 //二次侧电动势,单位V
|
||||
E1 uint32 //一次侧标定电动势,单位V
|
||||
E2 uint32 //二次侧标定电动势,单位V
|
||||
PortA *PipePort //变压器A端口连接的管线
|
||||
PortB *PipePort //变压器B端口连接的管线
|
||||
PortC *PipePort //变压器C端口连接的管线
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
)
|
||||
|
||||
type VoltageTransformerSystem struct {
|
||||
@ -21,5 +23,58 @@ func (s *VoltageTransformerSystem) Update(w ecs.World) {
|
||||
|
||||
// 变压器电力传递
|
||||
func (s *VoltageTransformerSystem) voltageTransformerTransPower(w ecs.World) {
|
||||
|
||||
wd := entity.GetWorldData(w)
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
vtId := component.UidType.Get(entry).Id
|
||||
vtModel := wd.Repo.FindById(vtId).(*repository.VoltageTransformer)
|
||||
//
|
||||
vtPortA := vtModel.PortA
|
||||
vtPortAEntry := wd.EntityMap[vtPortA.Device().Id()]
|
||||
vtPortAPipe := component.PowerPipeType.Get(vtPortAEntry) //变压器一次侧连接的管线
|
||||
//
|
||||
var vtPortBPipe *component.PowerPipe = nil
|
||||
if vtModel.PortB != nil {
|
||||
vtPortB := vtModel.PortB
|
||||
vtPortBEntry := wd.EntityMap[vtPortB.Device().Id()]
|
||||
vtPortBPipe = component.PowerPipeType.Get(vtPortBEntry)
|
||||
}
|
||||
//
|
||||
var vtPortCPipe *component.PowerPipe = nil
|
||||
if vtModel.PortC != nil {
|
||||
vtPortC := vtModel.PortC
|
||||
vtPortCEntry := wd.EntityMap[vtPortC.Device().Id()]
|
||||
vtPortCPipe = component.PowerPipeType.Get(vtPortCEntry)
|
||||
}
|
||||
//变压比
|
||||
rate := float64(vtModel.E2) / float64(vtModel.E1)
|
||||
//A->B、C ,电能从一次侧向二次侧传递
|
||||
for psId, ps := range vtPortAPipe.Sources {
|
||||
//二次侧输出电压
|
||||
outV := uint32(rate * float64(ps.Voltage))
|
||||
if vtPortBPipe != nil { //二次侧火线
|
||||
portBPs, ok := vtPortBPipe.Sources[psId]
|
||||
if ok {
|
||||
portBPs.Voltage = outV
|
||||
portBPs.Ac = ps.Ac
|
||||
portBPs.Fresh = ps.Fresh - 1
|
||||
} else {
|
||||
vtPortBPipe.Sources[psId] = &component.ElePower{Ac: ps.Ac, Voltage: outV, Fresh: ps.Fresh - 1}
|
||||
}
|
||||
}
|
||||
if vtPortCPipe != nil { //二次侧零线
|
||||
portCPs, ok := vtPortCPipe.Sources[psId]
|
||||
cV := uint32(0)
|
||||
if outV > 0 { //当二次火线电压大于零时,二次侧零线电压值1表示零电位
|
||||
cV = 1
|
||||
}
|
||||
if ok {
|
||||
portCPs.Voltage = cV
|
||||
portCPs.Ac = ps.Ac
|
||||
portCPs.Fresh = ps.Fresh - 1
|
||||
} else {
|
||||
vtPortCPipe.Sources[psId] = &component.ElePower{Ac: ps.Ac, Voltage: cV, Fresh: ps.Fresh - 1}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user