CppGenerator.xtend 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.generation
  2. import be.uantwerpen.ansymo.semanticadaptation.generator.SemanticAdaptationGenerator
  3. import org.eclipse.xtext.generator.IFileSystemAccess2
  4. import org.eclipse.xtext.generator.IGeneratorContext
  5. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptation
  6. import org.eclipse.emf.ecore.resource.Resource
  7. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Adaptation
  8. import java.util.ArrayList
  9. import java.util.LinkedHashMap
  10. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.MappedScalarVariable
  11. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InnerFMU
  12. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.exceptions.IncorrectAmountOfElementsException
  13. import java.io.File
  14. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SAScalarVariable
  15. import org.eclipse.emf.common.util.EList
  16. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Port
  17. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVCausality
  18. import java.util.Collection
  19. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InOutRules
  20. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InRulesBlock
  21. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.InOutRulesBlockResult
  22. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.OutRulesBlock
  23. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.GlobalInOutVariable
  24. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ControlRuleBlock
  25. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.RulesBlockResult
  26. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ScalarVariable
  27. import java.util.List
  28. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVType
  29. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ParamDeclarations
  30. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.InputOutputRuleType
  31. class CppGenerator extends SemanticAdaptationGenerator {
  32. private var IFileSystemAccess2 fsa;
  33. private List<File> resourcePaths = newArrayList();
  34. override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
  35. this.fsa = fsa;
  36. for (SemanticAdaptation type : resource.allContents.toIterable.filter(SemanticAdaptation)) {
  37. type.compile;
  38. }
  39. }
  40. // TODO: Verify adaptation.name is not a C++ keyword
  41. def void compile(SemanticAdaptation adaptation) {
  42. for (Adaptation adap : adaptation.elements.filter(Adaptation)) {
  43. // Value used for scoping variables in the .sa file
  44. val adapInteralRefName = adap.name;
  45. // The CPP class name
  46. val adapClassName = adap.name.toFirstUpper;
  47. // This is the external name used in the model description file for the semantic adaptation FMU.
  48. val adapExternalName = adap.type.name;
  49. // List of FMUs with a pairing between its name and its type.name.
  50. var ArrayList<Pair<String, String>> fmus = newArrayList();
  51. // TODO: Currently only 1 inner fmu is supported
  52. val innerFmus = adap.inner.eAllContents.toList.filter(InnerFMU);
  53. if (innerFmus.size > 1) {
  54. throw new IncorrectAmountOfElementsException("Only one InnerFmu is supported.")
  55. }
  56. if (innerFmus.isEmpty) {
  57. throw new IncorrectAmountOfElementsException("The adaptation does not contain any InnerFMUs.")
  58. }
  59. /*
  60. * This map will contain scalar variables from the FMUs defined in InnerFMU.
  61. * The structure is fmuName -> (SVName -> mappedSV) where SVName = mappedSV.name for easy lookup.
  62. * The mappedSV contains the original scalar variable and extra data such as define name.
  63. */
  64. var LinkedHashMap<String, LinkedHashMap<String, MappedScalarVariable>> mappedScalarVariables = newLinkedHashMap();
  65. /*
  66. * Loading the FMU defined in InnerFMU, the related model description file and its scalar variables.
  67. */
  68. // TODO: Add support for multiple inner fmus
  69. var ModelDescription md;
  70. for (fmu : adap.inner.eAllContents.toList.filter(InnerFMU)) {
  71. val fmuFile = new File(fmu.path.replace('\"', ''));
  72. this.resourcePaths.add(fmuFile);
  73. md = new ModelDescription(fmu.name, fmu.type.name, fmuFile);
  74. fmus.add(fmu.name -> fmu.type.name);
  75. val LinkedHashMap<String, MappedScalarVariable> mSV = newLinkedHashMap();
  76. for (sv : md.sv.values) {
  77. var mappedSv = new MappedScalarVariable(sv);
  78. mappedSv.define = (mappedSv.mappedSv.owner + mappedSv.mappedSv.name).toUpperCase;
  79. mSV.put(mappedSv.mappedSv.name, mappedSv);
  80. }
  81. mappedScalarVariables.put(fmu.name, mSV);
  82. }
  83. // C++ Defines for accessing FMU scalar variables.
  84. val String fmusDefines = calcDefines(mappedScalarVariables);
  85. // Compile Params
  86. var LinkedHashMap<String, GlobalInOutVariable> params = newLinkedHashMap;
  87. val String paramsConstructorSource = compileParams(params, adap.params);
  88. /*
  89. * This map contains all the ScalarVariables for the semantic adaptation.
  90. * The are not populated yet, but they will be during the compilation of the in and out rule blocks.
  91. */
  92. var LinkedHashMap<String, SAScalarVariable> SASVs = calcSASVsFromInportsOutports(adapInteralRefName,
  93. adap.inports, adap.outports)
  94. // C++ defines for accessing semantic adaptation scalar variables
  95. val String SADefines = calcSADefines(SASVs.values);
  96. // Compile the transparent in mappings
  97. // Compile the in rules
  98. val inRuleResult = compileInOutRuleBlocks(InputOutputRuleType.Input, adaptation.eAllContents.toIterable.filter(
  99. InRulesBlock).map[x|x as InOutRules], adapClassName, adapInteralRefName, mappedScalarVariables, SASVs,
  100. params);
  101. // Compile the out rules
  102. val outRuleResult = compileInOutRuleBlocks(InputOutputRuleType.Output, adaptation.eAllContents.toIterable.
  103. filter(OutRulesBlock).map[x|x as InOutRules], adapClassName, adapInteralRefName, mappedScalarVariables,
  104. SASVs, params);
  105. // Compile the Control Rules
  106. val crtlRuleResult = compileControlRuleBlock(adaptation.eAllContents.toIterable.filter(ControlRuleBlock),
  107. adapClassName, adapInteralRefName, SASVs, params);
  108. /*
  109. * Compile the constructor, destructor and initialize functions
  110. */
  111. val String deAndConstructorAndInitializeSource = compileDeAndConstructorAndInitialize(
  112. adapClassName,
  113. fmus.head.key,
  114. fmus.head.value,
  115. md.guid,
  116. paramsConstructorSource,
  117. inRuleResult.constructorInitialization,
  118. outRuleResult.constructorInitialization,
  119. crtlRuleResult.constructorInitialization
  120. );
  121. /*
  122. * Compile getRuleThis function
  123. */
  124. val String getRuleThisSource = compileGetRuleThis(adapClassName);
  125. /*
  126. * The in and out rules have populated the semantic adaptation scalar variables we can generate the getFmiValue* and setFmiValue functions.
  127. */
  128. val String getFuncsSource = compileGetFmiValueFunctions(adapClassName, SASVs);
  129. val String setFuncsSource = compileSetFmiValueFunctions(adapClassName, SASVs);
  130. // Compile the source file
  131. val String sourceInclude = '''#include "«adapClassName».h"''';
  132. val sourceFile = compileSource(
  133. sourceInclude,
  134. deAndConstructorAndInitializeSource,
  135. getRuleThisSource,
  136. getFuncsSource,
  137. setFuncsSource,
  138. inRuleResult.generatedCpp,
  139. outRuleResult.generatedCpp,
  140. crtlRuleResult.generatedCpp
  141. );
  142. fsa.generateFile(adapClassName + ".cpp", sourceFile);
  143. // Merge the global variables for use in compiling the header file.
  144. // TODO: Check for duplicates
  145. var LinkedHashMap<String, GlobalInOutVariable> allGVars = newLinkedHashMap();
  146. allGVars.putAll(params);
  147. allGVars.putAll(outRuleResult.gVars);
  148. allGVars.putAll(inRuleResult.gVars);
  149. allGVars.putAll(crtlRuleResult.gVars);
  150. // Compile the header file
  151. val headerFile = compileHeader(
  152. adapClassName,
  153. fmusDefines,
  154. SADefines,
  155. inRuleResult.functionSignatures,
  156. outRuleResult.functionSignatures,
  157. crtlRuleResult.functionSignatures,
  158. allGVars,
  159. fmus,
  160. SASVs.values.map[CalcSVar()].toList
  161. );
  162. fsa.generateFile(adapClassName + ".h", headerFile);
  163. // Compile the model description file
  164. val modelDescCreator = new ModelDescriptionCreator(adapExternalName);
  165. val modelDescription = modelDescCreator.generateModelDescription(SASVs.values);
  166. fsa.generateFile("modelDescription.xml", modelDescription);
  167. // Compile the fmu.cpp file
  168. val fmuCppFile = StaticGenerators.GenFmuCppFile(adapClassName);
  169. fsa.generateFile("Fmu.cpp", fmuCppFile);
  170. }
  171. }
  172. def String compileParams(LinkedHashMap<String, GlobalInOutVariable> gVars, EList<ParamDeclarations> params) {
  173. val paramsConditionSwitch = new ParamConditionSwitch(gVars);
  174. var String paramsConstructorSource = "";
  175. for (paramDecl : params) {
  176. val doSwitchRes = paramsConditionSwitch.doSwitch(paramDecl);
  177. paramsConstructorSource += doSwitchRes.code;
  178. }
  179. return paramsConstructorSource;
  180. }
  181. def calcSADefines(Collection<SAScalarVariable> variables) {
  182. var ArrayList<String> defines = newArrayList();
  183. for (SASV : variables) {
  184. defines.add("#define " + SASV.defineName + " " + SASV.valueReference);
  185. }
  186. return defines.join("\n");
  187. }
  188. def calcDefines(LinkedHashMap<String, LinkedHashMap<String, MappedScalarVariable>> map) {
  189. var ArrayList<String> defines = newArrayList();
  190. for (fmuEntries : map.entrySet) {
  191. for (MappedScalarVariable mSV : fmuEntries.value.values) {
  192. defines.add("#define " + mSV.define + " " + mSV.valueReference);
  193. }
  194. }
  195. return defines.join("\n");
  196. }
  197. // Compiles the final source file
  198. def String compileSource(String include, String constructor, String getRuleThis, String getFunctions,
  199. String setFunctions, String inFunctions, String outFunctions, String controlFunction) {
  200. return '''
  201. «include»
  202. namespace adaptation
  203. {
  204. «constructor»
  205. «getRuleThis»
  206. «getFunctions»
  207. «setFunctions»
  208. «inFunctions»
  209. «controlFunction»
  210. «outFunctions»
  211. }
  212. '''
  213. }
  214. /*
  215. * Compiles the header file split into two: The first part contains the includes and using namespace definitions and start the ,
  216. * the second part contains the class
  217. */
  218. def String compileHeader(String adapClassName, String fmusDefines, String SADefines, List<String> inRulesFuncSig,
  219. List<String> outRulesFuncSig, List<String> crtlRulesFuncSig,
  220. LinkedHashMap<String, GlobalInOutVariable> globalVariables, ArrayList<Pair<String, String>> fmus,
  221. Collection<ScalarVariable> sVars) {
  222. return '''
  223. #ifndef SRC_«adapClassName.toUpperCase»_H
  224. #define SRC_«adapClassName.toUpperCase»_H
  225. #include "SemanticAdaptation.h"
  226. #include <memory>
  227. #include "Fmu.h"
  228. using namespace std;
  229. using namespace fmi2;
  230. namespace adaptation
  231. {
  232. «fmusDefines»
  233. «SADefines»
  234. class «adapClassName» : public SemanticAdaptation<«adapClassName»>, public enable_shared_from_this<«adapClassName»>
  235. {
  236. public:
  237. «adapClassName»(shared_ptr<std::string> fmiInstanceName, shared_ptr<string> resourceLocation, const fmi2CallbackFunctions* functions);
  238. void initialize();
  239. virtual ~«adapClassName»();
  240. void setFmiValue(fmi2ValueReference id, int value);
  241. void setFmiValue(fmi2ValueReference id, bool value);
  242. void setFmiValue(fmi2ValueReference id, double value);
  243. void setFmiValue(fmi2ValueReference id, string value);
  244. int getFmiValueInteger(fmi2ValueReference id);
  245. bool getFmiValueBoolean(fmi2ValueReference id);
  246. double getFmiValueReal(fmi2ValueReference id);
  247. string getFmiValueString(fmi2ValueReference id);
  248. private:
  249. «adapClassName»* getRuleThis();
  250. /*in rules*/
  251. «inRulesFuncSig.map[x | x+";"].join("\n")»
  252. /*out rules*/
  253. «outRulesFuncSig.map[x | x+";"].join("\n")»
  254. «crtlRulesFuncSig.map[x | x+";"].join("\n")»
  255. «FOR fmu : fmus»
  256. shared_ptr<FmuComponent> «fmu.key»;
  257. «ENDFOR»
  258. «FOR sv : sVars»
  259. «Conversions.fmiTypeToCppType(sv.type)» «sv.name»;
  260. «IF sv.causality == SVCausality.input»
  261. bool isSet«sv.name»;
  262. «ENDIF»
  263. «ENDFOR»
  264. «FOR v : globalVariables.entrySet»
  265. «Conversions.fmiTypeToCppType(v.value.type)» «v.key»;
  266. «ENDFOR»
  267. };
  268. }
  269. #endif
  270. ''';
  271. }
  272. /*
  273. * Compiles the source file constructor, destructor and the initialize function
  274. */
  275. def String compileDeAndConstructorAndInitialize(String adapClassName, String fmuName, String fmuTypeName,
  276. String guid, String paramsCons, String inCons, String outCons, String crtlCons) {
  277. return '''
  278. «adapClassName»::«adapClassName»(shared_ptr<std::string> fmiInstanceName,shared_ptr<string> resourceLocation, const fmi2CallbackFunctions* functions) :
  279. SemanticAdaptation(fmiInstanceName, resourceLocation, createInputRules(),createOutputRules(), functions)
  280. {
  281. «paramsCons»
  282. «inCons»
  283. «outCons»
  284. «crtlCons»
  285. }
  286. void «adapClassName»::initialize()
  287. {
  288. auto path = make_shared<string>(*resourceLocation);
  289. path->append(string("«fmuTypeName».fmu"));
  290. auto «fmuName»Fmu = make_shared<fmi2::Fmu>(*path);
  291. «fmuName»Fmu->initialize();
  292. this->«fmuName» = «fmuName»Fmu->instantiate("«fmuName»",fmi2CoSimulation, "«guid»", true, true, shared_from_this());
  293. if(this->«fmuName»->component == NULL)
  294. this->lastErrorState = fmi2Fatal;
  295. this->instances->push_back(this->«fmuName»);
  296. }
  297. «adapClassName»::~«adapClassName»()
  298. {
  299. }
  300. ''';
  301. }
  302. /*
  303. * Compiles the source file function getRuleThis
  304. */
  305. def String compileGetRuleThis(String adaptationName) {
  306. return '''
  307. «adaptationName»* «adaptationName»::getRuleThis()
  308. {
  309. return this;
  310. }
  311. '''
  312. }
  313. /*
  314. * Compiles the source file functions getFmiValue<double, int, string, bool>
  315. */
  316. def String compileGetFmiValueFunctions(String adaptationName, LinkedHashMap<String, SAScalarVariable> variables) {
  317. var ArrayList<String> cpp = newArrayList();
  318. var List<ScalarVariable> convertedSASVs = variables.values.map[CalcSVar()].toList;
  319. var convertedSASVsOrdered = convertedSASVs.filter[causality === SVCausality.output].groupBy[type];
  320. for (SVType type : SVType.values) {
  321. val functionSignature = '''«Conversions.fmiTypeToCppType(type)» «adaptationName»::getFmiValue«type.toString»(fmi2ValueReference id)''';
  322. val functionReturn = '''return «Conversions.fmiTypeToCppDefaultValue(type)»''';
  323. if (convertedSASVsOrdered.containsKey(type)) {
  324. cpp.add(
  325. '''
  326. «functionSignature»
  327. {
  328. switch (id)
  329. {
  330. «FOR svInner : convertedSASVsOrdered.get(type)»
  331. case «variables.get(svInner.name).defineName»:
  332. {
  333. return this->«svInner.name»;
  334. }
  335. «ENDFOR»
  336. default:
  337. {
  338. «functionReturn»;
  339. }
  340. }
  341. }
  342. '''
  343. );
  344. } else {
  345. cpp.add(
  346. '''
  347. «functionSignature»
  348. {
  349. «functionReturn»;
  350. }
  351. '''
  352. );
  353. }
  354. }
  355. return cpp.join("\n");
  356. }
  357. /*
  358. * Compiles the source file functions setFmiValue<double, int, string, bool>*
  359. */
  360. def String compileSetFmiValueFunctions(String adapClassName, LinkedHashMap<String, SAScalarVariable> variables) {
  361. var ArrayList<String> cpp = newArrayList();
  362. var List<ScalarVariable> convertedSASVs = variables.values.map[CalcSVar()].filter [
  363. causality === SVCausality.input
  364. ].toList;
  365. var convertedSASVsOrdered = convertedSASVs.groupBy[type];
  366. for (SVType type : SVType.values) {
  367. cpp.add(
  368. '''
  369. void «adapClassName»::setFmiValue(fmi2ValueReference id, «Conversions.fmiTypeToCppType(type)» value)
  370. {
  371. «IF convertedSASVsOrdered.containsKey(type)»
  372. switch (id)
  373. {
  374. «FOR svInner : convertedSASVsOrdered.get(type)»
  375. case «variables.get(svInner.name).defineName»:
  376. {
  377. this->«svInner.name» = value;
  378. this->isSet«svInner.name» = true;
  379. break;
  380. }
  381. «ENDFOR»
  382. default:
  383. {
  384. }
  385. }
  386. «ENDIF»
  387. }
  388. '''
  389. );
  390. }
  391. return cpp.join("\n");
  392. }
  393. /*
  394. * Compiles the source file function executeInternalControlFlow.
  395. * Calculates necessary information on function signatures necessary for generation of the header file.
  396. */
  397. def InOutRulesBlockResult compileControlRuleBlock(Iterable<ControlRuleBlock> crtlRuleBlocks, String adaptationClassName,
  398. String adaptationName, LinkedHashMap<String, SAScalarVariable> SASVs, LinkedHashMap<String, GlobalInOutVariable> params) {
  399. var cpp = "";
  400. val visitor = new ControlConditionSwitch(adaptationClassName, adaptationName, SASVs, params);
  401. for (crtlRule : crtlRuleBlocks) {
  402. cpp += visitor.doSwitch(crtlRule).code;
  403. }
  404. return new InOutRulesBlockResult(cpp, visitor.functionSignatures, visitor.globalVars, visitor.constructorInitialization);
  405. }
  406. def String SplitAtSpaceAndRemoveFirst(String content) {
  407. content.substring(content.indexOf(" ") + 1, content.length);
  408. }
  409. def String removeEmptyArgumentParenthesis(String content) {
  410. return content.substring(0, content.length - 2);
  411. }
  412. /*
  413. * Compiles the source file functions <in/out>_rule_<condition, body, flush>.
  414. * Calculates necessary information on global in/out variables necessary for generation of the header file.
  415. * Calculates necessary information on function signatures necessary for generation of the header file.
  416. */
  417. def InOutRulesBlockResult compileInOutRuleBlocks(InputOutputRuleType ioType, Iterable<InOutRules> rulesBlocks,
  418. String adaptationClassName, String adaptationName,
  419. LinkedHashMap<String, LinkedHashMap<String, MappedScalarVariable>> mSVars,
  420. LinkedHashMap<String, SAScalarVariable> SASVs, LinkedHashMap<String, GlobalInOutVariable> params) {
  421. val visitor = if (ioType == InputOutputRuleType.Input)
  422. new InRulesConditionSwitch(adaptationClassName, adaptationName, mSVars, SASVs, params)
  423. else
  424. new OutRulesConditionSwitch(adaptationClassName, adaptationName, mSVars, SASVs, params);
  425. val functionName = "create" + ioType + "Rules()";
  426. var String cpp = "";
  427. val ruleBlock = rulesBlocks.head;
  428. if (ruleBlock !== null) {
  429. cpp += visitor.doSwitch(ruleBlock).code;
  430. if (!visitor.functionSignatures.empty) {
  431. var ArrayList<String> createRulesFunction = newArrayList();
  432. for (var int i = 0; i < (visitor.functionSignatures.length); i += 3) {
  433. createRulesFunction.add(
  434. '''
  435. list->push_back(
  436. (Rule<«adaptationClassName»>){
  437. &«adaptationClassName»::«visitor.functionSignatures.get(i).SplitAtSpaceAndRemoveFirst.removeEmptyArgumentParenthesis»,
  438. &«adaptationClassName»::«visitor.functionSignatures.get(i+1).SplitAtSpaceAndRemoveFirst.removeEmptyArgumentParenthesis»,
  439. &«adaptationClassName»::«visitor.functionSignatures.get(i+2).SplitAtSpaceAndRemoveFirst.removeEmptyArgumentParenthesis»
  440. });
  441. ''');
  442. }
  443. val functionPrefix = '''shared_ptr<list<Rule<«adaptationClassName»>>>''';
  444. visitor.functionSignatures.add(functionPrefix + " " + functionName)
  445. cpp += '''
  446. «functionPrefix» «adaptationClassName»::«functionName»
  447. {
  448. auto list = make_shared<std::list<Rule<«adaptationClassName»>>>();
  449. «createRulesFunction.join("\n")»
  450. return list;
  451. }
  452. '''
  453. }
  454. }
  455. return new InOutRulesBlockResult(cpp, visitor.functionSignatures, visitor.getGlobalVars,
  456. visitor.constructorInitialization);
  457. }
  458. /*
  459. * Calculates the semantic adaptation scalar variables via input ports and output ports.
  460. * Note: These a not fully populated yet as the in rules and out rules must be compiled first.
  461. */
  462. def LinkedHashMap<String, SAScalarVariable> calcSASVsFromInportsOutports(String definePrefix, EList<Port> inports,
  463. EList<Port> outports) {
  464. var LinkedHashMap<String, SAScalarVariable> saSVs = newLinkedHashMap();
  465. var int valueReference = 0;
  466. for (inport : inports) {
  467. var saSV = new SAScalarVariable();
  468. saSV.SetPartOfMD(true);
  469. saSV.valueReference = valueReference++;
  470. saSV.name = inport.name;
  471. saSV.defineName = (definePrefix + inport.name).toUpperCase
  472. saSV.causality = SVCausality.input;
  473. saSVs.put(saSV.name, saSV);
  474. }
  475. for (outport : outports) {
  476. var saSV = new SAScalarVariable();
  477. saSV.SetPartOfMD(true);
  478. saSV.valueReference = valueReference++;
  479. saSV.defineName = (definePrefix + outport.name).toUpperCase
  480. saSV.name = outport.name;
  481. saSV.causality = SVCausality.output;
  482. saSVs.put(saSV.name, saSV);
  483. }
  484. return saSVs;
  485. }
  486. def List<File> getResourcePaths() {
  487. return resourcePaths;
  488. }
  489. }