/** @file Typedef.h
 
   This file is taken from the Windows driver and adapted for Linux.
 
   @par CREATION  
   @author Krauth Julien
   @date   09.10.2006
   
   @par VERSION
   @verbatim
   $LastChangedRevision:$
   $LastChangedDate:$
   @endverbatim   
   
   @par LICENCE
   @verbatim
   Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
        
        ADDI-DATA GmbH 
        Dieselstrasse 3 
        D-77833 Ottersweier 
        Tel: +19(0)7223/9493-0 
        Fax: +49(0)7223/9493-92 
        http://www.addi-data-com 
        info@addi-data.com         
   @endverbatim   
 */
/*
  +-----------------------------------------------------------------------+
  | (C) ADDI-DATA GmbH          Dieselstrasse 3      D-77833 Ottersweier  |
  +-----------------------------------------------------------------------+
  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |
  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
  +-----------------------------------------------------------------------+
  | Project   : -                 | Compiler : BORLAND C                  |
  | Modulname : Typedef.H         | Version  : 3.1                        |
  +-------------------------------+---------------------------------------+
  | Author    : S.Weber           | Date     : 26.02.04                   |
  +-----------------------------------------------------------------------+
  | Description : Struct definition header                                |
  +-----------------------------------------------------------------------+
  |                             UPDATE'S                                  |
  +-----------------------------------------------------------------------+
  |   Date   |   Author  |          Description of updates                |
  +----------+-----------+------------------------------------------------+
  |          |           |                                                |
  +-----------------------------------------------------------------------+
*/

#ifndef SET3701_TYPEDEF
   #define SET3701_TYPEDEF
   
#ifndef DOUBLE 
	#define DOUBLE	double
#endif	
   
   typedef struct
      {
      CHAR                    c_BoardName [30];
      WORD                    w_BoardType;
      WORD                    w_DeviceNumber;
      WORD                    w_BusNumber;
      WORD                    w_Interrupt;
      str_AddressInformation  s_Address [6];
      DWORD                  dw_SerialNumber;
      WORD                    w_FirmwareVersion;
      WORD                    w_NumberOfInputs;
      } __attribute__ ((packed)) str_BoardInformation,*pstr_BoardInformation;

   typedef struct
      {
      BYTE	w_LVDTType;						// Inductive sensor type
      BYTE	w_LVDTSelectionTypeValue;		// Selection value. Value to write for the LVDT type selection
      //BYTE b_Dummy [56];
      DOUBLE	d_Range;					// Transducer range (mm)
      DOUBLE    d_Sensitivity;				// Transducer sensibility (mv/V/mm)
      DOUBLE	d_NominalFrequency;			// Nominal transducer frequency (Hz)
      DOUBLE	d_MinFrequency;				// Minimal transducer frequency (Hz)
      DOUBLE	d_MaxFrequency;				// Max transducer frequency (Hz)
      DOUBLE	d_PrimaryNominalVoltage;	// Transducer primary nominal voltage (Veff)
      WORD	w_PrimaryShortCircuitValue;		// Primary short circuit digital value
      WORD	w_PrimaryOpenCircuitValue;		// Primary open circuit digital value
      WORD	w_SecondaryShortCircuitValue;	// Secondary short circuit digital value
      WORD	w_SecondaryOpenCircuitValue;	// Secondary open circuit digital value
      } __attribute__ ((packed)) str_LVDTSingleInformations,*pstr_LVDTSingleInformations;

   typedef struct
      {
      WORD w_FineCalibration : 1;	// 0 : fine calibration not occur
									// 1 : fine calibration occur
      WORD w_PotisValue	     : 8;	// Potis Value
      WORD w_PhaseSwitch     : 1;
      WORD w_PotisCS         : 5;	// Potis CS
      WORD w_LastPosition    : 1;	// 0 : Not the last potis value
									// 1 : Last potis value
      } __attribute__ ((packed)) str_PotisData,*pstr_PotisData;

   typedef struct
      {
      WORD                             w_BoardSelection;
      WORD                             w_AutoUpdateMode;
      WORD *                          pw_FileEeprom;
      WORD *                          pw_FileHeader;
      BYTE                             b_Firmware [98400];
      WORD                             w_FileEepromSize;
      DWORD                           dw_FirmwareSize;
      WORD                             w_Save;
      WORD                             w_UpdateHeader;
      WORD                             w_UpdateFirmware;
      WORD                             w_FirstHeaderUpdate;
      INT                              i_SaveHeaderFileHandle; 
      INT                              i_SaveFirmwareFileHandle; 
      } __attribute__ ((packed)) str_UpdateHeaderFirmwareInformations,*pstr_UpdateHeaderFirmwareInformations;

   typedef struct
      {
      WORD            w_BoardSelection;
      WORD            w_AverageCounter;
      WORD            w_NumberOfChannels;
      WORD            w_ChannelArray [16];
      DOUBLE          d_RangeArray   [16];
      } __attribute__ ((packed)) str_MonitorInformations,*pstr_MonitorInformations;

   typedef struct
      {
      WORD                w_AdministratorMode;		// 0: User 1: Administrator
      WORD                w_BoardSelection;
      WORD                w_Type;					// 0: HB 1: LVDT 
      WORD                w_TransducerIndex;
      WORD                w_AverageCounter;
      WORD                w_Group1Channel;
      WORD                w_Group2Channel;
      WORD                w_BoardTypeSelection;
      DOUBLE              d_Range;
      DOUBLE              d_CalibrationPosition;
      WORD                w_PotisCS        [10];
      WORD                w_PotisValue     [10];
      WORD                w_PhaseSwitch    [10];
      } __attribute__ ((packed)) str_CalibrationInformations,*pstr_CalibrationInformations;

   typedef struct
      {
      WORD w_VersionHigh;
      WORD w_VersionLow;
      WORD w_Reserved [100];
      } __attribute__ ((packed)) str_DataBaseHeader,*pstr_DataBaseHeader;

   typedef struct
      {
      BYTE     b_Calibrate;				// 0: No calibrate 1: Calibrate
      WORD     w_Index;					// Initialisation index
      CHAR     c_Name [300];			// Type name
      WORD     w_Type;					// 0: HB 1: LVDT 
      DOUBLE   d_Veff;					// Veff (Vrms)
      LONG     l_Frequency;				// Frequency
      DOUBLE   d_Sensitivity;			// Sensitivity (mV/V/mm)
      DOUBLE   d_Range;					// Range (mm)
      DOUBLE   d_LoadImpedance;			// Impedance (KOhm)
      INT      i_SecondaryOpenValue;    // Secondary open circuit value
      INT      i_SecondaryCCValue;      // Secondary CC value
      WORD     w_PotisValue [5];		// Potis value
										// Index 0 : Dprim  (CS3)
										// Index 1 : Dload  (CS7)
										// Index 2 : Dsec   (CS8)
										// Index 3 : Ddiff  (CS13)
										// Index 4 : Dphase (CS14)
      } __attribute__ ((packed)) str_DataBaseTransducerInformation, *pstr_DataBaseTransducerInformation;

#endif
