From c5fa7c3e23b1e2007446064b8916ef2c4ebb3014 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Thu, 14 Dec 2023 08:44:38 +0100 Subject: [PATCH] fix: Managed to acknowledge the ApplicationReady request ... seems that there's problems with the "expectRequest" functionality. --- .../readwrite/PnIoCM_Block_Request.java | 372 ------------------ .../java/profinet/readwrite/PnIoCm_Block.java | 23 +- .../profinet/readwrite/PnIoCm_BlockType.java | 16 +- ...m_Block_ReqPlugAlarmApplicationReady.java} | 35 +- ...IoCm_Control_Request_ApplicationReady.java | 362 +++++++++++++++++ .../PnIoCm_Control_Request_ParameterEnd.java} | 40 +- ...Cm_Control_Response_ApplicationReady.java} | 38 +- ...PnIoCm_Control_Response_ParameterEnd.java} | 40 +- .../plc4x/java/profinet/ProfinetDriver.java | 2 - .../profinet/channel/ProfinetChannel.java | 5 +- ...ofinetRawSocketTransportConfiguration.java | 20 +- .../context/ProfinetDriverContext.java | 9 - .../profinet/packets/PnDcpPacketFactory.java | 224 ++++++++--- .../protocol/ProfinetProtocolLogic.java | 109 +++-- .../java/profinet/ManualProfinetIoTest.java | 2 +- .../java/profinet/ManualProfinetIoTest2.java | 45 +++ .../src/test/resources/logback-test.xml | 2 +- .../readwrite/PnIoCM_Block_Request.java | 372 ------------------ .../java/profinet/readwrite/PnIoCm_Block.java | 23 +- .../profinet/readwrite/PnIoCm_BlockType.java | 16 +- ...m_Block_ReqPlugAlarmApplicationReady.java} | 35 +- ...IoCm_Control_Request_ApplicationReady.java | 362 +++++++++++++++++ ... PnIoCm_Control_Request_ParameterEnd.java} | 40 +- ...Cm_Control_Response_ApplicationReady.java} | 38 +- ...PnIoCm_Control_Response_ParameterEnd.java} | 40 +- .../java/profinet/device/ProfinetDevice.java | 6 +- .../GeneratedDriverByteToMessageCodec.java | 4 +- .../resources/protocols/profinet/pnio.mspec | 28 +- 28 files changed, 1265 insertions(+), 1043 deletions(-) delete mode 100644 plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_Request.java rename plc4j/drivers/{profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPluginAlarmApplicationReady.java => profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPlugAlarmApplicationReady.java} (71%) create mode 100644 plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ApplicationReady.java rename plc4j/drivers/{profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request.java => profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ParameterEnd.java} (88%) rename plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/{PnIoCM_Block_ResponseConnect.java => PnIoCm_Control_Response_ApplicationReady.java} (88%) rename plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/{PnIoCm_Control_ResponseConnect.java => PnIoCm_Control_Response_ParameterEnd.java} (88%) create mode 100644 plc4j/drivers/profinet-ng/src/test/java/org/apache/plc4x/java/profinet/ManualProfinetIoTest2.java delete mode 100644 plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_Request.java rename plc4j/drivers/{profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPluginAlarmApplicationReady.java => profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPlugAlarmApplicationReady.java} (71%) create mode 100644 plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ApplicationReady.java rename plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/{PnIoCm_Control_ResponseConnect.java => PnIoCm_Control_Request_ParameterEnd.java} (88%) rename plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/{PnIoCM_Block_ResponseConnect.java => PnIoCm_Control_Response_ApplicationReady.java} (88%) rename plc4j/drivers/{profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request.java => profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ParameterEnd.java} (88%) diff --git a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_Request.java b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_Request.java deleted file mode 100644 index e1252f1d01e..00000000000 --- a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_Request.java +++ /dev/null @@ -1,372 +0,0 @@ -/* - * 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 PnIoCM_Block_Request extends PnIoCm_Block implements Message { - - // Accessors for discriminator values. - public PnIoCm_BlockType getBlockType() { - return PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION; - } - - // Properties. - protected final short blockVersionHigh; - protected final short blockVersionLow; - protected final Uuid arUuid; - protected final int sessionKey; - protected final int controlCommand; - protected final int controlBlockProperties; - - // Reserved Fields - private Integer reservedField0; - private Integer reservedField1; - - public PnIoCM_Block_Request( - short blockVersionHigh, - short blockVersionLow, - Uuid arUuid, - int sessionKey, - int controlCommand, - int controlBlockProperties) { - super(); - this.blockVersionHigh = blockVersionHigh; - this.blockVersionLow = blockVersionLow; - this.arUuid = arUuid; - this.sessionKey = sessionKey; - this.controlCommand = controlCommand; - this.controlBlockProperties = controlBlockProperties; - } - - public short getBlockVersionHigh() { - return blockVersionHigh; - } - - public short getBlockVersionLow() { - return blockVersionLow; - } - - public Uuid getArUuid() { - return arUuid; - } - - public int getSessionKey() { - return sessionKey; - } - - public int getControlCommand() { - return controlCommand; - } - - public int getControlBlockProperties() { - return controlBlockProperties; - } - - @Override - protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { - PositionAware positionAware = writeBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("PnIoCM_Block_Request"); - - // 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)); - - // Reserved Field (reserved) - writeReservedField( - "reserved", - reservedField0 != null ? reservedField0 : (int) 0x0000, - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Simple Field (arUuid) - writeSimpleField( - "arUuid", - arUuid, - new DataWriterComplexDefault<>(writeBuffer), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Simple Field (sessionKey) - writeSimpleField( - "sessionKey", - sessionKey, - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Reserved Field (reserved) - writeReservedField( - "reserved", - reservedField1 != null ? reservedField1 : (int) 0x0000, - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Simple Field (controlCommand) - writeSimpleField( - "controlCommand", - controlCommand, - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Simple Field (controlBlockProperties) - writeSimpleField( - "controlBlockProperties", - controlBlockProperties, - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - writeBuffer.popContext("PnIoCM_Block_Request"); - } - - @Override - public int getLengthInBytes() { - return (int) Math.ceil((float) getLengthInBits() / 8.0); - } - - @Override - public int getLengthInBits() { - int lengthInBits = super.getLengthInBits(); - PnIoCM_Block_Request _value = this; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - // Implicit Field (blockLength) - lengthInBits += 16; - - // Simple field (blockVersionHigh) - lengthInBits += 8; - - // Simple field (blockVersionLow) - lengthInBits += 8; - - // Reserved Field (reserved) - lengthInBits += 16; - - // Simple field (arUuid) - lengthInBits += arUuid.getLengthInBits(); - - // Simple field (sessionKey) - lengthInBits += 16; - - // Reserved Field (reserved) - lengthInBits += 16; - - // Simple field (controlCommand) - lengthInBits += 16; - - // Simple field (controlBlockProperties) - lengthInBits += 16; - - return lengthInBits; - } - - public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) - throws ParseException { - readBuffer.pullContext("PnIoCM_Block_Request"); - PositionAware positionAware = readBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - 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)); - - Integer reservedField0 = - readReservedField( - "reserved", - readUnsignedInt(readBuffer, 16), - (int) 0x0000, - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - Uuid arUuid = - readSimpleField( - "arUuid", - new DataReaderComplexDefault<>(() -> Uuid.staticParse(readBuffer), readBuffer), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - int sessionKey = - readSimpleField( - "sessionKey", - readUnsignedInt(readBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - Integer reservedField1 = - readReservedField( - "reserved", - readUnsignedInt(readBuffer, 16), - (int) 0x0000, - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - int controlCommand = - readSimpleField( - "controlCommand", - readUnsignedInt(readBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - int controlBlockProperties = - readSimpleField( - "controlBlockProperties", - readUnsignedInt(readBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - readBuffer.closeContext("PnIoCM_Block_Request"); - // Create the instance - return new PnIoCM_Block_RequestBuilderImpl( - blockVersionHigh, - blockVersionLow, - arUuid, - sessionKey, - controlCommand, - controlBlockProperties, - reservedField0, - reservedField1); - } - - public static class PnIoCM_Block_RequestBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder { - private final short blockVersionHigh; - private final short blockVersionLow; - private final Uuid arUuid; - private final int sessionKey; - private final int controlCommand; - private final int controlBlockProperties; - private final Integer reservedField0; - private final Integer reservedField1; - - public PnIoCM_Block_RequestBuilderImpl( - short blockVersionHigh, - short blockVersionLow, - Uuid arUuid, - int sessionKey, - int controlCommand, - int controlBlockProperties, - Integer reservedField0, - Integer reservedField1) { - this.blockVersionHigh = blockVersionHigh; - this.blockVersionLow = blockVersionLow; - this.arUuid = arUuid; - this.sessionKey = sessionKey; - this.controlCommand = controlCommand; - this.controlBlockProperties = controlBlockProperties; - this.reservedField0 = reservedField0; - this.reservedField1 = reservedField1; - } - - public PnIoCM_Block_Request build() { - PnIoCM_Block_Request pnIoCM_Block_Request = - new PnIoCM_Block_Request( - blockVersionHigh, - blockVersionLow, - arUuid, - sessionKey, - controlCommand, - controlBlockProperties); - pnIoCM_Block_Request.reservedField0 = reservedField0; - pnIoCM_Block_Request.reservedField1 = reservedField1; - return pnIoCM_Block_Request; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof PnIoCM_Block_Request)) { - return false; - } - PnIoCM_Block_Request that = (PnIoCM_Block_Request) o; - return (getBlockVersionHigh() == that.getBlockVersionHigh()) - && (getBlockVersionLow() == that.getBlockVersionLow()) - && (getArUuid() == that.getArUuid()) - && (getSessionKey() == that.getSessionKey()) - && (getControlCommand() == that.getControlCommand()) - && (getControlBlockProperties() == that.getControlBlockProperties()) - && super.equals(that) - && true; - } - - @Override - public int hashCode() { - return Objects.hash( - super.hashCode(), - getBlockVersionHigh(), - getBlockVersionLow(), - getArUuid(), - getSessionKey(), - getControlCommand(), - getControlBlockProperties()); - } - - @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-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block.java b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block.java index 4065b855370..20ea5e8bef8 100644 --- a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block.java +++ b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block.java @@ -125,14 +125,17 @@ public static PnIoCm_Block staticParse(ReadBuffer readBuffer) throws ParseExcept } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.AR_BLOCK_RES)) { builder = PnIoCm_Block_ArRes.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals( - blockType, PnIoCm_BlockType.IOD_BLOCK_REQ_CONNECTION_APPLICATION_READY)) { - builder = PnIoCm_Control_Request.staticParsePnIoCm_BlockBuilder(readBuffer); - } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION)) { - builder = PnIoCM_Block_Request.staticParsePnIoCm_BlockBuilder(readBuffer); - } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.IOX_BLOCK_RES_CONNECT)) { - builder = PnIoCM_Block_ResponseConnect.staticParsePnIoCm_BlockBuilder(readBuffer); - } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.IOD_CONTROL_RES_CONNECT)) { - builder = PnIoCm_Control_ResponseConnect.staticParsePnIoCm_BlockBuilder(readBuffer); + blockType, PnIoCm_BlockType.IOD_BLOCK_REQ_CONNECTION_PARAMETER_END)) { + builder = PnIoCm_Control_Request_ParameterEnd.staticParsePnIoCm_BlockBuilder(readBuffer); + } else if (EvaluationHelper.equals( + blockType, PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY)) { + builder = PnIoCm_Control_Request_ApplicationReady.staticParsePnIoCm_BlockBuilder(readBuffer); + } else if (EvaluationHelper.equals( + blockType, PnIoCm_BlockType.IOX_BLOCK_RES_CONNECTION_APPLICATION_READY)) { + builder = PnIoCm_Control_Response_ApplicationReady.staticParsePnIoCm_BlockBuilder(readBuffer); + } else if (EvaluationHelper.equals( + blockType, PnIoCm_BlockType.IOD_BLOCK_RES_CONNECTION_PARAMETER_END)) { + builder = PnIoCm_Control_Response_ParameterEnd.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.IO_CR_BLOCK_REQ)) { builder = PnIoCm_Block_IoCrReq.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.IO_CR_BLOCK_RES)) { @@ -150,9 +153,9 @@ public static PnIoCm_Block staticParse(ReadBuffer readBuffer) throws ParseExcept } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.REAL_IDENTIFICATION_DATA)) { builder = PnIoCm_Block_RealIdentificationData.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals( - blockType, PnIoCm_BlockType.IOD_BLOCK_REQ_PLUGIN_ALARM_APPLICATION_READY)) { + blockType, PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY_PLUG_ALARM)) { builder = - PnIoCm_Block_ReqPluginAlarmApplicationReady.staticParsePnIoCm_BlockBuilder(readBuffer); + PnIoCm_Block_ReqPlugAlarmApplicationReady.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.I_AND_M_0)) { builder = PnIoCm_Block_IAndM0.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.I_AND_M_1)) { diff --git a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_BlockType.java b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_BlockType.java index 1d15c7cb0a8..1fdebe70111 100644 --- a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_BlockType.java +++ b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_BlockType.java @@ -65,10 +65,10 @@ public enum PnIoCm_BlockType { SR_INFO_BLOCK((int) 0x010A), ARFSU_BLOCK((int) 0x010B), RS_INFO_BLOCK((int) 0x010C), - IOD_BLOCK_REQ_CONNECTION_APPLICATION_READY((int) 0x0110), - IOD_BLOCK_REQ_PLUGIN_ALARM_APPLICATION_READY((int) 0x0101), - IOX_BLOCK_REQ_CONNECTION((int) 0x0112), - IOX_BLOCK_REQ_PLUGIN_ALARM((int) 0x0113), + IOD_BLOCK_REQ_CONNECTION_PARAMETER_END((int) 0x0110), + IOD_BLOCK_REQ_CONNECTION_PARAMETER_END_PLUG_ALARM((int) 0x0111), + IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY((int) 0x0112), + IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY_PLUG_ALARM((int) 0x0113), RELEASE_BLOCK_REQ((int) 0x0114), IOX_BLOCK_REQ_CONNECTION_READY_FOR_COMPANION((int) 0x0116), IOX_BLOCK_REQ_CONNECTION_READY_FOR_RT_CLASS_3((int) 0x0117), @@ -101,10 +101,10 @@ public enum PnIoCm_BlockType { AR_SERVER_BLOCK((int) 0x8106), AR_RPC_BLOCK_RES((int) 0x8007), AR_VENDOR_BLOCK_RES((int) 0x8008), - IOD_CONTROL_RES_CONNECT((int) 0x8110), - IOD_CONTROL_RES_PLUG((int) 0x8111), - IOX_BLOCK_RES_CONNECT((int) 0x8112), - IOX_BLOCK_RES_PLUG((int) 0x8113), + IOD_BLOCK_RES_CONNECTION_PARAMETER_END((int) 0x8110), + IOD_BLOCK_REs_CONNECTION_PARAMETER_END_PLUG_ALARM((int) 0x8111), + IOX_BLOCK_RES_CONNECTION_APPLICATION_READY((int) 0x8112), + IOX_BLOCK_REs_CONNECTION_APPLICATION_READY_PLUG_ALARM((int) 0x8113), RELEASE_BLOCK_RES((int) 0x8114), IOX_BLOCK_RES_CONNECT_COMPANION_READY((int) 0x8116), IOX_BLOCK_RES_CONNECT_RT_CLASS_3_READY((int) 0x8117), diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPluginAlarmApplicationReady.java b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPlugAlarmApplicationReady.java similarity index 71% rename from plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPluginAlarmApplicationReady.java rename to plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPlugAlarmApplicationReady.java index 73b9d230c4f..37b53611c32 100644 --- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPluginAlarmApplicationReady.java +++ b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPlugAlarmApplicationReady.java @@ -35,14 +35,14 @@ // Code generated by code-generation. DO NOT EDIT. -public class PnIoCm_Block_ReqPluginAlarmApplicationReady extends PnIoCm_Block implements Message { +public class PnIoCm_Block_ReqPlugAlarmApplicationReady extends PnIoCm_Block implements Message { // Accessors for discriminator values. public PnIoCm_BlockType getBlockType() { - return PnIoCm_BlockType.IOD_BLOCK_REQ_PLUGIN_ALARM_APPLICATION_READY; + return PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY_PLUG_ALARM; } - public PnIoCm_Block_ReqPluginAlarmApplicationReady() { + public PnIoCm_Block_ReqPlugAlarmApplicationReady() { super(); } @@ -50,9 +50,9 @@ public PnIoCm_Block_ReqPluginAlarmApplicationReady() { protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { PositionAware positionAware = writeBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("PnIoCm_Block_ReqPluginAlarmApplicationReady"); + writeBuffer.pushContext("PnIoCm_Block_ReqPlugAlarmApplicationReady"); - writeBuffer.popContext("PnIoCm_Block_ReqPluginAlarmApplicationReady"); + writeBuffer.popContext("PnIoCm_Block_ReqPlugAlarmApplicationReady"); } @Override @@ -63,7 +63,7 @@ public int getLengthInBytes() { @Override public int getLengthInBits() { int lengthInBits = super.getLengthInBits(); - PnIoCm_Block_ReqPluginAlarmApplicationReady _value = this; + PnIoCm_Block_ReqPlugAlarmApplicationReady _value = this; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); return lengthInBits; @@ -71,24 +71,24 @@ public int getLengthInBits() { public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) throws ParseException { - readBuffer.pullContext("PnIoCm_Block_ReqPluginAlarmApplicationReady"); + readBuffer.pullContext("PnIoCm_Block_ReqPlugAlarmApplicationReady"); PositionAware positionAware = readBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - readBuffer.closeContext("PnIoCm_Block_ReqPluginAlarmApplicationReady"); + readBuffer.closeContext("PnIoCm_Block_ReqPlugAlarmApplicationReady"); // Create the instance - return new PnIoCm_Block_ReqPluginAlarmApplicationReadyBuilderImpl(); + return new PnIoCm_Block_ReqPlugAlarmApplicationReadyBuilderImpl(); } - public static class PnIoCm_Block_ReqPluginAlarmApplicationReadyBuilderImpl + public static class PnIoCm_Block_ReqPlugAlarmApplicationReadyBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder { - public PnIoCm_Block_ReqPluginAlarmApplicationReadyBuilderImpl() {} + public PnIoCm_Block_ReqPlugAlarmApplicationReadyBuilderImpl() {} - public PnIoCm_Block_ReqPluginAlarmApplicationReady build() { - PnIoCm_Block_ReqPluginAlarmApplicationReady pnIoCm_Block_ReqPluginAlarmApplicationReady = - new PnIoCm_Block_ReqPluginAlarmApplicationReady(); - return pnIoCm_Block_ReqPluginAlarmApplicationReady; + public PnIoCm_Block_ReqPlugAlarmApplicationReady build() { + PnIoCm_Block_ReqPlugAlarmApplicationReady pnIoCm_Block_ReqPlugAlarmApplicationReady = + new PnIoCm_Block_ReqPlugAlarmApplicationReady(); + return pnIoCm_Block_ReqPlugAlarmApplicationReady; } } @@ -97,11 +97,10 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof PnIoCm_Block_ReqPluginAlarmApplicationReady)) { + if (!(o instanceof PnIoCm_Block_ReqPlugAlarmApplicationReady)) { return false; } - PnIoCm_Block_ReqPluginAlarmApplicationReady that = - (PnIoCm_Block_ReqPluginAlarmApplicationReady) o; + PnIoCm_Block_ReqPlugAlarmApplicationReady that = (PnIoCm_Block_ReqPlugAlarmApplicationReady) o; return super.equals(that) && true; } diff --git a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ApplicationReady.java b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ApplicationReady.java new file mode 100644 index 00000000000..0df2f0ed2cf --- /dev/null +++ b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ApplicationReady.java @@ -0,0 +1,362 @@ +/* + * 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 PnIoCm_Control_Request_ApplicationReady extends PnIoCm_Block implements Message { + + // Accessors for discriminator values. + public PnIoCm_BlockType getBlockType() { + return PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY; + } + + // Properties. + protected final short blockVersionHigh; + protected final short blockVersionLow; + protected final Uuid arUuid; + protected final int sessionKey; + protected final int controlCommand; + + // Reserved Fields + private Integer reservedField0; + private Integer reservedField1; + private Integer reservedField2; + + public PnIoCm_Control_Request_ApplicationReady( + short blockVersionHigh, + short blockVersionLow, + Uuid arUuid, + int sessionKey, + int controlCommand) { + super(); + this.blockVersionHigh = blockVersionHigh; + this.blockVersionLow = blockVersionLow; + this.arUuid = arUuid; + this.sessionKey = sessionKey; + this.controlCommand = controlCommand; + } + + public short getBlockVersionHigh() { + return blockVersionHigh; + } + + public short getBlockVersionLow() { + return blockVersionLow; + } + + public Uuid getArUuid() { + return arUuid; + } + + public int getSessionKey() { + return sessionKey; + } + + public int getControlCommand() { + return controlCommand; + } + + @Override + protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { + PositionAware positionAware = writeBuffer; + boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); + writeBuffer.pushContext("PnIoCm_Control_Request_ApplicationReady"); + + // 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)); + + // Reserved Field (reserved) + writeReservedField( + "reserved", + reservedField0 != null ? reservedField0 : (int) 0x0000, + writeUnsignedInt(writeBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + // Simple Field (arUuid) + writeSimpleField( + "arUuid", + arUuid, + new DataWriterComplexDefault<>(writeBuffer), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + // Simple Field (sessionKey) + writeSimpleField( + "sessionKey", + sessionKey, + writeUnsignedInt(writeBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + // Reserved Field (reserved) + writeReservedField( + "reserved", + reservedField1 != null ? reservedField1 : (int) 0x0000, + writeUnsignedInt(writeBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + // Simple Field (controlCommand) + writeSimpleField( + "controlCommand", + controlCommand, + writeUnsignedInt(writeBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + // Reserved Field (reserved) + writeReservedField( + "reserved", + reservedField2 != null ? reservedField2 : (int) 0x0000, + writeUnsignedInt(writeBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + writeBuffer.popContext("PnIoCm_Control_Request_ApplicationReady"); + } + + @Override + public int getLengthInBytes() { + return (int) Math.ceil((float) getLengthInBits() / 8.0); + } + + @Override + public int getLengthInBits() { + int lengthInBits = super.getLengthInBits(); + PnIoCm_Control_Request_ApplicationReady _value = this; + boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); + + // Implicit Field (blockLength) + lengthInBits += 16; + + // Simple field (blockVersionHigh) + lengthInBits += 8; + + // Simple field (blockVersionLow) + lengthInBits += 8; + + // Reserved Field (reserved) + lengthInBits += 16; + + // Simple field (arUuid) + lengthInBits += arUuid.getLengthInBits(); + + // Simple field (sessionKey) + lengthInBits += 16; + + // Reserved Field (reserved) + lengthInBits += 16; + + // Simple field (controlCommand) + lengthInBits += 16; + + // Reserved Field (reserved) + lengthInBits += 16; + + return lengthInBits; + } + + public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) + throws ParseException { + readBuffer.pullContext("PnIoCm_Control_Request_ApplicationReady"); + PositionAware positionAware = readBuffer; + boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); + + 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)); + + Integer reservedField0 = + readReservedField( + "reserved", + readUnsignedInt(readBuffer, 16), + (int) 0x0000, + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + Uuid arUuid = + readSimpleField( + "arUuid", + new DataReaderComplexDefault<>(() -> Uuid.staticParse(readBuffer), readBuffer), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + int sessionKey = + readSimpleField( + "sessionKey", + readUnsignedInt(readBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + Integer reservedField1 = + readReservedField( + "reserved", + readUnsignedInt(readBuffer, 16), + (int) 0x0000, + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + int controlCommand = + readSimpleField( + "controlCommand", + readUnsignedInt(readBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + Integer reservedField2 = + readReservedField( + "reserved", + readUnsignedInt(readBuffer, 16), + (int) 0x0000, + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + readBuffer.closeContext("PnIoCm_Control_Request_ApplicationReady"); + // Create the instance + return new PnIoCm_Control_Request_ApplicationReadyBuilderImpl( + blockVersionHigh, + blockVersionLow, + arUuid, + sessionKey, + controlCommand, + reservedField0, + reservedField1, + reservedField2); + } + + public static class PnIoCm_Control_Request_ApplicationReadyBuilderImpl + implements PnIoCm_Block.PnIoCm_BlockBuilder { + private final short blockVersionHigh; + private final short blockVersionLow; + private final Uuid arUuid; + private final int sessionKey; + private final int controlCommand; + private final Integer reservedField0; + private final Integer reservedField1; + private final Integer reservedField2; + + public PnIoCm_Control_Request_ApplicationReadyBuilderImpl( + short blockVersionHigh, + short blockVersionLow, + Uuid arUuid, + int sessionKey, + int controlCommand, + Integer reservedField0, + Integer reservedField1, + Integer reservedField2) { + this.blockVersionHigh = blockVersionHigh; + this.blockVersionLow = blockVersionLow; + this.arUuid = arUuid; + this.sessionKey = sessionKey; + this.controlCommand = controlCommand; + this.reservedField0 = reservedField0; + this.reservedField1 = reservedField1; + this.reservedField2 = reservedField2; + } + + public PnIoCm_Control_Request_ApplicationReady build() { + PnIoCm_Control_Request_ApplicationReady pnIoCm_Control_Request_ApplicationReady = + new PnIoCm_Control_Request_ApplicationReady( + blockVersionHigh, blockVersionLow, arUuid, sessionKey, controlCommand); + pnIoCm_Control_Request_ApplicationReady.reservedField0 = reservedField0; + pnIoCm_Control_Request_ApplicationReady.reservedField1 = reservedField1; + pnIoCm_Control_Request_ApplicationReady.reservedField2 = reservedField2; + return pnIoCm_Control_Request_ApplicationReady; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof PnIoCm_Control_Request_ApplicationReady)) { + return false; + } + PnIoCm_Control_Request_ApplicationReady that = (PnIoCm_Control_Request_ApplicationReady) o; + return (getBlockVersionHigh() == that.getBlockVersionHigh()) + && (getBlockVersionLow() == that.getBlockVersionLow()) + && (getArUuid() == that.getArUuid()) + && (getSessionKey() == that.getSessionKey()) + && (getControlCommand() == that.getControlCommand()) + && super.equals(that) + && true; + } + + @Override + public int hashCode() { + return Objects.hash( + super.hashCode(), + getBlockVersionHigh(), + getBlockVersionLow(), + getArUuid(), + getSessionKey(), + getControlCommand()); + } + + @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/PnIoCm_Control_Request.java b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ParameterEnd.java similarity index 88% rename from plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request.java rename to plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ParameterEnd.java index fe974c49dab..56b098954da 100644 --- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request.java +++ b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ParameterEnd.java @@ -35,11 +35,11 @@ // Code generated by code-generation. DO NOT EDIT. -public class PnIoCm_Control_Request extends PnIoCm_Block implements Message { +public class PnIoCm_Control_Request_ParameterEnd extends PnIoCm_Block implements Message { // Accessors for discriminator values. public PnIoCm_BlockType getBlockType() { - return PnIoCm_BlockType.IOD_BLOCK_REQ_CONNECTION_APPLICATION_READY; + return PnIoCm_BlockType.IOD_BLOCK_REQ_CONNECTION_PARAMETER_END; } // Properties. @@ -54,7 +54,7 @@ public PnIoCm_BlockType getBlockType() { private Integer reservedField1; private Integer reservedField2; - public PnIoCm_Control_Request( + public PnIoCm_Control_Request_ParameterEnd( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -92,7 +92,7 @@ public int getControlCommand() { protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { PositionAware positionAware = writeBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("PnIoCm_Control_Request"); + writeBuffer.pushContext("PnIoCm_Control_Request_ParameterEnd"); // Implicit Field (blockLength) (Used for parsing, but its value is not stored as it's // implicitly given by the objects content) @@ -159,7 +159,7 @@ protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws Serial writeUnsignedInt(writeBuffer, 16), WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - writeBuffer.popContext("PnIoCm_Control_Request"); + writeBuffer.popContext("PnIoCm_Control_Request_ParameterEnd"); } @Override @@ -170,7 +170,7 @@ public int getLengthInBytes() { @Override public int getLengthInBits() { int lengthInBits = super.getLengthInBits(); - PnIoCm_Control_Request _value = this; + PnIoCm_Control_Request_ParameterEnd _value = this; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); // Implicit Field (blockLength) @@ -205,7 +205,7 @@ public int getLengthInBits() { public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) throws ParseException { - readBuffer.pullContext("PnIoCm_Control_Request"); + readBuffer.pullContext("PnIoCm_Control_Request_ParameterEnd"); PositionAware positionAware = readBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); @@ -266,9 +266,9 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read (int) 0x0000, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - readBuffer.closeContext("PnIoCm_Control_Request"); + readBuffer.closeContext("PnIoCm_Control_Request_ParameterEnd"); // Create the instance - return new PnIoCm_Control_RequestBuilderImpl( + return new PnIoCm_Control_Request_ParameterEndBuilderImpl( blockVersionHigh, blockVersionLow, arUuid, @@ -279,7 +279,7 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read reservedField2); } - public static class PnIoCm_Control_RequestBuilderImpl + public static class PnIoCm_Control_Request_ParameterEndBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder { private final short blockVersionHigh; private final short blockVersionLow; @@ -290,7 +290,7 @@ public static class PnIoCm_Control_RequestBuilderImpl private final Integer reservedField1; private final Integer reservedField2; - public PnIoCm_Control_RequestBuilderImpl( + public PnIoCm_Control_Request_ParameterEndBuilderImpl( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -309,14 +309,14 @@ public PnIoCm_Control_RequestBuilderImpl( this.reservedField2 = reservedField2; } - public PnIoCm_Control_Request build() { - PnIoCm_Control_Request pnIoCm_Control_Request = - new PnIoCm_Control_Request( + public PnIoCm_Control_Request_ParameterEnd build() { + PnIoCm_Control_Request_ParameterEnd pnIoCm_Control_Request_ParameterEnd = + new PnIoCm_Control_Request_ParameterEnd( blockVersionHigh, blockVersionLow, arUuid, sessionKey, controlCommand); - pnIoCm_Control_Request.reservedField0 = reservedField0; - pnIoCm_Control_Request.reservedField1 = reservedField1; - pnIoCm_Control_Request.reservedField2 = reservedField2; - return pnIoCm_Control_Request; + pnIoCm_Control_Request_ParameterEnd.reservedField0 = reservedField0; + pnIoCm_Control_Request_ParameterEnd.reservedField1 = reservedField1; + pnIoCm_Control_Request_ParameterEnd.reservedField2 = reservedField2; + return pnIoCm_Control_Request_ParameterEnd; } } @@ -325,10 +325,10 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof PnIoCm_Control_Request)) { + if (!(o instanceof PnIoCm_Control_Request_ParameterEnd)) { return false; } - PnIoCm_Control_Request that = (PnIoCm_Control_Request) o; + PnIoCm_Control_Request_ParameterEnd that = (PnIoCm_Control_Request_ParameterEnd) o; return (getBlockVersionHigh() == that.getBlockVersionHigh()) && (getBlockVersionLow() == that.getBlockVersionLow()) && (getArUuid() == that.getArUuid()) diff --git a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_ResponseConnect.java b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ApplicationReady.java similarity index 88% rename from plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_ResponseConnect.java rename to plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ApplicationReady.java index 6da07b18d72..8bdc5939b4d 100644 --- a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_ResponseConnect.java +++ b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ApplicationReady.java @@ -35,11 +35,11 @@ // Code generated by code-generation. DO NOT EDIT. -public class PnIoCM_Block_ResponseConnect extends PnIoCm_Block implements Message { +public class PnIoCm_Control_Response_ApplicationReady extends PnIoCm_Block implements Message { // Accessors for discriminator values. public PnIoCm_BlockType getBlockType() { - return PnIoCm_BlockType.IOX_BLOCK_RES_CONNECT; + return PnIoCm_BlockType.IOX_BLOCK_RES_CONNECTION_APPLICATION_READY; } // Properties. @@ -54,7 +54,7 @@ public PnIoCm_BlockType getBlockType() { private Integer reservedField0; private Integer reservedField1; - public PnIoCM_Block_ResponseConnect( + public PnIoCm_Control_Response_ApplicationReady( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -98,7 +98,7 @@ public int getControlBlockProperties() { protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { PositionAware positionAware = writeBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("PnIoCM_Block_ResponseConnect"); + writeBuffer.pushContext("PnIoCm_Control_Response_ApplicationReady"); // Implicit Field (blockLength) (Used for parsing, but its value is not stored as it's // implicitly given by the objects content) @@ -165,7 +165,7 @@ protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws Serial writeUnsignedInt(writeBuffer, 16), WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - writeBuffer.popContext("PnIoCM_Block_ResponseConnect"); + writeBuffer.popContext("PnIoCm_Control_Response_ApplicationReady"); } @Override @@ -176,7 +176,7 @@ public int getLengthInBytes() { @Override public int getLengthInBits() { int lengthInBits = super.getLengthInBits(); - PnIoCM_Block_ResponseConnect _value = this; + PnIoCm_Control_Response_ApplicationReady _value = this; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); // Implicit Field (blockLength) @@ -211,7 +211,7 @@ public int getLengthInBits() { public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) throws ParseException { - readBuffer.pullContext("PnIoCM_Block_ResponseConnect"); + readBuffer.pullContext("PnIoCm_Control_Response_ApplicationReady"); PositionAware positionAware = readBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); @@ -271,9 +271,9 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read readUnsignedInt(readBuffer, 16), WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - readBuffer.closeContext("PnIoCM_Block_ResponseConnect"); + readBuffer.closeContext("PnIoCm_Control_Response_ApplicationReady"); // Create the instance - return new PnIoCM_Block_ResponseConnectBuilderImpl( + return new PnIoCm_Control_Response_ApplicationReadyBuilderImpl( blockVersionHigh, blockVersionLow, arUuid, @@ -284,7 +284,7 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read reservedField1); } - public static class PnIoCM_Block_ResponseConnectBuilderImpl + public static class PnIoCm_Control_Response_ApplicationReadyBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder { private final short blockVersionHigh; private final short blockVersionLow; @@ -295,7 +295,7 @@ public static class PnIoCM_Block_ResponseConnectBuilderImpl private final Integer reservedField0; private final Integer reservedField1; - public PnIoCM_Block_ResponseConnectBuilderImpl( + public PnIoCm_Control_Response_ApplicationReadyBuilderImpl( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -314,18 +314,18 @@ public PnIoCM_Block_ResponseConnectBuilderImpl( this.reservedField1 = reservedField1; } - public PnIoCM_Block_ResponseConnect build() { - PnIoCM_Block_ResponseConnect pnIoCM_Block_ResponseConnect = - new PnIoCM_Block_ResponseConnect( + public PnIoCm_Control_Response_ApplicationReady build() { + PnIoCm_Control_Response_ApplicationReady pnIoCm_Control_Response_ApplicationReady = + new PnIoCm_Control_Response_ApplicationReady( blockVersionHigh, blockVersionLow, arUuid, sessionKey, controlCommand, controlBlockProperties); - pnIoCM_Block_ResponseConnect.reservedField0 = reservedField0; - pnIoCM_Block_ResponseConnect.reservedField1 = reservedField1; - return pnIoCM_Block_ResponseConnect; + pnIoCm_Control_Response_ApplicationReady.reservedField0 = reservedField0; + pnIoCm_Control_Response_ApplicationReady.reservedField1 = reservedField1; + return pnIoCm_Control_Response_ApplicationReady; } } @@ -334,10 +334,10 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof PnIoCM_Block_ResponseConnect)) { + if (!(o instanceof PnIoCm_Control_Response_ApplicationReady)) { return false; } - PnIoCM_Block_ResponseConnect that = (PnIoCM_Block_ResponseConnect) o; + PnIoCm_Control_Response_ApplicationReady that = (PnIoCm_Control_Response_ApplicationReady) o; return (getBlockVersionHigh() == that.getBlockVersionHigh()) && (getBlockVersionLow() == that.getBlockVersionLow()) && (getArUuid() == that.getArUuid()) diff --git a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_ResponseConnect.java b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ParameterEnd.java similarity index 88% rename from plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_ResponseConnect.java rename to plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ParameterEnd.java index 39f3c8a8fbf..5e0ead2de35 100644 --- a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_ResponseConnect.java +++ b/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ParameterEnd.java @@ -35,11 +35,11 @@ // Code generated by code-generation. DO NOT EDIT. -public class PnIoCm_Control_ResponseConnect extends PnIoCm_Block implements Message { +public class PnIoCm_Control_Response_ParameterEnd extends PnIoCm_Block implements Message { // Accessors for discriminator values. public PnIoCm_BlockType getBlockType() { - return PnIoCm_BlockType.IOD_CONTROL_RES_CONNECT; + return PnIoCm_BlockType.IOD_BLOCK_RES_CONNECTION_PARAMETER_END; } // Properties. @@ -54,7 +54,7 @@ public PnIoCm_BlockType getBlockType() { private Integer reservedField1; private Integer reservedField2; - public PnIoCm_Control_ResponseConnect( + public PnIoCm_Control_Response_ParameterEnd( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -92,7 +92,7 @@ public int getControlCommand() { protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { PositionAware positionAware = writeBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("PnIoCm_Control_ResponseConnect"); + writeBuffer.pushContext("PnIoCm_Control_Response_ParameterEnd"); // Implicit Field (blockLength) (Used for parsing, but its value is not stored as it's // implicitly given by the objects content) @@ -159,7 +159,7 @@ protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws Serial writeUnsignedInt(writeBuffer, 16), WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - writeBuffer.popContext("PnIoCm_Control_ResponseConnect"); + writeBuffer.popContext("PnIoCm_Control_Response_ParameterEnd"); } @Override @@ -170,7 +170,7 @@ public int getLengthInBytes() { @Override public int getLengthInBits() { int lengthInBits = super.getLengthInBits(); - PnIoCm_Control_ResponseConnect _value = this; + PnIoCm_Control_Response_ParameterEnd _value = this; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); // Implicit Field (blockLength) @@ -205,7 +205,7 @@ public int getLengthInBits() { public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) throws ParseException { - readBuffer.pullContext("PnIoCm_Control_ResponseConnect"); + readBuffer.pullContext("PnIoCm_Control_Response_ParameterEnd"); PositionAware positionAware = readBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); @@ -266,9 +266,9 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read (int) 0x0000, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - readBuffer.closeContext("PnIoCm_Control_ResponseConnect"); + readBuffer.closeContext("PnIoCm_Control_Response_ParameterEnd"); // Create the instance - return new PnIoCm_Control_ResponseConnectBuilderImpl( + return new PnIoCm_Control_Response_ParameterEndBuilderImpl( blockVersionHigh, blockVersionLow, arUuid, @@ -279,7 +279,7 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read reservedField2); } - public static class PnIoCm_Control_ResponseConnectBuilderImpl + public static class PnIoCm_Control_Response_ParameterEndBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder { private final short blockVersionHigh; private final short blockVersionLow; @@ -290,7 +290,7 @@ public static class PnIoCm_Control_ResponseConnectBuilderImpl private final Integer reservedField1; private final Integer reservedField2; - public PnIoCm_Control_ResponseConnectBuilderImpl( + public PnIoCm_Control_Response_ParameterEndBuilderImpl( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -309,14 +309,14 @@ public PnIoCm_Control_ResponseConnectBuilderImpl( this.reservedField2 = reservedField2; } - public PnIoCm_Control_ResponseConnect build() { - PnIoCm_Control_ResponseConnect pnIoCm_Control_ResponseConnect = - new PnIoCm_Control_ResponseConnect( + public PnIoCm_Control_Response_ParameterEnd build() { + PnIoCm_Control_Response_ParameterEnd pnIoCm_Control_Response_ParameterEnd = + new PnIoCm_Control_Response_ParameterEnd( blockVersionHigh, blockVersionLow, arUuid, sessionKey, controlCommand); - pnIoCm_Control_ResponseConnect.reservedField0 = reservedField0; - pnIoCm_Control_ResponseConnect.reservedField1 = reservedField1; - pnIoCm_Control_ResponseConnect.reservedField2 = reservedField2; - return pnIoCm_Control_ResponseConnect; + pnIoCm_Control_Response_ParameterEnd.reservedField0 = reservedField0; + pnIoCm_Control_Response_ParameterEnd.reservedField1 = reservedField1; + pnIoCm_Control_Response_ParameterEnd.reservedField2 = reservedField2; + return pnIoCm_Control_Response_ParameterEnd; } } @@ -325,10 +325,10 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof PnIoCm_Control_ResponseConnect)) { + if (!(o instanceof PnIoCm_Control_Response_ParameterEnd)) { return false; } - PnIoCm_Control_ResponseConnect that = (PnIoCm_Control_ResponseConnect) o; + PnIoCm_Control_Response_ParameterEnd that = (PnIoCm_Control_Response_ParameterEnd) o; return (getBlockVersionHigh() == that.getBlockVersionHigh()) && (getBlockVersionLow() == that.getBlockVersionLow()) && (getArUuid() == that.getArUuid()) diff --git a/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/ProfinetDriver.java b/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/ProfinetDriver.java index 459206d00b4..01d4d00e249 100644 --- a/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/ProfinetDriver.java +++ b/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/ProfinetDriver.java @@ -140,8 +140,6 @@ protected ProtocolStackConfigurer getStackConfigurer() { return SingleProtocolStackConfigurer.builder(Ethernet_Frame.class, Ethernet_Frame::staticParse) .withProtocol(ProfinetProtocolLogic.class) .withDriverContext(ProfinetDriverContext.class) - // Every incoming message is to be treated as a response. - .withParserArgs(true) .build(); } diff --git a/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/channel/ProfinetChannel.java b/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/channel/ProfinetChannel.java index a2113621d2c..67dbb41249d 100644 --- a/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/channel/ProfinetChannel.java +++ b/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/channel/ProfinetChannel.java @@ -30,7 +30,6 @@ import java.util.*; import java.util.function.BiConsumer; -import java.util.function.Consumer; public class ProfinetChannel { @@ -107,6 +106,8 @@ public PacketListener createListener() { // Check if it's a PROFINET packet if (payload.getHeader().getDstPort().value() == -30572 || payload.getHeader().getDstPort().value() == -15536 || payload.getHeader().getDstPort().value() == -15535) { isPnPacket = true; + } else { + System.out.println("UDP Packet from port: " + payload.getHeader().getSrcPort().value()); } } @@ -207,7 +208,7 @@ public Map getInterfaceHandles(List moduleIndex; private Map> submoduleIndex; @@ -205,14 +204,6 @@ public void setDataHoldFactor(int dataHoldFactor) { this.dataHoldFactor = dataHoldFactor; } - public String getDapId() { - return dapId; - } - - public void setDapId(String dapId) { - this.dapId = dapId; - } - public ProfinetDeviceAccessPointItem getDap() { return dap; } diff --git a/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/packets/PnDcpPacketFactory.java b/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/packets/PnDcpPacketFactory.java index 40b9d5fb9c7..1d54ad42361 100644 --- a/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/packets/PnDcpPacketFactory.java +++ b/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/packets/PnDcpPacketFactory.java @@ -70,9 +70,6 @@ public static CompletableFuture sendIdentificationRequest } public static Ethernet_Frame createReadIAndM0BlockRequest(RawSocketChannel pnChannel, ProfinetDriverContext driverContext) { - InetSocketAddress localAddress = (InetSocketAddress) pnChannel.getLocalAddress(); - InetSocketAddress remoteAddress = (InetSocketAddress) pnChannel.getRemoteAddress(); - DceRpc_Packet packet = new DceRpc_Packet( DceRpc_PacketType.REQUEST, true, false, false, IntegerEncoding.LITTLE_ENDIAN, CharacterEncoding.ASCII, FloatingPointEncoding.IEEE, @@ -92,25 +89,7 @@ public static Ethernet_Frame createReadIAndM0BlockRequest(RawSocketChannel pnCha )) ); - // Serialize it to a byte-payload - Random rand = new Random(); - Ethernet_FramePayload_IPv4 udpFrame = new Ethernet_FramePayload_IPv4( - rand.nextInt(65536), - true, - false, - (short) 64, - new IpAddress(localAddress.getAddress().getAddress()), - new IpAddress(remoteAddress.getAddress().getAddress()), - driverContext.getLocalPort(), - driverContext.getRemotePortImplicitCommunication(), - packet - ); - MacAddress srcAddress = new MacAddress(pnChannel.getLocalMacAddress().getAddress()); - MacAddress dstAddress = new MacAddress(pnChannel.getRemoteMacAddress().getAddress()); - return new Ethernet_Frame( - dstAddress, - srcAddress, - udpFrame); + return createEthernetFrame(pnChannel, driverContext, packet); } public static CompletableFuture sendReadIAndM0BlockRequest(ConversationContext context, RawSocketChannel pnChannel, ProfinetDriverContext driverContext) { @@ -150,10 +129,66 @@ public static CompletableFuture sendReadIAndM0BlockRequest( return future; } - public static Ethernet_Frame createReadRealIdentificationDataRequest(RawSocketChannel pnChannel, ProfinetDriverContext driverContext) { - InetSocketAddress localAddress = (InetSocketAddress) pnChannel.getLocalAddress(); - InetSocketAddress remoteAddress = (InetSocketAddress) pnChannel.getRemoteAddress(); + public static Ethernet_Frame createReadIAndM1BlockRequest(RawSocketChannel pnChannel, ProfinetDriverContext driverContext) { + DceRpc_Packet packet = new DceRpc_Packet( + DceRpc_PacketType.REQUEST, true, false, false, + IntegerEncoding.LITTLE_ENDIAN, CharacterEncoding.ASCII, FloatingPointEncoding.IEEE, + new DceRpc_ObjectUuid((byte) 0x00, (short) 0x0001, driverContext.getDeviceId(), driverContext.getVendorId()), + new DceRpc_InterfaceUuid_DeviceInterface(), + driverContext.getActivityUuid(), + 0, + driverContext.getAndIncrementIdentification(), + DceRpc_Operation.READ_IMPLICIT, + (short) 0, + new PnIoCm_Packet_Req(16696, 16696, 0, + Collections.singletonList( + new IODReadRequestHeader((short) 1, (short) 0, 0, + new Uuid(new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}), + 0, 0, 1, 0xAFF1, 16696, + new Uuid(new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})) + )) + ); + return createEthernetFrame(pnChannel, driverContext, packet); + } + public static CompletableFuture sendReadIAndM1BlockRequest(ConversationContext context, RawSocketChannel pnChannel, ProfinetDriverContext driverContext) { + // TODO: Handle error responses quickly (If the device doesn't support PN CM, then we can abort a lot quicker. + CompletableFuture future = new CompletableFuture<>(); + context.sendRequest(PnDcpPacketFactory.createReadIAndM1BlockRequest(pnChannel, driverContext)) + .expectResponse(Ethernet_Frame.class, Duration.ofMillis(6000)) + .onTimeout(future::completeExceptionally) + .onError((ethernetFrame, throwable) -> future.completeExceptionally(throwable)) + .unwrap(ethernetFrame -> { + if(ethernetFrame.getPayload() instanceof Ethernet_FramePayload_VirtualLan) { + return ((Ethernet_FramePayload_VirtualLan) ethernetFrame.getPayload()).getPayload(); + } + return ethernetFrame.getPayload(); + }) + .check(ethernetFramePayload -> ethernetFramePayload instanceof Ethernet_FramePayload_IPv4) + .unwrap(ethernetFramePayload -> (Ethernet_FramePayload_IPv4) ethernetFramePayload) + .unwrap(Ethernet_FramePayload_IPv4::getPayload) + .check((dceRpcPacket -> dceRpcPacket.getPayload() instanceof PnIoCm_Packet_Res)) + .unwrap(dceRpcPacket -> (PnIoCm_Packet_Res) dceRpcPacket.getPayload()) + .handle(dceRpcPacketRes -> { + if(dceRpcPacketRes.getBlocks().size() != 2) { + future.completeExceptionally(new PlcRuntimeException("Expected 2 blocks in the response")); + return; + } + if(!(dceRpcPacketRes.getBlocks().get(0) instanceof IODReadResponseHeader)) { + future.completeExceptionally(new PlcRuntimeException("The first block was expected to be of type IODReadResponseHeader")); + return; + } + if(!(dceRpcPacketRes.getBlocks().get(1) instanceof PnIoCm_Block_IAndM1)) { + future.completeExceptionally(new PlcRuntimeException("The second block was expected to be of type PnIoCm_Block_IAndM0")); + return; + } + PnIoCm_Block_IAndM1 iAndM1 = (PnIoCm_Block_IAndM1) dceRpcPacketRes.getBlocks().get(1); + future.complete(iAndM1); + }); + return future; + } + + public static Ethernet_Frame createReadRealIdentificationDataRequest(RawSocketChannel pnChannel, ProfinetDriverContext driverContext) { DceRpc_Packet packet = new DceRpc_Packet( DceRpc_PacketType.REQUEST, true, false, false, IntegerEncoding.LITTLE_ENDIAN, CharacterEncoding.ASCII, FloatingPointEncoding.IEEE, @@ -173,30 +208,12 @@ public static Ethernet_Frame createReadRealIdentificationDataRequest(RawSocketCh )) ); - // Serialize it to a byte-payload - Random rand = new Random(); - Ethernet_FramePayload_IPv4 udpFrame = new Ethernet_FramePayload_IPv4( - rand.nextInt(65536), - true, - false, - (short) 64, - new IpAddress(localAddress.getAddress().getAddress()), - new IpAddress(remoteAddress.getAddress().getAddress()), - driverContext.getLocalPort(), - driverContext.getRemotePortImplicitCommunication(), - packet - ); - MacAddress srcAddress = new MacAddress(pnChannel.getLocalMacAddress().getAddress()); - MacAddress dstAddress = new MacAddress(pnChannel.getRemoteMacAddress().getAddress()); - return new Ethernet_Frame( - dstAddress, - srcAddress, - udpFrame); + return createEthernetFrame(pnChannel, driverContext, packet); } public static CompletableFuture sendRealIdentificationDataRequest(ConversationContext context, RawSocketChannel pnChannel, ProfinetDriverContext driverContext) { CompletableFuture future = new CompletableFuture<>(); - context.sendRequest(PnDcpPacketFactory.createReadRealIdentificationDataRequest(pnChannel, driverContext)) + context.sendRequest(createReadRealIdentificationDataRequest(pnChannel, driverContext)) .expectResponse(Ethernet_Frame.class, Duration.ofMillis(6000)) .onTimeout(future::completeExceptionally) .onError((ethernetFrame, throwable) -> future.completeExceptionally(throwable)) @@ -212,7 +229,7 @@ public static CompletableFuture sendRealIde .unwrap(DceRpc_Packet::getPayload) .handle(dceRpcPacket -> { if(dceRpcPacket instanceof PnIoCm_Packet_Rej) { - future.completeExceptionally(new PlcRuntimeException("PN CM not supported")); + future.completeExceptionally(new PlcRuntimeException("RealIdentificationData not supported")); return; } if(!(dceRpcPacket instanceof PnIoCm_Packet_Res)) { @@ -238,4 +255,119 @@ public static CompletableFuture sendRealIde return future; } + public static Ethernet_Frame createParameterEndRequest(RawSocketChannel pnChannel, ProfinetDriverContext driverContext) { + DceRpc_Packet packet = new DceRpc_Packet( + DceRpc_PacketType.REQUEST, true, false, false, + IntegerEncoding.LITTLE_ENDIAN, CharacterEncoding.ASCII, FloatingPointEncoding.IEEE, + new DceRpc_ObjectUuid((byte) 0x00, (short) 0x0001, driverContext.getDeviceId(), driverContext.getVendorId()), + new DceRpc_InterfaceUuid_DeviceInterface(), + driverContext.getActivityUuid(), + 0, + driverContext.getAndIncrementIdentification(), + DceRpc_Operation.CONTROL, + (short) 0, + new PnIoCm_Packet_Req(16696, 16696, 0, + Collections.singletonList( + new PnIoCm_Control_Request_ParameterEnd((short) 1, (short) 0, + new Uuid(driverContext.getApplicationRelationUuid().getData()), 1, 1) + )) + ); + return createEthernetFrame(pnChannel, driverContext, packet); + } + + public static CompletableFuture sendParameterEndRequest(ConversationContext context, RawSocketChannel pnChannel, ProfinetDriverContext driverContext) { + CompletableFuture future = new CompletableFuture<>(); + context.sendRequest(createParameterEndRequest(pnChannel, driverContext)) + .expectResponse(Ethernet_Frame.class, Duration.ofMillis(6000)) + .onTimeout(future::completeExceptionally) + .onError((ethernetFrame, throwable) -> future.completeExceptionally(throwable)) + .unwrap(ethernetFrame -> { + if(ethernetFrame.getPayload() instanceof Ethernet_FramePayload_VirtualLan) { + return ((Ethernet_FramePayload_VirtualLan) ethernetFrame.getPayload()).getPayload(); + } + return ethernetFrame.getPayload(); + }) + .check(ethernetFramePayload -> ethernetFramePayload instanceof Ethernet_FramePayload_IPv4) + .unwrap(ethernetFramePayload -> (Ethernet_FramePayload_IPv4) ethernetFramePayload) + .unwrap(Ethernet_FramePayload_IPv4::getPayload) + .unwrap(DceRpc_Packet::getPayload) + .check(pnIoCmPacket -> pnIoCmPacket instanceof PnIoCm_Packet_Rej || pnIoCmPacket instanceof PnIoCm_Packet_Res) + .handle(dceRpcPacket -> { + if(dceRpcPacket instanceof PnIoCm_Packet_Rej) { + future.completeExceptionally(new PlcRuntimeException("ParameterEnd not supported")); + return; + } + PnIoCm_Packet_Res dceRpcPacketRes = (PnIoCm_Packet_Res) dceRpcPacket; + if(dceRpcPacketRes.getBlocks().size() != 1) { + future.completeExceptionally(new PlcRuntimeException("Expected 1 blocks in the response")); + return; + } + if(!(dceRpcPacketRes.getBlocks().get(0) instanceof PnIoCm_Control_Response_ParameterEnd)) { + future.completeExceptionally(new PlcRuntimeException("The block was expected to be of type PnIoCm_Control_Response_ParameterEnd")); + return; + } + PnIoCm_Control_Response_ParameterEnd controlResponse = (PnIoCm_Control_Response_ParameterEnd) dceRpcPacketRes.getBlocks().get(0); + future.complete(controlResponse); + }); + return future; + } + + public static Ethernet_Frame createApplicationReadyResponse(RawSocketChannel pnChannel, ProfinetDriverContext driverContext, Uuid arUuid, int sessionKey) { + DceRpc_Packet packet = new DceRpc_Packet( + DceRpc_PacketType.RESPONSE, true, false, false, + IntegerEncoding.LITTLE_ENDIAN, CharacterEncoding.ASCII, FloatingPointEncoding.IEEE, + new DceRpc_ObjectUuid((byte) 0x00, (short) 0x0001, driverContext.getDeviceId(), driverContext.getVendorId()), + new DceRpc_InterfaceUuid_DeviceInterface(), + driverContext.getActivityUuid(), + 0, + driverContext.getAndIncrementIdentification(), + DceRpc_Operation.CONTROL, + (short) 0, + new PnIoCm_Packet_Res((short) 0, (short) 0, (short) 0, (short) 0, 16696, (short) 0, + Collections.singletonList( + new PnIoCm_Control_Response_ApplicationReady((short) 1, (short) 0, + arUuid, sessionKey, 0x0008, 0x0000)) + ) + ); + + return createEthernetFrame(pnChannel, driverContext, packet); + } + + public static void sendApplicationReadyResponse(ConversationContext context, RawSocketChannel pnChannel, ProfinetDriverContext driverContext, Uuid arUuid, int sessionKey) { + context.sendToWire(createApplicationReadyResponse(pnChannel, driverContext, arUuid, sessionKey)); + } + + /** + * Simple helper that creates the UDP packet and Ethernet frame to transport the packet. + * + * @param pnChannel the channel that contains the local and remote address information. + * @param driverContext the context that contains the local and remote port information. + * @param packet the actual payload. + * @return an Ethernet frame that we can send. + */ + protected static Ethernet_Frame createEthernetFrame(RawSocketChannel pnChannel, ProfinetDriverContext driverContext, DceRpc_Packet packet) { + InetSocketAddress localAddress = (InetSocketAddress) pnChannel.getLocalAddress(); + InetSocketAddress remoteAddress = (InetSocketAddress) pnChannel.getRemoteAddress(); + + // Serialize it to a byte-payload + Random rand = new Random(); + Ethernet_FramePayload_IPv4 udpFrame = new Ethernet_FramePayload_IPv4( + rand.nextInt(65536), + true, + false, + (short) 64, + new IpAddress(localAddress.getAddress().getAddress()), + new IpAddress(remoteAddress.getAddress().getAddress()), + driverContext.getLocalPort(), + driverContext.getRemotePortImplicitCommunication(), + packet + ); + MacAddress srcAddress = new MacAddress(pnChannel.getLocalMacAddress().getAddress()); + MacAddress dstAddress = new MacAddress(pnChannel.getRemoteMacAddress().getAddress()); + return new Ethernet_Frame( + dstAddress, + srcAddress, + udpFrame); + } + } diff --git a/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/protocol/ProfinetProtocolLogic.java b/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/protocol/ProfinetProtocolLogic.java index f3a8c101b54..fafd7209fca 100644 --- a/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/protocol/ProfinetProtocolLogic.java +++ b/plc4j/drivers/profinet-ng/src/main/java/org/apache/plc4x/java/profinet/protocol/ProfinetProtocolLogic.java @@ -20,6 +20,7 @@ package org.apache.plc4x.java.profinet.protocol; import org.apache.plc4x.java.api.exceptions.PlcConnectionException; +import org.apache.plc4x.java.api.exceptions.PlcException; import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; import org.apache.plc4x.java.api.messages.*; import org.apache.plc4x.java.api.model.PlcSubscriptionTag; @@ -116,33 +117,28 @@ public void onConnect(ConversationContext context) { if (configuration.dapId != null) { for (ProfinetDeviceAccessPointItem profinetDeviceAccessPointItem : deviceProfile.getProfileBody().getApplicationProcess().getDeviceAccessPointList()) { if (profinetDeviceAccessPointItem.getId().equalsIgnoreCase(configuration.dapId)) { - profinetDriverContext.setDapId(profinetDeviceAccessPointItem.getId()); + profinetDriverContext.setDap(profinetDeviceAccessPointItem); break; } } - if (profinetDriverContext.getDapId() == null) { + if (profinetDriverContext.getDap() == null) { logger.error("Couldn't find requested device access points (DAP): {}", configuration.dapId); context.getChannel().close(); } } - - // In theory, we would need to resolve the details for the endpoint for implicit reading in order - // to correctly read and write asynchronously: - // https://cache.industry.siemens.com/dl/files/980/109810980/att_1107623/v4/109810980_ImplcitDataRecordHandling_DOC_de_V10.pdf - // Here and in the recordings of the PRONETA communication, we would - // - first request a "handle", - // - then in a second request using the handle request the port and object id - // - do a third request - // However it seems that we can simply send to the default udp port and we'll get a response from the - // correct port, and we can calculate the object id based on the vendor id and device id, which we - // already have from the discovery. + // If the user didn't define a dap, but the profile only has one, use that. + else if (deviceProfile.getProfileBody().getApplicationProcess().getDeviceAccessPointList().size() == 1) { + profinetDriverContext.setDap(deviceProfile.getProfileBody().getApplicationProcess().getDeviceAccessPointList().get(0)); + } + // Otherwise we'll have to use the RealIdentificationDataRequest to fetch all of this information. + // However, this is not supported by all PN devices. // If we've found a device profile with at least one dap, we request the "real identification data" from the // device. The response contains information about which slots are present and which module identifiers // apply to them as well as which subslots are present and which submodule identifiers these have. // In this part of the code, we simply look up the gsd dap, modules and submodules that match these // identifiers and save them in an easily accessible format in the deviceContext. - else if (!deviceProfile.getProfileBody().getApplicationProcess().getDeviceAccessPointList().isEmpty()) { + if (!deviceProfile.getProfileBody().getApplicationProcess().getDeviceAccessPointList().isEmpty()) { // Build an index of the String names. Map textMapping = new HashMap<>(); for (ProfinetTextIdValue profinetTextIdValue : deviceProfile.getProfileBody().getApplicationProcess().getExternalTextList().getPrimaryLanguage().getText()) { @@ -154,9 +150,16 @@ else if (!deviceProfile.getProfileBody().getApplicationProcess().getDeviceAccess CompletableFuture future1 = PnDcpPacketFactory.sendRealIdentificationDataRequest(context, pnChannel, profinetDriverContext); future1.whenComplete((realIdentificationData, throwable1) -> { + // If the device didn't support this, we'll have to handle the + // module index and submodule indexes when trying to use them. if (throwable1 != null) { - logger.error("Unable to detect device access point, closing channel...", throwable1); - context.getChannel().close(); + if(profinetDriverContext.getDap() != null) { + context.fireConnected(); + } else { + logger.error("Unable to auto-configure connection, please be sure to provide the 'dap-id' connection parameter"); + context.getChannel().close(); + return; + } return; } @@ -191,13 +194,18 @@ else if (!deviceProfile.getProfileBody().getApplicationProcess().getDeviceAccess } long moduleIdentNumber = Long.parseLong(moduleIdentNumberStr, 16); if (moduleIdentNumber == dapModuleIdentificationNumber) { + if((profinetDriverContext.getDap() != null) && + !profinetDriverContext.getDap().getId().equals(curDap.getId())) { + logger.warn("DAP configured in connection string differs from device-configuration."); + } profinetDriverContext.setDap(curDap); break; } } // Abort, if we weren't able to detect a DAP. if (profinetDriverContext.getDap() == null) { - logger.error("Unable to auto-detect the device access point, closing channel..."); + logger.error("Unable to auto-detect the device access point, please provide \"dap-id\" " + + "option in the connection-string. Closing channel..."); context.getChannel().close(); return; } @@ -207,7 +215,7 @@ else if (!deviceProfile.getProfileBody().getApplicationProcess().getDeviceAccess Map> submoduleIndex = new HashMap<>(); for (Map.Entry moduleEntry : slotModuleIdentificationNumbers.entrySet()) { int curSlot = moduleEntry.getKey(); - // Slot 0 is the DAP, so we'll continue with the next one. + // Slot 0 is the DAP, which we've already handled, so we'll continue with the next one. if (curSlot == 0) { continue; } @@ -265,6 +273,7 @@ else if (!deviceProfile.getProfileBody().getApplicationProcess().getDeviceAccess context.fireConnected(); }); + // Try to read the I&M0 block // * Commented out this code, as here it performed the same task as the ReadRealIdentificationData approach and If the other has side-effects, I can roll-back to this. /*CompletableFuture pnIoCmBlockIAndM0CompletableFuture = PnDcpPacketFactory.sendReadIAndM0BlockRequest(context, pnChannel, driverContext); @@ -436,7 +445,7 @@ public CompletableFuture subscribe(PlcSubscriptionReque // TODO: this will probably need to be dynamic, based on data in the GSD file. List expectedSubmodules = new ArrayList<>(); expectedSubmodules.add(new PnIoCm_Block_ExpectedSubmoduleReq((short) 1, (short) 0, Collections.singletonList( - new PnIoCm_ExpectedSubmoduleBlockReqApi((short)0x0000, (short) 0x00000010, 0, Arrays.asList( + new PnIoCm_ExpectedSubmoduleBlockReqApi((short) 0x0000, (short) 0x00000010, 0, Arrays.asList( new PnIoCm_Submodule_NoInputNoOutputData((short) 0x0001, (short) 0x00000001, false, false, false, false), new PnIoCm_Submodule_NoInputNoOutputData((short) 0x8000, (short) 0x00000002, false, false, false, false), new PnIoCm_Submodule_NoInputNoOutputData((short) 0x8001, (short) 0x00000003, false, false, false, false), @@ -494,9 +503,9 @@ public CompletableFuture subscribe(PlcSubscriptionReque // These define the structure of the data in outgoing messages sent to the device. if (direction.containsKey(ProfinetTag.Direction.OUTPUT)) { // Update the type of submodule io. - if(submoduleType == PnIoCm_SubmoduleType.NO_INPUT_NO_OUTPUT_DATA) { + if (submoduleType == PnIoCm_SubmoduleType.NO_INPUT_NO_OUTPUT_DATA) { submoduleType = PnIoCm_SubmoduleType.OUTPUT_DATA; - } else if(submoduleType == PnIoCm_SubmoduleType.INPUT_DATA) { + } else if (submoduleType == PnIoCm_SubmoduleType.INPUT_DATA) { submoduleType = PnIoCm_SubmoduleType.INPUT_AND_OUTPUT_DATA; } @@ -558,7 +567,7 @@ public CompletableFuture subscribe(PlcSubscriptionReque blocks.add(new PnIoCm_Block_ArReq( ProfinetDriverContext.BLOCK_VERSION_HIGH, ProfinetDriverContext.BLOCK_VERSION_LOW, PnIoCm_ArType.IO_CONTROLLER, - profinetDriverContext.generateUuid(), + profinetDriverContext.getApplicationRelationUuid(), profinetDriverContext.getSessionKey(), localMacAddress, profinetDriverContext.getCmInitiatorObjectUuid(), @@ -676,8 +685,6 @@ public CompletableFuture subscribe(PlcSubscriptionReque udpFrame); CompletableFuture future = new CompletableFuture<>(); - - // TODO: Send the packet to the device ... context.sendRequest(requestEthernetFrame) .expectResponse(Ethernet_Frame.class, Duration.ofMillis(1000)) .onTimeout(future::completeExceptionally) @@ -685,8 +692,35 @@ public CompletableFuture subscribe(PlcSubscriptionReque .check(responseEthernetFrame -> responseEthernetFrame.getPayload() instanceof Ethernet_FramePayload_IPv4) .unwrap(responseEthernetFrame -> ((Ethernet_FramePayload_IPv4) responseEthernetFrame.getPayload()).getPayload()) .handle(dceRpcPacket -> { - // TODO: Continue from here ... - System.out.println(dceRpcPacket); + if(dceRpcPacket.getPacketType() != DceRpc_PacketType.RESPONSE) { + future.completeExceptionally(new PlcException("Expected a response")); + return; + } + PnIoCm_Packet_Res payload = (PnIoCm_Packet_Res) dceRpcPacket.getPayload(); + // TODO: Maybe do some checks on this. + + // Now we wait for an incoming ApplicationReady request and confirm that. +/* context.expectRequest(Ethernet_Frame.class, Duration.ofMillis(500000)) + .onTimeout(future::completeExceptionally) + .check(ethernetFrame -> ethernetFrame.getPayload() instanceof Ethernet_FramePayload_IPv4) + .unwrap(ethernetFrame -> ((Ethernet_FramePayload_IPv4) ethernetFrame.getPayload()).getPayload()) + .check(dceRpc_packet -> dceRpcPacket.getPayload() instanceof PnIoCm_Packet_Req) + .unwrap(dceRpc_packet -> (PnIoCm_Packet_Req) dceRpcPacket.getPayload()) + .handle(requestPacket -> { + if(requestPacket.getBlocks().size() == 1) { + if (requestPacket.getBlocks().get(0) instanceof PnIoCm_Control_Request_ApplicationReady) { + // TODO: Send the response back to the udp port used in the request (It differs from the usual port) + System.out.println("Got ApplicationStart Request: "+ requestPacket); + } + } + });*/ + + // Now send the ParameterEnd request and wait for a response. + CompletableFuture parameterEndFuture = PnDcpPacketFactory.sendParameterEndRequest(context, rawSocketChannel, profinetDriverContext); + parameterEndFuture.whenComplete((parameterEnd, throwable) -> { + // Not quite sure what to do with this ... we already set up the listener before sending this request. + System.out.println("Got Parameter End Response: " + parameterEnd); + }); }); return future; @@ -694,11 +728,30 @@ public CompletableFuture subscribe(PlcSubscriptionReque @Override protected void decode(ConversationContext context, Ethernet_Frame msg) throws Exception { - if(msg.getPayload() instanceof Ethernet_FramePayload_PnDcp) { + if (msg.getPayload() instanceof Ethernet_FramePayload_PnDcp) { Ethernet_FramePayload_PnDcp dcpPacket = (Ethernet_FramePayload_PnDcp) msg.getPayload(); if (dcpPacket.getPdu() instanceof PnDcp_Pdu_RealTimeCyclic) { PnDcp_Pdu_RealTimeCyclic realTimeCyclic = (PnDcp_Pdu_RealTimeCyclic) dcpPacket.getPdu(); - System.out.println(realTimeCyclic); +// System.out.println(realTimeCyclic); + } else { + System.out.println(dcpPacket); + } + } else if(msg.getPayload() instanceof Ethernet_FramePayload_IPv4) { + Ethernet_FramePayload_IPv4 payloadIPv4 = (Ethernet_FramePayload_IPv4) msg.getPayload(); + if(payloadIPv4.getPayload().getPayload() instanceof PnIoCm_Packet_Req) { + PnIoCm_Packet_Req pnIoCmPacketReq = (PnIoCm_Packet_Req) payloadIPv4.getPayload().getPayload(); + if(pnIoCmPacketReq.getBlocks().size() == 1) { + PnIoCm_Block pnIoCmBlock = pnIoCmPacketReq.getBlocks().get(0); + if(pnIoCmBlock instanceof PnIoCm_Control_Request_ApplicationReady) { + // TODO: Save these + Uuid arUuid = ((PnIoCm_Control_Request_ApplicationReady) pnIoCmBlock).getArUuid(); + int sessionKey = ((PnIoCm_Control_Request_ApplicationReady) pnIoCmBlock).getSessionKey(); + + // Send back a response, but this is just a hack ... we need to move this into the subscribe method or we can't complete the future that we're returning. + RawSocketChannel pnChannel = (RawSocketChannel) context.getChannel(); + PnDcpPacketFactory.sendApplicationReadyResponse(context, pnChannel, profinetDriverContext, arUuid, sessionKey); + } + } } } } diff --git a/plc4j/drivers/profinet-ng/src/test/java/org/apache/plc4x/java/profinet/ManualProfinetIoTest.java b/plc4j/drivers/profinet-ng/src/test/java/org/apache/plc4x/java/profinet/ManualProfinetIoTest.java index 29ca2e0bad9..86c92af6085 100644 --- a/plc4j/drivers/profinet-ng/src/test/java/org/apache/plc4x/java/profinet/ManualProfinetIoTest.java +++ b/plc4j/drivers/profinet-ng/src/test/java/org/apache/plc4x/java/profinet/ManualProfinetIoTest.java @@ -31,7 +31,7 @@ public class ManualProfinetIoTest { public static void main(String[] args) throws Exception { - //try(PlcConnection connection = new DefaultPlcDriverManager().getConnection("profinet:raw://192.168.24.41")) { + // WireShark filter: "eth.addr == 88:3f:99:00:06:ef" try(PlcConnection connection = new DefaultPlcDriverManager().getConnection("profinet:raw://192.168.24.31")) { // Create and execute the subscription request. PlcSubscriptionRequest subscriptionRequest = connection.subscriptionRequestBuilder() diff --git a/plc4j/drivers/profinet-ng/src/test/java/org/apache/plc4x/java/profinet/ManualProfinetIoTest2.java b/plc4j/drivers/profinet-ng/src/test/java/org/apache/plc4x/java/profinet/ManualProfinetIoTest2.java new file mode 100644 index 00000000000..201986a321b --- /dev/null +++ b/plc4j/drivers/profinet-ng/src/test/java/org/apache/plc4x/java/profinet/ManualProfinetIoTest2.java @@ -0,0 +1,45 @@ +/* + * 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; + +import org.apache.plc4x.java.DefaultPlcDriverManager; +import org.apache.plc4x.java.api.PlcConnection; +import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest; +import org.apache.plc4x.java.api.messages.PlcSubscriptionResponse; + +import java.time.Duration; +import java.util.concurrent.TimeUnit; + +public class ManualProfinetIoTest2 { + + public static void main(String[] args) throws Exception { + // WireShark filter: "eth.addr == 74:fe:48:63:f6:c2" + try(PlcConnection connection = new DefaultPlcDriverManager().getConnection("profinet:raw://192.168.24.41")) { + // Create and execute the subscription request. + PlcSubscriptionRequest subscriptionRequest = connection.subscriptionRequestBuilder() + .addCyclicTagAddress("inputs", "1.1.INPUT.0:BYTE[10]", Duration.ofMillis(400)) + .addCyclicTagAddress("output", "1.1.OUTPUT.0:DWORD", Duration.ofMillis(400)) + .build(); + PlcSubscriptionResponse subscriptionResponse = subscriptionRequest.execute().get(10000, TimeUnit.MILLISECONDS); + System.out.println(subscriptionResponse); + } + } + +} diff --git a/plc4j/drivers/profinet-ng/src/test/resources/logback-test.xml b/plc4j/drivers/profinet-ng/src/test/resources/logback-test.xml index cc4250b212e..efb9ecdbebe 100644 --- a/plc4j/drivers/profinet-ng/src/test/resources/logback-test.xml +++ b/plc4j/drivers/profinet-ng/src/test/resources/logback-test.xml @@ -29,7 +29,7 @@ - + diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_Request.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_Request.java deleted file mode 100644 index e1252f1d01e..00000000000 --- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_Request.java +++ /dev/null @@ -1,372 +0,0 @@ -/* - * 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 PnIoCM_Block_Request extends PnIoCm_Block implements Message { - - // Accessors for discriminator values. - public PnIoCm_BlockType getBlockType() { - return PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION; - } - - // Properties. - protected final short blockVersionHigh; - protected final short blockVersionLow; - protected final Uuid arUuid; - protected final int sessionKey; - protected final int controlCommand; - protected final int controlBlockProperties; - - // Reserved Fields - private Integer reservedField0; - private Integer reservedField1; - - public PnIoCM_Block_Request( - short blockVersionHigh, - short blockVersionLow, - Uuid arUuid, - int sessionKey, - int controlCommand, - int controlBlockProperties) { - super(); - this.blockVersionHigh = blockVersionHigh; - this.blockVersionLow = blockVersionLow; - this.arUuid = arUuid; - this.sessionKey = sessionKey; - this.controlCommand = controlCommand; - this.controlBlockProperties = controlBlockProperties; - } - - public short getBlockVersionHigh() { - return blockVersionHigh; - } - - public short getBlockVersionLow() { - return blockVersionLow; - } - - public Uuid getArUuid() { - return arUuid; - } - - public int getSessionKey() { - return sessionKey; - } - - public int getControlCommand() { - return controlCommand; - } - - public int getControlBlockProperties() { - return controlBlockProperties; - } - - @Override - protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { - PositionAware positionAware = writeBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("PnIoCM_Block_Request"); - - // 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)); - - // Reserved Field (reserved) - writeReservedField( - "reserved", - reservedField0 != null ? reservedField0 : (int) 0x0000, - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Simple Field (arUuid) - writeSimpleField( - "arUuid", - arUuid, - new DataWriterComplexDefault<>(writeBuffer), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Simple Field (sessionKey) - writeSimpleField( - "sessionKey", - sessionKey, - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Reserved Field (reserved) - writeReservedField( - "reserved", - reservedField1 != null ? reservedField1 : (int) 0x0000, - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Simple Field (controlCommand) - writeSimpleField( - "controlCommand", - controlCommand, - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Simple Field (controlBlockProperties) - writeSimpleField( - "controlBlockProperties", - controlBlockProperties, - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - writeBuffer.popContext("PnIoCM_Block_Request"); - } - - @Override - public int getLengthInBytes() { - return (int) Math.ceil((float) getLengthInBits() / 8.0); - } - - @Override - public int getLengthInBits() { - int lengthInBits = super.getLengthInBits(); - PnIoCM_Block_Request _value = this; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - // Implicit Field (blockLength) - lengthInBits += 16; - - // Simple field (blockVersionHigh) - lengthInBits += 8; - - // Simple field (blockVersionLow) - lengthInBits += 8; - - // Reserved Field (reserved) - lengthInBits += 16; - - // Simple field (arUuid) - lengthInBits += arUuid.getLengthInBits(); - - // Simple field (sessionKey) - lengthInBits += 16; - - // Reserved Field (reserved) - lengthInBits += 16; - - // Simple field (controlCommand) - lengthInBits += 16; - - // Simple field (controlBlockProperties) - lengthInBits += 16; - - return lengthInBits; - } - - public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) - throws ParseException { - readBuffer.pullContext("PnIoCM_Block_Request"); - PositionAware positionAware = readBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - 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)); - - Integer reservedField0 = - readReservedField( - "reserved", - readUnsignedInt(readBuffer, 16), - (int) 0x0000, - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - Uuid arUuid = - readSimpleField( - "arUuid", - new DataReaderComplexDefault<>(() -> Uuid.staticParse(readBuffer), readBuffer), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - int sessionKey = - readSimpleField( - "sessionKey", - readUnsignedInt(readBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - Integer reservedField1 = - readReservedField( - "reserved", - readUnsignedInt(readBuffer, 16), - (int) 0x0000, - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - int controlCommand = - readSimpleField( - "controlCommand", - readUnsignedInt(readBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - int controlBlockProperties = - readSimpleField( - "controlBlockProperties", - readUnsignedInt(readBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - readBuffer.closeContext("PnIoCM_Block_Request"); - // Create the instance - return new PnIoCM_Block_RequestBuilderImpl( - blockVersionHigh, - blockVersionLow, - arUuid, - sessionKey, - controlCommand, - controlBlockProperties, - reservedField0, - reservedField1); - } - - public static class PnIoCM_Block_RequestBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder { - private final short blockVersionHigh; - private final short blockVersionLow; - private final Uuid arUuid; - private final int sessionKey; - private final int controlCommand; - private final int controlBlockProperties; - private final Integer reservedField0; - private final Integer reservedField1; - - public PnIoCM_Block_RequestBuilderImpl( - short blockVersionHigh, - short blockVersionLow, - Uuid arUuid, - int sessionKey, - int controlCommand, - int controlBlockProperties, - Integer reservedField0, - Integer reservedField1) { - this.blockVersionHigh = blockVersionHigh; - this.blockVersionLow = blockVersionLow; - this.arUuid = arUuid; - this.sessionKey = sessionKey; - this.controlCommand = controlCommand; - this.controlBlockProperties = controlBlockProperties; - this.reservedField0 = reservedField0; - this.reservedField1 = reservedField1; - } - - public PnIoCM_Block_Request build() { - PnIoCM_Block_Request pnIoCM_Block_Request = - new PnIoCM_Block_Request( - blockVersionHigh, - blockVersionLow, - arUuid, - sessionKey, - controlCommand, - controlBlockProperties); - pnIoCM_Block_Request.reservedField0 = reservedField0; - pnIoCM_Block_Request.reservedField1 = reservedField1; - return pnIoCM_Block_Request; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof PnIoCM_Block_Request)) { - return false; - } - PnIoCM_Block_Request that = (PnIoCM_Block_Request) o; - return (getBlockVersionHigh() == that.getBlockVersionHigh()) - && (getBlockVersionLow() == that.getBlockVersionLow()) - && (getArUuid() == that.getArUuid()) - && (getSessionKey() == that.getSessionKey()) - && (getControlCommand() == that.getControlCommand()) - && (getControlBlockProperties() == that.getControlBlockProperties()) - && super.equals(that) - && true; - } - - @Override - public int hashCode() { - return Objects.hash( - super.hashCode(), - getBlockVersionHigh(), - getBlockVersionLow(), - getArUuid(), - getSessionKey(), - getControlCommand(), - getControlBlockProperties()); - } - - @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/PnIoCm_Block.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block.java index 4065b855370..20ea5e8bef8 100644 --- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block.java +++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block.java @@ -125,14 +125,17 @@ public static PnIoCm_Block staticParse(ReadBuffer readBuffer) throws ParseExcept } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.AR_BLOCK_RES)) { builder = PnIoCm_Block_ArRes.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals( - blockType, PnIoCm_BlockType.IOD_BLOCK_REQ_CONNECTION_APPLICATION_READY)) { - builder = PnIoCm_Control_Request.staticParsePnIoCm_BlockBuilder(readBuffer); - } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION)) { - builder = PnIoCM_Block_Request.staticParsePnIoCm_BlockBuilder(readBuffer); - } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.IOX_BLOCK_RES_CONNECT)) { - builder = PnIoCM_Block_ResponseConnect.staticParsePnIoCm_BlockBuilder(readBuffer); - } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.IOD_CONTROL_RES_CONNECT)) { - builder = PnIoCm_Control_ResponseConnect.staticParsePnIoCm_BlockBuilder(readBuffer); + blockType, PnIoCm_BlockType.IOD_BLOCK_REQ_CONNECTION_PARAMETER_END)) { + builder = PnIoCm_Control_Request_ParameterEnd.staticParsePnIoCm_BlockBuilder(readBuffer); + } else if (EvaluationHelper.equals( + blockType, PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY)) { + builder = PnIoCm_Control_Request_ApplicationReady.staticParsePnIoCm_BlockBuilder(readBuffer); + } else if (EvaluationHelper.equals( + blockType, PnIoCm_BlockType.IOX_BLOCK_RES_CONNECTION_APPLICATION_READY)) { + builder = PnIoCm_Control_Response_ApplicationReady.staticParsePnIoCm_BlockBuilder(readBuffer); + } else if (EvaluationHelper.equals( + blockType, PnIoCm_BlockType.IOD_BLOCK_RES_CONNECTION_PARAMETER_END)) { + builder = PnIoCm_Control_Response_ParameterEnd.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.IO_CR_BLOCK_REQ)) { builder = PnIoCm_Block_IoCrReq.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.IO_CR_BLOCK_RES)) { @@ -150,9 +153,9 @@ public static PnIoCm_Block staticParse(ReadBuffer readBuffer) throws ParseExcept } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.REAL_IDENTIFICATION_DATA)) { builder = PnIoCm_Block_RealIdentificationData.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals( - blockType, PnIoCm_BlockType.IOD_BLOCK_REQ_PLUGIN_ALARM_APPLICATION_READY)) { + blockType, PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY_PLUG_ALARM)) { builder = - PnIoCm_Block_ReqPluginAlarmApplicationReady.staticParsePnIoCm_BlockBuilder(readBuffer); + PnIoCm_Block_ReqPlugAlarmApplicationReady.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.I_AND_M_0)) { builder = PnIoCm_Block_IAndM0.staticParsePnIoCm_BlockBuilder(readBuffer); } else if (EvaluationHelper.equals(blockType, PnIoCm_BlockType.I_AND_M_1)) { diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_BlockType.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_BlockType.java index 1d15c7cb0a8..1fdebe70111 100644 --- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_BlockType.java +++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_BlockType.java @@ -65,10 +65,10 @@ public enum PnIoCm_BlockType { SR_INFO_BLOCK((int) 0x010A), ARFSU_BLOCK((int) 0x010B), RS_INFO_BLOCK((int) 0x010C), - IOD_BLOCK_REQ_CONNECTION_APPLICATION_READY((int) 0x0110), - IOD_BLOCK_REQ_PLUGIN_ALARM_APPLICATION_READY((int) 0x0101), - IOX_BLOCK_REQ_CONNECTION((int) 0x0112), - IOX_BLOCK_REQ_PLUGIN_ALARM((int) 0x0113), + IOD_BLOCK_REQ_CONNECTION_PARAMETER_END((int) 0x0110), + IOD_BLOCK_REQ_CONNECTION_PARAMETER_END_PLUG_ALARM((int) 0x0111), + IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY((int) 0x0112), + IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY_PLUG_ALARM((int) 0x0113), RELEASE_BLOCK_REQ((int) 0x0114), IOX_BLOCK_REQ_CONNECTION_READY_FOR_COMPANION((int) 0x0116), IOX_BLOCK_REQ_CONNECTION_READY_FOR_RT_CLASS_3((int) 0x0117), @@ -101,10 +101,10 @@ public enum PnIoCm_BlockType { AR_SERVER_BLOCK((int) 0x8106), AR_RPC_BLOCK_RES((int) 0x8007), AR_VENDOR_BLOCK_RES((int) 0x8008), - IOD_CONTROL_RES_CONNECT((int) 0x8110), - IOD_CONTROL_RES_PLUG((int) 0x8111), - IOX_BLOCK_RES_CONNECT((int) 0x8112), - IOX_BLOCK_RES_PLUG((int) 0x8113), + IOD_BLOCK_RES_CONNECTION_PARAMETER_END((int) 0x8110), + IOD_BLOCK_REs_CONNECTION_PARAMETER_END_PLUG_ALARM((int) 0x8111), + IOX_BLOCK_RES_CONNECTION_APPLICATION_READY((int) 0x8112), + IOX_BLOCK_REs_CONNECTION_APPLICATION_READY_PLUG_ALARM((int) 0x8113), RELEASE_BLOCK_RES((int) 0x8114), IOX_BLOCK_RES_CONNECT_COMPANION_READY((int) 0x8116), IOX_BLOCK_RES_CONNECT_RT_CLASS_3_READY((int) 0x8117), diff --git a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPluginAlarmApplicationReady.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPlugAlarmApplicationReady.java similarity index 71% rename from plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPluginAlarmApplicationReady.java rename to plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPlugAlarmApplicationReady.java index 73b9d230c4f..37b53611c32 100644 --- a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPluginAlarmApplicationReady.java +++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ReqPlugAlarmApplicationReady.java @@ -35,14 +35,14 @@ // Code generated by code-generation. DO NOT EDIT. -public class PnIoCm_Block_ReqPluginAlarmApplicationReady extends PnIoCm_Block implements Message { +public class PnIoCm_Block_ReqPlugAlarmApplicationReady extends PnIoCm_Block implements Message { // Accessors for discriminator values. public PnIoCm_BlockType getBlockType() { - return PnIoCm_BlockType.IOD_BLOCK_REQ_PLUGIN_ALARM_APPLICATION_READY; + return PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY_PLUG_ALARM; } - public PnIoCm_Block_ReqPluginAlarmApplicationReady() { + public PnIoCm_Block_ReqPlugAlarmApplicationReady() { super(); } @@ -50,9 +50,9 @@ public PnIoCm_Block_ReqPluginAlarmApplicationReady() { protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { PositionAware positionAware = writeBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("PnIoCm_Block_ReqPluginAlarmApplicationReady"); + writeBuffer.pushContext("PnIoCm_Block_ReqPlugAlarmApplicationReady"); - writeBuffer.popContext("PnIoCm_Block_ReqPluginAlarmApplicationReady"); + writeBuffer.popContext("PnIoCm_Block_ReqPlugAlarmApplicationReady"); } @Override @@ -63,7 +63,7 @@ public int getLengthInBytes() { @Override public int getLengthInBits() { int lengthInBits = super.getLengthInBits(); - PnIoCm_Block_ReqPluginAlarmApplicationReady _value = this; + PnIoCm_Block_ReqPlugAlarmApplicationReady _value = this; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); return lengthInBits; @@ -71,24 +71,24 @@ public int getLengthInBits() { public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) throws ParseException { - readBuffer.pullContext("PnIoCm_Block_ReqPluginAlarmApplicationReady"); + readBuffer.pullContext("PnIoCm_Block_ReqPlugAlarmApplicationReady"); PositionAware positionAware = readBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - readBuffer.closeContext("PnIoCm_Block_ReqPluginAlarmApplicationReady"); + readBuffer.closeContext("PnIoCm_Block_ReqPlugAlarmApplicationReady"); // Create the instance - return new PnIoCm_Block_ReqPluginAlarmApplicationReadyBuilderImpl(); + return new PnIoCm_Block_ReqPlugAlarmApplicationReadyBuilderImpl(); } - public static class PnIoCm_Block_ReqPluginAlarmApplicationReadyBuilderImpl + public static class PnIoCm_Block_ReqPlugAlarmApplicationReadyBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder { - public PnIoCm_Block_ReqPluginAlarmApplicationReadyBuilderImpl() {} + public PnIoCm_Block_ReqPlugAlarmApplicationReadyBuilderImpl() {} - public PnIoCm_Block_ReqPluginAlarmApplicationReady build() { - PnIoCm_Block_ReqPluginAlarmApplicationReady pnIoCm_Block_ReqPluginAlarmApplicationReady = - new PnIoCm_Block_ReqPluginAlarmApplicationReady(); - return pnIoCm_Block_ReqPluginAlarmApplicationReady; + public PnIoCm_Block_ReqPlugAlarmApplicationReady build() { + PnIoCm_Block_ReqPlugAlarmApplicationReady pnIoCm_Block_ReqPlugAlarmApplicationReady = + new PnIoCm_Block_ReqPlugAlarmApplicationReady(); + return pnIoCm_Block_ReqPlugAlarmApplicationReady; } } @@ -97,11 +97,10 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof PnIoCm_Block_ReqPluginAlarmApplicationReady)) { + if (!(o instanceof PnIoCm_Block_ReqPlugAlarmApplicationReady)) { return false; } - PnIoCm_Block_ReqPluginAlarmApplicationReady that = - (PnIoCm_Block_ReqPluginAlarmApplicationReady) o; + PnIoCm_Block_ReqPlugAlarmApplicationReady that = (PnIoCm_Block_ReqPlugAlarmApplicationReady) o; return super.equals(that) && true; } diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ApplicationReady.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ApplicationReady.java new file mode 100644 index 00000000000..0df2f0ed2cf --- /dev/null +++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ApplicationReady.java @@ -0,0 +1,362 @@ +/* + * 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 PnIoCm_Control_Request_ApplicationReady extends PnIoCm_Block implements Message { + + // Accessors for discriminator values. + public PnIoCm_BlockType getBlockType() { + return PnIoCm_BlockType.IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY; + } + + // Properties. + protected final short blockVersionHigh; + protected final short blockVersionLow; + protected final Uuid arUuid; + protected final int sessionKey; + protected final int controlCommand; + + // Reserved Fields + private Integer reservedField0; + private Integer reservedField1; + private Integer reservedField2; + + public PnIoCm_Control_Request_ApplicationReady( + short blockVersionHigh, + short blockVersionLow, + Uuid arUuid, + int sessionKey, + int controlCommand) { + super(); + this.blockVersionHigh = blockVersionHigh; + this.blockVersionLow = blockVersionLow; + this.arUuid = arUuid; + this.sessionKey = sessionKey; + this.controlCommand = controlCommand; + } + + public short getBlockVersionHigh() { + return blockVersionHigh; + } + + public short getBlockVersionLow() { + return blockVersionLow; + } + + public Uuid getArUuid() { + return arUuid; + } + + public int getSessionKey() { + return sessionKey; + } + + public int getControlCommand() { + return controlCommand; + } + + @Override + protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { + PositionAware positionAware = writeBuffer; + boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); + writeBuffer.pushContext("PnIoCm_Control_Request_ApplicationReady"); + + // 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)); + + // Reserved Field (reserved) + writeReservedField( + "reserved", + reservedField0 != null ? reservedField0 : (int) 0x0000, + writeUnsignedInt(writeBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + // Simple Field (arUuid) + writeSimpleField( + "arUuid", + arUuid, + new DataWriterComplexDefault<>(writeBuffer), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + // Simple Field (sessionKey) + writeSimpleField( + "sessionKey", + sessionKey, + writeUnsignedInt(writeBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + // Reserved Field (reserved) + writeReservedField( + "reserved", + reservedField1 != null ? reservedField1 : (int) 0x0000, + writeUnsignedInt(writeBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + // Simple Field (controlCommand) + writeSimpleField( + "controlCommand", + controlCommand, + writeUnsignedInt(writeBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + // Reserved Field (reserved) + writeReservedField( + "reserved", + reservedField2 != null ? reservedField2 : (int) 0x0000, + writeUnsignedInt(writeBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + writeBuffer.popContext("PnIoCm_Control_Request_ApplicationReady"); + } + + @Override + public int getLengthInBytes() { + return (int) Math.ceil((float) getLengthInBits() / 8.0); + } + + @Override + public int getLengthInBits() { + int lengthInBits = super.getLengthInBits(); + PnIoCm_Control_Request_ApplicationReady _value = this; + boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); + + // Implicit Field (blockLength) + lengthInBits += 16; + + // Simple field (blockVersionHigh) + lengthInBits += 8; + + // Simple field (blockVersionLow) + lengthInBits += 8; + + // Reserved Field (reserved) + lengthInBits += 16; + + // Simple field (arUuid) + lengthInBits += arUuid.getLengthInBits(); + + // Simple field (sessionKey) + lengthInBits += 16; + + // Reserved Field (reserved) + lengthInBits += 16; + + // Simple field (controlCommand) + lengthInBits += 16; + + // Reserved Field (reserved) + lengthInBits += 16; + + return lengthInBits; + } + + public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) + throws ParseException { + readBuffer.pullContext("PnIoCm_Control_Request_ApplicationReady"); + PositionAware positionAware = readBuffer; + boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); + + 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)); + + Integer reservedField0 = + readReservedField( + "reserved", + readUnsignedInt(readBuffer, 16), + (int) 0x0000, + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + Uuid arUuid = + readSimpleField( + "arUuid", + new DataReaderComplexDefault<>(() -> Uuid.staticParse(readBuffer), readBuffer), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + int sessionKey = + readSimpleField( + "sessionKey", + readUnsignedInt(readBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + Integer reservedField1 = + readReservedField( + "reserved", + readUnsignedInt(readBuffer, 16), + (int) 0x0000, + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + int controlCommand = + readSimpleField( + "controlCommand", + readUnsignedInt(readBuffer, 16), + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + Integer reservedField2 = + readReservedField( + "reserved", + readUnsignedInt(readBuffer, 16), + (int) 0x0000, + WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); + + readBuffer.closeContext("PnIoCm_Control_Request_ApplicationReady"); + // Create the instance + return new PnIoCm_Control_Request_ApplicationReadyBuilderImpl( + blockVersionHigh, + blockVersionLow, + arUuid, + sessionKey, + controlCommand, + reservedField0, + reservedField1, + reservedField2); + } + + public static class PnIoCm_Control_Request_ApplicationReadyBuilderImpl + implements PnIoCm_Block.PnIoCm_BlockBuilder { + private final short blockVersionHigh; + private final short blockVersionLow; + private final Uuid arUuid; + private final int sessionKey; + private final int controlCommand; + private final Integer reservedField0; + private final Integer reservedField1; + private final Integer reservedField2; + + public PnIoCm_Control_Request_ApplicationReadyBuilderImpl( + short blockVersionHigh, + short blockVersionLow, + Uuid arUuid, + int sessionKey, + int controlCommand, + Integer reservedField0, + Integer reservedField1, + Integer reservedField2) { + this.blockVersionHigh = blockVersionHigh; + this.blockVersionLow = blockVersionLow; + this.arUuid = arUuid; + this.sessionKey = sessionKey; + this.controlCommand = controlCommand; + this.reservedField0 = reservedField0; + this.reservedField1 = reservedField1; + this.reservedField2 = reservedField2; + } + + public PnIoCm_Control_Request_ApplicationReady build() { + PnIoCm_Control_Request_ApplicationReady pnIoCm_Control_Request_ApplicationReady = + new PnIoCm_Control_Request_ApplicationReady( + blockVersionHigh, blockVersionLow, arUuid, sessionKey, controlCommand); + pnIoCm_Control_Request_ApplicationReady.reservedField0 = reservedField0; + pnIoCm_Control_Request_ApplicationReady.reservedField1 = reservedField1; + pnIoCm_Control_Request_ApplicationReady.reservedField2 = reservedField2; + return pnIoCm_Control_Request_ApplicationReady; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof PnIoCm_Control_Request_ApplicationReady)) { + return false; + } + PnIoCm_Control_Request_ApplicationReady that = (PnIoCm_Control_Request_ApplicationReady) o; + return (getBlockVersionHigh() == that.getBlockVersionHigh()) + && (getBlockVersionLow() == that.getBlockVersionLow()) + && (getArUuid() == that.getArUuid()) + && (getSessionKey() == that.getSessionKey()) + && (getControlCommand() == that.getControlCommand()) + && super.equals(that) + && true; + } + + @Override + public int hashCode() { + return Objects.hash( + super.hashCode(), + getBlockVersionHigh(), + getBlockVersionLow(), + getArUuid(), + getSessionKey(), + getControlCommand()); + } + + @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/PnIoCm_Control_ResponseConnect.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ParameterEnd.java similarity index 88% rename from plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_ResponseConnect.java rename to plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ParameterEnd.java index 39f3c8a8fbf..56b098954da 100644 --- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_ResponseConnect.java +++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request_ParameterEnd.java @@ -35,11 +35,11 @@ // Code generated by code-generation. DO NOT EDIT. -public class PnIoCm_Control_ResponseConnect extends PnIoCm_Block implements Message { +public class PnIoCm_Control_Request_ParameterEnd extends PnIoCm_Block implements Message { // Accessors for discriminator values. public PnIoCm_BlockType getBlockType() { - return PnIoCm_BlockType.IOD_CONTROL_RES_CONNECT; + return PnIoCm_BlockType.IOD_BLOCK_REQ_CONNECTION_PARAMETER_END; } // Properties. @@ -54,7 +54,7 @@ public PnIoCm_BlockType getBlockType() { private Integer reservedField1; private Integer reservedField2; - public PnIoCm_Control_ResponseConnect( + public PnIoCm_Control_Request_ParameterEnd( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -92,7 +92,7 @@ public int getControlCommand() { protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { PositionAware positionAware = writeBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("PnIoCm_Control_ResponseConnect"); + writeBuffer.pushContext("PnIoCm_Control_Request_ParameterEnd"); // Implicit Field (blockLength) (Used for parsing, but its value is not stored as it's // implicitly given by the objects content) @@ -159,7 +159,7 @@ protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws Serial writeUnsignedInt(writeBuffer, 16), WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - writeBuffer.popContext("PnIoCm_Control_ResponseConnect"); + writeBuffer.popContext("PnIoCm_Control_Request_ParameterEnd"); } @Override @@ -170,7 +170,7 @@ public int getLengthInBytes() { @Override public int getLengthInBits() { int lengthInBits = super.getLengthInBits(); - PnIoCm_Control_ResponseConnect _value = this; + PnIoCm_Control_Request_ParameterEnd _value = this; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); // Implicit Field (blockLength) @@ -205,7 +205,7 @@ public int getLengthInBits() { public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) throws ParseException { - readBuffer.pullContext("PnIoCm_Control_ResponseConnect"); + readBuffer.pullContext("PnIoCm_Control_Request_ParameterEnd"); PositionAware positionAware = readBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); @@ -266,9 +266,9 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read (int) 0x0000, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - readBuffer.closeContext("PnIoCm_Control_ResponseConnect"); + readBuffer.closeContext("PnIoCm_Control_Request_ParameterEnd"); // Create the instance - return new PnIoCm_Control_ResponseConnectBuilderImpl( + return new PnIoCm_Control_Request_ParameterEndBuilderImpl( blockVersionHigh, blockVersionLow, arUuid, @@ -279,7 +279,7 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read reservedField2); } - public static class PnIoCm_Control_ResponseConnectBuilderImpl + public static class PnIoCm_Control_Request_ParameterEndBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder { private final short blockVersionHigh; private final short blockVersionLow; @@ -290,7 +290,7 @@ public static class PnIoCm_Control_ResponseConnectBuilderImpl private final Integer reservedField1; private final Integer reservedField2; - public PnIoCm_Control_ResponseConnectBuilderImpl( + public PnIoCm_Control_Request_ParameterEndBuilderImpl( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -309,14 +309,14 @@ public PnIoCm_Control_ResponseConnectBuilderImpl( this.reservedField2 = reservedField2; } - public PnIoCm_Control_ResponseConnect build() { - PnIoCm_Control_ResponseConnect pnIoCm_Control_ResponseConnect = - new PnIoCm_Control_ResponseConnect( + public PnIoCm_Control_Request_ParameterEnd build() { + PnIoCm_Control_Request_ParameterEnd pnIoCm_Control_Request_ParameterEnd = + new PnIoCm_Control_Request_ParameterEnd( blockVersionHigh, blockVersionLow, arUuid, sessionKey, controlCommand); - pnIoCm_Control_ResponseConnect.reservedField0 = reservedField0; - pnIoCm_Control_ResponseConnect.reservedField1 = reservedField1; - pnIoCm_Control_ResponseConnect.reservedField2 = reservedField2; - return pnIoCm_Control_ResponseConnect; + pnIoCm_Control_Request_ParameterEnd.reservedField0 = reservedField0; + pnIoCm_Control_Request_ParameterEnd.reservedField1 = reservedField1; + pnIoCm_Control_Request_ParameterEnd.reservedField2 = reservedField2; + return pnIoCm_Control_Request_ParameterEnd; } } @@ -325,10 +325,10 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof PnIoCm_Control_ResponseConnect)) { + if (!(o instanceof PnIoCm_Control_Request_ParameterEnd)) { return false; } - PnIoCm_Control_ResponseConnect that = (PnIoCm_Control_ResponseConnect) o; + PnIoCm_Control_Request_ParameterEnd that = (PnIoCm_Control_Request_ParameterEnd) o; return (getBlockVersionHigh() == that.getBlockVersionHigh()) && (getBlockVersionLow() == that.getBlockVersionLow()) && (getArUuid() == that.getArUuid()) diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_ResponseConnect.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ApplicationReady.java similarity index 88% rename from plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_ResponseConnect.java rename to plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ApplicationReady.java index 6da07b18d72..8bdc5939b4d 100644 --- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCM_Block_ResponseConnect.java +++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ApplicationReady.java @@ -35,11 +35,11 @@ // Code generated by code-generation. DO NOT EDIT. -public class PnIoCM_Block_ResponseConnect extends PnIoCm_Block implements Message { +public class PnIoCm_Control_Response_ApplicationReady extends PnIoCm_Block implements Message { // Accessors for discriminator values. public PnIoCm_BlockType getBlockType() { - return PnIoCm_BlockType.IOX_BLOCK_RES_CONNECT; + return PnIoCm_BlockType.IOX_BLOCK_RES_CONNECTION_APPLICATION_READY; } // Properties. @@ -54,7 +54,7 @@ public PnIoCm_BlockType getBlockType() { private Integer reservedField0; private Integer reservedField1; - public PnIoCM_Block_ResponseConnect( + public PnIoCm_Control_Response_ApplicationReady( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -98,7 +98,7 @@ public int getControlBlockProperties() { protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { PositionAware positionAware = writeBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("PnIoCM_Block_ResponseConnect"); + writeBuffer.pushContext("PnIoCm_Control_Response_ApplicationReady"); // Implicit Field (blockLength) (Used for parsing, but its value is not stored as it's // implicitly given by the objects content) @@ -165,7 +165,7 @@ protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws Serial writeUnsignedInt(writeBuffer, 16), WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - writeBuffer.popContext("PnIoCM_Block_ResponseConnect"); + writeBuffer.popContext("PnIoCm_Control_Response_ApplicationReady"); } @Override @@ -176,7 +176,7 @@ public int getLengthInBytes() { @Override public int getLengthInBits() { int lengthInBits = super.getLengthInBits(); - PnIoCM_Block_ResponseConnect _value = this; + PnIoCm_Control_Response_ApplicationReady _value = this; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); // Implicit Field (blockLength) @@ -211,7 +211,7 @@ public int getLengthInBits() { public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) throws ParseException { - readBuffer.pullContext("PnIoCM_Block_ResponseConnect"); + readBuffer.pullContext("PnIoCm_Control_Response_ApplicationReady"); PositionAware positionAware = readBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); @@ -271,9 +271,9 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read readUnsignedInt(readBuffer, 16), WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - readBuffer.closeContext("PnIoCM_Block_ResponseConnect"); + readBuffer.closeContext("PnIoCm_Control_Response_ApplicationReady"); // Create the instance - return new PnIoCM_Block_ResponseConnectBuilderImpl( + return new PnIoCm_Control_Response_ApplicationReadyBuilderImpl( blockVersionHigh, blockVersionLow, arUuid, @@ -284,7 +284,7 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read reservedField1); } - public static class PnIoCM_Block_ResponseConnectBuilderImpl + public static class PnIoCm_Control_Response_ApplicationReadyBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder { private final short blockVersionHigh; private final short blockVersionLow; @@ -295,7 +295,7 @@ public static class PnIoCM_Block_ResponseConnectBuilderImpl private final Integer reservedField0; private final Integer reservedField1; - public PnIoCM_Block_ResponseConnectBuilderImpl( + public PnIoCm_Control_Response_ApplicationReadyBuilderImpl( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -314,18 +314,18 @@ public PnIoCM_Block_ResponseConnectBuilderImpl( this.reservedField1 = reservedField1; } - public PnIoCM_Block_ResponseConnect build() { - PnIoCM_Block_ResponseConnect pnIoCM_Block_ResponseConnect = - new PnIoCM_Block_ResponseConnect( + public PnIoCm_Control_Response_ApplicationReady build() { + PnIoCm_Control_Response_ApplicationReady pnIoCm_Control_Response_ApplicationReady = + new PnIoCm_Control_Response_ApplicationReady( blockVersionHigh, blockVersionLow, arUuid, sessionKey, controlCommand, controlBlockProperties); - pnIoCM_Block_ResponseConnect.reservedField0 = reservedField0; - pnIoCM_Block_ResponseConnect.reservedField1 = reservedField1; - return pnIoCM_Block_ResponseConnect; + pnIoCm_Control_Response_ApplicationReady.reservedField0 = reservedField0; + pnIoCm_Control_Response_ApplicationReady.reservedField1 = reservedField1; + return pnIoCm_Control_Response_ApplicationReady; } } @@ -334,10 +334,10 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof PnIoCM_Block_ResponseConnect)) { + if (!(o instanceof PnIoCm_Control_Response_ApplicationReady)) { return false; } - PnIoCM_Block_ResponseConnect that = (PnIoCM_Block_ResponseConnect) o; + PnIoCm_Control_Response_ApplicationReady that = (PnIoCm_Control_Response_ApplicationReady) o; return (getBlockVersionHigh() == that.getBlockVersionHigh()) && (getBlockVersionLow() == that.getBlockVersionLow()) && (getArUuid() == that.getArUuid()) diff --git a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ParameterEnd.java similarity index 88% rename from plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request.java rename to plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ParameterEnd.java index fe974c49dab..5e0ead2de35 100644 --- a/plc4j/drivers/profinet-ng/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Request.java +++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Control_Response_ParameterEnd.java @@ -35,11 +35,11 @@ // Code generated by code-generation. DO NOT EDIT. -public class PnIoCm_Control_Request extends PnIoCm_Block implements Message { +public class PnIoCm_Control_Response_ParameterEnd extends PnIoCm_Block implements Message { // Accessors for discriminator values. public PnIoCm_BlockType getBlockType() { - return PnIoCm_BlockType.IOD_BLOCK_REQ_CONNECTION_APPLICATION_READY; + return PnIoCm_BlockType.IOD_BLOCK_RES_CONNECTION_PARAMETER_END; } // Properties. @@ -54,7 +54,7 @@ public PnIoCm_BlockType getBlockType() { private Integer reservedField1; private Integer reservedField2; - public PnIoCm_Control_Request( + public PnIoCm_Control_Response_ParameterEnd( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -92,7 +92,7 @@ public int getControlCommand() { protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws SerializationException { PositionAware positionAware = writeBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("PnIoCm_Control_Request"); + writeBuffer.pushContext("PnIoCm_Control_Response_ParameterEnd"); // Implicit Field (blockLength) (Used for parsing, but its value is not stored as it's // implicitly given by the objects content) @@ -159,7 +159,7 @@ protected void serializePnIoCm_BlockChild(WriteBuffer writeBuffer) throws Serial writeUnsignedInt(writeBuffer, 16), WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - writeBuffer.popContext("PnIoCm_Control_Request"); + writeBuffer.popContext("PnIoCm_Control_Response_ParameterEnd"); } @Override @@ -170,7 +170,7 @@ public int getLengthInBytes() { @Override public int getLengthInBits() { int lengthInBits = super.getLengthInBits(); - PnIoCm_Control_Request _value = this; + PnIoCm_Control_Response_ParameterEnd _value = this; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); // Implicit Field (blockLength) @@ -205,7 +205,7 @@ public int getLengthInBits() { public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer readBuffer) throws ParseException { - readBuffer.pullContext("PnIoCm_Control_Request"); + readBuffer.pullContext("PnIoCm_Control_Response_ParameterEnd"); PositionAware positionAware = readBuffer; boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); @@ -266,9 +266,9 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read (int) 0x0000, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - readBuffer.closeContext("PnIoCm_Control_Request"); + readBuffer.closeContext("PnIoCm_Control_Response_ParameterEnd"); // Create the instance - return new PnIoCm_Control_RequestBuilderImpl( + return new PnIoCm_Control_Response_ParameterEndBuilderImpl( blockVersionHigh, blockVersionLow, arUuid, @@ -279,7 +279,7 @@ public static PnIoCm_BlockBuilder staticParsePnIoCm_BlockBuilder(ReadBuffer read reservedField2); } - public static class PnIoCm_Control_RequestBuilderImpl + public static class PnIoCm_Control_Response_ParameterEndBuilderImpl implements PnIoCm_Block.PnIoCm_BlockBuilder { private final short blockVersionHigh; private final short blockVersionLow; @@ -290,7 +290,7 @@ public static class PnIoCm_Control_RequestBuilderImpl private final Integer reservedField1; private final Integer reservedField2; - public PnIoCm_Control_RequestBuilderImpl( + public PnIoCm_Control_Response_ParameterEndBuilderImpl( short blockVersionHigh, short blockVersionLow, Uuid arUuid, @@ -309,14 +309,14 @@ public PnIoCm_Control_RequestBuilderImpl( this.reservedField2 = reservedField2; } - public PnIoCm_Control_Request build() { - PnIoCm_Control_Request pnIoCm_Control_Request = - new PnIoCm_Control_Request( + public PnIoCm_Control_Response_ParameterEnd build() { + PnIoCm_Control_Response_ParameterEnd pnIoCm_Control_Response_ParameterEnd = + new PnIoCm_Control_Response_ParameterEnd( blockVersionHigh, blockVersionLow, arUuid, sessionKey, controlCommand); - pnIoCm_Control_Request.reservedField0 = reservedField0; - pnIoCm_Control_Request.reservedField1 = reservedField1; - pnIoCm_Control_Request.reservedField2 = reservedField2; - return pnIoCm_Control_Request; + pnIoCm_Control_Response_ParameterEnd.reservedField0 = reservedField0; + pnIoCm_Control_Response_ParameterEnd.reservedField1 = reservedField1; + pnIoCm_Control_Response_ParameterEnd.reservedField2 = reservedField2; + return pnIoCm_Control_Response_ParameterEnd; } } @@ -325,10 +325,10 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof PnIoCm_Control_Request)) { + if (!(o instanceof PnIoCm_Control_Response_ParameterEnd)) { return false; } - PnIoCm_Control_Request that = (PnIoCm_Control_Request) o; + PnIoCm_Control_Response_ParameterEnd that = (PnIoCm_Control_Response_ParameterEnd) o; return (getBlockVersionHigh() == that.getBlockVersionHigh()) && (getBlockVersionLow() == that.getBlockVersionLow()) && (getArUuid() == that.getArUuid()) diff --git a/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/device/ProfinetDevice.java b/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/device/ProfinetDevice.java index dff032470cf..af122c280e0 100644 --- a/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/device/ProfinetDevice.java +++ b/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/device/ProfinetDevice.java @@ -311,7 +311,7 @@ public void handleResponse(Ethernet_FramePayload_IPv4 packet) { if (payloadPacket instanceof PnIoCm_Packet_Req) { PnIoCm_Packet_Req req = (PnIoCm_Packet_Req) payloadPacket; for (PnIoCm_Block block : req.getBlocks()) { - if (block instanceof PnIoCM_Block_Request) { + if (block instanceof PnIoCm_Control_Request_ApplicationReady) { deviceContext.setState(ProfinetDeviceState.APPLRDY); } } @@ -802,7 +802,7 @@ public DceRpc_Packet create() { (short) 0, new PnIoCm_Packet_Req(16696, 16696, 0, Collections.singletonList( - new PnIoCm_Control_Request( + new PnIoCm_Control_Request_ParameterEnd( (short) 1, (short) 0, ProfinetDeviceContext.ARUUID, @@ -884,7 +884,7 @@ public DceRpc_Packet create() { ProfinetDeviceContext.DEFAULT_MAX_ARRAY_COUNT, 0, Collections.singletonList( - new PnIoCM_Block_ResponseConnect( + new PnIoCm_Control_Response_ApplicationReady( (short) 1, (short) 0, ProfinetDeviceContext.ARUUID, diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/GeneratedDriverByteToMessageCodec.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/GeneratedDriverByteToMessageCodec.java index 28b3e26d8ba..a8ed314a121 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/GeneratedDriverByteToMessageCodec.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/GeneratedDriverByteToMessageCodec.java @@ -56,9 +56,9 @@ protected void encode(ChannelHandlerContext ctx, T packet, ByteBuf byteBuf) { buffer = new WriteBufferByteBased(packet.getLengthInBytes(), byteOrder); packet.serialize(buffer); } - byteBuf.writeBytes(buffer.getData()); + byteBuf.writeBytes(buffer.getBytes()); if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Sending bytes to PLC for message {} as data {}", packet, Hex.encodeHexString(buffer.getData())); + LOGGER.debug("Sending bytes to PLC for message {} as data {}", packet, Hex.encodeHexString(buffer.getBytes())); } } catch (Exception e) { LOGGER.warn("Error encoding package [{}]: {}", packet, e.getMessage(), e); diff --git a/protocols/profinet/src/main/resources/protocols/profinet/pnio.mspec b/protocols/profinet/src/main/resources/protocols/profinet/pnio.mspec index d01ce904705..16114b37b9f 100644 --- a/protocols/profinet/src/main/resources/protocols/profinet/pnio.mspec +++ b/protocols/profinet/src/main/resources/protocols/profinet/pnio.mspec @@ -199,7 +199,7 @@ [simple MacAddress cmResponderMacAddr ] [simple uint 16 responderUDPRTPort ] ] - ['IOD_BLOCK_REQ_CONNECTION_APPLICATION_READY' PnIoCm_Control_Request + ['IOD_BLOCK_REQ_CONNECTION_PARAMETER_END' PnIoCm_Control_Request_ParameterEnd [implicit uint 16 blockLength 'lengthInBytes - 4'] [simple uint 8 blockVersionHigh ] [simple uint 8 blockVersionLow ] @@ -210,7 +210,7 @@ [simple uint 16 controlCommand ] [reserved uint 16 '0x0000' ] ] - ['IOX_BLOCK_REQ_CONNECTION' PnIoCM_Block_Request + ['IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY' PnIoCm_Control_Request_ApplicationReady [implicit uint 16 blockLength 'lengthInBytes - 4'] [simple uint 8 blockVersionHigh ] [simple uint 8 blockVersionLow ] @@ -219,9 +219,9 @@ [simple uint 16 sessionKey ] [reserved uint 16 '0x0000' ] [simple uint 16 controlCommand ] - [simple uint 16 controlBlockProperties ] + [reserved uint 16 '0x0000' ] ] - ['IOX_BLOCK_RES_CONNECT' PnIoCM_Block_ResponseConnect + ['IOX_BLOCK_RES_CONNECTION_APPLICATION_READY' PnIoCm_Control_Response_ApplicationReady [implicit uint 16 blockLength 'lengthInBytes - 4'] [simple uint 8 blockVersionHigh ] [simple uint 8 blockVersionLow ] @@ -232,7 +232,7 @@ [simple uint 16 controlCommand ] [simple uint 16 controlBlockProperties ] ] - ['IOD_CONTROL_RES_CONNECT' PnIoCm_Control_ResponseConnect + ['IOD_BLOCK_RES_CONNECTION_PARAMETER_END' PnIoCm_Control_Response_ParameterEnd [implicit uint 16 blockLength 'lengthInBytes - 4'] [simple uint 8 blockVersionHigh ] [simple uint 8 blockVersionLow ] @@ -335,7 +335,7 @@ [implicit uint 16 numApis 'COUNT(apis)' ] [array PnIoCm_RealIdentificationApi apis count 'numApis'] ] - ['IOD_BLOCK_REQ_PLUGIN_ALARM_APPLICATION_READY' PnIoCm_Block_ReqPluginAlarmApplicationReady + ['IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY_PLUG_ALARM' PnIoCm_Block_ReqPlugAlarmApplicationReady // TODO: Implement ... ] @@ -560,10 +560,10 @@ ['0x010A' SR_INFO_BLOCK ] ['0x010B' ARFSU_BLOCK ] ['0x010C' RS_INFO_BLOCK ] - ['0x0110' IOD_BLOCK_REQ_CONNECTION_APPLICATION_READY ] - ['0x0101' IOD_BLOCK_REQ_PLUGIN_ALARM_APPLICATION_READY ] - ['0x0112' IOX_BLOCK_REQ_CONNECTION ] - ['0x0113' IOX_BLOCK_REQ_PLUGIN_ALARM ] + ['0x0110' IOD_BLOCK_REQ_CONNECTION_PARAMETER_END ] + ['0x0111' IOD_BLOCK_REQ_CONNECTION_PARAMETER_END_PLUG_ALARM] + ['0x0112' IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY ] + ['0x0113' IOX_BLOCK_REQ_CONNECTION_APPLICATION_READY_PLUG_ALARM] ['0x0114' RELEASE_BLOCK_REQ ] ['0x0116' IOX_BLOCK_REQ_CONNECTION_READY_FOR_COMPANION ] ['0x0117' IOX_BLOCK_REQ_CONNECTION_READY_FOR_RT_CLASS_3 ] @@ -598,10 +598,10 @@ ['0x8106' AR_SERVER_BLOCK ] ['0x8007' AR_RPC_BLOCK_RES ] ['0x8008' AR_VENDOR_BLOCK_RES ] - ['0x8110' IOD_CONTROL_RES_CONNECT ] - ['0x8111' IOD_CONTROL_RES_PLUG ] - ['0x8112' IOX_BLOCK_RES_CONNECT ] - ['0x8113' IOX_BLOCK_RES_PLUG ] + ['0x8110' IOD_BLOCK_RES_CONNECTION_PARAMETER_END ] + ['0x8111' IOD_BLOCK_REs_CONNECTION_PARAMETER_END_PLUG_ALARM] + ['0x8112' IOX_BLOCK_RES_CONNECTION_APPLICATION_READY ] + ['0x8113' IOX_BLOCK_REs_CONNECTION_APPLICATION_READY_PLUG_ALARM] ['0x8114' RELEASE_BLOCK_RES ] ['0x8116' IOX_BLOCK_RES_CONNECT_COMPANION_READY ] ['0x8117' IOX_BLOCK_RES_CONNECT_RT_CLASS_3_READY ]