<commit_before>package org.eclipse.scanning.example.detector;

import org.eclipse.dawnsci.analysis.api.dataset.IDataset;
import org.eclipse.dawnsci.analysis.api.dataset.ILazyWriteableDataset;
import org.eclipse.dawnsci.analysis.api.dataset.SliceND;
import org.eclipse.dawnsci.analysis.dataset.impl.Dataset;
import org.eclipse.dawnsci.analysis.dataset.impl.Random;
import org.eclipse.dawnsci.nexus.INexusDevice;
import org.eclipse.dawnsci.nexus.NXdetector;
import org.eclipse.dawnsci.nexus.NXobject;
import org.eclipse.dawnsci.nexus.NexusBaseClass;
import org.eclipse.dawnsci.nexus.NexusScanInfo;
import org.eclipse.dawnsci.nexus.builder.DelegateNexusProvider;
import org.eclipse.dawnsci.nexus.builder.NexusObjectProvider;
import org.eclipse.dawnsci.nexus.impl.NXdetectorImpl;
import org.eclipse.dawnsci.nexus.impl.NexusNodeFactory;
import org.eclipse.scanning.api.event.scan.DeviceState;
import org.eclipse.scanning.api.points.IPosition;
import org.eclipse.scanning.api.scan.AbstractRunnableDevice;
import org.eclipse.scanning.api.scan.IWritableDetector;
import org.eclipse.scanning.api.scan.ScanningException;

/**
 * This device mimicks telling EPICS to do a constant velcity scan down a line.
 * It basically is like a 1D malcolm device running in a scan. This allows I18
 * to continue doing a CVscan with the new scanning for mapping by creating a 
 * device to do the cv scan.
 * 
 * It writes an HDF5 file for the line (actually random data)
 * 
 * @author <NAME>
 *
 */
public class ConstantVelocityDevice extends AbstractRunnableDevice<ConstantVelocityModel> implements IWritableDetector<ConstantVelocityModel>, INexusDevice {

	private ILazyWriteableDataset context;
	private IDataset              data;

	@Override
	public NexusObjectProvider<NXdetector> getNexusProvider(NexusScanInfo info) {
		return new DelegateNexusProvider<NXdetector>(getName(), NexusBaseClass.NX_DETECTOR, info, this);
	}

	@Override
	public NXdetector createNexusObject(NexusNodeFactory nodeFactory, NexusScanInfo info) {
		
		final NXdetectorImpl detector = nodeFactory.createNXdetector();
		// We add 2 to the scan rank to include the image
		int rank = info.getRank()+3; // scan rank plus three dimensions for the CV scan.
		
		context = detector.initializeLazyDataset(NXdetectorImpl.NX_DATA, rank, Dataset.FLOAT64);
		
		// Setting chunking is a very good idea if speed is required.
		int[] chunk = info.createChunk(model.getLineSize(), model.getChannelCount(), model.getSpectraSize());<commit_msg>Fixed interface declaration.<commit_after>package org.eclipse.scanning.example.detector;

import org.eclipse.dawnsci.analysis.api.dataset.IDataset;
import org.eclipse.dawnsci.analysis.api.dataset.ILazyWriteableDataset;
import org.eclipse.dawnsci.analysis.api.dataset.SliceND;
import org.eclipse.dawnsci.analysis.dataset.impl.Dataset;
import org.eclipse.dawnsci.analysis.dataset.impl.Random;
import org.eclipse.dawnsci.nexus.INexusDevice;
import org.eclipse.dawnsci.nexus.NXdetector;
import org.eclipse.dawnsci.nexus.NXobject;
import org.eclipse.dawnsci.nexus.NexusBaseClass;
import org.eclipse.dawnsci.nexus.NexusNodeFactory;
import org.eclipse.dawnsci.nexus.NexusScanInfo;
import org.eclipse.dawnsci.nexus.builder.DelegateNexusProvider;
import org.eclipse.dawnsci.nexus.builder.NexusObjectProvider;
import org.eclipse.scanning.api.event.scan.DeviceState;
import org.eclipse.scanning.api.points.IPosition;
import org.eclipse.scanning.api.scan.AbstractRunnableDevice;
import org.eclipse.scanning.api.scan.IWritableDetector;
import org.eclipse.scanning.api.scan.ScanningException;

/**
 * This device mimicks telling EPICS to do a constant velcity scan down a line.
 * It basically is like a 1D malcolm device running in a scan. This allows I18
 * to continue doing a CVscan with the new scanning for mapping by creating a 
 * device to do the cv scan.
 * 
 * It writes an HDF5 file for the line (actually random data)
 * 
 * @author <NAME>
 *
 */
public class ConstantVelocityDevice extends AbstractRunnableDevice<ConstantVelocityModel> implements IWritableDetector<ConstantVelocityModel>, INexusDevice {

	private ILazyWriteableDataset context;
	private IDataset              data;

	@Override
	public NexusObjectProvider<NXdetector> getNexusProvider(NexusScanInfo info) {
		return new DelegateNexusProvider<NXdetector>(getName(), NexusBaseClass.NX_DETECTOR, info, this);
	}

	@Override
	public NXdetector createNexusObject(NexusNodeFactory nodeFactory, NexusScanInfo info) {
		
		final NXdetector detector = nodeFactory.createNXdetector();
		// We add 2 to the scan rank to include the image
		int rank = info.getRank()+3; // scan rank plus three dimensions for the CV scan.
		
		context = detector.initializeLazyDataset(NXdetector.NX_DATA, rank, Dataset.FLOAT64);
		
		// Setting chunking is a very good idea if speed is required.
		int[] chunk = info.createChunk(model.getLineSize(), model.getChannelCount(), model.getSpectraSize());
{'fraction_non_alphanumeric': 0.08895207148659626, 'fraction_numerical': 0.003249390739236393, 'mean_word_length': 5.412760416666667, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '145666', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1521, 'n_words': 361}