iscs pscada 一次图 电力传递实现
This commit is contained in:
parent
3ba7610c61
commit
44ee9266f8
@ -75,6 +75,11 @@ type VoltageTransformer struct {
|
||||
Normal bool //true-正常
|
||||
}
|
||||
|
||||
// EarthingDevice 接地装置
|
||||
type EarthingDevice struct {
|
||||
Voltage uint32 //接地装置电压
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// PowerPipe 电力母线
|
||||
@ -132,7 +137,8 @@ var (
|
||||
RectifierType = ecs.NewComponentType[Rectifier]() //整流器
|
||||
VoltageTransformerType = ecs.NewComponentType[VoltageTransformer]() //变压器
|
||||
PowerPipeType = ecs.NewComponentType[PowerPipe]() //电力母线
|
||||
PowerSourceType = ecs.NewComponentType[PowerSource]()
|
||||
PowerSourceType = ecs.NewComponentType[PowerSource]() //电源
|
||||
EarthingDeviceType = ecs.NewComponentType[EarthingDevice]() //接地装置
|
||||
)
|
||||
|
||||
// BackupZiTouInputTag 备自投投入、退出标签
|
||||
|
@ -47,6 +47,10 @@ func LoadIscs(w ecs.World) error {
|
||||
for _, la := range data.Repo.LightningArresterMap {
|
||||
NewLightningArresterEntity(w, la.Id())
|
||||
}
|
||||
//接地装置
|
||||
for _, ed := range data.Repo.EarthingDeviceMap {
|
||||
NewEarthingDeviceEntity(w, ed.Id())
|
||||
}
|
||||
//
|
||||
return nil
|
||||
}
|
||||
|
@ -94,6 +94,19 @@ func NewLightningArresterEntity(w ecs.World, id string) *ecs.Entry {
|
||||
return e
|
||||
}
|
||||
|
||||
// NewEarthingDeviceEntity 创建接地装置实体
|
||||
func NewEarthingDeviceEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.EarthingDeviceType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.EarthingDeviceType.Set(e, &component.EarthingDevice{Voltage: 0})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// NewVoltageTransformerEntity 创建变压器实体
|
||||
func NewVoltageTransformerEntity(w ecs.World, id string) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
|
@ -48,6 +48,8 @@ message Repository {
|
||||
repeated PowerSource powerSources = 308;
|
||||
//ISCS避雷器
|
||||
repeated LightningArrester lightningArresters = 309;
|
||||
//ISCS接地装置
|
||||
repeated EarthingDevice earthingDevices = 310;
|
||||
}
|
||||
|
||||
// 信号布置数据
|
||||
@ -321,7 +323,8 @@ enum DeviceType {
|
||||
DeviceType_PipeFitting = 384;
|
||||
//ISCS 电源
|
||||
DeviceType_PowerSource = 385;
|
||||
|
||||
//ISCS 接地装置
|
||||
DeviceType_EarthingDevice = 386;
|
||||
}
|
||||
|
||||
|
||||
@ -607,4 +610,11 @@ message PowerSource{
|
||||
message LightningArrester{
|
||||
string id = 1;
|
||||
string code = 2;
|
||||
}
|
||||
|
||||
//接地装置
|
||||
//接地装置自身与大地一体,只有一个输入端口A,该端口用来接收意外电能然后导入大地
|
||||
message EarthingDevice{
|
||||
string id = 1;
|
||||
string code = 2;
|
||||
}
|
@ -399,3 +399,36 @@ func (p *LightningArresterPort) Port() proto.Port {
|
||||
func (p *LightningArresterPort) Device() PortedDevice {
|
||||
return p.arrester
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
// EarthingDevice 接地装置
|
||||
type EarthingDevice struct {
|
||||
Identity
|
||||
Code string
|
||||
PortA *PipePort //接地输入端口
|
||||
}
|
||||
|
||||
func NewEarthingDevice(id string, code string) *EarthingDevice {
|
||||
return &EarthingDevice{
|
||||
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_EarthingDevice},
|
||||
Code: code,
|
||||
}
|
||||
}
|
||||
func (p *EarthingDevice) PortNum() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
// EarthingDevicePort 避雷器端口
|
||||
//
|
||||
// implement DevicePort
|
||||
type EarthingDevicePort struct {
|
||||
ed *EarthingDevice
|
||||
}
|
||||
|
||||
func (p *EarthingDevicePort) Port() proto.Port {
|
||||
return proto.Port_A
|
||||
}
|
||||
func (p *EarthingDevicePort) Device() PortedDevice {
|
||||
return p.ed
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -41,6 +41,7 @@ type Repository struct {
|
||||
VoltageTransformerMap map[string]*VoltageTransformer //ISCS 变压器
|
||||
PowerSourceMap map[string]*PowerSource //ISCS 电源
|
||||
LightningArresterMap map[string]*LightningArrester //ISCS 避雷器
|
||||
EarthingDeviceMap map[string]*EarthingDevice //ISCS 接地装置
|
||||
}
|
||||
|
||||
func newRepository(id string, version string) *Repository {
|
||||
@ -77,6 +78,7 @@ func newRepository(id string, version string) *Repository {
|
||||
VoltageTransformerMap: make(map[string]*VoltageTransformer), //ISCS 变压器
|
||||
PowerSourceMap: make(map[string]*PowerSource), //ISCS 电源
|
||||
LightningArresterMap: make(map[string]*LightningArrester), //ISCS 避雷器
|
||||
EarthingDeviceMap: make(map[string]*EarthingDevice), //ISCS 接地装置
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,6 +139,9 @@ func (repo *Repository) FindById(id string) Identity {
|
||||
if md, ok := repo.LightningArresterMap[id]; ok {
|
||||
return md
|
||||
}
|
||||
if md, ok := repo.EarthingDeviceMap[id]; ok {
|
||||
return md
|
||||
}
|
||||
//ISCS-end
|
||||
|
||||
return nil
|
||||
@ -310,6 +315,8 @@ func (repo *Repository) FindModel(deviceId string, deviceType proto.DeviceType)
|
||||
return repo.PowerSourceMap[deviceId], nil
|
||||
case proto.DeviceType_DeviceType_LightningArrester:
|
||||
return repo.LightningArresterMap[deviceId], nil
|
||||
case proto.DeviceType_DeviceType_EarthingDevice:
|
||||
return repo.EarthingDeviceMap[deviceId], nil
|
||||
default:
|
||||
return nil, fmt.Errorf("仓库中不存在[%s]类型的模型", deviceType)
|
||||
}
|
||||
|
@ -54,6 +54,11 @@ func buildIscsModels(source *proto.Repository, repository *Repository) error {
|
||||
m := NewLightningArrester(protoData.Id, protoData.Code)
|
||||
repository.LightningArresterMap[m.Id()] = m
|
||||
}
|
||||
//ISCS接地装置
|
||||
for _, protoData := range source.EarthingDevices {
|
||||
m := NewEarthingDevice(protoData.Id, protoData.Code)
|
||||
repository.EarthingDeviceMap[m.Id()] = m
|
||||
}
|
||||
//
|
||||
return nil
|
||||
}
|
||||
@ -189,6 +194,12 @@ func buildIscsPipeModelRelationship(source *proto.Repository, repository *Reposi
|
||||
pipePortRelatedDevice = &PowerSourcePort{ps: ps}
|
||||
ps.PortA = &PipePort{port: pipePort, pipe: pipeModel}
|
||||
}
|
||||
case proto.DeviceType_DeviceType_EarthingDevice:
|
||||
{
|
||||
ed := relatedDevice.(*EarthingDevice)
|
||||
ed.PortA = &PipePort{port: pipePort, pipe: pipeModel}
|
||||
pipePortRelatedDevice = &EarthingDevicePort{ed: ed}
|
||||
}
|
||||
}
|
||||
if pipePortRelatedDevice != nil {
|
||||
if pipePort == proto.Port_A {
|
||||
|
@ -56,5 +56,6 @@ func bindIscsSystem(w ecs.World) {
|
||||
iscs_sys.NewRectifierSystem(),
|
||||
iscs_sys.NewVoltageTransformerSystem(),
|
||||
iscs_sys.NewLightningArresterSystem(),
|
||||
iscs_sys.NewPowerPipeSystem())
|
||||
iscs_sys.NewPowerPipeSystem(),
|
||||
iscs_sys.NewEarthingDeviceSystem())
|
||||
}
|
||||
|
37
sys/iscs_sys/iscs_pscada_earthing_device.go
Normal file
37
sys/iscs_sys/iscs_pscada_earthing_device.go
Normal file
@ -0,0 +1,37 @@
|
||||
package iscs_sys
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
)
|
||||
|
||||
type EarthingDeviceSystem struct {
|
||||
query *ecs.Query
|
||||
}
|
||||
|
||||
func NewEarthingDeviceSystem() *EarthingDeviceSystem {
|
||||
return &EarthingDeviceSystem{
|
||||
query: ecs.NewQuery(filter.Contains(component.UidType, component.EarthingDeviceType)),
|
||||
}
|
||||
}
|
||||
|
||||
// Update 接地装置传递异常电能
|
||||
func (s *EarthingDeviceSystem) Update(w ecs.World) {
|
||||
wd := entity.GetWorldData(w)
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
edId := component.UidType.Get(entry).Id
|
||||
ed := component.EarthingDeviceType.Get(entry)
|
||||
//
|
||||
edModel := (wd.Repo.FindById(edId)).(*repository.EarthingDevice)
|
||||
if edModel.PortA != nil {
|
||||
edPipeEntry := wd.EntityMap[edModel.PortA.Device().Id()]
|
||||
edPipe := component.PowerPipeType.Get(edPipeEntry)
|
||||
ed.Voltage = edPipe.Voltage
|
||||
} else {
|
||||
ed.Voltage = 1 //零电压
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user