Skip to content

Commit 9e8954a

Browse files
feat: implement invoker based on web of things
1 parent cf9328a commit 9e8954a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2023. Smart Operating Block
3+
*
4+
* Use of this source code is governed by an MIT-style
5+
* license that can be found in the LICENSE file or at
6+
* https://opensource.org/licenses/MIT.
7+
*/
8+
9+
package infrastructure.wot;
10+
11+
import entity.actuator.ActuatorID;
12+
import entity.actuator.invoker.DimmableInvoker;
13+
import entity.actuator.invoker.SwitchableInvoker;
14+
15+
import java.util.Map;
16+
17+
/**
18+
* Web of Thing Invoker in order to be able to communicate with things and invoke actions.
19+
*/
20+
public class WotInvoker implements SwitchableInvoker, DimmableInvoker {
21+
private static final String SET_INTENSITY_ACTION = "setIntensity";
22+
private static final String SET_INTENSITY_ACTION_INPUT_NAME = "intensity";
23+
private static final String SET_TURN_ON_ACTION = "on";
24+
private static final String SET_TURN_OFF_ACTION = "off";
25+
@Override
26+
public final void setIntensity(final ActuatorID actuatorID, final int intensity) {
27+
final WotClient wotClient = new WotClient(actuatorID.getId());
28+
wotClient.invoke(SET_INTENSITY_ACTION, Map.of(SET_INTENSITY_ACTION_INPUT_NAME, intensity));
29+
}
30+
31+
@Override
32+
public final void turnOn(final ActuatorID actuatorID) {
33+
final WotClient wotClient = new WotClient(actuatorID.getId());
34+
wotClient.invoke(SET_TURN_ON_ACTION, Map.of());
35+
}
36+
37+
@Override
38+
public final void turnOff(final ActuatorID actuatorID) {
39+
final WotClient wotClient = new WotClient(actuatorID.getId());
40+
wotClient.invoke(SET_TURN_OFF_ACTION, Map.of());
41+
}
42+
}

0 commit comments

Comments
 (0)