config.h 11.5 KB
#ifndef CONFIG_H
#define CONFIG_H


#include <QObject>
#include <QSet>

#define STRUCT_PACK     __attribute__ ((packed))


#define MAX_CONFIG_COUNT 45
#define MAX_SOFTWARE_INFO_CNT   3
#define MAX_HOTLINE_CHEF_CNT    3
#define MAX_HOTLINE_SERVICE_CNT 2


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,
        config_keypad_sound1,
        config_keypad_sound2,
        config_request_loadexec,
        config_programstep_finish,
        config_cooktime_finish,
        config_stoperror_distinguish,
        config_sound_factory_reset,
        config_haccp_data_download,
        config_info_data_download,
        config_service_data_download,
        config_program_download,
        config_program_upload,
        config_program_initialize,
        config_ip,
        config_gateway,
        config_netmask,
        config_set_download,
        config_set_upload,
        config_set_half_energy,
        config_set_auto_darkness,
        config_set_ilc_cook_temphumi_ready,
        config_set_load_ready,
        config_duty_wash,
        config_loading_door_monitoring,
        config_cooking_door_monitoring,
        config_software_info,
        config_hotline_chef,
        config_hotline_service,
        config_steam_wash,
        config_demo_mode,
        config_enter_engineer_mode,
        config_invalid = MAX_CONFIG_COUNT
    };

    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;
            config_item keypad_sound1;
            config_item keypad_sound2;
            config_item request_loadexec;
            config_item programstep_finish;
            config_item cooktime_finish;
            config_item stoperror_distinguish;
            config_item sound_factory_reset;
            config_item haccp_data_download;
            config_item info_data_download;
            config_item service_data_download;
            config_item program_download;
            config_item program_upload;
            config_item program_initialize;
            config_item ip;
            config_item gateway;
            config_item netmask;
            config_item set_download;
            config_item set_upload;
            config_item set_half_energy;
            config_item set_auto_darkness;
            config_item set_ilc_cook_temphumi_ready;
            config_item set_load_ready;
            config_item duty_wash;
            config_item loading_door_monitoring;
            config_item cooking_door_monitoring;
            config_item software_info;
            config_item hotline_chef;
            config_item hotline_service;
            config_item steam_wash;
            config_item demo_mode;
            config_item enter_engineer_mode;
        }items;
    }STRUCT_PACK config_lists;


    enum temp_type{
        temp_type_c=0,
        temp_type_f,
    };

    enum time_type{
        time_type_24h = 0,
        time_type_12h
    };

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

    const char time_type_menu[2][16]={
        "24h\0",
        "am/pm\0"
    };



    const char temptype_menu[2][16]{
         "섭씨(℃)\0",
        "화씨(℉)\0"
    };

    const char best_dish_weight_menu[4][16]={
        "700g\0",
        "700-899g\0",
        "900-1099g\0",
        "1100g"
    };

    enum rest_time_type{
        rest_time_rest=0,
        rest_time_target
    };

    const char rest_time_type_menu[2][16] = {
         "잔여시간\0",
        "타겟시간\0"
    };

    const char on_off_menu[2][16]={
        "설정\0",
        "설정취소\0"
    };

    const char active_on_off_menu[2][16]={
        "비활성\0",
        "활성화\0"
    };

    typedef struct _config_1digit_set{
        char str_unit[8];
        int maxlen;
        int min;
        int max;
    }config_1digit_set;

    const config_1digit_set auto_darkness_dlgset = {
        "min\0",
        2,
        1,
        30,
    };

    const config_1digit_set load_ready_dlgset ={
        "min\0",
        2,
        2,
        10,
    };

    const char software_item_name[3][32] ={
        "모  델  명",
        "제조일자",
        "소프트웨어 버전"
    };

    const char hotline_chef_item_name[3][32] = {
        "연 락 처",
        "이       름",
        "위치정보"
    };

    const char hotline_service_item_name[3][32] ={
        "연 락 처",
        "위치정보"
    };
}



class Config : public QObject
{
    Q_OBJECT

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

    static Config *instance;







