/*
 * @Description: 
 * @Version: 1.0
 * @Autor: lishengyin
 * @Date: 2022-03-07 11:52:08
 * @LastEditors: lishengyin
 * @LastEditTime: 2022-07-22 16:55:36
 */
#ifndef __CONFIG_HPP_
#define __CONFIG_HPP_

#include <iostream>
#include <memory>
#include <mutex>  // mutex
#include <vector>
#include <unistd.h>
#include "Util/logger.h"
#include "BasicConfig.h"
#include "inifile.h"

#include "deviceBase.h"

using namespace std;
using namespace toolkit;
using namespace inifile;

#define GSD_MAJOR_VERSION 4
#define GSD_MINOR_VERSION 0
#define GSD_PATCH_VERSION 0

#define OK 0
#define ERR -1

class config
{
public:
    using Ptr = std::shared_ptr<config>;

    std::string Spug_IP;
    int Spug_Port;

    std::string NettyIP = "192.168.31.95";
    int NettyPort = 8080;
    std::string cameraIp;
    std::string usr;
    std::string pwd;
    std::string comPort;
    std::string SimCode;
    std::string vpnIP;

    // 过滤器设置
    int sensitivity = 0;
    int interval = 2000;
    int TimeOut = 0;

    // Debug配置
    int debug = 0;

    double DiskUsageThreshold = 0.80;
    int HardDiskCleanupTime = 3;
    int InferDataRetentionTime = 3;

    std::string mysql_IP = "192.168.31.174";
    int mysql_port = 13306;

    std::string app;

    // 临时版本
    vector<int> DeviceIds; 
    int deviceType = 0;
    
    vector<std::string> HostIPs;
    std::string localIP = "";

    int getHistoryVideoFlag = 0;
    
    int ClearPastRecords = 0;
    
    double bboxSize = 0.0;

    int ExpelInterval = 10000;

    int LowVersion = 1;

    int ExpelPort = 19002;

    int InferInterval = 2000;
    
protected:
    #ifdef RELEASE
        std::string configFile = "/etc/gsd/config.ini";
    #else 
        std::string configFile = "../config/config.ini";
    #endif
    std::string apiKey = "sunwin202110291532";
    IniFile m_ini;

private:
    config(){}

    config(config&) = delete;

    config& operator=(const config&) = delete;
public:

    ~config(){}

    /**
     * @description: 获取智能指针
     * @param {*}
     * @return {*}
     */    
    static Ptr getPtr();

    /**
     * @description: 更新数据
     * @param {*}
     * @return {*}
     */    
    bool Update();

    /**
     * @description: 获取Simcode
     * @param {*}
     * @return {*}
     */    
    std::string getSimCode();

    /**
     * @description: getApp
     * @param {*}
     * @return {*}
     */    
    std::string getApp();

    /**
     * @description: 获取基础配置
     * @param {*}
     * @return {*}
     */    
    bool getBasicConfig();

    /**
     * @description: 获取版本
     * @return {*}
     */    
    std::string getVersion();

    /**
     * @description: 获取IP列表
     * @return {*}
     */    
    vector<string> getHostIP();

    /**
     * @description: 获取历史视频
     * @return {*}
     */    
    void getHistoryVideo(vector<std::string>& result);
};








#endif