Package io.openems.edge.edge2edge.common
Class AbstractEdge2Edge
- java.lang.Object
-
- io.openems.edge.common.component.AbstractOpenemsComponent
-
- io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent
-
- io.openems.edge.edge2edge.common.AbstractEdge2Edge
-
- All Implemented Interfaces:
ModbusComponent
,OpenemsComponent
,Edge2Edge
- Direct Known Subclasses:
Edge2EdgeEssImpl
public abstract class AbstractEdge2Edge extends AbstractOpenemsModbusComponent implements Edge2Edge, ModbusComponent, OpenemsComponent
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent
AbstractOpenemsModbusComponent.BitConverter, AbstractOpenemsModbusComponent.ChannelMapper<T extends AbstractModbusElement<?>>
-
Nested classes/interfaces inherited from interface io.openems.edge.edge2edge.common.Edge2Edge
Edge2Edge.ChannelId
-
Nested classes/interfaces inherited from interface io.openems.edge.bridge.modbus.api.ModbusComponent
ModbusComponent.ChannelId
-
Nested classes/interfaces inherited from interface io.openems.edge.common.component.OpenemsComponent
OpenemsComponent.ChannelId
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractEdge2Edge(java.util.List<java.util.function.Function<AccessMode,ModbusSlaveNatureTable>> modbusSlaveNatureTableMethods, ChannelId[] firstInitialChannelIds, ChannelId[]... furtherInitialChannelIds)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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, java.lang.String remoteComponentId, AccessMode remoteAccessMode)
protected void
deactivate()
Handles @Deactivate of implementations.protected ModbusProtocol
defineModbusProtocol()
Defines the Modbus protocol.protected abstract java.util.function.Consumer<java.lang.Object>
getOnUpdateCallback(ModbusSlaveNatureTable modbusSlaveNatureTable, ModbusRecord record)
Provide a Consumer for Registers that cannot be automatically mapped to Channels.protected abstract ChannelId
getWriteChannelId(ModbusSlaveNatureTable modbusSlaveNatureTable, ModbusRecord record)
Provide a local ChannelId that gets mapped to remote READ_WRITE or WRITE_ONLY registers.protected static boolean
isHashEqual(java.lang.Integer value, java.lang.String text)
Compares a Integer (e.g.-
Methods inherited from class io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent
activate, activate, getBridgeModbus, getModbusProtocol, getUnitId, m, m, m, m, m, m, modified, modified, setModbus, unsetModbus
-
Methods inherited from class io.openems.edge.common.component.AbstractOpenemsComponent
_channel, addChannel, addChannels, addChannels, alias, channels, getComponentContext, id, isEnabled, logDebug, logError, logInfo, logWarn, removeChannel
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.openems.edge.edge2edge.common.Edge2Edge
_setMappingRemoteProtocolFault, _setRemoteNoOpenems, getMappingRemoteProtocolFault, getMappingRemoteProtocolFaultChannel, getRemoteNoOpenems, getRemoteNoOpenemsChannel
-
Methods inherited from interface io.openems.edge.bridge.modbus.api.ModbusComponent
_setModbusCommunicationFailed, getModbusCommunicationFailed, getModbusCommunicationFailedChannel
-
Methods inherited from interface io.openems.edge.common.component.OpenemsComponent
_channel, _getChannelAs, alias, channel, channel, channels, debugLog, getComponentContext, getState, getStateChannel, hasFaults, id, isEnabled, serviceFactoryPid, servicePid
-
-
-
-
Constructor Detail
-
AbstractEdge2Edge
protected AbstractEdge2Edge(java.util.List<java.util.function.Function<AccessMode,ModbusSlaveNatureTable>> modbusSlaveNatureTableMethods, ChannelId[] firstInitialChannelIds, ChannelId[]... furtherInitialChannelIds) throws OpenemsException
- Throws:
OpenemsException
-
-
Method Detail
-
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) throws OpenemsException
Description copied from class:AbstractOpenemsModbusComponent
Call this method from Component implementations activate().- Overrides:
activate
in classAbstractOpenemsModbusComponent
- Parameters:
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()'- Returns:
- true if the target filter was updated. You may use it to abort the activate() method.
- Throws:
OpenemsException
- on error
-
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, java.lang.String remoteComponentId, AccessMode remoteAccessMode) throws OpenemsException
- Throws:
OpenemsException
-
deactivate
protected void deactivate()
Description copied from class:AbstractOpenemsComponent
Handles @Deactivate of implementations. Prints log output.- Overrides:
deactivate
in classAbstractOpenemsModbusComponent
-
isHashEqual
protected static boolean isHashEqual(java.lang.Integer value, java.lang.String text)
Compares a Integer (e.g. read from Modbus) with the hash-code of a text.- Parameters:
value
- an Integer, possibly nulltext
- the text for the hash-code- Returns:
- true on match
-
defineModbusProtocol
protected final ModbusProtocol defineModbusProtocol()
Description copied from class:AbstractOpenemsModbusComponent
Defines the Modbus protocol.- Specified by:
defineModbusProtocol
in classAbstractOpenemsModbusComponent
- Returns:
- the ModbusProtocol
-
getOnUpdateCallback
protected abstract java.util.function.Consumer<java.lang.Object> getOnUpdateCallback(ModbusSlaveNatureTable modbusSlaveNatureTable, ModbusRecord record)
Provide a Consumer for Registers that cannot be automatically mapped to Channels.- Parameters:
modbusSlaveNatureTable
- theModbusSlaveNatureTable
of the Registerrecord
- theModbusRecord
- Returns:
- a Consumer that receives the value from Modbus
-
getWriteChannelId
protected abstract ChannelId getWriteChannelId(ModbusSlaveNatureTable modbusSlaveNatureTable, ModbusRecord record)
Provide a local ChannelId that gets mapped to remote READ_WRITE or WRITE_ONLY registers.- Parameters:
modbusSlaveNatureTable
- theModbusSlaveNatureTable
of the Registerrecord
- theModbusRecord
- Returns:
- a local ChannelId
-
-