config.h 3.75 KB
#ifndef CONFIG_H
#define CONFIG_H


#include <QObject>
#include <QSet>

#define STRUCT_PACK     __attribute__ ((packed))


#define MAX_CONFIG_COUNT 14

namespace Define
{
    enum ConfigType {
        config_language = 0,
        config_datetime,
        config_temptype,
        config_backlight,
        config_stop_delay,
        config_best_dish_weight,
        config_party_dish_weight,
        config_ilc_rack_number,
        config_ilc_rack_sequnece,
        config_ilc_cook_wait_time,
        config_cooktime_format,
        config_time_type,
        config_resttime_format,
        config_marster_vol,
    };

    typedef union _config_item{
        uint32_t d32;
        float       f32;
        struct{
            uint8_t d8_0;
            uint8_t d8_1;
            uint8_t d8_2;
            uint8_t d8_3;
        }d8;
    }config_item;

    typedef union _config_lists{
        uint8_t data[MAX_CONFIG_COUNT*4];
        config_item values[MAX_CONFIG_COUNT];
        struct{
            config_item language;
            config_item datetime;
            config_item temptype;
            config_item backlight;
            config_item stop_delay;
            config_item best_dish_weight;
            config_item party_dish_weight;
            config_item ilc_rack_number;
            config_item ilc_rack_sequnece;
            config_item ilc_cook_wait_time;
            config_item cooktime_format;
            config_item time_type;
            config_item resttime_format;
            config_item marster_vol;
        }items;
    }STRUCT_PACK config_lists;
}



class Config : public QObject
{
    Q_OBJECT

    explicit Config(QObject *parent = 0);
    ~Config(void);

    static Config *instance;

   const char language_menu[3][20]{
       "한국어\0",
       "中國語\0",
       "English"
   };


   /* config_data_type Description
    * 80  = Custom
    * 0 = int
    * 1 = float
    */
   const uint8_t config_data_type[MAX_CONFIG_COUNT] = {
        0x80, 0x80, 0x80, 0, 0, 0, 0, 0, 0, 0,
        0x80,0x80,0x80,0
    };

    const char config_format_kr[MAX_CONFIG_COUNT][64]={
        "%S",
        "%S",
        "%S",
        "%d",
        "%d 분",
        "%d g", //5
        "%d g",
        "%d",
        "%d",
        "%d min",  //9
        "%S",
        "%S",
        "%S",
        "%d"
    };

    char config_format[MAX_CONFIG_COUNT][64];

    const char config_title[MAX_CONFIG_COUNT][64]={
        "언어설정", //0
        "날짜와 시간",
        "온도단위",
        "화면밝기",
        "응축식 후드의 정지지연",
        "일품요리용 접시무게", //5
        "연회용 접시무게",
        "ILC 조리선반 개수",
        "ILC 조리선반 순서",
        "ILC 조리 온습도 대기시간",  //9
        "조리시간 포맷",
        "실시간 포맷",
        "잔여시간 포맷",
        "마스터 볼륨"
    };

    QSet<uint32_t> m_setFavorite;


public:
    static Config *getInstance(QObject *parent=0);
    //static void init();
    bool loadConfig(void);
    bool saveConfig(void);
    Define::config_item getConfigValue(Define::ConfigType idx);
    void setConfigValue(Define::ConfigType idx, Define::config_item& itemdata);
    QString getValueString(Define::ConfigType idx);
    QString getTitleString(Define::ConfigType idx);
    bool isFavorite(Define::ConfigType idx);
    QSetIterator<uint32_t> getConstBeginFavorite();
    bool loadFavorite(void);
    bool saveFavorite(void);
    void insertFavorite(Define::ConfigType idx);
    void removeFavorite(Define::ConfigType idx);
    static QString getDateTimeString(uint32_t sec);
    static QString getTempString(int cel_temp);

    void execConfigWindow(QWidget *parent, Define::ConfigType idx);


    Define::config_lists configlist;



signals:

public slots:
};



#endif // CONFIG_H