Search in sources :

Example 51 with OpenemsException

use of io.openems.common.exceptions.OpenemsException in project openems by OpenEMS.

the class WebsocketApiServer method onConfigUpdate.

public void onConfigUpdate() {
    for (UiEdgeWebsocketHandler handler : this.handlers.values()) {
        try {
            Role role = handler.getUserOpt().get().getRole();
            JsonObject j = DefaultMessages.configQueryReply(new JsonObject(), Config.getInstance().getJson(ConfigFormat.OPENEMS_UI, role, DEFAULT_CONFIG_LANGUAGE));
            handler.send(j);
        } catch (OpenemsException | NoSuchElementException e) {
            log.warn(e.getMessage());
        }
    }
}
Also used : Role(io.openems.common.session.Role) JsonObject(com.google.gson.JsonObject) OpenemsException(io.openems.common.exceptions.OpenemsException) NoSuchElementException(java.util.NoSuchElementException)

Example 52 with OpenemsException

use of io.openems.common.exceptions.OpenemsException in project openems by OpenEMS.

the class WebsocketApiServer method disposeHandler.

private void disposeHandler(WebSocket websocket) {
    UiEdgeWebsocketHandler handler;
    try {
        handler = getHandlerOrCloseWebsocket(websocket);
        UUID uuid = handler.getUuid();
        this.handlers.remove(uuid);
        handler.dispose();
    } catch (OpenemsException e) {
        log.warn("Unable to dispose Handler: " + e.getMessage());
    }
}
Also used : OpenemsException(io.openems.common.exceptions.OpenemsException) UUID(java.util.UUID)

Aggregations

OpenemsException (io.openems.common.exceptions.OpenemsException)52 JsonObject (com.google.gson.JsonObject)25 JsonElement (com.google.gson.JsonElement)11 Edge (io.openems.backend.metadata.api.Edge)8 HashMap (java.util.HashMap)8 JsonArray (com.google.gson.JsonArray)7 Channel (io.openems.api.channel.Channel)7 ConfigChannel (io.openems.api.channel.ConfigChannel)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 WriteChannel (io.openems.api.channel.WriteChannel)4 User (io.openems.api.security.User)4 Role (io.openems.common.session.Role)4 WriteJsonObject (io.openems.core.utilities.api.WriteJsonObject)4 JsonParser (com.google.gson.JsonParser)3 ChannelDoc (io.openems.api.doc.ChannelDoc)3 ConfigException (io.openems.api.exception.ConfigException)3 User (io.openems.backend.metadata.api.User)3 Map (java.util.Map)3 UUID (java.util.UUID)3