rts-sim-module/repository/iscs_pscada_yc.go
2023-12-20 15:22:36 +08:00

348 lines
7.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package repository
import "joylink.club/rtsssimulation/repository/model/proto"
//电力监控系统车站一次图中相关设备模型
// Pipe 管线模型
type Pipe struct {
Identity
Code string
Type proto.Pipe_Type
PortA DevicePort //管线的A端连接的设备
PortB DevicePort //管线的B端连接的设备
}
func NewPipe(id string, code string, pipeType proto.Pipe_Type) *Pipe {
return &Pipe{Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_Pipe}, Code: code, Type: pipeType}
}
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
}