iscs pscada 一次图 电力传递实现
This commit is contained in:
parent
f0433ef838
commit
f5c28fcdec
@ -50,8 +50,6 @@ const (
|
||||
// 具体异常-故障、报警、通信中断
|
||||
type Rectifier struct {
|
||||
Normal bool //true-正常
|
||||
InputAcV uint32 //输入交流电压
|
||||
OutputDcV uint32 //输出直流电压
|
||||
}
|
||||
|
||||
// Disconnector 隔离开关
|
||||
@ -75,8 +73,6 @@ type LightningArrester struct {
|
||||
// 具体异常-故障、报警、通信中断
|
||||
type VoltageTransformer struct {
|
||||
Normal bool //true-正常
|
||||
InputV uint32 //输入电压值,单位V
|
||||
OutputV uint32 //输出电压值,单位V
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -92,8 +88,11 @@ func (p *PowerPipe) TransPower(powerSourceId string, power *ElePower) {
|
||||
ep, ok := p.Sources[powerSourceId]
|
||||
if ok {
|
||||
*ep = *power
|
||||
ep.Fresh -= 1
|
||||
} else {
|
||||
p.Sources[powerSourceId] = power
|
||||
p.Sources[powerSourceId] = &ElePower{}
|
||||
*p.Sources[powerSourceId] = *power
|
||||
p.Sources[powerSourceId].Fresh -= 1
|
||||
}
|
||||
}
|
||||
|
||||
|
16
sys/bind.go
16
sys/bind.go
@ -5,6 +5,7 @@ import (
|
||||
"joylink.club/rtsssimulation/sys/circuit_sys"
|
||||
"joylink.club/rtsssimulation/sys/common_sys"
|
||||
"joylink.club/rtsssimulation/sys/device_sys"
|
||||
"joylink.club/rtsssimulation/sys/iscs_sys"
|
||||
)
|
||||
|
||||
// 添加系统到World
|
||||
@ -41,3 +42,18 @@ func BindSystem(w ecs.World) {
|
||||
device_sys.NewBaliseSystem(),
|
||||
)
|
||||
}
|
||||
|
||||
// ISCS 系统
|
||||
func bindIscsSystem(w ecs.World) {
|
||||
w.AddSystem(iscs_sys.NewIscsExceptionSystem(),
|
||||
iscs_sys.NewDevicePlacingSystem(),
|
||||
iscs_sys.NewPowerSourceSystem(),
|
||||
iscs_sys.NewCircuitBreakerSystem(),
|
||||
iscs_sys.NewDisconnectorSystem(),
|
||||
iscs_sys.NewHandcartSystem(),
|
||||
iscs_sys.NewThreePositionSwitchSystem(),
|
||||
iscs_sys.NewPipeFittingSystem(),
|
||||
iscs_sys.NewRectifierSystem(),
|
||||
iscs_sys.NewVoltageTransformerSystem(),
|
||||
iscs_sys.NewPowerPipeSystem())
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ type CircuitBreakerSystem struct {
|
||||
|
||||
func NewCircuitBreakerSystem() *CircuitBreakerSystem {
|
||||
return &CircuitBreakerSystem{
|
||||
query: ecs.NewQuery(filter.Contains(component.UidType, component.CircuitBreakerType, component.DeviceExceptionType)),
|
||||
query: ecs.NewQuery(filter.Contains(component.UidType, component.CircuitBreakerType)),
|
||||
}
|
||||
}
|
||||
func (s *CircuitBreakerSystem) Update(w ecs.World) {
|
||||
|
@ -14,7 +14,7 @@ type DisconnectorSystem struct {
|
||||
|
||||
func NewDisconnectorSystem() *DisconnectorSystem {
|
||||
return &DisconnectorSystem{
|
||||
query: ecs.NewQuery(filter.Contains(component.UidType, component.DisconnectorType, component.DeviceExceptionType)),
|
||||
query: ecs.NewQuery(filter.Contains(component.UidType, component.DisconnectorType)),
|
||||
}
|
||||
}
|
||||
func (s *DisconnectorSystem) Update(w ecs.World) {
|
||||
|
@ -14,7 +14,7 @@ type HandcartSystem struct {
|
||||
|
||||
func NewHandcartSystem() *HandcartSystem {
|
||||
return &HandcartSystem{
|
||||
query: ecs.NewQuery(filter.Contains(component.UidType, component.HandcartSwitchType, component.DeviceExceptionType)),
|
||||
query: ecs.NewQuery(filter.Contains(component.UidType, component.HandcartSwitchType)),
|
||||
}
|
||||
}
|
||||
func (s *HandcartSystem) Update(w ecs.World) {
|
||||
|
@ -19,22 +19,24 @@ func NewRectifierSystem() *RectifierSystem {
|
||||
}
|
||||
}
|
||||
func (s *RectifierSystem) Update(w ecs.World) {
|
||||
wd := entity.GetWorldData(w)
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
s.rectifierTransPower(wd, entry)
|
||||
s.rectifier(wd, entry)
|
||||
})
|
||||
}
|
||||
|
||||
// 整流器其他一般信息计算收集
|
||||
func (s *RectifierSystem) rectifier(wd *component.WorldData, entry *ecs.Entry) {
|
||||
rectifier := component.RectifierType.Get(entry)
|
||||
exception := component.DeviceExceptionType.Get(entry)
|
||||
//
|
||||
rectifier.Normal = exception.Exception == consts.DeviceExceptionNon
|
||||
|
||||
})
|
||||
//
|
||||
s.rectifierTransPower(w)
|
||||
}
|
||||
|
||||
// 整流器电能传递
|
||||
// 当线路接通时零线和负极电压规定值为1,当线路断开时零线和负极电压规定值为0
|
||||
func (s *RectifierSystem) rectifierTransPower(w ecs.World) {
|
||||
wd := entity.GetWorldData(w)
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
func (s *RectifierSystem) rectifierTransPower(wd *component.WorldData, entry *ecs.Entry) {
|
||||
rectifierId := component.UidType.Get(entry).Id
|
||||
rectifierModel := wd.Repo.FindById(rectifierId).(*repository.Rectifier)
|
||||
//
|
||||
@ -79,5 +81,4 @@ func (s *RectifierSystem) rectifierTransPower(w ecs.World) {
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ type ThreePositionSwitchSystem struct {
|
||||
|
||||
func NewThreePositionSwitchSystem() *ThreePositionSwitchSystem {
|
||||
return &ThreePositionSwitchSystem{
|
||||
query: ecs.NewQuery(filter.Contains(component.UidType, component.ThreePositionSwitchType, component.DeviceExceptionType)),
|
||||
query: ecs.NewQuery(filter.Contains(component.UidType, component.ThreePositionSwitchType)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/consts"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
)
|
||||
@ -18,13 +19,20 @@ func NewVoltageTransformerSystem() *VoltageTransformerSystem {
|
||||
}
|
||||
}
|
||||
func (s *VoltageTransformerSystem) Update(w ecs.World) {
|
||||
s.voltageTransformerTransPower(w)
|
||||
wd := entity.GetWorldData(w)
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
s.voltageTransformerTransPower(wd, entry)
|
||||
s.voltageTransformer(wd, entry)
|
||||
})
|
||||
|
||||
}
|
||||
func (s *VoltageTransformerSystem) voltageTransformer(wd *component.WorldData, entry *ecs.Entry) {
|
||||
vt := component.VoltageTransformerType.Get(entry)
|
||||
vt.Normal = component.DeviceExceptionType.Get(entry).Exception == consts.DeviceExceptionNon
|
||||
}
|
||||
|
||||
// 变压器电力传递
|
||||
func (s *VoltageTransformerSystem) voltageTransformerTransPower(w ecs.World) {
|
||||
wd := entity.GetWorldData(w)
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
func (s *VoltageTransformerSystem) voltageTransformerTransPower(wd *component.WorldData, entry *ecs.Entry) {
|
||||
vtId := component.UidType.Get(entry).Id
|
||||
vtModel := wd.Repo.FindById(vtId).(*repository.VoltageTransformer)
|
||||
//
|
||||
@ -76,5 +84,5 @@ func (s *VoltageTransformerSystem) voltageTransformerTransPower(w ecs.World) {
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user