Versão sem FFT e aquisição por DMA. 256 amostras.

Dependencies:   EthernetInterface NTPClient mbed-rtos mbed

Committer:
rebonatto
Date:
Tue Jan 05 11:45:44 2016 +0000
Revision:
0:e57bc370d339
Vers?o est?vel sem calculo de FFT. Aquisi??o por DMA. Usa 256 amostras.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rebonatto 0:e57bc370d339 1 /*
rebonatto 0:e57bc370d339 2 * EventDetector.h
rebonatto 0:e57bc370d339 3 *
rebonatto 0:e57bc370d339 4 * Created on:
rebonatto 0:e57bc370d339 5 * Author:
rebonatto 0:e57bc370d339 6 */
rebonatto 0:e57bc370d339 7
rebonatto 0:e57bc370d339 8 #ifndef EVENTDETECTOR_H
rebonatto 0:e57bc370d339 9 #define EVENTDETECTOR_H
rebonatto 0:e57bc370d339 10
rebonatto 0:e57bc370d339 11 #include <stdlib.h>
rebonatto 0:e57bc370d339 12
rebonatto 0:e57bc370d339 13 #include "rtos.h"
rebonatto 0:e57bc370d339 14
rebonatto 0:e57bc370d339 15 #include "Settings.h"
rebonatto 0:e57bc370d339 16 #include "Capture.h"
rebonatto 0:e57bc370d339 17 #include "SignalProcessor.h"
rebonatto 0:e57bc370d339 18
rebonatto 0:e57bc370d339 19 class CaptureEvent
rebonatto 0:e57bc370d339 20 {
rebonatto 0:e57bc370d339 21 char m_RFID[9];
rebonatto 0:e57bc370d339 22 int m_Type;
rebonatto 0:e57bc370d339 23 int m_OutletNumber;
rebonatto 0:e57bc370d339 24 float m_MeanValue;
rebonatto 0:e57bc370d339 25 float m_MV2;
rebonatto 0:e57bc370d339 26 float m_RMSValue;
rebonatto 0:e57bc370d339 27 int m_Under;
rebonatto 0:e57bc370d339 28 int m_Over;
rebonatto 0:e57bc370d339 29 float m_Gain;
rebonatto 0:e57bc370d339 30 int m_Offset;
rebonatto 0:e57bc370d339 31 int m_Duration;
rebonatto 0:e57bc370d339 32 short int m_Samples[NUMBER_OF_SAMPLES];
rebonatto 0:e57bc370d339 33
rebonatto 0:e57bc370d339 34 public:
rebonatto 0:e57bc370d339 35
rebonatto 0:e57bc370d339 36 CaptureEvent();
rebonatto 0:e57bc370d339 37
rebonatto 0:e57bc370d339 38 //void Setup(char* rfid,int type,int outlet,float mv,float rms,float gain, int offset,float* sin, float* cos);
rebonatto 0:e57bc370d339 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:e57bc370d339 40
rebonatto 0:e57bc370d339 41 char* get_RFID() { return m_RFID; }
rebonatto 0:e57bc370d339 42 int get_Type() { return m_Type; }
rebonatto 0:e57bc370d339 43 int get_OutletNumber() { return m_OutletNumber; }
rebonatto 0:e57bc370d339 44 float get_MeanValue() { return m_MeanValue; }
rebonatto 0:e57bc370d339 45 float get_MV2() { return m_MV2; }
rebonatto 0:e57bc370d339 46 float get_RMSValue() { return m_RMSValue; }
rebonatto 0:e57bc370d339 47 int get_Under() { return m_Under; }
rebonatto 0:e57bc370d339 48 int get_Over() { return m_Over; }
rebonatto 0:e57bc370d339 49 float get_Gain() { return m_Gain; }
rebonatto 0:e57bc370d339 50 int get_Offset() { return m_Offset; }
rebonatto 0:e57bc370d339 51 int get_Duration() { return m_Duration; }
rebonatto 0:e57bc370d339 52 short int get_SampleValue(int idx) { return m_Samples[idx];}
rebonatto 0:e57bc370d339 53 };
rebonatto 0:e57bc370d339 54
rebonatto 0:e57bc370d339 55 typedef Mail<CaptureEvent,LENGTH_MAIL_BOX> CaptureMailbox;
rebonatto 0:e57bc370d339 56
rebonatto 0:e57bc370d339 57 class EventDetector
rebonatto 0:e57bc370d339 58 {
rebonatto 0:e57bc370d339 59 protected:
rebonatto 0:e57bc370d339 60
rebonatto 0:e57bc370d339 61 static CaptureMailbox m_EventMailbox;
rebonatto 0:e57bc370d339 62 static const int m_EventLimit;
rebonatto 0:e57bc370d339 63
rebonatto 0:e57bc370d339 64 static EventDetector m_Detector[NUMBER_OF_CHANNELS];
rebonatto 0:e57bc370d339 65
rebonatto 0:e57bc370d339 66 bool m_OutletTriggered;
rebonatto 0:e57bc370d339 67 int m_EventCounter;
rebonatto 0:e57bc370d339 68 int m_Channel;
rebonatto 0:e57bc370d339 69 Timer m_tempo;
rebonatto 0:e57bc370d339 70
rebonatto 0:e57bc370d339 71 //void SendMessage(int ext,float rmsvalue);
rebonatto 0:e57bc370d339 72 void SendMessage(int ext, short int *buf, float rmsvalue, float mv2, int under, int over, int duration);
rebonatto 0:e57bc370d339 73
rebonatto 0:e57bc370d339 74 int TimeDelay(int t);
rebonatto 0:e57bc370d339 75
rebonatto 0:e57bc370d339 76 public:
rebonatto 0:e57bc370d339 77
rebonatto 0:e57bc370d339 78 EventDetector(int ch);
rebonatto 0:e57bc370d339 79
rebonatto 0:e57bc370d339 80 void ExternalTrigger();
rebonatto 0:e57bc370d339 81
rebonatto 0:e57bc370d339 82 //void ProcessEvent(float rmsvalue, int t);
rebonatto 0:e57bc370d339 83 void ProcessEvent(float rmsvalue, float mv2, int under, int over);
rebonatto 0:e57bc370d339 84
rebonatto 0:e57bc370d339 85 void ShowValues(CaptureEvent* e);
rebonatto 0:e57bc370d339 86
rebonatto 0:e57bc370d339 87 static CaptureMailbox& GetMailbox() { return m_EventMailbox; }
rebonatto 0:e57bc370d339 88 static EventDetector& get_Detector(int ch) { return m_Detector[ch]; }
rebonatto 0:e57bc370d339 89
rebonatto 0:e57bc370d339 90 };
rebonatto 0:e57bc370d339 91
rebonatto 0:e57bc370d339 92 #endif