ISCS电力系统ecs定义

This commit is contained in:
xzb 2023-12-11 11:09:07 +08:00
parent 357c6ad2c6
commit 9c36ae9581
12 changed files with 309 additions and 297 deletions

View File

@ -11,10 +11,7 @@ import (
// //
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsWireCabinetState struct { type IscsWireCabinetState struct {
Normal bool //true-正常 State consts.WireCabinetStateEnum
Fault bool //true-故障
Alarm bool //true-报警
Abnormal bool //true-通讯中断/异常
} }
// IscsCircuitBreakerState ISCS断路器状态 // IscsCircuitBreakerState ISCS断路器状态
@ -23,59 +20,42 @@ type IscsWireCabinetState struct {
// //
// 断路器PT、负极柜隔离开关、轨电位、上网隔离开关、隔离开关 // 断路器PT、负极柜隔离开关、轨电位、上网隔离开关、隔离开关
type IscsCircuitBreakerState struct { type IscsCircuitBreakerState struct {
Closed bool //true-合闸 State consts.CircuitBreakerStateEnum
Opened bool //true-开闸
Abnormal bool //true-通讯中断/异常
} }
// IscsRectifierState ISCS整流器状态 // IscsRectifierState ISCS整流器状态
// //
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsRectifierState struct { type IscsRectifierState struct {
Normal bool //true-正常 State consts.RectifierStateEnum
Fault bool //true-故障
Alarm bool //true-报警
CommunicationInterrupt bool //true-通讯中断
} }
// IscsHandcartSwitchState ISCS手车状态 // IscsHandcartSwitchState ISCS手车状态
// //
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsHandcartSwitchState struct { type IscsHandcartSwitchState struct {
WorkPosClosed bool //true-工作位合闸 State consts.HandcartSwitchStateEnum
WorkPosOpened bool //true-工作位分闸
TestPos bool //true-实验位
CommunicationInterrupt bool //true-通讯中断
} }
// IscsVoltageTransformerState ISCS变压器状态 // IscsVoltageTransformerState ISCS变压器状态
// //
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsVoltageTransformerState struct { type IscsVoltageTransformerState struct {
Normal bool //true-正常 State consts.VoltageTransformerStateEnum
Fault bool //true-故障 (注意-变压器110kV/35kv没有此项)
Alarm bool //true-报警
CommunicationInterrupt bool //true-通讯中断
} }
// IscsThreePositionSwitchState ISCS三工位隔离开关状态 // IscsThreePositionSwitchState ISCS三工位隔离开关状态
// //
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsThreePositionSwitchState struct { type IscsThreePositionSwitchState struct {
DisconnectSwitchClosed bool //true-隔离开关合闸 State consts.ThreePositionSwitchStateEnum
LandingSwitchClosed bool //true-接地开关合闸
Opened bool //true-开闸
Abnormal bool //true-异常
CommunicationInterrupt bool //true-通讯中断
} }
// IscsTransBackupZiTouState ISCS母联备自投状态 // IscsTransBusbarState ISCS母联备自投状态
// //
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
type IscsTransBackupZiTouState struct { type IscsTransBusbarState struct {
Input bool //true-备自投投入 State consts.TransBusbarZiTouStateEnum
Exit bool //true-备自投退出
CommunicationInterrupt bool //true-通讯中断
} }
// ISCS 相关设备状态组件 // ISCS 相关设备状态组件
@ -86,17 +66,39 @@ var (
IscsHandcartSwitchStateType = ecs.NewComponentType[IscsHandcartSwitchState]() IscsHandcartSwitchStateType = ecs.NewComponentType[IscsHandcartSwitchState]()
IscsVoltageTransformerStateType = ecs.NewComponentType[IscsVoltageTransformerState]() IscsVoltageTransformerStateType = ecs.NewComponentType[IscsVoltageTransformerState]()
IscsIscsThreePositionSwitchStateType = ecs.NewComponentType[IscsThreePositionSwitchState]() IscsIscsThreePositionSwitchStateType = ecs.NewComponentType[IscsThreePositionSwitchState]()
IscsTransBackupZiTouStateType = ecs.NewComponentType[IscsTransBackupZiTouState]() IscsTransBackupZiTouStateType = ecs.NewComponentType[IscsTransBusbarState]()
) )
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
// TransBusbar 输电母线 // TransBusbar 输电母线
type TransBusbar struct { type TransBusbar struct {
Vl consts.VoltageLevel //电压等级 Vl VoltageLevel //电压等级
Elec consts.ElecYwEnum 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 对一条路通-断控制的开关状态 // TwoPositionSwitch 对一条路通-断控制的开关状态
// 如断路器 // 如断路器
// 如PT、负极柜隔离开关、轨电位、上网隔离开关、隔离开关 // 如PT、负极柜隔离开关、轨电位、上网隔离开关、隔离开关
@ -109,16 +111,34 @@ type TwoPositionSwitch struct {
// ThreePositionSwitch 三工位开关 // ThreePositionSwitch 三工位开关
// 对于三工位隔离开关规定ClosedPosition1-合闸到工作位ClosedPosition2-合闸到接地位 // 对于三工位隔离开关规定ClosedPosition1-合闸到工作位ClosedPosition2-合闸到接地位
type ThreePositionSwitch struct { type ThreePositionSwitch struct {
Position consts.SwitchThreePosition //合闸到位置1与位置1线路导通;合闸到位置2与位置2线路导通;分闸,线路断开,未与任何位置接通 Position SwitchThreePosition //合闸到位置1与位置1线路导通;合闸到位置2与位置2线路导通;分闸,线路断开,未与任何位置接通
} }
// SwitchThreePosition 三工位开关位置定义
type SwitchThreePosition = uint8
const (
StpOpened SwitchThreePosition = iota //开关分闸,线路断开,未与任何位置接通
StpClosedPosition1 //开关合闸到位置1与位置1线路导通
StpClosedPosition2 //开关合闸到位置2与位置2线路导通
)
///////////////////////////////////////////// /////////////////////////////////////////////
// HandcartSwitch 手车式开关 // HandcartSwitch 手车式开关
type HandcartSwitch struct { type HandcartSwitch struct {
Position consts.HandcarPosition Position HandcarPosition
} }
// HandcarPosition 手车式开关位置定义
type HandcarPosition = uint8
const (
HpOpened HandcarPosition = iota //工作位分闸
HpClosed //工作位合闸
HpTest //实验位
)
////////////////////////////////////////// //////////////////////////////////////////
// ElecDevice 一般电力设备 // ElecDevice 一般电力设备

View File

@ -1,39 +1,71 @@
package consts package consts
// VoltageLevel 电压等级定义 // VoltageTransformerStateEnum ISCS变压器状态
type VoltageLevel = uint8 type VoltageTransformerStateEnum = int8
const ( const (
VlNon VoltageLevel = iota //未知电压等级 VtfNormal VoltageTransformerStateEnum = iota //正常
VlAc110Kv //110kV交流电 红色 VtfFault //故障 (注意-变压器110kV/35kv没有此项)
VlAc35Kv //35kV交流电 黄色 VtfAlarm //报警
VlAc400V //400V交流电 浅蓝色 VtfCommunicationInterrupt //通讯中断
VlDc1500V //1500V直流电
) )
// ElecYwEnum 电的有无定义 // TransBusbarZiTouStateEnum ISCS母联备自投状态
type ElecYwEnum = uint8 type TransBusbarZiTouStateEnum = int8
const ( const (
EywLossing ElecYwEnum = iota //失电,未受电 TbztExit TransBusbarZiTouStateEnum = iota //备自投退出
EywReceiving //受电 TbztInput //备自投投入
EywStatic //静态 TbztCommunicationInterrupt //通讯中断
) )
// SwitchThreePosition 三工位开关位置定义 // ThreePositionSwitchStateEnum ISCS三工位隔离开关状态
type SwitchThreePosition = uint8 type ThreePositionSwitchStateEnum = int8
// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户
const (
TpsOpened ThreePositionSwitchStateEnum = iota //开闸
TpsDisconnectSwitchClosed //隔离开关合闸
TpsLandingSwitchClosed //接地开关合闸
TpsAbnormal //异常
TpsCommunicationInterrupt //通讯中断
)
// HandcartSwitchStateEnum ISCS手车状态
type HandcartSwitchStateEnum = int8
const ( const (
StpOpened SwitchThreePosition = iota //开关分闸,线路断开,未与任何位置接通 HcsWorkPosOpened HandcartSwitchStateEnum = iota //工作位分闸
StpClosedPosition1 //开关合闸到位置1与位置1线路导通 HcsWorkPosClosed //工作位合闸
StpClosedPosition2 //开关合闸到位置2与位置2线路导通 HcsTestPos //实验位
HcsCommunicationInterrupt //通讯中断
) )
// HandcarPosition 手车式开关位置定义 // RectifierStateEnum ISCS整流器状态
type HandcarPosition = uint8 type RectifierStateEnum = int8
const ( const (
HpOpened HandcarPosition = iota //工作位分闸 RsNormal RectifierStateEnum = iota //正常
HpClosed //工作位合闸 RsFault //故障
HpTest //实验位 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

@ -3,7 +3,6 @@ package entity
import ( import (
"joylink.club/ecs" "joylink.club/ecs"
"joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/consts"
) )
// 电力监控系统相关实体创建 // 电力监控系统相关实体创建
@ -58,7 +57,7 @@ func NewIscsThreePositionSwitchEntity(w ecs.World, id string) *ecs.Entry {
func NewIscsTransBusbarEntity(w ecs.World, id string, haveBackupZiTou bool) *ecs.Entry { func NewIscsTransBusbarEntity(w ecs.World, id string, haveBackupZiTou bool) *ecs.Entry {
entry := w.Entry(w.Create(component.UidType, component.TransBusbarType)) entry := w.Entry(w.Create(component.UidType, component.TransBusbarType))
component.UidType.SetValue(entry, component.Uid{Id: id}) component.UidType.SetValue(entry, component.Uid{Id: id})
component.TransBusbarType.Set(entry, &component.TransBusbar{Vl: consts.VlNon, Elec: consts.EywLossing}) component.TransBusbarType.Set(entry, &component.TransBusbar{Vl: component.VlNon, Elec: component.EywLossing})
// //
if haveBackupZiTou { if haveBackupZiTou {
entry.AddComponent(component.IscsTransBackupZiTouStateType) entry.AddComponent(component.IscsTransBackupZiTouStateType)
@ -83,7 +82,7 @@ func NewTwoPositionSwitchEntity(w ecs.World, id string) *ecs.Entry {
func NewThreePositionSwitchEntity(w ecs.World, id string) *ecs.Entry { func NewThreePositionSwitchEntity(w ecs.World, id string) *ecs.Entry {
e := w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType)) e := w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType))
component.UidType.SetValue(e, component.Uid{Id: id}) component.UidType.SetValue(e, component.Uid{Id: id})
component.ThreePositionSwitchType.Set(e, &component.ThreePositionSwitch{Position: consts.StpOpened}) component.ThreePositionSwitchType.Set(e, &component.ThreePositionSwitch{Position: component.StpOpened})
return e return e
} }
@ -102,7 +101,7 @@ func NewElectricPowerDeviceEntity(w ecs.World, id string) *ecs.Entry {
func NewHandcartSwitchEntity(w ecs.World, id string) *ecs.Entry { func NewHandcartSwitchEntity(w ecs.World, id string) *ecs.Entry {
e := w.Entry(w.Create(component.UidType, component.HandcartSwitchType)) e := w.Entry(w.Create(component.UidType, component.HandcartSwitchType))
component.UidType.SetValue(e, component.Uid{Id: id}) component.UidType.SetValue(e, component.Uid{Id: id})
component.HandcartSwitchType.Set(e, &component.HandcartSwitch{Position: consts.HpOpened}) component.HandcartSwitchType.Set(e, &component.HandcartSwitch{Position: component.HpOpened})
return e return e
} }
@ -110,6 +109,6 @@ func NewHandcartSwitchEntity(w ecs.World, id string) *ecs.Entry {
func NewTransBusbarEntity(w ecs.World, id string) *ecs.Entry { func NewTransBusbarEntity(w ecs.World, id string) *ecs.Entry {
e := w.Entry(w.Create(component.UidType, component.TransBusbarType)) e := w.Entry(w.Create(component.UidType, component.TransBusbarType))
component.UidType.SetValue(e, component.Uid{Id: id}) component.UidType.SetValue(e, component.Uid{Id: id})
component.TransBusbarType.Set(e, &component.TransBusbar{Vl: consts.VlNon, Elec: consts.EywLossing}) component.TransBusbarType.Set(e, &component.TransBusbar{Vl: component.VlNon, Elec: component.EywLossing})
return e return e
} }

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"joylink.club/ecs" "joylink.club/ecs"
"joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/consts"
"joylink.club/rtsssimulation/entity" "joylink.club/rtsssimulation/entity"
) )
@ -173,16 +172,16 @@ func ThreePositionSwitchOperate(w ecs.World, deviceId string, opt SwitchThreePos
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId)) return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
} }
// //
optConvert := func(opt SwitchThreePositionOptEnum) (consts.SwitchThreePosition, error) { optConvert := func(opt SwitchThreePositionOptEnum) (component.SwitchThreePosition, error) {
switch opt { switch opt {
case StpOpened: case StpOpened:
return consts.StpOpened, nil return component.StpOpened, nil
case StpClosedPosition1: case StpClosedPosition1:
return consts.StpClosedPosition1, nil return component.StpClosedPosition1, nil
case StpClosedPosition2: case StpClosedPosition2:
return consts.StpClosedPosition2, nil return component.StpClosedPosition2, nil
default: default:
return consts.StpOpened, fmt.Errorf("三工位开关操作[%d]不存在", opt) return component.StpOpened, fmt.Errorf("三工位开关操作[%d]不存在", opt)
} }
} }
// //
@ -222,16 +221,16 @@ func HandcartSwitchOperate(w ecs.World, deviceId string, opt HandcartSwitchOptEn
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId)) return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
} }
// //
optConvert := func(opt HandcartSwitchOptEnum) (consts.HandcarPosition, error) { optConvert := func(opt HandcartSwitchOptEnum) (component.HandcarPosition, error) {
switch opt { switch opt {
case HpOpened: case HpOpened:
return consts.HpOpened, nil return component.HpOpened, nil
case HpClosed: case HpClosed:
return consts.HpClosed, nil return component.HpClosed, nil
case HpTest: case HpTest:
return consts.HpTest, nil return component.HpTest, nil
default: default:
return consts.StpOpened, fmt.Errorf("手车式开关操作[%d]不存在", opt) return component.StpOpened, fmt.Errorf("手车式开关操作[%d]不存在", opt)
} }
} }
// //

View File

@ -1,32 +0,0 @@
package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// IscsCircuitBreakerSystem ISCS 断路器
type IscsCircuitBreakerSystem struct {
query *ecs.Query
}
func NewIscsCircuitBreakerSystem() *IscsCircuitBreakerSystem {
return &IscsCircuitBreakerSystem{
query: ecs.NewQuery(filter.Contains(component.IscsCircuitBreakerStateType, component.TwoPositionSwitchType)),
}
}
func (s *IscsCircuitBreakerSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
state := component.IscsCircuitBreakerStateType.Get(entry)
tpSwitch := component.TwoPositionSwitchType.Get(entry)
//
state.Abnormal = entry.HasComponent(component.DeviceCommunicationInterruptTag) || entry.HasComponent(component.DeviceAbnormalTag)
if state.Abnormal { //当开关异常时,断开
tpSwitch.Closed = false
}
//
state.Closed = tpSwitch.Closed
state.Opened = !tpSwitch.Closed
})
}

