]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - apps/pdm-anomaly-detection.git/commitdiff
Add console logs to facilitate test automation
authorHongmei Gou <h-gou@ti.com>
Tue, 11 Jun 2019 17:51:26 +0000 (13:51 -0400)
committerHongmei Gou <h-gou@ti.com>
Tue, 11 Jun 2019 17:51:26 +0000 (13:51 -0400)
Signed-off-by: Hongmei Gou <h-gou@ti.com>
datasource.cpp

index 6d83302f5b7bc92d86d0df8235047b6b58960dee..592459f4b5c07787d10fca670c8fd6dc26768fec 100644 (file)
@@ -98,17 +98,36 @@ void DataSource::update(int sel_waveform, QAbstractSeries *series)
         // Use replace instead of clear + append, it's optimized for performance
         qreal x(0);
         qreal y(0);
-       for (int j = 0; j < m_sampleCount; j ++)
-       {
+       for (int j = 0; j < m_sampleCount; j ++) {
             y = m_samplesArray[DISPLAY_VECTOR*j + sel_waveform];
            x = j;
+            /* Time series 4 is for displaying the anomaly detection threshold
+             * (positive value). It is also carrying the stage information
+             * (calibration or anomaly detection): offset of 100 for calibration;
+             * offset of -100 for anomaly detection, as used in motor_pdm_process() */
             if (sel_waveform==4) {
-               if (y > 100) {y = y - 100; setPdmStage("Calibration......");}
-               if (y < -50) {y = y + 100; setPdmStage("Looking for anomaly......");}
+                if (y > 100) {
+                    y = y - 100;
+                    setPdmStage("Calibration......");
+                    std::cout << "Calibration......" << std::endl;
+                }
+                if (y < -50) {
+                    y = y + 100;
+                    setPdmStage("Looking for anomaly......");
+                    std::cout << "Looking for anomaly......" << std::endl;
+                }
             }
             points.replace(j, QPointF(x, y));
-            if ((sel_waveform==5) && (y>0)) setAnomalyDetection("Anomaly detected!!!");
-            if ((sel_waveform==5) && (y<=0)) setAnomalyDetection("");
+            /* Time series 5 is for displaying the anomaly detection results:
+             * value 0 indicates the normal operation, and positive value
+             * anomaly detection threshold*ratio(>1) indicates anomalies */
+            if ((sel_waveform==5) && (y>0)) {
+                setAnomalyDetection("Anomaly detected!!!");
+                std::cout << "Anomaly detected!!!" << std::endl;
+            }
+            if ((sel_waveform==5) && (y<=0)) {
+                setAnomalyDetection("");
+            }
         }
         xySeries->replace(points);
     }