/* * control_station.c * * Created on: 1 июн. 2020 г. * Author: Yura */ #include "control_station.h" #include "global_time.h" #pragma DATA_SECTION(control_station, ".slow_vars") CONTROL_STATION control_station = CONTROL_STATION_DEFAULTS; /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// void control_station_clear(CONTROL_STATION_handle cs) { int i,k,j; for (i=0;icount_error_modbus[i] = 0; cs->count_ok_modbus[i] = 0; cs->flag_waiting_answer[i] = 0; cs->flag_message_sent[i] = 0; cs->active_control_station[i] = 0; cs->alive_control_station[i] = 0; for (k=0;karray_cmd[i][k] = 0; cs->detect_get_data_control_station[i] = 0; cs->period_detect_active[i] = 0; cs->setup_time_detect_active[i] = CONTROL_STATION_SETUP_TIME_DETECT_ACTIVE; cs->setup_time_detect_active_resend_485[i] = CONTROL_STATION_SETUP_TIME_DETECT_ACTIVE_RESEND_485; cs->setup_time_send_cmd_after_off[i] = CONTROL_STATION_SETUP_TIME_SEND_CMD_AFTER_OFF; cs->time_detect_active[i] = 0; cs->time_detect_answer_485[i] = 0; for (k=0;kraw_array_data[i][k].all = 0; for (j=0;jraw_array_data_temp[i][k][j].all = 0; } cs->flag_refresh_array[i] = 0; cs->prev_CAN_count_cycle_input_units[i] = 0; cs->count_raw_array_data_temp[i] = 0; } for (k=0;kactive_array_cmd[k] = 0; } /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// void control_station_update_timers(CONTROL_STATION_handle cs) { static unsigned int old_time = 0; volatile int i; if (!detect_pause_milisec(CONTROL_STATION_TIME_WAIT,&old_time)) return; for (i=0;iflag_message_sent[i] == 1) (cs->time_detect_answer_485[i])++; // cs->time_detect_answer_485[i] = 0; if (cs->detect_get_data_control_station[i]) { cs->period_detect_active[i] = cs->time_detect_active[i]; cs->time_detect_active[i] = 0; cs->detect_get_data_control_station[i] = 0; cs->alive_control_station[i] = 1; } else { if (cs->time_detect_active[i]>=cs->setup_time_detect_active[i]) { cs->alive_control_station[i] = 0; // тут сдох cs->period_detect_active[i] = 0; // cs->flag_message_sent[i] = 0; cs->time_detect_active[i] = cs->setup_time_detect_active[i]+1; } else { cs->time_detect_active[i]++; // if (cs->flag_message_sent[i]) // { // if (cs->flag_waiting_answer[i]) // cs->time_detect_active[i]++; // else // { // cs->time_detect_active[i] = 0; // } // } // else // cs->time_detect_active[i]++; } } } } /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// void control_station_detect_active_station(CONTROL_STATION_handle cs) { } /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////