//---------------------------------------------------------------------------
#ifndef pmDevCtrlInterfaceMainH
#define pmDevCtrlInterfaceMainH
//---------------------------------------------------------------------------

 // Structures
  static const int mxDouble = 2;
  static const int mxSingle = 7;

/* Old mxArray structure
  typedef struct
  {
    char  Name[32];
    int   Reserved1[2];
    void* Reserved2;
    int   NumDims;
    int   NumElementsAllocated;
    int   Reserved3[3];
    union
    {
      struct
      {
        void* Real;
        void* Imag;
        void* Reserved4;
        int   Reserved5[3];
      } Array;
    } Data;
  } mxArray;
*/

/* New mxArray structure
  typedef struct
  {
    void* Reserved;
    int   Reserved1[2];
    void* Reserved2;
    int   NumDims;
    unsigned int Reserved3;
    struct
    {
      unsigned int flag0  : 1;
      unsigned int flag1  : 1;
      unsigned int flag2  : 1;
      unsigned int flag3  : 1;
      unsigned int flag4  : 1;
      unsigned int flag5  : 1;
      unsigned int flag6  : 1;
      unsigned int flag7  : 1;
      unsigned int flag7a : 1;
      unsigned int flag8  : 1;
      unsigned int flag9  : 1;
      unsigned int flag10 : 1;
      unsigned int flag11 : 4;
      unsigned int flag12 : 8;
      unsigned int flag13 : 8;
    } Flags;
    unsigned int Reserved4[2];
    union
    {
      struct
      {
        void* Real;
        void* Imag;
        void* Reserved5;
        int   Reserved6[3];
      } Array;
    } Data;
  } mxArray;
*/

  typedef struct
  {
    int dimSizes[2];
    float elt[1];
  } LabView2DArray;
  typedef LabView2DArray** dciHLabView2DArray;


 // Type definitions
  typedef int dciErrorCode;

 // Definitions
  #ifdef __DLL__
    #define DLL_DECLSPEC __declspec(dllexport)
  #else
    #define DLL_DECLSPEC __declspec(dllimport)
  #endif

  #define dciERROR 0
  #define dciOK 1

//---------------------------------------------------------------------------
//
//  DLL function prototypes
//
//---------------------------------------------------------------------------

