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 701 #776

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# User-specific stuff:
.idea/**
*/.idea/**
.idea/*.xml
*/.idea/*.xml
*.iml
.vscode/**
.java-version
Expand Down Expand Up @@ -196,3 +196,5 @@ link.txt*/
CMakeFiles/
CMakeCache.txt
DartConfiguration.tcl
/.idea/libraries/
/.idea/inspectionProfiles/
13 changes: 13 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions .idea/fileTemplates/includes/File Header Yml.yml

This file was deleted.

17 changes: 13 additions & 4 deletions plc4j/drivers/profinet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
<languageName>java</languageName>
<outputFlavor>read-write</outputFlavor>
<outputDir>src/main/generated</outputDir>
<options>
<generate-properties-for-parser-arguments>true</generate-properties-for-parser-arguments>
<!-- We want properties that contain the values of reserved fields, if the value differs from the expected one -->
<generate-properties-for-reserved-fields>true</generate-properties-for-reserved-fields>
</options>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -149,10 +154,6 @@
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down Expand Up @@ -218,6 +219,14 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.plc4x.java.profinet.readwrite;

import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*;
import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*;
import static org.apache.plc4x.java.spi.codegen.io.DataReaderFactory.*;
import static org.apache.plc4x.java.spi.codegen.io.DataWriterFactory.*;
import static org.apache.plc4x.java.spi.generation.StaticHelper.*;

import java.time.*;
import java.util.*;
import org.apache.plc4x.java.api.exceptions.*;
import org.apache.plc4x.java.api.value.*;
import org.apache.plc4x.java.spi.codegen.*;
import org.apache.plc4x.java.spi.codegen.fields.*;
import org.apache.plc4x.java.spi.codegen.io.*;
import org.apache.plc4x.java.spi.generation.*;

// Code generated by code-generation. DO NOT EDIT.

public class CheckPeers extends PnIoCm_Block implements Message {

// Accessors for discriminator values.
public PnIoCm_BlockType getBlockType() {
return PnIoCm_BlockType.CHECK_PEERS;
}

// Constant values.
public static final Short NOOFPEERS = 0x01;

// Properties.
protected final short blockVersionHigh;
protected final short blockVersionLow;
protected final PascalString peerPortId;
protected final PascalString peerChassisId;

public CheckPeers(
short blockVersionHigh,
short blockVersionLow,
PascalString peerPortId,
PascalString peerChassisId) {
super();
this.blockVersionHigh = blockVersionHigh;
this.blockVersionLow = blockVersionLow;
this.peerPortId = peerPortId;
this.peerChassisId = peerChassisId;
}

public short getBlockVersionHigh() {
return blockVersionHigh;
}

public short getBlockVersionLow() {
return blockVersionLow;
}

public PascalString getPeerPortId() {
return peerPortId;
}

public PascalString getPeerChassisId() {
return peerChassisId;
}

public short getNoOfPeers() {
return NOOFPEERS;
}

@Override
protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException {
PositionAware positionAware = writeBuffer;
int startPos = positionAware.getPos();
writeBuffer.pushContext("CheckPeers");

// Implicit Field (blockLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int blockLength = (int) ((getLengthInBytes()) - (4));
writeImplicitField(
"blockLength",
blockLength,
writeUnsignedInt(writeBuffer, 16),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

// Simple Field (blockVersionHigh)
writeSimpleField(
"blockVersionHigh",
blockVersionHigh,
writeUnsignedShort(writeBuffer, 8),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

// Simple Field (blockVersionLow)
writeSimpleField(
"blockVersionLow",
blockVersionLow,
writeUnsignedShort(writeBuffer, 8),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

// Const Field (noOfPeers)
writeConstField(
"noOfPeers",
NOOFPEERS,
writeUnsignedShort(writeBuffer, 8),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

// Simple Field (peerPortId)
writeSimpleField(
"peerPortId",
peerPortId,
new DataWriterComplexDefault<>(writeBuffer),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

// Simple Field (peerChassisId)
writeSimpleField(
"peerChassisId",
peerChassisId,
new DataWriterComplexDefault<>(writeBuffer),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

writeBuffer.popContext("CheckPeers");
}

@Override
public int getLengthInBytes() {
return (int) Math.ceil((float) getLengthInBits() / 8.0);
}

@Override
public int getLengthInBits() {
int lengthInBits = super.getLengthInBits();
CheckPeers _value = this;

// Implicit Field (blockLength)
lengthInBits += 16;

// Simple field (blockVersionHigh)
lengthInBits += 8;

// Simple field (blockVersionLow)
lengthInBits += 8;

// Const Field (noOfPeers)
lengthInBits += 8;

// Simple field (peerPortId)
lengthInBits += peerPortId.getLengthInBits();

// Simple field (peerChassisId)
lengthInBits += peerChassisId.getLengthInBits();

return lengthInBits;
}

public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer)
throws ParseException {
readBuffer.pullContext("CheckPeers");
PositionAware positionAware = readBuffer;
int startPos = positionAware.getPos();
int curPos;

int blockLength =
readImplicitField(
"blockLength",
readUnsignedInt(readBuffer, 16),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

short blockVersionHigh =
readSimpleField(
"blockVersionHigh",
readUnsignedShort(readBuffer, 8),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

short blockVersionLow =
readSimpleField(
"blockVersionLow",
readUnsignedShort(readBuffer, 8),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

short noOfPeers =
readConstField(
"noOfPeers",
readUnsignedShort(readBuffer, 8),
CheckPeers.NOOFPEERS,
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

PascalString peerPortId =
readSimpleField(
"peerPortId",
new DataReaderComplexDefault<>(() -> PascalString.staticParse(readBuffer), readBuffer),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

PascalString peerChassisId =
readSimpleField(
"peerChassisId",
new DataReaderComplexDefault<>(() -> PascalString.staticParse(readBuffer), readBuffer),
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));

readBuffer.closeContext("CheckPeers");
// Create the instance
return new CheckPeersBuilderImpl(blockVersionHigh, blockVersionLow, peerPortId, peerChassisId);
}

public static class CheckPeersBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder {
private final short blockVersionHigh;
private final short blockVersionLow;
private final PascalString peerPortId;
private final PascalString peerChassisId;

public CheckPeersBuilderImpl(
short blockVersionHigh,
short blockVersionLow,
PascalString peerPortId,
PascalString peerChassisId) {
this.blockVersionHigh = blockVersionHigh;
this.blockVersionLow = blockVersionLow;
this.peerPortId = peerPortId;
this.peerChassisId = peerChassisId;
}

public CheckPeers build() {
CheckPeers checkPeers =
new CheckPeers(blockVersionHigh, blockVersionLow, peerPortId, peerChassisId);
return checkPeers;
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CheckPeers)) {
return false;
}
CheckPeers that = (CheckPeers) o;
return (getBlockVersionHigh() == that.getBlockVersionHigh())
&& (getBlockVersionLow() == that.getBlockVersionLow())
&& (getPeerPortId() == that.getPeerPortId())
&& (getPeerChassisId() == that.getPeerChassisId())
&& super.equals(that)
&& true;
}

@Override
public int hashCode() {
return Objects.hash(
super.hashCode(),
getBlockVersionHigh(),
getBlockVersionLow(),
getPeerPortId(),
getPeerChassisId());
}

@Override
public String toString() {
WriteBufferBoxBased writeBufferBoxBased = new WriteBufferBoxBased(true, true);
try {
writeBufferBoxBased.writeSerializable(this);
} catch (SerializationException e) {
throw new RuntimeException(e);
}
return "\n" + writeBufferBoxBased.getBox().toString() + "\n";
}
}
Loading