#ifndef RAWSCAN_H
#define RAWSCAN_H

#include "NDTSEnums.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef RAW_SCAN_EXPORTS
	#define RAW_SCAN_API __declspec(dllexport)
#else
	#define RAW_SCAN_API __declspec(dllimport)
#endif
 
#ifdef STDCALL
	#define CALL_CONV __stdcall
#else
	#define CALL_CONV
#endif

#define RAW_SCAN_GATE_TRIGGER_ABSOLUTE 15

	typedef struct
	{
		NDTS_SnapshotDataSelection snapshotSelection;
		NDTS_Boolean isGateEnabled;
		NDTS_Boolean isDistanceMetricPeak;
		NDTS_Boolean storeGateOnlyWhenTriggered;
		int triggerGate;
	} RawScanGateSettings;


	typedef struct
	{
		unsigned long cardIndex ;
		// True = PRX compatible sequence or 2100 where there can be a different range or gate settings for each step. False = DI unit array where settings are the same for each element.
		NDTS_Boolean isSequence ;

		// For non sequenced - this is the same number for each A Scan in a B Scan.
		// The Raw Scan does not need aScanSamplePeriodsThisStep[]
		unsigned long aScanSampleValuesThisStep[NDTS_MAXIMUM_NUMBER_OF_ELEMENTS];

		// The number of aScanSamples has been divided by this ammount because DropSamples were called
		// E.g. if DropSamples is called with 3, the number of samples is divided by 4
		unsigned long samplesDivider;

		// Number of active elements if array probe. Number of sequence steps if PRX.
		unsigned long numberOfAScansInBScan ;  
		// Number of b-scans in the raw scan.
		unsigned long numberOfBScans ;  // The number of B Scans in either the gate or full sample data
		unsigned long numberOfFullBScans;  // The number of captured B Scans (1 instead of numberOfBScans if ScanStorage is e.g. NDTS_SSOneBScanMultipleCScan)

		NDTS_ScanStorage scanStorage ;
		// Number of bits per sample.
		NDTS_SampleSize sampleSize ;

		// Indexed [sequence step][active gate number] - only sequence step zero is used if isSequence is false.
		RawScanGateSettings  ppGateSettings[NDTS_MAXIMUM_NUMBER_OF_ELEMENTS][NDTS_MAXIMUM_NUMBER_OF_GATES_COMPILE_TIME];
		unsigned long numberOfGates[NDTS_MAXIMUM_NUMBER_OF_ELEMENTS] ;  // Indexed by [sequence step]

		void *pInternal ;
	} NDTS_RawScan ;

	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_Initialise() ;
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_Uninitialise() ;

	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_InitialiseRawScan(NDTS_RawScan *pRawScan) ;
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_UninitialiseRawScan(NDTS_RawScan *pRawScan) ;
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ClearRawScan(NDTS_RawScan *pRawScan) ;
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_CopyRawScan(NDTS_RawScan *pDestination, NDTS_RawScan *pSource) ;
	RAW_SCAN_API void RawScan_ConvertRawScanFromSignMagToTwosComp(NDTS_RawScan *pRawScan);

#ifdef __cplusplus
}
#endif


#endif
