Removed destroy() method from actuator and action interface

This commit is contained in:
2013-10-14 11:06:55 +02:00
parent 57eca36d27
commit a2d9216e84
25 changed files with 13 additions and 325 deletions

View File

@@ -344,15 +344,8 @@ public class Acquisition {
public void destroy(){
if(actionLoop != null){
logger.finest("Destroy action loop");
try{
actionLoop.destroy();
}
catch(Exception e){
logger.log(Level.SEVERE, "Unable to destroy action loop", e);
}
logger.finest("Destroy managed resources");
// Destroy all managed channels
for(Channel<?> c: channels){
try {
c.destroy();
@@ -1089,7 +1082,6 @@ public class Acquisition {
// Create loop
boolean zigZag = dimension.isZigzag(); // default value is false
// TODO rework CrlogicLoop class to accept templates here instead of cservice
CrlogicLoop actionLoop = new CrlogicLoop(cservice, configuration.getOtfCrlogicPrefix(), configuration.getOtfNfsServer(), configuration.getOtfNfsShare(), configuration.getOtfSmbShare(), zigZag);
actionLoop.setKeepTmpFiles(configuration.isOtfCrlogicKeepTmpFiles());

View File

@@ -34,13 +34,4 @@ public interface Action {
* Abort the execution logic of the action
*/
public void abort();
/**
* Destroy action.
* Can be used for the cleanup of used resources of the action (e.g. to close connections, ...) if
* this cannot be done automatically by the GarbageCollector.
*
* After calling this method the action must not be executed any more!
*/
public void destroy();
}

View File

@@ -51,14 +51,4 @@ public interface Actor {
* Reset the actuator to its initial configuration
*/
public void reset();
/**
* Destroy action.
* Can be used for the cleanup of used resources of the actor (e.g. to close connections, ...) if
* this cannot be done automatically by the GarbageCollector.
*
* After calling this method the actor must not be used any more!
*/
public void destroy();
}

View File

@@ -99,9 +99,4 @@ public class ChannelAccessCondition<E> implements Action {
waitT.interrupt();
}
}
@Override
public void destroy() {
}
}

View File

@@ -105,10 +105,4 @@ public class ChannelAccessConditionAnd implements Action {
waitT.interrupt();
}
}
@Override
public void destroy() {
}
}

View File

@@ -107,10 +107,4 @@ public class ChannelAccessConditionOr implements Action {
waitT.interrupt();
}
}
@Override
public void destroy() {
}
}

View File

@@ -101,9 +101,4 @@ public class ChannelAccessConditionRegex implements Action {
waitT.interrupt();
}
}
@Override
public void destroy() {
}
}

View File

@@ -94,8 +94,4 @@ public class ChannelAccessPut<E> implements Action {
public void abort() {
}
@Override
public void destroy() {
}
}

View File

@@ -51,9 +51,4 @@ public class Delay implements Action {
@Override
public void abort() {
}
@Override
public void destroy() {
}
}

View File