#ifdef __cplusplus
extern "C"
{
#endif

 // Exported functions
  DLL_DECLSPEC dciErrorCode __stdcall dciInit(int LoadDaq);
  DLL_DECLSPEC dciErrorCode __stdcall dciInitialised(void);

  DLL_DECLSPEC dciErrorCode __stdcall dciLoadDaq(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciDaqLoaded(void);

  DLL_DECLSPEC void __stdcall dciFreeMemory(void);

  DLL_DECLSPEC int __stdcall dciNumDevices(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciGetDeviceName(int DeviceNumber, char* Name, int Length);
  DLL_DECLSPEC dciErrorCode __stdcall dciAddDevice(const char* Name);
  DLL_DECLSPEC dciErrorCode __stdcall dciRemoveDevice(const char* Name);
  DLL_DECLSPEC dciErrorCode __stdcall dciRemoveDeviceNum(int DeviceNumber);
  DLL_DECLSPEC dciErrorCode __stdcall dciRemoveAllDevices(void);

  DLL_DECLSPEC int __stdcall dciDeviceNumChannels(int DeviceNumber);
  DLL_DECLSPEC int __stdcall dciTotalNumChannels(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciGetDeviceChannels(int DeviceNumber, int* Channels);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetDeviceChannels(int DeviceNumber, const int* Channels);
  DLL_DECLSPEC dciErrorCode __stdcall dciGetDeviceVoltageScales(int DeviceNumber, float* Scales);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetDeviceVoltageScales(int DeviceNumber, const float* Scales);
  DLL_DECLSPEC dciErrorCode __stdcall dciGetDeviceVoltageOffsets(int DeviceNumber, float* Offsets);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetDeviceVoltageOffsets(int DeviceNumber, const float* Offsets);

  DLL_DECLSPEC dciErrorCode __stdcall dciSetDeviceTFFileName(int DeviceNumber, const char* TFFileName);

  DLL_DECLSPEC dciErrorCode __stdcall dciZeroAllDevices(void);

  DLL_DECLSPEC dciErrorCode __stdcall dciMonitorDevices(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciStopMonitoringDevices(void);

  DLL_DECLSPEC float __stdcall dciAcquisitionScanRate(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetAcquisitionScanRate(float Rate);
  DLL_DECLSPEC int __stdcall dciAcquisitionBlockSize(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetAcquisitionBlockSize(int BlockSize);
  DLL_DECLSPEC int __stdcall dciOverSamplingRatio(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetOverSamplingRatio(int Ratio);

  DLL_DECLSPEC int __stdcall dciNumOutputSamples(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetNumOutputSamples(int NumSamples);
  DLL_DECLSPEC float __stdcall dciSamplingTime(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetSamplingTime(float Time);
  DLL_DECLSPEC float __stdcall dciDataOutputRate(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetDataOutputRate(float Rate);
  DLL_DECLSPEC int __stdcall dciOutputBlockSize(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetOutputBlockSize(int BlockSize);

  DLL_DECLSPEC int __stdcall dciOutputFileNameLength(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciGetOutputFileName(char* FileName, int Length);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetOutputFileName(const char* FileName);
  DLL_DECLSPEC int __stdcall dciOutputTimeHistoryFile(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetOutputTimeHistoryFile(int Output);
  DLL_DECLSPEC int __stdcall dciOutputSummaryFile(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetOutputSummaryFile(int Output);

  DLL_DECLSPEC float __stdcall dciTemperature(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetTemperature(float Temperature);
  DLL_DECLSPEC float __stdcall dciAbsPressure(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciSetAbsPressure(float AbsPressure);

  DLL_DECLSPEC dciErrorCode __stdcall dciSampleAndProcess(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciStopProcessing(void);
  DLL_DECLSPEC int __stdcall dciProcessing(void);

  DLL_DECLSPEC dciErrorCode __stdcall dciPrepareToPostProcess(void);
  DLL_DECLSPEC dciErrorCode __stdcall dciPostProcess(const float** VoltageData);
  DLL_DECLSPEC dciErrorCode __stdcall dciPostProcess1D(const float* VoltageData);
  DLL_DECLSPEC dciErrorCode __stdcall dciPostProcessML(const double* VoltageData);
//  DLL_DECLSPEC dciErrorCode __stdcall dciPostProcessML(const mxArray* VoltageData);
  DLL_DECLSPEC dciErrorCode __stdcall dciPostProcessSA(const SAFEARRAY** VoltageData);
  DLL_DECLSPEC dciErrorCode __stdcall dciPostProcessLV(const dciHLabView2DArray VoltageData);
  DLL_DECLSPEC dciErrorCode __stdcall dciDonePostProcessing(void);

  DLL_DECLSPEC dciErrorCode __stdcall dciPostProcessTHFile(const char* FileName);

  DLL_DECLSPEC dciErrorCode __stdcall dciGetData_FilteredAnalogue(int DeviceNumber, float** Data);
  DLL_DECLSPEC dciErrorCode __stdcall dciGetData_FilteredAnalogueML(int DeviceNumber, double* Data);
  DLL_DECLSPEC dciErrorCode __stdcall dciGetData_FilteredPressure(int DeviceNumber, float** Data);
  DLL_DECLSPEC dciErrorCode __stdcall dciGetData_FilteredPressureML(int DeviceNumber, double* Data);
//  DLL_DECLSPEC dciErrorCode __stdcall dciGetData_FilteredPressureML(int DeviceNumber, mxArray* Data);
  DLL_DECLSPEC dciErrorCode __stdcall dciGetData_UVW(int DeviceNumber, float* U, float* V, float* W, float* Ps);
  DLL_DECLSPEC dciErrorCode __stdcall dciGetData_VelPitchYaw(int DeviceNumber, float* Velocity, float* Pitch, float* Yaw, float* Ps);

#ifdef __cplusplus
}
#endif
//---------------------------------------------------------------------------
#endif
