3 object_ids =
'NodeIds.csv',
4 object_ids_tostring =
'NodeIds.csv',
5 status_codes =
'StatusCode.csv',
6 status_codes_tostring =
'StatusCode.csv',
7 attribute_ids =
'AttributeIds.csv',
8 attribute_ids_getoptionvalue =
'AttributeIds.csv',
9 attribute_ids_tostring =
'AttributeIds.csv',
16 if msg:
print (
'Error {0}'.
format(msg))
17 print (
'''Usage: {0} [cxx|py] [{1}]'''.
format(sys.argv[0],
','.join(schema_files.keys())))
21 first_cap_re = re.compile(
'(.)([A-Z][a-z]+)')
22 all_cap_re = re.compile(
'([a-z0-9])([A-Z])')
24 s1 = first_cap_re.sub(
r'\1 \2', s)
25 return all_cap_re.sub(
r'\1 \2', s1).lower()
30 // DO NOT EDIT THIS FILE! 31 // It is automatically generated from opcfoundation.org schemas. 40 enum class ObjectId : uint32_t 44 with open(fname)
as fd:
45 for e
in csv.reader(fd, delimiter=
','):
46 print (
' {0} = {1},'.
format(*e[:2]))
54 // DO NOT EDIT THIS FILE! 55 // It is automatically generated from opcfoundation.org schemas. 61 #include "opc/ua/protocol/object_ids.h" 66 std::string ToString(const ObjectId & value) 71 with open(fname)
as fd:
72 for e
in csv.reader(fd, delimiter=
','):
73 print (
''' case ObjectId::{0}: 74 return "{1}";'''.
format(e[0],e[0]))
78 std::stringstream result; 79 result << "unknown(" << static_cast<int>(value) << ")"; 90 // DO NOT EDIT THIS FILE! 91 // It is automatically generated from opcfoundation.org schemas. 100 enum class StatusCode : uint32_t 104 with open(fname)
as fd:
105 for e
in csv.reader(fd, delimiter=
','):
106 print (
' {0} = {1},'.
format(*e[:2]))
110 //raise appropriate exception if StatusCode is not Good 111 void CheckStatusCode(StatusCode code); 118 // DO NOT EDIT THIS FILE! 119 // It is automatically generated from opcfoundation.org schemas. 126 #include "opc/ua/protocol/status_codes.h" 131 std::string ToString(const StatusCode & code) 133 if (code == StatusCode::Good) 135 return std::string(); 138 std::stringstream stream; 143 with open(fname)
as fd:
144 for e
in csv.reader(fd, delimiter=
','):
145 print (
''' case StatusCode::{0}: 151 stream << "Unknown StatusCode?"; 155 stream << " (0x" << std::setfill('0') << std::setw(8) << std::hex << (unsigned)code << ")"; 165 // DO NOT EDIT THIS FILE! 166 // It is automatically generated from opcfoundation.org schemas. 175 enum class AttributeId : uint32_t 178 with open(fname)
as fd:
179 for e
in csv.reader(fd, delimiter=
','):
180 print (
' {0} = {1},'.
format(*e))
182 print (
''' Unknown = ~uint32_t(), 189 // DO NOT EDIT THIS FILE! 190 // It is automatically generated from opcfoundation.org schemas. 195 inline AttributeId GetAttributeIdOptionValue(const po::variables_map & vm) 197 const std::string name = vm[OPTION_ATTRIBUTE].as<std::string>(); 200 with open(fname)
as fd:
201 for e
in csv.reader(fd, delimiter=
','):
202 print (
''' if (name == "{0}") 204 return AttributeId::{1}; 208 print (
''' throw std::logic_error(std::string("Unknown AttributeId: ") + name); 214 // DO NOT EDIT THIS FILE! 215 // It is automatically generated from opcfoundation.org schemas. 221 #include "opc/ua/protocol/attribute_ids.h" 226 std::string ToString(const AttributeId & value) 231 with open(fname)
as fd:
232 for e
in csv.reader(fd, delimiter=
','):
233 print (
''' case AttributeId::{0}: 234 return "{1}";'''.
format(e[0],e[0]))
238 std::stringstream result; 239 result << "unknown(" << static_cast<int>(value) << ")"; 250 // DO NOT EDIT THIS FILE! 251 // It is automatically generated from opcfoundation.org schemas. 254 #include <boost/python.hpp> 256 #include "opc/ua/protocol/object_ids.h" 258 using namespace boost::python; 259 using namespace OpcUa; 261 void py_opcua_enums_ObjectId() 263 enum_<ObjectId>("ObjectId") 264 #define _value(X) value(#X, ObjectId:: X)''')
266 with open(fname)
as fd:
267 for e
in csv.reader(fd, delimiter=
','):
268 print (
' ._value({0})'.
format(e[0]))
270 print (
'''#undef _value 277 // DO NOT EDIT THIS FILE! 278 // It is automatically generated from opcfoundation.org schemas. 281 #include <boost/python.hpp> 283 #include "opc/ua/protocol/status_codes.h" 285 using namespace boost::python; 286 using namespace OpcUa; 288 void py_opcua_enums_StatusCode() 290 enum_<StatusCode>("StatusCode") 291 #define _value(X) value(#X, StatusCode:: X)''')
293 with open(fname)
as fd:
294 for e
in csv.reader(fd, delimiter=
','):
295 print (
' ._value({0})'.
format(e[0]))
297 print (
'''#undef _value 303 raise Exception(
'py_status_codes_tostring not implemented')
307 // DO NOT EDIT THIS FILE! 308 // It is automatically generated from opcfoundation.org schemas. 311 #include <boost/python.hpp> 313 #include "opc/ua/protocol/attribute_ids.h" 315 using namespace boost::python; 316 using namespace OpcUa; 318 void py_opcua_enums_AttributeId() 320 enum_<AttributeId>("AttributeId") 321 #define _value(X) value(#X, AttributeId:: X)''')
323 with open(fname)
as fd:
324 for e
in csv.reader(fd, delimiter=
','):
325 print (
' ._value({0})'.
format(e[0]))
327 print (
'''#undef _value 333 raise Exception(
'py_attribute_ids_getoptionvalue not implemented')
335 if __name__ ==
'__main__':
338 if len(sys.argv) != 3:
usage()
339 target, what = sys.argv[1:]
340 if target
not in (
'cxx',
'py',):
usage()
341 if what
not in schema_files.keys():
usage()
344 relpath = os.path.dirname(__file__)
345 locals()[call](os.path.join(relpath,schema_files[what]))
346 except Exception
as e:
def cxx_status_codes(fname)
FMT_API void print(std::FILE *f, CStringRef format_str, ArgList args)
std::string format(CStringRef format_str, ArgList args)
def cxx_attribute_ids(fname)
def py_attribute_ids_getoptionvalue(fname)
def py_attribute_ids(fname)
def camel_to_spacedstring(s)
def cxx_object_ids_tostring(fname)
def py_status_codes_tostring(fname)
def cxx_object_ids(fname)
def cxx_attribute_ids_tostring(fname)
def cxx_status_codes_tostring(fname)
def py_status_codes(fname)
def cxx_attribute_ids_getoptionvalue(fname)