Skip to content

Commit

Permalink
Signature of exportToFigaro updated.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20952 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Alexander Carlqvist committed Jun 4, 2014
1 parent 44296dd commit df4a8e1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -1984,8 +1984,9 @@ end list;
// exportToFigaro added by Alexander Carlqvist
function exportToFigaro
input TypeName path;
input String library;
input String database;
input String mode := "figaro0";
input String options := "";
input String processor := "C:/st/figp.exe";
output Boolean success;
external "builtin";
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -1146,12 +1146,12 @@ algorithm
case (cache,_,"list",_,st,_) then (cache,Values.STRING(""),st);

// exportToFigaro cases added by Alexander Carlqvist
case (cache, _, "exportToFigaro", {Values.CODE(Absyn.C_TYPENAME(path)), Values.STRING(filename), Values.STRING(str), Values.STRING(filename2)}, st as GlobalScript.SYMBOLTABLE(ast = p), _)
case (cache, _, "exportToFigaro", {Values.CODE(Absyn.C_TYPENAME(path)), Values.STRING(str), Values.STRING(str1), Values.STRING(str2), Values.STRING(str3)}, st as GlobalScript.SYMBOLTABLE(ast = p), _)
equation
(scodeP, _) = Interactive.symbolTableToSCode(st);
/* The following line of code should be commented out when building from trunk.
Uncomment when bootstrapping. */
//Figaro.run(scodeP, path, filename, str, filename2);
//Figaro.run(scodeP, path, str, str1, str2, str3);
then (cache, Values.BOOL(true), st);

case (cache, _, "exportToFigaro", _, st, _)
Expand Down
22 changes: 14 additions & 8 deletions Compiler/Script/Figaro.mo
Expand Up @@ -15,16 +15,17 @@ public function run "The main function to be called from CevalScript. This one i
because of all the side-effects. However, all of them are captured here."
input SCode.Program inProgram;
input Path inPath;
input String inBdcFile "Figaro library";
input String inDatabaseFile "Figaro database XML file";
input String inMode "Figaro processor mode";
input String inOptions "Figaro fault tree generation options";
input String inFigaroProcessorFile "Figaro processor to call";
protected
String bdfFile := System.pwd() +& "/BDF.fi" "Figaro code to the Figaro processor";
String figaroFile := System.pwd() +& "/Figaro0.fi" "Figaro code from the Figaro processor";
String argumentFile := System.pwd() +& "/figp_commands.xml" "instructions to the Figaro processor";
String resultFile := System.pwd() +& "/result.xml" "status from the Figaro processor"; // File name cannot be changed.
SCode.Element program;
String figaro, xml, xml2;
String figaro, database, xml, xml2;
list<String> sl;
algorithm
program := SCode.getElementWithPath(inProgram, inPath);
Expand All @@ -35,9 +36,13 @@ algorithm
then fail();
end if;
System.writeFile(bdfFile, figaro);

// Get XML defining the database.
database := System.readFile(inDatabaseFile);
database := System.trimWhitespace(database);

// Instructions for the Figaro processor.
xml := makeXml(inBdcFile, bdfFile, inMode, figaroFile);
xml := makeXml(database, bdfFile, inMode, inOptions, figaroFile);
System.writeFile(argumentFile, xml);

callFigaroProcessor(inFigaroProcessorFile, argumentFile);
Expand Down Expand Up @@ -523,17 +528,18 @@ algorithm
end figaroObjectToString;

protected function makeXml "Makes instructions for the Figaro processor."
input String inBdcFile "library the Figaro processor will use";
input String inDatabase "database the Figaro processor will use";
input String inBdfFile "Figaro code to the Figaro processor";
input String inMode "Figaro processor mode";
input String inOptions "Figaro fault tree generation options";
input String inFigaroFile "Figaro code from the Figaro processor";
output String outXml;
protected
String xml;
algorithm
xml := "<REQUESTS>\n<LOAD_BDC_FI>\n <FILE_FI>";
xml := xml +& inBdcFile;
xml := xml +& "</FILE_FI>\n</LOAD_BDC_FI>\n\n<LOAD_BDF_FI>\n <FILE>";
xml := "<REQUESTS>\n ";
xml := xml +& "<LOAD_BDC_FI>" +& inDatabase +& "\n </LOAD_BDC_FI>";
xml := xml +& "\n\n<LOAD_BDF_FI>\n <FILE>";
xml := xml +& inBdfFile;
xml := xml +& "</FILE>\n</LOAD_BDF_FI>\n";
xml := xml +& "<RUN_TREATMENT>\n";
Expand All @@ -548,7 +554,7 @@ algorithm
xml := xml +& System.pwd() +& "/FaultTree.xml";
xml := xml +& "</FILE>\n";
xml := xml +& " <FILE_MACRO>fiab_ADD.h</FILE_MACRO>";
xml := xml +& "\n <FILE_TREE_OPTIONS>C:\\st\\Test\\Params FT generation.xml</FILE_TREE_OPTIONS>";
xml := xml +& "\n <FILE_TREE_OPTIONS>" +& inOptions +& "</FILE_TREE_OPTIONS>";
end if;

xml := xml +& "\n <RESOLVE_CONST>VRAI</RESOLVE_CONST>\n <RESOLVE_ATTR>FAUX</RESOLVE_ATTR>\n <INST_RULE>VRAI</INST_RULE>\n";
Expand Down

0 comments on commit df4a8e1

Please sign in to comment.