Compare commits
8 Commits
2.x.experi
...
1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b9ee77f76 | |||
| 81af4449dc | |||
| 858d8dbd45 | |||
| 879ec1d657 | |||
| 3025f597c0 | |||
| 73107a4799 | |||
| a5da9a2527 | |||
| 21d935e35e |
@@ -28,7 +28,7 @@
|
|||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
org.eclipse.jdt.core.compiler.source=1.7
|
org.eclipse.jdt.core.compiler.source=1.6
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>ch.psi</groupId>
|
<groupId>ch.psi</groupId>
|
||||||
<artifactId>fda</artifactId>
|
<artifactId>fda</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>1.1.40</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.psi</groupId>
|
<groupId>ch.psi</groupId>
|
||||||
<artifactId>jcae</artifactId>
|
<artifactId>jcae</artifactId>
|
||||||
<version>2.1.11</version>
|
<version>1.0.30</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Plotting library -->
|
<!-- Plotting library -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -32,7 +32,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.python</groupId>
|
<groupId>org.python</groupId>
|
||||||
<artifactId>jython</artifactId>
|
<artifactId>jython</artifactId>
|
||||||
<!-- <artifactId>jython-standalone</artifactId> -->
|
|
||||||
<version>2.5.3</version>
|
<version>2.5.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- CLI Libraries -->
|
<!-- CLI Libraries -->
|
||||||
@@ -59,51 +58,13 @@
|
|||||||
<artifactId>freehep-xdr</artifactId>
|
<artifactId>freehep-xdr</artifactId>
|
||||||
<version>2.0.4</version>
|
<version>2.0.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- JUnit test library -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.inject</groupId>
|
|
||||||
<artifactId>guice</artifactId>
|
|
||||||
<version>3.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<version>14.0.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<scope>test</scope>
|
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.11</version>
|
<version>4.8.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- For Testing NG functionality purposes -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.glassfish.jersey.containers</groupId>
|
|
||||||
<artifactId>jersey-container-grizzly2-http</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
|
||||||
<artifactId>jersey-media-sse</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
|
||||||
<artifactId>jersey-media-json-jackson</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-cli</groupId>
|
|
||||||
<artifactId>commons-cli</artifactId>
|
|
||||||
<version>1.2</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -112,8 +73,8 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.6</source>
|
||||||
<target>1.7</target>
|
<target>1.6</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Generate Javadoc Jar -->
|
<!-- Generate Javadoc Jar -->
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package ch.psi.fda.aq;
|
package ch.psi.fda.aq;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
@@ -35,8 +37,6 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.logging.SimpleFormatter;
|
import java.util.logging.SimpleFormatter;
|
||||||
|
|
||||||
import ch.psi.fda.aq.ng.AcquisitionEngineNG;
|
|
||||||
import ch.psi.fda.aq.ng.ScanMapperNG;
|
|
||||||
import ch.psi.fda.core.ActionLoop;
|
import ch.psi.fda.core.ActionLoop;
|
||||||
import ch.psi.fda.core.Actor;
|
import ch.psi.fda.core.Actor;
|
||||||
import ch.psi.fda.core.EngineConfiguration;
|
import ch.psi.fda.core.EngineConfiguration;
|
||||||
@@ -118,8 +118,7 @@ import ch.psi.fda.model.v1.Variable;
|
|||||||
import ch.psi.fda.model.v1.VariableParameterMapping;
|
import ch.psi.fda.model.v1.VariableParameterMapping;
|
||||||
import ch.psi.fda.notification.NotificationAgent;
|
import ch.psi.fda.notification.NotificationAgent;
|
||||||
import ch.psi.fda.serializer.DataSerializerTXT;
|
import ch.psi.fda.serializer.DataSerializerTXT;
|
||||||
import ch.psi.jcae.ChannelService;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data acquisition engine for performing scans
|
* Data acquisition engine for performing scans
|
||||||
@@ -129,8 +128,6 @@ import ch.psi.jcae.impl.DefaultChannelService;
|
|||||||
*/
|
*/
|
||||||
public class Acquisition {
|
public class Acquisition {
|
||||||
|
|
||||||
private static boolean NEW_ENGINE = true;
|
|
||||||
|
|
||||||
// Get Logger
|
// Get Logger
|
||||||
private static Logger logger = Logger.getLogger(Acquisition.class.getName());
|
private static Logger logger = Logger.getLogger(Acquisition.class.getName());
|
||||||
|
|
||||||
@@ -138,8 +135,6 @@ public class Acquisition {
|
|||||||
|
|
||||||
private ActionLoop actionLoop;
|
private ActionLoop actionLoop;
|
||||||
private Collector collector;
|
private Collector collector;
|
||||||
private ScanMapperNG mapper;
|
|
||||||
private AcquisitionEngineNG acquisitionEngine;
|
|
||||||
private DataDispatcher dispatcher;
|
private DataDispatcher dispatcher;
|
||||||
private Manipulator manipulator;
|
private Manipulator manipulator;
|
||||||
private DataSerializerTXT serializer;
|
private DataSerializerTXT serializer;
|
||||||
@@ -151,8 +146,6 @@ public class Acquisition {
|
|||||||
|
|
||||||
private Handler logHandler = null;
|
private Handler logHandler = null;
|
||||||
|
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the datafile
|
* Name of the datafile
|
||||||
*/
|
*/
|
||||||
@@ -188,9 +181,7 @@ public class Acquisition {
|
|||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
public DataQueue initalize(Configuration smodel, boolean getQueue) {
|
public DataQueue initalize(Configuration smodel, boolean getQueue) {
|
||||||
|
|
||||||
cservice = new DefaultChannelService();
|
|
||||||
|
|
||||||
// Create notification agent with globally configured recipients
|
// Create notification agent with globally configured recipients
|
||||||
notificationAgent = new NotificationAgent(configuration.getSmptServer(), "fda.notification@psi.ch");
|
notificationAgent = new NotificationAgent(configuration.getSmptServer(), "fda.notification@psi.ch");
|
||||||
|
|
||||||
@@ -246,29 +237,20 @@ public class Acquisition {
|
|||||||
// Configure core engine
|
// Configure core engine
|
||||||
EngineConfiguration.getInstance().setFailOnSensorError(smodel.isFailOnSensorError());
|
EngineConfiguration.getInstance().setFailOnSensorError(smodel.isFailOnSensorError());
|
||||||
|
|
||||||
if(NEW_ENGINE){
|
|
||||||
acquisitionEngine = new AcquisitionEngineNG(cservice);
|
|
||||||
mapper = new ScanMapperNG();
|
|
||||||
mapper.map(smodel);
|
|
||||||
|
|
||||||
this.manipulator = new Manipulator(new DataQueue( acquisitionEngine.getOutQueue(), mapper.getDataMessageMetadata()), this.manipulations);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
logger.fine("Map Model to internal logic");
|
|
||||||
|
|
||||||
// Map scan to base model
|
|
||||||
// After this call actionLoop and collector will be initialized
|
|
||||||
mapScan(smodel);
|
|
||||||
|
|
||||||
logger.fine("ActionLoop and Collector initialized");
|
|
||||||
|
|
||||||
// TODO Remove this workaround
|
|
||||||
Collections.reverse(collector.getQueues());
|
|
||||||
|
|
||||||
// Add manipulator into processing chain
|
|
||||||
this.manipulator = new Manipulator(collector.getOutQueue(), this.manipulations);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
logger.fine("Map Model to internal logic");
|
||||||
|
|
||||||
|
// Map scan to base model
|
||||||
|
// After this call actionLoop and collector will be initialized
|
||||||
|
mapScan(smodel);
|
||||||
|
|
||||||
|
logger.fine("ActionLoop and Collector initialized");
|
||||||
|
|
||||||
|
// TODO Remove this workaround
|
||||||
|
Collections.reverse(collector.getQueues());
|
||||||
|
|
||||||
|
// Add manipulator into processing chain
|
||||||
|
this.manipulator = new Manipulator(collector.getOutQueue(), this.manipulations);
|
||||||
|
|
||||||
// // Insert dispatcher into processing chain
|
// // Insert dispatcher into processing chain
|
||||||
this.dispatcher = new DataDispatcher(manipulator.getOutQueue());
|
this.dispatcher = new DataDispatcher(manipulator.getOutQueue());
|
||||||
@@ -302,11 +284,8 @@ public class Acquisition {
|
|||||||
try{
|
try{
|
||||||
active = true;
|
active = true;
|
||||||
|
|
||||||
Thread tc = null;
|
Thread tc = new Thread(collector);
|
||||||
if(!NEW_ENGINE){
|
tc.start();
|
||||||
tc = new Thread(collector);
|
|
||||||
tc.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread tm = new Thread(manipulator);
|
Thread tm = new Thread(manipulator);
|
||||||
tm.start();
|
tm.start();
|
||||||
@@ -317,25 +296,15 @@ public class Acquisition {
|
|||||||
Thread t = new Thread(serializer);
|
Thread t = new Thread(serializer);
|
||||||
t.start();
|
t.start();
|
||||||
|
|
||||||
if(NEW_ENGINE){
|
actionLoop.prepare();
|
||||||
acquisitionEngine.execute(mapper.getResourceDescriptors(), mapper.getScript(), new ArrayList<String>());
|
actionLoop.execute();
|
||||||
}
|
actionLoop.cleanup();
|
||||||
else {
|
|
||||||
actionLoop.prepare();
|
|
||||||
actionLoop.execute();
|
|
||||||
actionLoop.cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Wait for data collector threads
|
// Wait for data collector threads
|
||||||
// Do this with a Latch or something like that
|
// Do this with a Latch or something like that
|
||||||
|
|
||||||
// Give the threads 1 minute to catch up
|
// Give the threads 1 minute to catch up
|
||||||
if(!NEW_ENGINE){
|
tc.join(60000);
|
||||||
tc.join(60000);
|
|
||||||
}
|
|
||||||
tm.join(60000);
|
tm.join(60000);
|
||||||
td.join(60000);
|
td.join(60000);
|
||||||
t.join(60000);
|
t.join(60000);
|
||||||
@@ -398,9 +367,11 @@ public class Acquisition {
|
|||||||
// Destroy the CA context
|
// Destroy the CA context
|
||||||
try {
|
try {
|
||||||
logger.fine("Destroy Channel Access context");
|
logger.fine("Destroy Channel Access context");
|
||||||
cservice.destroy();
|
ChannelBeanFactory.getFactory().getChannelFactory().destroyContext();
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
logger.log(Level.SEVERE, "Unable to destroy channel access context", e);
|
logger.log(Level.SEVERE, "Unable to destroy channel access context", e);
|
||||||
|
} catch (CAException e) {
|
||||||
|
logger.log(Level.SEVERE, "Unable to destroy channel access context", e);
|
||||||
}
|
}
|
||||||
logger.fine("Context destroyed");
|
logger.fine("Context destroyed");
|
||||||
|
|
||||||
@@ -538,7 +509,13 @@ public class Acquisition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JythonManipulation manipulation = new JythonManipulation(cservice, sm.getId(), sm.getScript(), mapping, sm.isReturnArray());
|
JythonManipulation manipulation = new JythonManipulation(sm.getId(), sm.getScript(), mapping, sm.isReturnArray());
|
||||||
|
|
||||||
|
if(configuration.getData()!=null){ // Safety
|
||||||
|
manipulation.setVariable("FILENAME", configuration.getData().getFileName());
|
||||||
|
manipulation.setVariable("DATAFILE", datafile.getAbsoluteFile());
|
||||||
|
}
|
||||||
|
|
||||||
this.manipulations.add(manipulation);
|
this.manipulations.add(manipulation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -564,24 +541,24 @@ public class Acquisition {
|
|||||||
timeout = Math.round(ca.getTimeout()*1000);
|
timeout = Math.round(ca.getTimeout()*1000);
|
||||||
}
|
}
|
||||||
if(type.equals("String")){
|
if(type.equals("String")){
|
||||||
alist.add(new ChannelAccessPut<String>(cservice, ca.getChannel(), ca.getValue(), false, timeout));
|
alist.add(new ChannelAccessPut<String>(ca.getChannel(), ca.getValue(), false, timeout));
|
||||||
}
|
}
|
||||||
else if(type.equals("Integer")){
|
else if(type.equals("Integer")){
|
||||||
alist.add(new ChannelAccessPut<Integer>(cservice, ca.getChannel(), new Integer(ca.getValue()), false, timeout));
|
alist.add(new ChannelAccessPut<Integer>(ca.getChannel(), new Integer(ca.getValue()), false, timeout));
|
||||||
}
|
}
|
||||||
else if(type.equals("Double")){
|
else if(type.equals("Double")){
|
||||||
alist.add(new ChannelAccessPut<Double>(cservice, ca.getChannel(), new Double(ca.getValue()), false, timeout));
|
alist.add(new ChannelAccessPut<Double>(ca.getChannel(), new Double(ca.getValue()), false, timeout));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(operation.equals("putq")){
|
else if(operation.equals("putq")){
|
||||||
if(type.equals("String")){
|
if(type.equals("String")){
|
||||||
alist.add(new ChannelAccessPut<String>(cservice, ca.getChannel(), ca.getValue(), true, null));
|
alist.add(new ChannelAccessPut<String>(ca.getChannel(), ca.getValue(), true, null));
|
||||||
}
|
}
|
||||||
else if(type.equals("Integer")){
|
else if(type.equals("Integer")){
|
||||||
alist.add(new ChannelAccessPut<Integer>(cservice, ca.getChannel(), new Integer(ca.getValue()), true, null));
|
alist.add(new ChannelAccessPut<Integer>(ca.getChannel(), new Integer(ca.getValue()), true, null));
|
||||||
}
|
}
|
||||||
else if(type.equals("Double")){
|
else if(type.equals("Double")){
|
||||||
alist.add(new ChannelAccessPut<Double>(cservice, ca.getChannel(), new Double(ca.getValue()), true, null));
|
alist.add(new ChannelAccessPut<Double>(ca.getChannel(), new Double(ca.getValue()), true, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(operation.equals("wait")){
|
else if(operation.equals("wait")){
|
||||||
@@ -590,13 +567,13 @@ public class Acquisition {
|
|||||||
timeout = Math.round(ca.getTimeout()*1000);
|
timeout = Math.round(ca.getTimeout()*1000);
|
||||||
}
|
}
|
||||||
if(type.equals("String")){
|
if(type.equals("String")){
|
||||||
alist.add(new ChannelAccessCondition<String>(cservice, ca.getChannel(), ca.getValue(), timeout));
|
alist.add(new ChannelAccessCondition<String>(ca.getChannel(), ca.getValue(), timeout));
|
||||||
}
|
}
|
||||||
else if(type.equals("Integer")){
|
else if(type.equals("Integer")){
|
||||||
alist.add(new ChannelAccessCondition<Integer>(cservice, ca.getChannel(), new Integer(ca.getValue()), timeout));
|
alist.add(new ChannelAccessCondition<Integer>(ca.getChannel(), new Integer(ca.getValue()), timeout));
|
||||||
}
|
}
|
||||||
else if(type.equals("Double")){
|
else if(type.equals("Double")){
|
||||||
alist.add(new ChannelAccessCondition<Double>(cservice, ca.getChannel(), new Double(ca.getValue()), timeout));
|
alist.add(new ChannelAccessCondition<Double>(ca.getChannel(), new Double(ca.getValue()), timeout));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(operation.equals("waitREGEX")){
|
else if(operation.equals("waitREGEX")){
|
||||||
@@ -605,7 +582,7 @@ public class Acquisition {
|
|||||||
timeout = Math.round(ca.getTimeout()*1000);
|
timeout = Math.round(ca.getTimeout()*1000);
|
||||||
}
|
}
|
||||||
if(type.equals("String")){
|
if(type.equals("String")){
|
||||||
alist.add(new ChannelAccessConditionRegex<String>(cservice, ca.getChannel(), ca.getValue(), timeout));
|
alist.add(new ChannelAccessConditionRegex<String>(ca.getChannel(), ca.getValue(), timeout));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
logger.warning("Operation "+operation+" wity type "+type+" for action is not supported");
|
logger.warning("Operation "+operation+" wity type "+type+" for action is not supported");
|
||||||
@@ -618,7 +595,7 @@ public class Acquisition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(type.equals("Integer")){
|
if(type.equals("Integer")){
|
||||||
alist.add(new ChannelAccessConditionOr<Integer>(cservice, ca.getChannel(), new Integer(ca.getValue()), timeout));
|
alist.add(new ChannelAccessConditionOr<Integer>(ca.getChannel(), new Integer(ca.getValue()), timeout));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
logger.warning("Operation "+operation+" wity type "+type+" for action is not supported");
|
logger.warning("Operation "+operation+" wity type "+type+" for action is not supported");
|
||||||
@@ -630,7 +607,7 @@ public class Acquisition {
|
|||||||
timeout = Math.round(ca.getTimeout()*1000);
|
timeout = Math.round(ca.getTimeout()*1000);
|
||||||
}
|
}
|
||||||
if(type.equals("Integer")){
|
if(type.equals("Integer")){
|
||||||
alist.add(new ChannelAccessConditionAnd<Integer>(cservice, ca.getChannel(), new Integer(ca.getValue()), timeout));
|
alist.add(new ChannelAccessConditionAnd<Integer>(ca.getChannel(), new Integer(ca.getValue()), timeout));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.warning("Operation "+operation+" wity type "+type+" for action is not supported");
|
logger.warning("Operation "+operation+" wity type "+type+" for action is not supported");
|
||||||
@@ -650,7 +627,9 @@ public class Acquisition {
|
|||||||
}
|
}
|
||||||
else if(a instanceof ShellAction){
|
else if(a instanceof ShellAction){
|
||||||
ShellAction sa = (ShellAction) a;
|
ShellAction sa = (ShellAction) a;
|
||||||
ch.psi.fda.core.actions.ShellAction action = new ch.psi.fda.core.actions.ShellAction(sa.getCommand());
|
String com = sa.getCommand().replaceAll("\\$\\{DATAFILE\\}", datafile.getAbsolutePath());
|
||||||
|
com = com.replaceAll("\\$\\{FILENAME\\}", datafile.getName().replaceAll("\\.\\w*$", ""));
|
||||||
|
ch.psi.fda.core.actions.ShellAction action = new ch.psi.fda.core.actions.ShellAction(com);
|
||||||
action.setCheckExitValue(sa.isCheckExitValue());
|
action.setCheckExitValue(sa.isCheckExitValue());
|
||||||
action.setExitValue(sa.getExitValue());
|
action.setExitValue(sa.getExitValue());
|
||||||
alist.add(action);
|
alist.add(action);
|
||||||
@@ -658,6 +637,9 @@ public class Acquisition {
|
|||||||
else if(a instanceof ScriptAction){
|
else if(a instanceof ScriptAction){
|
||||||
|
|
||||||
ScriptAction sa = (ScriptAction) a;
|
ScriptAction sa = (ScriptAction) a;
|
||||||
|
|
||||||
|
// TODO set global variables DATAFILE and FILENAME
|
||||||
|
|
||||||
// TODO create Jython Action
|
// TODO create Jython Action
|
||||||
List<JythonParameterMappingChannel> mapping = new ArrayList<JythonParameterMappingChannel>();
|
List<JythonParameterMappingChannel> mapping = new ArrayList<JythonParameterMappingChannel>();
|
||||||
for(ChannelParameterMapping ma: sa.getMapping()){
|
for(ChannelParameterMapping ma: sa.getMapping()){
|
||||||
@@ -674,7 +656,11 @@ public class Acquisition {
|
|||||||
logger.warning("Channel type ["+ma.getType()+"] is not supported for mapping");
|
logger.warning("Channel type ["+ma.getType()+"] is not supported for mapping");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alist.add(new ch.psi.fda.core.actions.JythonAction(cservice, sa.getScript(), mapping));
|
|
||||||
|
ch.psi.fda.core.actions.JythonAction ja = new ch.psi.fda.core.actions.JythonAction(sa.getScript(), mapping);
|
||||||
|
ja.setVariable("FILENAME", datafile.getName().replaceAll("\\.\\w*$", ""));
|
||||||
|
ja.setVariable("DATAFILE", datafile.getAbsoluteFile());
|
||||||
|
alist.add(ja);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(alist);
|
return(alist);
|
||||||
@@ -707,14 +693,14 @@ public class Acquisition {
|
|||||||
LinearPositioner lp =(LinearPositioner) p;
|
LinearPositioner lp =(LinearPositioner) p;
|
||||||
ChannelAccessLinearActuator<?> a;
|
ChannelAccessLinearActuator<?> a;
|
||||||
if(lp.getType().equals("String")){
|
if(lp.getType().equals("String")){
|
||||||
a = new ChannelAccessLinearActuator<String>(cservice, lp.getName(), lp.getDone(), lp.getDoneValue(), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
a = new ChannelAccessLinearActuator<String>(lp.getName(), lp.getDone(), lp.getDoneValue(), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
else if(lp.getType().equals("Double")){
|
else if(lp.getType().equals("Double")){
|
||||||
a = new ChannelAccessLinearActuator<Double>(cservice, lp.getName(), lp.getDone(), Double.parseDouble(lp.getDoneValue()), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
a = new ChannelAccessLinearActuator<Double>(lp.getName(), lp.getDone(), Double.parseDouble(lp.getDoneValue()), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Default
|
// Default
|
||||||
a = new ChannelAccessLinearActuator<Integer>(cservice, lp.getName(), lp.getDone(), Integer.parseInt(lp.getDoneValue()), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
a = new ChannelAccessLinearActuator<Integer>(lp.getName(), lp.getDone(), Integer.parseInt(lp.getDoneValue()), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
a.setAsynchronous(lp.isAsynchronous());
|
a.setAsynchronous(lp.isAsynchronous());
|
||||||
@@ -727,7 +713,7 @@ public class Acquisition {
|
|||||||
if(name==null){
|
if(name==null){
|
||||||
name = lp.getName();
|
name = lp.getName();
|
||||||
}
|
}
|
||||||
ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(cservice, lp.getId(), name);
|
ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(lp.getId(), name);
|
||||||
aLoop.getSensors().add(sensor);
|
aLoop.getSensors().add(sensor);
|
||||||
}
|
}
|
||||||
else if(p instanceof FunctionPositioner){
|
else if(p instanceof FunctionPositioner){
|
||||||
@@ -740,14 +726,14 @@ public class Acquisition {
|
|||||||
// Create actuator
|
// Create actuator
|
||||||
ChannelAccessFunctionActuator<?> a;
|
ChannelAccessFunctionActuator<?> a;
|
||||||
if(lp.getType().equals("String")){
|
if(lp.getType().equals("String")){
|
||||||
a = new ChannelAccessFunctionActuator<String>(cservice, lp.getName(), lp.getDone(), lp.getDoneValue(), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
a = new ChannelAccessFunctionActuator<String>(lp.getName(), lp.getDone(), lp.getDoneValue(), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
else if(lp.getType().equals("Double")){
|
else if(lp.getType().equals("Double")){
|
||||||
a = new ChannelAccessFunctionActuator<Double>(cservice, lp.getName(), lp.getDone(), Double.parseDouble(lp.getDoneValue()), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
a = new ChannelAccessFunctionActuator<Double>(lp.getName(), lp.getDone(), Double.parseDouble(lp.getDoneValue()), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Default
|
// Default
|
||||||
a = new ChannelAccessFunctionActuator<Integer>(cservice, lp.getName(), lp.getDone(), Integer.parseInt(lp.getDoneValue()), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
a = new ChannelAccessFunctionActuator<Integer>(lp.getName(), lp.getDone(), Integer.parseInt(lp.getDoneValue()), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
a.setAsynchronous(lp.isAsynchronous());
|
a.setAsynchronous(lp.isAsynchronous());
|
||||||
@@ -760,7 +746,7 @@ public class Acquisition {
|
|||||||
if(name==null){
|
if(name==null){
|
||||||
name = lp.getName();
|
name = lp.getName();
|
||||||
}
|
}
|
||||||
ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(cservice, lp.getId(), name);
|
ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(lp.getId(), name);
|
||||||
aLoop.getSensors().add(sensor);
|
aLoop.getSensors().add(sensor);
|
||||||
}
|
}
|
||||||
else if (p instanceof ArrayPositioner){
|
else if (p instanceof ArrayPositioner){
|
||||||
@@ -773,14 +759,14 @@ public class Acquisition {
|
|||||||
|
|
||||||
ChannelAccessTableActuator<?> a;
|
ChannelAccessTableActuator<?> a;
|
||||||
if(p.getType().equals("String")){
|
if(p.getType().equals("String")){
|
||||||
a = new ChannelAccessTableActuator<String>(cservice, p.getName(), p.getDone(), p.getDoneValue(), p.getDoneDelay(), table, moveTimeout);
|
a = new ChannelAccessTableActuator<String>(p.getName(), p.getDone(), p.getDoneValue(), p.getDoneDelay(), table, moveTimeout);
|
||||||
}
|
}
|
||||||
else if(p.getType().equals("Double")){
|
else if(p.getType().equals("Double")){
|
||||||
a = new ChannelAccessTableActuator<Double>(cservice, p.getName(), p.getDone(), Double.parseDouble(p.getDoneValue()), p.getDoneDelay(), table, moveTimeout);
|
a = new ChannelAccessTableActuator<Double>(p.getName(), p.getDone(), Double.parseDouble(p.getDoneValue()), p.getDoneDelay(), table, moveTimeout);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Default
|
// Default
|
||||||
a = new ChannelAccessTableActuator<Integer>(cservice, p.getName(), p.getDone(), Integer.parseInt(p.getDoneValue()), p.getDoneDelay(), table, moveTimeout);
|
a = new ChannelAccessTableActuator<Integer>(p.getName(), p.getDone(), Integer.parseInt(p.getDoneValue()), p.getDoneDelay(), table, moveTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
a.setAsynchronous(p.isAsynchronous());
|
a.setAsynchronous(p.isAsynchronous());
|
||||||
@@ -793,7 +779,7 @@ public class Acquisition {
|
|||||||
if(name==null){
|
if(name==null){
|
||||||
name = ap.getName();
|
name = ap.getName();
|
||||||
}
|
}
|
||||||
ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(cservice, ap.getId(), name);
|
ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(ap.getId(), name);
|
||||||
aLoop.getSensors().add(sensor);
|
aLoop.getSensors().add(sensor);
|
||||||
}
|
}
|
||||||
else if (p instanceof RegionPositioner){
|
else if (p instanceof RegionPositioner){
|
||||||
@@ -826,14 +812,14 @@ public class Acquisition {
|
|||||||
// Create actuator
|
// Create actuator
|
||||||
ChannelAccessLinearActuator<?> act;
|
ChannelAccessLinearActuator<?> act;
|
||||||
if(rp.getType().equals("String")){
|
if(rp.getType().equals("String")){
|
||||||
act = new ChannelAccessLinearActuator<String>(cservice, rp.getName(), rp.getDone(), rp.getDoneValue(), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
|
act = new ChannelAccessLinearActuator<String>(rp.getName(), rp.getDone(), rp.getDoneValue(), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
else if(rp.getType().equals("Double")){
|
else if(rp.getType().equals("Double")){
|
||||||
act = new ChannelAccessLinearActuator<Double>(cservice, rp.getName(), rp.getDone(), Double.parseDouble(rp.getDoneValue()), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
|
act = new ChannelAccessLinearActuator<Double>(rp.getName(), rp.getDone(), Double.parseDouble(rp.getDoneValue()), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Default
|
// Default
|
||||||
act = new ChannelAccessLinearActuator<Integer>(cservice, rp.getName(), rp.getDone(), Integer.parseInt(rp.getDoneValue()), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
|
act = new ChannelAccessLinearActuator<Integer>(rp.getName(), rp.getDone(), Integer.parseInt(rp.getDoneValue()), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
act.setAsynchronous(rp.isAsynchronous());
|
act.setAsynchronous(rp.isAsynchronous());
|
||||||
@@ -854,14 +840,14 @@ public class Acquisition {
|
|||||||
JythonFunction function = mapFunction(r.getFunction());
|
JythonFunction function = mapFunction(r.getFunction());
|
||||||
ChannelAccessFunctionActuator<?> act;
|
ChannelAccessFunctionActuator<?> act;
|
||||||
if(rp.getType().equals("String")){
|
if(rp.getType().equals("String")){
|
||||||
act = new ChannelAccessFunctionActuator<String>(cservice, rp.getName(), rp.getDone(), rp.getDoneValue(), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
|
act = new ChannelAccessFunctionActuator<String>(rp.getName(), rp.getDone(), rp.getDoneValue(), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
else if(rp.getType().equals("Double")){
|
else if(rp.getType().equals("Double")){
|
||||||
act = new ChannelAccessFunctionActuator<Double>(cservice, rp.getName(), rp.getDone(), Double.parseDouble(rp.getDoneValue()), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
|
act = new ChannelAccessFunctionActuator<Double>(rp.getName(), rp.getDone(), Double.parseDouble(rp.getDoneValue()), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Default
|
// Default
|
||||||
act = new ChannelAccessFunctionActuator<Integer>(cservice, rp.getName(), rp.getDone(), Integer.parseInt(rp.getDoneValue()), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
|
act = new ChannelAccessFunctionActuator<Integer>(rp.getName(), rp.getDone(), Integer.parseInt(rp.getDoneValue()), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
act.setAsynchronous(rp.isAsynchronous());
|
act.setAsynchronous(rp.isAsynchronous());
|
||||||
@@ -881,7 +867,7 @@ public class Acquisition {
|
|||||||
if(name==null){
|
if(name==null){
|
||||||
name = rp.getName();
|
name = rp.getName();
|
||||||
}
|
}
|
||||||
ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(cservice, rp.getId(), name);
|
ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(rp.getId(), name);
|
||||||
aLoop.getSensors().add(sensor);
|
aLoop.getSensors().add(sensor);
|
||||||
}
|
}
|
||||||
else if(p instanceof PseudoPositioner){
|
else if(p instanceof PseudoPositioner){
|
||||||
@@ -928,7 +914,7 @@ public class Acquisition {
|
|||||||
value = con.getValue();
|
value = con.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
conditions.add(new ChannelAccessGuardCondition(cservice, con.getChannel(), value));
|
conditions.add(new ChannelAccessGuardCondition(con.getChannel(), value));
|
||||||
}
|
}
|
||||||
// Create guard and add to loop
|
// Create guard and add to loop
|
||||||
ChannelAccessGuard guard = new ChannelAccessGuard(conditions);
|
ChannelAccessGuard guard = new ChannelAccessGuard(conditions);
|
||||||
@@ -979,10 +965,10 @@ public class Acquisition {
|
|||||||
// Add sensor
|
// Add sensor
|
||||||
Sensor sensor;
|
Sensor sensor;
|
||||||
if(sd.getType().equals("String")){
|
if(sd.getType().equals("String")){
|
||||||
sensor = new ChannelAccessStringSensor(cservice, sd.getId(), sd.getName());
|
sensor = new ChannelAccessStringSensor(sd.getId(), sd.getName());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
sensor = new ChannelAccessDoubleSensor(cservice, sd.getId(), sd.getName());
|
sensor = new ChannelAccessDoubleSensor(sd.getId(), sd.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
aLoop.getSensors().add(sensor);
|
aLoop.getSensors().add(sensor);
|
||||||
@@ -994,7 +980,7 @@ public class Acquisition {
|
|||||||
aLoop.getPreSensorActions().addAll(mapActions(ad.getPreAction()));
|
aLoop.getPreSensorActions().addAll(mapActions(ad.getPreAction()));
|
||||||
|
|
||||||
// Ad sensor
|
// Ad sensor
|
||||||
ChannelAccessDoubleArraySensor sensor = new ChannelAccessDoubleArraySensor(cservice, ad.getId(), ad.getName(), ad.getArraySize());
|
ChannelAccessDoubleArraySensor sensor = new ChannelAccessDoubleArraySensor(ad.getId(), ad.getName(), ad.getArraySize());
|
||||||
aLoop.getSensors().add(sensor);
|
aLoop.getSensors().add(sensor);
|
||||||
}
|
}
|
||||||
else if (detector instanceof DetectorOfDetectors){
|
else if (detector instanceof DetectorOfDetectors){
|
||||||
@@ -1037,7 +1023,7 @@ public class Acquisition {
|
|||||||
// Create loop
|
// Create loop
|
||||||
boolean zigZag = dimension.isZigzag(); // default value is false
|
boolean zigZag = dimension.isZigzag(); // default value is false
|
||||||
|
|
||||||
OTFLoop actionLoop = new OTFLoop(cservice, configuration.getOtfChannelPrefix(), configuration.getOtfNfsServer(), configuration.getOtfNfsShare(), configuration.getOtfSmbShare(), zigZag);
|
OTFLoop actionLoop = new OTFLoop(configuration.getOtfChannelPrefix(), configuration.getOtfNfsServer(), configuration.getOtfNfsShare(), configuration.getOtfSmbShare(), zigZag);
|
||||||
|
|
||||||
actionLoop.getPreActions().addAll(mapActions(dimension.getPreAction()));
|
actionLoop.getPreActions().addAll(mapActions(dimension.getPreAction()));
|
||||||
|
|
||||||
@@ -1096,7 +1082,7 @@ public class Acquisition {
|
|||||||
// Create loop
|
// Create loop
|
||||||
boolean zigZag = dimension.isZigzag(); // default value is false
|
boolean zigZag = dimension.isZigzag(); // default value is false
|
||||||
|
|
||||||
CrlogicLoop actionLoop = new CrlogicLoop(cservice, configuration.getOtfCrlogicPrefix(), configuration.getOtfNfsServer(), configuration.getOtfNfsShare(), configuration.getOtfSmbShare(), zigZag);
|
CrlogicLoop actionLoop = new CrlogicLoop(configuration.getOtfCrlogicPrefix(), configuration.getOtfNfsServer(), configuration.getOtfNfsShare(), configuration.getOtfSmbShare(), zigZag);
|
||||||
actionLoop.setKeepTmpFiles(configuration.isOtfCrlogicKeepTmpFiles());
|
actionLoop.setKeepTmpFiles(configuration.isOtfCrlogicKeepTmpFiles());
|
||||||
|
|
||||||
actionLoop.getPreActions().addAll(mapActions(dimension.getPreAction()));
|
actionLoop.getPreActions().addAll(mapActions(dimension.getPreAction()));
|
||||||
@@ -1142,11 +1128,11 @@ public class Acquisition {
|
|||||||
List<Sensor> sensors = new ArrayList<Sensor>();
|
List<Sensor> sensors = new ArrayList<Sensor>();
|
||||||
for(SimpleScalarDetector detector: dimension.getDetector()){
|
for(SimpleScalarDetector detector: dimension.getDetector()){
|
||||||
if(detector.isScr()){
|
if(detector.isScr()){
|
||||||
sensors.add(new ChannelAccessDoubleSensor(cservice, detector.getId(), detector.getName()));
|
sensors.add(new ChannelAccessDoubleSensor(detector.getId(), detector.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Create soft(ware) based crlogic
|
// Create soft(ware) based crlogic
|
||||||
ScrlogicLoop scrlogic = new ScrlogicLoop(cservice, sensors);
|
ScrlogicLoop scrlogic = new ScrlogicLoop(sensors);
|
||||||
|
|
||||||
// Create parallel logic
|
// Create parallel logic
|
||||||
ParallelCrlogic pcrlogic = new ParallelCrlogic(actionLoop, scrlogic);
|
ParallelCrlogic pcrlogic = new ParallelCrlogic(actionLoop, scrlogic);
|
||||||
|
|||||||
@@ -1,154 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng;
|
|
||||||
|
|
||||||
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.LinkedBlockingQueue;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.script.ScriptEngine;
|
|
||||||
import javax.script.ScriptEngineManager;
|
|
||||||
import javax.script.ScriptException;
|
|
||||||
|
|
||||||
import ch.psi.fda.aq.ng.rdescriptors.ProbeDescriptor;
|
|
||||||
import ch.psi.fda.aq.ng.rdescriptors.ShellDescriptor;
|
|
||||||
import ch.psi.fda.aq.ng.resources.ChannelProbeResource;
|
|
||||||
import ch.psi.fda.aq.ng.resources.ShellResource;
|
|
||||||
import ch.psi.fda.core.messages.Message;
|
|
||||||
import ch.psi.jcae.Channel;
|
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ebner
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class AcquisitionEngineNG {
|
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(AcquisitionEngineNG.class.getName());
|
|
||||||
|
|
||||||
private ChannelService cservice;
|
|
||||||
private BlockingQueue<Message> outQueue;
|
|
||||||
|
|
||||||
public AcquisitionEngineNG(ChannelService cservice) {
|
|
||||||
this.cservice = cservice;
|
|
||||||
this.outQueue = new LinkedBlockingQueue<Message>(1000); // Create bounded queue to prevent running out of memory ...
|
|
||||||
|
|
||||||
// Workaround for Jython memory leak
|
|
||||||
// http://blog.hillbrecht.de/2009/07/11/jython-memory-leakout-of-memory-problem/
|
|
||||||
System.setProperty("python.options.internalTablesImpl", "weak");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the specified script/logic while using the specified resources and paramters
|
|
||||||
* @param resourceDescriptors
|
|
||||||
* @param script
|
|
||||||
* @param parameter
|
|
||||||
*/
|
|
||||||
public void execute(Map<String, ?> resourceDescriptors, String script, List<String> parameter){
|
|
||||||
|
|
||||||
// TODO Remove debugging messages
|
|
||||||
// For debugging purpose only
|
|
||||||
logger.info("Resources to create: "+resourceDescriptors);
|
|
||||||
logger.info("Script to execute: "+script);
|
|
||||||
|
|
||||||
try {
|
|
||||||
ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");
|
|
||||||
|
|
||||||
// Set logger
|
|
||||||
engine.put("logger", logger);
|
|
||||||
|
|
||||||
// Set parameters
|
|
||||||
engine.put("parameter", parameter);
|
|
||||||
|
|
||||||
// Create/retrieve and set resources
|
|
||||||
Map<String,?> resources = createResources(resourceDescriptors);
|
|
||||||
engine.put("resources", resources);
|
|
||||||
for(String k: resources.keySet()){ // For convenience make resources also available as variable named by the resource id
|
|
||||||
engine.put(k, resources.get(k));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute script
|
|
||||||
engine.eval(script);
|
|
||||||
|
|
||||||
|
|
||||||
} catch (ScriptException e) {
|
|
||||||
logger.info(e.getMessage());
|
|
||||||
throw new RuntimeException("Action failed while executing the Jython script",e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create resources based on the passed rDescriptors
|
|
||||||
* Supported descriptor types are:
|
|
||||||
* ChannelDescriptor, ShellDescriptor, ProbeDescriptor
|
|
||||||
*
|
|
||||||
* @param resourceDescriptors
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String,?> createResources(Map<String, ?> resourceDescriptors){
|
|
||||||
Map<String,Object> resources = new HashMap<>();
|
|
||||||
for(String k: resourceDescriptors.keySet()){
|
|
||||||
if(resourceDescriptors.get(k) instanceof ChannelDescriptor){
|
|
||||||
ChannelDescriptor<?> descriptor = (ChannelDescriptor<?>)resourceDescriptors.get(k);
|
|
||||||
try {
|
|
||||||
resources.put(k, cservice.createChannel(descriptor));
|
|
||||||
// engine.put(k, cservice.createChannel(descriptor));
|
|
||||||
} catch (ChannelException | InterruptedException | TimeoutException e) {
|
|
||||||
throw new RuntimeException("Unable to create resource for channel: "+descriptor.getName(),e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(resourceDescriptors.get(k) instanceof ShellDescriptor){
|
|
||||||
resources.put(k, new ShellResource());
|
|
||||||
// engine.put(k, new ShellResource());
|
|
||||||
}
|
|
||||||
else if(resourceDescriptors.get(k) instanceof ProbeDescriptor){
|
|
||||||
ProbeDescriptor descriptor = (ProbeDescriptor) resourceDescriptors.get(k);
|
|
||||||
List<Channel<?>> channels = new ArrayList<>();
|
|
||||||
|
|
||||||
for(ChannelDescriptor<?> s: descriptor.getSensors()){
|
|
||||||
try {
|
|
||||||
channels.add(cservice.createChannel(s));
|
|
||||||
|
|
||||||
} catch (ChannelException | InterruptedException | TimeoutException e) {
|
|
||||||
throw new RuntimeException("Unable to create resource for channel: "+s.getName(),e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO Remove workaround ...
|
|
||||||
resources.put(k, new ChannelProbeResource(channels, outQueue)); // Configure the probe to use the acquisitions out queue for writing data into
|
|
||||||
// engine.put(k, new ChannelProbeResource(channels, outQueue));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
throw new RuntimeException("Resource type not supported: "+resourceDescriptors.get(k).getClass().getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resources;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockingQueue<Message> getOutQueue(){
|
|
||||||
return outQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.ws.rs.Consumes;
|
|
||||||
import javax.ws.rs.GET;
|
|
||||||
import javax.ws.rs.NotFoundException;
|
|
||||||
import javax.ws.rs.POST;
|
|
||||||
import javax.ws.rs.PUT;
|
|
||||||
import javax.ws.rs.Path;
|
|
||||||
import javax.ws.rs.PathParam;
|
|
||||||
import javax.ws.rs.Produces;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
|
|
||||||
import ch.psi.fda.aq.ng.rdescriptors.ShellDescriptor;
|
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ebner
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Path("/")
|
|
||||||
public class AcquisitionEngineNGResource {
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private AcquisitionEngineNG engine;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private LManager lmanager;
|
|
||||||
|
|
||||||
// @PUT
|
|
||||||
// @Path("logic")
|
|
||||||
// public void execute(String logic){
|
|
||||||
// Map<String, ?> map = new HashMap<>();
|
|
||||||
// engine.execute(map, logic);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("logic")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public Set<String> getLogics(){
|
|
||||||
return lmanager.getLogics();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PUT
|
|
||||||
@Path("logic/{id}")
|
|
||||||
public void setLogic(@PathParam("id") String id, String logic){
|
|
||||||
lmanager.addLogic(id, logic);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("logic/{id}")
|
|
||||||
public String getLogic(@PathParam("id") String id){
|
|
||||||
String logic = lmanager.getLogic(id);
|
|
||||||
if(logic==null){
|
|
||||||
throw new NotFoundException();
|
|
||||||
}
|
|
||||||
return logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("logic/{id}")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
public void executeLogic(@PathParam("id") String id, EDescriptor edescriptor){
|
|
||||||
|
|
||||||
// Before executing the logic first merge the default descriptors and provided descriptors
|
|
||||||
// Where the provided descriptors take precedence over the default onces.
|
|
||||||
Map<String, RDescriptor> rdesc = new HashMap<>();
|
|
||||||
rdesc.putAll(lmanager.getResources(id));
|
|
||||||
if (edescriptor.getResources() != null) {
|
|
||||||
rdesc.putAll(edescriptor.getResources());
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, ?> map = createResourceDescriptors(rdesc);
|
|
||||||
|
|
||||||
List<String> parameters = new ArrayList<>();
|
|
||||||
if(edescriptor.getParameter()!=null){
|
|
||||||
parameters = edescriptor.getParameter();
|
|
||||||
}
|
|
||||||
|
|
||||||
engine.execute(map, lmanager.getLogic(id), parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PUT
|
|
||||||
@Path("logic/{id}/resources")
|
|
||||||
public void setLogicResources(@PathParam("id") String id, Map<String, RDescriptor> rprofile){
|
|
||||||
lmanager.addResources(id, rprofile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("logic/{id}/resources")
|
|
||||||
public Map<String, RDescriptor> getLogicResources(@PathParam("id") String id){
|
|
||||||
Map<String, RDescriptor> rprofile = lmanager.getResources(id);
|
|
||||||
if(rprofile==null){
|
|
||||||
throw new NotFoundException();
|
|
||||||
}
|
|
||||||
return rprofile;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create internal resource descriptors based on the rdescriptors passed to the method.
|
|
||||||
*
|
|
||||||
* Currently following rdescriptor types are supported:
|
|
||||||
* - channel
|
|
||||||
* - shell
|
|
||||||
*
|
|
||||||
* @param descriptor
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, ?> createResourceDescriptors(Map<String, RDescriptor> resourceDescriptors) {
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
|
|
||||||
for (String k : resourceDescriptors.keySet()) {
|
|
||||||
RDescriptor r = resourceDescriptors.get(k);
|
|
||||||
if (r.getType().equals("channel")) {
|
|
||||||
Class<?> c;
|
|
||||||
switch (r.getParameter().get("type").toLowerCase()) {
|
|
||||||
case "double":
|
|
||||||
c = Double.class;
|
|
||||||
break;
|
|
||||||
case "integer":
|
|
||||||
c = Integer.class;
|
|
||||||
break;
|
|
||||||
case "boolean":
|
|
||||||
c = Boolean.class;
|
|
||||||
break;
|
|
||||||
case "String":
|
|
||||||
c = String.class;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
c = String.class;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
String name = r.getParameter().get("name");
|
|
||||||
boolean monitored = false;
|
|
||||||
if(r.getParameter().get("monitor")!=null){
|
|
||||||
monitored = new Boolean(r.getParameter().get("monitor"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create channel descriptor
|
|
||||||
ChannelDescriptor<?> cd = new ChannelDescriptor<>(c, name, monitored);
|
|
||||||
map.put(k, cd);
|
|
||||||
}
|
|
||||||
else if (r.getType().equals("shell")) {
|
|
||||||
map.put(k, new ShellDescriptor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
import org.codehaus.jackson.map.annotate.JsonSerialize;
|
|
||||||
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execution descriptor - Describes resources and parameters used to execute a logic
|
|
||||||
*/
|
|
||||||
@XmlRootElement
|
|
||||||
@JsonSerialize(include = Inclusion.NON_NULL) // Do not serialize NULL values
|
|
||||||
public class EDescriptor {
|
|
||||||
|
|
||||||
private Map<String, RDescriptor> resources;
|
|
||||||
private List<String> parameter;
|
|
||||||
|
|
||||||
public Map<String, RDescriptor> getResources() {
|
|
||||||
return resources;
|
|
||||||
}
|
|
||||||
public void setResources(Map<String, RDescriptor> resources) {
|
|
||||||
this.resources = resources;
|
|
||||||
}
|
|
||||||
public List<String> getParameter() {
|
|
||||||
return parameter;
|
|
||||||
}
|
|
||||||
public void setParameter(List<String> parameter) {
|
|
||||||
this.parameter = parameter;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logic Manager
|
|
||||||
* Basically a map holding id->logic pairs
|
|
||||||
*
|
|
||||||
* also holds default resource profiles for logics (rprofiles)
|
|
||||||
*/
|
|
||||||
public class LManager {
|
|
||||||
private final Map<String, String> logics = new HashMap<>();
|
|
||||||
|
|
||||||
/** Default resourses assigned to a logic */
|
|
||||||
private final Map<String, Map<String, RDescriptor>> resources = new HashMap<>();
|
|
||||||
|
|
||||||
public void addLogic(String id, String logic){
|
|
||||||
logics.put(id, logic);
|
|
||||||
resources.put(id, new HashMap<String,RDescriptor>()); // No default resources attached to logic
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addResources(String id, Map<String, RDescriptor> lresources){
|
|
||||||
resources.put(id, lresources);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLogic(String id){
|
|
||||||
return logics.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getLogics(){
|
|
||||||
return logics.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, RDescriptor> getResources(String id){
|
|
||||||
return resources.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.UriBuilder;
|
|
||||||
import javax.ws.rs.core.UriBuilderException;
|
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
|
||||||
import org.apache.commons.cli.GnuParser;
|
|
||||||
import org.apache.commons.cli.HelpFormatter;
|
|
||||||
import org.apache.commons.cli.Options;
|
|
||||||
import org.apache.commons.cli.ParseException;
|
|
||||||
import org.glassfish.grizzly.http.server.HttpServer;
|
|
||||||
import org.glassfish.grizzly.http.server.StaticHttpHandler;
|
|
||||||
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
|
|
||||||
import org.glassfish.jersey.jackson.JacksonFeature;
|
|
||||||
import org.glassfish.jersey.media.sse.SseFeature;
|
|
||||||
import org.glassfish.jersey.server.ResourceConfig;
|
|
||||||
|
|
||||||
import sun.misc.Signal;
|
|
||||||
import sun.misc.SignalHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ebner
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
public class NGServer {
|
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(NGServer.class.getName());
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args
|
|
||||||
* @throws ParseException
|
|
||||||
* @throws UnknownHostException
|
|
||||||
* @throws UriBuilderException
|
|
||||||
* @throws IllegalArgumentException
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) throws ParseException, IllegalArgumentException, UriBuilderException, UnknownHostException {
|
|
||||||
// Option handling
|
|
||||||
int port = 8080;
|
|
||||||
|
|
||||||
Options options = new Options();
|
|
||||||
options.addOption("h", false, "Help");
|
|
||||||
options.addOption("p", true, "Server port (default: " + port + ")");
|
|
||||||
|
|
||||||
GnuParser parser = new GnuParser();
|
|
||||||
CommandLine line = parser.parse(options, args);
|
|
||||||
|
|
||||||
if (line.hasOption("p")) {
|
|
||||||
port = Integer.parseInt(line.getOptionValue("p"));
|
|
||||||
}
|
|
||||||
if (line.hasOption("h")) {
|
|
||||||
HelpFormatter f = new HelpFormatter();
|
|
||||||
f.printHelp("dae", options); // definition dae - http://www.urbandictionary.com/define.php?term=dae
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
URI baseUri = UriBuilder.fromUri("http://" + InetAddress.getLocalHost().getHostName() + "/").port(port).build();
|
|
||||||
|
|
||||||
// final ResourceConfig resourceConfig = new
|
|
||||||
// ResourceConfig(ServerSentEventsResource.class, SseFeature.class);
|
|
||||||
ResourceConfig resourceConfig = new ResourceConfig(SseFeature.class, JacksonFeature.class);
|
|
||||||
resourceConfig.packages(AcquisitionEngineNGResource.class.getPackage().getName());
|
|
||||||
resourceConfig.register(new ResourceBinder());
|
|
||||||
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);
|
|
||||||
|
|
||||||
// Static content
|
|
||||||
String home = System.getenv("DAE_BASE");
|
|
||||||
if (home == null) {
|
|
||||||
home = "src/main/assembly";
|
|
||||||
}
|
|
||||||
home = home + "/www";
|
|
||||||
server.getServerConfiguration().addHttpHandler(new StaticHttpHandler(home), "/static");
|
|
||||||
|
|
||||||
logger.info("dae started");
|
|
||||||
logger.info(String.format("Management interface available at %sstatic/", baseUri));
|
|
||||||
logger.info("Use ctrl+c to stop ...");
|
|
||||||
|
|
||||||
// Signal handling
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
Signal.handle(new Signal("INT"), new SignalHandler() {
|
|
||||||
public void handle(Signal sig) {
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Wait for termination, i.e. wait for ctrl+c
|
|
||||||
try {
|
|
||||||
latch.await();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
server.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
import org.codehaus.jackson.map.annotate.JsonSerialize;
|
|
||||||
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resource descriptor - Used to identify and/or create resource on server
|
|
||||||
*/
|
|
||||||
@XmlRootElement
|
|
||||||
@JsonSerialize(include = Inclusion.NON_NULL) // Do not serialize NULL values
|
|
||||||
public class RDescriptor {
|
|
||||||
|
|
||||||
private String ref;
|
|
||||||
private String type;
|
|
||||||
private Map<String,String> parameter;
|
|
||||||
|
|
||||||
public String getRef() {
|
|
||||||
return ref;
|
|
||||||
}
|
|
||||||
public void setRef(String ref) {
|
|
||||||
this.ref = ref;
|
|
||||||
}
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
public Map<String, String> getParameter() {
|
|
||||||
return parameter;
|
|
||||||
}
|
|
||||||
public void setParameter(Map<String, String> parameter) {
|
|
||||||
this.parameter = parameter;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package ch.psi.fda.aq.ng;
|
|
||||||
|
|
||||||
import org.glassfish.hk2.utilities.binding.AbstractBinder;
|
|
||||||
//import org.glassfish.jersey.media.sse.SseBroadcaster;
|
|
||||||
|
|
||||||
//import ch.psi.da.hub.model.Keystore;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
public class ResourceBinder extends AbstractBinder {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
// request scope binding
|
|
||||||
// bind(MyInjectablePerRequest.class).to(MyInjectablePerRequest.class).in(RequestScope.class);
|
|
||||||
// singleton binding
|
|
||||||
// bind(MyInjectableSingleton.class).in(Singleton.class);
|
|
||||||
// singleton instance binding
|
|
||||||
|
|
||||||
// KeystoreSerializer serializer = new KeystoreSerializer();
|
|
||||||
// Keystore keystore = serializer.deserialize();
|
|
||||||
|
|
||||||
// bind(new SseBroadcaster()).to(SseBroadcaster.class);
|
|
||||||
// bind(serializer).to(KeystoreSerializer.class);
|
|
||||||
// bind(new KeystoreBroadcaster()).to(KeystoreBroadcaster.class);
|
|
||||||
// bind(keystore).to(Keystore.class);
|
|
||||||
|
|
||||||
bind(new AcquisitionEngineNG(new DefaultChannelService())).to(AcquisitionEngineNG.class);
|
|
||||||
bind(new LManager()).to(LManager.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,405 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import ch.psi.fda.aq.ng.rdescriptors.ProbeDescriptor;
|
|
||||||
import ch.psi.fda.aq.ng.rdescriptors.ShellDescriptor;
|
|
||||||
import ch.psi.fda.core.messages.ComponentMetadata;
|
|
||||||
import ch.psi.fda.core.messages.DataMessageMetadata;
|
|
||||||
import ch.psi.fda.model.v1.Action;
|
|
||||||
import ch.psi.fda.model.v1.ArrayPositioner;
|
|
||||||
import ch.psi.fda.model.v1.ChannelAction;
|
|
||||||
import ch.psi.fda.model.v1.Configuration;
|
|
||||||
import ch.psi.fda.model.v1.ContinuousDimension;
|
|
||||||
import ch.psi.fda.model.v1.Dimension;
|
|
||||||
import ch.psi.fda.model.v1.DiscreteStepDimension;
|
|
||||||
import ch.psi.fda.model.v1.DiscreteStepPositioner;
|
|
||||||
import ch.psi.fda.model.v1.FunctionPositioner;
|
|
||||||
import ch.psi.fda.model.v1.LinearPositioner;
|
|
||||||
import ch.psi.fda.model.v1.PseudoPositioner;
|
|
||||||
import ch.psi.fda.model.v1.RegionPositioner;
|
|
||||||
import ch.psi.fda.model.v1.Scan;
|
|
||||||
import ch.psi.fda.model.v1.ScriptAction;
|
|
||||||
import ch.psi.fda.model.v1.ShellAction;
|
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
|
||||||
import ch.psi.jcae.util.ComparatorAND;
|
|
||||||
import ch.psi.jcae.util.ComparatorOR;
|
|
||||||
import ch.psi.jcae.util.ComparatorREGEX;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapper to transform a FDA v1 xml into the new internal model
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ScanMapperNG {
|
|
||||||
|
|
||||||
// Reserved resource id's
|
|
||||||
private static final String PROBE_RESOURCE_ID = "probe";
|
|
||||||
private static final String SHELL_RESOURCE_ID = "shell";
|
|
||||||
// "logger" is also a special variable as it is bound to the logger of the application!
|
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(ScanMapperNG.class.getName());
|
|
||||||
|
|
||||||
private static final String INDENT = " ";
|
|
||||||
|
|
||||||
private StringBuilder script = new StringBuilder();
|
|
||||||
private Set<String> imports = new HashSet<>();
|
|
||||||
private Map<String, Object> resourceDescriptors = new HashMap<>();
|
|
||||||
|
|
||||||
private ProbeDescriptor probeDescriptor = new ProbeDescriptor();
|
|
||||||
private DataMessageMetadata dataMessageMetadata = new DataMessageMetadata();
|
|
||||||
|
|
||||||
|
|
||||||
private String indentation = "";
|
|
||||||
|
|
||||||
public void map(Configuration configuration) {
|
|
||||||
|
|
||||||
// Clear object state
|
|
||||||
script = new StringBuilder();
|
|
||||||
imports = new HashSet<>();
|
|
||||||
resourceDescriptors = new HashMap<>();
|
|
||||||
probeDescriptor = new ProbeDescriptor();
|
|
||||||
|
|
||||||
resourceDescriptors.put(PROBE_RESOURCE_ID, probeDescriptor);
|
|
||||||
|
|
||||||
Scan scan = configuration.getScan();
|
|
||||||
mapActions(scan.getPreAction());
|
|
||||||
|
|
||||||
// Bring the dimensions into the correct order and then map them
|
|
||||||
// to the script
|
|
||||||
List<Dimension> dimensions = new ArrayList<>();
|
|
||||||
int size = scan.getDimension().size();
|
|
||||||
for (int i = size - 1; i >= 0; i--) {
|
|
||||||
dimensions.add(scan.getDimension().get(i));
|
|
||||||
}
|
|
||||||
// Continuous dimensions are always at the very end
|
|
||||||
if (scan.getCdimension() != null) {
|
|
||||||
dimensions.add(scan.getCdimension());
|
|
||||||
}
|
|
||||||
mapDimensions(dimensions, 0);
|
|
||||||
|
|
||||||
// map
|
|
||||||
mapActions(scan.getPostAction());
|
|
||||||
|
|
||||||
// TODO CONSIDER TO PROVIDE RESOURCE MAP AND SCRIPT IN ONE OBJECT AS
|
|
||||||
// RETURN TYPE
|
|
||||||
// WOULD MAKE MORE SENSE
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the generated script
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getScript() {
|
|
||||||
StringBuilder scriptlines = new StringBuilder();
|
|
||||||
for (String s : imports) {
|
|
||||||
scriptlines.append(s + "\n");
|
|
||||||
}
|
|
||||||
scriptlines.append(script);
|
|
||||||
return scriptlines.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get map of required resources
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Map<String, Object> getResourceDescriptors(){
|
|
||||||
return resourceDescriptors;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO need to be moved somewhere else
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public DataMessageMetadata getDataMessageMetadata(){
|
|
||||||
return dataMessageMetadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void mapDimensions(List<Dimension> dimensions, int index) {
|
|
||||||
|
|
||||||
if(dimensions.size()<1){
|
|
||||||
logger.info("There are no dimensions to map");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dimension dimension = dimensions.get(index);
|
|
||||||
if (dimension instanceof DiscreteStepDimension) {
|
|
||||||
DiscreteStepDimension d = (DiscreteStepDimension) dimension;
|
|
||||||
|
|
||||||
mapActions(d.getPreAction());
|
|
||||||
|
|
||||||
List<String> actuators = new ArrayList<>();
|
|
||||||
|
|
||||||
for(DiscreteStepPositioner positioner: d.getPositioner()){
|
|
||||||
Class<?> type = String.class;
|
|
||||||
switch (positioner.getType()) {
|
|
||||||
case "Integer":
|
|
||||||
type = Integer.class;
|
|
||||||
break;
|
|
||||||
case "Double":
|
|
||||||
type = Double.class;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
String var = getChannelResourceVariable(positioner.getName(), type, false);
|
|
||||||
actuators.add(var);
|
|
||||||
|
|
||||||
// Readback
|
|
||||||
if(positioner.getReadback()==null){
|
|
||||||
probeDescriptor.getSensors().add(new ChannelDescriptor<>(type, positioner.getName(), false));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// Use readback
|
|
||||||
probeDescriptor.getSensors().add(new ChannelDescriptor<>(type, positioner.getReadback(), false));
|
|
||||||
}
|
|
||||||
// System.out.println(positioner.getId());
|
|
||||||
dataMessageMetadata.getComponents().add(new ComponentMetadata(positioner.getId(), (dimensions.size()-1-index)));
|
|
||||||
|
|
||||||
// TODO Done resource
|
|
||||||
|
|
||||||
|
|
||||||
if(positioner instanceof LinearPositioner){
|
|
||||||
// Calculate steps and add it to position array
|
|
||||||
LinearPositioner lpositioner = (LinearPositioner) positioner;
|
|
||||||
boolean first = true;
|
|
||||||
StringBuffer b = new StringBuffer();
|
|
||||||
b.append("[");
|
|
||||||
for(double i=0;(lpositioner.getStart()+i*lpositioner.getStepSize())<=lpositioner.getEnd();i++){
|
|
||||||
if(first){
|
|
||||||
first=false;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
b.append(",");
|
|
||||||
}
|
|
||||||
b.append(String.format("%f", (lpositioner.getStart()+i*lpositioner.getStepSize())));
|
|
||||||
}
|
|
||||||
b.append("]");
|
|
||||||
script.append(indentation + var+"_positions="+b.toString()+"\n");
|
|
||||||
}
|
|
||||||
else if(positioner instanceof ArrayPositioner){
|
|
||||||
ArrayPositioner apositioner = (ArrayPositioner) positioner;
|
|
||||||
// Calculate positions
|
|
||||||
String[] positions = apositioner.getPositions().trim().split(" +");
|
|
||||||
boolean first = true;
|
|
||||||
StringBuffer b = new StringBuffer();
|
|
||||||
b.append("[");
|
|
||||||
for(String po: positions){
|
|
||||||
if(first){
|
|
||||||
first=false;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
b.append(",");
|
|
||||||
}
|
|
||||||
|
|
||||||
b.append(getPythonValue(po, type));
|
|
||||||
}
|
|
||||||
b.append("]");
|
|
||||||
script.append(indentation + var+"_positions="+b.toString()+"\n");
|
|
||||||
}
|
|
||||||
else if(positioner instanceof FunctionPositioner){
|
|
||||||
// TODO take variable mappings into account !
|
|
||||||
}
|
|
||||||
else if(positioner instanceof PseudoPositioner){
|
|
||||||
// TODO implement
|
|
||||||
}
|
|
||||||
else if(positioner instanceof RegionPositioner){
|
|
||||||
// TODO implement
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create dimension loop
|
|
||||||
String v = getUniqueVariableName();
|
|
||||||
script.append(indentation + "for "+v+"_idx ,"+v+"_pos in enumerate("+actuators.get(0)+"_positions):\n");
|
|
||||||
indentation = indentation + INDENT;
|
|
||||||
|
|
||||||
// Set all actuators of this dimension
|
|
||||||
for(String a: actuators){
|
|
||||||
script.append(indentation + a+".setValue("+a+"_positions["+v+"_idx])\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add all actions executed between actuator and sensors
|
|
||||||
mapActions(d.getAction());
|
|
||||||
|
|
||||||
// TODO map guard and sensors
|
|
||||||
|
|
||||||
|
|
||||||
// Check whether final dimension reached
|
|
||||||
if ((index + 1) < dimensions.size()) {
|
|
||||||
// Map next dimension
|
|
||||||
mapDimensions(dimensions, (index + 1));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// Final dimension reached - readout probe
|
|
||||||
script.append(indentation + PROBE_RESOURCE_ID+".read()\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
indentation = indentation.replaceFirst(INDENT, ""); // decrease indentation
|
|
||||||
|
|
||||||
|
|
||||||
script.append(indentation + PROBE_RESOURCE_ID+".delimiter("+(dimensions.size()-1-index)+", "+(d.isDataGroup()?"True":"False")+")\n");
|
|
||||||
// send delimiter for this dimension
|
|
||||||
// if lowest dimension end of stream message
|
|
||||||
// if highest dimension no delimiter
|
|
||||||
if(index==0){
|
|
||||||
script.append(indentation + PROBE_RESOURCE_ID+".terminateStream()\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
mapActions(d.getPostAction());
|
|
||||||
} else if (dimension instanceof ContinuousDimension) {
|
|
||||||
// ContinuousDimension d = (ContinuousDimension) dimension;
|
|
||||||
// TODO Map continuous dimension
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void mapActions(List<Action> actions) {
|
|
||||||
for (Action action : actions) {
|
|
||||||
if (action instanceof ChannelAction) {
|
|
||||||
ChannelAction ca = (ChannelAction) action;
|
|
||||||
Class<?> type = String.class;
|
|
||||||
long waitTimeout=1800000; // Max wait timeout is 30 minutes
|
|
||||||
if(ca.getTimeout()!=null){
|
|
||||||
waitTimeout = ca.getTimeout().longValue()*1000; // wait timeout is currently in seconds
|
|
||||||
}
|
|
||||||
ca.getTimeout();
|
|
||||||
switch (ca.getType()) {
|
|
||||||
case "Integer":
|
|
||||||
type = Integer.class;
|
|
||||||
break;
|
|
||||||
case "Double":
|
|
||||||
type = Double.class;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
String var = getChannelResourceVariable(ca.getChannel(), type, false);
|
|
||||||
switch (ca.getOperation()) {
|
|
||||||
case "put":
|
|
||||||
if(ca.getTimeout()==null){
|
|
||||||
script.append(var+".setValue("+getPythonValue(ca.getValue(), type)+")\n");
|
|
||||||
} else {
|
|
||||||
imports.add("from java.util.concurrent import TimeUnit");
|
|
||||||
script.append(var+".setValueAsync("+getPythonValue(ca.getValue(), type)+").get("+ca.getTimeout()+", TimeUnit.MILLISECONDS)\n");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "putq":
|
|
||||||
script.append(var+".setValueNoWait("+getPythonValue(ca.getValue(), type)+")\n");
|
|
||||||
break;
|
|
||||||
case "wait":
|
|
||||||
script.append(var+".waitForValue("+getPythonValue(ca.getValue(), type)+", "+waitTimeout+")\n");
|
|
||||||
break;
|
|
||||||
case "waitREGEX":
|
|
||||||
imports.add("from"+ComparatorREGEX.class.getPackage().getName()+" import "+ComparatorREGEX.class.getName());
|
|
||||||
script.append(var+".waitForValue("+getPythonValue(ca.getValue(), type)+", "+ComparatorREGEX.class.getName()+"() "+waitTimeout+")\n");
|
|
||||||
break;
|
|
||||||
case "waitOR":
|
|
||||||
imports.add("from"+ComparatorOR.class.getPackage().getName()+" import "+ComparatorOR.class.getName());
|
|
||||||
script.append(var+".waitForValue("+getPythonValue(ca.getValue(), type)+", "+ComparatorOR.class.getName()+"() "+waitTimeout+")\n");
|
|
||||||
break;
|
|
||||||
case "waitAND":
|
|
||||||
imports.add("from"+ComparatorAND.class.getPackage().getName()+" import "+ComparatorAND.class.getName());
|
|
||||||
script.append(var+".waitForValue("+getPythonValue(ca.getValue(), type)+", "+ComparatorAND.class.getName()+"() "+waitTimeout+")\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
logger.warning("Operation - "+ca.getOperation()+" - is not supported");
|
|
||||||
// TODO Eventually throw exception - have two modes one logging, one exception?
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If delay is specified wait specified time
|
|
||||||
if (ca.getDelay() != null) {
|
|
||||||
imports.add("import time");
|
|
||||||
script.append("time.sleep(" + (ca.getDelay()) + ")\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (action instanceof ShellAction) {
|
|
||||||
ShellAction saction = (ShellAction) action;
|
|
||||||
resourceDescriptors.put(SHELL_RESOURCE_ID, new ShellDescriptor());
|
|
||||||
// TODO Need to indicate that shell resource is required
|
|
||||||
script.append(indentation + String.format(SHELL_RESOURCE_ID+".execute('%s', %d, %s)\n", saction.getCommand(), saction.getExitValue(), saction.isCheckExitValue()?"True":"False"));
|
|
||||||
} else if (action instanceof ScriptAction) {
|
|
||||||
ScriptAction saction = (ScriptAction) action;
|
|
||||||
|
|
||||||
// TODO Need to indicate that that mapped resources are required
|
|
||||||
// Read script line by line and prepend the current indentation
|
|
||||||
// level
|
|
||||||
String[] lines = saction.getScript().split(System.getProperty("line.separator"));
|
|
||||||
for (String s : lines) {
|
|
||||||
script.append(indentation + s+"\n");
|
|
||||||
}
|
|
||||||
script.append(indentation + "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get unique variable names that do not collide with others. (at least have
|
|
||||||
* an extreme unlikeness to do so)
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String getUniqueVariableName() {
|
|
||||||
return "v" + UUID.randomUUID().toString().replaceAll("-", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the string representation for a variable in python
|
|
||||||
* i.e. surrounds String with '', ensures that double has a . in the value, ...
|
|
||||||
* @param value
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String getPythonValue(String value, Class<?> type){
|
|
||||||
if(type.equals(String.class)){
|
|
||||||
return "'"+value+"'";
|
|
||||||
}
|
|
||||||
else if(type.equals(Double.class)){
|
|
||||||
return String.format("%f", new Double(value));
|
|
||||||
}
|
|
||||||
else if(type.equals(Integer.class)){
|
|
||||||
return String.format("%d", new Integer(value));
|
|
||||||
}
|
|
||||||
return value.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request resource
|
|
||||||
*
|
|
||||||
* @param resourceId
|
|
||||||
* @return variable name for resource
|
|
||||||
*
|
|
||||||
* TODO Eventually we need to add type of resource here to be able
|
|
||||||
* to generate the resource before the script is executed.
|
|
||||||
*/
|
|
||||||
private String getChannelResourceVariable(String channelName, Class<?> type, boolean monitor) {
|
|
||||||
// Right now each a new channel object will be created for each requirested channel resource (even it is the same channel)
|
|
||||||
// TODO Optimize the resource consumption by checking whether the resource already exists and return only one reference.
|
|
||||||
String varname = getUniqueVariableName();
|
|
||||||
resourceDescriptors.put(varname, new ChannelDescriptor<>(type, channelName, monitor));
|
|
||||||
return varname;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng.rdescriptors;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ebner
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ProbeDescriptor {
|
|
||||||
|
|
||||||
private List<ChannelDescriptor<?>> sensors = new ArrayList<>();
|
|
||||||
|
|
||||||
public List<ChannelDescriptor<?>> getSensors(){
|
|
||||||
return sensors;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng.rdescriptors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resource descriptor of an operating system shell.
|
|
||||||
* @author ebner
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ShellDescriptor {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng.resources;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import ch.psi.fda.core.messages.DataMessage;
|
|
||||||
import ch.psi.fda.core.messages.EndOfStreamMessage;
|
|
||||||
import ch.psi.fda.core.messages.Message;
|
|
||||||
import ch.psi.fda.core.messages.StreamDelimiterMessage;
|
|
||||||
import ch.psi.jcae.Channel;
|
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ebner
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ChannelProbeResource {
|
|
||||||
|
|
||||||
private final List<Channel<?>> channels;
|
|
||||||
private BlockingQueue<Message> queue;
|
|
||||||
|
|
||||||
public ChannelProbeResource(List<Channel<?>> channels, BlockingQueue<Message> queue){
|
|
||||||
this.channels = channels;
|
|
||||||
this.queue = queue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read configured channels and send out data message
|
|
||||||
*/
|
|
||||||
public void read(){
|
|
||||||
try{
|
|
||||||
DataMessage message = new DataMessage();
|
|
||||||
for(Channel<?> sensor: channels){
|
|
||||||
// Readout sensor
|
|
||||||
Object o = sensor.getValue();
|
|
||||||
// Add sensor data item to message
|
|
||||||
message.getData().add(o);
|
|
||||||
}
|
|
||||||
System.out.println("MESSAGE: "+message);
|
|
||||||
queue.put(message);
|
|
||||||
} catch (InterruptedException | TimeoutException | ChannelException | ExecutionException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a stream delimiter message for the given index
|
|
||||||
* @param index
|
|
||||||
* @param iflag
|
|
||||||
*/
|
|
||||||
public void delimiter(int index, boolean iflag){
|
|
||||||
try {
|
|
||||||
StreamDelimiterMessage message = new StreamDelimiterMessage(index, iflag);
|
|
||||||
System.out.println(message);
|
|
||||||
queue.put(message);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException("Unable to send delimiter message", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send end of stream message
|
|
||||||
*/
|
|
||||||
public void terminateStream(){
|
|
||||||
try {
|
|
||||||
EndOfStreamMessage message = new EndOfStreamMessage();
|
|
||||||
System.out.println(message);
|
|
||||||
queue.put(message);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException("Unable to send end of stream message", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng.resources;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ebner
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ShellResource {
|
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(ShellResource.class.getName());
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute script/command in shell
|
|
||||||
* @param script
|
|
||||||
*/
|
|
||||||
public void execute(String script){
|
|
||||||
execute(script, 0, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute script/command in shell
|
|
||||||
* @param script
|
|
||||||
* @param returnValue
|
|
||||||
* @param checkReturnValue
|
|
||||||
*/
|
|
||||||
public void execute(String script, int returnValue, boolean checkReturnValue){
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(new String[]{"/bin/bash","-c",script});
|
|
||||||
pb.redirectErrorStream(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Process p = pb.start();
|
|
||||||
int rvalue = p.waitFor();
|
|
||||||
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
|
||||||
String line = null;
|
|
||||||
while((line=reader.readLine()) != null){
|
|
||||||
logger.info(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check return value if need to be checked
|
|
||||||
if(checkReturnValue){
|
|
||||||
if(rvalue != returnValue){
|
|
||||||
throw new RuntimeException("Executing script "+script+" failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException | InterruptedException e) {
|
|
||||||
throw new RuntimeException("Unable to execute script", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,15 +2,15 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2010 Paul Scherrer Institute. All rights reserved.
|
* Copyright 2010 Paul Scherrer Institute. All rights reserved.
|
||||||
*
|
*
|
||||||
* This code is free software: you can redistribute it and/or modify it under
|
* This code is free software: you can redistribute it and/or modify
|
||||||
* the terms of the GNU Lesser General Public License as published by the Free
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This code is distributed in the hope that it will be useful, but without any
|
* This code is distributed in the hope that it will be useful,
|
||||||
* warranty; without even the implied warranty of merchantability or fitness for
|
* but without any warranty; without even the implied warranty of
|
||||||
* a particular purpose. See the GNU Lesser General Public License for more
|
* merchantability or fitness for a particular purpose. See the
|
||||||
* details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with this code. If not, see <http://www.gnu.org/licenses/>.
|
* along with this code. If not, see <http://www.gnu.org/licenses/>.
|
||||||
@@ -19,145 +19,124 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.actions;
|
package ch.psi.fda.core.actions;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
import ch.psi.fda.core.Action;
|
import ch.psi.fda.core.Action;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a put on the specified Channel Access channel. The put can be done
|
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
|
||||||
* synchronous or asynchronously.
|
* asynchronously.
|
||||||
*
|
|
||||||
* @author ebner
|
* @author ebner
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ChannelAccessCondition<E> implements Action {
|
public class ChannelAccessCondition<E> implements Action {
|
||||||
|
|
||||||
// Get Logger
|
// Get Logger
|
||||||
private static Logger logger = Logger.getLogger(ChannelAccessCondition.class.getName());
|
private static Logger logger = Logger.getLogger(ChannelAccessCondition.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel to set
|
* Channel to set
|
||||||
*/
|
*/
|
||||||
private final Channel<E> channel;
|
private final ChannelBean<E> channel;
|
||||||
/**
|
/**
|
||||||
* Value to wait for
|
* Value to wait for
|
||||||
*/
|
*/
|
||||||
private final E expectedValue;
|
private final E expectedValue;
|
||||||
|
|
||||||
private Long timeout;
|
private final Long timeout;
|
||||||
|
|
||||||
private volatile boolean abort = false;
|
private volatile boolean abort = false;
|
||||||
private volatile Thread waitT = null;
|
private volatile Thread waitT = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
* @param channelName Name of the channel to set the value
|
||||||
|
* @param expectedValue Value to wait for
|
||||||
|
* @param timeout Timeout of the condition in milliseconds (null accepted - will take default wait timeout for channels ch.psi.jcae.ChannelBeanFactory.waitTimeout)
|
||||||
*
|
*
|
||||||
* @param channelName
|
* @throws IllegalArgumentException Unable to initialize channel,
|
||||||
* Name of the channel to set the value
|
* Timeout specified is not >=0
|
||||||
* @param expectedValue
|
|
||||||
* Value to wait for
|
|
||||||
* @param timeout
|
|
||||||
* Timeout of the condition in milliseconds (null accepted - will
|
|
||||||
* take default wait timeout for channels
|
|
||||||
* ch.psi.jcae.ChannelBeanFactory.waitTimeout)
|
|
||||||
*
|
|
||||||
* @throws IllegalArgumentException
|
|
||||||
* Unable to initialize channel, Timeout specified is not >=0
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ChannelAccessCondition(ChannelService s, String channelName, E expectedValue, Long timeout) {
|
public ChannelAccessCondition(String channelName, E expectedValue, Long timeout){
|
||||||
|
|
||||||
if (timeout != null && timeout <= 0) {
|
if(timeout !=null && timeout<=0){
|
||||||
throw new IllegalArgumentException("Timeout must be > 0");
|
throw new IllegalArgumentException("Timeout must be > 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.channel = (Channel<E>) s.createChannel(new ChannelDescriptor<>(expectedValue.getClass(), channelName, false));
|
this.channel = (ChannelBean<E>) ChannelBeanFactory.getFactory().createChannelBean( (Class<E>) expectedValue.getClass(), channelName, false);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:" + channelName + "]", e);
|
// Convert Exception into unchecked RuntimeException
|
||||||
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException("Unable to initialize actuator channel [name:" + channelName + "]", e);
|
throw new RuntimeException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.expectedValue = expectedValue;
|
this.expectedValue = expectedValue;
|
||||||
|
|
||||||
if (timeout == null) {
|
if(timeout==null){
|
||||||
// this.timeout = channel.get.getWaitTimeout();
|
this.timeout = channel.getWaitTimeout();
|
||||||
this.timeout=1L;
|
}
|
||||||
} else {
|
else{
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
*
|
|
||||||
* @see ch.psi.fda.core.Action#execute()
|
* @see ch.psi.fda.core.Action#execute()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException Channel value did not reach expected value (within the specified timeout period)
|
||||||
* Channel value did not reach expected value (within the
|
|
||||||
* specified timeout period)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws InterruptedException {
|
public void execute() throws InterruptedException {
|
||||||
abort = false;
|
abort=false;
|
||||||
logger.finest("Checking channel " + channel.getName() + " for value " + expectedValue + " [timeout: " + timeout + "]");
|
logger.finest("Checking channel "+channel.getName()+" for value "+expectedValue+" [timeout: "+timeout+"]" );
|
||||||
try {
|
try{
|
||||||
waitT = Thread.currentThread();
|
waitT = Thread.currentThread();
|
||||||
channel.waitForValueAsync(expectedValue).get(timeout, TimeUnit.MILLISECONDS); // Workaround use
|
channel.waitForValue(expectedValue, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value
|
||||||
// 10seconds default
|
} catch (CAException e) {
|
||||||
// set timeout to
|
throw new RuntimeException("Channel [name:"+channel.getName()+"] did not reach expected value "+expectedValue+" ", e);
|
||||||
// check several
|
} catch(InterruptedException e){
|
||||||
// times whether the
|
if(!abort){
|
||||||
// channel has
|
|
||||||
// reached the value
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
if (!abort) {
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
} catch (ExecutionException | TimeoutException | ChannelException e) {
|
}
|
||||||
throw new RuntimeException("Channel [name:" + channel.getName() + "] did not reach expected value " + expectedValue + " ", e);
|
finally{
|
||||||
} finally {
|
waitT=null;
|
||||||
waitT = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* (non-Javadoc)
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see ch.psi.fda.core.Action#abort()
|
* @see ch.psi.fda.core.Action#abort()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void abort() {
|
public void abort() {
|
||||||
abort = true;
|
abort=true;
|
||||||
if (waitT != null) {
|
if(waitT!=null){
|
||||||
waitT.interrupt();
|
waitT.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
*
|
|
||||||
* @see ch.psi.fda.core.Action#destroy()
|
* @see ch.psi.fda.core.Action#destroy()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
// Destroy channel
|
// Destroy channel
|
||||||
logger.finest("Destroy action channel: " + channel.getName());
|
try {
|
||||||
try {
|
logger.finest("Destroy action channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel [" + channel.getName() + "]", e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,15 +20,12 @@
|
|||||||
package ch.psi.fda.core.actions;
|
package ch.psi.fda.core.actions;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
import ch.psi.fda.core.Action;
|
import ch.psi.fda.core.Action;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
|
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
|
||||||
@@ -44,7 +41,7 @@ public class ChannelAccessConditionAnd<E extends Integer> implements Action {
|
|||||||
/**
|
/**
|
||||||
* Channel to set
|
* Channel to set
|
||||||
*/
|
*/
|
||||||
private final Channel<E> channel;
|
private final ChannelBean<E> channel;
|
||||||
/**
|
/**
|
||||||
* Value to wait for
|
* Value to wait for
|
||||||
*/
|
*/
|
||||||
@@ -65,15 +62,15 @@ public class ChannelAccessConditionAnd<E extends Integer> implements Action {
|
|||||||
* Timeout specified is not >=0
|
* Timeout specified is not >=0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ChannelAccessConditionAnd(ChannelService s, String channelName, E expectedValue, Long timeout){
|
public ChannelAccessConditionAnd(String channelName, E expectedValue, Long timeout){
|
||||||
|
|
||||||
if(timeout !=null && timeout<=0){
|
if(timeout !=null && timeout<=0){
|
||||||
throw new IllegalArgumentException("Timeout must be > 0");
|
throw new IllegalArgumentException("Timeout must be > 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.channel = s.createChannel(new ChannelDescriptor<>( (Class<E>) expectedValue.getClass(), channelName, false));
|
this.channel = (ChannelBean<E>) ChannelBeanFactory.getFactory().createChannelBean( (Class<E>) expectedValue.getClass(), channelName, false);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -83,8 +80,7 @@ public class ChannelAccessConditionAnd<E extends Integer> implements Action {
|
|||||||
this.expectedValue = expectedValue;
|
this.expectedValue = expectedValue;
|
||||||
|
|
||||||
if(timeout==null){
|
if(timeout==null){
|
||||||
// this.timeout = channel.getWaitTimeout();
|
this.timeout = channel.getWaitTimeout();
|
||||||
this.timeout = 0L;
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
@@ -118,7 +114,7 @@ public class ChannelAccessConditionAnd<E extends Integer> implements Action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value
|
, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value
|
||||||
} catch (ChannelException | ExecutionException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Channel [name:"+channel.getName()+"] did not reach expected value "+expectedValue+" ", e);
|
throw new RuntimeException("Channel [name:"+channel.getName()+"] did not reach expected value "+expectedValue+" ", e);
|
||||||
} catch(InterruptedException e){
|
} catch(InterruptedException e){
|
||||||
if(!abort){
|
if(!abort){
|
||||||
@@ -151,7 +147,7 @@ public class ChannelAccessConditionAnd<E extends Integer> implements Action {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy action channel: "+channel.getName());
|
logger.finest("Destroy action channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,15 +20,12 @@
|
|||||||
package ch.psi.fda.core.actions;
|
package ch.psi.fda.core.actions;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
import ch.psi.fda.core.Action;
|
import ch.psi.fda.core.Action;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
|
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
|
||||||
@@ -44,7 +41,7 @@ public class ChannelAccessConditionOr<E extends Integer> implements Action {
|
|||||||
/**
|
/**
|
||||||
* Channel to set
|
* Channel to set
|
||||||
*/
|
*/
|
||||||
private final Channel<E> channel;
|
private final ChannelBean<E> channel;
|
||||||
/**
|
/**
|
||||||
* Value to wait for
|
* Value to wait for
|
||||||
*/
|
*/
|
||||||
@@ -65,15 +62,15 @@ public class ChannelAccessConditionOr<E extends Integer> implements Action {
|
|||||||
* Timeout specified is not >=0
|
* Timeout specified is not >=0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ChannelAccessConditionOr(ChannelService s, String channelName, E expectedValue, Long timeout){
|
public ChannelAccessConditionOr(String channelName, E expectedValue, Long timeout){
|
||||||
|
|
||||||
if(timeout !=null && timeout<=0){
|
if(timeout !=null && timeout<=0){
|
||||||
throw new IllegalArgumentException("Timeout must be > 0");
|
throw new IllegalArgumentException("Timeout must be > 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.channel = s.createChannel(new ChannelDescriptor<>( (Class<E>) expectedValue.getClass(), channelName, false));
|
this.channel = (ChannelBean<E>) ChannelBeanFactory.getFactory().createChannelBean( (Class<E>) expectedValue.getClass(), channelName, false);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -83,8 +80,7 @@ public class ChannelAccessConditionOr<E extends Integer> implements Action {
|
|||||||
this.expectedValue = expectedValue;
|
this.expectedValue = expectedValue;
|
||||||
|
|
||||||
if(timeout==null){
|
if(timeout==null){
|
||||||
// this.timeout = channel.getWaitTimeout();
|
this.timeout = channel.getWaitTimeout();
|
||||||
this.timeout = 0L;
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
@@ -118,7 +114,7 @@ public class ChannelAccessConditionOr<E extends Integer> implements Action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value
|
, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value
|
||||||
} catch (ChannelException | ExecutionException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Channel [name:"+channel.getName()+"] did not reach expected value "+expectedValue+" ", e);
|
throw new RuntimeException("Channel [name:"+channel.getName()+"] did not reach expected value "+expectedValue+" ", e);
|
||||||
} catch(InterruptedException e){
|
} catch(InterruptedException e){
|
||||||
if(!abort){
|
if(!abort){
|
||||||
@@ -151,7 +147,7 @@ public class ChannelAccessConditionOr<E extends Integer> implements Action {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy action channel: "+channel.getName());
|
logger.finest("Destroy action channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,15 +20,12 @@
|
|||||||
package ch.psi.fda.core.actions;
|
package ch.psi.fda.core.actions;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
import ch.psi.fda.core.Action;
|
import ch.psi.fda.core.Action;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
|
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
|
||||||
@@ -44,7 +41,7 @@ public class ChannelAccessConditionRegex<E extends String> implements Action {
|
|||||||
/**
|
/**
|
||||||
* Channel to set
|
* Channel to set
|
||||||
*/
|
*/
|
||||||
private final Channel<E> channel;
|
private final ChannelBean<E> channel;
|
||||||
/**
|
/**
|
||||||
* Value to wait for
|
* Value to wait for
|
||||||
*/
|
*/
|
||||||
@@ -65,15 +62,15 @@ public class ChannelAccessConditionRegex<E extends String> implements Action {
|
|||||||
* Timeout specified is not >=0
|
* Timeout specified is not >=0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ChannelAccessConditionRegex(ChannelService s, String channelName, E expectedValue, Long timeout){
|
public ChannelAccessConditionRegex(String channelName, E expectedValue, Long timeout){
|
||||||
|
|
||||||
if(timeout !=null && timeout<=0){
|
if(timeout !=null && timeout<=0){
|
||||||
throw new IllegalArgumentException("Timeout must be > 0");
|
throw new IllegalArgumentException("Timeout must be > 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.channel = s.createChannel(new ChannelDescriptor<>( (Class<E>) expectedValue.getClass(), channelName, false));
|
this.channel = (ChannelBean<E>) ChannelBeanFactory.getFactory().createChannelBean( (Class<E>) expectedValue.getClass(), channelName, false);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -83,8 +80,7 @@ public class ChannelAccessConditionRegex<E extends String> implements Action {
|
|||||||
this.expectedValue = expectedValue;
|
this.expectedValue = expectedValue;
|
||||||
|
|
||||||
if(timeout==null){
|
if(timeout==null){
|
||||||
// this.timeout = channel.getWaitTimeout();
|
this.timeout = channel.getWaitTimeout();
|
||||||
this.timeout = 0L;
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
@@ -112,7 +108,7 @@ public class ChannelAccessConditionRegex<E extends String> implements Action {
|
|||||||
return o1.matches(o2) ? 0:1;
|
return o1.matches(o2) ? 0:1;
|
||||||
}
|
}
|
||||||
}, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value
|
}, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value
|
||||||
} catch (ChannelException | ExecutionException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Channel [name:"+channel.getName()+"] did not reach expected value "+expectedValue+" ", e);
|
throw new RuntimeException("Channel [name:"+channel.getName()+"] did not reach expected value "+expectedValue+" ", e);
|
||||||
} catch(InterruptedException e){
|
} catch(InterruptedException e){
|
||||||
if(!abort){
|
if(!abort){
|
||||||
@@ -145,7 +141,7 @@ public class ChannelAccessConditionRegex<E extends String> implements Action {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy action channel: "+channel.getName());
|
logger.finest("Destroy action channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,16 +19,12 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.actions;
|
package ch.psi.fda.core.actions;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
import ch.psi.fda.core.Action;
|
import ch.psi.fda.core.Action;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
|
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
|
||||||
@@ -44,7 +40,7 @@ public class ChannelAccessPut<E> implements Action {
|
|||||||
/**
|
/**
|
||||||
* Channel to set
|
* Channel to set
|
||||||
*/
|
*/
|
||||||
private final Channel<E> channel;
|
private final ChannelBean<E> channel;
|
||||||
/**
|
/**
|
||||||
* Value to set
|
* Value to set
|
||||||
*/
|
*/
|
||||||
@@ -66,11 +62,11 @@ public class ChannelAccessPut<E> implements Action {
|
|||||||
* @throws IllegalArgumentException Unable to initialize channel
|
* @throws IllegalArgumentException Unable to initialize channel
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ChannelAccessPut(ChannelService s, String channelName, E value, boolean asynchronous, Long timeout){
|
public ChannelAccessPut(String channelName, E value, boolean asynchronous, Long timeout){
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.channel = s.createChannel(new ChannelDescriptor<>((Class<E>)value.getClass(), channelName, false));
|
this.channel = ChannelBeanFactory.getFactory().createChannelBean((Class<E>)value.getClass(), channelName, false);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -89,8 +85,8 @@ public class ChannelAccessPut<E> implements Action {
|
|||||||
*
|
*
|
||||||
* @throws RuntimeException Unable to initialize channel
|
* @throws RuntimeException Unable to initialize channel
|
||||||
*/
|
*/
|
||||||
public ChannelAccessPut(ChannelService s, String channelName, E value){
|
public ChannelAccessPut(String channelName, E value){
|
||||||
this(s, channelName, value, false, null);
|
this(channelName, value, false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -112,10 +108,10 @@ public class ChannelAccessPut<E> implements Action {
|
|||||||
channel.setValue(value);
|
channel.setValue(value);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
channel.setValueAsync(value).get(timeout, TimeUnit.MILLISECONDS);
|
channel.setValue(value, timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ChannelException | ExecutionException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new RuntimeException("Unable to set channel [name:"+channel.getName()+"] to value "+value, e);
|
throw new RuntimeException("Unable to set channel [name:"+channel.getName()+"] to value "+value, e);
|
||||||
}
|
}
|
||||||
@@ -138,7 +134,7 @@ public class ChannelAccessPut<E> implements Action {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy action channel: "+channel.getName());
|
logger.finest("Destroy action channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,11 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.actions;
|
package ch.psi.fda.core.actions;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -32,10 +35,8 @@ import javax.script.ScriptException;
|
|||||||
import ch.psi.fda.core.Action;
|
import ch.psi.fda.core.Action;
|
||||||
import ch.psi.fda.core.scripting.JythonParameterMapping;
|
import ch.psi.fda.core.scripting.JythonParameterMapping;
|
||||||
import ch.psi.fda.core.scripting.JythonParameterMappingChannel;
|
import ch.psi.fda.core.scripting.JythonParameterMappingChannel;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -61,8 +62,10 @@ public class JythonAction implements Action {
|
|||||||
* Jython entry call
|
* Jython entry call
|
||||||
*/
|
*/
|
||||||
private String jythonCall;
|
private String jythonCall;
|
||||||
|
|
||||||
|
private Map<String,Object> gvariables = new HashMap<String,Object>();
|
||||||
|
|
||||||
public JythonAction(ChannelService s, String script, List<JythonParameterMappingChannel> mapping){
|
public JythonAction(String script, List<JythonParameterMappingChannel> mapping){
|
||||||
|
|
||||||
// Workaround for Jython memory leak
|
// Workaround for Jython memory leak
|
||||||
// http://blog.hillbrecht.de/2009/07/11/jython-memory-leakout-of-memory-problem/
|
// http://blog.hillbrecht.de/2009/07/11/jython-memory-leakout-of-memory-problem/
|
||||||
@@ -77,7 +80,12 @@ public class JythonAction implements Action {
|
|||||||
String[] functionParameters = null;
|
String[] functionParameters = null;
|
||||||
if(matcher.find() && matcher.groupCount()==1){
|
if(matcher.find() && matcher.groupCount()==1){
|
||||||
logger.finest("Entry function '"+entryFunctionPattern+"' found - Identified parameters: "+matcher.group(1));
|
logger.finest("Entry function '"+entryFunctionPattern+"' found - Identified parameters: "+matcher.group(1));
|
||||||
functionParameters = matcher.group(1).split(" *, *");
|
if(matcher.group(1).matches(" *")){
|
||||||
|
functionParameters = new String[0];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functionParameters = matcher.group(1).split(" *, *");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
throw new IllegalArgumentException("Cannot determine entry function: "+entryFunctionPattern);
|
throw new IllegalArgumentException("Cannot determine entry function: "+entryFunctionPattern);
|
||||||
@@ -113,14 +121,14 @@ public class JythonAction implements Action {
|
|||||||
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append(entryFunction);
|
buffer.append(entryFunction);
|
||||||
buffer.append("(");
|
buffer.append("( "); // Need to have trailing space as otherwise there will be a problem if no paramters are specified
|
||||||
for(JythonParameterMappingChannel b: mapping){
|
for(JythonParameterMappingChannel b: mapping){
|
||||||
// Create channel
|
// Create channel
|
||||||
|
|
||||||
Channel<?> cb;
|
ChannelBean<?> cb;
|
||||||
try {
|
try {
|
||||||
cb = s.createChannel(new ChannelDescriptor<>(b.getType(), b.getChannel(), true));
|
cb = ChannelBeanFactory.getFactory().createChannelBean(b.getType(), b.getChannel(), true);
|
||||||
} catch (TimeoutException | ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new IllegalArgumentException("Unable to establish channel: "+b.getChannel(), e);
|
throw new IllegalArgumentException("Unable to establish channel: "+b.getChannel(), e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException("Unable to establish channel: "+b.getChannel(), e);
|
throw new RuntimeException("Unable to establish channel: "+b.getChannel(), e);
|
||||||
@@ -143,6 +151,15 @@ public class JythonAction implements Action {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
|
// Set global variables - WORKAROUND gvariables
|
||||||
|
// This block is not in initialization as we want to assure that all invocations
|
||||||
|
// of this manipulation will get the same value (i.e. to prevent inconsistent behaviour
|
||||||
|
// if variable was changed during an execution of the manipulation)
|
||||||
|
for(String k: gvariables.keySet()){
|
||||||
|
engine.put(k, gvariables.get(k));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
engine.eval(jythonCall);
|
engine.eval(jythonCall);
|
||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
@@ -167,4 +184,13 @@ public class JythonAction implements Action {
|
|||||||
// Nothing to be done
|
// Nothing to be done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workaround to put variables into the jython engine.
|
||||||
|
* @param name
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public void setVariable(String name, Object value){
|
||||||
|
gvariables.put(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,17 +19,14 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.actors;
|
package ch.psi.fda.core.actors;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import gov.aps.jca.CAException;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import ch.psi.fda.core.Actor;
|
import ch.psi.fda.core.Actor;
|
||||||
import ch.psi.fda.core.EngineConfiguration;
|
import ch.psi.fda.core.EngineConfiguration;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This actuator sets an Channel Access channel from a start to an end value by doing discrete steps.
|
* This actuator sets an Channel Access channel from a start to an end value by doing discrete steps.
|
||||||
@@ -89,12 +86,12 @@ public class ChannelAccessFunctionActuator<T> implements Actor {
|
|||||||
/**
|
/**
|
||||||
* Channel Access channel of the actuator
|
* Channel Access channel of the actuator
|
||||||
*/
|
*/
|
||||||
private Channel<Double> channel;
|
private ChannelBean<Double> channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel Access channel of the actuator
|
* Channel Access channel of the actuator
|
||||||
*/
|
*/
|
||||||
private Channel<T> doneChannel = null;
|
private ChannelBean<T> doneChannel = null;
|
||||||
|
|
||||||
private final T doneValue;
|
private final T doneValue;
|
||||||
private final long doneDelay;
|
private final long doneDelay;
|
||||||
@@ -119,8 +116,8 @@ public class ChannelAccessFunctionActuator<T> implements Actor {
|
|||||||
* @param stepSize
|
* @param stepSize
|
||||||
* @param timeout Maximum move time (in milliseconds)
|
* @param timeout Maximum move time (in milliseconds)
|
||||||
*/
|
*/
|
||||||
public ChannelAccessFunctionActuator(ChannelService s, String channelName, Function function, double start, double end, double stepSize, Long timeout){
|
public ChannelAccessFunctionActuator(String channelName, Function function, double start, double end, double stepSize, Long timeout){
|
||||||
this(s, channelName, null, null, 0, function, start, end, stepSize, timeout);
|
this(channelName, null, null, 0, function, start, end, stepSize, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,7 +132,7 @@ public class ChannelAccessFunctionActuator<T> implements Actor {
|
|||||||
* @param timeout Maximum move time (in milliseconds)
|
* @param timeout Maximum move time (in milliseconds)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ChannelAccessFunctionActuator(ChannelService s, String channelName, String doneChannelName, T doneValue, double doneDelay, Function function, double start, double end, double stepSize, Long timeout){
|
public ChannelAccessFunctionActuator(String channelName, String doneChannelName, T doneValue, double doneDelay, Function function, double start, double end, double stepSize, Long timeout){
|
||||||
|
|
||||||
this.doneValue = doneValue;
|
this.doneValue = doneValue;
|
||||||
this.doneDelay = (long) Math.floor((doneDelay*1000));
|
this.doneDelay = (long) Math.floor((doneDelay*1000));
|
||||||
@@ -173,8 +170,8 @@ public class ChannelAccessFunctionActuator<T> implements Actor {
|
|||||||
|
|
||||||
// Initialize/create Channel Access channel
|
// Initialize/create Channel Access channel
|
||||||
try {
|
try {
|
||||||
channel = s.createChannel(new ChannelDescriptor<>(Double.class, channelName, false));
|
channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -182,8 +179,8 @@ public class ChannelAccessFunctionActuator<T> implements Actor {
|
|||||||
}
|
}
|
||||||
if(doneChannelName != null){
|
if(doneChannelName != null){
|
||||||
try {
|
try {
|
||||||
doneChannel = s.createChannel(new ChannelDescriptor<>((Class<T>)doneValue.getClass(), doneChannelName, false));
|
doneChannel = ChannelBeanFactory.getFactory().createChannelBean((Class<T>)doneValue.getClass(), doneChannelName, false);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+doneChannelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+doneChannelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -213,7 +210,7 @@ public class ChannelAccessFunctionActuator<T> implements Actor {
|
|||||||
channel.setValue(fvalue);
|
channel.setValue(fvalue);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
channel.setValueAsync(fvalue).get(timeout, TimeUnit.MILLISECONDS);
|
channel.setValue(fvalue, timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -234,7 +231,7 @@ public class ChannelAccessFunctionActuator<T> implements Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ChannelException | ExecutionException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new RuntimeException("Unable to move actuator [channel: "+channel.getName()+"] to value "+value,e);
|
throw new RuntimeException("Unable to move actuator [channel: "+channel.getName()+"] to value "+value,e);
|
||||||
}
|
}
|
||||||
@@ -321,7 +318,7 @@ public class ChannelAccessFunctionActuator<T> implements Actor {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy actor channel: "+channel.getName());
|
logger.finest("Destroy actor channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +327,7 @@ public class ChannelAccessFunctionActuator<T> implements Actor {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy actor done channel: "+doneChannel.getName());
|
logger.finest("Destroy actor done channel: "+doneChannel.getName());
|
||||||
doneChannel.destroy();
|
doneChannel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,17 +19,14 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.actors;
|
package ch.psi.fda.core.actors;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import gov.aps.jca.CAException;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import ch.psi.fda.core.Actor;
|
import ch.psi.fda.core.Actor;
|
||||||
import ch.psi.fda.core.EngineConfiguration;
|
import ch.psi.fda.core.EngineConfiguration;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This actuator sets an Channel Access channel from a start to an end value by doing discrete steps.
|
* This actuator sets an Channel Access channel from a start to an end value by doing discrete steps.
|
||||||
@@ -89,12 +86,12 @@ public class ChannelAccessLinearActuator<T> implements Actor {
|
|||||||
/**
|
/**
|
||||||
* Channel Access channel of the actuator
|
* Channel Access channel of the actuator
|
||||||
*/
|
*/
|
||||||
private Channel<Double> channel;
|
private ChannelBean<Double> channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel Access channel of the actuator
|
* Channel Access channel of the actuator
|
||||||
*/
|
*/
|
||||||
private Channel<T> doneChannel = null;
|
private ChannelBean<T> doneChannel = null;
|
||||||
|
|
||||||
private final T doneValue;
|
private final T doneValue;
|
||||||
private final long doneDelay;
|
private final long doneDelay;
|
||||||
@@ -122,7 +119,7 @@ public class ChannelAccessLinearActuator<T> implements Actor {
|
|||||||
* @param timeout Maximum move time (in milliseconds)
|
* @param timeout Maximum move time (in milliseconds)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ChannelAccessLinearActuator(ChannelService s, String channelName, String doneChannelName, T doneValue, double doneDelay, double start, double end, double stepSize, Long timeout){
|
public ChannelAccessLinearActuator(String channelName, String doneChannelName, T doneValue, double doneDelay, double start, double end, double stepSize, Long timeout){
|
||||||
|
|
||||||
this.doneValue = doneValue;
|
this.doneValue = doneValue;
|
||||||
this.doneDelay = (long) Math.floor((doneDelay*1000));
|
this.doneDelay = (long) Math.floor((doneDelay*1000));
|
||||||
@@ -155,8 +152,8 @@ public class ChannelAccessLinearActuator<T> implements Actor {
|
|||||||
|
|
||||||
// Initialize/create Channel Access channel
|
// Initialize/create Channel Access channel
|
||||||
try {
|
try {
|
||||||
channel = s.createChannel(new ChannelDescriptor<>(Double.class, channelName, false));
|
channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -164,8 +161,8 @@ public class ChannelAccessLinearActuator<T> implements Actor {
|
|||||||
}
|
}
|
||||||
if(doneChannelName != null){
|
if(doneChannelName != null){
|
||||||
try {
|
try {
|
||||||
doneChannel = s.createChannel(new ChannelDescriptor<>((Class<T>) doneValue.getClass(), doneChannelName, false));
|
doneChannel = ChannelBeanFactory.getFactory().createChannelBean((Class<T>) doneValue.getClass(), doneChannelName, false);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+doneChannelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+doneChannelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -194,7 +191,7 @@ public class ChannelAccessLinearActuator<T> implements Actor {
|
|||||||
channel.setValue(value);
|
channel.setValue(value);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
channel.setValueAsync(value).get(timeout, TimeUnit.MILLISECONDS);
|
channel.setValue(value, timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -215,7 +212,7 @@ public class ChannelAccessLinearActuator<T> implements Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ChannelException | TimeoutException | ExecutionException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new RuntimeException("Unable to move actuator [channel: "+channel.getName()+"] to value "+value,e);
|
throw new RuntimeException("Unable to move actuator [channel: "+channel.getName()+"] to value "+value,e);
|
||||||
}
|
}
|
||||||
@@ -298,7 +295,7 @@ public class ChannelAccessLinearActuator<T> implements Actor {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy actor channel: "+channel.getName());
|
logger.finest("Destroy actor channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +304,7 @@ public class ChannelAccessLinearActuator<T> implements Actor {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy actor done channel: "+doneChannel.getName());
|
logger.finest("Destroy actor done channel: "+doneChannel.getName());
|
||||||
doneChannel.destroy();
|
doneChannel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,17 +19,14 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.actors;
|
package ch.psi.fda.core.actors;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import gov.aps.jca.CAException;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import ch.psi.fda.core.Actor;
|
import ch.psi.fda.core.Actor;
|
||||||
import ch.psi.fda.core.EngineConfiguration;
|
import ch.psi.fda.core.EngineConfiguration;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This actuator sets an Channel Access channel by using the positions from the given table.
|
* This actuator sets an Channel Access channel by using the positions from the given table.
|
||||||
@@ -69,12 +66,12 @@ public class ChannelAccessTableActuator<T> implements Actor {
|
|||||||
/**
|
/**
|
||||||
* Channel Access channel of the actuator
|
* Channel Access channel of the actuator
|
||||||
*/
|
*/
|
||||||
private Channel<Double> channel;
|
private ChannelBean<Double> channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel Access channel of the actuator
|
* Channel Access channel of the actuator
|
||||||
*/
|
*/
|
||||||
private Channel<T> doneChannel = null;
|
private ChannelBean<T> doneChannel = null;
|
||||||
|
|
||||||
private final T doneValue;
|
private final T doneValue;
|
||||||
private final long doneDelay;
|
private final long doneDelay;
|
||||||
@@ -97,8 +94,8 @@ public class ChannelAccessTableActuator<T> implements Actor {
|
|||||||
* @param table Position table with the explicit positions for each step
|
* @param table Position table with the explicit positions for each step
|
||||||
* @param timeout Maximum move time (in milliseconds)
|
* @param timeout Maximum move time (in milliseconds)
|
||||||
*/
|
*/
|
||||||
public ChannelAccessTableActuator(ChannelService s, String channelName, double[] table, Long timeout){
|
public ChannelAccessTableActuator(String channelName, double[] table, Long timeout){
|
||||||
this(s, channelName, null, null, 0, table, timeout);
|
this(channelName, null, null, 0, table, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,7 +108,7 @@ public class ChannelAccessTableActuator<T> implements Actor {
|
|||||||
* @param timeout Maximum move time (in milliseconds)
|
* @param timeout Maximum move time (in milliseconds)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ChannelAccessTableActuator(ChannelService s, String channelName, String doneChannelName, T doneValue, double doneDelay, double[] table, Long timeout){
|
public ChannelAccessTableActuator(String channelName, String doneChannelName, T doneValue, double doneDelay, double[] table, Long timeout){
|
||||||
|
|
||||||
this.doneValue = doneValue;
|
this.doneValue = doneValue;
|
||||||
this.doneDelay = (long) Math.floor((doneDelay*1000));
|
this.doneDelay = (long) Math.floor((doneDelay*1000));
|
||||||
@@ -140,8 +137,8 @@ public class ChannelAccessTableActuator<T> implements Actor {
|
|||||||
|
|
||||||
// Initialize/create Channel Access channel
|
// Initialize/create Channel Access channel
|
||||||
try {
|
try {
|
||||||
channel = s.createChannel(new ChannelDescriptor<>(Double.class, channelName, false));
|
channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -150,8 +147,8 @@ public class ChannelAccessTableActuator<T> implements Actor {
|
|||||||
|
|
||||||
if(doneChannelName != null){
|
if(doneChannelName != null){
|
||||||
try {
|
try {
|
||||||
doneChannel = s.createChannel(new ChannelDescriptor<>((Class<T>)doneValue.getClass(), doneChannelName, false));
|
doneChannel = ChannelBeanFactory.getFactory().createChannelBean((Class<T>)doneValue.getClass(), doneChannelName, false);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+doneChannelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+doneChannelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -179,7 +176,7 @@ public class ChannelAccessTableActuator<T> implements Actor {
|
|||||||
channel.setValue(table[count]);
|
channel.setValue(table[count]);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
channel.setValueAsync(table[count]).get(timeout, TimeUnit.MILLISECONDS);
|
channel.setValue(table[count], timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -199,7 +196,7 @@ public class ChannelAccessTableActuator<T> implements Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ChannelException | ExecutionException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new RuntimeException("Move actuator [channel: "+channel.getName()+"] to value "+table[count],e);
|
throw new RuntimeException("Move actuator [channel: "+channel.getName()+"] to value "+table[count],e);
|
||||||
}
|
}
|
||||||
@@ -283,7 +280,7 @@ public class ChannelAccessTableActuator<T> implements Actor {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy actor channel: "+channel.getName());
|
logger.finest("Destroy actor channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +289,7 @@ public class ChannelAccessTableActuator<T> implements Actor {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy actor done channel: "+doneChannel.getName());
|
logger.finest("Destroy actor done channel: "+doneChannel.getName());
|
||||||
doneChannel.destroy();
|
doneChannel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,16 +19,15 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.guard;
|
package ch.psi.fda.core.guard;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import ch.psi.fda.core.Guard;
|
import ch.psi.fda.core.Guard;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Guard checking channels to meet a certain condition
|
* Guard checking channels to meet a certain condition
|
||||||
@@ -86,7 +85,7 @@ public class ChannelAccessGuard implements Guard {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(ChannelException | TimeoutException | ExecutionException e){
|
catch(CAException e){
|
||||||
logger.log(Level.WARNING, "Unable ", e);
|
logger.log(Level.WARNING, "Unable ", e);
|
||||||
check=false;
|
check=false;
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|||||||
@@ -19,13 +19,11 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.guard;
|
package ch.psi.fda.core.guard;
|
||||||
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import ch.psi.jcae.Channel;
|
import gov.aps.jca.CAException;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelException;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel and condition that need to be met.
|
* Channel and condition that need to be met.
|
||||||
@@ -40,7 +38,7 @@ public class ChannelAccessGuardCondition {
|
|||||||
/**
|
/**
|
||||||
* Channel name
|
* Channel name
|
||||||
*/
|
*/
|
||||||
private final Channel<?> channel;
|
private final ChannelBean<?> channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value of the channel to meet condition
|
* Value of the channel to meet condition
|
||||||
@@ -52,10 +50,10 @@ public class ChannelAccessGuardCondition {
|
|||||||
* @param channel Name of the channel that contributes to a guard
|
* @param channel Name of the channel that contributes to a guard
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
public ChannelAccessGuardCondition(ChannelService s, String channel, Object value){
|
public ChannelAccessGuardCondition(String channel, Object value){
|
||||||
try {
|
try {
|
||||||
this.channel = s.createChannel(new ChannelDescriptor<>(value.getClass(), channel, true));
|
this.channel = ChannelBeanFactory.getFactory().createChannelBean(value.getClass(), channel, true);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channel+"]",e);
|
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channel+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -67,7 +65,7 @@ public class ChannelAccessGuardCondition {
|
|||||||
/**
|
/**
|
||||||
* @return the channel
|
* @return the channel
|
||||||
*/
|
*/
|
||||||
public Channel<?> getChannel() {
|
public ChannelBean<?> getChannel() {
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +88,7 @@ public class ChannelAccessGuardCondition {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy guard condition channel: "+channel.getName());
|
logger.finest("Destroy guard condition channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,12 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.loops;
|
package ch.psi.fda.core.loops;
|
||||||
|
|
||||||
import java.util.List;
|
import gov.aps.jca.CAException;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.List;
|
||||||
|
|
||||||
import ch.psi.jcae.Channel;
|
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.annotation.CaChannel;
|
import ch.psi.jcae.annotation.CaChannel;
|
||||||
|
import ch.psi.jcae.ChannelBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean holding all OTF channels and functionality
|
* Bean holding all OTF channels and functionality
|
||||||
@@ -40,101 +39,101 @@ public class OTFBean {
|
|||||||
private long timeoutMotorOk = 8000;
|
private long timeoutMotorOk = 8000;
|
||||||
private long commandTimeout = 20000; // Maximum time until a command should take effect
|
private long commandTimeout = 20000; // Maximum time until a command should take effect
|
||||||
|
|
||||||
@CaChannel(type=String.class, name ="${PREFIX}:UMOT")
|
@CaChannel(type=String.class, name =":UMOT")
|
||||||
private Channel<String> motor;
|
private ChannelBean<String> motor;
|
||||||
|
|
||||||
@CaChannel(type=String.class, name="${PREFIX}:MENC")
|
@CaChannel(type=String.class, name=":MENC")
|
||||||
private Channel<String> encoder;
|
private ChannelBean<String> encoder;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:UBEG")
|
@CaChannel(type=Double.class, name=":UBEG")
|
||||||
private Channel<Double> begin;
|
private ChannelBean<Double> begin;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:UBEG.DRVL")
|
@CaChannel(type=Double.class, name=":UBEG.DRVL")
|
||||||
private Channel<Double> beginMin;
|
private ChannelBean<Double> beginMin;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:UBEG.DRVH")
|
@CaChannel(type=Double.class, name=":UBEG.DRVH")
|
||||||
private Channel<Double> beginMax;
|
private ChannelBean<Double> beginMax;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:UEND")
|
@CaChannel(type=Double.class, name=":UEND")
|
||||||
private Channel<Double> end;
|
private ChannelBean<Double> end;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:UEND.DRVL")
|
@CaChannel(type=Double.class, name=":UEND.DRVL")
|
||||||
private Channel<Double> endMin;
|
private ChannelBean<Double> endMin;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:UEND.DRVH")
|
@CaChannel(type=Double.class, name=":UEND.DRVH")
|
||||||
private Channel<Double> endMax;
|
private ChannelBean<Double> endMax;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:USSIZ")
|
@CaChannel(type=Double.class, name=":USSIZ")
|
||||||
private Channel<Double> stepSize;
|
private ChannelBean<Double> stepSize;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:USSIZ.DRVL")
|
@CaChannel(type=Double.class, name=":USSIZ.DRVL")
|
||||||
private Channel<Double> stepSizeMin;
|
private ChannelBean<Double> stepSizeMin;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:UITIM")
|
@CaChannel(type=Double.class, name=":UITIM")
|
||||||
private Channel<Double> integrationTime;
|
private ChannelBean<Double> integrationTime;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:UITIM.DRVL")
|
@CaChannel(type=Double.class, name=":UITIM.DRVL")
|
||||||
private Channel<Double> integrationTimeMin;
|
private ChannelBean<Double> integrationTimeMin;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:UITIM.DRVH")
|
@CaChannel(type=Double.class, name=":UITIM.DRVH")
|
||||||
private Channel<Double> integrationTimeMax;
|
private ChannelBean<Double> integrationTimeMax;
|
||||||
|
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}:UBCL")
|
@CaChannel(type=Double.class, name=":UBCL")
|
||||||
private Channel<Double> userBacklash;
|
private ChannelBean<Double> userBacklash;
|
||||||
|
|
||||||
@CaChannel(type=String.class, name="${PREFIX}:NFSSE")
|
@CaChannel(type=String.class, name=":NFSSE")
|
||||||
private Channel<String> nfsServer;
|
private ChannelBean<String> nfsServer;
|
||||||
|
|
||||||
@CaChannel(type=String.class, name="${PREFIX}:NFSSH")
|
@CaChannel(type=String.class, name=":NFSSH")
|
||||||
private Channel<String> nfsShare;
|
private ChannelBean<String> nfsShare;
|
||||||
|
|
||||||
@CaChannel(type=String.class, name="${PREFIX}:DFNAM")
|
@CaChannel(type=String.class, name=":DFNAM")
|
||||||
private Channel<String> fileName;
|
private ChannelBean<String> fileName;
|
||||||
|
|
||||||
@CaChannel(type=String.class, name="${PREFIX}:FFORM")
|
@CaChannel(type=String.class, name=":FFORM")
|
||||||
private Channel<String> fileNameFormat;
|
private ChannelBean<String> fileNameFormat;
|
||||||
|
|
||||||
@CaChannel(type=Integer.class, name="${PREFIX}:FCNT")
|
@CaChannel(type=Integer.class, name=":FCNT")
|
||||||
private Channel<Integer> fileCount;
|
private ChannelBean<Integer> fileCount;
|
||||||
|
|
||||||
@CaChannel(type=Integer.class, name="${PREFIX}:FCNT.B")
|
@CaChannel(type=Integer.class, name=":FCNT.B")
|
||||||
private Channel<Integer> resetFileCounter;
|
private ChannelBean<Integer> resetFileCounter;
|
||||||
|
|
||||||
@CaChannel(type=Boolean.class, name="${PREFIX}:FAPPE")
|
@CaChannel(type=Boolean.class, name=":FAPPE")
|
||||||
private Channel<Boolean> appendFile;
|
private ChannelBean<Boolean> appendFile;
|
||||||
|
|
||||||
@CaChannel(type=Boolean.class, name="${PREFIX}:FUSE")
|
@CaChannel(type=Boolean.class, name=":FUSE")
|
||||||
private Channel<Boolean> fileNameGeneration;
|
private ChannelBean<Boolean> fileNameGeneration;
|
||||||
|
|
||||||
@CaChannel(type=Boolean.class, name="${PREFIX}:UZIGZ")
|
@CaChannel(type=Boolean.class, name=":UZIGZ")
|
||||||
private Channel<Boolean> zigZag;
|
private ChannelBean<Boolean> zigZag;
|
||||||
|
|
||||||
@CaChannel(type=Integer.class, name="${PREFIX}:UCOM")
|
@CaChannel(type=Integer.class, name=":UCOM")
|
||||||
private Channel<Integer> command;
|
private ChannelBean<Integer> command;
|
||||||
|
|
||||||
@CaChannel(type=Boolean.class, name="${PREFIX}:SCRU", monitor=true)
|
@CaChannel(type=Boolean.class, name=":SCRU", monitor=true)
|
||||||
private Channel<Boolean> scanRunning;
|
private ChannelBean<Boolean> scanRunning;
|
||||||
|
|
||||||
@CaChannel(type=Boolean.class, name="${PREFIX}:MUENC")
|
@CaChannel(type=Boolean.class, name=":MUENC")
|
||||||
private Channel<Boolean> useEncoder;
|
private ChannelBean<Boolean> useEncoder;
|
||||||
|
|
||||||
@CaChannel(type=String.class, name={"${PREFIX}:CTM0","${PREFIX}:CTM1","${PREFIX}:CTM2","${PREFIX}:CTM3","${PREFIX}:CTM4","${PREFIX}:CTM5","${PREFIX}:CTM6","${PREFIX}:CTM7"})
|
@CaChannel(type=String.class, name={":CTM0",":CTM1",":CTM2",":CTM3",":CTM4",":CTM5",":CTM6",":CTM7"})
|
||||||
private List<Channel<String>> monitoredChannels;
|
private List<ChannelBean<String>> monitoredChannels;
|
||||||
|
|
||||||
@CaChannel(type=Boolean.class, name="${PREFIX}:OTF", monitor=true)
|
@CaChannel(type=Boolean.class, name=":OTF", monitor=true)
|
||||||
private Channel<Boolean> running;
|
private ChannelBean<Boolean> running;
|
||||||
|
|
||||||
@CaChannel(type=Integer.class, name="${PREFIX}:USTAT", monitor=true)
|
@CaChannel(type=Integer.class, name=":USTAT", monitor=true)
|
||||||
private Channel<Integer> status;
|
private ChannelBean<Integer> status;
|
||||||
|
|
||||||
@CaChannel(type=Boolean.class, name="${PREFIX}:MOK", monitor=true)
|
@CaChannel(type=Boolean.class, name=":MOK", monitor=true)
|
||||||
private Channel<Boolean> motorOk;
|
private ChannelBean<Boolean> motorOk;
|
||||||
|
|
||||||
@CaChannel(type=Boolean.class, name="${PREFIX}:EOK", monitor=true)
|
@CaChannel(type=Boolean.class, name=":EOK", monitor=true)
|
||||||
private Channel<Boolean> encoderOk;
|
private ChannelBean<Boolean> encoderOk;
|
||||||
|
|
||||||
@CaChannel(type=String.class, name="${PREFIX}:MSG")
|
@CaChannel(type=String.class, name=":MSG")
|
||||||
private Channel<String> message;
|
private ChannelBean<String> message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the trigger name that can be used by the sscan record to trigger an OTFScan
|
* Get the trigger name that can be used by the sscan record to trigger an OTFScan
|
||||||
@@ -211,7 +210,7 @@ public class OTFBean {
|
|||||||
throw new RuntimeException("OTFSCAN failed with message: "+message.getValue());
|
throw new RuntimeException("OTFSCAN failed with message: "+message.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ChannelException | ExecutionException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("An error occurred while waiting for the OTF logic to finish.", e);
|
throw new RuntimeException("An error occurred while waiting for the OTF logic to finish.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,7 +229,7 @@ public class OTFBean {
|
|||||||
throw new RuntimeException("OTFSCAN failed with message: "+message.getValue());
|
throw new RuntimeException("OTFSCAN failed with message: "+message.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ChannelException | ExecutionException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("An error occurred while waiting for the OTF logic to finish.", e);
|
throw new RuntimeException("An error occurred while waiting for the OTF logic to finish.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,10 +239,10 @@ public class OTFBean {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset OTFScan records to defaults
|
* Reset OTFScan records to defaults
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
public void resetToDefaults() throws ChannelException , ExecutionException , TimeoutException, InterruptedException{
|
public void resetToDefaults() throws CAException, InterruptedException{
|
||||||
setMonitoredChannels(new String[]{});
|
setMonitoredChannels(new String[]{});
|
||||||
setMotor("");
|
setMotor("");
|
||||||
begin.setValue(0d);
|
begin.setValue(0d);
|
||||||
@@ -268,69 +267,54 @@ public class OTFBean {
|
|||||||
/**
|
/**
|
||||||
* Get motor of the OTFScan axis
|
* Get motor of the OTFScan axis
|
||||||
* @return Name of the OTF motor
|
* @return Name of the OTF motor
|
||||||
* @throws ExecutionException
|
* @throws CAException
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
|
||||||
*/
|
*/
|
||||||
public String getMotor() throws ChannelException, InterruptedException, TimeoutException, ExecutionException {
|
public String getMotor() throws CAException, InterruptedException {
|
||||||
return(this.motor.getValue());
|
return(this.motor.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set motor of the OTFScan axis
|
* Set motor of the OTFScan axis
|
||||||
* @param motor
|
* @param motor
|
||||||
* @throws ChannelException
|
* @throws CAException
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
|
||||||
*/
|
*/
|
||||||
public void setMotor(String motor) throws InterruptedException, ExecutionException, ChannelException {
|
public void setMotor(String motor) throws CAException, InterruptedException {
|
||||||
this.motor.setValue(motor);
|
this.motor.setValue(motor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get encoder of the OTFScan axis
|
* Get encoder of the OTFScan axis
|
||||||
* @return Name of the used encoder
|
* @return Name of the used encoder
|
||||||
* @throws ExecutionException
|
* @throws CAException
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
|
||||||
*/
|
*/
|
||||||
public String getEncoder() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public String getEncoder() throws CAException, InterruptedException {
|
||||||
return(this.encoder.getValue());
|
return(this.encoder.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set encoder to use of the OTFScan axis
|
* Set encoder to use of the OTFScan axis
|
||||||
* @param encoder
|
* @param encoder
|
||||||
* @throws ChannelException
|
* @throws CAException
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
|
||||||
*/
|
*/
|
||||||
public void setEncoder(String encoder) throws InterruptedException, ExecutionException, ChannelException {
|
public void setEncoder(String encoder) throws CAException, InterruptedException {
|
||||||
this.encoder.setValue(encoder);
|
this.encoder.setValue(encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get begin position of the scan
|
* Get begin position of the scan
|
||||||
* @return Begin position scan
|
* @return Begin position scan
|
||||||
* @throws ExecutionException
|
* @throws CAException
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
|
||||||
*/
|
*/
|
||||||
public Double getBegin() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public Double getBegin() throws CAException, InterruptedException {
|
||||||
return(this.begin.getValue());
|
return(this.begin.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set begin position of scan
|
* Set begin position of scan
|
||||||
* @param begin
|
* @param begin
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void setBegin(Double begin) throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void setBegin(Double begin) throws CAException, InterruptedException {
|
||||||
|
|
||||||
if(begin==null){
|
if(begin==null){
|
||||||
throw new IllegalArgumentException("Begin position must not be null");
|
throw new IllegalArgumentException("Begin position must not be null");
|
||||||
@@ -346,48 +330,36 @@ public class OTFBean {
|
|||||||
/**
|
/**
|
||||||
* Get minimum value of the begin position
|
* Get minimum value of the begin position
|
||||||
* @return Min value for begin
|
* @return Min value for begin
|
||||||
* @throws ExecutionException
|
* @throws CAException
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
|
||||||
*/
|
*/
|
||||||
public Double getMinBegin() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public Double getMinBegin() throws CAException, InterruptedException {
|
||||||
return(this.beginMin.getValue());
|
return(this.beginMin.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get maximum value of the begin position
|
* Get maximum value of the begin position
|
||||||
* @return Max value for begin
|
* @return Max value for begin
|
||||||
* @throws ExecutionException
|
* @throws CAException
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
|
||||||
*/
|
*/
|
||||||
public Double getMaxBegin() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public Double getMaxBegin() throws CAException, InterruptedException {
|
||||||
return(this.beginMax.getValue());
|
return(this.beginMax.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get end position of the scan
|
* Get end position of the scan
|
||||||
* @return End position scan
|
* @return End position scan
|
||||||
* @throws ExecutionException
|
* @throws CAException
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
|
||||||
*/
|
*/
|
||||||
public Double getEnd() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public Double getEnd() throws CAException, InterruptedException {
|
||||||
return(this.end.getValue());
|
return(this.end.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set end positon of scan
|
* Set end positon of scan
|
||||||
* @param end
|
* @param end
|
||||||
* @throws ExecutionException
|
* @throws CAException
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
|
||||||
*/
|
*/
|
||||||
public void setEnd(Double end) throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void setEnd(Double end) throws CAException, InterruptedException {
|
||||||
|
|
||||||
if(end==null){
|
if(end==null){
|
||||||
throw new IllegalArgumentException("End position must not be null");
|
throw new IllegalArgumentException("End position must not be null");
|
||||||
@@ -403,38 +375,35 @@ public class OTFBean {
|
|||||||
/**
|
/**
|
||||||
* Get minimum value of end position
|
* Get minimum value of end position
|
||||||
* @return Min value for end
|
* @return Min value for end
|
||||||
* @throws ExecutionException
|
* @throws CAException
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
|
||||||
*/
|
*/
|
||||||
public Double getMinEnd() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public Double getMinEnd() throws CAException, InterruptedException {
|
||||||
return(this.endMin.getValue());
|
return(this.endMin.getValue());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get maximum value of end position
|
* Get maximum value of end position
|
||||||
* @return Max value for end
|
* @return Max value for end
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public Double getMaxEnd() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public Double getMaxEnd() throws CAException, InterruptedException {
|
||||||
return(this.endMax.getValue());
|
return(this.endMax.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get scan step size
|
* Get scan step size
|
||||||
* @return Step size
|
* @return Step size
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public Double getStepSize() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public Double getStepSize() throws CAException, InterruptedException {
|
||||||
return(this.stepSize.getValue());
|
return(this.stepSize.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set step size of scan
|
* Set step size of scan
|
||||||
* @param stepSize
|
* @param stepSize
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void setStepSize(Double stepSize) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setStepSize(Double stepSize) throws CAException, InterruptedException {
|
||||||
|
|
||||||
if(integrationTime==null){
|
if(integrationTime==null){
|
||||||
throw new IllegalArgumentException("Step size must not be null");
|
throw new IllegalArgumentException("Step size must not be null");
|
||||||
@@ -454,27 +423,27 @@ public class OTFBean {
|
|||||||
/**
|
/**
|
||||||
* Get minimum integration time
|
* Get minimum integration time
|
||||||
* @return Min value for step size
|
* @return Min value for step size
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public double getMinStepSize() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public double getMinStepSize() throws CAException, InterruptedException {
|
||||||
return(this.stepSizeMin.getValue());
|
return(this.stepSizeMin.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get scan integration time (time that is spend in one step)
|
* Get scan integration time (time that is spend in one step)
|
||||||
* @return Integration time
|
* @return Integration time
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public Double getIntegrationTime() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public Double getIntegrationTime() throws CAException, InterruptedException {
|
||||||
return(this.integrationTime.getValue());
|
return(this.integrationTime.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set integration time of scan
|
* Set integration time of scan
|
||||||
* @param integrationTime
|
* @param integrationTime
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void setIntegrationTime(Double integrationTime) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setIntegrationTime(Double integrationTime) throws CAException, InterruptedException {
|
||||||
|
|
||||||
if(integrationTime==null){
|
if(integrationTime==null){
|
||||||
throw new IllegalArgumentException("Integration time must not be null");
|
throw new IllegalArgumentException("Integration time must not be null");
|
||||||
@@ -503,35 +472,35 @@ public class OTFBean {
|
|||||||
/**
|
/**
|
||||||
* Get minimum integration time
|
* Get minimum integration time
|
||||||
* @return Min value for integration time
|
* @return Min value for integration time
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public Double getMinIntegrationTime() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public Double getMinIntegrationTime() throws CAException, InterruptedException {
|
||||||
return(this.integrationTimeMin.getValue());
|
return(this.integrationTimeMin.getValue());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get maximum integration time
|
* Get maximum integration time
|
||||||
* @return Max value for integration time
|
* @return Max value for integration time
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public Double getMaxIntegrationTime() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public Double getMaxIntegrationTime() throws CAException, InterruptedException {
|
||||||
return(this.integrationTimeMax.getValue());
|
return(this.integrationTimeMax.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get additional user defined backlash
|
* Get additional user defined backlash
|
||||||
* @return User backlash
|
* @return User backlash
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public Double getUserBacklash() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public Double getUserBacklash() throws CAException, InterruptedException {
|
||||||
return(this.userBacklash.getValue());
|
return(this.userBacklash.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set additional user defined backlash
|
* Set additional user defined backlash
|
||||||
* @param userBacklash
|
* @param userBacklash
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void setUserBacklash(Double userBacklash) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setUserBacklash(Double userBacklash) throws CAException, InterruptedException {
|
||||||
if(userBacklash==null){
|
if(userBacklash==null){
|
||||||
throw new IllegalArgumentException("User backlash must not be null");
|
throw new IllegalArgumentException("User backlash must not be null");
|
||||||
}
|
}
|
||||||
@@ -542,63 +511,63 @@ public class OTFBean {
|
|||||||
/**
|
/**
|
||||||
* Get the current NFS server the data is written to
|
* Get the current NFS server the data is written to
|
||||||
* @return Name of NFS server
|
* @return Name of NFS server
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public String getNfsServer() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public String getNfsServer() throws CAException, InterruptedException {
|
||||||
return(this.nfsServer.getValue());
|
return(this.nfsServer.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set name of the NFS server the data is written to
|
* Set name of the NFS server the data is written to
|
||||||
* @param nfsServer
|
* @param nfsServer
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void setNfsServer(String nfsServer) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setNfsServer(String nfsServer) throws CAException, InterruptedException {
|
||||||
this.nfsServer.setValue(nfsServer);
|
this.nfsServer.setValue(nfsServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the NFS share the data is written to
|
* Get the NFS share the data is written to
|
||||||
* @return Name of NFS share
|
* @return Name of NFS share
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public String getNfsShare() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public String getNfsShare() throws CAException, InterruptedException {
|
||||||
return(this.nfsShare.getValue());
|
return(this.nfsShare.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set name of the NFS share the data is written to
|
* Set name of the NFS share the data is written to
|
||||||
* @param nfsShare
|
* @param nfsShare
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void setNfsShare(String nfsShare) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setNfsShare(String nfsShare) throws CAException, InterruptedException {
|
||||||
this.nfsShare.setValue(nfsShare);
|
this.nfsShare.setValue(nfsShare);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the data file
|
* Get the name of the data file
|
||||||
* @return Name of data file name
|
* @return Name of data file name
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public String getFileName() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public String getFileName() throws CAException, InterruptedException {
|
||||||
return(this.fileName.getValue());
|
return(this.fileName.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set name of the data file
|
* Set name of the data file
|
||||||
* @param filename
|
* @param filename
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void setFileName(String filename) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setFileName(String filename) throws CAException, InterruptedException {
|
||||||
this.fileName.setValue(filename);
|
this.fileName.setValue(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get File name formate
|
* Get File name formate
|
||||||
* @return Get format for file name
|
* @return Get format for file name
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public String getFileNameFormat() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public String getFileNameFormat() throws CAException, InterruptedException {
|
||||||
return(this.fileNameFormat.getValue());
|
return(this.fileNameFormat.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,102 +576,102 @@ public class OTFBean {
|
|||||||
* @param fileNameFormat
|
* @param fileNameFormat
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void setFileNameFormat(String fileNameFormat) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setFileNameFormat(String fileNameFormat) throws CAException, InterruptedException {
|
||||||
this.fileNameFormat.setValue(fileNameFormat);
|
this.fileNameFormat.setValue(fileNameFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get value of the IOC based file name counter
|
* Get value of the IOC based file name counter
|
||||||
* @return File counter
|
* @return File counter
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public int getFileCounter() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public int getFileCounter() throws CAException, InterruptedException {
|
||||||
return(this.fileCount.getValue());
|
return(this.fileCount.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the IOC based file counter
|
* Reset the IOC based file counter
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void resetFileCounter() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void resetFileCounter() throws CAException, InterruptedException {
|
||||||
this.resetFileCounter.setValue(1);
|
this.resetFileCounter.setValue(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if append file option is activated
|
* Get if append file option is activated
|
||||||
* @return Append file flag
|
* @return Append file flag
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public boolean isAppendFile() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public boolean isAppendFile() throws CAException, InterruptedException {
|
||||||
return(this.appendFile.getValue());
|
return(this.appendFile.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether to append the specified file if the file exists
|
* Set whether to append the specified file if the file exists
|
||||||
* @param append
|
* @param append
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void setAppendFile(boolean append) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setAppendFile(boolean append) throws CAException, InterruptedException {
|
||||||
this.appendFile.setValue(append);
|
this.appendFile.setValue(append);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if file name generation is on or off
|
* Get if file name generation is on or off
|
||||||
* @return File name generation flag
|
* @return File name generation flag
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public boolean isFileNameGeneration() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public boolean isFileNameGeneration() throws CAException, InterruptedException {
|
||||||
return(this.fileNameGeneration.getValue());
|
return(this.fileNameGeneration.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Whether the file name should be generated out of the file name format and the file counter
|
* Set Whether the file name should be generated out of the file name format and the file counter
|
||||||
* @param generation
|
* @param generation
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void setFileNameGeneration(boolean generation) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setFileNameGeneration(boolean generation) throws CAException, InterruptedException {
|
||||||
this.fileNameGeneration.setValue(generation);
|
this.fileNameGeneration.setValue(generation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if ZigZag scan option is on or off
|
* Get if ZigZag scan option is on or off
|
||||||
* @return ZigZag flag
|
* @return ZigZag flag
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public boolean isZigZag() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public boolean isZigZag() throws CAException, InterruptedException {
|
||||||
return(this.zigZag.getValue());
|
return(this.zigZag.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set ZigZag scan mode on/off
|
* Set ZigZag scan mode on/off
|
||||||
* @param zigZag ZigZag mode on = true, ZigZag mode off = false
|
* @param zigZag ZigZag mode on = true, ZigZag mode off = false
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void setZigZag(boolean zigZag) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setZigZag(boolean zigZag) throws CAException, InterruptedException {
|
||||||
this.zigZag.setValue(zigZag);
|
this.zigZag.setValue(zigZag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether encoder is used
|
* Get whether encoder is used
|
||||||
*/
|
*/
|
||||||
public boolean isUseEncoder() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public boolean isUseEncoder() throws CAException, InterruptedException {
|
||||||
return(this.useEncoder.getValue());
|
return(this.useEncoder.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set flag to use encoder
|
* Set flag to use encoder
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void setUseEncoder(boolean flag) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setUseEncoder(boolean flag) throws CAException, InterruptedException {
|
||||||
this.useEncoder.setValue(flag);
|
this.useEncoder.setValue(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the channels that are currently monitored by the OTFScan logic
|
* Get the channels that are currently monitored by the OTFScan logic
|
||||||
* @return Names of the monitored channels
|
* @return Names of the monitored channels
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public String[] getMonitoredChannels() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public String[] getMonitoredChannels() throws CAException, InterruptedException {
|
||||||
String[] values = new String[this.monitoredChannels.size()];
|
String[] values = new String[this.monitoredChannels.size()];
|
||||||
|
|
||||||
for(int i=0; i<this.monitoredChannels.size();i++){
|
for(int i=0; i<this.monitoredChannels.size();i++){
|
||||||
@@ -717,9 +686,9 @@ public class OTFBean {
|
|||||||
* Note: As OTF only supports 8 channels to be monitored, only the first 8
|
* Note: As OTF only supports 8 channels to be monitored, only the first 8
|
||||||
* values of the passed channelNames are considered.
|
* values of the passed channelNames are considered.
|
||||||
* @param values Array of channel names to be monitored
|
* @param values Array of channel names to be monitored
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public void setMonitoredChannels(String[] values) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void setMonitoredChannels(String[] values) throws CAException, InterruptedException {
|
||||||
|
|
||||||
if(values.length>monitoredChannels.size()){
|
if(values.length>monitoredChannels.size()){
|
||||||
throw new IllegalArgumentException("Only up to "+monitoredChannels.size()+" monitored channels are supported by OTF");
|
throw new IllegalArgumentException("Only up to "+monitoredChannels.size()+" monitored channels are supported by OTF");
|
||||||
@@ -738,36 +707,36 @@ public class OTFBean {
|
|||||||
/**
|
/**
|
||||||
* Returns whether an scan is running
|
* Returns whether an scan is running
|
||||||
* @return Running flag
|
* @return Running flag
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public boolean isRunning() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public boolean isRunning() throws CAException, InterruptedException {
|
||||||
return(running.getValue());
|
return(running.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get status of the scan
|
* Get status of the scan
|
||||||
* @return Status of the scan
|
* @return Status of the scan
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public Status getStatus() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public Status getStatus() throws CAException, InterruptedException {
|
||||||
return(Status.values()[this.status.getValue()]);
|
return(Status.values()[this.status.getValue()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the (error) message from the OTF records
|
* Get the (error) message from the OTF records
|
||||||
* @return Message from OTF C logic
|
* @return Message from OTF C logic
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public String getMessage() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public String getMessage() throws CAException, InterruptedException {
|
||||||
return(message.getValue());
|
return(message.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the specified motor is recognized as ok (i.e. it is registered as OTFScan motor)
|
* Check whether the specified motor is recognized as ok (i.e. it is registered as OTFScan motor)
|
||||||
* @return Flag whether motor is ok
|
* @return Flag whether motor is ok
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
public boolean isMotorOk() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public boolean isMotorOk() throws CAException, InterruptedException {
|
||||||
return(motorOk.getValue());
|
return(motorOk.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -775,9 +744,9 @@ public class OTFBean {
|
|||||||
* Wait until the motor flag goes to ok
|
* Wait until the motor flag goes to ok
|
||||||
* @param timeout Timout in milliseconds
|
* @param timeout Timout in milliseconds
|
||||||
*
|
*
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException If motor ok flag does not switch to ok within the specified timeout
|
* @throws CAException If motor ok flag does not switch to ok within the specified timeout
|
||||||
*/
|
*/
|
||||||
public void waitUntilMotorOk(long timeout) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void waitUntilMotorOk(long timeout) throws CAException, InterruptedException {
|
||||||
motorOk.waitForValue(true, timeout);
|
motorOk.waitForValue(true, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -785,14 +754,14 @@ public class OTFBean {
|
|||||||
* Wait until the motor flag goes to not ok
|
* Wait until the motor flag goes to not ok
|
||||||
* @param timeout Timout in milliseconds
|
* @param timeout Timout in milliseconds
|
||||||
*
|
*
|
||||||
* @throws TimeoutException, ChannelException, ExecutionException If motor ok flag does not switch to ok within the specified timeout
|
* @throws CAException If motor ok flag does not switch to ok within the specified timeout
|
||||||
*/
|
*/
|
||||||
public void waitUntilMotorNotOk(long timeout) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void waitUntilMotorNotOk(long timeout) throws CAException, InterruptedException {
|
||||||
motorOk.waitForValue(false, timeout);
|
motorOk.waitForValue(false, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void waitUntilEncoderOk(long timeout) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
|
public void waitUntilEncoderOk(long timeout) throws CAException, InterruptedException {
|
||||||
if(!useEncoder.getValue()){
|
if(!useEncoder.getValue()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,24 +24,15 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
//import jcifs.smb.SmbException;
|
//import jcifs.smb.SmbException;
|
||||||
//import jcifs.smb.SmbFile;
|
//import jcifs.smb.SmbFile;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import ch.psi.fda.core.Action;
|
import ch.psi.fda.core.Action;
|
||||||
import ch.psi.fda.core.ActionLoop;
|
import ch.psi.fda.core.ActionLoop;
|
||||||
import ch.psi.fda.core.Sensor;
|
import ch.psi.fda.core.Sensor;
|
||||||
@@ -56,8 +47,7 @@ import ch.psi.fda.core.sensors.MillisecondTimestampSensor;
|
|||||||
import ch.psi.fda.core.sensors.OTFNamedChannelSensor;
|
import ch.psi.fda.core.sensors.OTFNamedChannelSensor;
|
||||||
import ch.psi.fda.core.sensors.OTFReadbackSensor;
|
import ch.psi.fda.core.sensors.OTFReadbackSensor;
|
||||||
import ch.psi.fda.core.sensors.OTFScalerChannelSensor;
|
import ch.psi.fda.core.sensors.OTFScalerChannelSensor;
|
||||||
import ch.psi.jcae.ChannelException;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActionLoop that is implementing the OTF Scan logic.
|
* ActionLoop that is implementing the OTF Scan logic.
|
||||||
@@ -153,8 +143,6 @@ public class OTFLoop implements ActionLoop {
|
|||||||
*/
|
*/
|
||||||
private volatile boolean abort = false;
|
private volatile boolean abort = false;
|
||||||
|
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param channelPrefix Prefix of the OTF related records, e.g. MTEST-HW3-OTF
|
* @param channelPrefix Prefix of the OTF related records, e.g. MTEST-HW3-OTF
|
||||||
@@ -163,15 +151,13 @@ public class OTFLoop implements ActionLoop {
|
|||||||
* @param smbShare SMB share to get the data written by the OTF C Logic
|
* @param smbShare SMB share to get the data written by the OTF C Logic
|
||||||
* @param zigZag Operate loop in zig zag mode
|
* @param zigZag Operate loop in zig zag mode
|
||||||
*/
|
*/
|
||||||
public OTFLoop(ChannelService s, String channelPrefix, String server, String share, String smbShare, boolean zigZag){
|
public OTFLoop(String channelPrefix, String server, String share, String smbShare, boolean zigZag){
|
||||||
cservice = s;
|
|
||||||
// Initialize connection to the OTF records
|
// Initialize connection to the OTF records
|
||||||
try {
|
try {
|
||||||
this.obean = new OTFBean();
|
this.obean = new OTFBean();
|
||||||
Map<String,String> m = new HashMap<>();
|
ChannelBeanFactory.getFactory().createChannelBeans(obean, channelPrefix);
|
||||||
m.put("PREFIX", channelPrefix);
|
} catch (CAException e) {
|
||||||
s.createAnnotatedChannels(obean, m);
|
|
||||||
} catch (ChannelException | TimeoutException e) {
|
|
||||||
throw new IllegalArgumentException("Unable to connect to the OTF channels",e);
|
throw new IllegalArgumentException("Unable to connect to the OTF channels",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException("Unable to connect to the OTF channels",e);
|
throw new RuntimeException("Unable to connect to the OTF channels",e);
|
||||||
@@ -325,7 +311,7 @@ public class OTFLoop implements ActionLoop {
|
|||||||
// Set monitored channels
|
// Set monitored channels
|
||||||
obean.setMonitoredChannels(monitoredChannels.toArray(new String[monitoredChannels.size()]));
|
obean.setMonitoredChannels(monitoredChannels.toArray(new String[monitoredChannels.size()]));
|
||||||
}
|
}
|
||||||
catch(ChannelException | ExecutionException | TimeoutException e){
|
catch(CAException e){
|
||||||
throw new RuntimeException("Unable to set OTF configuration parameters",e);
|
throw new RuntimeException("Unable to set OTF configuration parameters",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException("Unable to set OTF configuration parameters",e);
|
throw new RuntimeException("Unable to set OTF configuration parameters",e);
|
||||||
@@ -372,8 +358,10 @@ public class OTFLoop implements ActionLoop {
|
|||||||
public void destroy() {
|
public void destroy() {
|
||||||
// Close all connections used by the OTFBean
|
// Close all connections used by the OTFBean
|
||||||
try {
|
try {
|
||||||
cservice.destroyAnnotatedChannels(obean);
|
ChannelBeanFactory.getFactory().destroyChannelBeans(obean);
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
|
throw new RuntimeException("Unable to destroy channels",e);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException("Unable to destroy channels",e);
|
throw new RuntimeException("Unable to destroy channels",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.loops.cr;
|
package ch.psi.fda.core.loops.cr;
|
||||||
|
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.annotation.CaChannel;
|
import ch.psi.jcae.annotation.CaChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,120 +37,120 @@ public class CrlogicChannelsTemplate {
|
|||||||
* Ticks per second - IOC setting
|
* Ticks per second - IOC setting
|
||||||
* ATTENTION - This field must only be set bu the IOC - ATTENTION
|
* ATTENTION - This field must only be set bu the IOC - ATTENTION
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}:TPS")
|
@CaChannel(type=Integer.class, name =":TPS")
|
||||||
private Channel<Integer> ticksPerSecond;
|
private ChannelBean<Integer> ticksPerSecond;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status of the OTFSCAN IOC logic
|
* Status of the OTFSCAN IOC logic
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=String.class, name ="${PREFIX}:STATUS")
|
@CaChannel(type=String.class, name =":STATUS")
|
||||||
private Channel<String> status;
|
private ChannelBean<String> status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message from the OTFSCAN IOC logic
|
* Message from the OTFSCAN IOC logic
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=String.class, name ="${PREFIX}:MSG")
|
@CaChannel(type=String.class, name =":MSG")
|
||||||
private Channel<String> message;
|
private ChannelBean<String> message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IOC ticks between data acquisition interrupts
|
* IOC ticks between data acquisition interrupts
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}:TBINT")
|
@CaChannel(type=Integer.class, name =":TBINT")
|
||||||
private Channel<Integer> ticksBetweenInterrupts;
|
private ChannelBean<Integer> ticksBetweenInterrupts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name or ip address of the NFS server to save the data to
|
* Name or ip address of the NFS server to save the data to
|
||||||
* (depending on the IOC setup)
|
* (depending on the IOC setup)
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=String.class, name ="${PREFIX}:NFSSE")
|
@CaChannel(type=String.class, name =":NFSSE")
|
||||||
private Channel<String> nfsServer;
|
private ChannelBean<String> nfsServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the NFS share on the NFS server
|
* Name of the NFS share on the NFS server
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=String.class, name ="${PREFIX}:NFSSH")
|
@CaChannel(type=String.class, name =":NFSSH")
|
||||||
private Channel<String> nfsShare;
|
private ChannelBean<String> nfsShare;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the data file
|
* Name of the data file
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=String.class, name ="${PREFIX}:DFNAM")
|
@CaChannel(type=String.class, name =":DFNAM")
|
||||||
private Channel<String> dataFile;
|
private ChannelBean<String> dataFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to identify whether the data file should be appended
|
* Flag to identify whether the data file should be appended
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Boolean.class, name ="${PREFIX}:FAPPE")
|
@CaChannel(type=Boolean.class, name =":FAPPE")
|
||||||
private Channel<Boolean> appendFile;
|
private ChannelBean<Boolean> appendFile;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Readout resources
|
* Readout resources
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=String[].class, name ="${PREFIX}:RRES")
|
@CaChannel(type=String[].class, name =":RRES")
|
||||||
private Channel<String[]> readoutResources;
|
private ChannelBean<String[]> readoutResources;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the ticksPerSecond
|
* @return the ticksPerSecond
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getTicksPerSecond() {
|
public ChannelBean<Integer> getTicksPerSecond() {
|
||||||
return ticksPerSecond;
|
return ticksPerSecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the status
|
* @return the status
|
||||||
*/
|
*/
|
||||||
public Channel<String> getStatus() {
|
public ChannelBean<String> getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the message
|
* @return the message
|
||||||
*/
|
*/
|
||||||
public Channel<String> getMessage() {
|
public ChannelBean<String> getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the ticksBetweenInterrupts
|
* @return the ticksBetweenInterrupts
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getTicksBetweenInterrupts() {
|
public ChannelBean<Integer> getTicksBetweenInterrupts() {
|
||||||
return ticksBetweenInterrupts;
|
return ticksBetweenInterrupts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the nfsServer
|
* @return the nfsServer
|
||||||
*/
|
*/
|
||||||
public Channel<String> getNfsServer() {
|
public ChannelBean<String> getNfsServer() {
|
||||||
return nfsServer;
|
return nfsServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the nfsShare
|
* @return the nfsShare
|
||||||
*/
|
*/
|
||||||
public Channel<String> getNfsShare() {
|
public ChannelBean<String> getNfsShare() {
|
||||||
return nfsShare;
|
return nfsShare;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the dataFile
|
* @return the dataFile
|
||||||
*/
|
*/
|
||||||
public Channel<String> getDataFile() {
|
public ChannelBean<String> getDataFile() {
|
||||||
return dataFile;
|
return dataFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the appendFile
|
* @return the appendFile
|
||||||
*/
|
*/
|
||||||
public Channel<Boolean> getAppendFile() {
|
public ChannelBean<Boolean> getAppendFile() {
|
||||||
return appendFile;
|
return appendFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the readoutResources
|
* @return the readoutResources
|
||||||
*/
|
*/
|
||||||
public Channel<String[]> getReadoutResources() {
|
public ChannelBean<String[]> getReadoutResources() {
|
||||||
return readoutResources;
|
return readoutResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,14 +27,12 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import jcifs.smb.SmbFile;
|
import jcifs.smb.SmbFile;
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
import ch.psi.fda.core.Action;
|
import ch.psi.fda.core.Action;
|
||||||
import ch.psi.fda.core.ActionLoop;
|
import ch.psi.fda.core.ActionLoop;
|
||||||
import ch.psi.fda.core.Sensor;
|
import ch.psi.fda.core.Sensor;
|
||||||
@@ -48,8 +46,7 @@ import ch.psi.fda.core.messages.Message;
|
|||||||
import ch.psi.fda.core.sensors.MillisecondTimestampSensor;
|
import ch.psi.fda.core.sensors.MillisecondTimestampSensor;
|
||||||
import ch.psi.fda.core.sensors.OTFNamedChannelSensor;
|
import ch.psi.fda.core.sensors.OTFNamedChannelSensor;
|
||||||
import ch.psi.fda.core.sensors.OTFScalerChannelSensor;
|
import ch.psi.fda.core.sensors.OTFScalerChannelSensor;
|
||||||
import ch.psi.jcae.ChannelException;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -153,9 +150,8 @@ public class CrlogicLoop implements ActionLoop {
|
|||||||
private boolean abortForce = false;
|
private boolean abortForce = false;
|
||||||
private Thread executionThread = null;
|
private Thread executionThread = null;
|
||||||
|
|
||||||
private ChannelService cservice;
|
|
||||||
public CrlogicLoop(ChannelService s, String prefix, String server, String share, String smbShare, boolean zigZag){
|
public CrlogicLoop(String prefix, String server, String share, String smbShare, boolean zigZag){
|
||||||
cservice = s;
|
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.share = share;
|
this.share = share;
|
||||||
@@ -466,7 +462,7 @@ public class CrlogicLoop implements ActionLoop {
|
|||||||
|
|
||||||
// Move to start
|
// Move to start
|
||||||
logger.info("Move motor to start ["+realStart+"]");
|
logger.info("Move motor to start ["+realStart+"]");
|
||||||
motortemplate.getSetValue().setValueAsync(realStart).get(timeout, TimeUnit.MILLISECONDS); // Will block until move is done
|
motortemplate.getSetValue().setValue(realStart, timeout); // Will block until move is done
|
||||||
|
|
||||||
|
|
||||||
// Set motor paramters
|
// Set motor paramters
|
||||||
@@ -504,7 +500,7 @@ public class CrlogicLoop implements ActionLoop {
|
|||||||
try{
|
try{
|
||||||
template.getStatus().waitForValue(CrlogicChannelsTemplate.Status.ACTIVE.toString(), startStopTimeout);
|
template.getStatus().waitForValue(CrlogicChannelsTemplate.Status.ACTIVE.toString(), startStopTimeout);
|
||||||
}
|
}
|
||||||
catch(ChannelException e){
|
catch(CAException e){
|
||||||
logger.info( "Failed to start CRLOGIC. Logic in status: "+template.getStatus().getValue() );
|
logger.info( "Failed to start CRLOGIC. Logic in status: "+template.getStatus().getValue() );
|
||||||
if(template.getStatus().getValue().equals(CrlogicChannelsTemplate.Status.FAULT.toString())){
|
if(template.getStatus().getValue().equals(CrlogicChannelsTemplate.Status.FAULT.toString())){
|
||||||
logger.info("Error message: "+template.getMessage().getValue());
|
logger.info("Error message: "+template.getMessage().getValue());
|
||||||
@@ -519,7 +515,7 @@ public class CrlogicLoop implements ActionLoop {
|
|||||||
// Move motor(s) to end / wait until motor is stopped
|
// Move motor(s) to end / wait until motor is stopped
|
||||||
logger.info("Move motor to end ["+realEnd+"]");
|
logger.info("Move motor to end ["+realEnd+"]");
|
||||||
try{
|
try{
|
||||||
motortemplate.getSetValue().setValueAsync(realEnd).get(timeout, TimeUnit.MILLISECONDS); // Will block until move is done
|
motortemplate.getSetValue().setValue(realEnd, timeout); // Will block until move is done
|
||||||
}
|
}
|
||||||
catch (InterruptedException e) {
|
catch (InterruptedException e) {
|
||||||
if(abort & (!abortForce)){
|
if(abort & (!abortForce)){
|
||||||
@@ -541,7 +537,7 @@ public class CrlogicLoop implements ActionLoop {
|
|||||||
try{
|
try{
|
||||||
template.getStatus().waitForValue(CrlogicChannelsTemplate.Status.INACTIVE.toString(), startStopTimeout);
|
template.getStatus().waitForValue(CrlogicChannelsTemplate.Status.INACTIVE.toString(), startStopTimeout);
|
||||||
}
|
}
|
||||||
catch(ChannelException | ExecutionException e){
|
catch(CAException e){
|
||||||
logger.info( "Failed to stop CRLOGIC. Logic in status: "+template.getStatus().getValue() );
|
logger.info( "Failed to stop CRLOGIC. Logic in status: "+template.getStatus().getValue() );
|
||||||
// TODO Improve error handling
|
// TODO Improve error handling
|
||||||
throw new RuntimeException("Failed to stop CRLOGIC. Logic in status: "+template.getStatus().getValue(), e);
|
throw new RuntimeException("Failed to stop CRLOGIC. Logic in status: "+template.getStatus().getValue(), e);
|
||||||
@@ -593,7 +589,7 @@ public class CrlogicLoop implements ActionLoop {
|
|||||||
executionThread = null;
|
executionThread = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(ChannelException | ExecutionException | TimeoutException e){
|
catch(CAException e){
|
||||||
throw new RuntimeException("Unable to execute crloop", e);
|
throw new RuntimeException("Unable to execute crloop", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -631,8 +627,8 @@ public class CrlogicLoop implements ActionLoop {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
cservice.destroyAnnotatedChannels(template);
|
ChannelBeanFactory.getFactory().destroyChannelBeans(template);
|
||||||
cservice.destroyAnnotatedChannels(motortemplate);
|
ChannelBeanFactory.getFactory().destroyChannelBeans(motortemplate);
|
||||||
template = null;
|
template = null;
|
||||||
motortemplate = null;
|
motortemplate = null;
|
||||||
|
|
||||||
@@ -681,15 +677,11 @@ public class CrlogicLoop implements ActionLoop {
|
|||||||
// Connect crlogic channels
|
// Connect crlogic channels
|
||||||
template = new CrlogicChannelsTemplate();
|
template = new CrlogicChannelsTemplate();
|
||||||
logger.info("Connect channels");
|
logger.info("Connect channels");
|
||||||
Map<String, String> m = new HashMap<>();
|
ChannelBeanFactory.getFactory().createChannelBeans(template, prefix);
|
||||||
m.put("PREFIX", prefix);
|
|
||||||
cservice.createAnnotatedChannels(template, m);
|
|
||||||
|
|
||||||
// Connect motor channels
|
// Connect motor channels
|
||||||
motortemplate = new MotorChannelsTemplate();
|
motortemplate = new MotorChannelsTemplate();
|
||||||
m = new HashMap<>();
|
ChannelBeanFactory.getFactory().createChannelBeans(motortemplate, actuator.getName());
|
||||||
m.put("PREFIX", actuator.getName());
|
|
||||||
cservice.createAnnotatedChannels(motortemplate, m);
|
|
||||||
|
|
||||||
useReadback = motortemplate.getUseReadback().getValue();
|
useReadback = motortemplate.getUseReadback().getValue();
|
||||||
useEncoder = motortemplate.getUseEncoder().getValue();
|
useEncoder = motortemplate.getUseEncoder().getValue();
|
||||||
@@ -731,9 +723,7 @@ public class CrlogicLoop implements ActionLoop {
|
|||||||
// Fill readback encoder settings
|
// Fill readback encoder settings
|
||||||
// Connect to encoder
|
// Connect to encoder
|
||||||
EncoderChannelsTemplate encodertemplate = new EncoderChannelsTemplate();
|
EncoderChannelsTemplate encodertemplate = new EncoderChannelsTemplate();
|
||||||
m = new HashMap<>();
|
ChannelBeanFactory.getFactory().createChannelBeans(encodertemplate, readback);
|
||||||
m.put("PREFIX", readback);
|
|
||||||
cservice.createAnnotatedChannels(encodertemplate, m);
|
|
||||||
|
|
||||||
// Read encoder settings
|
// Read encoder settings
|
||||||
if(encodertemplate.getDirection().getValue()==EncoderChannelsTemplate.Direction.Positive.ordinal()){
|
if(encodertemplate.getDirection().getValue()==EncoderChannelsTemplate.Direction.Positive.ordinal()){
|
||||||
@@ -746,7 +736,7 @@ public class CrlogicLoop implements ActionLoop {
|
|||||||
crlogicDataFilter.setEncoderResolution(encodertemplate.getResolution().getValue());
|
crlogicDataFilter.setEncoderResolution(encodertemplate.getResolution().getValue());
|
||||||
|
|
||||||
// Disconnect from encoder
|
// Disconnect from encoder
|
||||||
cservice.destroyAnnotatedChannels(encodertemplate);
|
ChannelBeanFactory.getFactory().destroyChannelBeans(encodertemplate);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (useEncoder && (!useReadback)){
|
else if (useEncoder && (!useReadback)){
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.loops.cr;
|
package ch.psi.fda.core.loops.cr;
|
||||||
|
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.annotation.CaChannel;
|
import ch.psi.jcae.annotation.CaChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,41 +31,41 @@ public class EncoderChannelsTemplate {
|
|||||||
/**
|
/**
|
||||||
* Resolution - $(P)$(E)_SCL
|
* Resolution - $(P)$(E)_SCL
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name="${PREFIX}_SCL")
|
@CaChannel(type=Double.class, name="_SCL")
|
||||||
private Channel<Double> resolution;
|
private ChannelBean<Double> resolution;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset - $(P)$(E)_OFF
|
* Offset - $(P)$(E)_OFF
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}_OFF")
|
@CaChannel(type=Double.class, name ="_OFF")
|
||||||
private Channel<Double> offset;
|
private ChannelBean<Double> offset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Direction - $(P)$(E)_DIR
|
* Direction - $(P)$(E)_DIR
|
||||||
*/
|
*/
|
||||||
public enum Direction {Negative, Positive};
|
public enum Direction {Negative, Positive};
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}_DIR")
|
@CaChannel(type=Integer.class, name ="_DIR")
|
||||||
private Channel<Integer> direction;
|
private ChannelBean<Integer> direction;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the resolution
|
* @return the resolution
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getResolution() {
|
public ChannelBean<Double> getResolution() {
|
||||||
return resolution;
|
return resolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the offset
|
* @return the offset
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getOffset() {
|
public ChannelBean<Double> getOffset() {
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the direction
|
* @return the direction
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getDirection() {
|
public ChannelBean<Integer> getDirection() {
|
||||||
return direction;
|
return direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.loops.cr;
|
package ch.psi.fda.core.loops.cr;
|
||||||
|
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.annotation.CaChannel;
|
import ch.psi.jcae.annotation.CaChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,92 +38,92 @@ public class MotorChannelsTemplate {
|
|||||||
/**
|
/**
|
||||||
* .HLM High limit - double
|
* .HLM High limit - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.HLM")
|
@CaChannel(type=Double.class, name =".HLM")
|
||||||
private Channel<Double> highLimit;
|
private ChannelBean<Double> highLimit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .LLM Low limit - double
|
* .LLM Low limit - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.LLM")
|
@CaChannel(type=Double.class, name =".LLM")
|
||||||
private Channel<Double> lowLimit;
|
private ChannelBean<Double> lowLimit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .RBV Readback value - double
|
* .RBV Readback value - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.RBV", monitor=true)
|
@CaChannel(type=Double.class, name =".RBV", monitor=true)
|
||||||
private Channel<Double> readbackValue;
|
private ChannelBean<Double> readbackValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .VAL Set value - double
|
* .VAL Set value - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.VAL", monitor=true)
|
@CaChannel(type=Double.class, name =".VAL", monitor=true)
|
||||||
private Channel<Double> setValue;
|
private ChannelBean<Double> setValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .RLV Relative move value - double
|
* .RLV Relative move value - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.RLV")
|
@CaChannel(type=Double.class, name =".RLV")
|
||||||
private Channel<Double> relativeMoveValue;
|
private ChannelBean<Double> relativeMoveValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .TWV Teak value - double
|
* .TWV Teak value - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.TWV")
|
@CaChannel(type=Double.class, name =".TWV")
|
||||||
private Channel<Double> tweakValue;
|
private ChannelBean<Double> tweakValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .TWR Tweak reverse - move left - int
|
* .TWR Tweak reverse - move left - int
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.TWR")
|
@CaChannel(type=Integer.class, name =".TWR")
|
||||||
private Channel<Integer> tweakReverse;
|
private ChannelBean<Integer> tweakReverse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .TWF Tweak forward - move right - int
|
* .TWF Tweak forward - move right - int
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.TWF")
|
@CaChannel(type=Integer.class, name =".TWF")
|
||||||
private Channel<Integer> tweakForward;
|
private ChannelBean<Integer> tweakForward;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .JOGR Jog reverse - int
|
* .JOGR Jog reverse - int
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.JOGR")
|
@CaChannel(type=Integer.class, name =".JOGR")
|
||||||
private Channel<Integer> jogReverse;
|
private ChannelBean<Integer> jogReverse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .JOGF Jog forward - int
|
* .JOGF Jog forward - int
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.JOGF")
|
@CaChannel(type=Integer.class, name =".JOGF")
|
||||||
private Channel<Integer> jogForward;
|
private ChannelBean<Integer> jogForward;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .HOMR Home reverse - int
|
* .HOMR Home reverse - int
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.HOMR")
|
@CaChannel(type=Integer.class, name =".HOMR")
|
||||||
private Channel<Integer> homeReverse;
|
private ChannelBean<Integer> homeReverse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .HOMF Home forward - int
|
* .HOMF Home forward - int
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.HOMF")
|
@CaChannel(type=Integer.class, name =".HOMF")
|
||||||
private Channel<Integer> homeForward;
|
private ChannelBean<Integer> homeForward;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .EGU Engineering unit - String
|
* .EGU Engineering unit - String
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=String.class, name ="${PREFIX}.EGU")
|
@CaChannel(type=String.class, name =".EGU")
|
||||||
private Channel<String> engineeringUnit;
|
private ChannelBean<String> engineeringUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .DTYP Type - String (e.g. "OMS MAXv") see enum Type
|
* .DTYP Type - String (e.g. "OMS MAXv") see enum Type
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.DTYP")
|
@CaChannel(type=Integer.class, name =".DTYP")
|
||||||
private Channel<Integer> type;
|
private ChannelBean<Integer> type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .DESC Description - String
|
* .DESC Description - String
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=String.class, name ="${PREFIX}.DESC")
|
@CaChannel(type=String.class, name =".DESC")
|
||||||
private Channel<String> description;
|
private ChannelBean<String> description;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,45 +133,45 @@ public class MotorChannelsTemplate {
|
|||||||
/**
|
/**
|
||||||
* .DHLM Dial high limit - double
|
* .DHLM Dial high limit - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.DHLM")
|
@CaChannel(type=Double.class, name =".DHLM")
|
||||||
private Channel<Double> dialHighLimit;
|
private ChannelBean<Double> dialHighLimit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .DLLM Dial low limit - double
|
* .DLLM Dial low limit - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.DLLM")
|
@CaChannel(type=Double.class, name =".DLLM")
|
||||||
private Channel<Double> dialLowLimit;
|
private ChannelBean<Double> dialLowLimit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .DRBV Dial readback value - double
|
* .DRBV Dial readback value - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.DRBV", monitor=true)
|
@CaChannel(type=Double.class, name =".DRBV", monitor=true)
|
||||||
private Channel<Double> dialReadbackValue;
|
private ChannelBean<Double> dialReadbackValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .DVAL Dial set value - double
|
* .DVAL Dial set value - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.DVAL", monitor=true)
|
@CaChannel(type=Double.class, name =".DVAL", monitor=true)
|
||||||
private Channel<Double> dialSetValue;
|
private ChannelBean<Double> dialSetValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .RVAL Raw value - int
|
* .RVAL Raw value - int
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.RVAL", monitor=true)
|
@CaChannel(type=Integer.class, name =".RVAL", monitor=true)
|
||||||
private Channel<Integer> rawValue;
|
private ChannelBean<Integer> rawValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .RRBV Raw readback value - int
|
* .RRBV Raw readback value - int
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.RRBV", monitor=true)
|
@CaChannel(type=Integer.class, name =".RRBV", monitor=true)
|
||||||
private Channel<Integer> rawReadbackValue;
|
private ChannelBean<Integer> rawReadbackValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .SPMG Stop/Pause/Move/Go - (0:"Stop", 1:"Pause", 2:"Move", 3:"Go") - 3
|
* .SPMG Stop/Pause/Move/Go - (0:"Stop", 1:"Pause", 2:"Move", 3:"Go") - 3
|
||||||
*/
|
*/
|
||||||
public enum Commands { Stop, Pause, Move, Go };
|
public enum Commands { Stop, Pause, Move, Go };
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.SPMG")
|
@CaChannel(type=Integer.class, name =".SPMG")
|
||||||
private Channel<Integer> command;
|
private ChannelBean<Integer> command;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -182,28 +182,28 @@ public class MotorChannelsTemplate {
|
|||||||
* .SET Set/Use Switch - (0:"Use", 1:"Set") - 0
|
* .SET Set/Use Switch - (0:"Use", 1:"Set") - 0
|
||||||
*/
|
*/
|
||||||
public enum Calibration {Use, Set};
|
public enum Calibration {Use, Set};
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.SET")
|
@CaChannel(type=Integer.class, name =".SET")
|
||||||
private Channel<Integer> calibration;
|
private ChannelBean<Integer> calibration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .OFF User offset (EGU) - double
|
* .OFF User offset (EGU) - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.OFF")
|
@CaChannel(type=Double.class, name =".OFF")
|
||||||
private Channel<Double> offset;
|
private ChannelBean<Double> offset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .FOFF Offset-Freeze Switch - (0:"Variable", 1:"Frozen") - 1
|
* .FOFF Offset-Freeze Switch - (0:"Variable", 1:"Frozen") - 1
|
||||||
*/
|
*/
|
||||||
public enum OffsetMode {Variable, Frozen};
|
public enum OffsetMode {Variable, Frozen};
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.FOFF")
|
@CaChannel(type=Integer.class, name =".FOFF")
|
||||||
private Channel<Integer> offsetMode;
|
private ChannelBean<Integer> offsetMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .DIR User direction - (0:"Pos", 1:"Neg")
|
* .DIR User direction - (0:"Pos", 1:"Neg")
|
||||||
*/
|
*/
|
||||||
public enum Direction {Positive, Negative};
|
public enum Direction {Positive, Negative};
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.DIR")
|
@CaChannel(type=Integer.class, name =".DIR")
|
||||||
private Channel<Integer> direction;
|
private ChannelBean<Integer> direction;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -213,44 +213,44 @@ public class MotorChannelsTemplate {
|
|||||||
/**
|
/**
|
||||||
* .VELO Velocity (EGU/s) - double
|
* .VELO Velocity (EGU/s) - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.VELO")
|
@CaChannel(type=Double.class, name =".VELO")
|
||||||
private Channel<Double> velocity;
|
private ChannelBean<Double> velocity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .BVEL Backlash velocity (EGU/s) - double
|
* .BVEL Backlash velocity (EGU/s) - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.BVEL")
|
@CaChannel(type=Double.class, name =".BVEL")
|
||||||
private Channel<Double> backlashVelocity;
|
private ChannelBean<Double> backlashVelocity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .VBAS Base speed (EGU/s) - double
|
* .VBAS Base speed (EGU/s) - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.VBAS")
|
@CaChannel(type=Double.class, name =".VBAS")
|
||||||
private Channel<Double> baseSpeed;
|
private ChannelBean<Double> baseSpeed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .ACCL Acceleration time / seconds to velocity - double
|
* .ACCL Acceleration time / seconds to velocity - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.ACCL")
|
@CaChannel(type=Double.class, name =".ACCL")
|
||||||
private Channel<Double> accelerationTime;
|
private ChannelBean<Double> accelerationTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .BACC Backlash acceleration time / seconds to velocity - double
|
* .BACC Backlash acceleration time / seconds to velocity - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.BACC")
|
@CaChannel(type=Double.class, name =".BACC")
|
||||||
private Channel<Double> backlashAccelerationTime;
|
private ChannelBean<Double> backlashAccelerationTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .BDST Backlash distance (EGU) - double
|
* .BDST Backlash distance (EGU) - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.BDST")
|
@CaChannel(type=Double.class, name =".BDST")
|
||||||
private Channel<Double> backlashDistance;
|
private ChannelBean<Double> backlashDistance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .FRAC Move fraction - double
|
* .FRAC Move fraction - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.FRAC")
|
@CaChannel(type=Double.class, name =".FRAC")
|
||||||
private Channel<Double> moveFracion;
|
private ChannelBean<Double> moveFracion;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -260,69 +260,69 @@ public class MotorChannelsTemplate {
|
|||||||
/**
|
/**
|
||||||
* .MRES Motor resolution - double
|
* .MRES Motor resolution - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.MRES")
|
@CaChannel(type=Double.class, name =".MRES")
|
||||||
private Channel<Double> motorResolution;
|
private ChannelBean<Double> motorResolution;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .ERES Encoder resolution - double
|
* .ERES Encoder resolution - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.ERES")
|
@CaChannel(type=Double.class, name =".ERES")
|
||||||
private Channel<Double> encoderResolution;
|
private ChannelBean<Double> encoderResolution;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .RRES Readback resolution - double
|
* .RRES Readback resolution - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.RRES")
|
@CaChannel(type=Double.class, name =".RRES")
|
||||||
private Channel<Double> readbackResolution;
|
private ChannelBean<Double> readbackResolution;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .RDBD Retry deadband (EGU) - double
|
* .RDBD Retry deadband (EGU) - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.RDBD")
|
@CaChannel(type=Double.class, name =".RDBD")
|
||||||
private Channel<Double> retryDeadband;
|
private ChannelBean<Double> retryDeadband;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .RTRY Max retry count - int
|
* .RTRY Max retry count - int
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.RTRY")
|
@CaChannel(type=Integer.class, name =".RTRY")
|
||||||
private Channel<Integer> maxRetryCount;
|
private ChannelBean<Integer> maxRetryCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .RCNT Retry count - int
|
* .RCNT Retry count - int
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.RCNT", monitor=true)
|
@CaChannel(type=Integer.class, name =".RCNT", monitor=true)
|
||||||
private Channel<Integer> retryCount;
|
private ChannelBean<Integer> retryCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .UEIP Use encoder (if present) - (0:"No", 1:"Yes")
|
* .UEIP Use encoder (if present) - (0:"No", 1:"Yes")
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Boolean.class, name ="${PREFIX}.UEIP")
|
@CaChannel(type=Boolean.class, name =".UEIP")
|
||||||
private Channel<Boolean> useEncoder;
|
private ChannelBean<Boolean> useEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .URIP Use readback link (if present) - (0:"No", 1:"Yes")
|
* .URIP Use readback link (if present) - (0:"No", 1:"Yes")
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Boolean.class, name ="${PREFIX}.URIP")
|
@CaChannel(type=Boolean.class, name =".URIP")
|
||||||
private Channel<Boolean> useReadback;
|
private ChannelBean<Boolean> useReadback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .DLY Readback delay (s) - double
|
* .DLY Readback delay (s) - double
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Double.class, name ="${PREFIX}.DLY")
|
@CaChannel(type=Double.class, name =".DLY")
|
||||||
private Channel<Double> readbackDelay;
|
private ChannelBean<Double> readbackDelay;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .RDBL Readback link - String
|
* .RDBL Readback link - String
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=String.class, name ="${PREFIX}.RDBL")
|
@CaChannel(type=String.class, name =".RDBL")
|
||||||
private Channel<String> readbackLink;
|
private ChannelBean<String> readbackLink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .OMSL Output mode select - (0:"supervisory", 1:"closed_loop")
|
* .OMSL Output mode select - (0:"supervisory", 1:"closed_loop")
|
||||||
*/
|
*/
|
||||||
public enum OutputMode {Supervisory, Closed_Loop};
|
public enum OutputMode {Supervisory, Closed_Loop};
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.OMSL")
|
@CaChannel(type=Integer.class, name =".OMSL")
|
||||||
private Channel<Integer> outputMode;
|
private ChannelBean<Integer> outputMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Status ##
|
* ## Status ##
|
||||||
@@ -331,321 +331,321 @@ public class MotorChannelsTemplate {
|
|||||||
/**
|
/**
|
||||||
* .DMOV Done move - int
|
* .DMOV Done move - int
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Boolean.class, name ="${PREFIX}.DMOV", monitor=true)
|
@CaChannel(type=Boolean.class, name =".DMOV", monitor=true)
|
||||||
private Channel<Boolean> moveDone;
|
private ChannelBean<Boolean> moveDone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the highLimit
|
* @return the highLimit
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getHighLimit() {
|
public ChannelBean<Double> getHighLimit() {
|
||||||
return highLimit;
|
return highLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the lowLimit
|
* @return the lowLimit
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getLowLimit() {
|
public ChannelBean<Double> getLowLimit() {
|
||||||
return lowLimit;
|
return lowLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the readbackValue
|
* @return the readbackValue
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getReadbackValue() {
|
public ChannelBean<Double> getReadbackValue() {
|
||||||
return readbackValue;
|
return readbackValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the setValue
|
* @return the setValue
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getSetValue() {
|
public ChannelBean<Double> getSetValue() {
|
||||||
return setValue;
|
return setValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the relativeMoveValue
|
* @return the relativeMoveValue
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getRelativeMoveValue() {
|
public ChannelBean<Double> getRelativeMoveValue() {
|
||||||
return relativeMoveValue;
|
return relativeMoveValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the tweakValue
|
* @return the tweakValue
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getTweakValue() {
|
public ChannelBean<Double> getTweakValue() {
|
||||||
return tweakValue;
|
return tweakValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the tweakReverse
|
* @return the tweakReverse
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getTweakReverse() {
|
public ChannelBean<Integer> getTweakReverse() {
|
||||||
return tweakReverse;
|
return tweakReverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the tweakForward
|
* @return the tweakForward
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getTweakForward() {
|
public ChannelBean<Integer> getTweakForward() {
|
||||||
return tweakForward;
|
return tweakForward;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the jogReverse
|
* @return the jogReverse
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getJogReverse() {
|
public ChannelBean<Integer> getJogReverse() {
|
||||||
return jogReverse;
|
return jogReverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the jogForward
|
* @return the jogForward
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getJogForward() {
|
public ChannelBean<Integer> getJogForward() {
|
||||||
return jogForward;
|
return jogForward;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the homeReverse
|
* @return the homeReverse
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getHomeReverse() {
|
public ChannelBean<Integer> getHomeReverse() {
|
||||||
return homeReverse;
|
return homeReverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the homeForward
|
* @return the homeForward
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getHomeForward() {
|
public ChannelBean<Integer> getHomeForward() {
|
||||||
return homeForward;
|
return homeForward;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the engineeringUnit
|
* @return the engineeringUnit
|
||||||
*/
|
*/
|
||||||
public Channel<String> getEngineeringUnit() {
|
public ChannelBean<String> getEngineeringUnit() {
|
||||||
return engineeringUnit;
|
return engineeringUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the type
|
* @return the type
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getType() {
|
public ChannelBean<Integer> getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the description
|
* @return the description
|
||||||
*/
|
*/
|
||||||
public Channel<String> getDescription() {
|
public ChannelBean<String> getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the dialHighLimit
|
* @return the dialHighLimit
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getDialHighLimit() {
|
public ChannelBean<Double> getDialHighLimit() {
|
||||||
return dialHighLimit;
|
return dialHighLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the dialLowLimit
|
* @return the dialLowLimit
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getDialLowLimit() {
|
public ChannelBean<Double> getDialLowLimit() {
|
||||||
return dialLowLimit;
|
return dialLowLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the dialReadbackValue
|
* @return the dialReadbackValue
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getDialReadbackValue() {
|
public ChannelBean<Double> getDialReadbackValue() {
|
||||||
return dialReadbackValue;
|
return dialReadbackValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the dialSetValue
|
* @return the dialSetValue
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getDialSetValue() {
|
public ChannelBean<Double> getDialSetValue() {
|
||||||
return dialSetValue;
|
return dialSetValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the rawValue
|
* @return the rawValue
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getRawValue() {
|
public ChannelBean<Integer> getRawValue() {
|
||||||
return rawValue;
|
return rawValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the rawReadbackValue
|
* @return the rawReadbackValue
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getRawReadbackValue() {
|
public ChannelBean<Integer> getRawReadbackValue() {
|
||||||
return rawReadbackValue;
|
return rawReadbackValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the command
|
* @return the command
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getCommand() {
|
public ChannelBean<Integer> getCommand() {
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the calibration
|
* @return the calibration
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getCalibration() {
|
public ChannelBean<Integer> getCalibration() {
|
||||||
return calibration;
|
return calibration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the userOffset
|
* @return the userOffset
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getOffset() {
|
public ChannelBean<Double> getOffset() {
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the offsetMode
|
* @return the offsetMode
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getOffsetMode() {
|
public ChannelBean<Integer> getOffsetMode() {
|
||||||
return offsetMode;
|
return offsetMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the direction
|
* @return the direction
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getDirection() {
|
public ChannelBean<Integer> getDirection() {
|
||||||
return direction;
|
return direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the velocity
|
* @return the velocity
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getVelocity() {
|
public ChannelBean<Double> getVelocity() {
|
||||||
return velocity;
|
return velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the backlashVelocity
|
* @return the backlashVelocity
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getBacklashVelocity() {
|
public ChannelBean<Double> getBacklashVelocity() {
|
||||||
return backlashVelocity;
|
return backlashVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the baseSpeed
|
* @return the baseSpeed
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getBaseSpeed() {
|
public ChannelBean<Double> getBaseSpeed() {
|
||||||
return baseSpeed;
|
return baseSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the accelerationTime
|
* @return the accelerationTime
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getAccelerationTime() {
|
public ChannelBean<Double> getAccelerationTime() {
|
||||||
return accelerationTime;
|
return accelerationTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the backlashAccelerationTime
|
* @return the backlashAccelerationTime
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getBacklashAccelerationTime() {
|
public ChannelBean<Double> getBacklashAccelerationTime() {
|
||||||
return backlashAccelerationTime;
|
return backlashAccelerationTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the backlashDistance
|
* @return the backlashDistance
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getBacklashDistance() {
|
public ChannelBean<Double> getBacklashDistance() {
|
||||||
return backlashDistance;
|
return backlashDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the moveFracion
|
* @return the moveFracion
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getMoveFracion() {
|
public ChannelBean<Double> getMoveFracion() {
|
||||||
return moveFracion;
|
return moveFracion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the motorResolution
|
* @return the motorResolution
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getMotorResolution() {
|
public ChannelBean<Double> getMotorResolution() {
|
||||||
return motorResolution;
|
return motorResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the encoderResolution
|
* @return the encoderResolution
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getEncoderResolution() {
|
public ChannelBean<Double> getEncoderResolution() {
|
||||||
return encoderResolution;
|
return encoderResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the readbackResolution
|
* @return the readbackResolution
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getReadbackResolution() {
|
public ChannelBean<Double> getReadbackResolution() {
|
||||||
return readbackResolution;
|
return readbackResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the retryDeadband
|
* @return the retryDeadband
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getRetryDeadband() {
|
public ChannelBean<Double> getRetryDeadband() {
|
||||||
return retryDeadband;
|
return retryDeadband;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the maxRetryCount
|
* @return the maxRetryCount
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getMaxRetryCount() {
|
public ChannelBean<Integer> getMaxRetryCount() {
|
||||||
return maxRetryCount;
|
return maxRetryCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the retryCount
|
* @return the retryCount
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getRetryCount() {
|
public ChannelBean<Integer> getRetryCount() {
|
||||||
return retryCount;
|
return retryCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the useEncoder
|
* @return the useEncoder
|
||||||
*/
|
*/
|
||||||
public Channel<Boolean> getUseEncoder() {
|
public ChannelBean<Boolean> getUseEncoder() {
|
||||||
return useEncoder;
|
return useEncoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the useReadback
|
* @return the useReadback
|
||||||
*/
|
*/
|
||||||
public Channel<Boolean> getUseReadback() {
|
public ChannelBean<Boolean> getUseReadback() {
|
||||||
return useReadback;
|
return useReadback;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the readbackDelay
|
* @return the readbackDelay
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getReadbackDelay() {
|
public ChannelBean<Double> getReadbackDelay() {
|
||||||
return readbackDelay;
|
return readbackDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the readbackLink
|
* @return the readbackLink
|
||||||
*/
|
*/
|
||||||
public Channel<String> getReadbackLink() {
|
public ChannelBean<String> getReadbackLink() {
|
||||||
return readbackLink;
|
return readbackLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the outputMode
|
* @return the outputMode
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getOutputMode() {
|
public ChannelBean<Integer> getOutputMode() {
|
||||||
return outputMode;
|
return outputMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the moveDone
|
* @return the moveDone
|
||||||
*/
|
*/
|
||||||
public Channel<Boolean> getMoveDone() {
|
public ChannelBean<Boolean> getMoveDone() {
|
||||||
return moveDone;
|
return moveDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,17 +19,15 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.loops.cr;
|
package ch.psi.fda.core.loops.cr;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
import gov.aps.jca.Monitor;
|
import gov.aps.jca.Monitor;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.beans.PropertyChangeListener;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -43,11 +41,8 @@ import ch.psi.fda.core.messages.DataQueue;
|
|||||||
import ch.psi.fda.core.messages.EndOfStreamMessage;
|
import ch.psi.fda.core.messages.EndOfStreamMessage;
|
||||||
import ch.psi.fda.core.messages.Message;
|
import ch.psi.fda.core.messages.Message;
|
||||||
import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.MonitorListenerDoubleTimestamp;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.type.DoubleTimestamp;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -90,13 +85,13 @@ public class ScrlogicLoop implements ActionLoop {
|
|||||||
/**
|
/**
|
||||||
* Sensors to read out
|
* Sensors to read out
|
||||||
*/
|
*/
|
||||||
// private List<Sensor> sensors;
|
private List<Sensor> sensors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of monitors that were attached to the sensor channels (i.e
|
* List of monitors that were attached to the sensor channels (i.e
|
||||||
* workaround)
|
* workaround)
|
||||||
*/
|
*/
|
||||||
private final List<PropertyChangeListener> monitors = new ArrayList<>();
|
private final List<Monitor> monitors = new ArrayList<Monitor>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of blocking queues that hold the data for one sensor (channel)
|
* List of blocking queues that hold the data for one sensor (channel)
|
||||||
@@ -105,20 +100,8 @@ public class ScrlogicLoop implements ActionLoop {
|
|||||||
|
|
||||||
private CountDownLatch latch;
|
private CountDownLatch latch;
|
||||||
|
|
||||||
private List<Channel<DoubleTimestamp>> sensors = new ArrayList<>();
|
public ScrlogicLoop(List<Sensor> sensors) {
|
||||||
private List<String> sensorIds = new ArrayList<>();
|
this.sensors = sensors;
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
public ScrlogicLoop(ChannelService s, List<Sensor> sensors) {
|
|
||||||
try{
|
|
||||||
for(Sensor ss: sensors){
|
|
||||||
this.sensors.add(s.createChannel(new ChannelDescriptor<DoubleTimestamp>(DoubleTimestamp.class, ((ChannelAccessDoubleSensor)ss).getChannel().getName(), true)));
|
|
||||||
sensorIds.add(ss.getId());
|
|
||||||
}
|
|
||||||
this.cservice = s;
|
|
||||||
} catch (ChannelException | InterruptedException | TimeoutException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -133,40 +116,53 @@ public class ScrlogicLoop implements ActionLoop {
|
|||||||
queues.clear();
|
queues.clear();
|
||||||
latch = new CountDownLatch(1);
|
latch = new CountDownLatch(1);
|
||||||
|
|
||||||
|
try {
|
||||||
// Attach monitors to the channels (this is actually a workaround)
|
// Attach monitors to the channels (this is actually a workaround)
|
||||||
for (Channel<DoubleTimestamp> sensor : sensors) {
|
for (Sensor sensor : sensors) {
|
||||||
// if (sensor instanceof ChannelAccessDoubleSensor) {
|
if (sensor instanceof ChannelAccessDoubleSensor) {
|
||||||
// ChannelAccessDoubleSensor s = (ChannelAccessDoubleSensor) sensor;
|
ChannelAccessDoubleSensor s = (ChannelAccessDoubleSensor) sensor;
|
||||||
// Channel<Double> b = s.getChannel();
|
ChannelBean<Double> b = s.getChannel();
|
||||||
// Create data queue for the channel
|
// Create data queue for the channel
|
||||||
final BlockingQueue<TimestampedValue> q = new LinkedBlockingQueue<TimestampedValue>();
|
final BlockingQueue<TimestampedValue> q = new LinkedBlockingQueue<TimestampedValue>();
|
||||||
queues.add(q);
|
queues.add(q);
|
||||||
|
|
||||||
PropertyChangeListener b = new PropertyChangeListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
|
||||||
DoubleTimestamp value = (DoubleTimestamp) evt.getNewValue();
|
|
||||||
q.add(new TimestampedValue(value.getValue(), value.getTimestamp().getTime(), value.getNanosecondOffset()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
sensor.addPropertyChangeListener("value", b);
|
Monitor m = b
|
||||||
|
.attachMonitor(new MonitorListenerDoubleTimestamp() {
|
||||||
monitors.add(b);
|
|
||||||
// }
|
@Override
|
||||||
|
public void valueChanged(Double value, Date timestamp, long nanosecondsOffset) {
|
||||||
|
// Add values to channel queue
|
||||||
|
q.add(new TimestampedValue(value, timestamp.getTime(), nanosecondsOffset));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
monitors.add(m);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (CAException e) {
|
||||||
|
new RuntimeException("Unable to create monitor for channels", e);
|
||||||
|
}
|
||||||
|
|
||||||
logger.info("Start data acquisition");
|
logger.info("Start data acquisition");
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
|
|
||||||
// Remove monitors
|
// Remove monitors
|
||||||
try{
|
try {
|
||||||
for (int i = 0; i < sensors.size(); i++) {
|
for (int i = 0; i < sensors.size(); i++) {
|
||||||
Channel<DoubleTimestamp> sensor = sensors.get(i);
|
Sensor sensor = sensors.get(i);
|
||||||
sensor.removePropertyChangeListener(monitors.get(i));
|
if (sensor instanceof ChannelAccessDoubleSensor) {
|
||||||
|
ChannelAccessDoubleSensor s = (ChannelAccessDoubleSensor) sensor;
|
||||||
|
ChannelBean<Double> b = s.getChannel();
|
||||||
|
try{
|
||||||
|
b.removeMonitor(monitors.get(i));
|
||||||
|
}
|
||||||
|
catch(IllegalArgumentException e){
|
||||||
|
logger.log(Level.SEVERE, "Unable to detach monitor", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (CAException e) {
|
||||||
|
new RuntimeException(e);
|
||||||
}
|
}
|
||||||
finally{
|
finally{
|
||||||
// Clear all monitors in the list
|
// Clear all monitors in the list
|
||||||
@@ -205,12 +201,8 @@ public class ScrlogicLoop implements ActionLoop {
|
|||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
// Destroy all sensors
|
// Destroy all sensors
|
||||||
for (Channel<DoubleTimestamp> s : sensors) {
|
for (Sensor s : sensors) {
|
||||||
try {
|
s.destroy();
|
||||||
s.destroy();
|
|
||||||
} catch (ChannelException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sensors.clear();
|
sensors.clear();
|
||||||
}
|
}
|
||||||
@@ -288,8 +280,8 @@ public class ScrlogicLoop implements ActionLoop {
|
|||||||
m.getComponents().add(new ComponentMetadata(ID_TIMESTAMP_MILLISECONDS));
|
m.getComponents().add(new ComponentMetadata(ID_TIMESTAMP_MILLISECONDS));
|
||||||
m.getComponents().add(
|
m.getComponents().add(
|
||||||
new ComponentMetadata(ID_TIMESTAMP_OFFSET_NANOSECONDS));
|
new ComponentMetadata(ID_TIMESTAMP_OFFSET_NANOSECONDS));
|
||||||
for (String id : sensorIds) {
|
for (Sensor s : sensors) {
|
||||||
m.getComponents().add(new ComponentMetadata(id));
|
m.getComponents().add(new ComponentMetadata(s.getId()));
|
||||||
}
|
}
|
||||||
return new DataQueue(dataQueue, m);
|
return new DataQueue(dataQueue, m);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ package ch.psi.fda.core.loops.cr;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.annotation.CaChannel;
|
import ch.psi.jcae.annotation.CaChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,68 +35,68 @@ public class VSC16ScalerChannelsTemplate {
|
|||||||
/**
|
/**
|
||||||
* Command
|
* Command
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.CNT")
|
@CaChannel(type=Integer.class, name =".CNT")
|
||||||
private Channel<Integer> command;
|
private ChannelBean<Integer> command;
|
||||||
|
|
||||||
|
|
||||||
public enum Mode {OneShot, AutoCount};
|
public enum Mode {OneShot, AutoCount};
|
||||||
/**
|
/**
|
||||||
* Count mode
|
* Count mode
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name ="${PREFIX}.CONT")
|
@CaChannel(type=Integer.class, name =".CONT")
|
||||||
private Channel<Integer> mode;
|
private ChannelBean<Integer> mode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel description
|
* Channel description
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Boolean.class, name={"${PREFIX}.NM1", "${PREFIX}.NM2", "${PREFIX}.NM3", "${PREFIX}.NM4", "${PREFIX}.NM5", "${PREFIX}.NM6", "${PREFIX}.NM7", "${PREFIX}.NM8", "${PREFIX}.NM9", "${PREFIX}.NM10", "${PREFIX}.NM11", "${PREFIX}.NM12", "${PREFIX}.NM13", "${PREFIX}.NM14", "${PREFIX}.NM15", "${PREFIX}.NM16"})
|
@CaChannel(type=Boolean.class, name={".NM1", ".NM2", ".NM3", ".NM4", ".NM5", ".NM6", ".NM7", ".NM8", ".NM9", ".NM10", ".NM11", ".NM12", ".NM13", ".NM14", ".NM15", ".NM16"})
|
||||||
private List<Channel<Boolean>> channelDescription;
|
private List<ChannelBean<Boolean>> channelDescription;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel gate
|
* Channel gate
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Boolean.class, name={"${PREFIX}.G1", "${PREFIX}.G2", "${PREFIX}.G3", "${PREFIX}.G4", "${PREFIX}.G5", "${PREFIX}.G6", "${PREFIX}.G7", "${PREFIX}.G8", "${PREFIX}.G9", "${PREFIX}.G10", "${PREFIX}.G11", "${PREFIX}.G12", "${PREFIX}.G13", "${PREFIX}.G14", "${PREFIX}.G15", "${PREFIX}.G16"})
|
@CaChannel(type=Boolean.class, name={".G1", ".G2", ".G3", ".G4", ".G5", ".G6", ".G7", ".G8", ".G9", ".G10", ".G11", ".G12", ".G13", ".G14", ".G15", ".G16"})
|
||||||
private List<Channel<Boolean>> channelGate;
|
private List<ChannelBean<Boolean>> channelGate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel preset count
|
* Channel preset count
|
||||||
* If gate is on scaler will only count until this value
|
* If gate is on scaler will only count until this value
|
||||||
*/
|
*/
|
||||||
@CaChannel(type=Integer.class, name={"${PREFIX}.PR1", "${PREFIX}.PR2", "${PREFIX}.PR3", "${PREFIX}.PR4", "${PREFIX}.PR5", "${PREFIX}.PR6", "${PREFIX}.PR7", "${PREFIX}.PR8", "${PREFIX}.PR9", "${PREFIX}.PR10", "${PREFIX}.PR11", "${PREFIX}.PR12", "${PREFIX}.PR13", "${PREFIX}.PR14", "${PREFIX}.PR15", "${PREFIX}.PR16"})
|
@CaChannel(type=Integer.class, name={".PR1", ".PR2", ".PR3", ".PR4", ".PR5", ".PR6", ".PR7", ".PR8", ".PR9", ".PR10", ".PR11", ".PR12", ".PR13", ".PR14", ".PR15", ".PR16"})
|
||||||
private List<Channel<Integer>> channelPresetCount;
|
private List<ChannelBean<Integer>> channelPresetCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the command
|
* @return the command
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getCommand() {
|
public ChannelBean<Integer> getCommand() {
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the mode
|
* @return the mode
|
||||||
*/
|
*/
|
||||||
public Channel<Integer> getMode() {
|
public ChannelBean<Integer> getMode() {
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the channelDescription
|
* @return the channelDescription
|
||||||
*/
|
*/
|
||||||
public List<Channel<Boolean>> getChannelDescription() {
|
public List<ChannelBean<Boolean>> getChannelDescription() {
|
||||||
return channelDescription;
|
return channelDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the channelGate
|
* @return the channelGate
|
||||||
*/
|
*/
|
||||||
public List<Channel<Boolean>> getChannelGate() {
|
public List<ChannelBean<Boolean>> getChannelGate() {
|
||||||
return channelGate;
|
return channelGate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the channelPresetCount
|
* @return the channelPresetCount
|
||||||
*/
|
*/
|
||||||
public List<Channel<Integer>> getChannelPresetCount() {
|
public List<ChannelBean<Integer>> getChannelPresetCount() {
|
||||||
return channelPresetCount;
|
return channelPresetCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,11 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.manipulator;
|
package ch.psi.fda.core.manipulator;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -36,10 +39,8 @@ import ch.psi.fda.core.scripting.JythonParameterMapping;
|
|||||||
import ch.psi.fda.core.scripting.JythonParameterMappingChannel;
|
import ch.psi.fda.core.scripting.JythonParameterMappingChannel;
|
||||||
import ch.psi.fda.core.scripting.JythonParameterMappingGlobalVariable;
|
import ch.psi.fda.core.scripting.JythonParameterMappingGlobalVariable;
|
||||||
import ch.psi.fda.core.scripting.JythonParameterMappingID;
|
import ch.psi.fda.core.scripting.JythonParameterMappingID;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manipulation
|
* Manipulation
|
||||||
@@ -97,15 +98,18 @@ public class JythonManipulation implements Manipulation{
|
|||||||
* Parameter array of the entry function
|
* Parameter array of the entry function
|
||||||
*/
|
*/
|
||||||
private String[] parameter;
|
private String[] parameter;
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jython entry call
|
* Jython entry call
|
||||||
*/
|
*/
|
||||||
private String jythonCall;
|
private String jythonCall;
|
||||||
|
|
||||||
public JythonManipulation(ChannelService s, String id, String script, List<JythonParameterMapping> mapping){
|
|
||||||
this(s, id, script, mapping, false);
|
private Map<String,Object> gvariables = new HashMap<String,Object>();
|
||||||
|
|
||||||
|
|
||||||
|
public JythonManipulation(String id, String script, List<JythonParameterMapping> mapping){
|
||||||
|
this(id, script, mapping, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,12 +118,11 @@ public class JythonManipulation implements Manipulation{
|
|||||||
* @param script
|
* @param script
|
||||||
* @param mapping
|
* @param mapping
|
||||||
*/
|
*/
|
||||||
public JythonManipulation(ChannelService s, String id, String script, List<JythonParameterMapping> mapping, boolean returnArray){
|
public JythonManipulation(String id, String script, List<JythonParameterMapping> mapping, boolean returnArray){
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.script = script;
|
this.script = script;
|
||||||
this.mapping = mapping;
|
this.mapping = mapping;
|
||||||
this.returnArray = returnArray;
|
this.returnArray = returnArray;
|
||||||
this.cservice = s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,10 +198,10 @@ public class JythonManipulation implements Manipulation{
|
|||||||
JythonParameterMappingChannel pm = (JythonParameterMappingChannel)jpm;
|
JythonParameterMappingChannel pm = (JythonParameterMappingChannel)jpm;
|
||||||
parameterIndex[i] = null;
|
parameterIndex[i] = null;
|
||||||
|
|
||||||
Channel<?> cb;
|
ChannelBean<?> cb;
|
||||||
try {
|
try {
|
||||||
cb = cservice.createChannel(new ChannelDescriptor<>(pm.getType(), pm.getChannel(), true));
|
cb = ChannelBeanFactory.getFactory().createChannelBean(pm.getType(), pm.getChannel(), true);
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
throw new IllegalArgumentException("Unable to establish channel: "+pm.getChannel(), e);
|
throw new IllegalArgumentException("Unable to establish channel: "+pm.getChannel(), e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException("Unable to establish channel: "+pm.getChannel(), e);
|
throw new RuntimeException("Unable to establish channel: "+pm.getChannel(), e);
|
||||||
@@ -235,12 +238,19 @@ public class JythonManipulation implements Manipulation{
|
|||||||
buffer.setCharAt(buffer.length()-1, ')');
|
buffer.setCharAt(buffer.length()-1, ')');
|
||||||
|
|
||||||
jythonCall = buffer.toString();
|
jythonCall = buffer.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(DataMessage message){
|
public Object execute(DataMessage message){
|
||||||
|
|
||||||
|
// Set global variables - WORKAROUND gvariables
|
||||||
|
// This block is not in initialization as we want to assure that all invocations
|
||||||
|
// of this manipulation will get the same value (i.e. to prevent inconsistent behaviour
|
||||||
|
// if variable was changed during an execution of the manipulation)
|
||||||
|
for(String k: gvariables.keySet()){
|
||||||
|
engine.put(k, gvariables.get(k));
|
||||||
|
}
|
||||||
|
|
||||||
// Manipulate data
|
// Manipulate data
|
||||||
for(int i=0;i<parameterIndex.length;i++){
|
for(int i=0;i<parameterIndex.length;i++){
|
||||||
if(parameterIndex[i] != null){
|
if(parameterIndex[i] != null){
|
||||||
@@ -264,7 +274,8 @@ public class JythonManipulation implements Manipulation{
|
|||||||
return(((Integer)r).doubleValue());
|
return(((Integer)r).doubleValue());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return Double.NaN;
|
// return Double.NaN;
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
@@ -273,4 +284,13 @@ public class JythonManipulation implements Manipulation{
|
|||||||
return Double.NaN;
|
return Double.NaN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workaround to put variables into the jython engine.
|
||||||
|
* @param name
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public void setVariable(String name, Object value){
|
||||||
|
gvariables.put(name, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -19,16 +19,13 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.sensors;
|
package ch.psi.fda.core.sensors;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
import ch.psi.fda.core.EngineConfiguration;
|
import ch.psi.fda.core.EngineConfiguration;
|
||||||
import ch.psi.fda.core.Sensor;
|
import ch.psi.fda.core.Sensor;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scalar sensor that reads a double form a Channel Access channel
|
* Scalar sensor that reads a double form a Channel Access channel
|
||||||
@@ -43,7 +40,7 @@ public class ChannelAccessDoubleArraySensor implements Sensor {
|
|||||||
/**
|
/**
|
||||||
* Channel Access channel of this sensor
|
* Channel Access channel of this sensor
|
||||||
*/
|
*/
|
||||||
private final Channel<double[]> channel;
|
private final ChannelBean<double[]> channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of elements to read from the waveform
|
* Number of elements to read from the waveform
|
||||||
@@ -61,12 +58,12 @@ public class ChannelAccessDoubleArraySensor implements Sensor {
|
|||||||
* @param channelName Name of the Channel Access channel of this sensor
|
* @param channelName Name of the Channel Access channel of this sensor
|
||||||
* @param numberOfElements Number of elements to read out of the waveform
|
* @param numberOfElements Number of elements to read out of the waveform
|
||||||
*/
|
*/
|
||||||
public ChannelAccessDoubleArraySensor(ChannelService s, String id, String channelName, int numberOfElements){
|
public ChannelAccessDoubleArraySensor(String id, String channelName, int numberOfElements){
|
||||||
try {
|
try {
|
||||||
this.channel = s.createChannel(new ChannelDescriptor<>(double[].class, channelName, false, numberOfElements));
|
this.channel = ChannelBeanFactory.getFactory().createChannelBean(double[].class, channelName, false);
|
||||||
this.numberOfElements = numberOfElements;
|
this.numberOfElements = numberOfElements;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize sensor channel [name:"+channelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize sensor channel [name:"+channelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -83,8 +80,7 @@ public class ChannelAccessDoubleArraySensor implements Sensor {
|
|||||||
|
|
||||||
double[] v;
|
double[] v;
|
||||||
try {
|
try {
|
||||||
// v = channel.getValue(numberOfElements);
|
v = channel.getValue(numberOfElements);
|
||||||
v = channel.getValue();
|
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// Only fail during data acquisition if fail on error sensor flag is on true. Otherwise
|
// Only fail during data acquisition if fail on error sensor flag is on true. Otherwise
|
||||||
// return NaN (Not a Number)
|
// return NaN (Not a Number)
|
||||||
@@ -95,7 +91,7 @@ public class ChannelAccessDoubleArraySensor implements Sensor {
|
|||||||
for(int i =0;i<v.length;i++){
|
for(int i =0;i<v.length;i++){
|
||||||
v[i] = Double.NaN;
|
v[i] = Double.NaN;
|
||||||
}
|
}
|
||||||
} catch (ChannelException | TimeoutException | ExecutionException e) {
|
} catch (CAException e) {
|
||||||
// Only fail during data acquisition if fail on error sensor flag is on true. Otherwise
|
// Only fail during data acquisition if fail on error sensor flag is on true. Otherwise
|
||||||
// return NaN (Not a Number)
|
// return NaN (Not a Number)
|
||||||
if(EngineConfiguration.getInstance().isFailOnSensorError()){
|
if(EngineConfiguration.getInstance().isFailOnSensorError()){
|
||||||
@@ -140,7 +136,7 @@ public class ChannelAccessDoubleArraySensor implements Sensor {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy sensor channel: "+channel.getName());
|
logger.finest("Destroy sensor channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,16 +19,13 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.sensors;
|
package ch.psi.fda.core.sensors;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
import ch.psi.fda.core.EngineConfiguration;
|
import ch.psi.fda.core.EngineConfiguration;
|
||||||
import ch.psi.fda.core.Sensor;
|
import ch.psi.fda.core.Sensor;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scalar sensor that reads a double form a Channel Access channel
|
* Scalar sensor that reads a double form a Channel Access channel
|
||||||
@@ -44,7 +41,7 @@ public class ChannelAccessDoubleSensor implements Sensor {
|
|||||||
/**
|
/**
|
||||||
* Channel Access channel of this sensor
|
* Channel Access channel of this sensor
|
||||||
*/
|
*/
|
||||||
private Channel<Double> channel;
|
private ChannelBean<Double> channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global id of the sensor
|
* Global id of the sensor
|
||||||
@@ -56,11 +53,11 @@ public class ChannelAccessDoubleSensor implements Sensor {
|
|||||||
* @param id Global id of the sensor
|
* @param id Global id of the sensor
|
||||||
* @param channelName Name of the Channel Access channel of this sensor
|
* @param channelName Name of the Channel Access channel of this sensor
|
||||||
*/
|
*/
|
||||||
public ChannelAccessDoubleSensor(ChannelService s, String id, String channelName){
|
public ChannelAccessDoubleSensor(String id, String channelName){
|
||||||
try {
|
try {
|
||||||
channel = s.createChannel(new ChannelDescriptor<>(Double.class, channelName, false));
|
channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
} catch (ChannelException | TimeoutException e) {
|
} catch (CAException e) {
|
||||||
// Convert Exception into unchecked RuntimeException
|
// Convert Exception into unchecked RuntimeException
|
||||||
throw new IllegalArgumentException("Unable to initialize sensor channel [name:"+channelName+"]",e);
|
throw new IllegalArgumentException("Unable to initialize sensor channel [name:"+channelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -85,7 +82,7 @@ public class ChannelAccessDoubleSensor implements Sensor {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
v = Double.NaN;
|
v = Double.NaN;
|
||||||
} catch (ChannelException | TimeoutException | ExecutionException e) {
|
} catch (CAException e) {
|
||||||
// Only fail during data acquisition if fail on error sensor flag is on true. Otherwise
|
// Only fail during data acquisition if fail on error sensor flag is on true. Otherwise
|
||||||
// return NaN (Not a Number)
|
// return NaN (Not a Number)
|
||||||
if(EngineConfiguration.getInstance().isFailOnSensorError()){
|
if(EngineConfiguration.getInstance().isFailOnSensorError()){
|
||||||
@@ -119,7 +116,7 @@ public class ChannelAccessDoubleSensor implements Sensor {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy sensor channel: "+channel.getName());
|
logger.finest("Destroy sensor channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,7 +125,7 @@ public class ChannelAccessDoubleSensor implements Sensor {
|
|||||||
* Get channel object of sensor
|
* Get channel object of sensor
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Channel<Double> getChannel(){
|
public ChannelBean<Double> getChannel(){
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,16 +19,13 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.sensors;
|
package ch.psi.fda.core.sensors;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
import ch.psi.fda.core.EngineConfiguration;
|
import ch.psi.fda.core.EngineConfiguration;
|
||||||
import ch.psi.fda.core.Sensor;
|
import ch.psi.fda.core.Sensor;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scalar sensor that reads a double form a Channel Access channel
|
* Scalar sensor that reads a double form a Channel Access channel
|
||||||
@@ -44,7 +41,7 @@ public class ChannelAccessStringSensor implements Sensor {
|
|||||||
/**
|
/**
|
||||||
* Channel Access channel of this sensor
|
* Channel Access channel of this sensor
|
||||||
*/
|
*/
|
||||||
private Channel<String> channel;
|
private ChannelBean<String> channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global id of the sensor
|
* Global id of the sensor
|
||||||
@@ -56,16 +53,15 @@ public class ChannelAccessStringSensor implements Sensor {
|
|||||||
* @param id Global id of the sensor
|
* @param id Global id of the sensor
|
||||||
* @param channelName Name of the Channel Access channel of this sensor
|
* @param channelName Name of the Channel Access channel of this sensor
|
||||||
*/
|
*/
|
||||||
public ChannelAccessStringSensor(ChannelService s, String id, String channelName){
|
public ChannelAccessStringSensor(String id, String channelName){
|
||||||
try {
|
try {
|
||||||
channel = s.createChannel(new ChannelDescriptor<String>(String.class, channelName, false));
|
channel = ChannelBeanFactory.getFactory().createChannelBean(String.class, channelName, false);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
} catch (CAException e) {
|
||||||
|
// Convert Exception into unchecked RuntimeException
|
||||||
|
throw new IllegalArgumentException("Unable to initialize sensor channel [name:"+channelName+"]",e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException("Unable to initialize sensor channel [name:"+channelName+"]",e);
|
throw new RuntimeException("Unable to initialize sensor channel [name:"+channelName+"]",e);
|
||||||
} catch (ChannelException e) {
|
|
||||||
throw new IllegalArgumentException("Unable to initialize sensor channel [name:"+channelName+"]",e);
|
|
||||||
} catch (TimeoutException e) {
|
|
||||||
throw new IllegalArgumentException("Unable to initialize sensor channel [name:"+channelName+"]",e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +82,7 @@ public class ChannelAccessStringSensor implements Sensor {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
v = null;
|
v = null;
|
||||||
} catch (TimeoutException | ExecutionException |ChannelException e) {
|
} catch (CAException e) {
|
||||||
// Only fail during data acquisition if fail on error sensor flag is on true. Otherwise
|
// Only fail during data acquisition if fail on error sensor flag is on true. Otherwise
|
||||||
// return NaN (Not a Number)
|
// return NaN (Not a Number)
|
||||||
if(EngineConfiguration.getInstance().isFailOnSensorError()){
|
if(EngineConfiguration.getInstance().isFailOnSensorError()){
|
||||||
@@ -100,7 +96,6 @@ public class ChannelAccessStringSensor implements Sensor {
|
|||||||
// }
|
// }
|
||||||
// v = null;
|
// v = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(v);
|
return(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +116,7 @@ public class ChannelAccessStringSensor implements Sensor {
|
|||||||
try {
|
try {
|
||||||
logger.finest("Destroy sensor channel: "+channel.getName());
|
logger.finest("Destroy sensor channel: "+channel.getName());
|
||||||
channel.destroy();
|
channel.destroy();
|
||||||
} catch (ChannelException e) {
|
} catch (CAException e) {
|
||||||
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import org.xml.sax.SAXException;
|
|||||||
import org.xml.sax.SAXParseException;
|
import org.xml.sax.SAXParseException;
|
||||||
|
|
||||||
import ch.psi.fda.model.v1.Configuration;
|
import ch.psi.fda.model.v1.Configuration;
|
||||||
|
//import ch.psi.fda.model.v1.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage the serialization and deserialization of the model
|
* Manage the serialization and deserialization of the model
|
||||||
@@ -111,6 +112,15 @@ public class ModelManager {
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
Configuration model = (Configuration) u.unmarshal(bsource, Configuration.class).getValue();
|
Configuration model = (Configuration) u.unmarshal(bsource, Configuration.class).getValue();
|
||||||
|
|
||||||
|
// // Ensure that the filename inside the xml file is always the file name
|
||||||
|
// Data d = model.getData();
|
||||||
|
// if(d==null){
|
||||||
|
// d = new Data();
|
||||||
|
// model.setData(d);
|
||||||
|
// }
|
||||||
|
// d.setFileName(file.getName().replaceAll("\\.xml$", ""));
|
||||||
|
|
||||||
return (model);
|
return (model);
|
||||||
}
|
}
|
||||||
catch(UnmarshalException e){
|
catch(UnmarshalException e){
|
||||||
@@ -142,6 +152,15 @@ public class ModelManager {
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
Configuration model = (Configuration) u.unmarshal(new StreamSource(file), Configuration.class).getValue();
|
Configuration model = (Configuration) u.unmarshal(new StreamSource(file), Configuration.class).getValue();
|
||||||
|
|
||||||
|
// // Ensure that the filename inside the xml file is always the file name
|
||||||
|
// Data d = model.getData();
|
||||||
|
// if(d==null){
|
||||||
|
// d = new Data();
|
||||||
|
// model.setData(d);
|
||||||
|
// }
|
||||||
|
// d.setFileName(file.getName().replaceAll("\\.xml$", ""));
|
||||||
|
|
||||||
return (model);
|
return (model);
|
||||||
}
|
}
|
||||||
catch(UnmarshalException e){
|
catch(UnmarshalException e){
|
||||||
@@ -173,6 +192,14 @@ public class ModelManager {
|
|||||||
Schema schema = sf.newSchema(new Source[]{s}); // Use schema reference provided in XML
|
Schema schema = sf.newSchema(new Source[]{s}); // Use schema reference provided in XML
|
||||||
m.setSchema(schema);
|
m.setSchema(schema);
|
||||||
|
|
||||||
|
// // Set scan name equal to file name
|
||||||
|
// Data d = model.getData();
|
||||||
|
// if(d==null){
|
||||||
|
// d = new Data();
|
||||||
|
// model.setData(d);
|
||||||
|
// }
|
||||||
|
// d.setFileName(file.getName().replaceAll("\\.xml$", ""));
|
||||||
|
|
||||||
m.marshal( new JAXBElement<Configuration>(qname, Configuration.class, model ), file);
|
m.marshal( new JAXBElement<Configuration>(qname, Configuration.class, model ), file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,22 @@ public class Visualizer {
|
|||||||
// XYSeriesP series = ((LinePlot) xyfilter.getPlot()).getData().getSeries(xyfilter.getCount()); // TODO Does not work with multiple series filter per plot !!!!
|
// XYSeriesP series = ((LinePlot) xyfilter.getPlot()).getData().getSeries(xyfilter.getCount()); // TODO Does not work with multiple series filter per plot !!!!
|
||||||
XYSeriesP series = xyfilter.getActualSeries(); // TODO Does not work with multiple series filter per plot !!!!
|
XYSeriesP series = xyfilter.getActualSeries(); // TODO Does not work with multiple series filter per plot !!!!
|
||||||
// series.add((Double) m.getData().get(xyfilter.getIndexX()), (Double) m.getData().get(xyfilter.getIndexY()));
|
// series.add((Double) m.getData().get(xyfilter.getIndexX()), (Double) m.getData().get(xyfilter.getIndexY()));
|
||||||
series.add((Double) m.getData().get(xyfilter.getIndexX()), (Double) m.getData().get(xyfilter.getIndexY()), updateAtStreamElement);
|
|
||||||
|
|
||||||
|
// There might be other values than double in the data, therefore we have to check for it
|
||||||
|
Object dX = m.getData().get(xyfilter.getIndexX());
|
||||||
|
Object dY = m.getData().get(xyfilter.getIndexY());
|
||||||
|
Double dataX = Double.NaN;
|
||||||
|
Double dataY = Double.NaN;
|
||||||
|
if(dX instanceof Double){
|
||||||
|
dataX = (Double) dX;
|
||||||
|
}
|
||||||
|
if(dY instanceof Double){
|
||||||
|
dataY = (Double) dY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add Data to the series
|
||||||
|
series.add(dataX , dataY, updateAtStreamElement);
|
||||||
}
|
}
|
||||||
if(filter instanceof XYSeriesArrayDataFilter){
|
if(filter instanceof XYSeriesArrayDataFilter){
|
||||||
final XYSeriesArrayDataFilter xyfilter = (XYSeriesArrayDataFilter) filter;
|
final XYSeriesArrayDataFilter xyfilter = (XYSeriesArrayDataFilter) filter;
|
||||||
|
|||||||
@@ -1,208 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import ch.psi.fda.TestChannels;
|
|
||||||
import ch.psi.fda.aq.ng.AcquisitionEngineNG;
|
|
||||||
import ch.psi.fda.aq.ng.ScanMapperNG;
|
|
||||||
import ch.psi.fda.model.v1.ArrayPositioner;
|
|
||||||
import ch.psi.fda.model.v1.ChannelAction;
|
|
||||||
import ch.psi.fda.model.v1.Configuration;
|
|
||||||
import ch.psi.fda.model.v1.DiscreteStepDimension;
|
|
||||||
import ch.psi.fda.model.v1.Scan;
|
|
||||||
import ch.psi.fda.model.v1.ScriptAction;
|
|
||||||
import ch.psi.fda.model.v1.ShellAction;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ebner
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class AcquisitionEngineNGTest {
|
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(AcquisitionEngineNGTest.class.getName());
|
|
||||||
|
|
||||||
private AcquisitionEngineNG engine;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws java.lang.Exception
|
|
||||||
*/
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
engine = new AcquisitionEngineNG(new DefaultChannelService());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws java.lang.Exception
|
|
||||||
*/
|
|
||||||
@After
|
|
||||||
public void tearDown() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test method for {@link ch.psi.fda.aq.ng.AcquisitionEngineNG#execute(java.lang.String)}.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testExecuteChannelAction() {
|
|
||||||
|
|
||||||
Configuration config = new Configuration();
|
|
||||||
config.setScan(new Scan());
|
|
||||||
|
|
||||||
// Set value
|
|
||||||
ChannelAction ca = new ChannelAction();
|
|
||||||
ca.setChannel(TestChannels.ANALOG_OUT);
|
|
||||||
ca.setValue("12");
|
|
||||||
ca.setType("Double");
|
|
||||||
ca.setDelay(1.2);
|
|
||||||
|
|
||||||
config.getScan().getPreAction().add(ca);
|
|
||||||
|
|
||||||
// Wait for value
|
|
||||||
ca = new ChannelAction();
|
|
||||||
ca.setChannel(TestChannels.ANALOG_OUT);
|
|
||||||
ca.setValue("12"); // use other value than 12 to test
|
|
||||||
ca.setOperation("wait");
|
|
||||||
ca.setTimeout(10.0);
|
|
||||||
ca.setType("Double");
|
|
||||||
|
|
||||||
config.getScan().getPreAction().add(ca);
|
|
||||||
|
|
||||||
ScriptAction sa = new ScriptAction();
|
|
||||||
sa.setScript("for i in range(0, 3):\n logger.info('hello %d' %i)\n");
|
|
||||||
|
|
||||||
|
|
||||||
// Add discrete step dimension
|
|
||||||
DiscreteStepDimension dimension = new DiscreteStepDimension();
|
|
||||||
|
|
||||||
ArrayPositioner positioner = new ArrayPositioner();
|
|
||||||
positioner.setName(TestChannels.ANALOG_OUT);
|
|
||||||
positioner.setPositions(" 1 2 3 4 5 6 7");
|
|
||||||
dimension.getPositioner().add(positioner);
|
|
||||||
|
|
||||||
dimension.getAction().add(sa);
|
|
||||||
|
|
||||||
config.getScan().getDimension().add(dimension);
|
|
||||||
|
|
||||||
ShellAction a = new ShellAction();
|
|
||||||
a.setCommand("echo hello world this is a test");
|
|
||||||
// a.setExitValue(1);
|
|
||||||
|
|
||||||
// config.getScan().getPostAction().add(sa);
|
|
||||||
config.getScan().getPostAction().add(a);
|
|
||||||
|
|
||||||
|
|
||||||
ScanMapperNG mapper = new ScanMapperNG();
|
|
||||||
mapper.map(config);
|
|
||||||
|
|
||||||
logger.info("Resources to create: "+mapper.getResourceDescriptors());
|
|
||||||
logger.info("Script to execute: "+mapper.getScript());
|
|
||||||
|
|
||||||
|
|
||||||
engine.execute(mapper.getResourceDescriptors(), mapper.getScript(), new ArrayList<String>());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExecuteDimensionActuators() {
|
|
||||||
|
|
||||||
Configuration config = new Configuration();
|
|
||||||
config.setScan(new Scan());
|
|
||||||
|
|
||||||
// Add discrete step dimension
|
|
||||||
DiscreteStepDimension dimension = new DiscreteStepDimension();
|
|
||||||
|
|
||||||
ArrayPositioner positioner = new ArrayPositioner();
|
|
||||||
positioner.setName(TestChannels.ANALOG_OUT);
|
|
||||||
// positioner.setReadback(TestChannels.BINARY_OUT);
|
|
||||||
positioner.setPositions(" 1 2 3 4 5 6 7");
|
|
||||||
dimension.getPositioner().add(positioner);
|
|
||||||
|
|
||||||
positioner = new ArrayPositioner();
|
|
||||||
positioner.setName(TestChannels.BINARY_OUT);
|
|
||||||
positioner.setType("Double");
|
|
||||||
positioner.setPositions(" 10 20 30 40 50 60 70");
|
|
||||||
dimension.getPositioner().add(positioner);
|
|
||||||
|
|
||||||
config.getScan().getDimension().add(dimension);
|
|
||||||
|
|
||||||
|
|
||||||
dimension = new DiscreteStepDimension();
|
|
||||||
|
|
||||||
positioner = new ArrayPositioner();
|
|
||||||
positioner.setName(TestChannels.BINARY_OUT_TWO);
|
|
||||||
positioner.setType("Double");
|
|
||||||
// positioner.setReadback(TestChannels.BINARY_OUT);
|
|
||||||
positioner.setPositions(" 0.1 0.2 0.3 0.4 0.5 0.6 0.7");
|
|
||||||
dimension.getPositioner().add(positioner);
|
|
||||||
|
|
||||||
config.getScan().getDimension().add(dimension);
|
|
||||||
|
|
||||||
ScanMapperNG mapper = new ScanMapperNG();
|
|
||||||
mapper.map(config);
|
|
||||||
|
|
||||||
logger.info("Resources to create: "+mapper.getResourceDescriptors());
|
|
||||||
logger.info("Script to execute: "+mapper.getScript());
|
|
||||||
|
|
||||||
long start, end, elapsed;
|
|
||||||
start = System.currentTimeMillis();
|
|
||||||
engine.execute(mapper.getResourceDescriptors(), mapper.getScript(), new ArrayList<String>());
|
|
||||||
end = System.currentTimeMillis();
|
|
||||||
elapsed = end-start;
|
|
||||||
logger.info("Elapsed time: "+elapsed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCustomScript() {
|
|
||||||
Map<String, Object> rdescriptors = new HashMap<>();
|
|
||||||
rdescriptors.put("x", new ChannelDescriptor<>(Double.class, "MTEST-HW3:MOT1", false));
|
|
||||||
rdescriptors.put("xr", new ChannelDescriptor<>(Double.class, "MTEST-HW3:MOT1.RBV", false));
|
|
||||||
String script = "for i in range(1,5,1):\n"+
|
|
||||||
" x.setValueNoWait(float(i))\n"+
|
|
||||||
" print xr.getValue()\n";
|
|
||||||
// " print 'done'\n";
|
|
||||||
|
|
||||||
engine.execute(rdescriptors, script, new ArrayList<String>());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testT() throws ChannelException, InterruptedException, TimeoutException, ExecutionException{
|
|
||||||
ChannelService c = new DefaultChannelService();
|
|
||||||
Channel<Double> ch = c.createChannel(new ChannelDescriptor<>(Double.class, "MTEST-HW3:MOT1", false));
|
|
||||||
for(double i=0;i<=5.0; i=i+1){
|
|
||||||
ch.setValueAsync(i);
|
|
||||||
// System.out.println(ch.getValue());
|
|
||||||
System.out.println("done");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2013 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package ch.psi.fda.aq.ng;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import ch.psi.fda.TestChannels;
|
|
||||||
import ch.psi.fda.aq.ng.ScanMapperNG;
|
|
||||||
import ch.psi.fda.model.v1.ArrayPositioner;
|
|
||||||
import ch.psi.fda.model.v1.ChannelAction;
|
|
||||||
import ch.psi.fda.model.v1.Configuration;
|
|
||||||
import ch.psi.fda.model.v1.DiscreteStepDimension;
|
|
||||||
import ch.psi.fda.model.v1.LinearPositioner;
|
|
||||||
import ch.psi.fda.model.v1.Scan;
|
|
||||||
import ch.psi.fda.model.v1.ScriptAction;
|
|
||||||
import ch.psi.fda.model.v1.ShellAction;
|
|
||||||
import ch.psi.fda.model.v1.Action;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ebner
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ScanMapperNGTest {
|
|
||||||
|
|
||||||
private ScanMapperNG mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws java.lang.Exception
|
|
||||||
*/
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
mapper = new ScanMapperNG();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws java.lang.Exception
|
|
||||||
*/
|
|
||||||
@After
|
|
||||||
public void tearDown() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test method for {@link ch.psi.fda.aq.ng.ScanMapperNG#mapActions(java.util.List)}.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testMap() {
|
|
||||||
|
|
||||||
Configuration config = new Configuration();
|
|
||||||
config.setScan(new Scan());
|
|
||||||
|
|
||||||
ShellAction a = new ShellAction();
|
|
||||||
a.setCommand("echo hello world this is a test");
|
|
||||||
|
|
||||||
ChannelAction ca = new ChannelAction();
|
|
||||||
ca.setValue("hossa");
|
|
||||||
ca.setDelay(1.2);
|
|
||||||
|
|
||||||
config.getScan().getPreAction().add(a);
|
|
||||||
config.getScan().getPreAction().add(ca);
|
|
||||||
|
|
||||||
ScriptAction sa = new ScriptAction();
|
|
||||||
sa.setScript("print 'hello'");
|
|
||||||
|
|
||||||
config.getScan().getPostAction().add(sa);
|
|
||||||
config.getScan().getPostAction().add(a);
|
|
||||||
|
|
||||||
|
|
||||||
DiscreteStepDimension d = new DiscreteStepDimension();
|
|
||||||
|
|
||||||
ArrayPositioner positioner = new ArrayPositioner();
|
|
||||||
positioner.setName(TestChannels.ANALOG_OUT);
|
|
||||||
positioner.setPositions(" 1 2 3 4 5 6 7");
|
|
||||||
|
|
||||||
d.getPreAction().add(a);
|
|
||||||
d.getPositioner().add(positioner);
|
|
||||||
d.getAction().add(sa);
|
|
||||||
d.getPostAction().add(a);
|
|
||||||
|
|
||||||
config.getScan().getDimension().add(d);
|
|
||||||
config.getScan().getDimension().add(d);
|
|
||||||
|
|
||||||
|
|
||||||
mapper.map(config);
|
|
||||||
String script = mapper.getScript();
|
|
||||||
|
|
||||||
System.out.println(script);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testMapLinearPositioner() {
|
|
||||||
|
|
||||||
Configuration config = new Configuration();
|
|
||||||
config.setScan(new Scan());
|
|
||||||
|
|
||||||
DiscreteStepDimension d = new DiscreteStepDimension();
|
|
||||||
|
|
||||||
LinearPositioner positioner = new LinearPositioner();
|
|
||||||
positioner.setName(TestChannels.ANALOG_OUT);
|
|
||||||
positioner.setStart(0.1);
|
|
||||||
positioner.setEnd(2.2);
|
|
||||||
positioner.setStepSize(0.000001);
|
|
||||||
|
|
||||||
d.getPositioner().add(positioner);
|
|
||||||
|
|
||||||
config.getScan().getDimension().add(d);
|
|
||||||
// config.getScan().getDimension().add(d);
|
|
||||||
|
|
||||||
|
|
||||||
mapper.map(config);
|
|
||||||
String script = mapper.getScript();
|
|
||||||
|
|
||||||
System.out.println(script);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -21,21 +21,18 @@ package ch.psi.fda.core.actions;
|
|||||||
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ch.psi.fda.TestChannels;
|
import ch.psi.fda.TestChannels;
|
||||||
import ch.psi.fda.core.actions.ChannelAccessCondition;
|
import ch.psi.fda.core.actions.ChannelAccessCondition;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -46,14 +43,11 @@ public class ChannelAccessConditionTest {
|
|||||||
// Get Logger
|
// Get Logger
|
||||||
private static Logger logger = Logger.getLogger(ChannelAccessConditionTest.class.getName());
|
private static Logger logger = Logger.getLogger(ChannelAccessConditionTest.class.getName());
|
||||||
|
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,24 +60,21 @@ public class ChannelAccessConditionTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actions.ChannelAccessStringCondition#ChannelAccessStringCondition(java.lang.String, java.lang.String, long)}.
|
* Test method for {@link ch.psi.fda.core.actions.ChannelAccessStringCondition#ChannelAccessStringCondition(java.lang.String, java.lang.String, long)}.
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testChannelAccessStringCondition() throws InterruptedException, ChannelException, TimeoutException, ExecutionException {
|
public void testChannelAccessStringCondition() throws InterruptedException, CAException {
|
||||||
final Channel<String> channel = cservice.createChannel(new ChannelDescriptor<>(String.class, TestChannels.STRING_OUT, false));
|
final ChannelBean<String> channel = ChannelBeanFactory.getFactory().createChannelBean(String.class, TestChannels.STRING_OUT, false);
|
||||||
channel.setValue("SomeValue");
|
channel.setValue("SomeValue");
|
||||||
ChannelAccessCondition<String> c = new ChannelAccessCondition<String>(cservice, TestChannels.STRING_OUT, "SomeValue", 1000l);
|
ChannelAccessCondition<String> c = new ChannelAccessCondition<String>(TestChannels.STRING_OUT, "SomeValue", 1000l);
|
||||||
c.execute();
|
c.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChannelAccessStringConditionRegex() throws InterruptedException, ExecutionException, ChannelException, TimeoutException {
|
public void testChannelAccessStringConditionRegex() throws InterruptedException, CAException {
|
||||||
final Channel<String> channel = cservice.createChannel(new ChannelDescriptor<>(String.class, TestChannels.STRING_OUT, false));
|
final ChannelBean<String> channel = ChannelBeanFactory.getFactory().createChannelBean(String.class, TestChannels.STRING_OUT, false);
|
||||||
channel.setValue("SomeValue");
|
channel.setValue("SomeValue");
|
||||||
ChannelAccessConditionRegex<String> c = new ChannelAccessConditionRegex<String>(cservice, TestChannels.STRING_OUT, "Some.*", 1000l);
|
ChannelAccessConditionRegex<String> c = new ChannelAccessConditionRegex<String>(TestChannels.STRING_OUT, "Some.*", 1000l);
|
||||||
c.execute();
|
c.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,23 +83,20 @@ public class ChannelAccessConditionTest {
|
|||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessStringConditionNotExist() {
|
public void testChannelAccessStringConditionNotExist() {
|
||||||
new ChannelAccessCondition<String>(cservice, TestChannels.STRING_OUT_NOT_EXIST, "SomeValue", 1000l);
|
new ChannelAccessCondition<String>(TestChannels.STRING_OUT_NOT_EXIST, "SomeValue", 1000l);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actions.ChannelAccessStringCondition#execute()}.
|
* Test method for {@link ch.psi.fda.core.actions.ChannelAccessStringCondition#execute()}.
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecute() throws InterruptedException, ChannelException, TimeoutException, ExecutionException {
|
public void testExecute() throws CAException, InterruptedException {
|
||||||
String value = "SomeValue";
|
String value = "SomeValue";
|
||||||
|
|
||||||
final ChannelAccessCondition<String> action = new ChannelAccessCondition<String>(cservice, TestChannels.STRING_OUT, value, 10000l);
|
final ChannelAccessCondition<String> action = new ChannelAccessCondition<String>(TestChannels.STRING_OUT, value, 10000l);
|
||||||
final Channel<String> channel = cservice.createChannel(new ChannelDescriptor<>(String.class, TestChannels.STRING_OUT, false));
|
final ChannelBean<String> channel = ChannelBeanFactory.getFactory().createChannelBean(String.class, TestChannels.STRING_OUT, false);
|
||||||
|
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
|
|
||||||
@@ -143,11 +131,11 @@ public class ChannelAccessConditionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=RuntimeException.class)
|
@Test(expected=RuntimeException.class)
|
||||||
public void testExecuteFail() throws InterruptedException, ExecutionException, ChannelException, TimeoutException {
|
public void testExecuteFail() throws CAException, InterruptedException {
|
||||||
String value = "SomeValue";
|
String value = "SomeValue";
|
||||||
|
|
||||||
final ChannelAccessCondition<String> action = new ChannelAccessCondition<String>(cservice, TestChannels.STRING_OUT, value, 9000l);
|
final ChannelAccessCondition<String> action = new ChannelAccessCondition<String>(TestChannels.STRING_OUT, value, 9000l);
|
||||||
final Channel<String> channel = cservice.createChannel(new ChannelDescriptor<>(String.class, TestChannels.STRING_OUT, false));
|
final ChannelBean<String> channel = ChannelBeanFactory.getFactory().createChannelBean(String.class, TestChannels.STRING_OUT, false);
|
||||||
|
|
||||||
|
|
||||||
// Set the value to something else than the expected value
|
// Set the value to something else than the expected value
|
||||||
@@ -160,16 +148,13 @@ public class ChannelAccessConditionTest {
|
|||||||
* Test method for {@link ch.psi.fda.core.actions.ChannelAccessStringCondition#execute()}.
|
* Test method for {@link ch.psi.fda.core.actions.ChannelAccessStringCondition#execute()}.
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteInteger() throws InterruptedException, ChannelException, TimeoutException, ExecutionException {
|
public void testExecuteInteger() throws CAException, InterruptedException {
|
||||||
Integer value = 12;
|
Integer value = 12;
|
||||||
|
|
||||||
final ChannelAccessCondition<Integer> action = new ChannelAccessCondition<Integer>(cservice, TestChannels.STRING_OUT, value, 10000l);
|
final ChannelAccessCondition<Integer> action = new ChannelAccessCondition<Integer>(TestChannels.STRING_OUT, value, 10000l);
|
||||||
final Channel<Integer> channel = cservice.createChannel(new ChannelDescriptor<>(Integer.class, TestChannels.STRING_OUT, false));
|
final ChannelBean<Integer> channel = ChannelBeanFactory.getFactory().createChannelBean(Integer.class, TestChannels.STRING_OUT, false);
|
||||||
|
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
|
|
||||||
@@ -207,14 +192,11 @@ public class ChannelAccessConditionTest {
|
|||||||
* Test to ensure that the abort function is working correctly
|
* Test to ensure that the abort function is working correctly
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testWaitAbort() throws InterruptedException, ChannelException, TimeoutException, ExecutionException {
|
public void testWaitAbort() throws CAException, InterruptedException {
|
||||||
final ChannelAccessCondition<Integer> action = new ChannelAccessCondition<Integer>(cservice, TestChannels.BINARY_OUT, 1, 10000l);
|
final ChannelAccessCondition<Integer> action = new ChannelAccessCondition<Integer>(TestChannels.BINARY_OUT, 1, 10000l);
|
||||||
final Channel<Integer> channel = cservice.createChannel(new ChannelDescriptor<>(Integer.class, TestChannels.BINARY_OUT, false));
|
final ChannelBean<Integer> channel = ChannelBeanFactory.getFactory().createChannelBean(Integer.class, TestChannels.BINARY_OUT, false);
|
||||||
|
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -32,11 +32,8 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import ch.psi.fda.TestChannels;
|
import ch.psi.fda.TestChannels;
|
||||||
import ch.psi.fda.core.actions.ChannelAccessPut;
|
import ch.psi.fda.core.actions.ChannelAccessPut;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for ChannelAccessStringPut
|
* Test class for ChannelAccessStringPut
|
||||||
@@ -45,14 +42,12 @@ import ch.psi.jcae.impl.DefaultChannelService;
|
|||||||
*/
|
*/
|
||||||
public class ChannelAccessPutTest {
|
public class ChannelAccessPutTest {
|
||||||
|
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,7 +63,7 @@ public class ChannelAccessPutTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testChannelAccessStringPutStringStringBoolean() {
|
public void testChannelAccessStringPutStringStringBoolean() {
|
||||||
new ChannelAccessPut<String>(cservice, TestChannels.STRING_OUT, "SomeValue", true, null);
|
new ChannelAccessPut<String>(TestChannels.STRING_OUT, "SomeValue", true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,7 +72,7 @@ public class ChannelAccessPutTest {
|
|||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessStringPutStringStringBooleanNotExist() {
|
public void testChannelAccessStringPutStringStringBooleanNotExist() {
|
||||||
new ChannelAccessPut<String>(cservice, TestChannels.STRING_OUT_NOT_EXIST, "SomeValue", true, null);
|
new ChannelAccessPut<String>(TestChannels.STRING_OUT_NOT_EXIST, "SomeValue", true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,7 +81,7 @@ public class ChannelAccessPutTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testChannelAccessStringPutStringString() {
|
public void testChannelAccessStringPutStringString() {
|
||||||
new ChannelAccessPut<String>(cservice, TestChannels.STRING_OUT, "SomeValue");
|
new ChannelAccessPut<String>(TestChannels.STRING_OUT, "SomeValue");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,25 +90,22 @@ public class ChannelAccessPutTest {
|
|||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessStringPutStringStringNotExist() {
|
public void testChannelAccessStringPutStringStringNotExist() {
|
||||||
new ChannelAccessPut<String>(cservice, TestChannels.STRING_OUT_NOT_EXIST, "SomeValue");
|
new ChannelAccessPut<String>(TestChannels.STRING_OUT_NOT_EXIST, "SomeValue");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actions.ChannelAccessStringPut#execute()}.
|
* Test method for {@link ch.psi.fda.core.actions.ChannelAccessStringPut#execute()}.
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecute() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testExecute() throws CAException, InterruptedException {
|
||||||
|
|
||||||
String setValue = "MyTestString";
|
String setValue = "MyTestString";
|
||||||
ChannelAccessPut<String> action = new ChannelAccessPut<String>(cservice, TestChannels.STRING_OUT, setValue);
|
ChannelAccessPut<String> action = new ChannelAccessPut<String>(TestChannels.STRING_OUT, setValue);
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
Channel<String> channel = cservice.createChannel(new ChannelDescriptor<>(String.class, TestChannels.STRING_OUT, false));
|
ChannelBean<String> channel = ChannelBeanFactory.getFactory().createChannelBean(String.class, TestChannels.STRING_OUT, false);
|
||||||
String value = channel.getValue();
|
String value = channel.getValue();
|
||||||
|
|
||||||
if(!value.equals(setValue)){
|
if(!value.equals(setValue)){
|
||||||
@@ -123,21 +115,18 @@ public class ChannelAccessPutTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actions.ChannelAccessStringPut#execute()}.
|
* Test method for {@link ch.psi.fda.core.actions.ChannelAccessStringPut#execute()}.
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteString() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testExecuteString() throws CAException, InterruptedException {
|
||||||
|
|
||||||
String setValue = "MyTestString";
|
String setValue = "MyTestString";
|
||||||
|
|
||||||
Channel<String> channel = cservice.createChannel(new ChannelDescriptor<>(String.class, TestChannels.STRING_OUT, false));
|
ChannelBean<String> channel = ChannelBeanFactory.getFactory().createChannelBean(String.class, TestChannels.STRING_OUT, false);
|
||||||
// Set channel to something else
|
// Set channel to something else
|
||||||
channel.setValue(setValue+"test");
|
channel.setValue(setValue+"test");
|
||||||
|
|
||||||
ChannelAccessPut<String> action = new ChannelAccessPut<String>(cservice, TestChannels.STRING_OUT, setValue);
|
ChannelAccessPut<String> action = new ChannelAccessPut<String>(TestChannels.STRING_OUT, setValue);
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
|
|
||||||
@@ -154,11 +143,11 @@ public class ChannelAccessPutTest {
|
|||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteMulti() throws InterruptedException {
|
public void testExecuteMulti() throws CAException, InterruptedException {
|
||||||
|
|
||||||
List<ChannelAccessPut<String>> actions = new ArrayList<ChannelAccessPut<String>>();
|
List<ChannelAccessPut<String>> actions = new ArrayList<ChannelAccessPut<String>>();
|
||||||
for(int i=0;i<20;i++){
|
for(int i=0;i<20;i++){
|
||||||
actions.add(new ChannelAccessPut<String>(cservice, TestChannels.STRING_OUT, i+""));
|
actions.add(new ChannelAccessPut<String>(TestChannels.STRING_OUT, i+""));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ChannelAccessPut<String> action: actions){
|
for(ChannelAccessPut<String> action: actions){
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ import org.junit.Test;
|
|||||||
import ch.psi.fda.TestChannels;
|
import ch.psi.fda.TestChannels;
|
||||||
import ch.psi.fda.core.actions.JythonAction;
|
import ch.psi.fda.core.actions.JythonAction;
|
||||||
import ch.psi.fda.core.scripting.JythonParameterMappingChannel;
|
import ch.psi.fda.core.scripting.JythonParameterMappingChannel;
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -40,13 +38,11 @@ import ch.psi.jcae.impl.DefaultChannelService;
|
|||||||
*/
|
*/
|
||||||
public class JythonActionTest {
|
public class JythonActionTest {
|
||||||
|
|
||||||
private ChannelService cservice;
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,7 +61,7 @@ public class JythonActionTest {
|
|||||||
String script = "import math\ndef process(o):\n print o.getValue()\n o.setValue(-1.0)\n print o.getValue()\n val=math.cos(10.0) + math.sin(o.getValue())\n print val\n o.setValue(val)";
|
String script = "import math\ndef process(o):\n print o.getValue()\n o.setValue(-1.0)\n print o.getValue()\n val=math.cos(10.0) + math.sin(o.getValue())\n print val\n o.setValue(val)";
|
||||||
List<JythonParameterMappingChannel> mapping = new ArrayList<JythonParameterMappingChannel>();
|
List<JythonParameterMappingChannel> mapping = new ArrayList<JythonParameterMappingChannel>();
|
||||||
mapping.add(new JythonParameterMappingChannel("o", TestChannels.ANALOG_OUT, Double.class));
|
mapping.add(new JythonParameterMappingChannel("o", TestChannels.ANALOG_OUT, Double.class));
|
||||||
JythonAction action = new JythonAction(cservice, script, mapping);
|
JythonAction action = new JythonAction(script, mapping);
|
||||||
|
|
||||||
// Execute action
|
// Execute action
|
||||||
action.execute();
|
action.execute();
|
||||||
@@ -82,7 +78,7 @@ public class JythonActionTest {
|
|||||||
List<JythonParameterMappingChannel> mapping = new ArrayList<JythonParameterMappingChannel>();
|
List<JythonParameterMappingChannel> mapping = new ArrayList<JythonParameterMappingChannel>();
|
||||||
mapping.add(new JythonParameterMappingChannel("o", TestChannels.ANALOG_OUT, Double.class));
|
mapping.add(new JythonParameterMappingChannel("o", TestChannels.ANALOG_OUT, Double.class));
|
||||||
mapping.add(new JythonParameterMappingChannel("b", TestChannels.ANALOG_OUT, Double.class));
|
mapping.add(new JythonParameterMappingChannel("b", TestChannels.ANALOG_OUT, Double.class));
|
||||||
JythonAction action = new JythonAction(cservice, script, mapping);
|
JythonAction action = new JythonAction(script, mapping);
|
||||||
|
|
||||||
// Execute action
|
// Execute action
|
||||||
action.execute();
|
action.execute();
|
||||||
@@ -98,7 +94,7 @@ public class JythonActionTest {
|
|||||||
String script = "import math\ndef process(o):\n print o.getValue()\n o.setValue(-1.0)\n print o.getValue()\n val=math.cos(10.0) + math.sin(o.getValue())\n print val\n o.setValue(val)";
|
String script = "import math\ndef process(o):\n print o.getValue()\n o.setValue(-1.0)\n print o.getValue()\n val=math.cos(10.0) + math.sin(o.getValue())\n print val\n o.setValue(val)";
|
||||||
List<JythonParameterMappingChannel> mapping = new ArrayList<JythonParameterMappingChannel>();
|
List<JythonParameterMappingChannel> mapping = new ArrayList<JythonParameterMappingChannel>();
|
||||||
mapping.add(new JythonParameterMappingChannel("ooo", TestChannels.ANALOG_OUT, Double.class));
|
mapping.add(new JythonParameterMappingChannel("ooo", TestChannels.ANALOG_OUT, Double.class));
|
||||||
JythonAction action = new JythonAction(cservice, script, mapping);
|
JythonAction action = new JythonAction(script, mapping);
|
||||||
|
|
||||||
// Execute action
|
// Execute action
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|||||||
@@ -21,12 +21,11 @@ package ch.psi.fda.core.actors;
|
|||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -35,11 +34,8 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import ch.psi.fda.TestChannels;
|
import ch.psi.fda.TestChannels;
|
||||||
import ch.psi.fda.core.actors.ChannelAccessFunctionActuator;
|
import ch.psi.fda.core.actors.ChannelAccessFunctionActuator;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class specific for the FunctionActuatorChannelAccess implementation.
|
* Test class specific for the FunctionActuatorChannelAccess implementation.
|
||||||
@@ -57,20 +53,18 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
private static final double doneDelay = 0;
|
private static final double doneDelay = 0;
|
||||||
private static final Long timeout = 1800000l; // 30 minutes
|
private static final Long timeout = 1800000l; // 30 minutes
|
||||||
|
|
||||||
private Channel<Double> channel;
|
private ChannelBean<Double> channel;
|
||||||
private Channel<Integer> doneChannel;
|
private ChannelBean<Integer> doneChannel;
|
||||||
|
|
||||||
private Function function;
|
private Function function;
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
|
||||||
channel = cservice.createChannel(new ChannelDescriptor<>(Double.class, channelName, false));
|
doneChannel = ChannelBeanFactory.getFactory().createChannelBean(Integer.class, channelNameDone, false);
|
||||||
doneChannel = cservice.createChannel(new ChannelDescriptor<>(Integer.class, channelNameDone, false));
|
|
||||||
|
|
||||||
function = new Function() {
|
function = new Function() {
|
||||||
|
|
||||||
@@ -93,22 +87,22 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
* Check whether Exception is thrown if a negative step size is specified.
|
* Check whether Exception is thrown if a negative step size is specified.
|
||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessFunctionActuatorNegativeStepSize() throws SocketException, Exception {
|
public void testChannelAccessFunctionActuatorNegativeStepSize() throws SocketException, CAException, Exception {
|
||||||
// Need to throw exception because of negative step size
|
// Need to throw exception because of negative step size
|
||||||
new ChannelAccessFunctionActuator<Object>(cservice, channelName, function,0, 1, -0.1, timeout);
|
new ChannelAccessFunctionActuator<Object>(channelName, function,0, 1, -0.1, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessFunctionActuator#FunctionActuatorChannelAccess(String, double, double, double)}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessFunctionActuator#FunctionActuatorChannelAccess(String, double, double, double)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testChannelAccessFunctionActuatorTimeout() throws SocketException, Exception {
|
public void testChannelAccessFunctionActuatorTimeout() throws SocketException, CAException, Exception {
|
||||||
|
|
||||||
// Negative timeout
|
// Negative timeout
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
try{
|
try{
|
||||||
// Need to return IllegalArgumentException due to negative Timeout
|
// Need to return IllegalArgumentException due to negative Timeout
|
||||||
new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, 0, 1, 0.1, -1l);
|
new ChannelAccessFunctionActuator<Object>(channelName, function, 0, 1, 0.1, -1l);
|
||||||
}
|
}
|
||||||
catch(IllegalArgumentException e){
|
catch(IllegalArgumentException e){
|
||||||
flag=true;
|
flag=true;
|
||||||
@@ -121,7 +115,7 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
flag=false;
|
flag=false;
|
||||||
try{
|
try{
|
||||||
// Need to return IllegalArgumentException
|
// Need to return IllegalArgumentException
|
||||||
new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, 0, 1, 0.1, -0l);
|
new ChannelAccessFunctionActuator<Object>(channelName, function, 0, 1, 0.1, -0l);
|
||||||
}
|
}
|
||||||
catch(IllegalArgumentException e){
|
catch(IllegalArgumentException e){
|
||||||
flag=true;
|
flag=true;
|
||||||
@@ -131,10 +125,10 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Accept null timeout
|
// Accept null timeout
|
||||||
new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, 0, 1, 0.1, null);
|
new ChannelAccessFunctionActuator<Object>(channelName, function, 0, 1, 0.1, null);
|
||||||
|
|
||||||
// Accept positive timeout
|
// Accept positive timeout
|
||||||
new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, 0, 1, 0.1, 1l);
|
new ChannelAccessFunctionActuator<Object>(channelName, function, 0, 1, 0.1, 1l);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,18 +137,18 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
* Check whether Exception is thrown if a zero step size is specified.
|
* Check whether Exception is thrown if a zero step size is specified.
|
||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessFunctionActuatorZeroStepSize() throws SocketException, Exception {
|
public void testChannelAccessFunctionActuatorZeroStepSize() throws SocketException, CAException, Exception {
|
||||||
// Zero step size need to cause an exception
|
// Zero step size need to cause an exception
|
||||||
new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, 0, 1, 0, timeout);
|
new ChannelAccessFunctionActuator<Object>(channelName, function, 0, 1, 0, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessFunctionActuator#FunctionActuatorChannelAccess(String, double, double, double)}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessFunctionActuator#FunctionActuatorChannelAccess(String, double, double, double)}.
|
||||||
* Check correct initialization
|
* Check correct initialization
|
||||||
*/
|
*/
|
||||||
public void testChannelAccessFunctionActuator() throws SocketException, Exception {
|
public void testChannelAccessFunctionActuator() throws SocketException, CAException, Exception {
|
||||||
// Zero step size need to cause an exception
|
// Zero step size need to cause an exception
|
||||||
new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, 0, 10, 1, timeout);
|
new ChannelAccessFunctionActuator<Object>(channelName, function, 0, 10, 1, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -164,7 +158,7 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSet() throws InterruptedException {
|
public void testSet() throws InterruptedException {
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, 0, 0.09999, 0.1, timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, function, 0, 0.09999, 0.1, timeout);
|
||||||
actuator.set();
|
actuator.set();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +169,7 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test(expected=IllegalStateException.class)
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testSetNoNext() throws InterruptedException {
|
public void testSetNoNext() throws InterruptedException {
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, 0, 0.09999, 0.1, timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, function, 0, 0.09999, 0.1, timeout);
|
||||||
actuator.set();
|
actuator.set();
|
||||||
actuator.set();
|
actuator.set();
|
||||||
}
|
}
|
||||||
@@ -186,7 +180,7 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHasNextOneStep() throws InterruptedException {
|
public void testHasNextOneStep() throws InterruptedException {
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, 0, 0.09999, 0.1, timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, function, 0, 0.09999, 0.1, timeout);
|
||||||
// Execute first set (because there is always a first move)
|
// Execute first set (because there is always a first move)
|
||||||
actuator.set();
|
actuator.set();
|
||||||
|
|
||||||
@@ -203,7 +197,7 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHasNext() throws InterruptedException {
|
public void testHasNext() throws InterruptedException {
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, 0, 10, 0.1, timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, function, 0, 10, 0.1, timeout);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int steps = (int) ((10-0)/0.1)+1;
|
int steps = (int) ((10-0)/0.1)+1;
|
||||||
@@ -233,7 +227,7 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
|
|
||||||
|
|
||||||
for(double[] svalue: settings){
|
for(double[] svalue: settings){
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, svalue[0], svalue[1], svalue[2], timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, function, svalue[0], svalue[1], svalue[2], timeout);
|
||||||
|
|
||||||
int count =0;
|
int count =0;
|
||||||
while(actuator.hasNext()){
|
while(actuator.hasNext()){
|
||||||
@@ -252,13 +246,10 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessFunctionActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessFunctionActuator#set()}.
|
||||||
* Test actuator move start<end and start>end ...
|
* Test actuator move start<end and start>end ...
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testReverse() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testReverse() throws CAException, InterruptedException {
|
||||||
|
|
||||||
List<double[]> settings = new ArrayList<double[]>();
|
List<double[]> settings = new ArrayList<double[]>();
|
||||||
// start end stepsize
|
// start end stepsize
|
||||||
@@ -267,7 +258,7 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
|
|
||||||
|
|
||||||
for(double[] svalue: settings){
|
for(double[] svalue: settings){
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, svalue[0], svalue[1], svalue[2], timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, function, svalue[0], svalue[1], svalue[2], timeout);
|
||||||
actuator.init();
|
actuator.init();
|
||||||
|
|
||||||
int count =0;
|
int count =0;
|
||||||
@@ -337,13 +328,10 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessFunctionActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessFunctionActuator#set()}.
|
||||||
* Test actuator move start<end and start>end ...
|
* Test actuator move start<end and start>end ...
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testReverseReset() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testReverseReset() throws CAException, InterruptedException {
|
||||||
|
|
||||||
List<double[]> settings = new ArrayList<double[]>();
|
List<double[]> settings = new ArrayList<double[]>();
|
||||||
// start end stepsize
|
// start end stepsize
|
||||||
@@ -352,7 +340,7 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
|
|
||||||
|
|
||||||
for(double[] svalue: settings){
|
for(double[] svalue: settings){
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, svalue[0], svalue[1], svalue[2], timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, function, svalue[0], svalue[1], svalue[2], timeout);
|
||||||
actuator.init();
|
actuator.init();
|
||||||
|
|
||||||
int count =0;
|
int count =0;
|
||||||
@@ -429,9 +417,9 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
* Check whether Exception is thrown if a negative step size is specified.
|
* Check whether Exception is thrown if a negative step size is specified.
|
||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessGPFunctionActuatorNegativeStepSize() throws SocketException, Exception {
|
public void testChannelAccessGPFunctionActuatorNegativeStepSize() throws SocketException, CAException, Exception {
|
||||||
// Need to throw exception because of negative step size
|
// Need to throw exception because of negative step size
|
||||||
new ChannelAccessFunctionActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, function, 0, 1, -0.1, timeout);
|
new ChannelAccessFunctionActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, function, 0, 1, -0.1, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -439,31 +427,29 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
* Check whether Exception is thrown if a zero step size is specified.
|
* Check whether Exception is thrown if a zero step size is specified.
|
||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessGPFunctionActuatorZeroStepSize() throws SocketException, Exception {
|
public void testChannelAccessGPFunctionActuatorZeroStepSize() throws SocketException, CAException, Exception {
|
||||||
// Zero step size need to cause an exception
|
// Zero step size need to cause an exception
|
||||||
new ChannelAccessFunctionActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, function, 0, 1, 0, timeout);
|
new ChannelAccessFunctionActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, function, 0, 1, 0, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#FunctionActuatorChannelAccess(String, double, double, double)}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#FunctionActuatorChannelAccess(String, double, double, double)}.
|
||||||
* Check correct initialization
|
* Check correct initialization
|
||||||
*/
|
*/
|
||||||
public void testChannelAccessGPFunctionActuator() throws SocketException, Exception {
|
public void testChannelAccessGPFunctionActuator() throws SocketException, CAException, Exception {
|
||||||
// Zero step size need to cause an exception
|
// Zero step size need to cause an exception
|
||||||
new ChannelAccessFunctionActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, function, 0, 10, 1, timeout);
|
new ChannelAccessFunctionActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, function, 0, 10, 1, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#set()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneSet() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneSet() throws CAException, InterruptedException {
|
||||||
|
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, function, 0, 0.09999, 0.1, timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, function, 0, 0.09999, 0.1, timeout);
|
||||||
|
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
doneChannel.setValue(0);
|
doneChannel.setValue(0);
|
||||||
@@ -486,14 +472,12 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#set()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneDelay() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneDelay() throws CAException, InterruptedException {
|
||||||
|
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, channelNameDone, doneValue, 1.5, function, 0, 1, 0.1, timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, channelNameDone, doneValue, 1.5, function, 0, 1, 0.1, timeout);
|
||||||
|
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
doneChannel.setValue(1);
|
doneChannel.setValue(1);
|
||||||
@@ -526,14 +510,12 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#hasNext()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#hasNext()}.
|
||||||
* Check whether the actuator throws an Exception if there is no next point but set() is called
|
* Check whether the actuator throws an Exception if there is no next point but set() is called
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test(expected=IllegalStateException.class)
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testDoneSetNoNext() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneSetNoNext() throws CAException, InterruptedException {
|
||||||
|
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, function,0, 0.09999, 0.1, timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, function,0, 0.09999, 0.1, timeout);
|
||||||
|
|
||||||
|
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
@@ -576,13 +558,11 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#hasNext()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#hasNext()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneHasNextOneStep() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneHasNextOneStep() throws CAException, InterruptedException {
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, function, 0, 0.09999, 0.1, timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, function, 0, 0.09999, 0.1, timeout);
|
||||||
|
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
doneChannel.setValue(0);
|
doneChannel.setValue(0);
|
||||||
@@ -612,13 +592,11 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#hasNext()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#hasNext()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneHasNext() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneHasNext() throws CAException, InterruptedException {
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, function,0, 10, 0.1, timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, function,0, 10, 0.1, timeout);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int steps = (int) ((10-0)/0.1)+1;
|
int steps = (int) ((10-0)/0.1)+1;
|
||||||
@@ -655,12 +633,10 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#set()}.
|
||||||
* Test actuator move start<end and start>end ...
|
* Test actuator move start<end and start>end ...
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneSetLoop() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneSetLoop() throws CAException, InterruptedException {
|
||||||
|
|
||||||
List<double[]> settings = new ArrayList<double[]>();
|
List<double[]> settings = new ArrayList<double[]>();
|
||||||
// start end stepsize
|
// start end stepsize
|
||||||
@@ -669,7 +645,7 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
|
|
||||||
|
|
||||||
for(double[] svalue: settings){
|
for(double[] svalue: settings){
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, function, svalue[0], svalue[1], svalue[2], timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, function, svalue[0], svalue[1], svalue[2], timeout);
|
||||||
|
|
||||||
int count =0;
|
int count =0;
|
||||||
while(actuator.hasNext()){
|
while(actuator.hasNext()){
|
||||||
@@ -706,13 +682,10 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPFunctionActuator#set()}.
|
||||||
* Test whether the actuator returns if the actuator is already on the position it should be before the move ...
|
* Test whether the actuator returns if the actuator is already on the position it should be before the move ...
|
||||||
* (see issue XASEC-278)
|
* (see issue XASEC-278)
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMoveToActualPosition() throws InterruptedException, ExecutionException, ChannelException, TimeoutException {
|
public void testMoveToActualPosition() throws CAException, InterruptedException {
|
||||||
|
|
||||||
double start = 0;
|
double start = 0;
|
||||||
double end = 2;
|
double end = 2;
|
||||||
@@ -724,7 +697,7 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
|
|
||||||
logger.info("Current channel value: "+channel.getValue());
|
logger.info("Current channel value: "+channel.getValue());
|
||||||
|
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, function, start, end, stepSize, timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, function, start, end, stepSize, timeout);
|
||||||
while(actuator.hasNext()){
|
while(actuator.hasNext()){
|
||||||
|
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
@@ -767,7 +740,7 @@ public class ChannelAccessFunctionActuatorTest {
|
|||||||
|
|
||||||
|
|
||||||
for(double[] svalue: settings){
|
for(double[] svalue: settings){
|
||||||
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(cservice, channelName, function, svalue[0], svalue[1], svalue[2], timeout);
|
ChannelAccessFunctionActuator<Object> actuator = new ChannelAccessFunctionActuator<Object>(channelName, function, svalue[0], svalue[1], svalue[2], timeout);
|
||||||
|
|
||||||
int count =0;
|
int count =0;
|
||||||
while(actuator.hasNext()){
|
while(actuator.hasNext()){
|
||||||
|
|||||||
@@ -21,12 +21,11 @@ package ch.psi.fda.core.actors;
|
|||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -35,11 +34,8 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import ch.psi.fda.TestChannels;
|
import ch.psi.fda.TestChannels;
|
||||||
import ch.psi.fda.core.actors.ChannelAccessLinearActuator;
|
import ch.psi.fda.core.actors.ChannelAccessLinearActuator;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class specific for the LinearActuatorChannelAccess implementation.
|
* Test class specific for the LinearActuatorChannelAccess implementation.
|
||||||
@@ -57,18 +53,16 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
private static final double doneDelay = 0;
|
private static final double doneDelay = 0;
|
||||||
private static final Long timeout = 1800000l; // 30 minutes
|
private static final Long timeout = 1800000l; // 30 minutes
|
||||||
|
|
||||||
private Channel<Double> channel;
|
private ChannelBean<Double> channel;
|
||||||
private Channel<Integer> doneChannel;
|
private ChannelBean<Integer> doneChannel;
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
|
||||||
channel = cservice.createChannel(new ChannelDescriptor<>(Double.class, channelName, false));
|
doneChannel = ChannelBeanFactory.getFactory().createChannelBean(Integer.class, channelNameDone, false);
|
||||||
doneChannel = cservice.createChannel(new ChannelDescriptor<>(Integer.class, channelNameDone, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,22 +77,22 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
* Check whether Exception is thrown if a negative step size is specified.
|
* Check whether Exception is thrown if a negative step size is specified.
|
||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessLinearActuatorNegativeStepSize() throws SocketException, Exception {
|
public void testChannelAccessLinearActuatorNegativeStepSize() throws SocketException, CAException, Exception {
|
||||||
// Need to throw exception because of negative step size
|
// Need to throw exception because of negative step size
|
||||||
new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, 0, 1, -0.1, timeout);
|
new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, 0, 1, -0.1, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessLinearActuator#LinearActuatorChannelAccess(String, double, double, double)}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessLinearActuator#LinearActuatorChannelAccess(String, double, double, double)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testChannelAccessLinearActuatorTimeout() throws SocketException, Exception {
|
public void testChannelAccessLinearActuatorTimeout() throws SocketException, CAException, Exception {
|
||||||
|
|
||||||
// Negative timeout
|
// Negative timeout
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
try{
|
try{
|
||||||
// Need to return IllegalArgumentException due to negative Timeout
|
// Need to return IllegalArgumentException due to negative Timeout
|
||||||
new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, 0, 1, 0.1, -1l);
|
new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, 0, 1, 0.1, -1l);
|
||||||
}
|
}
|
||||||
catch(IllegalArgumentException e){
|
catch(IllegalArgumentException e){
|
||||||
flag=true;
|
flag=true;
|
||||||
@@ -111,7 +105,7 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
flag=false;
|
flag=false;
|
||||||
try{
|
try{
|
||||||
// Need to return IllegalArgumentException
|
// Need to return IllegalArgumentException
|
||||||
new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, 0, 1, 0.1, -0l);
|
new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, 0, 1, 0.1, -0l);
|
||||||
}
|
}
|
||||||
catch(IllegalArgumentException e){
|
catch(IllegalArgumentException e){
|
||||||
flag=true;
|
flag=true;
|
||||||
@@ -121,10 +115,10 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Accept null timeout
|
// Accept null timeout
|
||||||
new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, 0, 1, 0.1, null);
|
new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, 0, 1, 0.1, null);
|
||||||
|
|
||||||
// Accept positive timeout
|
// Accept positive timeout
|
||||||
new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, 0, 1, 0.1, 1l);
|
new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, 0, 1, 0.1, 1l);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,18 +127,18 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
* Check whether Exception is thrown if a zero step size is specified.
|
* Check whether Exception is thrown if a zero step size is specified.
|
||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessLinearActuatorZeroStepSize() throws SocketException, Exception {
|
public void testChannelAccessLinearActuatorZeroStepSize() throws SocketException, CAException, Exception {
|
||||||
// Zero step size need to cause an exception
|
// Zero step size need to cause an exception
|
||||||
new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, 0, 1, 0, timeout);
|
new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, 0, 1, 0, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessLinearActuator#LinearActuatorChannelAccess(String, double, double, double)}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessLinearActuator#LinearActuatorChannelAccess(String, double, double, double)}.
|
||||||
* Check correct initialization
|
* Check correct initialization
|
||||||
*/
|
*/
|
||||||
public void testChannelAccessLinearActuator() throws SocketException, Exception {
|
public void testChannelAccessLinearActuator() throws SocketException, CAException, Exception {
|
||||||
// Zero step size need to cause an exception
|
// Zero step size need to cause an exception
|
||||||
new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, 0, 10, 1, timeout);
|
new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, 0, 10, 1, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -154,7 +148,7 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSet() throws InterruptedException {
|
public void testSet() throws InterruptedException {
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, 0, 0.09999, 0.1, timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, 0, 0.09999, 0.1, timeout);
|
||||||
actuator.set();
|
actuator.set();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +159,7 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test(expected=IllegalStateException.class)
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testSetNoNext() throws InterruptedException {
|
public void testSetNoNext() throws InterruptedException {
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, 0, 0.09999, 0.1, timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, 0, 0.09999, 0.1, timeout);
|
||||||
actuator.set();
|
actuator.set();
|
||||||
actuator.set();
|
actuator.set();
|
||||||
}
|
}
|
||||||
@@ -176,7 +170,7 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHasNextOneStep() throws InterruptedException {
|
public void testHasNextOneStep() throws InterruptedException {
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, 0, 0.09999, 0.1, timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, 0, 0.09999, 0.1, timeout);
|
||||||
// Execute first set (because there is always a first move)
|
// Execute first set (because there is always a first move)
|
||||||
actuator.set();
|
actuator.set();
|
||||||
|
|
||||||
@@ -193,7 +187,7 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHasNext() throws InterruptedException {
|
public void testHasNext() throws InterruptedException {
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, 0, 10, 0.1, timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, 0, 10, 0.1, timeout);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int steps = (int) ((10-0)/0.1)+1;
|
int steps = (int) ((10-0)/0.1)+1;
|
||||||
@@ -223,7 +217,7 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
|
|
||||||
|
|
||||||
for(double[] svalue: settings){
|
for(double[] svalue: settings){
|
||||||
ChannelAccessLinearActuator<Integer> actuator = new ChannelAccessLinearActuator<Integer>(cservice, channelName, null, 1,0, svalue[0], svalue[1], svalue[2], timeout);
|
ChannelAccessLinearActuator<Integer> actuator = new ChannelAccessLinearActuator<Integer>(channelName, null, 1,0, svalue[0], svalue[1], svalue[2], timeout);
|
||||||
|
|
||||||
int count =0;
|
int count =0;
|
||||||
while(actuator.hasNext()){
|
while(actuator.hasNext()){
|
||||||
@@ -242,13 +236,10 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessLinearActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessLinearActuator#set()}.
|
||||||
* Test actuator move start<end and start>end ...
|
* Test actuator move start<end and start>end ...
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testReverse() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testReverse() throws CAException, InterruptedException {
|
||||||
|
|
||||||
List<double[]> settings = new ArrayList<double[]>();
|
List<double[]> settings = new ArrayList<double[]>();
|
||||||
// start end stepsize
|
// start end stepsize
|
||||||
@@ -257,7 +248,7 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
|
|
||||||
|
|
||||||
for(double[] svalue: settings){
|
for(double[] svalue: settings){
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, svalue[0], svalue[1], svalue[2], timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, svalue[0], svalue[1], svalue[2], timeout);
|
||||||
actuator.init();
|
actuator.init();
|
||||||
|
|
||||||
int count =0;
|
int count =0;
|
||||||
@@ -325,13 +316,10 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessLinearActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessLinearActuator#set()}.
|
||||||
* Test actuator move start<end and start>end ...
|
* Test actuator move start<end and start>end ...
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testReverseReset() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testReverseReset() throws CAException, InterruptedException {
|
||||||
|
|
||||||
List<double[]> settings = new ArrayList<double[]>();
|
List<double[]> settings = new ArrayList<double[]>();
|
||||||
// start end stepsize
|
// start end stepsize
|
||||||
@@ -340,7 +328,7 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
|
|
||||||
|
|
||||||
for(double[] svalue: settings){
|
for(double[] svalue: settings){
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, null, 1,0, svalue[0], svalue[1], svalue[2], timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, null, 1,0, svalue[0], svalue[1], svalue[2], timeout);
|
||||||
actuator.init();
|
actuator.init();
|
||||||
|
|
||||||
int count =0;
|
int count =0;
|
||||||
@@ -415,9 +403,9 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
* Check whether Exception is thrown if a negative step size is specified.
|
* Check whether Exception is thrown if a negative step size is specified.
|
||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessGPLinearActuatorNegativeStepSize() throws SocketException, Exception {
|
public void testChannelAccessGPLinearActuatorNegativeStepSize() throws SocketException, CAException, Exception {
|
||||||
// Need to throw exception because of negative step size
|
// Need to throw exception because of negative step size
|
||||||
new ChannelAccessLinearActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, 0, 1, -0.1, timeout);
|
new ChannelAccessLinearActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, 0, 1, -0.1, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -425,31 +413,29 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
* Check whether Exception is thrown if a zero step size is specified.
|
* Check whether Exception is thrown if a zero step size is specified.
|
||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessGPLinearActuatorZeroStepSize() throws SocketException, Exception {
|
public void testChannelAccessGPLinearActuatorZeroStepSize() throws SocketException, CAException, Exception {
|
||||||
// Zero step size need to cause an exception
|
// Zero step size need to cause an exception
|
||||||
new ChannelAccessLinearActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, 0, 1, 0, timeout);
|
new ChannelAccessLinearActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, 0, 1, 0, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#LinearActuatorChannelAccess(String, double, double, double)}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#LinearActuatorChannelAccess(String, double, double, double)}.
|
||||||
* Check correct initialization
|
* Check correct initialization
|
||||||
*/
|
*/
|
||||||
public void testChannelAccessGPLinearActuator() throws SocketException, Exception {
|
public void testChannelAccessGPLinearActuator() throws SocketException, CAException, Exception {
|
||||||
// Zero step size need to cause an exception
|
// Zero step size need to cause an exception
|
||||||
new ChannelAccessLinearActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, 0, 10, 1, timeout);
|
new ChannelAccessLinearActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, 0, 10, 1, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#set()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneSet() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneSet() throws CAException, InterruptedException {
|
||||||
|
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, 0, 0.09999, 0.1, timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, 0, 0.09999, 0.1, timeout);
|
||||||
|
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
doneChannel.setValue(0);
|
doneChannel.setValue(0);
|
||||||
@@ -472,14 +458,12 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#set()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneDelay() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneDelay() throws CAException, InterruptedException {
|
||||||
|
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, channelNameDone, doneValue, 1.5, 0, 1, 0.1, timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, channelNameDone, doneValue, 1.5, 0, 1, 0.1, timeout);
|
||||||
|
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
doneChannel.setValue(1);
|
doneChannel.setValue(1);
|
||||||
@@ -512,14 +496,12 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#hasNext()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#hasNext()}.
|
||||||
* Check whether the actuator throws an Exception if there is no next point but set() is called
|
* Check whether the actuator throws an Exception if there is no next point but set() is called
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test(expected=IllegalStateException.class)
|
@Test(expected=IllegalStateException.class)
|
||||||
public void testDoneSetNoNext() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneSetNoNext() throws CAException, InterruptedException {
|
||||||
|
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, 0, 0.09999, 0.1, timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, 0, 0.09999, 0.1, timeout);
|
||||||
|
|
||||||
|
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
@@ -562,13 +544,11 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#hasNext()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#hasNext()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneHasNextOneStep() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneHasNextOneStep() throws CAException, InterruptedException {
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, 0, 0.09999, 0.1, timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, 0, 0.09999, 0.1, timeout);
|
||||||
|
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
doneChannel.setValue(0);
|
doneChannel.setValue(0);
|
||||||
@@ -598,13 +578,11 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#hasNext()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#hasNext()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneHasNext() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneHasNext() throws CAException, InterruptedException {
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, 0, 10, 0.1, timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, 0, 10, 0.1, timeout);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int steps = (int) ((10-0)/0.1)+1;
|
int steps = (int) ((10-0)/0.1)+1;
|
||||||
@@ -641,12 +619,10 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#set()}.
|
||||||
* Test actuator move start<end and start>end ...
|
* Test actuator move start<end and start>end ...
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneSetLoop() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneSetLoop() throws CAException, InterruptedException {
|
||||||
|
|
||||||
List<double[]> settings = new ArrayList<double[]>();
|
List<double[]> settings = new ArrayList<double[]>();
|
||||||
// start end stepsize
|
// start end stepsize
|
||||||
@@ -655,7 +631,7 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
|
|
||||||
|
|
||||||
for(double[] svalue: settings){
|
for(double[] svalue: settings){
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, svalue[0], svalue[1], svalue[2], timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, svalue[0], svalue[1], svalue[2], timeout);
|
||||||
|
|
||||||
int count =0;
|
int count =0;
|
||||||
while(actuator.hasNext()){
|
while(actuator.hasNext()){
|
||||||
@@ -692,13 +668,10 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessGPLinearActuator#set()}.
|
||||||
* Test whether the actuator returns if the actuator is already on the position it should be before the move ...
|
* Test whether the actuator returns if the actuator is already on the position it should be before the move ...
|
||||||
* (see issue XASEC-278)
|
* (see issue XASEC-278)
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMoveToActualPosition() throws InterruptedException, ExecutionException, ChannelException, TimeoutException {
|
public void testMoveToActualPosition() throws CAException, InterruptedException {
|
||||||
|
|
||||||
double start = 0;
|
double start = 0;
|
||||||
double end = 2;
|
double end = 2;
|
||||||
@@ -710,7 +683,7 @@ public class ChannelAccessLinearActuatorTest {
|
|||||||
|
|
||||||
logger.info("Current channel value: "+channel.getValue());
|
logger.info("Current channel value: "+channel.getValue());
|
||||||
|
|
||||||
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, start, end, stepSize, timeout);
|
ChannelAccessLinearActuator<Object> actuator = new ChannelAccessLinearActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, start, end, stepSize, timeout);
|
||||||
while(actuator.hasNext()){
|
while(actuator.hasNext()){
|
||||||
|
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
|
|||||||
@@ -21,21 +21,18 @@ package ch.psi.fda.core.actors;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ch.psi.fda.TestChannels;
|
import ch.psi.fda.TestChannels;
|
||||||
import ch.psi.fda.core.actors.ChannelAccessTableActuator;
|
import ch.psi.fda.core.actors.ChannelAccessTableActuator;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -53,19 +50,16 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
private static final double doneDelay = 0;
|
private static final double doneDelay = 0;
|
||||||
private static final Long timeout = 1800000l; // 30 minutes
|
private static final Long timeout = 1800000l; // 30 minutes
|
||||||
|
|
||||||
private Channel<Double> channel;
|
private ChannelBean<Double> channel;
|
||||||
private Channel<Integer> doneChannel;
|
private ChannelBean<Integer> doneChannel;
|
||||||
|
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
|
||||||
channel = cservice.createChannel(new ChannelDescriptor<>(Double.class, channelName, false));
|
doneChannel = ChannelBeanFactory.getFactory().createChannelBean(Integer.class, channelNameDone, false);
|
||||||
doneChannel = cservice.createChannel(new ChannelDescriptor<>(Integer.class, channelNameDone, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +74,7 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testChannelAccessTableActuator() {
|
public void testChannelAccessTableActuator() {
|
||||||
new ChannelAccessTableActuator<Object>(cservice, channelName, new double[]{1}, timeout);
|
new ChannelAccessTableActuator<Object>(channelName, new double[]{1}, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,7 +86,7 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
try{
|
try{
|
||||||
// Need to return IllegalArgumentException due to negative Timeout
|
// Need to return IllegalArgumentException due to negative Timeout
|
||||||
new ChannelAccessTableActuator<Object>(cservice, channelName, new double[]{1}, -1l);
|
new ChannelAccessTableActuator<Object>(channelName, new double[]{1}, -1l);
|
||||||
}
|
}
|
||||||
catch(IllegalArgumentException e){
|
catch(IllegalArgumentException e){
|
||||||
flag=true;
|
flag=true;
|
||||||
@@ -105,7 +99,7 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
flag=false;
|
flag=false;
|
||||||
try{
|
try{
|
||||||
// Need to return IllegalArgumentException
|
// Need to return IllegalArgumentException
|
||||||
new ChannelAccessTableActuator<Object>(cservice, channelName, new double[]{1}, 0l);
|
new ChannelAccessTableActuator<Object>(channelName, new double[]{1}, 0l);
|
||||||
}
|
}
|
||||||
catch(IllegalArgumentException e){
|
catch(IllegalArgumentException e){
|
||||||
flag=true;
|
flag=true;
|
||||||
@@ -115,10 +109,10 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Accept null timeout
|
// Accept null timeout
|
||||||
new ChannelAccessTableActuator<Object>(cservice, channelName, new double[]{1}, null);
|
new ChannelAccessTableActuator<Object>(channelName, new double[]{1}, null);
|
||||||
|
|
||||||
// Accept positive timeout
|
// Accept positive timeout
|
||||||
new ChannelAccessTableActuator<Object>(cservice, channelName, new double[]{1}, 1l);
|
new ChannelAccessTableActuator<Object>(channelName, new double[]{1}, 1l);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +122,7 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessTableActuatorNull() {
|
public void testChannelAccessTableActuatorNull() {
|
||||||
new ChannelAccessTableActuator<Object>(cservice, channelName, null, timeout);
|
new ChannelAccessTableActuator<Object>(channelName, null, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,20 +131,17 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChannelAccessTableActuatorEmptyTable() {
|
public void testChannelAccessTableActuatorEmptyTable() {
|
||||||
new ChannelAccessTableActuator<Object>(cservice, channelName, new double[0], timeout);
|
new ChannelAccessTableActuator<Object>(channelName, new double[0], timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSet() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testSet() throws CAException, InterruptedException {
|
||||||
double[] table = new double[]{1,2,3,4,5,6};
|
double[] table = new double[]{1,2,3,4,5,6};
|
||||||
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(cservice, channelName, table, timeout);
|
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(channelName, table, timeout);
|
||||||
|
|
||||||
int count=0;
|
int count=0;
|
||||||
while(actor.hasNext()){
|
while(actor.hasNext()){
|
||||||
@@ -175,7 +166,7 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
@Test(expected=RuntimeException.class)
|
@Test(expected=RuntimeException.class)
|
||||||
public void testSetFail() throws InterruptedException {
|
public void testSetFail() throws InterruptedException {
|
||||||
double[] table = new double[]{1};
|
double[] table = new double[]{1};
|
||||||
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(cservice, channelName, table, timeout);
|
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(channelName, table, timeout);
|
||||||
actor.set();
|
actor.set();
|
||||||
|
|
||||||
// This set() call has to fail with an RuntimeException
|
// This set() call has to fail with an RuntimeException
|
||||||
@@ -190,7 +181,7 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
public void testHasNext() throws InterruptedException {
|
public void testHasNext() throws InterruptedException {
|
||||||
|
|
||||||
double[] table = new double[]{1};
|
double[] table = new double[]{1};
|
||||||
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(cservice, channelName, table, timeout);
|
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(channelName, table, timeout);
|
||||||
actor.set();
|
actor.set();
|
||||||
|
|
||||||
boolean next = actor.hasNext();
|
boolean next = actor.hasNext();
|
||||||
@@ -201,15 +192,12 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testReverse() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testReverse() throws CAException, InterruptedException {
|
||||||
double[] table = new double[]{1,2,3,4,5,6};
|
double[] table = new double[]{1,2,3,4,5,6};
|
||||||
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(cservice, channelName, table, timeout);
|
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(channelName, table, timeout);
|
||||||
actor.init();
|
actor.init();
|
||||||
|
|
||||||
int count=0;
|
int count=0;
|
||||||
@@ -249,15 +237,12 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testReverseReset() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testReverseReset() throws CAException, InterruptedException {
|
||||||
double[] table = new double[]{1,2,3,4,5,6};
|
double[] table = new double[]{1,2,3,4,5,6};
|
||||||
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(cservice, channelName, table, timeout);
|
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(channelName, table, timeout);
|
||||||
actor.init();
|
actor.init();
|
||||||
|
|
||||||
int count=0;
|
int count=0;
|
||||||
@@ -302,7 +287,7 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneChannelAccessTableActuator() {
|
public void testDoneChannelAccessTableActuator() {
|
||||||
new ChannelAccessTableActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, new double[]{1}, timeout);
|
new ChannelAccessTableActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, new double[]{1}, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -311,7 +296,7 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testDoneChannelAccessTableActuatorNull() {
|
public void testDoneChannelAccessTableActuatorNull() {
|
||||||
new ChannelAccessTableActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, null, timeout);
|
new ChannelAccessTableActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, null, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -320,20 +305,17 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
*/
|
*/
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testDoneChannelAccessTableActuatorEmptyTable() {
|
public void testDoneChannelAccessTableActuatorEmptyTable() {
|
||||||
new ChannelAccessTableActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, new double[0], timeout);
|
new ChannelAccessTableActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, new double[0], timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneSet() throws InterruptedException, ExecutionException, ChannelException, TimeoutException {
|
public void testDoneSet() throws CAException, InterruptedException {
|
||||||
double[] table = new double[]{1,2,3,4,5,6};
|
double[] table = new double[]{1,2,3,4,5,6};
|
||||||
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, table, timeout);
|
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, table, timeout);
|
||||||
|
|
||||||
int count=0;
|
int count=0;
|
||||||
while(actor.hasNext()){
|
while(actor.hasNext()){
|
||||||
@@ -367,15 +349,12 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneDelay() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testDoneDelay() throws CAException, InterruptedException {
|
||||||
double[] table = new double[]{1,2,3,4,5,6};
|
double[] table = new double[]{1,2,3,4,5,6};
|
||||||
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(cservice, channelName, channelNameDone, doneValue, 0.1, table, timeout);
|
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(channelName, channelNameDone, doneValue, 0.1, table, timeout);
|
||||||
|
|
||||||
int count=0;
|
int count=0;
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
@@ -419,14 +398,12 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#set()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test(expected=RuntimeException.class)
|
@Test(expected=RuntimeException.class)
|
||||||
public void testDoneSetFail() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneSetFail() throws CAException, InterruptedException {
|
||||||
double[] table = new double[]{1};
|
double[] table = new double[]{1};
|
||||||
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, table, timeout);
|
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, table, timeout);
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
doneChannel.setValue(0);
|
doneChannel.setValue(0);
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@@ -465,15 +442,13 @@ public class ChannelAccessTableActuatorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#hasNext()}.
|
* Test method for {@link ch.psi.fda.core.actors.ChannelAccessTableActuator#hasNext()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoneHasNext() throws InterruptedException, ExecutionException, ChannelException {
|
public void testDoneHasNext() throws CAException, InterruptedException {
|
||||||
|
|
||||||
double[] table = new double[]{1};
|
double[] table = new double[]{1};
|
||||||
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(cservice, channelName, channelNameDone, doneValue, doneDelay, table, timeout);
|
ChannelAccessTableActuator<Object> actor = new ChannelAccessTableActuator<Object>(channelName, channelNameDone, doneValue, doneDelay, table, timeout);
|
||||||
|
|
||||||
// Simulate done channel
|
// Simulate done channel
|
||||||
doneChannel.setValue(0);
|
doneChannel.setValue(0);
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ import org.junit.Test;
|
|||||||
import ch.psi.fda.TestChannels;
|
import ch.psi.fda.TestChannels;
|
||||||
import ch.psi.fda.core.actors.ChannelAccessLinearActuator;
|
import ch.psi.fda.core.actors.ChannelAccessLinearActuator;
|
||||||
import ch.psi.fda.core.actors.ComplexActuator;
|
import ch.psi.fda.core.actors.ComplexActuator;
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prerequisites for this test are:
|
* Prerequisites for this test are:
|
||||||
@@ -47,14 +45,12 @@ public class ComplexActorTest {
|
|||||||
private static Logger logger = Logger.getLogger(ComplexActorTest.class.getName());
|
private static Logger logger = Logger.getLogger(ComplexActorTest.class.getName());
|
||||||
|
|
||||||
private static final Long timeout = 1800000l;
|
private static final Long timeout = 1800000l;
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,9 +69,9 @@ public class ComplexActorTest {
|
|||||||
|
|
||||||
ComplexActuator actuator = new ComplexActuator();
|
ComplexActuator actuator = new ComplexActuator();
|
||||||
|
|
||||||
actuator.getActors().add(new ChannelAccessLinearActuator<Object>(cservice, TestChannels.ANALOG_OUT, null, 1,0, 0, 0.09999, 0.1, timeout));
|
actuator.getActors().add(new ChannelAccessLinearActuator<Object>(TestChannels.ANALOG_OUT, null, 1,0, 0, 0.09999, 0.1, timeout));
|
||||||
actuator.getActors().add(new ChannelAccessLinearActuator<Object>(cservice, TestChannels.ANALOG_OUT, null, 1,0, 1, 2, 0.1, timeout));
|
actuator.getActors().add(new ChannelAccessLinearActuator<Object>(TestChannels.ANALOG_OUT, null, 1,0, 1, 2, 0.1, timeout));
|
||||||
actuator.getActors().add(new ChannelAccessLinearActuator<Object>(cservice, TestChannels.ANALOG_OUT, null, 1,0, -1, -2, 0.1, timeout));
|
actuator.getActors().add(new ChannelAccessLinearActuator<Object>(TestChannels.ANALOG_OUT, null, 1,0, -1, -2, 0.1, timeout));
|
||||||
|
|
||||||
// Initialize actuator
|
// Initialize actuator
|
||||||
actuator.init();
|
actuator.init();
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ package ch.psi.fda.core.guard;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -34,11 +34,8 @@ import ch.psi.fda.TestChannels;
|
|||||||
import ch.psi.fda.core.Guard;
|
import ch.psi.fda.core.Guard;
|
||||||
import ch.psi.fda.core.guard.ChannelAccessGuard;
|
import ch.psi.fda.core.guard.ChannelAccessGuard;
|
||||||
import ch.psi.fda.core.guard.ChannelAccessGuardCondition;
|
import ch.psi.fda.core.guard.ChannelAccessGuardCondition;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -46,13 +43,11 @@ import ch.psi.jcae.impl.DefaultChannelService;
|
|||||||
*/
|
*/
|
||||||
public class ChannelAccessGuardTest {
|
public class ChannelAccessGuardTest {
|
||||||
|
|
||||||
private ChannelService cservice;
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,20 +60,17 @@ public class ChannelAccessGuardTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.guard.ChannelAccessGuard#check()}.
|
* Test method for {@link ch.psi.fda.core.guard.ChannelAccessGuard#check()}.
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCheck() throws InterruptedException, ExecutionException, ChannelException, TimeoutException {
|
public void testCheck() throws InterruptedException, CAException {
|
||||||
String guardChannel = TestChannels.ANALOG_OUT;
|
String guardChannel = TestChannels.ANALOG_OUT;
|
||||||
Integer channelOkValue = 10;
|
Integer channelOkValue = 10;
|
||||||
List<ChannelAccessGuardCondition> conditions = new ArrayList<ChannelAccessGuardCondition>();
|
List<ChannelAccessGuardCondition> conditions = new ArrayList<ChannelAccessGuardCondition>();
|
||||||
conditions.add(new ChannelAccessGuardCondition(cservice, guardChannel, channelOkValue));
|
conditions.add(new ChannelAccessGuardCondition(guardChannel, channelOkValue));
|
||||||
Guard guard = new ChannelAccessGuard(conditions );
|
Guard guard = new ChannelAccessGuard(conditions );
|
||||||
|
|
||||||
Channel<Integer> b = cservice.createChannel(new ChannelDescriptor<>(Integer.class, guardChannel, false));
|
ChannelBean<Integer> b = ChannelBeanFactory.getFactory().createChannelBean(Integer.class, guardChannel, false);
|
||||||
b.setValue(channelOkValue);
|
b.setValue(channelOkValue);
|
||||||
|
|
||||||
guard.init();
|
guard.init();
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ package ch.psi.fda.core.loops;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -48,11 +48,8 @@ import ch.psi.fda.core.messages.Message;
|
|||||||
import ch.psi.fda.core.sensors.ChannelAccessDoubleArraySensor;
|
import ch.psi.fda.core.sensors.ChannelAccessDoubleArraySensor;
|
||||||
import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
||||||
import ch.psi.fda.core.sensors.ChannelAccessStringSensor;
|
import ch.psi.fda.core.sensors.ChannelAccessStringSensor;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -69,21 +66,20 @@ public class ActorSensorLoopTest {
|
|||||||
private static final Long timeout = 1800000l; // 30 minutes
|
private static final Long timeout = 1800000l; // 30 minutes
|
||||||
|
|
||||||
private ActorSensorLoop loopOne;
|
private ActorSensorLoop loopOne;
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
|
||||||
loopOne = new ActorSensorLoop();
|
loopOne = new ActorSensorLoop();
|
||||||
|
|
||||||
ChannelAccessLinearActuator<Object> a = new ChannelAccessLinearActuator<Object>(cservice, aoChannel, null, 1,0, 0, 10, 0.1, timeout); // Positioner
|
ChannelAccessLinearActuator<Object> a = new ChannelAccessLinearActuator<Object>(aoChannel, null, 1,0, 0, 10, 0.1, timeout); // Positioner
|
||||||
ChannelAccessDoubleSensor s = new ChannelAccessDoubleSensor(cservice, "id0", boChannel); // Positioner Readback
|
ChannelAccessDoubleSensor s = new ChannelAccessDoubleSensor("id0", boChannel); // Positioner Readback
|
||||||
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor(cservice, "id1", aoChannel); // Scalar Detector
|
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor("id1", aoChannel); // Scalar Detector
|
||||||
ChannelAccessStringSensor s1string = new ChannelAccessStringSensor(cservice, "id3", boChannel+".NAME"); // Scalar String Detector
|
ChannelAccessStringSensor s1string = new ChannelAccessStringSensor("id3", boChannel+".NAME"); // Scalar String Detector
|
||||||
ChannelAccessDoubleArraySensor s2 = new ChannelAccessDoubleArraySensor(cservice, "id2", wfChannel, 10);
|
ChannelAccessDoubleArraySensor s2 = new ChannelAccessDoubleArraySensor("id2", wfChannel, 10);
|
||||||
|
|
||||||
loopOne.getActors().add(a);
|
loopOne.getActors().add(a);
|
||||||
loopOne.getSensors().add(s);
|
loopOne.getSensors().add(s);
|
||||||
@@ -144,8 +140,8 @@ public class ActorSensorLoopTest {
|
|||||||
ActorSensorLoop loop = new ActorSensorLoop();
|
ActorSensorLoop loop = new ActorSensorLoop();
|
||||||
|
|
||||||
int numberOfSensors = 2;
|
int numberOfSensors = 2;
|
||||||
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor(cservice, "id0", boChannel); // Positioner Readback
|
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor("id0", boChannel); // Positioner Readback
|
||||||
ChannelAccessDoubleSensor s2 = new ChannelAccessDoubleSensor(cservice, "id1", aoChannel); // Scalar Detector
|
ChannelAccessDoubleSensor s2 = new ChannelAccessDoubleSensor("id1", aoChannel); // Scalar Detector
|
||||||
loop.getSensors().add(s1);
|
loop.getSensors().add(s1);
|
||||||
loop.getSensors().add(s2);
|
loop.getSensors().add(s2);
|
||||||
|
|
||||||
@@ -171,21 +167,18 @@ public class ActorSensorLoopTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.loops.ActorSensorLoop#execute()}.
|
* Test method for {@link ch.psi.fda.core.loops.ActorSensorLoop#execute()}.
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteGuard() throws InterruptedException, ExecutionException, ChannelException, TimeoutException {
|
public void testExecuteGuard() throws InterruptedException, CAException {
|
||||||
|
|
||||||
ActorSensorLoop loop = new ActorSensorLoop();
|
ActorSensorLoop loop = new ActorSensorLoop();
|
||||||
|
|
||||||
ChannelAccessLinearActuator<Object> a = new ChannelAccessLinearActuator<Object>(cservice, aoChannel, null, 1,0, 0, 1.5, 0.1,timeout); // Positioner
|
ChannelAccessLinearActuator<Object> a = new ChannelAccessLinearActuator<Object>(aoChannel, null, 1,0, 0, 1.5, 0.1,timeout); // Positioner
|
||||||
|
|
||||||
ChannelAccessDoubleSensor s = new ChannelAccessDoubleSensor(cservice, "id0", aoChannel); // Positioner Readback
|
ChannelAccessDoubleSensor s = new ChannelAccessDoubleSensor("id0", aoChannel); // Positioner Readback
|
||||||
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor(cservice, "id1", boChannel); // Scalar Detector
|
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor("id1", boChannel); // Scalar Detector
|
||||||
ChannelAccessDoubleArraySensor s2 = new ChannelAccessDoubleArraySensor(cservice, "id2", wfChannel, 10);
|
ChannelAccessDoubleArraySensor s2 = new ChannelAccessDoubleArraySensor("id2", wfChannel, 10);
|
||||||
|
|
||||||
loop.getActors().add(a);
|
loop.getActors().add(a);
|
||||||
loop.getPostActorActions().add(new Delay(500));
|
loop.getPostActorActions().add(new Delay(500));
|
||||||
@@ -196,11 +189,11 @@ public class ActorSensorLoopTest {
|
|||||||
// Guard
|
// Guard
|
||||||
final Integer okValue = 0;
|
final Integer okValue = 0;
|
||||||
List<ChannelAccessGuardCondition> conditions = new ArrayList<ChannelAccessGuardCondition>();
|
List<ChannelAccessGuardCondition> conditions = new ArrayList<ChannelAccessGuardCondition>();
|
||||||
conditions.add(new ChannelAccessGuardCondition(cservice, boChannel, new Integer(0)));
|
conditions.add(new ChannelAccessGuardCondition(boChannel, new Integer(0)));
|
||||||
Guard guard = new ChannelAccessGuard(conditions);
|
Guard guard = new ChannelAccessGuard(conditions);
|
||||||
loop.setGuard(guard);
|
loop.setGuard(guard);
|
||||||
|
|
||||||
final Channel<Integer> b = cservice.createChannel(new ChannelDescriptor<>(Integer.class, boChannel, false));
|
final ChannelBean<Integer> b = ChannelBeanFactory.getFactory().createChannelBean(Integer.class, boChannel, false);
|
||||||
|
|
||||||
Thread tguard = new Thread(new Runnable() {
|
Thread tguard = new Thread(new Runnable() {
|
||||||
|
|
||||||
@@ -260,16 +253,16 @@ public class ActorSensorLoopTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParallelSet() throws InterruptedException {
|
public void testParallelSet() throws InterruptedException, CAException {
|
||||||
|
|
||||||
final int steps = 2;
|
final int steps = 2;
|
||||||
final HashMap<String,Long> timestamps = new HashMap<String, Long>();
|
final HashMap<String,Long> timestamps = new HashMap<String, Long>();
|
||||||
|
|
||||||
ActorSensorLoop loop = new ActorSensorLoop();
|
ActorSensorLoop loop = new ActorSensorLoop();
|
||||||
|
|
||||||
ChannelAccessLinearActuator<Object> a = new ChannelAccessLinearActuator<Object>(cservice, aoChannel, null, 1,0, 0, (steps*0.1), 0.1, timeout); // Positioner
|
ChannelAccessLinearActuator<Object> a = new ChannelAccessLinearActuator<Object>(aoChannel, null, 1,0, 0, (steps*0.1), 0.1, timeout); // Positioner
|
||||||
|
|
||||||
ChannelAccessDoubleSensor s = new ChannelAccessDoubleSensor(cservice, "id0", aoChannel); // Positioner Readback
|
ChannelAccessDoubleSensor s = new ChannelAccessDoubleSensor("id0", aoChannel); // Positioner Readback
|
||||||
|
|
||||||
loop.getActors().add(a);
|
loop.getActors().add(a);
|
||||||
loop.getActors().add(new Actor() {
|
loop.getActors().add(new Actor() {
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ package ch.psi.fda.core.loops;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,11 +42,8 @@ import ch.psi.fda.core.sensors.MillisecondTimestampSensor;
|
|||||||
import ch.psi.fda.core.sensors.OTFNamedChannelSensor;
|
import ch.psi.fda.core.sensors.OTFNamedChannelSensor;
|
||||||
import ch.psi.fda.core.sensors.OTFReadbackSensor;
|
import ch.psi.fda.core.sensors.OTFReadbackSensor;
|
||||||
import ch.psi.fda.core.sensors.OTFScalerChannelSensor;
|
import ch.psi.fda.core.sensors.OTFScalerChannelSensor;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -91,17 +88,15 @@ public class OTFLoopTest {
|
|||||||
|
|
||||||
private OTFLoop loopZigZag;
|
private OTFLoop loopZigZag;
|
||||||
private OTFLoop loop;
|
private OTFLoop loop;
|
||||||
private Channel<Integer> statusChannel;
|
private ChannelBean<Integer> statusChannel;
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
|
||||||
|
|
||||||
statusChannel = cservice.createChannel(new ChannelDescriptor<>(Integer.class, configuration.getOtfPrefix()+":USTAT", false));
|
statusChannel = ChannelBeanFactory.getFactory().createChannelBean(Integer.class, configuration.getOtfPrefix()+":USTAT", false);
|
||||||
|
|
||||||
OTFActuator actor = new OTFActuator("id", configuration.getMotor1(), null, 0, 8, 0.5, 0.5, 0);
|
OTFActuator actor = new OTFActuator("id", configuration.getMotor1(), null, 0, 8, 0.5, 0.5, 0);
|
||||||
OTFReadbackSensor s1 = new OTFReadbackSensor("id0");
|
OTFReadbackSensor s1 = new OTFReadbackSensor("id0");
|
||||||
@@ -112,7 +107,7 @@ public class OTFLoopTest {
|
|||||||
|
|
||||||
|
|
||||||
// ZigZag loop
|
// ZigZag loop
|
||||||
loopZigZag = new OTFLoop(cservice, configuration.getOtfPrefix(), configuration.getServer(), configuration.getShare(), configuration.getSmbShare(), true);
|
loopZigZag = new OTFLoop(configuration.getOtfPrefix(), configuration.getServer(), configuration.getShare(), configuration.getSmbShare(), true);
|
||||||
loopZigZag.setActor(actor);
|
loopZigZag.setActor(actor);
|
||||||
loopZigZag.getSensors().add(s1);
|
loopZigZag.getSensors().add(s1);
|
||||||
loopZigZag.getSensors().add(s2);
|
loopZigZag.getSensors().add(s2);
|
||||||
@@ -122,7 +117,7 @@ public class OTFLoopTest {
|
|||||||
|
|
||||||
|
|
||||||
// Normal loop
|
// Normal loop
|
||||||
loop = new OTFLoop(cservice, configuration.getOtfPrefix(), configuration.getServer(), configuration.getShare(), configuration.getSmbShare(), false);
|
loop = new OTFLoop(configuration.getOtfPrefix(), configuration.getServer(), configuration.getShare(), configuration.getSmbShare(), false);
|
||||||
loop.setActor(actor);
|
loop.setActor(actor);
|
||||||
loop.getSensors().add(s1);
|
loop.getSensors().add(s1);
|
||||||
loop.getSensors().add(s2);
|
loop.getSensors().add(s2);
|
||||||
@@ -141,13 +136,10 @@ public class OTFLoopTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.loops.OTFLoop#execute()}.
|
* Test method for {@link ch.psi.fda.core.loops.OTFLoop#execute()}.
|
||||||
* Test ordinary 1D OTF scan
|
* Test ordinary 1D OTF scan
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecute() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testExecute() throws CAException, InterruptedException {
|
||||||
|
|
||||||
Thread t = new Thread(new TestCollector(loop.getDataQueue().getQueue()));
|
Thread t = new Thread(new TestCollector(loop.getDataQueue().getQueue()));
|
||||||
t.start();
|
t.start();
|
||||||
@@ -166,13 +158,10 @@ public class OTFLoopTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.loops.OTFLoop#execute()}.
|
* Test method for {@link ch.psi.fda.core.loops.OTFLoop#execute()}.
|
||||||
* Test OTF ZigZag mode
|
* Test OTF ZigZag mode
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteZigZag() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testExecuteZigZag() throws CAException, InterruptedException {
|
||||||
|
|
||||||
Thread t = new Thread(new TestCollector(loopZigZag.getDataQueue().getQueue()));
|
Thread t = new Thread(new TestCollector(loopZigZag.getDataQueue().getQueue()));
|
||||||
t.start();
|
t.start();
|
||||||
@@ -192,13 +181,10 @@ public class OTFLoopTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.loops.OTFLoop#execute()}.
|
* Test method for {@link ch.psi.fda.core.loops.OTFLoop#execute()}.
|
||||||
* Test abort functionality while executing an OTF scan
|
* Test abort functionality while executing an OTF scan
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteAbort() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
|
public void testExecuteAbort() throws CAException, InterruptedException {
|
||||||
|
|
||||||
// Data collector thread
|
// Data collector thread
|
||||||
Thread t = new Thread(new TestCollector(loop.getDataQueue().getQueue()));
|
Thread t = new Thread(new TestCollector(loop.getDataQueue().getQueue()));
|
||||||
|
|||||||
@@ -20,17 +20,16 @@
|
|||||||
package ch.psi.fda.core.loops.cr;
|
package ch.psi.fda.core.loops.cr;
|
||||||
|
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ch.psi.fda.TestConfiguration;
|
import ch.psi.fda.TestConfiguration;
|
||||||
@@ -42,9 +41,7 @@ import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
|||||||
import ch.psi.fda.core.sensors.MillisecondTimestampSensor;
|
import ch.psi.fda.core.sensors.MillisecondTimestampSensor;
|
||||||
import ch.psi.fda.core.sensors.OTFNamedChannelSensor;
|
import ch.psi.fda.core.sensors.OTFNamedChannelSensor;
|
||||||
import ch.psi.fda.core.sensors.OTFScalerChannelSensor;
|
import ch.psi.fda.core.sensors.OTFScalerChannelSensor;
|
||||||
import ch.psi.jcae.ChannelException;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -54,13 +51,12 @@ public class ParallelCrlogicTest {
|
|||||||
|
|
||||||
// Get Logger
|
// Get Logger
|
||||||
private static final Logger logger = Logger.getLogger(ParallelCrlogicTest.class.getName());
|
private static final Logger logger = Logger.getLogger(ParallelCrlogicTest.class.getName());
|
||||||
private ChannelService cservice;
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +68,7 @@ public class ParallelCrlogicTest {
|
|||||||
|
|
||||||
// @Ignore
|
// @Ignore
|
||||||
@Test(timeout=60000)
|
@Test(timeout=60000)
|
||||||
public void testExecute() throws InterruptedException, ChannelException, TimeoutException, ExecutionException{
|
public void testExecute() throws InterruptedException, CAException{
|
||||||
|
|
||||||
TestConfiguration c = TestConfiguration.getInstance();
|
TestConfiguration c = TestConfiguration.getInstance();
|
||||||
|
|
||||||
@@ -86,18 +82,18 @@ public class ParallelCrlogicTest {
|
|||||||
double additionalBacklash = 0;
|
double additionalBacklash = 0;
|
||||||
|
|
||||||
List<Sensor> sensors = new ArrayList<Sensor>();
|
List<Sensor> sensors = new ArrayList<Sensor>();
|
||||||
ChannelAccessDoubleSensor s2 = new ChannelAccessDoubleSensor(cservice, "mot1", c.getMotor1()+".RVAL");
|
ChannelAccessDoubleSensor s2 = new ChannelAccessDoubleSensor("mot1", c.getMotor1()+".RVAL");
|
||||||
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor(cservice, "mot2", c.getMotor1()+".RBV");
|
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor("mot2", c.getMotor1()+".RBV");
|
||||||
ChannelAccessDoubleSensor s3 = new ChannelAccessDoubleSensor(cservice, "mot2", "ARIDI-PCT:CURRENT");
|
ChannelAccessDoubleSensor s3 = new ChannelAccessDoubleSensor("mot2", "ARIDI-PCT:CURRENT");
|
||||||
|
|
||||||
sensors.add(s1);
|
sensors.add(s1);
|
||||||
sensors.add(s2);
|
sensors.add(s2);
|
||||||
sensors.add(s3);
|
sensors.add(s3);
|
||||||
|
|
||||||
ScrlogicLoop scrlogic = new ScrlogicLoop(cservice, sensors);
|
ScrlogicLoop scrlogic = new ScrlogicLoop(sensors);
|
||||||
|
|
||||||
|
|
||||||
CrlogicLoop crlogic = new CrlogicLoop(cservice, c.getCrlogicPrefix(), c.getServer(), c.getShare(), c.getSmbShare(), zigZag);
|
CrlogicLoop crlogic = new CrlogicLoop(c.getCrlogicPrefix(), c.getServer(), c.getShare(), c.getSmbShare(), zigZag);
|
||||||
crlogic.setActor(new OTFActuator("cmot", c.getMotor1(), readback, start, end, stepSize, integrationTime, additionalBacklash));
|
crlogic.setActor(new OTFActuator("cmot", c.getMotor1(), readback, start, end, stepSize, integrationTime, additionalBacklash));
|
||||||
crlogic.getSensors().add(new OTFNamedChannelSensor("trigger", "TRIGGER0"));
|
crlogic.getSensors().add(new OTFNamedChannelSensor("trigger", "TRIGGER0"));
|
||||||
crlogic.getSensors().add(new OTFScalerChannelSensor("scaler0", 0));
|
crlogic.getSensors().add(new OTFScalerChannelSensor("scaler0", 0));
|
||||||
@@ -107,10 +103,7 @@ public class ParallelCrlogicTest {
|
|||||||
|
|
||||||
// Initialize scaler template
|
// Initialize scaler template
|
||||||
VSC16ScalerChannelsTemplate scalertemplate = new VSC16ScalerChannelsTemplate();
|
VSC16ScalerChannelsTemplate scalertemplate = new VSC16ScalerChannelsTemplate();
|
||||||
Map<String,String> ma = new HashMap<>();
|
ChannelBeanFactory.getFactory().createChannelBeans(scalertemplate, c.getPrefixScaler());
|
||||||
ma.put("PREFIX", c.getPrefixScaler());
|
|
||||||
System.out.println(c.getPrefixScaler());
|
|
||||||
cservice.createAnnotatedChannels(scalertemplate, ma);
|
|
||||||
|
|
||||||
|
|
||||||
ParallelCrlogic pcrlogic = new ParallelCrlogic(crlogic, scrlogic);
|
ParallelCrlogic pcrlogic = new ParallelCrlogic(crlogic, scrlogic);
|
||||||
@@ -134,7 +127,7 @@ public class ParallelCrlogicTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Destroy scaler template
|
// Destroy scaler template
|
||||||
cservice.destroyAnnotatedChannels(scalertemplate);
|
ChannelBeanFactory.getFactory().destroyChannelBeans(scalertemplate);
|
||||||
|
|
||||||
pcrlogic.destroy();
|
pcrlogic.destroy();
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package ch.psi.fda.core.loops.cr;
|
package ch.psi.fda.core.loops.cr;
|
||||||
|
|
||||||
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
@@ -32,10 +34,8 @@ import ch.psi.fda.core.Sensor;
|
|||||||
import ch.psi.fda.core.messages.EndOfStreamMessage;
|
import ch.psi.fda.core.messages.EndOfStreamMessage;
|
||||||
import ch.psi.fda.core.messages.Message;
|
import ch.psi.fda.core.messages.Message;
|
||||||
import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -43,13 +43,11 @@ import ch.psi.jcae.impl.DefaultChannelService;
|
|||||||
*/
|
*/
|
||||||
public class ScrlogicLoopTest {
|
public class ScrlogicLoopTest {
|
||||||
|
|
||||||
private ChannelService cservice;
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,20 +63,20 @@ public class ScrlogicLoopTest {
|
|||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecute() throws InterruptedException {
|
public void testExecute() throws InterruptedException, CAException {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println("For this test the motor MTEST-HW3:MOT1 need to be moved manually");
|
System.out.println("For this test the motor MTEST-HW3:MOT1 need to be moved manually");
|
||||||
|
|
||||||
List<Sensor> sensors = new ArrayList<Sensor>();
|
List<Sensor> sensors = new ArrayList<Sensor>();
|
||||||
ChannelAccessDoubleSensor s2 = new ChannelAccessDoubleSensor(cservice, "mot1", "MTEST-HW3:MOT1.RBV");
|
ChannelAccessDoubleSensor s2 = new ChannelAccessDoubleSensor("mot1", "MTEST-HW3:MOT1.RBV");
|
||||||
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor(cservice, "mot2", "MTEST-HW3:MOT1");
|
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor("mot2", "MTEST-HW3:MOT1");
|
||||||
|
|
||||||
sensors.add(s1);
|
sensors.add(s1);
|
||||||
sensors.add(s2);
|
sensors.add(s2);
|
||||||
|
|
||||||
final ScrlogicLoop logic = new ScrlogicLoop(cservice, sensors);
|
final ScrlogicLoop logic = new ScrlogicLoop(sensors);
|
||||||
|
|
||||||
|
|
||||||
for(int i=0;i<2;i++){
|
for(int i=0;i<2;i++){
|
||||||
@@ -106,7 +104,7 @@ public class ScrlogicLoopTest {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try{
|
try{
|
||||||
Channel<Double> channel = cservice.createChannel(new ChannelDescriptor<>(Double.class, "MTEST-HW3:MOT1", false));
|
ChannelBean<Double> channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, "MTEST-HW3:MOT1", false);
|
||||||
// Wait some time until
|
// Wait some time until
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
channel.setValue(1.5);
|
channel.setValue(1.5);
|
||||||
|
|||||||
@@ -20,13 +20,12 @@
|
|||||||
package ch.psi.fda.core.manipulator;
|
package ch.psi.fda.core.manipulator;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import gov.aps.jca.CAException;
|
import gov.aps.jca.CAException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -47,11 +46,8 @@ import ch.psi.fda.core.messages.Message;
|
|||||||
import ch.psi.fda.core.scripting.JythonParameterMapping;
|
import ch.psi.fda.core.scripting.JythonParameterMapping;
|
||||||
import ch.psi.fda.core.scripting.JythonParameterMappingChannel;
|
import ch.psi.fda.core.scripting.JythonParameterMappingChannel;
|
||||||
import ch.psi.fda.core.scripting.JythonParameterMappingID;
|
import ch.psi.fda.core.scripting.JythonParameterMappingID;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.ChannelService;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ebner
|
* @author ebner
|
||||||
@@ -62,14 +58,12 @@ public class ManipulatorTest {
|
|||||||
// Get Logger
|
// Get Logger
|
||||||
private static Logger logger = Logger.getLogger(ManipulatorTest.class.getName());
|
private static Logger logger = Logger.getLogger(ManipulatorTest.class.getName());
|
||||||
|
|
||||||
private ChannelService cservice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
cservice = new DefaultChannelService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,7 +85,7 @@ public class ManipulatorTest {
|
|||||||
String script = "import math\ndef process(o):\n return math.cos(10.0) + math.sin(o)";
|
String script = "import math\ndef process(o):\n return math.cos(10.0) + math.sin(o)";
|
||||||
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
||||||
mapping.add(new JythonParameterMappingID("o", "myid"));
|
mapping.add(new JythonParameterMappingID("o", "myid"));
|
||||||
JythonManipulation manipulation = new JythonManipulation(cservice, id, script, mapping);
|
JythonManipulation manipulation = new JythonManipulation(id, script, mapping);
|
||||||
|
|
||||||
// This constructor need to throw an IllegalArgumentException as there is no component
|
// This constructor need to throw an IllegalArgumentException as there is no component
|
||||||
// id "myid" which is expected in the mapping
|
// id "myid" which is expected in the mapping
|
||||||
@@ -116,7 +110,7 @@ public class ManipulatorTest {
|
|||||||
String script = "import math\ndef process():\n return 0.0";
|
String script = "import math\ndef process():\n return 0.0";
|
||||||
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
||||||
mapping.add(new JythonParameterMappingID("o", "myid"));
|
mapping.add(new JythonParameterMappingID("o", "myid"));
|
||||||
JythonManipulation manipulation = new JythonManipulation(cservice, id, script, mapping);
|
JythonManipulation manipulation = new JythonManipulation(id, script, mapping);
|
||||||
|
|
||||||
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
||||||
manipulations.add(manipulation);
|
manipulations.add(manipulation);
|
||||||
@@ -141,7 +135,7 @@ public class ManipulatorTest {
|
|||||||
String script = "import math\ndef process():\n return 0.0";
|
String script = "import math\ndef process():\n return 0.0";
|
||||||
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
||||||
mapping.add(new JythonParameterMappingID("o", "myid"));
|
mapping.add(new JythonParameterMappingID("o", "myid"));
|
||||||
JythonManipulation manipulation = new JythonManipulation(cservice, id, script, mapping);
|
JythonManipulation manipulation = new JythonManipulation(id, script, mapping);
|
||||||
|
|
||||||
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
||||||
manipulations.add(manipulation);
|
manipulations.add(manipulation);
|
||||||
@@ -169,7 +163,7 @@ public class ManipulatorTest {
|
|||||||
String script = "import math\ndef process(o ,c):\n return math.cos(c) + math.sin(o)";
|
String script = "import math\ndef process(o ,c):\n return math.cos(c) + math.sin(o)";
|
||||||
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
||||||
mapping.add(new JythonParameterMappingID("o", "myid"));
|
mapping.add(new JythonParameterMappingID("o", "myid"));
|
||||||
JythonManipulation manipulation = new JythonManipulation(cservice, id, script, mapping);
|
JythonManipulation manipulation = new JythonManipulation(id, script, mapping);
|
||||||
|
|
||||||
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
||||||
manipulations.add(manipulation);
|
manipulations.add(manipulation);
|
||||||
@@ -196,7 +190,7 @@ public class ManipulatorTest {
|
|||||||
String script = "import math\ndef process(o):\n return math.cos(10.0) + math.sin(o)";
|
String script = "import math\ndef process(o):\n return math.cos(10.0) + math.sin(o)";
|
||||||
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
||||||
mapping.add(new JythonParameterMappingID("o", "myid"));
|
mapping.add(new JythonParameterMappingID("o", "myid"));
|
||||||
JythonManipulation manipulation = new JythonManipulation(cservice, id, script, mapping);
|
JythonManipulation manipulation = new JythonManipulation(id, script, mapping);
|
||||||
|
|
||||||
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
||||||
manipulations.add(manipulation);
|
manipulations.add(manipulation);
|
||||||
@@ -262,7 +256,7 @@ public class ManipulatorTest {
|
|||||||
String script = "import math\ndef process(o):\n return 1";
|
String script = "import math\ndef process(o):\n return 1";
|
||||||
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
||||||
mapping.add(new JythonParameterMappingID("o", "myid"));
|
mapping.add(new JythonParameterMappingID("o", "myid"));
|
||||||
JythonManipulation manipulation = new JythonManipulation(cservice, id, script, mapping);
|
JythonManipulation manipulation = new JythonManipulation(id, script, mapping);
|
||||||
|
|
||||||
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
||||||
manipulations.add(manipulation);
|
manipulations.add(manipulation);
|
||||||
@@ -341,7 +335,7 @@ public class ManipulatorTest {
|
|||||||
String script = "import math\ndef process(o):\n return math.cos(10.0) + math.sin(o)";
|
String script = "import math\ndef process(o):\n return math.cos(10.0) + math.sin(o)";
|
||||||
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
||||||
mapping.add(new JythonParameterMappingID("o", "myid"));
|
mapping.add(new JythonParameterMappingID("o", "myid"));
|
||||||
JythonManipulation manipulation = new JythonManipulation(cservice, id, script, mapping);
|
JythonManipulation manipulation = new JythonManipulation(id, script, mapping);
|
||||||
|
|
||||||
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
||||||
manipulations.add(manipulation);
|
manipulations.add(manipulation);
|
||||||
@@ -407,7 +401,7 @@ public class ManipulatorTest {
|
|||||||
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
List<JythonParameterMapping> mapping = new ArrayList<JythonParameterMapping>();
|
||||||
mapping.add(new JythonParameterMappingID("o", "myid"));
|
mapping.add(new JythonParameterMappingID("o", "myid"));
|
||||||
mapping.add(new JythonParameterMappingID("c", "myid2"));
|
mapping.add(new JythonParameterMappingID("c", "myid2"));
|
||||||
JythonManipulation manipulation = new JythonManipulation(cservice, id, script, mapping);
|
JythonManipulation manipulation = new JythonManipulation(id, script, mapping);
|
||||||
|
|
||||||
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
||||||
manipulations.add(manipulation);
|
manipulations.add(manipulation);
|
||||||
@@ -465,16 +459,13 @@ public class ManipulatorTest {
|
|||||||
* Test method for {@link ch.psi.fda.core.manipulator.Manipulator#run()}.
|
* Test method for {@link ch.psi.fda.core.manipulator.Manipulator#run()}.
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testRunMultipleParameterAndChannel() throws InterruptedException, ChannelException, TimeoutException, ExecutionException {
|
public void testRunMultipleParameterAndChannel() throws InterruptedException, CAException {
|
||||||
|
|
||||||
Double setValue = 12.22;
|
Double setValue = 12.22;
|
||||||
|
|
||||||
Channel<Double> cbean = new DefaultChannelService().createChannel(new ChannelDescriptor<Double>(Double.class, TestChannels.ANALOG_OUT, false));
|
ChannelBean<Double> cbean = ChannelBeanFactory.getFactory().createChannelBean(Double.class, TestChannels.ANALOG_OUT, false);
|
||||||
|
|
||||||
DataMessageMetadata dmm = new DataMessageMetadata();
|
DataMessageMetadata dmm = new DataMessageMetadata();
|
||||||
dmm.getComponents().add(new ComponentMetadata("myid"));
|
dmm.getComponents().add(new ComponentMetadata("myid"));
|
||||||
@@ -493,7 +484,7 @@ public class ManipulatorTest {
|
|||||||
mapping.add(new JythonParameterMappingID("o", "myid"));
|
mapping.add(new JythonParameterMappingID("o", "myid"));
|
||||||
mapping.add(new JythonParameterMappingID("c", "myid2"));
|
mapping.add(new JythonParameterMappingID("c", "myid2"));
|
||||||
mapping.add(new JythonParameterMappingChannel("d", TestChannels.ANALOG_OUT, Double.class));
|
mapping.add(new JythonParameterMappingChannel("d", TestChannels.ANALOG_OUT, Double.class));
|
||||||
JythonManipulation manipulation = new JythonManipulation(cservice, id, script, mapping);
|
JythonManipulation manipulation = new JythonManipulation(id, script, mapping);
|
||||||
|
|
||||||
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
List<Manipulation> manipulations = new ArrayList<Manipulation>();
|
||||||
manipulations.add(manipulation);
|
manipulations.add(manipulation);
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ package ch.psi.fda.core.sensors;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import gov.aps.jca.CAException;
|
import gov.aps.jca.CAException;
|
||||||
@@ -33,10 +31,8 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import ch.psi.fda.TestChannels;
|
import ch.psi.fda.TestChannels;
|
||||||
import ch.psi.fda.core.sensors.ChannelAccessDoubleArraySensor;
|
import ch.psi.fda.core.sensors.ChannelAccessDoubleArraySensor;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for the ScalarDoubleSensorChannelAccess class.
|
* Test class for the ScalarDoubleSensorChannelAccess class.
|
||||||
@@ -68,14 +64,11 @@ public class ChannelAccessDoubleArraySensorTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.sensors.ChannelAccessDoubleSensor#read()}.
|
* Test method for {@link ch.psi.fda.core.sensors.ChannelAccessDoubleSensor#read()}.
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testRead() throws InterruptedException, ChannelException, TimeoutException, ExecutionException {
|
public void testRead() throws CAException, InterruptedException {
|
||||||
ChannelAccessDoubleArraySensor sensor = new ChannelAccessDoubleArraySensor(new DefaultChannelService(), "id0", channelName, numberOfPoints);
|
ChannelAccessDoubleArraySensor sensor = new ChannelAccessDoubleArraySensor("id0", channelName, numberOfPoints);
|
||||||
Channel<double[]> channel = new DefaultChannelService().createChannel(new ChannelDescriptor<double[]>(double[].class, channelName, false));
|
ChannelBean<double[]> channel = ChannelBeanFactory.getFactory().createChannelBean(double[].class, channelName, false);
|
||||||
|
|
||||||
// Prepare sensor channel
|
// Prepare sensor channel
|
||||||
double[] setValue = new double[] { 0.1,0.2,0.3,4,5,6,77,88,99,10.2};
|
double[] setValue = new double[] { 0.1,0.2,0.3,4,5,6,77,88,99,10.2};
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ package ch.psi.fda.core.sensors;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import gov.aps.jca.CAException;
|
import gov.aps.jca.CAException;
|
||||||
@@ -33,10 +31,8 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import ch.psi.fda.TestChannels;
|
import ch.psi.fda.TestChannels;
|
||||||
import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for the ScalarDoubleSensorChannelAccess class.
|
* Test class for the ScalarDoubleSensorChannelAccess class.
|
||||||
@@ -66,15 +62,12 @@ public class ChannelAccessDoubleSensorTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.sensors.ChannelAccessDoubleSensor#read()}.
|
* Test method for {@link ch.psi.fda.core.sensors.ChannelAccessDoubleSensor#read()}.
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testRead() throws InterruptedException, ExecutionException, ChannelException, TimeoutException {
|
public void testRead() throws CAException, InterruptedException {
|
||||||
ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(new DefaultChannelService(), "id0", channelName);
|
ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor("id0", channelName);
|
||||||
Channel<Double> channel = new DefaultChannelService().createChannel(new ChannelDescriptor<Double>(Double.class, channelName, false));
|
ChannelBean<Double> channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
|
||||||
|
|
||||||
// Prepare sensor channel
|
// Prepare sensor channel
|
||||||
Double setValue = 0.1d;
|
Double setValue = 0.1d;
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ch.psi.fda.TestChannels;
|
import ch.psi.fda.TestChannels;
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for the ScalarDoubleSensorChannelAccess class.
|
* Test class for the ScalarDoubleSensorChannelAccess class.
|
||||||
@@ -65,7 +64,7 @@ public class ChannelAccessStringSensorTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testRead() throws CAException, InterruptedException {
|
public void testRead() throws CAException, InterruptedException {
|
||||||
ChannelAccessStringSensor sensor = new ChannelAccessStringSensor(new DefaultChannelService(), "id0", channelName);
|
ChannelAccessStringSensor sensor = new ChannelAccessStringSensor("id0", channelName);
|
||||||
|
|
||||||
// Get sensor readout value
|
// Get sensor readout value
|
||||||
String value = (String) sensor.read();
|
String value = (String) sensor.read();
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ package ch.psi.fda.core.sensors;
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import gov.aps.jca.CAException;
|
import gov.aps.jca.CAException;
|
||||||
@@ -36,10 +34,8 @@ import ch.psi.fda.TestChannels;
|
|||||||
import ch.psi.fda.core.Action;
|
import ch.psi.fda.core.Action;
|
||||||
import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
import ch.psi.fda.core.sensors.ChannelAccessDoubleSensor;
|
||||||
import ch.psi.fda.core.sensors.ComplexSensor;
|
import ch.psi.fda.core.sensors.ComplexSensor;
|
||||||
import ch.psi.jcae.Channel;
|
import ch.psi.jcae.ChannelBean;
|
||||||
import ch.psi.jcae.ChannelDescriptor;
|
import ch.psi.jcae.ChannelBeanFactory;
|
||||||
import ch.psi.jcae.ChannelException;
|
|
||||||
import ch.psi.jcae.impl.DefaultChannelService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for the ScalarDoubleSensorChannelAccess class.
|
* Test class for the ScalarDoubleSensorChannelAccess class.
|
||||||
@@ -70,16 +66,13 @@ public class ComplexSensorTest {
|
|||||||
/**
|
/**
|
||||||
* Test method for {@link ch.psi.fda.core.sensors.ChannelAccessDoubleSensor#read()}.
|
* Test method for {@link ch.psi.fda.core.sensors.ChannelAccessDoubleSensor#read()}.
|
||||||
* @throws CAException
|
* @throws CAException
|
||||||
* @throws TimeoutException
|
|
||||||
* @throws ChannelException
|
|
||||||
* @throws ExecutionException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testRead() throws CAException, InterruptedException, ChannelException, TimeoutException, ExecutionException {
|
public void testRead() throws CAException, InterruptedException {
|
||||||
|
|
||||||
final HashMap<String, Long> timestamps = new HashMap<String,Long>();
|
final HashMap<String, Long> timestamps = new HashMap<String,Long>();
|
||||||
|
|
||||||
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor(new DefaultChannelService(), "id0", channelName);
|
ChannelAccessDoubleSensor s1 = new ChannelAccessDoubleSensor("id0", channelName);
|
||||||
ComplexSensor sensor = new ComplexSensor("id2", s1);
|
ComplexSensor sensor = new ComplexSensor("id2", s1);
|
||||||
|
|
||||||
// Add pre action
|
// Add pre action
|
||||||
@@ -119,7 +112,7 @@ public class ComplexSensorTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Create channel bean for test sensor channel
|
// Create channel bean for test sensor channel
|
||||||
Channel<Double> channel = new DefaultChannelService().createChannel(new ChannelDescriptor<Double>(Double.class, channelName, false));
|
ChannelBean<Double> channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
|
||||||
|
|
||||||
// Prepare sensor channel
|
// Prepare sensor channel
|
||||||
Double setValue = 0.1d;
|
Double setValue = 0.1d;
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ public class ModelManagerTest {
|
|||||||
URL url = this.getClass().getClassLoader().getResource("home/scans/templates/scan1d.xml");
|
URL url = this.getClass().getClassLoader().getResource("home/scans/templates/scan1d.xml");
|
||||||
Configuration c = ModelManager.unmarshall(new File(new URI(url.toString())));
|
Configuration c = ModelManager.unmarshall(new File(new URI(url.toString())));
|
||||||
logger.info(""+c.getData().getFormat());
|
logger.info(""+c.getData().getFormat());
|
||||||
|
|
||||||
|
logger.info("FILENAME: "+c.getData().getFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,7 +108,7 @@ public class ModelManagerTest {
|
|||||||
Scan s = new Scan();
|
Scan s = new Scan();
|
||||||
c.setScan(s);
|
c.setScan(s);
|
||||||
|
|
||||||
ModelManager.marshall(c, new File(tmpDirectory+"/scan.xml"));
|
ModelManager.marshall(c, new File(tmpDirectory+"/scan1234.xml"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration numberOfExecution="0" xmlns="http://www.psi.ch/~ebner/models/scan/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.psi.ch/~ebner/models/scan/1.0 ../../src/model-v1.xsd">
|
||||||
|
<!--
|
||||||
|
1D Scan reading out scalar channels and the timestamp for each point
|
||||||
|
-->
|
||||||
|
<data format="txt"/>
|
||||||
|
<scan id="">
|
||||||
|
<preAction xsi:type="ShellAction" command="/bin/echo hello ${DATAFILE} ${FILENAME}"/>
|
||||||
|
<preAction xsi:type="ScriptAction">
|
||||||
|
<script>
|
||||||
|
def process( ):
|
||||||
|
print "filename __ %s" % FILENAME
|
||||||
|
print "data __ %s" % DATAFILE
|
||||||
|
</script>
|
||||||
|
</preAction>
|
||||||
|
</scan>
|
||||||
|
</configuration>
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration numberOfExecution="0" xmlns="http://www.psi.ch/~ebner/models/scan/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.psi.ch/~ebner/models/scan/1.0 ../../../src/model-v1.xsd">
|
|
||||||
<!--
|
|
||||||
1D scan reading out an array channel
|
|
||||||
-->
|
|
||||||
<data format="txt"/>
|
|
||||||
<scan id="">
|
|
||||||
<dimension>
|
|
||||||
<positioner id="id0" type="Double" name="MTEST-HW3:MOT1" xsi:type="ArrayPositioner"> <!-- settlingTime="0.1" -->
|
|
||||||
<positions>0.0 1.0 2.0 3.0 4.0</positions>
|
|
||||||
</positioner>
|
|
||||||
<detector id="idD0" xsi:type="ScalarDetector" name="MTEST-HW3:MOT1.RRBV"/>
|
|
||||||
<!-- <detector id="idD2" xsi:type="ArrayDetector" name="MTEST-PC-SSCAN:scan2.P1PA" arraySize="10"/>
|
|
||||||
<detector id="idD20" xsi:type="ArrayDetector" name="MTEST-PC-SSCAN:scan1.P1PA" arraySize="10"/> -->
|
|
||||||
<detector id="idD1" xsi:type="ScalarDetector" name="MTEST-HW3:MOT1.RBV"/>
|
|
||||||
</dimension>
|
|
||||||
</scan>
|
|
||||||
|
|
||||||
<visualization title="Array" xsi:type="LinePlot" x="id0" y="id0"/>
|
|
||||||
|
|
||||||
|
|
||||||
</configuration>
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
|
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
|
||||||
<data format="txt" fileName="scan1d"/>
|
<data format="txt" fileName="scan1d_plus_bla"/>
|
||||||
<scan>
|
<scan>
|
||||||
<dimension zigzag="true">
|
<dimension zigzag="true">
|
||||||
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinearPositioner" name="MTEST-HW3:MOT1" settlingTime="0.1" doneValue="1" doneDelay="0.0" id="id0">
|
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinearPositioner" name="MTEST-HW3:MOT1" settlingTime="0.1" doneValue="1" doneDelay="0.0" id="id0">
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration numberOfExecution="0" xmlns="http://www.psi.ch/~ebner/models/scan/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.psi.ch/~ebner/models/scan/1.0 ../../src/model-v1.xsd">
|
||||||
|
<!--
|
||||||
|
1D Scan reading out scalar channels and the timestamp for each point
|
||||||
|
-->
|
||||||
|
<data format="txt"/>
|
||||||
|
<scan id="">
|
||||||
|
<dimension zigzag="true">
|
||||||
|
<positioner id="id0" name="MTEST-HW3:MOT1" settlingTime="0.1" xsi:type="LinearPositioner">
|
||||||
|
<start>0.0</start>
|
||||||
|
<end>8.0</end>
|
||||||
|
<stepSize>0.5</stepSize>
|
||||||
|
</positioner>
|
||||||
|
<detector id="idD0" xsi:type="ScalarDetector" name="MTEST-HW3:MOT1.RRBV"/>
|
||||||
|
<detector id="idD1" xsi:type="ScalarDetector" name="MTEST-HW3:MOT1.RBV"/>
|
||||||
|
<detector xsi:type="Timestamp" id="timestamp"/>
|
||||||
|
</dimension>
|
||||||
|
|
||||||
|
<manipulation id="man1" xsi:type="ScriptManipulation">
|
||||||
|
<mapping xsi:type="IDParameterMapping" variable="a" refid="idD1"/>
|
||||||
|
<script>
|
||||||
|
def process(a):
|
||||||
|
return [1,a]
|
||||||
|
</script>
|
||||||
|
</manipulation>
|
||||||
|
<manipulation id="man2" xsi:type="ScriptManipulation">
|
||||||
|
<mapping xsi:type="IDParameterMapping" variable="a" refid="man1"/>
|
||||||
|
<script>
|
||||||
|
def process(a):
|
||||||
|
print a[1]
|
||||||
|
print FILENAME
|
||||||
|
return 1.0
|
||||||
|
</script>
|
||||||
|
</manipulation>
|
||||||
|
</scan>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<visualization title="Line Plot One" xsi:type="LinePlot" x="id0" y="idD0"/>
|
||||||
|
<visualization title="Line Plot Two" xsi:type="LinePlot" x="id0" y="idD1"/>
|
||||||
|
<visualization title="Line Plot Two" xsi:type="LinePlot" x="id0" y="man1"/>
|
||||||
|
<visualization title="Line Plot Two" xsi:type="LinePlot" x="id0" y="man2"/>
|
||||||
|
<visualization xsi:type="LinePlot" x="id0" y="timestamp" title="Timestamp" />
|
||||||
|
</configuration>
|
||||||
Reference in New Issue
Block a user