#ifndef RAWSCANOffline_H
#define RAWSCANOffline_H

#include "NDTSEnums.h"
#include "RawScan.h"

/*
*	 __cplusplus, __declspec(...), and __stdcall are Microsoft specific.
*/

#ifdef __cplusplus
extern "C" {
#endif



	typedef enum
	{
		RawScan_BOAdd,
		RawScan_BOSubtract,
		RawScan_BODivide,
		RawScan_BOMultiply,
		RawScan_BONop
	} RawScan_BinaryOperator ;

typedef enum
{
	RawScan_GMAbsDistance = 256,
	RawScan_GMAbsAmplitude,
	RawScan_GM0Distance,
	RawScan_GM0Amplitude,
	RawScan_GM1Distance,
	RawScan_GM1Amplitude,
	RawScan_GM2Distance,
	RawScan_GM2Amplitude,
	RawScan_GM3Distance,
	RawScan_GM3Amplitude,
	RawScan_GM4Distance,
	RawScan_GM4Amplitude,
	RawScan_GM5Distance,
	RawScan_GM5Amplitude,
	RawScan_GM6Distance,
	RawScan_GM6Amplitude,
	RawScan_GM7Distance,
	RawScan_GM7Amplitude,
	RawScan_GM8Distance,
	RawScan_GM8Amplitude,
	RawScan_GM9Distance,
	RawScan_GM9Amplitude,
	RawScan_GMNull
} RawScan_GateMetric ;


#define RawScan_MAXIMUM_RPN_SEQUENCE_LENGTH				256


	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractAScan(unsigned long bScanIndex, unsigned long aScanIndex, NDTS_RawScan *pRawScan, short *pAScan, unsigned long numberOfBufferValues) ;
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractBScan(unsigned long bScanIndex, NDTS_RawScan *pRawScan, short **ppBScan, unsigned long numberOfAScanPointers, unsigned long numberOfAScanBufferValues) ;
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractCScan(int *pRPNSequence, unsigned long bScanIndex, unsigned long numberOfBScans, NDTS_RawScan *pRawScan, NDTS_CScan *pRawCScan, unsigned long numberOfBufferRows, unsigned long numberOfBufferColumns) ;
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractGateValues(unsigned long bScanIndex, unsigned long aScanIndex, NDTS_RawScan *pRawScan, NDTS_GateOutput *pGateOutputs, unsigned long numberOfBufferValues) ;
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractEncoderValue(unsigned long bScanIndex, unsigned long encoderIndex, NDTS_RawScan *pRawScan, long *pEncoderValue) ;
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractEncoderValues(unsigned long bScanIndex, NDTS_RawScan *pRawScan, long *pEncoderValues, int numberOfEncodersInBuffer);
    
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractAScanPtr(unsigned long bScanIndex, unsigned long aScanIndex, NDTS_RawScan *pRawScan, short **ppAScan, unsigned long *pNumberOfAScanSamples) ;
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractBScanPtrs(unsigned long bScanIndex, NDTS_RawScan *pRawScan, short **ppBScan, unsigned long numberOfAScanPointers, unsigned long *pNumberOfAScanSamples) ;

	NDTS_Boolean RAW_SCAN_API CALL_CONV RawScan_CheckAScanHeader(unsigned long aScanHeader, unsigned long expectedAScanIndex, NDTS_Boolean *pIsIdentifierPresent) ;
	NDTS_Boolean RAW_SCAN_API CALL_CONV RawScan_CheckCScanHeader(unsigned long cScanHeader, unsigned long expectedCScanIndex, NDTS_Boolean *pIsIdentifierPresent) ;

	// This isn't a pure offline extract function as it pulls the requried AScan from the card rather than the rawScan, avoiding
	// the downloading of all the AScans from the card.
	// Now takes the gate data as input and only generates new gate values and copies A Scans if 
	// one of the gates in the raw scan fits the selection better than the existing gate values.
	// The raw scan is not padded with zeros but the minimum of the number of samples and the buffer size is copied.
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractFullBScanGateValuesSequenced(unsigned long bScanIndex, NDTS_RawScan *pRawScan, NDTS_GateOutput *pGateData, int nSteps, int nGates);
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractOneStepGateValuesSequenced(unsigned long bScanIndex, unsigned long stepIndex, NDTS_RawScan *pRawScan, NDTS_GateOutput *pGateData, int nGates);
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractOneStepLargeGateValuesSequenced(unsigned long bScanIndex, unsigned long stepIndex, NDTS_RawScan *pRawScan, NDTS_GateOutputLarge *pGateData, int nGates);
	RAW_SCAN_API NDTS_Boolean CALL_CONV RawScan_ExtractEncoderValuesProtected(unsigned long bScanIndex, NDTS_RawScan *pRawScan, long *pEncoderValues, int nEncoders);
	RAW_SCAN_API void RawScan_ExtractGateDepthValues(NDTS_RawScan *pRawScan, unsigned long channelIndex, short *pAmplitude, short *pDepth);
	RAW_SCAN_API void RawScan_ExtractGateAmplitudeValues(NDTS_RawScan *pRawScan, unsigned long channelIndex, short *pAmplitude, short *pDepth);
	RAW_SCAN_API NDTS_Boolean RawScan_ReturnIsSelectionGateDependent(NDTS_SnapshotDataSelection selection);
	RAW_SCAN_API int RawScan_ExtractSelectSpecificBScanIndex(NDTS_RawScan *pRawScan, unsigned long channelIndex, NDTS_SnapshotDataSelection selection, unsigned long gateIndex, short *pAmplitude, short *pDepth);

	RAW_SCAN_API void RawScan_FillRawScanWithTestAScanData(NDTS_RawScan *pRawScan);
	RAW_SCAN_API void RawScan_FillRawScanWithTestCScanData(NDTS_RawScan *pRawScan);

#ifdef __cplusplus
}
#endif


#endif
