iscs pscada 一次图 repository

This commit is contained in:
xzb 2023-12-20 10:53:12 +08:00
parent e56d998ba7
commit ec8d3e1bca
3 changed files with 413 additions and 0 deletions

View File

@ -536,6 +536,7 @@ message Pipe{
DevicePort portB = 4;//线B端连接的设备
}
//
//A B C D
message PipeFitting{
string id = 1;
string code = 2;

View File

@ -0,0 +1,346 @@
package repository
import "joylink.club/rtsssimulation/repository/model/proto"
//电力监控系统车站一次图中相关设备模型
// Pipe 管线模型
type Pipe struct {
Identity
Code string
PortA DevicePort //管线的A端连接的设备
PortB DevicePort //管线的B端连接的设备
}
func NewPipe(id string, code string) *Pipe {
return &Pipe{Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_Pipe}, Code: code}
}
func (p *Pipe) PortNum() int {
return 2
}
// PipePort 管线端口
//
// implement DevicePort
type PipePort struct {
port proto.Port
pipe *Pipe
}
func (p *PipePort) Port() proto.Port {
return p.port
}
func (p *PipePort) Device() PortedDevice {
return p.pipe
}
///////////////////////////////////////////////////
// PipeFitting 管件模型
type PipeFitting struct {
Identity
Code string
portsSum int8 //管件端口数
PortA *PipePort //管件A端口连接的管线
PortB *PipePort //管件B端口连接的管线
PortC *PipePort //管件C端口连接的管线
PortD *PipePort //管件D端口连接的管线
}
func NewPipeFitting(id string, code string, portsSum int8) *PipeFitting {
return &PipeFitting{
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_PipeFitting},
Code: code,
portsSum: portsSum,
}
}
func (p *PipeFitting) PortNum() int {
return int(p.portsSum)
}
func (p *PipeFitting) Ports() []*PipePort {
var ports []*PipePort
if p.PortA != nil {
ports = append(ports, p.PortA)
}
if p.PortB != nil {
ports = append(ports, p.PortB)
}
if p.PortC != nil {
ports = append(ports, p.PortC)
}
if p.PortD != nil {
ports = append(ports, p.PortD)
}
return ports
}
// PipeFittingPort 管件端口
//
// implement DevicePort
type PipeFittingPort struct {
port proto.Port
pipeFitting *PipeFitting
}
func (p *PipeFittingPort) Port() proto.Port {
return p.port
}
func (p *PipeFittingPort) Device() PortedDevice {
return p.pipeFitting
}
/////////////////////////////////////////////////////////////////////////////
// CircuitBreaker 断路器模型
type CircuitBreaker struct {
Identity
Code string
PortA *PipePort //断路器A端口连接的管线
PortB *PipePort //断路器B端口连接的管线
}
func NewCircuitBreaker(id string, code string) *CircuitBreaker {
return &CircuitBreaker{
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_CircuitBreaker},
Code: code,
}
}
func (p *CircuitBreaker) PortNum() int {
return 2
}
// CircuitBreakerPort 断路器端口
//
// implement DevicePort
type CircuitBreakerPort struct {
port proto.Port
breaker *CircuitBreaker
}
func (p *CircuitBreakerPort) Port() proto.Port {
return p.port
}
func (p *CircuitBreakerPort) Device() PortedDevice {
return p.breaker
}
//////////////////////////////////////////////////////////
// ThreePositionSwitch 三工位开关模型
// 有三个连接端口公共连接点A,隔离开关连接点B,接地开关连接点C
type ThreePositionSwitch struct {
Identity
Code string
PortA *PipePort //三工位开关A端口连接的管线
PortB *PipePort //三工位开关B端口连接的管线
PortC *PipePort //三工位开关C端口连接的管线
}
func NewThreePositionSwitch(id string, code string) *ThreePositionSwitch {
return &ThreePositionSwitch{
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_ThreePositionSwitch},
Code: code,
}
}
func (p *ThreePositionSwitch) PortNum() int {
return 3
}
// ThreePositionSwitchPort 三工位开关端口
//
// implement DevicePort
type ThreePositionSwitchPort struct {
port proto.Port
breaker *ThreePositionSwitch
}
func (p *ThreePositionSwitchPort) Port() proto.Port {
return p.port
}
func (p *ThreePositionSwitchPort) Device() PortedDevice {
return p.breaker
}
////////////////////////////////////////////////////////
// HandcartSwitch 手车模型
type HandcartSwitch struct {
Identity
Code string
PortA *PipePort //手车A端口连接的管线
PortB *PipePort //手车B端口连接的管线
}
func NewHandcartSwitch(id string, code string) *HandcartSwitch {
return &HandcartSwitch{
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_HandcartSwitch},
Code: code,
}
}
func (p *HandcartSwitch) PortNum() int {
return 2
}
// HandcartSwitchPort 手车端口
//
// implement DevicePort
type HandcartSwitchPort struct {
port proto.Port
breaker *HandcartSwitch
}
func (p *HandcartSwitchPort) Port() proto.Port {
return p.port
}
func (p *HandcartSwitchPort) Device() PortedDevice {
return p.breaker
}
////////////////////////////////////////////
// Rectifier 整流器模型
//
// PSCADA中整流器有两个交流输入端分别为A和B;直流输出端口有两个分别为直流正极端口C和直流负极端口D
type Rectifier struct {
Identity
Code string
PortA *PipePort //整流器A端口连接的管线
PortB *PipePort //整流器B端口连接的管线
PortC *PipePort //整流器C端口连接的管线
PortD *PipePort //整流器D端口连接的管线
}
func NewRectifier(id string, code string) *Rectifier {
return &Rectifier{
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_Rectifier},
Code: code,
}
}
func (p *Rectifier) PortNum() int {
return 4
}
// RectifierPort 整流器端口
//
// implement DevicePort
type RectifierPort struct {
port proto.Port
rectifier *Rectifier
}
func (p *RectifierPort) Port() proto.Port {
return p.port
}
func (p *RectifierPort) Device() PortedDevice {
return p.rectifier
}
///////////////////////////////////////////////////////
// Disconnector 隔离开关模型
type Disconnector struct {
Identity
Code string
PortA *PipePort //隔离开关A端口连接的管线
PortB *PipePort //隔离开关B端口连接的管线
}
func NewDisconnector(id string, code string) *Disconnector {
return &Disconnector{
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_Disconnector},
Code: code,
}
}
func (p *Disconnector) PortNum() int {
return 2
}
// DisconnectorPort 隔离开关端口
//
// implement DevicePort
type DisconnectorPort struct {
port proto.Port
breaker *Disconnector
}
func (p *DisconnectorPort) Port() proto.Port {
return p.port
}
func (p *DisconnectorPort) Device() PortedDevice {
return p.breaker
}
//////////////////////////////////////////////////////
// VoltageTransformer 变压器模型
// 一次侧端口A,二次侧端口B或C
type VoltageTransformer struct {
Identity
Code string
PortA *PipePort //变压器A端口连接的管线
PortB *PipePort //变压器B端口连接的管线
PortC *PipePort //变压器C端口连接的管线
}
func NewVoltageTransformer(id string, code string) *VoltageTransformer {
return &VoltageTransformer{
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_VoltageTransformer},
Code: code,
}
}
func (p *VoltageTransformer) PortNum() int {
if p.PortC == nil {
return 2
} else {
return 3
}
}
// VoltageTransformerPort 变压器端口
//
// implement DevicePort
type VoltageTransformerPort struct {
port proto.Port
vt *VoltageTransformer
}
func (p *VoltageTransformerPort) Port() proto.Port {
return p.port
}
func (p *VoltageTransformerPort) Device() PortedDevice {
return p.vt
}
//////////////////////////////////////////////////////////
// PowerSource 电源模型
// 只有一个输出端口A
type PowerSource struct {
Identity
Code string
PortA *PipePort //电源A端口连接的管线
}
func NewPowerSource(id string, code string) *PowerSource {
return &PowerSource{
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_PowerSource},
Code: code,
}
}
func (p *PowerSource) PortNum() int {
return 1
}
// PowerSourcePort 电源端口
//
// implement DevicePort
type PowerSourcePort struct {
ps *PowerSource
}
func (p *PowerSourcePort) Port() proto.Port {
return proto.Port_A
}
func (p *PowerSourcePort) Device() PortedDevice {
return p.ps
}

