diff --git a/component/pscada.go b/component/pscada.go new file mode 100644 index 0000000..ceef9cc --- /dev/null +++ b/component/pscada.go @@ -0,0 +1,60 @@ +package component + +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/consts" +) + +//电力系统相关组件定义 + +// TransBusbar 输电母线 +type TransBusbar struct { + Vl consts.VoltageLevel //电压等级 + Elec consts.ElecYwEnum +} + +// TwoPositionSwitch 对一条路通-断控制的开关状态 +// 如断路器 +// 如PT、负极柜隔离开关、轨电位、上网隔离开关、隔离开关 +type TwoPositionSwitch struct { + Position consts.SwitchTwoPosition +} + +// ///////////////////////////////////////// + +// ThreePositionSwitch 三工位开关 +// 对于三工位隔离开关,规定:ClosedPosition1-合闸到工作位,ClosedPosition2-合闸到接地位 +type ThreePositionSwitch struct { + Position consts.SwitchThreePosition +} + +///////////////////////////////////////////// + +// HandcartSwitch 手车式开关 +type HandcartSwitch struct { + Position consts.HandcarPosition +} + +////////////////////////////////////////// + +// ElecDevice 一般电力设备 +// 如:变压器、整流器 +// Epu所有状态如:35kV进线柜、35kV出线柜、1500V直流进线柜、配电变馈线柜、整流变馈线柜、35kV母联柜、500V直流馈线柜、1500V直流馈线柜、1500V直流负极柜 +// Epu状态中除去报警,如:400V进线柜、400V母联柜、三级负荷总开关、上网隔离开关柜、接口柜 +type ElecDevice struct { + State consts.EpuStateEnum +} + +// DeviceNet 设备联网状态 +type DeviceNet struct { + Online bool //true-网络通信正常,false-通信中断 +} + +var ( + ElecDeviceType = ecs.NewComponentType[ElecDevice]() + DeviceNetType = ecs.NewComponentType[DeviceNet]() + HandcartSwitchType = ecs.NewComponentType[HandcartSwitch]() + ThreePositionSwitchType = ecs.NewComponentType[ThreePositionSwitch]() + TwoPositionSwitchType = ecs.NewComponentType[TwoPositionSwitch]() + TransBusbarType = ecs.NewComponentType[TransBusbar]() +) diff --git a/consts/pscada.go b/consts/pscada.go new file mode 100644 index 0000000..edec412 --- /dev/null +++ b/consts/pscada.go @@ -0,0 +1,58 @@ +package consts + +// 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 //静态 +) + +// SwitchThreePosition 三工位开关位置定义 +type SwitchThreePosition = uint8 + +const ( + StpClosedPosition1 SwitchThreePosition = iota + 1 //开关合闸到位置1,与位置1线路导通 + StpClosedPosition2 //开关合闸到位置2,与位置2线路导通 + StpOpened //开关分闸,线路断开,未与任何位置接通 + StpFault //异常 +) + +// SwitchTwoPosition 两工位开关位置定义 +type SwitchTwoPosition = uint8 + +const ( + S2pClosed SwitchTwoPosition = iota + 1 //开关合闸到位,与线路导通 + S2pOpened //开关分闸,线路断开,未与任何位置接通 + S2pFault //故障异常 +) + +// HandcarPosition 手车式开关位置定义 +type HandcarPosition = uint8 + +const ( + HpClosed HandcarPosition = iota + 1 //工作位合闸 + HpOpened //工作位分闸 + HpTest //实验位 +) + +// EpuStateEnum 一般电力设备状态定义 +type EpuStateEnum = uint8 + +const ( + EpuNormal EpuStateEnum = iota + 1 //正常 + EpuFault //故障,有预告信号产生 + EpuAlarm //报警,有事故信号产生 +) diff --git a/entity/pscada.go b/entity/pscada.go new file mode 100644 index 0000000..3fb32f5 --- /dev/null +++ b/entity/pscada.go @@ -0,0 +1,56 @@ +package entity + +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/consts" +) + +// NewTwoPositionSwitchEntity 创建两工位开关实体 +// 如断路器 +// 如PT、负极柜隔离开关、轨电位、上网隔离开关、隔离开关 +func NewTwoPositionSwitchEntity(w ecs.World, id string) *ecs.Entry { + e := w.Entry(w.Create(component.UidType, component.TwoPositionSwitchType, component.DeviceNetType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + component.TwoPositionSwitchType.Set(e, &component.TwoPositionSwitch{Position: consts.S2pOpened}) + component.DeviceNetType.Set(e, &component.DeviceNet{Online: true}) + return e +} + +// NewThreePositionSwitchEntity 创建三工位隔离开关实体 +func NewThreePositionSwitchEntity(w ecs.World, id string) *ecs.Entry { + e := w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType, component.DeviceNetType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + component.ThreePositionSwitchType.Set(e, &component.ThreePositionSwitch{Position: consts.StpOpened}) + component.DeviceNetType.Set(e, &component.DeviceNet{Online: true}) + return e +} + +// NewElectricPowerDeviceEntity 创建一般电力设备实体 +// 如:变压器、整流器 +// Epu所有状态如:35kV进线柜、35kV出线柜、1500V直流进线柜、配电变馈线柜、整流变馈线柜、35kV母联柜、500V直流馈线柜、1500V直流馈线柜、1500V直流负极柜 +// Epu状态中除去报警,如:400V进线柜、400V母联柜、三级负荷总开关、上网隔离开关柜、接口柜 +func NewElectricPowerDeviceEntity(w ecs.World, id string) *ecs.Entry { + e := w.Entry(w.Create(component.UidType, component.ElecDeviceType, component.DeviceNetType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + component.ElecDeviceType.Set(e, &component.ElecDevice{State: consts.EpuNormal}) + component.DeviceNetType.Set(e, &component.DeviceNet{Online: true}) + return e +} + +// NewHandcartSwitchEntity 创建手车实体 +func NewHandcartSwitchEntity(w ecs.World, id string) *ecs.Entry { + e := w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType, component.DeviceNetType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + component.HandcartSwitchType.Set(e, &component.HandcartSwitch{Position: consts.HpOpened}) + component.DeviceNetType.Set(e, &component.DeviceNet{Online: true}) + return e +} + +// NewTransBusbarEntity 创建输电母线实体 +func NewTransBusbarEntity(w ecs.World, id string) *ecs.Entry { + e := w.Entry(w.Create(component.UidType, component.TransBusbarType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + component.TransBusbarType.Set(e, &component.TransBusbar{Vl: consts.VlNon, Elec: consts.EywLossing}) + return e +}