diff options
author | Hongmei Gou | 2019-06-11 12:51:26 -0500 |
---|---|---|
committer | Hongmei Gou | 2019-06-11 12:51:26 -0500 |
commit | 5a14649e3834c7d45d522d35b28ec113db44ab1c (patch) | |
tree | 15b52ef13039d09917d13bea90e17cef8fa6d1f1 | |
parent | 832c4021de19998c7e47e94e1868943c9a145489 (diff) | |
download | pdm-anomaly-detection-5a14649e3834c7d45d522d35b28ec113db44ab1c.tar.gz pdm-anomaly-detection-5a14649e3834c7d45d522d35b28ec113db44ab1c.tar.xz pdm-anomaly-detection-5a14649e3834c7d45d522d35b28ec113db44ab1c.zip |
Add console logs to facilitate test automation
Signed-off-by: Hongmei Gou <h-gou@ti.com>
-rw-r--r-- | datasource.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/datasource.cpp b/datasource.cpp index 6d83302..592459f 100644 --- a/datasource.cpp +++ b/datasource.cpp | |||
@@ -98,17 +98,36 @@ void DataSource::update(int sel_waveform, QAbstractSeries *series) | |||
98 | // Use replace instead of clear + append, it's optimized for performance | 98 | // Use replace instead of clear + append, it's optimized for performance |
99 | qreal x(0); | 99 | qreal x(0); |
100 | qreal y(0); | 100 | qreal y(0); |
101 | for (int j = 0; j < m_sampleCount; j ++) | 101 | for (int j = 0; j < m_sampleCount; j ++) { |
102 | { | ||
103 | y = m_samplesArray[DISPLAY_VECTOR*j + sel_waveform]; | 102 | y = m_samplesArray[DISPLAY_VECTOR*j + sel_waveform]; |
104 | x = j; | 103 | x = j; |
104 | /* Time series 4 is for displaying the anomaly detection threshold | ||
105 | * (positive value). It is also carrying the stage information | ||
106 | * (calibration or anomaly detection): offset of 100 for calibration; | ||
107 | * offset of -100 for anomaly detection, as used in motor_pdm_process() */ | ||
105 | if (sel_waveform==4) { | 108 | if (sel_waveform==4) { |
106 | if (y > 100) {y = y - 100; setPdmStage("Calibration......");} | 109 | if (y > 100) { |
107 | if (y < -50) {y = y + 100; setPdmStage("Looking for anomaly......");} | 110 | y = y - 100; |
111 | setPdmStage("Calibration......"); | ||
112 | std::cout << "Calibration......" << std::endl; | ||
113 | } | ||
114 | if (y < -50) { | ||
115 | y = y + 100; | ||
116 | setPdmStage("Looking for anomaly......"); | ||
117 | std::cout << "Looking for anomaly......" << std::endl; | ||
118 | } | ||
108 | } | 119 | } |
109 | points.replace(j, QPointF(x, y)); | 120 | points.replace(j, QPointF(x, y)); |
110 | if ((sel_waveform==5) && (y>0)) setAnomalyDetection("Anomaly detected!!!"); | 121 | /* Time series 5 is for displaying the anomaly detection results: |
111 | if ((sel_waveform==5) && (y<=0)) setAnomalyDetection(""); | 122 | * value 0 indicates the normal operation, and positive value |
123 | * anomaly detection threshold*ratio(>1) indicates anomalies */ | ||
124 | if ((sel_waveform==5) && (y>0)) { | ||
125 | setAnomalyDetection("Anomaly detected!!!"); | ||
126 | std::cout << "Anomaly detected!!!" << std::endl; | ||
127 | } | ||
128 | if ((sel_waveform==5) && (y<=0)) { | ||
129 | setAnomalyDetection(""); | ||
130 | } | ||
112 | } | 131 | } |
113 | xySeries->replace(points); | 132 | xySeries->replace(points); |
114 | } | 133 | } |