use of org.eclipse.scanning.example.detector.MandelbrotModel in project gda-core by openGDA.
the class ScanRequestConverterTest method testUnknownDetector.
@Test(expected = IllegalArgumentException.class)
public void testUnknownDetector() throws Exception {
final String detName = "mandelbrot";
final String displayName = "Mandelbrot Detector";
final IDetectorModel detModel = new MandelbrotModel();
detModel.setName(detName);
mappingBean.setDetectorParameters(Arrays.asList(new DetectorModelWrapper(displayName, detModel, true)));
// Act - convert mapping bean to scan request
final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
// Assert
assertEquals(detModel, scanRequest.getDetectors().get(detName));
// Act again - convert scan request back to mapping bean, throws exception
scanRequestConverter.mergeIntoMappingBean(scanRequest, newMappingBean);
}
use of org.eclipse.scanning.example.detector.MandelbrotModel in project gda-core by openGDA.
the class MappingUISerializationTest method testSerializeDetectorModelWrapper.
@Test
public void testSerializeDetectorModelWrapper() throws Exception {
MandelbrotModel model = createMandelbrotModel();
DetectorModelWrapper detectorModelWrapper = new DetectorModelWrapper("Mandelbrot Detector", model, true);
String json = service.marshal(detectorModelWrapper);
DetectorModelWrapper newDetectorModelWrapper = service.unmarshal(json, DetectorModelWrapper.class);
assertEquals(detectorModelWrapper, newDetectorModelWrapper);
}
use of org.eclipse.scanning.example.detector.MandelbrotModel in project gda-core by openGDA.
the class MappingUISerializationTest method createMandelbrotModel.
private MandelbrotModel createMandelbrotModel() {
MandelbrotModel model = new MandelbrotModel();
model.setName("mandelbrot");
model.setRealAxisName("xNex");
model.setImaginaryAxisName("yNex");
model.setColumns(64);
model.setRows(64);
model.setMaxIterations(1);
model.setExposureTime(0.0);
return model;
}
use of org.eclipse.scanning.example.detector.MandelbrotModel in project gda-core by openGDA.
the class MappingUISerializationTest method testSerializeMappingExperimentBean.
@Test
public void testSerializeMappingExperimentBean() throws Exception {
ScriptFiles scriptFiles = new ScriptFiles();
scriptFiles.setBeforeScanScript("/path/to/before.py");
scriptFiles.setAfterScanScript("/path/to/after.py");
Map<String, Object> beamlineConfiguration = new HashMap<>();
beamlineConfiguration.put("D7A", "Gap");
beamlineConfiguration.put("D7B", "gap");
beamlineConfiguration.put("kb_vfm_x", "7.0");
MandelbrotModel model = createMandelbrotModel();
DetectorModelWrapper mandelbrotWrapper = new DetectorModelWrapper("Mandelbrot Detector", model, true);
SimpleSampleMetadata sampleMetadata = new SimpleSampleMetadata();
sampleMetadata.setSampleName("SampleName");
sampleMetadata.setDescription("Description of sample");
IScanDefinition scanDefinition = createScanDefinition();
MappingExperimentBean mappingBean = new MappingExperimentBean();
mappingBean.setScriptFiles(scriptFiles);
mappingBean.setBeamlineConfiguration(beamlineConfiguration);
mappingBean.setDetectorParameters(Arrays.asList(mandelbrotWrapper));
mappingBean.setSampleMetadata(sampleMetadata);
mappingBean.setScanDefinition(scanDefinition);
ConfigWrapper w = new ConfigWrapper();
w.setAppName("dawn");
w.setPathToConfig("/path/to/config.json");
mappingBean.addProcessingRequest(w);
String json = service.marshal(mappingBean);
MappingExperimentBean newMappingBean = service.unmarshal(json, MappingExperimentBean.class);
assertEquals(mappingBean, newMappingBean);
}
use of org.eclipse.scanning.example.detector.MandelbrotModel in project gda-core by openGDA.
the class ScannableNexusWrapperScanTest method before.
@Before
public void before() throws Exception {
final MandelbrotModel model = new MandelbrotModel();
model.setName("mandelbrot");
model.setRealAxisName(SCANNABLE_NAME_SALONG);
model.setImaginaryAxisName(SCANNABLE_NAME_SAPERP);
detector = TestDetectorHelpers.createAndConfigureMandelbrotDetector(model);
assertThat(detector, is(notNullValue()));
detector.addRunListener(IRunListener.createRunPerformedListener(event -> System.out.println("Ran mandelbrot detector @ " + event.getPosition())));
readLegacySpringConfig(TEST_CONFIG_FILE_PATH);
ServiceHolder.getNexusDataWriterConfiguration().setLocationMap(locationMap);
ServiceHolder.getNexusDataWriterConfiguration().setMetadataScannables(legacyMetadataScannables);
final Factory factory = TestHelpers.createTestFactory();
factory.addFindable(jythonServer);
factory.addFindable(new SampleAngleScannable(SCANNABLE_NAME_SALONG, false));
factory.addFindable(new SampleAngleScannable(SCANNABLE_NAME_SAPERP, true));
factory.addFindable(new DummyScannable("sax", 5.0, "BL00P-MO-SAMPLE-01:SAX"));
factory.addFindable(new DummyScannable("say", 23.4, "BL00P-MO-SAMPLE-01:SAY"));
factory.addFindable(new DummyScannable("satilt", 127.4));
factory.addFindable(new DummyScannable("saazimuth", 24.32));
factory.addFindable(new DummyScannable("s6_xsize", 2.92));
factory.addFindable(new DummyScannable("s2_ysize", 8.34));
factory.addFindable(new DummyScannable("s2_xsize", 1.66));
factory.addFindable(new DummyScannable("exit_slit", 0.0683, "BL00P-MO-SLIT-01:EXIT"));
factory.addFindable(new DummyEnergyScannable("pgm_cff", 123.45));
factory.addFindable(new DummyScannable("energy", 9.357e8));
factory.addFindable(new DummyScannable("pgm_linedensity", 28));
factory.addFindable(new DummyScannable("ring_current", 15.2, "SR-DI-DCCT-01:SIGNAL"));
factory.addFindable(new DummyScannable("ring_energy", 47.53, "CS-CS-MSTAT-01:BEAMENERGY"));
factory.addFindable(new DummyScannable("lc_pressure", 73.012));
factory.addFindable(new DummyStringScannable("sample_name", "name", "test sample"));
final DummyMultiFieldUnitsScannable<Temperature> cryostat = new DummyMultiFieldUnitsScannable<>("cryostat", "K");
cryostat.setInputNames(new String[] { "temperature_demand" });
cryostat.setExtraNames(new String[] { "cryostat_temperature", "temperature", "shield_temperature", "heater_percent", "heater_setting" });
cryostat.setCurrentPosition(20.0);
cryostat.setExtraFieldsPosition(19.9, 19.9, 26.5, 64.3, 15.3);
factory.addFindable(cryostat);
final DummyMultiFieldUnitsScannable<Length> id = new DummyMultiFieldUnitsScannable<>("id");
id.setScanMetadataAttribute(Scannable.ATTR_NX_CLASS, "NXinsertion_device");
// no input names
id.setInputNames(new String[0]);
id.setExtraNames(new String[] { "gap", "final_polarisation_label", "phase" });
id.setExtraFieldsPosition(20, "label", 60);
factory.addFindable(id);
final DummyMultiFieldUnitsScannable<Angle> sapolar = new DummyMultiFieldUnitsScannable<>("sapolar");
sapolar.setInputNames(new String[] { "alpha", "delta", "omicron" });
sapolar.setExtraNames(new String[0]);
sapolar.setCurrentPosition(0.5, 1.25, -0.75);
factory.addFindable(sapolar);
final DummyScannable attr = new DummyScannable("attributes", 2.5);
attr.setInputNames(new String[] { NXpositioner.NX_VALUE });
attr.setScanMetadataAttribute("stringAttr", "foo");
attr.setScanMetadataAttribute("doubleAttr", 123.456);
factory.addFindable(attr);
final DummyScannable beam = new DummyScannable("beam", 3.25);
beam.setInputNames(new String[] { "extent" });
beam.setScanMetadataAttribute(Scannable.ATTR_NX_CLASS, "NXbeam");
beam.setScanMetadataAttribute(Scannable.ATTR_NEXUS_CATEGORY, "NXsample");
factory.addFindable(beam);
Finder.addFactory(factory);
}
Aggregations