View File

@ -1,34 +0,0 @@
package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/consts"
)
type IscsHandcartSwitchSystem struct {
query *ecs.Query
}
func NewIscsHandcartSwitchSystem() *IscsHandcartSwitchSystem {
return &IscsHandcartSwitchSystem{
query: ecs.NewQuery(filter.Contains(component.IscsHandcartSwitchStateType, component.HandcartSwitchType)),
}
}
func (s *IscsHandcartSwitchSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
state := component.IscsHandcartSwitchStateType.Get(entry)
hdSwitch := component.HandcartSwitchType.Get(entry)
//
state.CommunicationInterrupt = entry.HasComponent(component.DeviceCommunicationInterruptTag)
//
if state.CommunicationInterrupt { //不正常,开关断开
hdSwitch.Position = consts.HpOpened
}
//
state.WorkPosClosed = hdSwitch.Position == consts.HpClosed
state.WorkPosOpened = hdSwitch.Position == consts.HpOpened
state.TestPos = hdSwitch.Position == consts.HpTest
})
}

187
sys/iscs_sys/iscs_pscada.go Normal file
View File

@ -0,0 +1,187 @@
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
}
})
}

View File

@ -1,29 +0,0 @@
package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// IscsRectifierSystem ISCS整流器
type IscsRectifierSystem struct {
query *ecs.Query
}
func NewIscsRectifierSystem() *IscsRectifierSystem {
return &IscsRectifierSystem{query: ecs.NewQuery(filter.Contains(component.IscsRectifierStateType, component.ElecDeviceType))}
}
func (s *IscsRectifierSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
state := component.IscsRectifierStateType.Get(entry)
//
state.Fault = entry.HasComponent(component.DeviceFaultTag)
state.Alarm = entry.HasComponent(component.DeviceAlarmTag)
state.CommunicationInterrupt = entry.HasComponent(component.DeviceCommunicationInterruptTag)
//
component.ElecDeviceType.Get(entry).Normal = !state.Fault && !state.Alarm && !state.CommunicationInterrupt
//
state.Normal = component.ElecDeviceType.Get(entry).Normal
})
}

