Advertisement
Nuke29

tech_channel.h

Oct 3rd, 2022 (edited)
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.64 KB | Source Code | 0 0
  1. #ifndef INC_TECH_CHANNEL_H_
  2. #define INC_TECH_CHANNEL_H_
  3.  
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7.  
  8. #include "global.h"
  9. #include <stdint.h>
  10. #include <stddef.h>
  11.  
  12. class Tech_Channel {
  13. public:
  14.     Tech_Channel(const Tech_Channel& rhs) = delete;
  15.     Tech_Channel(Tech_Channel&& rhs) = delete;
  16.     Tech_Channel& operator =(const Tech_Channel& rhs) = delete;
  17.     Tech_Channel& operator =(Tech_Channel&& rhs) = delete;
  18.  
  19.     virtual ~Tech_Channel() = default;
  20.  
  21.     virtual void push_to_calc(int64_t data1_, int64_t data2_, int64_t data3_) = 0;
  22.     virtual const int get_triggered() const = 0;
  23.     virtual const int get_trigglvl() const = 0;
  24.  
  25.     virtual const int ret_events_count() const {
  26.         return events_count;
  27.     }
  28.     virtual void reset_events_count() {
  29.         events_count = 0;
  30.     }
  31.  
  32.     bool has_detected();
  33.     void switch_to_running_mode();
  34.     void switch_to_background_mode();
  35.     void stop_triggering();
  36.  
  37.     static constexpr int tech_ch_length = 1700;
  38.     static constexpr int silence_sec = 15;
  39.  
  40. protected:
  41.     Tech_Channel();
  42.  
  43.     bool is_background_mode_on = true;
  44.     bool is_triggered = false;
  45.     int64_t tech_buf[tech_ch_length];
  46.     int events_count = 0;
  47. };
  48.  
  49. inline
  50. Tech_Channel::Tech_Channel() : tech_buf{} // init tech_buf with 0
  51. {}
  52.  
  53. inline
  54. bool Tech_Channel::has_detected() {
  55.     return is_triggered;
  56. }
  57.  
  58. inline
  59. void Tech_Channel::switch_to_background_mode() {
  60.     is_background_mode_on = true;
  61.     is_triggered = false;
  62. }
  63.  
  64. inline
  65. void Tech_Channel::stop_triggering() {
  66.     is_triggered = false;
  67. }
  68.  
  69. inline
  70. void Tech_Channel::switch_to_running_mode() {
  71.     is_background_mode_on = false;
  72.     is_triggered = false;
  73. }
  74.  
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78.  
  79. #endif /* INC_TECH_CHANNEL_H_ */
  80.  
Tags: Ring buffer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement