Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
c64d052
WIP: ECDAR reference added, dependency section updated, and spelling …
Nielswps Feb 8, 2023
d20a900
WIP: Backend replaced with Engine to be consistent with naming
Nielswps Feb 8, 2023
0521d58
WIP: Engine Configuration enriched
Nielswps Feb 8, 2023
5541728
Contributing section added and code snippets updated to be executable…
Nielswps Feb 10, 2023
61b8963
Rename branched out from readme_update
Nielswps Feb 10, 2023
fc990cd
File used on other branch
Nielswps Feb 10, 2023
2a70993
WIP: ECDAR reference added, dependency section updated, and spelling …
Nielswps Feb 8, 2023
dc5c07d
WIP: Backend replaced with Engine to be consistent with naming
Nielswps Feb 8, 2023
62eb03d
Contributing section added and code snippets updated to be executable…
Nielswps Feb 10, 2023
ab6422f
File used on other branch
Nielswps Feb 10, 2023
764e7e1
Rebased with main
Nielswps Feb 23, 2023
afccbc2
WIP: Backend replaced with Engine to be consistent with naming
Nielswps Feb 8, 2023
848d83e
WIP: Engine Configuration enriched
Nielswps Feb 8, 2023
fbd3b17
File used on other branch
Nielswps Feb 10, 2023
36c2070
Merge branch 'backend_to_engine' of github.com:Nielswps/Ecdar-GUI int…
Nielswps Feb 23, 2023
8143573
Line about the deprecated mutation package added
Nielswps Feb 24, 2023
936cdbf
WIP: Potential fix for dangling engines by keeping track of started c…
Nielswps Feb 26, 2023
c36303b
Dependency termination and refactoring
Nielswps Feb 26, 2023
fe50ef1
WIP: ToDo tested and removed
Nielswps Feb 26, 2023
f5b3a58
WIP: Major refactoring with dependency elimination and removal of bus…
Nielswps Feb 27, 2023
2aef3a3
Merged with main
Nielswps Mar 1, 2023
600416b
WIP: Preparation to eliminate dependency in
Nielswps Mar 1, 2023
fd0d497
Query state indicator width locked to prevent inconsistent sizes acro…
Nielswps Mar 1, 2023
8bbb040
WIP: Potential fix for dangling engines by keeping track of started c…
Nielswps Feb 26, 2023
b085767
Dependency termination and refactoring
Nielswps Feb 26, 2023
4c1423e
WIP: ToDo tested and removed
Nielswps Feb 26, 2023
0443fa1
WIP: Major refactoring with dependency elimination and removal of bus…
Nielswps Feb 27, 2023
4abd261
WIP: Preparation to eliminate dependency in
Nielswps Mar 1, 2023
a85c750
Merge branch 'query_refactor' of github.com:Nielswps/Ecdar-GUI into q…
Nielswps Mar 1, 2023
e78ad50
Update src/main/java/ecdar/abstractions/Query.java
Nielswps Mar 2, 2023
d85703e
WIP: Review changes (part 1/2)
Nielswps Mar 2, 2023
a2df214
Update src/main/java/ecdar/backend/BackendHelper.java
Nielswps Mar 2, 2023
8dc64e1
WIP: refactoring started
Nielswps Mar 2, 2023
c5b4c42
Merge branch 'backend_to_engine' of github.com:Nielswps/Ecdar-GUI int…
Nielswps Mar 2, 2023
f047d48
WIP: Review changes (part 2/2)
Nielswps Mar 2, 2023
0f8cbb0
Merge branch 'backend_to_engine' into ed_ref
Nielswps Mar 2, 2023
c4b46d1
BackendDriver refactored to be more readable (method division)
Nielswps Mar 2, 2023
0c50fab
More refactoring
Nielswps Mar 3, 2023
ea08a97
Merge branch 'Ecdar:main' into ed_ref
Nielswps Mar 10, 2023
307d820
WIP: Backend replaced with Engine to be consistent with naming
Nielswps Feb 8, 2023
8de2d3b
File used on other branch
Nielswps Feb 10, 2023
cffde82
WIP: Backend replaced with Engine to be consistent with naming
Nielswps Feb 8, 2023
da7ebe0
File used on other branch
Nielswps Feb 10, 2023
8c694ef
BackendDriver refactored to be more readable (method division)
Nielswps Mar 2, 2023
efab027
More refactoring
Nielswps Mar 3, 2023
b1f5cda
Merge with origin after rebase
Nielswps Mar 12, 2023
05352b0
Ensure successful rebase and merge (#16)
Nielswps Mar 12, 2023
1677426
Merge branch 'ed_ref' of github.com:Nielswps/Ecdar-GUI into ed_ref
Nielswps Mar 12, 2023
6ad07d4
Minor naming and comment errors fixed
Nielswps Mar 12, 2023
c3ce752
WIP: Exception handling added (not done) to engine handling
Nielswps Mar 16, 2023
974e4b5
WIP: Comment removed
Nielswps Mar 16, 2023
aaf4017
Engine process and connection exception handling finished
Nielswps Mar 16, 2023
d7072d9
Final backend refactor
Nielswps Mar 16, 2023
7727cf8
Review renaming implemented
Nielswps Mar 16, 2023
016f4c9
Get IP added to Engine for better interface
Nielswps Mar 17, 2023
27a066f
EngineConnection initialization moved to separate class
Nielswps Mar 17, 2023
bac4cd6
ToDo's removed and added as issues on the repo
Nielswps Mar 17, 2023
231ef1b
ToDo's removed and added as issues on the repo v2
Nielswps Mar 17, 2023
aa450b5
Merged with ed_ref. **WARNING**: ed_ref should be merged first and th…
Nielswps Mar 17, 2023
bb838b3
Query execution logic moved to controller
Nielswps Mar 17, 2023
fe253d9
Minor refactoring and runQuery test fixed
Nielswps Mar 17, 2023
0e67b57
Observable list fixed
Nielswps Mar 18, 2023
d5ae7d3
Shutdown of the application updated for better handling
Nielswps Mar 24, 2023
cf97976
Merged with ed_ref
Nielswps Mar 24, 2023
5677be8
Failing controller test removed (testing will be done at a later point)
Nielswps Mar 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 25 additions & 35 deletions src/main/java/ecdar/Ecdar.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package ecdar;

import ecdar.abstractions.*;
import ecdar.backend.BackendDriver;
import ecdar.backend.BackendException;
import ecdar.backend.BackendHelper;
import ecdar.backend.QueryHandler;
import ecdar.code_analysis.CodeAnalysis;
import ecdar.controllers.EcdarController;
import ecdar.issues.ExitStatusCodes;
import ecdar.presentations.*;
import ecdar.utility.keyboard.Keybind;
import ecdar.utility.keyboard.KeyboardTracker;
Expand Down Expand Up @@ -50,8 +50,6 @@ public class Ecdar extends Application {
private static BooleanProperty isUICached = new SimpleBooleanProperty();
public static BooleanProperty shouldRunBackgroundQueries = new SimpleBooleanProperty(true);
private static final BooleanProperty isSplit = new SimpleBooleanProperty(false);
private static BackendDriver backendDriver = new BackendDriver();
private static QueryHandler queryHandler = new QueryHandler(backendDriver);
private Stage debugStage;

/**
Expand Down Expand Up @@ -179,20 +177,6 @@ public static void toggleCanvasSplit() {
isSplit.set(!isSplit.get());
}

/**
* Returns the backend driver used to execute queries and handle simulation
*
* @return BackendDriver
*/
public static BackendDriver getBackendDriver() {
return backendDriver;
}

public static QueryHandler getQueryExecutor() {
return queryHandler;

}

public static double getDpiScale() {
if (!autoScalingEnabled.getValue())
return 1;
Expand Down Expand Up @@ -256,6 +240,21 @@ public void start(final Stage stage) {
Ecdar.showToast("The application icon could not be loaded");
}

BackendHelper.addEngineInstanceListener(() -> {
// When the engines change, clear the backendDriver
// to prevent dangling connections and queries
try {
presentation.getController().queryPane.getController().stopAllQueries();
BackendHelper.clearEngineConnections();
} catch (BackendException e) {
showToast("An exception was encountered during shutdown of engine connections");
}
});

// Whenever the Runtime is requested to exit, first stop all queries and exit the Platform
Runtime.getRuntime().addShutdownHook(new Thread(presentation.getController().queryPane.getController()::stopAllQueries));
Runtime.getRuntime().addShutdownHook(new Thread(Platform::exit));

// We're now ready! Let the curtains fall!
stage.show();

Expand Down Expand Up @@ -298,28 +297,19 @@ public void start(final Stage stage) {
}));

stage.setOnCloseRequest(event -> {
BackendHelper.stopQueries();

int statusCode = ExitStatusCodes.SHUTDOWN_SUCCESSFUL.getStatusCode();
try {
backendDriver.closeAllEngineConnections();
} catch (IOException e) {
e.printStackTrace();
BackendHelper.clearEngineConnections();
} catch (BackendException e) {
statusCode = ExitStatusCodes.CLOSE_ENGINE_CONNECTIONS_FAILED.getStatusCode();
}

Platform.exit();
System.exit(0);
});

BackendHelper.addEngineInstanceListener(() -> {
// When the engines change, re-instantiate the backendDriver
// to prevent dangling connections and queries
try {
backendDriver.closeAllEngineConnections();
} catch (IOException e) {
throw new RuntimeException(e);
System.exit(statusCode);
} catch (SecurityException e) {
// Forcefully shutdown the Java Runtime
Runtime.getRuntime().halt(ExitStatusCodes.GRACEFUL_SHUTDOWN_FAILED.getStatusCode());
}

backendDriver = new BackendDriver();
});

project = presentation.getController().projectPane.getController().project;
Expand Down
119 changes: 0 additions & 119 deletions src/main/java/ecdar/abstractions/Engine.java

This file was deleted.

71 changes: 6 additions & 65 deletions src/main/java/ecdar/abstractions/Query.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package ecdar.abstractions;

import ecdar.Ecdar;
import ecdar.backend.*;
import ecdar.controllers.EcdarController;
import ecdar.utility.serialize.Serializable;
import com.google.gson.JsonObject;
import javafx.application.Platform;
import javafx.beans.property.*;

import java.util.function.Consumer;

public class Query implements Serializable {
private static final String QUERY = "query";
private static final String COMMENT = "comment";
Expand All @@ -18,49 +13,20 @@ public class Query implements Serializable {

private final StringProperty query = new SimpleStringProperty("");
private final StringProperty comment = new SimpleStringProperty("");
private final StringProperty errors = new SimpleStringProperty("");
private final SimpleBooleanProperty isPeriodic = new SimpleBooleanProperty(false);
private final ObjectProperty<QueryState> queryState = new SimpleObjectProperty<>(QueryState.UNKNOWN);
private final ObjectProperty<QueryType> type = new SimpleObjectProperty<>();
private Engine engine;


private final Consumer<Boolean> successConsumer = (aBoolean) -> {
if (aBoolean) {
setQueryState(QueryState.SUCCESSFUL);
} else {
setQueryState(QueryState.ERROR);
}
};

private Boolean forcedCancel = false;
private final Consumer<Exception> failureConsumer = (e) -> {
if (forcedCancel) {
setQueryState(QueryState.UNKNOWN);
} else {
setQueryState(QueryState.SYNTAX_ERROR);
if (e instanceof BackendException.MissingFileQueryException) {
Ecdar.showToast("Please save the project before trying to run queries");
}

this.addError(e.getMessage());
final Throwable cause = e.getCause();
if (cause != null) {
// We had trouble generating the model if we get a NullPointerException
if (cause instanceof NullPointerException) {
setQueryState(QueryState.UNKNOWN);
} else {
Platform.runLater(() -> EcdarController.openQueryDialog(this, cause.toString()));
}
}
}
};

public Query(final String query, final String comment, final QueryState queryState) {
public Query(final String query, final String comment, final QueryState queryState, final Engine engine) {
this.query.set(query);
this.comment.set(comment);
this.queryState.set(queryState);
setEngine(BackendHelper.getDefaultEngine());
setEngine(engine);
}

public Query(final String query, final String comment, final QueryState queryState) {
this(query, comment, queryState, BackendHelper.getDefaultEngine());
}

public Query(final JsonObject jsonElement) {
Expand Down Expand Up @@ -103,8 +69,6 @@ public StringProperty commentProperty() {
return comment;
}

public StringProperty errors() { return errors; }

public boolean isPeriodic() {
return isPeriodic.get();
}
Expand Down Expand Up @@ -137,14 +101,6 @@ public ObjectProperty<QueryType> getTypeProperty() {
return this.type;
}

public Consumer<Boolean> getSuccessConsumer() {
return successConsumer;
}

public Consumer<Exception> getFailureConsumer() {
return failureConsumer;
}

@Override
public JsonObject serialize() {
final JsonObject result = new JsonObject();
Expand Down Expand Up @@ -181,19 +137,4 @@ public void deserialize(final JsonObject json) {
setEngine(BackendHelper.getDefaultEngine());
}
}

public void cancel() {
if (getQueryState().equals(QueryState.RUNNING)) {
forcedCancel = true;
setQueryState(QueryState.UNKNOWN);
}
}

public void addError(String e) {
errors.set(errors.getValue() + e + "\n");
}

public String getCurrentErrors() {
return errors.getValue();
}
}
Loading