From 2cba6e79916ad5f094aaf4927a6eb270ab7ef25b Mon Sep 17 00:00:00 2001 From: Simon Ebner Date: Mon, 14 Oct 2013 16:10:54 +0200 Subject: [PATCH] Cleanup OTF scan --- .../main/java/ch/psi/fda/aq/Acquisition.java | 14 +-- .../ch/psi/fda/core/actors/OTFActuator.java | 99 ------------------- .../psi/fda/core/loops/ActorSensorLoop.java | 71 ------------- .../ch/psi/fda/core/loops/cr/CrlogicLoop.java | 69 ++++++------- .../core/loops/{ => otf}/DistributedFile.java | 6 +- .../psi/fda/core/loops/{ => otf}/OTFLoop.java | 72 +++++++------- .../fda/core/loops/{ => otf}/TemplateOTF.java | 2 +- .../fda/core/sensors/OTFReadbackSensor.java | 48 --------- .../fda/core/loops/DistributedFileTest.java | 17 ++-- .../ch/psi/fda/core/loops/OTFLoopTest.java | 23 ++--- .../core/loops/cr/ParallelCrlogicTest.java | 3 +- 11 files changed, 98 insertions(+), 326 deletions(-) delete mode 100644 ch.psi.fda/src/main/java/ch/psi/fda/core/actors/OTFActuator.java rename ch.psi.fda/src/main/java/ch/psi/fda/core/loops/{ => otf}/DistributedFile.java (98%) rename ch.psi.fda/src/main/java/ch/psi/fda/core/loops/{ => otf}/OTFLoop.java (90%) rename ch.psi.fda/src/main/java/ch/psi/fda/core/loops/{ => otf}/TemplateOTF.java (99%) delete mode 100644 ch.psi.fda/src/main/java/ch/psi/fda/core/sensors/OTFReadbackSensor.java diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java b/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java index 65885d9..5b338ec 100644 --- a/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java +++ b/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java @@ -52,16 +52,15 @@ import ch.psi.fda.core.actors.ChannelAccessLinearActuator; import ch.psi.fda.core.actors.ChannelAccessTableActuator; import ch.psi.fda.core.actors.ComplexActuator; import ch.psi.fda.core.actors.JythonFunction; -import ch.psi.fda.core.actors.OTFActuator; import ch.psi.fda.core.actors.PseudoActuatorSensor; import ch.psi.fda.core.guard.ChannelAccessGuard; import ch.psi.fda.core.guard.ChannelAccessGuardCondition; import ch.psi.fda.core.loops.ActorSensorLoop; -import ch.psi.fda.core.loops.TemplateOTF; -import ch.psi.fda.core.loops.OTFLoop; import ch.psi.fda.core.loops.cr.CrlogicLoop; import ch.psi.fda.core.loops.cr.ParallelCrlogic; import ch.psi.fda.core.loops.cr.ScrlogicLoop; +import ch.psi.fda.core.loops.otf.OTFLoop; +import ch.psi.fda.core.loops.otf.TemplateOTF; import ch.psi.fda.core.manipulator.JythonManipulation; import ch.psi.fda.core.messages.DataMessageMetadata; import ch.psi.fda.core.scripting.JythonGlobalVariable; @@ -73,7 +72,6 @@ import ch.psi.fda.core.scripting.JythonParameterMappingID; import ch.psi.fda.core.sensors.ChannelAccessSensor; import ch.psi.fda.core.sensors.MillisecondTimestampSensor; import ch.psi.fda.core.sensors.OTFNamedChannelSensor; -import ch.psi.fda.core.sensors.OTFReadbackSensor; import ch.psi.fda.core.sensors.OTFScalerChannelSensor; import ch.psi.fda.model.ModelManager; import ch.psi.fda.model.v1.Action; @@ -1031,10 +1029,7 @@ public class Acquisition { if(p.getAdditionalBacklash()!=null){ backlash = p.getAdditionalBacklash(); } - OTFActuator actor = new OTFActuator(p.getId(), p.getName(), p.getReadback(), p.getStart(), p.getEnd(), p.getStepSize(), p.getIntegrationTime(), backlash); - actionLoop.setActor(actor); - - actionLoop.getSensors().add(new OTFReadbackSensor(p.getId())); + actionLoop.setActuator(p.getId(), p.getName(), p.getReadback(), p.getStart(), p.getEnd(), p.getStepSize(), p.getIntegrationTime(), backlash); // Map sensors // ATTENTION: the sequence of the mapping depends on the sequence in the schema file ! @@ -1091,8 +1086,7 @@ public class Acquisition { if(p.getAdditionalBacklash()!=null){ backlash = p.getAdditionalBacklash(); } - OTFActuator actor = new OTFActuator(p.getId(), p.getName(), p.getReadback(), p.getStart(), p.getEnd(), p.getStepSize(), p.getIntegrationTime(), backlash); - actionLoop.setActor(actor); + actionLoop.setActuator(p.getId(), p.getName(), p.getReadback(), p.getStart(), p.getEnd(), p.getStepSize(), p.getIntegrationTime(), backlash); // Map sensors // ATTENTION: the sequence of the mapping depends on the sequence in the schema file ! diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/OTFActuator.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/OTFActuator.java deleted file mode 100644 index b6fb0af..0000000 --- a/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/OTFActuator.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * - * Copyright 2010 Paul Scherrer Institute. All rights reserved. - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This code is distributed in the hope that it will be useful, - * but without any warranty; without even the implied warranty of - * merchantability or fitness for a particular purpose. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this code. If not, see . - * - */ - -package ch.psi.fda.core.actors; - -import ch.psi.fda.core.Actor; - -/** - * Special actuator for the OTFLoop. This type of actor must not be used in any other - * type of loop than OTFLoop. If it is used it will, depending on the loop, immediately stop the loop - * as it no single step. - */ -public class OTFActuator implements Actor { - - private final String id; - private final String name; // name of the motor channel - private final String readback; // name of the encoder channel - private double start; - private double end; - private final double stepSize; - private final double integrationTime; - private final double additionalBacklash; - - - public OTFActuator(String id, String name, String readback, double start, double end, double stepSize, double integrationTime, double additionalBacklash){ - this.id = id; - this.name = name; - this.readback = readback; - this.start = start; - this.end = end; - this.stepSize = stepSize; - this.integrationTime = integrationTime; - this.additionalBacklash = additionalBacklash; - } - - @Override - public void set() { - } - - @Override - public boolean hasNext() { - return false; - } - @Override - public void init() { - } - - @Override - public void reverse() { - double aend = end; - end=start; - start=aend; - } - - @Override - public void reset() { - } - - public String getName() { - return name; - } - public String getReadback() { - return readback; - } - public double getStart() { - return start; - } - public double getEnd() { - return end; - } - public double getStepSize() { - return stepSize; - } - public double getIntegrationTime() { - return integrationTime; - } - public double getAdditionalBacklash() { - return additionalBacklash; - } - public String getId() { - return id; - } -} 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 314817d..844d6c5 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 @@ -49,7 +49,6 @@ import ch.psi.fda.core.messages.Message; */ public class ActorSensorLoop implements ActionLoop { - // Get Logger private static Logger logger = Logger.getLogger(ActorSensorLoop.class.getName()); /** @@ -120,16 +119,10 @@ public class ActorSensorLoop implements ActionLoop { private List pactors; - /** - * Default constructor - */ public ActorSensorLoop(){ this(false); } - /** - * Create instance of the - */ public ActorSensorLoop(boolean zigZag){ this.zigZag = zigZag; this.actionLoops = new ArrayList(); @@ -148,9 +141,6 @@ public class ActorSensorLoop implements ActionLoop { } - /* (non-Javadoc) - * @see ch.psi.fda.engine.ActionLoop#execute() - */ /** * Executes the actor sensor loop. The actor sensor loop is build up as follows: * preActions @@ -353,9 +343,6 @@ public class ActorSensorLoop implements ActionLoop { } - /* (non-Javadoc) - * @see ch.psi.fda.engine.ActionLoop#abort() - */ @Override public void abort(){ abort = true; @@ -372,9 +359,6 @@ public class ActorSensorLoop implements ActionLoop { } } - /* (non-Javadoc) - * @see ch.psi.fda.core.ActionLoop#prepare() - */ @Override public void prepare() { // Put in prepare code here @@ -396,10 +380,6 @@ public class ActorSensorLoop implements ActionLoop { } } - - /* (non-Javadoc) - * @see ch.psi.fda.core.ActionLoop#cleanup() - */ @Override public void cleanup() { // Put in cleanup code here @@ -436,89 +416,38 @@ public class ActorSensorLoop implements ActionLoop { return new DataQueue(dataQueue, m); } - // Getter functions for variable parts - /** - * @return the actionLoops - */ public List getActionLoops() { return actionLoops; } - - - /** - * @return the preActorActions - */ public List getPreActorActions() { return preActorActions; } - - - /** - * @return the postActorActions - */ public List getPostActorActions() { return postActorActions; } - - - /** - * @return the preSensorActions - */ public List getPreSensorActions() { return preSensorActions; } - - - /** - * @return the postSensorActions - */ public List getPostSensorActions() { return postSensorActions; } - - - /** - * @return the actors - */ public List getActors() { return actors; } - - - /** - * @return the sensors - */ public List getSensors() { return sensors; } - - /** - * @return the guard - */ public Guard getGuard() { return guard; } - - /** - * @param guard the guard to set - */ public void setGuard(Guard guard) { this.guard = guard; } - - /** - * @return the dataGroup - */ public boolean isDataGroup() { return dataGroup; } - - /** - * @param dataGroup the dataGroup to set - */ public void setDataGroup(boolean dataGroup) { this.dataGroup = dataGroup; } - } diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicLoop.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicLoop.java index 1daaee0..a7a1462 100644 --- a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicLoop.java +++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicLoop.java @@ -38,7 +38,6 @@ import jcifs.smb.SmbFile; import ch.psi.fda.core.Action; import ch.psi.fda.core.ActionLoop; import ch.psi.fda.core.Sensor; -import ch.psi.fda.core.actors.OTFActuator; import ch.psi.fda.core.messages.ComponentMetadata; import ch.psi.fda.core.messages.DataMessage; import ch.psi.fda.core.messages.DataMessageMetadata; @@ -126,11 +125,6 @@ public class CrlogicLoop implements ActionLoop { */ private Semaphore semaphore = new Semaphore(1); - /** - * Special OTF Actuator - */ - private OTFActuator actuator = null; - /** * List of sensors of this loop */ @@ -156,6 +150,15 @@ public class CrlogicLoop implements ActionLoop { private final ChannelService cservice; + private String id; + private String name; // name of the motor channel + private String readback; // name of the encoder channel + private double start; + private double end; + private double stepSize; + private double integrationTime; + private double additionalBacklash; + public CrlogicLoop(ChannelService cservice, String prefix, String server, String share, String smbShare, boolean zigZag){ this.cservice = cservice; this.prefix = prefix; @@ -175,7 +178,18 @@ public class CrlogicLoop implements ActionLoop { this.dataQueue = new LinkedBlockingQueue(2000); } - + public void setActuator(String id, String name, String readback, double start, double end, double stepSize, double integrationTime, double additionalBacklash){ + this.id = id; + this.name = name; + this.readback = readback; + this.start = start; + this.end = end; + this.stepSize = stepSize; + this.integrationTime = integrationTime; + this.additionalBacklash = additionalBacklash; + } + + /** * Collect data from share * @param tmpFileName Name of the temporary file @@ -323,15 +337,9 @@ public class CrlogicLoop implements ActionLoop { public void execute() throws InterruptedException { try{ - double stepSize = actuator.getStepSize(); - double start = actuator.getStart(); - double end = actuator.getEnd(); - double integrationTime = actuator.getIntegrationTime(); - double ubacklash = actuator.getAdditionalBacklash(); - // Set values for the datafilter - crlogicDataFilter.setStart(actuator.getStart()); - crlogicDataFilter.setEnd(actuator.getEnd()); + crlogicDataFilter.setStart(start); + crlogicDataFilter.setEnd(end); // Reset data filter for(Integer k: scalerIndices.keySet()){ @@ -461,7 +469,7 @@ public class CrlogicLoop implements ActionLoop { // TODO Calculate and set motor speed, backlash, etc. double motorSpeed = stepSize/integrationTime; - double backlash = (0.5*motorSpeed*motortemplate.getAccelerationTime().getValue())+motorBacklash+ubacklash; + double backlash = (0.5*motorSpeed*motortemplate.getAccelerationTime().getValue())+motorBacklash+additionalBacklash; double realEnd = end+(backlash*direction); double realStart = start-(backlash*direction); @@ -569,7 +577,10 @@ public class CrlogicLoop implements ActionLoop { readQueue.put(tmpFileName); if(zigZag){ - actuator.reverse(); + // reverse start/end + double aend = end; + end=start; + start=aend; } synchronized(this){ @@ -638,7 +649,7 @@ public class CrlogicLoop implements ActionLoop { // Connect motor channels motortemplate = new TemplateMotor(); map = new HashMap<>(); - map.put("PREFIX", actuator.getName()); + map.put("PREFIX", this.name); cservice.createAnnotatedChannels(motortemplate, map); useReadback = motortemplate.getUseReadback().getValue(); @@ -655,20 +666,20 @@ public class CrlogicLoop implements ActionLoop { // Determine mode of motor if((!useReadback) && (!useEncoder)){ // Open loop - if(actuator.getReadback()!=null){ + if(this.readback!=null){ throw new IllegalArgumentException("Readback not supported if motor is configured in open loop"); } else{ - readoutResources.add(actuator.getName()); + readoutResources.add(this.name); } } else if(useReadback && (!useEncoder)){ String readback; // use readback link - if(actuator.getReadback()!=null){ + if(this.readback!=null){ // Use specified readback - readback = (actuator.getReadback()); + readback = this.readback; } else{ // Set resouce to readback link @@ -701,12 +712,12 @@ public class CrlogicLoop implements ActionLoop { } else if (useEncoder && (!useReadback)){ // use readback link - if(actuator.getReadback()!=null){ + if(this.readback!=null){ throw new IllegalArgumentException("Readback not supported if motor is configured to use encoder"); } else{ // Set resouce to readback link - readoutResources.add(actuator.getName()+"_ENC"); + readoutResources.add(this.name+"_ENC"); } } else{ @@ -799,14 +810,6 @@ public class CrlogicLoop implements ActionLoop { return sensors; } - public OTFActuator getActor() { - return actuator; - } - - public void setActor(OTFActuator actor) { - this.actuator = actor; - } - /** * The structure of the data message depends on the sensors registered at this loop * at the time this method is called. @@ -816,7 +819,7 @@ public class CrlogicLoop implements ActionLoop { DataMessageMetadata m = new DataMessageMetadata(); // Build up data message metadata based on the sensors currently registered. - m.getComponents().add(new ComponentMetadata(actuator.getId())); + m.getComponents().add(new ComponentMetadata(this.id)); for(Sensor s: sensors){ m.getComponents().add(new ComponentMetadata(s.getId())); } diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/DistributedFile.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/otf/DistributedFile.java similarity index 98% rename from ch.psi.fda/src/main/java/ch/psi/fda/core/loops/DistributedFile.java rename to ch.psi.fda/src/main/java/ch/psi/fda/core/loops/otf/DistributedFile.java index 6318148..2c2c384 100644 --- a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/DistributedFile.java +++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/otf/DistributedFile.java @@ -16,7 +16,7 @@ * along with this code. If not, see . * */ -package ch.psi.fda.core.loops; +package ch.psi.fda.core.loops.otf; import java.io.File; import java.io.FileReader; @@ -26,10 +26,6 @@ import java.net.MalformedURLException; import jcifs.smb.SmbFile; -/** - * @author ebner - * - */ public class DistributedFile { private SmbFile smbfile = null; diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/OTFLoop.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/otf/OTFLoop.java similarity index 90% rename from ch.psi.fda/src/main/java/ch/psi/fda/core/loops/OTFLoop.java rename to ch.psi.fda/src/main/java/ch/psi/fda/core/loops/otf/OTFLoop.java index 07cc944..3459e4f 100644 --- a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/OTFLoop.java +++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/otf/OTFLoop.java @@ -17,7 +17,7 @@ * */ -package ch.psi.fda.core.loops; +package ch.psi.fda.core.loops.otf; import java.io.BufferedReader; import java.io.IOException; @@ -32,7 +32,6 @@ import java.util.logging.Logger; import ch.psi.fda.core.Action; import ch.psi.fda.core.ActionLoop; import ch.psi.fda.core.Sensor; -import ch.psi.fda.core.actors.OTFActuator; import ch.psi.fda.core.messages.ComponentMetadata; import ch.psi.fda.core.messages.DataMessage; import ch.psi.fda.core.messages.DataMessageMetadata; @@ -41,18 +40,14 @@ import ch.psi.fda.core.messages.EndOfStreamMessage; import ch.psi.fda.core.messages.Message; import ch.psi.fda.core.sensors.MillisecondTimestampSensor; import ch.psi.fda.core.sensors.OTFNamedChannelSensor; -import ch.psi.fda.core.sensors.OTFReadbackSensor; import ch.psi.fda.core.sensors.OTFScalerChannelSensor; /** * ActionLoop that is implementing the OTF Scan logic. * While executing the loop a full OTF scan procedure is executed. - * @author ebner - * */ public class OTFLoop implements ActionLoop { - // Get Logger private static Logger logger = Logger.getLogger(OTFLoop.class.getName()); /** @@ -61,7 +56,6 @@ public class OTFLoop implements ActionLoop { */ private boolean dataGroup = false; - // Constants /** * Maximum number of monitored channels */ @@ -108,11 +102,6 @@ public class OTFLoop implements ActionLoop { */ private List postActions; - /** - * Special OTF Actuator - */ - private OTFActuator actor = null; - /** * List of sensors of this loop */ @@ -138,8 +127,18 @@ public class OTFLoop implements ActionLoop { */ private volatile boolean abort = false; + + private String id; + private String name; // name of the motor channel + private String readback; // name of the encoder channel + private double start; + private double end; + private double stepSize; + private double integrationTime; + private double additionalBacklash; + + /** - * Constructor * @param channelPrefix Prefix of the OTF related records, e.g. MTEST-HW3-OTF * @param server NFS server the OTF C Logic should put its data to * @param share Share on NFS server to put the OTF C Logic data @@ -164,6 +163,18 @@ public class OTFLoop implements ActionLoop { this.dataQueue = new LinkedBlockingQueue(2000); } + public void setActuator(String id, String name, String readback, double start, double end, double stepSize, double integrationTime, double additionalBacklash){ + this.id = id; + this.name = name; + this.readback = readback; + this.start = start; + this.end = end; + this.stepSize = stepSize; + this.integrationTime = integrationTime; + this.additionalBacklash = additionalBacklash; + } + + /* (non-Javadoc) * @see ch.psi.fda.core.Action#execute() */ @@ -218,14 +229,10 @@ public class OTFLoop implements ActionLoop { // Set abort flag to false abort=false; - // Check whether actor is set for the loop - if(actor == null){ - throw new IllegalStateException("No actor specified for this loop"); - } - // list with all monitored channels List monitoredChannels = new ArrayList(); dataIndexes = new ArrayList(); + dataIndexes.add(1); // The first one is always the readback of the motor int channelCount =0; for(Sensor s: sensors){ if(s instanceof OTFNamedChannelSensor){ @@ -251,9 +258,9 @@ public class OTFLoop implements ActionLoop { else if (s instanceof MillisecondTimestampSensor){ dataIndexes.add(2+numberOfScalerChannels+numberOfMonitoredChannels); } - else if (s instanceof OTFReadbackSensor){ - dataIndexes.add(1); - } +// else if (s instanceof OTFReadbackSensor){ +// dataIndexes.add(1); +// } else{ throw new IllegalArgumentException("Sensor type "+s.getClass()+" is not supported by this loop"); } @@ -264,23 +271,23 @@ public class OTFLoop implements ActionLoop { obean.resetToDefaults(); // Set actor properties - obean.setMotor(actor.getName()); + obean.setMotor(this.name); obean.waitUntilMotorOk(timeout); - obean.setBegin(actor.getStart()); - obean.setEnd(actor.getEnd()); - obean.setStepSize(actor.getStepSize()); - obean.setIntegrationTime(actor.getIntegrationTime()); + obean.setBegin(this.start); + obean.setEnd(this.end); + obean.setStepSize(this.stepSize); + obean.setIntegrationTime(this.integrationTime); // Override encoder if specified - if(actor.getReadback()!=null){ + if(this.readback!=null){ obean.setUseEncoder(true); - obean.setEncoder(actor.getReadback()); + obean.setEncoder(this.readback); obean.waitUntilEncoderOk(timeout); } // Set user backlash - obean.setUserBacklash(actor.getAdditionalBacklash()); + obean.setUserBacklash(this.additionalBacklash); // NFS settings @@ -348,6 +355,7 @@ public class OTFLoop implements ActionLoop { */ public DataQueue getDataQueue() { DataMessageMetadata m = new DataMessageMetadata(); + m.getComponents().add(new ComponentMetadata(id)); // Id of the readback of the motor // Build up data message metadata based on the sensors currently registered. for(Sensor s: sensors){ @@ -441,12 +449,6 @@ public class OTFLoop implements ActionLoop { public List getSensors() { return sensors; } - public OTFActuator getActor() { - return actor; - } - public void setActor(OTFActuator actor) { - this.actor = actor; - } public boolean isDataGroup() { return dataGroup; } diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/TemplateOTF.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/otf/TemplateOTF.java similarity index 99% rename from ch.psi.fda/src/main/java/ch/psi/fda/core/loops/TemplateOTF.java rename to ch.psi.fda/src/main/java/ch/psi/fda/core/loops/otf/TemplateOTF.java index 3d51297..427c4b6 100644 --- a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/TemplateOTF.java +++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/otf/TemplateOTF.java @@ -17,7 +17,7 @@ * */ -package ch.psi.fda.core.loops; +package ch.psi.fda.core.loops.otf; import java.util.List; import java.util.concurrent.ExecutionException; diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/sensors/OTFReadbackSensor.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/sensors/OTFReadbackSensor.java deleted file mode 100644 index 9b9cdb0..0000000 --- a/ch.psi.fda/src/main/java/ch/psi/fda/core/sensors/OTFReadbackSensor.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - * Copyright 2010 Paul Scherrer Institute. All rights reserved. - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This code is distributed in the hope that it will be useful, - * but without any warranty; without even the implied warranty of - * merchantability or fitness for a particular purpose. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this code. If not, see . - * - */ - -package ch.psi.fda.core.sensors; - -import ch.psi.fda.core.Sensor; - -/** - * Sensor to read actuator readback. This sensor must only be used within the - * OTFLoop. If it is used in other loops, the read value will always be 0. - * @author ebner - * - */ -public class OTFReadbackSensor implements Sensor { - - private final String id; - - public OTFReadbackSensor(String id){ - this.id = id; - } - - @Override - public Object read() { - // Always return 0 if read() method is called. - return 0d; - } - - @Override - public String getId() { - return id; - } -} diff --git a/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/DistributedFileTest.java b/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/DistributedFileTest.java index d64fbb0..958fbb8 100644 --- a/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/DistributedFileTest.java +++ b/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/DistributedFileTest.java @@ -28,6 +28,7 @@ import org.junit.Before; import org.junit.Test; import ch.psi.fda.TestConfiguration; +import ch.psi.fda.core.loops.otf.DistributedFile; /** * @author ebner @@ -58,7 +59,7 @@ public class DistributedFileTest { } /** - * Test method for {@link ch.psi.fda.core.loops.DistributedFile#getCanonicalPath()}. + * Test method for {@link ch.psi.fda.core.loops.otf.DistributedFile#getCanonicalPath()}. * @throws IOException */ @Test @@ -68,7 +69,7 @@ public class DistributedFileTest { } /** - * Test method for {@link ch.psi.fda.core.loops.DistributedFile#exists()}. + * Test method for {@link ch.psi.fda.core.loops.otf.DistributedFile#exists()}. * @throws IOException */ @Test @@ -82,7 +83,7 @@ public class DistributedFileTest { } /** - * Test method for {@link ch.psi.fda.core.loops.DistributedFile#isDirectory()}. + * Test method for {@link ch.psi.fda.core.loops.otf.DistributedFile#isDirectory()}. * @throws IOException */ @Test @@ -96,7 +97,7 @@ public class DistributedFileTest { } /** - * Test method for {@link ch.psi.fda.core.loops.DistributedFile#listFiles()}. + * Test method for {@link ch.psi.fda.core.loops.otf.DistributedFile#listFiles()}. */ @Test public void testListFiles() { @@ -104,7 +105,7 @@ public class DistributedFileTest { } /** - * Test method for {@link ch.psi.fda.core.loops.DistributedFile#getName()}. + * Test method for {@link ch.psi.fda.core.loops.otf.DistributedFile#getName()}. */ @Test public void testGetName() { @@ -113,7 +114,7 @@ public class DistributedFileTest { } /** - * Test method for {@link ch.psi.fda.core.loops.DistributedFile#isFile()}. + * Test method for {@link ch.psi.fda.core.loops.otf.DistributedFile#isFile()}. * @throws IOException */ @Test @@ -127,7 +128,7 @@ public class DistributedFileTest { } /** - * Test method for {@link ch.psi.fda.core.loops.DistributedFile#delete()}. + * Test method for {@link ch.psi.fda.core.loops.otf.DistributedFile#delete()}. */ @Test public void testDelete() { @@ -135,7 +136,7 @@ public class DistributedFileTest { } /** - * Test method for {@link ch.psi.fda.core.loops.DistributedFile#getInputStream()}. + * Test method for {@link ch.psi.fda.core.loops.otf.DistributedFile#getInputStream()}. */ @Test public void testGetInputStream() { diff --git a/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/OTFLoopTest.java b/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/OTFLoopTest.java index 0bfee22..cd6cc53 100644 --- a/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/OTFLoopTest.java +++ b/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/OTFLoopTest.java @@ -34,15 +34,14 @@ import org.junit.Before; import org.junit.Test; import ch.psi.fda.TestConfiguration; -import ch.psi.fda.core.actors.OTFActuator; -import ch.psi.fda.core.loops.OTFLoop; +import ch.psi.fda.core.loops.otf.OTFLoop; +import ch.psi.fda.core.loops.otf.TemplateOTF; import ch.psi.fda.core.messages.ControlMessage; import ch.psi.fda.core.messages.DataMessage; import ch.psi.fda.core.messages.DataMessageMetadata; import ch.psi.fda.core.messages.Message; import ch.psi.fda.core.sensors.MillisecondTimestampSensor; import ch.psi.fda.core.sensors.OTFNamedChannelSensor; -import ch.psi.fda.core.sensors.OTFReadbackSensor; import ch.psi.fda.core.sensors.OTFScalerChannelSensor; import ch.psi.jcae.Channel; import ch.psi.jcae.ChannelDescriptor; @@ -70,8 +69,6 @@ public class OTFLoopTest { cservice = new DefaultChannelService(); statusChannel = cservice.createChannel(new ChannelDescriptor<>(Integer.class, configuration.getOtfPrefix()+":USTAT")); - OTFActuator actor = new OTFActuator("id", configuration.getMotor1(), null, 0, 8, 0.5, 0.5, 0); - OTFReadbackSensor s1 = new OTFReadbackSensor("id0"); OTFScalerChannelSensor s2 = new OTFScalerChannelSensor("id1", 0); OTFScalerChannelSensor s3 = new OTFScalerChannelSensor("id2", 1); MillisecondTimestampSensor s4 = new MillisecondTimestampSensor("id3"); @@ -85,8 +82,7 @@ public class OTFLoopTest { // ZigZag loop loopZigZag = new OTFLoop(template, configuration.getServer(), configuration.getShare(), configuration.getSmbShare(), true); - loopZigZag.setActor(actor); - loopZigZag.getSensors().add(s1); + loopZigZag.setActuator("id0", configuration.getMotor1(), null, 0, 8, 0.5, 0.5, 0); loopZigZag.getSensors().add(s2); loopZigZag.getSensors().add(s3); loopZigZag.getSensors().add(s4); @@ -95,8 +91,7 @@ public class OTFLoopTest { // Normal loop loop = new OTFLoop(template, configuration.getServer(), configuration.getShare(), configuration.getSmbShare(), false); - loop.setActor(actor); - loop.getSensors().add(s1); + loop.setActuator("id0", configuration.getMotor1(), null, 0, 8, 0.5, 0.5, 0); loop.getSensors().add(s2); loop.getSensors().add(s3); loop.getSensors().add(s4); @@ -109,7 +104,7 @@ public class OTFLoopTest { } /** - * Test method for {@link ch.psi.fda.core.loops.OTFLoop#execute()}. + * Test method for {@link ch.psi.fda.core.loops.otf.OTFLoop#execute()}. * Test ordinary 1D OTF scan * @throws ExecutionException * @throws ChannelException @@ -134,7 +129,7 @@ public class OTFLoopTest { } /** - * Test method for {@link ch.psi.fda.core.loops.OTFLoop#execute()}. + * Test method for {@link ch.psi.fda.core.loops.otf.OTFLoop#execute()}. * Test OTF ZigZag mode * @throws ExecutionException * @throws ChannelException @@ -160,7 +155,7 @@ public class OTFLoopTest { } /** - * Test method for {@link ch.psi.fda.core.loops.OTFLoop#execute()}. + * Test method for {@link ch.psi.fda.core.loops.otf.OTFLoop#execute()}. * Test abort functionality while executing an OTF scan * @throws ExecutionException * @throws ChannelException @@ -240,10 +235,10 @@ public class OTFLoopTest { Message m = queue.take(); if(m instanceof DataMessage){ DataMessage x = (DataMessage) m; - logger.fine( x.toString() ); + logger.info( x.toString() ); } else if(m instanceof ControlMessage){ - logger.fine("---- "+m.toString()+" ----"); + logger.info("---- "+m.toString()+" ----"); } } } catch (InterruptedException e) { diff --git a/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/cr/ParallelCrlogicTest.java b/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/cr/ParallelCrlogicTest.java index fc94893..4f6575f 100644 --- a/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/cr/ParallelCrlogicTest.java +++ b/ch.psi.fda/src/test/java/ch/psi/fda/core/loops/cr/ParallelCrlogicTest.java @@ -33,7 +33,6 @@ import org.junit.Before; import org.junit.Test; import ch.psi.fda.TestConfiguration; -import ch.psi.fda.core.actors.OTFActuator; import ch.psi.fda.core.messages.EndOfStreamMessage; import ch.psi.fda.core.messages.Message; import ch.psi.fda.core.sensors.MillisecondTimestampSensor; @@ -92,7 +91,7 @@ public class ParallelCrlogicTest { CrlogicLoop crlogic = new CrlogicLoop(cservice, c.getCrlogicPrefix(), c.getServer(), c.getShare(), c.getSmbShare(), zigZag); - crlogic.setActor(new OTFActuator("cmot", c.getMotor1(), readback, start, end, stepSize, integrationTime, additionalBacklash)); + crlogic.setActuator("cmot", c.getMotor1(), readback, start, end, stepSize, integrationTime, additionalBacklash); crlogic.getSensors().add(new OTFNamedChannelSensor("trigger", "TRIGGER0")); crlogic.getSensors().add(new OTFScalerChannelSensor("scaler0", 0)); crlogic.getSensors().add(new OTFScalerChannelSensor("scaler1", 1));