From d1a19314cba22e739fb2f9e7f07605f4edd95c3e Mon Sep 17 00:00:00 2001 From: SofiaFaraci Date: Mon, 11 Nov 2024 11:24:53 +0100 Subject: [PATCH 1/3] add log option Signed-off-by: SofiaFaraci --- include/Data.h | 15 +++++++++++++ include/Replacer.h | 7 +++++- include/Translator.h | 11 ++++++---- include/strManipulation.h | 2 +- src/Data.cpp | 32 +++++++++++++++++++++------ src/ExtractFromXML.cpp | 20 ++++++++++------- src/Replacer.cpp | 46 ++++++++++++++++++++++----------------- src/Translator.cpp | 34 ++++++++++++++++++----------- src/main.cpp | 27 +++++++++++++++-------- src/strManipulation.cpp | 9 ++++---- 10 files changed, 136 insertions(+), 67 deletions(-) diff --git a/include/Data.h b/include/Data.h index 5ddfce1..42b0b5f 100644 --- a/include/Data.h +++ b/include/Data.h @@ -35,6 +35,8 @@ #define rspTick "TICK_RESPONSE" #define rspHalt "HALT_RESPONSE" + + struct skillDataStr{ std::string SMName; std::string className; @@ -86,6 +88,7 @@ struct fileDataStr{ bool datamodel_mode; bool translate_mode; bool generate_mode; + bool log_mode; }; struct templateFileDataStr{ @@ -197,3 +200,15 @@ void printSkillData(skillDataStr skillData); */ void setFileData(fileDataStr& fileData, const skillDataStr skillData); +/** + * @brief Add a message to the log + * + * @param fileName file name + * @param path path passed by reference where the path is stored + */ +void add_to_log(const std::string& message); +/** + * @brief print the log + * + */ +void print_log(); \ No newline at end of file diff --git a/include/Replacer.h b/include/Replacer.h index 1de2f62..72b05c9 100644 --- a/include/Replacer.h +++ b/include/Replacer.h @@ -95,7 +95,12 @@ void replaceEventCode(std::map & codeMap); */ bool readTemplates(templateFileDataStr& templateFileData, std::map & codeMap); - +/** + * @brief function to create a directory + * + * @param path string of the directory path + * @return true if the directory is created successfully + */ bool createDirectory(const std::string& path); /** diff --git a/include/Translator.h b/include/Translator.h index de8d048..917e498 100644 --- a/include/Translator.h +++ b/include/Translator.h @@ -30,15 +30,18 @@ bool deleteElementAttribute(tinyxml2::XMLElement* element, const std::string& at bool deleteElementAttributeFromVector(std::vector& elements, const std::string& attribute); /** - * @brief + * @brief read the XML file * - * @param + * @param doc XMLDocument to read the file + * @param fileName file name to read + * @return true if the file is read successfully */ bool readHLXMLFile(tinyxml2::XMLDocument& doc, const std::string fileName); /** - * @brief + * @brief translate the XML file from High-Level SCXML to SCXML * - * @param + * @param fileData file data structure passed by reference where the file data is stored + * @return true if the translation is successful */ bool Translator(fileDataStr& fileData); \ No newline at end of file diff --git a/include/strManipulation.h b/include/strManipulation.h index d4fa43b..38a68af 100644 --- a/include/strManipulation.h +++ b/include/strManipulation.h @@ -56,7 +56,7 @@ bool readTemplateFile(const std::string filePath, std::string& fileContent); * @return true * @return false */ -bool writeFile(const std::string filePath, const std::string fileContent); +bool writeFile(const std::string filePath, const std::string fileName, const std::string fileContent); /** * @brief function that replaces all the occurences of a string with another string diff --git a/src/Data.cpp b/src/Data.cpp index 48b6268..e724cf6 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -11,6 +11,7 @@ #include "Data.h" +std::string log_str; /** * @brief Get component and function data from event string (Format: componentName.functionName.eventName) * @@ -55,7 +56,7 @@ bool getDataFromRootName(const std::string attributeName, skillDataStr& skillDat { // e.g. attributeName = "FirstTemplateSkillAction" if (attributeName != ""){ - std::cout << "Root attribute name: " << attributeName << std::endl; + add_to_log("Root attribute name: " + attributeName); size_t dotPos = attributeName.find("Skill"); if (dotPos != std::string::npos){ skillData.SMName = attributeName; // e.g. SMName = "FirstTemplateSkillAction" @@ -105,11 +106,11 @@ bool getDataFromRootName(const std::string attributeName, skillDataStr& skillDat */ void printEventData(eventDataStr eventData) { - std::cout << "\tcomponent=" << eventData.componentName << ", service=" << eventData.functionName << ", eventName=" << eventData.eventName << std::endl; - std::cout<< "\tinterface=" << eventData.interfaceName << ", type=" << eventData.interfaceType; + add_to_log("\tcomponent=" + eventData.componentName + ", service=" + eventData.functionName + ", eventName=" + eventData.eventName); + add_to_log("\tinterface=" + eventData.interfaceName + ", type=" + eventData.interfaceType); for(auto it = eventData.interfaceData.begin(); it != eventData.interfaceData.end(); ++it) { - std::cout << "\n\t dataField=" << it->first << ", dataType=" << it->second; + add_to_log("\n\t dataField=" + it->first + ", dataType=" + it->second); } std::cout << std::endl; @@ -122,9 +123,9 @@ void printEventData(eventDataStr eventData) */ void printSkillData(skillDataStr skillData) { - std::cout << "-----------" << std::endl; - std::cout << "Class name: " << skillData.className << std::endl << "Skill name: " << skillData.skillName << std::endl << "Skill type: " << skillData.skillType << std::endl; - std::cout << "-----------" << std::endl; + add_to_log("-----------"); + add_to_log("Class name: " + skillData.className + "\nSkill name: " + skillData.skillName + "\nSkill type: " + skillData.skillType); + add_to_log("-----------"); } /** @} */ // end of printData subgroup @@ -143,4 +144,21 @@ void setFileData(fileDataStr& fileData, const skillDataStr skillData) fileData.outputMainFileName = "main.cpp"; fileData.outputCMakeListsFileName = "CMakeLists.txt"; fileData.outputPackageXMLFileName = "package.xml"; +} + +/** + * @brief Add a message to the log + * + * @param fileName file name + * @param path path passed by reference where the path is stored + */ +void add_to_log(const std::string& message) { + log_str += message + "\n"; +} +/** + * @brief print the log + * + */ +void print_log() { + std::cout << log_str; } \ No newline at end of file diff --git a/src/ExtractFromXML.cpp b/src/ExtractFromXML.cpp index 488a8e5..61d404a 100644 --- a/src/ExtractFromXML.cpp +++ b/src/ExtractFromXML.cpp @@ -103,23 +103,27 @@ bool extractInterfaceType(const std::string fileName, eventDataStr& eventData) eventData.interfaceType = interfaceType; if(!findElementByTag(elementFunction, std::string("dataField"), elementDataField)) { - std::cerr << "No tag for function '" << functionName << "'."<< std::endl; + // std::cerr << "No tag for function '" << functionName << "'."<< std::endl; + add_to_log("No tag for function '" + functionName + "'."); return true; } if(!getElementText(elementDataField, interfaceDataField)) { - std::cerr << "No value in tag for function '" << functionName << "'."<< std::endl; + // std::cerr << "No value in tag for function '" << functionName << "'."<< std::endl; + add_to_log("No value in tag for function '" + functionName + "'."); return true; } if(!findElementByTag(elementFunction, std::string("dataType"), elementDataType)) { - std::cerr << "No tag for function '" << functionName << "'."<< std::endl; + // std::cerr << "No tag for function '" << functionName << "'."<< std::endl; + add_to_log("No tag for function '" + functionName + "'."); //Not every interface has a defined DataType TODO return true; } if(!getElementText(elementDataType, interfaceDataType)) { - std::cerr << "No value in tag for function '" << functionName << "'."<< std::endl; + // std::cerr << "No value in tag for function '" << functionName << "'."<< std::endl; + add_to_log("No value in tag for function '" + functionName + "'."); return true; } std::vector elementsReturnValue; @@ -168,21 +172,21 @@ bool extractFromSCXML(tinyxml2::XMLDocument& doc, const std::string fileName, st // Get transitions findElementVectorByTagAndAttribute(root, std::string("transition"), "event", elementsTransition); if (elementsTransition.empty()) { - std::cout << "No transition elements found." << std::endl; + add_to_log("No transition elements found."); } else { - std::cout << "Transition elements found." << std::endl; + add_to_log("Transition elements found."); } // Get Send findElementVectorByTagAndAttribute(root, std::string("send"), "event", elementsSend); if (elementsSend.empty()) { - std::cout << "No Send elements found." << std::endl; + add_to_log("No Send elements found."); } else { - std::cout << "Send elements found." << std::endl; + add_to_log("Send elements found."); } return true; } diff --git a/src/Replacer.cpp b/src/Replacer.cpp index e42af20..0e82ed2 100644 --- a/src/Replacer.cpp +++ b/src/Replacer.cpp @@ -21,7 +21,7 @@ bool getEventData(fileDataStr fileData, eventDataStr& eventData) { if(eventsMap.find(eventData.event) != eventsMap.end()){ - std::cout << "Event already processed: " << eventData.event << std::endl; + add_to_log("Event already processed: " + eventData.event); return true; } eventsMap[eventData.event]; @@ -67,7 +67,8 @@ bool getEventsVecData(fileDataStr fileData, const std::vector codeMap; std::vector elementsTransition, elementsSend; tinyxml2::XMLDocument doc; - std::cout << "-----------" << std::endl; + add_to_log("-----------"); if(!extractFromSCXML(doc, fileData.inputFileNameGeneration, rootName, elementsTransition, elementsSend)){ return 0; } @@ -473,7 +479,6 @@ bool Replacer(fileDataStr& fileData, templateFileDataStr& templateFileData) } for (auto it = codeMap.begin(); it != codeMap.end(); it++) { - // std::cout << it->first << ": " << it->second << std::endl; replaceAll(it->second, "$className$", skillData.className); replaceAll(it->second, "$projectName$", skillData.classNameSnakeCase); replaceAll(it->second, "$SMName$", skillData.SMName); @@ -501,22 +506,23 @@ bool Replacer(fileDataStr& fileData, templateFileDataStr& templateFileData) return false; } replaceEventCode(codeMap); - std::cout << "-----------" << std::endl; + + add_to_log("-----------"); if(fileData.datamodel_mode) { - writeFile(fileData.outputPathInclude + fileData.outputDatamodelFileNameH, codeMap["hDataModelCode"]); - writeFile(fileData.outputPathSrc + fileData.outputDatamodelFileNameCPP, codeMap["cppDataModelCode"]); + writeFile(fileData.outputPathInclude, fileData.outputDatamodelFileNameH, codeMap["hDataModelCode"]); + writeFile(fileData.outputPathSrc, fileData.outputDatamodelFileNameCPP, codeMap["cppDataModelCode"]); } - std::cout << "-----------" << std::endl; + add_to_log("-----------"); createDirectory(fileData.outputPath); createDirectory(fileData.outputPathInclude); createDirectory(fileData.outputPathSrc); - std::cout << "-----------" << std::endl; - writeFile(fileData.outputPathInclude + fileData.outputFileNameH, codeMap["hCode"]); - writeFile(fileData.outputPathSrc + fileData.outputFileNameCPP, codeMap["cppCode"]); - writeFile(fileData.outputPath + fileData.outputCMakeListsFileName, codeMap["cmakeCode"]); - writeFile(fileData.outputPath + fileData.outputPackageXMLFileName, codeMap["packageCode"]); - writeFile(fileData.outputPathSrc + fileData.outputMainFileName, codeMap["mainCode"]); + add_to_log("-----------"); + writeFile(fileData.outputPathInclude, fileData.outputFileNameH, codeMap["hCode"]); + writeFile(fileData.outputPathSrc, fileData.outputFileNameCPP, codeMap["cppCode"]); + writeFile(fileData.outputPath, fileData.outputCMakeListsFileName, codeMap["cmakeCode"]); + writeFile(fileData.outputPath, fileData.outputPackageXMLFileName, codeMap["packageCode"]); + writeFile(fileData.outputPathSrc, fileData.outputMainFileName, codeMap["mainCode"]); return true; } \ No newline at end of file diff --git a/src/Translator.cpp b/src/Translator.cpp index 8b4197f..1e28757 100644 --- a/src/Translator.cpp +++ b/src/Translator.cpp @@ -546,7 +546,7 @@ bool getDataFromRootNameHighLevel(const std::string attributeName, skillDataStr& { // e.g. attributeName = "FirstTemplateSkill" if (attributeName != ""){ - std::cout << "Root attribute name: " << attributeName << std::endl; + add_to_log("Root attribute name: " + attributeName); size_t dotPos = attributeName.find("Skill"); if (dotPos != std::string::npos){ skillData.SMName = attributeName; // e.g. SMName = "FirstTemplateSkill" +"Action" added later @@ -567,12 +567,15 @@ bool getDataFromRootNameHighLevel(const std::string attributeName, skillDataStr& } /** - * @brief + * @brief read the high level xml file * - * @param + * @param doc XMLDocument to load the file + * @param fileContent string to store the file content + * @param fileName file name to read + * @return true if the file is read successfully */ bool readHLXMLFile(tinyxml2::XMLDocument& doc, std::string& fileContent, const std::string fileName){ - std::cout << "readFile" << std::endl; + add_to_log("readFile"); if (doc.LoadFile(fileName.c_str()) != tinyxml2::XML_SUCCESS) { std::cerr << "Failed to load '" << fileName << "' file" << std::endl; return false; @@ -585,13 +588,14 @@ bool readHLXMLFile(tinyxml2::XMLDocument& doc, std::string& fileContent, const s } /** - * @brief + * @brief translator function to translate the high level xml to scxml * - * @param fileData + * @param fileData fileDataStr structure containing the input and output file names + * @return true if the translation is successful */ bool Translator(fileDataStr& fileData){ - std::cout << "-----------" << std::endl; - std::cout << "Translator" << std::endl; + add_to_log("-----------"); + add_to_log("Translator"); skillDataStr skillData; tinyxml2::XMLDocument doc; std::string fileContent; @@ -610,10 +614,10 @@ bool Translator(fileDataStr& fileData){ tinyxml2::XMLElement* haltServerElement; if(findElementByTagAndAttValueContaining(root, std::string("ros_service_server"), std::string("service_name"), std::string("halt"), haltServerElement)) { - std::cout << "Halt found => Action Skill" << std::endl; + add_to_log("Halt found => Action Skill"); skillData.skillType = "Action"; } else { - std::cout << "Halt not found => Condition Skill" << std::endl; + add_to_log("Halt not found => Condition Skill"); skillData.skillType = "Condition"; } skillData.SMName = skillData.SMName + skillData.skillType; @@ -624,7 +628,7 @@ bool Translator(fileDataStr& fileData){ } if(!replaceAttributeValue(root, "name", skillData.SMName)) { - std::cout << "Could not replace name attribute for root element" << std::endl; + add_to_log("Could not replace name attribute for root element"); return false; } @@ -712,11 +716,15 @@ bool Translator(fileDataStr& fileData){ tinyxml2::XMLPrinter printer; doc.Print(&printer); // Print the XML document into the printer std::string outputContent = std::string(printer.CStr()); - std::cout << "-----------" << std::endl; + // add_to_log("-----------"); createDirectory(fileData.outputPath); createDirectory(fileData.outputPathSrc); std::cout << "-----------" << std::endl; - writeFile(ouputFilePath, outputContent); + std::cout << "Model2Code" << std::endl; + std::cout << "Generating Skill-level code for: "<< skillData.className << std::endl; + std::cout << "Output directory: " << fileData.outputPath << std::endl; + std::cout << "-----------" << std::endl; + writeFile(fileData.outputPathSrc, skillData.className + "SM.scxml", outputContent); fileData.outputFileTranslatedSM = ouputFilePath; return true; diff --git a/src/main.cpp b/src/main.cpp index c4b20bf..256d84a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,7 @@ void print_help() std::cout << "--interface_filename \"interfaceFile.xml\" "; std::cout << "--template_path \"path/to/template_skill/directory\" "; std::cout << "--output_path \"path/to/output/directory\"\n"; + std::cout << "--log_mode [to show log]\n"; // std::cout << "--datamodel_mode \n"; // std::cout << "--translate_mode \n"; // std::cout << "--generate_mode \n"; @@ -48,6 +49,7 @@ bool handleInputs(int argc, char* argv[], fileDataStr& fileData, templateFileDat fileData.datamodel_mode = false; fileData.translate_mode = false; fileData.generate_mode = false; + fileData.log_mode = false; templateFileData.templatePath = templateFilePath; if (argc == 1) @@ -92,6 +94,9 @@ bool handleInputs(int argc, char* argv[], fileDataStr& fileData, templateFileDat else if (arg == "--generate_mode") { fileData.generate_mode = true; } + else if (arg == "--log_mode") { + fileData.log_mode = true; + } } if(fileData.inputFileName == "") @@ -104,8 +109,9 @@ bool handleInputs(int argc, char* argv[], fileDataStr& fileData, templateFileDat if(fileData.outputPath == "") { - std::cout << "-----------" << std::endl; - std::cerr << "Output path not provided" << std::endl; + add_to_log("-----------"); + add_to_log("Output path not provided"); + // std::cerr << "Output path not provided" << std::endl; getPath(fileData.inputFileName, fileData.outputPath); if(fileData.outputPath == "") { @@ -115,7 +121,7 @@ bool handleInputs(int argc, char* argv[], fileDataStr& fileData, templateFileDat } else { - std::cout << "Got output path from input file name: " << fileData.outputPath << std::endl; + add_to_log("Got output path from input file name: " + fileData.outputPath); } } @@ -156,11 +162,11 @@ int main(int argc, char* argv[]) if(fileData.translate_mode) { - std::cout << "Translation request" << std::endl; + add_to_log("Translation request"); if(!Translator(fileData)) { - std::cout << "-----------" << std::endl; - std::cout << "Error in translation" << std::endl; + add_to_log("-----------"); + add_to_log("Error in translation"); return RETURN_CODE_ERROR; } fileData.inputFileNameGeneration = fileData.outputFileTranslatedSM; @@ -171,11 +177,14 @@ int main(int argc, char* argv[]) if(!Replacer(fileData, templateFileData)) { - std::cout << "-----------" << std::endl; - std::cout << "Error in code generation" << std::endl; + add_to_log("-----------"); + add_to_log("Error in code generation"); return RETURN_CODE_ERROR; } } - + if(fileData.log_mode) + { + print_log(); + } return RETURN_CODE_OK; }; \ No newline at end of file diff --git a/src/strManipulation.cpp b/src/strManipulation.cpp index 5eda5a0..f10a3db 100644 --- a/src/strManipulation.cpp +++ b/src/strManipulation.cpp @@ -112,16 +112,17 @@ bool readTemplateFile(const std::string filePath, std::string& fileContent) * @return true * @return false */ -bool writeFile(const std::string filePath, const std::string fileContent) +bool writeFile(const std::string filePath, const std::string fileName, const std::string fileContent) { - std::ofstream outputFile(filePath); + std::string path = filePath + fileName; + std::ofstream outputFile(path); if (!outputFile.is_open()) { - std::cerr << "Failed to open file for writing: " << filePath << std::endl; + std::cerr << "Failed to open file for writing: " << path << std::endl; return false; } outputFile << fileContent; outputFile.close(); - std::cout << filePath << " file generated" << std::endl; + std::cout << fileName << " file generated" << std::endl; return true; } From d2511307d80574d1773d864bc8bb2faa5da044eb Mon Sep 17 00:00:00 2001 From: SofiaFaraci Date: Mon, 11 Nov 2024 11:30:51 +0100 Subject: [PATCH 2/3] add --log_mode to documentation Signed-off-by: SofiaFaraci --- README.md | 3 ++- docs/source/index.rst | 1 + docs/source/tutorials.rst | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aedfbc7..f99d234 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ model2code --input_filename "input_model.scxml" --model_filename "project_model_ ``` replace `input_model.scxml`, `project_model_definition.scxml`, `interface_definition.scxml`, `path/to/output/directory` and `path/to/template_skill/directory` with your needs. +Add `--log_mode` for enabling the logging. By default the `path/to/output/directory` is set to the location of `input_model.scxml`, and `path/to/template_skill/directory` is set to the 'template_skill' directory of this repository. Example XML files with the required structure for defining the project's model and interfaces are available in the `tutorials/specifications` folder. @@ -52,5 +53,5 @@ model2code --input_filename "tutorials/skills/first_tutorial_skill/src/FirstTuto ``` Example 2: ``` -model2code --input_filename "tutorials/skills/second_tutorial_skill/src/SecondTutorialSkill.scxml" --model_filename "tutorials/specifications/full-model.xml" --interface_filename "tutorials/specifications/interfaces.xml" +model2code --input_filename "tutorials/skills/second_tutorial_skill/src/SecondTutorialSkill.scxml" --model_filename "tutorials/specifications/full-model.xml" --interface_filename "tutorials/specifications/interfaces.xml" --log_mode ``` \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index 4febf8f..b6df33a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -32,6 +32,7 @@ Required parameters: By default, the program generates the code in the same directory as the SCXML file specified by the ``--input_filename`` parameter. However, you can select a different output directory by using the ``--output_path`` parameter. Additionally, the program uses files from the ``templates`` directory by default to generate the code, but you can specify a different directory with the ``--templates_path`` parameter. +The ``--log_mode`` parameter can be used to enable verbose logging. The generated skills are based on a behavior tree structure. Skills corresponding to condition nodes will have a ROS2 tick service, while skills corresponding to action nodes will have both tick and halt services. diff --git a/docs/source/tutorials.rst b/docs/source/tutorials.rst index c44886d..fdbe838 100644 --- a/docs/source/tutorials.rst +++ b/docs/source/tutorials.rst @@ -32,6 +32,7 @@ To run the model2code use the following parameters: - `--interface_filename` (required): The path to the XML file that describes the interfaces used. - `--template_path`: The path to the directory containing the templates for the files to be generated. By default, the program uses the `templates` directory. - `--output_path`: The path to the directory where the generated files will be placed. By default, the program generates the code in the same directory as the SCXML file specified by the `--input_filename` parameter. + - `--log_mode`: To enable logging. By default, the program does not log. First example ``````````````` @@ -62,6 +63,7 @@ To generate the code for this skill, move to the model2code folder and run the f .. code-block:: bash - model2code --input_filename "tutorials/skills/second_tutorial_skill/src/SecondTutorialSkill.scxml" --model_filename "tutorials/specifications/full-model.xml" --interface_filename "tutorials/specifications/interfaces.xml" --output_path "tutorials/skills/second_tutorial_skill" + model2code --input_filename "tutorials/skills/second_tutorial_skill/src/SecondTutorialSkill.scxml" --model_filename "tutorials/specifications/full-model.xml" --interface_filename "tutorials/specifications/interfaces.xml" --output_path "tutorials/skills/second_tutorial_skill" --log_mode -The generated code will be placed in the `tutorials/skills/second_tutorial_skill` folder. The structure of generated files follows that of the first example, with the only difference being that 'SecondTutorialSkill.cpp' omits the halt service and includes a subscriber for 'Function2'. \ No newline at end of file +The generated code will be placed in the `tutorials/skills/second_tutorial_skill` folder. The structure of generated files follows that of the first example, with the only difference being that 'SecondTutorialSkill.cpp' omits the halt service and includes a subscriber for 'Function2'. +In this example the `--log_mode` parameter is used to enable verbose logging. \ No newline at end of file From 67874f3c514802866bedcc89818fdcec09e3f38e Mon Sep 17 00:00:00 2001 From: SofiaFaraci Date: Tue, 19 Nov 2024 08:45:05 +0100 Subject: [PATCH 3/3] edit log_mode to verbose_mode Signed-off-by: SofiaFaraci --- README.md | 4 ++-- include/Data.h | 2 +- src/main.cpp | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f99d234..19c9f0a 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ model2code --input_filename "input_model.scxml" --model_filename "project_model_ ``` replace `input_model.scxml`, `project_model_definition.scxml`, `interface_definition.scxml`, `path/to/output/directory` and `path/to/template_skill/directory` with your needs. -Add `--log_mode` for enabling the logging. +Add `--verbose_mode` for enabling the logging. By default the `path/to/output/directory` is set to the location of `input_model.scxml`, and `path/to/template_skill/directory` is set to the 'template_skill' directory of this repository. Example XML files with the required structure for defining the project's model and interfaces are available in the `tutorials/specifications` folder. @@ -53,5 +53,5 @@ model2code --input_filename "tutorials/skills/first_tutorial_skill/src/FirstTuto ``` Example 2: ``` -model2code --input_filename "tutorials/skills/second_tutorial_skill/src/SecondTutorialSkill.scxml" --model_filename "tutorials/specifications/full-model.xml" --interface_filename "tutorials/specifications/interfaces.xml" --log_mode +model2code --input_filename "tutorials/skills/second_tutorial_skill/src/SecondTutorialSkill.scxml" --model_filename "tutorials/specifications/full-model.xml" --interface_filename "tutorials/specifications/interfaces.xml" --verbose_mode ``` \ No newline at end of file diff --git a/include/Data.h b/include/Data.h index 42b0b5f..b264cbf 100644 --- a/include/Data.h +++ b/include/Data.h @@ -88,7 +88,7 @@ struct fileDataStr{ bool datamodel_mode; bool translate_mode; bool generate_mode; - bool log_mode; + bool verbose_mode; }; struct templateFileDataStr{ diff --git a/src/main.cpp b/src/main.cpp index 256d84a..2c30af7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,7 @@ void print_help() std::cout << "--interface_filename \"interfaceFile.xml\" "; std::cout << "--template_path \"path/to/template_skill/directory\" "; std::cout << "--output_path \"path/to/output/directory\"\n"; - std::cout << "--log_mode [to show log]\n"; + std::cout << "--verbose_mode [to show log]\n"; // std::cout << "--datamodel_mode \n"; // std::cout << "--translate_mode \n"; // std::cout << "--generate_mode \n"; @@ -49,7 +49,7 @@ bool handleInputs(int argc, char* argv[], fileDataStr& fileData, templateFileDat fileData.datamodel_mode = false; fileData.translate_mode = false; fileData.generate_mode = false; - fileData.log_mode = false; + fileData.verbose_mode = false; templateFileData.templatePath = templateFilePath; if (argc == 1) @@ -94,8 +94,8 @@ bool handleInputs(int argc, char* argv[], fileDataStr& fileData, templateFileDat else if (arg == "--generate_mode") { fileData.generate_mode = true; } - else if (arg == "--log_mode") { - fileData.log_mode = true; + else if (arg == "--verbose_mode") { + fileData.verbose_mode = true; } } @@ -182,7 +182,7 @@ int main(int argc, char* argv[]) return RETURN_CODE_ERROR; } } - if(fileData.log_mode) + if(fileData.verbose_mode) { print_log(); }