diff --git a/ch.psi.fda/.classpath b/ch.psi.fda/.classpath
index 3865a70..a37deec 100644
--- a/ch.psi.fda/.classpath
+++ b/ch.psi.fda/.classpath
@@ -28,6 +28,10 @@
-
+
+
+
+
+
diff --git a/ch.psi.fda/.settings/org.eclipse.jdt.core.prefs b/ch.psi.fda/.settings/org.eclipse.jdt.core.prefs
index 60105c1..ec4300d 100644
--- a/ch.psi.fda/.settings/org.eclipse.jdt.core.prefs
+++ b/ch.psi.fda/.settings/org.eclipse.jdt.core.prefs
@@ -1,5 +1,5 @@
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/ch.psi.fda/pom.xml b/ch.psi.fda/pom.xml
index a2e65bc..c4259a2 100644
--- a/ch.psi.fda/pom.xml
+++ b/ch.psi.fda/pom.xml
@@ -9,7 +9,7 @@
ch.psi
jcae
- 1.0.30
+ 2.1.8
@@ -58,12 +58,24 @@
freehep-xdr
2.0.4
-
+
+ com.google.inject
+ guice
+ 3.0
+
+
+
+ com.google.guava
+ guava
+ 14.0.1
+
+
+
+ test
junit
junit
- 4.8.2
- test
+ 4.11
@@ -73,8 +85,8 @@
org.apache.maven.plugins
maven-compiler-plugin
- 1.6
- 1.6
+ 1.7
+ 1.7
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java b/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java
index 4e78ad1..6a1ef4e 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java
@@ -19,8 +19,6 @@
package ch.psi.fda.aq;
-import gov.aps.jca.CAException;
-
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
@@ -118,7 +116,8 @@ import ch.psi.fda.model.v1.Variable;
import ch.psi.fda.model.v1.VariableParameterMapping;
import ch.psi.fda.notification.NotificationAgent;
import ch.psi.fda.serializer.DataSerializerTXT;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.ChannelService;
+import ch.psi.jcae.impl.DefaultChannelService;
/**
* Data acquisition engine for performing scans
@@ -146,6 +145,8 @@ public class Acquisition {
private Handler logHandler = null;
+ private ChannelService cservice;
+
/**
* Name of the datafile
*/
@@ -181,7 +182,9 @@ public class Acquisition {
* @throws InterruptedException
*/
public DataQueue initalize(Configuration smodel, boolean getQueue) {
-
+
+ cservice = new DefaultChannelService();
+
// Create notification agent with globally configured recipients
notificationAgent = new NotificationAgent(configuration.getSmptServer(), "fda.notification@psi.ch");
@@ -367,11 +370,9 @@ public class Acquisition {
// Destroy the CA context
try {
logger.fine("Destroy Channel Access context");
- ChannelBeanFactory.getFactory().getChannelFactory().destroyContext();
+ cservice.destroy();
} catch (IllegalStateException 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");
@@ -509,7 +510,7 @@ public class Acquisition {
}
}
- JythonManipulation manipulation = new JythonManipulation(sm.getId(), sm.getScript(), mapping, sm.isReturnArray());
+ JythonManipulation manipulation = new JythonManipulation(cservice, sm.getId(), sm.getScript(), mapping, sm.isReturnArray());
this.manipulations.add(manipulation);
}
}
@@ -535,24 +536,24 @@ public class Acquisition {
timeout = Math.round(ca.getTimeout()*1000);
}
if(type.equals("String")){
- alist.add(new ChannelAccessPut(ca.getChannel(), ca.getValue(), false, timeout));
+ alist.add(new ChannelAccessPut(cservice, ca.getChannel(), ca.getValue(), false, timeout));
}
else if(type.equals("Integer")){
- alist.add(new ChannelAccessPut(ca.getChannel(), new Integer(ca.getValue()), false, timeout));
+ alist.add(new ChannelAccessPut(cservice, ca.getChannel(), new Integer(ca.getValue()), false, timeout));
}
else if(type.equals("Double")){
- alist.add(new ChannelAccessPut(ca.getChannel(), new Double(ca.getValue()), false, timeout));
+ alist.add(new ChannelAccessPut(cservice, ca.getChannel(), new Double(ca.getValue()), false, timeout));
}
}
else if(operation.equals("putq")){
if(type.equals("String")){
- alist.add(new ChannelAccessPut(ca.getChannel(), ca.getValue(), true, null));
+ alist.add(new ChannelAccessPut(cservice, ca.getChannel(), ca.getValue(), true, null));
}
else if(type.equals("Integer")){
- alist.add(new ChannelAccessPut(ca.getChannel(), new Integer(ca.getValue()), true, null));
+ alist.add(new ChannelAccessPut(cservice, ca.getChannel(), new Integer(ca.getValue()), true, null));
}
else if(type.equals("Double")){
- alist.add(new ChannelAccessPut(ca.getChannel(), new Double(ca.getValue()), true, null));
+ alist.add(new ChannelAccessPut(cservice, ca.getChannel(), new Double(ca.getValue()), true, null));
}
}
else if(operation.equals("wait")){
@@ -561,13 +562,13 @@ public class Acquisition {
timeout = Math.round(ca.getTimeout()*1000);
}
if(type.equals("String")){
- alist.add(new ChannelAccessCondition(ca.getChannel(), ca.getValue(), timeout));
+ alist.add(new ChannelAccessCondition(cservice, ca.getChannel(), ca.getValue(), timeout));
}
else if(type.equals("Integer")){
- alist.add(new ChannelAccessCondition(ca.getChannel(), new Integer(ca.getValue()), timeout));
+ alist.add(new ChannelAccessCondition(cservice, ca.getChannel(), new Integer(ca.getValue()), timeout));
}
else if(type.equals("Double")){
- alist.add(new ChannelAccessCondition(ca.getChannel(), new Double(ca.getValue()), timeout));
+ alist.add(new ChannelAccessCondition(cservice, ca.getChannel(), new Double(ca.getValue()), timeout));
}
}
else if(operation.equals("waitREGEX")){
@@ -576,7 +577,7 @@ public class Acquisition {
timeout = Math.round(ca.getTimeout()*1000);
}
if(type.equals("String")){
- alist.add(new ChannelAccessConditionRegex(ca.getChannel(), ca.getValue(), timeout));
+ alist.add(new ChannelAccessConditionRegex(cservice, ca.getChannel(), ca.getValue(), timeout));
}
else{
logger.warning("Operation "+operation+" wity type "+type+" for action is not supported");
@@ -589,7 +590,7 @@ public class Acquisition {
}
if(type.equals("Integer")){
- alist.add(new ChannelAccessConditionOr(ca.getChannel(), new Integer(ca.getValue()), timeout));
+ alist.add(new ChannelAccessConditionOr(cservice, ca.getChannel(), new Integer(ca.getValue()), timeout));
}
else{
logger.warning("Operation "+operation+" wity type "+type+" for action is not supported");
@@ -601,7 +602,7 @@ public class Acquisition {
timeout = Math.round(ca.getTimeout()*1000);
}
if(type.equals("Integer")){
- alist.add(new ChannelAccessConditionAnd(ca.getChannel(), new Integer(ca.getValue()), timeout));
+ alist.add(new ChannelAccessConditionAnd(cservice, ca.getChannel(), new Integer(ca.getValue()), timeout));
}
else {
logger.warning("Operation "+operation+" wity type "+type+" for action is not supported");
@@ -645,7 +646,7 @@ public class Acquisition {
logger.warning("Channel type ["+ma.getType()+"] is not supported for mapping");
}
}
- alist.add(new ch.psi.fda.core.actions.JythonAction(sa.getScript(), mapping));
+ alist.add(new ch.psi.fda.core.actions.JythonAction(cservice, sa.getScript(), mapping));
}
}
return(alist);
@@ -678,14 +679,14 @@ public class Acquisition {
LinearPositioner lp =(LinearPositioner) p;
ChannelAccessLinearActuator> a;
if(lp.getType().equals("String")){
- a = new ChannelAccessLinearActuator(lp.getName(), lp.getDone(), lp.getDoneValue(), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
+ a = new ChannelAccessLinearActuator(cservice, lp.getName(), lp.getDone(), lp.getDoneValue(), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
}
else if(lp.getType().equals("Double")){
- a = new ChannelAccessLinearActuator(lp.getName(), lp.getDone(), Double.parseDouble(lp.getDoneValue()), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
+ a = new ChannelAccessLinearActuator(cservice, lp.getName(), lp.getDone(), Double.parseDouble(lp.getDoneValue()), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
}
else{
// Default
- a = new ChannelAccessLinearActuator(lp.getName(), lp.getDone(), Integer.parseInt(lp.getDoneValue()), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
+ a = new ChannelAccessLinearActuator(cservice, lp.getName(), lp.getDone(), Integer.parseInt(lp.getDoneValue()), lp.getDoneDelay(), lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
}
a.setAsynchronous(lp.isAsynchronous());
@@ -698,7 +699,7 @@ public class Acquisition {
if(name==null){
name = lp.getName();
}
- ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(lp.getId(), name);
+ ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(cservice, lp.getId(), name);
aLoop.getSensors().add(sensor);
}
else if(p instanceof FunctionPositioner){
@@ -711,14 +712,14 @@ public class Acquisition {
// Create actuator
ChannelAccessFunctionActuator> a;
if(lp.getType().equals("String")){
- a = new ChannelAccessFunctionActuator(lp.getName(), lp.getDone(), lp.getDoneValue(), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
+ a = new ChannelAccessFunctionActuator(cservice, lp.getName(), lp.getDone(), lp.getDoneValue(), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
}
else if(lp.getType().equals("Double")){
- a = new ChannelAccessFunctionActuator(lp.getName(), lp.getDone(), Double.parseDouble(lp.getDoneValue()), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
+ a = new ChannelAccessFunctionActuator(cservice, lp.getName(), lp.getDone(), Double.parseDouble(lp.getDoneValue()), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
}
else{
// Default
- a = new ChannelAccessFunctionActuator(lp.getName(), lp.getDone(), Integer.parseInt(lp.getDoneValue()), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
+ a = new ChannelAccessFunctionActuator(cservice, lp.getName(), lp.getDone(), Integer.parseInt(lp.getDoneValue()), lp.getDoneDelay(), function, lp.getStart(), lp.getEnd(), lp.getStepSize(), moveTimeout);
}
a.setAsynchronous(lp.isAsynchronous());
@@ -731,7 +732,7 @@ public class Acquisition {
if(name==null){
name = lp.getName();
}
- ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(lp.getId(), name);
+ ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(cservice, lp.getId(), name);
aLoop.getSensors().add(sensor);
}
else if (p instanceof ArrayPositioner){
@@ -744,14 +745,14 @@ public class Acquisition {
ChannelAccessTableActuator> a;
if(p.getType().equals("String")){
- a = new ChannelAccessTableActuator(p.getName(), p.getDone(), p.getDoneValue(), p.getDoneDelay(), table, moveTimeout);
+ a = new ChannelAccessTableActuator(cservice, p.getName(), p.getDone(), p.getDoneValue(), p.getDoneDelay(), table, moveTimeout);
}
else if(p.getType().equals("Double")){
- a = new ChannelAccessTableActuator(p.getName(), p.getDone(), Double.parseDouble(p.getDoneValue()), p.getDoneDelay(), table, moveTimeout);
+ a = new ChannelAccessTableActuator(cservice, p.getName(), p.getDone(), Double.parseDouble(p.getDoneValue()), p.getDoneDelay(), table, moveTimeout);
}
else{
// Default
- a = new ChannelAccessTableActuator(p.getName(), p.getDone(), Integer.parseInt(p.getDoneValue()), p.getDoneDelay(), table, moveTimeout);
+ a = new ChannelAccessTableActuator(cservice, p.getName(), p.getDone(), Integer.parseInt(p.getDoneValue()), p.getDoneDelay(), table, moveTimeout);
}
a.setAsynchronous(p.isAsynchronous());
@@ -764,7 +765,7 @@ public class Acquisition {
if(name==null){
name = ap.getName();
}
- ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(ap.getId(), name);
+ ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(cservice, ap.getId(), name);
aLoop.getSensors().add(sensor);
}
else if (p instanceof RegionPositioner){
@@ -797,14 +798,14 @@ public class Acquisition {
// Create actuator
ChannelAccessLinearActuator> act;
if(rp.getType().equals("String")){
- act = new ChannelAccessLinearActuator(rp.getName(), rp.getDone(), rp.getDoneValue(), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
+ act = new ChannelAccessLinearActuator(cservice, rp.getName(), rp.getDone(), rp.getDoneValue(), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
}
else if(rp.getType().equals("Double")){
- act = new ChannelAccessLinearActuator(rp.getName(), rp.getDone(), Double.parseDouble(rp.getDoneValue()), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
+ act = new ChannelAccessLinearActuator(cservice, rp.getName(), rp.getDone(), Double.parseDouble(rp.getDoneValue()), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
}
else{
// Default
- act = new ChannelAccessLinearActuator(rp.getName(), rp.getDone(), Integer.parseInt(rp.getDoneValue()), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
+ act = new ChannelAccessLinearActuator(cservice, rp.getName(), rp.getDone(), Integer.parseInt(rp.getDoneValue()), rp.getDoneDelay(), start, r.getEnd(), r.getStepSize(), moveTimeout);
}
act.setAsynchronous(rp.isAsynchronous());
@@ -825,14 +826,14 @@ public class Acquisition {
JythonFunction function = mapFunction(r.getFunction());
ChannelAccessFunctionActuator> act;
if(rp.getType().equals("String")){
- act = new ChannelAccessFunctionActuator(rp.getName(), rp.getDone(), rp.getDoneValue(), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
+ act = new ChannelAccessFunctionActuator(cservice, rp.getName(), rp.getDone(), rp.getDoneValue(), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
}
else if(rp.getType().equals("Double")){
- act = new ChannelAccessFunctionActuator(rp.getName(), rp.getDone(), Double.parseDouble(rp.getDoneValue()), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
+ act = new ChannelAccessFunctionActuator(cservice, rp.getName(), rp.getDone(), Double.parseDouble(rp.getDoneValue()), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
}
else{
// Default
- act = new ChannelAccessFunctionActuator(rp.getName(), rp.getDone(), Integer.parseInt(rp.getDoneValue()), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
+ act = new ChannelAccessFunctionActuator(cservice, rp.getName(), rp.getDone(), Integer.parseInt(rp.getDoneValue()), rp.getDoneDelay(), function, r.getStart(), r.getEnd(), r.getStepSize(), moveTimeout);
}
act.setAsynchronous(rp.isAsynchronous());
@@ -852,7 +853,7 @@ public class Acquisition {
if(name==null){
name = rp.getName();
}
- ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(rp.getId(), name);
+ ChannelAccessDoubleSensor sensor = new ChannelAccessDoubleSensor(cservice, rp.getId(), name);
aLoop.getSensors().add(sensor);
}
else if(p instanceof PseudoPositioner){
@@ -899,7 +900,7 @@ public class Acquisition {
value = con.getValue();
}
- conditions.add(new ChannelAccessGuardCondition(con.getChannel(), value));
+ conditions.add(new ChannelAccessGuardCondition(cservice, con.getChannel(), value));
}
// Create guard and add to loop
ChannelAccessGuard guard = new ChannelAccessGuard(conditions);
@@ -950,10 +951,10 @@ public class Acquisition {
// Add sensor
Sensor sensor;
if(sd.getType().equals("String")){
- sensor = new ChannelAccessStringSensor(sd.getId(), sd.getName());
+ sensor = new ChannelAccessStringSensor(cservice, sd.getId(), sd.getName());
}
else{
- sensor = new ChannelAccessDoubleSensor(sd.getId(), sd.getName());
+ sensor = new ChannelAccessDoubleSensor(cservice, sd.getId(), sd.getName());
}
aLoop.getSensors().add(sensor);
@@ -965,7 +966,7 @@ public class Acquisition {
aLoop.getPreSensorActions().addAll(mapActions(ad.getPreAction()));
// Ad sensor
- ChannelAccessDoubleArraySensor sensor = new ChannelAccessDoubleArraySensor(ad.getId(), ad.getName(), ad.getArraySize());
+ ChannelAccessDoubleArraySensor sensor = new ChannelAccessDoubleArraySensor(cservice, ad.getId(), ad.getName(), ad.getArraySize());
aLoop.getSensors().add(sensor);
}
else if (detector instanceof DetectorOfDetectors){
@@ -1008,7 +1009,7 @@ public class Acquisition {
// Create loop
boolean zigZag = dimension.isZigzag(); // default value is false
- OTFLoop actionLoop = new OTFLoop(configuration.getOtfChannelPrefix(), configuration.getOtfNfsServer(), configuration.getOtfNfsShare(), configuration.getOtfSmbShare(), zigZag);
+ OTFLoop actionLoop = new OTFLoop(cservice, configuration.getOtfChannelPrefix(), configuration.getOtfNfsServer(), configuration.getOtfNfsShare(), configuration.getOtfSmbShare(), zigZag);
actionLoop.getPreActions().addAll(mapActions(dimension.getPreAction()));
@@ -1067,7 +1068,7 @@ public class Acquisition {
// Create loop
boolean zigZag = dimension.isZigzag(); // default value is false
- CrlogicLoop actionLoop = new CrlogicLoop(configuration.getOtfCrlogicPrefix(), configuration.getOtfNfsServer(), configuration.getOtfNfsShare(), configuration.getOtfSmbShare(), zigZag);
+ CrlogicLoop actionLoop = new CrlogicLoop(cservice, configuration.getOtfCrlogicPrefix(), configuration.getOtfNfsServer(), configuration.getOtfNfsShare(), configuration.getOtfSmbShare(), zigZag);
actionLoop.setKeepTmpFiles(configuration.isOtfCrlogicKeepTmpFiles());
actionLoop.getPreActions().addAll(mapActions(dimension.getPreAction()));
@@ -1113,11 +1114,11 @@ public class Acquisition {
List sensors = new ArrayList();
for(SimpleScalarDetector detector: dimension.getDetector()){
if(detector.isScr()){
- sensors.add(new ChannelAccessDoubleSensor(detector.getId(), detector.getName()));
+ sensors.add(new ChannelAccessDoubleSensor(cservice, detector.getId(), detector.getName()));
}
}
// Create soft(ware) based crlogic
- ScrlogicLoop scrlogic = new ScrlogicLoop(sensors);
+ ScrlogicLoop scrlogic = new ScrlogicLoop(cservice, sensors);
// Create parallel logic
ParallelCrlogic pcrlogic = new ParallelCrlogic(actionLoop, scrlogic);
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessCondition.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessCondition.java
index f56d416..0b3333a 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessCondition.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessCondition.java
@@ -2,15 +2,15 @@
*
* Copyright 2010 Paul Scherrer Institute. All rights reserved.
*
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * This code is 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.
+ * 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 .
@@ -19,124 +19,145 @@
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 gov.aps.jca.CAException;
import ch.psi.fda.core.Action;
-import ch.psi.jcae.ChannelBean;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.Channel;
+import ch.psi.jcae.ChannelDescriptor;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
- * Perform a put on the specified Channel Access channel. The put can be done synchronous or
- * asynchronously.
+ * Perform a put on the specified Channel Access channel. The put can be done
+ * synchronous or asynchronously.
+ *
* @author ebner
- *
+ *
*/
public class ChannelAccessCondition implements Action {
// Get Logger
private static Logger logger = Logger.getLogger(ChannelAccessCondition.class.getName());
-
+
/**
* Channel to set
*/
- private final ChannelBean channel;
+ private final Channel channel;
/**
* Value to wait for
*/
private final E expectedValue;
-
- private final Long timeout;
-
+
+ private Long timeout;
+
private volatile boolean abort = false;
private volatile Thread waitT = null;
-
+
/**
* 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)
*
- * @throws IllegalArgumentException Unable to initialize channel,
- * Timeout specified is not >=0
+ * @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)
+ *
+ * @throws IllegalArgumentException
+ * Unable to initialize channel, Timeout specified is not >=0
*/
@SuppressWarnings("unchecked")
- public ChannelAccessCondition(String channelName, E expectedValue, Long timeout){
+ public ChannelAccessCondition(ChannelService s, String channelName, E expectedValue, Long timeout) {
- if(timeout !=null && timeout<=0){
+ if (timeout != null && timeout <= 0) {
throw new IllegalArgumentException("Timeout must be > 0");
}
-
+
try {
- this.channel = (ChannelBean) ChannelBeanFactory.getFactory().createChannelBean( (Class) expectedValue.getClass(), channelName, false);
- } catch (CAException e) {
- // Convert Exception into unchecked RuntimeException
- throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
+ this.channel = (Channel) s.createChannel(new ChannelDescriptor<>(expectedValue.getClass(), channelName, false));
+ } catch (ChannelException | TimeoutException e) {
+ throw new IllegalArgumentException("Unable to initialize actuator channel [name:" + channelName + "]", 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;
-
- if(timeout==null){
- this.timeout = channel.getWaitTimeout();
- }
- else{
+
+ if (timeout == null) {
+ // this.timeout = channel.get.getWaitTimeout();
+ this.timeout=1L;
+ } else {
this.timeout = timeout;
}
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see ch.psi.fda.core.Action#execute()
*/
/**
- * @throws InterruptedException
- * @throws RuntimeException Channel value did not reach expected value (within the specified timeout period)
+ * @throws InterruptedException
+ * @throws RuntimeException
+ * Channel value did not reach expected value (within the
+ * specified timeout period)
*/
@Override
public void execute() throws InterruptedException {
- abort=false;
- logger.finest("Checking channel "+channel.getName()+" for value "+expectedValue+" [timeout: "+timeout+"]" );
- try{
+ abort = false;
+ logger.finest("Checking channel " + channel.getName() + " for value " + expectedValue + " [timeout: " + timeout + "]");
+ try {
waitT = Thread.currentThread();
- channel.waitForValue(expectedValue, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value
- } catch (CAException e) {
- throw new RuntimeException("Channel [name:"+channel.getName()+"] did not reach expected value "+expectedValue+" ", e);
- } catch(InterruptedException e){
- if(!abort){
+ channel.waitForValueAsync(expectedValue).get(timeout, TimeUnit.MILLISECONDS); // Workaround use
+ // 10seconds default
+ // set timeout to
+ // check several
+ // times whether the
+ // channel has
+ // reached the value
+ } catch (InterruptedException e) {
+ if (!abort) {
throw e;
}
- }
- finally{
- waitT=null;
+ } catch (ExecutionException | TimeoutException | ChannelException e) {
+ throw new RuntimeException("Channel [name:" + channel.getName() + "] did not reach expected value " + expectedValue + " ", e);
+ } finally {
+ waitT = null;
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see ch.psi.fda.core.Action#abort()
*/
@Override
public void abort() {
- abort=true;
- if(waitT!=null){
+ abort = true;
+ if (waitT != null) {
waitT.interrupt();
}
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see ch.psi.fda.core.Action#destroy()
*/
@Override
public void destroy() {
// Destroy channel
- try {
- logger.finest("Destroy action channel: "+channel.getName());
- channel.destroy();
- } catch (CAException e) {
- throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
- }
+ logger.finest("Destroy action channel: " + channel.getName());
+ try {
+ channel.destroy();
+ } catch (ChannelException e) {
+ throw new RuntimeException("Unable to destroy channel [" + channel.getName() + "]", e);
+ }
}
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionAnd.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionAnd.java
index 3c52821..9a18895 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionAnd.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionAnd.java
@@ -20,12 +20,15 @@
package ch.psi.fda.core.actions;
import java.util.Comparator;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
-import gov.aps.jca.CAException;
import ch.psi.fda.core.Action;
-import ch.psi.jcae.ChannelBean;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.Channel;
+import ch.psi.jcae.ChannelDescriptor;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
@@ -41,7 +44,7 @@ public class ChannelAccessConditionAnd implements Action {
/**
* Channel to set
*/
- private final ChannelBean channel;
+ private final Channel channel;
/**
* Value to wait for
*/
@@ -62,15 +65,15 @@ public class ChannelAccessConditionAnd implements Action {
* Timeout specified is not >=0
*/
@SuppressWarnings("unchecked")
- public ChannelAccessConditionAnd(String channelName, E expectedValue, Long timeout){
+ public ChannelAccessConditionAnd(ChannelService s, String channelName, E expectedValue, Long timeout){
if(timeout !=null && timeout<=0){
throw new IllegalArgumentException("Timeout must be > 0");
}
try {
- this.channel = (ChannelBean) ChannelBeanFactory.getFactory().createChannelBean( (Class) expectedValue.getClass(), channelName, false);
- } catch (CAException e) {
+ this.channel = s.createChannel(new ChannelDescriptor<>( (Class) expectedValue.getClass(), channelName, false));
+ } catch (ChannelException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
} catch (InterruptedException e) {
@@ -80,7 +83,8 @@ public class ChannelAccessConditionAnd implements Action {
this.expectedValue = expectedValue;
if(timeout==null){
- this.timeout = channel.getWaitTimeout();
+// this.timeout = channel.getWaitTimeout();
+ this.timeout = 0L;
}
else{
this.timeout = timeout;
@@ -114,7 +118,7 @@ public class ChannelAccessConditionAnd implements Action {
}
}
, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value
- } catch (CAException e) {
+ } catch (ChannelException | ExecutionException e) {
throw new RuntimeException("Channel [name:"+channel.getName()+"] did not reach expected value "+expectedValue+" ", e);
} catch(InterruptedException e){
if(!abort){
@@ -147,7 +151,7 @@ public class ChannelAccessConditionAnd implements Action {
try {
logger.finest("Destroy action channel: "+channel.getName());
channel.destroy();
- } catch (CAException e) {
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
}
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionOr.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionOr.java
index b4ca64b..042a314 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionOr.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionOr.java
@@ -20,12 +20,15 @@
package ch.psi.fda.core.actions;
import java.util.Comparator;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
-import gov.aps.jca.CAException;
import ch.psi.fda.core.Action;
-import ch.psi.jcae.ChannelBean;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.Channel;
+import ch.psi.jcae.ChannelDescriptor;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
@@ -41,7 +44,7 @@ public class ChannelAccessConditionOr implements Action {
/**
* Channel to set
*/
- private final ChannelBean channel;
+ private final Channel channel;
/**
* Value to wait for
*/
@@ -62,15 +65,15 @@ public class ChannelAccessConditionOr implements Action {
* Timeout specified is not >=0
*/
@SuppressWarnings("unchecked")
- public ChannelAccessConditionOr(String channelName, E expectedValue, Long timeout){
+ public ChannelAccessConditionOr(ChannelService s, String channelName, E expectedValue, Long timeout){
if(timeout !=null && timeout<=0){
throw new IllegalArgumentException("Timeout must be > 0");
}
try {
- this.channel = (ChannelBean) ChannelBeanFactory.getFactory().createChannelBean( (Class) expectedValue.getClass(), channelName, false);
- } catch (CAException e) {
+ this.channel = s.createChannel(new ChannelDescriptor<>( (Class) expectedValue.getClass(), channelName, false));
+ } catch (ChannelException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
} catch (InterruptedException e) {
@@ -80,7 +83,8 @@ public class ChannelAccessConditionOr implements Action {
this.expectedValue = expectedValue;
if(timeout==null){
- this.timeout = channel.getWaitTimeout();
+// this.timeout = channel.getWaitTimeout();
+ this.timeout = 0L;
}
else{
this.timeout = timeout;
@@ -114,7 +118,7 @@ public class ChannelAccessConditionOr implements Action {
}
}
, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value
- } catch (CAException e) {
+ } catch (ChannelException | ExecutionException e) {
throw new RuntimeException("Channel [name:"+channel.getName()+"] did not reach expected value "+expectedValue+" ", e);
} catch(InterruptedException e){
if(!abort){
@@ -147,7 +151,7 @@ public class ChannelAccessConditionOr implements Action {
try {
logger.finest("Destroy action channel: "+channel.getName());
channel.destroy();
- } catch (CAException e) {
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
}
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionRegex.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionRegex.java
index a904ab4..ca16148 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionRegex.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessConditionRegex.java
@@ -20,12 +20,15 @@
package ch.psi.fda.core.actions;
import java.util.Comparator;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
-import gov.aps.jca.CAException;
import ch.psi.fda.core.Action;
-import ch.psi.jcae.ChannelBean;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.Channel;
+import ch.psi.jcae.ChannelDescriptor;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
@@ -41,7 +44,7 @@ public class ChannelAccessConditionRegex implements Action {
/**
* Channel to set
*/
- private final ChannelBean channel;
+ private final Channel channel;
/**
* Value to wait for
*/
@@ -62,15 +65,15 @@ public class ChannelAccessConditionRegex implements Action {
* Timeout specified is not >=0
*/
@SuppressWarnings("unchecked")
- public ChannelAccessConditionRegex(String channelName, E expectedValue, Long timeout){
+ public ChannelAccessConditionRegex(ChannelService s, String channelName, E expectedValue, Long timeout){
if(timeout !=null && timeout<=0){
throw new IllegalArgumentException("Timeout must be > 0");
}
try {
- this.channel = (ChannelBean) ChannelBeanFactory.getFactory().createChannelBean( (Class) expectedValue.getClass(), channelName, false);
- } catch (CAException e) {
+ this.channel = s.createChannel(new ChannelDescriptor<>( (Class) expectedValue.getClass(), channelName, false));
+ } catch (ChannelException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
} catch (InterruptedException e) {
@@ -80,7 +83,8 @@ public class ChannelAccessConditionRegex implements Action {
this.expectedValue = expectedValue;
if(timeout==null){
- this.timeout = channel.getWaitTimeout();
+// this.timeout = channel.getWaitTimeout();
+ this.timeout = 0L;
}
else{
this.timeout = timeout;
@@ -108,7 +112,7 @@ public class ChannelAccessConditionRegex implements Action {
return o1.matches(o2) ? 0:1;
}
}, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value
- } catch (CAException e) {
+ } catch (ChannelException | ExecutionException e) {
throw new RuntimeException("Channel [name:"+channel.getName()+"] did not reach expected value "+expectedValue+" ", e);
} catch(InterruptedException e){
if(!abort){
@@ -141,7 +145,7 @@ public class ChannelAccessConditionRegex implements Action {
try {
logger.finest("Destroy action channel: "+channel.getName());
channel.destroy();
- } catch (CAException e) {
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
}
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessPut.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessPut.java
index fec10df..809b4c0 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessPut.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/ChannelAccessPut.java
@@ -19,12 +19,16 @@
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 gov.aps.jca.CAException;
import ch.psi.fda.core.Action;
-import ch.psi.jcae.ChannelBean;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.Channel;
+import ch.psi.jcae.ChannelDescriptor;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
* Perform a put on the specified Channel Access channel. The put can be done synchronous or
@@ -40,7 +44,7 @@ public class ChannelAccessPut implements Action {
/**
* Channel to set
*/
- private final ChannelBean channel;
+ private final Channel channel;
/**
* Value to set
*/
@@ -62,11 +66,11 @@ public class ChannelAccessPut implements Action {
* @throws IllegalArgumentException Unable to initialize channel
*/
@SuppressWarnings("unchecked")
- public ChannelAccessPut(String channelName, E value, boolean asynchronous, Long timeout){
+ public ChannelAccessPut(ChannelService s, String channelName, E value, boolean asynchronous, Long timeout){
try {
- this.channel = ChannelBeanFactory.getFactory().createChannelBean((Class)value.getClass(), channelName, false);
- } catch (CAException e) {
+ this.channel = s.createChannel(new ChannelDescriptor<>((Class)value.getClass(), channelName, false));
+ } catch (ChannelException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
} catch (InterruptedException e) {
@@ -85,8 +89,8 @@ public class ChannelAccessPut implements Action {
*
* @throws RuntimeException Unable to initialize channel
*/
- public ChannelAccessPut(String channelName, E value){
- this(channelName, value, false, null);
+ public ChannelAccessPut(ChannelService s, String channelName, E value){
+ this(s, channelName, value, false, null);
}
/* (non-Javadoc)
@@ -101,17 +105,17 @@ public class ChannelAccessPut implements Action {
logger.finest("Put to channel: "+channel.getName()+ " asynchronous: "+asynchronous);
try{
if(asynchronous){
- channel.setValueNoWait(value);
+ channel.setValueAsync(value);
}
else{
if(timeout==null){
channel.setValue(value);
}
else{
- channel.setValue(value, timeout);
+ channel.setValueAsync(value).get(timeout, TimeUnit.MILLISECONDS);
}
}
- } catch (CAException e) {
+ } catch (ChannelException | ExecutionException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new RuntimeException("Unable to set channel [name:"+channel.getName()+"] to value "+value, e);
}
@@ -134,7 +138,7 @@ public class ChannelAccessPut implements Action {
try {
logger.finest("Destroy action channel: "+channel.getName());
channel.destroy();
- } catch (CAException e) {
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
}
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/JythonAction.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/JythonAction.java
index 9eecdba..638878e 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/JythonAction.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/actions/JythonAction.java
@@ -19,9 +19,8 @@
package ch.psi.fda.core.actions;
-import gov.aps.jca.CAException;
-
import java.util.List;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -33,8 +32,10 @@ import javax.script.ScriptException;
import ch.psi.fda.core.Action;
import ch.psi.fda.core.scripting.JythonParameterMapping;
import ch.psi.fda.core.scripting.JythonParameterMappingChannel;
-import ch.psi.jcae.ChannelBean;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.Channel;
+import ch.psi.jcae.ChannelDescriptor;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
* @author ebner
@@ -61,7 +62,7 @@ public class JythonAction implements Action {
*/
private String jythonCall;
- public JythonAction(String script, List mapping){
+ public JythonAction(ChannelService s, String script, List mapping){
// Workaround for Jython memory leak
// http://blog.hillbrecht.de/2009/07/11/jython-memory-leakout-of-memory-problem/
@@ -116,10 +117,10 @@ public class JythonAction implements Action {
for(JythonParameterMappingChannel b: mapping){
// Create channel
- ChannelBean> cb;
+ Channel> cb;
try {
- cb = ChannelBeanFactory.getFactory().createChannelBean(b.getType(), b.getChannel(), true);
- } catch (CAException e) {
+ cb = s.createChannel(new ChannelDescriptor<>(b.getType(), b.getChannel(), true));
+ } catch (TimeoutException | ChannelException e) {
throw new IllegalArgumentException("Unable to establish channel: "+b.getChannel(), e);
} catch (InterruptedException e) {
throw new RuntimeException("Unable to establish channel: "+b.getChannel(), e);
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessFunctionActuator.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessFunctionActuator.java
index 478da04..719492c 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessFunctionActuator.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessFunctionActuator.java
@@ -19,14 +19,17 @@
package ch.psi.fda.core.actors;
-import gov.aps.jca.CAException;
-
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
import ch.psi.fda.core.Actor;
import ch.psi.fda.core.EngineConfiguration;
-import ch.psi.jcae.ChannelBean;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.Channel;
+import ch.psi.jcae.ChannelDescriptor;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
* This actuator sets an Channel Access channel from a start to an end value by doing discrete steps.
@@ -86,12 +89,12 @@ public class ChannelAccessFunctionActuator implements Actor {
/**
* Channel Access channel of the actuator
*/
- private ChannelBean channel;
+ private Channel channel;
/**
* Channel Access channel of the actuator
*/
- private ChannelBean doneChannel = null;
+ private Channel doneChannel = null;
private final T doneValue;
private final long doneDelay;
@@ -116,8 +119,8 @@ public class ChannelAccessFunctionActuator implements Actor {
* @param stepSize
* @param timeout Maximum move time (in milliseconds)
*/
- public ChannelAccessFunctionActuator(String channelName, Function function, double start, double end, double stepSize, Long timeout){
- this(channelName, null, null, 0, function, start, end, stepSize, timeout);
+ public ChannelAccessFunctionActuator(ChannelService s, String channelName, Function function, double start, double end, double stepSize, Long timeout){
+ this(s, channelName, null, null, 0, function, start, end, stepSize, timeout);
}
/**
@@ -132,7 +135,7 @@ public class ChannelAccessFunctionActuator implements Actor {
* @param timeout Maximum move time (in milliseconds)
*/
@SuppressWarnings("unchecked")
- public ChannelAccessFunctionActuator(String channelName, String doneChannelName, T doneValue, double doneDelay, Function function, double start, double end, double stepSize, Long timeout){
+ public ChannelAccessFunctionActuator(ChannelService s, String channelName, String doneChannelName, T doneValue, double doneDelay, Function function, double start, double end, double stepSize, Long timeout){
this.doneValue = doneValue;
this.doneDelay = (long) Math.floor((doneDelay*1000));
@@ -170,8 +173,8 @@ public class ChannelAccessFunctionActuator implements Actor {
// Initialize/create Channel Access channel
try {
- channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
- } catch (CAException e) {
+ channel = s.createChannel(new ChannelDescriptor<>(Double.class, channelName, false));
+ } catch (ChannelException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
} catch (InterruptedException e) {
@@ -179,8 +182,8 @@ public class ChannelAccessFunctionActuator implements Actor {
}
if(doneChannelName != null){
try {
- doneChannel = ChannelBeanFactory.getFactory().createChannelBean((Class)doneValue.getClass(), doneChannelName, false);
- } catch (CAException e) {
+ doneChannel = s.createChannel(new ChannelDescriptor<>((Class)doneValue.getClass(), doneChannelName, false));
+ } catch (ChannelException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+doneChannelName+"]",e);
} catch (InterruptedException e) {
@@ -210,11 +213,11 @@ public class ChannelAccessFunctionActuator implements Actor {
channel.setValue(fvalue);
}
else{
- channel.setValue(fvalue, timeout);
+ channel.setValueAsync(fvalue).get(timeout, TimeUnit.MILLISECONDS);
}
}
else{
- channel.setValueNoWait(fvalue);
+ channel.setValueAsync(fvalue);
}
if(doneChannel != null){
@@ -231,7 +234,7 @@ public class ChannelAccessFunctionActuator implements Actor {
}
}
- } catch (CAException e) {
+ } catch (ChannelException | ExecutionException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new RuntimeException("Unable to move actuator [channel: "+channel.getName()+"] to value "+value,e);
}
@@ -318,7 +321,7 @@ public class ChannelAccessFunctionActuator implements Actor {
try {
logger.finest("Destroy actor channel: "+channel.getName());
channel.destroy();
- } catch (CAException e) {
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
}
@@ -327,7 +330,7 @@ public class ChannelAccessFunctionActuator implements Actor {
try {
logger.finest("Destroy actor done channel: "+doneChannel.getName());
doneChannel.destroy();
- } catch (CAException e) {
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
}
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessLinearActuator.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessLinearActuator.java
index 7279eca..ea42a55 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessLinearActuator.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessLinearActuator.java
@@ -19,14 +19,17 @@
package ch.psi.fda.core.actors;
-import gov.aps.jca.CAException;
-
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
import ch.psi.fda.core.Actor;
import ch.psi.fda.core.EngineConfiguration;
-import ch.psi.jcae.ChannelBean;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.Channel;
+import ch.psi.jcae.ChannelDescriptor;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
* This actuator sets an Channel Access channel from a start to an end value by doing discrete steps.
@@ -86,12 +89,12 @@ public class ChannelAccessLinearActuator implements Actor {
/**
* Channel Access channel of the actuator
*/
- private ChannelBean channel;
+ private Channel channel;
/**
* Channel Access channel of the actuator
*/
- private ChannelBean doneChannel = null;
+ private Channel doneChannel = null;
private final T doneValue;
private final long doneDelay;
@@ -119,7 +122,7 @@ public class ChannelAccessLinearActuator implements Actor {
* @param timeout Maximum move time (in milliseconds)
*/
@SuppressWarnings("unchecked")
- public ChannelAccessLinearActuator(String channelName, String doneChannelName, T doneValue, double doneDelay, double start, double end, double stepSize, Long timeout){
+ public ChannelAccessLinearActuator(ChannelService s, String channelName, String doneChannelName, T doneValue, double doneDelay, double start, double end, double stepSize, Long timeout){
this.doneValue = doneValue;
this.doneDelay = (long) Math.floor((doneDelay*1000));
@@ -152,8 +155,8 @@ public class ChannelAccessLinearActuator implements Actor {
// Initialize/create Channel Access channel
try {
- channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
- } catch (CAException e) {
+ channel = s.createChannel(new ChannelDescriptor<>(Double.class, channelName, false));
+ } catch (ChannelException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
} catch (InterruptedException e) {
@@ -161,8 +164,8 @@ public class ChannelAccessLinearActuator implements Actor {
}
if(doneChannelName != null){
try {
- doneChannel = ChannelBeanFactory.getFactory().createChannelBean((Class) doneValue.getClass(), doneChannelName, false);
- } catch (CAException e) {
+ doneChannel = s.createChannel(new ChannelDescriptor<>((Class) doneValue.getClass(), doneChannelName, false));
+ } catch (ChannelException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+doneChannelName+"]",e);
} catch (InterruptedException e) {
@@ -191,11 +194,11 @@ public class ChannelAccessLinearActuator implements Actor {
channel.setValue(value);
}
else{
- channel.setValue(value, timeout);
+ channel.setValueAsync(value).get(timeout, TimeUnit.MILLISECONDS);
}
}
else{
- channel.setValueNoWait(value);
+ channel.setValueAsync(value);
}
if(doneChannel != null){
@@ -212,7 +215,7 @@ public class ChannelAccessLinearActuator implements Actor {
}
}
- } catch (CAException e) {
+ } catch (ChannelException | TimeoutException | ExecutionException e) {
// Convert Exception into unchecked RuntimeException
throw new RuntimeException("Unable to move actuator [channel: "+channel.getName()+"] to value "+value,e);
}
@@ -295,7 +298,7 @@ public class ChannelAccessLinearActuator implements Actor {
try {
logger.finest("Destroy actor channel: "+channel.getName());
channel.destroy();
- } catch (CAException e) {
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
}
@@ -304,7 +307,7 @@ public class ChannelAccessLinearActuator implements Actor {
try {
logger.finest("Destroy actor done channel: "+doneChannel.getName());
doneChannel.destroy();
- } catch (CAException e) {
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
}
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessTableActuator.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessTableActuator.java
index 60eb4fe..2d849d4 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessTableActuator.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/actors/ChannelAccessTableActuator.java
@@ -19,14 +19,17 @@
package ch.psi.fda.core.actors;
-import gov.aps.jca.CAException;
-
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
import ch.psi.fda.core.Actor;
import ch.psi.fda.core.EngineConfiguration;
-import ch.psi.jcae.ChannelBean;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.Channel;
+import ch.psi.jcae.ChannelDescriptor;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
* This actuator sets an Channel Access channel by using the positions from the given table.
@@ -66,12 +69,12 @@ public class ChannelAccessTableActuator implements Actor {
/**
* Channel Access channel of the actuator
*/
- private ChannelBean channel;
+ private Channel channel;
/**
* Channel Access channel of the actuator
*/
- private ChannelBean doneChannel = null;
+ private Channel doneChannel = null;
private final T doneValue;
private final long doneDelay;
@@ -94,8 +97,8 @@ public class ChannelAccessTableActuator implements Actor {
* @param table Position table with the explicit positions for each step
* @param timeout Maximum move time (in milliseconds)
*/
- public ChannelAccessTableActuator(String channelName, double[] table, Long timeout){
- this(channelName, null, null, 0, table, timeout);
+ public ChannelAccessTableActuator(ChannelService s, String channelName, double[] table, Long timeout){
+ this(s, channelName, null, null, 0, table, timeout);
}
/**
@@ -108,7 +111,7 @@ public class ChannelAccessTableActuator implements Actor {
* @param timeout Maximum move time (in milliseconds)
*/
@SuppressWarnings("unchecked")
- public ChannelAccessTableActuator(String channelName, String doneChannelName, T doneValue, double doneDelay, double[] table, Long timeout){
+ public ChannelAccessTableActuator(ChannelService s, String channelName, String doneChannelName, T doneValue, double doneDelay, double[] table, Long timeout){
this.doneValue = doneValue;
this.doneDelay = (long) Math.floor((doneDelay*1000));
@@ -137,8 +140,8 @@ public class ChannelAccessTableActuator implements Actor {
// Initialize/create Channel Access channel
try {
- channel = ChannelBeanFactory.getFactory().createChannelBean(Double.class, channelName, false);
- } catch (CAException e) {
+ channel = s.createChannel(new ChannelDescriptor<>(Double.class, channelName, false));
+ } catch (ChannelException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channelName+"]",e);
} catch (InterruptedException e) {
@@ -147,8 +150,8 @@ public class ChannelAccessTableActuator implements Actor {
if(doneChannelName != null){
try {
- doneChannel = ChannelBeanFactory.getFactory().createChannelBean((Class)doneValue.getClass(), doneChannelName, false);
- } catch (CAException e) {
+ doneChannel = s.createChannel(new ChannelDescriptor<>((Class)doneValue.getClass(), doneChannelName, false));
+ } catch (ChannelException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+doneChannelName+"]",e);
} catch (InterruptedException e) {
@@ -176,11 +179,11 @@ public class ChannelAccessTableActuator implements Actor {
channel.setValue(table[count]);
}
else{
- channel.setValue(table[count], timeout);
+ channel.setValueAsync(table[count]).get(timeout, TimeUnit.MILLISECONDS);
}
}
else{
- channel.setValueNoWait(table[count]);
+ channel.setValueAsync(table[count]);
}
@@ -196,7 +199,7 @@ public class ChannelAccessTableActuator implements Actor {
}
}
- } catch (CAException e) {
+ } catch (ChannelException | ExecutionException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new RuntimeException("Move actuator [channel: "+channel.getName()+"] to value "+table[count],e);
}
@@ -280,7 +283,7 @@ public class ChannelAccessTableActuator implements Actor {
try {
logger.finest("Destroy actor channel: "+channel.getName());
channel.destroy();
- } catch (CAException e) {
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
}
@@ -289,7 +292,7 @@ public class ChannelAccessTableActuator implements Actor {
try {
logger.finest("Destroy actor done channel: "+doneChannel.getName());
doneChannel.destroy();
- } catch (CAException e) {
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
}
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/guard/ChannelAccessGuard.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/guard/ChannelAccessGuard.java
index 84144f7..c3e7f12 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/guard/ChannelAccessGuard.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/guard/ChannelAccessGuard.java
@@ -19,15 +19,16 @@
package ch.psi.fda.core.guard;
-import gov.aps.jca.CAException;
-
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import ch.psi.fda.core.Guard;
+import ch.psi.jcae.ChannelException;
/**
* Guard checking channels to meet a certain condition
@@ -85,7 +86,7 @@ public class ChannelAccessGuard implements Guard {
break;
}
}
- catch(CAException e){
+ catch(ChannelException | TimeoutException | ExecutionException e){
logger.log(Level.WARNING, "Unable ", e);
check=false;
} catch (InterruptedException e) {
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/guard/ChannelAccessGuardCondition.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/guard/ChannelAccessGuardCondition.java
index a844d11..734f019 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/guard/ChannelAccessGuardCondition.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/guard/ChannelAccessGuardCondition.java
@@ -19,11 +19,13 @@
package ch.psi.fda.core.guard;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
-import gov.aps.jca.CAException;
-import ch.psi.jcae.ChannelBean;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.Channel;
+import ch.psi.jcae.ChannelDescriptor;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
* Channel and condition that need to be met.
@@ -38,7 +40,7 @@ public class ChannelAccessGuardCondition {
/**
* Channel name
*/
- private final ChannelBean> channel;
+ private final Channel> channel;
/**
* Value of the channel to meet condition
@@ -50,10 +52,10 @@ public class ChannelAccessGuardCondition {
* @param channel Name of the channel that contributes to a guard
* @param value
*/
- public ChannelAccessGuardCondition(String channel, Object value){
+ public ChannelAccessGuardCondition(ChannelService s, String channel, Object value){
try {
- this.channel = ChannelBeanFactory.getFactory().createChannelBean(value.getClass(), channel, true);
- } catch (CAException e) {
+ this.channel = s.createChannel(new ChannelDescriptor<>(value.getClass(), channel, true));
+ } catch (ChannelException | TimeoutException e) {
// Convert Exception into unchecked RuntimeException
throw new IllegalArgumentException("Unable to initialize actuator channel [name:"+channel+"]",e);
} catch (InterruptedException e) {
@@ -65,7 +67,7 @@ public class ChannelAccessGuardCondition {
/**
* @return the channel
*/
- public ChannelBean> getChannel() {
+ public Channel> getChannel() {
return channel;
}
@@ -88,7 +90,7 @@ public class ChannelAccessGuardCondition {
try {
logger.finest("Destroy guard condition channel: "+channel.getName());
channel.destroy();
- } catch (CAException e) {
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channel ["+channel.getName()+"]",e);
}
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/OTFBean.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/OTFBean.java
index 7725ba7..9bd99d6 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/OTFBean.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/OTFBean.java
@@ -19,12 +19,13 @@
package ch.psi.fda.core.loops;
-import gov.aps.jca.CAException;
-
import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+import ch.psi.jcae.Channel;
+import ch.psi.jcae.ChannelException;
import ch.psi.jcae.annotation.CaChannel;
-import ch.psi.jcae.ChannelBean;
/**
* Bean holding all OTF channels and functionality
@@ -39,101 +40,101 @@ public class OTFBean {
private long timeoutMotorOk = 8000;
private long commandTimeout = 20000; // Maximum time until a command should take effect
- @CaChannel(type=String.class, name =":UMOT")
- private ChannelBean motor;
+ @CaChannel(type=String.class, name ="${PREFIX}:UMOT")
+ private Channel motor;
- @CaChannel(type=String.class, name=":MENC")
- private ChannelBean encoder;
+ @CaChannel(type=String.class, name="${PREFIX}:MENC")
+ private Channel encoder;
- @CaChannel(type=Double.class, name=":UBEG")
- private ChannelBean begin;
+ @CaChannel(type=Double.class, name="${PREFIX}:UBEG")
+ private Channel begin;
- @CaChannel(type=Double.class, name=":UBEG.DRVL")
- private ChannelBean beginMin;
+ @CaChannel(type=Double.class, name="${PREFIX}:UBEG.DRVL")
+ private Channel beginMin;
- @CaChannel(type=Double.class, name=":UBEG.DRVH")
- private ChannelBean beginMax;
+ @CaChannel(type=Double.class, name="${PREFIX}:UBEG.DRVH")
+ private Channel beginMax;
- @CaChannel(type=Double.class, name=":UEND")
- private ChannelBean end;
+ @CaChannel(type=Double.class, name="${PREFIX}:UEND")
+ private Channel end;
- @CaChannel(type=Double.class, name=":UEND.DRVL")
- private ChannelBean endMin;
+ @CaChannel(type=Double.class, name="${PREFIX}:UEND.DRVL")
+ private Channel endMin;
- @CaChannel(type=Double.class, name=":UEND.DRVH")
- private ChannelBean endMax;
+ @CaChannel(type=Double.class, name="${PREFIX}:UEND.DRVH")
+ private Channel endMax;
- @CaChannel(type=Double.class, name=":USSIZ")
- private ChannelBean stepSize;
+ @CaChannel(type=Double.class, name="${PREFIX}:USSIZ")
+ private Channel stepSize;
- @CaChannel(type=Double.class, name=":USSIZ.DRVL")
- private ChannelBean stepSizeMin;
+ @CaChannel(type=Double.class, name="${PREFIX}:USSIZ.DRVL")
+ private Channel stepSizeMin;
- @CaChannel(type=Double.class, name=":UITIM")
- private ChannelBean integrationTime;
+ @CaChannel(type=Double.class, name="${PREFIX}:UITIM")
+ private Channel integrationTime;
- @CaChannel(type=Double.class, name=":UITIM.DRVL")
- private ChannelBean integrationTimeMin;
+ @CaChannel(type=Double.class, name="${PREFIX}:UITIM.DRVL")
+ private Channel integrationTimeMin;
- @CaChannel(type=Double.class, name=":UITIM.DRVH")
- private ChannelBean integrationTimeMax;
+ @CaChannel(type=Double.class, name="${PREFIX}:UITIM.DRVH")
+ private Channel integrationTimeMax;
- @CaChannel(type=Double.class, name=":UBCL")
- private ChannelBean userBacklash;
+ @CaChannel(type=Double.class, name="${PREFIX}:UBCL")
+ private Channel userBacklash;
- @CaChannel(type=String.class, name=":NFSSE")
- private ChannelBean nfsServer;
+ @CaChannel(type=String.class, name="${PREFIX}:NFSSE")
+ private Channel nfsServer;
- @CaChannel(type=String.class, name=":NFSSH")
- private ChannelBean nfsShare;
+ @CaChannel(type=String.class, name="${PREFIX}:NFSSH")
+ private Channel nfsShare;
- @CaChannel(type=String.class, name=":DFNAM")
- private ChannelBean fileName;
+ @CaChannel(type=String.class, name="${PREFIX}:DFNAM")
+ private Channel fileName;
- @CaChannel(type=String.class, name=":FFORM")
- private ChannelBean fileNameFormat;
+ @CaChannel(type=String.class, name="${PREFIX}:FFORM")
+ private Channel fileNameFormat;
- @CaChannel(type=Integer.class, name=":FCNT")
- private ChannelBean fileCount;
+ @CaChannel(type=Integer.class, name="${PREFIX}:FCNT")
+ private Channel fileCount;
- @CaChannel(type=Integer.class, name=":FCNT.B")
- private ChannelBean resetFileCounter;
+ @CaChannel(type=Integer.class, name="${PREFIX}:FCNT.B")
+ private Channel resetFileCounter;
- @CaChannel(type=Boolean.class, name=":FAPPE")
- private ChannelBean appendFile;
+ @CaChannel(type=Boolean.class, name="${PREFIX}:FAPPE")
+ private Channel appendFile;
- @CaChannel(type=Boolean.class, name=":FUSE")
- private ChannelBean fileNameGeneration;
+ @CaChannel(type=Boolean.class, name="${PREFIX}:FUSE")
+ private Channel fileNameGeneration;
- @CaChannel(type=Boolean.class, name=":UZIGZ")
- private ChannelBean zigZag;
+ @CaChannel(type=Boolean.class, name="${PREFIX}:UZIGZ")
+ private Channel zigZag;
- @CaChannel(type=Integer.class, name=":UCOM")
- private ChannelBean command;
+ @CaChannel(type=Integer.class, name="${PREFIX}:UCOM")
+ private Channel command;
- @CaChannel(type=Boolean.class, name=":SCRU", monitor=true)
- private ChannelBean scanRunning;
+ @CaChannel(type=Boolean.class, name="${PREFIX}:SCRU", monitor=true)
+ private Channel scanRunning;
- @CaChannel(type=Boolean.class, name=":MUENC")
- private ChannelBean useEncoder;
+ @CaChannel(type=Boolean.class, name="${PREFIX}:MUENC")
+ private Channel useEncoder;
- @CaChannel(type=String.class, name={":CTM0",":CTM1",":CTM2",":CTM3",":CTM4",":CTM5",":CTM6",":CTM7"})
- private List> monitoredChannels;
+ @CaChannel(type=String.class, name={"${PREFIX}:CTM0","${PREFIX}:CTM1","${PREFIX}:CTM2","${PREFIX}:CTM3","${PREFIX}:CTM4","${PREFIX}:CTM5","${PREFIX}:CTM6","${PREFIX}:CTM7"})
+ private List> monitoredChannels;
- @CaChannel(type=Boolean.class, name=":OTF", monitor=true)
- private ChannelBean running;
+ @CaChannel(type=Boolean.class, name="${PREFIX}:OTF", monitor=true)
+ private Channel running;
- @CaChannel(type=Integer.class, name=":USTAT", monitor=true)
- private ChannelBean status;
+ @CaChannel(type=Integer.class, name="${PREFIX}:USTAT", monitor=true)
+ private Channel status;
- @CaChannel(type=Boolean.class, name=":MOK", monitor=true)
- private ChannelBean motorOk;
+ @CaChannel(type=Boolean.class, name="${PREFIX}:MOK", monitor=true)
+ private Channel motorOk;
- @CaChannel(type=Boolean.class, name=":EOK", monitor=true)
- private ChannelBean encoderOk;
+ @CaChannel(type=Boolean.class, name="${PREFIX}:EOK", monitor=true)
+ private Channel encoderOk;
- @CaChannel(type=String.class, name=":MSG")
- private ChannelBean message;
+ @CaChannel(type=String.class, name="${PREFIX}:MSG")
+ private Channel message;
/**
* Get the trigger name that can be used by the sscan record to trigger an OTFScan
@@ -174,7 +175,7 @@ public class OTFBean {
this.command.setValue(Command.STOP.ordinal());
// Do not wait for put to return
- this.running.setValueNoWait(false);
+ this.running.setValueAsync(false);
}
catch(Exception e){
throw new RuntimeException("Unable to abort OTF logic" ,e);
@@ -210,7 +211,7 @@ public class OTFBean {
throw new RuntimeException("OTFSCAN failed with message: "+message.getValue());
}
- } catch (CAException e) {
+ } catch (ChannelException | ExecutionException | TimeoutException e) {
throw new RuntimeException("An error occurred while waiting for the OTF logic to finish.", e);
}
}
@@ -229,7 +230,7 @@ public class OTFBean {
throw new RuntimeException("OTFSCAN failed with message: "+message.getValue());
}
- } catch (CAException e) {
+ } catch (ChannelException | ExecutionException | TimeoutException e) {
throw new RuntimeException("An error occurred while waiting for the OTF logic to finish.", e);
}
@@ -239,10 +240,10 @@ public class OTFBean {
/**
* Reset OTFScan records to defaults
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
* @throws InterruptedException
*/
- public void resetToDefaults() throws CAException, InterruptedException{
+ public void resetToDefaults() throws ChannelException , ExecutionException , TimeoutException, InterruptedException{
setMonitoredChannels(new String[]{});
setMotor("");
begin.setValue(0d);
@@ -267,54 +268,69 @@ public class OTFBean {
/**
* Get motor of the OTFScan axis
* @return Name of the OTF motor
- * @throws CAException
+ * @throws ExecutionException
+ * @throws TimeoutException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public String getMotor() throws CAException, InterruptedException {
+ public String getMotor() throws ChannelException, InterruptedException, TimeoutException, ExecutionException {
return(this.motor.getValue());
}
/**
* Set motor of the OTFScan axis
* @param motor
- * @throws CAException
+ * @throws ChannelException
+ * @throws ExecutionException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setMotor(String motor) throws CAException, InterruptedException {
+ public void setMotor(String motor) throws InterruptedException, ExecutionException, ChannelException {
this.motor.setValue(motor);
}
/**
* Get encoder of the OTFScan axis
* @return Name of the used encoder
- * @throws CAException
+ * @throws ExecutionException
+ * @throws ChannelException
+ * @throws TimeoutException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public String getEncoder() throws CAException, InterruptedException {
+ public String getEncoder() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
return(this.encoder.getValue());
}
/**
* Set encoder to use of the OTFScan axis
* @param encoder
- * @throws CAException
+ * @throws ChannelException
+ * @throws ExecutionException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setEncoder(String encoder) throws CAException, InterruptedException {
+ public void setEncoder(String encoder) throws InterruptedException, ExecutionException, ChannelException {
this.encoder.setValue(encoder);
}
/**
* Get begin position of the scan
* @return Begin position scan
- * @throws CAException
+ * @throws ExecutionException
+ * @throws ChannelException
+ * @throws TimeoutException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Double getBegin() throws CAException, InterruptedException {
+ public Double getBegin() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
return(this.begin.getValue());
}
/**
* Set begin position of scan
* @param begin
+ * @throws ExecutionException
+ * @throws ChannelException
+ * @throws TimeoutException
* @throws Exception
*/
- public void setBegin(Double begin) throws CAException, InterruptedException {
+ public void setBegin(Double begin) throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
if(begin==null){
throw new IllegalArgumentException("Begin position must not be null");
@@ -330,36 +346,48 @@ public class OTFBean {
/**
* Get minimum value of the begin position
* @return Min value for begin
- * @throws CAException
+ * @throws ExecutionException
+ * @throws ChannelException
+ * @throws TimeoutException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Double getMinBegin() throws CAException, InterruptedException {
+ public Double getMinBegin() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
return(this.beginMin.getValue());
}
/**
* Get maximum value of the begin position
* @return Max value for begin
- * @throws CAException
+ * @throws ExecutionException
+ * @throws ChannelException
+ * @throws TimeoutException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Double getMaxBegin() throws CAException, InterruptedException {
+ public Double getMaxBegin() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
return(this.beginMax.getValue());
}
/**
* Get end position of the scan
* @return End position scan
- * @throws CAException
+ * @throws ExecutionException
+ * @throws ChannelException
+ * @throws TimeoutException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Double getEnd() throws CAException, InterruptedException {
+ public Double getEnd() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
return(this.end.getValue());
}
/**
* Set end positon of scan
* @param end
- * @throws CAException
+ * @throws ExecutionException
+ * @throws ChannelException
+ * @throws TimeoutException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setEnd(Double end) throws CAException, InterruptedException {
+ public void setEnd(Double end) throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
if(end==null){
throw new IllegalArgumentException("End position must not be null");
@@ -375,35 +403,38 @@ public class OTFBean {
/**
* Get minimum value of end position
* @return Min value for end
- * @throws CAException
+ * @throws ExecutionException
+ * @throws ChannelException
+ * @throws TimeoutException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Double getMinEnd() throws CAException, InterruptedException {
+ public Double getMinEnd() throws InterruptedException, TimeoutException, ChannelException, ExecutionException {
return(this.endMin.getValue());
}
/**
* Get maximum value of end position
* @return Max value for end
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Double getMaxEnd() throws CAException, InterruptedException {
+ public Double getMaxEnd() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.endMax.getValue());
}
/**
* Get scan step size
* @return Step size
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Double getStepSize() throws CAException, InterruptedException {
+ public Double getStepSize() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.stepSize.getValue());
}
/**
* Set step size of scan
* @param stepSize
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setStepSize(Double stepSize) throws CAException, InterruptedException {
+ public void setStepSize(Double stepSize) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
if(integrationTime==null){
throw new IllegalArgumentException("Step size must not be null");
@@ -423,27 +454,27 @@ public class OTFBean {
/**
* Get minimum integration time
* @return Min value for step size
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public double getMinStepSize() throws CAException, InterruptedException {
+ public double getMinStepSize() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.stepSizeMin.getValue());
}
/**
* Get scan integration time (time that is spend in one step)
* @return Integration time
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Double getIntegrationTime() throws CAException, InterruptedException {
+ public Double getIntegrationTime() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.integrationTime.getValue());
}
/**
* Set integration time of scan
* @param integrationTime
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setIntegrationTime(Double integrationTime) throws CAException, InterruptedException {
+ public void setIntegrationTime(Double integrationTime) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
if(integrationTime==null){
throw new IllegalArgumentException("Integration time must not be null");
@@ -472,35 +503,35 @@ public class OTFBean {
/**
* Get minimum integration time
* @return Min value for integration time
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Double getMinIntegrationTime() throws CAException, InterruptedException {
+ public Double getMinIntegrationTime() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.integrationTimeMin.getValue());
}
/**
* Get maximum integration time
* @return Max value for integration time
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Double getMaxIntegrationTime() throws CAException, InterruptedException {
+ public Double getMaxIntegrationTime() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.integrationTimeMax.getValue());
}
/**
* Get additional user defined backlash
* @return User backlash
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Double getUserBacklash() throws CAException, InterruptedException {
+ public Double getUserBacklash() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.userBacklash.getValue());
}
/**
* Set additional user defined backlash
* @param userBacklash
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setUserBacklash(Double userBacklash) throws CAException, InterruptedException {
+ public void setUserBacklash(Double userBacklash) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
if(userBacklash==null){
throw new IllegalArgumentException("User backlash must not be null");
}
@@ -511,63 +542,63 @@ public class OTFBean {
/**
* Get the current NFS server the data is written to
* @return Name of NFS server
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public String getNfsServer() throws CAException, InterruptedException {
+ public String getNfsServer() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.nfsServer.getValue());
}
/**
* Set name of the NFS server the data is written to
* @param nfsServer
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setNfsServer(String nfsServer) throws CAException, InterruptedException {
+ public void setNfsServer(String nfsServer) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
this.nfsServer.setValue(nfsServer);
}
/**
* Get the NFS share the data is written to
* @return Name of NFS share
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public String getNfsShare() throws CAException, InterruptedException {
+ public String getNfsShare() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.nfsShare.getValue());
}
/**
* Set name of the NFS share the data is written to
* @param nfsShare
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setNfsShare(String nfsShare) throws CAException, InterruptedException {
+ public void setNfsShare(String nfsShare) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
this.nfsShare.setValue(nfsShare);
}
/**
* Get the name of the data file
* @return Name of data file name
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public String getFileName() throws CAException, InterruptedException {
+ public String getFileName() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.fileName.getValue());
}
/**
* Set name of the data file
* @param filename
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setFileName(String filename) throws CAException, InterruptedException {
+ public void setFileName(String filename) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
this.fileName.setValue(filename);
}
/**
* Get File name formate
* @return Get format for file name
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public String getFileNameFormat() throws CAException, InterruptedException {
+ public String getFileNameFormat() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.fileNameFormat.getValue());
}
@@ -576,102 +607,102 @@ public class OTFBean {
* @param fileNameFormat
* @throws Exception
*/
- public void setFileNameFormat(String fileNameFormat) throws CAException, InterruptedException {
+ public void setFileNameFormat(String fileNameFormat) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
this.fileNameFormat.setValue(fileNameFormat);
}
/**
* Get value of the IOC based file name counter
* @return File counter
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public int getFileCounter() throws CAException, InterruptedException {
+ public int getFileCounter() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.fileCount.getValue());
}
/**
* Reset the IOC based file counter
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void resetFileCounter() throws CAException, InterruptedException {
+ public void resetFileCounter() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
this.resetFileCounter.setValue(1);
}
/**
* Get if append file option is activated
* @return Append file flag
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public boolean isAppendFile() throws CAException, InterruptedException {
+ public boolean isAppendFile() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.appendFile.getValue());
}
/**
* Set whether to append the specified file if the file exists
* @param append
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setAppendFile(boolean append) throws CAException, InterruptedException {
+ public void setAppendFile(boolean append) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
this.appendFile.setValue(append);
}
/**
* Get if file name generation is on or off
* @return File name generation flag
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public boolean isFileNameGeneration() throws CAException, InterruptedException {
+ public boolean isFileNameGeneration() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.fileNameGeneration.getValue());
}
/**
* Set Whether the file name should be generated out of the file name format and the file counter
* @param generation
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setFileNameGeneration(boolean generation) throws CAException, InterruptedException {
+ public void setFileNameGeneration(boolean generation) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
this.fileNameGeneration.setValue(generation);
}
/**
* Get if ZigZag scan option is on or off
* @return ZigZag flag
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public boolean isZigZag() throws CAException, InterruptedException {
+ public boolean isZigZag() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.zigZag.getValue());
}
/**
* Set ZigZag scan mode on/off
* @param zigZag ZigZag mode on = true, ZigZag mode off = false
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setZigZag(boolean zigZag) throws CAException, InterruptedException {
+ public void setZigZag(boolean zigZag) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
this.zigZag.setValue(zigZag);
}
/**
* Get whether encoder is used
*/
- public boolean isUseEncoder() throws CAException, InterruptedException {
+ public boolean isUseEncoder() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(this.useEncoder.getValue());
}
/**
* Set flag to use encoder
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public void setUseEncoder(boolean flag) throws CAException, InterruptedException {
+ public void setUseEncoder(boolean flag) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
this.useEncoder.setValue(flag);
}
/**
* Get the channels that are currently monitored by the OTFScan logic
* @return Names of the monitored channels
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public String[] getMonitoredChannels() throws CAException, InterruptedException {
+ public String[] getMonitoredChannels() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
String[] values = new String[this.monitoredChannels.size()];
for(int i=0; imonitoredChannels.size()){
throw new IllegalArgumentException("Only up to "+monitoredChannels.size()+" monitored channels are supported by OTF");
@@ -707,36 +738,36 @@ public class OTFBean {
/**
* Returns whether an scan is running
* @return Running flag
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public boolean isRunning() throws CAException, InterruptedException {
+ public boolean isRunning() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(running.getValue());
}
/**
* Get status of the scan
* @return Status of the scan
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public Status getStatus() throws CAException, InterruptedException {
+ public Status getStatus() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(Status.values()[this.status.getValue()]);
}
/**
* Get the (error) message from the OTF records
* @return Message from OTF C logic
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public String getMessage() throws CAException, InterruptedException {
+ public String getMessage() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(message.getValue());
}
/**
* Check whether the specified motor is recognized as ok (i.e. it is registered as OTFScan motor)
* @return Flag whether motor is ok
- * @throws CAException
+ * @throws TimeoutException, ChannelException, ExecutionException
*/
- public boolean isMotorOk() throws CAException, InterruptedException {
+ public boolean isMotorOk() throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
return(motorOk.getValue());
}
@@ -744,9 +775,9 @@ public class OTFBean {
* Wait until the motor flag goes to ok
* @param timeout Timout in milliseconds
*
- * @throws CAException If motor ok flag does not switch to ok within the specified timeout
+ * @throws TimeoutException, ChannelException, ExecutionException If motor ok flag does not switch to ok within the specified timeout
*/
- public void waitUntilMotorOk(long timeout) throws CAException, InterruptedException {
+ public void waitUntilMotorOk(long timeout) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
motorOk.waitForValue(true, timeout);
}
@@ -754,14 +785,14 @@ public class OTFBean {
* Wait until the motor flag goes to not ok
* @param timeout Timout in milliseconds
*
- * @throws CAException If motor ok flag does not switch to ok within the specified timeout
+ * @throws TimeoutException, ChannelException, ExecutionException If motor ok flag does not switch to ok within the specified timeout
*/
- public void waitUntilMotorNotOk(long timeout) throws CAException, InterruptedException {
+ public void waitUntilMotorNotOk(long timeout) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
motorOk.waitForValue(false, timeout);
}
- public void waitUntilEncoderOk(long timeout) throws CAException, InterruptedException {
+ public void waitUntilEncoderOk(long timeout) throws TimeoutException, ChannelException, ExecutionException, InterruptedException {
if(!useEncoder.getValue()){
return;
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/OTFLoop.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/OTFLoop.java
index fb53dc7..987a709 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/OTFLoop.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/OTFLoop.java
@@ -24,15 +24,24 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
//import jcifs.smb.SmbException;
//import jcifs.smb.SmbFile;
-import gov.aps.jca.CAException;
+
+
+
+
+
+
import ch.psi.fda.core.Action;
import ch.psi.fda.core.ActionLoop;
import ch.psi.fda.core.Sensor;
@@ -47,7 +56,8 @@ import ch.psi.fda.core.sensors.MillisecondTimestampSensor;
import ch.psi.fda.core.sensors.OTFNamedChannelSensor;
import ch.psi.fda.core.sensors.OTFReadbackSensor;
import ch.psi.fda.core.sensors.OTFScalerChannelSensor;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
* ActionLoop that is implementing the OTF Scan logic.
@@ -143,6 +153,8 @@ public class OTFLoop implements ActionLoop {
*/
private volatile boolean abort = false;
+ private ChannelService cservice;
+
/**
* Constructor
* @param channelPrefix Prefix of the OTF related records, e.g. MTEST-HW3-OTF
@@ -151,13 +163,15 @@ public class OTFLoop implements ActionLoop {
* @param smbShare SMB share to get the data written by the OTF C Logic
* @param zigZag Operate loop in zig zag mode
*/
- public OTFLoop(String channelPrefix, String server, String share, String smbShare, boolean zigZag){
-
+ public OTFLoop(ChannelService s, String channelPrefix, String server, String share, String smbShare, boolean zigZag){
+ cservice = s;
// Initialize connection to the OTF records
try {
this.obean = new OTFBean();
- ChannelBeanFactory.getFactory().createChannelBeans(obean, channelPrefix);
- } catch (CAException e) {
+ Map m = new HashMap<>();
+ m.put("PREFIX", channelPrefix);
+ s.createAnnotatedChannels(obean, m);
+ } catch (ChannelException | TimeoutException e) {
throw new IllegalArgumentException("Unable to connect to the OTF channels",e);
} catch (InterruptedException e) {
throw new RuntimeException("Unable to connect to the OTF channels",e);
@@ -311,7 +325,7 @@ public class OTFLoop implements ActionLoop {
// Set monitored channels
obean.setMonitoredChannels(monitoredChannels.toArray(new String[monitoredChannels.size()]));
}
- catch(CAException e){
+ catch(ChannelException | ExecutionException | TimeoutException e){
throw new RuntimeException("Unable to set OTF configuration parameters",e);
} catch (InterruptedException e) {
throw new RuntimeException("Unable to set OTF configuration parameters",e);
@@ -358,10 +372,8 @@ public class OTFLoop implements ActionLoop {
public void destroy() {
// Close all connections used by the OTFBean
try {
- ChannelBeanFactory.getFactory().destroyChannelBeans(obean);
- } catch (CAException e) {
- throw new RuntimeException("Unable to destroy channels",e);
- } catch (InterruptedException e) {
+ cservice.destroyAnnotatedChannels(obean);
+ } catch (ChannelException e) {
throw new RuntimeException("Unable to destroy channels",e);
}
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicChannelsTemplate.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicChannelsTemplate.java
index 107dec1..f3dd630 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicChannelsTemplate.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicChannelsTemplate.java
@@ -19,7 +19,7 @@
package ch.psi.fda.core.loops.cr;
-import ch.psi.jcae.ChannelBean;
+import ch.psi.jcae.Channel;
import ch.psi.jcae.annotation.CaChannel;
/**
@@ -37,120 +37,120 @@ public class CrlogicChannelsTemplate {
* Ticks per second - IOC setting
* ATTENTION - This field must only be set bu the IOC - ATTENTION
*/
- @CaChannel(type=Integer.class, name =":TPS")
- private ChannelBean ticksPerSecond;
+ @CaChannel(type=Integer.class, name ="${PREFIX}:TPS")
+ private Channel ticksPerSecond;
/**
* Status of the OTFSCAN IOC logic
*/
- @CaChannel(type=String.class, name =":STATUS")
- private ChannelBean status;
+ @CaChannel(type=String.class, name ="${PREFIX}:STATUS")
+ private Channel status;
/**
* Message from the OTFSCAN IOC logic
*/
- @CaChannel(type=String.class, name =":MSG")
- private ChannelBean message;
+ @CaChannel(type=String.class, name ="${PREFIX}:MSG")
+ private Channel message;
/**
* IOC ticks between data acquisition interrupts
*/
- @CaChannel(type=Integer.class, name =":TBINT")
- private ChannelBean ticksBetweenInterrupts;
+ @CaChannel(type=Integer.class, name ="${PREFIX}:TBINT")
+ private Channel ticksBetweenInterrupts;
/**
* Name or ip address of the NFS server to save the data to
* (depending on the IOC setup)
*/
- @CaChannel(type=String.class, name =":NFSSE")
- private ChannelBean nfsServer;
+ @CaChannel(type=String.class, name ="${PREFIX}:NFSSE")
+ private Channel nfsServer;
/**
* Name of the NFS share on the NFS server
*/
- @CaChannel(type=String.class, name =":NFSSH")
- private ChannelBean nfsShare;
+ @CaChannel(type=String.class, name ="${PREFIX}:NFSSH")
+ private Channel nfsShare;
/**
* Name of the data file
*/
- @CaChannel(type=String.class, name =":DFNAM")
- private ChannelBean dataFile;
+ @CaChannel(type=String.class, name ="${PREFIX}:DFNAM")
+ private Channel dataFile;
/**
* Flag to identify whether the data file should be appended
*/
- @CaChannel(type=Boolean.class, name =":FAPPE")
- private ChannelBean appendFile;
+ @CaChannel(type=Boolean.class, name ="${PREFIX}:FAPPE")
+ private Channel appendFile;
/**
* Readout resources
*/
- @CaChannel(type=String[].class, name =":RRES")
- private ChannelBean readoutResources;
+ @CaChannel(type=String[].class, name ="${PREFIX}:RRES")
+ private Channel readoutResources;
/**
* @return the ticksPerSecond
*/
- public ChannelBean getTicksPerSecond() {
+ public Channel getTicksPerSecond() {
return ticksPerSecond;
}
/**
* @return the status
*/
- public ChannelBean getStatus() {
+ public Channel getStatus() {
return status;
}
/**
* @return the message
*/
- public ChannelBean getMessage() {
+ public Channel getMessage() {
return message;
}
/**
* @return the ticksBetweenInterrupts
*/
- public ChannelBean getTicksBetweenInterrupts() {
+ public Channel getTicksBetweenInterrupts() {
return ticksBetweenInterrupts;
}
/**
* @return the nfsServer
*/
- public ChannelBean getNfsServer() {
+ public Channel getNfsServer() {
return nfsServer;
}
/**
* @return the nfsShare
*/
- public ChannelBean getNfsShare() {
+ public Channel getNfsShare() {
return nfsShare;
}
/**
* @return the dataFile
*/
- public ChannelBean getDataFile() {
+ public Channel getDataFile() {
return dataFile;
}
/**
* @return the appendFile
*/
- public ChannelBean getAppendFile() {
+ public Channel getAppendFile() {
return appendFile;
}
/**
* @return the readoutResources
*/
- public ChannelBean getReadoutResources() {
+ public Channel getReadoutResources() {
return readoutResources;
}
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicLoop.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicLoop.java
index 8c9e967..96c1161 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicLoop.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/CrlogicLoop.java
@@ -27,12 +27,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
import jcifs.smb.SmbFile;
-import gov.aps.jca.CAException;
import ch.psi.fda.core.Action;
import ch.psi.fda.core.ActionLoop;
import ch.psi.fda.core.Sensor;
@@ -46,7 +48,8 @@ import ch.psi.fda.core.messages.Message;
import ch.psi.fda.core.sensors.MillisecondTimestampSensor;
import ch.psi.fda.core.sensors.OTFNamedChannelSensor;
import ch.psi.fda.core.sensors.OTFScalerChannelSensor;
-import ch.psi.jcae.ChannelBeanFactory;
+import ch.psi.jcae.ChannelException;
+import ch.psi.jcae.ChannelService;
/**
* @author ebner
@@ -150,8 +153,9 @@ public class CrlogicLoop implements ActionLoop {
private boolean abortForce = false;
private Thread executionThread = null;
-
- public CrlogicLoop(String prefix, String server, String share, String smbShare, boolean zigZag){
+ private ChannelService cservice;
+ public CrlogicLoop(ChannelService s, String prefix, String server, String share, String smbShare, boolean zigZag){
+ cservice = s;
this.prefix = prefix;
this.server = server;
this.share = share;
@@ -462,7 +466,7 @@ public class CrlogicLoop implements ActionLoop {
// Move to start
logger.info("Move motor to start ["+realStart+"]");
- motortemplate.getSetValue().setValue(realStart, timeout); // Will block until move is done
+ motortemplate.getSetValue().setValueAsync(realStart).get(timeout, TimeUnit.MILLISECONDS); // Will block until move is done
// Set motor paramters
@@ -500,7 +504,7 @@ public class CrlogicLoop implements ActionLoop {
try{
template.getStatus().waitForValue(CrlogicChannelsTemplate.Status.ACTIVE.toString(), startStopTimeout);
}
- catch(CAException e){
+ catch(ChannelException e){
logger.info( "Failed to start CRLOGIC. Logic in status: "+template.getStatus().getValue() );
if(template.getStatus().getValue().equals(CrlogicChannelsTemplate.Status.FAULT.toString())){
logger.info("Error message: "+template.getMessage().getValue());
@@ -515,7 +519,7 @@ public class CrlogicLoop implements ActionLoop {
// Move motor(s) to end / wait until motor is stopped
logger.info("Move motor to end ["+realEnd+"]");
try{
- motortemplate.getSetValue().setValue(realEnd, timeout); // Will block until move is done
+ motortemplate.getSetValue().setValueAsync(realEnd).get(timeout, TimeUnit.MILLISECONDS); // Will block until move is done
}
catch (InterruptedException e) {
if(abort & (!abortForce)){
@@ -537,7 +541,7 @@ public class CrlogicLoop implements ActionLoop {
try{
template.getStatus().waitForValue(CrlogicChannelsTemplate.Status.INACTIVE.toString(), startStopTimeout);
}
- catch(CAException e){
+ catch(ChannelException | ExecutionException e){
logger.info( "Failed to stop CRLOGIC. Logic in status: "+template.getStatus().getValue() );
// TODO Improve error handling
throw new RuntimeException("Failed to stop CRLOGIC. Logic in status: "+template.getStatus().getValue(), e);
@@ -589,7 +593,7 @@ public class CrlogicLoop implements ActionLoop {
executionThread = null;
}
}
- catch(CAException e){
+ catch(ChannelException | ExecutionException | TimeoutException e){
throw new RuntimeException("Unable to execute crloop", e);
}
}
@@ -627,8 +631,8 @@ public class CrlogicLoop implements ActionLoop {
try {
- ChannelBeanFactory.getFactory().destroyChannelBeans(template);
- ChannelBeanFactory.getFactory().destroyChannelBeans(motortemplate);
+ cservice.destroyAnnotatedChannels(template);
+ cservice.destroyAnnotatedChannels(motortemplate);
template = null;
motortemplate = null;
@@ -677,11 +681,15 @@ public class CrlogicLoop implements ActionLoop {
// Connect crlogic channels
template = new CrlogicChannelsTemplate();
logger.info("Connect channels");
- ChannelBeanFactory.getFactory().createChannelBeans(template, prefix);
+ Map m = new HashMap<>();
+ m.put("PREFIX", prefix);
+ cservice.createAnnotatedChannels(template, m);
// Connect motor channels
motortemplate = new MotorChannelsTemplate();
- ChannelBeanFactory.getFactory().createChannelBeans(motortemplate, actuator.getName());
+ m = new HashMap<>();
+ m.put("PREFIX", actuator.getName());
+ cservice.createAnnotatedChannels(motortemplate, m);
useReadback = motortemplate.getUseReadback().getValue();
useEncoder = motortemplate.getUseEncoder().getValue();
@@ -723,7 +731,9 @@ public class CrlogicLoop implements ActionLoop {
// Fill readback encoder settings
// Connect to encoder
EncoderChannelsTemplate encodertemplate = new EncoderChannelsTemplate();
- ChannelBeanFactory.getFactory().createChannelBeans(encodertemplate, readback);
+ m = new HashMap<>();
+ m.put("PREFIX", readback);
+ cservice.createAnnotatedChannels(encodertemplate, m);
// Read encoder settings
if(encodertemplate.getDirection().getValue()==EncoderChannelsTemplate.Direction.Positive.ordinal()){
@@ -736,7 +746,7 @@ public class CrlogicLoop implements ActionLoop {
crlogicDataFilter.setEncoderResolution(encodertemplate.getResolution().getValue());
// Disconnect from encoder
- ChannelBeanFactory.getFactory().destroyChannelBeans(encodertemplate);
+ cservice.destroyAnnotatedChannels(encodertemplate);
}
else if (useEncoder && (!useReadback)){
diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/EncoderChannelsTemplate.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/EncoderChannelsTemplate.java
index ef8cb63..fd5247d 100644
--- a/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/EncoderChannelsTemplate.java
+++ b/ch.psi.fda/src/main/java/ch/psi/fda/core/loops/cr/EncoderChannelsTemplate.java
@@ -19,7 +19,7 @@
package ch.psi.fda.core.loops.cr;
-import ch.psi.jcae.ChannelBean;
+import ch.psi.jcae.Channel;
import ch.psi.jcae.annotation.CaChannel;
/**
@@ -31,41 +31,41 @@ public class EncoderChannelsTemplate {
/**
* Resolution - $(P)$(E)_SCL
*/
- @CaChannel(type=Double.class, name="_SCL")
- private ChannelBean resolution;
+ @CaChannel(type=Double.class, name="${PREFIX}_SCL")
+ private Channel resolution;
/**
* Offset - $(P)$(E)_OFF
*/
- @CaChannel(type=Double.class, name ="_OFF")
- private ChannelBean offset;
+ @CaChannel(type=Double.class, name ="${PREFIX}_OFF")
+ private Channel offset;
/**
* Direction - $(P)$(E)_DIR
*/
public enum Direction {Negative, Positive};
- @CaChannel(type=Integer.class, name ="_DIR")
- private ChannelBean