use of org.eclipse.scanning.api.event.IEventService 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.event.IEventService in project gda-core by openGDA.
the class PlanTest method setupBasicplan.
@Before
public void setupBasicplan() throws Exception {
plan = new Plan(EXPERIMENT_NAME);
sev = new MockSEV();
plan.setFactory(new TestFactory(sev));
plan.experimentController = mock(ExperimentController.class);
// TestFactory::addSEV returns our MockSEV
plan.addSEV(() -> 0.0);
// OSGi would usually set the following
IEventService eventService = mock(IEventService.class);
ExperimentRecord experimentRecord = new ExperimentRecord("");
experimentRecord.setEventService(eventService);
TestHelpers.setUpTest(PlanTest.class, "DontCare", true);
}
use of org.eclipse.scanning.api.event.IEventService in project gda-core by openGDA.
the class PlanBroadcastTest method mockOsgiInjection.
/**
* Give the plan an event service which creates our dummy publisher
*/
private void mockOsgiInjection() {
IEventService eventService = mock(IEventService.class);
publisher = new DummyPublisher();
doReturn(publisher).when(eventService).createPublisher(any(), eq(EXPERIMENT_PLAN_TOPIC));
ExperimentRecord experimentRecord = new ExperimentRecord("doesn't matter");
experimentRecord.setEventService(eventService);
}
use of org.eclipse.scanning.api.event.IEventService in project gda-core by openGDA.
the class ScannableNexusWrapperScanTest method setServices.
@BeforeClass
public static void setServices() throws Exception {
jythonServer = mock(JythonServer.class);
scannableDeviceService = new ScannableDeviceConnectorService();
// Not testing OSGi so using hard coded service.
scanService = new RunnableDeviceServiceImpl(scannableDeviceService);
pointGenService = new PointGeneratorService();
nexusFileFactory = new NexusFileFactoryHDF5();
final ActivemqConnectorService activemqConnectorService = new ActivemqConnectorService();
activemqConnectorService.setJsonMarshaller(new MarshallerService(new PointsModelMarshaller()));
final IEventService eservice = new EventServiceImpl(activemqConnectorService);
final Services services = new Services();
services.setEventService(eservice);
services.setRunnableDeviceService(scanService);
services.setGeneratorService(pointGenService);
services.setConnector(scannableDeviceService);
final INexusDeviceService nexusDeviceService = new NexusDeviceService();
new org.eclipse.dawnsci.nexus.ServiceHolder().setNexusFileFactory(nexusFileFactory);
final org.eclipse.scanning.sequencer.ServiceHolder serviceHolder = new org.eclipse.scanning.sequencer.ServiceHolder();
serviceHolder.setNexusDeviceService(nexusDeviceService);
serviceHolder.setNexusScanFileService(new NexusScanFileServiceImpl());
serviceHolder.setOperationService(new MockOperationService());
serviceHolder.setFilePathService(new MockFilePathService());
final org.eclipse.dawnsci.nexus.scan.ServiceHolder scanServiceHolder = new org.eclipse.dawnsci.nexus.scan.ServiceHolder();
scanServiceHolder.setNexusDeviceService(nexusDeviceService);
scanServiceHolder.setNexusBuilderFactory(new DefaultNexusBuilderFactory());
final org.eclipse.scanning.points.ServiceHolder pointsServiceHolder = new org.eclipse.scanning.points.ServiceHolder();
pointsServiceHolder.setValidatorService(new ValidatorService());
pointsServiceHolder.setPointGeneratorService(new PointGeneratorService());
}
use of org.eclipse.scanning.api.event.IEventService in project gda-core by openGDA.
the class FrameCollectingScannable method getRequester.
private IRequester<AcquireRequest> getRequester() throws EventException {
if (acquireRequester == null) {
final IEventService eventService = org.eclipse.scanning.sequencer.ServiceHolder.getEventService();
try {
final var uri = new URI(LocalProperties.getActiveMQBrokerURI());
acquireRequester = eventService.createRequestor(uri, EventConstants.ACQUIRE_REQUEST_TOPIC, EventConstants.ACQUIRE_RESPONSE_TOPIC);
acquireRequester.setTimeout(5, TimeUnit.SECONDS);
} catch (URISyntaxException e) {
throw new EventException(e);
}
}
return acquireRequester;
}
Aggregations