Skip to content

Commit

Permalink
Issue/s7h (#1214)
Browse files Browse the repository at this point in the history
* Important flaws in the management of pipe lines are corrected. Time adjustment is added. Pending in the interpretation of the URL.

* Fixed URL handling in S7MuxImpl. Pending with parameter management in parameter management in tcp transports.

* Reorganization of the examples by type of PLC.

* Updated example for S7-1200.

* Improved CYC example. Go to develop.

---------

Co-authored-by: Cesar Garcia <[email protected]>
  • Loading branch information
glcj and ceos01 authored Nov 18, 2023
1 parent 02c6782 commit 5f6c232
Show file tree
Hide file tree
Showing 61 changed files with 5,367 additions and 1,426 deletions.
Binary file added images/s7h_image01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/s7h_image02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/s7h_image03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/s7h_image04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/s7h_image05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/s7h_image06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/s7h_image07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/s7h_szlxy11demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
141 changes: 74 additions & 67 deletions plc4j/drivers/s7/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.plc4x.plugins</groupId>
<artifactId>plc4x-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-driver</id>
<phase>generate-sources</phase>
<goals>
<goal>generate-driver</goal>
</goals>
<configuration>
<protocolName>s7</protocolName>
<languageName>java</languageName>
<outputFlavor>read-write</outputFlavor>
<outputDir>src/main/generated</outputDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
Expand Down Expand Up @@ -85,6 +104,16 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<usedDependencies combine.children="append">
<usedDependency>org.apache.plc4x:plc4x-code-generation-language-java</usedDependency>
<usedDependency>org.apache.plc4x:plc4x-protocols-s7</usedDependency>
</usedDependencies>
</configuration>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -122,46 +151,45 @@
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>

<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-utils-test-utils</artifactId>
<version>0.12.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>1.5.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>test</scope>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-code-generation-language-java</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-protocols-s7</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-protocols-s7</artifactId>
Expand All @@ -170,53 +198,32 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230618</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>update-generated-code</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.plc4x.plugins</groupId>
<artifactId>plc4x-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-driver</id>
<phase>generate-sources</phase>
<goals>
<goal>generate-driver</goal>
</goals>
<configuration>
<protocolName>s7</protocolName>
<languageName>java</languageName>
<outputFlavor>read-write</outputFlavor>
<outputDir>src/main/generated</outputDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-code-generation-language-java</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-protocols-s7</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ protected void serializeCycServiceItemTypeChild(WriteBuffer writeBuffer)
boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
writeBuffer.pushContext("CycServiceItemAnyType");

// Simple Field (transportSize)
writeSimpleEnumField(
// Enum field (transportSize)
writeEnumField(
"transportSize",
"TransportSize",
transportSize,
new DataWriterEnumDefault<>(
TransportSize::getValue, TransportSize::name, writeUnsignedShort(writeBuffer, 8)));
TransportSize::getCode, TransportSize::name, writeUnsignedShort(writeBuffer, 8)));

