Interface OpenemsComponent
-
- All Known Subinterfaces:
ActivePowerVoltageCharacteristic
,AllAlphabeticallyScheduler
,AppManager
,AsymmetricEss
,AsymmetricMeter
,AsymmetricMeterEvcs
,Awattar
,BackendApi
,BalancingSchedule
,Battery
,BatteryBoxC130
,BmwBattery
,BoschBpts5HybridCore
,BpCharger
,BpCore
,BpEss
,BpPvInverter
,BridgeModbus
,BridgeModbusSerial
,BridgeModbusTcp
,BridgeOnewire
,ChannelSingleThreshold
,ClusterVersionC
,ComponentManager
,ComponentManagerProvider
,Controller
,Corrently
,Cycle
,DailyScheduler
,DebugLog
,DelayedSellToGrid
,DigitalInput
,DigitalOutput
,Edge2Edge
,Edge2EdgeEss
,EmergencyCapacityReserve
,EssCluster
,EssCycle
,EssDcCharger
,EssDcChargerFeneconCommercial40
,EssFeneconCommercial40
,EssFixActivePower
,EssLinearPowerBand
,EssSellToGridLimit
,Evcs
,EvcsCluster
,FeneconCommercialBattery
,FeneconDessCharger
,FeneconDessEss
,FeneconDessGridMeter
,FeneconDessPvMeter
,FeneconHomeBattery
,FeneconMiniEss
,FeneconMiniGridMeter
,FeneconMiniPvMeter
,FixedOrderScheduler
,GenericManagedEss
,GenericManagedSymmetricEss
,GenericOffGridEss
,GoodWe
,GoodWeBatteryInverter
,GoodWeEmergencyPowerMeter
,GoodWeEss
,GoodWeEtCharger
,GoodWeGridMeter
,GridOptimizedCharge
,HeatPump
,Host
,HybridEss
,HybridManagedSymmetricBatteryInverter
,InfluxTimedata
,KacoBlueplanetGridsave
,KmtronicRelay4Port
,KmtronicRelay8Port
,LimitTotalDischargeController
,ManagedAsymmetricEss
,ManagedEvcs
,ManagedSinglePhaseEss
,ManagedSymmetricBatteryInverter
,ManagedSymmetricEss
,ManagedSymmetricPvInverter
,MeasuringEvcs
,Meta
,MetaEss
,MeterBControlEM300
,MeterBgeTechDrt428M2
,MeterCarloGavazziEm300
,MeterJanitzaUmg511
,MeterJanitzaUmg604
,MeterKdk2puct
,MeterMicrocareSdm630
,MeterPqplusUmd96
,MeterPqplusUmd97
,MeterZiehlEfr4001Ip
,ModbusComponent
,ModbusSlave
,ModbusTcpApi
,ModbusTcpApiReadOnly
,ModbusTcpApiReadWrite
,MqttApiController
,OffGridBatteryInverter
,OffGridEss
,OffGridSwitch
,PersistenceModelPredictor
,PlexlogDatalogger
,PowerComponent
,Predictor24Hours
,PredictorManager
,ReactivePowerVoltageCharacteristic
,RefuStore88k
,RestApi
,RestApiReadOnly
,RestApiReadWrite
,Rrd4jTimedata
,Scheduler
,Shelly25
,ShellyPlug
,SiemensPacMeter
,SimilarDayPredictor
,SimulatedThermometer
,Sinexcel
,SinglePhaseEss
,SinglePhaseMeter
,SingleRackVersionB
,SingleRackVersionC
,SocEvcs
,SocomecMeter
,SocomecMeterSinglephase
,SocomecMeterThreephase
,SolarLog
,SoltaroBatteryVersionC
,SoltaroCluster
,StandbyController
,StartStoppable
,Sum
,SunnyIslandEss
,SurplusFeedToGridController
,SymmetricBatteryInverter
,SymmetricEss
,SymmetricMeter
,TeslaPowerwall2Core
,Thermometer
,Tibber
,Timedata
,TimedataProvider
,TimeOfUseTariffDischarge
,Vectis
,VirtualMeter
,WeidmuellerUR20
- All Known Implementing Classes:
Abl
,AbstractCsvDatasource
,AbstractEdge2Edge
,AbstractEssDcChargerFeneconCommercial40
,AbstractFeneconDessCharger
,AbstractGenericManagedEss
,AbstractGoodWe
,AbstractGoodWeEtCharger
,AbstractKmtronicRelay
,AbstractManagedEvcsComponent
,AbstractManagedOcppEvcsComponent
,AbstractModbusBridge
,AbstractModbusTcpApi
,AbstractOpenemsComponent
,AbstractOpenemsMbusComponent
,AbstractOpenemsModbusComponent
,AbstractOpenemsSunSpecComponent
,AbstractPredictor24Hours
,AbstractRestApi
,AbstractSocomecMeter
,AbstractSunSpecBatteryInverter
,AbstractSunSpecMeter
,AbstractSunSpecPvInverter
,AcIsland
,ActivePowerVoltageCharacteristicImpl
,AdstecStoraxeEssImpl
,AllAlphabeticallySchedulerImpl
,AppManagerImpl
,AsymmetricFixActivePower
,AsymmetricFixReactivePower
,AwattarImpl
,BackendApiImpl
,Balancing
,BalancingScheduleImpl
,BatteryBoxC130Impl
,BatteryDummy
,BmwBatteryImpl
,BoschBpts5HybridCoreImpl
,BoschBpts5HybridEss
,BoschBpts5HybridMeter
,BoschBpts5HybridPv
,BpChargerImpl
,BpCoreImpl
,BpEssImpl
,BpPvInverterImpl
,BridgeMbusImpl
,BridgeModbusSerialImpl
,BridgeModbusTcpImpl
,BridgeOnewireImpl
,BydContainerWatchdog
,ChannelSingleThresholdImpl
,ChannelThreshold
,ClusterVersionB
,ClusterVersionCImpl
,ComponentManagerImpl
,ControllerChpSoc
,ControllerHeatingElementImpl
,CorrentlyImpl
,CosPhi
,CsvDatasourceDirect
,CsvDatasourcePredefined
,CycleImpl
,DailySchedulerImpl
,DebugDetailedLog
,DebugLogImpl
,DelayChargeController
,DelayedSellToGridImpl
,DigitalInputOutput
,DummyAsymmetricMeter
,DummyBattery
,DummyComponentManager
,DummyController
,DummyCycle
,DummyHost
,DummyHybridEss
,DummyInputOutput
,DummyManagedAsymmetricEss
,DummyManagedEvcs
,DummyManagedSymmetricBatteryInverter
,DummyManagedSymmetricEss
,DummyManagedSymmetricPvInverter
,DummyMetaEss
,DummyModbusBridge
,DummyOffGridBatteryInverter
,DummyOffGridSwitch
,DummyPredictor24Hours
,DummyPredictorManager
,DummySum
,DummySymmetricMeter
,DummyTimedata
,Edge2EdgeEssImpl
,EmergencyCapacityReserveImpl
,EssAsymmetric
,EssClusterImpl
,EssCycleImpl
,EssDcChargerFeneconCommercial40Pv1Impl
,EssDcChargerFeneconCommercial40Pv2Impl
,EssFeneconBydContainer
,EssFeneconCommercial40Impl
,EssFixActivePowerImpl
,EssGridcon
,EssGridconOnGrid
,EssGridconOnOffGrid
,EssLinearPowerBandImpl
,EssSellToGridLimitImpl
,EssSinglePhase
,EssSymmetric
,EvcsClusterImpl
,EvcsController
,EvcsFixActivePower
,EvcsPowerComponent
,FeneconCommercialBatteryImpl
,FeneconDessCharger1
,FeneconDessCharger2
,FeneconDessEssImpl
,FeneconDessGridMeterImpl
,FeneconDessPvMeterImpl
,FeneconHomeBatteryImpl
,FeneconMiniEssImpl
,FeneconMiniGridMeterImpl
,FeneconMiniPvMeterImpl
,FeneconProEssImpl
,FeneconProPvMeter
,FixDigitalOutput
,FixedOrderSchedulerImpl
,FroniusPvInverter
,FundamentalFrequency
,GenericManagedSymmetricEssImpl
,GenericOffGridEssImpl
,GoeChargerHomeImpl
,GoodWeBatteryInverterImpl
,GoodWeEmergencyPowerMeterImpl
,GoodWeEssImpl
,GoodWeEtCharger1
,GoodWeEtCharger2
,GoodWeGridMeterImpl
,GridconPcsImpl
,GridMeter
,GridMeter
,GridOptimizedChargeImpl
,HardyBarthImpl
,HeatPumpImpl
,HighLoadTimeslot
,HostImpl
,IesKeywattSingleCcs
,InfluxTimedataImpl
,IoAlarm
,IoOffGridSwitch
,JsonLogicController
,KacoBlueplanet
,KacoBlueplanetGridsaveImpl
,KebaKeContact
,KmtronicRelay4PortImpl
,KmtronicRelay8PortImpl
,KostalPikoCharger
,KostalPikoCoreImpl
,KostalPikoEss
,KostalPikoGridMeter
,KostalPvInverter
,LimitTotalDischargeControllerImpl
,MetaImpl
,MeterAbbB23Mbus
,MeterArtemesAM2
,MeterBControlEM300Impl
,MeterBgeTechDrt428M2Impl
,MeterCarloGavazziEm300Impl
,MeterDiscovergy
,MeterGridcon
,MeterJanitzaUmg511Impl
,MeterJanitzaUmg604Impl
,MeterJanitzaUmg96rme
,MeterKdk2puctImpl
,MeterMicrocareSdm630Impl
,MeterPqplusUmd96Impl
,MeterPqplusUmd97Impl
,MeterSchneiderActi9Smartlink
,MeterSmaShm20Impl
,MeterWeidmueller525
,MeterZiehlEfr4001IpImpl
,MinDischargePeriod
,ModbusSimulator
,ModbusTcpApiReadOnlyImpl
,ModbusTcpApiReadWriteImpl
,MqttApiControllerImpl
,NrcMeter
,OcppServerImpl
,OneWireThermometer
,PeakShaving
,PeakShaving
,PersistenceModelPredictorImpl
,PhaseRectification
,PlexlogDataloggerImpl
,PowerComponentImpl
,PredictorManagerImpl
,ProductionMeter
,PvInverter
,PvInverterCluster
,PvInverterFixPowerLimit
,PvInverterSellToGridLimit
,ReactivePwrVoltChractersticImpl
,RefuStore88kImpl
,RestApiReadOnlyImpl
,RestApiReadWriteImpl
,RevPiDigitalIoDevice
,Rrd4jTimedataImpl
,SetBalancing
,Shelly25Impl
,ShellyPlugImpl
,SiemensPacMeterImpl
,SimilarDayPredictorImpl
,SimulatedEvcs
,SimulatedThermometerImpl
,SimulatorApp
,SimulatorTimedata
,SinexcelImpl
,SingleDatasourceDirect
,SingleRack
,SingleRackVersionBImpl
,SingleRackVersionCImpl
,SmaPvInverter
,SocomecMeterSinglephaseImpl
,SocomecMeterThreephaseImpl
,SolarEdgeGridMeter
,SolarEdgePvInverter
,SolarLogImpl
,StandbyControllerImpl
,SumImpl
,SunnyIslandEssImpl
,SurplusFeedToGridControllerImpl
,SymmetricFixReactivePower
,SymmetricLimitActivePower
,SymmetricRandomPower
,TeslaPowerwall2Battery
,TeslaPowerwall2CoreImpl
,TibberImpl
,TimeOfUseTariffDischargeImpl
,TimeslotPeakshaving
,VectisImpl
,VirtualAdd
,VirtualSubtractMeter
,Wago
,WebsocketApi
,WeidmuellerUR20Impl
public interface OpenemsComponent
This is the base interface for and should be implemented by every service component in OpenEMS Edge.Every OpenEMS service has:
- a unique ID (see
id()
) - an enabled/disabled state (see
isEnabled()
) - an OSGi service PID (see
servicePid()
- Channels (see
Channel
), identified byOpenemsComponent.ChannelId
or String-ID and provided viachannel(String)
,channel(io.openems.edge.common.channel.ChannelId)
andchannels()
- a kind of 'toString' method which provides the most important info about
the component. (see
debugLog()
)
The recommended implementation of an OpenEMS component is via
AbstractOpenemsComponent
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
OpenemsComponent.ChannelId
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description Channel<?>
_channel(java.lang.String channelName)
Deprecated.default <T extends Channel<?>>
T_getChannelAs(OpenemsComponent.ChannelId channelId, java.lang.Class<T> type)
Gets the Channel as the given Type.java.lang.String
alias()
Returns a human-readable name of this Component..default <T extends Channel<?>>
Tchannel(ChannelId channelId)
Returns a Channel defined by its ChannelId.default <T extends Channel<?>>
Tchannel(java.lang.String channelName)
Returns a Channel defined by its ChannelId string representation.java.util.Collection<Channel<?>>
channels()
Returns all Channels.default java.lang.String
debugLog()
Gets some output that is suitable for a continuous Debug log.org.osgi.service.component.ComponentContext
getComponentContext()
Returns the ComponentContext.static ModbusSlaveNatureTable
getModbusSlaveNatureTable(AccessMode accessMode)
Used for Modbus/TCP Api Controller.default Level
getState()
Gets the Component StateLevel
.default StateCollectorChannel
getStateChannel()
Gets the Component State-Channel.default boolean
hasFaults()
Does this OpenEMS Component report any Faults?java.lang.String
id()
Returns a unique ID for this OpenEMS component.boolean
isEnabled()
Returns whether this component is enabled.static void
logDebug(OpenemsComponent component, org.slf4j.Logger log, java.lang.String message)
Log a debug message including the Component ID.static void
logError(OpenemsComponent component, org.slf4j.Logger log, java.lang.String message)
Log a error message including the Component ID.static void
logInfo(OpenemsComponent component, org.slf4j.Logger log, java.lang.String message)
Log a info message including the Component ID.static void
logWarn(OpenemsComponent component, org.slf4j.Logger log, java.lang.String message)
Log a warn message including the Component ID.default java.lang.String
serviceFactoryPid()
Returns the Service Factory-PID.default java.lang.String
servicePid()
Returns the Service PID.static void
updateConfigurationProperty(org.osgi.service.cm.ConfigurationAdmin cm, java.lang.String pid, java.lang.String property, java.lang.Object value)
Update a configuration property.static boolean
updateReferenceFilter(org.osgi.service.cm.ConfigurationAdmin cm, java.lang.String pid, java.lang.String member, java.lang.String... ids)
Sets a target filter for a Declarative Service @Reference member.static boolean
updateReferenceFilterRaw(org.osgi.service.cm.ConfigurationAdmin cm, java.lang.String pid, java.lang.String member, java.lang.String filter)
Sets a target filter for a Declarative Service @Reference member.static boolean
validateSingleton(org.osgi.service.cm.ConfigurationAdmin cm, java.lang.String pid, java.lang.String expectedId)
Validates and possibly fixes the Component-ID of a Singleton.
-
-
-
Method Detail
-
id
java.lang.String id()
Returns a unique ID for this OpenEMS component.- Returns:
- the unique ID
-
alias
java.lang.String alias()
Returns a human-readable name of this Component..- Returns:
- the human-readable name
-
isEnabled
boolean isEnabled()
Returns whether this component is enabled.- Returns:
- true if the component is enabled
-
servicePid
default java.lang.String servicePid()
Returns the Service PID.- Returns:
- the OSGi Service PID
-
serviceFactoryPid
default java.lang.String serviceFactoryPid()
Returns the Service Factory-PID.- Returns:
- the OSGi Service Factory-PID
-
getComponentContext
org.osgi.service.component.ComponentContext getComponentContext()
Returns the ComponentContext.- Returns:
- the OSGi ComponentContext
-
_channel
@Deprecated Channel<?> _channel(java.lang.String channelName)
Deprecated.Returns an undefined Channel defined by its ChannelId string representation.Note: It is preferred to use the typed channel()-method, that's why it is marked as @Deprecated.
- Parameters:
channelName
- the Channel-ID as a string- Returns:
- the Channel or null
-
channel
default <T extends Channel<?>> T channel(java.lang.String channelName) throws java.lang.IllegalArgumentException
Returns a Channel defined by its ChannelId string representation.- Type Parameters:
T
- the expected typed Channel- Parameters:
channelName
- the Channel-ID as a string- Returns:
- the Channel or throw Exception
- Throws:
java.lang.IllegalArgumentException
- on error
-
channel
default <T extends Channel<?>> T channel(ChannelId channelId) throws java.lang.IllegalArgumentException
Returns a Channel defined by its ChannelId.- Type Parameters:
T
- the Type of the Channel. SeeDoc.getType()
- Parameters:
channelId
- the Channel-ID- Returns:
- the Channel
- Throws:
java.lang.IllegalArgumentException
- on error
-
channels
java.util.Collection<Channel<?>> channels()
Returns all Channels.- Returns:
- a Collection of Channels
-
getModbusSlaveNatureTable
static ModbusSlaveNatureTable getModbusSlaveNatureTable(AccessMode accessMode)
Used for Modbus/TCP Api Controller. Provides a Modbus table for the Channels of this Component.- Parameters:
accessMode
- filters the Modbus-Records that should be shown- Returns:
- the
ModbusSlaveNatureTable
-
getStateChannel
default StateCollectorChannel getStateChannel()
Gets the Component State-Channel.- Returns:
- the StateCollectorChannel
-
getState
default Level getState()
Gets the Component StateLevel
.- Returns:
- the StateCollectorChannel
-
_getChannelAs
default <T extends Channel<?>> T _getChannelAs(OpenemsComponent.ChannelId channelId, java.lang.Class<T> type)
Gets the Channel as the given Type.- Type Parameters:
T
- the expected Channel type- Parameters:
channelId
- the Channel-IDtype
- the expected Type- Returns:
- the Channel
-
debugLog
default java.lang.String debugLog()
Gets some output that is suitable for a continuous Debug log. Returns 'null' by default which causes no output.- Returns:
- the debug log output
-
hasFaults
default boolean hasFaults()
Does this OpenEMS Component report any Faults?Evaluates all
StateChannel
s and returns true if any Channel withLevel.FAULT
is set.- Returns:
- true if there is a Fault.
-
updateReferenceFilter
static boolean updateReferenceFilter(org.osgi.service.cm.ConfigurationAdmin cm, java.lang.String pid, java.lang.String member, java.lang.String... ids)
Sets a target filter for a Declarative Service @Reference member.Usage:
updateReferenceFilter(config.service_pid(), "Controllers", controllersIds);
Generates a 'target' filter on the 'Controllers' member so, that the the expected service to be injected needs to fulfill:
- the service must be enabled
- the service must not have the same PID as the calling component
- the service "id" must be one of the provided "controllersIds"
- Parameters:
cm
- a ConfigurationAdmin instance. Get one using@Reference ConfigurationAdmin cm;
pid
- PID of the calling component (use 'config.service_pid()' or '(String)prop.get(Constants.SERVICE_PID)'; if null, PID filter is not added to the resulting target filtermember
- Name of the Method or Field with the Reference annotationids
- Component IDs to be filtered for; for empty list, no ids are added to the target filter- Returns:
- true if the filter was updated. You may use it to abort the activate() method.
-
updateReferenceFilterRaw
static boolean updateReferenceFilterRaw(org.osgi.service.cm.ConfigurationAdmin cm, java.lang.String pid, java.lang.String member, java.lang.String filter)
Sets a target filter for a Declarative Service @Reference member.Use this method only if you know what you are doing. Usually you will want to use the
updateReferenceFilter(ConfigurationAdmin, String, String, String...)
method instead.Usage:
updateReferenceFilterRaw(config.service_pid(), "Controllers", "(enabled=true)");
- Parameters:
cm
- a ConfigurationAdmin instance. Get one using@Reference ConfigurationAdmin cm;
pid
- PID of the calling component (use 'config.service_pid()' or '(String)prop.get(Constants.SERVICE_PID)'; if null, PID filter is not added to the resulting target filtermember
- Name of the Method or Field with the Reference annotation, e.g.filter
- The filter attribute- Returns:
- true if the filter was updated. You may use it to abort the activate() method.
-
validateSingleton
static boolean validateSingleton(org.osgi.service.cm.ConfigurationAdmin cm, java.lang.String pid, java.lang.String expectedId)
Validates and possibly fixes the Component-ID of a Singleton.Singleton Components are allowed to live only exactly once in an OpenEMS instance. These Components are marked with an Annotation:
@Designate(factory = false)
By design it is required for these Singleton Components to have a predefined Component-ID, like '_cycle', '_sum', etc. This method makes sure the Component-ID matches this predefined ID - and if not automatically adjusts it.
Sidenote: ideally it would be possible to use the Component Annotation
@Component(property = { "id=_cycle" })
for this purpose. Unfortunately this is not sufficient to have the 'id' property listed in EdgeConfig, ConfigurationAdmin, etc. This is why this workaround is required.
Usage:
if (OpenemsComponent.validateSingletonComponentId(this.cm, this.serviceFactoryPid(), SINGLETON_COMPONENT_ID)) { return; }
- Parameters:
cm
- a ConfigurationAdmin instance. Get one using@Reference ConfigurationAdmin cm;
pid
- PID of the calling component (use 'config.service_pid()' or '(String)prop.get(Constants.SERVICE_PID)'; if null, Component-ID can not be updated.expectedId
- The expected predefined Component-ID- Returns:
- true if the ID was updated. You may use it to abort the activate() method.
-
updateConfigurationProperty
static void updateConfigurationProperty(org.osgi.service.cm.ConfigurationAdmin cm, java.lang.String pid, java.lang.String property, java.lang.Object value)
Update a configuration property.Usage:
updateConfigurationProperty(cm, servicePid, "propertyName", "propertyValue");
- Parameters:
cm
- a ConfigurationAdmin instance. Get one using@Reference ConfigurationAdmin cm;
pid
- PID of the calling component (use 'config.service_pid()' or '(String)prop.get(Constants.SERVICE_PID)'property
- Name of the configuration propertyvalue
- New configuration value
-
logDebug
static void logDebug(OpenemsComponent component, org.slf4j.Logger log, java.lang.String message)
Log a debug message including the Component ID.- Parameters:
component
- theOpenemsComponent
log
- theLogger
instancemessage
- the message
-
logInfo
static void logInfo(OpenemsComponent component, org.slf4j.Logger log, java.lang.String message)
Log a info message including the Component ID.- Parameters:
component
- theOpenemsComponent
log
- theLogger
instancemessage
- the message
-
logWarn
static void logWarn(OpenemsComponent component, org.slf4j.Logger log, java.lang.String message)
Log a warn message including the Component ID.- Parameters:
component
- theOpenemsComponent
log
- theLogger
instancemessage
- the message
-
logError
static void logError(OpenemsComponent component, org.slf4j.Logger log, java.lang.String message)
Log a error message including the Component ID.- Parameters:
component
- theOpenemsComponent
log
- theLogger
instancemessage
- the message
-
-