Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart loops control offset #77

Merged
merged 8 commits into from
Apr 12, 2024
2 changes: 2 additions & 0 deletions epics-service/src/main/java/edu/gemini/epics/EpicsReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public interface EpicsReader {

<T extends Enum<T>> ReadOnlyClientEpicsChannel<T> getEnumChannel(String channelName, Class<T> enumClass);

ReadOnlyClientEpicsChannel<Short> getEnumAsShortChannel(String channelName);

ReadOnlyClientEpicsChannel<?> getChannelAsync(String channelName);

void destroyChannel(ReadOnlyClientEpicsChannel<?> channel) throws CAException;
Expand Down
3 changes: 3 additions & 0 deletions epics-service/src/main/java/edu/gemini/epics/EpicsWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public interface EpicsWriter extends EpicsReader {
@Override
<T extends Enum<T>> ReadWriteClientEpicsChannel<T> getEnumChannel(String channelName, Class<T> enumClass);

@Override
ReadWriteClientEpicsChannel<Short> getEnumAsShortChannel(String channelName);

@Override
ReadWriteClientEpicsChannel<?> getChannelAsync(String channelName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,23 @@ protected <T extends Enum<T>> ReadWriteEpicsEnumChannel<T> _getEnumChannel(Strin
return ch;
}

protected ReadWriteEpicsChannelImpl<Short> _getEnumAsShortChannel(String channelName) {
ReadWriteEpicsChannelImpl<Short> ch;

CAJChannel cajChannel = bindChannel(channelName);
if (!cajChannel.getFieldType().isENUM()) {
try {
cajChannel.destroy();
} catch (CAException e) {
LOG.log(Level.WARNING, e.getMessage(), e);
}
throw new IllegalArgumentException("Channel " + channelName + " can be connected to, but is of incorrect type.");
} else {
ch = new ReadWriteEpicsChannelImpl<Short>(cajChannel, timeout, readRetries);
}
return ch;
}

protected ReadWriteEpicsChannelImpl<?> _getChannelAsync(String channelName) {
CAJChannel cajChannel = bindChannelAsync(channelName, null);
ReadWriteEpicsChannelImpl<?> ch = new ReadWriteEpicsChannelImpl(cajChannel, timeout, readRetries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public <T extends Enum<T>> ReadOnlyClientEpicsChannel<T> getEnumChannel(String c
return _getEnumChannel(channelName, enumClass);
}

@Override
public ReadOnlyClientEpicsChannel<Short> getEnumAsShortChannel(String channelName) {
return _getEnumAsShortChannel(channelName);
}

@Override
public ReadOnlyClientEpicsChannel<?> getChannelAsync(String channelName) {
return _getChannelAsync(channelName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public <T extends Enum<T>> ReadWriteClientEpicsChannel<T> getEnumChannel(String
return _getEnumChannel(channelName, enumClass);
}

@Override
public ReadWriteClientEpicsChannel<Short> getEnumAsShortChannel(String channelName) {
return _getEnumAsShortChannel(channelName);
}

@Override
public ReadWriteClientEpicsChannel<?> getChannelAsync(String channelName) {
return _getChannelAsync(channelName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void setValue(List<T> values) throws CAException, TimeoutException {
arr[i] = list.get(i);
}
channel.put(arr);
} else if (getType().isSHORT()) {
} else if (getType().isSHORT() || getType().isENUM() ) {
List<Short> list = (List<Short>) values;
short arr[] = new short[list.size()];
for (int i = 0; i < list.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import javax.jms.JMSException;
import javax.jms.Message;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ public <T extends Enum<T>> ReadOnlyClientEpicsChannel<T> getEnumChannel(String c
throw new UnsupportedOperationException();
}

@Override
public ReadOnlyClientEpicsChannel<Short> getEnumAsShortChannel(String channelName) {
throw new UnsupportedOperationException();
}

@Override
public ReadOnlyClientEpicsChannel<?> getChannelAsync(String channel) throws EpicsException {
throw new UnsupportedOperationException();
Expand Down
Loading
Loading