Search in sources :

Example 1 with IEventService

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() + "''");
        }
    }
}
Also used : IRunnableDeviceService(org.eclipse.scanning.api.device.IRunnableDeviceService) ArrayList(java.util.ArrayList) MappingStageOptions(uk.ac.diamond.daq.mapping.impl.MappingStageOptions) IMalcolmDevice(org.eclipse.scanning.api.malcolm.IMalcolmDevice) IEventService(org.eclipse.scanning.api.event.IEventService) URI(java.net.URI)

Example 2 with IEventService

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);
}
Also used : ExperimentController(uk.ac.diamond.daq.experiment.api.structure.ExperimentController) IEventService(org.eclipse.scanning.api.event.IEventService) Before(org.junit.Before)

Example 3 with IEventService

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);
}
Also used : IEventService(org.eclipse.scanning.api.event.IEventService)

Example 4 with IEventService

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());
}
Also used : RunnableDeviceServiceImpl(org.eclipse.scanning.sequencer.RunnableDeviceServiceImpl) ServiceHolder(gda.data.ServiceHolder) IPointGeneratorService(org.eclipse.scanning.api.points.IPointGeneratorService) PointGeneratorService(org.eclipse.scanning.points.PointGeneratorService) NexusFileFactoryHDF5(org.eclipse.dawnsci.hdf5.nexus.NexusFileFactoryHDF5) MockOperationService(org.eclipse.scanning.test.utilities.scan.mock.MockOperationService) ValidatorService(org.eclipse.scanning.points.validation.ValidatorService) JythonServer(gda.jython.JythonServer) NexusDeviceService(org.eclipse.dawnsci.nexus.device.impl.NexusDeviceService) INexusDeviceService(org.eclipse.dawnsci.nexus.device.INexusDeviceService) INexusDeviceService(org.eclipse.dawnsci.nexus.device.INexusDeviceService) EventServiceImpl(org.eclipse.scanning.event.EventServiceImpl) IEventService(org.eclipse.scanning.api.event.IEventService) ActivemqConnectorService(org.eclipse.scanning.connector.activemq.ActivemqConnectorService) MockFilePathService(org.eclipse.scanning.example.file.MockFilePathService) MarshallerService(org.eclipse.dawnsci.json.MarshallerService) PointsModelMarshaller(org.eclipse.scanning.points.serialization.PointsModelMarshaller) NexusScanFileServiceImpl(org.eclipse.dawnsci.nexus.scan.impl.NexusScanFileServiceImpl) DefaultNexusBuilderFactory(org.eclipse.dawnsci.nexus.builder.impl.DefaultNexusBuilderFactory) Services(org.eclipse.scanning.server.servlet.Services) BeforeClass(org.junit.BeforeClass)

Example 5 with IEventService

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;
}
Also used : EventException(org.eclipse.scanning.api.event.EventException) IEventService(org.eclipse.scanning.api.event.IEventService) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

IEventService (org.eclipse.scanning.api.event.IEventService)12 URI (java.net.URI)8 EventException (org.eclipse.scanning.api.event.EventException)7 URISyntaxException (java.net.URISyntaxException)5 IRunnableDeviceService (org.eclipse.scanning.api.device.IRunnableDeviceService)2 ServiceHolder (gda.data.ServiceHolder)1 JythonServer (gda.jython.JythonServer)1 ArrayList (java.util.ArrayList)1 PostConstruct (javax.annotation.PostConstruct)1 NexusFileFactoryHDF5 (org.eclipse.dawnsci.hdf5.nexus.NexusFileFactoryHDF5)1 MarshallerService (org.eclipse.dawnsci.json.MarshallerService)1 DefaultNexusBuilderFactory (org.eclipse.dawnsci.nexus.builder.impl.DefaultNexusBuilderFactory)1 INexusDeviceService (org.eclipse.dawnsci.nexus.device.INexusDeviceService)1 NexusDeviceService (org.eclipse.dawnsci.nexus.device.impl.NexusDeviceService)1 NexusScanFileServiceImpl (org.eclipse.dawnsci.nexus.scan.impl.NexusScanFileServiceImpl)1 IBeanListener (org.eclipse.scanning.api.event.bean.IBeanListener)1 QueueCommandBean (org.eclipse.scanning.api.event.queue.QueueCommandBean)1 ScanBean (org.eclipse.scanning.api.event.scan.ScanBean)1 IMalcolmDevice (org.eclipse.scanning.api.malcolm.IMalcolmDevice)1 IPointGeneratorService (org.eclipse.scanning.api.points.IPointGeneratorService)1