servicedata.h 6.01 KB
#ifndef SERVICEDATA_H
#define SERVICEDATA_H

#include <stdint.h>
#include <time.h>

#define STRUCT_PACK     __attribute__ ((packed))

#define MAX_ERROR_TYPE_CNT  31

#define MAX_STATICS_CNT            23

#define MAX_LOG_SENSOR          16

typedef struct _error_item{
    uint16_t fired_cnt;
    time_t first_fired;
    time_t last_fried;
}STRUCT_PACK error_item;

typedef union{
    int16_t itemp;
    uint16_t utemp;
}type_temp;

typedef struct _sensor_log_item{
    type_temp high_temp;
    time_t last_high_time;
}STRUCT_PACK sensor_log_item;


typedef union _sensor_statics_log{
    uint8_t data[MAX_LOG_SENSOR * sizeof(sensor_log_item)];
    sensor_log_item values[MAX_LOG_SENSOR];
    struct{
        sensor_log_item B1;
        sensor_log_item B2;
        sensor_log_item Reserved1;
        sensor_log_item B4;
        sensor_log_item B5;
        sensor_log_item B3_1;
        sensor_log_item B3_2;
        sensor_log_item B3_3;
        sensor_log_item B3_4;
        sensor_log_item Reserved2; //10
        sensor_log_item mbar1;
        sensor_log_item mbar2;
        sensor_log_item pcb;
        sensor_log_item adc;
        sensor_log_item convec_fan_rpm;
        sensor_log_item bunner_rpm;
    }items;
}STRUCT_PACK sensor_statics_log;



typedef union _error_log{
        uint8_t data[MAX_ERROR_TYPE_CNT*sizeof(error_item)];
        error_item values[MAX_ERROR_TYPE_CNT];
        struct{
            error_item door;
            error_item upper_fire_fail;
            error_item upper_pan_fail;
            error_item lower_fire_fail;
            error_item lower_pan_fail;
            error_item steam_fire_fail;
            error_item steam_pan_fail;
            error_item water_level_sensor_fail;
            error_item water_flow_sensor_fail;
            error_item inner_temp_high_alarm;                   //B1 Sensor
            error_item inner_temp_fail;
            error_item qunching_temp_high_alarm;            //B2 Sensor
            error_item qunching_temp_fail;
            error_item meatprove_temp1_high_alarm;         //B3 Sensor
            error_item meatprove_temp1_fail;
            error_item wall_temp1_high_alarm;                   //B4 Sensor
            error_item wall_temp1_fail;
            error_item steam_gen_temp_high_alram;          //B5 Sensor
            error_item steam_gen_temp_fail;
            error_item meatprove_temp2_fail;
            error_item meatprove_temp3_fail;
            error_item meatprove_temp4_fail;            
            error_item pcb_temp_high_alarm;                         //PCB Temp
            error_item pcb_temp_fail;
            error_item upper_motor_fail;
            error_item lower_motor_fail;
            error_item small_motor_fail;
            error_item midd_motor_fail;
            error_item supply_motor_fail;                               // Steam Generator Tank Supply Pump
            error_item humidity_tamper_fail;
            error_item repeat_error;
        }items;
}STRUCT_PACK error_log;

enum ERROR_ITEM_IDX{
    ERROR_IDX_door=0,
    ERROR_IDX_upper_fire_fail,
    ERROR_IDX_upper_pan_fail,
    ERROR_IDX_lower_fire_fail,
    ERROR_IDX_lower_pan_fail,
    ERROR_IDX_steam_fire_fail,
    ERROR_IDX_steam_pan_fail,
    ERROR_IDX_water_level_sensor_fail,
    ERROR_IDX_water_flow_sensor_fail,
    ERROR_IDX_inner_temp_high_alarm,                   //B1 Sensor
    ERROR_IDX_inner_temp_fail,
    ERROR_IDX_qunching_temp_high_alarm,            //B2 Sensor
    ERROR_IDX_qunching_temp_fail,
    ERROR_IDX_meatprove_temp1_high_alarm,         //B3 Sensor
    ERROR_IDX_meatprove_temp1_fail,
    ERROR_IDX_wall_temp1_high_alarm,                   //B4 Sensor
    ERROR_IDX_wall_temp1_fail,
    ERROR_IDX_steam_gen_temp_high_alram,         //B5 Sensor
    ERROR_IDX_steam_gen_temp_fail,
    ERROR_IDX_meatprove_temp2_fail,
    ERROR_IDX_meatprove_temp3_fail,
    ERROR_IDX_meatprove_temp4_fail,
    ERROR_IDX_pcb_temp_high_alarm,                         //PCB Temp
    ERROR_IDX_pcb_temp_fail,
    ERROR_IDX_upper_motor_fail,
    ERROR_IDX_lower_motor_fail,
    ERROR_IDX_small_motor_fail,
    ERROR_IDX_midd_motor_fail,
    ERROR_IDX_supply_motor_fail,                               // Steam Generator Tank Supply Pump
    ERROR_IDX_humidity_tamper_fail
};

enum USE_ITEMS_IDX{
    USE_ITEM_steam_heat=0,
    USE_ITEM_dry_heat,
    USE_ITEM_upper_heat,
    USE_ITEM_lower_heat,
    USE_ITEM_cook_dry_mode,
    USE_ITEM_cook_steam_mode,
    USE_ITEM_cook_combi_mode,
    USE_ITEM_wash_mode_nocleanser,
    USE_ITEM_wash_mode_simple,
    USE_ITEM_wash_mode_standard,
    USE_ITEM_wash_mode_strong,
    USE_ITEM_wash_mode_speed,
    USE_ITEM_cooldown_mode,
    USE_ITEM_door_open,
    USE_ITEM_dv_open,
    USE_ITEM_ssv_open,
    USE_ITEM_qnv_open,
    USE_ITEM_ssp_open,
    USE_ITEM_snv_open,
    USE_ITEM_hosereel,
    USE_ITEM_hdm_open,
    USE_ITEM_dp_open,
    USE_ITEM_unp_open
};




typedef union _use_statics_log{
        uint8_t data[MAX_STATICS_CNT*4];
        uint32_t values[MAX_STATICS_CNT];
        struct{
            uint32_t steam_heat;
            uint32_t dry_heat;
            uint32_t upper_heat;
            uint32_t lower_heat;
            uint32_t cook_dry_mode;
            uint32_t cook_steam_mode;
            uint32_t cook_combi_mode;
            uint32_t wash_mode_nocleanser;
            uint32_t wash_mode_simple;
            uint32_t wash_mode_standard;
            uint32_t wash_mode_strong;
            uint32_t wash_mode_speed;
            uint32_t cooldown_mode;
            uint32_t door_open;
            uint32_t dv_open;
            uint32_t ssv_open;
            uint32_t qnv_open;
            uint32_t ssp_open;
            uint32_t snv_open;
            uint32_t hosereel;
            uint32_t hdm_open;
            uint32_t dp_open;
            uint32_t unp_open;
        }items;
}STRUCT_PACK use_statics_log;

class ServiceData
{
public:
    ServiceData();


    error_log err_log;
    use_statics_log use_log;
    sensor_statics_log sensor_log;
    uint16_t m_nRepeatErrorIdx;
    bool saveServiceData(void);
    bool loadServiceData(void);
    bool resetSensorlogData(void);
};

#endif // SERVICEDATA_H