Cleanup Crlogic code

This commit is contained in:
2013-10-14 16:42:00 +02:00
parent 2cba6e7991
commit 768ea9f254
8 changed files with 22 additions and 50 deletions
@@ -57,9 +57,12 @@ 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.cr.CrlogicLoop;
import ch.psi.fda.core.loops.cr.CrlogicResource;
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.OTFNamedChannelSensor;
import ch.psi.fda.core.loops.otf.OTFScalerChannelSensor;
import ch.psi.fda.core.loops.otf.TemplateOTF;
import ch.psi.fda.core.manipulator.JythonManipulation;
import ch.psi.fda.core.messages.DataMessageMetadata;
@@ -71,8 +74,6 @@ import ch.psi.fda.core.scripting.JythonParameterMappingGlobalVariable;
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.OTFScalerChannelSensor;
import ch.psi.fda.model.ModelManager;
import ch.psi.fda.model.v1.Action;
import ch.psi.fda.model.v1.ArrayDetector;
@@ -1092,17 +1093,17 @@ public class Acquisition {
// ATTENTION: the sequence of the mapping depends on the sequence in the schema file !
for(SimpleScalarDetector detector: dimension.getDetector()){
if(!detector.isScr()){
actionLoop.getSensors().add(new OTFNamedChannelSensor(detector.getId(), detector.getName()));
actionLoop.getSensors().add(new CrlogicResource(detector.getId(), detector.getName()));
}
}
for(ScalerChannel detector: dimension.getScaler()){
actionLoop.getSensors().add(new OTFScalerChannelSensor(detector.getId(), detector.getChannel()));
actionLoop.getSensors().add(new CrlogicResource(detector.getId(), "SCALER"+detector.getChannel(), true));
}
Timestamp tdetector = dimension.getTimestamp();
if(tdetector != null){
actionLoop.getSensors().add(new MillisecondTimestampSensor(tdetector.getId()));
actionLoop.getSensors().add(new CrlogicResource(tdetector.getId(), "TIMESTAMP"));
}
actionLoop.getPostActions().addAll(mapActions(dimension.getPostAction()));
@@ -37,16 +37,12 @@ import java.util.logging.Logger;
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.messages.ComponentMetadata;
import ch.psi.fda.core.messages.DataMessage;
import ch.psi.fda.core.messages.DataMessageMetadata;
import ch.psi.fda.core.messages.DataQueue;
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.OTFScalerChannelSensor;
import ch.psi.jcae.ChannelException;
import ch.psi.jcae.ChannelService;
@@ -60,7 +56,6 @@ import ch.psi.jcae.ChannelService;
*/
public class CrlogicLoop implements ActionLoop {
// Get Logger
private static final Logger logger = Logger.getLogger(CrlogicLoop.class.getName());
/**
@@ -75,8 +70,6 @@ public class CrlogicLoop implements ActionLoop {
private volatile boolean stopReadoutThread = false;
private Thread readoutThread;
// Constants
/**
* Default timeout (in milliseconds) for wait operations
*/
@@ -128,7 +121,7 @@ public class CrlogicLoop implements ActionLoop {
/**
* List of sensors of this loop
*/
private List<Sensor> sensors;
private List<CrlogicResource> sensors;
private List<String> readoutResources;
private Map<Integer, CrlogicDeltaDataFilter> scalerIndices;
@@ -170,7 +163,7 @@ public class CrlogicLoop implements ActionLoop {
// Initialize lists used by the loop
this.preActions = new ArrayList<Action>();
this.postActions = new ArrayList<Action>();
this.sensors = new ArrayList<Sensor>();
this.sensors = new ArrayList<>();
this.readoutResources = new ArrayList<String>();
this.scalerIndices = new HashMap<Integer, CrlogicDeltaDataFilter>();
@@ -740,23 +733,11 @@ public class CrlogicLoop implements ActionLoop {
scalerIndices.clear();
int c = 1; // We start at 1 because the actuator right now is an implicit sensor
for(Sensor s: sensors){
if(s instanceof OTFNamedChannelSensor){
// Monitored channel (MUST be configured MODULE ID'S)
OTFNamedChannelSensor so = (OTFNamedChannelSensor) s;
readoutResources.add(so.getName());
}
else if (s instanceof OTFScalerChannelSensor){
OTFScalerChannelSensor so = (OTFScalerChannelSensor) s;
readoutResources.add("SCALER"+so.getIndex());
for(CrlogicResource s: sensors){
readoutResources.add(s.getKey());
if(s.isDelta()){
scalerIndices.put(c, new CrlogicDeltaDataFilter());
}
else if (s instanceof MillisecondTimestampSensor){
readoutResources.add("TIMESTAMP");
}
else{
throw new IllegalArgumentException("Sensor type "+s.getClass()+" is not supported by this loop");
}
c++;
}
@@ -806,7 +787,7 @@ public class CrlogicLoop implements ActionLoop {
this.dataGroup = dataGroup;
}
public List<Sensor> getSensors() {
public List<CrlogicResource> getSensors() {
return sensors;
}
@@ -820,7 +801,7 @@ public class CrlogicLoop implements ActionLoop {
// Build up data message metadata based on the sensors currently registered.
m.getComponents().add(new ComponentMetadata(this.id));
for(Sensor s: sensors){
for(CrlogicResource s: sensors){
m.getComponents().add(new ComponentMetadata(s.getId()));
}
return new DataQueue(dataQueue, m);
@@ -34,12 +34,7 @@ import java.util.logging.Logger;
import ch.psi.fda.core.Action;
import ch.psi.fda.core.ActionLoop;
import ch.psi.fda.core.messages.DataQueue;
import ch.psi.fda.core.sensors.MillisecondTimestampSensor;
/**
* @author ebner
*
*/
public class ParallelCrlogic implements ActionLoop {
private static final Logger logger = Logger.getLogger(ParallelCrlogic.class.getName());
@@ -77,7 +72,7 @@ public class ParallelCrlogic implements ActionLoop {
this.crlogic = crlogic;
// Add timestamp to sensor at the beginning of the sensor list as this is required for merging the data
// Timestamp will be at the second position of a message in the queue!
this.crlogic.getSensors().add(0, new MillisecondTimestampSensor("tmp_timestamp"));
this.crlogic.getSensors().add(0, new CrlogicResource("tmp_timestamp","TIMESTAMP"));
this.scrlogic = scrlogic;
// Initialize lists used by the loop
@@ -39,8 +39,6 @@ import ch.psi.fda.core.messages.DataQueue;
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.OTFScalerChannelSensor;
/**
* ActionLoop that is implementing the OTF Scan logic.
@@ -17,7 +17,7 @@
*
*/
package ch.psi.fda.core.sensors;
package ch.psi.fda.core.loops.otf;
import ch.psi.fda.core.Sensor;
@@ -17,7 +17,7 @@
*
*/
package ch.psi.fda.core.sensors;
package ch.psi.fda.core.loops.otf;
import ch.psi.fda.core.Sensor;
@@ -35,14 +35,14 @@ import org.junit.Test;
import ch.psi.fda.TestConfiguration;
import ch.psi.fda.core.loops.otf.OTFLoop;
import ch.psi.fda.core.loops.otf.OTFNamedChannelSensor;
import ch.psi.fda.core.loops.otf.OTFScalerChannelSensor;
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.OTFScalerChannelSensor;
import ch.psi.jcae.Channel;
import ch.psi.jcae.ChannelDescriptor;
import ch.psi.jcae.ChannelException;
@@ -35,9 +35,6 @@ import org.junit.Test;
import ch.psi.fda.TestConfiguration;
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.OTFScalerChannelSensor;
import ch.psi.jcae.Channel;
import ch.psi.jcae.ChannelDescriptor;
import ch.psi.jcae.ChannelException;
@@ -92,10 +89,10 @@ public class ParallelCrlogicTest {
CrlogicLoop crlogic = new CrlogicLoop(cservice, c.getCrlogicPrefix(), c.getServer(), c.getShare(), c.getSmbShare(), zigZag);
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));
crlogic.getSensors().add(new MillisecondTimestampSensor("timestamp"));
crlogic.getSensors().add(new CrlogicResource("trigger", "TRIGGER0"));
crlogic.getSensors().add(new CrlogicResource("scaler0", "SCALER0", true));
crlogic.getSensors().add(new CrlogicResource("scaler1", "SCALER1", true));
crlogic.getSensors().add(new CrlogicResource("timestamp", "TIMESTAMP"));
// Initialize scaler template