25 import xml.dom.minidom
as dom
26 from ua_constants
import *
28 from time
import strftime, strptime
29 from open62541_MacroHelper
import open62541_MacroHelper
31 logger = logging.getLogger(__name__)
36 xmlvalue = xmlvalue.nextSibling
37 while not xmlvalue ==
None and not xmlvalue.nodeType == xmlvalue.ELEMENT_NODE:
38 xmlvalue = xmlvalue.nextSibling
41 if sys.version_info[0] >= 3:
51 stringRepresentation =
""
63 self.
knownTypes = [
'boolean',
'int32',
'uint32',
'int16',
'uint16', \
64 'int64',
'uint64',
'byte',
'sbyte',
'float',
'double', \
65 'string',
'bytestring',
'localizedtext',
'statuscode', \
66 'diagnosticinfo',
'nodeid',
'guid',
'datetime', \
67 'qualifiedname',
'expandednodeid',
'xmlelement']
72 if not isinstance(self.
value, list):
74 if not isinstance(self.
value[0], opcua_value_t):
76 for val
in self.
value:
77 if val.alias() == fieldname:
103 stringName =
str(stringName.lower())
104 if stringName ==
'boolean':
106 t.setEncodingRule(encodingRule)
107 elif stringName ==
'int32':
109 t.setEncodingRule(encodingRule)
110 elif stringName ==
'uint32':
112 t.setEncodingRule(encodingRule)
113 elif stringName ==
'int16':
115 t.setEncodingRule(encodingRule)
116 elif stringName ==
'uint16':
118 t.setEncodingRule(encodingRule)
119 elif stringName ==
'int64':
121 t.setEncodingRule(encodingRule)
122 elif stringName ==
'uint64':
124 t.setEncodingRule(encodingRule)
125 elif stringName ==
'byte':
127 t.setEncodingRule(encodingRule)
128 elif stringName ==
'sbyte':
130 t.setEncodingRule(encodingRule)
131 elif stringName ==
'float':
133 t.setEncodingRule(encodingRule)
134 elif stringName ==
'double':
136 t.setEncodingRule(encodingRule)
137 elif stringName ==
'string':
139 t.setEncodingRule(encodingRule)
140 elif stringName ==
'bytestring':
142 t.setEncodingRule(encodingRule)
143 elif stringName ==
'localizedtext':
145 t.setEncodingRule(encodingRule)
146 elif stringName ==
'statuscode':
148 t.setEncodingRule(encodingRule)
149 elif stringName ==
'diagnosticinfo':
151 t.setEncodingRule(encodingRule)
152 elif stringName ==
'nodeid':
154 t.setEncodingRule(encodingRule)
155 elif stringName ==
'guid':
157 t.setEncodingRule(encodingRule)
158 elif stringName ==
'datetime':
160 t.setEncodingRule(encodingRule)
161 elif stringName ==
'qualifiedname':
163 t.setEncodingRule(encodingRule)
164 elif stringName ==
'expandednodeid':
166 t.setEncodingRule(encodingRule)
167 elif stringName ==
'xmlelement':
169 t.setEncodingRule(encodingRule)
171 logger.debug(
"No class representing stringName " + stringName +
" was found. Cannot create builtinType.")
176 logger.debug(
"parsing xmlvalue for " + self.
parent.browseName() +
" (" +
str(self.
parent.
id()) +
") according to " +
str(self.
parent.
dataType().target().getEncoding()))
178 if not "value" in xmlvalue.tagName.lower():
179 logger.error(
"Expected <Value> , but found " + xmlvalue.tagName +
" instead. Value will not be parsed.")
182 if len(xmlvalue.childNodes) == 0:
183 logger.error(
"Expected childnodes for value, but none where found... Value will not be parsed.")
186 for n
in xmlvalue.childNodes:
187 if n.nodeType == n.ELEMENT_NODE:
191 if "ListOf" in xmlvalue.tagName:
193 for el
in xmlvalue.childNodes:
194 if not el.nodeType == el.ELEMENT_NODE:
200 logger.debug(
"Parsed Value: " +
str(self.
value))
202 def __parseXMLSingleValue(self, xmlvalue, alias=None, encodingPart=None):
211 if encodingPart ==
None:
222 if isinstance(enc[0], str):
225 if not xmlvalue.tagName == alias:
226 logger.error(
"Expected XML element with tag " + alias +
" but found " + xmlvalue.tagName +
" instead")
235 logger.error(
"Expected XML describing builtin type " + enc[0] +
" but found " + xmlvalue.tagName +
" instead")
244 elif len(enc) == 3
and isinstance(enc[0], str):
249 elif alias !=
None and len(enc[1]) > 1:
262 if not xmlvalue.tagName ==
"ExtensionObject":
263 logger.error(
"Expected XML tag <ExtensionObject> for multipart type, but found " + xmlvalue.tagName +
" instead.")
267 extobj.setEncodingRule(enc)
268 etype = xmlvalue.getElementsByTagName(
"TypeId")
270 logger.error(
"Did not find <TypeId> for ExtensionObject")
272 etype = etype[0].getElementsByTagName(
"Identifier")
274 logger.error(
"Did not find <Identifier> for ExtensionObject")
276 etype = self.
parent.getNamespace().getNodeByIDString(etype[0].firstChild.data)
278 logger.error(
"Identifier Node not found in namespace" )
283 ebody = xmlvalue.getElementsByTagName(
"Body")
285 logger.error(
"Did not find <Body> for ExtensionObject")
290 ebodypart = ebody.firstChild
291 if not ebodypart.nodeType == ebodypart.ELEMENT_NODE:
293 if ebodypart ==
None:
294 logger.error(
"Expected ExtensionObject to hold a variable of type " +
str(self.
parent.
dataType().target().browseName()) +
" but found nothing.")
297 if not ebodypart.tagName == self.
parent.
dataType().target().browseName():
298 logger.error(
"Expected ExtensionObject to hold a variable of type " +
str(self.
parent.
dataType().target().browseName()) +
" but found " +
str(ebodypart.tagName) +
" instead.")
300 extobj.alias(ebodypart.tagName)
302 ebodypart = ebodypart.firstChild
303 if not ebodypart.nodeType == ebodypart.ELEMENT_NODE:
305 if ebodypart ==
None:
306 logger.error(
"Description of dataType " +
str(self.
parent.
dataType().target().browseName()) +
" in ExtensionObject is empty/invalid.")
311 if not ebodypart ==
None:
312 extobj.value.append(extobj.__parseXMLSingleValue(ebodypart, alias=
None, encodingPart=e))
314 logger.error(
"Expected encoding " +
str(e) +
" but found none in body.")
325 return self.__binTypeId__
341 valueName = self.
parent.getCodePrintableID() +
"_variant_DataContents"
354 if (len(self.
value) == 0):
356 if not isinstance(self.
value[0], opcua_value_t):
359 if self.
parent.valueRank() != -1
and (self.
parent.valueRank() >=0
or (len(self.
value) > 1
and (self.
parent.valueRank() != -2
or self.
parent.valueRank() != -3))):
361 if self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_GUID:
362 logger.warn(
"Don't know how to print array of GUID in node " +
str(self.
parent.
id()))
363 elif self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_DATETIME:
364 logger.warn(
"Don't know how to print array of DateTime in node " +
str(self.
parent.
id()))
365 elif self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_DIAGNOSTICINFO:
366 logger.warn(
"Don't know how to print array of DiagnosticInfo in node " +
str(self.
parent.
id()))
367 elif self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_STATUSCODE:
368 logger.warn(
"Don't know how to print array of StatusCode in node " +
str(self.
parent.
id()))
370 if self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_EXTENSIONOBJECT:
372 logger.debug(
"Building extObj array index " +
str(self.
value.index(v)))
373 code = code + v.printOpen62541CCode_SubType_build(arrayIndex=self.
value.index(v))
375 code.append(
"UA_" + self.
value[0].stringRepresentation +
" " + valueName +
"[" +
str(len(self.
value)) +
"];")
376 if self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_EXTENSIONOBJECT:
378 logger.debug(
"Printing extObj array index " +
str(self.
value.index(v)))
379 code.append(valueName +
"[" +
str(self.
value.index(v)) +
"] = " + v.printOpen62541CCode_SubType(asIndirect=
False) +
";")
380 code.append(
"UA_free(" + v.printOpen62541CCode_SubType() +
");")
383 code.append(valueName +
"[" +
str(self.
value.index(v)) +
"] = " + v.printOpen62541CCode_SubType() +
";")
384 code.append(
"UA_Variant_setArray( &attr.value, &" + valueName +
385 ", (UA_Int32) " +
str(len(self.
value)) +
", &UA_TYPES[UA_TYPES_" + self.
value[0].stringRepresentation.upper() +
"]);")
388 if self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_GUID:
389 logger.warn(
"Don't know how to print scalar GUID in node " +
str(self.
parent.
id()))
390 elif self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_DATETIME:
391 logger.warn(
"Don't know how to print scalar DateTime in node " +
str(self.
parent.
id()))
392 elif self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_DIAGNOSTICINFO:
393 logger.warn(
"Don't know how to print scalar DiagnosticInfo in node " +
str(self.
parent.
id()))
394 elif self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_STATUSCODE:
395 logger.warn(
"Don't know how to print scalar StatusCode in node " +
str(self.
parent.
id()))
398 if self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_EXTENSIONOBJECT:
399 code = code + self.
value[0].printOpen62541CCode_SubType_build()
401 if self.
value[0].__binTypeId__ == BUILTINTYPE_TYPEID_EXTENSIONOBJECT:
403 code.append(
"UA_Variant_setScalar( &attr.value, " + valueName +
", &UA_TYPES[UA_TYPES_" + self.
value[0].stringRepresentation.upper() +
"]);")
408 if bootstrapping ==
True:
409 code.append(
"UA_Variant* " + self.
parent.getCodePrintableID() +
"_variant = UA_Variant_new();" )
410 code.append(
"UA_" + self.
value[0].stringRepresentation +
" *" + valueName +
" = UA_" + self.
value[0].stringRepresentation +
"_new();")
412 if bootstrapping ==
False:
413 code.append(
"UA_Variant_setScalar( &attr.value, " + valueName +
", &UA_TYPES[UA_TYPES_" + self.
value[0].stringRepresentation.upper() +
"]);")
415 code.append(
"UA_Variant_setScalar( "+self.
parent.getCodePrintableID()+
"_variant, " + valueName +
", &UA_TYPES[UA_TYPES_" + self.
value[0].stringRepresentation.upper() +
"]);")
450 logger.debug(
"Building extensionObject for " +
str(self.
parent.
id()))
451 logger.debug(
"Value " +
str(self.
value))
457 for subv
in self.
value:
458 if isinstance(subv, list):
459 logger.debug(
"ExtensionObject contains an ExtensionObject, which is currently not encodable!", LOG_LEVEL_ERR)
461 code.append(
"struct {")
466 code.append(
" UA_Int32 " +
str(field[0]) +
"Size;")
468 if len(field[1]) == 1:
469 code.append(
" UA_" +
str(field[1][0]) +
" " + ptrSym +
str(field[0]) +
";")
471 code.append(
" UA_ExtensionObject " +
" " + ptrSym +
str(field[0]) +
";")
477 for subv
in self.
value:
479 encFieldIdx = encFieldIdx + 1;
480 logger.debug(
"Encoding of field " + subv.alias() +
" is " +
str(subv.getEncodingRule()) +
"defined by " +
str(encField))
483 code.append(self.
getCodeInstanceName()+
"_struct."+subv.alias() +
" = " + subv.printOpen62541CCode_SubType(asIndirect=
False) +
";")
485 if isinstance(subv, list):
488 code.append(self.
getCodeInstanceName()+
"_struct."+subv.alias()+
" = (UA_" + subv.stringRepresentation +
" *) UA_malloc(sizeof(UA_" + subv.stringRepresentation +
")*"+
str(len(subv))+
");")
489 logger.debug(
"Encoding included array of " +
str(len(subv)) +
" values.")
490 for subvidx
in range(0,len(subv)):
491 subvv = subv[subvidx]
492 logger.debug(
" " +
str(subvix) +
" " +
str(subvv))
493 code.append(self.
getCodeInstanceName()+
"_struct."+subv.alias() +
"[" +
str(subvidx) +
"] = " + subvv.printOpen62541CCode_SubType(asIndirect=
True) +
";")
497 code.append(self.
getCodeInstanceName()+
"_struct."+subv.alias()+
" = (UA_" + subv.stringRepresentation +
" *) UA_malloc(sizeof(UA_" + subv.stringRepresentation +
"));")
498 code.append(self.
getCodeInstanceName()+
"_struct."+subv.alias() +
"[0] = " + subv.printOpen62541CCode_SubType(asIndirect=
True) +
";")
502 code.append(
"UA_ExtensionObject *" + self.
getCodeInstanceName() +
" = UA_ExtensionObject_new();")
503 code.append(self.
getCodeInstanceName() +
"->encoding = UA_EXTENSIONOBJECT_ENCODED_BYTESTRING;")
505 code.append(
"if(UA_ByteString_allocBuffer(&" + self.
getCodeInstanceName() +
"->content.encoded.body, 65000) != UA_STATUSCODE_GOOD) {}" )
510 for subv
in self.
value:
512 encFieldIdx = encFieldIdx + 1;
515 code.append(
"retval |= UA_encodeBinary(&" + self.
getCodeInstanceName()+
"_struct."+subv.alias() +
", &UA_TYPES[UA_TYPES_" + subv.stringRepresentation.upper() +
"], NULL, NULL, &" + self.
getCodeInstanceName() +
"->content.encoded.body, &" + self.
getCodeInstanceName() +
"_encOffset);" )
517 if isinstance(subv, list):
518 for subvidx
in range(0,len(subv)):
520 code.append(
"retval |= UA_encodeBinary(&" + self.
getCodeInstanceName()+
"_struct."+subv.alias() +
"[" +
str(subvidx) +
"], &UA_TYPES[UA_TYPES_" + subv.stringRepresentation.upper() +
"], NULL, NULL, &" + self.
getCodeInstanceName() +
"->content.encoded.body, &" + self.
getCodeInstanceName() +
"_encOffset);" )
522 code.append(
"retval |= UA_encodeBinary(&" + self.
getCodeInstanceName()+
"_struct."+subv.alias() +
"[0], &UA_TYPES[UA_TYPES_" + subv.stringRepresentation.upper() +
"], NULL, NULL, &" + self.
getCodeInstanceName() +
"->content.encoded.body, &" + self.
getCodeInstanceName() +
"_encOffset);" )
535 if asIndirect ==
False:
555 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
556 logger.error(
"Expected XML Element, but got junk...")
559 if self.
alias() !=
None:
560 if not self.
alias() == xmlvalue.tagName:
561 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
564 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
566 if xmlvalue.firstChild ==
None:
567 if self.
alias() !=
None:
568 logger.debug(
"Neither locale nor text in XML description field " + self.
alias() +
". Setting to default ['en_US','']")
570 logger.debug(
"Neither locale nor text in XML description. Setting to default ['en_US','']")
575 tmp = xmlvalue.getElementsByTagName(
"Locale")
577 logger.warn(
"Did not find a locale. Setting to en_US per default.")
578 self.
value.append(
'en_US')
580 if tmp[0].firstChild ==
None:
581 logger.warn(
"Locale tag without contents. Setting to en_US per default.")
582 self.
value.append(
'en_US')
584 self.
value.append(tmp[0].firstChild.data)
586 for s
in self.
value[0]:
587 if s
in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_":
589 self.
value[0] = clean
591 tmp = xmlvalue.getElementsByTagName(
"Text")
593 logger.warn(
"Did not find a Text. Setting to empty string per default.")
594 self.
value.append(
'')
596 if tmp[0].firstChild ==
None:
597 logger.warn(
"Text tag without content. Setting to empty string per default.")
598 self.
value.append(
'')
600 self.
value.append(tmp[0].firstChild.data)
604 code =
"UA_LOCALIZEDTEXT_ALLOC(\"" +
str(self.
value[0]) +
"\", \"" +
str(self.
value[1].encode(
'utf-8')) +
"\")"
606 code =
"UA_LOCALIZEDTEXT(\"" +
str(self.
value[0]) +
"\", \"" +
str(self.
value[1].encode(
'utf-8')) +
"\")"
617 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
618 logger.error(
"Expected XML Element, but got junk...")
621 logger.debug(
"Not implemented", LOG_LEVEL_ERR)
641 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
642 logger.error(
"Expected XML Element, but got junk...")
645 if self.
alias() !=
None:
646 if not self.
alias() == xmlvalue.tagName:
647 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
650 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
653 if xmlvalue.firstChild ==
None :
654 logger.error(
"No value is given, which is illegal for Node Types...")
658 if len(xmlvalue.getElementsByTagName(
"Identifier")) != 0:
659 xmlvalue = xmlvalue.getElementsByTagName(
"Identifier")[0]
660 self.
value = self.
parent.getNamespace().getNodeByIDString(
unicode(xmlvalue.firstChild.data))
661 if self.
value ==
None:
662 logger.error(
"Node with id " +
str(
unicode(xmlvalue.firstChild.data)) +
" was not found in namespace.")
665 if self.
value ==
None:
666 return "UA_NODEID_NUMERIC(0,0)"
669 return "UA_NODEID_NUMERIC(" +
str(nodeId.ns) +
", " +
str(nodeId.i) +
")"
670 elif nodeId.s !=
None:
671 return "UA_NODEID_STRING(" +
str(nodeId.ns) +
", " +
str(nodeId.s) +
")"
672 elif nodeId.b !=
None:
673 logger.debug(
"NodeID Generation macro for bytestrings has not been implemented.")
674 return "UA_NODEID_NUMERIC(0,0)"
675 elif nodeId.g !=
None:
676 logger.debug(
"NodeID Generation macro for guids has not been implemented.")
677 return "UA_NODEID_NUMERIC(0,0)"
678 return "UA_NODEID_NUMERIC(0,0)"
691 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
692 logger.error(
"Expected XML Element, but got junk...")
695 if self.
alias() !=
None:
696 if not self.
alias() == xmlvalue.tagName:
697 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
700 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
703 if xmlvalue.firstChild ==
None :
704 logger.debug(
"No value is given. Setting to default now()")
705 self.
value = strptime(strftime(
"%Y-%m-%dT%H:%M%S"),
"%Y-%m-%dT%H:%M%S")
707 timestr =
unicode(xmlvalue.firstChild.data)
711 timestr = timestr[:timestr.index(
".")]
713 while len(timestr)>0
and not timestr[-1]
in "0123456789":
714 timestr = timestr[:-1]
716 self.
value = strptime(timestr,
"%Y-%m-%dT%H:%M:%S")
718 logger.error(
"Timestring format is illegible. Expected 2001-01-30T21:22:23, but got " + timestr +
" instead. Time will be defaultet to now()")
719 self.
value = strptime(strftime(
"%Y-%m-%dT%H:%M%S"),
"%Y-%m-%dT%H:%M%S")
733 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
734 logger.error(
"Expected XML Element, but got junk...")
737 if self.
alias() !=
None:
738 if not self.
alias() == xmlvalue.tagName:
739 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
742 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
745 if xmlvalue.firstChild ==
None :
746 logger.debug(
"No value is given. Setting to default empty string in ns=0: [0, '']")
750 if len(xmlvalue.getElementsByTagName(
"NamespaceIndex")) != 0:
751 self.
value = [int(xmlvalue.getElementsByTagName(
"NamespaceIndex")[0].firstChild.data)]
753 if len(xmlvalue.getElementsByTagName(
"Name")) != 0:
754 self.
value.append(xmlvalue.getElementsByTagName(
"Name")[0].firstChild.data)
756 logger.debug(
"No name is specified, will default to empty string")
757 self.
value.append(
'')
759 logger.debug(
"No namespace is specified, will default to 0")
764 code =
"UA_QUALIFIEDNAME_ALLOC(" +
str(self.
value[0]) +
", \"" + self.
value[1].encode(
'utf-8') +
"\")"
775 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
776 logger.error(
"Expected XML Element, but got junk...")
778 logger.warn(
"Not implemented")
788 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
789 logger.error(
"Expected XML Element, but got junk...")
791 logger.warn(
"Not implemented")
801 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
802 logger.error(
"Expected XML Element, but got junk...")
805 if self.
alias() !=
None:
806 if not self.
alias() == xmlvalue.tagName:
807 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
810 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
813 if xmlvalue.firstChild ==
None:
814 logger.debug(
"No value is given. Setting to default 0")
825 tmp.append(int(
"0x"+g, 16))
827 logger.error(
"Invalid formatting of Guid. Expected {01234567-89AB-CDEF-ABCD-0123456789AB}, got " +
unicode(xmlvalue.firstChild.data))
828 self.
value = [0,0,0,0,0]
831 logger.error(
"Invalid formatting of Guid. Expected {01234567-89AB-CDEF-ABCD-0123456789AB}, got " +
unicode(xmlvalue.firstChild.data))
832 self.
value = [0,0,0,0]
846 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
847 logger.error(
"Expected XML Element, but got junk...")
850 if self.
alias() !=
None:
851 if not self.
alias() == xmlvalue.tagName:
852 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
855 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
858 if xmlvalue.firstChild ==
None:
859 logger.debug(
"No value is given. Setting to default 0")
862 if "false" in unicode(xmlvalue.firstChild.data).lower():
880 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
881 logger.error(
"Expected XML Element, but got junk...")
884 if self.
alias() !=
None:
885 if not self.
alias() == xmlvalue.tagName:
886 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
889 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
892 if xmlvalue.firstChild ==
None:
893 logger.debug(
"No value is given. Setting to default 0")
914 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
915 logger.error(
"Expected XML Element, but got junk...")
918 if self.
alias() !=
None:
919 if not self.
alias() == xmlvalue.tagName:
920 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
923 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
926 if xmlvalue.firstChild ==
None:
927 logger.debug(
"No value is given. Setting to default 0")
948 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
949 logger.error(
"Expected XML Element, but got junk...")
952 if self.
alias() !=
None:
953 if not self.
alias() == xmlvalue.tagName:
954 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
957 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
960 if xmlvalue.firstChild ==
None:
961 logger.debug(
"No value is given. Setting to default 0")
982 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
983 logger.error(
"Expected XML Element, but got junk...")
986 if self.
alias() !=
None:
987 if not self.
alias() == xmlvalue.tagName:
988 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
991 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
994 if xmlvalue.firstChild ==
None:
995 logger.debug(
"No value is given. Setting to default 0")
1016 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
1017 logger.error(
"Expected XML Element, but got junk...")
1020 if self.
alias() !=
None:
1021 if not self.
alias() == xmlvalue.tagName:
1022 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1025 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1028 if xmlvalue.firstChild ==
None:
1029 logger.debug(
"No value is given. Setting to default 0")
1050 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
1051 logger.error(
"Expected XML Element, but got junk...")
1054 if self.
alias() !=
None:
1055 if not self.
alias() == xmlvalue.tagName:
1056 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1059 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1062 if xmlvalue.firstChild ==
None:
1063 logger.debug(
"No value is given. Setting to default 0")
1084 if self.
alias() !=
None:
1085 if not self.
alias() == xmlvalue.tagName:
1086 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1089 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1092 if xmlvalue.firstChild ==
None:
1093 logger.debug(
"No value is given. Setting to default 0")
1114 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
1115 logger.error(
"Expected XML Element, but got junk...")
1118 if self.
alias() !=
None:
1119 if not self.
alias() == xmlvalue.tagName:
1120 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1123 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1126 if xmlvalue.firstChild ==
None:
1127 logger.debug(
"No value is given. Setting to default 0")
1148 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
1149 logger.error(
"Expected XML Element, but got junk...")
1152 if self.
alias() !=
None:
1153 if not self.
alias() == xmlvalue.tagName:
1154 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1157 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1160 if xmlvalue.firstChild ==
None:
1161 logger.debug(
"No value is given. Setting to default 0")
1182 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
1183 logger.error(
"Expected XML Element, but got junk...")
1186 if self.
alias() !=
None:
1187 if not self.
alias() == xmlvalue.tagName:
1188 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1191 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1194 if xmlvalue.firstChild ==
None:
1195 logger.debug(
"No value is given. Setting to default 0")
1221 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
1222 logger.error(
"Expected XML Element, but got junk...")
1225 if self.
alias() !=
None:
1226 if not self.
alias() == xmlvalue.tagName:
1227 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1230 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1233 if xmlvalue.firstChild ==
None:
1234 logger.debug(
"No value is given. Setting to default 0")
1240 code =
"UA_STRING_ALLOC(\"" + self.
value.encode(
'utf-8') +
"\")"
1251 code =
"UA_XMLELEMENT_ALLOC(\"" + self.
value.encode(
'utf-8') +
"\")"
1264 if xmlvalue ==
None or xmlvalue.nodeType != xmlvalue.ELEMENT_NODE:
1265 logger.error(
"Expected XML Element, but got junk...")
1268 if self.
alias() !=
None:
1269 if not self.
alias() == xmlvalue.tagName:
1270 logger.warn(
"Expected an aliased XML field called " + self.
alias() +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1273 logger.warn(
"Expected XML field " + self.
stringRepresentation +
" but got " + xmlvalue.tagName +
" instead. This is a parsing error of opcua_value_t.__parseXMLSingleValue(), will try to continue anyway.")
1276 if xmlvalue.firstChild ==
None:
1277 logger.debug(
"No value is given. Setting to default 0")
1284 for line
in self.
value:
1285 bs = bs +
str(line).replace(
"\n",
"");
1287 logger.debug(
"Encoded Bytestring: " + outs)
1292 code =
"UA_STRING_ALLOC(\"" + outs +
"\")"