/*******************************************************************************
*                                                                              *
* Société de Transports de Montréal.                                    	   *
* 2012                                                                         *
*                                                                              *
* Projet Zones Tests                                                           *
*                                                                              *
*                                                                              *
*                                                                              *
*******************************************************************************/
/*
    Description:
    Description du fichier si nécessaire.
    
*/

/* ************************************************************************** */
/* Revision:
### 20121210 JFM
    Verision d'origine.
    
### YYYYMMDD Description du besoin ou du bug
    Description du changement.
 */

/* ************************************************************************** */

#ifndef ZTCONFIGMGR_H
#define ZTCONFIGMGR_H

#include "GlobalDefine.h"
#include <QFile>
#include <QList>
#include "Externaliomodule.h"
#include "LazerProbe.h"
#include "LazerProbesMgr.h"
#include <QString>


typedef enum eZTConfigResult
{
    ZT_CONFIG_OK,
    ZT_CONFIG_FILE_ERROR,
    ZT_CONFIG_PARAMETER_ERROR
}ZTConfigResult;

typedef enum eZTConfigModbusEnableMode
{
    ZT_CONFIG_MODBUS_ENABLE_FORCE_ON,
    ZT_CONFIG_MODBUS_ENABLE_FORCE_OFF,
    ZT_CONFIG_MODBUS_ENABLE_AUTODETECT
}ZTConfigModbusEnableMode;


typedef struct stExtModulesConfig
{
    eExternalModuleType_t ModuleType;
    unsigned int ModuleSlaveAddress;
    unsigned int ModuleID;
}stExtModulesConfig_t;


typedef struct stLazerProbesConfig
{
	unsigned int ProbeType;
	unsigned int ProbeID;
	QString SerialPort;
}stLazerProbesConfig_t;


class CZTConfigMgr
{
public:



    static CZTConfigMgr* instance(){return &mSingleton;}
    static CZTConfigMgr mSingleton;

    ZTConfigResult LoadZTConfig(void);

    QFile *mZTConfigFile;

    CZTConfigMgr();

    QString GetStationName(void);
    QString GetExtIOIPAddress(void);
    QString GetDataQIPAddress();
    QList<stExtModulesConfig_t> *GetExtIOModulesConfigList(void);
	QList<stLazerProbesConfig_t> *GetLazerProbesConfigList(void);
    int GetEngLog(void);
	bool GetSimulatorEnabled();
    ZTConfigModbusEnableMode GetModbusCCEnabled();
    int GetModbusCCPort();
    int GetModbusCCDevID();
    int GetModbusSEIPort();
    int GetModbusSEIDevID();
    QString GetModbusCCIFName();
//	int GetLaserSensorCalib(){return mConfig_Station_LaserSensorCalib;}
    bool GetSAMBADriveActivated();
    QString GetSAMBAMountPoint();
    QString GetSAMBALogin();
    QString GetSAMBAPassword();
    QString GetSAMBADomain();
    bool GetSFTPActivated();
    QString GetSFTPLogin();
    QString GetSFTPPassword();
    QString GetSFTPServerAddress();
    QString GetSFTPServerRemoteDir();
    bool GetPIHistorianEnabled();
    int GetPIHistorianModbusDevID();
    int GetPIHistorianModbusPort();





private:
    //configuration values

    //External IO Modules
    QString mConfig_ExtIO_MasterIPAddr;
    QString mDataQIPAddr;
    QList<stExtModulesConfig_t> mConfig_ExtIOModulesConfigList;
	QList<stLazerProbesConfig_t> mConfig_LazerProbeModulesConfigList;

    QString mConfig_Station_StationName;
    QString mModbusCCIFName;

//    int mConfig_Station_LaserSensorCalib;
    int mEngLogVerbosity;
	bool mUseSimulator;
    ZTConfigModbusEnableMode mUseModbusCCMode;
    int mModbusCCDevID;
    int mModbusCCPort;
    int mModbusSEIPort;
    int mModbusSEIDevID;

// SAMBA drive parametesr
    bool mActivateSAMBADrive;
    QString mSAMBAMountPoint;
    QString mSAMBALogin;
    QString mSAMBAPassword;
    QString mSAMBADomain;

// SFTP server parameters
    bool mActivateSFTPClient;
    QString mSFTPLogin;
    QString mSFTPPassword;
    QString mSFTPAddress;
    QString mSFTPRemoteDir;

//Historien PI parameters
    bool mEnablePIHistorian;
    int mPIHistorianModbusPort;
    int mPIHistorianModbusDevID;
};

#endif // ZTCONFIGMGR_H
