nodes.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. #!/usr/bin/env/python
  2. # -*- coding: utf-8 -*-
  3. ###
  4. ### Author: Chris Iatrou (ichrispa@core-vector.net)
  5. ### Version: rev 13
  6. ###
  7. ### This program was created for educational purposes and has been
  8. ### contributed to the open62541 project by the author. All licensing
  9. ### terms for this source is inherited by the terms and conditions
  10. ### specified for by the open62541 project (see the projects readme
  11. ### file for more information on the LGPL terms and restrictions).
  12. ###
  13. ### This program is not meant to be used in a production environment. The
  14. ### author is not liable for any complications arising due to the use of
  15. ### this program.
  16. ###
  17. import sys
  18. import logging
  19. from datatypes import *
  20. from constants import *
  21. logger = logging.getLogger(__name__)
  22. if sys.version_info[0] >= 3:
  23. # strings are already parsed to unicode
  24. def unicode(s):
  25. return s
  26. class Reference(object):
  27. # all either nodeids or strings with an alias
  28. def __init__(self, source, referenceType, target, isForward):
  29. self.source = source
  30. self.referenceType = referenceType
  31. self.target = target
  32. self.isForward = isForward
  33. def __str__(self):
  34. retval = str(self.source)
  35. if not self.isForward:
  36. retval = retval + "<"
  37. retval = retval + "--[" + str(self.referenceType) + "]--"
  38. if self.isForward:
  39. retval = retval + ">"
  40. return retval + str(self.target)
  41. def __repr__(self):
  42. return str(self)
  43. def __eq__(self, other):
  44. return str(self) == str(other)
  45. def __hash__(self):
  46. return hash(str(self))
  47. def RefOrAlias(s):
  48. try:
  49. return NodeId(s)
  50. except Exception:
  51. return s
  52. class Node(object):
  53. def __init__(self):
  54. self.id = NodeId()
  55. self.nodeClass = NODE_CLASS_GENERERIC
  56. self.browseName = QualifiedName()
  57. self.displayName = LocalizedText()
  58. self.description = LocalizedText()
  59. self.symbolicName = String()
  60. self.writeMask = 0
  61. self.userWriteMask = 0
  62. self.references = set()
  63. self.hidden = False
  64. def __str__(self):
  65. return self.__class__.__name__ + "(" + str(self.id) + ")"
  66. def __repr__(self):
  67. return str(self)
  68. def sanitize(self):
  69. pass
  70. def parseXML(self, xmlelement):
  71. for idname in ['NodeId', 'NodeID', 'nodeid']:
  72. if xmlelement.hasAttribute(idname):
  73. self.id = RefOrAlias(xmlelement.getAttribute(idname))
  74. for (at, av) in xmlelement.attributes.items():
  75. if at == "BrowseName":
  76. self.browseName = QualifiedName(av)
  77. elif at == "DisplayName":
  78. self.displayName = LocalizedText(av)
  79. elif at == "Description":
  80. self.description = LocalizedText(av)
  81. elif at == "WriteMask":
  82. self.writeMask = int(av)
  83. elif at == "UserWriteMask":
  84. self.userWriteMask = int(av)
  85. elif at == "EventNotifier":
  86. self.eventNotifier = int(av)
  87. elif at == "SymbolicName":
  88. self.symbolicName = String(av)
  89. for x in xmlelement.childNodes:
  90. if x.nodeType != x.ELEMENT_NODE:
  91. continue
  92. if x.firstChild:
  93. if x.localName == "BrowseName":
  94. self.browseName = QualifiedName(x.firstChild.data)
  95. elif x.localName == "DisplayName":
  96. self.displayName = LocalizedText(x.firstChild.data)
  97. elif x.localName == "Description":
  98. self.description = LocalizedText(x.firstChild.data)
  99. elif x.localName == "WriteMask":
  100. self.writeMask = int(unicode(x.firstChild.data))
  101. elif x.localName == "UserWriteMask":
  102. self.userWriteMask = int(unicode(x.firstChild.data))
  103. if x.localName == "References":
  104. self.parseXMLReferences(x)
  105. def parseXMLReferences(self, xmlelement):
  106. for ref in xmlelement.childNodes:
  107. if ref.nodeType != ref.ELEMENT_NODE:
  108. continue
  109. source = RefOrAlias(str(self.id)) # deep-copy of the nodeid
  110. target = RefOrAlias(ref.firstChild.data)
  111. reftype = None
  112. forward = True
  113. for (at, av) in ref.attributes.items():
  114. if at == "ReferenceType":
  115. reftype = RefOrAlias(av)
  116. elif at == "IsForward":
  117. forward = not "false" in av.lower()
  118. self.references.add(Reference(source, reftype, target, forward))
  119. def popParentRef(self, parentreftypes):
  120. # HasSubtype has precedence
  121. for ref in self.references:
  122. if ref.referenceType == NodeId("ns=0;i=45") and not ref.isForward:
  123. self.references.remove(ref)
  124. return ref
  125. for ref in self.references:
  126. if ref.referenceType in parentreftypes and not ref.isForward:
  127. self.references.remove(ref)
  128. return ref
  129. return Reference(NodeId(), NodeId(), NodeId(), False)
  130. def popTypeDef(self):
  131. for ref in self.references:
  132. if ref.referenceType.i == 40 and ref.isForward:
  133. self.references.remove(ref)
  134. return ref
  135. return Reference(NodeId(), NodeId(), NodeId(), False)
  136. def replaceAliases(self, aliases):
  137. if str(self.id) in aliases:
  138. self.id = NodeId(aliases[self.id])
  139. if isinstance(self, VariableNode) or isinstance(self, VariableTypeNode):
  140. if str(self.dataType) in aliases:
  141. self.dataType = NodeId(aliases[self.dataType])
  142. new_refs = set()
  143. for ref in self.references:
  144. if str(ref.source) in aliases:
  145. ref.source = NodeId(aliases[ref.source])
  146. if str(ref.target) in aliases:
  147. ref.target = NodeId(aliases[ref.target])
  148. if str(ref.referenceType) in aliases:
  149. ref.referenceType = NodeId(aliases[ref.referenceType])
  150. new_refs.add(ref)
  151. self.references = new_refs
  152. def replaceNamespaces(self, nsMapping):
  153. self.id.ns = nsMapping[self.id.ns]
  154. self.browseName.ns = nsMapping[self.browseName.ns]
  155. if hasattr(self, 'dataType') and isinstance(self.dataType, NodeId):
  156. self.dataType.ns = nsMapping[self.dataType.ns]
  157. new_refs = set()
  158. for ref in self.references:
  159. ref.source.ns = nsMapping[ref.source.ns]
  160. ref.target.ns = nsMapping[ref.target.ns]
  161. ref.referenceType.ns = nsMapping[ref.referenceType.ns]
  162. new_refs.add(ref)
  163. self.references = new_refs
  164. class ReferenceTypeNode(Node):
  165. def __init__(self, xmlelement=None):
  166. Node.__init__(self)
  167. self.nodeClass = NODE_CLASS_REFERENCETYPE
  168. self.isAbstract = False
  169. self.symmetric = False
  170. self.inverseName = ""
  171. if xmlelement:
  172. self.parseXML(xmlelement)
  173. def parseXML(self, xmlelement):
  174. Node.parseXML(self, xmlelement)
  175. for (at, av) in xmlelement.attributes.items():
  176. if at == "Symmetric":
  177. self.symmetric = "false" not in av.lower()
  178. elif at == "InverseName":
  179. self.inverseName = str(av)
  180. elif at == "IsAbstract":
  181. self.isAbstract = "false" not in av.lower()
  182. for x in xmlelement.childNodes:
  183. if x.nodeType == x.ELEMENT_NODE:
  184. if x.localName == "InverseName" and x.firstChild:
  185. self.inverseName = str(unicode(x.firstChild.data))
  186. class ObjectNode(Node):
  187. def __init__(self, xmlelement=None):
  188. Node.__init__(self)
  189. self.nodeClass = NODE_CLASS_OBJECT
  190. self.eventNotifier = 0
  191. if xmlelement:
  192. self.parseXML(xmlelement)
  193. def parseXML(self, xmlelement):
  194. Node.parseXML(self, xmlelement)
  195. for (at, av) in xmlelement.attributes.items():
  196. if at == "EventNotifier":
  197. self.eventNotifier = int(av)
  198. class VariableNode(Node):
  199. def __init__(self, xmlelement=None):
  200. Node.__init__(self)
  201. self.nodeClass = NODE_CLASS_VARIABLE
  202. self.dataType = NodeId()
  203. self.valueRank = -2
  204. self.arrayDimensions = []
  205. # Set access levels to read by default
  206. self.accessLevel = 1
  207. self.userAccessLevel = 1
  208. self.minimumSamplingInterval = 0.0
  209. self.historizing = False
  210. self.value = None
  211. self.xmlValueDef = None
  212. if xmlelement:
  213. self.parseXML(xmlelement)
  214. def parseXML(self, xmlelement):
  215. Node.parseXML(self, xmlelement)
  216. for (at, av) in xmlelement.attributes.items():
  217. if at == "ValueRank":
  218. self.valueRank = int(av)
  219. elif at == "AccessLevel":
  220. self.accessLevel = int(av)
  221. elif at == "UserAccessLevel":
  222. self.userAccessLevel = int(av)
  223. elif at == "MinimumSamplingInterval":
  224. self.minimumSamplingInterval = float(av)
  225. elif at == "DataType":
  226. self.dataType = RefOrAlias(av)
  227. elif at == "ArrayDimensions":
  228. self.arrayDimensions = av.split(",")
  229. for x in xmlelement.childNodes:
  230. if x.nodeType != x.ELEMENT_NODE:
  231. continue
  232. if x.localName == "Value":
  233. self.xmlValueDef = x
  234. elif x.localName == "DataType":
  235. self.dataType = RefOrAlias(av)
  236. elif x.localName == "ValueRank":
  237. self.valueRank = int(unicode(x.firstChild.data))
  238. elif x.localName == "ArrayDimensions" and len(self.arrayDimensions) == 0:
  239. elements = x.getElementsByTagName("ListOfUInt32");
  240. if len(elements):
  241. for idx, v in enumerate(elements[0].getElementsByTagName("UInt32")):
  242. self.arrayDimensions.append(v.firstChild.data)
  243. elif x.localName == "AccessLevel":
  244. self.accessLevel = int(unicode(x.firstChild.data))
  245. elif x.localName == "UserAccessLevel":
  246. self.userAccessLevel = int(unicode(x.firstChild.data))
  247. elif x.localName == "MinimumSamplingInterval":
  248. self.minimumSamplingInterval = float(unicode(x.firstChild.data))
  249. elif x.localName == "Historizing":
  250. self.historizing = "false" not in x.lower()
  251. def allocateValue(self, nodeset):
  252. dataTypeNode = nodeset.getDataTypeNode(self.dataType)
  253. if dataTypeNode is None:
  254. return False
  255. # FIXME: Don't build at all or allocate "defaults"? I'm for not building at all.
  256. if self.xmlValueDef == None:
  257. #logger.warn("Variable " + self.browseName() + "/" + str(self.id()) + " is not initialized. No memory will be allocated.")
  258. return False
  259. self.value = Value()
  260. self.value.parseXMLEncoding(self.xmlValueDef, dataTypeNode, self)
  261. # Array Dimensions must accurately represent the value and will be patched
  262. # reflect the exaxt dimensions attached binary stream.
  263. if not isinstance(self.value, Value) or len(self.value.value) == 0:
  264. self.arrayDimensions = []
  265. return True
  266. class VariableTypeNode(VariableNode):
  267. def __init__(self, xmlelement=None):
  268. VariableNode.__init__(self)
  269. self.nodeClass = NODE_CLASS_VARIABLETYPE
  270. self.isAbstract = False
  271. if xmlelement:
  272. self.parseXML(xmlelement)
  273. def parseXML(self, xmlelement):
  274. Node.parseXML(self, xmlelement)
  275. for (at, av) in xmlelement.attributes.items():
  276. if at == "IsAbstract":
  277. self.isAbstract = "false" not in av.lower()
  278. class MethodNode(Node):
  279. def __init__(self, xmlelement=None):
  280. Node.__init__(self)
  281. self.nodeClass = NODE_CLASS_METHOD
  282. self.executable = True
  283. self.userExecutable = True
  284. self.methodDecalaration = None
  285. if xmlelement:
  286. self.parseXML(xmlelement)
  287. def parseXML(self, xmlelement):
  288. Node.parseXML(self, xmlelement)
  289. for (at, av) in xmlelement.attributes.items():
  290. if at == "Executable":
  291. self.executable = "false" not in av.lower()
  292. if at == "UserExecutable":
  293. self.userExecutable = "false" not in av.lower()
  294. if at == "MethodDeclarationId":
  295. self.methodDeclaration = str(av)
  296. class ObjectTypeNode(Node):
  297. def __init__(self, xmlelement=None):
  298. Node.__init__(self)
  299. self.nodeClass = NODE_CLASS_OBJECTTYPE
  300. self.isAbstract = False
  301. if xmlelement:
  302. self.parseXML(xmlelement)
  303. def parseXML(self, xmlelement):
  304. Node.parseXML(self, xmlelement)
  305. for (at, av) in xmlelement.attributes.items():
  306. if at == "IsAbstract":
  307. self.isAbstract = "false" not in av.lower()
  308. class DataTypeNode(Node):
  309. """ DataTypeNode is a subtype of Node describing DataType nodes.
  310. DataType contain definitions and structure information usable for Variables.
  311. The format of this structure is determined by buildEncoding()
  312. Two definition styles are distinguished in XML:
  313. 1) A DataType can be a structure of fields, each field having a name and a type.
  314. The type must be either an encodable builtin node (ex. UInt32) or point to
  315. another DataType node that inherits its encoding from a builtin type using
  316. a inverse "hasSubtype" (hasSuperType) reference.
  317. 2) A DataType may be an enumeration, in which each field has a name and a numeric
  318. value.
  319. The definition is stored as an ordered list of tuples. Depending on which
  320. definition style was used, the __definition__ will hold
  321. 1) A list of ("Fieldname", Node) tuples.
  322. 2) A list of ("Fieldname", int) tuples.
  323. A DataType (and in consequence all Variables using it) shall be deemed not
  324. encodable if any of its fields cannot be traced to an encodable builtin type.
  325. A DataType shall be further deemed not encodable if it contains mixed structure/
  326. enumaration definitions.
  327. If encodable, the encoding can be retrieved using getEncoding().
  328. """
  329. __isEnum__ = False
  330. __xmlDefinition__ = None
  331. __baseTypeEncoding__ = []
  332. __encodable__ = False
  333. __encodingBuilt__ = False
  334. __definition__ = []
  335. def __init__(self, xmlelement=None):
  336. Node.__init__(self)
  337. self.nodeClass = NODE_CLASS_DATATYPE
  338. self.isAbstract = False
  339. self.__xmlDefinition__ = None
  340. self.__baseTypeEncoding__ = []
  341. self.__encodable__ = None
  342. self.__encodingBuilt__ = False
  343. self.__definition__ = []
  344. self.__isEnum__ = False
  345. if xmlelement:
  346. self.parseXML(xmlelement)
  347. def parseXML(self, xmlelement):
  348. Node.parseXML(self, xmlelement)
  349. for (at, av) in xmlelement.attributes.items():
  350. if at == "IsAbstract":
  351. self.isAbstract = "false" not in av.lower()
  352. for x in xmlelement.childNodes:
  353. if x.nodeType == x.ELEMENT_NODE:
  354. if x.localName == "Definition":
  355. self.__xmlDefinition__ = x
  356. def isEncodable(self):
  357. """ Will return True if buildEncoding() was able to determine which builtin
  358. type corresponds to all fields of this DataType.
  359. If no encoding has been build yet, this function will call buildEncoding()
  360. and return True if it succeeds.
  361. """
  362. return self.__encodable__
  363. def getEncoding(self):
  364. """ If the dataType is encodable, getEncoding() returns a nested list
  365. containing the encoding the structure definition for this type.
  366. If no encoding has been build yet, this function will call buildEncoding()
  367. and return the encoding if buildEncoding() succeeds.
  368. If buildEncoding() fails or has failed, an empty list will be returned.
  369. """
  370. if self.__encodable__ == False:
  371. if self.__encodingBuilt__ == False:
  372. return self.buildEncoding()
  373. return []
  374. else:
  375. return self.__baseTypeEncoding__
  376. def buildEncoding(self, nodeset, indent=0, force=False):
  377. """ buildEncoding() determines the structure and aliases used for variables
  378. of this DataType.
  379. The function will parse the XML <Definition> of the dataType and extract
  380. "Name"-"Type" tuples. If successful, buildEncoding will return a nested
  381. list of the following format:
  382. [['Alias1', ['Alias2', ['BuiltinType']]], [Alias2, ['BuiltinType']], ...]
  383. Aliases are fieldnames defined by this DataType or DataTypes referenced. A
  384. list such as ['DataPoint', ['Int32']] indicates that a value will encode
  385. an Int32 with the alias 'DataPoint' such as <DataPoint>12827</DataPoint>.
  386. Only the first Alias of a nested list is considered valid for the BuiltinType.
  387. Single-Elemented lists are always BuiltinTypes. Every nested list must
  388. converge in a builtin type to be encodable. buildEncoding will follow
  389. the first type inheritance reference (hasSupertype) of the dataType if
  390. necessary;
  391. If instead to "DataType" a numeric "Value" attribute is encountered,
  392. the DataType will be considered an enumeration and all Variables using
  393. it will be encoded as Int32.
  394. DataTypes can be either structures or enumeration - mixed definitions will
  395. be unencodable.
  396. Calls to getEncoding() will be iterative. buildEncoding() can be called
  397. only once per dataType, with all following calls returning the predetermined
  398. value. Use of the 'force=True' parameter will force the Definition to be
  399. reparsed.
  400. After parsing, __definition__ holds the field definition as a list. Note
  401. that this might deviate from the encoding, especially if inheritance was
  402. used.
  403. """
  404. prefix = " " + "|"*indent+ "+"
  405. if force==True:
  406. self.__encodingBuilt__ = False
  407. if self.__encodingBuilt__ == True:
  408. if self.isEncodable():
  409. logger.debug(prefix + str(self.__baseTypeEncoding__) + " (already analyzed)")
  410. else:
  411. logger.debug( prefix + str(self.__baseTypeEncoding__) + "(already analyzed, not encodable!)")
  412. return self.__baseTypeEncoding__
  413. self.__encodingBuilt__ = True # signify that we have attempted to built this type
  414. self.__encodable__ = True
  415. if indent==0:
  416. logger.debug("Parsing DataType " + str(self.browseName) + " (" + str(self.id) + ")")
  417. if valueIsInternalType(self.browseName.name):
  418. self.__baseTypeEncoding__ = [self.browseName.name]
  419. self.__encodable__ = True
  420. logger.debug( prefix + str(self.browseName) + "*")
  421. logger.debug("Encodable as: " + str(self.__baseTypeEncoding__))
  422. logger.debug("")
  423. return self.__baseTypeEncoding__
  424. if self.__xmlDefinition__ == None:
  425. # Check if there is a supertype available
  426. for ref in self.references:
  427. if ref.isForward:
  428. continue
  429. # hasSubtype
  430. if ref.referenceType.i == 45:
  431. targetNode = nodeset.nodes[ref.target]
  432. if targetNode is not None and isinstance(targetNode, DataTypeNode):
  433. logger.debug( prefix + "Attempting definition using supertype " + str(targetNode.browseName) + " for DataType " + " " + str(self.browseName))
  434. subenc = targetNode.buildEncoding(nodeset=nodeset, indent=indent+1)
  435. if not targetNode.isEncodable():
  436. self.__encodable__ = False
  437. break
  438. else:
  439. self.__baseTypeEncoding__ = self.__baseTypeEncoding__ + [self.browseName.name, subenc, 0]
  440. if len(self.__baseTypeEncoding__) == 0:
  441. logger.debug(prefix + "No viable definition for " + str(self.browseName) + " " + str(self.id) + " found.")
  442. self.__encodable__ = False
  443. if indent==0:
  444. if not self.__encodable__:
  445. logger.debug("Not encodable (partial): " + str(self.__baseTypeEncoding__))
  446. else:
  447. logger.debug("Encodable as: " + str(self.__baseTypeEncoding__))
  448. logger.debug( "")
  449. return self.__baseTypeEncoding__
  450. isEnum = True
  451. isSubType = True
  452. hasValueRank = 0
  453. # We need to store the definition as ordered data, but can't use orderedDict
  454. # for backward compatibility with Python 2.6 and 3.4
  455. enumDict = []
  456. typeDict = []
  457. # An XML Definition is provided and will be parsed... now
  458. for x in self.__xmlDefinition__.childNodes:
  459. if x.nodeType == x.ELEMENT_NODE:
  460. fname = ""
  461. fdtype = ""
  462. enumVal = ""
  463. valueRank = 0
  464. for at,av in x.attributes.items():
  465. if at == "DataType":
  466. fdtype = str(av)
  467. if fdtype in nodeset.aliases:
  468. fdtype = nodeset.aliases[fdtype]
  469. isEnum = False
  470. elif at == "Name":
  471. fname = str(av)
  472. elif at == "Value":
  473. enumVal = int(av)
  474. isSubType = False
  475. elif at == "ValueRank":
  476. valueRank = int(av)
  477. if valueRank > 0:
  478. logger.warn("Value ranks >0 not fully supported. Further steps may fail")
  479. else:
  480. logger.warn("Unknown Field Attribute " + str(at))
  481. # This can either be an enumeration OR a structure, not both.
  482. # Figure out which of the dictionaries gets the newly read value pair
  483. if isEnum == isSubType:
  484. # This is an error
  485. logger.warn("DataType contains both enumeration and subtype (or neither)")
  486. self.__encodable__ = False
  487. break
  488. elif isEnum:
  489. # This is an enumeration
  490. enumDict.append((fname, enumVal))
  491. continue
  492. else:
  493. if fdtype == "":
  494. # If no datatype given use base datatype
  495. fdtype = "i=24"
  496. # This might be a subtype... follow the node defined as datatype to find out
  497. # what encoding to use
  498. if not NodeId(fdtype) in nodeset.nodes:
  499. raise Exception("Node {} not found in nodeset".format(NodeId(fdtype)))
  500. dtnode = nodeset.nodes[NodeId(fdtype)]
  501. # The node in the datatype element was found. we inherit its encoding,
  502. # but must still ensure that the dtnode is itself validly encodable
  503. typeDict.append([fname, dtnode])
  504. fdtype = str(dtnode.browseName.name)
  505. logger.debug( prefix + fname + " : " + fdtype + " -> " + str(dtnode.id))
  506. subenc = dtnode.buildEncoding(nodeset=nodeset, indent=indent+1)
  507. self.__baseTypeEncoding__ = self.__baseTypeEncoding__ + [[fname, subenc, valueRank]]
  508. if not dtnode.isEncodable():
  509. # If we inherit an encoding from an unencodable not, this node is
  510. # also not encodable
  511. self.__encodable__ = False
  512. break
  513. # If we used inheritance to determine an encoding without alias, there is a
  514. # the possibility that lists got double-nested despite of only one element
  515. # being encoded, such as [['Int32']] or [['alias',['int32']]]. Remove that
  516. # enclosing list.
  517. while len(self.__baseTypeEncoding__) == 1 and isinstance(self.__baseTypeEncoding__[0], list):
  518. self.__baseTypeEncoding__ = self.__baseTypeEncoding__[0]
  519. if isEnum == True:
  520. self.__baseTypeEncoding__ = self.__baseTypeEncoding__ + ['Int32']
  521. self.__definition__ = enumDict
  522. self.__isEnum__ = True
  523. logger.debug( prefix+"Int32* -> enumeration with dictionary " + str(enumDict) + " encodable " + str(self.__encodable__))
  524. return self.__baseTypeEncoding__
  525. if indent==0:
  526. if not self.__encodable__:
  527. logger.debug( "Not encodable (partial): " + str(self.__baseTypeEncoding__))
  528. else:
  529. logger.debug( "Encodable as: " + str(self.__baseTypeEncoding__))
  530. self.__isEnum__ = False
  531. self.__definition__ = typeDict
  532. logger.debug( "")
  533. return self.__baseTypeEncoding__
  534. class ViewNode(Node):
  535. def __init__(self, xmlelement=None):
  536. Node.__init__(self)
  537. self.nodeClass = NODE_CLASS_VIEW
  538. self.containsNoLoops == False
  539. self.eventNotifier == False
  540. if xmlelement:
  541. self.parseXML(xmlelement)
  542. def parseXML(self, xmlelement):
  543. Node.parseXML(self, xmlelement)
  544. for (at, av) in xmlelement.attributes.items():
  545. if at == "ContainsNoLoops":
  546. self.containsNoLoops = "false" not in av.lower()
  547. if at == "EventNotifier":
  548. self.eventNotifier = "false" not in av.lower()