Skip to content

Commit

Permalink
- Added a check for the installation of go
Browse files Browse the repository at this point in the history
- Updated the dotnet check to check for at least version 4.5.2
- Added code generation for C# enums
  • Loading branch information
chrisdutz committed Dec 15, 2021
1 parent 7a4b8cb commit 3e17453
Show file tree
Hide file tree
Showing 13 changed files with 4,226 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ protected List<Template> getComplexTypeTemplates(Configuration freemarkerConfigu

@Override
protected List<Template> getEnumTypeTemplates(Configuration freemarkerConfiguration) throws IOException {
return Collections.emptyList();
return Collections.singletonList(
freemarkerConfiguration.getTemplate("templates/cs/enum-template.ftlh"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<#--
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.
-->
<#-- Prevent freemarker from escaping stuff -->
<#outputformat "undefined">
<#-- Declare the name and type of variables passed in to the template -->
<#-- @ftlvariable name="languageName" type="java.lang.String" -->
<#-- @ftlvariable name="protocolName" type="java.lang.String" -->
<#-- @ftlvariable name="outputFlavor" type="java.lang.String" -->
<#-- @ftlvariable name="helper" type="org.apache.plc4x.language.cs.CsLanguageTemplateHelper" -->
<#-- @ftlvariable name="type" type="org.apache.plc4x.plugins.codegenerator.types.definitions.EnumTypeDefinition" -->
<#-- @ftlvariable name="simpleTypeReference" type="org.apache.plc4x.plugins.codegenerator.types.references.SimpleTypeReference" -->
${helper.fileName(protocolName, languageName, outputFlavor)?replace(".", "/")}/model/${type.name}.cs
//
// 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.
//

namespace org.apache.plc4net.drivers.${protocolName?replace("-", "")}.${outputFlavor?replace("-", "")}.model
{

public enum ${type.name}<#if !helper.isStringTypeReference(type.type)> : ${helper.getLanguageTypeNameForTypeReference(type.type)}</#if>
{

<#list type.enumValues as enumValue>
${enumValue.name}<#if !helper.isStringTypeReference(type.type)> = ${enumValue.value}</#if>,
</#list>

}

<#if type.constantNames?has_content>
public static class ${type.name}Info
{
<#list type.constantNames as constantName>

public static ${helper.getLanguageTypeNameForTypeReference(type.getConstantType(constantName))} ${constantName?cap_first}(this ${type.name} value)
{
switch (value)
{
<#list helper.getUniqueEnumValues(type.enumValues) as enumValue>
case ${type.name}.${enumValue.name}: { /* '${enumValue.value}' */
return ${helper.escapeEnumValue(type.getConstantType(constantName), enumValue.getConstant(constantName))};
}
</#list>
default: {
return ${helper.getNullValueForTypeReference(type.getConstantType(constantName))};
}
}
}
</#list>
}

</#if>
}

</#outputformat>
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
using System;
//
// 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.
//

using System.Collections.Generic;
using org.apache.plc4net.api.value;
using org.apache.plc4net.drivers.knxnetip.readwrite.model;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// 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.
//

namespace org.apache.plc4net.drivers.knxnetip.readwrite.model
{

public enum APCI : byte
{

GROUP_VALUE_READ_PDU = 0x0,
GROUP_VALUE_RESPONSE_PDU = 0x1,
GROUP_VALUE_WRITE_PDU = 0x2,
INDIVIDUAL_ADDRESS_WRITE_PDU = 0x3,
INDIVIDUAL_ADDRESS_READ_PDU = 0x4,
INDIVIDUAL_ADDRESS_RESPONSE_PDU = 0x5,
ADC_READ_PDU = 0x6,
ADC_RESPONSE_PDU = 0x7,
MEMORY_READ_PDU = 0x8,
MEMORY_RESPONSE_PDU = 0x9,
MEMORY_WRITE_PDU = 0xA,
USER_MESSAGE_PDU = 0xB,
DEVICE_DESCRIPTOR_READ_PDU = 0xC,
DEVICE_DESCRIPTOR_RESPONSE_PDU = 0xD,
RESTART_PDU = 0xE,
OTHER_PDU = 0xF,

}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// 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.
//

namespace org.apache.plc4net.drivers.knxnetip.readwrite.model
{

public enum CEMIPriority : byte
{

SYSTEM = 0x0,
NORMAL = 0x1,
URGENT = 0x2,
LOW = 0x3,

}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// 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.
//

namespace org.apache.plc4net.drivers.knxnetip.readwrite.model
{

public enum HostProtocolCode : byte
{

IPV4_UDP = 0x01,
IPV4_TCP = 0x02,

}

}

Loading

0 comments on commit 3e17453

Please sign in to comment.