#pragma once
// Gates copied from RQ_Structs.h to support the legacy gates interface
#include "NDTSRS2A.h"


// Remove these includes if using the definitions below
#include "RQ.h"

/* Need to use the acutal include files because the same IW code is used to build the RS2A and the PRX
typedef enum
{
	NDTS_BFalse,
	NDTS_BTrue
} NDTS_Boolean ;

typedef enum 
{
	RQ_GIGate0,
	RQ_GIGate1,
	RQ_GIGate2,
	RQ_GIGate3,
	RQ_GIGate4,
	RQ_GIGate5,
	RQ_GIGate6,
	RQ_GIGate7,
	RQ_GIGate8,
	RQ_GIGate9,
	RQ_GIGateCurved = 7
} RQ_GateIndex ;

typedef enum 
{
	RQ_GTGate0,
	RQ_GTGate1,
	RQ_GTGate2,
	RQ_GTGate3,
	RQ_GTGate4,
	RQ_GTGate5,
	RQ_GTGate6,
	RQ_GTGate7,
	RQ_GTGate8,
	RQ_GTGate9,
	RQ_GTGateCurved = 7,
	RQ_GTAbsolute = 15, 
	RQ_GTLastPlusOne
} RQ_GateTrigger ;

typedef enum 
{
	RQ_GTPBipolar,
	RQ_GTPPositive,
	RQ_GTPNegative, 
	RQ_GTPLastPlusOne, 
} RQ_GateThresholdPolarity ;

typedef enum 
{
	RQ_GTMLevel,
	RQ_GTMEdge,
	RQ_GTMLastPlusOne
} RQ_GateTriggerMode ;

typedef enum
{
	RQ_GDMLeadingFlank,
	RQ_GDMTrailingFlank,
	RQ_GDMPeak, 
	RQ_GDMLeadingZeroCrossing,
	RQ_GDMTrailingZeroCrossing,

} RQ_GateDistanceMetric ;

typedef enum 
{
	RQ_GAPSPeak0,
	RQ_GAPSPeak1,
	RQ_GAPSPeak2,
	RQ_GAPSPeak3,
	RQ_GAPSPeak4,
	RQ_GAPSPeak5,
	RQ_GAPSPeak6,
	RQ_GAPSPeak7,
	RQ_GAPSPeak8,
	RQ_GAPSPeak9,
	RQ_GAPSPeak10,
	RQ_GAPSPeak11,
	RQ_GAPSPeak12,
	RQ_GAPSPeak13,
	RQ_GAPSLastPeak,
	RQ_GAPSLargestPeak, 
	RQ_GAPSLastPlusOne
} RQ_GateAmplitudePeakSelect ;

typedef enum 
{
	RQ_GDPSPeak0,
	RQ_GDPSPeak1,
	RQ_GDPSPeak2,
	RQ_GDPSPeak3,
	RQ_GDPSPeak4,
	RQ_GDPSPeak5,
	RQ_GDPSPeak6,
	RQ_GDPSPeak7,
	RQ_GDPSPeak8,
	RQ_GDPSPeak9,
	RQ_GDPSPeak10,
	RQ_GDPSPeak11,
	RQ_GDPSPeak12,
	RQ_GDPSPeak13,
	RQ_GDPSLastPeak,
	RQ_GDPSLargestPeak, 
	RQ_GDPSLastPlusOne
} RQ_GateDistancePeakSelect ;

typedef enum 
{								
	RQ_SGVOnlyWhenTriggered,  // Store zero if the gate is not triggered
	RQ_SGVAlways			  // Always store max value between gate start and end even if not triggered
} RQ_StoreGateValue;

typedef enum
{
	NDTS_PDSLatest,		// get the last ASCAN in the buffer
	NDTS_PDSMax,			// get the ASCAN with the largest amplitude in gate N
	NDTS_PDSMin,			// get the ASCAN with the smallest amplitude in gate N 
	NDTS_PDSFurthest,		// get the ASCAN with the largest depth in gate N
	NDTS_PDSNearest,		// get the ASCAN with the largest depth in gate N
	NDTS_PDSIndexed		// get the ASCAN from BSCAN N in the buffer
} NDTS_SnapshotDataSelection;


typedef struct 
{
	RQ_GateIndex index ;
	long startCount ;
	long stopCount ;
	unsigned long threshold ;
	RQ_GateTrigger triggerGate ;
	RQ_GateThresholdPolarity thresholdPolarity ;
	RQ_GateTriggerMode triggerMode ;
	RQ_GateDistanceMetric distanceMetric ;
	NDTS_Boolean isEnabled ;
	RQ_GateAmplitudePeakSelect amplitudePeakSelect ;
	RQ_GateDistancePeakSelect distancePeakSelect ;
	RQ_StoreGateValue storeGateValue;  
	NDTS_SnapshotDataSelection snapshotSelection;
	int reservedSetToZero0;  // Set these values to zero so that it is possible to use them for future expansion 
	// without recompiling the application.  The values in the board state are set to zero during
	// init so apps (like WinRS) that use RQ_GetGate then modify an individual field don't need to explicitly set these values.
	int reservedSetToZero1;
	int reservedSetToZero2;
	int reservedSetToZero3;
	int reservedSetToZero4;
} RQ_Gate ;

*/

// Provides a C Style interface to access the gates.
// This completely bypasses the gate Properties and so an application should
// only ever use Properties or this interface to set gates and never both.


///////////////////////////////////////////////////////////////////////////////////
// Gates are not subject to checking against other properties 
// and don't use the standard interface.
///////////////////////////////////////////////////////////////////////////////////

RS2A_API void CALL_CONV RS2A_InitialiseLegacyGatesInterface();
RS2A_API NDTS_Boolean CALL_CONV RS2A_SetGate(const RQ_Gate *pGate);
RS2A_API NDTS_Boolean CALL_CONV RS2A_GetGate(int gateIndex, RQ_Gate *pGate);


