opc source code
This commit is contained in:
302
third_party/open62541/tools/nodeset_injector/CMakeLists.txt
vendored
Normal file
302
third_party/open62541/tools/nodeset_injector/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,302 @@
|
||||
foreach(MODEL ${UA_INFORMATION_MODEL_AUTOLOAD})
|
||||
string(TOLOWER "${MODEL}" NODESET_NAME)
|
||||
|
||||
# only one xml file
|
||||
# no dependency
|
||||
if(MODEL STREQUAL "DEXPI" OR MODEL STREQUAL "Safety" OR MODEL STREQUAL "CNC" OR MODEL STREQUAL "BACnet"
|
||||
OR MODEL STREQUAL "AMB" OR MODEL STREQUAL "MachineVision" OR MODEL STREQUAL "RSL" OR MODEL STREQUAL "I4AAS"
|
||||
OR MODEL STREQUAL "PackML" OR MODEL STREQUAL "MTConnect")
|
||||
# get csv file
|
||||
file(GLOB files "${UA_NODESET_DIR}/${MODEL}/*.csv")
|
||||
foreach(file ${files})
|
||||
string(REGEX MATCH "(.*nodeids.csv)|(.*NodeIds.csv)|(Opc.Ua.${MODEL}.NodeSet[2]?.csv)" csv_file_match ${file})
|
||||
if(csv_file_match)
|
||||
set(csv_file ${file})
|
||||
endif()
|
||||
endforeach()
|
||||
# get xml file
|
||||
file(GLOB files "${UA_NODESET_DIR}/${MODEL}/*.xml")
|
||||
foreach(file ${files})
|
||||
string(REGEX MATCH "Opc.Ua.${MODEL}.NodeSet[2]?.xml" xml_file_match ${file})
|
||||
if(xml_file_match)
|
||||
set(xml_file ${file})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${csv_file}"
|
||||
IMPORT_BSD "UA_TYPES#${UA_NODESET_DIR}/Schema/Opc.Ua.Types.bsd"
|
||||
FILE_NS "${xml_file}"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
)
|
||||
|
||||
# only one xml file
|
||||
# di as dependency
|
||||
elseif(MODEL STREQUAL "CSPPlusForMachine" OR MODEL STREQUAL "POWERLINK"
|
||||
OR MODEL STREQUAL "IA" OR MODEL STREQUAL "FDT" OR MODEL STREQUAL "Robotics"
|
||||
OR MODEL STREQUAL "CommercialKitchenEquipment" OR MODEL STREQUAL "Machinery")
|
||||
# get csv file
|
||||
file(GLOB files "${UA_NODESET_DIR}/${MODEL}/*.csv")
|
||||
foreach(file ${files})
|
||||
string(REGEX MATCH "(.*nodeids.csv)|(.*NodeIds.csv)|(Opc.Ua.${MODEL}.NodeSet[2]?.csv)" csv_file_match ${file})
|
||||
if(csv_file_match)
|
||||
set(csv_file ${file})
|
||||
endif()
|
||||
endforeach()
|
||||
# get xml file
|
||||
file(GLOB files "${UA_NODESET_DIR}/${MODEL}/*.xml")
|
||||
foreach(file ${files})
|
||||
string(REGEX MATCH "Opc.Ua.${MODEL}.NodeSet[2]?.xml" xml_file_match ${file})
|
||||
if(xml_file_match)
|
||||
set(xml_file ${file})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${csv_file}"
|
||||
IMPORT_BSD "UA_TYPES#${UA_NODESET_DIR}/Schema/Opc.Ua.Types.bsd"
|
||||
FILE_NS "${xml_file}"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
)
|
||||
|
||||
# more dependencies
|
||||
elseif(MODEL STREQUAL "CAS")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeIds.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
DEPENDS "machinery"
|
||||
DEPENDS "ia"
|
||||
)
|
||||
elseif(MODEL STREQUAL "TMC")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeIds.csv"
|
||||
IMPORT_BSD "UA_TYPES#${UA_NODESET_DIR}/Schema/Opc.Ua.Types.bsd"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
DEPENDS "packml"
|
||||
)
|
||||
elseif(MODEL STREQUAL "Pumps")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeSet2.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
DEPENDS "machinery"
|
||||
)
|
||||
elseif(MODEL STREQUAL "Weihenstephan")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/NodeIds.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
DEPENDS "machinery"
|
||||
DEPENDS "packml"
|
||||
)
|
||||
elseif(MODEL STREQUAL "MachineTool")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/NodeIds.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
DEPENDS "machinery"
|
||||
DEPENDS "ia"
|
||||
)
|
||||
elseif(MODEL STREQUAL "Scales")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeIds.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
DEPENDS "machinery"
|
||||
DEPENDS "packml"
|
||||
)
|
||||
# Extra
|
||||
elseif(MODEL STREQUAL "DI")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.Di.NodeIds.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.Di.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
)
|
||||
elseif(MODEL STREQUAL "AutoID")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${PROJECT_SOURCE_DIR}/tools/nodeset_injector/schema/Opc.Ua.AutoID.NodeIds.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.AutoID.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
)
|
||||
elseif(MODEL STREQUAL "PROFINET")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.Pn.NodeIds.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.Pn.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
)
|
||||
elseif(MODEL STREQUAL "Glass")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/Flat/NodeIds.csv"
|
||||
IMPORT_BSD "UA_TYPES#${UA_NODESET_DIR}/Schema/Opc.Ua.Types.bsd"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Flat/Opc.Ua.${MODEL}.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
DEPENDS "machinery"
|
||||
)
|
||||
elseif(MODEL STREQUAL "IJT")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/Tightening/NodeIds.csv"
|
||||
IMPORT_BSD "UA_TYPES#${UA_NODESET_DIR}/Schema/Opc.Ua.Types.bsd"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Tightening/Opc.Ua.Ijt.Tightening.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
DEPENDS "machinery"
|
||||
)
|
||||
elseif(MODEL STREQUAL "OpenSCS")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/NodeIds.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.OPENSCS.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
)
|
||||
elseif(MODEL STREQUAL "PNEM")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/NodeIds.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.PnEm.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
)
|
||||
elseif(MODEL STREQUAL "PNRIO")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/NodeIds.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.PnRio.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
)
|
||||
elseif(MODEL STREQUAL "ISA95-JOBCONTROL")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/opc.ua.isa95-jobcontrol.nodeset2.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/opc.ua.isa95-jobcontrol.nodeset2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
)
|
||||
elseif(MODEL STREQUAL "PLCopen")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeSet2_V1.02.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeSet2_V1.02.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
)
|
||||
elseif(MODEL STREQUAL "ADI")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/OpcUaAdiModel.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.Adi.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
)
|
||||
elseif(MODEL STREQUAL "MDIS")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/MDIS.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.MDIS.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
)
|
||||
elseif(MODEL STREQUAL "Sercos")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/SercosModel.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Sercos.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
)
|
||||
elseif(MODEL STREQUAL "GDS")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
IMPORT_BSD "UA_TYPES#${UA_NODESET_DIR}/Schema/Opc.Ua.Types.bsd"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/OpcUaGdsModel.csv"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.Gds.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
)
|
||||
elseif(MODEL STREQUAL "PADIM")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "irdi"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.IRDI.NodeSet2.xml"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
)
|
||||
|
||||
set(TMP_NSURI "http://opcfoundation.org/UA/${MODEL}/")
|
||||
configure_file(${PROJECT_SOURCE_DIR}/tools/nodeset_injector/empty.bsd.template "${CMAKE_BINARY_DIR}/bsd_files_gen/Opc.Ua.${MODEL}.Types.bsd")
|
||||
ua_generate_nodeset_and_datatypes(
|
||||
NAME "${NODESET_NAME}"
|
||||
FILE_NS "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeSet2.xml"
|
||||
FILE_CSV "${UA_NODESET_DIR}/${MODEL}/Opc.Ua.${MODEL}.NodeIds.csv"
|
||||
FILE_BSD "${CMAKE_BINARY_DIR}/bsd_files_gen/Opc.Ua.${MODEL}.Types.bsd"
|
||||
INTERNAL
|
||||
AUTOLOAD
|
||||
DEPENDS "di"
|
||||
DEPENDS "irdi"
|
||||
)
|
||||
else()
|
||||
MESSAGE(WARNING "The specified nodeset '${MODEL}' is not supported or is misspelled.")
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
|
||||
|
||||
add_library(autoinject_library ${UA_NODESETINJECTOR_SOURCE_FILES} ${PROJECT_BINARY_DIR}/src_generated/open62541/nodesetinjector.c)
|
||||
target_link_libraries(autoinject_library open62541)
|
||||
foreach(EXAMPLE_NAME ${UA_NODESETINJECTOR_EXAMPLE_NAMES})
|
||||
if(UA_NODESETINJECTOR_GENERATORS)
|
||||
target_link_libraries(${EXAMPLE_NAME} autoinject_library)
|
||||
add_dependencies(${EXAMPLE_NAME} ${UA_NODESETINJECTOR_GENERATORS})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(UA_BUILD_UNIT_TESTS)
|
||||
foreach(TEST_NAME ${UA_NODESETINJECTOR_TEST_NAMES})
|
||||
if(UA_NODESETINJECTOR_GENERATORS)
|
||||
target_link_libraries(${TEST_NAME} autoinject_library)
|
||||
add_dependencies(${TEST_NAME} ${UA_NODESETINJECTOR_GENERATORS})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
3
third_party/open62541/tools/nodeset_injector/empty.bsd.template
vendored
Normal file
3
third_party/open62541/tools/nodeset_injector/empty.bsd.template
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<opc:TypeDictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="${TMP_NSURI}" DefaultByteOrder="LittleEndian" xmlns:opc="http://opcfoundation.org/BinarySchema/" xmlns:ua="http://opcfoundation.org/UA/" TargetNamespace="${TMP_NSURI}">
|
||||
<opc:Import Namespace="http://opcfoundation.org/UA/"/>
|
||||
</opc:TypeDictionary>
|
||||
68
third_party/open62541/tools/nodeset_injector/generate_nodesetinjector.py
vendored
Normal file
68
third_party/open62541/tools/nodeset_injector/generate_nodesetinjector.py
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
### This Source Code Form is subject to the terms of the Mozilla Public
|
||||
### License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
### file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
### Copyright 2023 (c) Fraunhofer IOSB (Author: Noel Graf)
|
||||
|
||||
import argparse
|
||||
from io import open
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('outfile', help='outfile w/o extension')
|
||||
args = parser.parse_args()
|
||||
|
||||
fh = open(args.outfile + ".h", "wt", encoding='utf8')
|
||||
fc = open(args.outfile + ".c", "wt", encoding='utf8')
|
||||
|
||||
def printh(string):
|
||||
print(string, end=u'\n', file=fh)
|
||||
def printc(string):
|
||||
print(string, end=u'\n', file=fc)
|
||||
|
||||
#########################
|
||||
# Print the header file #
|
||||
#########################
|
||||
|
||||
printh(u'''
|
||||
/* WARNING: This is a generated file.
|
||||
* Any manual changes will be overwritten. */
|
||||
|
||||
#ifndef NODESETINJECTOR_H_
|
||||
#define NODESETINJECTOR_H_
|
||||
|
||||
#include <open62541/server.h>
|
||||
#include <open62541/plugin/log_stdout.h>
|
||||
|
||||
_UA_BEGIN_DECLS
|
||||
|
||||
extern UA_StatusCode UA_Server_injectNodesets(UA_Server *server);
|
||||
|
||||
_UA_END_DECLS
|
||||
|
||||
#endif /* NODESETINJECTOR_H_ */
|
||||
''')
|
||||
|
||||
#########################
|
||||
# Print the source file #
|
||||
#########################
|
||||
|
||||
printc(u'''
|
||||
/* WARNING: This is a generated file.
|
||||
* Any manual changes will be overwritten. */
|
||||
|
||||
#include "nodesetinjector.h"
|
||||
//<
|
||||
|
||||
UA_StatusCode UA_Server_injectNodesets(UA_Server *server) {
|
||||
UA_StatusCode retval = UA_STATUSCODE_GOOD;
|
||||
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Attaching the AUTOLOAD Nodesets to the server!");
|
||||
//>
|
||||
|
||||
return retval;
|
||||
}
|
||||
''')
|
||||
|
||||
fc.close()
|
||||
fh.close()
|
||||
148
third_party/open62541/tools/nodeset_injector/generate_nodesetinjector_content.py
vendored
Normal file
148
third_party/open62541/tools/nodeset_injector/generate_nodesetinjector_content.py
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
### This Source Code Form is subject to the terms of the Mozilla Public
|
||||
### License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
### file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
### Copyright 2023 (c) Fraunhofer IOSB (Author: Noel Graf)
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import os
|
||||
import platform
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('outfile', help='outfile w/o extension')
|
||||
parser.add_argument('namespace', help='namespace')
|
||||
args = parser.parse_args()
|
||||
|
||||
include_line_counter = 0
|
||||
code_line_counter = 0
|
||||
existing_namespaces = []
|
||||
data = []
|
||||
|
||||
|
||||
def is_unix():
|
||||
try:
|
||||
# Check if the os.uname() function is available
|
||||
os.uname()
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def windows_exec():
|
||||
import msvcrt
|
||||
|
||||
global include_line_counter
|
||||
global code_line_counter
|
||||
global existing_namespaces
|
||||
global data
|
||||
|
||||
# Open the file in read-write mode
|
||||
with open(args.outfile + ".c", "r+", encoding='utf8') as file:
|
||||
# Lock the file
|
||||
msvcrt.locking(file.fileno(), msvcrt.LK_LOCK, 1)
|
||||
|
||||
# Write to the file
|
||||
write_code_generation(file)
|
||||
|
||||
# Unlock the file
|
||||
msvcrt.locking(file.fileno(), msvcrt.LK_UNLCK, 1)
|
||||
|
||||
|
||||
def unix_exec():
|
||||
import fcntl
|
||||
|
||||
global include_line_counter
|
||||
global code_line_counter
|
||||
global existing_namespaces
|
||||
global data
|
||||
|
||||
with open(args.outfile + ".c", "r+", encoding='utf8') as file:
|
||||
# Acquire a lock on the file
|
||||
fcntl.flock(file, fcntl.LOCK_EX)
|
||||
|
||||
# Write to the file
|
||||
write_code_generation(file)
|
||||
|
||||
# Release the lock on the file
|
||||
fcntl.flock(file, fcntl.LOCK_UN)
|
||||
|
||||
|
||||
def print_include(string):
|
||||
data[include_line_counter] = string
|
||||
|
||||
|
||||
def print_function_call(string):
|
||||
data[code_line_counter] = string
|
||||
|
||||
|
||||
def generate_code():
|
||||
#########################
|
||||
# Print the header file #
|
||||
#########################
|
||||
|
||||
print_include(u'''
|
||||
#include <open62541/{namespace}.h>
|
||||
//<
|
||||
'''.format(namespace=args.namespace))
|
||||
|
||||
#########################
|
||||
# Print the source file #
|
||||
#########################
|
||||
|
||||
print_function_call(u'''
|
||||
/* {namespace} */
|
||||
retval |= {namespace}(server);
|
||||
if(retval != UA_STATUSCODE_GOOD) {{
|
||||
UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Adding the {namespace} failed. Please check previous error output.");
|
||||
UA_Server_delete(server);
|
||||
return EXIT_FAILURE;
|
||||
}}
|
||||
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "The {namespace} successfully added.");
|
||||
//>
|
||||
'''.format(namespace=args.namespace))
|
||||
|
||||
|
||||
def write_code_generation(file):
|
||||
global include_line_counter
|
||||
global code_line_counter
|
||||
global existing_namespaces
|
||||
global data
|
||||
|
||||
# Write to the file
|
||||
lines = file.readlines()
|
||||
line_counter = 0
|
||||
# List which contains the existing namespaces
|
||||
existing_namespaces = []
|
||||
for line in lines:
|
||||
namespaces = re.findall("namespace_.*_generated\(.*\)", line)
|
||||
if namespaces:
|
||||
namespaces = namespaces[0].split("(")[0]
|
||||
existing_namespaces.append(namespaces)
|
||||
if re.search("//<", line):
|
||||
include_line_counter = line_counter
|
||||
if re.search("//>", line):
|
||||
code_line_counter = line_counter
|
||||
line_counter += 1
|
||||
|
||||
if args.namespace not in existing_namespaces:
|
||||
# Set the file descriptor to the beginning of the file
|
||||
file.seek(0)
|
||||
# read a list of lines into data
|
||||
data = file.readlines()
|
||||
generate_code()
|
||||
# Set the file descriptor to the beginning of the file and delete content
|
||||
file.seek(0)
|
||||
file.truncate(0)
|
||||
file.writelines(data)
|
||||
|
||||
|
||||
if platform.system == "Linux":
|
||||
unix_exec()
|
||||
else:
|
||||
if is_unix():
|
||||
unix_exec()
|
||||
else:
|
||||
windows_exec()
|
||||
240
third_party/open62541/tools/nodeset_injector/schema/Opc.Ua.AutoID.NodeIds.csv
vendored
Normal file
240
third_party/open62541/tools/nodeset_injector/schema/Opc.Ua.AutoID.NodeIds.csv
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
AutoIdDeviceType,1001,ObjectType
|
||||
OcrReaderDeviceType,1002,ObjectType
|
||||
RfidReaderDeviceType,1003,ObjectType
|
||||
AutoIdScanEventType,1004,ObjectType
|
||||
OcrScanEventType,1005,ObjectType
|
||||
RfidScanEventType,1006,ObjectType
|
||||
OpticalReaderDeviceType,1008,ObjectType
|
||||
OpticalScanEventType,1009,ObjectType
|
||||
OpticalVerifierDeviceType,1011,ObjectType
|
||||
RtlsDeviceType,1012,ObjectType
|
||||
OpticalVerifierScanEventType,1013,ObjectType
|
||||
RtlsLocationEventType,1014,ObjectType
|
||||
LocationVariableType,2002,VariableType
|
||||
ScanResult,3001,DataType
|
||||
OcrScanResult,3002,DataType
|
||||
DeviceStatusEnumeration,3003,DataType
|
||||
Position,3004,DataType
|
||||
RfidSighting,3006,DataType
|
||||
RfidScanResult,3007,DataType
|
||||
Location,3008,DataType
|
||||
LocationTypeEnumeration,3009,DataType
|
||||
ScanSettings,3010,DataType
|
||||
AntennaNameIdPair,3011,DataType
|
||||
NmeaCoordinateString,3012,DataType
|
||||
AutoIdOperationStatusEnumeration,3013,DataType
|
||||
RfidPasswordTypeEnumeration,3014,DataType
|
||||
RfidLockRegionEnumeration,3015,DataType
|
||||
RfidLockOperationEnumeration,3016,DataType
|
||||
AccessResult,3017,DataType
|
||||
RfidAccessResult,3018,DataType
|
||||
LocalCoordinate,3019,DataType
|
||||
ScanData,3020,DataType
|
||||
LocationName,3021,DataType
|
||||
DhcpGeoConfCoordinate,3023,DataType
|
||||
ScanDataEpc,3024,DataType
|
||||
OpticalScanResult,3026,DataType
|
||||
WGS84Coordinate,3027,DataType
|
||||
RtlsLocationResult,3028,DataType
|
||||
Rotation,3029,DataType
|
||||
OpticalVerifierScanResult,3030,DataType
|
||||
CodeTypeDataType,3031,DataType
|
||||
OpticalReaderDeviceType_Images,5001,Object
|
||||
ScanResult_Encoding_DefaultBinary,5002,Object
|
||||
ScanResult_Encoding_DefaultXml,5003,Object
|
||||
OcrScanResult_Encoding_DefaultBinary,5004,Object
|
||||
OcrScanResult_Encoding_DefaultXml,5005,Object
|
||||
OcrReaderDeviceType_Images,5006,Object
|
||||
Position_Encoding_DefaultBinary,5007,Object
|
||||
Position_Encoding_DefaultXml,5008,Object
|
||||
RfidSighting_Encoding_DefaultBinary,5009,Object
|
||||
RfidSighting_Encoding_DefaultXml,5010,Object
|
||||
RfidScanResult_Encoding_DefaultBinary,5011,Object
|
||||
RfidScanResult_Encoding_DefaultXml,5012,Object
|
||||
Location_Encoding_DefaultBinary,5013,Object
|
||||
Location_Encoding_DefaultXml,5014,Object
|
||||
ScanSettings_Encoding_DefaultBinary,5015,Object
|
||||
ScanSettings_Encoding_DefaultXml,5016,Object
|
||||
AntennaNameIdPair_Encoding_DefaultBinary,5017,Object
|
||||
AntennaNameIdPair_Encoding_DefaultXml,5018,Object
|
||||
Server_Namespaces_http___opcfoundation_org_UA_AutoID_,5019,Object
|
||||
OpticalReaderDeviceType_Images_ImageName,5020,Object
|
||||
OcrReaderDeviceType_Images_ImageName,5021,Object
|
||||
LocalCoordinate_Encoding_DefaultBinary,5028,Object
|
||||
LocalCoordinate_Encoding_DefaultXml,5029,Object
|
||||
ScanData_Encoding_DefaultBinary,5030,Object
|
||||
ScanData_Encoding_DefaultXml,5031,Object
|
||||
DhcpGeoConfCoordinate_Encoding_DefaultBinary,5034,Object
|
||||
DhcpGeoConfCoordinate_Encoding_DefaultXml,5035,Object
|
||||
ScanDataEpc_Encoding_DefaultBinary,5036,Object
|
||||
ScanDataEpc_Encoding_DefaultXml,5037,Object
|
||||
OpticalScanResult_Encoding_DefaultBinary,5040,Object
|
||||
OpticalScanResult_Encoding_DefaultXml,5041,Object
|
||||
AutoIdDeviceType_RuntimeParameters,5044,Object
|
||||
WGS84Coordinate_Encoding_DefaultBinary,5046,Object
|
||||
WGS84Coordinate_Encoding_DefaultXml,5047,Object
|
||||
RtlsLocationResult_Encoding_DefaultBinary,5048,Object
|
||||
RtlsLocationResult_Encoding_DefaultXml,5049,Object
|
||||
Rotation_Encoding_DefaultBinary,5050,Object
|
||||
Rotation_Encoding_DefaultXml,5051,Object
|
||||
OpticalVerifierScanResult_Encoding_DefaultBinary,5052,Object
|
||||
OpticalVerifierScanResult_Encoding_DefaultXml,5053,Object
|
||||
AutoIdDeviceType_IOData,5054,Object
|
||||
AutoIdDeviceType_Scan_OutputArguments,6001,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_Close_InputArguments,6002,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_GetPosition_InputArguments,6003,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_GetPosition_OutputArguments,6004,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_Open_InputArguments,6005,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_Open_OutputArguments,6006,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_OpenCount,6007,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_Read_InputArguments,6008,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_Read_OutputArguments,6009,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_SetPosition_InputArguments,6010,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_Size,6011,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_UserWritable,6012,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_Writable,6013,Variable
|
||||
OpticalReaderDeviceType_Images_ImageName_Write_InputArguments,6014,Variable
|
||||
OcrReaderDeviceType_Scan_OutputArguments,6015,Variable
|
||||
AutoID,6016,Variable
|
||||
AutoID_NamespaceUri,6017,Variable
|
||||
AutoID,6018,Variable
|
||||
AutoID_NamespaceUri,6019,Variable
|
||||
AutoID_ScanResult,6020,Variable
|
||||
AutoID_ScanResult,6021,Variable
|
||||
AutoID_OcrScanResult,6022,Variable
|
||||
AutoID_OcrScanResult,6023,Variable
|
||||
AutoIdScanEventType_ScanResult,6024,Variable
|
||||
AutoID_RfidSighting,6025,Variable
|
||||
AutoIdDeviceType_DeviceInfo,6026,Variable
|
||||
OcrReaderDeviceType_Scan_InputArguments,6027,Variable
|
||||
Server_Namespaces_http___opcfoundation_org_UA_AutoID__IsNamespaceSubset,6028,Variable
|
||||
DeviceStatusEnumeration_EnumStrings,6029,Variable
|
||||
AutoIdDeviceType_DeviceStatus,6030,Variable
|
||||
OpticalVerifierDeviceType_Scan_InputArguments,6031,Variable
|
||||
AutoID_Position,6032,Variable
|
||||
AutoID_Position,6033,Variable
|
||||
AutoID_Location,6034,Variable
|
||||
AutoID_RfidSighting,6035,Variable
|
||||
AutoID_Location,6036,Variable
|
||||
AutoID_RfidScanResult,6037,Variable
|
||||
AutoID_RfidScanResult,6038,Variable
|
||||
Server_Namespaces_http___opcfoundation_org_UA_AutoID__NamespacePublicationDate,6039,Variable
|
||||
LocationTypeEnumeration_EnumStrings,6040,Variable
|
||||
OcrScanEventType_ScanResult,6041,Variable
|
||||
RfidScanEventType_ScanResult,6042,Variable
|
||||
RfidReaderDeviceType_Scan_OutputArguments,6043,Variable
|
||||
AutoID_ScanSettings,6044,Variable
|
||||
AutoID_ScanSettings,6045,Variable
|
||||
AutoID_AntennaNameIdPair,6046,Variable
|
||||
AutoID_AntennaNameIdPair,6047,Variable
|
||||
RfidReaderDeviceType_AntennaNames,6048,Variable
|
||||
AutoIdScanEventType_DeviceName,6049,Variable
|
||||
AutoIdDeviceType_Scan_InputArguments,6050,Variable
|
||||
AutoIdDeviceType_ScanStart_InputArguments,6051,Variable
|
||||
RfidReaderDeviceType_Scan_InputArguments,6052,Variable
|
||||
Server_Namespaces_http___opcfoundation_org_UA_AutoID__NamespaceUri,6053,Variable
|
||||
RfidReaderDeviceType_ReadTag_InputArguments,6054,Variable
|
||||
AutoIdDeviceType_LastScanData,6055,Variable
|
||||
RfidReaderDeviceType_ReadTag_OutputArguments,6056,Variable
|
||||
RfidReaderDeviceType_WriteTag_InputArguments,6057,Variable
|
||||
RfidReaderDeviceType_WriteTag_OutputArguments,6058,Variable
|
||||
RfidReaderDeviceType_SetTagPassword_InputArguments,6059,Variable
|
||||
RfidReaderDeviceType_SetTagPassword_OutputArguments,6060,Variable
|
||||
RfidPasswordTypeEnumeration_EnumStrings,6061,Variable
|
||||
RfidReaderDeviceType_KillTag_InputArguments,6062,Variable
|
||||
RfidReaderDeviceType_KillTag_OutputArguments,6063,Variable
|
||||
RfidReaderDeviceType_LockTag_InputArguments,6064,Variable
|
||||
RfidReaderDeviceType_LockTag_OutputArguments,6065,Variable
|
||||
RfidLockRegionEnumeration_EnumStrings,6066,Variable
|
||||
RfidLockOperationEnumeration_EnumStrings,6067,Variable
|
||||
Server_Namespaces_http___opcfoundation_org_UA_AutoID__NamespaceVersion,6068,Variable
|
||||
Server_Namespaces_http___opcfoundation_org_UA_AutoID__StaticNodeIdIdentifierTypes,6069,Variable
|
||||
Server_Namespaces_http___opcfoundation_org_UA_AutoID__StaticNumericNodeIdRange,6070,Variable
|
||||
Server_Namespaces_http___opcfoundation_org_UA_AutoID__StaticStringNodeIdPattern,6071,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_Close_InputArguments,6072,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_GetPosition_InputArguments,6073,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_GetPosition_OutputArguments,6074,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_Open_InputArguments,6075,Variable
|
||||
OpticalVerifierDeviceType_Scan_OutputArguments,6076,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_Open_OutputArguments,6077,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_OpenCount,6078,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_Read_InputArguments,6079,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_Read_OutputArguments,6080,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_SetPosition_InputArguments,6081,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_Size,6082,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_UserWritable,6083,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_Writable,6084,Variable
|
||||
OcrReaderDeviceType_Images_ImageName_Write_InputArguments,6085,Variable
|
||||
AutoID_LocalCoordinate,6122,Variable
|
||||
AutoID_LocalCoordinate,6123,Variable
|
||||
AutoIdDeviceType_DeviceName,6124,Variable
|
||||
AutoIdDeviceType_DeviceLocationName,6127,Variable
|
||||
AutoIdDeviceType_DeviceLocation,6128,Variable
|
||||
AutoIdDeviceType_GetDeviceLocation_OutputArguments,6129,Variable
|
||||
AutoIdDeviceType_GetDeviceLocation_InputArguments,6130,Variable
|
||||
AutoID_ScanData,6131,Variable
|
||||
AutoID_ScanData,6132,Variable
|
||||
AutoID_ScanDataEpc,6138,Variable
|
||||
AutoID_ScanDataEpc,6139,Variable
|
||||
AutoID_OpticalScanResult,6142,Variable
|
||||
AutoID_OpticalScanResult,6143,Variable
|
||||
OpticalReaderDeviceType_Scan_InputArguments,6144,Variable
|
||||
OpticalReaderDeviceType_Scan_OutputArguments,6145,Variable
|
||||
OpticalScanEventType_ScanResult,6147,Variable
|
||||
AutoID_DhcpGeoConfCoordinate,6189,Variable
|
||||
AutoID_DhcpGeoConfCoordinate,6190,Variable
|
||||
AutoIdDeviceType_AutoIdModelVersion,6193,Variable
|
||||
LocationVariableType_LengthUnit,6197,Variable
|
||||
LocationVariableType_RotationalUnit,6198,Variable
|
||||
LocationVariableType_GeographicalUnit,6199,Variable
|
||||
LocationVariableType_SpeedUnit,6200,Variable
|
||||
AutoIdOperationStatusEnumeration_EnumValues,6201,Variable
|
||||
AutoIdDeviceType_ScanStart_OutputArguments,6208,Variable
|
||||
AutoID_WGS84Coordinate,6212,Variable
|
||||
AutoID_WGS84Coordinate,6213,Variable
|
||||
RtlsDeviceType_GeographicalUnit,6214,Variable
|
||||
RtlsDeviceType_SpeedUnit,6215,Variable
|
||||
RtlsDeviceType_RotationalUnit,6216,Variable
|
||||
RtlsDeviceType_LengthUnit,6217,Variable
|
||||
RtlsDeviceType_Scan_InputArguments,6218,Variable
|
||||
RtlsDeviceType_Scan_OutputArguments,6219,Variable
|
||||
AutoID_RtlsLocationResult,6220,Variable
|
||||
AutoID_RtlsLocationResult,6221,Variable
|
||||
AutoID_Rotation,6222,Variable
|
||||
AutoID_Rotation,6223,Variable
|
||||
RtlsDeviceType_GetLocation_InputArguments,6224,Variable
|
||||
RtlsDeviceType_GetLocation_OutputArguments,6225,Variable
|
||||
RtlsDeviceType_GetSupportedLocationTypes_OutputArguments,6226,Variable
|
||||
OpticalVerifierScanEventType_ScanResult,6227,Variable
|
||||
RtlsLocationEventType_ScanResult,6228,Variable
|
||||
AutoID_OpticalVerifierScanResult,6229,Variable
|
||||
AutoID_OpticalVerifierScanResult,6230,Variable
|
||||
OcrReaderDeviceType_Scan,7001,Method
|
||||
OpticalReaderDeviceType_Images_ImageName_Close,7002,Method
|
||||
OpticalReaderDeviceType_Images_ImageName_GetPosition,7003,Method
|
||||
OpticalReaderDeviceType_Images_ImageName_Open,7004,Method
|
||||
OpticalReaderDeviceType_Images_ImageName_Read,7005,Method
|
||||
OpticalReaderDeviceType_Images_ImageName_SetPosition,7006,Method
|
||||
OpticalReaderDeviceType_Images_ImageName_Write,7007,Method
|
||||
AutoIdDeviceType_Scan,7008,Method
|
||||
AutoIdDeviceType_ScanStart,7009,Method
|
||||
AutoIdDeviceType_ScanStop,7010,Method
|
||||
OcrReaderDeviceType_Images_ImageName_Close,7011,Method
|
||||
OcrReaderDeviceType_Images_ImageName_GetPosition,7012,Method
|
||||
RfidReaderDeviceType_Scan,7013,Method
|
||||
RfidReaderDeviceType_ReadTag,7014,Method
|
||||
RfidReaderDeviceType_WriteTag,7015,Method
|
||||
RfidReaderDeviceType_SetTagPassword,7016,Method
|
||||
RfidReaderDeviceType_KillTag,7017,Method
|
||||
RfidReaderDeviceType_LockTag,7018,Method
|
||||
OcrReaderDeviceType_Images_ImageName_Open,7019,Method
|
||||
OcrReaderDeviceType_Images_ImageName_Read,7020,Method
|
||||
OcrReaderDeviceType_Images_ImageName_SetPosition,7021,Method
|
||||
OcrReaderDeviceType_Images_ImageName_Write,7022,Method
|
||||
AutoIdDeviceType_GetDeviceLocation,7042,Method
|
||||
OpticalReaderDeviceType_Scan,7043,Method
|
||||
OpticalVerifierDeviceType_Scan,7054,Method
|
||||
RtlsDeviceType_Scan,7055,Method
|
||||
RtlsDeviceType_GetLocation,7056,Method
|
||||
RtlsDeviceType_GetUnits,7057,Method
|
||||
RtlsDeviceType_GetSupportedLocationTypes,7058,Method
|
||||
|
Reference in New Issue
Block a user