Example #1
0
 def getDwell(self, idx):
     """
     Retrieve one of the dwell values. These are measured in seconds.
     """
     WbDefs.checkRange(idx, 0, WbDefs.DWELLCOUNT)
     nodeList = self.dom.getElementsByTagName("CW")
     return int(getElemText(nodeList[idx]))
Example #2
0
 def getSetPoint(self,idx):
     """
     Retrieve one of the set points, these are a number between 0 and 100 (%)
     """
     WbDefs.checkRange(idx, 0, WbDefs.SPCOUNT)
     nodeList = self.dom.getElementsByTagName("CS")
     return int(getElemText(nodeList[idx]))
Example #3
0
def maskNF(mask):
    """
    Returns function to return N (on) or F (off) corresponding to the setting of
    a masked bit in the integer value of text from an element.
    
    E.g. maskNF(0x20) is "N" if the element contains a a number in which bit 0x20
    is set, otherwise "F".
    """
    def mapNF(v): 
        if v!=0: return "N"
        return "F"
    return (lambda e: mapNF(int(getElemText(e))&mask))
Example #4
0
 def __init__(self, xml ):
     WbEventOther.__init__(self)
     # read eventype
     # read event source
     # read parameters
     self._type = getAttrText( xml, 'type' )
     self._source = getAttrText( xml, 'source' )
     self._other_data = None
     if xml.childNodes:
         self._other_data = dict()
         # There are parameters.
         for param in xml.childNodes:
             if param.nodeType == param.ELEMENT_NODE:
                 # for each element in param create param entry
                 self._other_data[param.tagName] = getElemText(param)
Example #5
0
 def configure( self, xml ):
     # read eventype
     # read event source
     # read parameters
     self._type = getAttrText( xml, 'type' )
     self._source = getAttrText( xml, 'source' )
     self._params = None
     paramElem = getNamedElem(xml, "params")
     if paramElem and paramElem.childNodes:
         self._params = dict()
         # There are parameters.
         for param in paramElem.childNodes:
             if param.nodeType == param.ELEMENT_NODE:
                 isList = getAttrText(param, "type") == "list"
                 txt = getElemText(param)
                 # for each element in param create param entry
                 if isList:
                     self._params[param.tagName] = txt.split(',')
                 else:
                     self._params[param.tagName] = txt
         if len(self._params) == 0:
             self._params = None
Example #6
0
def getNameText(elem):
    return stripReservedNameChars(getElemText(elem))
Example #7
0
def maskInt(mask):
    """
    Returns function to extract a masked integer value from the text of an element.
    """
    return (lambda e: "%i"%(int(getElemText(e))&mask))