#ifndef _SFC5XXXDEVICE_H_
#define _SFC5XXXDEVICE_H_

/***************************************
* Includes
***************************************/

#include <stdint.h>

/***************************************
* Typedefs for ShdlcDriver.dll
***************************************/
typedef uint32_t        (__cdecl *Shdlc_FctOpenPort)              (uint8_t aPortType, char* aPortConfig, uint32_t* aPortHandle);
typedef uint32_t        (__cdecl *Shdlc_FctClosePort)             (uint32_t aPortHandle);
typedef uint32_t        (__cdecl *Shdlc_FctGetPortInformation)    (uint32_t aPortHandle, uint8_t* aPortType, char* aPortConfigString, uint32_t aStringMaxSize);
typedef uint32_t        (__cdecl *Shdlc_FctGetDeviceInfo)         (uint32_t aPortHandle, uint8_t aSlaveAdr, uint32_t aResponseTimeoutMs, uint8_t aInfoType, char* aInfoString, uint32_t aStringMaxSize);
typedef uint32_t        (__cdecl *Shdlc_FctGetVersionString)      (uint32_t aPortHandle, uint8_t aSlaveAdr, char* aVersionString, uint32_t aStringMaxSize);
typedef uint32_t        (__cdecl *Shdlc_FctGetVersionNbr)         (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t* aFwMajor, uint8_t* aFwMinor, uint8_t* aFwDebugState, uint8_t* aHwMajor, uint8_t* aHwMinor, uint8_t* aShdlcMajor, uint8_t* aShdlcMinor);
typedef uint32_t        (__cdecl *Shdlc_FctGetDeviceErrorState)   (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t aClearAfloaterRead, uint32_t* aDeviceState, uint8_t* aLastError);
typedef uint32_t        (__cdecl *Shdlc_FctDeviceReset)           (uint32_t aPortHandle, uint8_t aSlaveAdr);
typedef uint32_t        (__cdecl *Shdlc_FctFactoryReset)          (uint32_t aPortHandle, uint8_t aSlaveAdr);
typedef uint32_t        (__cdecl *Shdlc_FctGetDeviceAddress)      (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t* aAddress);
typedef uint32_t        (__cdecl *Shdlc_FctSetDeviceAddress)      (uint32_t aPortHandle, uint8_t aBroadcastMode, uint8_t aSlaveAdr, uint8_t aAddress);
typedef uint32_t        (__cdecl *Shdlc_FctGetBaudrate)           (uint32_t aPortHandle, uint8_t aSlaveAdr, uint32_t* aBaudrate);
typedef uint32_t        (__cdecl *Shdlc_FctSetBaudrate)           (uint32_t aPortHandle, uint8_t aBroadcastMode, uint8_t aSlaveAdr, uint32_t aBaudrate, uint8_t aUpdateDll);