// Simple Field (length)
writeSimpleField("length", length, writeUnsignedInt(writeBuffer, 16));
Expand Down Expand Up @@ -128,7 +128,7 @@ public int getLengthInBits() {
CycServiceItemAnyType _value = this;
boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();

// Simple field (transportSize)
// Enum Field (transportSize)
lengthInBits += 8;

// Simple field (length)
Expand Down Expand Up @@ -156,8 +156,7 @@ public static CycServiceItemTypeBuilder staticParseCycServiceItemTypeBuilder(
readEnumField(
"transportSize",
"TransportSize",
new DataReaderEnumDefault<>(
TransportSize::enumForValue, readUnsignedShort(readBuffer, 8)));
readEnum(TransportSize::firstEnumForFieldCode, readUnsignedShort(readBuffer, 8)));

int length = readSimpleField("length", readUnsignedInt(readBuffer, 16));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,10 @@ public static int getLengthInBits(PlcValue _value, String dataProtocolId, Intege
sizeInBits += 16;
} else if (EvaluationHelper.equals(dataProtocolId, "IEC61131_STRING")) { // STRING
// Manual Field (value)
sizeInBits += (((stringLength) * (8))) + (16);
sizeInBits += (STR_LEN(_value)) + (2);
} else if (EvaluationHelper.equals(dataProtocolId, "IEC61131_WSTRING")) { // STRING
// Manual Field (value)
sizeInBits += (((stringLength) * (16))) + (32);
sizeInBits += (((STR_LEN(_value)) * (2))) + (2);
} else if (EvaluationHelper.equals(dataProtocolId, "IEC61131_TIME")) { // TIME
// Simple Field (milliseconds)
sizeInBits += 32;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,42 @@ public static S7PayloadUserDataItem staticParse(
S7PayloadUserDataItemCpuFunctionAlarmQueryResponse
.staticParseS7PayloadUserDataItemBuilder(
readBuffer, dataLength, cpuFunctionGroup, cpuFunctionType, cpuSubfunction);
} else if (EvaluationHelper.equals(cpuFunctionGroup, (byte) 0x07)
&& EvaluationHelper.equals(cpuFunctionType, (byte) 0x04)
&& EvaluationHelper.equals(cpuSubfunction, (short) 0x01)) {
builder =
S7PayloadUserDataItemClkRequest.staticParseS7PayloadUserDataItemBuilder(
readBuffer, cpuFunctionGroup, cpuFunctionType, cpuSubfunction);
} else if (EvaluationHelper.equals(cpuFunctionGroup, (byte) 0x07)
&& EvaluationHelper.equals(cpuFunctionType, (byte) 0x08)
&& EvaluationHelper.equals(cpuSubfunction, (short) 0x01)) {
builder =
S7PayloadUserDataItemClkResponse.staticParseS7PayloadUserDataItemBuilder(
readBuffer, dataLength, cpuFunctionGroup, cpuFunctionType, cpuSubfunction);
} else if (EvaluationHelper.equals(cpuFunctionGroup, (byte) 0x07)
&& EvaluationHelper.equals(cpuFunctionType, (byte) 0x04)
&& EvaluationHelper.equals(cpuSubfunction, (short) 0x03)) {
builder =
S7PayloadUserDataItemClkFRequest.staticParseS7PayloadUserDataItemBuilder(
readBuffer, cpuFunctionGroup, cpuFunctionType, cpuSubfunction);
} else if (EvaluationHelper.equals(cpuFunctionGroup, (byte) 0x07)
&& EvaluationHelper.equals(cpuFunctionType, (byte) 0x08)
&& EvaluationHelper.equals(cpuSubfunction, (short) 0x03)) {
builder =
S7PayloadUserDataItemClkFResponse.staticParseS7PayloadUserDataItemBuilder(
readBuffer, dataLength, cpuFunctionGroup, cpuFunctionType, cpuSubfunction);
} else if (EvaluationHelper.equals(cpuFunctionGroup, (byte) 0x07)
&& EvaluationHelper.equals(cpuFunctionType, (byte) 0x04)
&& EvaluationHelper.equals(cpuSubfunction, (short) 0x04)) {
builder =
S7PayloadUserDataItemClkSetRequest.staticParseS7PayloadUserDataItemBuilder(
readBuffer, cpuFunctionGroup, cpuFunctionType, cpuSubfunction);
} else if (EvaluationHelper.equals(cpuFunctionGroup, (byte) 0x07)
&& EvaluationHelper.equals(cpuFunctionType, (byte) 0x08)
&& EvaluationHelper.equals(cpuSubfunction, (short) 0x04)) {
builder =
S7PayloadUserDataItemClkSetResponse.staticParseS7PayloadUserDataItemBuilder(
readBuffer, cpuFunctionGroup, cpuFunctionType, cpuSubfunction);
}
if (builder == null) {
throw new ParseException(
Expand Down
Loading

0 comments on commit 5f6c232

Please sign in to comment.