Fixed remaining broken tests
This commit is contained in:
@@ -116,8 +116,10 @@ public class ScrlogicLoop implements ActionLoop {
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
DoubleTimestamp v = (DoubleTimestamp) evt.getNewValue();
|
||||
q.add(new TimestampedValue(v.getValue(), v.getTimestamp().getTime(), v.getNanosecondOffset()));
|
||||
if(evt.getPropertyName().equals("value")){
|
||||
DoubleTimestamp v = (DoubleTimestamp) evt.getNewValue();
|
||||
q.add(new TimestampedValue(v.getValue(), v.getTimestamp().getTime(), v.getNanosecondOffset()));
|
||||
}
|
||||
}
|
||||
};
|
||||
sensor.addPropertyChangeListener(listener);
|
||||
|
||||
@@ -162,10 +162,13 @@ public class OTFLoopTest {
|
||||
/**
|
||||
* Test method for {@link ch.psi.fda.core.loops.OTFLoop#execute()}.
|
||||
* Test abort functionality while executing an OTF scan
|
||||
* @throws ExecutionException
|
||||
* @throws ChannelException
|
||||
* @throws TimeoutException
|
||||
* @throws CAException
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteAbort() throws InterruptedException {
|
||||
public void testExecuteAbort() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
||||
|
||||
// Data collector thread
|
||||
Thread t = new Thread(new TestCollector(loop.getDataQueue().getQueue()));
|
||||
|
||||
@@ -19,12 +19,13 @@
|
||||
|
||||
package ch.psi.fda.core.loops.cr;
|
||||
|
||||
|
||||
import gov.aps.jca.CAException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -32,42 +33,38 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ch.psi.fda.TestConfiguration;
|
||||
import ch.psi.fda.core.Sensor;
|
||||
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.ChannelAccessDoubleSensor;
|
||||
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.ChannelBeanFactory;
|
||||
import ch.psi.jcae.Channel;
|
||||
import ch.psi.jcae.ChannelDescriptor;
|
||||
import ch.psi.jcae.ChannelException;
|
||||
import ch.psi.jcae.ChannelService;
|
||||
import ch.psi.jcae.impl.DefaultChannelService;
|
||||
import ch.psi.jcae.impl.type.DoubleTimestamp;
|
||||
|
||||
/**
|
||||
* @author ebner
|
||||
*
|
||||
*/
|
||||
public class ParallelCrlogicTest {
|
||||
|
||||
// Get Logger
|
||||
private static final Logger logger = Logger.getLogger(ParallelCrlogicTest.class.getName());
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
private ChannelService cservice;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
cservice = new DefaultChannelService();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
cservice.destroy();
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Test(timeout=60000)
|
||||
public void testExecute() throws InterruptedException, CAException{
|
||||
public void testExecute() throws InterruptedException, ChannelException, TimeoutException, ExecutionException{
|
||||
|
||||
TestConfiguration c = TestConfiguration.getInstance();
|
||||
|
||||
@@ -80,19 +77,21 @@ public class ParallelCrlogicTest {
|
||||
double integrationTime = 0.01;
|
||||
double additionalBacklash = 0;
|
||||
|
||||
List<Sensor> sensors = new ArrayList<Sensor>();
|
||||
ChannelAccessDoubleSensor s2 = new ChannelAccessDoubleSensor("mot1", c.getMotor1()+".RVAL");
|
||||
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor("mot2", c.getMotor1()+".RBV");
|
||||
ChannelAccessDoubleSensor s3 = new ChannelAccessDoubleSensor("mot2", "ARIDI-PCT:CURRENT");
|
||||
List<String> ids = new ArrayList<>();
|
||||
List<Channel<DoubleTimestamp>> sensors = new ArrayList<>();
|
||||
|
||||
sensors.add(s1);
|
||||
sensors.add(s2);
|
||||
sensors.add(s3);
|
||||
|
||||
ScrlogicLoop scrlogic = new ScrlogicLoop(sensors);
|
||||
ids.add("mot1");
|
||||
ids.add("mot2");
|
||||
ids.add("mot3");
|
||||
sensors.add(cservice.createChannel(new ChannelDescriptor<>(DoubleTimestamp.class, c.getMotor1()+".RVAL")));
|
||||
sensors.add(cservice.createChannel(new ChannelDescriptor<>(DoubleTimestamp.class, c.getMotor1()+".RBV")));
|
||||
sensors.add(cservice.createChannel(new ChannelDescriptor<>(DoubleTimestamp.class, "ARIDI-PCT:CURRENT")));
|
||||
|
||||
|
||||
CrlogicLoop crlogic = new CrlogicLoop(c.getCrlogicPrefix(), c.getServer(), c.getShare(), c.getSmbShare(), zigZag);
|
||||
ScrlogicLoop scrlogic = new ScrlogicLoop(ids, sensors);
|
||||
|
||||
|
||||
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.getSensors().add(new OTFNamedChannelSensor("trigger", "TRIGGER0"));
|
||||
crlogic.getSensors().add(new OTFScalerChannelSensor("scaler0", 0));
|
||||
@@ -102,7 +101,9 @@ public class ParallelCrlogicTest {
|
||||
|
||||
// Initialize scaler template
|
||||
VSC16ScalerChannelsTemplate scalertemplate = new VSC16ScalerChannelsTemplate();
|
||||
ChannelBeanFactory.getFactory().createChannelBeans(scalertemplate, c.getPrefixScaler());
|
||||
Map<String,String> macros = new HashMap<>();
|
||||
macros.put("PREFIX", c.getPrefixScaler());
|
||||
cservice.createAnnotatedChannels(scalertemplate, macros);
|
||||
|
||||
|
||||
ParallelCrlogic pcrlogic = new ParallelCrlogic(crlogic, scrlogic);
|
||||
@@ -126,27 +127,9 @@ public class ParallelCrlogicTest {
|
||||
}
|
||||
|
||||
// Destroy scaler template
|
||||
ChannelBeanFactory.getFactory().destroyChannelBeans(scalertemplate);
|
||||
cservice.destroyAnnotatedChannels(scalertemplate);
|
||||
|
||||
pcrlogic.destroy();
|
||||
|
||||
|
||||
// System.out.println("CRLOGIC data:");
|
||||
// BlockingQueue<Message> queue = crlogic.getDataQueue().getQueue();
|
||||
// Message m = queue.take();
|
||||
// while(! (m instanceof EndOfStreamMessage)){
|
||||
// System.out.println(m.toString());
|
||||
// m = queue.take();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// System.out.println("SCRLOGIC data:");
|
||||
// queue = scrlogic.getDataQueue().getQueue();
|
||||
// m = queue.take();
|
||||
// while(! (m instanceof EndOfStreamMessage)){
|
||||
// System.out.println(m.toString());
|
||||
// m = queue.take();
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,64 +19,70 @@
|
||||
|
||||
package ch.psi.fda.core.loops.cr;
|
||||
|
||||
import gov.aps.jca.CAException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ch.psi.fda.core.Sensor;
|
||||
import ch.psi.fda.core.messages.EndOfStreamMessage;
|
||||
import ch.psi.fda.core.messages.Message;
|
||||
import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
||||
import ch.psi.jcae.ChannelBean;
|
||||
import ch.psi.jcae.ChannelBeanFactory;
|
||||
import ch.psi.jcae.Channel;
|
||||
import ch.psi.jcae.ChannelDescriptor;
|
||||
import ch.psi.jcae.ChannelException;
|
||||
import ch.psi.jcae.ChannelService;
|
||||
import ch.psi.jcae.impl.DefaultChannelService;
|
||||
import ch.psi.jcae.impl.type.DoubleTimestamp;
|
||||
|
||||
/**
|
||||
* @author ebner
|
||||
*
|
||||
*/
|
||||
public class ScrlogicLoopTest {
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
private ChannelService cservice;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
cservice = new DefaultChannelService();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
cservice.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link ch.psi.fda.core.loops.cr.ScrlogicLoop#execute()}.
|
||||
* @throws InterruptedException
|
||||
* @throws TimeoutException
|
||||
* @throws ChannelException
|
||||
* @throws CAException
|
||||
*/
|
||||
@Test
|
||||
public void testExecute() throws InterruptedException, CAException {
|
||||
public void testExecute() throws InterruptedException, ChannelException, TimeoutException {
|
||||
|
||||
|
||||
|
||||
System.out.println("For this test the motor MTEST-HW3:MOT1 need to be moved manually");
|
||||
|
||||
List<Sensor> sensors = new ArrayList<Sensor>();
|
||||
ChannelAccessDoubleSensor s2 = new ChannelAccessDoubleSensor("mot1", "MTEST-HW3:MOT1.RBV");
|
||||
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor("mot2", "MTEST-HW3:MOT1");
|
||||
// List<Sensor> sensors = new ArrayList<Sensor>();
|
||||
// ChannelAccessDoubleSensor s2 = new ChannelAccessDoubleSensor("mot1", "MTEST-HW3:MOT1.RBV");
|
||||
// ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor("mot2", "MTEST-HW3:MOT1");
|
||||
|
||||
sensors.add(s1);
|
||||
sensors.add(s2);
|
||||
// sensors.add(s1);
|
||||
// sensors.add(s2);
|
||||
|
||||
final ScrlogicLoop logic = new ScrlogicLoop(sensors);
|
||||
List<String> ids = new ArrayList<>();
|
||||
List<Channel<DoubleTimestamp>> sensors = new ArrayList<>();
|
||||
|
||||
ids.add("mot1");
|
||||
ids.add("mot2");
|
||||
sensors.add(cservice.createChannel(new ChannelDescriptor<>(DoubleTimestamp.class, "MTEST-HW3:MOT1.RBV")));
|
||||
sensors.add(cservice.createChannel(new ChannelDescriptor<>(DoubleTimestamp.class, "MTEST-HW3:MOT1")));
|
||||
|
||||
|
||||
final ScrlogicLoop logic = new ScrlogicLoop(ids, sensors);
|
||||
|
||||
|
||||
for(int i=0;i<2;i++){
|
||||
@@ -104,7 +110,7 @@ public class ScrlogicLoopTest {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
ChannelBean<Double> channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, "MTEST-HW3:MOT1", false);
|
||||
Channel<Double> channel = cservice.createChannel(new ChannelDescriptor<>(Double.class, "MTEST-HW3:MOT1", false));
|
||||
// Wait some time until
|
||||
Thread.sleep(100);
|
||||
channel.setValue(1.5);
|
||||
|
||||
Reference in New Issue
Block a user