/******************************************************************************
*
*	NDT Solutions Rapid Scan 2 Automated (RS2A) Software Development Kit v1.0
*
******************************************************************************
*
*  File:        NDTSRS2A.h
*
*  Description: Definitions for building the SDK, not for inclusion in other projectse
*
*
******************************************************************************/
#pragma once


#define RS2A_WAIT_FOR_SAMPLES_TIMEOUT_MILLIS 1000

#include <limits.h>
#include "NDTSRS2A.h"
#include "NDTSEnums.h"
#include "NDTSRS2AErrors.h"
#include "RawScan.h"
#include "PropertiesInterface.h"
#include "TCG.h"
#include "SDKPropertiesCollection.h"

NDTS_Boolean CALL_CONV RS2A_DLLInitialise() ;
NDTS_Boolean CALL_CONV RS2A_DLLUninitialise() ;
NDTS_Boolean RS2A_InitialiseInternal();


namespace NDTS
{
	namespace RS2A
	{
		// Variables that need to be used in C code as well as C++
		typedef struct
		{
			unsigned long cardIndex ;
			NDTS_RawScan rawScan ;
			bool isInitialised;
			TCGInternal *pTcg;
			int sampleFrequencyHz;
			int repSafetySamples;
		} NDTSRS2A_GlobalState ;

		extern NDTSRS2A_GlobalState rs2aGlobalState ;

		// Implementations of the classes that provide the non property side of the interface to the app
		class SnapshotInternal : public Snapshot
		{
		public:
			SnapshotInternal() {};
			virtual ~SnapshotInternal() {};
			virtual bool getAScan(int bScanIndex, int aScanIndex, short *pSamples, int numberOfBufferValues) ;
			virtual bool getPackedGateData(int bScanIndex, int aScanIndex, GateOutput *pGateOutputs, int numberOfBufferValues);
			virtual bool getUnPackedGateData(int bScanIndex, int aScanIndex, GateOutput *pGateOutputs, int numberOfBufferValues);
			virtual bool getEncoderValue(int bScanIndex, int encoderIndex, int *pEncoderValue);
			virtual bool getEncoderValues(int bScanIndex, int numberOfEncoders, int *pEncoderValue);
			virtual void resetEncoder(int encoderIndex);
			virtual unsigned long returnNumberOfSamples();	
		};

		class ErrorLogInternal : public ErrorLog
		{
		public:
			ErrorLogInternal() {};
			virtual ~ErrorLogInternal() {};
			virtual bool getErrorLogLine(int lineNumber, char *pMessageBuffer, int numberOfBytesInMessageBuffer);
		};

		// The TCGInternal class is declared in tcg.h / tcg.cpp
		class FactoryInternal : public Factory
		{

		public:
			FactoryInternal();
			virtual ~FactoryInternal();

		public:
			virtual Snapshot *getSnapshot();
			virtual ErrorLog *getErrorLog();
			virtual TCG *getTcg();
			virtual NDTS::SCO::Property *getRootProperty();
			virtual bool initialise();
			virtual void uninitialise();

			
		private:
			SnapshotInternal snapshot;
			ErrorLogInternal errorLog;
			TCGInternal tcg;
			SDKPropertiesCollection *pPropertiesCollection;
		};
	}
}