View File

@ -1,38 +0,0 @@
package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/consts"
)
// IscsThreePositionSwitchSystem 三工位开关
type IscsThreePositionSwitchSystem struct {
query *ecs.Query
}
func NewIscsThreePositionSwitchSystem() *IscsThreePositionSwitchSystem {
return &IscsThreePositionSwitchSystem{
query: ecs.NewQuery(filter.Contains(component.IscsIscsThreePositionSwitchStateType, component.ThreePositionSwitchType)),
}
}
func (s *IscsThreePositionSwitchSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
state := component.IscsIscsThreePositionSwitchStateType.Get(entry)
tpSwitch := component.ThreePositionSwitchType.Get(entry)
//
state.Abnormal = entry.HasComponent(component.DeviceAbnormalTag)
state.CommunicationInterrupt = entry.HasComponent(component.DeviceCommunicationInterruptTag)
//
isTpSwitchNormal := !state.Abnormal && !state.CommunicationInterrupt
//
if !isTpSwitchNormal { //当开关不正常时,断开开关设备
tpSwitch.Position = consts.StpOpened
}
//
state.Opened = tpSwitch.Position == consts.StpOpened
state.DisconnectSwitchClosed = tpSwitch.Position == consts.StpClosedPosition1
state.LandingSwitchClosed = tpSwitch.Position == consts.StpClosedPosition2
})
}

