Exemple #1
0
 def statesCode(xmlTypeNode):
    if len(xmlTypeNode.findall("case")) != 1:
       util.warning("func/type : Unsupported number of \"case\" tags (expected 1) for \"" + xmlTypeNode.find("title").text.encode("utf-8") + "\" node. This profile will be ignored.")
       return "   return m_historizers;\n"
    code = ""
    for xmlDataFieldNode in xmlHelper.findUsefulDataFieldNodes(inXmlNode=xmlTypeNode.find("case")):
       if isLinearValue(xmlDataFieldNode):
          dataText = xmlDataFieldNode.find("data").text
          if dataText == "Temperature" or \
             dataText == "Humidity" or \
             dataText == "Barometer" or \
             dataText == "Supply voltage" or \
             dataText == "Illumination" or \
             dataText == "Illuminance":
             code += statesCodeForLinearValue(xmlDataFieldNode)
          elif dataText.encode("utf-8") == "Sun – West" \
             or dataText.encode("utf-8") == "Sun – South" \
             or dataText.encode("utf-8") == "Sun – East": # Provided as kilo-lux when Yadoms knows only lux
             code += statesCodeForLinearValue(xmlDataFieldNode, 1000)
          elif dataText == "Energy Storage":
             code += statesCodeForLinearValue(xmlDataFieldNode, applyCoef=None, finalCast="int")
          else:
             util.warning("func/type : Unsupported linear data type \"" + dataText.encode("utf-8") + "\" for \"" + xmlTypeNode.find("title").text.encode("utf-8") + "\" node. This data will be ignored.")
             continue
       elif isBoolValue(xmlDataFieldNode):
          code += statesCodeForBoolValue(xmlDataFieldNode)
       else:
          util.warning("func/type : Unsupported data type \"" + xmlDataFieldNode.find("data").text.encode("utf-8") + "\" for \"" + xmlTypeNode.find("title").text.encode("utf-8") + "\" node. This data will be ignored.")
          continue
    code += "   return m_historizers;"
    return code
Exemple #2
0
                                                 enumValues))
                return cppHistorizerClass

            def printCtorExtraParameters(ctorExtraParameters):
                if not ctorExtraParameters:
                    return ""
                return ", ".join(ctorExtraParameters)

            historizersCppName = []
            if len(xmlTypeNode.findall("case")) != 1:
                util.warning(
                    "func/type : Unsupported number of \"case\" tags (expected 1) for \""
                    + xmlTypeNode.find("title").text.encode("utf-8") +
                    "\" node. This profile will be ignored.")
            else:
                for xmlDataFieldNode in xmlHelper.findUsefulDataFieldNodes(
                        inXmlNode=xmlTypeNode.find("case")):
                    dataText = xmlDataFieldNode.find("data").text
                    keywordName = xmlDataFieldNode.find(
                        "shortcut").text + " - " + dataText
                    historizerCppName = "m_" + cppHelper.toCppName(keywordName)
                    cppHistorizerClassName = ""
                    ctorExtraParameters = []
                    if isLinearValue(xmlDataFieldNode):
                        if dataText == "Temperature":
                            if not supportedUnit(xmlDataFieldNode, u"°C"):
                                continue
                            cppHistorizerClassName = "yApi::historization::CTemperature"
                        elif dataText == "Humidity":
                            if not supportedUnit(xmlDataFieldNode, u"%"):
                                continue
                            cppHistorizerClassName = "yApi::historization::CHumidity"