protegemed, aquisição via A/D simples utilizando interrupção do timer
Dependencies: EthernetInterface NTPClient mbed-rtos mbed
Fork of ptgm_semDMA by
Headers/EventDetector.h@0:fac116e94d44, 2016-01-05 (annotated)
- Committer:
- rebonatto
- Date:
- Tue Jan 05 11:47:35 2016 +0000
- Revision:
- 0:fac116e94d44
Vers?o est?vel sem DMA e FFT. 128 amostras.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rebonatto | 0:fac116e94d44 | 1 | /* |
rebonatto | 0:fac116e94d44 | 2 | * EventDetector.h |
rebonatto | 0:fac116e94d44 | 3 | * |
rebonatto | 0:fac116e94d44 | 4 | * Created on: |
rebonatto | 0:fac116e94d44 | 5 | * Author: |
rebonatto | 0:fac116e94d44 | 6 | */ |
rebonatto | 0:fac116e94d44 | 7 | |
rebonatto | 0:fac116e94d44 | 8 | #ifndef EVENTDETECTOR_H |
rebonatto | 0:fac116e94d44 | 9 | #define EVENTDETECTOR_H |
rebonatto | 0:fac116e94d44 | 10 | |
rebonatto | 0:fac116e94d44 | 11 | #include <stdlib.h> |
rebonatto | 0:fac116e94d44 | 12 | |
rebonatto | 0:fac116e94d44 | 13 | #include "rtos.h" |
rebonatto | 0:fac116e94d44 | 14 | |
rebonatto | 0:fac116e94d44 | 15 | #include "Settings.h" |
rebonatto | 0:fac116e94d44 | 16 | #include "Capture.h" |
rebonatto | 0:fac116e94d44 | 17 | #include "SignalProcessor.h" |
rebonatto | 0:fac116e94d44 | 18 | |
rebonatto | 0:fac116e94d44 | 19 | class CaptureEvent |
rebonatto | 0:fac116e94d44 | 20 | { |
rebonatto | 0:fac116e94d44 | 21 | char m_RFID[9]; |
rebonatto | 0:fac116e94d44 | 22 | int m_Type; |
rebonatto | 0:fac116e94d44 | 23 | int m_OutletNumber; |
rebonatto | 0:fac116e94d44 | 24 | float m_MeanValue; |
rebonatto | 0:fac116e94d44 | 25 | float m_MV2; |
rebonatto | 0:fac116e94d44 | 26 | float m_RMSValue; |
rebonatto | 0:fac116e94d44 | 27 | int m_Under; |
rebonatto | 0:fac116e94d44 | 28 | int m_Over; |
rebonatto | 0:fac116e94d44 | 29 | float m_Gain; |
rebonatto | 0:fac116e94d44 | 30 | int m_Offset; |
rebonatto | 0:fac116e94d44 | 31 | int m_Duration; |
rebonatto | 0:fac116e94d44 | 32 | short int m_Samples[NUMBER_OF_SAMPLES]; |
rebonatto | 0:fac116e94d44 | 33 | |
rebonatto | 0:fac116e94d44 | 34 | public: |
rebonatto | 0:fac116e94d44 | 35 | |
rebonatto | 0:fac116e94d44 | 36 | CaptureEvent(); |
rebonatto | 0:fac116e94d44 | 37 | |
rebonatto | 0:fac116e94d44 | 38 | //void Setup(char* rfid,int type,int outlet,float mv,float rms,float gain, int offset,float* sin, float* cos); |
rebonatto | 0:fac116e94d44 | 39 | void Setup(char* rfid, int type, int outlet, float mv, float mv2, float rms, int under, int over, float gain, int offset, int duration, short int *samples); |
rebonatto | 0:fac116e94d44 | 40 | |
rebonatto | 0:fac116e94d44 | 41 | char* get_RFID() { return m_RFID; } |
rebonatto | 0:fac116e94d44 | 42 | int get_Type() { return m_Type; } |
rebonatto | 0:fac116e94d44 | 43 | int get_OutletNumber() { return m_OutletNumber; } |
rebonatto | 0:fac116e94d44 | 44 | float get_MeanValue() { return m_MeanValue; } |
rebonatto | 0:fac116e94d44 | 45 | float get_MV2() { return m_MV2; } |
rebonatto | 0:fac116e94d44 | 46 | float get_RMSValue() { return m_RMSValue; } |
rebonatto | 0:fac116e94d44 | 47 | int get_Under() { return m_Under; } |
rebonatto | 0:fac116e94d44 | 48 | int get_Over() { return m_Over; } |
rebonatto | 0:fac116e94d44 | 49 | float get_Gain() { return m_Gain; } |
rebonatto | 0:fac116e94d44 | 50 | int get_Offset() { return m_Offset; } |
rebonatto | 0:fac116e94d44 | 51 | int get_Duration() { return m_Duration; } |
rebonatto | 0:fac116e94d44 | 52 | short int get_SampleValue(int idx) { return m_Samples[idx];} |
rebonatto | 0:fac116e94d44 | 53 | }; |
rebonatto | 0:fac116e94d44 | 54 | |
rebonatto | 0:fac116e94d44 | 55 | typedef Mail<CaptureEvent,LENGTH_MAIL_BOX> CaptureMailbox; |
rebonatto | 0:fac116e94d44 | 56 | |
rebonatto | 0:fac116e94d44 | 57 | class EventDetector |
rebonatto | 0:fac116e94d44 | 58 | { |
rebonatto | 0:fac116e94d44 | 59 | protected: |
rebonatto | 0:fac116e94d44 | 60 | |
rebonatto | 0:fac116e94d44 | 61 | static CaptureMailbox m_EventMailbox; |
rebonatto | 0:fac116e94d44 | 62 | static const int m_EventLimit; |
rebonatto | 0:fac116e94d44 | 63 | |
rebonatto | 0:fac116e94d44 | 64 | static EventDetector m_Detector[NUMBER_OF_CHANNELS]; |
rebonatto | 0:fac116e94d44 | 65 | |
rebonatto | 0:fac116e94d44 | 66 | bool m_OutletTriggered; |
rebonatto | 0:fac116e94d44 | 67 | int m_EventCounter; |
rebonatto | 0:fac116e94d44 | 68 | int m_Channel; |
rebonatto | 0:fac116e94d44 | 69 | Timer m_tempo; |
rebonatto | 0:fac116e94d44 | 70 | |
rebonatto | 0:fac116e94d44 | 71 | //void SendMessage(int ext,float rmsvalue); |
rebonatto | 0:fac116e94d44 | 72 | void SendMessage(int ext, float rmsvalue, float mv2, int under, int over, int duration); |
rebonatto | 0:fac116e94d44 | 73 | |
rebonatto | 0:fac116e94d44 | 74 | int TimeDelay(int t); |
rebonatto | 0:fac116e94d44 | 75 | |
rebonatto | 0:fac116e94d44 | 76 | public: |
rebonatto | 0:fac116e94d44 | 77 | |
rebonatto | 0:fac116e94d44 | 78 | EventDetector(int ch); |
rebonatto | 0:fac116e94d44 | 79 | |
rebonatto | 0:fac116e94d44 | 80 | void ExternalTrigger(); |
rebonatto | 0:fac116e94d44 | 81 | |
rebonatto | 0:fac116e94d44 | 82 | //void ProcessEvent(float rmsvalue, int t); |
rebonatto | 0:fac116e94d44 | 83 | void ProcessEvent(float rmsvalue, float mv2, int under, int over); |
rebonatto | 0:fac116e94d44 | 84 | |
rebonatto | 0:fac116e94d44 | 85 | void ShowValues(CaptureEvent* e); |
rebonatto | 0:fac116e94d44 | 86 | |
rebonatto | 0:fac116e94d44 | 87 | static CaptureMailbox& GetMailbox() { return m_EventMailbox; } |
rebonatto | 0:fac116e94d44 | 88 | static EventDetector& get_Detector(int ch) { return m_Detector[ch]; } |
rebonatto | 0:fac116e94d44 | 89 | |
rebonatto | 0:fac116e94d44 | 90 | }; |
rebonatto | 0:fac116e94d44 | 91 | |
rebonatto | 0:fac116e94d44 | 92 | #endif |