/***************************************
* Typedefs for SFC5xxxDriver.dll
***************************************/
typedef const char*     (__cdecl *SFC5xxx_FctTranslateErrorCode)                      (uint32_t aErrorCode);
typedef uint32_t        (__cdecl *SFC5xxx_FctReadMeasuredValue)                       (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t aDataReprsentation, float* aMeasuredValue);
typedef uint32_t        (__cdecl *SFC5xxx_FctReadMeasuredValueBuffered)               (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t aDataReprsentation, uint32_t *aLostValues, uint32_t *aRemainingValues, uint8_t *aValidValues, float *aSamplingTime, float* aBufferedValues);
typedef uint32_t        (__cdecl *SFC5xxx_FctGetCurrentCalibInfo)                     (uint32_t aPortHandle, uint8_t aSlaveAdr, char* aMediumDescription, uint32_t aStringMaxSize, uint32_t *aMediumId, int8_t* aMediumPrefix, uint8_t* aMediumUnit, uint8_t* aMediumTimebase, float *aFullscaleFlow);
typedef uint32_t        (__cdecl *SFC5xxx_FctLoadAndSelectCalibration)                (uint32_t aPortHandle, uint8_t aSlaveAdr, uint32_t aFlashLocation);
typedef uint32_t        (__cdecl *SFC5xxx_FctSetSetpoint)                             (uint32_t aPortHandle, uint8_t aSlaveAdr, float aSetPoint, uint8_t aSetPointIsPhysical);
typedef uint32_t        (__cdecl *SFC5xxx_FctGetSetpoint)                             (uint32_t aPortHandle, uint8_t aSlaveAdr, float *aSetPoint, uint8_t aSetPointIsPhysical);
typedef uint32_t        (__cdecl *SFC5xxx_FctSetSetpointAndReadMeasuredValue)         (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t aIsPhysical, float aSetpoint, float* aMeasuredFlow);
typedef uint32_t        (__cdecl *SFC5xxx_FctSetSetpointAndReadMeasuredValues2Sensors)(uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t aIsPhysical, float aSetpoint, float* aMeasuredFlow1, float* aMeasuredFlow2);
typedef uint32_t        (__cdecl *SFC5xxx_FctValveSetInputSource)                     (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t aInputSource);
typedef uint32_t        (__cdecl *SFC5xxx_FctValveGetInputSource)                     (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t* aInputSource);
typedef uint32_t        (__cdecl *SFC5xxx_FctValveSetUserDefinedValue)                (uint32_t aPortHandle, uint8_t aSlaveAdr, float aUserDefinedValue);
typedef uint32_t        (__cdecl *SFC5xxx_FctValveGetUserDefinedValue)                (uint32_t aPortHandle, uint8_t aSlaveAdr, float* aUserDefinedValue);
typedef uint32_t        (__cdecl *SFC5xxx_FctSetUserDefinedMediumUnit)                (uint32_t aPortHandle, uint8_t aSlaveAdr, int8_t aMediumPrefix, uint8_t aMediumUnit, uint8_t aMediumTimebase);
typedef uint32_t        (__cdecl *SFC5xxx_FctGetUserDefinedMediumUnit)                (uint32_t aPortHandle, uint8_t aSlaveAdr, int8_t* aMediumPrefix, uint8_t* aMediumUnit, uint8_t* aMediumTimebase);
typedef uint32_t        (__cdecl *SFC5xxx_FctGetUserDefinedMediumFullscale)           (uint32_t aPortHandle, uint8_t aSlaveAdr, int8_t* aMediumPrefix, float* aFullscale);
typedef uint32_t        (__cdecl *SFC5xxx_FctGetSensorTemperatureInCelsius)           (uint32_t aPortHandle, uint8_t aSlaveAdr, float* aValue);
typedef uint32_t        (__cdecl *SFC5xxx_FctGetUserControllerGain)                   (uint32_t aPortHandle, uint8_t aSlaveAdr, float* aUserGain);
typedef uint32_t        (__cdecl *SFC5xxx_FctSetUserControllerGain)                   (uint32_t aPortHandle, uint8_t aSlaveAdr, float aUserGain);
typedef uint32_t        (__cdecl *SFC5xxx_FctGetUsePressureDependentGain)             (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t* aEnabled);
typedef uint32_t        (__cdecl *SFC5xxx_FctSetUsePressureDependentGain)             (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t aEnabled);
typedef uint32_t        (__cdecl *SFC5xxx_FctGetInletPressure)                        (uint32_t aPortHandle, uint8_t aSlaveAdr, float* aPressure);
typedef uint32_t        (__cdecl *SFC5xxx_FctSetInletPressure)                        (uint32_t aPortHandle, uint8_t aSlaveAdr, float aPressure);
typedef uint32_t        (__cdecl *SFC5xxx_FctGetUseGasTemperatureCompensation)        (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t* aEnabled);
typedef uint32_t        (__cdecl *SFC5xxx_FctSetUseGasTemperatureCompensation)        (uint32_t aPortHandle, uint8_t aSlaveAdr, uint8_t aEnabled);
typedef uint32_t        (__cdecl *SFC5xxx_FctGetInletGasTemperature)                  (uint32_t aPortHandle, uint8_t aSlaveAdr, float* aTemperature);
typedef uint32_t        (__cdecl *SFC5xxx_FctSetInletGasTemperature)                  (uint32_t aPortHandle, uint8_t aSlaveAdr, float aTemperature);

/***************************************
* Function pointers from ShdlcDriver.dll
***************************************/

