diff --git a/ch.psi.fda/pom.xml b/ch.psi.fda/pom.xml
index 46f7f4d..ab85943 100644
--- a/ch.psi.fda/pom.xml
+++ b/ch.psi.fda/pom.xml
@@ -3,7 +3,7 @@
4.0.0ch.psifda
- 1.1.30
+ 1.1.31
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ShellAction.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ShellAction.java
index b015045..e408fc8 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ShellAction.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ShellAction.java
@@ -35,6 +35,9 @@ public class ShellAction implements Action{
// Get Logger
private static Logger logger = Logger.getLogger(ShellAction.class.getName());
+ private volatile Process process;
+ private volatile boolean abort = false;
+
/**
* Name (full path if it is not in the system path) of the script to execute when
* the execute() function of this action is invoked.
@@ -67,15 +70,22 @@ public class ShellAction implements Action{
@Override
public void execute() throws InterruptedException {
try{
+ abort = false;
logger.fine("Execute script "+script);
- Process process = Runtime.getRuntime().exec(script);
+ process = Runtime.getRuntime().exec(script);
int exitValue = process.waitFor();
logger.fine("Script ["+script+"] return value: "+exitValue);
- // Check script exit value to 0 if != 0 then throw an runtime exception
- if(exitValue != 0){
- throw new RuntimeException("Script ["+script+"] returned with an exit value not equal to 0");
+ if(abort){
+ throw new RuntimeException("Script ["+script+"] was aborted");
}
+ else{
+ // Check script exit value to 0 if != 0 then throw an runtime exception
+ if(exitValue != 0){
+ throw new RuntimeException("Script ["+script+"] returned with an exit value not equal to 0");
+ }
+ }
+ process = null; // Ensure that the process is null
}
catch(IOException e){
// Convert Exception into unchecked RuntimeException
@@ -88,7 +98,12 @@ public class ShellAction implements Action{
*/
@Override
public void abort() {
+ abort=true;
// This action cannot be aborted, therefore this function is not implemented.
+ if(process!=null){
+ // Terminate process via kill
+ process.destroy();
+ }
}
/* (non-Javadoc)
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/ActorSensorLoop.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/ActorSensorLoop.java
index e06d02f..f172a28 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/ActorSensorLoop.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/ActorSensorLoop.java
@@ -191,151 +191,157 @@ public class ActorSensorLoop implements ActionLoop {
// Variable to store the last guard status
boolean guardOK=true;
- // Execute loop logic
- while(loop){
+ try{
- if(guardOK){
+ // Execute loop logic
+ while(loop){
-
- // If actors are defined for the loop check whether all of them
- // have a next step defined if there is no actor defined only run this loop once
- if(actors.size()>0){
- // Check whether the actors of this loop have a next step. If not
- // abort the loop
- boolean hasNext = true;
- for(Actor actor: actors){
- if(!actor.hasNext()){
- hasNext=false;
- break; // Stop actor check loop
+ if(guardOK){
+
+
+ // If actors are defined for the loop check whether all of them
+ // have a next step defined if there is no actor defined only run this loop once
+ if(actors.size()>0){
+ // Check whether the actors of this loop have a next step. If not
+ // abort the loop
+ boolean hasNext = true;
+ for(Actor actor: actors){
+ if(!actor.hasNext()){
+ hasNext=false;
+ break; // Stop actor check loop
+ }
+ }
+
+ // If not all actors have a next step abort the loop
+ if(!hasNext){
+ break; // Stop action loop
}
}
-
- // If not all actors have a next step abort the loop
- if(!hasNext){
- break; // Stop action loop
+ else{
+ // No actors defined, only run loop once
+ loop = false;
}
- }
- else{
- // No actors defined, only run loop once
- loop = false;
- }
-
-
-
- // Execute pre actor actions
- for(Action action: preActorActions){
- action.execute();
- }
-
- if(abort){ // End loop if abort was issued
- break;
- }
-
- // Set actors
-// for(Actor actor: actors){
-// actor.set();
-// }
- // Parallel set of the actors
- try {
- for (Future