View File

@ -1,31 +0,0 @@
package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// IscsTransBusbarSystem ISCS电力母线
type IscsTransBusbarSystem struct {
backupZiTouQuery *ecs.Query //备自投
}
func NewIscsTransBusbarSystem() *IscsTransBusbarSystem {
return &IscsTransBusbarSystem{
backupZiTouQuery: ecs.NewQuery(filter.Contains(component.IscsTransBackupZiTouStateType)),
}
}
func (s *IscsTransBusbarSystem) Update(w ecs.World) {
s.backupZiTouQuery.Each(w, func(entry *ecs.Entry) {
s.calculateBackupZiTou(entry)
})
}
// 备自投 状态处理
func (s *IscsTransBusbarSystem) calculateBackupZiTou(entry *ecs.Entry) {
ziTouState := component.IscsTransBackupZiTouStateType.Get(entry)
ziTouState.CommunicationInterrupt = entry.HasComponent(component.DeviceCommunicationInterruptTag)
ziTouState.Input = entry.HasComponent(component.BackupZiTouInputTag)
ziTouState.Exit = !entry.HasComponent(component.BackupZiTouInputTag)
}

View File

@ -1,32 +0,0 @@
package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// IscsVoltageTransformerSystem ISCS变压器
type IscsVoltageTransformerSystem struct {
query *ecs.Query
}
func NewIscsVoltageTransformerSystem() *IscsVoltageTransformerSystem {
return &IscsVoltageTransformerSystem{
query: ecs.NewQuery(filter.Contains(component.IscsVoltageTransformerStateType, component.ElecDeviceType)),
}
}
func (s *IscsVoltageTransformerSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
state := component.IscsVoltageTransformerStateType.Get(entry)
vt := component.ElecDeviceType.Get(entry)
//
state.Fault = entry.HasComponent(component.DeviceFaultTag)
state.Alarm = entry.HasComponent(component.DeviceAlarmTag)
state.CommunicationInterrupt = entry.HasComponent(component.DeviceCommunicationInterruptTag)
//
vt.Normal = !state.Fault && !state.Alarm && !state.CommunicationInterrupt
//
state.Normal = vt.Normal
})
}

View File

@ -1,29 +0,0 @@
package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// IscsWireCabinetSystem ISCS 线柜
type IscsWireCabinetSystem struct {
query *ecs.Query
}
func NewIscsWireCabinetSystem() *IscsWireCabinetSystem {
return &IscsWireCabinetSystem{query: ecs.NewQuery(filter.Contains(component.IscsWireCabinetStateType, component.ElecDeviceType))}
}
func (s *IscsWireCabinetSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
state := component.IscsWireCabinetStateType.Get(entry)
//
state.Fault = entry.HasComponent(component.DeviceFaultTag)
state.Alarm = entry.HasComponent(component.DeviceAlarmTag)
state.Abnormal = entry.HasComponent(component.DeviceAbnormalTag) || entry.HasComponent(component.DeviceCommunicationInterruptTag)
//
component.ElecDeviceType.Get(entry).Normal = !state.Fault && !state.Alarm && !state.Abnormal
//
state.Normal = component.ElecDeviceType.Get(entry).Normal
})
}