You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2020/10/10 15:00:31 UTC
[plc4x] branch feature/plc4go updated: - Added some first S7 driver
code ...
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/plc4go
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/feature/plc4go by this push:
new 1336386 - Added some first S7 driver code ...
1336386 is described below
commit 1336386c9229beb9c8ae7f457440a6159e72c6d4
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Sat Oct 10 17:00:23 2020 +0200
- Added some first S7 driver code ...
---
.../language/go/GoLanguageTemplateHelper.java | 74 +-
.../main/resources/templates/go/enum-template.ftlh | 7 +-
.../resources/templates/go/model-template.ftlh | 124 ++--
.../s7/src/main/resources/protocols/s7/s7.mspec | 10 +-
.../generated-sources/modbus/include/modbus_pdu.h | 4 +-
.../generated-sources/modbus/src/modbus_pdu.c | 168 ++---
.../plc4c/generated-sources/s7/src/s7_address.c | 4 +-
.../s7/src/s7_payload_user_data_item.c | 8 +-
.../s7/src/s7_var_payload_data_item.c | 8 +-
.../s7/src/s7_var_payload_status_item.c | 4 +-
sandbox/plc4c/generated-sources/s7/src/szl_id.c | 8 +-
.../plc4go/cmd/{modbus => main/drivers}/modbus.go | 4 +-
.../cmd/{modbus/modbus.go => main/drivers/s7.go} | 14 +-
.../plc4go/cmd/{modbus/modbus.go => main/main.go} | 19 +-
.../modbus/readwrite/model/ModbusConstants.go | 8 +-
.../modbus/readwrite/model/ModbusDataType.go | 59 +-
.../readwrite/model/ModbusPDUDiagnosticRequest.go | 4 +-
.../modbus/readwrite/model/ModbusPDUError.go | 4 +-
.../model/ModbusPDUGetComEventLogRequest.go | 4 +-
.../model/ModbusPDUGetComEventLogResponse.go | 8 +-
.../ModbusPDUMaskWriteHoldingRegisterRequest.go | 4 +-
.../ModbusPDUMaskWriteHoldingRegisterResponse.go | 4 +-
.../readwrite/model/ModbusPDUReadCoilsRequest.go | 4 +-
.../readwrite/model/ModbusPDUReadCoilsResponse.go | 8 +-
.../ModbusPDUReadDeviceIdentificationRequest.go | 4 +-
.../ModbusPDUReadDeviceIdentificationResponse.go | 4 +-
.../model/ModbusPDUReadDiscreteInputsRequest.go | 4 +-
.../model/ModbusPDUReadDiscreteInputsResponse.go | 8 +-
.../model/ModbusPDUReadExceptionStatusRequest.go | 4 +-
.../model/ModbusPDUReadExceptionStatusResponse.go | 4 +-
.../model/ModbusPDUReadFifoQueueRequest.go | 4 +-
.../model/ModbusPDUReadFifoQueueResponse.go | 10 +-
.../model/ModbusPDUReadFileRecordRequest.go | 6 +-
.../model/ModbusPDUReadFileRecordRequestItem.go | 2 +-
.../model/ModbusPDUReadFileRecordResponse.go | 6 +-
.../model/ModbusPDUReadFileRecordResponseItem.go | 4 +-
.../model/ModbusPDUReadHoldingRegistersRequest.go | 4 +-
.../model/ModbusPDUReadHoldingRegistersResponse.go | 8 +-
.../model/ModbusPDUReadInputRegistersRequest.go | 4 +-
.../model/ModbusPDUReadInputRegistersResponse.go | 8 +-
...sPDUReadWriteMultipleHoldingRegistersRequest.go | 8 +-
...PDUReadWriteMultipleHoldingRegistersResponse.go | 8 +-
.../model/ModbusPDUReportServerIdRequest.go | 4 +-
.../model/ModbusPDUReportServerIdResponse.go | 8 +-
.../model/ModbusPDUWriteFileRecordRequest.go | 6 +-
.../model/ModbusPDUWriteFileRecordRequestItem.go | 4 +-
.../model/ModbusPDUWriteFileRecordResponse.go | 6 +-
.../model/ModbusPDUWriteFileRecordResponseItem.go | 4 +-
.../model/ModbusPDUWriteMultipleCoilsRequest.go | 8 +-
.../model/ModbusPDUWriteMultipleCoilsResponse.go | 4 +-
...odbusPDUWriteMultipleHoldingRegistersRequest.go | 8 +-
...dbusPDUWriteMultipleHoldingRegistersResponse.go | 4 +-
.../model/ModbusPDUWriteSingleCoilRequest.go | 4 +-
.../model/ModbusPDUWriteSingleCoilResponse.go | 4 +-
.../model/ModbusPDUWriteSingleRegisterRequest.go | 4 +-
.../model/ModbusPDUWriteSingleRegisterResponse.go | 4 +-
.../modbus/readwrite/model/ModbusSerialADU.go | 2 +-
.../plc4go/modbus/readwrite/model/ModbusTcpADU.go | 10 +-
.../plc4go/s7/readwrite/model/COTPPacket.go | 180 +++++
.../readwrite/model/COTPPacketConnectionRequest.go | 110 +++
.../model/COTPPacketConnectionResponse.go | 110 +++
.../readwrite/model/COTPPacketData.go} | 69 +-
.../readwrite/model/COTPPacketDisconnectRequest.go | 110 +++
.../model/COTPPacketDisconnectResponse.go | 95 +++
.../s7/readwrite/model/COTPPacketTpduError.go | 95 +++
.../plc4go/s7/readwrite/model/COTPParameter.go | 111 +++
.../readwrite/model/COTPParameterCalledTsap.go} | 51 +-
.../readwrite/model/COTPParameterCallingTsap.go} | 51 +-
.../readwrite/model/COTPParameterChecksum.go} | 51 +-
...COTPParameterDisconnectAdditionalInformation.go | 95 +++
.../readwrite/model/COTPParameterTpduSize.go} | 60 +-
.../plc4go/s7/readwrite/model/COTPProtocolClass.go | 40 ++
.../plc4go/s7/readwrite/model/COTPTpduSize.go | 79 +++
.../s7/readwrite/model/DataTransportErrorCode.go | 41 ++
.../plc4go/s7/readwrite/model/DataTransportSize.go | 79 +++
.../plc4go/s7/readwrite/model/DeviceGroup.go} | 36 +-
.../plc4go/s7/readwrite/model/MemoryArea.go | 89 +++
.../plc4go/s7/readwrite/model/S7Address.go | 93 +++
.../plc4go/s7/readwrite/model/S7AddressAny.go | 162 +++++
.../plc4go/s7/readwrite/model/S7Message.go | 221 ++++++
.../readwrite/model/S7MessageRequest.go} | 45 +-
.../plc4go/s7/readwrite/model/S7MessageResponse.go | 96 +++
.../s7/readwrite/model/S7MessageResponseData.go | 96 +++
.../readwrite/model/S7MessageUserData.go} | 45 +-
.../plc4go/s7/readwrite/model/S7Parameter.go | 108 +++
.../readwrite/model/S7ParameterReadVarRequest.go | 122 ++++
.../readwrite/model/S7ParameterReadVarResponse.go} | 56 +-
.../model/S7ParameterSetupCommunication.go | 126 ++++
.../s7/readwrite/model/S7ParameterUserData.go | 122 ++++
.../s7/readwrite/model/S7ParameterUserDataItem.go | 93 +++
.../model/S7ParameterUserDataItemCPUFunctions.go | 196 +++++
.../readwrite/model/S7ParameterWriteVarRequest.go | 122 ++++
.../model/S7ParameterWriteVarResponse.go} | 56 +-
.../plc4go/s7/readwrite/model/S7Payload.go | 94 +++
.../s7/readwrite/model/S7PayloadReadVarResponse.go | 116 +++
.../plc4go/s7/readwrite/model/S7PayloadUserData.go | 112 +++
.../s7/readwrite/model/S7PayloadUserDataItem.go | 154 ++++
...PayloadUserDataItemCpuFunctionReadSzlRequest.go | 75 ++
...ayloadUserDataItemCpuFunctionReadSzlResponse.go | 138 ++++
.../s7/readwrite/model/S7PayloadWriteVarRequest.go | 116 +++
.../readwrite/model/S7PayloadWriteVarResponse.go | 112 +++
.../s7/readwrite/model/S7VarPayloadDataItem.go | 148 ++++
.../readwrite/model/S7VarPayloadStatusItem.go} | 42 +-
.../readwrite/model/S7VarRequestParameterItem.go | 93 +++
.../model/S7VarRequestParameterItemAddress.go | 102 +++
.../plc4go/s7/readwrite/model/SzlDataTreeItem.go | 129 ++++
.../internal/plc4go/s7/readwrite/model/SzlId.go | 101 +++
.../s7/readwrite/model/SzlModuleTypeClass.go} | 37 +-
.../plc4go/s7/readwrite/model/SzlSublist.go | 54 ++
.../plc4go/s7/readwrite/model/TPKTPacket.go | 126 ++++
.../plc4go/s7/readwrite/model/TransportSize.go | 790 +++++++++++++++++++++
.../modbus.go => internal/plc4go/spi/Utils.go} | 29 +-
sandbox/plc4go/pom.xml | 38 +-
113 files changed, 6004 insertions(+), 660 deletions(-)
diff --git a/build-utils/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java b/build-utils/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java
index f6fd0c1..2374e61 100644
--- a/build-utils/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java
+++ b/build-utils/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java
@@ -151,11 +151,13 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
return "0.0";
}
case STRING: {
- return "";
+ return "\"\"";
}
}
+ } else if(typeReference instanceof ComplexTypeReference) {
+ return "0";
}
- return "null";
+ return "nil";
}
public int getNumBits(SimpleTypeReference simpleTypeReference) {
@@ -367,7 +369,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
Term a = tt.getA();
Term b = tt.getB();
Term c = tt.getC();
- return "((" + toExpression(field, a, variableExpressionGenerator) + ") ? " + toExpression(field, b, variableExpressionGenerator) + " : " + toExpression(field, c, variableExpressionGenerator) + ")";
+ return "spi.InlineIf((" + toExpression(field, a, variableExpressionGenerator) + "), uint16(" + toExpression(field, b, variableExpressionGenerator) + "), uint16(" + toExpression(field, c, variableExpressionGenerator) + "))";
} else {
throw new RuntimeException("Unsupported ternary operation type " + tt.getOperation());
}
@@ -380,12 +382,12 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
VariableLiteral vl = (VariableLiteral) term;
// CAST expressions are special as we need to add a ".class" to the second parameter in Java.
if("CAST".equals(vl.getName())) {
- StringBuilder sb = new StringBuilder(vl.getName());
if((vl.getArgs() == null) || (vl.getArgs().size() != 2)) {
throw new RuntimeException("A CAST expression expects exactly two arguments.");
}
- sb.append("(").append(toVariableParseExpression(field, vl.getArgs().get(0), parserArguments))
- .append(", ").append(((VariableLiteral) vl.getArgs().get(1)).getName()).append(".class)");
+ VariableLiteral type = (VariableLiteral) vl.getArgs().get(1);
+ StringBuilder sb = new StringBuilder(type.getName());
+ sb.append("(").append(toVariableParseExpression(field, vl.getArgs().get(0), parserArguments)).append(")");
return sb.toString() + ((vl.getChild() != null) ? "." + toVariableExpressionRest(vl.getChild()) : "");
}
else if("STATIC_CALL".equals(vl.getName())) {
@@ -677,7 +679,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
}
String typeName = valueString.substring(0, valueString.indexOf('.'));
String constantName = valueString.substring(valueString.indexOf('.') + 1);
- return constantName;
+ return typeName + "_" + constantName;
} else {
return escapeValue(typeReference, valueString);
}
@@ -710,6 +712,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
// "Fields with complex type": "reflect"
if(((ComplexTypeDefinition) getThisTypeDefinition()).getFields().stream().anyMatch(field ->
+ !(field instanceof EnumField) &&
((field instanceof TypedField) && ((TypedField) field).getType() instanceof ComplexTypeReference))) {
imports.add("\"reflect\"");
}
@@ -792,6 +795,13 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
return name;
}
}
+ if(curField.getParams() != null) {
+ for (Term param : curField.getParams()) {
+ if(param.contains(name)) {
+ return name;
+ }
+ }
+ }
}
}
@@ -825,16 +835,58 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
*/
public Map<String, String> requiresHelperFunctions(String functionName) {
Map<String, String> result = new HashMap<>();
- // Search for array fields ...
+ boolean usesFunction = false;
+ // As the ARRAY_SIZE_IN_BYTES only applies to ArrayFields, search for these
for (Field curField : ((ComplexTypeDefinition) getThisTypeDefinition()).getFields()) {
if(curField instanceof ArrayField) {
ArrayField arrayField = (ArrayField) curField;
- if(arrayField.getType() instanceof ComplexTypeReference) {
- result.put(arrayField.getName(), getLanguageTypeNameForField(arrayField));
+ if(arrayField.getLoopExpression().contains(functionName)) {
+ usesFunction = true;
+ }
+ result.put(arrayField.getName(), getLanguageTypeNameForField(arrayField));
+ } else if(curField instanceof ImplicitField) {
+ ImplicitField implicitField = (ImplicitField) curField;
+ if(implicitField.getSerializeExpression().contains(functionName)) {
+ usesFunction = true;
+ }
+ }
+ }
+ if(usesFunction) {
+ return result;
+ } else {
+ return Collections.emptyMap();
+ }
+ }
+
+ public boolean requiresStartPosAndCurPos() {
+ for (Field curField : ((ComplexTypeDefinition) getThisTypeDefinition()).getFields()) {
+ if(requiresVariable(curField, "curPos")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean requiresVariable(Field curField, String variable) {
+ if(curField instanceof ArrayField) {
+ ArrayField arrayField = (ArrayField) curField;
+ if(arrayField.getLoopExpression().contains(variable)) {
+ return true;
+ }
+ } else if(curField instanceof OptionalField) {
+ OptionalField optionalField = (OptionalField) curField;
+ if(optionalField.getConditionExpression().contains(variable)) {
+ return true;
+ }
+ }
+ if(curField.getParams() != null) {
+ for (Term paramTerm : curField.getParams()) {
+ if (paramTerm.contains(variable)) {
+ return true;
}
}
}
- return result;
+ return false;
}
public Term findTerm(Term baseTerm, String name) {
diff --git a/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh b/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh
index 5559e67..58a001d 100644
--- a/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh
+++ b/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh
@@ -52,7 +52,7 @@ type ${type.name} <#if type.type?has_content>${helper.getLanguageTypeNameForType
const(
<#list type.enumValues as enumValue>
- ${enumValue.name} ${type.name} = ${enumValue.value}
+ ${type.name}_${enumValue.name} ${type.name} = ${enumValue.value}
</#list>
)
@@ -72,7 +72,7 @@ func (e ${type.name}) Get${constantName?cap_first}() ${helper.getLanguageTypeNam
}
</#list>
default: {
- return 0
+ return ${helper.getNullValueForTypeReference(type.getConstantType(constantName))}
}
}
}
@@ -80,8 +80,9 @@ func (e ${type.name}) Get${constantName?cap_first}() ${helper.getLanguageTypeNam
</#if>
<#if type.type?has_content>
-func (e *${type.name}) Parse(io spi.ReadBuffer) {
+func ${type.name}Parse(io spi.ReadBuffer) (${type.name}, error) {
// TODO: Implement ...
+ return 0, nil
}
func (e ${type.name}) Serialize(io spi.WriteBuffer) {
diff --git a/build-utils/language-go/src/main/resources/templates/go/model-template.ftlh b/build-utils/language-go/src/main/resources/templates/go/model-template.ftlh
index ebb8656..535e92a 100644
--- a/build-utils/language-go/src/main/resources/templates/go/model-template.ftlh
+++ b/build-utils/language-go/src/main/resources/templates/go/model-template.ftlh
@@ -74,7 +74,7 @@ import (
// Constant values.
<#list type.constFields as field>
-const ${field.name?upper_case} ${helper.getLanguageTypeNameForField(field)} = ${field.referenceValue}
+const ${type.name}_${field.name?upper_case} ${helper.getLanguageTypeNameForField(field)} = ${field.referenceValue}
</#list>
</#if>
@@ -83,7 +83,7 @@ type ${type.name} struct {
<#-- Prpoerty fields are fields that require a property in the pojo -->
<#if type.propertyFields?has_content>
<#list type.propertyFields as field>
- ${field.name} <#if field.loopType??>[]</#if>${helper.getLanguageTypeNameForField(field)}
+ ${field.name} <#if field.typeName == "optional">*</#if><#if field.loopType??>[]</#if>${helper.getLanguageTypeNameForField(field)}
</#list>
</#if>
<#--
@@ -127,7 +127,7 @@ func (m ${type.name}) ${discriminatorName?cap_first}() ${helper.getLanguageTypeN
</#if>
<#if helper.isDiscriminatedParentTypeDefinition()>
type ${type.name}Initializer interface {
- initialize(<#list type.getAllPropertyFields() as field>${field.name}: ${field.name}<#sep>, </#sep></#list>) spi.Message
+ initialize(<#list type.getAllPropertyFields() as field>${field.name} <#if field.typeName == "optional">*</#if><#if field.loopType??>[]</#if>${helper.getLanguageTypeNameForField(field)}<#sep>, </#sep></#list>) spi.Message
}
<#list helper.getDiscriminatorTypes() as discriminatorName, discriminatorType>
@@ -140,13 +140,16 @@ func ${type.name}${discriminatorName?cap_first}(m I${type.name}) ${helper.getLan
</#if>
</#list>
<#else>
-<#if type.parentType??>func (m ${type.name}) initialize(<#list type.parentType.getAllPropertyFields() as field>${field.name}: ${field.name}<#sep>, </#sep></#list>) spi.Message {
- return spi.Message(m)
+<#if type.parentType??>func (m ${type.name}) initialize(<#list type.parentType.getAllPropertyFields() as field>${field.name} <#if field.typeName == "optional">*</#if><#if field.loopType??>[]</#if>${helper.getLanguageTypeNameForField(field)}<#sep>, </#sep></#list>) spi.Message {
+ <#list type.parentType.getAllPropertyFields() as field>
+ m.${field.name} = ${field.name}
+ </#list>
+ return m
}
</#if>
-func New${type.name}(<#list type.getAllPropertyFields() as field>${field.name} <#if field.loopType??>[]</#if>${helper.getLanguageTypeNameForField(field)}<#sep>, </#sep></#list>) <#if type.parentType??>${type.parentType.name}Initializer<#else>spi.Message</#if> {
- return &${type.name}{<#list type.getAllPropertyFields() as field>${field.name}: ${field.name}<#sep>, </#sep></#list>}
+func New${type.name}(<#list type.getPropertyFields() as field>${field.name} <#if field.typeName == "optional">*</#if><#if field.loopType??>[]</#if>${helper.getLanguageTypeNameForField(field)}<#sep>, </#sep></#list>) <#if type.parentType??>${type.parentType.name}Initializer<#else>spi.Message</#if> {
+ return &${type.name}{<#list type.getPropertyFields() as field>${field.name}: ${field.name}<#sep>, </#sep></#list>}
}
</#if>
@@ -234,8 +237,8 @@ func (m ${type.name}) LengthInBits() uint16 {
// Padding Field (padding)
<#-- We're replacing the "lastItem" with 'false' here as the item itself can't know if it is the last -->
- _timesPadding:uint8 = uint8(${helper.toParseExpression(paddingField, paddingField.paddingCondition, type.parserArguments)?replace("lastItem", "false")})
- for _timesPadding > 0; _timesPadding-- {
+ _timesPadding := uint8(${helper.toParseExpression(paddingField, paddingField.paddingCondition, type.parserArguments)?replace("lastItem", "false")})
+ for ;_timesPadding > 0; _timesPadding-- {
lengthInBits += ${simpleTypeReference.sizeInBits}
}
<#break>
@@ -278,8 +281,10 @@ func (m ${type.name}) LengthInBytes() uint16 {
}
func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>, <#list type.parserArguments as parserArgument>${parserArgument.name} ${helper.getLanguageTypeNameForTypeReference(parserArgument.type)}<#sep>, </#sep></#list></#if>) (<#if type.parentType??>${type.parentType.name}Initializer<#else>spi.Message</#if>, error) {
-<#-- var startPos = io.GetPos()
- var curPos uint16-->
+ <#if helper.requiresStartPosAndCurPos()>
+ var startPos = io.GetPos()
+ var curPos uint16
+ </#if>
<#list type.fields as field>
<#switch field.typeName>
<#case "array">
@@ -290,15 +295,29 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
<#if arrayField.loopExpression.contains("curPos")>
curPos = io.GetPos() - startPos
</#if>
- var ${arrayField.name} []${helper.getLanguageTypeNameForField(field)}
+ var ${arrayField.name} []${helper.getLanguageTypeNameForField(arrayField)}
<#-- If this is a count array, we can directly initialize an array with the given size -->
<#if helper.isCountArrayField(field)>
// Count array
{
- ${arrayField.name} := make([]${helper.getLanguageTypeNameForField(field)}, ${helper.toParseExpression(arrayField, arrayField.loopExpression, type.parserArguments)})
+ ${arrayField.name} := make([]${helper.getLanguageTypeNameForField(field)}, ${helper.toParseExpression(arrayField, arrayField.loopExpression, type.parserArguments)} )
for curItem := uint16(0); curItem < uint16(${helper.toParseExpression(arrayField, arrayField.loopExpression, type.parserArguments)}); curItem++ {
-<#if !helper.isSimpleTypeReference(arrayField.type)> boolean lastItem = curItem == (itemCount - 1);</#if>
- ${arrayField.name}[curItem] = <#if helper.isSimpleTypeReference(arrayField.type)><#assign simpleTypeReference = arrayField.type>${helper.getReadBufferReadMethodCall(simpleTypeReference)}<#else>${arrayField.type.name}IO.staticParse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getLanguageTypeNameForTypeReference(helper.getArgumentType(arrayField.type, parserArgument?index))}) (${helper.toParseExpression(arrayField, parserArgument, type.parse [...]
+<#if (!helper.isSimpleTypeReference(arrayField.type)) && helper.requiresVariable(arrayField, "lastItem")> lastItem := curItem == uint16(${helper.toParseExpression(arrayField, arrayField.loopExpression, type.parserArguments)} - 1)</#if>
+ <#if helper.isSimpleTypeReference(arrayField.type)>
+ <#assign simpleTypeReference = arrayField.type>
+ ${arrayField.name} = append(${arrayField.name}, ${helper.getReadBufferReadMethodCall(simpleTypeReference)})
+ <#else>
+ _message, _err := ${arrayField.type.name}Parse(io<#if field.params?has_content>, <#list field.params as parserArgument>${helper.getLanguageTypeNameForTypeReference(helper.getArgumentType(arrayField.type, parserArgument?index))}(${helper.toParseExpression(arrayField, parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)
+ if _err != nil {
+ return nil, errors.New("Error parsing '${arrayField.name}' field " + _err.Error())
+ }
+ var _item ${helper.getLanguageTypeNameForField(field)}
+ _item, _ok := _message.(${arrayField.type.name})
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to ${arrayField.type.name}")
+ }
+ ${arrayField.name} = append(${arrayField.name}, _item)
+ </#if>
}
}
<#-- In all other cases do we have to work with a list, that is later converted to an array -->
@@ -312,7 +331,7 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
<#assign simpleTypeReference = arrayField.type>
${arrayField.name} = append(${arrayField.name}, ${helper.getReadBufferReadMethodCall(simpleTypeReference)})
<#else>
- _message, _err := ${arrayField.type.name}Parse(io<#if field.params?has_content>, <#list field.params as parserArgument>${helper.getLanguageTypeNameForTypeReference(helper.getArgumentType(simpleField.type, parserArgument?index))}(${helper.toParseExpression(simpleField, parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)
+ _message, _err := ${arrayField.type.name}Parse(io<#if field.params?has_content>, <#list field.params as parserArgument>${helper.getLanguageTypeNameForTypeReference(helper.getArgumentType(arrayField.type, parserArgument?index))}(${helper.toParseExpression(arrayField, parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)
if _err != nil {
return nil, errors.New("Error parsing '${arrayField.name}' field " + _err.Error())
}
@@ -325,7 +344,7 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
</#if>
<#-- After parsing, update the current position, but only if it's needed -->
<#if arrayField.loopExpression.contains("curPos")>
- curPos = io.getPos() - startPos;
+ curPos = io.GetPos() - startPos
</#if>
}
<#-- A terminated array keeps on reading data as long as the termination expression evaluates to false -->
@@ -349,7 +368,7 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
<#-- After parsing, update the current position, but only if it's needed -->
<#if arrayField.loopExpression.contains("curPos")>
- curPos = io.getPos() - startPos
+ curPos = io.GetPos() - startPos
</#if>
}
</#if>
@@ -362,7 +381,7 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
{
checksum = ${helper.getNullValueForTypeReference(checksumField.type)}
// Create an array of all the bytes read in this message element so far.
- byte[] checksumRawData = io.getBytes(startPos, io.getPos())
+ byte[] checksumRawData = io.getBytes(startPos, io.GetPos())
${helper.getLanguageTypeNameForField(field)} checksumRef = ${helper.getReadBufferReadMethodCall(simpleTypeReference)}
checksum = (${helper.getLanguageTypeNameForField(field)}) (${helper.toParseExpression(checksumField, checksumField.checksumExpression, type.parserArguments)})
if checksum != checksumRef {
@@ -376,8 +395,8 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
// Const Field (${constField.name})
var ${constField.name} ${helper.getLanguageTypeNameForField(field)} = ${helper.getReadBufferReadMethodCall(simpleTypeReference)}
- if ${constField.name} != ${constField.name?upper_case} {
- return nil, errors.New("Expected constant value " + strconv.Itoa(int(${constField.name?upper_case})) + " but got " + strconv.Itoa(int(${constField.name})))
+ if ${constField.name} != ${type.name}_${constField.name?upper_case} {
+ return nil, errors.New("Expected constant value " + strconv.Itoa(int(${type.name}_${constField.name?upper_case})) + " but got " + strconv.Itoa(int(${constField.name})))
}
<#break>
<#case "discriminator">
@@ -391,7 +410,10 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
<#assign enumField = field>
// Enum field (${enumField.name})
- var ${enumField.name} ${helper.getLanguageTypeNameForField(field)} = ${helper.getLanguageTypeNameForField(field)}.valueOf(${helper.getReadBufferReadMethodCall(helper.getEnumBaseTypeReference(enumField.type))})
+ ${enumField.name}, _${enumField.name}Err := ${helper.getLanguageTypeNameForField(field)}Parse(io)
+ if _${enumField.name}Err != nil {
+ return nil, errors.New("Error parsing '${enumField.name}' field " + _${enumField.name}Err.Error())
+ }
<#break>
<#case "implicit">
<#assign implicitField = field>
@@ -406,7 +428,7 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
// Manual Array Field (${manualArrayField.name})
<#-- Only update curPos if the length expression uses it -->
<#if manualArrayField.loopExpression.contains("curPos")>
- curPos = io.getPos() - startPos
+ curPos = io.GetPos() - startPos
</#if>
<#-- If this is a count array, we can directly initialize an array with the given size -->
<#if helper.isCountArrayField(field)>
@@ -423,12 +445,12 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
// Length array
_${manualArrayField.name}Length := ${helper.toParseExpression(manualArrayField, manualArrayField.loopExpression, type.parserArguments)}
List<${helper.getLanguageTypeNameForField(manualArrayField)}> _${manualArrayField.name}List = new LinkedList<>()
- ${manualArrayField.name}EndPos := io.getPos() + _${manualArrayField.name}Length
- for ;io.getPos() < ${manualArrayField.name}EndPos; {
+ ${manualArrayField.name}EndPos := io.GetPos() + _${manualArrayField.name}Length
+ for ;io.GetPos() < ${manualArrayField.name}EndPos; {
_${manualArrayField.name}List.add((${helper.getLanguageTypeNameForField(field)}) (${helper.toParseExpression(manualArrayField, manualArrayField.parseExpression, type.parserArguments)}))
<#-- After parsing, update the current position, but only if it's needed -->
<#if manualArrayField.loopExpression.contains("curPos")>
- curPos = io.getPos() - startPos
+ curPos = io.GetPos() - startPos
</#if>
}
<#-- A terminated array keeps on reading data as long as the termination expression evaluates to false -->
@@ -440,7 +462,7 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
<#-- After parsing, update the current position, but only if it's needed -->
<#if manualArrayField.loopExpression.contains("curPos")>
- curPos = io.getPos() - startPos
+ curPos = io.GetPos() - startPos
</#if>
}
</#if>
@@ -470,11 +492,25 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
// Optional Field (${optionalField.name}) (Can be skipped, if a given expression evaluates to false)
<#if optionalField.conditionExpression.contains("curPos")>
- curPos = io.getPos() - startPos
+ curPos = io.GetPos() - startPos
</#if>
- var ${optionalField.name} ${helper.getLanguageTypeNameForField(field)} = null
+ var ${optionalField.name} *${helper.getLanguageTypeNameForField(field)} = nil
if ${helper.toParseExpression(optionalField, optionalField.conditionExpression, type.parserArguments)} {
- ${optionalField.name} = <#if helper.isSimpleTypeReference(optionalField.type)>${helper.getReadBufferReadMethodCall(optionalField.type)}<#else>${optionalField.type.name}IO.staticParse(io<#if field.params?has_content>, <#list field.params as parserArgument>(${helper.getLanguageTypeNameForTypeReference(helper.getArgumentType(optionalField.type, parserArgument?index))}) (${helper.toParseExpression(optionalField, parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)</#if>
+ <#if helper.isSimpleTypeReference(optionalField.type)>
+ _val := ${helper.getReadBufferReadMethodCall(optionalField.type)}
+ ${optionalField.name} = &_val
+ <#else>
+ _message, _err := ${helper.getLanguageTypeNameForField(field)}Parse(io<#if field.params?has_content>, <#list field.params as parserArgument>${helper.getLanguageTypeNameForTypeReference(helper.getArgumentType(optionalField.type, parserArgument?index))}(${helper.toParseExpression(optionalField, parserArgument, type.parserArguments)})<#sep>, </#sep></#list></#if>)
+ if _err != nil {
+ return nil, errors.New("Error parsing '${optionalField.name}' field " + _err.Error())
+ }
+ var _item ${helper.getLanguageTypeNameForField(field)}
+ _item, _ok := _message.(${helper.getLanguageTypeNameForField(field)})
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to ${helper.getLanguageTypeNameForField(field)}")
+ }
+ ${optionalField.name} = &_item
+ </#if>
}
<#break>
<#case "padding">
@@ -484,7 +520,7 @@ func ${type.name}Parse(io spi.ReadBuffer<#if type.parserArguments?has_content>,
// Padding Field (padding)
{
_timesPadding := (${helper.toParseExpression(paddingField, paddingField.paddingCondition, type.parserArguments)})
- for ;(io.hasMore(${helper.getNumBits(simpleTypeReference)})) && (_timesPadding-- > 0); {
+ for ;(io.HasMore(${helper.getNumBits(simpleTypeReference)})) && (_timesPadding > 0);_timesPadding-- {
// Just read the padding data and ignore it
${helper.getReadBufferReadMethodCall(simpleTypeReference)}
}
@@ -575,7 +611,7 @@ func (m ${type.name}) Serialize(io spi.WriteBuffer) {
</#list>
</#if>
serializeFunc := func(typ interface{}) {
- if <#if helper.isDiscriminatedParentTypeDefinition()>i${type.name}<#else>_</#if>, ok :=typ.(IModbusPDU); ok {
+ if <#if helper.isDiscriminatedParentTypeDefinition()>i${type.name}<#else>_</#if>, ok :=typ.(I${type.name}); ok {
<#list type.fields as field>
<#switch field.typeName>
<#case "array">
@@ -584,8 +620,8 @@ func (m ${type.name}) Serialize(io spi.WriteBuffer) {
// Array Field (${arrayField.name})
if m.${arrayField.name} != nil {
- <#if helper.isComplexTypeReference(arrayField.type) && helper.needsVariable(arrayField, "curItem", true)>
- itemCount := len(m.${arrayField.name})
+ <#if helper.isComplexTypeReference(arrayField.type) && (helper.needsVariable(arrayField, "curItem", true) || helper.needsVariable(arrayField, "lastItem", true))>
+ itemCount := uint16(len(m.${arrayField.name}))
var curItem uint16 = 0
</#if>
for _, _element := range m.${arrayField.name} {
@@ -594,12 +630,12 @@ func (m ${type.name}) Serialize(io spi.WriteBuffer) {
${helper.getWriteBufferWriteMethodCall(simpleTypeReference, "_element")}
<#else>
<#assign complexTypeReference = arrayField.type>
- <#if helper.needsVariable(arrayField, "curItem", true)>
+ <#if helper.needsVariable(arrayField, "lastItem", true)>
var lastItem bool = curItem == (itemCount - 1)
</#if>
_element.Serialize(io<#if helper.getSerializerTerms(field.params)?has_content>, <#list helper.getSerializerTerms(field.params) as parserArgument>${parserArgument.name}<#sep>, </#sep></#list></#if>)
</#if>
- <#if helper.needsVariable(arrayField, "curItem", true)>
+ <#if helper.needsVariable(arrayField, "curItem", true) || helper.needsVariable(arrayField, "lastItem", true)>
curItem++
</#if>
}
@@ -613,7 +649,7 @@ func (m ${type.name}) Serialize(io spi.WriteBuffer) {
{
_checksum := ${helper.getNullValueForTypeReference(checksumField.type)}
// Create an array of all the bytes written in this message element so far.
- checksumRawData []uint8 = io.getBytes(startPos, io.getPos())
+ checksumRawData []uint8 = io.getBytes(startPos, io.GetPos())
_checksum = (${helper.getLanguageTypeNameForField(field)}) (${helper.toSerializationExpression(checksumField, checksumField.checksumExpression, type.parserArguments)})
${helper.getWriteBufferWriteMethodCall(simpleTypeReference, "(_checksum)")}
}
@@ -638,14 +674,14 @@ func (m ${type.name}) Serialize(io spi.WriteBuffer) {
// Enum field (${enumField.name})
${enumField.name} := m.${enumField.name}
- ${helper.getWriteBufferWriteMethodCall(helper.getEnumBaseTypeReference(enumField.type), "(" + enumField.name + ".getValue())")}
+ ${enumField.name}.Serialize(io)
<#break>
<#case "implicit">
<#assign implicitField = field>
<#assign simpleTypeReference = implicitField.type>
// Implicit Field (${implicitField.name}) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var ${implicitField.name} ${helper.getLanguageTypeNameForField(field)} = (${helper.toSerializationExpression(implicitField, implicitField.serializeExpression, type.parserArguments)})
+ ${implicitField.name} := ${helper.getLanguageTypeNameForField(field)}(${helper.toSerializationExpression(implicitField, implicitField.serializeExpression, type.parserArguments)})
${helper.getWriteBufferWriteMethodCall(simpleTypeReference, "(" + implicitField.name + ")")}
<#break>
<#case "manualArray">
@@ -668,15 +704,15 @@ func (m ${type.name}) Serialize(io spi.WriteBuffer) {
<#assign optionalField = field>
// Optional Field (${optionalField.name}) (Can be skipped, if the value is null)
- var ${optionalField.name} ${helper.getLanguageTypeNameForField(field)} = nil
+ var ${optionalField.name} *${helper.getLanguageTypeNameForField(field)} = nil
if m.${optionalField.name} != nil {
${optionalField.name} = m.${optionalField.name}
<#if helper.isSimpleTypeReference(optionalField.type)>
<#assign simpleTypeReference = optionalField.type>
- ${helper.getWriteBufferWriteMethodCall(simpleTypeReference, "(" + optionalField.name + ")")}
+ ${helper.getWriteBufferWriteMethodCall(simpleTypeReference, "*(" + optionalField.name + ")")}
<#else>
<#assign complexTypeReference = optionalField.type>
- ${complexTypeReference.name}IO.staticSerialize(io, ${optionalField.name})
+ ${optionalField.name}.Serialize(io)
</#if>
}
<#break>
@@ -686,9 +722,9 @@ func (m ${type.name}) Serialize(io spi.WriteBuffer) {
// Padding Field (padding)
{
- int _timesPadding = (int) (${helper.toSerializationExpression(paddingField, paddingField.paddingCondition, type.parserArguments)})
+ _timesPadding := uint8(${helper.toSerializationExpression(paddingField, paddingField.paddingCondition, type.parserArguments)})
for ;_timesPadding > 0; _timesPadding-- {
- ${helper.getLanguageTypeNameForField(field)} _paddingValue = (${helper.getLanguageTypeNameForField(field)}) (${helper.toSerializationExpression(paddingField, paddingField.paddingValue, type.parserArguments)})
+ _paddingValue := ${helper.getLanguageTypeNameForField(field)}(${helper.toSerializationExpression(paddingField, paddingField.paddingValue, type.parserArguments)})
${helper.getWriteBufferWriteMethodCall(simpleTypeReference, "(_paddingValue)")}
}
}
diff --git a/protocols/s7/src/main/resources/protocols/s7/s7.mspec b/protocols/s7/src/main/resources/protocols/s7/s7.mspec
index 5128e71..aea6ac5 100644
--- a/protocols/s7/src/main/resources/protocols/s7/s7.mspec
+++ b/protocols/s7/src/main/resources/protocols/s7/s7.mspec
@@ -442,7 +442,7 @@
['0x0F' DATE_AND_TIME ['X' , '12' , 'null' , 'null' , '56' , 'true' , 'true' , 'false' , 'true' , 'false' ]]
]
-[enum int 8 'MemoryArea' [string 24 'utf8' 'shortName']
+[enum uint 8 'MemoryArea' [string 24 'utf8' 'shortName']
['0x1C' COUNTERS ['C']]
['0x1D' TIMERS ['T']]
['0x80' DIRECT_PERIPHERAL_ACCESS ['D']]
@@ -454,7 +454,7 @@
['0x86' LOCAL_DATA ['LD']]
]
-[enum int 8 'DataTransportSize' [bit 'sizeInBits']
+[enum uint 8 'DataTransportSize' [bit 'sizeInBits']
['0x00' NULL ['false']]
['0x03' BIT ['true']]
['0x04' BYTE_WORD_DWORD ['true']]
@@ -464,7 +464,7 @@
['0x09' OCTET_STRING ['false']]
]
-[enum int 8 'DataTransportErrorCode'
+[enum uint 8 'DataTransportErrorCode'
['0x00' RESERVED ]
['0xFF' OK ]
['0x03' ACCESS_DENIED ]
@@ -473,14 +473,14 @@
['0x0A' NOT_FOUND ]
]
-[enum int 4 'SzlModuleTypeClass'
+[enum uint 4 'SzlModuleTypeClass'
['0x0' CPU]
['0x4' IM]
['0x8' FM]
['0xC' CP]
]
-[enum int 8 'SzlSublist'
+[enum uint 8 'SzlSublist'
['0x11' MODULE_IDENTIFICATION]
['0x12' CPU_FEATURES]
['0x13' USER_MEMORY_AREA]
diff --git a/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu.h b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu.h
index 08adfa5..4ab70e6 100644
--- a/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu.h
+++ b/sandbox/plc4c/generated-sources/modbus/include/modbus_pdu.h
@@ -37,8 +37,8 @@ extern "C" {
// Structure used to contain the discriminator values for discriminated types using this as a parent
struct plc4c_modbus_read_write_modbus_pdu_discriminator {
- bool error;
- unsigned int function;
+ bool errorFlag;
+ unsigned int functionFlag;
bool response;
};
typedef struct plc4c_modbus_read_write_modbus_pdu_discriminator plc4c_modbus_read_write_modbus_pdu_discriminator;
diff --git a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c
index b29b90d..8478c70 100644
--- a/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c
+++ b/sandbox/plc4c/generated-sources/modbus/src/modbus_pdu.c
@@ -26,77 +26,77 @@
// enum constant to directly access a given types discriminator values)
const plc4c_modbus_read_write_modbus_pdu_discriminator plc4c_modbus_read_write_modbus_pdu_discriminators[] = {
{/* plc4c_modbus_read_write_modbus_pdu_error */
- .error = true, .function = -1, .response = -1},
+ .errorFlag = true, .functionFlag = -1, .response = -1},
{/* plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_request */
- .error = false, .function = 0x02, .response = false},
+ .errorFlag = false, .functionFlag = 0x02, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_response */
- .error = false, .function = 0x02, .response = true},
+ .errorFlag = false, .functionFlag = 0x02, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_read_coils_request */
- .error = false, .function = 0x01, .response = false},
+ .errorFlag = false, .functionFlag = 0x01, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_read_coils_response */
- .error = false, .function = 0x01, .response = true},
+ .errorFlag = false, .functionFlag = 0x01, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_write_single_coil_request */
- .error = false, .function = 0x05, .response = false},
+ .errorFlag = false, .functionFlag = 0x05, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_write_single_coil_response */
- .error = false, .function = 0x05, .response = true},
+ .errorFlag = false, .functionFlag = 0x05, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_request */
- .error = false, .function = 0x0F, .response = false},
+ .errorFlag = false, .functionFlag = 0x0F, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_response */
- .error = false, .function = 0x0F, .response = true},
+ .errorFlag = false, .functionFlag = 0x0F, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_read_input_registers_request */
- .error = false, .function = 0x04, .response = false},
+ .errorFlag = false, .functionFlag = 0x04, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_read_input_registers_response */
- .error = false, .function = 0x04, .response = true},
+ .errorFlag = false, .functionFlag = 0x04, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_read_holding_registers_request */
- .error = false, .function = 0x03, .response = false},
+ .errorFlag = false, .functionFlag = 0x03, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_read_holding_registers_response */
- .error = false, .function = 0x03, .response = true},
+ .errorFlag = false, .functionFlag = 0x03, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_write_single_register_request */
- .error = false, .function = 0x06, .response = false},
+ .errorFlag = false, .functionFlag = 0x06, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_write_single_register_response */
- .error = false, .function = 0x06, .response = true},
+ .errorFlag = false, .functionFlag = 0x06, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_request */
- .error = false, .function = 0x10, .response = false},
+ .errorFlag = false, .functionFlag = 0x10, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_response */
- .error = false, .function = 0x10, .response = true},
+ .errorFlag = false, .functionFlag = 0x10, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_request */
- .error = false, .function = 0x17, .response = false},
+ .errorFlag = false, .functionFlag = 0x17, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_response */
- .error = false, .function = 0x17, .response = true},
+ .errorFlag = false, .functionFlag = 0x17, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_request */
- .error = false, .function = 0x16, .response = false},
+ .errorFlag = false, .functionFlag = 0x16, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_response */
- .error = false, .function = 0x16, .response = true},
+ .errorFlag = false, .functionFlag = 0x16, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_request */
- .error = false, .function = 0x18, .response = false},
+ .errorFlag = false, .functionFlag = 0x18, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_response */
- .error = false, .function = 0x18, .response = true},
+ .errorFlag = false, .functionFlag = 0x18, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_read_file_record_request */
- .error = false, .function = 0x14, .response = false},
+ .errorFlag = false, .functionFlag = 0x14, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_read_file_record_response */
- .error = false, .function = 0x14, .response = true},
+ .errorFlag = false, .functionFlag = 0x14, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_write_file_record_request */
- .error = false, .function = 0x15, .response = false},
+ .errorFlag = false, .functionFlag = 0x15, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_write_file_record_response */
- .error = false, .function = 0x15, .response = true},
+ .errorFlag = false, .functionFlag = 0x15, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_read_exception_status_request */
- .error = false, .function = 0x07, .response = false},
+ .errorFlag = false, .functionFlag = 0x07, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_read_exception_status_response */
- .error = false, .function = 0x07, .response = true},
+ .errorFlag = false, .functionFlag = 0x07, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_diagnostic_request */
- .error = false, .function = 0x08, .response = false},
+ .errorFlag = false, .functionFlag = 0x08, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_get_com_event_log_request */
- .error = false, .function = 0x0C, .response = false},
+ .errorFlag = false, .functionFlag = 0x0C, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_get_com_event_log_response */
- .error = false, .function = 0x0C, .response = true},
+ .errorFlag = false, .functionFlag = 0x0C, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_report_server_id_request */
- .error = false, .function = 0x11, .response = false},
+ .errorFlag = false, .functionFlag = 0x11, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_report_server_id_response */
- .error = false, .function = 0x11, .response = true},
+ .errorFlag = false, .functionFlag = 0x11, .response = true},
{/* plc4c_modbus_read_write_modbus_pdu_read_device_identification_request */
- .error = false, .function = 0x2B, .response = false},
+ .errorFlag = false, .functionFlag = 0x2B, .response = false},
{/* plc4c_modbus_read_write_modbus_pdu_read_device_identification_response */
- .error = false, .function = 0x2B, .response = true}
+ .errorFlag = false, .functionFlag = 0x2B, .response = true}
};
// Function returning the discriminator values for a given type constant.
@@ -124,22 +124,22 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
return NO_MEMORY;
}
- // Discriminator Field (error) (Used as input to a switch field)
- bool error = false;
- _res = plc4c_spi_read_bit(io, (bool*) &error);
+ // Discriminator Field (errorFlag) (Used as input to a switch field)
+ bool errorFlag = false;
+ _res = plc4c_spi_read_bit(io, (bool*) &errorFlag);
if(_res != OK) {
return _res;
}
- // Discriminator Field (function) (Used as input to a switch field)
- unsigned int function = 0;
- _res = plc4c_spi_read_unsigned_byte(io, 7, (uint8_t*) &function);
+ // Discriminator Field (functionFlag) (Used as input to a switch field)
+ unsigned int functionFlag = 0;
+ _res = plc4c_spi_read_unsigned_byte(io, 7, (uint8_t*) &functionFlag);
if(_res != OK) {
return _res;
}
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
- if(error == true) { /* ModbusPDUError */
+ if(errorFlag == true) { /* ModbusPDUError */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_error;
// Simple Field (exceptionCode)
@@ -151,7 +151,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_error_exception_code = exceptionCode;
} else
- if((error == false) && (function == 0x02) && (response == false)) { /* ModbusPDUReadDiscreteInputsRequest */
+ if((errorFlag == false) && (functionFlag == 0x02) && (response == false)) { /* ModbusPDUReadDiscreteInputsRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_request;
// Simple Field (startingAddress)
@@ -173,7 +173,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_discrete_inputs_request_quantity = quantity;
} else
- if((error == false) && (function == 0x02) && (response == true)) { /* ModbusPDUReadDiscreteInputsResponse */
+ if((errorFlag == false) && (functionFlag == 0x02) && (response == true)) { /* ModbusPDUReadDiscreteInputsResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_discrete_inputs_response;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -207,7 +207,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_discrete_inputs_response_value = value;
} else
- if((error == false) && (function == 0x01) && (response == false)) { /* ModbusPDUReadCoilsRequest */
+ if((errorFlag == false) && (functionFlag == 0x01) && (response == false)) { /* ModbusPDUReadCoilsRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_coils_request;
// Simple Field (startingAddress)
@@ -229,7 +229,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_coils_request_quantity = quantity;
} else
- if((error == false) && (function == 0x01) && (response == true)) { /* ModbusPDUReadCoilsResponse */
+ if((errorFlag == false) && (functionFlag == 0x01) && (response == true)) { /* ModbusPDUReadCoilsResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_coils_response;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -263,7 +263,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_coils_response_value = value;
} else
- if((error == false) && (function == 0x05) && (response == false)) { /* ModbusPDUWriteSingleCoilRequest */
+ if((errorFlag == false) && (functionFlag == 0x05) && (response == false)) { /* ModbusPDUWriteSingleCoilRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_single_coil_request;
// Simple Field (address)
@@ -285,7 +285,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_write_single_coil_request_value = value;
} else
- if((error == false) && (function == 0x05) && (response == true)) { /* ModbusPDUWriteSingleCoilResponse */
+ if((errorFlag == false) && (functionFlag == 0x05) && (response == true)) { /* ModbusPDUWriteSingleCoilResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_single_coil_response;
// Simple Field (address)
@@ -307,7 +307,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_write_single_coil_response_value = value;
} else
- if((error == false) && (function == 0x0F) && (response == false)) { /* ModbusPDUWriteMultipleCoilsRequest */
+ if((errorFlag == false) && (functionFlag == 0x0F) && (response == false)) { /* ModbusPDUWriteMultipleCoilsRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_request;
// Simple Field (startingAddress)
@@ -361,7 +361,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_write_multiple_coils_request_value = value;
} else
- if((error == false) && (function == 0x0F) && (response == true)) { /* ModbusPDUWriteMultipleCoilsResponse */
+ if((errorFlag == false) && (functionFlag == 0x0F) && (response == true)) { /* ModbusPDUWriteMultipleCoilsResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_multiple_coils_response;
// Simple Field (startingAddress)
@@ -383,7 +383,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_write_multiple_coils_response_quantity = quantity;
} else
- if((error == false) && (function == 0x04) && (response == false)) { /* ModbusPDUReadInputRegistersRequest */
+ if((errorFlag == false) && (functionFlag == 0x04) && (response == false)) { /* ModbusPDUReadInputRegistersRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_input_registers_request;
// Simple Field (startingAddress)
@@ -405,7 +405,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_input_registers_request_quantity = quantity;
} else
- if((error == false) && (function == 0x04) && (response == true)) { /* ModbusPDUReadInputRegistersResponse */
+ if((errorFlag == false) && (functionFlag == 0x04) && (response == true)) { /* ModbusPDUReadInputRegistersResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_input_registers_response;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -439,7 +439,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_input_registers_response_value = value;
} else
- if((error == false) && (function == 0x03) && (response == false)) { /* ModbusPDUReadHoldingRegistersRequest */
+ if((errorFlag == false) && (functionFlag == 0x03) && (response == false)) { /* ModbusPDUReadHoldingRegistersRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_holding_registers_request;
// Simple Field (startingAddress)
@@ -461,7 +461,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_holding_registers_request_quantity = quantity;
} else
- if((error == false) && (function == 0x03) && (response == true)) { /* ModbusPDUReadHoldingRegistersResponse */
+ if((errorFlag == false) && (functionFlag == 0x03) && (response == true)) { /* ModbusPDUReadHoldingRegistersResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_holding_registers_response;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -495,7 +495,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_holding_registers_response_value = value;
} else
- if((error == false) && (function == 0x06) && (response == false)) { /* ModbusPDUWriteSingleRegisterRequest */
+ if((errorFlag == false) && (functionFlag == 0x06) && (response == false)) { /* ModbusPDUWriteSingleRegisterRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_single_register_request;
// Simple Field (address)
@@ -517,7 +517,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_write_single_register_request_value = value;
} else
- if((error == false) && (function == 0x06) && (response == true)) { /* ModbusPDUWriteSingleRegisterResponse */
+ if((errorFlag == false) && (functionFlag == 0x06) && (response == true)) { /* ModbusPDUWriteSingleRegisterResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_single_register_response;
// Simple Field (address)
@@ -539,7 +539,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_write_single_register_response_value = value;
} else
- if((error == false) && (function == 0x10) && (response == false)) { /* ModbusPDUWriteMultipleHoldingRegistersRequest */
+ if((errorFlag == false) && (functionFlag == 0x10) && (response == false)) { /* ModbusPDUWriteMultipleHoldingRegistersRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_request;
// Simple Field (startingAddress)
@@ -593,7 +593,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_write_multiple_holding_registers_request_value = value;
} else
- if((error == false) && (function == 0x10) && (response == true)) { /* ModbusPDUWriteMultipleHoldingRegistersResponse */
+ if((errorFlag == false) && (functionFlag == 0x10) && (response == true)) { /* ModbusPDUWriteMultipleHoldingRegistersResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_multiple_holding_registers_response;
// Simple Field (startingAddress)
@@ -615,7 +615,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_write_multiple_holding_registers_response_quantity = quantity;
} else
- if((error == false) && (function == 0x17) && (response == false)) { /* ModbusPDUReadWriteMultipleHoldingRegistersRequest */
+ if((errorFlag == false) && (functionFlag == 0x17) && (response == false)) { /* ModbusPDUReadWriteMultipleHoldingRegistersRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_request;
// Simple Field (readStartingAddress)
@@ -689,7 +689,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_write_multiple_holding_registers_request_value = value;
} else
- if((error == false) && (function == 0x17) && (response == true)) { /* ModbusPDUReadWriteMultipleHoldingRegistersResponse */
+ if((errorFlag == false) && (functionFlag == 0x17) && (response == true)) { /* ModbusPDUReadWriteMultipleHoldingRegistersResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_write_multiple_holding_registers_response;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -723,7 +723,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_write_multiple_holding_registers_response_value = value;
} else
- if((error == false) && (function == 0x16) && (response == false)) { /* ModbusPDUMaskWriteHoldingRegisterRequest */
+ if((errorFlag == false) && (functionFlag == 0x16) && (response == false)) { /* ModbusPDUMaskWriteHoldingRegisterRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_request;
// Simple Field (referenceAddress)
@@ -755,7 +755,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_mask_write_holding_register_request_or_mask = orMask;
} else
- if((error == false) && (function == 0x16) && (response == true)) { /* ModbusPDUMaskWriteHoldingRegisterResponse */
+ if((errorFlag == false) && (functionFlag == 0x16) && (response == true)) { /* ModbusPDUMaskWriteHoldingRegisterResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_mask_write_holding_register_response;
// Simple Field (referenceAddress)
@@ -787,7 +787,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_mask_write_holding_register_response_or_mask = orMask;
} else
- if((error == false) && (function == 0x18) && (response == false)) { /* ModbusPDUReadFifoQueueRequest */
+ if((errorFlag == false) && (functionFlag == 0x18) && (response == false)) { /* ModbusPDUReadFifoQueueRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_request;
// Simple Field (fifoPointerAddress)
@@ -799,7 +799,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_fifo_queue_request_fifo_pointer_address = fifoPointerAddress;
} else
- if((error == false) && (function == 0x18) && (response == true)) { /* ModbusPDUReadFifoQueueResponse */
+ if((errorFlag == false) && (functionFlag == 0x18) && (response == true)) { /* ModbusPDUReadFifoQueueResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_fifo_queue_response;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -842,7 +842,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_fifo_queue_response_fifo_value = fifoValue;
} else
- if((error == false) && (function == 0x14) && (response == false)) { /* ModbusPDUReadFileRecordRequest */
+ if((errorFlag == false) && (functionFlag == 0x14) && (response == false)) { /* ModbusPDUReadFileRecordRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_file_record_request;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -876,7 +876,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_file_record_request_items = items;
} else
- if((error == false) && (function == 0x14) && (response == true)) { /* ModbusPDUReadFileRecordResponse */
+ if((errorFlag == false) && (functionFlag == 0x14) && (response == true)) { /* ModbusPDUReadFileRecordResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_file_record_response;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -910,7 +910,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_file_record_response_items = items;
} else
- if((error == false) && (function == 0x15) && (response == false)) { /* ModbusPDUWriteFileRecordRequest */
+ if((errorFlag == false) && (functionFlag == 0x15) && (response == false)) { /* ModbusPDUWriteFileRecordRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_file_record_request;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -944,7 +944,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_write_file_record_request_items = items;
} else
- if((error == false) && (function == 0x15) && (response == true)) { /* ModbusPDUWriteFileRecordResponse */
+ if((errorFlag == false) && (functionFlag == 0x15) && (response == true)) { /* ModbusPDUWriteFileRecordResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_write_file_record_response;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -978,10 +978,10 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_write_file_record_response_items = items;
} else
- if((error == false) && (function == 0x07) && (response == false)) { /* ModbusPDUReadExceptionStatusRequest */
+ if((errorFlag == false) && (functionFlag == 0x07) && (response == false)) { /* ModbusPDUReadExceptionStatusRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_exception_status_request;
} else
- if((error == false) && (function == 0x07) && (response == true)) { /* ModbusPDUReadExceptionStatusResponse */
+ if((errorFlag == false) && (functionFlag == 0x07) && (response == true)) { /* ModbusPDUReadExceptionStatusResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_exception_status_response;
// Simple Field (value)
@@ -993,7 +993,7 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_read_exception_status_response_value = value;
} else
- if((error == false) && (function == 0x08) && (response == false)) { /* ModbusPDUDiagnosticRequest */
+ if((errorFlag == false) && (functionFlag == 0x08) && (response == false)) { /* ModbusPDUDiagnosticRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_diagnostic_request;
// Simple Field (status)
@@ -1015,10 +1015,10 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_diagnostic_request_event_count = eventCount;
} else
- if((error == false) && (function == 0x0C) && (response == false)) { /* ModbusPDUGetComEventLogRequest */
+ if((errorFlag == false) && (functionFlag == 0x0C) && (response == false)) { /* ModbusPDUGetComEventLogRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_get_com_event_log_request;
} else
- if((error == false) && (function == 0x0C) && (response == true)) { /* ModbusPDUGetComEventLogResponse */
+ if((errorFlag == false) && (functionFlag == 0x0C) && (response == true)) { /* ModbusPDUGetComEventLogResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_get_com_event_log_response;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -1082,10 +1082,10 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_get_com_event_log_response_events = events;
} else
- if((error == false) && (function == 0x11) && (response == false)) { /* ModbusPDUReportServerIdRequest */
+ if((errorFlag == false) && (functionFlag == 0x11) && (response == false)) { /* ModbusPDUReportServerIdRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_report_server_id_request;
} else
- if((error == false) && (function == 0x11) && (response == true)) { /* ModbusPDUReportServerIdResponse */
+ if((errorFlag == false) && (functionFlag == 0x11) && (response == true)) { /* ModbusPDUReportServerIdResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_report_server_id_response;
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -1119,10 +1119,10 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
(*_message)->modbus_pdu_report_server_id_response_value = value;
} else
- if((error == false) && (function == 0x2B) && (response == false)) { /* ModbusPDUReadDeviceIdentificationRequest */
+ if((errorFlag == false) && (functionFlag == 0x2B) && (response == false)) { /* ModbusPDUReadDeviceIdentificationRequest */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_device_identification_request;
} else
- if((error == false) && (function == 0x2B) && (response == true)) { /* ModbusPDUReadDeviceIdentificationResponse */
+ if((errorFlag == false) && (functionFlag == 0x2B) && (response == true)) { /* ModbusPDUReadDeviceIdentificationResponse */
(*_message)->_type = plc4c_modbus_read_write_modbus_pdu_type_plc4c_modbus_read_write_modbus_pdu_read_device_identification_response;
}
@@ -1132,11 +1132,11 @@ plc4c_return_code plc4c_modbus_read_write_modbus_pdu_parse(plc4c_spi_read_buffer
plc4c_return_code plc4c_modbus_read_write_modbus_pdu_serialize(plc4c_spi_write_buffer* io, plc4c_modbus_read_write_modbus_pdu* _message) {
plc4c_return_code _res = OK;
- // Discriminator Field (error)
- plc4c_spi_write_bit(io, plc4c_modbus_read_write_modbus_pdu_get_discriminator(_message->_type).error);
+ // Discriminator Field (errorFlag)
+ plc4c_spi_write_bit(io, plc4c_modbus_read_write_modbus_pdu_get_discriminator(_message->_type).errorFlag);
- // Discriminator Field (function)
- plc4c_spi_write_unsigned_byte(io, 7, plc4c_modbus_read_write_modbus_pdu_get_discriminator(_message->_type).function);
+ // Discriminator Field (functionFlag)
+ plc4c_spi_write_unsigned_byte(io, 7, plc4c_modbus_read_write_modbus_pdu_get_discriminator(_message->_type).functionFlag);
// Switch Field (Depending of the current type, serialize the sub-type elements)
switch(_message->_type) {
@@ -1806,10 +1806,10 @@ uint16_t plc4c_modbus_read_write_modbus_pdu_length_in_bytes(plc4c_modbus_read_wr
uint16_t plc4c_modbus_read_write_modbus_pdu_length_in_bits(plc4c_modbus_read_write_modbus_pdu* _message) {
uint16_t lengthInBits = 0;
- // Discriminator Field (error)
+ // Discriminator Field (errorFlag)
lengthInBits += 1;
- // Discriminator Field (function)
+ // Discriminator Field (functionFlag)
lengthInBits += 7;
// Depending of the current type, add the length of sub-type elements ...
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_address.c b/sandbox/plc4c/generated-sources/s7/src/s7_address.c
index 99b5fef..0f239fb 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_address.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_address.c
@@ -97,7 +97,7 @@ plc4c_return_code plc4c_s7_read_write_s7_address_parse(plc4c_spi_read_buffer* io
// Enum field (area)
plc4c_s7_read_write_memory_area area = plc4c_s7_read_write_memory_area_null();
- _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &area);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &area);
if(_res != OK) {
return _res;
}
@@ -171,7 +171,7 @@ plc4c_return_code plc4c_s7_read_write_s7_address_serialize(plc4c_spi_write_buffe
}
// Enum field (area)
- _res = plc4c_spi_write_signed_byte(io, 8, _message->s7_address_any_area);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->s7_address_any_area);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c b/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c
index 830f547..2958660 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c
@@ -64,7 +64,7 @@ plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_parse(plc4c_spi_
// Enum field (returnCode)
plc4c_s7_read_write_data_transport_error_code returnCode = plc4c_s7_read_write_data_transport_error_code_null();
- _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &returnCode);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &returnCode);
if(_res != OK) {
return _res;
}
@@ -72,7 +72,7 @@ plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_parse(plc4c_spi_
// Enum field (transportSize)
plc4c_s7_read_write_data_transport_size transportSize = plc4c_s7_read_write_data_transport_size_null();
- _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &transportSize);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &transportSize);
if(_res != OK) {
return _res;
}
@@ -160,13 +160,13 @@ plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_serialize(plc4c_
plc4c_return_code _res = OK;
// Enum field (returnCode)
- _res = plc4c_spi_write_signed_byte(io, 8, _message->return_code);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->return_code);
if(_res != OK) {
return _res;
}
// Enum field (transportSize)
- _res = plc4c_spi_write_signed_byte(io, 8, _message->transport_size);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->transport_size);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_data_item.c b/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_data_item.c
index aa06042..4fc5901 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_data_item.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_data_item.c
@@ -36,7 +36,7 @@ plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_parse(plc4c_spi_r
// Enum field (returnCode)
plc4c_s7_read_write_data_transport_error_code returnCode = plc4c_s7_read_write_data_transport_error_code_null();
- _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &returnCode);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &returnCode);
if(_res != OK) {
return _res;
}
@@ -44,7 +44,7 @@ plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_parse(plc4c_spi_r
// Enum field (transportSize)
plc4c_s7_read_write_data_transport_size transportSize = plc4c_s7_read_write_data_transport_size_null();
- _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &transportSize);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &transportSize);
if(_res != OK) {
return _res;
}
@@ -98,13 +98,13 @@ plc4c_return_code plc4c_s7_read_write_s7_var_payload_data_item_serialize(plc4c_s
plc4c_return_code _res = OK;
// Enum field (returnCode)
- _res = plc4c_spi_write_signed_byte(io, 8, _message->return_code);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->return_code);
if(_res != OK) {
return _res;
}
// Enum field (transportSize)
- _res = plc4c_spi_write_signed_byte(io, 8, _message->transport_size);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->transport_size);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_status_item.c b/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_status_item.c
index 94e9b04..eeb3ba1 100644
--- a/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_status_item.c
+++ b/sandbox/plc4c/generated-sources/s7/src/s7_var_payload_status_item.c
@@ -36,7 +36,7 @@ plc4c_return_code plc4c_s7_read_write_s7_var_payload_status_item_parse(plc4c_spi
// Enum field (returnCode)
plc4c_s7_read_write_data_transport_error_code returnCode = plc4c_s7_read_write_data_transport_error_code_null();
- _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &returnCode);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &returnCode);
if(_res != OK) {
return _res;
}
@@ -49,7 +49,7 @@ plc4c_return_code plc4c_s7_read_write_s7_var_payload_status_item_serialize(plc4c
plc4c_return_code _res = OK;
// Enum field (returnCode)
- _res = plc4c_spi_write_signed_byte(io, 8, _message->return_code);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->return_code);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4c/generated-sources/s7/src/szl_id.c b/sandbox/plc4c/generated-sources/s7/src/szl_id.c
index 21a77ad..ba7d4f5 100644
--- a/sandbox/plc4c/generated-sources/s7/src/szl_id.c
+++ b/sandbox/plc4c/generated-sources/s7/src/szl_id.c
@@ -36,7 +36,7 @@ plc4c_return_code plc4c_s7_read_write_szl_id_parse(plc4c_spi_read_buffer* io, pl
// Enum field (typeClass)
plc4c_s7_read_write_szl_module_type_class typeClass = plc4c_s7_read_write_szl_module_type_class_null();
- _res = plc4c_spi_read_signed_byte(io, 4, (int8_t*) &typeClass);
+ _res = plc4c_spi_read_unsigned_byte(io, 4, (uint8_t*) &typeClass);
if(_res != OK) {
return _res;
}
@@ -52,7 +52,7 @@ plc4c_return_code plc4c_s7_read_write_szl_id_parse(plc4c_spi_read_buffer* io, pl
// Enum field (sublistList)
plc4c_s7_read_write_szl_sublist sublistList = plc4c_s7_read_write_szl_sublist_null();
- _res = plc4c_spi_read_signed_byte(io, 8, (int8_t*) &sublistList);
+ _res = plc4c_spi_read_unsigned_byte(io, 8, (uint8_t*) &sublistList);
if(_res != OK) {
return _res;
}
@@ -65,7 +65,7 @@ plc4c_return_code plc4c_s7_read_write_szl_id_serialize(plc4c_spi_write_buffer* i
plc4c_return_code _res = OK;
// Enum field (typeClass)
- _res = plc4c_spi_write_signed_byte(io, 4, _message->type_class);
+ _res = plc4c_spi_write_unsigned_byte(io, 4, _message->type_class);
if(_res != OK) {
return _res;
}
@@ -77,7 +77,7 @@ plc4c_return_code plc4c_s7_read_write_szl_id_serialize(plc4c_spi_write_buffer* i
}
// Enum field (sublistList)
- _res = plc4c_spi_write_signed_byte(io, 8, _message->sublist_list);
+ _res = plc4c_spi_write_unsigned_byte(io, 8, _message->sublist_list);
if(_res != OK) {
return _res;
}
diff --git a/sandbox/plc4go/cmd/modbus/modbus.go b/sandbox/plc4go/cmd/main/drivers/modbus.go
similarity index 97%
copy from sandbox/plc4go/cmd/modbus/modbus.go
copy to sandbox/plc4go/cmd/main/drivers/modbus.go
index 1b1982a..464e221 100644
--- a/sandbox/plc4go/cmd/modbus/modbus.go
+++ b/sandbox/plc4go/cmd/main/drivers/modbus.go
@@ -13,7 +13,7 @@
// specific language governing permissions and limitations
// under the License.
//
-package main
+package drivers
import (
"encoding/hex"
@@ -21,7 +21,7 @@ import (
"plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
)
-func main() {
+func Modbus() {
request, err := hex.DecodeString("000a00000006010300000004")
if err != nil {
// Output an error ...
diff --git a/sandbox/plc4go/cmd/modbus/modbus.go b/sandbox/plc4go/cmd/main/drivers/s7.go
similarity index 83%
copy from sandbox/plc4go/cmd/modbus/modbus.go
copy to sandbox/plc4go/cmd/main/drivers/s7.go
index 1b1982a..7f1ada5 100644
--- a/sandbox/plc4go/cmd/modbus/modbus.go
+++ b/sandbox/plc4go/cmd/main/drivers/s7.go
@@ -13,21 +13,21 @@
// specific language governing permissions and limitations
// under the License.
//
-package main
+package drivers
-import (
- "encoding/hex"
- "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/modbus/readwrite/model"
+/*import (
+ "encoding/hex"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/s7/readwrite/model"
"plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
)
-func main() {
+func S7() {
request, err := hex.DecodeString("000a00000006010300000004")
if err != nil {
// Output an error ...
}
rb := spi.ReadBufferNew(request)
- adu, err := model.ModbusTcpADUParse(*rb, false)
+ adu, err := model.TPKTPacketParse(*rb)
if err != nil {
// Output an error ...
}
@@ -35,4 +35,4 @@ func main() {
// Output success ...
}
-}
+}*/
diff --git a/sandbox/plc4go/cmd/modbus/modbus.go b/sandbox/plc4go/cmd/main/main.go
similarity index 61%
copy from sandbox/plc4go/cmd/modbus/modbus.go
copy to sandbox/plc4go/cmd/main/main.go
index 1b1982a..40d865a 100644
--- a/sandbox/plc4go/cmd/modbus/modbus.go
+++ b/sandbox/plc4go/cmd/main/main.go
@@ -16,23 +16,10 @@
package main
import (
- "encoding/hex"
- "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/modbus/readwrite/model"
- "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/cmd/main/drivers"
)
func main() {
- request, err := hex.DecodeString("000a00000006010300000004")
- if err != nil {
- // Output an error ...
- }
- rb := spi.ReadBufferNew(request)
- adu, err := model.ModbusTcpADUParse(*rb, false)
- if err != nil {
- // Output an error ...
- }
- if adu != nil {
- // Output success ...
- }
-
+ drivers.Modbus()
+ //drivers.S7()
}
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusConstants.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusConstants.go
index d225bed..72270f9 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusConstants.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusConstants.go
@@ -25,7 +25,7 @@ import (
)
// Constant values.
-const MODBUSTCPDEFAULTPORT uint16 = 502
+const ModbusConstants_MODBUSTCPDEFAULTPORT uint16 = 502
// The data-structure of this message
type ModbusConstants struct {
@@ -58,8 +58,8 @@ func ModbusConstantsParse(io spi.ReadBuffer) (spi.Message, error) {
// Const Field (modbusTcpDefaultPort)
var modbusTcpDefaultPort uint16 = io.ReadUint16(16)
- if modbusTcpDefaultPort != MODBUSTCPDEFAULTPORT {
- return nil, errors.New("Expected constant value " + strconv.Itoa(int(MODBUSTCPDEFAULTPORT)) + " but got " + strconv.Itoa(int(modbusTcpDefaultPort)))
+ if modbusTcpDefaultPort != ModbusConstants_MODBUSTCPDEFAULTPORT {
+ return nil, errors.New("Expected constant value " + strconv.Itoa(int(ModbusConstants_MODBUSTCPDEFAULTPORT)) + " but got " + strconv.Itoa(int(modbusTcpDefaultPort)))
}
// Create the instance
@@ -68,7 +68,7 @@ func ModbusConstantsParse(io spi.ReadBuffer) (spi.Message, error) {
func (m ModbusConstants) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusConstants); ok {
// Const Field (modbusTcpDefaultPort)
io.WriteUint16(16, 502)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go
index 8816890..c40260f 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go
@@ -23,34 +23,34 @@ import "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
type ModbusDataType uint8
const (
- NULL ModbusDataType = 00
- BOOL ModbusDataType = 01
- BYTE ModbusDataType = 10
- WORD ModbusDataType = 11
- DWORD ModbusDataType = 12
- LWORD ModbusDataType = 13
- SINT ModbusDataType = 20
- INT ModbusDataType = 21
- DINT ModbusDataType = 22
- LINT ModbusDataType = 23
- USINT ModbusDataType = 24
- UINT ModbusDataType = 25
- UDINT ModbusDataType = 26
- ULINT ModbusDataType = 27
- REAL ModbusDataType = 30
- LREAL ModbusDataType = 31
- TIME ModbusDataType = 40
- LTIME ModbusDataType = 41
- DATE ModbusDataType = 50
- LDATE ModbusDataType = 51
- TIME_OF_DAY ModbusDataType = 60
- LTIME_OF_DAY ModbusDataType = 61
- DATE_AND_TIME ModbusDataType = 70
- LDATE_AND_TIME ModbusDataType = 71
- CHAR ModbusDataType = 80
- WCHAR ModbusDataType = 81
- STRING ModbusDataType = 82
- WSTRING ModbusDataType = 83
+ ModbusDataType_NULL ModbusDataType = 00
+ ModbusDataType_BOOL ModbusDataType = 01
+ ModbusDataType_BYTE ModbusDataType = 10
+ ModbusDataType_WORD ModbusDataType = 11
+ ModbusDataType_DWORD ModbusDataType = 12
+ ModbusDataType_LWORD ModbusDataType = 13
+ ModbusDataType_SINT ModbusDataType = 20
+ ModbusDataType_INT ModbusDataType = 21
+ ModbusDataType_DINT ModbusDataType = 22
+ ModbusDataType_LINT ModbusDataType = 23
+ ModbusDataType_USINT ModbusDataType = 24
+ ModbusDataType_UINT ModbusDataType = 25
+ ModbusDataType_UDINT ModbusDataType = 26
+ ModbusDataType_ULINT ModbusDataType = 27
+ ModbusDataType_REAL ModbusDataType = 30
+ ModbusDataType_LREAL ModbusDataType = 31
+ ModbusDataType_TIME ModbusDataType = 40
+ ModbusDataType_LTIME ModbusDataType = 41
+ ModbusDataType_DATE ModbusDataType = 50
+ ModbusDataType_LDATE ModbusDataType = 51
+ ModbusDataType_TIME_OF_DAY ModbusDataType = 60
+ ModbusDataType_LTIME_OF_DAY ModbusDataType = 61
+ ModbusDataType_DATE_AND_TIME ModbusDataType = 70
+ ModbusDataType_LDATE_AND_TIME ModbusDataType = 71
+ ModbusDataType_CHAR ModbusDataType = 80
+ ModbusDataType_WCHAR ModbusDataType = 81
+ ModbusDataType_STRING ModbusDataType = 82
+ ModbusDataType_WSTRING ModbusDataType = 83
)
func (e ModbusDataType) GetDataTypeSize() uint8 {
@@ -174,8 +174,9 @@ func (e ModbusDataType) GetDataTypeSize() uint8 {
}
}
-func (e *ModbusDataType) Parse(io spi.ReadBuffer) {
+func ModbusDataTypeParse(io spi.ReadBuffer) (ModbusDataType, error) {
// TODO: Implement ...
+ return 0, nil
}
func (e ModbusDataType) Serialize(io spi.WriteBuffer) {
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUDiagnosticRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUDiagnosticRequest.go
index a0bce64..3ae6e42 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUDiagnosticRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUDiagnosticRequest.go
@@ -49,7 +49,7 @@ func (m ModbusPDUDiagnosticRequest) Response() bool {
}
func (m ModbusPDUDiagnosticRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUDiagnosticRequest(status uint16, eventCount uint16) ModbusPDUInitializer {
@@ -86,7 +86,7 @@ func ModbusPDUDiagnosticRequestParse(io spi.ReadBuffer) (ModbusPDUInitializer, e
func (m ModbusPDUDiagnosticRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUDiagnosticRequest); ok {
// Simple Field (status)
var status uint16 = m.status
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go
index c4cd251..901953c 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go
@@ -48,7 +48,7 @@ func (m ModbusPDUError) Response() bool {
}
func (m ModbusPDUError) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUError(exceptionCode uint8) ModbusPDUInitializer {
@@ -79,7 +79,7 @@ func ModbusPDUErrorParse(io spi.ReadBuffer) (ModbusPDUInitializer, error) {
func (m ModbusPDUError) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUError); ok {
// Simple Field (exceptionCode)
var exceptionCode uint8 = m.exceptionCode
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUGetComEventLogRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUGetComEventLogRequest.go
index 6cb08a6..a94346f 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUGetComEventLogRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUGetComEventLogRequest.go
@@ -47,7 +47,7 @@ func (m ModbusPDUGetComEventLogRequest) Response() bool {
}
func (m ModbusPDUGetComEventLogRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUGetComEventLogRequest() ModbusPDUInitializer {
@@ -72,7 +72,7 @@ func ModbusPDUGetComEventLogRequestParse(io spi.ReadBuffer) (ModbusPDUInitialize
func (m ModbusPDUGetComEventLogRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUGetComEventLogRequest); ok {
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUGetComEventLogResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUGetComEventLogResponse.go
index a7cd498..115eed6 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUGetComEventLogResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUGetComEventLogResponse.go
@@ -51,7 +51,7 @@ func (m ModbusPDUGetComEventLogResponse) Response() bool {
}
func (m ModbusPDUGetComEventLogResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUGetComEventLogResponse(status uint16, eventCount uint16, messageCount uint16, events []int8) ModbusPDUInitializer {
@@ -106,7 +106,7 @@ func ModbusPDUGetComEventLogResponseParse(io spi.ReadBuffer) (ModbusPDUInitializ
events := make([]int8, (byteCount)-(6))
for curItem := uint16(0); curItem < uint16((byteCount)-(6)); curItem++ {
- events[curItem] = io.ReadInt8(8)
+ events = append(events, io.ReadInt8(8))
}
}
@@ -116,10 +116,10 @@ func ModbusPDUGetComEventLogResponseParse(io spi.ReadBuffer) (ModbusPDUInitializ
func (m ModbusPDUGetComEventLogResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUGetComEventLogResponse); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = ((uint8(len(m.events))) + (6))
+ byteCount := uint8((uint8(len(m.events))) + (6))
io.WriteUint8(8, (byteCount))
// Simple Field (status)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUMaskWriteHoldingRegisterRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUMaskWriteHoldingRegisterRequest.go
index d30d57f..ae96dfe 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUMaskWriteHoldingRegisterRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUMaskWriteHoldingRegisterRequest.go
@@ -50,7 +50,7 @@ func (m ModbusPDUMaskWriteHoldingRegisterRequest) Response() bool {
}
func (m ModbusPDUMaskWriteHoldingRegisterRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUMaskWriteHoldingRegisterRequest(referenceAddress uint16, andMask uint16, orMask uint16) ModbusPDUInitializer {
@@ -93,7 +93,7 @@ func ModbusPDUMaskWriteHoldingRegisterRequestParse(io spi.ReadBuffer) (ModbusPDU
func (m ModbusPDUMaskWriteHoldingRegisterRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUMaskWriteHoldingRegisterRequest); ok {
// Simple Field (referenceAddress)
var referenceAddress uint16 = m.referenceAddress
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUMaskWriteHoldingRegisterResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUMaskWriteHoldingRegisterResponse.go
index 2381b41..15267ac 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUMaskWriteHoldingRegisterResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUMaskWriteHoldingRegisterResponse.go
@@ -50,7 +50,7 @@ func (m ModbusPDUMaskWriteHoldingRegisterResponse) Response() bool {
}
func (m ModbusPDUMaskWriteHoldingRegisterResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUMaskWriteHoldingRegisterResponse(referenceAddress uint16, andMask uint16, orMask uint16) ModbusPDUInitializer {
@@ -93,7 +93,7 @@ func ModbusPDUMaskWriteHoldingRegisterResponseParse(io spi.ReadBuffer) (ModbusPD
func (m ModbusPDUMaskWriteHoldingRegisterResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUMaskWriteHoldingRegisterResponse); ok {
// Simple Field (referenceAddress)
var referenceAddress uint16 = m.referenceAddress
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadCoilsRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadCoilsRequest.go
index 6177331..a40fb5a 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadCoilsRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadCoilsRequest.go
@@ -49,7 +49,7 @@ func (m ModbusPDUReadCoilsRequest) Response() bool {
}
func (m ModbusPDUReadCoilsRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadCoilsRequest(startingAddress uint16, quantity uint16) ModbusPDUInitializer {
@@ -86,7 +86,7 @@ func ModbusPDUReadCoilsRequestParse(io spi.ReadBuffer) (ModbusPDUInitializer, er
func (m ModbusPDUReadCoilsRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadCoilsRequest); ok {
// Simple Field (startingAddress)
var startingAddress uint16 = m.startingAddress
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadCoilsResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadCoilsResponse.go
index 9df93c6..3f634c5 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadCoilsResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadCoilsResponse.go
@@ -48,7 +48,7 @@ func (m ModbusPDUReadCoilsResponse) Response() bool {
}
func (m ModbusPDUReadCoilsResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadCoilsResponse(value []int8) ModbusPDUInitializer {
@@ -85,7 +85,7 @@ func ModbusPDUReadCoilsResponseParse(io spi.ReadBuffer) (ModbusPDUInitializer, e
value := make([]int8, byteCount)
for curItem := uint16(0); curItem < uint16(byteCount); curItem++ {
- value[curItem] = io.ReadInt8(8)
+ value = append(value, io.ReadInt8(8))
}
}
@@ -95,10 +95,10 @@ func ModbusPDUReadCoilsResponseParse(io spi.ReadBuffer) (ModbusPDUInitializer, e
func (m ModbusPDUReadCoilsResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadCoilsResponse); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(len(m.value)))
+ byteCount := uint8(uint8(len(m.value)))
io.WriteUint8(8, (byteCount))
// Array Field (value)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationRequest.go
index 9038e1d..e6571d2 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationRequest.go
@@ -47,7 +47,7 @@ func (m ModbusPDUReadDeviceIdentificationRequest) Response() bool {
}
func (m ModbusPDUReadDeviceIdentificationRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadDeviceIdentificationRequest() ModbusPDUInitializer {
@@ -72,7 +72,7 @@ func ModbusPDUReadDeviceIdentificationRequestParse(io spi.ReadBuffer) (ModbusPDU
func (m ModbusPDUReadDeviceIdentificationRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadDeviceIdentificationRequest); ok {
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go
index e26ede6..ee20d3f 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go
@@ -47,7 +47,7 @@ func (m ModbusPDUReadDeviceIdentificationResponse) Response() bool {
}
func (m ModbusPDUReadDeviceIdentificationResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadDeviceIdentificationResponse() ModbusPDUInitializer {
@@ -72,7 +72,7 @@ func ModbusPDUReadDeviceIdentificationResponseParse(io spi.ReadBuffer) (ModbusPD
func (m ModbusPDUReadDeviceIdentificationResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadDeviceIdentificationResponse); ok {
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDiscreteInputsRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDiscreteInputsRequest.go
index 4e702f4..a8da313 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDiscreteInputsRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDiscreteInputsRequest.go
@@ -49,7 +49,7 @@ func (m ModbusPDUReadDiscreteInputsRequest) Response() bool {
}
func (m ModbusPDUReadDiscreteInputsRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadDiscreteInputsRequest(startingAddress uint16, quantity uint16) ModbusPDUInitializer {
@@ -86,7 +86,7 @@ func ModbusPDUReadDiscreteInputsRequestParse(io spi.ReadBuffer) (ModbusPDUInitia
func (m ModbusPDUReadDiscreteInputsRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadDiscreteInputsRequest); ok {
// Simple Field (startingAddress)
var startingAddress uint16 = m.startingAddress
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDiscreteInputsResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDiscreteInputsResponse.go
index 229732f..16ea3cf 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDiscreteInputsResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadDiscreteInputsResponse.go
@@ -48,7 +48,7 @@ func (m ModbusPDUReadDiscreteInputsResponse) Response() bool {
}
func (m ModbusPDUReadDiscreteInputsResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadDiscreteInputsResponse(value []int8) ModbusPDUInitializer {
@@ -85,7 +85,7 @@ func ModbusPDUReadDiscreteInputsResponseParse(io spi.ReadBuffer) (ModbusPDUIniti
value := make([]int8, byteCount)
for curItem := uint16(0); curItem < uint16(byteCount); curItem++ {
- value[curItem] = io.ReadInt8(8)
+ value = append(value, io.ReadInt8(8))
}
}
@@ -95,10 +95,10 @@ func ModbusPDUReadDiscreteInputsResponseParse(io spi.ReadBuffer) (ModbusPDUIniti
func (m ModbusPDUReadDiscreteInputsResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadDiscreteInputsResponse); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(len(m.value)))
+ byteCount := uint8(uint8(len(m.value)))
io.WriteUint8(8, (byteCount))
// Array Field (value)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadExceptionStatusRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadExceptionStatusRequest.go
index 1c0ea2b..ffa6b3b 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadExceptionStatusRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadExceptionStatusRequest.go
@@ -47,7 +47,7 @@ func (m ModbusPDUReadExceptionStatusRequest) Response() bool {
}
func (m ModbusPDUReadExceptionStatusRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadExceptionStatusRequest() ModbusPDUInitializer {
@@ -72,7 +72,7 @@ func ModbusPDUReadExceptionStatusRequestParse(io spi.ReadBuffer) (ModbusPDUIniti
func (m ModbusPDUReadExceptionStatusRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadExceptionStatusRequest); ok {
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadExceptionStatusResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadExceptionStatusResponse.go
index ace466c..8188e64 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadExceptionStatusResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadExceptionStatusResponse.go
@@ -48,7 +48,7 @@ func (m ModbusPDUReadExceptionStatusResponse) Response() bool {
}
func (m ModbusPDUReadExceptionStatusResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadExceptionStatusResponse(value uint8) ModbusPDUInitializer {
@@ -79,7 +79,7 @@ func ModbusPDUReadExceptionStatusResponseParse(io spi.ReadBuffer) (ModbusPDUInit
func (m ModbusPDUReadExceptionStatusResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadExceptionStatusResponse); ok {
// Simple Field (value)
var value uint8 = m.value
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFifoQueueRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFifoQueueRequest.go
index 079e66b..81a8d13 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFifoQueueRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFifoQueueRequest.go
@@ -48,7 +48,7 @@ func (m ModbusPDUReadFifoQueueRequest) Response() bool {
}
func (m ModbusPDUReadFifoQueueRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadFifoQueueRequest(fifoPointerAddress uint16) ModbusPDUInitializer {
@@ -79,7 +79,7 @@ func ModbusPDUReadFifoQueueRequestParse(io spi.ReadBuffer) (ModbusPDUInitializer
func (m ModbusPDUReadFifoQueueRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadFifoQueueRequest); ok {
// Simple Field (fifoPointerAddress)
var fifoPointerAddress uint16 = m.fifoPointerAddress
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go
index 111f656..71e8515 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go
@@ -48,7 +48,7 @@ func (m ModbusPDUReadFifoQueueResponse) Response() bool {
}
func (m ModbusPDUReadFifoQueueResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadFifoQueueResponse(fifoValue []uint16) ModbusPDUInitializer {
@@ -91,7 +91,7 @@ func ModbusPDUReadFifoQueueResponseParse(io spi.ReadBuffer) (ModbusPDUInitialize
fifoValue := make([]uint16, fifoCount)
for curItem := uint16(0); curItem < uint16(fifoCount); curItem++ {
- fifoValue[curItem] = io.ReadUint16(16)
+ fifoValue = append(fifoValue, io.ReadUint16(16))
}
}
@@ -101,14 +101,14 @@ func ModbusPDUReadFifoQueueResponseParse(io spi.ReadBuffer) (ModbusPDUInitialize
func (m ModbusPDUReadFifoQueueResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadFifoQueueResponse); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint16 = (((uint16(len(m.fifoValue))) * (2)) + (2))
+ byteCount := uint16(((uint16(len(m.fifoValue))) * (2)) + (2))
io.WriteUint16(16, (byteCount))
// Implicit Field (fifoCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var fifoCount uint16 = (((uint16(len(m.fifoValue))) * (2)) / (2))
+ fifoCount := uint16(((uint16(len(m.fifoValue))) * (2)) / (2))
io.WriteUint16(16, (fifoCount))
// Array Field (fifoValue)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordRequest.go
index 3e6ae9a..f0c16ca 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordRequest.go
@@ -50,7 +50,7 @@ func (m ModbusPDUReadFileRecordRequest) Response() bool {
}
func (m ModbusPDUReadFileRecordRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadFileRecordRequest(items []ModbusPDUReadFileRecordRequestItem) ModbusPDUInitializer {
@@ -113,10 +113,10 @@ func (m ModbusPDUReadFileRecordRequest) Serialize(io spi.WriteBuffer) {
return sizeInBytes
}
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadFileRecordRequest); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(itemsArraySizeInBytes(m.items)))
+ byteCount := uint8(uint8(itemsArraySizeInBytes(m.items)))
io.WriteUint8(8, (byteCount))
// Array Field (items)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordRequestItem.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordRequestItem.go
index de361cf..77f7fa6 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordRequestItem.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordRequestItem.go
@@ -82,7 +82,7 @@ func ModbusPDUReadFileRecordRequestItemParse(io spi.ReadBuffer) (spi.Message, er
func (m ModbusPDUReadFileRecordRequestItem) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadFileRecordRequestItem); ok {
// Simple Field (referenceType)
var referenceType uint8 = m.referenceType
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordResponse.go
index ebb0dd8..124445f 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordResponse.go
@@ -50,7 +50,7 @@ func (m ModbusPDUReadFileRecordResponse) Response() bool {
}
func (m ModbusPDUReadFileRecordResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadFileRecordResponse(items []ModbusPDUReadFileRecordResponseItem) ModbusPDUInitializer {
@@ -113,10 +113,10 @@ func (m ModbusPDUReadFileRecordResponse) Serialize(io spi.WriteBuffer) {
return sizeInBytes
}
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadFileRecordResponse); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(itemsArraySizeInBytes(m.items)))
+ byteCount := uint8(uint8(itemsArraySizeInBytes(m.items)))
io.WriteUint8(8, (byteCount))
// Array Field (items)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordResponseItem.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordResponseItem.go
index 828dccf..6ee3b77 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordResponseItem.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadFileRecordResponseItem.go
@@ -82,10 +82,10 @@ func ModbusPDUReadFileRecordResponseItemParse(io spi.ReadBuffer) (spi.Message, e
func (m ModbusPDUReadFileRecordResponseItem) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadFileRecordResponseItem); ok {
// Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var dataLength uint8 = ((uint8(len(m.data))) + (1))
+ dataLength := uint8((uint8(len(m.data))) + (1))
io.WriteUint8(8, (dataLength))
// Simple Field (referenceType)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadHoldingRegistersRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadHoldingRegistersRequest.go
index 40a5cab..fe2a40c 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadHoldingRegistersRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadHoldingRegistersRequest.go
@@ -49,7 +49,7 @@ func (m ModbusPDUReadHoldingRegistersRequest) Response() bool {
}
func (m ModbusPDUReadHoldingRegistersRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadHoldingRegistersRequest(startingAddress uint16, quantity uint16) ModbusPDUInitializer {
@@ -86,7 +86,7 @@ func ModbusPDUReadHoldingRegistersRequestParse(io spi.ReadBuffer) (ModbusPDUInit
func (m ModbusPDUReadHoldingRegistersRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadHoldingRegistersRequest); ok {
// Simple Field (startingAddress)
var startingAddress uint16 = m.startingAddress
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadHoldingRegistersResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadHoldingRegistersResponse.go
index 2c9d599..5d2945f 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadHoldingRegistersResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadHoldingRegistersResponse.go
@@ -48,7 +48,7 @@ func (m ModbusPDUReadHoldingRegistersResponse) Response() bool {
}
func (m ModbusPDUReadHoldingRegistersResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadHoldingRegistersResponse(value []int8) ModbusPDUInitializer {
@@ -85,7 +85,7 @@ func ModbusPDUReadHoldingRegistersResponseParse(io spi.ReadBuffer) (ModbusPDUIni
value := make([]int8, byteCount)
for curItem := uint16(0); curItem < uint16(byteCount); curItem++ {
- value[curItem] = io.ReadInt8(8)
+ value = append(value, io.ReadInt8(8))
}
}
@@ -95,10 +95,10 @@ func ModbusPDUReadHoldingRegistersResponseParse(io spi.ReadBuffer) (ModbusPDUIni
func (m ModbusPDUReadHoldingRegistersResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadHoldingRegistersResponse); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(len(m.value)))
+ byteCount := uint8(uint8(len(m.value)))
io.WriteUint8(8, (byteCount))
// Array Field (value)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadInputRegistersRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadInputRegistersRequest.go
index 603f5a5..4edaefd 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadInputRegistersRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadInputRegistersRequest.go
@@ -49,7 +49,7 @@ func (m ModbusPDUReadInputRegistersRequest) Response() bool {
}
func (m ModbusPDUReadInputRegistersRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadInputRegistersRequest(startingAddress uint16, quantity uint16) ModbusPDUInitializer {
@@ -86,7 +86,7 @@ func ModbusPDUReadInputRegistersRequestParse(io spi.ReadBuffer) (ModbusPDUInitia
func (m ModbusPDUReadInputRegistersRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadInputRegistersRequest); ok {
// Simple Field (startingAddress)
var startingAddress uint16 = m.startingAddress
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadInputRegistersResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadInputRegistersResponse.go
index 07566d9..6bef03a 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadInputRegistersResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadInputRegistersResponse.go
@@ -48,7 +48,7 @@ func (m ModbusPDUReadInputRegistersResponse) Response() bool {
}
func (m ModbusPDUReadInputRegistersResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadInputRegistersResponse(value []int8) ModbusPDUInitializer {
@@ -85,7 +85,7 @@ func ModbusPDUReadInputRegistersResponseParse(io spi.ReadBuffer) (ModbusPDUIniti
value := make([]int8, byteCount)
for curItem := uint16(0); curItem < uint16(byteCount); curItem++ {
- value[curItem] = io.ReadInt8(8)
+ value = append(value, io.ReadInt8(8))
}
}
@@ -95,10 +95,10 @@ func ModbusPDUReadInputRegistersResponseParse(io spi.ReadBuffer) (ModbusPDUIniti
func (m ModbusPDUReadInputRegistersResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadInputRegistersResponse); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(len(m.value)))
+ byteCount := uint8(uint8(len(m.value)))
io.WriteUint8(8, (byteCount))
// Array Field (value)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersRequest.go
index 35949d0..144c7a9 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersRequest.go
@@ -52,7 +52,7 @@ func (m ModbusPDUReadWriteMultipleHoldingRegistersRequest) Response() bool {
}
func (m ModbusPDUReadWriteMultipleHoldingRegistersRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadWriteMultipleHoldingRegistersRequest(readStartingAddress uint16, readQuantity uint16, writeStartingAddress uint16, writeQuantity uint16, value []int8) ModbusPDUInitializer {
@@ -113,7 +113,7 @@ func ModbusPDUReadWriteMultipleHoldingRegistersRequestParse(io spi.ReadBuffer) (
value := make([]int8, byteCount)
for curItem := uint16(0); curItem < uint16(byteCount); curItem++ {
- value[curItem] = io.ReadInt8(8)
+ value = append(value, io.ReadInt8(8))
}
}
@@ -123,7 +123,7 @@ func ModbusPDUReadWriteMultipleHoldingRegistersRequestParse(io spi.ReadBuffer) (
func (m ModbusPDUReadWriteMultipleHoldingRegistersRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadWriteMultipleHoldingRegistersRequest); ok {
// Simple Field (readStartingAddress)
var readStartingAddress uint16 = m.readStartingAddress
@@ -142,7 +142,7 @@ func (m ModbusPDUReadWriteMultipleHoldingRegistersRequest) Serialize(io spi.Writ
io.WriteUint16(16, (writeQuantity))
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(len(m.value)))
+ byteCount := uint8(uint8(len(m.value)))
io.WriteUint8(8, (byteCount))
// Array Field (value)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersResponse.go
index 0aa3706..897481a 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersResponse.go
@@ -48,7 +48,7 @@ func (m ModbusPDUReadWriteMultipleHoldingRegistersResponse) Response() bool {
}
func (m ModbusPDUReadWriteMultipleHoldingRegistersResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReadWriteMultipleHoldingRegistersResponse(value []int8) ModbusPDUInitializer {
@@ -85,7 +85,7 @@ func ModbusPDUReadWriteMultipleHoldingRegistersResponseParse(io spi.ReadBuffer)
value := make([]int8, byteCount)
for curItem := uint16(0); curItem < uint16(byteCount); curItem++ {
- value[curItem] = io.ReadInt8(8)
+ value = append(value, io.ReadInt8(8))
}
}
@@ -95,10 +95,10 @@ func ModbusPDUReadWriteMultipleHoldingRegistersResponseParse(io spi.ReadBuffer)
func (m ModbusPDUReadWriteMultipleHoldingRegistersResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReadWriteMultipleHoldingRegistersResponse); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(len(m.value)))
+ byteCount := uint8(uint8(len(m.value)))
io.WriteUint8(8, (byteCount))
// Array Field (value)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
index 0e6437b..2947c57 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
@@ -47,7 +47,7 @@ func (m ModbusPDUReportServerIdRequest) Response() bool {
}
func (m ModbusPDUReportServerIdRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReportServerIdRequest() ModbusPDUInitializer {
@@ -72,7 +72,7 @@ func ModbusPDUReportServerIdRequestParse(io spi.ReadBuffer) (ModbusPDUInitialize
func (m ModbusPDUReportServerIdRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReportServerIdRequest); ok {
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdResponse.go
index 10114ce..267da8c 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdResponse.go
@@ -48,7 +48,7 @@ func (m ModbusPDUReportServerIdResponse) Response() bool {
}
func (m ModbusPDUReportServerIdResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUReportServerIdResponse(value []int8) ModbusPDUInitializer {
@@ -85,7 +85,7 @@ func ModbusPDUReportServerIdResponseParse(io spi.ReadBuffer) (ModbusPDUInitializ
value := make([]int8, byteCount)
for curItem := uint16(0); curItem < uint16(byteCount); curItem++ {
- value[curItem] = io.ReadInt8(8)
+ value = append(value, io.ReadInt8(8))
}
}
@@ -95,10 +95,10 @@ func ModbusPDUReportServerIdResponseParse(io spi.ReadBuffer) (ModbusPDUInitializ
func (m ModbusPDUReportServerIdResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUReportServerIdResponse); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(len(m.value)))
+ byteCount := uint8(uint8(len(m.value)))
io.WriteUint8(8, (byteCount))
// Array Field (value)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordRequest.go
index 286b871..a16b646 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordRequest.go
@@ -50,7 +50,7 @@ func (m ModbusPDUWriteFileRecordRequest) Response() bool {
}
func (m ModbusPDUWriteFileRecordRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUWriteFileRecordRequest(items []ModbusPDUWriteFileRecordRequestItem) ModbusPDUInitializer {
@@ -113,10 +113,10 @@ func (m ModbusPDUWriteFileRecordRequest) Serialize(io spi.WriteBuffer) {
return sizeInBytes
}
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteFileRecordRequest); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(itemsArraySizeInBytes(m.items)))
+ byteCount := uint8(uint8(itemsArraySizeInBytes(m.items)))
io.WriteUint8(8, (byteCount))
// Array Field (items)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordRequestItem.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordRequestItem.go
index 3557087..7c6736b 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordRequestItem.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordRequestItem.go
@@ -96,7 +96,7 @@ func ModbusPDUWriteFileRecordRequestItemParse(io spi.ReadBuffer) (spi.Message, e
func (m ModbusPDUWriteFileRecordRequestItem) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteFileRecordRequestItem); ok {
// Simple Field (referenceType)
var referenceType uint8 = m.referenceType
@@ -111,7 +111,7 @@ func (m ModbusPDUWriteFileRecordRequestItem) Serialize(io spi.WriteBuffer) {
io.WriteUint16(16, (recordNumber))
// Implicit Field (recordLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var recordLength uint16 = ((uint16(len(m.recordData))) / (2))
+ recordLength := uint16((uint16(len(m.recordData))) / (2))
io.WriteUint16(16, (recordLength))
// Array Field (recordData)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordResponse.go
index 862d106..1d54ba1 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordResponse.go
@@ -50,7 +50,7 @@ func (m ModbusPDUWriteFileRecordResponse) Response() bool {
}
func (m ModbusPDUWriteFileRecordResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUWriteFileRecordResponse(items []ModbusPDUWriteFileRecordResponseItem) ModbusPDUInitializer {
@@ -113,10 +113,10 @@ func (m ModbusPDUWriteFileRecordResponse) Serialize(io spi.WriteBuffer) {
return sizeInBytes
}
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteFileRecordResponse); ok {
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(itemsArraySizeInBytes(m.items)))
+ byteCount := uint8(uint8(itemsArraySizeInBytes(m.items)))
io.WriteUint8(8, (byteCount))
// Array Field (items)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordResponseItem.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordResponseItem.go
index 88b84ef..a3803a1 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordResponseItem.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteFileRecordResponseItem.go
@@ -96,7 +96,7 @@ func ModbusPDUWriteFileRecordResponseItemParse(io spi.ReadBuffer) (spi.Message,
func (m ModbusPDUWriteFileRecordResponseItem) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteFileRecordResponseItem); ok {
// Simple Field (referenceType)
var referenceType uint8 = m.referenceType
@@ -111,7 +111,7 @@ func (m ModbusPDUWriteFileRecordResponseItem) Serialize(io spi.WriteBuffer) {
io.WriteUint16(16, (recordNumber))
// Implicit Field (recordLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var recordLength uint16 = ((uint16(len(m.recordData))) / (2))
+ recordLength := uint16((uint16(len(m.recordData))) / (2))
io.WriteUint16(16, (recordLength))
// Array Field (recordData)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsRequest.go
index e6e2f3c..1d11474 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsRequest.go
@@ -50,7 +50,7 @@ func (m ModbusPDUWriteMultipleCoilsRequest) Response() bool {
}
func (m ModbusPDUWriteMultipleCoilsRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUWriteMultipleCoilsRequest(startingAddress uint16, quantity uint16, value []int8) ModbusPDUInitializer {
@@ -99,7 +99,7 @@ func ModbusPDUWriteMultipleCoilsRequestParse(io spi.ReadBuffer) (ModbusPDUInitia
value := make([]int8, byteCount)
for curItem := uint16(0); curItem < uint16(byteCount); curItem++ {
- value[curItem] = io.ReadInt8(8)
+ value = append(value, io.ReadInt8(8))
}
}
@@ -109,7 +109,7 @@ func ModbusPDUWriteMultipleCoilsRequestParse(io spi.ReadBuffer) (ModbusPDUInitia
func (m ModbusPDUWriteMultipleCoilsRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteMultipleCoilsRequest); ok {
// Simple Field (startingAddress)
var startingAddress uint16 = m.startingAddress
@@ -120,7 +120,7 @@ func (m ModbusPDUWriteMultipleCoilsRequest) Serialize(io spi.WriteBuffer) {
io.WriteUint16(16, (quantity))
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(len(m.value)))
+ byteCount := uint8(uint8(len(m.value)))
io.WriteUint8(8, (byteCount))
// Array Field (value)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsResponse.go
index c5fefc0..890d6d5 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsResponse.go
@@ -49,7 +49,7 @@ func (m ModbusPDUWriteMultipleCoilsResponse) Response() bool {
}
func (m ModbusPDUWriteMultipleCoilsResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUWriteMultipleCoilsResponse(startingAddress uint16, quantity uint16) ModbusPDUInitializer {
@@ -86,7 +86,7 @@ func ModbusPDUWriteMultipleCoilsResponseParse(io spi.ReadBuffer) (ModbusPDUIniti
func (m ModbusPDUWriteMultipleCoilsResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteMultipleCoilsResponse); ok {
// Simple Field (startingAddress)
var startingAddress uint16 = m.startingAddress
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersRequest.go
index 9e1112b..541ae3b 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersRequest.go
@@ -50,7 +50,7 @@ func (m ModbusPDUWriteMultipleHoldingRegistersRequest) Response() bool {
}
func (m ModbusPDUWriteMultipleHoldingRegistersRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUWriteMultipleHoldingRegistersRequest(startingAddress uint16, quantity uint16, value []int8) ModbusPDUInitializer {
@@ -99,7 +99,7 @@ func ModbusPDUWriteMultipleHoldingRegistersRequestParse(io spi.ReadBuffer) (Modb
value := make([]int8, byteCount)
for curItem := uint16(0); curItem < uint16(byteCount); curItem++ {
- value[curItem] = io.ReadInt8(8)
+ value = append(value, io.ReadInt8(8))
}
}
@@ -109,7 +109,7 @@ func ModbusPDUWriteMultipleHoldingRegistersRequestParse(io spi.ReadBuffer) (Modb
func (m ModbusPDUWriteMultipleHoldingRegistersRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteMultipleHoldingRegistersRequest); ok {
// Simple Field (startingAddress)
var startingAddress uint16 = m.startingAddress
@@ -120,7 +120,7 @@ func (m ModbusPDUWriteMultipleHoldingRegistersRequest) Serialize(io spi.WriteBuf
io.WriteUint16(16, (quantity))
// Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var byteCount uint8 = (uint8(len(m.value)))
+ byteCount := uint8(uint8(len(m.value)))
io.WriteUint8(8, (byteCount))
// Array Field (value)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersResponse.go
index 07f5484..06c79fc 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersResponse.go
@@ -49,7 +49,7 @@ func (m ModbusPDUWriteMultipleHoldingRegistersResponse) Response() bool {
}
func (m ModbusPDUWriteMultipleHoldingRegistersResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUWriteMultipleHoldingRegistersResponse(startingAddress uint16, quantity uint16) ModbusPDUInitializer {
@@ -86,7 +86,7 @@ func ModbusPDUWriteMultipleHoldingRegistersResponseParse(io spi.ReadBuffer) (Mod
func (m ModbusPDUWriteMultipleHoldingRegistersResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteMultipleHoldingRegistersResponse); ok {
// Simple Field (startingAddress)
var startingAddress uint16 = m.startingAddress
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleCoilRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleCoilRequest.go
index 0fc77ca..1674673 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleCoilRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleCoilRequest.go
@@ -49,7 +49,7 @@ func (m ModbusPDUWriteSingleCoilRequest) Response() bool {
}
func (m ModbusPDUWriteSingleCoilRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUWriteSingleCoilRequest(address uint16, value uint16) ModbusPDUInitializer {
@@ -86,7 +86,7 @@ func ModbusPDUWriteSingleCoilRequestParse(io spi.ReadBuffer) (ModbusPDUInitializ
func (m ModbusPDUWriteSingleCoilRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteSingleCoilRequest); ok {
// Simple Field (address)
var address uint16 = m.address
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleCoilResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleCoilResponse.go
index b9bbdf5..aa53df8 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleCoilResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleCoilResponse.go
@@ -49,7 +49,7 @@ func (m ModbusPDUWriteSingleCoilResponse) Response() bool {
}
func (m ModbusPDUWriteSingleCoilResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUWriteSingleCoilResponse(address uint16, value uint16) ModbusPDUInitializer {
@@ -86,7 +86,7 @@ func ModbusPDUWriteSingleCoilResponseParse(io spi.ReadBuffer) (ModbusPDUInitiali
func (m ModbusPDUWriteSingleCoilResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteSingleCoilResponse); ok {
// Simple Field (address)
var address uint16 = m.address
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleRegisterRequest.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleRegisterRequest.go
index 22ea642..be3aa81 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleRegisterRequest.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleRegisterRequest.go
@@ -49,7 +49,7 @@ func (m ModbusPDUWriteSingleRegisterRequest) Response() bool {
}
func (m ModbusPDUWriteSingleRegisterRequest) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUWriteSingleRegisterRequest(address uint16, value uint16) ModbusPDUInitializer {
@@ -86,7 +86,7 @@ func ModbusPDUWriteSingleRegisterRequestParse(io spi.ReadBuffer) (ModbusPDUIniti
func (m ModbusPDUWriteSingleRegisterRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteSingleRegisterRequest); ok {
// Simple Field (address)
var address uint16 = m.address
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleRegisterResponse.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleRegisterResponse.go
index 329c2d9..c10365b 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleRegisterResponse.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUWriteSingleRegisterResponse.go
@@ -49,7 +49,7 @@ func (m ModbusPDUWriteSingleRegisterResponse) Response() bool {
}
func (m ModbusPDUWriteSingleRegisterResponse) initialize() spi.Message {
- return spi.Message(m)
+ return m
}
func NewModbusPDUWriteSingleRegisterResponse(address uint16, value uint16) ModbusPDUInitializer {
@@ -86,7 +86,7 @@ func ModbusPDUWriteSingleRegisterResponseParse(io spi.ReadBuffer) (ModbusPDUInit
func (m ModbusPDUWriteSingleRegisterResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusPDUWriteSingleRegisterResponse); ok {
// Simple Field (address)
var address uint16 = m.address
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusSerialADU.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusSerialADU.go
index 981e0a9..2a200da 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusSerialADU.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusSerialADU.go
@@ -107,7 +107,7 @@ func ModbusSerialADUParse(io spi.ReadBuffer, response bool) (spi.Message, error)
func (m ModbusSerialADU) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusSerialADU); ok {
// Simple Field (transactionId)
var transactionId uint16 = m.transactionId
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusTcpADU.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusTcpADU.go
index b66224d..e805e87 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusTcpADU.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusTcpADU.go
@@ -26,7 +26,7 @@ import (
)
// Constant values.
-const PROTOCOLIDENTIFIER uint16 = 0x0000
+const ModbusTcpADU_PROTOCOLIDENTIFIER uint16 = 0x0000
// The data-structure of this message
type ModbusTcpADU struct {
@@ -77,8 +77,8 @@ func ModbusTcpADUParse(io spi.ReadBuffer, response bool) (spi.Message, error) {
// Const Field (protocolIdentifier)
var protocolIdentifier uint16 = io.ReadUint16(16)
- if protocolIdentifier != PROTOCOLIDENTIFIER {
- return nil, errors.New("Expected constant value " + strconv.Itoa(int(PROTOCOLIDENTIFIER)) + " but got " + strconv.Itoa(int(protocolIdentifier)))
+ if protocolIdentifier != ModbusTcpADU_PROTOCOLIDENTIFIER {
+ return nil, errors.New("Expected constant value " + strconv.Itoa(int(ModbusTcpADU_PROTOCOLIDENTIFIER)) + " but got " + strconv.Itoa(int(protocolIdentifier)))
}
// Implicit Field (length) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
@@ -104,7 +104,7 @@ func ModbusTcpADUParse(io spi.ReadBuffer, response bool) (spi.Message, error) {
func (m ModbusTcpADU) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IModbusTcpADU); ok {
// Simple Field (transactionIdentifier)
var transactionIdentifier uint16 = m.transactionIdentifier
@@ -114,7 +114,7 @@ func (m ModbusTcpADU) Serialize(io spi.WriteBuffer) {
io.WriteUint16(16, 0x0000)
// Implicit Field (length) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
- var length uint16 = ((m.pdu.LengthInBytes()) + (1))
+ length := uint16((m.pdu.LengthInBytes()) + (1))
io.WriteUint16(16, (length))
// Simple Field (unitIdentifier)
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacket.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacket.go
new file mode 100644
index 0000000..727c7cc
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacket.go
@@ -0,0 +1,180 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+)
+
+// The data-structure of this message
+type COTPPacket struct {
+ parameters []COTPParameter
+ payload *S7Message
+}
+
+// The corresponding interface
+type ICOTPPacket interface {
+ spi.Message
+ TpduCode() uint8
+ Serialize(io spi.WriteBuffer)
+}
+
+type COTPPacketInitializer interface {
+ initialize(parameters []COTPParameter, payload *S7Message) spi.Message
+}
+
+func COTPPacketTpduCode(m ICOTPPacket) uint8 {
+ return m.TpduCode()
+}
+
+func (m COTPPacket) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Implicit Field (headerLength)
+ lengthInBits += 8
+
+ // Discriminator Field (tpduCode)
+ lengthInBits += 8
+
+ // Length of sub-type elements will be added by sub-type...
+
+ // Array field
+ if len(m.parameters) > 0 {
+ for _, element := range m.parameters {
+ lengthInBits += element.LengthInBits()
+ }
+ }
+
+ // Optional Field (payload)
+ if m.payload != nil {
+ lengthInBits += m.payload.LengthInBits()
+ }
+
+ return lengthInBits
+}
+
+func (m COTPPacket) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func COTPPacketParse(io spi.ReadBuffer, cotpLen uint16) (spi.Message, error) {
+ var startPos = io.GetPos()
+ var curPos uint16
+
+ // Implicit Field (headerLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var headerLength uint8 = io.ReadUint8(8)
+
+ // Discriminator Field (tpduCode) (Used as input to a switch field)
+ var tpduCode uint8 = io.ReadUint8(8)
+
+ // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
+ var initializer COTPPacketInitializer
+ var typeSwitchError error
+ switch {
+ case tpduCode == 0xF0:
+ initializer, typeSwitchError = COTPPacketDataParse(io)
+ case tpduCode == 0xE0:
+ initializer, typeSwitchError = COTPPacketConnectionRequestParse(io)
+ case tpduCode == 0xD0:
+ initializer, typeSwitchError = COTPPacketConnectionResponseParse(io)
+ case tpduCode == 0x80:
+ initializer, typeSwitchError = COTPPacketDisconnectRequestParse(io)
+ case tpduCode == 0xC0:
+ initializer, typeSwitchError = COTPPacketDisconnectResponseParse(io)
+ case tpduCode == 0x70:
+ initializer, typeSwitchError = COTPPacketTpduErrorParse(io)
+ }
+ if typeSwitchError != nil {
+ return nil, errors.New("Error parsing sub-type for type-switch. " + typeSwitchError.Error())
+ }
+
+ // Array field (parameters)
+ curPos = io.GetPos() - startPos
+ var parameters []COTPParameter
+ // Length array
+ _parametersLength := uint16(((headerLength) + (1)) - (curPos))
+ _parametersEndPos := io.GetPos() + _parametersLength
+ for io.GetPos() < _parametersEndPos {
+ _message, _err := COTPParameterParse(io, uint8(((headerLength)+(1))-(curPos)))
+ if _err != nil {
+ return nil, errors.New("Error parsing 'parameters' field " + _err.Error())
+ }
+ var _item COTPParameter
+ _item, _ok := _message.(COTPParameter)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to COTPParameter")
+ }
+ parameters = append(parameters, _item)
+ curPos = io.GetPos() - startPos
+ }
+
+ // Optional Field (payload) (Can be skipped, if a given expression evaluates to false)
+ curPos = io.GetPos() - startPos
+ var payload *S7Message = nil
+ if (curPos) < (cotpLen) {
+ _message, _err := S7MessageParse(io)
+ if _err != nil {
+ return nil, errors.New("Error parsing 'payload' field " + _err.Error())
+ }
+ var _item S7Message
+ _item, _ok := _message.(S7Message)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to S7Message")
+ }
+ payload = &_item
+ }
+
+ // Create the instance
+ return initializer.initialize(parameters, payload), nil
+}
+
+func (m COTPPacket) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if iCOTPPacket, ok := typ.(ICOTPPacket); ok {
+
+ // Implicit Field (headerLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ headerLength := uint8((m.LengthInBytes()) - ((spi.InlineIf(((m.payload) != (nil)), uint16(m.payload.LengthInBytes()), uint16(0))) + (1)))
+ io.WriteUint8(8, (headerLength))
+
+ // Discriminator Field (tpduCode) (Used as input to a switch field)
+ tpduCode := COTPPacketTpduCode(iCOTPPacket)
+ io.WriteUint8(8, (tpduCode))
+
+ // Switch field (Depending on the discriminator values, passes the serialization to a sub-type)
+ iCOTPPacket.Serialize(io)
+
+ // Array Field (parameters)
+ if m.parameters != nil {
+ for _, _element := range m.parameters {
+ _element.Serialize(io)
+ }
+ }
+
+ // Optional Field (payload) (Can be skipped, if the value is null)
+ var payload *S7Message = nil
+ if m.payload != nil {
+ payload = m.payload
+ payload.Serialize(io)
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketConnectionRequest.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketConnectionRequest.go
new file mode 100644
index 0000000..049b5ca
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketConnectionRequest.go
@@ -0,0 +1,110 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type COTPPacketConnectionRequest struct {
+ destinationReference uint16
+ sourceReference uint16
+ protocolClass COTPProtocolClass
+ COTPPacket
+}
+
+// The corresponding interface
+type ICOTPPacketConnectionRequest interface {
+ ICOTPPacket
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m COTPPacketConnectionRequest) TpduCode() uint8 {
+ return 0xE0
+}
+
+func (m COTPPacketConnectionRequest) initialize(parameters []COTPParameter, payload *S7Message) spi.Message {
+ m.parameters = parameters
+ m.payload = payload
+ return m
+}
+
+func NewCOTPPacketConnectionRequest(destinationReference uint16, sourceReference uint16, protocolClass COTPProtocolClass) COTPPacketInitializer {
+ return &COTPPacketConnectionRequest{destinationReference: destinationReference, sourceReference: sourceReference, protocolClass: protocolClass}
+}
+
+func (m COTPPacketConnectionRequest) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.COTPPacket.LengthInBits()
+
+ // Simple field (destinationReference)
+ lengthInBits += 16
+
+ // Simple field (sourceReference)
+ lengthInBits += 16
+
+ // Enum Field (protocolClass)
+ lengthInBits += 8
+
+ return lengthInBits
+}
+
+func (m COTPPacketConnectionRequest) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func COTPPacketConnectionRequestParse(io spi.ReadBuffer) (COTPPacketInitializer, error) {
+
+ // Simple Field (destinationReference)
+ var destinationReference uint16 = io.ReadUint16(16)
+
+ // Simple Field (sourceReference)
+ var sourceReference uint16 = io.ReadUint16(16)
+
+ // Enum field (protocolClass)
+ protocolClass, _protocolClassErr := COTPProtocolClassParse(io)
+ if _protocolClassErr != nil {
+ return nil, errors.New("Error parsing 'protocolClass' field " + _protocolClassErr.Error())
+ }
+
+ // Create the instance
+ return NewCOTPPacketConnectionRequest(destinationReference, sourceReference, protocolClass), nil
+}
+
+func (m COTPPacketConnectionRequest) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(ICOTPPacketConnectionRequest); ok {
+
+ // Simple Field (destinationReference)
+ var destinationReference uint16 = m.destinationReference
+ io.WriteUint16(16, (destinationReference))
+
+ // Simple Field (sourceReference)
+ var sourceReference uint16 = m.sourceReference
+ io.WriteUint16(16, (sourceReference))
+
+ // Enum field (protocolClass)
+ protocolClass := m.protocolClass
+ protocolClass.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketConnectionResponse.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketConnectionResponse.go
new file mode 100644
index 0000000..98b84ec
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketConnectionResponse.go
@@ -0,0 +1,110 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type COTPPacketConnectionResponse struct {
+ destinationReference uint16
+ sourceReference uint16
+ protocolClass COTPProtocolClass
+ COTPPacket
+}
+
+// The corresponding interface
+type ICOTPPacketConnectionResponse interface {
+ ICOTPPacket
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m COTPPacketConnectionResponse) TpduCode() uint8 {
+ return 0xD0
+}
+
+func (m COTPPacketConnectionResponse) initialize(parameters []COTPParameter, payload *S7Message) spi.Message {
+ m.parameters = parameters
+ m.payload = payload
+ return m
+}
+
+func NewCOTPPacketConnectionResponse(destinationReference uint16, sourceReference uint16, protocolClass COTPProtocolClass) COTPPacketInitializer {
+ return &COTPPacketConnectionResponse{destinationReference: destinationReference, sourceReference: sourceReference, protocolClass: protocolClass}
+}
+
+func (m COTPPacketConnectionResponse) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.COTPPacket.LengthInBits()
+
+ // Simple field (destinationReference)
+ lengthInBits += 16
+
+ // Simple field (sourceReference)
+ lengthInBits += 16
+
+ // Enum Field (protocolClass)
+ lengthInBits += 8
+
+ return lengthInBits
+}
+
+func (m COTPPacketConnectionResponse) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func COTPPacketConnectionResponseParse(io spi.ReadBuffer) (COTPPacketInitializer, error) {
+
+ // Simple Field (destinationReference)
+ var destinationReference uint16 = io.ReadUint16(16)
+
+ // Simple Field (sourceReference)
+ var sourceReference uint16 = io.ReadUint16(16)
+
+ // Enum field (protocolClass)
+ protocolClass, _protocolClassErr := COTPProtocolClassParse(io)
+ if _protocolClassErr != nil {
+ return nil, errors.New("Error parsing 'protocolClass' field " + _protocolClassErr.Error())
+ }
+
+ // Create the instance
+ return NewCOTPPacketConnectionResponse(destinationReference, sourceReference, protocolClass), nil
+}
+
+func (m COTPPacketConnectionResponse) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(ICOTPPacketConnectionResponse); ok {
+
+ // Simple Field (destinationReference)
+ var destinationReference uint16 = m.destinationReference
+ io.WriteUint16(16, (destinationReference))
+
+ // Simple Field (sourceReference)
+ var sourceReference uint16 = m.sourceReference
+ io.WriteUint16(16, (sourceReference))
+
+ // Enum field (protocolClass)
+ protocolClass := m.protocolClass
+ protocolClass.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketData.go
similarity index 50%
copy from sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketData.go
index c4cd251..9530383 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketData.go
@@ -23,67 +23,72 @@ import (
)
// The data-structure of this message
-type ModbusPDUError struct {
- exceptionCode uint8
- ModbusPDU
+type COTPPacketData struct {
+ eot bool
+ tpduRef uint8
+ COTPPacket
}
// The corresponding interface
-type IModbusPDUError interface {
- IModbusPDU
+type ICOTPPacketData interface {
+ ICOTPPacket
Serialize(io spi.WriteBuffer)
}
// Accessors for discriminator values.
-func (m ModbusPDUError) ErrorFlag() bool {
- return true
+func (m COTPPacketData) TpduCode() uint8 {
+ return 0xF0
}
-func (m ModbusPDUError) FunctionFlag() uint8 {
- return 0
+func (m COTPPacketData) initialize(parameters []COTPParameter, payload *S7Message) spi.Message {
+ m.parameters = parameters
+ m.payload = payload
+ return m
}
-func (m ModbusPDUError) Response() bool {
- return false
+func NewCOTPPacketData(eot bool, tpduRef uint8) COTPPacketInitializer {
+ return &COTPPacketData{eot: eot, tpduRef: tpduRef}
}
-func (m ModbusPDUError) initialize() spi.Message {
- return spi.Message(m)
-}
-
-func NewModbusPDUError(exceptionCode uint8) ModbusPDUInitializer {
- return &ModbusPDUError{exceptionCode: exceptionCode}
-}
+func (m COTPPacketData) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.COTPPacket.LengthInBits()
-func (m ModbusPDUError) LengthInBits() uint16 {
- var lengthInBits uint16 = m.ModbusPDU.LengthInBits()
+ // Simple field (eot)
+ lengthInBits += 1
- // Simple field (exceptionCode)
- lengthInBits += 8
+ // Simple field (tpduRef)
+ lengthInBits += 7
return lengthInBits
}
-func (m ModbusPDUError) LengthInBytes() uint16 {
+func (m COTPPacketData) LengthInBytes() uint16 {
return m.LengthInBits() / 8
}
-func ModbusPDUErrorParse(io spi.ReadBuffer) (ModbusPDUInitializer, error) {
+func COTPPacketDataParse(io spi.ReadBuffer) (COTPPacketInitializer, error) {
- // Simple Field (exceptionCode)
- var exceptionCode uint8 = io.ReadUint8(8)
+ // Simple Field (eot)
+ var eot bool = io.ReadBit()
+
+ // Simple Field (tpduRef)
+ var tpduRef uint8 = io.ReadUint8(7)
// Create the instance
- return NewModbusPDUError(exceptionCode), nil
+ return NewCOTPPacketData(eot, tpduRef), nil
}
-func (m ModbusPDUError) Serialize(io spi.WriteBuffer) {
+func (m COTPPacketData) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(ICOTPPacketData); ok {
+
+ // Simple Field (eot)
+ var eot bool = m.eot
+ io.WriteBit((bool)(eot))
- // Simple Field (exceptionCode)
- var exceptionCode uint8 = m.exceptionCode
- io.WriteUint8(8, (exceptionCode))
+ // Simple Field (tpduRef)
+ var tpduRef uint8 = m.tpduRef
+ io.WriteUint8(7, (tpduRef))
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketDisconnectRequest.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketDisconnectRequest.go
new file mode 100644
index 0000000..7645ae6
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketDisconnectRequest.go
@@ -0,0 +1,110 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type COTPPacketDisconnectRequest struct {
+ destinationReference uint16
+ sourceReference uint16
+ protocolClass COTPProtocolClass
+ COTPPacket
+}
+
+// The corresponding interface
+type ICOTPPacketDisconnectRequest interface {
+ ICOTPPacket
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m COTPPacketDisconnectRequest) TpduCode() uint8 {
+ return 0x80
+}
+
+func (m COTPPacketDisconnectRequest) initialize(parameters []COTPParameter, payload *S7Message) spi.Message {
+ m.parameters = parameters
+ m.payload = payload
+ return m
+}
+
+func NewCOTPPacketDisconnectRequest(destinationReference uint16, sourceReference uint16, protocolClass COTPProtocolClass) COTPPacketInitializer {
+ return &COTPPacketDisconnectRequest{destinationReference: destinationReference, sourceReference: sourceReference, protocolClass: protocolClass}
+}
+
+func (m COTPPacketDisconnectRequest) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.COTPPacket.LengthInBits()
+
+ // Simple field (destinationReference)
+ lengthInBits += 16
+
+ // Simple field (sourceReference)
+ lengthInBits += 16
+
+ // Enum Field (protocolClass)
+ lengthInBits += 8
+
+ return lengthInBits
+}
+
+func (m COTPPacketDisconnectRequest) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func COTPPacketDisconnectRequestParse(io spi.ReadBuffer) (COTPPacketInitializer, error) {
+
+ // Simple Field (destinationReference)
+ var destinationReference uint16 = io.ReadUint16(16)
+
+ // Simple Field (sourceReference)
+ var sourceReference uint16 = io.ReadUint16(16)
+
+ // Enum field (protocolClass)
+ protocolClass, _protocolClassErr := COTPProtocolClassParse(io)
+ if _protocolClassErr != nil {
+ return nil, errors.New("Error parsing 'protocolClass' field " + _protocolClassErr.Error())
+ }
+
+ // Create the instance
+ return NewCOTPPacketDisconnectRequest(destinationReference, sourceReference, protocolClass), nil
+}
+
+func (m COTPPacketDisconnectRequest) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(ICOTPPacketDisconnectRequest); ok {
+
+ // Simple Field (destinationReference)
+ var destinationReference uint16 = m.destinationReference
+ io.WriteUint16(16, (destinationReference))
+
+ // Simple Field (sourceReference)
+ var sourceReference uint16 = m.sourceReference
+ io.WriteUint16(16, (sourceReference))
+
+ // Enum field (protocolClass)
+ protocolClass := m.protocolClass
+ protocolClass.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketDisconnectResponse.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketDisconnectResponse.go
new file mode 100644
index 0000000..27422e3
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketDisconnectResponse.go
@@ -0,0 +1,95 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type COTPPacketDisconnectResponse struct {
+ destinationReference uint16
+ sourceReference uint16
+ COTPPacket
+}
+
+// The corresponding interface
+type ICOTPPacketDisconnectResponse interface {
+ ICOTPPacket
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m COTPPacketDisconnectResponse) TpduCode() uint8 {
+ return 0xC0
+}
+
+func (m COTPPacketDisconnectResponse) initialize(parameters []COTPParameter, payload *S7Message) spi.Message {
+ m.parameters = parameters
+ m.payload = payload
+ return m
+}
+
+func NewCOTPPacketDisconnectResponse(destinationReference uint16, sourceReference uint16) COTPPacketInitializer {
+ return &COTPPacketDisconnectResponse{destinationReference: destinationReference, sourceReference: sourceReference}
+}
+
+func (m COTPPacketDisconnectResponse) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.COTPPacket.LengthInBits()
+
+ // Simple field (destinationReference)
+ lengthInBits += 16
+
+ // Simple field (sourceReference)
+ lengthInBits += 16
+
+ return lengthInBits
+}
+
+func (m COTPPacketDisconnectResponse) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func COTPPacketDisconnectResponseParse(io spi.ReadBuffer) (COTPPacketInitializer, error) {
+
+ // Simple Field (destinationReference)
+ var destinationReference uint16 = io.ReadUint16(16)
+
+ // Simple Field (sourceReference)
+ var sourceReference uint16 = io.ReadUint16(16)
+
+ // Create the instance
+ return NewCOTPPacketDisconnectResponse(destinationReference, sourceReference), nil
+}
+
+func (m COTPPacketDisconnectResponse) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(ICOTPPacketDisconnectResponse); ok {
+
+ // Simple Field (destinationReference)
+ var destinationReference uint16 = m.destinationReference
+ io.WriteUint16(16, (destinationReference))
+
+ // Simple Field (sourceReference)
+ var sourceReference uint16 = m.sourceReference
+ io.WriteUint16(16, (sourceReference))
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketTpduError.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketTpduError.go
new file mode 100644
index 0000000..6a1b8a2
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPPacketTpduError.go
@@ -0,0 +1,95 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type COTPPacketTpduError struct {
+ destinationReference uint16
+ rejectCause uint8
+ COTPPacket
+}
+
+// The corresponding interface
+type ICOTPPacketTpduError interface {
+ ICOTPPacket
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m COTPPacketTpduError) TpduCode() uint8 {
+ return 0x70
+}
+
+func (m COTPPacketTpduError) initialize(parameters []COTPParameter, payload *S7Message) spi.Message {
+ m.parameters = parameters
+ m.payload = payload
+ return m
+}
+
+func NewCOTPPacketTpduError(destinationReference uint16, rejectCause uint8) COTPPacketInitializer {
+ return &COTPPacketTpduError{destinationReference: destinationReference, rejectCause: rejectCause}
+}
+
+func (m COTPPacketTpduError) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.COTPPacket.LengthInBits()
+
+ // Simple field (destinationReference)
+ lengthInBits += 16
+
+ // Simple field (rejectCause)
+ lengthInBits += 8
+
+ return lengthInBits
+}
+
+func (m COTPPacketTpduError) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func COTPPacketTpduErrorParse(io spi.ReadBuffer) (COTPPacketInitializer, error) {
+
+ // Simple Field (destinationReference)
+ var destinationReference uint16 = io.ReadUint16(16)
+
+ // Simple Field (rejectCause)
+ var rejectCause uint8 = io.ReadUint8(8)
+
+ // Create the instance
+ return NewCOTPPacketTpduError(destinationReference, rejectCause), nil
+}
+
+func (m COTPPacketTpduError) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(ICOTPPacketTpduError); ok {
+
+ // Simple Field (destinationReference)
+ var destinationReference uint16 = m.destinationReference
+ io.WriteUint16(16, (destinationReference))
+
+ // Simple Field (rejectCause)
+ var rejectCause uint8 = m.rejectCause
+ io.WriteUint8(8, (rejectCause))
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameter.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameter.go
new file mode 100644
index 0000000..4bc2756
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameter.go
@@ -0,0 +1,111 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type COTPParameter struct {
+}
+
+// The corresponding interface
+type ICOTPParameter interface {
+ spi.Message
+ ParameterType() uint8
+ Serialize(io spi.WriteBuffer)
+}
+
+type COTPParameterInitializer interface {
+ initialize() spi.Message
+}
+
+func COTPParameterParameterType(m ICOTPParameter) uint8 {
+ return m.ParameterType()
+}
+
+func (m COTPParameter) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Discriminator Field (parameterType)
+ lengthInBits += 8
+
+ // Implicit Field (parameterLength)
+ lengthInBits += 8
+
+ // Length of sub-type elements will be added by sub-type...
+
+ return lengthInBits
+}
+
+func (m COTPParameter) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func COTPParameterParse(io spi.ReadBuffer, rest uint8) (spi.Message, error) {
+
+ // Discriminator Field (parameterType) (Used as input to a switch field)
+ var parameterType uint8 = io.ReadUint8(8)
+
+ // Implicit Field (parameterLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var _ uint8 = io.ReadUint8(8)
+
+ // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
+ var initializer COTPParameterInitializer
+ var typeSwitchError error
+ switch {
+ case parameterType == 0xC0:
+ initializer, typeSwitchError = COTPParameterTpduSizeParse(io)
+ case parameterType == 0xC1:
+ initializer, typeSwitchError = COTPParameterCallingTsapParse(io)
+ case parameterType == 0xC2:
+ initializer, typeSwitchError = COTPParameterCalledTsapParse(io)
+ case parameterType == 0xC3:
+ initializer, typeSwitchError = COTPParameterChecksumParse(io)
+ case parameterType == 0xE0:
+ initializer, typeSwitchError = COTPParameterDisconnectAdditionalInformationParse(io, rest)
+ }
+ if typeSwitchError != nil {
+ return nil, errors.New("Error parsing sub-type for type-switch. " + typeSwitchError.Error())
+ }
+
+ // Create the instance
+ return initializer.initialize(), nil
+}
+
+func (m COTPParameter) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if iCOTPParameter, ok := typ.(ICOTPParameter); ok {
+
+ // Discriminator Field (parameterType) (Used as input to a switch field)
+ parameterType := COTPParameterParameterType(iCOTPParameter)
+ io.WriteUint8(8, (parameterType))
+
+ // Implicit Field (parameterLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ parameterLength := uint8((m.LengthInBytes()) - (2))
+ io.WriteUint8(8, (parameterLength))
+
+ // Switch field (Depending on the discriminator values, passes the serialization to a sub-type)
+ iCOTPParameter.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterCalledTsap.go
similarity index 54%
copy from sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterCalledTsap.go
index 0e6437b..379eb93 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterCalledTsap.go
@@ -23,56 +23,59 @@ import (
)
// The data-structure of this message
-type ModbusPDUReportServerIdRequest struct {
- ModbusPDU
+type COTPParameterCalledTsap struct {
+ tsapId uint16
+ COTPParameter
}
// The corresponding interface
-type IModbusPDUReportServerIdRequest interface {
- IModbusPDU
+type ICOTPParameterCalledTsap interface {
+ ICOTPParameter
Serialize(io spi.WriteBuffer)
}
// Accessors for discriminator values.
-func (m ModbusPDUReportServerIdRequest) ErrorFlag() bool {
- return false
+func (m COTPParameterCalledTsap) ParameterType() uint8 {
+ return 0xC2
}
-func (m ModbusPDUReportServerIdRequest) FunctionFlag() uint8 {
- return 0x11
+func (m COTPParameterCalledTsap) initialize() spi.Message {
+ return m
}
-func (m ModbusPDUReportServerIdRequest) Response() bool {
- return false
+func NewCOTPParameterCalledTsap(tsapId uint16) COTPParameterInitializer {
+ return &COTPParameterCalledTsap{tsapId: tsapId}
}
-func (m ModbusPDUReportServerIdRequest) initialize() spi.Message {
- return spi.Message(m)
-}
-
-func NewModbusPDUReportServerIdRequest() ModbusPDUInitializer {
- return &ModbusPDUReportServerIdRequest{}
-}
+func (m COTPParameterCalledTsap) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.COTPParameter.LengthInBits()
-func (m ModbusPDUReportServerIdRequest) LengthInBits() uint16 {
- var lengthInBits uint16 = m.ModbusPDU.LengthInBits()
+ // Simple field (tsapId)
+ lengthInBits += 16
return lengthInBits
}
-func (m ModbusPDUReportServerIdRequest) LengthInBytes() uint16 {
+func (m COTPParameterCalledTsap) LengthInBytes() uint16 {
return m.LengthInBits() / 8
}
-func ModbusPDUReportServerIdRequestParse(io spi.ReadBuffer) (ModbusPDUInitializer, error) {
+func COTPParameterCalledTsapParse(io spi.ReadBuffer) (COTPParameterInitializer, error) {
+
+ // Simple Field (tsapId)
+ var tsapId uint16 = io.ReadUint16(16)
// Create the instance
- return NewModbusPDUReportServerIdRequest(), nil
+ return NewCOTPParameterCalledTsap(tsapId), nil
}
-func (m ModbusPDUReportServerIdRequest) Serialize(io spi.WriteBuffer) {
+func (m COTPParameterCalledTsap) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(ICOTPParameterCalledTsap); ok {
+
+ // Simple Field (tsapId)
+ var tsapId uint16 = m.tsapId
+ io.WriteUint16(16, (tsapId))
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterCallingTsap.go
similarity index 54%
copy from sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterCallingTsap.go
index 0e6437b..144beeb 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterCallingTsap.go
@@ -23,56 +23,59 @@ import (
)
// The data-structure of this message
-type ModbusPDUReportServerIdRequest struct {
- ModbusPDU
+type COTPParameterCallingTsap struct {
+ tsapId uint16
+ COTPParameter
}
// The corresponding interface
-type IModbusPDUReportServerIdRequest interface {
- IModbusPDU
+type ICOTPParameterCallingTsap interface {
+ ICOTPParameter
Serialize(io spi.WriteBuffer)
}
// Accessors for discriminator values.
-func (m ModbusPDUReportServerIdRequest) ErrorFlag() bool {
- return false
+func (m COTPParameterCallingTsap) ParameterType() uint8 {
+ return 0xC1
}
-func (m ModbusPDUReportServerIdRequest) FunctionFlag() uint8 {
- return 0x11
+func (m COTPParameterCallingTsap) initialize() spi.Message {
+ return m
}
-func (m ModbusPDUReportServerIdRequest) Response() bool {
- return false
+func NewCOTPParameterCallingTsap(tsapId uint16) COTPParameterInitializer {
+ return &COTPParameterCallingTsap{tsapId: tsapId}
}
-func (m ModbusPDUReportServerIdRequest) initialize() spi.Message {
- return spi.Message(m)
-}
-
-func NewModbusPDUReportServerIdRequest() ModbusPDUInitializer {
- return &ModbusPDUReportServerIdRequest{}
-}
+func (m COTPParameterCallingTsap) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.COTPParameter.LengthInBits()
-func (m ModbusPDUReportServerIdRequest) LengthInBits() uint16 {
- var lengthInBits uint16 = m.ModbusPDU.LengthInBits()
+ // Simple field (tsapId)
+ lengthInBits += 16
return lengthInBits
}
-func (m ModbusPDUReportServerIdRequest) LengthInBytes() uint16 {
+func (m COTPParameterCallingTsap) LengthInBytes() uint16 {
return m.LengthInBits() / 8
}
-func ModbusPDUReportServerIdRequestParse(io spi.ReadBuffer) (ModbusPDUInitializer, error) {
+func COTPParameterCallingTsapParse(io spi.ReadBuffer) (COTPParameterInitializer, error) {
+
+ // Simple Field (tsapId)
+ var tsapId uint16 = io.ReadUint16(16)
// Create the instance
- return NewModbusPDUReportServerIdRequest(), nil
+ return NewCOTPParameterCallingTsap(tsapId), nil
}
-func (m ModbusPDUReportServerIdRequest) Serialize(io spi.WriteBuffer) {
+func (m COTPParameterCallingTsap) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(ICOTPParameterCallingTsap); ok {
+
+ // Simple Field (tsapId)
+ var tsapId uint16 = m.tsapId
+ io.WriteUint16(16, (tsapId))
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterChecksum.go
similarity index 55%
copy from sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterChecksum.go
index 0e6437b..9c0bd5f 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterChecksum.go
@@ -23,56 +23,59 @@ import (
)
// The data-structure of this message
-type ModbusPDUReportServerIdRequest struct {
- ModbusPDU
+type COTPParameterChecksum struct {
+ crc uint8
+ COTPParameter
}
// The corresponding interface
-type IModbusPDUReportServerIdRequest interface {
- IModbusPDU
+type ICOTPParameterChecksum interface {
+ ICOTPParameter
Serialize(io spi.WriteBuffer)
}
// Accessors for discriminator values.
-func (m ModbusPDUReportServerIdRequest) ErrorFlag() bool {
- return false
+func (m COTPParameterChecksum) ParameterType() uint8 {
+ return 0xC3
}
-func (m ModbusPDUReportServerIdRequest) FunctionFlag() uint8 {
- return 0x11
+func (m COTPParameterChecksum) initialize() spi.Message {
+ return m
}
-func (m ModbusPDUReportServerIdRequest) Response() bool {
- return false
+func NewCOTPParameterChecksum(crc uint8) COTPParameterInitializer {
+ return &COTPParameterChecksum{crc: crc}
}
-func (m ModbusPDUReportServerIdRequest) initialize() spi.Message {
- return spi.Message(m)
-}
-
-func NewModbusPDUReportServerIdRequest() ModbusPDUInitializer {
- return &ModbusPDUReportServerIdRequest{}
-}
+func (m COTPParameterChecksum) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.COTPParameter.LengthInBits()
-func (m ModbusPDUReportServerIdRequest) LengthInBits() uint16 {
- var lengthInBits uint16 = m.ModbusPDU.LengthInBits()
+ // Simple field (crc)
+ lengthInBits += 8
return lengthInBits
}
-func (m ModbusPDUReportServerIdRequest) LengthInBytes() uint16 {
+func (m COTPParameterChecksum) LengthInBytes() uint16 {
return m.LengthInBits() / 8
}
-func ModbusPDUReportServerIdRequestParse(io spi.ReadBuffer) (ModbusPDUInitializer, error) {
+func COTPParameterChecksumParse(io spi.ReadBuffer) (COTPParameterInitializer, error) {
+
+ // Simple Field (crc)
+ var crc uint8 = io.ReadUint8(8)
// Create the instance
- return NewModbusPDUReportServerIdRequest(), nil
+ return NewCOTPParameterChecksum(crc), nil
}
-func (m ModbusPDUReportServerIdRequest) Serialize(io spi.WriteBuffer) {
+func (m COTPParameterChecksum) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(ICOTPParameterChecksum); ok {
+
+ // Simple Field (crc)
+ var crc uint8 = m.crc
+ io.WriteUint8(8, (crc))
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterDisconnectAdditionalInformation.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterDisconnectAdditionalInformation.go
new file mode 100644
index 0000000..fe3e138
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterDisconnectAdditionalInformation.go
@@ -0,0 +1,95 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type COTPParameterDisconnectAdditionalInformation struct {
+ data []uint8
+ COTPParameter
+}
+
+// The corresponding interface
+type ICOTPParameterDisconnectAdditionalInformation interface {
+ ICOTPParameter
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m COTPParameterDisconnectAdditionalInformation) ParameterType() uint8 {
+ return 0xE0
+}
+
+func (m COTPParameterDisconnectAdditionalInformation) initialize() spi.Message {
+ return m
+}
+
+func NewCOTPParameterDisconnectAdditionalInformation(data []uint8) COTPParameterInitializer {
+ return &COTPParameterDisconnectAdditionalInformation{data: data}
+}
+
+func (m COTPParameterDisconnectAdditionalInformation) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.COTPParameter.LengthInBits()
+
+ // Array field
+ if len(m.data) > 0 {
+ lengthInBits += 8 * uint16(len(m.data))
+ }
+
+ return lengthInBits
+}
+
+func (m COTPParameterDisconnectAdditionalInformation) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func COTPParameterDisconnectAdditionalInformationParse(io spi.ReadBuffer, rest uint8) (COTPParameterInitializer, error) {
+
+ // Array field (data)
+ var data []uint8
+ // Count array
+ {
+ data := make([]uint8, rest)
+ for curItem := uint16(0); curItem < uint16(rest); curItem++ {
+
+ data = append(data, io.ReadUint8(8))
+ }
+ }
+
+ // Create the instance
+ return NewCOTPParameterDisconnectAdditionalInformation(data), nil
+}
+
+func (m COTPParameterDisconnectAdditionalInformation) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(ICOTPParameterDisconnectAdditionalInformation); ok {
+
+ // Array Field (data)
+ if m.data != nil {
+ for _, _element := range m.data {
+ io.WriteUint8(8, _element)
+ }
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterTpduSize.go
similarity index 52%
copy from sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterTpduSize.go
index c4cd251..dbfdbe7 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPParameterTpduSize.go
@@ -19,71 +19,67 @@
package model
import (
+ "errors"
"plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
)
// The data-structure of this message
-type ModbusPDUError struct {
- exceptionCode uint8
- ModbusPDU
+type COTPParameterTpduSize struct {
+ tpduSize COTPTpduSize
+ COTPParameter
}
// The corresponding interface
-type IModbusPDUError interface {
- IModbusPDU
+type ICOTPParameterTpduSize interface {
+ ICOTPParameter
Serialize(io spi.WriteBuffer)
}
// Accessors for discriminator values.
-func (m ModbusPDUError) ErrorFlag() bool {
- return true
+func (m COTPParameterTpduSize) ParameterType() uint8 {
+ return 0xC0
}
-func (m ModbusPDUError) FunctionFlag() uint8 {
- return 0
+func (m COTPParameterTpduSize) initialize() spi.Message {
+ return m
}
-func (m ModbusPDUError) Response() bool {
- return false
+func NewCOTPParameterTpduSize(tpduSize COTPTpduSize) COTPParameterInitializer {
+ return &COTPParameterTpduSize{tpduSize: tpduSize}
}
-func (m ModbusPDUError) initialize() spi.Message {
- return spi.Message(m)
-}
-
-func NewModbusPDUError(exceptionCode uint8) ModbusPDUInitializer {
- return &ModbusPDUError{exceptionCode: exceptionCode}
-}
+func (m COTPParameterTpduSize) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.COTPParameter.LengthInBits()
-func (m ModbusPDUError) LengthInBits() uint16 {
- var lengthInBits uint16 = m.ModbusPDU.LengthInBits()
-
- // Simple field (exceptionCode)
+ // Enum Field (tpduSize)
lengthInBits += 8
return lengthInBits
}
-func (m ModbusPDUError) LengthInBytes() uint16 {
+func (m COTPParameterTpduSize) LengthInBytes() uint16 {
return m.LengthInBits() / 8
}
-func ModbusPDUErrorParse(io spi.ReadBuffer) (ModbusPDUInitializer, error) {
+func COTPParameterTpduSizeParse(io spi.ReadBuffer) (COTPParameterInitializer, error) {
- // Simple Field (exceptionCode)
- var exceptionCode uint8 = io.ReadUint8(8)
+ // Enum field (tpduSize)
+ tpduSize, _tpduSizeErr := COTPTpduSizeParse(io)
+ if _tpduSizeErr != nil {
+ return nil, errors.New("Error parsing 'tpduSize' field " + _tpduSizeErr.Error())
+ }
// Create the instance
- return NewModbusPDUError(exceptionCode), nil
+ return NewCOTPParameterTpduSize(tpduSize), nil
}
-func (m ModbusPDUError) Serialize(io spi.WriteBuffer) {
+func (m COTPParameterTpduSize) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(ICOTPParameterTpduSize); ok {
- // Simple Field (exceptionCode)
- var exceptionCode uint8 = m.exceptionCode
- io.WriteUint8(8, (exceptionCode))
+ // Enum field (tpduSize)
+ tpduSize := m.tpduSize
+ tpduSize.Serialize(io)
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPProtocolClass.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPProtocolClass.go
new file mode 100644
index 0000000..4713fc2
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPProtocolClass.go
@@ -0,0 +1,40 @@
+//
+// 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
+//
+// http://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 model
+
+import "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+
+type COTPProtocolClass int8
+
+const (
+ COTPProtocolClass_CLASS_0 COTPProtocolClass = 0x00
+ COTPProtocolClass_CLASS_1 COTPProtocolClass = 0x10
+ COTPProtocolClass_CLASS_2 COTPProtocolClass = 0x20
+ COTPProtocolClass_CLASS_3 COTPProtocolClass = 0x30
+ COTPProtocolClass_CLASS_4 COTPProtocolClass = 0x40
+)
+
+func COTPProtocolClassParse(io spi.ReadBuffer) (COTPProtocolClass, error) {
+ // TODO: Implement ...
+ return 0, nil
+}
+
+func (e COTPProtocolClass) Serialize(io spi.WriteBuffer) {
+ // TODO: Implement ...
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPTpduSize.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPTpduSize.go
new file mode 100644
index 0000000..4a2074b
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPTpduSize.go
@@ -0,0 +1,79 @@
+//
+// 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
+//
+// http://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 model
+
+import "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+
+type COTPTpduSize int8
+
+const (
+ COTPTpduSize_SIZE_128 COTPTpduSize = 0x07
+ COTPTpduSize_SIZE_256 COTPTpduSize = 0x08
+ COTPTpduSize_SIZE_512 COTPTpduSize = 0x09
+ COTPTpduSize_SIZE_1024 COTPTpduSize = 0x0a
+ COTPTpduSize_SIZE_2048 COTPTpduSize = 0x0b
+ COTPTpduSize_SIZE_4096 COTPTpduSize = 0x0c
+ COTPTpduSize_SIZE_8192 COTPTpduSize = 0x0d
+)
+
+func (e COTPTpduSize) GetSizeInBytes() uint16 {
+ switch e {
+ case 0x07:
+ { /* '0x07' */
+ return 128
+ }
+ case 0x08:
+ { /* '0x08' */
+ return 256
+ }
+ case 0x09:
+ { /* '0x09' */
+ return 512
+ }
+ case 0x0a:
+ { /* '0x0a' */
+ return 1024
+ }
+ case 0x0b:
+ { /* '0x0b' */
+ return 2048
+ }
+ case 0x0c:
+ { /* '0x0c' */
+ return 4096
+ }
+ case 0x0d:
+ { /* '0x0d' */
+ return 8192
+ }
+ default:
+ {
+ return 0
+ }
+ }
+}
+
+func COTPTpduSizeParse(io spi.ReadBuffer) (COTPTpduSize, error) {
+ // TODO: Implement ...
+ return 0, nil
+}
+
+func (e COTPTpduSize) Serialize(io spi.WriteBuffer) {
+ // TODO: Implement ...
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportErrorCode.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportErrorCode.go
new file mode 100644
index 0000000..1be3951
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportErrorCode.go
@@ -0,0 +1,41 @@
+//
+// 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
+//
+// http://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 model
+
+import "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+
+type DataTransportErrorCode uint8
+
+const (
+ DataTransportErrorCode_RESERVED DataTransportErrorCode = 0x00
+ DataTransportErrorCode_OK DataTransportErrorCode = 0xFF
+ DataTransportErrorCode_ACCESS_DENIED DataTransportErrorCode = 0x03
+ DataTransportErrorCode_INVALID_ADDRESS DataTransportErrorCode = 0x05
+ DataTransportErrorCode_DATA_TYPE_NOT_SUPPORTED DataTransportErrorCode = 0x06
+ DataTransportErrorCode_NOT_FOUND DataTransportErrorCode = 0x0A
+)
+
+func DataTransportErrorCodeParse(io spi.ReadBuffer) (DataTransportErrorCode, error) {
+ // TODO: Implement ...
+ return 0, nil
+}
+
+func (e DataTransportErrorCode) Serialize(io spi.WriteBuffer) {
+ // TODO: Implement ...
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportSize.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportSize.go
new file mode 100644
index 0000000..0d0e5e1
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportSize.go
@@ -0,0 +1,79 @@
+//
+// 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
+//
+// http://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 model
+
+import "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+
+type DataTransportSize uint8
+
+const (
+ DataTransportSize_NULL DataTransportSize = 0x00
+ DataTransportSize_BIT DataTransportSize = 0x03
+ DataTransportSize_BYTE_WORD_DWORD DataTransportSize = 0x04
+ DataTransportSize_INTEGER DataTransportSize = 0x05
+ DataTransportSize_DINTEGER DataTransportSize = 0x06
+ DataTransportSize_REAL DataTransportSize = 0x07
+ DataTransportSize_OCTET_STRING DataTransportSize = 0x09
+)
+
+func (e DataTransportSize) GetSizeInBits() bool {
+ switch e {
+ case 0x00:
+ { /* '0x00' */
+ return false
+ }
+ case 0x03:
+ { /* '0x03' */
+ return true
+ }
+ case 0x04:
+ { /* '0x04' */
+ return true
+ }
+ case 0x05:
+ { /* '0x05' */
+ return true
+ }
+ case 0x06:
+ { /* '0x06' */
+ return false
+ }
+ case 0x07:
+ { /* '0x07' */
+ return false
+ }
+ case 0x09:
+ { /* '0x09' */
+ return false
+ }
+ default:
+ {
+ return false
+ }
+ }
+}
+
+func DataTransportSizeParse(io spi.ReadBuffer) (DataTransportSize, error) {
+ // TODO: Implement ...
+ return 0, nil
+}
+
+func (e DataTransportSize) Serialize(io spi.WriteBuffer) {
+ // TODO: Implement ...
+}
diff --git a/sandbox/plc4go/cmd/modbus/modbus.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DeviceGroup.go
similarity index 55%
copy from sandbox/plc4go/cmd/modbus/modbus.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/DeviceGroup.go
index 1b1982a..9a97af4 100644
--- a/sandbox/plc4go/cmd/modbus/modbus.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DeviceGroup.go
@@ -1,3 +1,6 @@
+//
+// 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
@@ -13,26 +16,23 @@
// specific language governing permissions and limitations
// under the License.
//
-package main
+package model
+
+import "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
-import (
- "encoding/hex"
- "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/modbus/readwrite/model"
- "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+type DeviceGroup int8
+
+const (
+ DeviceGroup_PG_OR_PC DeviceGroup = 0x01
+ DeviceGroup_OS DeviceGroup = 0x02
+ DeviceGroup_OTHERS DeviceGroup = 0x03
)
-func main() {
- request, err := hex.DecodeString("000a00000006010300000004")
- if err != nil {
- // Output an error ...
- }
- rb := spi.ReadBufferNew(request)
- adu, err := model.ModbusTcpADUParse(*rb, false)
- if err != nil {
- // Output an error ...
- }
- if adu != nil {
- // Output success ...
- }
+func DeviceGroupParse(io spi.ReadBuffer) (DeviceGroup, error) {
+ // TODO: Implement ...
+ return 0, nil
+}
+func (e DeviceGroup) Serialize(io spi.WriteBuffer) {
+ // TODO: Implement ...
}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/MemoryArea.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/MemoryArea.go
new file mode 100644
index 0000000..6db38a1
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/MemoryArea.go
@@ -0,0 +1,89 @@
+//
+// 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
+//
+// http://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 model
+
+import "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+
+type MemoryArea uint8
+
+const (
+ MemoryArea_COUNTERS MemoryArea = 0x1C
+ MemoryArea_TIMERS MemoryArea = 0x1D
+ MemoryArea_DIRECT_PERIPHERAL_ACCESS MemoryArea = 0x80
+ MemoryArea_INPUTS MemoryArea = 0x81
+ MemoryArea_OUTPUTS MemoryArea = 0x82
+ MemoryArea_FLAGS_MARKERS MemoryArea = 0x83
+ MemoryArea_DATA_BLOCKS MemoryArea = 0x84
+ MemoryArea_INSTANCE_DATA_BLOCKS MemoryArea = 0x85
+ MemoryArea_LOCAL_DATA MemoryArea = 0x86
+)
+
+func (e MemoryArea) GetShortName() string {
+ switch e {
+ case 0x1C:
+ { /* '0x1C' */
+ return "C"
+ }
+ case 0x1D:
+ { /* '0x1D' */
+ return "T"
+ }
+ case 0x80:
+ { /* '0x80' */
+ return "D"
+ }
+ case 0x81:
+ { /* '0x81' */
+ return "I"
+ }
+ case 0x82:
+ { /* '0x82' */
+ return "Q"
+ }
+ case 0x83:
+ { /* '0x83' */
+ return "M"
+ }
+ case 0x84:
+ { /* '0x84' */
+ return "DB"
+ }
+ case 0x85:
+ { /* '0x85' */
+ return "DBI"
+ }
+ case 0x86:
+ { /* '0x86' */
+ return "LD"
+ }
+ default:
+ {
+ return ""
+ }
+ }
+}
+
+func MemoryAreaParse(io spi.ReadBuffer) (MemoryArea, error) {
+ // TODO: Implement ...
+ return 0, nil
+}
+
+func (e MemoryArea) Serialize(io spi.WriteBuffer) {
+ // TODO: Implement ...
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Address.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Address.go
new file mode 100644
index 0000000..00d04d4
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Address.go
@@ -0,0 +1,93 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7Address struct {
+}
+
+// The corresponding interface
+type IS7Address interface {
+ spi.Message
+ AddressType() uint8
+ Serialize(io spi.WriteBuffer)
+}
+
+type S7AddressInitializer interface {
+ initialize() spi.Message
+}
+
+func S7AddressAddressType(m IS7Address) uint8 {
+ return m.AddressType()
+}
+
+func (m S7Address) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Discriminator Field (addressType)
+ lengthInBits += 8
+
+ // Length of sub-type elements will be added by sub-type...
+
+ return lengthInBits
+}
+
+func (m S7Address) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7AddressParse(io spi.ReadBuffer) (spi.Message, error) {
+
+ // Discriminator Field (addressType) (Used as input to a switch field)
+ var addressType uint8 = io.ReadUint8(8)
+
+ // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
+ var initializer S7AddressInitializer
+ var typeSwitchError error
+ switch {
+ case addressType == 0x10:
+ initializer, typeSwitchError = S7AddressAnyParse(io)
+ }
+ if typeSwitchError != nil {
+ return nil, errors.New("Error parsing sub-type for type-switch. " + typeSwitchError.Error())
+ }
+
+ // Create the instance
+ return initializer.initialize(), nil
+}
+
+func (m S7Address) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if iS7Address, ok := typ.(IS7Address); ok {
+
+ // Discriminator Field (addressType) (Used as input to a switch field)
+ addressType := S7AddressAddressType(iS7Address)
+ io.WriteUint8(8, (addressType))
+
+ // Switch field (Depending on the discriminator values, passes the serialization to a sub-type)
+ iS7Address.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7AddressAny.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7AddressAny.go
new file mode 100644
index 0000000..2ed3d36
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7AddressAny.go
@@ -0,0 +1,162 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ log "github.com/sirupsen/logrus"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7AddressAny struct {
+ transportSize TransportSize
+ numberOfElements uint16
+ dbNumber uint16
+ area MemoryArea
+ byteAddress uint16
+ bitAddress uint8
+ S7Address
+}
+
+// The corresponding interface
+type IS7AddressAny interface {
+ IS7Address
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7AddressAny) AddressType() uint8 {
+ return 0x10
+}
+
+func (m S7AddressAny) initialize() spi.Message {
+ return m
+}
+
+func NewS7AddressAny(transportSize TransportSize, numberOfElements uint16, dbNumber uint16, area MemoryArea, byteAddress uint16, bitAddress uint8) S7AddressInitializer {
+ return &S7AddressAny{transportSize: transportSize, numberOfElements: numberOfElements, dbNumber: dbNumber, area: area, byteAddress: byteAddress, bitAddress: bitAddress}
+}
+
+func (m S7AddressAny) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Address.LengthInBits()
+
+ // Enum Field (transportSize)
+ lengthInBits += 8
+
+ // Simple field (numberOfElements)
+ lengthInBits += 16
+
+ // Simple field (dbNumber)
+ lengthInBits += 16
+
+ // Enum Field (area)
+ lengthInBits += 8
+
+ // Reserved Field (reserved)
+ lengthInBits += 5
+
+ // Simple field (byteAddress)
+ lengthInBits += 16
+
+ // Simple field (bitAddress)
+ lengthInBits += 3
+
+ return lengthInBits
+}
+
+func (m S7AddressAny) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7AddressAnyParse(io spi.ReadBuffer) (S7AddressInitializer, error) {
+
+ // Enum field (transportSize)
+ transportSize, _transportSizeErr := TransportSizeParse(io)
+ if _transportSizeErr != nil {
+ return nil, errors.New("Error parsing 'transportSize' field " + _transportSizeErr.Error())
+ }
+
+ // Simple Field (numberOfElements)
+ var numberOfElements uint16 = io.ReadUint16(16)
+
+ // Simple Field (dbNumber)
+ var dbNumber uint16 = io.ReadUint16(16)
+
+ // Enum field (area)
+ area, _areaErr := MemoryAreaParse(io)
+ if _areaErr != nil {
+ return nil, errors.New("Error parsing 'area' field " + _areaErr.Error())
+ }
+
+ // Reserved Field (Compartmentalized so the "reserved" variable can't leak)
+ {
+ var reserved uint8 = io.ReadUint8(5)
+ if reserved != uint8(0x00) {
+ log.WithFields(log.Fields{
+ "expected value": uint8(0x00),
+ "got value": reserved,
+ }).Info("Got unexpected response.")
+ }
+ }
+
+ // Simple Field (byteAddress)
+ var byteAddress uint16 = io.ReadUint16(16)
+
+ // Simple Field (bitAddress)
+ var bitAddress uint8 = io.ReadUint8(3)
+
+ // Create the instance
+ return NewS7AddressAny(transportSize, numberOfElements, dbNumber, area, byteAddress, bitAddress), nil
+}
+
+func (m S7AddressAny) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7AddressAny); ok {
+
+ // Enum field (transportSize)
+ transportSize := m.transportSize
+ transportSize.Serialize(io)
+
+ // Simple Field (numberOfElements)
+ var numberOfElements uint16 = m.numberOfElements
+ io.WriteUint16(16, (numberOfElements))
+
+ // Simple Field (dbNumber)
+ var dbNumber uint16 = m.dbNumber
+ io.WriteUint16(16, (dbNumber))
+
+ // Enum field (area)
+ area := m.area
+ area.Serialize(io)
+
+ // Reserved Field (reserved)
+ io.WriteUint8(5, uint8(0x00))
+
+ // Simple Field (byteAddress)
+ var byteAddress uint16 = m.byteAddress
+ io.WriteUint16(16, (byteAddress))
+
+ // Simple Field (bitAddress)
+ var bitAddress uint8 = m.bitAddress
+ io.WriteUint8(3, (bitAddress))
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Message.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Message.go
new file mode 100644
index 0000000..87119d7
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Message.go
@@ -0,0 +1,221 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ log "github.com/sirupsen/logrus"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+ "strconv"
+)
+
+// Constant values.
+const S7Message_PROTOCOLID uint8 = 0x32
+
+// The data-structure of this message
+type S7Message struct {
+ tpduReference uint16
+ parameter *S7Parameter
+ payload *S7Payload
+}
+
+// The corresponding interface
+type IS7Message interface {
+ spi.Message
+ MessageType() uint8
+ Serialize(io spi.WriteBuffer)
+}
+
+type S7MessageInitializer interface {
+ initialize(tpduReference uint16, parameter *S7Parameter, payload *S7Payload) spi.Message
+}
+
+func S7MessageMessageType(m IS7Message) uint8 {
+ return m.MessageType()
+}
+
+func (m S7Message) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Const Field (protocolId)
+ lengthInBits += 8
+
+ // Discriminator Field (messageType)
+ lengthInBits += 8
+
+ // Reserved Field (reserved)
+ lengthInBits += 16
+
+ // Simple field (tpduReference)
+ lengthInBits += 16
+
+ // Implicit Field (parameterLength)
+ lengthInBits += 16
+
+ // Implicit Field (payloadLength)
+ lengthInBits += 16
+
+ // Length of sub-type elements will be added by sub-type...
+
+ // Optional Field (parameter)
+ if m.parameter != nil {
+ lengthInBits += m.parameter.LengthInBits()
+ }
+
+ // Optional Field (payload)
+ if m.payload != nil {
+ lengthInBits += m.payload.LengthInBits()
+ }
+
+ return lengthInBits
+}
+
+func (m S7Message) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7MessageParse(io spi.ReadBuffer) (spi.Message, error) {
+
+ // Const Field (protocolId)
+ var protocolId uint8 = io.ReadUint8(8)
+ if protocolId != S7Message_PROTOCOLID {
+ return nil, errors.New("Expected constant value " + strconv.Itoa(int(S7Message_PROTOCOLID)) + " but got " + strconv.Itoa(int(protocolId)))
+ }
+
+ // Discriminator Field (messageType) (Used as input to a switch field)
+ var messageType uint8 = io.ReadUint8(8)
+
+ // Reserved Field (Compartmentalized so the "reserved" variable can't leak)
+ {
+ var reserved uint16 = io.ReadUint16(16)
+ if reserved != uint16(0x0000) {
+ log.WithFields(log.Fields{
+ "expected value": uint16(0x0000),
+ "got value": reserved,
+ }).Info("Got unexpected response.")
+ }
+ }
+
+ // Simple Field (tpduReference)
+ var tpduReference uint16 = io.ReadUint16(16)
+
+ // Implicit Field (parameterLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var parameterLength uint16 = io.ReadUint16(16)
+
+ // Implicit Field (payloadLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var payloadLength uint16 = io.ReadUint16(16)
+
+ // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
+ var initializer S7MessageInitializer
+ var typeSwitchError error
+ switch {
+ case messageType == 0x01:
+ initializer, typeSwitchError = S7MessageRequestParse(io)
+ case messageType == 0x02:
+ initializer, typeSwitchError = S7MessageResponseParse(io)
+ case messageType == 0x03:
+ initializer, typeSwitchError = S7MessageResponseDataParse(io)
+ case messageType == 0x07:
+ initializer, typeSwitchError = S7MessageUserDataParse(io)
+ }
+ if typeSwitchError != nil {
+ return nil, errors.New("Error parsing sub-type for type-switch. " + typeSwitchError.Error())
+ }
+
+ // Optional Field (parameter) (Can be skipped, if a given expression evaluates to false)
+ var parameter *S7Parameter = nil
+ if (parameterLength) > (0) {
+ _message, _err := S7ParameterParse(io, uint8(messageType))
+ if _err != nil {
+ return nil, errors.New("Error parsing 'parameter' field " + _err.Error())
+ }
+ var _item S7Parameter
+ _item, _ok := _message.(S7Parameter)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to S7Parameter")
+ }
+ parameter = &_item
+ }
+
+ // Optional Field (payload) (Can be skipped, if a given expression evaluates to false)
+ var payload *S7Payload = nil
+ if (payloadLength) > (0) {
+ _message, _err := S7PayloadParse(io, uint8(messageType), S7Parameter(parameter))
+ if _err != nil {
+ return nil, errors.New("Error parsing 'payload' field " + _err.Error())
+ }
+ var _item S7Payload
+ _item, _ok := _message.(S7Payload)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to S7Payload")
+ }
+ payload = &_item
+ }
+
+ // Create the instance
+ return initializer.initialize(tpduReference, parameter, payload), nil
+}
+
+func (m S7Message) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if iS7Message, ok := typ.(IS7Message); ok {
+
+ // Const Field (protocolId)
+ io.WriteUint8(8, 0x32)
+
+ // Discriminator Field (messageType) (Used as input to a switch field)
+ messageType := S7MessageMessageType(iS7Message)
+ io.WriteUint8(8, (messageType))
+
+ // Reserved Field (reserved)
+ io.WriteUint16(16, uint16(0x0000))
+
+ // Simple Field (tpduReference)
+ var tpduReference uint16 = m.tpduReference
+ io.WriteUint16(16, (tpduReference))
+
+ // Implicit Field (parameterLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ parameterLength := uint16(spi.InlineIf(((m.parameter) != (nil)), uint16(m.parameter.LengthInBytes()), uint16(0)))
+ io.WriteUint16(16, (parameterLength))
+
+ // Implicit Field (payloadLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ payloadLength := uint16(spi.InlineIf(((m.payload) != (nil)), uint16(m.payload.LengthInBytes()), uint16(0)))
+ io.WriteUint16(16, (payloadLength))
+
+ // Switch field (Depending on the discriminator values, passes the serialization to a sub-type)
+ iS7Message.Serialize(io)
+
+ // Optional Field (parameter) (Can be skipped, if the value is null)
+ var parameter *S7Parameter = nil
+ if m.parameter != nil {
+ parameter = m.parameter
+ parameter.Serialize(io)
+ }
+
+ // Optional Field (payload) (Can be skipped, if the value is null)
+ var payload *S7Payload = nil
+ if m.payload != nil {
+ payload = m.payload
+ payload.Serialize(io)
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageRequest.go
similarity index 55%
copy from sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageRequest.go
index 0e6437b..30d8aeb 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageRequest.go
@@ -23,56 +23,51 @@ import (
)
// The data-structure of this message
-type ModbusPDUReportServerIdRequest struct {
- ModbusPDU
+type S7MessageRequest struct {
+ S7Message
}
// The corresponding interface
-type IModbusPDUReportServerIdRequest interface {
- IModbusPDU
+type IS7MessageRequest interface {
+ IS7Message
Serialize(io spi.WriteBuffer)
}
// Accessors for discriminator values.
-func (m ModbusPDUReportServerIdRequest) ErrorFlag() bool {
- return false
+func (m S7MessageRequest) MessageType() uint8 {
+ return 0x01
}
-func (m ModbusPDUReportServerIdRequest) FunctionFlag() uint8 {
- return 0x11
+func (m S7MessageRequest) initialize(tpduReference uint16, parameter *S7Parameter, payload *S7Payload) spi.Message {
+ m.tpduReference = tpduReference
+ m.parameter = parameter
+ m.payload = payload
+ return m
}
-func (m ModbusPDUReportServerIdRequest) Response() bool {
- return false
+func NewS7MessageRequest() S7MessageInitializer {
+ return &S7MessageRequest{}
}
-func (m ModbusPDUReportServerIdRequest) initialize() spi.Message {
- return spi.Message(m)
-}
-
-func NewModbusPDUReportServerIdRequest() ModbusPDUInitializer {
- return &ModbusPDUReportServerIdRequest{}
-}
-
-func (m ModbusPDUReportServerIdRequest) LengthInBits() uint16 {
- var lengthInBits uint16 = m.ModbusPDU.LengthInBits()
+func (m S7MessageRequest) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Message.LengthInBits()
return lengthInBits
}
-func (m ModbusPDUReportServerIdRequest) LengthInBytes() uint16 {
+func (m S7MessageRequest) LengthInBytes() uint16 {
return m.LengthInBits() / 8
}
-func ModbusPDUReportServerIdRequestParse(io spi.ReadBuffer) (ModbusPDUInitializer, error) {
+func S7MessageRequestParse(io spi.ReadBuffer) (S7MessageInitializer, error) {
// Create the instance
- return NewModbusPDUReportServerIdRequest(), nil
+ return NewS7MessageRequest(), nil
}
-func (m ModbusPDUReportServerIdRequest) Serialize(io spi.WriteBuffer) {
+func (m S7MessageRequest) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IS7MessageRequest); ok {
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageResponse.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageResponse.go
new file mode 100644
index 0000000..04a02ec
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageResponse.go
@@ -0,0 +1,96 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7MessageResponse struct {
+ errorClass uint8
+ errorCode uint8
+ S7Message
+}
+
+// The corresponding interface
+type IS7MessageResponse interface {
+ IS7Message
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7MessageResponse) MessageType() uint8 {
+ return 0x02
+}
+
+func (m S7MessageResponse) initialize(tpduReference uint16, parameter *S7Parameter, payload *S7Payload) spi.Message {
+ m.tpduReference = tpduReference
+ m.parameter = parameter
+ m.payload = payload
+ return m
+}
+
+func NewS7MessageResponse(errorClass uint8, errorCode uint8) S7MessageInitializer {
+ return &S7MessageResponse{errorClass: errorClass, errorCode: errorCode}
+}
+
+func (m S7MessageResponse) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Message.LengthInBits()
+
+ // Simple field (errorClass)
+ lengthInBits += 8
+
+ // Simple field (errorCode)
+ lengthInBits += 8
+
+ return lengthInBits
+}
+
+func (m S7MessageResponse) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7MessageResponseParse(io spi.ReadBuffer) (S7MessageInitializer, error) {
+
+ // Simple Field (errorClass)
+ var errorClass uint8 = io.ReadUint8(8)
+
+ // Simple Field (errorCode)
+ var errorCode uint8 = io.ReadUint8(8)
+
+ // Create the instance
+ return NewS7MessageResponse(errorClass, errorCode), nil
+}
+
+func (m S7MessageResponse) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7MessageResponse); ok {
+
+ // Simple Field (errorClass)
+ var errorClass uint8 = m.errorClass
+ io.WriteUint8(8, (errorClass))
+
+ // Simple Field (errorCode)
+ var errorCode uint8 = m.errorCode
+ io.WriteUint8(8, (errorCode))
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageResponseData.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageResponseData.go
new file mode 100644
index 0000000..7afbb1b
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageResponseData.go
@@ -0,0 +1,96 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7MessageResponseData struct {
+ errorClass uint8
+ errorCode uint8
+ S7Message
+}
+
+// The corresponding interface
+type IS7MessageResponseData interface {
+ IS7Message
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7MessageResponseData) MessageType() uint8 {
+ return 0x03
+}
+
+func (m S7MessageResponseData) initialize(tpduReference uint16, parameter *S7Parameter, payload *S7Payload) spi.Message {
+ m.tpduReference = tpduReference
+ m.parameter = parameter
+ m.payload = payload
+ return m
+}
+
+func NewS7MessageResponseData(errorClass uint8, errorCode uint8) S7MessageInitializer {
+ return &S7MessageResponseData{errorClass: errorClass, errorCode: errorCode}
+}
+
+func (m S7MessageResponseData) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Message.LengthInBits()
+
+ // Simple field (errorClass)
+ lengthInBits += 8
+
+ // Simple field (errorCode)
+ lengthInBits += 8
+
+ return lengthInBits
+}
+
+func (m S7MessageResponseData) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7MessageResponseDataParse(io spi.ReadBuffer) (S7MessageInitializer, error) {
+
+ // Simple Field (errorClass)
+ var errorClass uint8 = io.ReadUint8(8)
+
+ // Simple Field (errorCode)
+ var errorCode uint8 = io.ReadUint8(8)
+
+ // Create the instance
+ return NewS7MessageResponseData(errorClass, errorCode), nil
+}
+
+func (m S7MessageResponseData) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7MessageResponseData); ok {
+
+ // Simple Field (errorClass)
+ var errorClass uint8 = m.errorClass
+ io.WriteUint8(8, (errorClass))
+
+ // Simple Field (errorCode)
+ var errorCode uint8 = m.errorCode
+ io.WriteUint8(8, (errorCode))
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageUserData.go
similarity index 55%
copy from sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageUserData.go
index 0e6437b..40dc655 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUReportServerIdRequest.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7MessageUserData.go
@@ -23,56 +23,51 @@ import (
)
// The data-structure of this message
-type ModbusPDUReportServerIdRequest struct {
- ModbusPDU
+type S7MessageUserData struct {
+ S7Message
}
// The corresponding interface
-type IModbusPDUReportServerIdRequest interface {
- IModbusPDU
+type IS7MessageUserData interface {
+ IS7Message
Serialize(io spi.WriteBuffer)
}
// Accessors for discriminator values.
-func (m ModbusPDUReportServerIdRequest) ErrorFlag() bool {
- return false
+func (m S7MessageUserData) MessageType() uint8 {
+ return 0x07
}
-func (m ModbusPDUReportServerIdRequest) FunctionFlag() uint8 {
- return 0x11
+func (m S7MessageUserData) initialize(tpduReference uint16, parameter *S7Parameter, payload *S7Payload) spi.Message {
+ m.tpduReference = tpduReference
+ m.parameter = parameter
+ m.payload = payload
+ return m
}
-func (m ModbusPDUReportServerIdRequest) Response() bool {
- return false
+func NewS7MessageUserData() S7MessageInitializer {
+ return &S7MessageUserData{}
}
-func (m ModbusPDUReportServerIdRequest) initialize() spi.Message {
- return spi.Message(m)
-}
-
-func NewModbusPDUReportServerIdRequest() ModbusPDUInitializer {
- return &ModbusPDUReportServerIdRequest{}
-}
-
-func (m ModbusPDUReportServerIdRequest) LengthInBits() uint16 {
- var lengthInBits uint16 = m.ModbusPDU.LengthInBits()
+func (m S7MessageUserData) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Message.LengthInBits()
return lengthInBits
}
-func (m ModbusPDUReportServerIdRequest) LengthInBytes() uint16 {
+func (m S7MessageUserData) LengthInBytes() uint16 {
return m.LengthInBits() / 8
}
-func ModbusPDUReportServerIdRequestParse(io spi.ReadBuffer) (ModbusPDUInitializer, error) {
+func S7MessageUserDataParse(io spi.ReadBuffer) (S7MessageInitializer, error) {
// Create the instance
- return NewModbusPDUReportServerIdRequest(), nil
+ return NewS7MessageUserData(), nil
}
-func (m ModbusPDUReportServerIdRequest) Serialize(io spi.WriteBuffer) {
+func (m S7MessageUserData) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IS7MessageUserData); ok {
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Parameter.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Parameter.go
new file mode 100644
index 0000000..4c4d066
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Parameter.go
@@ -0,0 +1,108 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7Parameter struct {
+}
+
+// The corresponding interface
+type IS7Parameter interface {
+ spi.Message
+ MessageType() uint8
+ ParameterType() uint8
+ Serialize(io spi.WriteBuffer)
+}
+
+type S7ParameterInitializer interface {
+ initialize() spi.Message
+}
+
+func S7ParameterMessageType(m IS7Parameter) uint8 {
+ return m.MessageType()
+}
+
+func S7ParameterParameterType(m IS7Parameter) uint8 {
+ return m.ParameterType()
+}
+
+func (m S7Parameter) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Discriminator Field (parameterType)
+ lengthInBits += 8
+
+ // Length of sub-type elements will be added by sub-type...
+
+ return lengthInBits
+}
+
+func (m S7Parameter) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7ParameterParse(io spi.ReadBuffer, messageType uint8) (spi.Message, error) {
+
+ // Discriminator Field (parameterType) (Used as input to a switch field)
+ var parameterType uint8 = io.ReadUint8(8)
+
+ // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
+ var initializer S7ParameterInitializer
+ var typeSwitchError error
+ switch {
+ case parameterType == 0xF0:
+ initializer, typeSwitchError = S7ParameterSetupCommunicationParse(io)
+ case parameterType == 0x04 && messageType == 0x01:
+ initializer, typeSwitchError = S7ParameterReadVarRequestParse(io)
+ case parameterType == 0x04 && messageType == 0x03:
+ initializer, typeSwitchError = S7ParameterReadVarResponseParse(io)
+ case parameterType == 0x05 && messageType == 0x01:
+ initializer, typeSwitchError = S7ParameterWriteVarRequestParse(io)
+ case parameterType == 0x05 && messageType == 0x03:
+ initializer, typeSwitchError = S7ParameterWriteVarResponseParse(io)
+ case parameterType == 0x00 && messageType == 0x07:
+ initializer, typeSwitchError = S7ParameterUserDataParse(io)
+ }
+ if typeSwitchError != nil {
+ return nil, errors.New("Error parsing sub-type for type-switch. " + typeSwitchError.Error())
+ }
+
+ // Create the instance
+ return initializer.initialize(), nil
+}
+
+func (m S7Parameter) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if iS7Parameter, ok := typ.(IS7Parameter); ok {
+
+ // Discriminator Field (parameterType) (Used as input to a switch field)
+ parameterType := S7ParameterParameterType(iS7Parameter)
+ io.WriteUint8(8, (parameterType))
+
+ // Switch field (Depending on the discriminator values, passes the serialization to a sub-type)
+ iS7Parameter.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterReadVarRequest.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterReadVarRequest.go
new file mode 100644
index 0000000..a499b2d
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterReadVarRequest.go
@@ -0,0 +1,122 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+)
+
+// The data-structure of this message
+type S7ParameterReadVarRequest struct {
+ items []S7VarRequestParameterItem
+ S7Parameter
+}
+
+// The corresponding interface
+type IS7ParameterReadVarRequest interface {
+ IS7Parameter
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7ParameterReadVarRequest) ParameterType() uint8 {
+ return 0x04
+}
+
+func (m S7ParameterReadVarRequest) MessageType() uint8 {
+ return 0x01
+}
+
+func (m S7ParameterReadVarRequest) initialize() spi.Message {
+ return m
+}
+
+func NewS7ParameterReadVarRequest(items []S7VarRequestParameterItem) S7ParameterInitializer {
+ return &S7ParameterReadVarRequest{items: items}
+}
+
+func (m S7ParameterReadVarRequest) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Parameter.LengthInBits()
+
+ // Implicit Field (numItems)
+ lengthInBits += 8
+
+ // Array field
+ if len(m.items) > 0 {
+ for _, element := range m.items {
+ lengthInBits += element.LengthInBits()
+ }
+ }
+
+ return lengthInBits
+}
+
+func (m S7ParameterReadVarRequest) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7ParameterReadVarRequestParse(io spi.ReadBuffer) (S7ParameterInitializer, error) {
+
+ // Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var numItems uint8 = io.ReadUint8(8)
+
+ // Array field (items)
+ var items []S7VarRequestParameterItem
+ // Count array
+ {
+ items := make([]S7VarRequestParameterItem, numItems)
+ for curItem := uint16(0); curItem < uint16(numItems); curItem++ {
+
+ _message, _err := S7VarRequestParameterItemParse(io)
+ if _err != nil {
+ return nil, errors.New("Error parsing 'items' field " + _err.Error())
+ }
+ var _item S7VarRequestParameterItem
+ _item, _ok := _message.(S7VarRequestParameterItem)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to S7VarRequestParameterItem")
+ }
+ items = append(items, _item)
+ }
+ }
+
+ // Create the instance
+ return NewS7ParameterReadVarRequest(items), nil
+}
+
+func (m S7ParameterReadVarRequest) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7ParameterReadVarRequest); ok {
+
+ // Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ numItems := uint8(uint8(len(m.items)))
+ io.WriteUint8(8, (numItems))
+
+ // Array Field (items)
+ if m.items != nil {
+ for _, _element := range m.items {
+ _element.Serialize(io)
+ }
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterReadVarResponse.go
similarity index 52%
copy from sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterReadVarResponse.go
index c4cd251..84f934e 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterReadVarResponse.go
@@ -23,67 +23,63 @@ import (
)
// The data-structure of this message
-type ModbusPDUError struct {
- exceptionCode uint8
- ModbusPDU
+type S7ParameterReadVarResponse struct {
+ numItems uint8
+ S7Parameter
}
// The corresponding interface
-type IModbusPDUError interface {
- IModbusPDU
+type IS7ParameterReadVarResponse interface {
+ IS7Parameter
Serialize(io spi.WriteBuffer)
}
// Accessors for discriminator values.
-func (m ModbusPDUError) ErrorFlag() bool {
- return true
+func (m S7ParameterReadVarResponse) ParameterType() uint8 {
+ return 0x04
}
-func (m ModbusPDUError) FunctionFlag() uint8 {
- return 0
+func (m S7ParameterReadVarResponse) MessageType() uint8 {
+ return 0x03
}
-func (m ModbusPDUError) Response() bool {
- return false
+func (m S7ParameterReadVarResponse) initialize() spi.Message {
+ return m
}
-func (m ModbusPDUError) initialize() spi.Message {
- return spi.Message(m)
+func NewS7ParameterReadVarResponse(numItems uint8) S7ParameterInitializer {
+ return &S7ParameterReadVarResponse{numItems: numItems}
}
-func NewModbusPDUError(exceptionCode uint8) ModbusPDUInitializer {
- return &ModbusPDUError{exceptionCode: exceptionCode}
-}
-
-func (m ModbusPDUError) LengthInBits() uint16 {
- var lengthInBits uint16 = m.ModbusPDU.LengthInBits()
+func (m S7ParameterReadVarResponse) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Parameter.LengthInBits()
- // Simple field (exceptionCode)
+ // Simple field (numItems)
lengthInBits += 8
return lengthInBits
}
-func (m ModbusPDUError) LengthInBytes() uint16 {
+func (m S7ParameterReadVarResponse) LengthInBytes() uint16 {
return m.LengthInBits() / 8
}
-func ModbusPDUErrorParse(io spi.ReadBuffer) (ModbusPDUInitializer, error) {
+func S7ParameterReadVarResponseParse(io spi.ReadBuffer) (S7ParameterInitializer, error) {
- // Simple Field (exceptionCode)
- var exceptionCode uint8 = io.ReadUint8(8)
+ // Simple Field (numItems)
+ var numItems uint8 = io.ReadUint8(8)
// Create the instance
- return NewModbusPDUError(exceptionCode), nil
+ return NewS7ParameterReadVarResponse(numItems), nil
}
-func (m ModbusPDUError) Serialize(io spi.WriteBuffer) {
+func (m S7ParameterReadVarResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IS7ParameterReadVarResponse); ok {
- // Simple Field (exceptionCode)
- var exceptionCode uint8 = m.exceptionCode
- io.WriteUint8(8, (exceptionCode))
+ // Simple Field (numItems)
+ var numItems uint8 = m.numItems
+ io.WriteUint8(8, (numItems))
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterSetupCommunication.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterSetupCommunication.go
new file mode 100644
index 0000000..c43d6c8
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterSetupCommunication.go
@@ -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
+//
+// http://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 model
+
+import (
+ log "github.com/sirupsen/logrus"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7ParameterSetupCommunication struct {
+ maxAmqCaller uint16
+ maxAmqCallee uint16
+ pduLength uint16
+ S7Parameter
+}
+
+// The corresponding interface
+type IS7ParameterSetupCommunication interface {
+ IS7Parameter
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7ParameterSetupCommunication) ParameterType() uint8 {
+ return 0xF0
+}
+
+func (m S7ParameterSetupCommunication) MessageType() uint8 {
+ return 0
+}
+
+func (m S7ParameterSetupCommunication) initialize() spi.Message {
+ return m
+}
+
+func NewS7ParameterSetupCommunication(maxAmqCaller uint16, maxAmqCallee uint16, pduLength uint16) S7ParameterInitializer {
+ return &S7ParameterSetupCommunication{maxAmqCaller: maxAmqCaller, maxAmqCallee: maxAmqCallee, pduLength: pduLength}
+}
+
+func (m S7ParameterSetupCommunication) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Parameter.LengthInBits()
+
+ // Reserved Field (reserved)
+ lengthInBits += 8
+
+ // Simple field (maxAmqCaller)
+ lengthInBits += 16
+
+ // Simple field (maxAmqCallee)
+ lengthInBits += 16
+
+ // Simple field (pduLength)
+ lengthInBits += 16
+
+ return lengthInBits
+}
+
+func (m S7ParameterSetupCommunication) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7ParameterSetupCommunicationParse(io spi.ReadBuffer) (S7ParameterInitializer, error) {
+
+ // Reserved Field (Compartmentalized so the "reserved" variable can't leak)
+ {
+ var reserved uint8 = io.ReadUint8(8)
+ if reserved != uint8(0x00) {
+ log.WithFields(log.Fields{
+ "expected value": uint8(0x00),
+ "got value": reserved,
+ }).Info("Got unexpected response.")
+ }
+ }
+
+ // Simple Field (maxAmqCaller)
+ var maxAmqCaller uint16 = io.ReadUint16(16)
+
+ // Simple Field (maxAmqCallee)
+ var maxAmqCallee uint16 = io.ReadUint16(16)
+
+ // Simple Field (pduLength)
+ var pduLength uint16 = io.ReadUint16(16)
+
+ // Create the instance
+ return NewS7ParameterSetupCommunication(maxAmqCaller, maxAmqCallee, pduLength), nil
+}
+
+func (m S7ParameterSetupCommunication) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7ParameterSetupCommunication); ok {
+
+ // Reserved Field (reserved)
+ io.WriteUint8(8, uint8(0x00))
+
+ // Simple Field (maxAmqCaller)
+ var maxAmqCaller uint16 = m.maxAmqCaller
+ io.WriteUint16(16, (maxAmqCaller))
+
+ // Simple Field (maxAmqCallee)
+ var maxAmqCallee uint16 = m.maxAmqCallee
+ io.WriteUint16(16, (maxAmqCallee))
+
+ // Simple Field (pduLength)
+ var pduLength uint16 = m.pduLength
+ io.WriteUint16(16, (pduLength))
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterUserData.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterUserData.go
new file mode 100644
index 0000000..7a38ba7
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterUserData.go
@@ -0,0 +1,122 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+)
+
+// The data-structure of this message
+type S7ParameterUserData struct {
+ items []S7ParameterUserDataItem
+ S7Parameter
+}
+
+// The corresponding interface
+type IS7ParameterUserData interface {
+ IS7Parameter
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7ParameterUserData) ParameterType() uint8 {
+ return 0x00
+}
+
+func (m S7ParameterUserData) MessageType() uint8 {
+ return 0x07
+}
+
+func (m S7ParameterUserData) initialize() spi.Message {
+ return m
+}
+
+func NewS7ParameterUserData(items []S7ParameterUserDataItem) S7ParameterInitializer {
+ return &S7ParameterUserData{items: items}
+}
+
+func (m S7ParameterUserData) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Parameter.LengthInBits()
+
+ // Implicit Field (numItems)
+ lengthInBits += 8
+
+ // Array field
+ if len(m.items) > 0 {
+ for _, element := range m.items {
+ lengthInBits += element.LengthInBits()
+ }
+ }
+
+ return lengthInBits
+}
+
+func (m S7ParameterUserData) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7ParameterUserDataParse(io spi.ReadBuffer) (S7ParameterInitializer, error) {
+
+ // Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var numItems uint8 = io.ReadUint8(8)
+
+ // Array field (items)
+ var items []S7ParameterUserDataItem
+ // Count array
+ {
+ items := make([]S7ParameterUserDataItem, numItems)
+ for curItem := uint16(0); curItem < uint16(numItems); curItem++ {
+
+ _message, _err := S7ParameterUserDataItemParse(io)
+ if _err != nil {
+ return nil, errors.New("Error parsing 'items' field " + _err.Error())
+ }
+ var _item S7ParameterUserDataItem
+ _item, _ok := _message.(S7ParameterUserDataItem)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to S7ParameterUserDataItem")
+ }
+ items = append(items, _item)
+ }
+ }
+
+ // Create the instance
+ return NewS7ParameterUserData(items), nil
+}
+
+func (m S7ParameterUserData) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7ParameterUserData); ok {
+
+ // Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ numItems := uint8(uint8(len(m.items)))
+ io.WriteUint8(8, (numItems))
+
+ // Array Field (items)
+ if m.items != nil {
+ for _, _element := range m.items {
+ _element.Serialize(io)
+ }
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterUserDataItem.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterUserDataItem.go
new file mode 100644
index 0000000..5c3eea8
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterUserDataItem.go
@@ -0,0 +1,93 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7ParameterUserDataItem struct {
+}
+
+// The corresponding interface
+type IS7ParameterUserDataItem interface {
+ spi.Message
+ ItemType() uint8
+ Serialize(io spi.WriteBuffer)
+}
+
+type S7ParameterUserDataItemInitializer interface {
+ initialize() spi.Message
+}
+
+func S7ParameterUserDataItemItemType(m IS7ParameterUserDataItem) uint8 {
+ return m.ItemType()
+}
+
+func (m S7ParameterUserDataItem) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Discriminator Field (itemType)
+ lengthInBits += 8
+
+ // Length of sub-type elements will be added by sub-type...
+
+ return lengthInBits
+}
+
+func (m S7ParameterUserDataItem) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7ParameterUserDataItemParse(io spi.ReadBuffer) (spi.Message, error) {
+
+ // Discriminator Field (itemType) (Used as input to a switch field)
+ var itemType uint8 = io.ReadUint8(8)
+
+ // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
+ var initializer S7ParameterUserDataItemInitializer
+ var typeSwitchError error
+ switch {
+ case itemType == 0x12:
+ initializer, typeSwitchError = S7ParameterUserDataItemCPUFunctionsParse(io)
+ }
+ if typeSwitchError != nil {
+ return nil, errors.New("Error parsing sub-type for type-switch. " + typeSwitchError.Error())
+ }
+
+ // Create the instance
+ return initializer.initialize(), nil
+}
+
+func (m S7ParameterUserDataItem) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if iS7ParameterUserDataItem, ok := typ.(IS7ParameterUserDataItem); ok {
+
+ // Discriminator Field (itemType) (Used as input to a switch field)
+ itemType := S7ParameterUserDataItemItemType(iS7ParameterUserDataItem)
+ io.WriteUint8(8, (itemType))
+
+ // Switch field (Depending on the discriminator values, passes the serialization to a sub-type)
+ iS7ParameterUserDataItem.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterUserDataItemCPUFunctions.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterUserDataItemCPUFunctions.go
new file mode 100644
index 0000000..b12aa9a
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterUserDataItemCPUFunctions.go
@@ -0,0 +1,196 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7ParameterUserDataItemCPUFunctions struct {
+ method uint8
+ cpuFunctionType uint8
+ cpuFunctionGroup uint8
+ cpuSubfunction uint8
+ sequenceNumber uint8
+ dataUnitReferenceNumber *uint8
+ lastDataUnit *uint8
+ errorCode *uint16
+ S7ParameterUserDataItem
+}
+
+// The corresponding interface
+type IS7ParameterUserDataItemCPUFunctions interface {
+ IS7ParameterUserDataItem
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7ParameterUserDataItemCPUFunctions) ItemType() uint8 {
+ return 0x12
+}
+
+func (m S7ParameterUserDataItemCPUFunctions) initialize() spi.Message {
+ return m
+}
+
+func NewS7ParameterUserDataItemCPUFunctions(method uint8, cpuFunctionType uint8, cpuFunctionGroup uint8, cpuSubfunction uint8, sequenceNumber uint8, dataUnitReferenceNumber *uint8, lastDataUnit *uint8, errorCode *uint16) S7ParameterUserDataItemInitializer {
+ return &S7ParameterUserDataItemCPUFunctions{method: method, cpuFunctionType: cpuFunctionType, cpuFunctionGroup: cpuFunctionGroup, cpuSubfunction: cpuSubfunction, sequenceNumber: sequenceNumber, dataUnitReferenceNumber: dataUnitReferenceNumber, lastDataUnit: lastDataUnit, errorCode: errorCode}
+}
+
+func (m S7ParameterUserDataItemCPUFunctions) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7ParameterUserDataItem.LengthInBits()
+
+ // Implicit Field (itemLength)
+ lengthInBits += 8
+
+ // Simple field (method)
+ lengthInBits += 8
+
+ // Simple field (cpuFunctionType)
+ lengthInBits += 4
+
+ // Simple field (cpuFunctionGroup)
+ lengthInBits += 4
+
+ // Simple field (cpuSubfunction)
+ lengthInBits += 8
+
+ // Simple field (sequenceNumber)
+ lengthInBits += 8
+
+ // Optional Field (dataUnitReferenceNumber)
+ if m.dataUnitReferenceNumber != nil {
+ lengthInBits += 8
+ }
+
+ // Optional Field (lastDataUnit)
+ if m.lastDataUnit != nil {
+ lengthInBits += 8
+ }
+
+ // Optional Field (errorCode)
+ if m.errorCode != nil {
+ lengthInBits += 16
+ }
+
+ return lengthInBits
+}
+
+func (m S7ParameterUserDataItemCPUFunctions) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7ParameterUserDataItemCPUFunctionsParse(io spi.ReadBuffer) (S7ParameterUserDataItemInitializer, error) {
+
+ // Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var _ uint8 = io.ReadUint8(8)
+
+ // Simple Field (method)
+ var method uint8 = io.ReadUint8(8)
+
+ // Simple Field (cpuFunctionType)
+ var cpuFunctionType uint8 = io.ReadUint8(4)
+
+ // Simple Field (cpuFunctionGroup)
+ var cpuFunctionGroup uint8 = io.ReadUint8(4)
+
+ // Simple Field (cpuSubfunction)
+ var cpuSubfunction uint8 = io.ReadUint8(8)
+
+ // Simple Field (sequenceNumber)
+ var sequenceNumber uint8 = io.ReadUint8(8)
+
+ // Optional Field (dataUnitReferenceNumber) (Can be skipped, if a given expression evaluates to false)
+ var dataUnitReferenceNumber *uint8 = nil
+ if (cpuFunctionType) == (8) {
+ _val := io.ReadUint8(8)
+ dataUnitReferenceNumber = &_val
+ }
+
+ // Optional Field (lastDataUnit) (Can be skipped, if a given expression evaluates to false)
+ var lastDataUnit *uint8 = nil
+ if (cpuFunctionType) == (8) {
+ _val := io.ReadUint8(8)
+ lastDataUnit = &_val
+ }
+
+ // Optional Field (errorCode) (Can be skipped, if a given expression evaluates to false)
+ var errorCode *uint16 = nil
+ if (cpuFunctionType) == (8) {
+ _val := io.ReadUint16(16)
+ errorCode = &_val
+ }
+
+ // Create the instance
+ return NewS7ParameterUserDataItemCPUFunctions(method, cpuFunctionType, cpuFunctionGroup, cpuSubfunction, sequenceNumber, dataUnitReferenceNumber, lastDataUnit, errorCode), nil
+}
+
+func (m S7ParameterUserDataItemCPUFunctions) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7ParameterUserDataItemCPUFunctions); ok {
+
+ // Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ itemLength := uint8((m.LengthInBytes()) - (2))
+ io.WriteUint8(8, (itemLength))
+
+ // Simple Field (method)
+ var method uint8 = m.method
+ io.WriteUint8(8, (method))
+
+ // Simple Field (cpuFunctionType)
+ var cpuFunctionType uint8 = m.cpuFunctionType
+ io.WriteUint8(4, (cpuFunctionType))
+
+ // Simple Field (cpuFunctionGroup)
+ var cpuFunctionGroup uint8 = m.cpuFunctionGroup
+ io.WriteUint8(4, (cpuFunctionGroup))
+
+ // Simple Field (cpuSubfunction)
+ var cpuSubfunction uint8 = m.cpuSubfunction
+ io.WriteUint8(8, (cpuSubfunction))
+
+ // Simple Field (sequenceNumber)
+ var sequenceNumber uint8 = m.sequenceNumber
+ io.WriteUint8(8, (sequenceNumber))
+
+ // Optional Field (dataUnitReferenceNumber) (Can be skipped, if the value is null)
+ var dataUnitReferenceNumber *uint8 = nil
+ if m.dataUnitReferenceNumber != nil {
+ dataUnitReferenceNumber = m.dataUnitReferenceNumber
+ io.WriteUint8(8, *(dataUnitReferenceNumber))
+ }
+
+ // Optional Field (lastDataUnit) (Can be skipped, if the value is null)
+ var lastDataUnit *uint8 = nil
+ if m.lastDataUnit != nil {
+ lastDataUnit = m.lastDataUnit
+ io.WriteUint8(8, *(lastDataUnit))
+ }
+
+ // Optional Field (errorCode) (Can be skipped, if the value is null)
+ var errorCode *uint16 = nil
+ if m.errorCode != nil {
+ errorCode = m.errorCode
+ io.WriteUint16(16, *(errorCode))
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterWriteVarRequest.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterWriteVarRequest.go
new file mode 100644
index 0000000..83f194e
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterWriteVarRequest.go
@@ -0,0 +1,122 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+)
+
+// The data-structure of this message
+type S7ParameterWriteVarRequest struct {
+ items []S7VarRequestParameterItem
+ S7Parameter
+}
+
+// The corresponding interface
+type IS7ParameterWriteVarRequest interface {
+ IS7Parameter
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7ParameterWriteVarRequest) ParameterType() uint8 {
+ return 0x05
+}
+
+func (m S7ParameterWriteVarRequest) MessageType() uint8 {
+ return 0x01
+}
+
+func (m S7ParameterWriteVarRequest) initialize() spi.Message {
+ return m
+}
+
+func NewS7ParameterWriteVarRequest(items []S7VarRequestParameterItem) S7ParameterInitializer {
+ return &S7ParameterWriteVarRequest{items: items}
+}
+
+func (m S7ParameterWriteVarRequest) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Parameter.LengthInBits()
+
+ // Implicit Field (numItems)
+ lengthInBits += 8
+
+ // Array field
+ if len(m.items) > 0 {
+ for _, element := range m.items {
+ lengthInBits += element.LengthInBits()
+ }
+ }
+
+ return lengthInBits
+}
+
+func (m S7ParameterWriteVarRequest) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7ParameterWriteVarRequestParse(io spi.ReadBuffer) (S7ParameterInitializer, error) {
+
+ // Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var numItems uint8 = io.ReadUint8(8)
+
+ // Array field (items)
+ var items []S7VarRequestParameterItem
+ // Count array
+ {
+ items := make([]S7VarRequestParameterItem, numItems)
+ for curItem := uint16(0); curItem < uint16(numItems); curItem++ {
+
+ _message, _err := S7VarRequestParameterItemParse(io)
+ if _err != nil {
+ return nil, errors.New("Error parsing 'items' field " + _err.Error())
+ }
+ var _item S7VarRequestParameterItem
+ _item, _ok := _message.(S7VarRequestParameterItem)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to S7VarRequestParameterItem")
+ }
+ items = append(items, _item)
+ }
+ }
+
+ // Create the instance
+ return NewS7ParameterWriteVarRequest(items), nil
+}
+
+func (m S7ParameterWriteVarRequest) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7ParameterWriteVarRequest); ok {
+
+ // Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ numItems := uint8(uint8(len(m.items)))
+ io.WriteUint8(8, (numItems))
+
+ // Array Field (items)
+ if m.items != nil {
+ for _, _element := range m.items {
+ _element.Serialize(io)
+ }
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterWriteVarResponse.go
similarity index 52%
copy from sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterWriteVarResponse.go
index c4cd251..1a84d7c 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusPDUError.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7ParameterWriteVarResponse.go
@@ -23,67 +23,63 @@ import (
)
// The data-structure of this message
-type ModbusPDUError struct {
- exceptionCode uint8
- ModbusPDU
+type S7ParameterWriteVarResponse struct {
+ numItems uint8
+ S7Parameter
}
// The corresponding interface
-type IModbusPDUError interface {
- IModbusPDU
+type IS7ParameterWriteVarResponse interface {
+ IS7Parameter
Serialize(io spi.WriteBuffer)
}
// Accessors for discriminator values.
-func (m ModbusPDUError) ErrorFlag() bool {
- return true
+func (m S7ParameterWriteVarResponse) ParameterType() uint8 {
+ return 0x05
}
-func (m ModbusPDUError) FunctionFlag() uint8 {
- return 0
+func (m S7ParameterWriteVarResponse) MessageType() uint8 {
+ return 0x03
}
-func (m ModbusPDUError) Response() bool {
- return false
+func (m S7ParameterWriteVarResponse) initialize() spi.Message {
+ return m
}
-func (m ModbusPDUError) initialize() spi.Message {
- return spi.Message(m)
+func NewS7ParameterWriteVarResponse(numItems uint8) S7ParameterInitializer {
+ return &S7ParameterWriteVarResponse{numItems: numItems}
}
-func NewModbusPDUError(exceptionCode uint8) ModbusPDUInitializer {
- return &ModbusPDUError{exceptionCode: exceptionCode}
-}
-
-func (m ModbusPDUError) LengthInBits() uint16 {
- var lengthInBits uint16 = m.ModbusPDU.LengthInBits()
+func (m S7ParameterWriteVarResponse) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Parameter.LengthInBits()
- // Simple field (exceptionCode)
+ // Simple field (numItems)
lengthInBits += 8
return lengthInBits
}
-func (m ModbusPDUError) LengthInBytes() uint16 {
+func (m S7ParameterWriteVarResponse) LengthInBytes() uint16 {
return m.LengthInBits() / 8
}
-func ModbusPDUErrorParse(io spi.ReadBuffer) (ModbusPDUInitializer, error) {
+func S7ParameterWriteVarResponseParse(io spi.ReadBuffer) (S7ParameterInitializer, error) {
- // Simple Field (exceptionCode)
- var exceptionCode uint8 = io.ReadUint8(8)
+ // Simple Field (numItems)
+ var numItems uint8 = io.ReadUint8(8)
// Create the instance
- return NewModbusPDUError(exceptionCode), nil
+ return NewS7ParameterWriteVarResponse(numItems), nil
}
-func (m ModbusPDUError) Serialize(io spi.WriteBuffer) {
+func (m S7ParameterWriteVarResponse) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IS7ParameterWriteVarResponse); ok {
- // Simple Field (exceptionCode)
- var exceptionCode uint8 = m.exceptionCode
- io.WriteUint8(8, (exceptionCode))
+ // Simple Field (numItems)
+ var numItems uint8 = m.numItems
+ io.WriteUint8(8, (numItems))
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Payload.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Payload.go
new file mode 100644
index 0000000..6da4172
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7Payload.go
@@ -0,0 +1,94 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7Payload struct {
+}
+
+// The corresponding interface
+type IS7Payload interface {
+ spi.Message
+ MessageType() uint8
+ ParameterParameterType() uint8
+ Serialize(io spi.WriteBuffer)
+}
+
+type S7PayloadInitializer interface {
+ initialize() spi.Message
+}
+
+func S7PayloadMessageType(m IS7Payload) uint8 {
+ return m.MessageType()
+}
+
+func S7PayloadParameterParameterType(m IS7Payload) uint8 {
+ return m.ParameterParameterType()
+}
+
+func (m S7Payload) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Length of sub-type elements will be added by sub-type...
+
+ return lengthInBits
+}
+
+func (m S7Payload) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7PayloadParse(io spi.ReadBuffer, messageType uint8, parameter S7Parameter) (spi.Message, error) {
+
+ // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
+ var initializer S7PayloadInitializer
+ var typeSwitchError error
+ switch {
+ case parameter.parameterType == 0x04 && messageType == 0x03:
+ initializer, typeSwitchError = S7PayloadReadVarResponseParse(io, parameter)
+ case parameter.parameterType == 0x05 && messageType == 0x01:
+ initializer, typeSwitchError = S7PayloadWriteVarRequestParse(io, parameter)
+ case parameter.parameterType == 0x05 && messageType == 0x03:
+ initializer, typeSwitchError = S7PayloadWriteVarResponseParse(io, parameter)
+ case parameter.parameterType == 0x00 && messageType == 0x07:
+ initializer, typeSwitchError = S7PayloadUserDataParse(io, parameter)
+ }
+ if typeSwitchError != nil {
+ return nil, errors.New("Error parsing sub-type for type-switch. " + typeSwitchError.Error())
+ }
+
+ // Create the instance
+ return initializer.initialize(), nil
+}
+
+func (m S7Payload) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if iS7Payload, ok := typ.(IS7Payload); ok {
+
+ // Switch field (Depending on the discriminator values, passes the serialization to a sub-type)
+ iS7Payload.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadReadVarResponse.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadReadVarResponse.go
new file mode 100644
index 0000000..ef0a0be
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadReadVarResponse.go
@@ -0,0 +1,116 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+)
+
+// The data-structure of this message
+type S7PayloadReadVarResponse struct {
+ items []S7VarPayloadDataItem
+ S7Payload
+}
+
+// The corresponding interface
+type IS7PayloadReadVarResponse interface {
+ IS7Payload
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7PayloadReadVarResponse) ParameterParameterType() uint8 {
+ return 0x04
+}
+
+func (m S7PayloadReadVarResponse) MessageType() uint8 {
+ return 0x03
+}
+
+func (m S7PayloadReadVarResponse) initialize() spi.Message {
+ return m
+}
+
+func NewS7PayloadReadVarResponse(items []S7VarPayloadDataItem) S7PayloadInitializer {
+ return &S7PayloadReadVarResponse{items: items}
+}
+
+func (m S7PayloadReadVarResponse) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Payload.LengthInBits()
+
+ // Array field
+ if len(m.items) > 0 {
+ for _, element := range m.items {
+ lengthInBits += element.LengthInBits()
+ }
+ }
+
+ return lengthInBits
+}
+
+func (m S7PayloadReadVarResponse) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7PayloadReadVarResponseParse(io spi.ReadBuffer, parameter S7Parameter) (S7PayloadInitializer, error) {
+
+ // Array field (items)
+ var items []S7VarPayloadDataItem
+ // Count array
+ {
+ items := make([]S7VarPayloadDataItem, S7ParameterReadVarResponse(parameter).numItems)
+ for curItem := uint16(0); curItem < uint16(S7ParameterReadVarResponse(parameter).numItems); curItem++ {
+ lastItem := curItem == uint16(S7ParameterReadVarResponse(parameter).numItems-1)
+ _message, _err := S7VarPayloadDataItemParse(io, bool(lastItem))
+ if _err != nil {
+ return nil, errors.New("Error parsing 'items' field " + _err.Error())
+ }
+ var _item S7VarPayloadDataItem
+ _item, _ok := _message.(S7VarPayloadDataItem)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to S7VarPayloadDataItem")
+ }
+ items = append(items, _item)
+ }
+ }
+
+ // Create the instance
+ return NewS7PayloadReadVarResponse(items), nil
+}
+
+func (m S7PayloadReadVarResponse) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7PayloadReadVarResponse); ok {
+
+ // Array Field (items)
+ if m.items != nil {
+ itemCount := uint16(len(m.items))
+ var curItem uint16 = 0
+ for _, _element := range m.items {
+ var lastItem bool = curItem == (itemCount - 1)
+ _element.Serialize(io, lastItem)
+ curItem++
+ }
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserData.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserData.go
new file mode 100644
index 0000000..cd3e407
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserData.go
@@ -0,0 +1,112 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+)
+
+// The data-structure of this message
+type S7PayloadUserData struct {
+ items []S7PayloadUserDataItem
+ S7Payload
+}
+
+// The corresponding interface
+type IS7PayloadUserData interface {
+ IS7Payload
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7PayloadUserData) ParameterParameterType() uint8 {
+ return 0x00
+}
+
+func (m S7PayloadUserData) MessageType() uint8 {
+ return 0x07
+}
+
+func (m S7PayloadUserData) initialize() spi.Message {
+ return m
+}
+
+func NewS7PayloadUserData(items []S7PayloadUserDataItem) S7PayloadInitializer {
+ return &S7PayloadUserData{items: items}
+}
+
+func (m S7PayloadUserData) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Payload.LengthInBits()
+
+ // Array field
+ if len(m.items) > 0 {
+ for _, element := range m.items {
+ lengthInBits += element.LengthInBits()
+ }
+ }
+
+ return lengthInBits
+}
+
+func (m S7PayloadUserData) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7PayloadUserDataParse(io spi.ReadBuffer, parameter S7Parameter) (S7PayloadInitializer, error) {
+
+ // Array field (items)
+ var items []S7PayloadUserDataItem
+ // Count array
+ {
+ items := make([]S7PayloadUserDataItem, uint8(len(COUNT)))
+ for curItem := uint16(0); curItem < uint16(uint8(len(COUNT))); curItem++ {
+
+ _message, _err := S7PayloadUserDataItemParse(io, uint8(S7ParameterUserDataItemCPUFunctions(S7ParameterUserData(parameter).items[0]).cpuFunctionType))
+ if _err != nil {
+ return nil, errors.New("Error parsing 'items' field " + _err.Error())
+ }
+ var _item S7PayloadUserDataItem
+ _item, _ok := _message.(S7PayloadUserDataItem)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to S7PayloadUserDataItem")
+ }
+ items = append(items, _item)
+ }
+ }
+
+ // Create the instance
+ return NewS7PayloadUserData(items), nil
+}
+
+func (m S7PayloadUserData) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7PayloadUserData); ok {
+
+ // Array Field (items)
+ if m.items != nil {
+ for _, _element := range m.items {
+ _element.Serialize(io)
+ }
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserDataItem.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserDataItem.go
new file mode 100644
index 0000000..a760524
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserDataItem.go
@@ -0,0 +1,154 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+)
+
+// The data-structure of this message
+type S7PayloadUserDataItem struct {
+ returnCode DataTransportErrorCode
+ transportSize DataTransportSize
+ szlId SzlId
+ szlIndex uint16
+}
+
+// The corresponding interface
+type IS7PayloadUserDataItem interface {
+ spi.Message
+ CpuFunctionType() uint8
+ Serialize(io spi.WriteBuffer)
+}
+
+type S7PayloadUserDataItemInitializer interface {
+ initialize(returnCode DataTransportErrorCode, transportSize DataTransportSize, szlId SzlId, szlIndex uint16) spi.Message
+}
+
+func S7PayloadUserDataItemCpuFunctionType(m IS7PayloadUserDataItem) uint8 {
+ return m.CpuFunctionType()
+}
+
+func (m S7PayloadUserDataItem) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Enum Field (returnCode)
+ lengthInBits += 8
+
+ // Enum Field (transportSize)
+ lengthInBits += 8
+
+ // Implicit Field (dataLength)
+ lengthInBits += 16
+
+ // Simple field (szlId)
+ lengthInBits += m.szlId.LengthInBits()
+
+ // Simple field (szlIndex)
+ lengthInBits += 16
+
+ // Length of sub-type elements will be added by sub-type...
+
+ return lengthInBits
+}
+
+func (m S7PayloadUserDataItem) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7PayloadUserDataItemParse(io spi.ReadBuffer, cpuFunctionType uint8) (spi.Message, error) {
+
+ // Enum field (returnCode)
+ returnCode, _returnCodeErr := DataTransportErrorCodeParse(io)
+ if _returnCodeErr != nil {
+ return nil, errors.New("Error parsing 'returnCode' field " + _returnCodeErr.Error())
+ }
+
+ // Enum field (transportSize)
+ transportSize, _transportSizeErr := DataTransportSizeParse(io)
+ if _transportSizeErr != nil {
+ return nil, errors.New("Error parsing 'transportSize' field " + _transportSizeErr.Error())
+ }
+
+ // Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var _ uint16 = io.ReadUint16(16)
+
+ // Simple Field (szlId)
+ _szlIdMessage, _err := SzlIdParse(io)
+ if _err != nil {
+ return nil, errors.New("Error parsing simple field 'szlId'. " + _err.Error())
+ }
+ var szlId SzlId
+ szlId, _szlIdOk := _szlIdMessage.(SzlId)
+ if !_szlIdOk {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_szlIdMessage).Name() + " to SzlId")
+ }
+
+ // Simple Field (szlIndex)
+ var szlIndex uint16 = io.ReadUint16(16)
+
+ // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
+ var initializer S7PayloadUserDataItemInitializer
+ var typeSwitchError error
+ switch {
+ case cpuFunctionType == 0x04:
+ initializer, typeSwitchError = S7PayloadUserDataItemCpuFunctionReadSzlRequestParse(io)
+ case cpuFunctionType == 0x08:
+ initializer, typeSwitchError = S7PayloadUserDataItemCpuFunctionReadSzlResponseParse(io)
+ }
+ if typeSwitchError != nil {
+ return nil, errors.New("Error parsing sub-type for type-switch. " + typeSwitchError.Error())
+ }
+
+ // Create the instance
+ return initializer.initialize(returnCode, transportSize, szlId, szlIndex), nil
+}
+
+func (m S7PayloadUserDataItem) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if iS7PayloadUserDataItem, ok := typ.(IS7PayloadUserDataItem); ok {
+
+ // Enum field (returnCode)
+ returnCode := m.returnCode
+ returnCode.Serialize(io)
+
+ // Enum field (transportSize)
+ transportSize := m.transportSize
+ transportSize.Serialize(io)
+
+ // Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ dataLength := uint16((m.LengthInBytes()) - (4))
+ io.WriteUint16(16, (dataLength))
+
+ // Simple Field (szlId)
+ var szlId SzlId = m.szlId
+ szlId.Serialize(io)
+
+ // Simple Field (szlIndex)
+ var szlIndex uint16 = m.szlIndex
+ io.WriteUint16(16, (szlIndex))
+
+ // Switch field (Depending on the discriminator values, passes the serialization to a sub-type)
+ iS7PayloadUserDataItem.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionReadSzlRequest.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionReadSzlRequest.go
new file mode 100644
index 0000000..e7fad41
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionReadSzlRequest.go
@@ -0,0 +1,75 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7PayloadUserDataItemCpuFunctionReadSzlRequest struct {
+ S7PayloadUserDataItem
+}
+
+// The corresponding interface
+type IS7PayloadUserDataItemCpuFunctionReadSzlRequest interface {
+ IS7PayloadUserDataItem
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7PayloadUserDataItemCpuFunctionReadSzlRequest) CpuFunctionType() uint8 {
+ return 0x04
+}
+
+func (m S7PayloadUserDataItemCpuFunctionReadSzlRequest) initialize(returnCode DataTransportErrorCode, transportSize DataTransportSize, szlId SzlId, szlIndex uint16) spi.Message {
+ m.returnCode = returnCode
+ m.transportSize = transportSize
+ m.szlId = szlId
+ m.szlIndex = szlIndex
+ return m
+}
+
+func NewS7PayloadUserDataItemCpuFunctionReadSzlRequest() S7PayloadUserDataItemInitializer {
+ return &S7PayloadUserDataItemCpuFunctionReadSzlRequest{}
+}
+
+func (m S7PayloadUserDataItemCpuFunctionReadSzlRequest) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7PayloadUserDataItem.LengthInBits()
+
+ return lengthInBits
+}
+
+func (m S7PayloadUserDataItemCpuFunctionReadSzlRequest) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7PayloadUserDataItemCpuFunctionReadSzlRequestParse(io spi.ReadBuffer) (S7PayloadUserDataItemInitializer, error) {
+
+ // Create the instance
+ return NewS7PayloadUserDataItemCpuFunctionReadSzlRequest(), nil
+}
+
+func (m S7PayloadUserDataItemCpuFunctionReadSzlRequest) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7PayloadUserDataItemCpuFunctionReadSzlRequest); ok {
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionReadSzlResponse.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionReadSzlResponse.go
new file mode 100644
index 0000000..5162646
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionReadSzlResponse.go
@@ -0,0 +1,138 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+ "strconv"
+)
+
+// Constant values.
+const S7PayloadUserDataItemCpuFunctionReadSzlResponse_SZLITEMLENGTH uint16 = 28
+
+// The data-structure of this message
+type S7PayloadUserDataItemCpuFunctionReadSzlResponse struct {
+ items []SzlDataTreeItem
+ S7PayloadUserDataItem
+}
+
+// The corresponding interface
+type IS7PayloadUserDataItemCpuFunctionReadSzlResponse interface {
+ IS7PayloadUserDataItem
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7PayloadUserDataItemCpuFunctionReadSzlResponse) CpuFunctionType() uint8 {
+ return 0x08
+}
+
+func (m S7PayloadUserDataItemCpuFunctionReadSzlResponse) initialize(returnCode DataTransportErrorCode, transportSize DataTransportSize, szlId SzlId, szlIndex uint16) spi.Message {
+ m.returnCode = returnCode
+ m.transportSize = transportSize
+ m.szlId = szlId
+ m.szlIndex = szlIndex
+ return m
+}
+
+func NewS7PayloadUserDataItemCpuFunctionReadSzlResponse(items []SzlDataTreeItem) S7PayloadUserDataItemInitializer {
+ return &S7PayloadUserDataItemCpuFunctionReadSzlResponse{items: items}
+}
+
+func (m S7PayloadUserDataItemCpuFunctionReadSzlResponse) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7PayloadUserDataItem.LengthInBits()
+
+ // Const Field (szlItemLength)
+ lengthInBits += 16
+
+ // Implicit Field (szlItemCount)
+ lengthInBits += 16
+
+ // Array field
+ if len(m.items) > 0 {
+ for _, element := range m.items {
+ lengthInBits += element.LengthInBits()
+ }
+ }
+
+ return lengthInBits
+}
+
+func (m S7PayloadUserDataItemCpuFunctionReadSzlResponse) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7PayloadUserDataItemCpuFunctionReadSzlResponseParse(io spi.ReadBuffer) (S7PayloadUserDataItemInitializer, error) {
+
+ // Const Field (szlItemLength)
+ var szlItemLength uint16 = io.ReadUint16(16)
+ if szlItemLength != S7PayloadUserDataItemCpuFunctionReadSzlResponse_SZLITEMLENGTH {
+ return nil, errors.New("Expected constant value " + strconv.Itoa(int(S7PayloadUserDataItemCpuFunctionReadSzlResponse_SZLITEMLENGTH)) + " but got " + strconv.Itoa(int(szlItemLength)))
+ }
+
+ // Implicit Field (szlItemCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var szlItemCount uint16 = io.ReadUint16(16)
+
+ // Array field (items)
+ var items []SzlDataTreeItem
+ // Count array
+ {
+ items := make([]SzlDataTreeItem, szlItemCount)
+ for curItem := uint16(0); curItem < uint16(szlItemCount); curItem++ {
+
+ _message, _err := SzlDataTreeItemParse(io)
+ if _err != nil {
+ return nil, errors.New("Error parsing 'items' field " + _err.Error())
+ }
+ var _item SzlDataTreeItem
+ _item, _ok := _message.(SzlDataTreeItem)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to SzlDataTreeItem")
+ }
+ items = append(items, _item)
+ }
+ }
+
+ // Create the instance
+ return NewS7PayloadUserDataItemCpuFunctionReadSzlResponse(items), nil
+}
+
+func (m S7PayloadUserDataItemCpuFunctionReadSzlResponse) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7PayloadUserDataItemCpuFunctionReadSzlResponse); ok {
+
+ // Const Field (szlItemLength)
+ io.WriteUint16(16, 28)
+
+ // Implicit Field (szlItemCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ szlItemCount := uint16(uint16(len(m.items)))
+ io.WriteUint16(16, (szlItemCount))
+
+ // Array Field (items)
+ if m.items != nil {
+ for _, _element := range m.items {
+ _element.Serialize(io)
+ }
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadWriteVarRequest.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadWriteVarRequest.go
new file mode 100644
index 0000000..9d94feb
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadWriteVarRequest.go
@@ -0,0 +1,116 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+)
+
+// The data-structure of this message
+type S7PayloadWriteVarRequest struct {
+ items []S7VarPayloadDataItem
+ S7Payload
+}
+
+// The corresponding interface
+type IS7PayloadWriteVarRequest interface {
+ IS7Payload
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7PayloadWriteVarRequest) ParameterParameterType() uint8 {
+ return 0x05
+}
+
+func (m S7PayloadWriteVarRequest) MessageType() uint8 {
+ return 0x01
+}
+
+func (m S7PayloadWriteVarRequest) initialize() spi.Message {
+ return m
+}
+
+func NewS7PayloadWriteVarRequest(items []S7VarPayloadDataItem) S7PayloadInitializer {
+ return &S7PayloadWriteVarRequest{items: items}
+}
+
+func (m S7PayloadWriteVarRequest) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Payload.LengthInBits()
+
+ // Array field
+ if len(m.items) > 0 {
+ for _, element := range m.items {
+ lengthInBits += element.LengthInBits()
+ }
+ }
+
+ return lengthInBits
+}
+
+func (m S7PayloadWriteVarRequest) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7PayloadWriteVarRequestParse(io spi.ReadBuffer, parameter S7Parameter) (S7PayloadInitializer, error) {
+
+ // Array field (items)
+ var items []S7VarPayloadDataItem
+ // Count array
+ {
+ items := make([]S7VarPayloadDataItem, uint8(len(COUNT)))
+ for curItem := uint16(0); curItem < uint16(uint8(len(COUNT))); curItem++ {
+ lastItem := curItem == uint16(uint8(len(COUNT))-1)
+ _message, _err := S7VarPayloadDataItemParse(io, bool(lastItem))
+ if _err != nil {
+ return nil, errors.New("Error parsing 'items' field " + _err.Error())
+ }
+ var _item S7VarPayloadDataItem
+ _item, _ok := _message.(S7VarPayloadDataItem)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to S7VarPayloadDataItem")
+ }
+ items = append(items, _item)
+ }
+ }
+
+ // Create the instance
+ return NewS7PayloadWriteVarRequest(items), nil
+}
+
+func (m S7PayloadWriteVarRequest) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7PayloadWriteVarRequest); ok {
+
+ // Array Field (items)
+ if m.items != nil {
+ itemCount := uint16(len(m.items))
+ var curItem uint16 = 0
+ for _, _element := range m.items {
+ var lastItem bool = curItem == (itemCount - 1)
+ _element.Serialize(io, lastItem)
+ curItem++
+ }
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadWriteVarResponse.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadWriteVarResponse.go
new file mode 100644
index 0000000..c4f94bc
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7PayloadWriteVarResponse.go
@@ -0,0 +1,112 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+)
+
+// The data-structure of this message
+type S7PayloadWriteVarResponse struct {
+ items []S7VarPayloadStatusItem
+ S7Payload
+}
+
+// The corresponding interface
+type IS7PayloadWriteVarResponse interface {
+ IS7Payload
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7PayloadWriteVarResponse) ParameterParameterType() uint8 {
+ return 0x05
+}
+
+func (m S7PayloadWriteVarResponse) MessageType() uint8 {
+ return 0x03
+}
+
+func (m S7PayloadWriteVarResponse) initialize() spi.Message {
+ return m
+}
+
+func NewS7PayloadWriteVarResponse(items []S7VarPayloadStatusItem) S7PayloadInitializer {
+ return &S7PayloadWriteVarResponse{items: items}
+}
+
+func (m S7PayloadWriteVarResponse) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7Payload.LengthInBits()
+
+ // Array field
+ if len(m.items) > 0 {
+ for _, element := range m.items {
+ lengthInBits += element.LengthInBits()
+ }
+ }
+
+ return lengthInBits
+}
+
+func (m S7PayloadWriteVarResponse) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7PayloadWriteVarResponseParse(io spi.ReadBuffer, parameter S7Parameter) (S7PayloadInitializer, error) {
+
+ // Array field (items)
+ var items []S7VarPayloadStatusItem
+ // Count array
+ {
+ items := make([]S7VarPayloadStatusItem, S7ParameterWriteVarResponse(parameter).numItems)
+ for curItem := uint16(0); curItem < uint16(S7ParameterWriteVarResponse(parameter).numItems); curItem++ {
+
+ _message, _err := S7VarPayloadStatusItemParse(io)
+ if _err != nil {
+ return nil, errors.New("Error parsing 'items' field " + _err.Error())
+ }
+ var _item S7VarPayloadStatusItem
+ _item, _ok := _message.(S7VarPayloadStatusItem)
+ if !_ok {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_item).Name() + " to S7VarPayloadStatusItem")
+ }
+ items = append(items, _item)
+ }
+ }
+
+ // Create the instance
+ return NewS7PayloadWriteVarResponse(items), nil
+}
+
+func (m S7PayloadWriteVarResponse) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7PayloadWriteVarResponse); ok {
+
+ // Array Field (items)
+ if m.items != nil {
+ for _, _element := range m.items {
+ _element.Serialize(io)
+ }
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarPayloadDataItem.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarPayloadDataItem.go
new file mode 100644
index 0000000..9a556a0
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarPayloadDataItem.go
@@ -0,0 +1,148 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7VarPayloadDataItem struct {
+ returnCode DataTransportErrorCode
+ transportSize DataTransportSize
+ data []int8
+}
+
+// The corresponding interface
+type IS7VarPayloadDataItem interface {
+ spi.Message
+ Serialize(io spi.WriteBuffer)
+}
+
+func NewS7VarPayloadDataItem(returnCode DataTransportErrorCode, transportSize DataTransportSize, data []int8) spi.Message {
+ return &S7VarPayloadDataItem{returnCode: returnCode, transportSize: transportSize, data: data}
+}
+
+func (m S7VarPayloadDataItem) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Enum Field (returnCode)
+ lengthInBits += 8
+
+ // Enum Field (transportSize)
+ lengthInBits += 8
+
+ // Implicit Field (dataLength)
+ lengthInBits += 16
+
+ // Array field
+ if len(m.data) > 0 {
+ lengthInBits += 8 * uint16(len(m.data))
+ }
+
+ // Padding Field (padding)
+ _timesPadding := uint8(spi.InlineIf((false), uint16(0), uint16((uint8(len(COUNT)))%(2))))
+ for ; _timesPadding > 0; _timesPadding-- {
+ lengthInBits += 8
+ }
+
+ return lengthInBits
+}
+
+func (m S7VarPayloadDataItem) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7VarPayloadDataItemParse(io spi.ReadBuffer, lastItem bool) (spi.Message, error) {
+
+ // Enum field (returnCode)
+ returnCode, _returnCodeErr := DataTransportErrorCodeParse(io)
+ if _returnCodeErr != nil {
+ return nil, errors.New("Error parsing 'returnCode' field " + _returnCodeErr.Error())
+ }
+
+ // Enum field (transportSize)
+ transportSize, _transportSizeErr := DataTransportSizeParse(io)
+ if _transportSizeErr != nil {
+ return nil, errors.New("Error parsing 'transportSize' field " + _transportSizeErr.Error())
+ }
+
+ // Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var dataLength uint16 = io.ReadUint16(16)
+
+ // Array field (data)
+ var data []int8
+ // Count array
+ {
+ data := make([]int8, spi.InlineIf((transportSize.sizeInBits), uint16(CEIL((dataLength)/(8.0))), uint16(dataLength)))
+ for curItem := uint16(0); curItem < uint16(spi.InlineIf((transportSize.sizeInBits), uint16(CEIL((dataLength)/(8.0))), uint16(dataLength))); curItem++ {
+
+ data = append(data, io.ReadInt8(8))
+ }
+ }
+
+ // Padding Field (padding)
+ {
+ _timesPadding := (spi.InlineIf((lastItem), uint16(0), uint16((uint8(len(COUNT)))%(2))))
+ for ; (io.HasMore(8)) && (_timesPadding > 0); _timesPadding-- {
+ // Just read the padding data and ignore it
+ io.ReadUint8(8)
+ }
+ }
+
+ // Create the instance
+ return NewS7VarPayloadDataItem(returnCode, transportSize, data), nil
+}
+
+func (m S7VarPayloadDataItem) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7VarPayloadDataItem); ok {
+
+ // Enum field (returnCode)
+ returnCode := m.returnCode
+ returnCode.Serialize(io)
+
+ // Enum field (transportSize)
+ transportSize := m.transportSize
+ transportSize.Serialize(io)
+
+ // Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ dataLength := uint16((uint16(len(m.data))) * (spi.InlineIf(((m.transportSize) == (DataTransportSize.BIT)), uint16(1), uint16((spi.InlineIf((m.transportSize.sizeInBits), uint16(8), uint16(1)))))))
+ io.WriteUint16(16, (dataLength))
+
+ // Array Field (data)
+ if m.data != nil {
+ for _, _element := range m.data {
+ io.WriteInt8(8, _element)
+ }
+ }
+
+ // Padding Field (padding)
+ {
+ _timesPadding := uint8(spi.InlineIf((lastItem), uint16(0), uint16((uint8(len(m.data)))%(2))))
+ for ; _timesPadding > 0; _timesPadding-- {
+ _paddingValue := uint8(0)
+ io.WriteUint8(8, (_paddingValue))
+ }
+ }
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusConstants.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarPayloadStatusItem.go
similarity index 56%
copy from sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusConstants.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarPayloadStatusItem.go
index d225bed..138ce68 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusConstants.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarPayloadStatusItem.go
@@ -21,57 +21,55 @@ package model
import (
"errors"
"plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
- "strconv"
)
-// Constant values.
-const MODBUSTCPDEFAULTPORT uint16 = 502
-
// The data-structure of this message
-type ModbusConstants struct {
+type S7VarPayloadStatusItem struct {
+ returnCode DataTransportErrorCode
}
// The corresponding interface
-type IModbusConstants interface {
+type IS7VarPayloadStatusItem interface {
spi.Message
Serialize(io spi.WriteBuffer)
}
-func NewModbusConstants() spi.Message {
- return &ModbusConstants{}
+func NewS7VarPayloadStatusItem(returnCode DataTransportErrorCode) spi.Message {
+ return &S7VarPayloadStatusItem{returnCode: returnCode}
}
-func (m ModbusConstants) LengthInBits() uint16 {
+func (m S7VarPayloadStatusItem) LengthInBits() uint16 {
var lengthInBits uint16 = 0
- // Const Field (modbusTcpDefaultPort)
- lengthInBits += 16
+ // Enum Field (returnCode)
+ lengthInBits += 8
return lengthInBits
}
-func (m ModbusConstants) LengthInBytes() uint16 {
+func (m S7VarPayloadStatusItem) LengthInBytes() uint16 {
return m.LengthInBits() / 8
}
-func ModbusConstantsParse(io spi.ReadBuffer) (spi.Message, error) {
+func S7VarPayloadStatusItemParse(io spi.ReadBuffer) (spi.Message, error) {
- // Const Field (modbusTcpDefaultPort)
- var modbusTcpDefaultPort uint16 = io.ReadUint16(16)
- if modbusTcpDefaultPort != MODBUSTCPDEFAULTPORT {
- return nil, errors.New("Expected constant value " + strconv.Itoa(int(MODBUSTCPDEFAULTPORT)) + " but got " + strconv.Itoa(int(modbusTcpDefaultPort)))
+ // Enum field (returnCode)
+ returnCode, _returnCodeErr := DataTransportErrorCodeParse(io)
+ if _returnCodeErr != nil {
+ return nil, errors.New("Error parsing 'returnCode' field " + _returnCodeErr.Error())
}
// Create the instance
- return NewModbusConstants(), nil
+ return NewS7VarPayloadStatusItem(returnCode), nil
}
-func (m ModbusConstants) Serialize(io spi.WriteBuffer) {
+func (m S7VarPayloadStatusItem) Serialize(io spi.WriteBuffer) {
serializeFunc := func(typ interface{}) {
- if _, ok := typ.(IModbusPDU); ok {
+ if _, ok := typ.(IS7VarPayloadStatusItem); ok {
- // Const Field (modbusTcpDefaultPort)
- io.WriteUint16(16, 502)
+ // Enum field (returnCode)
+ returnCode := m.returnCode
+ returnCode.Serialize(io)
}
}
serializeFunc(m)
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarRequestParameterItem.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarRequestParameterItem.go
new file mode 100644
index 0000000..ed7a193
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarRequestParameterItem.go
@@ -0,0 +1,93 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type S7VarRequestParameterItem struct {
+}
+
+// The corresponding interface
+type IS7VarRequestParameterItem interface {
+ spi.Message
+ ItemType() uint8
+ Serialize(io spi.WriteBuffer)
+}
+
+type S7VarRequestParameterItemInitializer interface {
+ initialize() spi.Message
+}
+
+func S7VarRequestParameterItemItemType(m IS7VarRequestParameterItem) uint8 {
+ return m.ItemType()
+}
+
+func (m S7VarRequestParameterItem) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Discriminator Field (itemType)
+ lengthInBits += 8
+
+ // Length of sub-type elements will be added by sub-type...
+
+ return lengthInBits
+}
+
+func (m S7VarRequestParameterItem) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7VarRequestParameterItemParse(io spi.ReadBuffer) (spi.Message, error) {
+
+ // Discriminator Field (itemType) (Used as input to a switch field)
+ var itemType uint8 = io.ReadUint8(8)
+
+ // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
+ var initializer S7VarRequestParameterItemInitializer
+ var typeSwitchError error
+ switch {
+ case itemType == 0x12:
+ initializer, typeSwitchError = S7VarRequestParameterItemAddressParse(io)
+ }
+ if typeSwitchError != nil {
+ return nil, errors.New("Error parsing sub-type for type-switch. " + typeSwitchError.Error())
+ }
+
+ // Create the instance
+ return initializer.initialize(), nil
+}
+
+func (m S7VarRequestParameterItem) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if iS7VarRequestParameterItem, ok := typ.(IS7VarRequestParameterItem); ok {
+
+ // Discriminator Field (itemType) (Used as input to a switch field)
+ itemType := S7VarRequestParameterItemItemType(iS7VarRequestParameterItem)
+ io.WriteUint8(8, (itemType))
+
+ // Switch field (Depending on the discriminator values, passes the serialization to a sub-type)
+ iS7VarRequestParameterItem.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarRequestParameterItemAddress.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarRequestParameterItemAddress.go
new file mode 100644
index 0000000..314c50a
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/S7VarRequestParameterItemAddress.go
@@ -0,0 +1,102 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+)
+
+// The data-structure of this message
+type S7VarRequestParameterItemAddress struct {
+ address S7Address
+ S7VarRequestParameterItem
+}
+
+// The corresponding interface
+type IS7VarRequestParameterItemAddress interface {
+ IS7VarRequestParameterItem
+ Serialize(io spi.WriteBuffer)
+}
+
+// Accessors for discriminator values.
+func (m S7VarRequestParameterItemAddress) ItemType() uint8 {
+ return 0x12
+}
+
+func (m S7VarRequestParameterItemAddress) initialize() spi.Message {
+ return m
+}
+
+func NewS7VarRequestParameterItemAddress(address S7Address) S7VarRequestParameterItemInitializer {
+ return &S7VarRequestParameterItemAddress{address: address}
+}
+
+func (m S7VarRequestParameterItemAddress) LengthInBits() uint16 {
+ var lengthInBits uint16 = m.S7VarRequestParameterItem.LengthInBits()
+
+ // Implicit Field (itemLength)
+ lengthInBits += 8
+
+ // Simple field (address)
+ lengthInBits += m.address.LengthInBits()
+
+ return lengthInBits
+}
+
+func (m S7VarRequestParameterItemAddress) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func S7VarRequestParameterItemAddressParse(io spi.ReadBuffer) (S7VarRequestParameterItemInitializer, error) {
+
+ // Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var _ uint8 = io.ReadUint8(8)
+
+ // Simple Field (address)
+ _addressMessage, _err := S7AddressParse(io)
+ if _err != nil {
+ return nil, errors.New("Error parsing simple field 'address'. " + _err.Error())
+ }
+ var address S7Address
+ address, _addressOk := _addressMessage.(S7Address)
+ if !_addressOk {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_addressMessage).Name() + " to S7Address")
+ }
+
+ // Create the instance
+ return NewS7VarRequestParameterItemAddress(address), nil
+}
+
+func (m S7VarRequestParameterItemAddress) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(IS7VarRequestParameterItemAddress); ok {
+
+ // Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ itemLength := uint8(m.address.LengthInBytes())
+ io.WriteUint8(8, (itemLength))
+
+ // Simple Field (address)
+ var address S7Address = m.address
+ address.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlDataTreeItem.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlDataTreeItem.go
new file mode 100644
index 0000000..0a44493
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlDataTreeItem.go
@@ -0,0 +1,129 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type SzlDataTreeItem struct {
+ itemIndex uint16
+ mlfb []int8
+ moduleTypeId uint16
+ ausbg uint16
+ ausbe uint16
+}
+
+// The corresponding interface
+type ISzlDataTreeItem interface {
+ spi.Message
+ Serialize(io spi.WriteBuffer)
+}
+
+func NewSzlDataTreeItem(itemIndex uint16, mlfb []int8, moduleTypeId uint16, ausbg uint16, ausbe uint16) spi.Message {
+ return &SzlDataTreeItem{itemIndex: itemIndex, mlfb: mlfb, moduleTypeId: moduleTypeId, ausbg: ausbg, ausbe: ausbe}
+}
+
+func (m SzlDataTreeItem) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Simple field (itemIndex)
+ lengthInBits += 16
+
+ // Array field
+ if len(m.mlfb) > 0 {
+ lengthInBits += 8 * uint16(len(m.mlfb))
+ }
+
+ // Simple field (moduleTypeId)
+ lengthInBits += 16
+
+ // Simple field (ausbg)
+ lengthInBits += 16
+
+ // Simple field (ausbe)
+ lengthInBits += 16
+
+ return lengthInBits
+}
+
+func (m SzlDataTreeItem) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func SzlDataTreeItemParse(io spi.ReadBuffer) (spi.Message, error) {
+
+ // Simple Field (itemIndex)
+ var itemIndex uint16 = io.ReadUint16(16)
+
+ // Array field (mlfb)
+ var mlfb []int8
+ // Count array
+ {
+ mlfb := make([]int8, 20)
+ for curItem := uint16(0); curItem < uint16(20); curItem++ {
+
+ mlfb = append(mlfb, io.ReadInt8(8))
+ }
+ }
+
+ // Simple Field (moduleTypeId)
+ var moduleTypeId uint16 = io.ReadUint16(16)
+
+ // Simple Field (ausbg)
+ var ausbg uint16 = io.ReadUint16(16)
+
+ // Simple Field (ausbe)
+ var ausbe uint16 = io.ReadUint16(16)
+
+ // Create the instance
+ return NewSzlDataTreeItem(itemIndex, mlfb, moduleTypeId, ausbg, ausbe), nil
+}
+
+func (m SzlDataTreeItem) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(ISzlDataTreeItem); ok {
+
+ // Simple Field (itemIndex)
+ var itemIndex uint16 = m.itemIndex
+ io.WriteUint16(16, (itemIndex))
+
+ // Array Field (mlfb)
+ if m.mlfb != nil {
+ for _, _element := range m.mlfb {
+ io.WriteInt8(8, _element)
+ }
+ }
+
+ // Simple Field (moduleTypeId)
+ var moduleTypeId uint16 = m.moduleTypeId
+ io.WriteUint16(16, (moduleTypeId))
+
+ // Simple Field (ausbg)
+ var ausbg uint16 = m.ausbg
+ io.WriteUint16(16, (ausbg))
+
+ // Simple Field (ausbe)
+ var ausbe uint16 = m.ausbe
+ io.WriteUint16(16, (ausbe))
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlId.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlId.go
new file mode 100644
index 0000000..c443318
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlId.go
@@ -0,0 +1,101 @@
+//
+// 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
+//
+// http://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 model
+
+import (
+ "errors"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+)
+
+// The data-structure of this message
+type SzlId struct {
+ typeClass SzlModuleTypeClass
+ sublistExtract uint8
+ sublistList SzlSublist
+}
+
+// The corresponding interface
+type ISzlId interface {
+ spi.Message
+ Serialize(io spi.WriteBuffer)
+}
+
+func NewSzlId(typeClass SzlModuleTypeClass, sublistExtract uint8, sublistList SzlSublist) spi.Message {
+ return &SzlId{typeClass: typeClass, sublistExtract: sublistExtract, sublistList: sublistList}
+}
+
+func (m SzlId) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Enum Field (typeClass)
+ lengthInBits += 4
+
+ // Simple field (sublistExtract)
+ lengthInBits += 4
+
+ // Enum Field (sublistList)
+ lengthInBits += 8
+
+ return lengthInBits
+}
+
+func (m SzlId) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func SzlIdParse(io spi.ReadBuffer) (spi.Message, error) {
+
+ // Enum field (typeClass)
+ typeClass, _typeClassErr := SzlModuleTypeClassParse(io)
+ if _typeClassErr != nil {
+ return nil, errors.New("Error parsing 'typeClass' field " + _typeClassErr.Error())
+ }
+
+ // Simple Field (sublistExtract)
+ var sublistExtract uint8 = io.ReadUint8(4)
+
+ // Enum field (sublistList)
+ sublistList, _sublistListErr := SzlSublistParse(io)
+ if _sublistListErr != nil {
+ return nil, errors.New("Error parsing 'sublistList' field " + _sublistListErr.Error())
+ }
+
+ // Create the instance
+ return NewSzlId(typeClass, sublistExtract, sublistList), nil
+}
+
+func (m SzlId) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(ISzlId); ok {
+
+ // Enum field (typeClass)
+ typeClass := m.typeClass
+ typeClass.Serialize(io)
+
+ // Simple Field (sublistExtract)
+ var sublistExtract uint8 = m.sublistExtract
+ io.WriteUint8(4, (sublistExtract))
+
+ // Enum field (sublistList)
+ sublistList := m.sublistList
+ sublistList.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/cmd/modbus/modbus.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlModuleTypeClass.go
similarity index 51%
copy from sandbox/plc4go/cmd/modbus/modbus.go
copy to sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlModuleTypeClass.go
index 1b1982a..7ea74cd 100644
--- a/sandbox/plc4go/cmd/modbus/modbus.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlModuleTypeClass.go
@@ -1,3 +1,6 @@
+//
+// 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
@@ -13,26 +16,24 @@
// specific language governing permissions and limitations
// under the License.
//
-package main
+package model
+
+import "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
-import (
- "encoding/hex"
- "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/modbus/readwrite/model"
- "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+type SzlModuleTypeClass uint8
+
+const (
+ SzlModuleTypeClass_CPU SzlModuleTypeClass = 0x0
+ SzlModuleTypeClass_IM SzlModuleTypeClass = 0x4
+ SzlModuleTypeClass_FM SzlModuleTypeClass = 0x8
+ SzlModuleTypeClass_CP SzlModuleTypeClass = 0xC
)
-func main() {
- request, err := hex.DecodeString("000a00000006010300000004")
- if err != nil {
- // Output an error ...
- }
- rb := spi.ReadBufferNew(request)
- adu, err := model.ModbusTcpADUParse(*rb, false)
- if err != nil {
- // Output an error ...
- }
- if adu != nil {
- // Output success ...
- }
+func SzlModuleTypeClassParse(io spi.ReadBuffer) (SzlModuleTypeClass, error) {
+ // TODO: Implement ...
+ return 0, nil
+}
+func (e SzlModuleTypeClass) Serialize(io spi.WriteBuffer) {
+ // TODO: Implement ...
}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlSublist.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlSublist.go
new file mode 100644
index 0000000..03e7735
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlSublist.go
@@ -0,0 +1,54 @@
+//
+// 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
+//
+// http://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 model
+
+import "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+
+type SzlSublist uint8
+
+const (
+ SzlSublist_MODULE_IDENTIFICATION SzlSublist = 0x11
+ SzlSublist_CPU_FEATURES SzlSublist = 0x12
+ SzlSublist_USER_MEMORY_AREA SzlSublist = 0x13
+ SzlSublist_SYSTEM_AREAS SzlSublist = 0x14
+ SzlSublist_BLOCK_TYPES SzlSublist = 0x15
+ SzlSublist_STATUS_MODULE_LEDS SzlSublist = 0x19
+ SzlSublist_COMPONENT_IDENTIFICATION SzlSublist = 0x1C
+ SzlSublist_INTERRUPT_STATUS SzlSublist = 0x22
+ SzlSublist_ASSIGNMENT_BETWEEN_PROCESS_IMAGE_PARTITIONS_AND_OBS SzlSublist = 0x25
+ SzlSublist_COMMUNICATION_STATUS_DATA SzlSublist = 0x32
+ SzlSublist_STATUS_SINGLE_MODULE_LED SzlSublist = 0x74
+ SzlSublist_DP_MASTER_SYSTEM_INFORMATION SzlSublist = 0x90
+ SzlSublist_MODULE_STATUS_INFORMATION SzlSublist = 0x91
+ SzlSublist_RACK_OR_STATION_STATUS_INFORMATION SzlSublist = 0x92
+ SzlSublist_RACK_OR_STATION_STATUS_INFORMATION_2 SzlSublist = 0x94
+ SzlSublist_ADDITIONAL_DP_MASTER_SYSTEM_OR_PROFINET_IO_SYSTEM_INFORMATION SzlSublist = 0x95
+ SzlSublist_MODULE_STATUS_INFORMATION_PROFINET_IO_AND_PROFIBUS_DP SzlSublist = 0x96
+ SzlSublist_DIAGNOSTIC_BUFFER SzlSublist = 0xA0
+ SzlSublist_MODULE_DIAGNOSTIC_DATA SzlSublist = 0xB1
+)
+
+func SzlSublistParse(io spi.ReadBuffer) (SzlSublist, error) {
+ // TODO: Implement ...
+ return 0, nil
+}
+
+func (e SzlSublist) Serialize(io spi.WriteBuffer) {
+ // TODO: Implement ...
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/TPKTPacket.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/TPKTPacket.go
new file mode 100644
index 0000000..932b5e5
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/TPKTPacket.go
@@ -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
+//
+// http://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 model
+
+import (
+ "errors"
+ log "github.com/sirupsen/logrus"
+ "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+ "reflect"
+ "strconv"
+)
+
+// Constant values.
+const TPKTPacket_PROTOCOLID uint8 = 0x03
+
+// The data-structure of this message
+type TPKTPacket struct {
+ payload COTPPacket
+}
+
+// The corresponding interface
+type ITPKTPacket interface {
+ spi.Message
+ Serialize(io spi.WriteBuffer)
+}
+
+func NewTPKTPacket(payload COTPPacket) spi.Message {
+ return &TPKTPacket{payload: payload}
+}
+
+func (m TPKTPacket) LengthInBits() uint16 {
+ var lengthInBits uint16 = 0
+
+ // Const Field (protocolId)
+ lengthInBits += 8
+
+ // Reserved Field (reserved)
+ lengthInBits += 8
+
+ // Implicit Field (len)
+ lengthInBits += 16
+
+ // Simple field (payload)
+ lengthInBits += m.payload.LengthInBits()
+
+ return lengthInBits
+}
+
+func (m TPKTPacket) LengthInBytes() uint16 {
+ return m.LengthInBits() / 8
+}
+
+func TPKTPacketParse(io spi.ReadBuffer) (spi.Message, error) {
+
+ // Const Field (protocolId)
+ var protocolId uint8 = io.ReadUint8(8)
+ if protocolId != TPKTPacket_PROTOCOLID {
+ return nil, errors.New("Expected constant value " + strconv.Itoa(int(TPKTPacket_PROTOCOLID)) + " but got " + strconv.Itoa(int(protocolId)))
+ }
+
+ // Reserved Field (Compartmentalized so the "reserved" variable can't leak)
+ {
+ var reserved uint8 = io.ReadUint8(8)
+ if reserved != uint8(0x00) {
+ log.WithFields(log.Fields{
+ "expected value": uint8(0x00),
+ "got value": reserved,
+ }).Info("Got unexpected response.")
+ }
+ }
+
+ // Implicit Field (len) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ var len uint16 = io.ReadUint16(16)
+
+ // Simple Field (payload)
+ _payloadMessage, _err := COTPPacketParse(io, uint16((len)-(4)))
+ if _err != nil {
+ return nil, errors.New("Error parsing simple field 'payload'. " + _err.Error())
+ }
+ var payload COTPPacket
+ payload, _payloadOk := _payloadMessage.(COTPPacket)
+ if !_payloadOk {
+ return nil, errors.New("Couldn't cast message of type " + reflect.TypeOf(_payloadMessage).Name() + " to COTPPacket")
+ }
+
+ // Create the instance
+ return NewTPKTPacket(payload), nil
+}
+
+func (m TPKTPacket) Serialize(io spi.WriteBuffer) {
+ serializeFunc := func(typ interface{}) {
+ if _, ok := typ.(ITPKTPacket); ok {
+
+ // Const Field (protocolId)
+ io.WriteUint8(8, 0x03)
+
+ // Reserved Field (reserved)
+ io.WriteUint8(8, uint8(0x00))
+
+ // Implicit Field (len) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content)
+ len := uint16((m.payload.LengthInBytes()) + (4))
+ io.WriteUint16(16, (len))
+
+ // Simple Field (payload)
+ var payload COTPPacket = m.payload
+ payload.Serialize(io)
+ }
+ }
+ serializeFunc(m)
+}
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/TransportSize.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/TransportSize.go
new file mode 100644
index 0000000..cd72bb9
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/TransportSize.go
@@ -0,0 +1,790 @@
+//
+// 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
+//
+// http://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 model
+
+import "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
+
+type TransportSize int8
+
+const (
+ TransportSize_BOOL TransportSize = 0x01
+ TransportSize_BYTE TransportSize = 0x02
+ TransportSize_WORD TransportSize = 0x04
+ TransportSize_DWORD TransportSize = 0x06
+ TransportSize_LWORD TransportSize = 0x00
+ TransportSize_INT TransportSize = 0x05
+ TransportSize_UINT TransportSize = 0x05
+ TransportSize_SINT TransportSize = 0x02
+ TransportSize_USINT TransportSize = 0x02
+ TransportSize_DINT TransportSize = 0x07
+ TransportSize_UDINT TransportSize = 0x07
+ TransportSize_LINT TransportSize = 0x00
+ TransportSize_ULINT TransportSize = 0x00
+ TransportSize_REAL TransportSize = 0x08
+ TransportSize_LREAL TransportSize = 0x30
+ TransportSize_CHAR TransportSize = 0x03
+ TransportSize_WCHAR TransportSize = 0x13
+ TransportSize_STRING TransportSize = 0x03
+ TransportSize_WSTRING TransportSize = 0x00
+ TransportSize_TIME TransportSize = 0x0B
+ TransportSize_S5TIME TransportSize = 0x0C
+ TransportSize_LTIME TransportSize = 0x00
+ TransportSize_DATE TransportSize = 0x09
+ TransportSize_TIME_OF_DAY TransportSize = 0x0A
+ TransportSize_DATE_AND_TIME TransportSize = 0x0F
+)
+
+func (e TransportSize) GetSupported_S7_300() bool {
+ switch e {
+ case 0x00:
+ { /* '0x00' */
+ return false
+ }
+ case 0x01:
+ { /* '0x01' */
+ return true
+ }
+ case 0x02:
+ { /* '0x02' */
+ return true
+ }
+ case 0x03:
+ { /* '0x03' */
+ return true
+ }
+ case 0x04:
+ { /* '0x04' */
+ return true
+ }
+ case 0x05:
+ { /* '0x05' */
+ return true
+ }
+ case 0x06:
+ { /* '0x06' */
+ return true
+ }
+ case 0x07:
+ { /* '0x07' */
+ return true
+ }
+ case 0x08:
+ { /* '0x08' */
+ return true
+ }
+ case 0x09:
+ { /* '0x09' */
+ return true
+ }
+ case 0x0A:
+ { /* '0x0A' */
+ return true
+ }
+ case 0x0B:
+ { /* '0x0B' */
+ return true
+ }
+ case 0x0C:
+ { /* '0x0C' */
+ return true
+ }
+ case 0x0F:
+ { /* '0x0F' */
+ return true
+ }
+ case 0x13:
+ { /* '0x13' */
+ return false
+ }
+ case 0x30:
+ { /* '0x30' */
+ return false
+ }
+ default:
+ {
+ return false
+ }
+ }
+}
+
+func (e TransportSize) GetSupported_LOGO() bool {
+ switch e {
+ case 0x00:
+ { /* '0x00' */
+ return false
+ }
+ case 0x01:
+ { /* '0x01' */
+ return true
+ }
+ case 0x02:
+ { /* '0x02' */
+ return true
+ }
+ case 0x03:
+ { /* '0x03' */
+ return true
+ }
+ case 0x04:
+ { /* '0x04' */
+ return true
+ }
+ case 0x05:
+ { /* '0x05' */
+ return true
+ }
+ case 0x06:
+ { /* '0x06' */
+ return true
+ }
+ case 0x07:
+ { /* '0x07' */
+ return true
+ }
+ case 0x08:
+ { /* '0x08' */
+ return true
+ }
+ case 0x09:
+ { /* '0x09' */
+ return true
+ }
+ case 0x0A:
+ { /* '0x0A' */
+ return true
+ }
+ case 0x0B:
+ { /* '0x0B' */
+ return true
+ }
+ case 0x0C:
+ { /* '0x0C' */
+ return true
+ }
+ case 0x0F:
+ { /* '0x0F' */
+ return false
+ }
+ case 0x13:
+ { /* '0x13' */
+ return true
+ }
+ case 0x30:
+ { /* '0x30' */
+ return false
+ }
+ default:
+ {
+ return false
+ }
+ }
+}
+
+func (e TransportSize) GetSizeInBytes() uint8 {
+ switch e {
+ case 0x00:
+ { /* '0x00' */
+ return 8
+ }
+ case 0x01:
+ { /* '0x01' */
+ return 1
+ }
+ case 0x02:
+ { /* '0x02' */
+ return 1
+ }
+ case 0x03:
+ { /* '0x03' */
+ return 1
+ }
+ case 0x04:
+ { /* '0x04' */
+ return 2
+ }
+ case 0x05:
+ { /* '0x05' */
+ return 2
+ }
+ case 0x06:
+ { /* '0x06' */
+ return 4
+ }
+ case 0x07:
+ { /* '0x07' */
+ return 4
+ }
+ case 0x08:
+ { /* '0x08' */
+ return 4
+ }
+ case 0x09:
+ { /* '0x09' */
+ return 2
+ }
+ case 0x0A:
+ { /* '0x0A' */
+ return 4
+ }
+ case 0x0B:
+ { /* '0x0B' */
+ return 4
+ }
+ case 0x0C:
+ { /* '0x0C' */
+ return 4
+ }
+ case 0x0F:
+ { /* '0x0F' */
+ return 12
+ }
+ case 0x13:
+ { /* '0x13' */
+ return 2
+ }
+ case 0x30:
+ { /* '0x30' */
+ return 8
+ }
+ default:
+ {
+ return 0
+ }
+ }
+}
+
+func (e TransportSize) GetSupported_S7_400() bool {
+ switch e {
+ case 0x00:
+ { /* '0x00' */
+ return false
+ }
+ case 0x01:
+ { /* '0x01' */
+ return true
+ }
+ case 0x02:
+ { /* '0x02' */
+ return true
+ }
+ case 0x03:
+ { /* '0x03' */
+ return true
+ }
+ case 0x04:
+ { /* '0x04' */
+ return true
+ }
+ case 0x05:
+ { /* '0x05' */
+ return true
+ }
+ case 0x06:
+ { /* '0x06' */
+ return true
+ }
+ case 0x07:
+ { /* '0x07' */
+ return true
+ }
+ case 0x08:
+ { /* '0x08' */
+ return true
+ }
+ case 0x09:
+ { /* '0x09' */
+ return true
+ }
+ case 0x0A:
+ { /* '0x0A' */
+ return true
+ }
+ case 0x0B:
+ { /* '0x0B' */
+ return true
+ }
+ case 0x0C:
+ { /* '0x0C' */
+ return true
+ }
+ case 0x0F:
+ { /* '0x0F' */
+ return true
+ }
+ case 0x13:
+ { /* '0x13' */
+ return false
+ }
+ case 0x30:
+ { /* '0x30' */
+ return false
+ }
+ default:
+ {
+ return false
+ }
+ }
+}
+
+func (e TransportSize) GetSupported_S7_1200() bool {
+ switch e {
+ case 0x00:
+ { /* '0x00' */
+ return false
+ }
+ case 0x01:
+ { /* '0x01' */
+ return true
+ }
+ case 0x02:
+ { /* '0x02' */
+ return true
+ }
+ case 0x03:
+ { /* '0x03' */
+ return true
+ }
+ case 0x04:
+ { /* '0x04' */
+ return true
+ }
+ case 0x05:
+ { /* '0x05' */
+ return true
+ }
+ case 0x06:
+ { /* '0x06' */
+ return true
+ }
+ case 0x07:
+ { /* '0x07' */
+ return true
+ }
+ case 0x08:
+ { /* '0x08' */
+ return true
+ }
+ case 0x09:
+ { /* '0x09' */
+ return true
+ }
+ case 0x0A:
+ { /* '0x0A' */
+ return true
+ }
+ case 0x0B:
+ { /* '0x0B' */
+ return true
+ }
+ case 0x0C:
+ { /* '0x0C' */
+ return true
+ }
+ case 0x0F:
+ { /* '0x0F' */
+ return false
+ }
+ case 0x13:
+ { /* '0x13' */
+ return true
+ }
+ case 0x30:
+ { /* '0x30' */
+ return true
+ }
+ default:
+ {
+ return false
+ }
+ }
+}
+
+func (e TransportSize) GetSizeCode() uint8 {
+ switch e {
+ case 0x00:
+ { /* '0x00' */
+ return 'X'
+ }
+ case 0x01:
+ { /* '0x01' */
+ return 'X'
+ }
+ case 0x02:
+ { /* '0x02' */
+ return 'B'
+ }
+ case 0x03:
+ { /* '0x03' */
+ return 'B'
+ }
+ case 0x04:
+ { /* '0x04' */
+ return 'W'
+ }
+ case 0x05:
+ { /* '0x05' */
+ return 'W'
+ }
+ case 0x06:
+ { /* '0x06' */
+ return 'D'
+ }
+ case 0x07:
+ { /* '0x07' */
+ return 'D'
+ }
+ case 0x08:
+ { /* '0x08' */
+ return 'D'
+ }
+ case 0x09:
+ { /* '0x09' */
+ return 'X'
+ }
+ case 0x0A:
+ { /* '0x0A' */
+ return 'X'
+ }
+ case 0x0B:
+ { /* '0x0B' */
+ return 'X'
+ }
+ case 0x0C:
+ { /* '0x0C' */
+ return 'X'
+ }
+ case 0x0F:
+ { /* '0x0F' */
+ return 'X'
+ }
+ case 0x13:
+ { /* '0x13' */
+ return 'X'
+ }
+ case 0x30:
+ { /* '0x30' */
+ return 'X'
+ }
+ default:
+ {
+ return 0
+ }
+ }
+}
+
+func (e TransportSize) GetSupported_S7_1500() bool {
+ switch e {
+ case 0x00:
+ { /* '0x00' */
+ return true
+ }
+ case 0x01:
+ { /* '0x01' */
+ return true
+ }
+ case 0x02:
+ { /* '0x02' */
+ return true
+ }
+ case 0x03:
+ { /* '0x03' */
+ return true
+ }
+ case 0x04:
+ { /* '0x04' */
+ return true
+ }
+ case 0x05:
+ { /* '0x05' */
+ return true
+ }
+ case 0x06:
+ { /* '0x06' */
+ return true
+ }
+ case 0x07:
+ { /* '0x07' */
+ return true
+ }
+ case 0x08:
+ { /* '0x08' */
+ return true
+ }
+ case 0x09:
+ { /* '0x09' */
+ return true
+ }
+ case 0x0A:
+ { /* '0x0A' */
+ return true
+ }
+ case 0x0B:
+ { /* '0x0B' */
+ return true
+ }
+ case 0x0C:
+ { /* '0x0C' */
+ return true
+ }
+ case 0x0F:
+ { /* '0x0F' */
+ return true
+ }
+ case 0x13:
+ { /* '0x13' */
+ return true
+ }
+ case 0x30:
+ { /* '0x30' */
+ return true
+ }
+ default:
+ {
+ return false
+ }
+ }
+}
+
+func (e TransportSize) GetDataTransportSize() DataTransportSize {
+ switch e {
+ case 0x00:
+ { /* '0x00' */
+ return -1
+ }
+ case 0x01:
+ { /* '0x01' */
+ return DataTransportSize_BIT
+ }
+ case 0x02:
+ { /* '0x02' */
+ return DataTransportSize_BYTE_WORD_DWORD
+ }
+ case 0x03:
+ { /* '0x03' */
+ return DataTransportSize_BYTE_WORD_DWORD
+ }
+ case 0x04:
+ { /* '0x04' */
+ return DataTransportSize_BYTE_WORD_DWORD
+ }
+ case 0x05:
+ { /* '0x05' */
+ return DataTransportSize_INTEGER
+ }
+ case 0x06:
+ { /* '0x06' */
+ return DataTransportSize_BYTE_WORD_DWORD
+ }
+ case 0x07:
+ { /* '0x07' */
+ return DataTransportSize_INTEGER
+ }
+ case 0x08:
+ { /* '0x08' */
+ return DataTransportSize_BYTE_WORD_DWORD
+ }
+ case 0x09:
+ { /* '0x09' */
+ return DataTransportSize_BYTE_WORD_DWORD
+ }
+ case 0x0A:
+ { /* '0x0A' */
+ return DataTransportSize_BYTE_WORD_DWORD
+ }
+ case 0x0B:
+ { /* '0x0B' */
+ return -1
+ }
+ case 0x0C:
+ { /* '0x0C' */
+ return -1
+ }
+ case 0x0F:
+ { /* '0x0F' */
+ return -1
+ }
+ case 0x13:
+ { /* '0x13' */
+ return -1
+ }
+ case 0x30:
+ { /* '0x30' */
+ return -1
+ }
+ default:
+ {
+ return 0
+ }
+ }
+}
+
+func (e TransportSize) GetBaseType() TransportSize {
+ switch e {
+ case 0x00:
+ { /* '0x00' */
+ return -1
+ }
+ case 0x01:
+ { /* '0x01' */
+ return -1
+ }
+ case 0x02:
+ { /* '0x02' */
+ return -1
+ }
+ case 0x03:
+ { /* '0x03' */
+ return -1
+ }
+ case 0x04:
+ { /* '0x04' */
+ return -1
+ }
+ case 0x05:
+ { /* '0x05' */
+ return -1
+ }
+ case 0x06:
+ { /* '0x06' */
+ return TransportSize_WORD
+ }
+ case 0x07:
+ { /* '0x07' */
+ return TransportSize_INT
+ }
+ case 0x08:
+ { /* '0x08' */
+ return -1
+ }
+ case 0x09:
+ { /* '0x09' */
+ return -1
+ }
+ case 0x0A:
+ { /* '0x0A' */
+ return -1
+ }
+ case 0x0B:
+ { /* '0x0B' */
+ return -1
+ }
+ case 0x0C:
+ { /* '0x0C' */
+ return -1
+ }
+ case 0x0F:
+ { /* '0x0F' */
+ return -1
+ }
+ case 0x13:
+ { /* '0x13' */
+ return -1
+ }
+ case 0x30:
+ { /* '0x30' */
+ return TransportSize_REAL
+ }
+ default:
+ {
+ return 0
+ }
+ }
+}
+
+func (e TransportSize) GetDataProtocolId() uint8 {
+ switch e {
+ case 0x00:
+ { /* '0x00' */
+ return 14
+ }
+ case 0x01:
+ { /* '0x01' */
+ return 01
+ }
+ case 0x02:
+ { /* '0x02' */
+ return 11
+ }
+ case 0x03:
+ { /* '0x03' */
+ return 41
+ }
+ case 0x04:
+ { /* '0x04' */
+ return 12
+ }
+ case 0x05:
+ { /* '0x05' */
+ return 23
+ }
+ case 0x06:
+ { /* '0x06' */
+ return 13
+ }
+ case 0x07:
+ { /* '0x07' */
+ return 25
+ }
+ case 0x08:
+ { /* '0x08' */
+ return 31
+ }
+ case 0x09:
+ { /* '0x09' */
+ return 54
+ }
+ case 0x0A:
+ { /* '0x0A' */
+ return 55
+ }
+ case 0x0B:
+ { /* '0x0B' */
+ return 51
+ }
+ case 0x0C:
+ { /* '0x0C' */
+ return 52
+ }
+ case 0x0F:
+ { /* '0x0F' */
+ return 56
+ }
+ case 0x13:
+ { /* '0x13' */
+ return 42
+ }
+ case 0x30:
+ { /* '0x30' */
+ return 32
+ }
+ default:
+ {
+ return 0
+ }
+ }
+}
+
+func TransportSizeParse(io spi.ReadBuffer) (TransportSize, error) {
+ // TODO: Implement ...
+ return 0, nil
+}
+
+func (e TransportSize) Serialize(io spi.WriteBuffer) {
+ // TODO: Implement ...
+}
diff --git a/sandbox/plc4go/cmd/modbus/modbus.go b/sandbox/plc4go/internal/plc4go/spi/Utils.go
similarity index 58%
rename from sandbox/plc4go/cmd/modbus/modbus.go
rename to sandbox/plc4go/internal/plc4go/spi/Utils.go
index 1b1982a..a67273f 100644
--- a/sandbox/plc4go/cmd/modbus/modbus.go
+++ b/sandbox/plc4go/internal/plc4go/spi/Utils.go
@@ -1,3 +1,6 @@
+//
+// 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
@@ -13,26 +16,12 @@
// specific language governing permissions and limitations
// under the License.
//
-package main
-
-import (
- "encoding/hex"
- "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/modbus/readwrite/model"
- "plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/spi"
-)
+package spi
-func main() {
- request, err := hex.DecodeString("000a00000006010300000004")
- if err != nil {
- // Output an error ...
- }
- rb := spi.ReadBufferNew(request)
- adu, err := model.ModbusTcpADUParse(*rb, false)
- if err != nil {
- // Output an error ...
+func InlineIf(test bool, a uint16, b uint16) uint16 {
+ if test {
+ return a
+ } else {
+ return b
}
- if adu != nil {
- // Output success ...
- }
-
}
diff --git a/sandbox/plc4go/pom.xml b/sandbox/plc4go/pom.xml
index eee6c90..f827c20 100644
--- a/sandbox/plc4go/pom.xml
+++ b/sandbox/plc4go/pom.xml
@@ -57,6 +57,19 @@
<outputDir>${project.basedir}/internal</outputDir>
</configuration>
</execution>
+ <execution>
+ <id>generate-driver-s7</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate-driver</goal>
+ </goals>
+ <configuration>
+ <protocolName>s7</protocolName>
+ <languageName>go</languageName>
+ <outputFlavor>read-write</outputFlavor>
+ <outputDir>${project.basedir}/internal</outputDir>
+ </configuration>
+ </execution>
</executions>
</plugin>
@@ -67,6 +80,22 @@
<extensions>true</extensions>
<executions>
<execution>
+ <id>default-fix</id>
+ <!-- Move the execution of this after the code generation -->
+ <phase>process-sources</phase>
+ <goals>
+ <goal>fix</goal>
+ </goals>
+ </execution>
+ <!-- Move the execution of this after the code generation -->
+ <execution>
+ <id>default-get</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>get</goal>
+ </goals>
+ </execution>
+ <execution>
<id>run-go-vet</id>
<phase>verify</phase>
<goals>
@@ -79,7 +108,7 @@
<package>cmd/modbus/modbus.go</package>
</packages-->
<packages>
- <package>plc4x.apache.org/plc4go-modbus-driver/0.8.0/cmd/modbus</package>
+ <package>plc4x.apache.org/plc4go-modbus-driver/0.8.0/cmd/main</package>
<!--package>plc4x.apache.org/plc4go-modbus-driver/0.8.0/internal/plc4go/modbus/readwrite/model</package-->
</packages>
<sources>.</sources>
@@ -105,6 +134,13 @@
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-protocols-s7</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <!-- Scope is 'provided' as this way it's not shipped with the driver -->
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>com.igormaznitsa</groupId>