Versão do protegemed que calcula o tempo em ms da fuga, calcula o numero de onverflow (valores muito baixo) e underflow (valores muito altos). Além disso, calcula um valor médio a partir dos valores capturados e não apenas pela fft.
Dependencies: EthernetInterface mbed-rtos mbed
Diff: Headers/EventDetector.h
- Revision:
- 0:c64e1194230b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Headers/EventDetector.h Wed Jul 09 21:16:23 2014 +0000 @@ -0,0 +1,97 @@ +/* + * EventDetector.h + * + * Created on: + * Author: + */ + +#ifndef EVENTDETECTOR_H +#define EVENTDETECTOR_H + +#include <stdlib.h> + +#include "rtos.h" + +#include "Settings.h" +#include "Capture.h" +#include "SignalProcessor.h" + +class CaptureEvent +{ + char m_RFID[9]; + int m_Type; + int m_OutletNumber; + float m_MeanValue; + float m_MV2; + float m_RMSValue; + int m_Under; + int m_Over; + float m_Gain; + int m_Offset; + int m_Duration; + float m_Sin[NUMBER_OF_HARMONICS]; + float m_Cos[NUMBER_OF_HARMONICS]; + +public: + + CaptureEvent(); + + //void Setup(char* rfid,int type,int outlet,float mv,float rms,float gain, int offset,float* sin, float* cos); + void Setup(char* rfid, int type, int outlet, float mv, float mv2, float rms, int under, int over, float gain, int offset, int duration, float* sin, float* cos); + + char* get_RFID() { return m_RFID; } + int get_Type() { return m_Type; } + int get_OutletNumber() { return m_OutletNumber; } + float get_MeanValue() { return m_MeanValue; } + float get_MV2() { return m_MV2; } + float get_RMSValue() { return m_RMSValue; } + int get_Under() { return m_Under; } + int get_Over() { return m_Over; } + float get_Gain() { return m_Gain; } + int get_Offset() { return m_Offset; } + int get_Duration() { return m_Duration; } + float get_SineValue(int idx) { return m_Sin[idx]; } + float get_CossineValue(int idx) { return m_Cos[idx]; } +}; + +typedef Mail<CaptureEvent,LENGTH_MAIL_BOX> CaptureMailbox; + +class EventDetector +{ +protected: + + static CaptureMailbox m_EventMailbox; + static const int m_EventLimit; + + static EventDetector m_Detector[NUMBER_OF_CHANNELS]; + + bool m_OutletTriggered; + int m_EventCounter; + int m_Channel; + Timer m_tempo; + + //void OnTrigger(float rmsvalue); + void OnTrigger(float rmsvalue, float mv2, int under, int over, int duration); + + //void SendMessage(int ext,float rmsvalue); + void SendMessage(int ext,float rmsvalue, float mv2, int under, int over, int duration); + + int TimeDelay(int t); + +public: + + EventDetector(int ch); + + void ExternalTrigger(); + + //void ProcessEvent(float rmsvalue, int t); + void ProcessEvent(float rmsvalue, float mv2, int under, int over); + + void ShowValues(CaptureEvent* e); + + static CaptureMailbox& GetMailbox() { return m_EventMailbox; } + static EventDetector& get_Detector(int ch) { return m_Detector[ch]; } + +}; + +#endif \ No newline at end of file