| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | #include "preset_ai.h"#include "FreeRTOS.h"#include "task.h"#include "settings_api.h"#include "triggers.h"#include "mux.h"#include "log.h"#include <stdio.h>#if defined (MAI_12)#undef DBG#define DBG if(1)extern led_t ai_alarm_led[];hyst_state_t hyst_state[AI_COMMON_NUMBER];preset_cur_t preset_cur[AI_COMMON_NUMBER];// void preset_init(void){    for (int i = 0; i < AI_COMMON_NUMBER; i++)    {        hyst_state[i] = hyst_idle;                preset_cur[i].max = false;        preset_cur[i].min = false;    }}//void preset_set_state(void){    for (int i = 0; i < AI_COMMON_NUMBER; i++)    {        if (((settings.preset_state_bits >> i) & 1) != settings.preset[i].state)        {            settings.preset[i].state = ((settings.preset_state_bits >> 1) & 1);        }    }}//void preset_process(float *data){    bool high = false;    bool low = false;    for (int i = 0; i < AI_COMMON_NUMBER; i++)    {        if ((settings.preset[i].state == 0) || (settings.ai[i].state == 0))            continue;                // 0 - тип уставки - фиксированное значение        if (settings.preset[i].type == 0)        {            high = trig_high_value(data[i], 0, settings.preset[i].max, settings.preset[i].hyst, &hyst_state[i]);            low = trig_low_value(data[i], settings.preset[i].min, 0, settings.preset[i].hyst, &hyst_state[i]);                           if (preset_cur[i].max != high) {                // Запись в журнал о срабатывании верхней уставки                if (high == true) {                    printf("LOG high level! [%f]\r\n", data[i]);                    //log_add_entry(LOG_SETPOINT, 1, i + 1, data[i]);                }                else {                    printf("LOF high norm [%f]\r\n", data[i]);                    //log_add_entry(LOG_SETPOINT, 1, i + 1, data[i]);                }            }            if (preset_cur[i].min != low) {                // Запись в журнал о срабатывании нижней уставки                if (low == true) {                    printf("LOG low level! [%f]\r\n", data[i]);                                    }                else {                    printf("LOF low norm [%f]\r\n", data[i]);                                    }            }                          preset_cur[i].max = high;            preset_cur[i].min = low;            #if 0                        //             if (high) {                DBG printf("Chan: %i, val: %f, HIGH\r\n", i, data[i]);            }                        if (low) {                DBG printf("Chan: %i, val: %f, LOW\r\n", i, data[i]);            }#endif                    }                    }}#endif
 |