extern Shdlc_FctOpenPort              Shdlc_OpenPort;
extern Shdlc_FctClosePort             Shdlc_ClosePort;
extern Shdlc_FctGetPortInformation    Shdlc_GetPortInformation;
extern Shdlc_FctGetDeviceInfo         Shdlc_GetDeviceInfo;
extern Shdlc_FctGetVersionString      Shdlc_GetVersionString;
extern Shdlc_FctGetVersionNbr         Shdlc_GetVersionNbr;
extern Shdlc_FctGetDeviceErrorState   Shdlc_GetDeviceErrorState;
extern Shdlc_FctDeviceReset           Shdlc_DeviceReset;
extern Shdlc_FctFactoryReset          Shdlc_FactoryReset;
extern Shdlc_FctGetDeviceAddress      Shdlc_GetDeviceAddress;
extern Shdlc_FctSetDeviceAddress      Shdlc_SetDeviceAddress;
extern Shdlc_FctGetBaudrate           Shdlc_GetBaudrate;
extern Shdlc_FctSetBaudrate           Shdlc_SetBaudrate;

/***************************************
* Function pointers from SFC5xxxDriver.dll
***************************************/
extern SFC5xxx_FctTranslateErrorCode                         SFC5xxx_TranslateErrorCode;
extern SFC5xxx_FctReadMeasuredValue                          SFC5xxx_ReadMeasuredValue;
extern SFC5xxx_FctReadMeasuredValueBuffered                  SFC5xxx_ReadMeasuredValueBuffered;
extern SFC5xxx_FctGetCurrentCalibInfo                        SFC5xxx_GetCurrentCalibInfo;
extern SFC5xxx_FctLoadAndSelectCalibration                   SFC5xxx_LoadAndSelectCalibration;
extern SFC5xxx_FctSetSetpoint                                SFC5xxx_SetSetpoint;                     
extern SFC5xxx_FctGetSetpoint                                SFC5xxx_GetSetpoint; 
extern SFC5xxx_FctSetSetpointAndReadMeasuredValue            SFC5xxx_SetSetpointAndReadMeasuredValue;
extern SFC5xxx_FctSetSetpointAndReadMeasuredValues2Sensors   SFC5xxx_SetSetpointAndReadMeasuredValues2Sensors;
extern SFC5xxx_FctValveSetInputSource                        SFC5xxx_ValveSetInputSource;
extern SFC5xxx_FctValveGetInputSource                        SFC5xxx_ValveGetInputSource;
extern SFC5xxx_FctValveSetUserDefinedValue                   SFC5xxx_ValveSetUserDefinedValue;
extern SFC5xxx_FctValveGetUserDefinedValue                   SFC5xxx_ValveGetUserDefinedValue;
extern SFC5xxx_FctSetUserDefinedMediumUnit                   SFC5xxx_SetUserDefinedMediumUnit;                      
extern SFC5xxx_FctGetUserDefinedMediumUnit                   SFC5xxx_GetUserDefinedMediumUnit;
extern SFC5xxx_FctGetUserDefinedMediumFullscale              SFC5xxx_GetUserDefinedMediumFullscale;
extern SFC5xxx_FctGetSensorTemperatureInCelsius              SFC5xxx_GetSensorTemperatureInCelsius;
extern SFC5xxx_FctGetUserControllerGain                      SFC5xxx_GetUserControllerGain;
extern SFC5xxx_FctSetUserControllerGain                      SFC5xxx_SetUserControllerGain;
extern SFC5xxx_FctGetUsePressureDependentGain                SFC5xxx_GetUsePressureDependentGain;
extern SFC5xxx_FctSetUsePressureDependentGain                SFC5xxx_SetUsePressureDependentGain;
extern SFC5xxx_FctGetInletPressure                           SFC5xxx_GetInletPressure;
extern SFC5xxx_FctSetInletPressure                           SFC5xxx_SetInletPressure;
extern SFC5xxx_FctGetUseGasTemperatureCompensation           SFC5xxx_GetUseGasTemperatureCompensation;
extern SFC5xxx_FctSetUseGasTemperatureCompensation           SFC5xxx_SetUseGasTemperatureCompensation;
extern SFC5xxx_FctGetInletGasTemperature                     SFC5xxx_GetInletGasTemperature;
extern SFC5xxx_FctSetInletGasTemperature                     SFC5xxx_SetInletGasTemperature;

/***************************************
* Functions to load/release the DLLs
***************************************/
extern int32_t SFC5xxxDevice_LoadLibrary();
extern void SFC5xxxDevice_ReleaseLibrary();

#endif