Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// 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.eip.readwrite;

import org.apache.plc4x.java.spi.buffers.api.Message;
import org.apache.plc4x.java.spi.buffers.api.ReadBuffer;
import org.apache.plc4x.java.spi.buffers.api.WithOption;
import org.apache.plc4x.java.spi.buffers.api.WriteBuffer;
import org.apache.plc4x.java.spi.buffers.api.exceptions.BufferException;
import org.apache.plc4x.java.spi.fields.data.reader.DataReaderFactory;
import org.apache.plc4x.java.spi.fields.data.writer.DataWriterFactory;
import org.apache.plc4x.java.spi.fields.fields.reader.FieldReaderFactory;
import org.apache.plc4x.java.spi.fields.fields.writer.FieldWriterFactory;
import org.apache.plc4x.java.spi.fields.utils.ThreadLocalHelper;

/**
* Code generated by code-generation. DO NOT EDIT.
*/
public class AttributeID extends LogicalSegmentType implements Message {
protected final byte format;

protected final short attribute;

public AttributeID(Byte format, Short attribute) {
this.format = format;
this.attribute = attribute;
}

/**
* Discriminator field logicalSegmentType
*/
@Override
public byte getLogicalSegmentType() {
return (byte) 0x04;
}

/**
* Property field format
*/
public byte getFormat() {
return format;
}

/**
* Property field attribute
*/
public short getAttribute() {
return attribute;
}

public static LogicalSegmentTypeBuilder staticParseLogicalSegmentTypeBuilder(
ReadBuffer readBuffer) throws BufferException {
readBuffer.pushContext(WithOption.WithName("AttributeID"));
int startPos = readBuffer.getPositionInBits();
boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
// Simple Field: format
byte format = FieldReaderFactory.readSimpleField(DataReaderFactory.readUnsignedByte(readBuffer, 2), WithOption.WithName("format"));

// Simple Field: attribute
short attribute = FieldReaderFactory.readSimpleField(DataReaderFactory.readUnsignedShort(readBuffer, 8), WithOption.WithName("attribute"));

readBuffer.popContext();
return new LogicalSegmentTypeBuilderImpl(format, attribute);
}

protected void serializeLogicalSegmentTypeChild(WriteBuffer writeBuffer) throws BufferException {
writeBuffer.pushContext(WithOption.WithName("AttributeID"));
int startPos = writeBuffer.getPositionInBits();
boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
// Simple Field: format
FieldWriterFactory.writeSimpleField((byte) format, DataWriterFactory.writeUnsignedByte(writeBuffer, 2), WithOption.WithName("format"));

// Simple Field: attribute
FieldWriterFactory.writeSimpleField((short) attribute, DataWriterFactory.writeUnsignedShort(writeBuffer, 8), WithOption.WithName("attribute"));

writeBuffer.popContext();
}

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

@Override
public int getLengthInBits() {
int lengthInBits = super.getLengthInBits();
AttributeID _value = this;
boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
// Simple Field: format
lengthInBits += 2;

// Simple Field: attribute
lengthInBits += 8;

return lengthInBits;
}

public static class LogicalSegmentTypeBuilderImpl implements LogicalSegmentType.LogicalSegmentTypeBuilder {
private final byte format;

private final short attribute;

public LogicalSegmentTypeBuilderImpl(byte format, short attribute) {
this.format = format;
this.attribute = attribute;
}

public LogicalSegmentType build() {
return new AttributeID(format, attribute);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,27 @@
import org.apache.plc4x.java.spi.buffers.api.WithOption;
import org.apache.plc4x.java.spi.buffers.api.WriteBuffer;
import org.apache.plc4x.java.spi.buffers.api.exceptions.BufferException;
import org.apache.plc4x.java.spi.fields.data.reader.DataReaderFactory;
import org.apache.plc4x.java.spi.fields.data.writer.DataWriterFactory;
import org.apache.plc4x.java.spi.fields.fields.reader.FieldReaderFactory;
import org.apache.plc4x.java.spi.fields.fields.writer.FieldWriterFactory;
import org.apache.plc4x.java.spi.fields.utils.ThreadLocalHelper;

/**
* Code generated by code-generation. DO NOT EDIT.
*/
public class GetAttributeSingleRequest extends CipService implements Message {
public GetAttributeSingleRequest() {
protected final PathSegment classSegment;

protected final PathSegment instanceSegment;

protected final PathSegment attributeSegment;

public GetAttributeSingleRequest(PathSegment classSegment, PathSegment instanceSegment,
PathSegment attributeSegment) {
this.classSegment = classSegment;
this.instanceSegment = instanceSegment;
this.attributeSegment = attributeSegment;
}

/**
Expand All @@ -54,19 +68,65 @@ public boolean getConnected() {
return false;
}

/**
* Property field classSegment
*/
public PathSegment getClassSegment() {
return classSegment;
}

/**
* Property field instanceSegment
*/
public PathSegment getInstanceSegment() {
return instanceSegment;
}

/**
* Property field attributeSegment
*/
public PathSegment getAttributeSegment() {
return attributeSegment;
}

public static CipServiceBuilder staticParseCipServiceBuilder(ReadBuffer readBuffer,
boolean connected, int serviceLen) throws BufferException {
readBuffer.pushContext(WithOption.WithName("GetAttributeSingleRequest"));
int startPos = readBuffer.getPositionInBits();
boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
// Implicit Field: requestPathSize
short requestPathSize = FieldReaderFactory.readImplicitField(DataReaderFactory.readUnsignedShort(readBuffer, 8), WithOption.WithName("requestPathSize"));

// Simple Field: classSegment
PathSegment classSegment = FieldReaderFactory.readSimpleField(DataReaderFactory.readComplex(() -> (PathSegment) PathSegment.staticParse(readBuffer), readBuffer), WithOption.WithName("classSegment"));

// Simple Field: instanceSegment
PathSegment instanceSegment = FieldReaderFactory.readSimpleField(DataReaderFactory.readComplex(() -> (PathSegment) PathSegment.staticParse(readBuffer), readBuffer), WithOption.WithName("instanceSegment"));

// Simple Field: attributeSegment
PathSegment attributeSegment = FieldReaderFactory.readSimpleField(DataReaderFactory.readComplex(() -> (PathSegment) PathSegment.staticParse(readBuffer), readBuffer), WithOption.WithName("attributeSegment"));

readBuffer.popContext();
return new CipServiceBuilderImpl();
return new CipServiceBuilderImpl(classSegment, instanceSegment, attributeSegment);
}

protected void serializeCipServiceChild(WriteBuffer writeBuffer) throws BufferException {
writeBuffer.pushContext(WithOption.WithName("GetAttributeSingleRequest"));
int startPos = writeBuffer.getPositionInBits();
boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
// Implicit Field: requestPathSize
short requestPathSize = (short) (((((classSegment.getLengthInBytes()) + (instanceSegment.getLengthInBytes())) + (attributeSegment.getLengthInBytes()))) / (2));
FieldWriterFactory.writeImplicitField((short) requestPathSize, DataWriterFactory.writeUnsignedShort(writeBuffer, 8), WithOption.WithName("requestPathSize"));

// Simple Field: classSegment
FieldWriterFactory.writeSimpleField((PathSegment) classSegment, DataWriterFactory.writeComplex(writeBuffer), WithOption.WithName("classSegment"));

// Simple Field: instanceSegment
FieldWriterFactory.writeSimpleField((PathSegment) instanceSegment, DataWriterFactory.writeComplex(writeBuffer), WithOption.WithName("instanceSegment"));

// Simple Field: attributeSegment
FieldWriterFactory.writeSimpleField((PathSegment) attributeSegment, DataWriterFactory.writeComplex(writeBuffer), WithOption.WithName("attributeSegment"));

writeBuffer.popContext();
}

Expand All @@ -80,15 +140,37 @@ public int getLengthInBits() {
int lengthInBits = super.getLengthInBits();
GetAttributeSingleRequest _value = this;
boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
// Implicit Field: requestPathSize
lengthInBits += 8;

// Simple Field: classSegment
lengthInBits += classSegment.getLengthInBits();

// Simple Field: instanceSegment
lengthInBits += instanceSegment.getLengthInBits();

// Simple Field: attributeSegment
lengthInBits += attributeSegment.getLengthInBits();

return lengthInBits;
}

public static class CipServiceBuilderImpl implements CipService.CipServiceBuilder {
public CipServiceBuilderImpl() {
private final PathSegment classSegment;

private final PathSegment instanceSegment;

private final PathSegment attributeSegment;

public CipServiceBuilderImpl(PathSegment classSegment, PathSegment instanceSegment,
PathSegment attributeSegment) {
this.classSegment = classSegment;
this.instanceSegment = instanceSegment;
this.attributeSegment = attributeSegment;
}

public CipService build() {
return new GetAttributeSingleRequest();
return new GetAttributeSingleRequest(classSegment, instanceSegment, attributeSegment);
}
}
}
Loading