-
Notifications
You must be signed in to change notification settings - Fork 5
Instrument Ready Manager_137625720
nxi edited this page Apr 9, 2015
·
1 revision
Created by Tony Lam, last modified on Jan 13, 2010
It is usual for GumTree to check if the instrument is ready when certain operation is performed. For example, users may want to check if the shutter is opened when batched execution is about to run. However, SICS does not have the notion of "instrument ready", and it may mean differently for different instruments.
Here we introduce the instrument ready manager API. The API contains a simple method "isInstrumentReady()":
The manager returns a status object to state either the instrument is ready or not. It also contains a list of reasons if the instrument is not ready. In the user interface, you can print out all reasons in a message dialog like this:
When the manager org.gumtree.gumnix.sics.core.IInstrumentReadyCriterion from the OSGi service registry, and run each criterion to see if the instrument is ready. To add a new criterion, simply create a new class and implements IInstrumentReadyCriterion. This new class needs to register to the OSGi service registry (programmatically or via declarative service like Spring-DM/OSGi-DS).
Example:
Note: There is a problem using the OSGi service if the instrument specific plug-in isn't activated when the instrument ready manager is called. In both Spring-DM and OSGi Declarative Services, the service registration is performed when the plug-in is activated. The solution to this problem is to make the plug-in active. Fortunately with OSGi DS, you can make the plug-in active when the DS definition is loaded.
IInstrumentReadyManager manager = GTPlatform.getService(IInstrumentReadyManager.class); IInstrumentReadyStatus status = manager.isInstrumentReady();
if (!status.isInstrumentReady()) {
// Prepare message
StringBuilder builder = new StringBuilder();
builder.append("Instrument is not ready due to the following reasons:\n");
for (String message : status.getMessages()) {
builder.append(" * " + message + "\n");
}
// Pop up dialog
MessageDialog.openWarning(getShell(), "Instrument is not ready", builder.toString());
}
public IInstrumentReadyStatus checkInstrumentReady() {
IDataAccessManager dam = GTPlatform.getService(IDataAccessManager.class);
try {
String shutterState = dam.get(
URI.create("sics://hdb/instrument/status/secondary"),
String.class);
if (shutterState.equals("Opened")) {
return InstrumentReadyStatus.READY_STATUS;
} else {
return new InstrumentReadyStatus(
false, "Shutter information is missing");
}
} catch (Exception e) {
return new InstrumentReadyStatus(
false, "Shutter information is missing");
}
}
}
Document generated by Confluence on Apr 01, 2015 00:11
Home | Developer Guide | Copyright © 2013 ANSTO