/*
 * detect_overload.h
 *
 *  Created on: 15 дек. 2020 г.
 *      Author: star
 */

#ifndef SRC_MAIN_DETECT_OVERLOAD_H_
#define SRC_MAIN_DETECT_OVERLOAD_H_

typedef struct {
    _iq val;    //Текущее значение
    _iq level_overload; //Уровень перегрузки
    int overload_detected; //Ограничение включено

    unsigned long time_over_tics;
    unsigned long time_latch_tics;
    unsigned long tics_counter;

    int (*calc)();
} DETECT_OVERLOAD;

#define DETECT_OVERLOAD_DEFAULTS {0,0,0, 0,0,0, \
                        calc_detect_overload }

void init_detect_overloads(void);
int calc_detect_overload(DETECT_OVERLOAD *v);
void check_all_power_limits();

extern DETECT_OVERLOAD out_I_over_1_6;

#endif /* SRC_MAIN_DETECT_OVERLOAD_H_ */
