use of org.eclipse.scanning.api.malcolm.IMalcolmDevice in project gda-core by openGDA.
the class EditMappingStageDialog method findMappingStageOptions.
private void findMappingStageOptions() {
// may be null if not configured for this beamline
options = getService(MappingStageOptions.class);
if (malcolmDeviceName.isPresent()) {
try {
final URI jmsURI = new URI(LocalProperties.getActiveMQBrokerURI());
final IEventService eventService = getService(IEventService.class);
IRunnableDeviceService runnableDeviceService = eventService.createRemoteService(jmsURI, IRunnableDeviceService.class);
IMalcolmDevice malcolmDevice = (IMalcolmDevice) (IRunnableDevice<?>) runnableDeviceService.getRunnableDevice(malcolmDeviceName.get());
List<String> availableAxes = new ArrayList<>(malcolmDevice.getAvailableAxes());
List<String> associatedAxes = null;
if (options != null) {
// Currently these are not Malcolm related
associatedAxes = options.getAssociatedAxes();
}
options = new MappingStageOptions();
options.setFastAxes(availableAxes);
options.setSlowAxes(availableAxes);
if (associatedAxes != null)
options.setAssociatedAxes(associatedAxes);
} catch (Exception e) {
MessageDialog.openError(getShell(), "", "Could not get available axes for malcolm device ''" + malcolmDeviceName.get() + "''");
}
}
}
use of org.eclipse.scanning.api.malcolm.IMalcolmDevice in project gda-core by openGDA.
the class FocusScanSetupPage method getMalcolmAxes.
private List<String> getMalcolmAxes(IMalcolmModel malcolmModel) throws ScanningException {
final String deviceName = malcolmModel.getName();
final IMalcolmDevice malcolmDevice = (IMalcolmDevice) (IRunnableDevice<?>) getRunnableDeviceService().getRunnableDevice(deviceName);
return malcolmDevice.getAvailableAxes();
}
use of org.eclipse.scanning.api.malcolm.IMalcolmDevice in project gda-core by openGDA.
the class ProcessingSelectionWizardPage method getDetectorDatasetNameForMalcolm.
/**
* Get the name of the dataset to use for the malcolm device with the given name. This is the
* first dataset of type 'primary' in the {@link MalcolmTable} of the {@link MalcolmConstants#ATTRIBUTE_NAME_DATASETS}
* attribute.
* @param malcolmModel
* @return
*/
private Optional<String> getDetectorDatasetNameForMalcolm(IMalcolmModel malcolmModel) {
if (malcolmDetectorDatasetNames != null && malcolmDetectorDatasetNames.containsKey(malcolmModel.getName())) {
return Optional.of(malcolmDetectorDatasetNames.get(malcolmModel.getName()));
}
Optional<String> datasetName = Optional.empty();
try {
final IRunnableDevice<IMalcolmModel> malcolmDevice = getRunnableDeviceService().getRunnableDevice(malcolmModel.getName());
if (malcolmDevice.getDeviceState() != DeviceState.READY) {
throw new ScanningException("The malcolm device is not ready. A scan may be running.");
}
try {
// configure the malcolm device, puts it in 'Armed' state
malcolmDevice.configure(malcolmModel);
if (malcolmDevice instanceof IMalcolmDevice) {
final MalcolmTable datasetsTable = ((IMalcolmDevice) malcolmDevice).getDatasets();
if (datasetsTable != null) {
datasetName = getPrimaryDatasetNameForMalcolm(datasetsTable);
}
}
if (datasetName.isPresent()) {
// if we found the dataset name, cache it
logger.debug("Got ''{}'' as dataset for processing for malcolm device ''{}''", datasetName.get(), malcolmModel.getName());
if (malcolmDetectorDatasetNames == null) {
malcolmDetectorDatasetNames = new HashMap<>(4);
}
malcolmDetectorDatasetNames.put(malcolmModel.getName(), datasetName.get());
} else {
logger.error("Could not get primary dataset for malcolm device ''{}''. The dataset for the malcolm device may not be set correctly.", malcolmModel.getName());
}
} finally {
// Reset the malcolm device back to the 'Ready' state
malcolmDevice.reset();
}
} catch (Exception e) {
logger.error("Could not get primary dataset for malcolm device: " + malcolmModel.getName(), e);
}
return datasetName;
}
Aggregations