summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2019-02-03 03:54:42 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2019-02-03 03:54:42 -0600
commitcfa07a982ddc08418be36784165c4b672eae9742 (patch)
tree74754811a3926af1f190f26b09b36bf3932ab6ea
parent42e4e042754231f00a55b40d2d6364d8a2c41069 (diff)
downloadulab-master.zip
ulab-master.tar.gz
Add average/integral/derivative math operatorsHEADmaster
-rw-r--r--clients/tde/src/part/scope/part.cpp67
1 files changed, 66 insertions, 1 deletions
diff --git a/clients/tde/src/part/scope/part.cpp b/clients/tde/src/part/scope/part.cpp
index 18a19c0..ab9c2d0 100644
--- a/clients/tde/src/part/scope/part.cpp
+++ b/clients/tde/src/part/scope/part.cpp
@@ -482,6 +482,9 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
m_availableMathOperators.append(MathOperator("-", 2));
m_availableMathOperators.append(MathOperator("*", 2));
m_availableMathOperators.append(MathOperator("/", 2));
+ m_availableMathOperators.append(MathOperator("Average", 1));
+ m_availableMathOperators.append(MathOperator("Integral", 1));
+ m_availableMathOperators.append(MathOperator("Derivative", 1));
#ifdef ENABLE_FFT
m_availableMathOperators.append(MathOperator("FFT", 1));
#endif // ENABLE_FFT
@@ -2569,7 +2572,10 @@ void ScopePart::updateMathTraceAllowedVoltsPerDivList(int traceno) {
if ((m_mathOperator[traceno] == "+")
|| (m_mathOperator[traceno] == "-")
|| (m_mathOperator[traceno] == "*")
- || (m_mathOperator[traceno] == "/")) {
+ || (m_mathOperator[traceno] == "/")
+ || (m_mathOperator[traceno] == "Average")
+ || (m_mathOperator[traceno] == "Integral")
+ || (m_mathOperator[traceno] == "Derivative")) {
// Compute intersection of both trace operand volt/div lists
m_mathTraceAllowedVoltsDiv[traceno].clear();
TQDoubleList::iterator it;
@@ -2684,6 +2690,65 @@ void ScopePart::processMathTraces() {
m_base->traceZoomWidget->setSamples(m_maxNumberOfTraces-1+traceno, outputValues);
m_base->traceZoomWidget->setPositions(m_maxNumberOfTraces-1+traceno, outputPositions);
}
+ else if (m_mathOperator[traceno] == "Average") {
+ TQDoubleArray outputValues;
+ TQDoubleArray outputPositions;
+ TQDoubleArray inputValues = m_traceWidget->samples(m_mathFirstOperand[traceno]-1);
+ TQDoubleArray inputPositions = m_traceWidget->positions(m_mathFirstOperand[traceno]-1);
+ outputValues.resize(m_samplesInMathTrace[traceno]);
+ outputPositions = inputPositions;
+
+ double accumulator = 0;
+ for (int i=0; i < m_samplesInMathTrace[traceno]; i++) {
+ accumulator += inputValues[i];
+ }
+ accumulator /= m_samplesInMathTrace[traceno];
+ for (int i=0; i < m_samplesInMathTrace[traceno]; i++) {
+ outputValues[i] = accumulator;
+ }
+
+ m_traceWidget->setSamples(m_maxNumberOfTraces-1+traceno, outputValues);
+ m_traceWidget->setPositions(m_maxNumberOfTraces-1+traceno, outputPositions);
+ m_base->traceZoomWidget->setSamples(m_maxNumberOfTraces-1+traceno, outputValues);
+ m_base->traceZoomWidget->setPositions(m_maxNumberOfTraces-1+traceno, outputPositions);
+ }
+ else if (m_mathOperator[traceno] == "Integral") {
+ TQDoubleArray outputValues;
+ TQDoubleArray outputPositions;
+ TQDoubleArray inputValues = m_traceWidget->samples(m_mathFirstOperand[traceno]-1);
+ TQDoubleArray inputPositions = m_traceWidget->positions(m_mathFirstOperand[traceno]-1);
+ outputValues.resize(m_samplesInMathTrace[traceno]);
+ outputPositions = inputPositions;
+
+ double accumulator = 0;
+ for (int i=0; i < m_samplesInMathTrace[traceno]; i++) {
+ accumulator += inputValues[i];
+ outputValues[i] = accumulator;
+ }
+
+ m_traceWidget->setSamples(m_maxNumberOfTraces-1+traceno, outputValues);
+ m_traceWidget->setPositions(m_maxNumberOfTraces-1+traceno, outputPositions);
+ m_base->traceZoomWidget->setSamples(m_maxNumberOfTraces-1+traceno, outputValues);
+ m_base->traceZoomWidget->setPositions(m_maxNumberOfTraces-1+traceno, outputPositions);
+ }
+ else if (m_mathOperator[traceno] == "Derivative") {
+ TQDoubleArray outputValues;
+ TQDoubleArray outputPositions;
+ TQDoubleArray inputValues = m_traceWidget->samples(m_mathFirstOperand[traceno]-1);
+ TQDoubleArray inputPositions = m_traceWidget->positions(m_mathFirstOperand[traceno]-1);
+ outputValues.resize(m_samplesInMathTrace[traceno]);
+ outputPositions = inputPositions;
+
+ outputValues[0] = 0;
+ for (int i=1; i < m_samplesInMathTrace[traceno]; i++) {
+ outputValues[i] = inputValues[i] - inputValues[i-1];
+ }
+
+ m_traceWidget->setSamples(m_maxNumberOfTraces-1+traceno, outputValues);
+ m_traceWidget->setPositions(m_maxNumberOfTraces-1+traceno, outputPositions);
+ m_base->traceZoomWidget->setSamples(m_maxNumberOfTraces-1+traceno, outputValues);
+ m_base->traceZoomWidget->setPositions(m_maxNumberOfTraces-1+traceno, outputPositions);
+ }
#ifdef ENABLE_FFT
else if (m_mathOperator[traceno] == "FFT") {
TQDoubleArray outputValues;