Class AbstractModbusTcpApi
java.lang.Object
io.openems.edge.common.component.AbstractOpenemsComponent
io.openems.edge.controller.api.modbus.AbstractModbusTcpApi
- All Implemented Interfaces:
OpenemsComponent
,JsonApi
,Controller
,ModbusTcpApi
- Direct Known Subclasses:
ControllerApiModbusTcpReadOnlyImpl
,ControllerApiModbusTcpReadWriteImpl
public abstract class AbstractModbusTcpApi
extends AbstractOpenemsComponent
implements ModbusTcpApi, Controller, OpenemsComponent, JsonApi
-
Nested Class Summary
Nested 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
Modifier 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
ConstructorDescriptionAbstractModbusTcpApi
(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) protected void
Handles @Deactivate of implementations.protected abstract AccessMode
Gets the AccessMode.protected ModbusSlave
getPossiblyDisabledComponent
(String componentId) Gets the Component.handleJsonrpcRequest
(User user, JsonrpcRequest message) Handles a JSON-RPC Request.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.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
-
handleJsonrpcRequest
public CompletableFuture<JsonrpcResponseSuccess> handleJsonrpcRequest(User user, JsonrpcRequest message) throws OpenemsError.OpenemsNamedException Description copied from interface:JsonApi
Handles a JSON-RPC Request.- Specified by:
handleJsonrpcRequest
in interfaceJsonApi
- Parameters:
user
- the authenticatedUser
message
- the JSON-RPC Request- Returns:
- a Future JSON-RPC Success Response; null response results in a OpenemsError.JSONRPC_UNHANDLED_METHOD
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
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
-