Ejemplo n.º 1
0
 def createSpecificEnumHistorizer(xmlDataFieldNode, xmlTypeNode):
     enumValues = xmlHelper.getEnumValues(
         xmlDataFieldNode.find("enum"), "item", "description",
         "value")
     for enumValue in enumValues:
         enumValue[1] = re.split(":|<", enumValue[1])[0]
     cppHistorizerClassName = "C" + cppHelper.toCppName(
         xmlTypeNode.find(
             "title").text) + "_" + cppHelper.toCppName(
                 xmlDataFieldNode.find("data").text) + "Historizer"
     historizerEnumName = "E" + cppHelper.toCppName(
         xmlTypeNode.find(
             "title").text) + "_" + cppHelper.toCppName(
                 xmlDataFieldNode.find(
                     "data").text) + "_" + cppHelper.toCppName(
                         xmlDataFieldNode.find("data").text)
     cppHistorizerClass = cppClass.CppClass(cppHistorizerClassName,
                                            createDefaultCtor=False)
     cppHistorizerClass.inheritFrom(
         "yApi::historization::CSingleHistorizableData<" +
         historizerEnumName + ">", cppClass.PUBLIC)
     cppHistorizerClass.addConstructor(cppClass.CppClassConstructor("const std::string& keywordName", \
        "CSingleHistorizableData<" + historizerEnumName + ">(keywordName, yApi::CStandardCapacity(\"" + historizerEnumName + "\", yApi::CStandardUnits::NoUnit(), yApi::EKeywordDataType::kNoData), yApi::EKeywordAccessMode::kGet)"))
     cppHistorizerClass.addDependency(
         cppClass.CppExtendedEnumType(historizerEnumName,
                                      enumValues))
     return cppHistorizerClass
Ejemplo n.º 2
0
hardCodedProfiles = cppHelper.HardCodedProfiles(profilePath)
# Supported profiles are at least composed of hard coded profiles
supportedProfiles = copy.deepcopy(hardCodedProfiles.getProfilesHardCoded())

#-------------------------------------------------------------------------------
xmlRootNode = xml.etree.ElementTree.parse(xmlInputFilePath).getroot()
if xmlRootNode.tag != "eep":
    raise Exception("getAllNodes : Invalid root \"" + xmlRootNode.tag +
                    "\", \"eep\" expected")
xmlProfileNode = xmlRootNode.find("profile")

util.info("Hard-coded profiles are : " +
          str(hardCodedProfiles.getProfilesHardCoded()))

# CRorgs : Main Rorgs class, listing Rorg messages
rorgsClass = cppClass.CppClass("CRorgs")
rorgsItems = xmlHelper.getEnumValues(inNode=xmlProfileNode,
                                     foreachSubNode="rorg",
                                     enumValueNameTag="title",
                                     enumValueTag="number")
# Add 0xD4 (Universal Teach-in message) to RORG list as it doesn't not appear in eepXX.xml file
rorgsItems.append(['UTE Telegram ', '0xD4'])
rorgsClass.addSubType(
    cppClass.CppEnumType("ERorgIds", rorgsItems, cppClass.PUBLIC))
rorgsClass.addMember(cppClass.CppMember("RorgMap", "std::map<unsigned int, std::string>", cppClass.PRIVATE, cppClass.STATIC | cppClass.CONST, \
   cppHelper.getMapInitCode(rorgsItems)))
rorgsClass.addMethod(cppClass.CppMethod("toRorgId", "CRorgs::ERorgIds", "unsigned int id", cppClass.PUBLIC, cppClass.STATIC, \
   "   if (RorgMap.find(id) == RorgMap.end())\n" \
   "      throw std::out_of_range(\"Unknown rorg \" + CProfileHelper::byteToHexString(id));\n" \
   "   return static_cast<ERorgIds>(id);\n"))
rorgsClass.addMethod(cppClass.CppMethod("name", "const std::string&", "unsigned int id", cppClass.PUBLIC, cppClass.STATIC, \
Ejemplo n.º 3
0
#-------------------------------------------------------------------------------
# Input parameters
xmlInputFilePath = sys.argv[1]
headerPath = sys.argv[2]
sourcePath = sys.argv[3]

#-------------------------------------------------------------------------------

xmlRootNode = xml.etree.ElementTree.parse(xmlInputFilePath).getroot()
if xmlRootNode.tag != "manufacturers":
    raise Exception("getAllNodes : Invalid root \"" + xmlRootNode.tag +
                    "\", \"manufacturers\" expected")

manufacturersClassName = "CManufacturers"
manufacturersClass = cppClass.CppClass(manufacturersClassName)
manufacturersClass.addSubType(cppClass.CppEnumType("EManufacturerIds", \
   xmlHelper.getEnumValues(inNode=xmlRootNode, foreachSubNode="manufacturer", enumValueNameTag="name", enumValueTag="id"), cppClass.PUBLIC))
manufacturersClass.addMember(cppClass.CppMember("ManufacturersMap", "std::map<unsigned int, std::string>", cppClass.PRIVATE, cppClass.STATIC | cppClass.CONST, \
   cppHelper.getMapInitCode(xmlHelper.getEnumValues(inNode=xmlRootNode, foreachSubNode="manufacturer", enumValueNameTag="name"))))
manufacturersClass.addMethod(cppClass.CppMethod("toManufacturerId", manufacturersClassName + "::EManufacturerIds", "unsigned int id", cppClass.PUBLIC, cppClass.STATIC, \
   "   if (ManufacturersMap.find(id) == ManufacturersMap.end())\n" \
   "      throw std::out_of_range(\"Unknown manufacturer\");\n" \
   "   return static_cast<EManufacturerIds>(id);\n"))
manufacturersClass.addMethod(cppClass.CppMethod("name", "const std::string&", "unsigned int id", cppClass.PUBLIC, cppClass.STATIC, \
   "   try {\n" \
   "      return ManufacturersMap.at(id);\n" \
   "   } catch(std::out_of_range&) {\n" \
   "      static const std::string UnknownManufacturer(\"Unknown manufacturer\");\n" \
   "      return UnknownManufacturer;\n" \
   "   }"))