Fixed compiler warnings
This commit is contained in:
3
ch.psi.fda/.settings/org.eclipse.core.resources.prefs
Normal file
3
ch.psi.fda/.settings/org.eclipse.core.resources.prefs
Normal file
@@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
@@ -582,7 +582,7 @@ public class Acquisition {
|
||||
timeout = Math.round(ca.getTimeout()*1000);
|
||||
}
|
||||
if(type.equals("String")){
|
||||
alist.add(new ChannelAccessConditionRegex<String>(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<Integer>(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<Integer>(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");
|
||||
|
||||
@@ -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<E extends Integer> 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<E extends Integer> implements Action {
|
||||
/**
|
||||
* Channel to set
|
||||
*/
|
||||
private final ChannelBean<E> channel;
|
||||
private final ChannelBean<Integer> channel;
|
||||
/**
|
||||
* Value to wait for
|
||||
*/
|
||||
private final E expectedValue;
|
||||
private final Integer expectedValue;
|
||||
|
||||
private final Long timeout;
|
||||
|
||||
@@ -62,14 +63,14 @@ public class ChannelAccessConditionAnd<E extends Integer> 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<E>) ChannelBeanFactory.getFactory().createChannelBean( (Class<E>) expectedValue.getClass(), channelName, false);
|
||||
this.channel = (ChannelBean<Integer>) ChannelBeanFactory.getFactory().createChannelBean( (Class<Integer>) 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<E extends Integer> implements Action {
|
||||
logger.finest("Checking channel "+channel.getName()+" for value "+expectedValue+" [timeout: "+timeout+"]" );
|
||||
try{
|
||||
waitT = Thread.currentThread();
|
||||
channel.waitForValue(expectedValue, new Comparator<E>() {
|
||||
channel.waitForValue(expectedValue, new Comparator<Integer>() {
|
||||
|
||||
@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){
|
||||
|
||||
@@ -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<E extends Integer> 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<E extends Integer> implements Action {
|
||||
/**
|
||||
* Channel to set
|
||||
*/
|
||||
private final ChannelBean<E> channel;
|
||||
private final ChannelBean<Integer> channel;
|
||||
/**
|
||||
* Value to wait for
|
||||
*/
|
||||
private final E expectedValue;
|
||||
private final Integer expectedValue;
|
||||
|
||||
private final Long timeout;
|
||||
|
||||
@@ -62,14 +63,14 @@ public class ChannelAccessConditionOr<E extends Integer> 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<E>) ChannelBeanFactory.getFactory().createChannelBean( (Class<E>) expectedValue.getClass(), channelName, false);
|
||||
this.channel = (ChannelBean<Integer>) ChannelBeanFactory.getFactory().createChannelBean( (Class<Integer>) 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<E extends Integer> implements Action {
|
||||
logger.finest("Checking channel "+channel.getName()+" for value "+expectedValue+" [timeout: "+timeout+"]" );
|
||||
try{
|
||||
waitT = Thread.currentThread();
|
||||
channel.waitForValue(expectedValue, new Comparator<E>() {
|
||||
channel.waitForValue(expectedValue, new Comparator<Integer>() {
|
||||
|
||||
@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){
|
||||
|
||||
@@ -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<E extends String> 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<E extends String> implements Action {
|
||||
/**
|
||||
* Channel to set
|
||||
*/
|
||||
private final ChannelBean<E> channel;
|
||||
private final ChannelBean<String> channel;
|
||||
/**
|
||||
* Value to wait for
|
||||
*/
|
||||
private final E expectedValue;
|
||||
private final String expectedValue;
|
||||
|
||||
private final Long timeout;
|
||||
|
||||
@@ -62,14 +62,14 @@ public class ChannelAccessConditionRegex<E extends String> 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<E>) ChannelBeanFactory.getFactory().createChannelBean( (Class<E>) expectedValue.getClass(), channelName, false);
|
||||
this.channel = (ChannelBean<String>) ChannelBeanFactory.getFactory().createChannelBean( (Class<String>) 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<E extends String> implements Action {
|
||||
logger.finest("Checking channel "+channel.getName()+" for value "+expectedValue+" [timeout: "+timeout+"]" );
|
||||
try{
|
||||
waitT = Thread.currentThread();
|
||||
channel.waitForValue(expectedValue, new Comparator<E>() {
|
||||
channel.waitForValue(expectedValue, new Comparator<String>() {
|
||||
|
||||
@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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ChannelAccessConditionTest {
|
||||
public void testChannelAccessStringConditionRegex() throws InterruptedException, CAException {
|
||||
final ChannelBean<String> channel = ChannelBeanFactory.getFactory().createChannelBean(String.class, TestChannels.STRING_OUT, false);
|
||||
channel.setValue("SomeValue");
|
||||
ChannelAccessConditionRegex<String> c = new ChannelAccessConditionRegex<String>(TestChannels.STRING_OUT, "Some.*", 1000l);
|
||||
ChannelAccessConditionRegex c = new ChannelAccessConditionRegex(TestChannels.STRING_OUT, "Some.*", 1000l);
|
||||
c.execute();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user