128 lines
6.0 KiB
C
128 lines
6.0 KiB
C
/*
|
|
* control_station.h
|
|
*
|
|
* Created on: 1 èþí. 2020 ã.
|
|
* Author: Vladislav
|
|
*/
|
|
|
|
#ifndef SRC_LIBS_NIO12_CONTROL_STATION_H_
|
|
#define SRC_LIBS_NIO12_CONTROL_STATION_H_
|
|
|
|
#include <control_station_project.h> // ãðóçèì âíåøíèå íàñòðîéêè ïðîåêòà
|
|
|
|
#include "word_structurs.h"
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
#define COUNT_CONTROL_STATION CONTROL_STATION_LAST // êîë-âî ïîñòîâ óïðàâëåíèÿ
|
|
//#define COUNT_CMD_ARR_CONTROL_STATION CONTROL_STATION_LAST // êîë-âî ïîñòîâ óïðàâëåíèÿ
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
#define CONTROL_STATION_TIME_WAIT 250//500 // ïåðèîä îïðîñà ìñåê
|
|
|
|
#define CONTROL_STATION_SETUP_TIME_DETECT_ACTIVE 18//12//6 // â òèêàõ îò CONTROL_STATION_TIME_WAIT
|
|
#define CONTROL_STATION_SETUP_TIME_DETECT_ACTIVE_RESEND_485 2 // â òèêàõ îò CONTROL_STATION_TIME_WAIT
|
|
#define CONTROL_STATION_SETUP_TIME_SEND_CMD_AFTER_OFF 5 // â òèêàõ îò CONTROL_STATION_TIME_WAIT
|
|
|
|
#define CONTROL_STATION_MAX_RAW_DATA 256 //128 // ìàêñèìàëüíîå êîë-âî äàííûõ äëÿ ñûðûõ äàííûõ ïîëó÷åííûõ îò ïîñòîâ
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
typedef struct {
|
|
|
|
unsigned int time_detect_active[COUNT_CONTROL_STATION]; // òåêóùèé òàéìåð äëÿ ïðîïàäàíèè ñâÿçè, ñáðàñûâàåòñÿ ïðè íàëè÷èè ñâÿçè
|
|
unsigned int period_detect_active[COUNT_CONTROL_STATION]; // ïåðèîä îáìåíà ñ ïîñòîì
|
|
unsigned int time_detect_answer_485[COUNT_CONTROL_STATION]; // òåêóùèé òàéìåð äëÿ îæèäàíèÿ îòâåòà ïî Modbus
|
|
|
|
unsigned int setup_time_detect_active[COUNT_CONTROL_STATION]; // âðåìÿ äî ñáðîñà ïðè ïðîïàäàíèè ñâÿçè
|
|
unsigned int setup_time_detect_active_resend_485[COUNT_CONTROL_STATION]; // âðåìÿ äî ñáðîñà ïðè ïðîïàäàíèè ñâÿçè, äîëæåí áûòü ìåíüøå setup_time_detect_active
|
|
unsigned int setup_time_send_cmd_after_off[COUNT_CONTROL_STATION]; // âðåìÿ çàäåðæêè íà ïåðåêëþ÷åíèå êîìàíä, íàïðèìåð íà Go. ×òîá íå áûëî äðåáåçãà íà âêë/âûêë.
|
|
|
|
unsigned int active_control_station[COUNT_CONTROL_STATION]; // àêòèâíûé ïîñò óïðàâëåíèÿ, âîçìîæíî èõ ìîæåò áûòü íåñêîëüêî îäíîâðåìåííî?
|
|
|
|
unsigned int detect_get_data_control_station[COUNT_CONTROL_STATION]; // åñëè åñòü îáìåí ñ ïîñòîì, òî âûñòàâëÿåì òóò ôëàã, îí ñáðîñèòñÿ ïðè update_timers
|
|
|
|
|
|
unsigned int alive_control_station[COUNT_CONTROL_STATION]; // ôëàã î òîì ÷òî ñâÿçü ñ ïîñòîì åñòü
|
|
|
|
|
|
int array_cmd[COUNT_CONTROL_STATION][CONTROL_STATION_CMD_LAST]; // ìàññèâ äàííûõ ïîëó÷åííûõ îò êàæäîãî èç ïîñòîâ, äàííûå ïîñëå parse
|
|
int active_array_cmd[CONTROL_STATION_CMD_LAST]; // ìàññèâ äàííûõ àêòóàëüíûõ äëÿ àâòèâíîãî ïîñòà, äàííûå ïîñëå parse
|
|
|
|
WORD_UINT2BITS_STRUCT raw_array_data[COUNT_CONTROL_STATION][CONTROL_STATION_MAX_RAW_DATA]; // ñûðîé ìàññèâ äàííûõ ïîëó÷åííûõ îò êàæäîãî èç ïîñòîâ, áåç parse.
|
|
|
|
unsigned int flag_message_sent[COUNT_CONTROL_STATION]; // ôëàã íà îæèäàíèå îòâåòà ïî ñèñòåìå çàïðîñ-îòâåò
|
|
unsigned int flag_waiting_answer[COUNT_CONTROL_STATION]; // îæèäàòü ëè îòâåò ïî ñèñòåìå çàïðîñ-îòâåò
|
|
|
|
unsigned int count_ok_modbus[COUNT_CONTROL_STATION]; // ñ÷åò÷èê îøèáîê ïî êîìàíäå modbus 15
|
|
unsigned int count_error_modbus[COUNT_CONTROL_STATION]; // ñ÷åò÷èê îøèáîê ïî êîìàíäå modbus 15
|
|
|
|
unsigned int flag_refresh_array[COUNT_CONTROL_STATION]; // ôëàã íà îæèäàíèå îáíîâëåíèÿ äàííûõ îò modbus
|
|
|
|
/*
|
|
unsigned int cmd_go_from_control_station[COUNT_CONTROL_STATION]; // cmd_go îò ïîñòà ïóñê/ñòîï ØÈÌà
|
|
unsigned int set_izad_from_control_station[COUNT_CONTROL_STATION]; // òîê îò ïîñòà
|
|
unsigned int set_rotor_from_control_station[COUNT_CONTROL_STATION]; // îáîðîòû îò ïîñòà
|
|
unsigned int cmd_charge_from_control_station[COUNT_CONTROL_STATION]; // ñáîð ñõåìû îò ïîñòà
|
|
unsigned int cmd_uncharge_from_control_station[COUNT_CONTROL_STATION]; // ðàçáîð ñõåìû îò ïîñòà
|
|
unsigned int cmd_checkback_from_control_station[COUNT_CONTROL_STATION]; // êâèòèðîâàíèå îò ïîñòà
|
|
unsigned int cmd_test_leds_from_control_station[COUNT_CONTROL_STATION]; // òåñò ëàìï îò ïîñòà
|
|
*/
|
|
|
|
void (*clear)(); // Clear buffers
|
|
void (*update_timers)(); // Îáíóëÿåì òàéìåðû íà ïîñòàõ ñ êîòîðûìè åñòü îáìåí
|
|
void (*detect_active_station)(); // îïðåäåëÿåì êàêîé ïîñò àêòèâåí
|
|
|
|
} CONTROL_STATION;
|
|
|
|
typedef CONTROL_STATION *CONTROL_STATION_handle;
|
|
|
|
|
|
|
|
#define CONTROL_STATION_DEFAULTS { \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
{0}, \
|
|
control_station_clear, \
|
|
control_station_update_timers, \
|
|
control_station_detect_active_station \
|
|
}
|
|
|
|
|
|
|
|
|
|
void control_station_clear(CONTROL_STATION_handle);
|
|
void control_station_update_timers(CONTROL_STATION_handle);
|
|
void control_station_detect_active_station(CONTROL_STATION_handle);
|
|
|
|
|
|
|
|
|
|
extern CONTROL_STATION control_station;
|
|
|
|
|
|
|
|
#endif /* SRC_LIBS_NIO12_CONTROL_STATION_H_ */
|