Class AbstractModbusTcpApi
java.lang.Object
io.openems.edge.common.component.AbstractOpenemsComponent
io.openems.edge.controller.api.modbus.AbstractModbusTcpApi
- All Implemented Interfaces:
OpenemsComponent
,ComponentJsonApi
,JsonApi
,Controller
,ModbusTcpApi
- Direct Known Subclasses:
ControllerApiModbusTcpReadOnlyImpl
,ControllerApiModbusTcpReadWriteImpl
public abstract class AbstractModbusTcpApi
extends AbstractOpenemsComponent
implements ModbusTcpApi, Controller, OpenemsComponent, ComponentJsonApi
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.openems.edge.controller.api.Controller
Controller.ChannelId
Nested classes/interfaces inherited from interface io.openems.edge.controller.api.modbus.ModbusTcpApi
ModbusTcpApi.ChannelId
Nested classes/interfaces inherited from interface io.openems.edge.common.component.OpenemsComponent
OpenemsComponent.ChannelId
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ApiWorker
static final int
static final int
protected final TreeMap
<Integer, ModbusRecord> Holds the link between Modbus address and ModbusRecord.static final int
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractModbusTcpApi
(String implementationName, ChannelId[] firstInitialChannelIds, ChannelId[]... furtherInitialChannelIds) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
activate
(org.osgi.service.component.ComponentContext context, String id, String alias, boolean enabled, org.osgi.service.cm.ConfigurationAdmin cm, AbstractModbusTcpApi.ConfigRecord config) protected void
addComponent
(OpenemsComponent component) void
buildJsonApiRoutes
(JsonApiBuilder builder) Specifies routes of the current component in the given builder.protected void
Handles @Deactivate of implementations.protected abstract AccessMode
Gets the AccessMode.protected ModbusSlave
getPossiblyDisabledComponent
(String componentId) Gets the Component.protected void
Log a debug message including the Component ID.protected void
Log an info message including the Component ID.protected void
Log a warn message including the Component ID.protected void
removeComponent
(OpenemsComponent component) void
run()
Executes the Controller logic.Methods inherited from class io.openems.edge.common.component.AbstractOpenemsComponent
_channel, activate, activate, addChannel, addChannels, addChannels, alias, channels, getComponentContext, id, isEnabled, logError, modified, 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.common.jsonapi.ComponentJsonApi
id
Methods inherited from interface io.openems.edge.controller.api.Controller
_setRunFailed, getRunFailed, getRunFailedChannel
Methods inherited from interface io.openems.edge.controller.api.modbus.ModbusTcpApi
_setComponentMissingFault, _setComponentNoModbusApiFault, _setProcessImageFault, _setUnableToStart, getComponentMissingFault, getComponentMissingFaultChannel, getComponentNoModbusApiFault, getComponentNoModbusApiFaultChannel, getProcessImageFault, getProcessImageFaultChannel, getUnableToStart, getUnableToStartChannel
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
-
Field Details
-
UNIT_ID
public static final int UNIT_ID- See Also:
-
DEFAULT_PORT
public static final int DEFAULT_PORT- See Also:
-
DEFAULT_MAX_CONCURRENT_CONNECTIONS
public static final int DEFAULT_MAX_CONCURRENT_CONNECTIONS- See Also:
-
apiWorker
-
records
Holds the link between Modbus address and ModbusRecord.
-
-
Constructor Details
-
AbstractModbusTcpApi
-
-
Method Details
-
addComponent
-
removeComponent
-
activate
protected void activate(org.osgi.service.component.ComponentContext context, String id, String alias, boolean enabled, org.osgi.service.cm.ConfigurationAdmin cm, AbstractModbusTcpApi.ConfigRecord config) throws OpenemsException - Throws:
OpenemsException
-
deactivate
protected void deactivate()Description copied from class:AbstractOpenemsComponent
Handles @Deactivate of implementations. Prints log output.- Overrides:
deactivate
in classAbstractOpenemsComponent
-
run
Description copied from interface:Controller
Executes the Controller logic.- Specified by:
run
in interfaceController
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
logDebug
Description copied from class:AbstractOpenemsComponent
Log a debug message including the Component ID.- Overrides:
logDebug
in classAbstractOpenemsComponent
- Parameters:
log
- the Logger instancemessage
- the message
-
logInfo
Description copied from class:AbstractOpenemsComponent
Log an info message including the Component ID.- Overrides:
logInfo
in classAbstractOpenemsComponent
- Parameters:
log
- the Logger instancemessage
- the message
-
logWarn
Description copied from class:AbstractOpenemsComponent
Log a warn message including the Component ID.- Overrides:
logWarn
in classAbstractOpenemsComponent
- Parameters:
log
- the Logger instancemessage
- the message
-
buildJsonApiRoutes
Description copied from interface:JsonApi
Specifies routes of the current component in the given builder.Example:
@Override
public void buildJsonApiRoutes(JsonApiBuilder builder) { builder.rpc("METHOD_NAME", call -> { // handle call... }); }- Specified by:
buildJsonApiRoutes
in interfaceJsonApi
- Parameters:
builder
- the builder to add the routes
-
getAccessMode
Gets the AccessMode.- Returns:
- the
AccessMode
-
getPossiblyDisabledComponent
Gets the Component. Be aware, that it might be 'disabled'.- Parameters:
componentId
- the Component-ID- Returns:
- the
ModbusSlave
Component; possibly null
-