use of org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel in project gda-core by openGDA.
the class ScanpathTest method createModelCreatesCorrectModelForGrid.
@Test
public void createModelCreatesCorrectModelForGrid() throws Exception {
pathParams = Arrays.asList(5, 6);
IScanPathModel model = GRID_POINTS.createModel(scannables, pathParams, bboxParams, mutators);
assertThat(model, is(instanceOf(TwoAxisGridPointsModel.class)));
TwoAxisGridPointsModel gModel = (TwoAxisGridPointsModel) model;
assertThat(gModel.getScannableNames(), contains("name1", "name2"));
assertThat(gModel.getBoundingBox().getxAxisStart(), is(1.0));
assertThat(gModel.getBoundingBox().getyAxisStart(), is(2.0));
assertThat(gModel.getBoundingBox().getxAxisLength(), is(3.0));
assertThat(gModel.getBoundingBox().getyAxisLength(), is(4.0));
assertThat(gModel.getxAxisPoints(), is(5));
assertThat(gModel.getyAxisPoints(), is(6));
assertThat(gModel.getBoundingBox().getyAxisStart(), is(2.0));
assertThat(gModel.getOrientation(), is(Orientation.HORIZONTAL));
assertThat(gModel.isAlternating(), is(false));
assertThat(gModel.isContinuous(), is(false));
}
use of org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel in project gda-core by openGDA.
the class MappingUISerializationTest method createScanRegion.
private IMappingScanRegion createScanRegion() {
IMappingScanRegion scanRegion = new MappingScanRegion();
TwoAxisGridPointsModel gmodel = new TwoAxisGridPointsModel();
gmodel.setxAxisName("xNex");
gmodel.setxAxisPoints(50);
gmodel.setyAxisName("yNex");
gmodel.setyAxisPoints(20);
gmodel.setBoundingBox(new BoundingBox(0, 0, 3, 3));
RectangularMappingRegion region = new RectangularMappingRegion();
region.setxStart(10.0);
region.setxStop(20.0);
region.setyStart(5.5);
region.setyStop(13.2);
scanRegion.setScanPath(gmodel);
scanRegion.setRegion(region);
return scanRegion;
}
use of org.eclipse.scanning.api.points.models.TwoAxisGridPointsModel in project gda-core by openGDA.
the class ScannableNexusWrapperScanTest method createGridScan.
private IRunnableDevice<ScanModel> createGridScan(final IRunnableDevice<? extends IDetectorModel> detector, String outerScannableName, int... size) throws Exception {
// Create scan points for a grid and make a generator
final TwoAxisGridPointsModel gridModel = new TwoAxisGridPointsModel();
gridModel.setxAxisName("salong");
gridModel.setxAxisPoints(size[size.length - 1]);
gridModel.setyAxisName("saperp");
gridModel.setyAxisPoints(size[size.length - 2]);
gridModel.setBoundingBox(new BoundingBox(0, 0, 3, 3));
final CompoundModel compoundModel = new CompoundModel();
// We add the outer scans, if any
if (outerScannableName != null) {
for (int dim = 0; dim < size.length - 2; dim++) {
if (size[dim] > 1) {
// TODO outer scannable name(s)? could use cryostat temperature as an outer scan
compoundModel.addModel(new AxialStepModel(outerScannableName, 10000, 20000, 9999.99d / (size[dim] - 1)));
} else {
// Will generate one value at 10
compoundModel.addModel(new AxialStepModel(outerScannableName + (dim + 1), 10, 20, 30));
}
}
}
compoundModel.addModel(gridModel);
final IPointGenerator<CompoundModel> pointGen = pointGenService.createCompoundGenerator(compoundModel);
// Create the model for a scan
final ScanModel scanModel = new ScanModel();
scanModel.setPointGenerator(pointGen);
scanModel.setScanPathModel(compoundModel);
scanModel.setDetector(detector);
final IScannable<?> attributeScannable = scannableDeviceService.getScannable("attributes");
final IScannable<?> beamSizeScannable = scannableDeviceService.getScannable("beam");
scanModel.setMonitorsPerScan(attributeScannable, beamSizeScannable);
// Create a file to scan into
final File output = File.createTempFile("test_legacy_nexus", ".nxs");
output.deleteOnExit();
scanModel.setFilePath(output.getAbsolutePath());
System.out.println("File writing to " + scanModel.getFilePath());
// Create a scan and run it without publishing events
final IRunnableDevice<ScanModel> scanner = scanService.createScanDevice(scanModel);
final IPointGenerator<?> fgen = pointGen;
((IRunnableEventDevice<ScanModel>) scanner).addRunListener(new IRunListener() {
@Override
public void runWillPerform(RunEvent evt) throws ScanningException {
System.out.println("Running acquisition scan of size " + fgen.size());
}
});
return scanner;
}
Aggregations