Skip to content

Commit

Permalink
feat(plc-simulator): graduate the plc-simulator into plc4j/utils
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Aug 30, 2022
1 parent cfecae2 commit 9500fef
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 21 deletions.
8 changes: 6 additions & 2 deletions plc4j/utils/pcap-replay/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand All @@ -30,7 +32,9 @@
<artifactId>plc4j-utils-pcap-replay</artifactId>

<name>PLC4J: Utils: Pcap-Replay</name>
<description>An implementation of a Netty Channel that uses a PCAP packet dump as input and simulates a raw socket device by replaying the recorded traffic.</description>
<description>An implementation of a Netty Channel that uses a PCAP packet dump as input and simulates a raw socket
device by replaying the recorded traffic.
</description>

<dependencies>
<dependency>
Expand Down
4 changes: 3 additions & 1 deletion plc4j/utils/pcap-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand Down
45 changes: 35 additions & 10 deletions sandbox/plc-simulator/pom.xml → plc4j/utils/plc-simulator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.plc4x.sandbox</groupId>
<artifactId>plc4x-sandbox</artifactId>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-utils</artifactId>
<version>0.10.0-SNAPSHOT</version>
</parent>

<artifactId>plc-simulator</artifactId>
<artifactId>plc4j-utils-plc-simulator</artifactId>

<name>Sandbox: PLC-Simulator</name>
<name>PLC4J: Utils: PLC-Simulator</name>

<build>
<plugins>
Expand All @@ -53,6 +56,15 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<usedDependencies>
<usedDependency>ch.qos.logback:logback-core</usedDependency>
</usedDependencies>
</configuration>
</plugin>
</plugins>
</build>

Expand All @@ -69,12 +81,21 @@
<version>0.10.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-api</artifactId>
<version>0.10.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-spi</artifactId>
<version>0.10.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
Expand All @@ -84,13 +105,17 @@
<artifactId>commons-cli</artifactId>
</dependency>


<!-- Explicitly override the scope to compile to include these -->

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
</dependency>


<!-- Explicitly override the scope to compile to include these -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,13 @@ private void syncChannelRead(ChannelHandlerContext ctx, Object msg) throws Excep
if (exstat) {
// TODO: map actuall values from simulator
byte blockStart = 0x0;
List<StatusByte> statusBytes = List.of(new StatusByte(GAVState.ON, GAVState.ERROR, GAVState.OFF, GAVState.DOES_NOT_EXIST));
List<StatusByte> statusBytes = Arrays.asList(new StatusByte(GAVState.ON, GAVState.ERROR, GAVState.OFF, GAVState.DOES_NOT_EXIST));
CALData calData = new CALDataStatusExtended(CALCommandTypeContainer.CALCommandReply_4Bytes, null, StatusCoding.BINARY_BY_THIS_SERIAL_INTERFACE, statusRequestBinaryState.getApplication(), blockStart, statusBytes, null, requestContext);
calReply = new CALReplyLong((byte) 0x0, calData, (byte) 0x0, new UnitAddress((byte) 0x0), null, null, (byte) 0x0, null, cBusOptions, requestContext);
} else {
// TODO: map actuall values from simulator
byte blockStart = 0x0;
List<StatusByte> statusBytes = List.of(new StatusByte(GAVState.ON, GAVState.ERROR, GAVState.OFF, GAVState.DOES_NOT_EXIST));
List<StatusByte> statusBytes = Arrays.asList(new StatusByte(GAVState.ON, GAVState.ERROR, GAVState.OFF, GAVState.DOES_NOT_EXIST));
CALData calData = new CALDataStatus(CALCommandTypeContainer.CALCommandReply_3Bytes, null, statusRequestBinaryState.getApplication(), blockStart, statusBytes, requestContext);
calReply = new CALReplyShort((byte) 0x0, calData, cBusOptions, requestContext);
}
Expand Down Expand Up @@ -313,7 +313,7 @@ private void syncChannelRead(ChannelHandlerContext ctx, Object msg) throws Excep
StatusCoding coding = StatusCoding.LEVEL_BY_THIS_SERIAL_INTERFACE;
// TODO: map actuall values from simulator
byte blockStart = statusRequestLevel.getStartingGroupAddressLabel();
List<LevelInformation> levelInformations = List.of(new LevelInformationNormal(0x5555, LevelInformationNibblePair.Value_F, LevelInformationNibblePair.Value_F));
List<LevelInformation> levelInformations = Arrays.asList(new LevelInformationNormal(0x5555, LevelInformationNibblePair.Value_F, LevelInformationNibblePair.Value_F));
CALData calData = new CALDataStatusExtended(CALCommandTypeContainer.CALCommandReply_4Bytes, null, coding, statusRequestLevel.getApplication(), blockStart, null, levelInformations, requestContext);
CALReply calReply = new CALReplyLong((byte) 0x0, calData, (byte) 0x0, new UnitAddress((byte) 0x0), null, null, (byte) 0x0, null, cBusOptions, requestContext);
EncodedReply encodedReply = new EncodedReplyCALReply((byte) 0x0, calReply, cBusOptions, requestContext);
Expand Down Expand Up @@ -451,7 +451,7 @@ private void handleCalDataIdentify(ChannelHandlerContext ctx, CALDataIdentify ca
break;
case LogicalAssignment:
numBytes = 0x0E;
identifyReplyCommand = new IdentifyReplyCommandLogicalAssignment(List.of(new LogicAssignment(false, true, true, true, true, true)), numBytes);
identifyReplyCommand = new IdentifyReplyCommandLogicalAssignment(Arrays.asList(new LogicAssignment(false, true, true, true, true, true)), numBytes);
break;
case Delays:
numBytes = 0x0F;
Expand Down
7 changes: 6 additions & 1 deletion plc4j/utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand All @@ -42,6 +44,9 @@
<!-- Utilities for building tests -->
<module>test-generator</module>
<module>test-utils</module>

<!-- Utilities for working with PLCs -->
<module>plc-simulator</module>
</modules>

</project>
7 changes: 5 additions & 2 deletions plc4j/utils/raw-sockets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand All @@ -30,7 +32,8 @@
<artifactId>plc4j-utils-raw-sockets</artifactId>

<name>PLC4J: Utils: Raw-Sockets</name>
<description>An implementation of a Netty Channel that allows implementing protocols below the TCP and UCP level.</description>
<description>An implementation of a Netty Channel that allows implementing protocols below the TCP and UCP level.
</description>

<dependencies>
<dependency>
Expand Down
1 change: 0 additions & 1 deletion sandbox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<modules>
<module>code-gen</module>
<module>discovery</module>
<module>plc-simulator</module>
<module>test-java-df1-driver</module>
</modules>

Expand Down

0 comments on commit 9500fef

Please sign in to comment.