nodes.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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=True, hidden=False, inferred=False):
  29. self.source = source
  30. self.referenceType = referenceType
  31. self.target = target
  32. self.isForward = isForward
  33. self.hidden = hidden # the reference is part of a nodeset that already exists
  34. self.inferred = inferred
  35. def __str__(self):
  36. retval = str(self.source)
  37. if not self.isForward:
  38. retval = retval + "<"
  39. retval = retval + "--[" + str(self.referenceType) + "]--"
  40. if self.isForward:
  41. retval = retval + ">"
  42. return retval + str(self.target)
  43. def __repr__(self):
  44. return str(self)
  45. def __eq__(self, other):
  46. return str(self) == str(other)
  47. def __hash__(self):
  48. return hash(str(self))
  49. class Node(object):
  50. def __init__(self):
  51. self.id = NodeId()
  52. self.nodeClass = NODE_CLASS_GENERERIC
  53. self.browseName = QualifiedName()
  54. self.displayName = LocalizedText()
  55. self.description = LocalizedText()
  56. self.symbolicName = String()
  57. self.writeMask = 0
  58. self.userWriteMask = 0
  59. self.references = set()
  60. self.inverseReferences = set()
  61. self.hidden = False
  62. def __str__(self):
  63. return self.__class__.__name__ + "(" + str(self.id) + ")"
  64. def __repr__(self):
  65. return str(self)
  66. def sanitize(self):
  67. pass
  68. def parseXML(self, xmlelement):
  69. for idname in ['NodeId', 'NodeID', 'nodeid']:
  70. if xmlelement.hasAttribute(idname):
  71. self.id = NodeId(xmlelement.getAttribute(idname))
  72. for (at, av) in xmlelement.attributes.items():
  73. if at == "BrowseName":
  74. self.browseName = QualifiedName(av)
  75. elif at == "DisplayName":
  76. self.displayName = LocalizedText(av)
  77. elif at == "Description":
  78. self.description = LocalizedText(av)
  79. elif at == "WriteMask":
  80. self.writeMask = int(av)
  81. elif at == "UserWriteMask":
  82. self.userWriteMask = int(av)
  83. elif at == "EventNotifier":
  84. self.eventNotifier = int(av)
  85. elif at == "SymbolicName":
  86. self.symbolicName = String(av)
  87. for x in xmlelement.childNodes:
  88. if x.nodeType != x.ELEMENT_NODE:
  89. continue
  90. if x.firstChild:
  91. if x.localName == "BrowseName":
  92. self.browseName = QualifiedName(x.firstChild.data)
  93. elif x.localName == "DisplayName":
  94. self.displayName = LocalizedText(x.firstChild.data)
  95. elif x.localName == "Description":
  96. self.description = LocalizedText(x.firstChild.data)
  97. elif x.localName == "WriteMask":
  98. self.writeMask = int(unicode(x.firstChild.data))
  99. elif x.localName == "UserWriteMask":
  100. self.userWriteMask = int(unicode(x.firstChild.data))
  101. if x.localName == "References":
  102. self.parseXMLReferences(x)
  103. def parseXMLReferences(self, xmlelement):
  104. for ref in xmlelement.childNodes:
  105. if ref.nodeType != ref.ELEMENT_NODE:
  106. continue
  107. source = NodeId(str(self.id)) # deep-copy of the nodeid
  108. target = NodeId(ref.firstChild.data)
  109. reftype = None
  110. forward = True
  111. for (at, av) in ref.attributes.items():
  112. if at == "ReferenceType":
  113. if '=' in av:
  114. reftype = NodeId(av)
  115. else:
  116. reftype = av # alias, such as "HasSubType"
  117. elif at == "IsForward":
  118. forward = not "false" in av.lower()
  119. if forward:
  120. self.references.add(Reference(source, reftype, target, forward))
  121. else:
  122. self.inverseReferences.add(Reference(source, reftype, target, forward))
  123. def replaceAliases(self, aliases):
  124. if str(self.id) in aliases:
  125. self.id = NodeId(aliases[self.id])
  126. new_refs = set()
  127. for ref in self.references:
  128. if str(ref.source) in aliases:
  129. ref.source = NodeId(aliases[ref.source])
  130. if str(ref.target) in aliases:
  131. ref.target = NodeId(aliases[ref.target])
  132. if str(ref.referenceType) in aliases:
  133. ref.referenceType = NodeId(aliases[ref.referenceType])
  134. new_refs.add(ref)
  135. self.references = new_refs
  136. new_inv_refs = set()
  137. for ref in self.inverseReferences:
  138. if str(ref.source) in aliases:
  139. ref.source = NodeId(aliases[ref.source])
  140. if str(ref.target) in aliases:
  141. ref.target = NodeId(aliases[ref.target])
  142. if str(ref.referenceType) in aliases:
  143. ref.referenceType = NodeId(aliases[ref.referenceType])
  144. new_inv_refs.add(ref)
  145. self.inverseReferences = new_inv_refs
  146. def replaceNamespaces(self, nsMapping):
  147. self.id.ns = nsMapping[self.id.ns]
  148. self.browseName.ns = nsMapping[self.browseName.ns]
  149. if hasattr(self, 'dataType') and isinstance(self.dataType, NodeId):
  150. self.dataType.ns = nsMapping[self.dataType.ns]
  151. new_refs = set()
  152. for ref in self.references:
  153. ref.source.ns = nsMapping[ref.source.ns]
  154. ref.target.ns = nsMapping[ref.target.ns]
  155. ref.referenceType.ns = nsMapping[ref.referenceType.ns]
  156. new_refs.add(ref)
  157. self.references = new_refs
  158. new_inv_refs = set()
  159. for ref in self.inverseReferences:
  160. ref.source.ns = nsMapping[ref.source.ns]
  161. ref.target.ns = nsMapping[ref.target.ns]
  162. ref.referenceType.ns = nsMapping[ref.referenceType.ns]
  163. new_inv_refs.add(ref)
  164. self.inverseReferences = new_inv_refs
  165. class ReferenceTypeNode(Node):
  166. def __init__(self, xmlelement=None):
  167. Node.__init__(self)
  168. self.nodeClass = NODE_CLASS_REFERENCETYPE
  169. self.isAbstract = False
  170. self.symmetric = False
  171. self.inverseName = ""
  172. if xmlelement:
  173. self.parseXML(xmlelement)
  174. def parseXML(self, xmlelement):
  175. Node.parseXML(self, xmlelement)
  176. for (at, av) in xmlelement.attributes.items():
  177. if at == "Symmetric":
  178. self.symmetric = "false" not in av.lower()
  179. elif at == "InverseName":
  180. self.inverseName = str(av)
  181. elif at == "IsAbstract":
  182. self.isAbstract = "false" not in av.lower()
  183. for x in xmlelement.childNodes:
  184. if x.nodeType == x.ELEMENT_NODE:
  185. if x.localName == "InverseName" and x.firstChild:
  186. self.inverseName = str(unicode(x.firstChild.data))
  187. class ObjectNode(Node):
  188. def __init__(self, xmlelement=None):
  189. Node.__init__(self)
  190. self.nodeClass = NODE_CLASS_OBJECT
  191. self.eventNotifier = 0
  192. if xmlelement:
  193. self.parseXML(xmlelement)
  194. def parseXML(self, xmlelement):
  195. Node.parseXML(self, xmlelement)
  196. for (at, av) in xmlelement.attributes.items():
  197. if at == "EventNotifier":
  198. self.eventNotifier = int(av)
  199. class VariableNode(Node):
  200. def __init__(self, xmlelement=None):
  201. Node.__init__(self)
  202. self.nodeClass = NODE_CLASS_VARIABLE
  203. self.dataType = NodeId()
  204. self.valueRank = -2
  205. self.arrayDimensions = []
  206. # Set access levels to read by default
  207. self.accessLevel = 1
  208. self.userAccessLevel = 1
  209. self.minimumSamplingInterval = 0.0
  210. self.historizing = False
  211. self.value = None
  212. self.xmlValueDef = None
  213. if xmlelement:
  214. self.parseXML(xmlelement)
  215. def parseXML(self, xmlelement):
  216. Node.parseXML(self, xmlelement)
  217. for (at, av) in xmlelement.attributes.items():
  218. if at == "ValueRank":
  219. self.valueRank = int(av)
  220. elif at == "AccessLevel":
  221. self.accessLevel = int(av)
  222. elif at == "UserAccessLevel":
  223. self.userAccessLevel = int(av)
  224. elif at == "MinimumSamplingInterval":
  225. self.minimumSamplingInterval = float(av)
  226. elif at == "DataType":
  227. if "=" in av:
  228. self.dataType = NodeId(av)
  229. else:
  230. self.dataType = av
  231. for x in xmlelement.childNodes:
  232. if x.nodeType != x.ELEMENT_NODE:
  233. continue
  234. if x.localName == "Value":
  235. self.xmlValueDef = x
  236. elif x.localName == "DataType":
  237. self.dataType = NodeId(str(x))
  238. elif x.localName == "ValueRank":
  239. self.valueRank = int(unicode(x.firstChild.data))
  240. elif x.localName == "ArrayDimensions":
  241. self.arrayDimensions = int(unicode(x.firstChild.data))
  242. elif x.localName == "AccessLevel":
  243. self.accessLevel = int(unicode(x.firstChild.data))
  244. elif x.localName == "UserAccessLevel":
  245. self.userAccessLevel = int(unicode(x.firstChild.data))
  246. elif x.localName == "MinimumSamplingInterval":
  247. self.minimumSamplingInterval = float(unicode(x.firstChild.data))
  248. elif x.localName == "Historizing":
  249. self.historizing = "false" not in x.lower()
  250. def allocateValue(self, nodeset):
  251. dataTypeNode = nodeset.getDataTypeNode(self.dataType)
  252. if dataTypeNode is None:
  253. return False
  254. # FIXME: Don't build at all or allocate "defaults"? I'm for not building at all.
  255. if self.xmlValueDef == None:
  256. #logger.warn("Variable " + self.browseName() + "/" + str(self.id()) + " is not initialized. No memory will be allocated.")
  257. return False
  258. self.value = Value()
  259. self.value.parseXMLEncoding(self.xmlValueDef, dataTypeNode)
  260. # Array Dimensions must accurately represent the value and will be patched
  261. # reflect the exaxt dimensions attached binary stream.
  262. if not isinstance(self.value, Value) or len(self.value.value) == 0:
  263. self.arrayDimensions = []
  264. else:
  265. # Parser only permits 1-d arrays, which means we do not have to check further dimensions
  266. self.arrayDimensions = [len(self.value.value)]
  267. return True
  268. class VariableTypeNode(VariableNode):
  269. def __init__(self, xmlelement=None):
  270. VariableNode.__init__(self)
  271. self.nodeClass = NODE_CLASS_VARIABLETYPE
  272. self.isAbstract = False
  273. if xmlelement:
  274. self.parseXML(xmlelement)
  275. def parseXML(self, xmlelement):
  276. Node.parseXML(self, xmlelement)
  277. for (at, av) in xmlelement.attributes.items():
  278. if at == "IsAbstract":
  279. self.isAbstract = "false" not in av.lower()
  280. class MethodNode(Node):
  281. def __init__(self, xmlelement=None):
  282. Node.__init__(self)
  283. self.nodeClass = NODE_CLASS_METHOD
  284. self.executable = True
  285. self.userExecutable = True
  286. self.methodDecalaration = None
  287. if xmlelement:
  288. self.parseXML(xmlelement)
  289. def parseXML(self, xmlelement):
  290. Node.parseXML(self, xmlelement)
  291. for (at, av) in xmlelement.attributes.items():
  292. if at == "Executable":
  293. self.executable = "false" not in av.lower()
  294. if at == "UserExecutable":
  295. self.userExecutable = "false" not in av.lower()
  296. if at == "MethodDeclarationId":
  297. self.methodDeclaration = str(av)
  298. class ObjectTypeNode(Node):
  299. def __init__(self, xmlelement=None):
  300. Node.__init__(self)
  301. self.nodeClass = NODE_CLASS_OBJECTTYPE
  302. self.isAbstract = False
  303. if xmlelement:
  304. self.parseXML(xmlelement)
  305. def parseXML(self, xmlelement):
  306. Node.parseXML(self, xmlelement)
  307. for (at, av) in xmlelement.attributes.items():
  308. if at == "IsAbstract":
  309. self.isAbstract = "false" not in av.lower()
  310. class DataTypeNode(Node):
  311. """ DataTypeNode is a subtype of Node describing DataType nodes.
  312. DataType contain definitions and structure information usable for Variables.
  313. The format of this structure is determined by buildEncoding()
  314. Two definition styles are distinguished in XML:
  315. 1) A DataType can be a structure of fields, each field having a name and a type.
  316. The type must be either an encodable builtin node (ex. UInt32) or point to
  317. another DataType node that inherits its encoding from a builtin type using
  318. a inverse "hasSubtype" (hasSuperType) reference.
  319. 2) A DataType may be an enumeration, in which each field has a name and a numeric
  320. value.
  321. The definition is stored as an ordered list of tuples. Depending on which
  322. definition style was used, the __definition__ will hold
  323. 1) A list of ("Fieldname", Node) tuples.
  324. 2) A list of ("Fieldname", int) tuples.
  325. A DataType (and in consequence all Variables using it) shall be deemed not
  326. encodable if any of its fields cannot be traced to an encodable builtin type.
  327. A DataType shall be further deemed not encodable if it contains mixed structure/
  328. enumaration definitions.
  329. If encodable, the encoding can be retrieved using getEncoding().
  330. """
  331. __isEnum__ = False
  332. __xmlDefinition__ = None
  333. __baseTypeEncoding__ = []
  334. __encodable__ = False
  335. __encodingBuilt__ = False
  336. __definition__ = []
  337. def __init__(self, xmlelement=None):
  338. Node.__init__(self)
  339. self.nodeClass = NODE_CLASS_DATATYPE
  340. self.isAbstract = False
  341. self.__xmlDefinition__ = None
  342. self.__baseTypeEncoding__ = []
  343. self.__encodable__ = None
  344. self.__encodingBuilt__ = False
  345. self.__definition__ = []
  346. self.__isEnum__ = False
  347. if xmlelement:
  348. self.parseXML(xmlelement)
  349. def parseXML(self, xmlelement):
  350. Node.parseXML(self, xmlelement)
  351. for (at, av) in xmlelement.attributes.items():
  352. if at == "IsAbstract":
  353. self.isAbstract = "false" not in av.lower()
  354. for x in xmlelement.childNodes:
  355. if x.nodeType == x.ELEMENT_NODE:
  356. if x.localName == "Definition":
  357. self.__xmlDefinition__ = x
  358. def isEncodable(self):
  359. """ Will return True if buildEncoding() was able to determine which builtin
  360. type corresponds to all fields of this DataType.
  361. If no encoding has been build yet, this function will call buildEncoding()
  362. and return True if it succeeds.
  363. """
  364. return self.__encodable__
  365. def getEncoding(self):
  366. """ If the dataType is encodable, getEncoding() returns a nested list
  367. containing the encoding the structure definition for this type.
  368. If no encoding has been build yet, this function will call buildEncoding()
  369. and return the encoding if buildEncoding() succeeds.
  370. If buildEncoding() fails or has failed, an empty list will be returned.
  371. """
  372. if self.__encodable__ == False:
  373. if self.__encodingBuilt__ == False:
  374. return self.buildEncoding()
  375. return []
  376. else:
  377. return self.__baseTypeEncoding__
  378. def buildEncoding(self, nodeset, indent=0, force=False):
  379. """ buildEncoding() determines the structure and aliases used for variables
  380. of this DataType.
  381. The function will parse the XML <Definition> of the dataType and extract
  382. "Name"-"Type" tuples. If successful, buildEncoding will return a nested
  383. list of the following format:
  384. [['Alias1', ['Alias2', ['BuiltinType']]], [Alias2, ['BuiltinType']], ...]
  385. Aliases are fieldnames defined by this DataType or DataTypes referenced. A
  386. list such as ['DataPoint', ['Int32']] indicates that a value will encode
  387. an Int32 with the alias 'DataPoint' such as <DataPoint>12827</DataPoint>.
  388. Only the first Alias of a nested list is considered valid for the BuiltinType.
  389. Single-Elemented lists are always BuiltinTypes. Every nested list must
  390. converge in a builtin type to be encodable. buildEncoding will follow
  391. the first type inheritance reference (hasSupertype) of the dataType if
  392. necessary;
  393. If instead to "DataType" a numeric "Value" attribute is encountered,
  394. the DataType will be considered an enumeration and all Variables using
  395. it will be encoded as Int32.
  396. DataTypes can be either structures or enumeration - mixed definitions will
  397. be unencodable.
  398. Calls to getEncoding() will be iterative. buildEncoding() can be called
  399. only once per dataType, with all following calls returning the predetermined
  400. value. Use of the 'force=True' parameter will force the Definition to be
  401. reparsed.
  402. After parsing, __definition__ holds the field definition as a list. Note
  403. that this might deviate from the encoding, especially if inheritance was
  404. used.
  405. """
  406. prefix = " " + "|"*indent+ "+"
  407. if force==True:
  408. self.__encodingBuilt__ = False
  409. if self.__encodingBuilt__ == True:
  410. if self.isEncodable():
  411. logger.debug(prefix + str(self.__baseTypeEncoding__) + " (already analyzed)")
  412. else:
  413. logger.debug( prefix + str(self.__baseTypeEncoding__) + "(already analyzed, not encodable!)")
  414. return self.__baseTypeEncoding__
  415. self.__encodingBuilt__ = True # signify that we have attempted to built this type
  416. self.__encodable__ = True
  417. if indent==0:
  418. logger.debug("Parsing DataType " + str(self.browseName) + " (" + str(self.id) + ")")
  419. if valueIsInternalType(self.browseName.name):
  420. self.__baseTypeEncoding__ = [self.browseName.name]
  421. self.__encodable__ = True
  422. logger.debug( prefix + str(self.browseName) + "*")
  423. logger.debug("Encodable as: " + str(self.__baseTypeEncoding__))
  424. logger.debug("")
  425. return self.__baseTypeEncoding__
  426. if self.__xmlDefinition__ == None:
  427. # Check if there is a supertype available
  428. for ref in self.inverseReferences:
  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()