Commit f0c7ed54 authored by Tiziano Munaro's avatar Tiziano Munaro
Browse files

[FMI] Wait for COE server to be started before running a simulation

Issue-Ref: 3853
Issue-Url: https://af3-developer.fortiss.org/issues/3853

Signed-off-by: Tiziano Munaro's avatarTiziano Munaro <munaro@fortiss.org>
parent 36dd99aa
CCodeGeneratorEasyStartMenu.java aee60ea30cbe51832305ffd448cabc4fafab4452 GREEN
CGeneratorExecutionTarget.java 270fd30aaa67a294fd2bf4585044b46a54ee907f GREEN
FMUGeneratorEasyStartMenu.java 4c2ae30d89d32bb045affa580c052db467c3d35d GREEN
FMUGeneratorExecutionTarget.java 5f9d46042f23a92e0775bdca5ebb3c99b735ee40 GREEN
FMUGeneratorExecutionTarget.java a2075edc7fc987934232228ebbb86997b84741fc YELLOW
JavaCodeGeneratorEasyStartMenu.java 08a5ef75fe3ff45840c1cf9e705cb226a1232efb GREEN
JavaGeneratorExecutionTarget.java dba521d1b700365c0522b7c70e49653fcced66cb GREEN
......@@ -21,7 +21,6 @@ import static java.nio.file.Files.createTempDirectory;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.lang.ArrayUtils.addAll;
import static org.eclipse.core.runtime.FileLocator.resolve;
import static org.eclipse.jface.dialogs.MessageDialog.openInformation;
import static org.eclipse.ui.PlatformUI.getWorkbench;
import static org.fortiss.af3.expression.utils.DataDictionaryUtils.findDataDictionary;
import static org.fortiss.af3.generator.common.textgen.c.FMUModelDescriptionTextGenerator.fmuArchiveToXML;
......@@ -32,6 +31,7 @@ import static org.fortiss.tooling.base.utils.SystemUtils.isMacOSXPlatform;
import static org.fortiss.tooling.base.utils.SystemUtils.isOs64BitArch;
import static org.fortiss.tooling.base.utils.SystemUtils.isWindowsPlatform;
import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.showErrorInUIThread;
import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.showInfoInUIThread;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.ResourceUtils.getResourceURI;
......@@ -110,7 +110,6 @@ public class FMUGeneratorExecutionTarget extends ExecutionTargetBase {
FMUArchivePackage fmuSource = (FMUArchivePackage)executable.getExecutableObject();
ExecutionConfiguration config = executable.getConfiguration();
Shell currentShell = getWorkbench().getActiveWorkbenchWindow().getShell();
DataDictionary dd = findDataDictionary(((EObject)executable.getSource()));
Double samplingTime = null;
IResource targetFolder;
......@@ -181,7 +180,7 @@ public class FMUGeneratorExecutionTarget extends ExecutionTargetBase {
error(AF3ComponentUIActivator.getDefault(), cex.getMessage(), cex);
}
if(config != null) {
openInformation(currentShell, "Successful FMU export",
showInfoInUIThread("[Success: FMI export]",
fmuSource.getModelDescription().getName() + ".fmu was successfuly generated!");
}
}
......@@ -353,7 +352,6 @@ public class FMUGeneratorExecutionTarget extends ExecutionTargetBase {
* Needed since a runtime execution blocks when the limited size output buffer is full.
* Therefore we need to concurrently read from BOTH the error and the output stream.
*/
// TODO
@SuppressWarnings("javadoc")
private static final class InputStreamConsumer implements Callable<List<String>> {
InputStream s;
......
CosimulationConfigurationsDialog.java 9fcc43de9ff6ee40b7cb9136155ba937e65b12bb GREEN
CosimulatorGraphGenerator.java 3f786448ab2d977ab9b855d09289df6b6eef61c1 GREEN
FMUSimulatorEasyStartMenu.java d11e36db19e4e46b9f662f6e1d2d762bf0a2c67b GREEN
FMUSimulatorExecutionTarget.java c7eaeb7bd104e2f09cfa9e4eb1661e31108a77ed YELLOW
FMUSimulatorExecutionTarget.java 0ec4a8d59448b665b9b87ad35a6b810b6cd5b6ce YELLOW
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.cosimulation.ui.simulator;
import static java.lang.Thread.sleep;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.createTemporaryComponentArchitecture;
......@@ -110,7 +111,6 @@ public class FMUSimulatorExecutionTarget extends ExecutionTargetBase {
};
job.setUser(true);
job.schedule();
}
/** Executes the co-simulation. */
......@@ -127,7 +127,7 @@ public class FMUSimulatorExecutionTarget extends ExecutionTargetBase {
String sessionID = null;
try {
sessionID = createSession();
} catch(IOException e) {
} catch(IOException | InterruptedException e) {
showErrorInUIThread("[Error: Session creation]", e.getMessage());
return null;
}
......@@ -281,11 +281,18 @@ public class FMUSimulatorExecutionTarget extends ExecutionTargetBase {
}
/** Creates the co-simulation and return the respective ID. */
private String createSession() throws IOException {
InputStream inputStream = sendGet("createSession");
private String createSession() throws IOException, InterruptedException {
InputStream inputStream = null;
do {
try {
inputStream = sendGet("createSession");
} catch(IOException e) {
sleep(100);
}
} while(inputStream == null);
StringBuffer response = new StringBuffer();
try(BufferedReader in1 = new BufferedReader(new InputStreamReader(inputStream))) {
response.append(in1.readLine());
try(BufferedReader in = new BufferedReader(new InputStreamReader(inputStream))) {
response.append(in.readLine());
}
// Extracting the session ID out of the retrieved response from server
return response.toString().substring(14, 50);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment