-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce HTTP-bridge & migrate Shelly Plug S #2381
Introduce HTTP-bridge & migrate Shelly Plug S #2381
Conversation
First test with a shelly IO plug.
added dummy BridgeHttp
moved notify
use dummy request to wait
io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java
Show resolved
Hide resolved
// TODO: Execute before TOPIC_CYCLE_BEFORE_PROCESS_IMAGE, like modbus bridge | ||
case EdgeEventConstants.TOPIC_CYCLE_BEFORE_PROCESS_IMAGE -> { | ||
|
||
this.endpoints.forEach(EndpointCountdown::decreaseCycleCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should decreaseCycleCount
not only get called inside the loop? Difference would be if an Exception happens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no the loop is only to handle endpoints wich have hit cycleCount
0 before that i decrease every cycle
io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java
Outdated
Show resolved
Hide resolved
io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java
Outdated
Show resolved
Hide resolved
io.openems.edge.io.shelly/src/io/openems/edge/io/shelly/shellyplug/IoShellyPlugImpl.java
Outdated
Show resolved
Hide resolved
use offer for adding endpoint removed return and replaced with continue to fix not iterating over all elements
handle result and error in one method set every channel to null on error
|
- "Fixed" bug where an exception gets throw during deactivation of a component using the HTTP-Bridge (ty @Sn0w3y #2381 (comment)) now to get an instance of a `BridgeHttp` the following code needs to be added ``` @reference private BridgeHttpFactory httpBridgeFactory; private BridgeHttp httpBridge; @activate private void activate() { this.httpBridge = this.httpBridgeFactory.get(); } @deactivate private void deactivate() { this.httpBridgeFactory.unget(this.httpBridge); this.httpBridge = null; } ``` as far as i know the exception which is happening is not intended to happen but for now to avoid unexpected behaviour because of the exception this is the prefered way to use it. - Made CycleSubscriber thread safe to avoid concurrent modification exceptions - Added time based subscribtions simple example to add a subscription with a delay of 1 minute between the calls would be ``` final var delayProvider = DelayTimeProviderChain.fixedDelay(new Delay(1L, TimeUnit.MINUTES); this.httpBridge.subscribeTime(delayProvider, "http://127.0.0.1/status", t -> { // process data }, t -> { // handle error }); ```
…#2539) - "Fixed" bug where an exception gets throw during deactivation of a component using the HTTP-Bridge (ty @Sn0w3y OpenEMS#2381 (comment)) now to get an instance of a `BridgeHttp` the following code needs to be added ``` @reference private BridgeHttpFactory httpBridgeFactory; private BridgeHttp httpBridge; @activate private void activate() { this.httpBridge = this.httpBridgeFactory.get(); } @deactivate private void deactivate() { this.httpBridgeFactory.unget(this.httpBridge); this.httpBridge = null; } ``` as far as i know the exception which is happening is not intended to happen but for now to avoid unexpected behaviour because of the exception this is the prefered way to use it. - Made CycleSubscriber thread safe to avoid concurrent modification exceptions - Added time based subscribtions simple example to add a subscription with a delay of 1 minute between the calls would be ``` final var delayProvider = DelayTimeProviderChain.fixedDelay(new Delay(1L, TimeUnit.MINUTES); this.httpBridge.subscribeTime(delayProvider, "http://127.0.0.1/status", t -> { // process data }, t -> { // handle error }); ```
Introduce a new bridge for http connections and communication.
Currently, each implementation of a device via RESTful APIs is implemented in its own bundle and is more or less stable depending on asynchronous calls.
In this PR it is currently used by the shelly IO plug as a first test.
Co-authored-by: Michael Grill [email protected]