Kaynağa Gözat

end to end application done

Claudio Gomes 7 yıl önce
ebeveyn
işleme
01dfef4631

+ 1 - 1
HintCO/HintCO.product

@@ -8,7 +8,7 @@
    </configIni>
 
    <launcherArgs>
-      <programArgs>-consolelog -noexit
+      <programArgs>-consolelog -nosplash
       </programArgs>
       <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
       </vmArgsMac>

+ 9 - 0
HintCO/instances/execute_cosim_test.xmi

@@ -25,6 +25,9 @@
     <cosimunits
         identifier="DLoopController_FixedEuler_1Em6"
         declaration="//@csuDeclarations.1">
+      <adaptation
+          xsi:type="hintco:MultiRateAdaptation"
+          rate="10"/>
       <ports
           xsi:type="hintco:InputPortInstance"
           identifier="VEL_FB@expseu_"
@@ -82,6 +85,9 @@
     <cosimunits
         identifier="EMAPlantNoLoad_FixedEuler_1Em6"
         declaration="//@csuDeclarations.2">
+      <adaptation
+          xsi:type="hintco:MultiRateAdaptation"
+          rate="10"/>
       <ports
           xsi:type="hintco:InputPortInstance"
           identifier="torque_input@expseu_"
@@ -160,6 +166,9 @@
     <cosimunits
         identifier="LoadNSensor_FixedEuler_1Em6"
         declaration="//@csuDeclarations.3">
+      <adaptation
+          xsi:type="hintco:MultiRateAdaptation"
+          rate="10"/>
       <ports
           xsi:type="hintco:InputPortInstance"
           identifier="F_INPUT@expseu_"

+ 8 - 3
HintCO/src/ua/ansymo/hintco/CandidateSpaceGenerator.xtend

@@ -37,9 +37,6 @@ class CandidateSpaceGenerator {
 	}
 	
 	def createCandidateSpace(Object hints, Candidates cs){
-		if (hints === null){
-			return createDefaultCandidateSpace(cs)
-		}
 		// TODO
 		return HintcoFactory.eINSTANCE.createCandidates()
 	}
@@ -61,6 +58,12 @@ class CandidateSpaceGenerator {
 		val f = HintcoFactory.eINSTANCE
 		
 		for (unit : scenario.cosimunits) {
+			
+			// Add multi-rate adaptation
+			val mr = f.createMultiRateAdaptation
+			unit.adaptation = mr
+			mr.rate = 10
+			
 			val inPorts = unit.ports.filter(InputPortInstance)
 			for (inPort : inPorts) {
 				val xor = f.createXorAdaptation()
@@ -82,11 +85,13 @@ class CandidateSpaceGenerator {
 				for (aT : intraAdaptations){
 					aS.implies.add(aT)
 				}
+				aS.implies.add(unit.adaptation)
 			}
 			for (aS : extraAdaptations){
 				for (aT : extraAdaptations){
 					aS.implies.add(aT)
 				}
+				aS.implies.add(unit.adaptation)
 			}
 		}
 		

+ 7 - 0
HintCO/src/ua/ansymo/hintco/CandidatesGenerator.xtend

@@ -42,6 +42,10 @@ class CandidatesGenerator {
 		// Creates a variant tree.
 		// The first level of the tree is the xor with the strongest weights.
 		
+		// Clear existing information
+		cs.root = null
+		cs.nodes.clear()
+		
 		// Get factory for creating objects.
 		val f = HintcoFactory.eINSTANCE
 		
@@ -126,6 +130,9 @@ class CandidatesGenerator {
 				DecompositionAdaptation: {
 					// Nothing to do.
 				}
+				MultiRateAdaptation: {
+					// Nothing to do
+				}
 				default:
 					if (n.alternative !== null){
 						throw new UnsupportedOperationException()

+ 1 - 1
HintCO/src/ua/ansymo/hintco/CosimRunner.xtend

@@ -25,7 +25,7 @@ class CosimRunner implements ICosimRunner {
 			val fmu = Factory.create(new File(unit.declaration.path))
 			fmu.load()
 			// TODO: Inject the AdaptedFMU object, which is a wrapper to the real FMU, containing the adaptations declared.
-			val fmuInstance = new AdaptedFMU(fmu.instantiate(unit.declaration.guid, unit.identifier, true, true, new IFmuCallback() {
+			val fmuInstance = new AdaptedFMU(fmu.instantiate(unit.declaration.guid, unit.identifier, true, false, new IFmuCallback() {
 				override log(String instanceName, Fmi2Status status, String category, String message) {
 					println("log: " + instanceName + " " + status + " " + category + " " + message);
 				}

+ 15 - 1
HintCO/src/ua/ansymo/hintco/Main.xtend

@@ -25,12 +25,16 @@ class Main implements IApplication {
 		
 		val helpOpt = Option.builder("h").longOpt("help").desc("Show this description").build();
 		val scenarioOpt = Option.builder("s").longOpt("scenario").desc("Path to scenario file").hasArg().numberOfArgs(1).argName("path").build();
+		val genDefAdaptations = Option.builder("d").longOpt("default").desc("Generate default adaptations").build();
 		val outDirOpt = Option.builder("o").longOpt("output").desc("Path to output directory").hasArg().numberOfArgs(1).argName("path").build();
+		val nVarsOpt = Option.builder("n").longOpt("variants").desc("Number of variants to run").hasArg().numberOfArgs(1).argName("int").build();
 		
 		val options = new Options();
 		options.addOption(helpOpt);
 		options.addOption(scenarioOpt)
+		options.addOption(genDefAdaptations)
 		options.addOption(outDirOpt)
+		options.addOption(nVarsOpt)
 		
 		val parser = new DefaultParser();
 		var CommandLine cmd;
@@ -58,10 +62,20 @@ class Main implements IApplication {
 		val loader = new ModelStorage()
 		val src = loader.loadCandidates(scenarioFile)
 		
+		if (cmd.hasOption(genDefAdaptations.getOpt())){
+			new CandidateSpaceGenerator().createDefaultCandidateSpace(src)
+		}
+		
 		val generator = new CandidatesGenerator(new ConstraintChecker,new VariantValidator, new VariantProcessor(new CosimRunner(new OutputProcessor(outDir))))
 		
 		generator.createVariantTree(src)
-		generator.generateVariants(src)
+		
+		if (cmd.hasOption(nVarsOpt.getOpt())){
+			val nVars = Integer.parseInt(cmd.getOptionValue(nVarsOpt.getOpt()))
+			generator.generateVariants(src, nVars)
+		} else {
+			generator.generateVariants(src)
+		}
 		
 		return IApplication.EXIT_OK
 	}

+ 1 - 1
HintCO/test/ua/ansymo/hintco/test/CosimRunnerTest.xtend

@@ -62,7 +62,7 @@ class CosimRunnerTest {
 		val fmu = Factory.create(new File("resources/watertank.fmu"))
 		assertNotNull(fmu)
 		fmu.load()
-		val fmuInstance = fmu.instantiate("{8c4e810f-3df3-4a00-8276-176fa3c9f001}", "watertank", true, true, new IFmuCallback()
+		val fmuInstance = fmu.instantiate("{8c4e810f-3df3-4a00-8276-176fa3c9f001}", "watertank", true, false, new IFmuCallback()
 		{
 			override log(String instanceName, Fmi2Status status, String category, String message) {
 				println("log: " + instanceName + " " + status + " "