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