|
|
Here, I'll walk you through the java source code, responsible for starting the [Light Hosts](What-am-I-looking-at-here#light-hosts). Additional startup procedures are explained in the documentation for the `start_component.sh` and the `run_demo.sh` scripts.
|
|
|
Here, I'll walk you through the java source code, responsible for starting the [Light Hosts](What-am-I-looking-at-here#light-hosts). Additional startup procedures are explained in the documentation for the [`start_component.sh`](implementation/start_component.sh) and the [`run_demo.sh`](implementation/run_demo.sh) scripts.
|
|
|
|
|
|
# Lightstrand
|
|
|
|
|
|
The discussed file can be found [here](https://gitlab.hrz.tu-chemnitz.de/s6869070--tu-dresden.de/vws-spielwiese/-/blob/6d65d24412bda2e555e70a4f9581eb142096bd49/basyx.lichterkette/src/main/java/de/olipar/basyx/lichterkette/Lightstrand.java).
|
|
|
The discussed file can be found [here](https://gitlab.hrz.tu-chemnitz.de/vws-demo/vws-spielwiese/-/blob/64e67bdaae14ef6945ab3e73b5a9c70c9c1ced67/basyx.lichterkette/src/main/java/de/olipar/basyx/lichterkette/Lightstrand.java).
|
|
|
|
|
|
We'll skip the license headers, imports and comments, as they are either pretty much self explanatory or not the product of conscious development effort.
|
|
|
|
... | ... | @@ -211,7 +211,7 @@ final int HOSTPORT = Common.getHostPort(); |
|
|
logger.info("Local host port is set to " + HOSTPORT);
|
|
|
logger.info("Ports " + HOSTPORT + " through including " + (HOSTPORT + redLights + greenLights - 1) + " will be used for lights.");
|
|
|
```
|
|
|
`getHostPort()`, part of the [Common class](Common-class-walkthrough) is used to get the port to host the soon to be created Submodels on.
|
|
|
`getHostPort()`, part of the [Common class](implementation/Common-class-walkthrough) is used to get the port to host the soon to be created Submodels on.
|
|
|
Since we're creating multiple Submodels, each requiring an own port, the `HOSTPORT` value will be used as the start of a sequence of ports used, the length of which depends on the amount of submodels to be created.
|
|
|
|
|
|
```java
|
... | ... | @@ -227,7 +227,7 @@ if (i < redPins.length) { |
|
|
light = new RedLight(Integer.toString(i));
|
|
|
}
|
|
|
```
|
|
|
a new RedLight is created. If we still have red GPIO ports left, we hand the GPIO port for this light over on creation, if not the constructor without will be used. See [here](Walkthrough-for-the-general-light-classes) for the declaration.
|
|
|
a new RedLight is created. If we still have red GPIO ports left, we hand the GPIO port for this light over on creation, if not the constructor without will be used. See [here](implementation/Walkthrough-for-the-general-light-classes) for the declaration.
|
|
|
|
|
|
```java
|
|
|
LightSwitchSubmodelProvider lssp = new LightSwitchSubmodelProvider("Lightstrand:redLight_" + light.getID());
|
... | ... | @@ -243,7 +243,7 @@ Finally, the same is done with the green lights. Only non-trivial difference is, |
|
|
|
|
|
# LightSwitchSubmodelProvider
|
|
|
|
|
|
The discussed file can be found [here](https://gitlab.hrz.tu-chemnitz.de/s6869070--tu-dresden.de/vws-spielwiese/-/blob/6d65d24412bda2e555e70a4f9581eb142096bd49/basyx.lichterkette/src/main/java/de/olipar/basyx/lichterkette/LightSwitchSubmodelProvider.java).
|
|
|
The discussed file can be found [here](https://gitlab.hrz.tu-chemnitz.de/vws-demo/vws-spielwiese/-/blob/64e67bdaae14ef6945ab3e73b5a9c70c9c1ced67/basyx.lichterkette/src/main/java/de/olipar/basyx/lichterkette/LightSwitchSubmodelProvider.java).
|
|
|
|
|
|
We'll skip the license headers, imports and comments, as they are either pretty much self explanatory or not the product of conscious development effort.
|
|
|
It is advisable to take a look at the file, as it is heavily commented.
|
... | ... | @@ -266,7 +266,7 @@ public LightSwitchSubmodelProvider(String uniqueID) { |
|
|
```java
|
|
|
public Submodel createMyLightSwitchModel(ILight light) {
|
|
|
```
|
|
|
This method creates Submodel for controlling the light its AAS represents. It requires an implementation of [`ILight`](Walkthrough-for-the-general-light-classes#ilight), to which it will bind the Operations.
|
|
|
This method creates Submodel for controlling the light its AAS represents. It requires an implementation of [`ILight`](implementation/Walkthrough-for-the-general-light-classes#ilight), to which it will bind the Operations.
|
|
|
|
|
|
```java
|
|
|
Submodel lightSwitchSubmodel = new Submodel();
|
... | ... | @@ -310,7 +310,7 @@ logger.info("Registry path set to " + REGISTRYPATH); |
|
|
final String AASSERVERPATH = Common.getAASServerPath();
|
|
|
logger.info("AAS server path set to " + AASSERVERPATH);
|
|
|
```
|
|
|
We start off by getting all three values the [`Common`-class](Common-class-walkthrough) has to offer and log them.
|
|
|
We start off by getting all three values the [`Common`-class](implementation/Common-class-walkthrough) has to offer and log them.
|
|
|
|
|
|
```java
|
|
|
Submodel lightSwitchModel = createMyLightSwitchModel(light);
|
... | ... | |