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

Dependencies:   EthernetInterface mbed-rtos mbed NTPClient

Revision:
43:69afea5f5a4d
Parent:
42:d6f9ce115eaf
--- a/Codes/EventDetector.cpp	Mon Jan 18 18:01:59 2016 +0000
+++ b/Codes/EventDetector.cpp	Mon Jan 18 18:26:03 2016 +0000
@@ -48,21 +48,20 @@
 void EventDetector::ProcessEvent(float rmsvalue, float mv2, int under, int over)
 {
     int i, tempofuga = 0;    
-    //float buf[NUMBER_OF_SAMPLES*2], newvm;    
-    float newvm, aux;
+    float buf[NUMBER_OF_SAMPLES*2];    
+    float newvm;
     
     if(rmsvalue > Settings::get_Limit(m_Channel))                
     {
         /* Retira o VM das amostras */
         //pega os dados da captura atual
         newvm = 0;
-        //Capture::CopyBufferFloat(m_Channel,buf);
+        Capture::CopyBuffer(m_Channel,buf);
 
         /* Retira o valorMedio de todas as amostras */                                                 
        for(i=0; i < NUMBER_OF_SAMPLES; i++){
-            aux = Capture::GetValue(i, m_Channel) - mv2;
-            Capture::PutValue(i, m_Channel,  aux) ;
-            newvm += aux;
+            buf[i] -= mv2;
+            newvm += buf[i];
         }
         
         if ( m_EventCounter == Settings::get_EventLimit() ){                    
@@ -70,7 +69,7 @@
             //printf("Novo valor medio %f RMS original %f\n", mv2, rmsvalue);
         }
             
-        rmsvalue = SignalProcessor::CalculateRMSFloat(&Capture::m_AdcBuffers[m_Channel][0], m_Channel);
+        rmsvalue = SignalProcessor::CalculateRMSFloat(buf, m_Channel);
         
         if(!m_OutletTriggered)
         {
@@ -88,7 +87,7 @@
                          
                     //OnTrigger(buf, rmsvalue, mv2, under, over, 0); //TODO: must change the parameter of this function call         
                     
-                    SendMessage(0, rmsvalue, mv2, under, over, 0);                           
+                    SendMessage(buf, rmsvalue, mv2, under, over, 0);                           
                     
                     m_EventCounter = 0;
                 }
@@ -118,7 +117,7 @@
                     tempofuga = 0;
                 m_OutletTriggered = false;
                 
-                SendMessage(0, rmsvalue, mv2, under, over, tempofuga);
+                SendMessage(buf, rmsvalue, mv2, under, over, tempofuga);
                 //printf("===> contliga %d contdesliga %d\n", contliga, contdesl);
                                 
                 m_EventCounter = 0;
@@ -154,12 +153,13 @@
 void EventDetector::ExternalTrigger()
 {
     // Ajustar valores de mv2, under, over e duration na chamada!!!
-    SendMessage(1, 0, 0, 0, 0, 0);
+    SendMessage(NULL, 0, 0, 0, 0, 0);
 }
 
 //void EventDetector::SendMessage(int ext,float rmsvalue)
-void EventDetector::SendMessage(int ext, float rmsvalue, float mv2, int under, int over, int duration)
+void EventDetector::SendMessage(float *buffer, float rmsvalue, float mv2, int under, int over, int duration)
 {       
+    int ext=0;// So para compatibilidade, foram retirada as mensagem externas
     int flagrfid = 0;
     float seno[NUMBER_OF_HARMONICS+1],coss[NUMBER_OF_HARMONICS+1],mv;
     int type=0,outlet_number=0, aux=0;
@@ -226,7 +226,7 @@
     
     
     if (type == 1 || type == 2 || type == 4) // Calula FFT s nos eventos de fuga, acompanhamento de fuga (diferencial) e liga
-        SignalProcessor::CalculateFFT(&Capture::m_AdcBuffers[m_Channel][0],seno,coss,&mv,1, m_Channel);        
+        SignalProcessor::CalculateFFT(buffer,seno,coss,&mv,1, m_Channel);        
     else
         for(int i=0; i < Settings::get_MaxHarmonics(); i++)
             seno[i] = coss[i] = 0;