/*
 * logs_hmi.h
 *
 *  Created on: 28 рту. 2024 у.
 *      Author: Evgeniy_Sokolov
 */

#ifndef SRC_MAIN_LOGS_HMI_H_
#define SRC_MAIN_LOGS_HMI_H_

#define _LOG_HMI_SMALL_TEST 0//1

#define PLACE_STORE_LOG_PULT_SD     1 //SD
#define PLACE_STORE_LOG_PULT_USB    2 //USB Flash

typedef struct {

    int send_log;

//  int new_send_log_checked;
    unsigned long log_size_sent;
//    int flag_data_received;



//  unsigned int number_of_log;
    unsigned long count_write_to_modbus;

//  unsigned long current_address;
    unsigned long start_log_address;
//  int log_address_step;

    int step;
    int progress_bar;
    int enable_progress_bar;

    int cleanLogs;
    int tick_step;
//    int tick_finish;

    int flag_log_array_sended;
    int flag_start_log_array_sent;

    int flag_log_array_sent_process;
    int count_data_in_buf;
    unsigned long count_sended_to_pult;

    unsigned long   max_size_logs_hmi;

    int tick_step2;
    int tick_step3;
    int tick_step4;
    int tick_step5;
    int n_log_array_sended;

    unsigned long   max_size_logs_hmi_small;
    unsigned long   max_size_logs_hmi_full;

    int saveLogsToSDCard;
    int ReportLogOut;
    int sdusb;

} t_Logs_with_modbus;

#define LOGS_WITH_MODBUS_DEFAULTS   {0,0,0,0,0, 0,0,0,0, 0,0,0,0,0, 0, 0,0,0,0,0, 0,0, 0,0,0}
extern t_Logs_with_modbus log_to_HMI;




#define LOG_START_ADRES         0xA0000UL
#define LOG_END_ADRES           0xF0000UL
#define LOG_BUFFER_SIZE         0x50000UL   //0x100UL

void fillLogArea(); //TODO for testing only

int alarm_log_get_data(unsigned long pos, int type_log);

int writeLogsArray(int flag_next);
static void prepareWriteLogsArray(void);
static int fillAnalogDataArrayForLogSend(void);
int sendLogToHMI(int status_ok);
void run_store_slow_logs(void);


#endif /* SRC_MAIN_LOGS_HMI_H_ */
