// NDTS2100SdkManagedWrapper.h

#pragma once

#include "PropertiesInterface.h"
#include "NDTSEnums.h"
//#include "RQStructs.h"
#include "NDTS2100Sdk.h"


#ifdef NDTS2100_EXPORTS
#define NDTS2100_API __declspec(dllexport)
#else
#define NDTS2100_API __declspec(dllimport)
#endif

#ifdef STDCALL
#define CALL_CONV __stdcall
#else
#define CALL_CONV
#endif

using namespace System;
using namespace System::Runtime::InteropServices;
namespace NDTS
{
	namespace Managed
	{
		namespace NDTS2100
		{
			public ref class Snapshot
			{
			public:
				Snapshot();
				// These functions all work on a snapshot of data, including GetEncoderValue
				typedef array<short> AScanBuffer;
				bool getAScan(int cardIndex, int sequenceIndex, int bScanIndex, [Out] AScanBuffer ^%pBuffer) ;
				// .net compatible structure that is unpacked from the raw gate value obtained by the SDK
				typedef array<int> IntArray;
				// Gets the data in unpacked format (e.g. if gates 1,2,5 are active, the data for gate 5 will be at index [5]  index[2] and [3] will contain zeros 
				bool getGateData(int cardIndex, int sequenceIndex, int bScanIndex, [Out] IntArray ^%amplitudes, [Out] IntArray ^%depths) ;
				int getEncoderValue(int cardIndex, int bScanIndex, int encoderIndex);
				void getEncoderValues(int cardIndex, int bScanIndex, [Out] IntArray ^%encoderValues);
			private:
				NDTS::NDTS2100::Snapshot *pSnapshot;
			};

			public ref class ErrorLog
			{
			public:
				ErrorLog();
				// The error log can be polled by the application or read when a function returns False.
				virtual String^getErrorLogLine(int lineNumber);
			private:
				NDTS::NDTS2100::ErrorLog *pErrorLog;
			};

			public ref class TCG
			{
			public:
				TCG();
				// TCG and gain normalisation

				// *pTCGCurve is an array of 32 bit numbers, one for each sample period.  
				// The TCG curve in the RapiDAQ is only 8 bits and each 32 bit number should be from 0..255.
				// 0 corresponds to 0dB of gain and 255 to 80dB.
				// numberOfPointsInCurve should match the A Scan range PIAScanRange.  It is used to prevent
				// a buffer overflow if the A Scan range of the application gets out of sync with the SDK
				typedef array<int> TCGBuffer;
				virtual bool setCurve(int cardIndex, int sequenceIndex, TCGBuffer ^%pTCGCurve, int numberOfPointsInCurve);

				// Other TCG settings are available via the properties interface
			private:
				NDTS::NDTS2100::TCG *pTcg;

			};

			public ref class RootProperty
			{
			public:
				NDTS::Managed::SCO::Property  ^getRootProperty();
			private:
				static bool isInitialised = false;
			};
  
			public ref class ArrayProperty
			{
			public:
				NDTS::Managed::SCO::GroupProperty  ^getRootGroup();
				NDTS::Managed::SCO::GroupProperty  ^getCardGroup(int cardIndex);
				NDTS::Managed::SCO::GroupProperty  ^getStepGroup(int cardIndex, int stepIndex);
				NDTS::Managed::SCO::GroupProperty  ^getGateGroup(int cardIndex, int stepIndex, int gateIndex);
			};
            
			public ref class Test
			{
			public:
				bool runUnitTests();
			};

		}
	}
}
