Versão limpa em 04/09/2014. Telnet funcionando.

Dependencies:   EthernetInterface mbed-rtos mbed NTPClient

Revision:
0:66d8bd1f9d4c
Child:
31:647771325538
diff -r 000000000000 -r 66d8bd1f9d4c Headers/EventDetector.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Headers/EventDetector.h	Thu Sep 04 19:40:18 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