public class WebsocketApi extends AbstractOpenemsComponent implements Controller, OpenemsComponent, org.ops4j.pax.logging.spi.PaxAppender, org.osgi.service.event.EventHandler
Modifier and Type | Class and Description |
---|---|
static class |
WebsocketApi.ChannelId |
Modifier and Type | Field and Description |
---|---|
protected ApiWorker |
apiWorker |
protected ComponentManager |
componentManager |
static int |
DEFAULT_PORT |
static java.lang.String |
EDGE_COMMENT |
static java.lang.String |
EDGE_ID |
static java.lang.String |
EDGE_PRODUCT_TYPE |
protected WebsocketServer |
server |
protected java.util.Map<java.util.UUID,EdgeUser> |
sessionTokens
Stores valid session tokens for authentication via Cookie.
|
protected UserService |
userService |
Constructor and Description |
---|
WebsocketApi() |
Modifier and Type | Method and Description |
---|---|
protected void |
activate(org.osgi.service.component.ComponentContext context,
io.openems.edge.controller.api.websocket.Config config) |
protected void |
deactivate()
Handles @Deactivate of implementations.
|
void |
doAppend(org.ops4j.pax.logging.spi.PaxLoggingEvent event) |
Timedata |
getTimedata()
Gets the Timedata service.
|
protected WsData |
getWsDataForTokenOrError(java.util.UUID token)
Gets the WebSocket connection attachment for a UI token.
|
void |
handleEvent(org.osgi.service.event.Event event) |
protected void |
handleSubscribeSystemLogRequest(java.util.UUID token,
SubscribeSystemLogRequest request)
Handles a SubscribeSystemLogRequest by forwarding it to the
'SystemLogHandler'.
|
protected void |
logInfo(org.slf4j.Logger log,
java.lang.String message)
Log an info message including the Component ID.
|
protected void |
logWarn(org.slf4j.Logger log,
java.lang.String message)
Log a warn message including the Component ID.
|
void |
run()
Executes the Controller logic.
|
_channel, activate, addChannel, addChannels, addChannels, alias, channels, getComponentContext, id, isEnabled, logDebug, logError, modified, removeChannel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
_setRunFailed, getModbusSlaveNatureTable, getRunFailed, getRunFailedChannel
_channel, _getChannelAs, alias, channel, channel, channels, debugLog, getComponentContext, getState, getStateChannel, hasFaults, id, isEnabled, logDebug, logError, logInfo, logWarn, serviceFactoryPid, servicePid, updateConfigurationProperty, updateReferenceFilter
public static final java.lang.String EDGE_ID
public static final java.lang.String EDGE_COMMENT
public static final java.lang.String EDGE_PRODUCT_TYPE
public static final int DEFAULT_PORT
protected final ApiWorker apiWorker
protected WebsocketServer server
protected final java.util.Map<java.util.UUID,EdgeUser> sessionTokens
protected ComponentManager componentManager
protected UserService userService
protected void activate(org.osgi.service.component.ComponentContext context, io.openems.edge.controller.api.websocket.Config config)
protected void deactivate()
AbstractOpenemsComponent
deactivate
in class AbstractOpenemsComponent
public void run() throws OpenemsError.OpenemsNamedException
Controller
run
in interface Controller
OpenemsError.OpenemsNamedException
- on errorprotected final void logInfo(org.slf4j.Logger log, java.lang.String message)
AbstractOpenemsComponent
logInfo
in class AbstractOpenemsComponent
log
- the Logger instancemessage
- the messageprotected final void logWarn(org.slf4j.Logger log, java.lang.String message)
AbstractOpenemsComponent
logWarn
in class AbstractOpenemsComponent
log
- the Logger instancemessage
- the messagepublic void doAppend(org.ops4j.pax.logging.spi.PaxLoggingEvent event)
doAppend
in interface org.ops4j.pax.logging.spi.PaxAppender
protected WsData getWsDataForTokenOrError(java.util.UUID token) throws OpenemsError.OpenemsNamedException
token
- the UI tokenOpenemsError.OpenemsNamedException
- if there is no connection with this tokenprotected void handleSubscribeSystemLogRequest(java.util.UUID token, SubscribeSystemLogRequest request) throws OpenemsError.OpenemsNamedException
token
- the UI tokenrequest
- the SubscribeSystemLogRequestOpenemsError.OpenemsNamedException
- on errorpublic void handleEvent(org.osgi.service.event.Event event)
handleEvent
in interface org.osgi.service.event.EventHandler
public Timedata getTimedata() throws OpenemsException
OpenemsException
- if the timeservice is not available