diff --git a/component/pscada.go b/component/pscada.go index 87a8470..011bc32 100644 --- a/component/pscada.go +++ b/component/pscada.go @@ -11,10 +11,7 @@ import ( // // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 type IscsWireCabinetState struct { - Normal bool //true-正常 - Fault bool //true-故障 - Alarm bool //true-报警 - Abnormal bool //true-通讯中断/异常 + State consts.WireCabinetStateEnum } // IscsCircuitBreakerState ISCS断路器状态 @@ -23,59 +20,42 @@ type IscsWireCabinetState struct { // // 断路器;PT、负极柜隔离开关、轨电位、上网隔离开关、隔离开关 type IscsCircuitBreakerState struct { - Closed bool //true-合闸 - Opened bool //true-开闸 - Abnormal bool //true-通讯中断/异常 + State consts.CircuitBreakerStateEnum } // IscsRectifierState ISCS整流器状态 // // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 type IscsRectifierState struct { - Normal bool //true-正常 - Fault bool //true-故障 - Alarm bool //true-报警 - CommunicationInterrupt bool //true-通讯中断 + State consts.RectifierStateEnum } // IscsHandcartSwitchState ISCS手车状态 // // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 type IscsHandcartSwitchState struct { - WorkPosClosed bool //true-工作位合闸 - WorkPosOpened bool //true-工作位分闸 - TestPos bool //true-实验位 - CommunicationInterrupt bool //true-通讯中断 + State consts.HandcartSwitchStateEnum } // IscsVoltageTransformerState ISCS变压器状态 // // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 type IscsVoltageTransformerState struct { - Normal bool //true-正常 - Fault bool //true-故障 (注意-变压器110kV/35kv没有此项) - Alarm bool //true-报警 - CommunicationInterrupt bool //true-通讯中断 + State consts.VoltageTransformerStateEnum } // IscsThreePositionSwitchState ISCS三工位隔离开关状态 // // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 type IscsThreePositionSwitchState struct { - DisconnectSwitchClosed bool //true-隔离开关合闸 - LandingSwitchClosed bool //true-接地开关合闸 - Opened bool //true-开闸 - Abnormal bool //true-异常 - CommunicationInterrupt bool //true-通讯中断 + State consts.ThreePositionSwitchStateEnum } -// IscsTransBackupZiTouState ISCS母联备自投状态 +// IscsTransBusbarState ISCS母联备自投状态 // // 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 -type IscsTransBackupZiTouState struct { - Input bool //true-备自投投入 - Exit bool //true-备自投退出 - CommunicationInterrupt bool //true-通讯中断 +type IscsTransBusbarState struct { + State consts.TransBusbarZiTouStateEnum } // ISCS 相关设备状态组件 @@ -86,17 +66,39 @@ var ( IscsHandcartSwitchStateType = ecs.NewComponentType[IscsHandcartSwitchState]() IscsVoltageTransformerStateType = ecs.NewComponentType[IscsVoltageTransformerState]() IscsIscsThreePositionSwitchStateType = ecs.NewComponentType[IscsThreePositionSwitchState]() - IscsTransBackupZiTouStateType = ecs.NewComponentType[IscsTransBackupZiTouState]() + IscsTransBackupZiTouStateType = ecs.NewComponentType[IscsTransBusbarState]() ) ///////////////////////////////////////////////////////// // TransBusbar 输电母线 type TransBusbar struct { - Vl consts.VoltageLevel //电压等级 - Elec consts.ElecYwEnum + 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、负极柜隔离开关、轨电位、上网隔离开关、隔离开关 @@ -109,16 +111,34 @@ type TwoPositionSwitch struct { // ThreePositionSwitch 三工位开关 // 对于三工位隔离开关,规定:ClosedPosition1-合闸到工作位,ClosedPosition2-合闸到接地位 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 手车式开关 type HandcartSwitch struct { - Position consts.HandcarPosition + Position HandcarPosition } +// HandcarPosition 手车式开关位置定义 +type HandcarPosition = uint8 + +const ( + HpOpened HandcarPosition = iota //工作位分闸 + HpClosed //工作位合闸 + HpTest //实验位 +) + ////////////////////////////////////////// // ElecDevice 一般电力设备 diff --git a/consts/pscada.go b/consts/pscada.go index f24bbc3..90ecac1 100644 --- a/consts/pscada.go +++ b/consts/pscada.go @@ -1,39 +1,71 @@ package consts -// VoltageLevel 电压等级定义 -type VoltageLevel = uint8 +// VoltageTransformerStateEnum ISCS变压器状态 +type VoltageTransformerStateEnum = int8 const ( - VlNon VoltageLevel = iota //未知电压等级 - VlAc110Kv //110kV交流电 红色 - VlAc35Kv //35kV交流电 黄色 - VlAc400V //400V交流电 浅蓝色 - VlDc1500V //1500V直流电 + VtfNormal VoltageTransformerStateEnum = iota //正常 + VtfFault //故障 (注意-变压器110kV/35kv没有此项) + VtfAlarm //报警 + VtfCommunicationInterrupt //通讯中断 ) -// ElecYwEnum 电的有无定义 -type ElecYwEnum = uint8 +// TransBusbarZiTouStateEnum ISCS母联备自投状态 +type TransBusbarZiTouStateEnum = int8 const ( - EywLossing ElecYwEnum = iota //失电,未受电 - EywReceiving //受电 - EywStatic //静态 + TbztExit TransBusbarZiTouStateEnum = iota //备自投退出 + TbztInput //备自投投入 + TbztCommunicationInterrupt //通讯中断 ) -// SwitchThreePosition 三工位开关位置定义 -type SwitchThreePosition = uint8 +// ThreePositionSwitchStateEnum ISCS三工位隔离开关状态 +type ThreePositionSwitchStateEnum = int8 + +// 状态由该设备的其他组件运算得到,该状态组件对外为只读组件,面向用户 +const ( + TpsOpened ThreePositionSwitchStateEnum = iota //开闸 + TpsDisconnectSwitchClosed //隔离开关合闸 + TpsLandingSwitchClosed //接地开关合闸 + TpsAbnormal //异常 + TpsCommunicationInterrupt //通讯中断 +) + +// HandcartSwitchStateEnum ISCS手车状态 +type HandcartSwitchStateEnum = int8 const ( - StpOpened SwitchThreePosition = iota //开关分闸,线路断开,未与任何位置接通 - StpClosedPosition1 //开关合闸到位置1,与位置1线路导通 - StpClosedPosition2 //开关合闸到位置2,与位置2线路导通 + HcsWorkPosOpened HandcartSwitchStateEnum = iota //工作位分闸 + HcsWorkPosClosed //工作位合闸 + HcsTestPos //实验位 + HcsCommunicationInterrupt //通讯中断 ) -// HandcarPosition 手车式开关位置定义 -type HandcarPosition = uint8 +// RectifierStateEnum ISCS整流器状态 +type RectifierStateEnum = int8 const ( - HpOpened HandcarPosition = iota //工作位分闸 - HpClosed //工作位合闸 - HpTest //实验位 + 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 //通讯中断/异常 ) diff --git a/entity/iscs_pscada.go b/entity/iscs_pscada.go index 992b616..c92c6cf 100644 --- a/entity/iscs_pscada.go +++ b/entity/iscs_pscada.go @@ -3,7 +3,6 @@ package entity import ( "joylink.club/ecs" "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 { entry := w.Entry(w.Create(component.UidType, component.TransBusbarType)) 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 { 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 { e := w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType)) 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 } @@ -102,7 +101,7 @@ func NewElectricPowerDeviceEntity(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)) 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 } @@ -110,6 +109,6 @@ func NewHandcartSwitchEntity(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)) 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 } diff --git a/fi/pscada.go b/fi/pscada.go index a133a08..3b110e1 100644 --- a/fi/pscada.go +++ b/fi/pscada.go @@ -4,7 +4,6 @@ import ( "fmt" "joylink.club/ecs" "joylink.club/rtsssimulation/component" - "joylink.club/rtsssimulation/consts" "joylink.club/rtsssimulation/entity" ) @@ -173,16 +172,16 @@ func ThreePositionSwitchOperate(w ecs.World, deviceId string, opt SwitchThreePos return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId)) } // - optConvert := func(opt SwitchThreePositionOptEnum) (consts.SwitchThreePosition, error) { + optConvert := func(opt SwitchThreePositionOptEnum) (component.SwitchThreePosition, error) { switch opt { case StpOpened: - return consts.StpOpened, nil + return component.StpOpened, nil case StpClosedPosition1: - return consts.StpClosedPosition1, nil + return component.StpClosedPosition1, nil case StpClosedPosition2: - return consts.StpClosedPosition2, nil + return component.StpClosedPosition2, nil 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)) } // - optConvert := func(opt HandcartSwitchOptEnum) (consts.HandcarPosition, error) { + optConvert := func(opt HandcartSwitchOptEnum) (component.HandcarPosition, error) { switch opt { case HpOpened: - return consts.HpOpened, nil + return component.HpOpened, nil case HpClosed: - return consts.HpClosed, nil + return component.HpClosed, nil case HpTest: - return consts.HpTest, nil + return component.HpTest, nil default: - return consts.StpOpened, fmt.Errorf("手车式开关操作[%d]不存在", opt) + return component.StpOpened, fmt.Errorf("手车式开关操作[%d]不存在", opt) } } // diff --git a/sys/iscs_sys/iscs_circuit_breaker.go b/sys/iscs_sys/iscs_circuit_breaker.go deleted file mode 100644 index d081ddb..0000000 --- a/sys/iscs_sys/iscs_circuit_breaker.go +++ /dev/null @@ -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 - }) -} diff --git a/sys/iscs_sys/iscs_handcart_switch.go b/sys/iscs_sys/iscs_handcart_switch.go deleted file mode 100644 index 107e3c1..0000000 --- a/sys/iscs_sys/iscs_handcart_switch.go +++ /dev/null @@ -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 - }) -} diff --git a/sys/iscs_sys/iscs_pscada.go b/sys/iscs_sys/iscs_pscada.go new file mode 100644 index 0000000..ee2d636 --- /dev/null +++ b/sys/iscs_sys/iscs_pscada.go @@ -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 + } + }) +} diff --git a/sys/iscs_sys/iscs_rectifier.go b/sys/iscs_sys/iscs_rectifier.go deleted file mode 100644 index cf84685..0000000 --- a/sys/iscs_sys/iscs_rectifier.go +++ /dev/null @@ -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 - }) -} diff --git a/sys/iscs_sys/iscs_three_position_switch.go b/sys/iscs_sys/iscs_three_position_switch.go deleted file mode 100644 index e777234..0000000 --- a/sys/iscs_sys/iscs_three_position_switch.go +++ /dev/null @@ -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 - }) -} diff --git a/sys/iscs_sys/iscs_trans_busbar.go b/sys/iscs_sys/iscs_trans_busbar.go deleted file mode 100644 index fa6bf9b..0000000 --- a/sys/iscs_sys/iscs_trans_busbar.go +++ /dev/null @@ -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) -} diff --git a/sys/iscs_sys/iscs_voltage_transformer.go b/sys/iscs_sys/iscs_voltage_transformer.go deleted file mode 100644 index e886e3f..0000000 --- a/sys/iscs_sys/iscs_voltage_transformer.go +++ /dev/null @@ -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 - }) -} diff --git a/sys/iscs_sys/iscs_wire_cabinet.go b/sys/iscs_sys/iscs_wire_cabinet.go deleted file mode 100644 index 881905e..0000000 --- a/sys/iscs_sys/iscs_wire_cabinet.go +++ /dev/null @@ -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 - }) -}