You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by hu...@apache.org on 2023/04/14 05:48:19 UTC
[plc4x] branch feat/profinet_ip_set updated: fix(plc4x/profinet): Filled out a bt more of the SetGet IP Address.
This is an automated email from the ASF dual-hosted git repository.
hutcheb pushed a commit to branch feat/profinet_ip_set
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/feat/profinet_ip_set by this push:
new b313b609fe fix(plc4x/profinet): Filled out a bt more of the SetGet IP Address.
b313b609fe is described below
commit b313b609fe27de9cb36fced0273c98c3b12ffeb7
Author: Ben Hutcheson <be...@gmail.com>
AuthorDate: Fri Apr 14 07:43:45 2023 +0200
fix(plc4x/profinet): Filled out a bt more of the SetGet IP Address.
Need to get IP address settings from network device for subnet and gateway.
---
.../java/profinet/readwrite/PcDcp_GetSet_Pdu.java | 345 +++++++++++++++++++++
.../plc4x/java/profinet/readwrite/PnDcp_Pdu.java | 2 +
.../profinet/context/ProfinetDeviceContext.java | 12 +
3 files changed, 359 insertions(+)
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PcDcp_GetSet_Pdu.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PcDcp_GetSet_Pdu.java
new file mode 100644
index 0000000000..df337ba4d1
--- /dev/null
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PcDcp_GetSet_Pdu.java
@@ -0,0 +1,345 @@
+/*
+ * 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 PcDcp_GetSet_Pdu extends PnDcp_Pdu implements Message {
+
+ // Accessors for discriminator values.
+
+ // Constant values.
+ public static final Short SERVICEID = 0x04;
+
+ // Properties.
+ protected final boolean notSupported;
+ protected final boolean response;
+ protected final long xid;
+ protected final List<PnDcp_Block> blocks;
+
+ // Reserved Fields
+ private Short reservedField0;
+ private Byte reservedField1;
+ private Integer reservedField2;
+
+ public PcDcp_GetSet_Pdu(
+ int frameIdValue,
+ boolean notSupported,
+ boolean response,
+ long xid,
+ List<PnDcp_Block> blocks) {
+ super(frameIdValue);
+ this.notSupported = notSupported;
+ this.response = response;
+ this.xid = xid;
+ this.blocks = blocks;
+ }
+
+ public boolean getNotSupported() {
+ return notSupported;
+ }
+
+ public boolean getResponse() {
+ return response;
+ }
+
+ public long getXid() {
+ return xid;
+ }
+
+ public List<PnDcp_Block> getBlocks() {
+ return blocks;
+ }
+
+ public short getServiceId() {
+ return SERVICEID;
+ }
+
+ @Override
+ protected void serializePnDcp_PduChild(WriteBuffer writeBuffer) throws SerializationException {
+ PositionAware positionAware = writeBuffer;
+ boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
+ int startPos = positionAware.getPos();
+ writeBuffer.pushContext("PcDcp_GetSet_Pdu");
+
+ // Const Field (serviceId)
+ writeConstField(
+ "serviceId",
+ SERVICEID,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ // Reserved Field (reserved)
+ writeReservedField(
+ "reserved",
+ reservedField0 != null ? reservedField0 : (short) 0x00,
+ writeUnsignedShort(writeBuffer, 5),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ // Simple Field (notSupported)
+ writeSimpleField(
+ "notSupported",
+ notSupported,
+ writeBoolean(writeBuffer),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ // Reserved Field (reserved)
+ writeReservedField(
+ "reserved",
+ reservedField1 != null ? reservedField1 : (byte) 0x00,
+ writeUnsignedByte(writeBuffer, 1),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ // Simple Field (response)
+ writeSimpleField(
+ "response",
+ response,
+ writeBoolean(writeBuffer),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ // Simple Field (xid)
+ writeSimpleField(
+ "xid",
+ xid,
+ writeUnsignedLong(writeBuffer, 32),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ // Reserved Field (reserved)
+ writeReservedField(
+ "reserved",
+ reservedField2 != null ? reservedField2 : (int) 0x0000,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ // Implicit Field (dcpDataLength) (Used for parsing, but its value is not stored as it's
+ // implicitly given by the objects content)
+ int dcpDataLength = (int) ((getLengthInBytes()) - (10));
+ writeImplicitField(
+ "dcpDataLength",
+ dcpDataLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ // Array Field (blocks)
+ writeComplexTypeArrayField(
+ "blocks", blocks, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ writeBuffer.popContext("PcDcp_GetSet_Pdu");
+ }
+
+ @Override
+ public int getLengthInBytes() {
+ return (int) Math.ceil((float) getLengthInBits() / 8.0);
+ }
+
+ @Override
+ public int getLengthInBits() {
+ int lengthInBits = super.getLengthInBits();
+ PcDcp_GetSet_Pdu _value = this;
+ boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
+
+ // Const Field (serviceId)
+ lengthInBits += 8;
+
+ // Reserved Field (reserved)
+ lengthInBits += 5;
+
+ // Simple field (notSupported)
+ lengthInBits += 1;
+
+ // Reserved Field (reserved)
+ lengthInBits += 1;
+
+ // Simple field (response)
+ lengthInBits += 1;
+
+ // Simple field (xid)
+ lengthInBits += 32;
+
+ // Reserved Field (reserved)
+ lengthInBits += 16;
+
+ // Implicit Field (dcpDataLength)
+ lengthInBits += 16;
+
+ // Array field
+ if (blocks != null) {
+ for (Message element : blocks) {
+ lengthInBits += element.getLengthInBits();
+ }
+ }
+
+ return lengthInBits;
+ }
+
+ public static PnDcp_PduBuilder staticParsePnDcp_PduBuilder(ReadBuffer readBuffer)
+ throws ParseException {
+ readBuffer.pullContext("PcDcp_GetSet_Pdu");
+ PositionAware positionAware = readBuffer;
+ int startPos = positionAware.getPos();
+ int curPos;
+ boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
+
+ short serviceId =
+ readConstField(
+ "serviceId",
+ readUnsignedShort(readBuffer, 8),
+ PcDcp_GetSet_Pdu.SERVICEID,
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ Short reservedField0 =
+ readReservedField(
+ "reserved",
+ readUnsignedShort(readBuffer, 5),
+ (short) 0x00,
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ boolean notSupported =
+ readSimpleField(
+ "notSupported",
+ readBoolean(readBuffer),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ Byte reservedField1 =
+ readReservedField(
+ "reserved",
+ readUnsignedByte(readBuffer, 1),
+ (byte) 0x00,
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ boolean response =
+ readSimpleField(
+ "response", readBoolean(readBuffer), WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ long xid =
+ readSimpleField(
+ "xid",
+ readUnsignedLong(readBuffer, 32),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ Integer reservedField2 =
+ readReservedField(
+ "reserved",
+ readUnsignedInt(readBuffer, 16),
+ (int) 0x0000,
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ int dcpDataLength =
+ readImplicitField(
+ "dcpDataLength",
+ readUnsignedInt(readBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ List<PnDcp_Block> blocks =
+ readLengthArrayField(
+ "blocks",
+ new DataReaderComplexDefault<>(() -> PnDcp_Block.staticParse(readBuffer), readBuffer),
+ dcpDataLength,
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
+
+ readBuffer.closeContext("PcDcp_GetSet_Pdu");
+ // Create the instance
+ return new PcDcp_GetSet_PduBuilderImpl(
+ notSupported, response, xid, blocks, reservedField0, reservedField1, reservedField2);
+ }
+
+ public static class PcDcp_GetSet_PduBuilderImpl implements PnDcp_Pdu.PnDcp_PduBuilder {
+ private final boolean notSupported;
+ private final boolean response;
+ private final long xid;
+ private final List<PnDcp_Block> blocks;
+ private final Short reservedField0;
+ private final Byte reservedField1;
+ private final Integer reservedField2;
+
+ public PcDcp_GetSet_PduBuilderImpl(
+ boolean notSupported,
+ boolean response,
+ long xid,
+ List<PnDcp_Block> blocks,
+ Short reservedField0,
+ Byte reservedField1,
+ Integer reservedField2) {
+ this.notSupported = notSupported;
+ this.response = response;
+ this.xid = xid;
+ this.blocks = blocks;
+ this.reservedField0 = reservedField0;
+ this.reservedField1 = reservedField1;
+ this.reservedField2 = reservedField2;
+ }
+
+ public PcDcp_GetSet_Pdu build(int frameIdValue) {
+ PcDcp_GetSet_Pdu pcDcp_GetSet_Pdu =
+ new PcDcp_GetSet_Pdu(frameIdValue, notSupported, response, xid, blocks);
+ pcDcp_GetSet_Pdu.reservedField0 = reservedField0;
+ pcDcp_GetSet_Pdu.reservedField1 = reservedField1;
+ pcDcp_GetSet_Pdu.reservedField2 = reservedField2;
+ return pcDcp_GetSet_Pdu;
+ }
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof PcDcp_GetSet_Pdu)) {
+ return false;
+ }
+ PcDcp_GetSet_Pdu that = (PcDcp_GetSet_Pdu) o;
+ return (getNotSupported() == that.getNotSupported())
+ && (getResponse() == that.getResponse())
+ && (getXid() == that.getXid())
+ && (getBlocks() == that.getBlocks())
+ && super.equals(that)
+ && true;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), getNotSupported(), getResponse(), getXid(), getBlocks());
+ }
+
+ @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";
+ }
+}
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnDcp_Pdu.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnDcp_Pdu.java
index fecec26267..a643ede656 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnDcp_Pdu.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnDcp_Pdu.java
@@ -131,6 +131,8 @@ public abstract class PnDcp_Pdu implements Message {
PnDcp_PduBuilder builder = null;
if (EvaluationHelper.equals(frameId, PnDcp_FrameId.RT_CLASS_1)) {
builder = PnDcp_Pdu_RealTimeCyclic.staticParsePnDcp_PduBuilder(readBuffer);
+ } else if (EvaluationHelper.equals(frameId, PnDcp_FrameId.DCP_GetSet_PDU)) {
+ builder = PcDcp_GetSet_Pdu.staticParsePnDcp_PduBuilder(readBuffer);
} else if (EvaluationHelper.equals(frameId, PnDcp_FrameId.PTCP_DelayReqPDU)) {
builder = PcDcp_Pdu_DelayReq.staticParsePnDcp_PduBuilder(readBuffer);
} else if (EvaluationHelper.equals(frameId, PnDcp_FrameId.Alarm_Low)) {
diff --git a/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/context/ProfinetDeviceContext.java b/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/context/ProfinetDeviceContext.java
index 345fe04366..acdb047621 100644
--- a/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/context/ProfinetDeviceContext.java
+++ b/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/context/ProfinetDeviceContext.java
@@ -231,6 +231,18 @@ public class ProfinetDeviceContext implements DriverContext, HasConfiguration<Pr
this.ipAddress = ipAddress;
}
+ public byte[] getIpAddressAsByteArray() {
+ return null;
+ }
+
+ public byte[] getSubnetAsByteArray() {
+ return null;
+ }
+
+ public byte[] getGatewayAsByteArray() {
+ return null;
+ }
+
public String getPortId() {
return portId;
}