FMU/Source/fmuTemplate.cpp
/**
 * @brief Checks the modelDescription file for parameter names
 * @details Checks the modelDescription file so the agent model know which variables in the array are which
 */
@brief Checks the modelDescription file for parameter names
@details Checks the modelDescription file so the agent model know which variables in the array are which
@brief Checks the modelDescription file for parameter names @details Checks the modelDescription file so the agent model know which variables in the array are which
void loadVariables() {
  std::string filename =
    Configuration::RunLocation + "modelDescription.xml";
  LOG << " Loading XML file: -" << filename << "-\n";
  namespace rx = rapidxml;
  rx::file<> xmlFile(filename.c_str());  
  rx::xml_document<> doc;
  doc.parse<0>(xmlFile.data());    
  rx::xml_node<> *root_node = doc.first_node("fmiModelDescription");
  rx::xml_node<> *mv_node = root_node->first_node("ModelVariables");
  rx::xml_node<> *node = mv_node->first_node("ScalarVariable");
  while (node) {
    rx::xml_attribute<> *pAttr;
    pAttr = node->first_attribute("name");
    std::string name = pAttr->value();
    pAttr = node->first_attribute("causality");
    std::string causality = pAttr->value();
    pAttr = node->first_attribute("valueReference");
    int valueReference = std::stoi(pAttr->value());
    Configuration::outputRegexs.push_back(name);
    DataStore::addVariable(name);
    if (causality.compare("input") == 0) {
    } else {
        rx::xml_node<> *cnode = node->first_node();
        double starValue = 0;
        if (std::strcmp(cnode->name(), "Real") == 0) {
          pAttr = cnode->first_attribute("start");
          starValue = std::stod(pAttr->value());
        }
        DataStore::addValueS(name, starValue);
    }
    valToRefs[valueReference] = name;
    node = node->next_sibling();
  }
  LOG << " Loaded XML file: -" << filename << "-\n";
}
void loadVariables ( ) { std :: string filename = Configuration :: RunLocation + " " ; LOG << " " << filename << " \n " ; namespace rx = rapidxml ; rx :: file < > xmlFile ( filename . c_str ( ) ) ; rx :: xml_document < > doc ; doc . parse < 0 > ( xmlFile . data ( ) ) ; rx :: xml_node < > * root_node = doc . first_node ( " " ) ; rx :: xml_node < > * mv_node = root_node -> first_node ( " " ) ; rx :: xml_node < > * node = mv_node -> first_node ( " " ) ; while ( node ) { rx :: xml_attribute < > * pAttr ; pAttr = node -> first_attribute ( " " ) ; std :: string name = pAttr -> value ( ) ; pAttr = node -> first_attribute ( " " ) ; std :: string causality = pAttr -> value ( ) ; pAttr = node -> first_attribute ( " " ) ; int valueReference = std :: stoi ( pAttr -> value ( ) ) ; Configuration :: outputRegexs . push_back ( name ) ; DataStore :: addVariable ( name ) ; if ( causality . compare ( " " ) == 0 ) { } else { rx :: xml_node < > * cnode = node -> first_node ( ) ; double starValue = 0 ; if ( std :: strcmp ( cnode -> name ( ) , " " ) == 0 ) { pAttr = cnode -> first_attribute ( " " ) ; starValue = std :: stod ( pAttr -> value ( ) ) ; } DataStore :: addValueS ( name , starValue ) ; } valToRefs [ valueReference ] = name ; node = node -> next_sibling ( ) ; } LOG << " " << filename << " \n " ; }
@brief Checks the modelDescription file for parameter names
 @details Checks the modelDescription file so the agent model know which variables in the array are which
@brief Checks the modelDescription file for parameter names @details Checks the modelDescription file so the agent model know which variables in the array are which
// Default template is char // 0 means default parse flags //std::cout << "added: " << name << std::endl;