-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
738 changed files
with
30,933 additions
and
23,112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
io.openems.backend.common/src/io/openems/backend/common/jsonrpc/SimulationEngine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.openems.backend.common.jsonrpc; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
import io.openems.backend.common.jsonrpc.request.SimulationRequest; | ||
import io.openems.backend.common.metadata.User; | ||
import io.openems.common.exceptions.OpenemsError.OpenemsNamedException; | ||
import io.openems.common.jsonrpc.base.JsonrpcResponseSuccess; | ||
|
||
public interface SimulationEngine { | ||
|
||
/** | ||
* Handles a JSON-RPC Request. | ||
* | ||
* @param edgeId the Edge-ID | ||
* @param user the authenticated {@link User} | ||
* @param request the {@link JsonrpcRequest} | ||
* @return the JSON-RPC Success Response Future | ||
* @throws OpenemsNamedException on error | ||
*/ | ||
public CompletableFuture<JsonrpcResponseSuccess> handleRequest(String edgeId, User user, SimulationRequest request) | ||
throws OpenemsNamedException; | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
...enems.backend.common/src/io/openems/backend/common/jsonrpc/request/SimulationRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package io.openems.backend.common.jsonrpc.request; | ||
|
||
import com.google.gson.JsonObject; | ||
|
||
import io.openems.common.exceptions.OpenemsError.OpenemsNamedException; | ||
import io.openems.common.jsonrpc.base.GenericJsonrpcRequest; | ||
import io.openems.common.jsonrpc.base.JsonrpcRequest; | ||
import io.openems.common.utils.JsonUtils; | ||
|
||
/** | ||
* Represents a JSON-RPC Request for 'SimulationRequest'. | ||
* | ||
* <pre> | ||
* { | ||
* "jsonrpc": "2.0", | ||
* "id": "UUID", | ||
* "method": "simulation", | ||
* "params": { | ||
* "payload": {@link JsonrpcRequest}, | ||
* } | ||
* } | ||
* </pre> | ||
*/ | ||
public class SimulationRequest extends JsonrpcRequest { | ||
|
||
public static final String METHOD = "simulation"; | ||
|
||
/** | ||
* Create {@link SimulationRequest} from a template {@link JsonrpcRequest}. | ||
* | ||
* @param r the template {@link JsonrpcRequest} | ||
* @return the {@link SimulationRequest} | ||
* @throws OpenemsNamedException on parse error | ||
*/ | ||
public static SimulationRequest from(JsonrpcRequest r) throws OpenemsNamedException { | ||
var p = r.getParams(); | ||
JsonrpcRequest payload = GenericJsonrpcRequest.from(JsonUtils.getAsJsonObject(p, "payload")); | ||
return new SimulationRequest(r, payload); | ||
} | ||
|
||
private final JsonrpcRequest payload; | ||
|
||
public SimulationRequest(JsonrpcRequest payload) { | ||
super(SimulationRequest.METHOD, payload.getTimeout() /* inherit timeout from payload */); | ||
this.payload = payload; | ||
} | ||
|
||
public SimulationRequest(JsonrpcRequest request, JsonrpcRequest payload) { | ||
super(request, SimulationRequest.METHOD); | ||
this.payload = payload; | ||
} | ||
|
||
/** | ||
* Gets the Payload {@link JsonrpcRequest}. | ||
* | ||
* @return Payload | ||
*/ | ||
public JsonrpcRequest getPayload() { | ||
return this.payload; | ||
} | ||
|
||
@Override | ||
public JsonObject getParams() { | ||
return JsonUtils.buildJsonObject() // | ||
.add("payload", this.payload.toJsonObject()) // | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.