/******************************************************************************
 *
 *	NDT Solutions RapiDAQ Software Development Kit v1.0beta
 *
 ******************************************************************************
 *
 *  File:        RQOffline.h.
 *
 *  Description: Extract functions that work on previoulsly captured raw scan data
 *
 *
 ******************************************************************************/



#ifndef RQOfflineInternal_H
#define RQOfflineInternal_H



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

#ifdef __cplusplus
extern "C" {
#endif

#include "RQOffline.h"
#include "RQError.h"

typedef struct
{
	NDTS_Boolean *pIsThisSampleNoise ;
	unsigned long sampleNoiseSize  ;
	RQ_ReturnCode offlineErrorCode ;
} RQOffline_State ;

RQOffline_State *pOfflineState ;


NDTS_Boolean RQOffline_Initialise() ;
NDTS_Boolean RQOffline_Uninitialise() ;
void RQOffline_BuildNoiseArray(RQ_RawScan *pRawScan, unsigned long channelIndex, unsigned long gateIndex) ;
int RQ_ExtractSelectSpecificBScanIndex(RQ_RawScan *pRawScan, unsigned long channelIndex, RQ_SnapshotDataSelection selection, unsigned long gateIndex, short *pAmplitude, short *pDepth);
short RQ_ExtractGateAmplitudeValue(RQ_RawScan *pRawScan,  unsigned long bscan, unsigned long channelIndex, unsigned long gateIndex);
short RQ_ExtractGateDepthValue(RQ_RawScan *pRawScan, unsigned long bscan, unsigned long channelIndex, unsigned long gateIndex);
// Not a pure offline extract function.  Downloads the AScan from the card if a better match is found.
// Only extract if the selection is a better match than the existing contents of *pAmplitude / *pDepth
NDTS_Boolean RQ_ExtractSpecificAScan(unsigned long cardIndex,RQ_RawScan *pRawScan, unsigned long channel, unsigned long gateIndex, short *pBuffer, unsigned long scanBufferBytes, short *pAmplitude, short *pDepth);
void RQ_ExtractGateDepthValues(RQ_RawScan *pRawScan, unsigned long channelIndex, short *pAmplitude, short *pDepth);
void RQ_ExtractGateAmplitudeValues(RQ_RawScan *pRawScan, unsigned long channelIndex, short *pAmplitude, short *pDepth);
void RQ_ExtractIsThisSampleNoiseArray(RQ_RawScan *pRawScan, unsigned long channelIndex, unsigned long gateIndex, NDTS_Boolean* pNoiseArray) ;
RQ_GateOutput RQ_ExtractReturnGateValue(RQ_RawScan *pRawScan, unsigned long bScanIndex, unsigned long aScanIndex, unsigned long gateIndex, unsigned long overSampleIndex) ;
NDTS_Boolean RQ_ExtractIsGateValueValid(RQ_RawScan *pRawScan, unsigned long bScanIndex, unsigned long step, unsigned long gateIndex, NDTS_Boolean isMetricAmplitude, unsigned long overSampleIndex);
NDTS_Boolean RQ_ReturnIsSelectionGateDependent(RQ_SnapshotDataSelection selection);
RQ_API NDTS_Boolean CALL_CONV RQ_ExtractGateValuesSequenced(unsigned long bScanIndex, RQ_RawScan *pRawScan, RQ_GateOutput *pGateData, int nSteps, int nGates);
RQ_API NDTS_Boolean CALL_CONV RQ_ExtractEncoderValuesProtected(unsigned long bScanIndex, RQ_RawScan *pRawScan, long *pEncoderValues, int nEncoders);

#ifdef __cplusplus
}
#endif


#endif