@@ -134,11 +134,6 @@ public class JythonAction implements Action {
public void abort() {
}
@Override
public void destroy() {
}
/**
* Workaround to put variables into the jython engine.
* @param name

View File

@@ -117,11 +117,6 @@ public class ShellAction implements Action{
}
}
@Override
public void destroy() {
}
public boolean isCheckExitValue() {
return checkExitValue;
}

View File

@@ -244,10 +244,6 @@ public class ChannelAccessFunctionActuator<T> implements Actor {
this.direction = this.originalDirection;
}
@Override
public void destroy() {
}
public boolean isAsynchronous() {
return asynchronous;
}

View File

@@ -226,10 +226,6 @@ public class ChannelAccessLinearActuator<T> implements Actor {
this.direction = this.originalDirection;
}
@Override
public void destroy() {
}
public boolean isAsynchronous() {
return asynchronous;
}

View File

@@ -229,10 +229,6 @@ public class ChannelAccessTableActuator<T> implements Actor {
this.positiveDirection = this.originalPositiveDirection;
}
@Override
public void destroy() {
}
public boolean isAsynchronous() {
return asynchronous;
}

View File

@@ -197,24 +197,6 @@ public class ComplexActuator implements Actor {
}
}
@Override
public void destroy() {
// Destroy preActions
for(Action a: preActions){
a.destroy();
}
// Destroy actors
for(Actor a: actors){
a.destroy();
}
// Destroy postActions
for(Action a: postActions){
a.destroy();
}
}
public List<Action> getPreActions() {
return preActions;
}

View File

@@ -71,12 +71,6 @@ public class OTFActuator implements Actor {
@Override
public void reset() {
}
@Override
public void destroy() {
}
public String getName() {
return name;

View File

@@ -24,8 +24,6 @@ import ch.psi.fda.core.Sensor;
/**
* Pseudo actor that is literally doing nothing for n times
* @author ebner
*
*/
public class PseudoActuatorSensor implements Actor, Sensor {
@@ -57,9 +55,6 @@ public class PseudoActuatorSensor implements Actor, Sensor {
}
/* (non-Javadoc)
* @see ch.psi.fda.core.Actor#set()
*/
@Override
public void set() {
@@ -71,65 +66,33 @@ public class PseudoActuatorSensor implements Actor, Sensor {
count++;
}
/* (non-Javadoc)
* @see ch.psi.fda.core.Actor#hasNext()
*/
@Override
public boolean hasNext() {
return (count<counts);
}
/* (non-Javadoc)
* @see ch.psi.fda.core.Actor#init()
*/
@Override
public void init() {
count=0; // Set count back to 0
}
/* (non-Javadoc)
* @see ch.psi.fda.core.Actor#reverse()
*/
@Override
public void reverse() {
// Not implemented
}
/* (non-Javadoc)
* @see ch.psi.fda.core.Actor#reset()
*/
@Override
public void reset() {
// NOt implemented
}
// Sensor implementation
/* (non-Javadoc)
* @see ch.psi.fda.core.Sensor#read()
*/
@Override
public Object read() {
return new Double(count); // Return actual count
}
/* (non-Javadoc)
* @see ch.psi.fda.core.Sensor#getId()
*/
@Override
public String getId() {
return this.id;
}
/* (non-Javadoc)
* @see ch.psi.fda.core.Actor#destroy()
*/
@Override
public void destroy() {
// Nothing to be done
}
}

View File

@@ -410,55 +410,6 @@ public class ActorSensorLoop implements ActionLoop {
}
}
/* (non-Javadoc)
* @see ch.psi.fda.core.Action#destroy()
*/
@Override
public void destroy() {
// Call destroy method of sub components
for(Action a: preActions){
logger.finest("Destroy pre-action");
a.destroy();
}
for(Action a: postActions){
logger.finest("Destroy post-action");
a.destroy();
}
for(Action a: preActorActions){
logger.finest("Destroy pre-actor action");
a.destroy();
}
for(Action a: postActorActions){
logger.finest("Destroy post-actor action");
a.destroy();
}
for(Action a: preSensorActions){
logger.finest("Destroy pre-sensor action");
a.destroy();
}
for(Action a: postSensorActions){
logger.finest("Destroy post-sensor action");
a.destroy();
}
for(Actor a: actors){
logger.finest("Destroy actor");
a.destroy();
}
// Recursively call cleanup() method of all registered action loops
for(ActionLoop actionLoop: actionLoops){
logger.finest("Destroy action loop");
actionLoop.destroy();
}
}
@Override
public List<Action> getPreActions() {
return preActions;

View File

@@ -331,10 +331,6 @@ public class OTFLoop implements ActionLoop {
public void cleanup() {
}
@Override
public void destroy() {
}
@Override
public List<Action> getPreActions() {
return preActions;

View File

@@ -596,29 +596,6 @@ public class CrlogicLoop implements ActionLoop {
}
}
@Override
public void destroy() {
stopReadoutThread = true;
readoutThread.interrupt();
// TODO eventually interrupt readout thread
try {
cservice.destroyAnnotatedChannels(template);
cservice.destroyAnnotatedChannels(motortemplate);
template = null;
motortemplate = null;
} catch (Exception e) {
throw new RuntimeException("Unable to destroy CrlogicLoop", e);
}
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#prepare()
*/
@Override
public void prepare() {
@@ -781,65 +758,51 @@ public class CrlogicLoop implements ActionLoop {
}
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#cleanup()
*/
@Override
public void cleanup() {
// TODO Auto-generated method stub
stopReadoutThread = true;
readoutThread.interrupt();
try {
cservice.destroyAnnotatedChannels(template);
cservice.destroyAnnotatedChannels(motortemplate);
template = null;
motortemplate = null;
} catch (Exception e) {
throw new RuntimeException("Unable to destroy CrlogicLoop", e);
}
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#getPreActions()
*/
@Override
public List<Action> getPreActions() {
return preActions;
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#getPostActions()
*/
@Override
public List<Action> getPostActions() {
return postActions;
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#isDataGroup()
*/
@Override
public boolean isDataGroup() {
// TODO Auto-generated method stub
return dataGroup;
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#setDataGroup(boolean)
*/
@Override
public void setDataGroup(boolean dataGroup) {
this.dataGroup = dataGroup;
}
/**
* @return the sensors
*/
public List<Sensor> getSensors() {
return sensors;
}
/**
* @return the actor
*/
public OTFActuator getActor() {
return actuator;
}
/**
* @param actor the actor to set
*/
public void setActor(OTFActuator actor) {
this.actuator = actor;
}
@@ -860,22 +823,11 @@ public class CrlogicLoop implements ActionLoop {
return new DataQueue(dataQueue, m);
}
/**
* @return the keepTmpFiles
*/
public boolean isKeepTmpFiles() {
return keepTmpFiles;
}
/**
* @param keepTmpFiles the keepTmpFiles to set
*/
public void setKeepTmpFiles(boolean keepTmpFiles) {
this.keepTmpFiles = keepTmpFiles;
}
}

View File

@@ -42,7 +42,6 @@ import ch.psi.fda.core.sensors.MillisecondTimestampSensor;
*/
public class ParallelCrlogic implements ActionLoop {
// Get Logger
private static final Logger logger = Logger.getLogger(ParallelCrlogic.class.getName());
/**
@@ -88,19 +87,10 @@ public class ParallelCrlogic implements ActionLoop {
this.merger = new ParallelCrlogicStreamMerge(crlogic.getDataQueue(), scrlogic.getDataQueue());
}
/* (non-Javadoc)
* @see ch.psi.fda.logic.Logic#prepare()
*/
@Override
public void prepare() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see ch.psi.fda.logic.Logic#execute()
*/
@Override
public void execute() throws InterruptedException {
@@ -191,78 +181,36 @@ public class ParallelCrlogic implements ActionLoop {
}
/* (non-Javadoc)
* @see ch.psi.fda.core.Action#abort()
*/
@Override
public void abort() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see ch.psi.fda.core.Action#destroy()
*/
@Override
public void destroy() {
crlogic.destroy();
scrlogic.destroy();
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#cleanup()
*/
@Override
public void cleanup() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#getPreActions()
*/
@Override
public List<Action> getPreActions() {
return preActions;
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#getPostActions()
*/
@Override
public List<Action> getPostActions() {
return postActions;
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#isDataGroup()
*/
@Override
public boolean isDataGroup() {
return dataGroup;
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#setDataGroup(boolean)
*/
@Override
public void setDataGroup(boolean dataGroup) {
this.dataGroup = dataGroup;
}
/* (non-Javadoc)
* @see ch.psi.fda.core.ActionLoop#getDataQueue()
*/
@Override
public DataQueue getDataQueue() {
return(merger.getDataQueue());
}
}

View File

@@ -157,10 +157,6 @@ public class ScrlogicLoop implements ActionLoop {
latch.countDown();
}
@Override
public void destroy() {
}
@Override
public void prepare() {
}

View File

@@ -94,7 +94,6 @@ public class ActorSensorLoopTest {
@After
public void tearDown() throws Exception {
loopOne.destroy();
cservice.destroy();
}
@@ -307,10 +306,6 @@ public class ActorSensorLoopTest {
}
return false;
}
@Override
public void destroy() {
}
});
loop.getActors().add(new Actor() {
@@ -348,10 +343,6 @@ public class ActorSensorLoopTest {
}
return false;
}
@Override
public void destroy() {
}
});
loop.getSensors().add(s);

View File

@@ -128,8 +128,6 @@ public class ParallelCrlogicTest {
// Destroy scaler template
cservice.destroyAnnotatedChannels(scalertemplate);
pcrlogic.destroy();
}
}

View File

@@ -142,9 +142,6 @@ public class ScrlogicLoopTest {
}
}
logic.destroy();
}
}