   /* config_data_type & Formatter Description
    * 80  = use Cutom Formatter
    * 0 = int
    * 1 = float
    * 2 = only String,
    * 3 = int +1
    */
   const uint8_t config_data_type[MAX_CONFIG_COUNT] = {
        0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, 0x80,  //Settings
        0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02,
        0x02, 0x02, 0x02,0x02, 0x02,0x02, 0x80, 0x80, 0x80, 0x02, 0x02,
        0x80, 0x00, 0x00,0x00,
        0x80, 0x00, 0x00,
        0x80, 0x80, 0x80,0x80,0x80,0x80
    };

    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", //10
        "%S",
        "%S", //end of Settings
        "%d" ,//start of Sound
        "%d번",
        "%d번",
        "%d번",
        "%d번",
        "%d번",
        "%d번",
        "공장초기화",
        "USB 삽입",       //config_haccp_data_download,
        "USB 삽입",       //config_info_data_download,
        "USB 삽입",       //config_service_data_download,
        "USB 삽입",       //config_program_download,
        "USB 삽입",       //config_program_upload,
        "초기화",           //config_program_initialize,
        "%d.%d.%d.%d", //config_ip,
        "%d.%d.%d.%d", //config_gateway,
        "%d.%d.%d.%d", //config_netmask,
        "USB 삽입",       //config_set_download,
        "USB 삽입",       //config_set_upload,
        "%s",               //config_set_half_energy,
        "%d",               //config_set_auto_darkness,
        "%d",               //config_set_ilc_cook_temphumi_ready,
        "%d",               //config_set_load_ready,
        "%s",               //config_duty_wash,
        "%d단계",         //config_loading_door_monitoring,
        "%d단계",          //config_cooking_door_monitoring
        "%s",                   //config_software_info,
        "%s",                   //config_hotline_chef,
        "%s",                   //config_hotline_service,
        "%s",                   //config_steam_wash
        "%s",                   //config_demo_mode,
        "%s",                   //config_enter_engineer_mode,
    };


    char config_format[MAX_CONFIG_COUNT][64];

    const char config_title[MAX_CONFIG_COUNT][64]={
        "언어설정", //0
        "날짜와 시간",
        "온도단위",
        "화면밝기",
        "응축식 후드의 정지지연",
        "일품요리용 접시무게", //5
        "연회용 접시무게",
        "ILC 조리선반 개수",
        "ILC 조리선반 순서",
        "ILC 조리 온습도 대기시간",
        "조리시간 포맷", //10
        "실시간 포맷",
        "잔여시간 포맷", //12
        "마스터 볼륨", //13
        "키패드 소리 - 1",
        "키패드 소리 - 2 ", //15
        "적재/실행 요청",
        "프로그램 단계 종료",
        "조리시간 종료",
        "과정 중단/오류 식별", //19
        "음향설정 초기화", //20
        "HACCP 데이터 다운로드",     //config_haccp_data_download,
        "인포 데이터 다운로드",          //config_info_data_download,
        "서비스 데이터 다운로드",       //config_service_data_download,
        "프로그램 다운로드",               //config_program_download,
        "프로그램 업로드",                  //25 config_program_upload,
        "모든 프로그램 삭제",              //config_program_initialize,
        "IP 주소",                                //config_ip,
        "IP 게이트웨이",                      //config_gateway,
        "IP 넷마스크",                         //config_netmask,
        "기본설정 다운로드",               //30 config_set_download,
        "기본설정 업로드",                  //31 end of system config config_set_upload,
        "하프에너지",                            //config_set_half_energy,
        "화면 밝기 자동 감소",              //config_set_auto_darkness,
        "ILC 조리 온습도 대기시간",      //config_set_ilc_cook_temphumi_ready,
        "적재중 대기 시간",                  //config_set_load_ready,
        "의무 세척과정",                      //config_duty_wash,
        "적재 중 문열림 시간 모니터링",//config_loading_door_monitoring,
        "조리 중 문열림 시간 모니터링" ,//config_cooking_door_monitoring
        "제품유형/소프트웨어에 관한 정보",//config_software_info,
        "핫라인-쉐프",                       //config_hotline_chef,
        "핫라인-서비스",                      //config_hotline_service,
        "증기 발생기 헹굼",                    //config_steam_wash
        "시연모드",                             //config_demo_mode,
        "서비스단계(엔지니어모드)"      //config_enter_engineer_mode,
    };

    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();
    QList<uint32_t> getConstSortedFavorite();
    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