Skip to content
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

Issue/s7h #1214

Merged
merged 5 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -33,6 +33,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 @@ -81,6 +100,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 @@ -118,46 +147,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 @@ -166,53 +194,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
Loading