iscs pscada

This commit is contained in:
xzb 2023-12-18 18:04:37 +08:00
parent 5d8be55300
commit c00ec9a7e3
6 changed files with 93 additions and 421 deletions

21
component/iscs.go Normal file
View File

@ -0,0 +1,21 @@
package component
import "joylink.club/ecs"
// 设备例外标签定义
var (
DeviceCommunicationInterruptTag = ecs.NewTag() //通信中断
DeviceAbnormalTag = ecs.NewTag() //异常
DeviceFaultTag = ecs.NewTag() //故障 有预告信号产生
DeviceAlarmTag = ecs.NewTag() //报警 有事故信号产生
DeviceStartTimeoutTag = ecs.NewTag() //启动超时
DeviceModuleFaultTag = ecs.NewTag() //模块故障
)
// 设备置牌标签定义
var (
DevicePlacingOverhaulCardTag = ecs.NewTag() //设备置牌:检修
DevicePlacingLandingCardTag = ecs.NewTag() //设备置牌:接地
DevicePlacingHandTag = ecs.NewTag() //设备置牌:就地(手型牌)
DevicePlacingOtherCardTag = ecs.NewTag() //设备置牌:其他
)

View File

@ -7,111 +7,17 @@ import (
//ISCS 电力系统相关组件定义
// IscsWireCabinetState ISCS线柜状态
//
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsWireCabinetState struct {
State consts.WireCabinetStateEnum
// CircuitBreaker 电路断路器
type CircuitBreaker struct {
Closed bool //true-合闸false-分闸
Exception consts.DeviceExceptionEnum //具体异常-通信中断
}
// IscsCircuitBreakerState ISCS断路器状态
//
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
//
// 断路器PT、负极柜隔离开关、轨电位、上网隔离开关、隔离开关
type IscsCircuitBreakerState struct {
State consts.CircuitBreakerStateEnum
}
// IscsRectifierState ISCS整流器状态
//
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsRectifierState struct {
State consts.RectifierStateEnum
}
// IscsHandcartSwitchState ISCS手车状态
//
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsHandcartSwitchState struct {
State consts.HandcartSwitchStateEnum
}
// IscsVoltageTransformerState ISCS变压器状态
//
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsVoltageTransformerState struct {
State consts.VoltageTransformerStateEnum
}
// IscsThreePositionSwitchState ISCS三工位隔离开关状态
//
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsThreePositionSwitchState struct {
State consts.ThreePositionSwitchStateEnum
}
// IscsTransBusbarState ISCS母联备自投状态
//
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsTransBusbarState struct {
State consts.TransBusbarZiTouStateEnum
}
// ISCS 相关设备状态组件
var (
IscsWireCabinetStateType = ecs.NewComponentType[IscsWireCabinetState]()
IscsCircuitBreakerStateType = ecs.NewComponentType[IscsCircuitBreakerState]()
IscsRectifierStateType = ecs.NewComponentType[IscsRectifierState]()
IscsHandcartSwitchStateType = ecs.NewComponentType[IscsHandcartSwitchState]()
IscsVoltageTransformerStateType = ecs.NewComponentType[IscsVoltageTransformerState]()
IscsIscsThreePositionSwitchStateType = ecs.NewComponentType[IscsThreePositionSwitchState]()
IscsTransBackupZiTouStateType = ecs.NewComponentType[IscsTransBusbarState]()
)
/////////////////////////////////////////////////////////
// TransBusbar 输电母线
type TransBusbar struct {
Vl VoltageLevel //电压等级
Elec ElecYwEnum
}
// VoltageLevel 电压等级定义
type VoltageLevel = uint8
const (
VlNon VoltageLevel = iota //未知电压等级
VlAc110Kv //110kV交流电 红色
VlAc35Kv //35kV交流电 黄色
VlAc400V //400V交流电 浅蓝色
VlDc1500V //1500V直流电
)
// ElecYwEnum 电的有无定义
type ElecYwEnum = uint8
const (
EywLossing ElecYwEnum = iota //失电,未受电
EywReceiving //受电
EywStatic //静态
)
/////////////////////////////////////////////////
// TwoPositionSwitch 对一条路通-断控制的开关状态
// 如断路器
// 如PT、负极柜隔离开关、轨电位、上网隔离开关、隔离开关
type TwoPositionSwitch struct {
Closed bool //true-合闸线路导通false-分闸,线路断开
}
// /////////////////////////////////////////
// ThreePositionSwitch 三工位开关
// 对于三工位隔离开关规定ClosedPosition1-合闸到工作位ClosedPosition2-合闸到接地位
type ThreePositionSwitch struct {
Position SwitchThreePosition //合闸到位置1与位置1线路导通;合闸到位置2与位置2线路导通;分闸,线路断开,未与任何位置接通
Position SwitchThreePosition //合闸到位置1与位置1线路导通;合闸到位置2与位置2线路导通;分闸,线路断开,未与任何位置接通
Exception consts.DeviceExceptionEnum //具体异常-异常、通信中断
}
// SwitchThreePosition 三工位开关位置定义
@ -123,11 +29,12 @@ const (
StpClosedPosition2 //开关合闸到位置2与位置2线路导通
)
/////////////////////////////////////////////
/////////////////////////
// HandcartSwitch 手车式开关
type HandcartSwitch struct {
Position HandcarPosition
Position HandcarPosition
Exception consts.DeviceExceptionEnum //具体异常-通信中断
}
// HandcarPosition 手车式开关位置定义
@ -139,41 +46,66 @@ const (
HpTest //实验位
)
//////////////////////////////////////////
////////////////////
// ElecDevice 一般电力设备
// 如:变压器、整流器
// Epu所有状态如35kV进线柜、35kV出线柜、1500V直流进线柜、配电变馈线柜、整流变馈线柜、35kV母联柜、500V直流馈线柜、1500V直流馈线柜、1500V直流负极柜
// Epu状态中除去报警400V进线柜、400V母联柜、三级负荷总开关、上网隔离开关柜、接口柜
type ElecDevice struct {
// Rectifier 整流器
type Rectifier struct {
Normal bool //true-正常
Exception consts.DeviceExceptionEnum //具体异常-故障、报警、通信中断
InputAcV uint32 //输入交流电压
OutputDcV uint32 //输出直流电压
}
// Disconnector 隔离开关
type Disconnector struct {
Closed bool //true-合闸false-分闸
Exception consts.DeviceExceptionEnum //具体异常-异常、通信中断
}
// WireCabinet 线柜
type WireCabinet struct {
Normal bool //true-正常
Exception consts.DeviceExceptionEnum //具体异常-故障、报警、异常、通信中断
}
// LightningArrester 避雷器
type LightningArrester struct {
Normal bool //true-正常
}
// 电力设备组件
var (
ElecDeviceType = ecs.NewComponentType[ElecDevice]()
HandcartSwitchType = ecs.NewComponentType[HandcartSwitch]()
ThreePositionSwitchType = ecs.NewComponentType[ThreePositionSwitch]()
TwoPositionSwitchType = ecs.NewComponentType[TwoPositionSwitch]()
TransBusbarType = ecs.NewComponentType[TransBusbar]()
)
// AbcVoltageSource 三相电压源
//
// 35KV 1#和2#进线连接的国家电网可以视作电压源,为整个一次图中最终电的来源
type AbcVoltageSource struct {
Ua uint32 //A相电压单位V
Ub uint32 //B相电压单位V
Uc uint32 //C相电压单位V
}
// 设备例外标签定义
var (
DeviceCommunicationInterruptTag = ecs.NewTag() //通信中断
DeviceAbnormalTag = ecs.NewTag() //异常
DeviceFaultTag = ecs.NewTag() //故障 有预告信号产生
DeviceAlarmTag = ecs.NewTag() //报警 有事故信号产生
DeviceStartTimeoutTag = ecs.NewTag() //启动超时
DeviceModuleFaultTag = ecs.NewTag() //模块故障
)
// VoltageTransformer 变压器
type VoltageTransformer struct {
Normal bool //true-正常
Exception consts.DeviceExceptionEnum //具体异常-故障、报警、通信中断
InputV uint32 //输入电压值单位V
OutputV uint32 //输出电压值单位V
}
// VoltageABTransmission 电压传递从A传递到B,如断路器闭合时,电压会从断路器一端传递到另一端
type VoltageABTransmission struct {
}
// VoltageANTransmission 电压传递电源从A点传递到N个点
type VoltageANTransmission struct {
}
// 设备置牌标签定义
var (
DevicePlacingOverhaulCardTag = ecs.NewTag() //设备置牌:检修
DevicePlacingLandingCardTag = ecs.NewTag() //设备置牌:接地
DevicePlacingHandTag = ecs.NewTag() //设备置牌:就地(手型牌)
DevicePlacingOtherCardTag = ecs.NewTag() //设备置牌:其他
CircuitBreakerType = ecs.NewComponentType[CircuitBreaker]() //断路器
ThreePositionSwitchType = ecs.NewComponentType[ThreePositionSwitch]() //三工位隔离开关
HandcartSwitchType = ecs.NewComponentType[HandcartSwitch]() //手车
DisconnectorType = ecs.NewComponentType[Disconnector]() //隔离开关
WireCabinetType = ecs.NewComponentType[WireCabinet]() //线柜
LightningArresterType = ecs.NewComponentType[LightningArrester]() //避雷器
AbcVoltageSourceType = ecs.NewComponentType[AbcVoltageSource]() //三相电压源
)
// BackupZiTouInputTag 备自投投入、退出标签

View File

@ -1,71 +0,0 @@
package consts
// VoltageTransformerStateEnum ISCS变压器状态
type VoltageTransformerStateEnum = int8
const (
VtfNormal VoltageTransformerStateEnum = iota //正常
VtfFault //故障 (注意-变压器110kV/35kv没有此项)
VtfAlarm //报警
VtfCommunicationInterrupt //通讯中断
)
// TransBusbarZiTouStateEnum ISCS母联备自投状态
type TransBusbarZiTouStateEnum = int8
const (
TbztExit TransBusbarZiTouStateEnum = iota //备自投退出
TbztInput //备自投投入
TbztCommunicationInterrupt //通讯中断
)
// ThreePositionSwitchStateEnum ISCS三工位隔离开关状态
type ThreePositionSwitchStateEnum = int8
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
const (
TpsOpened ThreePositionSwitchStateEnum = iota //开闸
TpsDisconnectSwitchClosed //隔离开关合闸
TpsLandingSwitchClosed //接地开关合闸
TpsAbnormal //异常
TpsCommunicationInterrupt //通讯中断
)
// HandcartSwitchStateEnum ISCS手车状态
type HandcartSwitchStateEnum = int8
const (
HcsWorkPosOpened HandcartSwitchStateEnum = iota //工作位分闸
HcsWorkPosClosed //工作位合闸
HcsTestPos //实验位
HcsCommunicationInterrupt //通讯中断
)
// RectifierStateEnum ISCS整流器状态
type RectifierStateEnum = int8
const (
RsNormal RectifierStateEnum = iota //正常
RsFault //故障
RsAlarm //报警
RsCommunicationInterrupt //通讯中断
)
// CircuitBreakerStateEnum ISCS断路器状态
type CircuitBreakerStateEnum = int8
const (
CbsOpened CircuitBreakerStateEnum = iota //开闸
CbsClosed //合闸
CbsAbnormal //通讯中断/异常
)
// WireCabinetStateEnum ISCS线柜状态
type WireCabinetStateEnum = int8
const (
WcsNormal WireCabinetStateEnum = iota //正常
WcsFault //故障
WcsAlarm //报警
WcsAbnormal //通讯中断/异常
)

View File

@ -140,33 +140,6 @@ func DeviceExceptionOperate(w ecs.World, deviceId string, opt DeviceExceptionOpt
return r.Err
}
////////////////////////////////////////////////////////
// TwoPositionSwitchOperate 两工位开关操作
//
// 如断路器
// 如PT、负极柜隔离开关、轨电位、上网隔离开关、隔离开关
//
// close true-合闸false-开闸
func TwoPositionSwitchOperate(w ecs.World, deviceId string, close bool) error {
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
deviceEntry, ok := wd.EntityMap[deviceId]
if !ok {
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
}
//
if deviceEntry.HasComponent(component.TwoPositionSwitchType) {
component.TwoPositionSwitchType.Get(deviceEntry).Closed = close
} else {
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是两工位开关", deviceId))
}
//
return ecs.NewOkEmptyResult()
})
return r.Err
}
///////////////////////////////////////////////////////////
// SwitchThreePositionOptEnum 三工位开关操作枚举定义

View File

@ -277,17 +277,21 @@ enum DeviceType {
//ISCS
DeviceType_FloodGate = 74;
//ISCS 线
DeviceType_IscsWireCabinet = 75;
DeviceType_WireCabinet = 75;
//ISCS
DeviceType_IscsCircuitBreaker = 76;
DeviceType_CircuitBreaker = 76;
//ISCS
DeviceType_IscsRectifier = 77;
DeviceType_Rectifier = 77;
//ISCS
DeviceType_IscsHandcartSwitch = 78;
DeviceType_HandcartSwitch = 78;
//ISCS
DeviceType_IscsVoltageTransformer = 79;
DeviceType_VoltageTransformer = 79;
//ISCS
DeviceType_IscsThreePositionSwitch = 80;
DeviceType_ThreePositionSwitch = 80;
//ISCS
DeviceType_LightningArrester = 81;
//ISCS
DeviceType_Disconnector = 82;
}

View File

@ -1,187 +0,0 @@
package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/consts"
)
// IscsPscadaSystem 电力监控系统
type IscsPscadaSystem struct {
queryCircuitBreaker *ecs.Query
queryHandcartSwitch *ecs.Query
queryRectifier *ecs.Query
queryThreePositionSwitch *ecs.Query
queryTransBusbarBackupZiTou *ecs.Query
queryVoltageTransformer *ecs.Query
queryWireCabinet *ecs.Query
}
func NewIscsPscadaSystem() *IscsPscadaSystem {
return &IscsPscadaSystem{
queryCircuitBreaker: ecs.NewQuery(filter.Contains(component.IscsCircuitBreakerStateType, component.TwoPositionSwitchType)),
queryHandcartSwitch: ecs.NewQuery(filter.Contains(component.IscsHandcartSwitchStateType, component.HandcartSwitchType)),
queryRectifier: ecs.NewQuery(filter.Contains(component.IscsRectifierStateType, component.ElecDeviceType)),
queryThreePositionSwitch: ecs.NewQuery(filter.Contains(component.IscsIscsThreePositionSwitchStateType, component.ThreePositionSwitchType)),
queryTransBusbarBackupZiTou: ecs.NewQuery(filter.Contains(component.IscsTransBackupZiTouStateType)),
queryVoltageTransformer: ecs.NewQuery(filter.Contains(component.IscsVoltageTransformerStateType, component.ElecDeviceType)),
queryWireCabinet: ecs.NewQuery(filter.Contains(component.IscsWireCabinetStateType, component.ElecDeviceType)),
}
}
func (s *IscsPscadaSystem) Update(w ecs.World) {
s.circuitBreaker(w)
s.handcartSwitch(w)
s.rectifier(w)
s.threePositionSwitch(w)
s.transBusbarBackupZiTou(w)
s.voltageTransformer(w)
s.wireCabinet(w)
}
func (s *IscsPscadaSystem) wireCabinet(w ecs.World) {
s.queryWireCabinet.Each(w, func(entry *ecs.Entry) {
wcState := component.IscsWireCabinetStateType.Get(entry)
wc := component.ElecDeviceType.Get(entry)
//
normal := true
if entry.HasComponent(component.DeviceFaultTag) {
wcState.State = consts.WcsFault
normal = false
}
if entry.HasComponent(component.DeviceAlarmTag) {
wcState.State = consts.WcsAlarm
normal = false
}
if entry.HasComponent(component.DeviceAbnormalTag) || entry.HasComponent(component.DeviceCommunicationInterruptTag) {
wcState.State = consts.WcsAbnormal
normal = false
}
wc.Normal = normal
if normal {
wcState.State = consts.WcsNormal
}
})
}
func (s *IscsPscadaSystem) voltageTransformer(w ecs.World) {
s.queryVoltageTransformer.Each(w, func(entry *ecs.Entry) {
vtState := component.IscsVoltageTransformerStateType.Get(entry)
vt := component.ElecDeviceType.Get(entry)
//
normal := true
if entry.HasComponent(component.DeviceFaultTag) {
vtState.State = consts.VtfFault
normal = false
}
if entry.HasComponent(component.DeviceAlarmTag) {
vtState.State = consts.VtfAlarm
normal = false
}
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
vtState.State = consts.VtfCommunicationInterrupt
normal = false
}
vt.Normal = normal
if normal {
vtState.State = consts.VtfNormal
}
})
}
// 电路母线备自投处理
func (s *IscsPscadaSystem) transBusbarBackupZiTou(w ecs.World) {
s.queryTransBusbarBackupZiTou.Each(w, func(entry *ecs.Entry) {
ziTouState := component.IscsTransBackupZiTouStateType.Get(entry)
//
if entry.HasComponent(component.BackupZiTouInputTag) {
ziTouState.State = consts.TbztInput
} else {
ziTouState.State = consts.TbztExit
}
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
ziTouState.State = consts.TbztCommunicationInterrupt
}
})
}
func (s *IscsPscadaSystem) threePositionSwitch(w ecs.World) {
s.queryThreePositionSwitch.Each(w, func(entry *ecs.Entry) {
tpSwitchState := component.IscsIscsThreePositionSwitchStateType.Get(entry)
tpSwitch := component.ThreePositionSwitchType.Get(entry)
//
switch tpSwitch.Position {
case component.StpOpened:
tpSwitchState.State = consts.TpsOpened
case component.StpClosedPosition1:
tpSwitchState.State = consts.TpsDisconnectSwitchClosed
case component.StpClosedPosition2:
tpSwitchState.State = consts.TpsLandingSwitchClosed
}
if entry.HasComponent(component.DeviceAbnormalTag) {
tpSwitchState.State = consts.TpsAbnormal
}
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
tpSwitchState.State = consts.TpsCommunicationInterrupt
}
})
}
func (s *IscsPscadaSystem) rectifier(w ecs.World) {
s.queryRectifier.Each(w, func(entry *ecs.Entry) {
rectifierState := component.IscsRectifierStateType.Get(entry)
elecDevice := component.ElecDeviceType.Get(entry)
//
normal := true
if entry.HasComponent(component.DeviceFaultTag) {
rectifierState.State = consts.RsFault
normal = false
}
if entry.HasComponent(component.DeviceAlarmTag) {
rectifierState.State = consts.RsAlarm
normal = false
}
//
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
rectifierState.State = consts.RsCommunicationInterrupt
normal = false
}
//
elecDevice.Normal = normal
//
if normal {
rectifierState.State = consts.RsNormal
}
})
}
func (s *IscsPscadaSystem) handcartSwitch(w ecs.World) {
s.queryHandcartSwitch.Each(w, func(entry *ecs.Entry) {
hdSwitchState := component.IscsHandcartSwitchStateType.Get(entry)
hdSwitch := component.HandcartSwitchType.Get(entry)
//
switch hdSwitch.Position {
case component.HpOpened:
hdSwitchState.State = consts.HcsWorkPosOpened
case component.HpClosed:
hdSwitchState.State = consts.HcsWorkPosClosed
case component.HpTest:
hdSwitchState.State = consts.HcsTestPos
}
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
hdSwitchState.State = consts.HcsCommunicationInterrupt
}
})
}
func (s *IscsPscadaSystem) circuitBreaker(w ecs.World) {
s.queryCircuitBreaker.Each(w, func(entry *ecs.Entry) {
tpSwitchState := component.IscsCircuitBreakerStateType.Get(entry)
tpSwitch := component.TwoPositionSwitchType.Get(entry)
//
if tpSwitch.Closed {
tpSwitchState.State = consts.CbsClosed
} else {
tpSwitchState.State = consts.CbsOpened
}
//
if entry.HasComponent(component.DeviceCommunicationInterruptTag) || entry.HasComponent(component.DeviceAbnormalTag) {
tpSwitchState.State = consts.CbsAbnormal
}
})
}