config.h 14.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
#ifndef CONFIG_H
#define CONFIG_H


#include <QObject>
#include <QSet>
#include "inputoverwatcher.h"

#define STRUCT_PACK     __attribute__ ((packed))


#define MAX_CONFIG_COUNT 54
#define MAX_SOFTWARE_INFO_CNT   7
#define MAX_HOTLINE_CHEF_CNT    3
#define MAX_HOTLINE_SERVICE_CNT 2

#define CONFIG_FILE_NAME    "/prime/config/config.ini"
#define FAVORITE_FILE_NAME "/prime/config/favorite.ini"


#define MODEL_INFO_FILE_NAME "/prime/config/model_info.csv"
#define CHEF_INFO_FILE_NAME "/prime/config/chef_info.csv"
#define SERVICE_INFO_FILE_NAME "/prime/config/service_info.csv"
#define RPM_INFO_FILE_NAME  "/prime/config/rpm_info.csv"

#define DEFAULT_PRODUCT_SERIAL  "0123"

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

static const char temptype_menu[2][16]{
     QT_TRANSLATE_NOOP("Config","섭씨(℃)"),
     QT_TRANSLATE_NOOP("Config","화씨(℉)")
};

static const char set_unset_menu[2][16]={
    QT_TRANSLATE_NOOP("Config","설정취소\0"),
    QT_TRANSLATE_NOOP("Config","설정\0")
};

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

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

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


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

const char on_off_menu[2][16] = {
    QT_TRANSLATE_NOOP("Config","끄기\0"),
    QT_TRANSLATE_NOOP("Config","켜기\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[MAX_SOFTWARE_INFO_CNT][32] ={
    QT_TRANSLATE_NOOP("Config","모  델  명"),
    QT_TRANSLATE_NOOP("Config","제조일자"),
    QT_TRANSLATE_NOOP("Config","제조국"),
    QT_TRANSLATE_NOOP("Config","제조사"),
    QT_TRANSLATE_NOOP("Config","제품번호"),
    QT_TRANSLATE_NOOP("Config","소프트웨어 버전"),
    QT_TRANSLATE_NOOP("Config","현재모델")
};

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

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



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_model,
        config_burner1_pwr1_normal_rpm,
        config_burner1_pwr2_normal_rpm,
        config_burner23_pwr1_normal_rpm,
        config_burner23_pwr2_normal_rpm,
        config_burner1_pwr1_half_rpm,
        config_burner1_pwr2_half_rpm,
        config_burner23_pwr1_half_rpm,
        config_burner23_pwr2_half_rpm,
        config_standard_info_upload,
        config_invalid = MAX_CONFIG_COUNT+1
    };

    typedef union _config_item{
        uint32_t d32;
        float       f32;
        struct{
            uint16_t d16[2];
        }d16;
        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;
            config_item model; //System Data, Do not copy after this item when config upload.
            config_item burner1_pwr1_normal_rpm;
            config_item burner1_pwr2_normal_rpm;
            config_item burner23_pwr1_normal_rpm;
            config_item burner23_pwr2_normal_rpm;
            config_item burner1_pwr1_half_rpm;
            config_item burner1_pwr2_half_rpm;
            config_item burner23_pwr1_half_rpm;
            config_item burner23_pwr2_half_rpm;
        }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
    };

    enum model_type{
            model_electric_10 = 0,
            model_electric_20,
            model_electric_24,
            model_electric_40,

            model_gas_lpg_10,
            model_gas_lpg_20,
            model_gas_lpg_24,
            model_gas_lpg_40,

            model_gas_lng_10,
            model_gas_lng_20,
            model_gas_lng_24,
            model_gas_lng_40
    };

    enum rest_time_type{
        rest_time_rest=0,
        rest_time_target
    };

    enum language_type{
        language_kr = 0,
        language_ch,
        language_en
    };
}



class Config : public QObject
{
    Q_OBJECT

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

    static Config *instance;
    InputOverwatcher watcher;
    QString m_strProductSerial;






   /* config_data_type & Formatter Description
    * 80  = use Cutom Formatter
    * 0 = int
    * 1 = float
    * 2 = only String,
    * 3 = int +1
    * 7f = none value
    */
   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, 0x00, 0x03, 0x03, 0x03, 0x03, 0x02,
        0x02, 0x02, 0x02,0x02, 0x02,0x02, 0x80, 0x80, 0x80, 0x02, 0x02,
        0x80, 0x00, 0x00,0x00,
        0x80, 0x80, 0x80,
        0x02,0x02,0x02,0x02,0x80,0x02
    };


    const char config_format[MAX_CONFIG_COUNT][64] = {
        "%S",
        "%S",
        "%S",
        "%1",
        QT_TR_NOOP("%1 분"),
        "%1 g", //5
        "%1 g",
        "%1",
        "%1",
        "%1 min",  //9
        "%S", //10
        "%S",
        "%S", //end of Settings
        "%1" ,//start of Sound
        QT_TR_NOOP("%1번"),
        "%1",
        "%1번",
        "%1번",
        "%1번",
        "%1번",
        QT_TR_NOOP("공장초기화"),
        QT_TR_NOOP("USB 삽입"),        //config_haccp_data_download,
        "USB 삽입",       //config_info_data_download,
        "USB 삽입",       //config_service_data_download,
        "USB 삽입",       //config_program_download,
        "USB 삽입",       //config_program_upload,
        QT_TR_NOOP("초기화"),           //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,
        "%1",               //config_set_auto_darkness,
        "%1",               //config_set_ilc_cook_temphumi_ready,
        "%1",               //config_set_load_ready,
        "%s",               //config_duty_wash,
        QT_TR_NOOP("%1단계"),         //config_loading_door_monitoring,
        QT_TR_NOOP("%1단계"),          //config_cooking_door_monitoring
        QT_TR_NOOP("정보확인"),                   //config_software_info,
        "정보확인",                   //config_hotline_chef,
        "정보확인",                   //config_hotline_service,
        QT_TR_NOOP("헹굼"),                   //config_steam_wash
        "%s",                   //config_demo_mode,
        QT_TR_NOOP("엔지니어모드 진입"),                   //config_enter_engineer_mode,
    };

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

    QSet<uint32_t> m_setFavorite;


public:
    static Config *getInstance(QObject *parent=0);
    //static void init();
    void initConfig(void);
    void soundConfigReset(void);
    bool loadConfig(void);
    void applyConfig(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 copyConfigArea(const char* buff);
    void insertFavorite(Define::ConfigType idx);
    void removeFavorite(Define::ConfigType idx);
    QString getProductSerial();
    void applyCurrentConfigLanguage();
    void allProgramInit(void);



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


    Define::config_lists configlist;

signals:

public slots:
};



#endif // CONFIG_H