diff --git a/ch.psi.fda/.settings/org.eclipse.core.resources.prefs b/ch.psi.fda/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..5b781ec --- /dev/null +++ b/ch.psi.fda/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 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 9122c49..b5d6edb 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 @@ -582,7 +582,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(ca.getChannel(), ca.getValue(), timeout)); } else{ logger.warning("Operation "+operation+" wity type "+type+" for action is not supported"); @@ -595,7 +595,7 @@ public class Acquisition { } if(type.equals("Integer")){ - alist.add(new ChannelAccessConditionOr(ca.getChannel(), new Integer(ca.getValue()), timeout)); + alist.add(new ChannelAccessConditionOr(ca.getChannel(), new Integer(ca.getValue()), timeout)); } else{ logger.warning("Operation "+operation+" wity type "+type+" for action is not supported"); @@ -607,7 +607,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(ca.getChannel(), new Integer(ca.getValue()), timeout)); } else { logger.warning("Operation "+operation+" wity type "+type+" for action is not supported"); 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..07bf441 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 @@ -28,12 +28,13 @@ import ch.psi.jcae.ChannelBean; import ch.psi.jcae.ChannelBeanFactory; /** - * Perform a put on the specified Channel Access channel. The put can be done synchronous or - * asynchronously. + * Condition a channnel needs to match + * Only accepts channels of type Integer + * * @author ebner * */ -public class ChannelAccessConditionAnd implements Action { +public class ChannelAccessConditionAnd implements Action { // Get Logger private static Logger logger = Logger.getLogger(ChannelAccessConditionAnd.class.getName()); @@ -41,11 +42,11 @@ public class ChannelAccessConditionAnd implements Action { /** * Channel to set */ - private final ChannelBean channel; + private final ChannelBean channel; /** * Value to wait for */ - private final E expectedValue; + private final Integer expectedValue; private final Long timeout; @@ -62,14 +63,14 @@ public class ChannelAccessConditionAnd implements Action { * Timeout specified is not >=0 */ @SuppressWarnings("unchecked") - public ChannelAccessConditionAnd(String channelName, E expectedValue, Long timeout){ + public ChannelAccessConditionAnd(String channelName, Integer 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); + 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); @@ -101,10 +102,10 @@ public class ChannelAccessConditionAnd implements Action { logger.finest("Checking channel "+channel.getName()+" for value "+expectedValue+" [timeout: "+timeout+"]" ); try{ waitT = Thread.currentThread(); - channel.waitForValue(expectedValue, new Comparator() { + channel.waitForValue(expectedValue, new Comparator() { @Override - public int compare(E o1, E o2) { + public int compare(Integer o1, Integer o2) { int one = o1; int two = o2; if((one & two) != 0){ 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..e8c4ae6 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 @@ -28,12 +28,13 @@ import ch.psi.jcae.ChannelBean; import ch.psi.jcae.ChannelBeanFactory; /** - * Perform a put on the specified Channel Access channel. The put can be done synchronous or - * asynchronously. + * Or condition of a channel + * Only supports Integer values and channel + * * @author ebner * */ -public class ChannelAccessConditionOr implements Action { +public class ChannelAccessConditionOr implements Action { // Get Logger private static Logger logger = Logger.getLogger(ChannelAccessConditionOr.class.getName()); @@ -41,11 +42,11 @@ public class ChannelAccessConditionOr implements Action { /** * Channel to set */ - private final ChannelBean channel; + private final ChannelBean channel; /** * Value to wait for */ - private final E expectedValue; + private final Integer expectedValue; private final Long timeout; @@ -62,14 +63,14 @@ public class ChannelAccessConditionOr implements Action { * Timeout specified is not >=0 */ @SuppressWarnings("unchecked") - public ChannelAccessConditionOr(String channelName, E expectedValue, Long timeout){ + public ChannelAccessConditionOr(String channelName, Integer 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); + 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); @@ -101,10 +102,10 @@ public class ChannelAccessConditionOr implements Action { logger.finest("Checking channel "+channel.getName()+" for value "+expectedValue+" [timeout: "+timeout+"]" ); try{ waitT = Thread.currentThread(); - channel.waitForValue(expectedValue, new Comparator() { + channel.waitForValue(expectedValue, new Comparator() { @Override - public int compare(E o1, E o2) { + public int compare(Integer o1, Integer o2) { int one = o1; int two = o2; if((one | two) != 0){ 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..cda3915 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 @@ -28,12 +28,12 @@ import ch.psi.jcae.ChannelBean; import ch.psi.jcae.ChannelBeanFactory; /** - * Perform a put on the specified Channel Access channel. The put can be done synchronous or - * asynchronously. + * Regex condition + * Only supports String value/channel. * @author ebner * */ -public class ChannelAccessConditionRegex implements Action { +public class ChannelAccessConditionRegex implements Action { // Get Logger private static Logger logger = Logger.getLogger(ChannelAccessConditionRegex.class.getName()); @@ -41,11 +41,11 @@ public class ChannelAccessConditionRegex implements Action { /** * Channel to set */ - private final ChannelBean channel; + private final ChannelBean channel; /** * Value to wait for */ - private final E expectedValue; + private final String expectedValue; private final Long timeout; @@ -62,14 +62,14 @@ public class ChannelAccessConditionRegex implements Action { * Timeout specified is not >=0 */ @SuppressWarnings("unchecked") - public ChannelAccessConditionRegex(String channelName, E expectedValue, Long timeout){ + public ChannelAccessConditionRegex(String channelName, String 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); + 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); @@ -101,10 +101,10 @@ public class ChannelAccessConditionRegex implements Action { logger.finest("Checking channel "+channel.getName()+" for value "+expectedValue+" [timeout: "+timeout+"]" ); try{ waitT = Thread.currentThread(); - channel.waitForValue(expectedValue, new Comparator() { + channel.waitForValue(expectedValue, new Comparator() { @Override - public int compare(E o1, E o2) { + public int compare(String o1, String o2) { return o1.matches(o2) ? 0:1; } }, timeout); // Workaround use 10seconds default set timeout to check several times whether the channel has reached the value diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/notification/NotificationAgent.java b/ch.psi.fda/src/main/java/ch/psi/fda/notification/NotificationAgent.java index eb76715..1a16db8 100644 --- a/ch.psi.fda/src/main/java/ch/psi/fda/notification/NotificationAgent.java +++ b/ch.psi.fda/src/main/java/ch/psi/fda/notification/NotificationAgent.java @@ -32,8 +32,7 @@ import javax.mail.internet.MimeMessage; import ch.psi.fda.model.v1.Recipient; /** - * This is a copy of the NotificationAgent class that should go into the foundation classes - * This actually should be extracted to an own project + * Agent to send out notifications to specified recipients. * @author ebner */ public class NotificationAgent { diff --git a/ch.psi.fda/src/test/java/ch/psi/fda/core/actions/ChannelAccessConditionTest.java b/ch.psi.fda/src/test/java/ch/psi/fda/core/actions/ChannelAccessConditionTest.java index d1c8ab7..155a409 100644 --- a/ch.psi.fda/src/test/java/ch/psi/fda/core/actions/ChannelAccessConditionTest.java +++ b/ch.psi.fda/src/test/java/ch/psi/fda/core/actions/ChannelAccessConditionTest.java @@ -74,7 +74,7 @@ public class ChannelAccessConditionTest { public void testChannelAccessStringConditionRegex() throws InterruptedException, CAException { final ChannelBean channel = ChannelBeanFactory.getFactory().createChannelBean(String.class, TestChannels.STRING_OUT, false); channel.setValue("SomeValue"); - ChannelAccessConditionRegex c = new ChannelAccessConditionRegex(TestChannels.STRING_OUT, "Some.*", 1000l); + ChannelAccessConditionRegex c = new ChannelAccessConditionRegex(TestChannels.STRING_OUT, "Some.*", 1000l); c.execute(); }