Skip to content

Commit

Permalink
feat(codegen): Fixed more issues in the C# code gent
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdutz committed Feb 25, 2022
1 parent 08dbabb commit b7dcde9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 25 deletions.
Expand Up @@ -80,8 +80,16 @@ public String getLanguageTypeNameForField(Field field) {
@Override
public String getLanguageTypeNameForTypeReference(TypeReference typeReference) {
Objects.requireNonNull(typeReference);
if (!(typeReference instanceof SimpleTypeReference)) {
return ((NonSimpleTypeReference) typeReference).getName();
if (typeReference instanceof ArrayTypeReference) {
final ArrayTypeReference arrayTypeReference = (ArrayTypeReference) typeReference;
return getLanguageTypeNameForTypeReference(arrayTypeReference.getElementTypeReference()) + "[]";
}
// DataIo data-types always have properties of type PlcValue
if (typeReference.isDataIoTypeReference()) {
return "PlcValue";
}
if (typeReference.isNonSimpleTypeReference()) {
return typeReference.asNonSimpleTypeReference().orElseThrow().getName();
}
SimpleTypeReference simpleTypeReference = (SimpleTypeReference) typeReference;
switch (simpleTypeReference.getBaseType()) {
Expand Down
Expand Up @@ -54,7 +54,7 @@ namespace org.apache.plc4net.drivers.${protocolName?replace("-", "")}.${outputFl
public enum ${type.name}
{
<#list type.enumValues as enumValue>
${enumValue.name}<#if type.type.orElseThrow().isNonSimpleTypeReference()> = ${enumValue.value}</#if>,
${enumValue.name}<#if type.type.isPresent()> = ${enumValue.value}</#if>,
</#list>
}

Expand Down
Expand Up @@ -106,12 +106,12 @@ namespace org.apache.plc4net.drivers.${protocolName?replace("-", "")}.${outputFl

// Properties.
<#list type.propertyFields as field>
public ${helper.getLanguageTypeNameForField(field)}<#if field.loopType??>[]</#if> ${field.name?cap_first} { get; }
public ${helper.getLanguageTypeNameForTypeReference(field.type)} ${field.name?cap_first} { get; }
</#list>
</#if>

<#-- getAllPropertyFields() returns not only the property fields of this type but also of it's parents -->
public ${type.name}(<#list type.getAllPropertyFields() as field>${helper.getLanguageTypeNameForField(field)}<#if field.loopType??>[]</#if> ${field.name}<#sep>, </#sep></#list>)
public ${type.name}(<#list type.getAllPropertyFields() as field>${helper.getLanguageTypeNameForField(field)} ${field.name}<#sep>, </#sep></#list>)
<#if type.getParentPropertyFields()?has_content>
: base(<#list type.getParentPropertyFields() as field>${field.name}<#sep>, </#sep></#list>)
</#if>
Expand Down
Expand Up @@ -24,8 +24,8 @@ namespace org.apache.plc4net.drivers.knxnetip.readwrite.model

public enum HostProtocolCode
{
IPV4_UDP,
IPV4_TCP,
IPV4_UDP = 0x01,
IPV4_TCP = 0x02,
}

}
Expand Down
Expand Up @@ -604,8 +604,10 @@ public enum KnxManufacturer
M_TECGET = 577,
M_XEROPOINT = 578,
M_HONEYWELL_BUILDING_TECHNOLOGIES = 579,
M_ABB___RESERVED = 580,
M_BUSCH_JAEGER_ELEKTRO___RESERVED = 581,
M_COMFORTCLICK = 580,
M_DORBAS_ELECTRIC = 581,
M_ABB___RESERVED = 582,
M_BUSCH_JAEGER_ELEKTRO___RESERVED = 583,
}

public static class KnxManufacturerInfo
Expand Down Expand Up @@ -2220,10 +2222,16 @@ public static class KnxManufacturerInfo
case KnxManufacturer.M_DAETWYLER: { /* '58' */
return 97;
}
case KnxManufacturer.M_ABB___RESERVED: { /* '580' */
case KnxManufacturer.M_COMFORTCLICK: { /* '580' */
return 638;
}
case KnxManufacturer.M_DORBAS_ELECTRIC: { /* '581' */
return 639;
}
case KnxManufacturer.M_ABB___RESERVED: { /* '582' */
return 43954;
}
case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '581' */
case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '583' */
return 43959;
}
case KnxManufacturer.M_ELECTRAK: { /* '59' */
Expand Down Expand Up @@ -3976,10 +3984,16 @@ public static string Name(this KnxManufacturer value)
case KnxManufacturer.M_DAETWYLER: { /* '58' */
return "Dätwyler";
}
case KnxManufacturer.M_ABB___RESERVED: { /* '580' */
case KnxManufacturer.M_COMFORTCLICK: { /* '580' */
return "ComfortClick";
}
case KnxManufacturer.M_DORBAS_ELECTRIC: { /* '581' */
return "DORBAS ELECTRIC";
}
case KnxManufacturer.M_ABB___RESERVED: { /* '582' */
return "ABB - reserved";
}
case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '581' */
case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '583' */
return "Busch-Jaeger Elektro - reserved";
}
case KnxManufacturer.M_ELECTRAK: { /* '59' */
Expand Down
Expand Up @@ -24,18 +24,18 @@ namespace org.apache.plc4net.drivers.knxnetip.readwrite.model

public enum Status
{
NO_ERROR,
PROTOCOL_TYPE_NOT_SUPPORTED,
UNSUPPORTED_PROTOCOL_VERSION,
OUT_OF_ORDER_SEQUENCE_NUMBER,
INVALID_CONNECTION_ID,
CONNECTION_TYPE_NOT_SUPPORTED,
CONNECTION_OPTION_NOT_SUPPORTED,
NO_MORE_CONNECTIONS,
NO_MORE_UNIQUE_CONNECTIONS,
DATA_CONNECTION,
KNX_CONNECTION,
TUNNELLING_LAYER_NOT_SUPPORTED,
NO_ERROR = 0x00,
PROTOCOL_TYPE_NOT_SUPPORTED = 0x01,
UNSUPPORTED_PROTOCOL_VERSION = 0x02,
OUT_OF_ORDER_SEQUENCE_NUMBER = 0x04,
INVALID_CONNECTION_ID = 0x21,
CONNECTION_TYPE_NOT_SUPPORTED = 0x22,
CONNECTION_OPTION_NOT_SUPPORTED = 0x23,
NO_MORE_CONNECTIONS = 0x24,
NO_MORE_UNIQUE_CONNECTIONS = 0x25,
DATA_CONNECTION = 0x26,
KNX_CONNECTION = 0x27,
TUNNELLING_LAYER_NOT_SUPPORTED = 0x29,
}

}
Expand Down

0 comments on commit b7dcde9

Please sign in to comment.