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<ELEMENT extends ModbusElement>
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
ModifierConstructorDescriptionprotected
AbstractEdge2Edge
(List<Function<AccessMode, ModbusSlaveNatureTable>> modbusSlaveNatureTableMethods, ChannelId[] firstInitialChannelIds, ChannelId[]... furtherInitialChannelIds) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
activate
(org.osgi.service.component.ComponentContext context, String id, String alias, boolean enabled, int unitId, org.osgi.service.cm.ConfigurationAdmin cm, String modbusReference, String modbusId) Call this method from Component implementations activate().protected boolean
activate
(org.osgi.service.component.ComponentContext context, String id, String alias, boolean enabled, int unitId, org.osgi.service.cm.ConfigurationAdmin cm, String modbusReference, String modbusId, String remoteComponentId, AccessMode remoteAccessMode) protected void
Handles @Deactivate of implementations.protected final ModbusProtocol
Defines the Modbus protocol.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
(Integer value, 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, retryModbusCommunication, 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, retryModbusCommunication
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 Details
-
AbstractEdge2Edge
protected AbstractEdge2Edge(List<Function<AccessMode, ModbusSlaveNatureTable>> modbusSlaveNatureTableMethods, ChannelId[] firstInitialChannelIds, ChannelId[]... furtherInitialChannelIds) throws OpenemsException- Throws:
OpenemsException
-
-
Method Details
-
activate
protected boolean activate(org.osgi.service.component.ComponentContext context, String id, String alias, boolean enabled, int unitId, org.osgi.service.cm.ConfigurationAdmin cm, String modbusReference, 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, String id, String alias, boolean enabled, int unitId, org.osgi.service.cm.ConfigurationAdmin cm, String modbusReference, String modbusId, 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
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
Description copied from class:AbstractOpenemsModbusComponent
Defines the Modbus protocol.- Specified by:
defineModbusProtocol
in classAbstractOpenemsModbusComponent
- Returns:
- the ModbusProtocol
-
getOnUpdateCallback
protected abstract Consumer<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
-