Stima V4 Slave RAIN  4.2
elaborate_data_task.h
Go to the documentation of this file.
1 
31 #ifndef _ELABORATE_DATA_TASK_H
32 #define _ELABORATE_DATA_TASK_H
33 
34 #include "debug_config.h"
35 #include "local_typedef.h"
36 #include "stima_utility.h"
37 #include "str.h"
38 
39 #include <STM32FreeRTOS.h>
40 #include "thread.hpp"
41 #include "ticks.hpp"
42 #include "semaphore.hpp"
43 #include "queue.hpp"
45 
46 #include "debug_F.h"
47 
48 #include <STM32RTC.h>
49 
50 using namespace cpp_freertos;
51 
52 // Main TASK Switch Delay
53 #define ELABORATE_TASK_WAIT_DELAY_MS (20)
54 #define ELABORATE_TASK_SLEEP_DELAY_MS (850)
55 
56 #define CLOGGED_TIMINGS_VERIFY (28800)
57 
59 typedef struct {
60  rmapdata_t values[SAMPLES_COUNT_MAX];
61  uint16_t count;
62  rmapdata_t *read_ptr;
63  rmapdata_t *write_ptr;
64 } sample_t;
65 
67 typedef struct {
68  bool values[SAMPLES_COUNT_MAX];
69  uint16_t count;
70  bool *read_ptr;
71  bool *write_ptr;
73 
75 typedef struct {
78  cpp_freertos::BinarySemaphore *configurationLock;
79  cpp_freertos::BinarySemaphore *systemStatusLock;
80  cpp_freertos::Queue *systemMessageQueue;
81  cpp_freertos::Queue *elaborateDataQueue;
82  cpp_freertos::Queue *requestDataQueue;
83  cpp_freertos::Queue *reportDataQueue;
84  cpp_freertos::Queue *rainQueue;
86 
88 class ElaborateDataTask : public cpp_freertos::Thread {
89 
91  typedef enum {
95  ELABORATE_DATA_SUSPEND
96  } State_t;
97 
98 public:
99  ElaborateDataTask(const char *taskName, uint16_t stackSize, uint8_t priority, ElaborateDataParam_t elaborateDataParam);
100 
101 protected:
102  virtual void Run();
103 
104 private:
105 
106  #if (ENABLE_STACK_USAGE)
107  void TaskMonitorStack();
108  #endif
109  void TaskWatchDog(uint32_t millis_standby);
110  void TaskState(uint8_t state_position, uint8_t state_subposition, task_flag state_operation);
111 
112  void make_report(uint16_t report_time_s = REPORTS_TIME_S, uint8_t observation_time_s = OBSERVATIONS_TIME_S);
113  uint8_t checkRain(void);
114 
115  // Rtc check event access
116  STM32RTC &rtc = STM32RTC::getInstance();
117 
120 
122 
126 };
127 
128 template<typename buffer_g, typename length_v, typename value_v> value_v bufferRead(buffer_g *buffer, length_v length);
129 template<typename buffer_g, typename length_v, typename value_v> value_v bufferReadBack(buffer_g *buffer, length_v length);
130 template<typename buffer_g, typename value_v> void bufferWrite(buffer_g *buffer, value_v value);
131 template<typename buffer_g> void bufferPtrReset(buffer_g *buffer);
132 template<typename buffer_g, typename length_v> void bufferPtrResetBack(buffer_g *buffer, length_v length);
133 template<typename buffer_g, typename length_v> void incrementBuffer(buffer_g *buffer, length_v length);
134 template<typename buffer_g, typename length_v, typename value_v> void bufferReset(buffer_g *buffer, length_v length);
135 template<typename buffer_g, typename length_v, typename value_v>void addValue(buffer_g *buffer, length_v length, value_v value);
136 
137 #endif
ELABORATE DATA TASK cpp_freertos class.
ElaborateDataParam_t param
State_t
Enum for state switch of running method.
#define REPORTS_TIME_S
Default report (RMAP) time in second.
Definition: config.h:229
#define OBSERVATIONS_TIME_S
Default observation (RMAP) time in second.
Definition: config.h:227
#define SAMPLES_COUNT_MAX
Sample and default value for elaborate task.
Definition: config.h:225
void incrementBuffer(buffer_g *buffer, length_v length)
void bufferPtrResetBack(buffer_g *buffer, length_v length)
void bufferPtrReset(buffer_g *buffer)
value_v bufferRead(buffer_g *buffer, length_v length)
void bufferReset(buffer_g *buffer, length_v length)
void bufferWrite(buffer_g *buffer, value_v value)
void addValue(buffer_g *buffer, length_v length, value_v value)
value_v bufferReadBack(buffer_g *buffer, length_v length)
task_flag
Task state Flag type.
Definition: local_typedef.h:65
Interface STM32 hardware_hal STIMAV4 Header config.
struct local elaborate data parameter
cpp_freertos::Queue * systemMessageQueue
Queue for system message.
cpp_freertos::Queue * elaborateDataQueue
Queue for elaborate data.
configuration_t * configuration
system configuration pointer struct
system_status_t * system_status
system status pointer struct
cpp_freertos::Queue * rainQueue
Queue to RAIN Event.
cpp_freertos::BinarySemaphore * systemStatusLock
semaphore access to system status
cpp_freertos::Queue * requestDataQueue
Queue for request data.
cpp_freertos::BinarySemaphore * configurationLock
semaphore access to configuration
cpp_freertos::Queue * reportDataQueue
Queue for report data.
System module configuration.
Definition: local_typedef.h:48
struct array for maintenance
bool * read_ptr
reader pointer
uint16_t count
samples counter
bool * write_ptr
writer pointer
Rain measure.
Report module.
struct array for module data
rmapdata_t * write_ptr
writer pointer
rmapdata_t * read_ptr
reader pointer
uint16_t count
samples counter
System module status.
Definition: local_typedef.h:84