Skip to content

Commit

Permalink
Merge f9ebc20 into 5604203
Browse files Browse the repository at this point in the history
  • Loading branch information
Pro committed Feb 26, 2019
2 parents 5604203 + f9ebc20 commit bf24293
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ ua_generate_datatypes(

# transport data types
ua_generate_datatypes(
INTERNAL
NAME "ua_transport"
TARGET_SUFFIX "transport"
NAMESPACE_IDX 1
Expand Down
13 changes: 1 addition & 12 deletions examples/nodeset/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,9 @@ endif()
# POWERLINK requires the full ns0 as basis
if(UA_NAMESPACE_ZERO STREQUAL "FULL")

# Generate types and namespace for DI
#ua_generate_nodeset_and_datatypes(
# NAME "di"
# FILE_CSV "${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/OpcUaDiModel.csv"
# FILE_BSD "${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.Types.bsd"
# NAMESPACE_IDX 2
# FILE_NS "${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml"
# INTERNAL
#)

# generate powerlink namespace which is using DI
ua_generate_nodeset_and_datatypes(
NAME "powerlink"
# POWERLINK does not define custom types. Only generate the nodeset
FILE_CSV "${PROJECT_SOURCE_DIR}/deps/ua-nodeset/POWERLINK/Opc.Ua.POWERLINK.NodeIds.csv"
FILE_BSD "${PROJECT_SOURCE_DIR}/examples/nodeset/Opc.Ua.POWERLINK.NodeSet2.bsd"
NAMESPACE_IDX 3
Expand All @@ -108,7 +97,7 @@ if(UA_NAMESPACE_ZERO STREQUAL "FULL")
${PROJECT_BINARY_DIR}/src_generated/ua_types_powerlink_generated.c
${PROJECT_BINARY_DIR}/src_generated/ua_namespace_di.c
${PROJECT_BINARY_DIR}/src_generated/ua_namespace_powerlink.c)
add_dependencies(server_nodeset_plcopen open62541-generator-ns-powerlink)
add_dependencies(server_nodeset_powerlink open62541-generator-ns-powerlink)


endif()
9 changes: 8 additions & 1 deletion tools/cmake/macros_public.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ endfunction()
# Options:
#
# [BUILTIN] Optional argument. If given, then builtin types will be generated.
# [INTERNAL] Optional argument. If given, then the given types file is seen as internal file (e.g. does not require a .csv)
#
# Arguments taking one value:
#
Expand All @@ -100,7 +101,7 @@ endfunction()
#
#
function(ua_generate_datatypes)
set(options BUILTIN)
set(options BUILTIN INTERNAL)
set(oneValueArgs NAME TARGET_SUFFIX TARGET_PREFIX NAMESPACE_IDX OUTPUT_DIR FILE_CSV)
set(multiValueArgs FILES_BSD FILES_SELECTED)
cmake_parse_arguments(UA_GEN_DT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
Expand Down Expand Up @@ -143,6 +144,11 @@ function(ua_generate_datatypes)
set(UA_GEN_DT_NO_BUILTIN "")
endif()

set(UA_GEN_DT_INTERNAL_ARG "")
if (UA_GEN_DT_INTERNAL)
set(UA_GEN_DT_INTERNAL_ARG "--internal")
endif()


set(SELECTED_TYPES_TMP "")
foreach(f ${UA_GEN_DT_FILES_SELECTED})
Expand Down Expand Up @@ -170,6 +176,7 @@ function(ua_generate_datatypes)
${BSD_FILES_TMP}
--type-csv=${UA_GEN_DT_FILE_CSV}
${UA_GEN_DT_NO_BUILTIN}
${UA_GEN_DT_INTERNAL_ARG}
${UA_GEN_DT_OUTPUT_DIR}/${UA_GEN_DT_NAME}
DEPENDS ${open62541_TOOLS_DIR}/generate_datatypes.py
${UA_GEN_DT_FILES_BSD}
Expand Down
14 changes: 13 additions & 1 deletion tools/generate_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"QualifiedName", "LocalizedText", "ExtensionObject", "DataValue",
"Variant", "DiagnosticInfo"]

# If set to False, every defined datatype must have a corresponding ID entry in the csv file
isInternalTypes = False

# Some types can be memcpy'd off the binary stream. That's especially important
# for arrays. But we need to check if they contain padding and whether the
# endianness is correct. This dict gives the C-statement that must be true for the
Expand Down Expand Up @@ -129,7 +132,10 @@ def datatype_c(self):
# xmlEncodingId = description.xmlEncodingId
binaryEncodingId = description.binaryEncodingId
else:
typeid = "{0, UA_NODEIDTYPE_NUMERIC, {0}}"
if not isInternalTypes:
raise RuntimeError("NodeId for " + self.name + " not found in .csv file")
else:
typeid = "{0, UA_NODEIDTYPE_NUMERIC, {0}}"
idName = makeCIdentifier(self.name)
return "{\n UA_TYPENAME(\"%s\") /* .typeName */\n" % idName + \
" " + typeid + ", /* .typeId */\n" + \
Expand Down Expand Up @@ -473,6 +479,11 @@ def merge_dicts(*dict_args):
default=[],
help='JSON file with opaque type mapping: { \'typename\': { \'ns\': 0, \'id\': 7, \'name\': \'UInt32\' }, ... }')

parser.add_argument('--internal',
action='store_true',
dest="internal",
help='Given bsd are internal types which do not have any .csv file')

parser.add_argument('-t', '--type-bsd',
metavar="<typeBsds>",
type=argparse.FileType('r'),
Expand All @@ -489,6 +500,7 @@ def merge_dicts(*dict_args):
outname = args.outfile.split("/")[-1]
inname = ', '.join(list(map(lambda x:x.name.split("/")[-1], args.type_bsd)))

isInternalTypes = args.internal

################
# Create Types #
Expand Down

0 comments on commit bf24293

Please sign in to comment.