Skip to content

Commit f45f405

Browse files
hutchebceos01
authored andcommitted
Plc4j/Profinet (#534)
* fix(plc4j/profinet): Fix to remove spaces from the generated connection string. * fix(plc4j(profinet): Connections are working for my setup * fix(plc4j(profinet): Add Dummy Advanced Connection Write Request * fix(plc4j(profinet): Started to add the LLDP broadcast * fix(plc4j(profinet): Continued to add the LLDP broadcast * fix(plc4j(profinet): Finished the connection setup. * feat(plc4j/profinet): Fixed a few minor issues and added the Application Ready packet * feat(plc4j/profinet): Escape spaces using %20 * feat(plc4j/): split out dcp and lldp tasks, so they can be processed separately. * fix(plc4j/profinet): Identified that the Application Ready request comes from the device. * fix(plc4j/profinet): Cleaned up the message send and receive interface * chore(plc4j/profinet): escape the device name and type within the connection string * fix(plc4j/profinet): Continued to split device logic out. * feat(plc4j/profinet): Add outline of GSDML parser. * feat(plc4j/profinet): Finished major components of parser * feat(plc4j/profinet): Add External text Data * feat(plc4j/profinet): Generated Getters * feat(plc4j/profinet): Add Dummy GSDML file * feat(plc4j/profinet): Added basic test case * feat(plc4j/profinet): Add GSD directory Configuration Parameter and cleaned up device parameter * feat(plc4j/profinet): Standardize the mac address key to uppercase * feat(plc4j/profinet): Need to Review the UDP checksum field. * feat(plc4j/profinet): Add dummy checksum field in IPv4 packets * feat(plc4j/profinet): Mistake leaving request as a response in mspec * feat(plc4j/profinet): Add reading gsd directory and starting to add support for optional submodules. * feat(plc4j/profinet): Splitting out connection request, using default config from gsd file. * feat(plc4j/profinet): Realised that the pcap promiscuous mode handles don't play nicely with other connections. * feat(plc4j/profinet): Add support for UDP packets, this allows us to use the same channel to receive all packets. * feat(plc4j/profinet): Fixed parsing of PnIo_CyclicServiceDataUnit into an array of bytes. This needs to be parsed into the format from the gsd file. * feat(plc4j/profinet): Cleaned up a little and added the IODataObject to the cyclic write packets. * feat(plc4j/profinet): Started to add the submodules to the configuration. * feat(plc4j/profinet): Add support for optional modules in the connection packet, still need to add support within the write parameters packet. * feat(plc4j/profinet): Add support for writing records during startup * feat(plc4j/profinet): Add datahold factor to configuration * fix(plc4j/profinet): Fix failing tests * feat(plc4j/profinet): Started to add the browse functionality, which is need to get a list of available tags. * feat(plc4j/profinet): Add more browse functionality. * feat(plc4j/profinet): Started to standardize the way the GSD file is queried. * feat(plc4j/profinet): Updated the parsing of the submodule connection string section * feat(plc4j/profinet): Fixed the cyclic comms after refactoring for tag browsing * feat(plc4j/profinet): add metadata to browse tags * fix(plc4j/profinet): Fix issues after merging develop * fix(plc4j/profinet): Finished removing the BaseConfiguration class, the local ip address is now taken from the channel config. * fix(plc4j/profinet): fix dependency check and remove manual test * fix(plc4j/profinet): fix disabled test for gsdfiles * fix(plc4j/profinet): Add support for checking if a submodule is found in the list of usable modules. * fix(plc4j/profinet): update tests for browsing * fix(plc4j/profinet): Continued filling out the browse structure. * fix(plc4j/profinet): Minor change to support older Java versions * fix(plc4j/profinet): Refactoring the configuration to allow for an easier initialization of devices. * fix(plc4j/profinet): Refactoring the configuration to allow for an easier initialization of devices. * fix(plc4j/profinet): Refactoring the submodules, this stops us from having to repeatedly querying the gsd file directly. * fix(plc4j/profinet): Continue refactoring * fix(readme): Flattening the tags returned by browsing. * fix(plc4j/profinet): Expanded supported data types. * fix(plc4j/profinet): Add extra tests for browsing tags * fix(plc4j/profinet): Fix issues after refactoring. * fix(plc4j/profinet): Add support for parsing returned data as well as routing cyclic data to device handler. * fix(plc4j/profinet): Add the subscription logic. * fix(plc4j/profinet): Starting to add error handling cases * fix(plc4j/profinet): Fixed issue with cycle timer as well as included auto re-connect on failed connection. Also updated the documentation. * fix(plc4j/profinet): Fixed up some files that were changed accidentally * fix(plc4j): don't exclude the template folder in .idea * fix(plc4j/profinet): update manual profinet test * fix(plc4j/profinet): Cleaned up and changed to using states for each device * fix(plc4j/profinet): Fixing exception handling. * fix(plc4j/profinet): Cleaned up a little * fix(plc4j/profinet): Add support for individual subscriptions and change of state subscriptions * fix(plc4j/profinet): Fixed issue with non bit data values and browse response * fix(plc4j/profinet): Merged Develop and updated generated classes
1 parent 91fb843 commit f45f405

File tree

148 files changed

+16986
-1135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+16986
-1135
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# User-specific stuff:
2-
.idea/**
3-
*/.idea/**
2+
.idea/*.xml
3+
*/.idea/*.xml
44
*.iml
55
.vscode/**
66
.java-version
@@ -196,3 +196,5 @@ link.txt*/
196196
CMakeFiles/
197197
CMakeCache.txt
198198
DartConfiguration.tcl
199+
/.idea/libraries/
200+
/.idea/inspectionProfiles/

.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/fileTemplates/includes/File Header Yml.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

plc4j/drivers/profinet/pom.xml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<languageName>java</languageName>
4848
<outputFlavor>read-write</outputFlavor>
4949
<outputDir>src/main/generated</outputDir>
50+
<options>
51+
<generate-properties-for-parser-arguments>true</generate-properties-for-parser-arguments>
52+
<!-- We want properties that contain the values of reserved fields, if the value differs from the expected one -->
53+
<generate-properties-for-reserved-fields>true</generate-properties-for-reserved-fields>
54+
</options>
5055
</configuration>
5156
</execution>
5257
</executions>
@@ -149,10 +154,6 @@
149154
<groupId>io.netty</groupId>
150155
<artifactId>netty-buffer</artifactId>
151156
</dependency>
152-
<dependency>
153-
<groupId>io.netty</groupId>
154-
<artifactId>netty-transport</artifactId>
155-
</dependency>
156157
<dependency>
157158
<groupId>org.apache.commons</groupId>
158159
<artifactId>commons-lang3</artifactId>
@@ -218,6 +219,14 @@
218219
<type>test-jar</type>
219220
<scope>test</scope>
220221
</dependency>
222+
<dependency>
223+
<groupId>com.fasterxml.jackson.core</groupId>
224+
<artifactId>jackson-annotations</artifactId>
225+
</dependency>
226+
<dependency>
227+
<groupId>com.fasterxml.jackson.dataformat</groupId>
228+
<artifactId>jackson-dataformat-xml</artifactId>
229+
</dependency>
221230
</dependencies>
222231

223232
</project>
Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.plc4x.java.profinet.readwrite;
20+
21+
import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*;
22+
import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*;
23+
import static org.apache.plc4x.java.spi.codegen.io.DataReaderFactory.*;
24+
import static org.apache.plc4x.java.spi.codegen.io.DataWriterFactory.*;
25+
import static org.apache.plc4x.java.spi.generation.StaticHelper.*;
26+
27+
import java.time.*;
28+
import java.util.*;
29+
import org.apache.plc4x.java.api.exceptions.*;
30+
import org.apache.plc4x.java.api.value.*;
31+
import org.apache.plc4x.java.spi.codegen.*;
32+
import org.apache.plc4x.java.spi.codegen.fields.*;
33+
import org.apache.plc4x.java.spi.codegen.io.*;
34+
import org.apache.plc4x.java.spi.generation.*;
35+
36+
// Code generated by code-generation. DO NOT EDIT.
37+
38+
public class CheckPeers extends PnIoCm_Block implements Message {
39+
40+
// Accessors for discriminator values.
41+
public PnIoCm_BlockType getBlockType() {
42+
return PnIoCm_BlockType.CHECK_PEERS;
43+
}
44+
45+
// Constant values.
46+
public static final Short NOOFPEERS = 0x01;
47+
48+
// Properties.
49+
protected final short blockVersionHigh;
50+
protected final short blockVersionLow;
51+
protected final PascalString peerPortId;
52+
protected final PascalString peerChassisId;
53+
54+
public CheckPeers(
55+
short blockVersionHigh,
56+
short blockVersionLow,
57+
PascalString peerPortId,
58+
PascalString peerChassisId) {
59+
super();
60+
this.blockVersionHigh = blockVersionHigh;
61+
this.blockVersionLow = blockVersionLow;
62+
this.peerPortId = peerPortId;
63+
this.peerChassisId = peerChassisId;
64+
}
65+
66+
public short getBlockVersionHigh() {
67+
return blockVersionHigh;
68+
}
69+
70+
public short getBlockVersionLow() {
71+
return blockVersionLow;
72+
}
73+
74+
public PascalString getPeerPortId() {
75+
return peerPortId;
76+
}
77+
78+
public PascalString getPeerChassisId() {
79+
return peerChassisId;
80+
}
81+
82+
public short getNoOfPeers() {
83+
return NOOFPEERS;
84+
}
85+
86+
@Override
87+
protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException {
88+
PositionAware positionAware = writeBuffer;
89+
int startPos = positionAware.getPos();
90+
writeBuffer.pushContext("CheckPeers");
91+
92+
// Implicit Field (blockLength) (Used for parsing, but its value is not stored as it's
93+
// implicitly given by the objects content)
94+
int blockLength = (int) ((getLengthInBytes()) - (4));
95+
writeImplicitField(
96+
"blockLength",
97+
blockLength,
98+
writeUnsignedInt(writeBuffer, 16),
99+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
100+
101+
// Simple Field (blockVersionHigh)
102+
writeSimpleField(
103+
"blockVersionHigh",
104+
blockVersionHigh,
105+
writeUnsignedShort(writeBuffer, 8),
106+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
107+
108+
// Simple Field (blockVersionLow)
109+
writeSimpleField(
110+
"blockVersionLow",
111+
blockVersionLow,
112+
writeUnsignedShort(writeBuffer, 8),
113+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
114+
115+
// Const Field (noOfPeers)
116+
writeConstField(
117+
"noOfPeers",
118+
NOOFPEERS,
119+
writeUnsignedShort(writeBuffer, 8),
120+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
121+
122+
// Simple Field (peerPortId)
123+
writeSimpleField(
124+
"peerPortId",
125+
peerPortId,
126+
new DataWriterComplexDefault<>(writeBuffer),
127+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
128+
129+
// Simple Field (peerChassisId)
130+
writeSimpleField(
131+
"peerChassisId",
132+
peerChassisId,
133+
new DataWriterComplexDefault<>(writeBuffer),
134+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
135+
136+
writeBuffer.popContext("CheckPeers");
137+
}
138+
139+
@Override
140+
public int getLengthInBytes() {
141+
return (int) Math.ceil((float) getLengthInBits() / 8.0);
142+
}
143+
144+
@Override
145+
public int getLengthInBits() {
146+
int lengthInBits = super.getLengthInBits();
147+
CheckPeers _value = this;
148+
149+
// Implicit Field (blockLength)
150+
lengthInBits += 16;
151+
152+
// Simple field (blockVersionHigh)
153+
lengthInBits += 8;
154+
155+
// Simple field (blockVersionLow)
156+
lengthInBits += 8;
157+
158+
// Const Field (noOfPeers)
159+
lengthInBits += 8;
160+
161+
// Simple field (peerPortId)
162+
lengthInBits += peerPortId.getLengthInBits();
163+
164+
// Simple field (peerChassisId)
165+
lengthInBits += peerChassisId.getLengthInBits();
166+
167+
return lengthInBits;
168+
}
169+
170+
public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer)
171+
throws ParseException {
172+
readBuffer.pullContext("CheckPeers");
173+
PositionAware positionAware = readBuffer;
174+
int startPos = positionAware.getPos();
175+
int curPos;
176+
177+
int blockLength =
178+
readImplicitField(
179+
"blockLength",
180+
readUnsignedInt(readBuffer, 16),
181+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
182+
183+
short blockVersionHigh =
184+
readSimpleField(
185+
"blockVersionHigh",
186+
readUnsignedShort(readBuffer, 8),
187+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
188+
189+
short blockVersionLow =
190+
readSimpleField(
191+
"blockVersionLow",
192+
readUnsignedShort(readBuffer, 8),
193+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
194+
195+
short noOfPeers =
196+
readConstField(
197+
"noOfPeers",
198+
readUnsignedShort(readBuffer, 8),
199+
CheckPeers.NOOFPEERS,
200+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
201+
202+
PascalString peerPortId =
203+
readSimpleField(
204+
"peerPortId",
205+
new DataReaderComplexDefault<>(() -> PascalString.staticParse(readBuffer), readBuffer),
206+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
207+
208+
PascalString peerChassisId =
209+
readSimpleField(
210+
"peerChassisId",
211+
new DataReaderComplexDefault<>(() -> PascalString.staticParse(readBuffer), readBuffer),
212+
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
213+
214+
readBuffer.closeContext("CheckPeers");
215+
// Create the instance
216+
return new CheckPeersBuilderImpl(blockVersionHigh, blockVersionLow, peerPortId, peerChassisId);
217+
}
218+
219+
public static class CheckPeersBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder {
220+
private final short blockVersionHigh;
221+
private final short blockVersionLow;
222+
private final PascalString peerPortId;
223+
private final PascalString peerChassisId;
224+
225+
public CheckPeersBuilderImpl(
226+
short blockVersionHigh,
227+
short blockVersionLow,
228+
PascalString peerPortId,
229+
PascalString peerChassisId) {
230+
this.blockVersionHigh = blockVersionHigh;
231+
this.blockVersionLow = blockVersionLow;
232+
this.peerPortId = peerPortId;
233+
this.peerChassisId = peerChassisId;
234+
}
235+
236+
public CheckPeers build() {
237+
CheckPeers checkPeers =
238+
new CheckPeers(blockVersionHigh, blockVersionLow, peerPortId, peerChassisId);
239+
return checkPeers;
240+
}
241+
}
242+
243+
@Override
244+
public boolean equals(Object o) {
245+
if (this == o) {
246+
return true;
247+
}
248+
if (!(o instanceof CheckPeers)) {
249+
return false;
250+
}
251+
CheckPeers that = (CheckPeers) o;
252+
return (getBlockVersionHigh() == that.getBlockVersionHigh())
253+
&& (getBlockVersionLow() == that.getBlockVersionLow())
254+
&& (getPeerPortId() == that.getPeerPortId())
255+
&& (getPeerChassisId() == that.getPeerChassisId())
256+
&& super.equals(that)
257+
&& true;
258+
}
259+
260+
@Override
261+
public int hashCode() {
262+
return Objects.hash(
263+
super.hashCode(),
264+
getBlockVersionHigh(),
265+
getBlockVersionLow(),
266+
getPeerPortId(),
267+
getPeerChassisId());
268+
}
269+
270+
@Override
271+
public String toString() {
272+
WriteBufferBoxBased writeBufferBoxBased = new WriteBufferBoxBased(true, true);
273+
try {
274+
writeBufferBoxBased.writeSerializable(this);
275+
} catch (SerializationException e) {
276+
throw new RuntimeException(e);
277+
}
278+
return "\n" + writeBufferBoxBased.getBox().toString() + "\n";
279+
}
280+
}

0 commit comments

Comments
 (0)