/******************************************************************************
//                                                                           //
//  Project: Software Interface for ADO8+4+8 Devices                         //
//                                                                           //
//  CGC Instruments, (c) 2009-2015, Version 1.00. All rights reserved.       //
//                                                                           //
//  Definition for ADO8_4_8.DLL routines                                     //
//                                                                           //
******************************************************************************/

#ifndef __ADO8_4_8_H__
#define __ADO8_4_8_H__

#include <windows.h>

#include "math.h"

#ifdef __cplusplus
extern "C" {
#endif

/************************************************************************************************************************
*
* The LPT_I2C_Open from LPT-I2C.dll must be called before the first usage of other routines.
*
* The return values of the routines are the defines LPT_I2C_ERR_XXX from LPT-I2C.h.
*
************************************************************************************************************************/

#define ADO8_4_8_ERR_ARG  1000 /* Wrong argument passed to the function */


WORD _export pascal ADO8_4_8_Version(); /* Get the ADO8+4+8 software version */

/* Communication */
int _export pascal ADO8_4_8_Check (BYTE & Present); /* Check for presence of the ADO8+4+8 device, if the device responds, return non-zero in Present */

/* Digital output control */
#define ADO8_4_8_DIG_CHAN  8
int _export pascal ADO8_4_8_SetDigitalState (BYTE Channel, BOOL   Enabled); /* Set the digital output                */
int _export pascal ADO8_4_8_GetDigitalState (              BYTE & State  ); /* Get the digital outputs as a bit mask */

/* Analog output control */
#define ADO8_4_8_ANAL_CHAN 8
int _export pascal ADO8_4_8_SetAnalogVolt    (BYTE Channel, double   Voltage); /* Set the analog output voltage in Volt             */
int _export pascal ADO8_4_8_GetAnalogVolt    (BYTE Channel, double & Voltage); /* Get the analog output voltage in Volt             */
int _export pascal ADO8_4_8_SetAnalogState   (BYTE Channel, BOOL     Enabled); /* Set the state of a specified analog channel       */
int _export pascal ADO8_4_8_GetAnalogState   (              BYTE   & State  ); /* Get the state of the analog outputs as a bit mask */
int _export pascal ADO8_4_8_SetMinAnalogVolt (BYTE Channel, double   Voltage); /* Set the minimum analog output voltage in Volt     */
int _export pascal ADO8_4_8_GetMinAnalogVolt (BYTE Channel, double & Voltage); /* Get the minimum analog output voltage in Volt     */
int _export pascal ADO8_4_8_SetMaxAnalogVolt (BYTE Channel, double   Voltage); /* Set the maximum analog output voltage in Volt     */
int _export pascal ADO8_4_8_GetMaxAnalogVolt (BYTE Channel, double & Voltage); /* Get the maximum analog output voltage in Volt     */

/* Power output control */
#define ADO8_4_8_POW_CHAN  4
int _export pascal ADO8_4_8_SetPowerVolt    (BYTE Channel, double   Voltage); /* Set the power output voltage in Volt             */
int _export pascal ADO8_4_8_GetPowerVolt    (BYTE Channel, double & Voltage); /* Get the power output voltage in Volt             */
int _export pascal ADO8_4_8_SetPowerCurr    (BYTE Channel, double   Current); /* Set the power output current in Ampere           */
int _export pascal ADO8_4_8_GetPowerCurr    (BYTE Channel, double & Current); /* Get the power output current in Ampere           */
int _export pascal ADO8_4_8_SetPowerState   (BYTE Channel, BOOL     Enabled); /* Set the state of a specified power channel       */
int _export pascal ADO8_4_8_GetPowerState   (              BYTE   & State  ); /* Get the state of the power outputs as a bit mask */
int _export pascal ADO8_4_8_SetMinPowerVolt (BYTE Channel, double   Voltage); /* Set the minimum power output voltage in Volt     */
int _export pascal ADO8_4_8_GetMinPowerVolt (BYTE Channel, double & Voltage); /* Get the minimum power output voltage in Volt     */
int _export pascal ADO8_4_8_SetMaxPowerVolt (BYTE Channel, double   Voltage); /* Set the maximum power output voltage in Volt     */
int _export pascal ADO8_4_8_GetMaxPowerVolt (BYTE Channel, double & Voltage); /* Get the maximum power output voltage in Volt     */
int _export pascal ADO8_4_8_SetMaxPowerCurr (BYTE Channel, double   Current); /* Set the maximum power output current in Ampere   */
int _export pascal ADO8_4_8_GetMaxPowerCurr (BYTE Channel, double & Current); /* Get the maximum power output current in Ampere   */

/* Hardware information */
int _export pascal ADO8_4_8_GetAnalogCapability  (BYTE & AnalogChannels, double & MinAnalogVoltage, double & MaxAnalogVoltage);                           /* Get the hardware properties of the analog channels  */
int _export pascal ADO8_4_8_GetPowerCapability   (BYTE & PowerChannels,  double & MinPowerVoltage,  double & MaxPowerVoltage,  double & MaxPowerCurrent); /* Get the hardware properties of the power channels   */
int _export pascal ADO8_4_8_GetDigitalCapability (BYTE & DigitalChannels);                                                                                /* Get the hardware properties of the digital channels */

/* General information */
int _export pascal ADO8_4_8_FW_Ver  (WORD & Version);        /* Get firmware version */
int _export pascal ADO8_4_8_FW_Date (char * DateString);     /* Get firmware date, the buffer DateString must be at least 16 bytes long */
int _export pascal ADO8_4_8_Prod_ID (char * Identification); /* Get product identification, the buffer DateString must be at least 81 bytes long */
int _export pascal ADO8_4_8_Prod_No (DWORD & Number);        /* Get product number */

/* Housekeeping data */
int _export pascal ADO8_4_8_Get5V   (float & Voltage    ); /* Get internal 5V supply voltage in Volt */
int _export pascal ADO8_4_8_Get3V   (float & Voltage    ); /* Get internal 3V supply voltage in Volt */
int _export pascal ADO8_4_8_GetTemp (float & Temperature); /* Get temperature in K */

/* Various */
int _export pascal ADO8_4_8_GetUptime (double & Uptime); /* Get the uptime in seconds */

#ifdef __cplusplus
}
#endif

#endif//__ADO8_4_8_H__
