public abstract class AbstractOpenemsSunSpecComponent extends AbstractOpenemsModbusComponent
AbstractOpenemsModbusComponent.BitConverter, AbstractOpenemsModbusComponent.ChannelMapper<T extends AbstractModbusElement<?>>
OpenemsComponent.ChannelId
Constructor and Description |
---|
AbstractOpenemsSunSpecComponent(java.util.Map<SunSpecModel,Priority> activeModels,
ChannelId[] firstInitialChannelIds,
ChannelId[]... furtherInitialChannelIds)
Constructs a AbstractOpenemsSunSpecComponent.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
activate(org.osgi.service.component.ComponentContext context,
java.lang.String id,
java.lang.String alias,
boolean enabled,
int unitId,
org.osgi.service.cm.ConfigurationAdmin cm,
java.lang.String modbusReference,
java.lang.String modbusId)
Call this method from Component implementations activate().
|
protected boolean |
activate(org.osgi.service.component.ComponentContext context,
java.lang.String id,
java.lang.String alias,
boolean enabled,
int unitId,
org.osgi.service.cm.ConfigurationAdmin cm,
java.lang.String modbusReference,
java.lang.String modbusId,
int readFromCommonBlockNo) |
protected void |
addBlock(int startAddress,
SunSpecModel model,
Priority priority)
Adds the block starting from startAddress.
|
protected ModbusProtocol |
defineModbusProtocol()
Defines the Modbus protocol.
|
protected <T extends Channel<?>> |
getSunSpecChannel(SunSpecPoint point)
Get the Channel for the given Point.
|
protected <T extends Channel<?>> |
getSunSpecChannelOrError(SunSpecPoint point)
Get the Channel for the given Point or throw an error if it is not available.
|
protected SunSpecModel |
getSunSpecModel(int blockId)
Overwrite to provide custom SunSpecModel.
|
boolean |
isSunSpecInitializationCompleted()
Is the SunSpec initialization completed?.
|
protected void |
mapFirstPointToChannel(ChannelId targetChannel,
ElementToChannelConverter converter,
SunSpecPoint... points)
Maps the first available SunSpec
SunSpecPoint to the targetChannel. |
protected abstract void |
onSunSpecInitializationCompleted()
This method is called after the SunSpec initialization was completed.
|
activate, activate, deactivate, getBridgeModbus, getModbusProtocol, getUnitId, m, m, m, m, setModbus, unsetModbus
_channel, addChannel, addChannels, addChannels, alias, channels, getComponentContext, id, isEnabled, logDebug, logError, logInfo, logWarn, modified, removeChannel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
_getChannelAs, channel, channel, debugLog, getModbusSlaveNatureTable, getState, getStateChannel, hasFaults, logDebug, logError, logInfo, logWarn, serviceFactoryPid, servicePid, updateConfigurationProperty, updateReferenceFilter
public AbstractOpenemsSunSpecComponent(java.util.Map<SunSpecModel,Priority> activeModels, ChannelId[] firstInitialChannelIds, ChannelId[]... furtherInitialChannelIds) throws OpenemsException
activeModels
- the active SunSpec Models (i.e.
SunSpecModel
) that should be
considered and their reading-priorityfirstInitialChannelIds
- forwarded to
AbstractOpenemsModbusComponent
furtherInitialChannelIds
- forwarded to
AbstractOpenemsModbusComponent
OpenemsException
- on errorprotected boolean activate(org.osgi.service.component.ComponentContext context, java.lang.String id, java.lang.String alias, boolean enabled, int unitId, org.osgi.service.cm.ConfigurationAdmin cm, java.lang.String modbusReference, java.lang.String modbusId)
AbstractOpenemsModbusComponent
activate
in class AbstractOpenemsModbusComponent
context
- ComponentContext of this component. Receive it from
parameter for @Activateid
- ID of this component. Typically 'config.id()'alias
- Human-readable name of this Component. Typically
'config.alias()'. Defaults to 'id' if emptyenabled
- Whether the component should be enabled. Typically
'config.enabled()'unitId
- Unit-ID of the Modbus targetcm
- An instance of ConfigurationAdmin. Receive it
using @ReferencemodbusReference
- The name of the @Reference setter method for the
Modbus bridge - e.g. 'Modbus' if you have a
setModbus()-methodmodbusId
- The ID of the Modbus bridge. Typically
'config.modbus_id()'protected boolean activate(org.osgi.service.component.ComponentContext context, java.lang.String id, java.lang.String alias, boolean enabled, int unitId, org.osgi.service.cm.ConfigurationAdmin cm, java.lang.String modbusReference, java.lang.String modbusId, int readFromCommonBlockNo) throws OpenemsException
OpenemsException
protected final ModbusProtocol defineModbusProtocol()
AbstractOpenemsModbusComponent
defineModbusProtocol
in class AbstractOpenemsModbusComponent
protected SunSpecModel getSunSpecModel(int blockId) throws java.lang.IllegalArgumentException
blockId
- the Block-IdSunSpecModel
java.lang.IllegalArgumentException
- on errorpublic boolean isSunSpecInitializationCompleted()
If this returns true, all Channels are available.
protected abstract void onSunSpecInitializationCompleted()
The purpose of this method is to add mappings between SunSpec Channel-Points to OpenEMS Nature Channels.
protected void addBlock(int startAddress, SunSpecModel model, Priority priority) throws OpenemsException
startAddress
- the address to start reading frommodel
- the SunSpecModelpriority
- the reading priorityOpenemsException
- on errorprotected <T extends Channel<?>> java.util.Optional<T> getSunSpecChannel(SunSpecPoint point)
T
- the Channel typepoint
- the SunSpec Pointprotected <T extends Channel<?>> T getSunSpecChannelOrError(SunSpecPoint point) throws OpenemsException
T
- the Channel typepoint
- the SunSpec PointOpenemsException
- if Channel is not availableprotected void mapFirstPointToChannel(ChannelId targetChannel, ElementToChannelConverter converter, SunSpecPoint... points)
SunSpecPoint
to the targetChannel.
The logic checks in order if a point is defined and uses that point.
Call this method only after all SunSpec models were completely read - i.e. onSunSpecInitializationCompleted()
targetChannel
- the targetChannelconverter
- convert from Point value to the Unit of the Channelpoints
- the points.