View File

@ -31,6 +31,15 @@ type Repository struct {
linkMap map[string]*Link
platformMap map[string]*Platform
centralizedMap map[string]*proto.CentralizedStationRef
pipeMap map[string]*Pipe //ISCS 管线
pipeFittingMap map[string]*PipeFitting //ISCS 管件
circuitBreakerMap map[string]*CircuitBreaker //ISCS 断路器
threePositionSwitchMap map[string]*ThreePositionSwitch //ISCS 三工位开关
handcartSwitchMap map[string]*HandcartSwitch //ISCS 手车
rectifierMap map[string]*Rectifier //ISCS 整流器
disconnectorMap map[string]*Disconnector //ISCS 隔离开关
voltageTransformerMap map[string]*VoltageTransformer //ISCS 变压器
powerSource map[string]*PowerSource //ISCS 电源
}
func newRepository(id string, version string) *Repository {
@ -57,6 +66,15 @@ func newRepository(id string, version string) *Repository {
keyMap: make(map[string]*Key),
platformMap: make(map[string]*Platform),
centralizedMap: make(map[string]*proto.CentralizedStationRef),
pipeMap: make(map[string]*Pipe), //ISCS 管线
pipeFittingMap: make(map[string]*PipeFitting), //ISCS 管件
circuitBreakerMap: make(map[string]*CircuitBreaker), //ISCS 断路器
threePositionSwitchMap: make(map[string]*ThreePositionSwitch), //ISCS 三工位开关
handcartSwitchMap: make(map[string]*HandcartSwitch), //ISCS 手车
rectifierMap: make(map[string]*Rectifier), //ISCS 整流器
disconnectorMap: make(map[string]*Disconnector), //ISCS 隔离开关
voltageTransformerMap: make(map[string]*VoltageTransformer), //ISCS 变压器
powerSource: make(map[string]*PowerSource), //ISCS 电源
}
}
@ -86,6 +104,36 @@ func (repo *Repository) FindById(id string) Identity {
if md, ok := repo.platformMap[id]; ok {
return md
}
//ISCS-begin
if md, ok := repo.pipeMap[id]; ok {
return md
}
if md, ok := repo.pipeFittingMap[id]; ok {
return md
}
if md, ok := repo.circuitBreakerMap[id]; ok {
return md
}
if md, ok := repo.threePositionSwitchMap[id]; ok {
return md
}
if md, ok := repo.handcartSwitchMap[id]; ok {
return md
}
if md, ok := repo.rectifierMap[id]; ok {
return md
}
if md, ok := repo.disconnectorMap[id]; ok {
return md
}
if md, ok := repo.voltageTransformerMap[id]; ok {
return md
}
if md, ok := repo.powerSource[id]; ok {
return md
}
//ISCS-end
return nil
}
@ -237,6 +285,24 @@ func (repo *Repository) FindModel(deviceId string, deviceType proto.DeviceType)
return repo.linkMap[deviceId], nil
case proto.DeviceType_DeviceType_Psd:
return repo.psdMap[deviceId], nil
case proto.DeviceType_DeviceType_Pipe: //ISCS
return repo.pipeMap[deviceId], nil
case proto.DeviceType_DeviceType_PipeFitting:
return repo.pipeFittingMap[deviceId], nil
case proto.DeviceType_DeviceType_CircuitBreaker:
return repo.circuitBreakerMap[deviceId], nil
case proto.DeviceType_DeviceType_ThreePositionSwitch:
return repo.threePositionSwitchMap[deviceId], nil
case proto.DeviceType_DeviceType_HandcartSwitch:
return repo.handcartSwitchMap[deviceId], nil
case proto.DeviceType_DeviceType_Rectifier:
return repo.rectifierMap[deviceId], nil
case proto.DeviceType_DeviceType_Disconnector:
return repo.disconnectorMap[deviceId], nil
case proto.DeviceType_DeviceType_VoltageTransformer:
return repo.voltageTransformerMap[deviceId], nil
case proto.DeviceType_DeviceType_PowerSource:
return repo.powerSource[deviceId], nil
default:
return nil, fmt.Errorf("仓库中不存在[%s]类型的模型", deviceType)
}