|
|
|
@ -20,6 +20,8 @@
|
|
|
|
|
* http://www.raptorengineeringinc.com
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define ENABLE_FFT
|
|
|
|
|
|
|
|
|
|
#include "define.h"
|
|
|
|
|
#include "part.h"
|
|
|
|
|
|
|
|
|
@ -48,6 +50,10 @@
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_FFT
|
|
|
|
|
#include <ffts/ffts.h>
|
|
|
|
|
#endif // ENABLE_FFT
|
|
|
|
|
|
|
|
|
|
#include "tracewidget.h"
|
|
|
|
|
#include "floatspinbox.h"
|
|
|
|
|
#include "layout.h"
|
|
|
|
@ -183,6 +189,213 @@ void TraceControlWidget::triggerRequested() {
|
|
|
|
|
emit(triggerChannelChangeRequested());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MathTraceControlWidget::MathTraceControlWidget(TQWidget *parent, const char *name)
|
|
|
|
|
: TQWidget(parent, name)
|
|
|
|
|
{
|
|
|
|
|
TQGridLayout *topGrid = new TQGridLayout(this);
|
|
|
|
|
m_groupBox = new TQGroupBox(this);
|
|
|
|
|
m_groupBox->setColumnLayout(0, TQt::Vertical);
|
|
|
|
|
topGrid->addMultiCellWidget(m_groupBox, 0, 0, 0, 0);
|
|
|
|
|
m_groupBox->setTitle(i18n("Unknown Math Channel"));
|
|
|
|
|
m_primaryLayout = new TQGridLayout(m_groupBox->layout(), 1, 1, KDialog::spacingHint());
|
|
|
|
|
|
|
|
|
|
m_channelEnabledCheckBox = new TQCheckBox(m_groupBox);
|
|
|
|
|
connect(m_channelEnabledCheckBox, SIGNAL(clicked()), this, SLOT(enableClicked()));
|
|
|
|
|
m_channelEnabledCheckBox->setText(i18n("Enable"));
|
|
|
|
|
m_primaryLayout->addMultiCellWidget(m_channelEnabledCheckBox, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
|
|
m_voltsDivComboBox = new TQComboBox(m_groupBox);
|
|
|
|
|
connect(m_voltsDivComboBox, SIGNAL(activated(int)), this, SLOT(vdivChanged(int)));
|
|
|
|
|
m_primaryLayout->addMultiCellWidget(m_voltsDivComboBox, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
|
|
m_verticalUnitsLabel = new TQLabel(m_groupBox);
|
|
|
|
|
m_verticalUnitsLabel->setText(i18n("V/div"));
|
|
|
|
|
m_primaryLayout->addMultiCellWidget(m_verticalUnitsLabel, 0, 0, 2, 2);
|
|
|
|
|
|
|
|
|
|
m_operandFirstComboBox = new TQComboBox(m_groupBox);
|
|
|
|
|
connect(m_operandFirstComboBox, SIGNAL(activated(int)), this, SLOT(operandFirstChanged(int)));
|
|
|
|
|
m_primaryLayout->addMultiCellWidget(m_operandFirstComboBox, 1, 1, 0, 0);
|
|
|
|
|
|
|
|
|
|
m_operandSecondComboBox = new TQComboBox(m_groupBox);
|
|
|
|
|
connect(m_operandSecondComboBox, SIGNAL(activated(int)), this, SLOT(operandSecondChanged(int)));
|
|
|
|
|
m_primaryLayout->addMultiCellWidget(m_operandSecondComboBox, 1, 1, 2, 2);
|
|
|
|
|
|
|
|
|
|
m_operatorComboBox = new TQComboBox(m_groupBox);
|
|
|
|
|
connect(m_operatorComboBox, SIGNAL(activated(int)), this, SLOT(operatorChanged(int)));
|
|
|
|
|
m_primaryLayout->addMultiCellWidget(m_operatorComboBox, 1, 1, 1, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MathTraceControlWidget::~MathTraceControlWidget() {
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::setVoltsPerDivList(TQDoubleList list) {
|
|
|
|
|
m_voltsDivList = list;
|
|
|
|
|
|
|
|
|
|
// Update drop down list
|
|
|
|
|
double prevValue = m_voltsDivComboBox->currentText().toDouble();
|
|
|
|
|
m_voltsDivComboBox->clear();
|
|
|
|
|
TQDoubleList::iterator it;
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (it = m_voltsDivList.begin(); it != m_voltsDivList.end(); ++it) {
|
|
|
|
|
m_voltsDivComboBox->insertItem(TQString("%1").arg(*it), i);
|
|
|
|
|
if (prevValue == (*it)) {
|
|
|
|
|
m_voltsDivComboBox->setCurrentItem(i);
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::setSelectedVoltsPerDiv(double vdiv) {
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (i=0;i<m_voltsDivComboBox->count();i++) {
|
|
|
|
|
if (m_voltsDivComboBox->text(i).toDouble() == vdiv) {
|
|
|
|
|
m_voltsDivComboBox->setCurrentItem(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::setFirstMathOperandList(TQInt16List list) {
|
|
|
|
|
m_firstMathOperandList = list;
|
|
|
|
|
|
|
|
|
|
// Update drop down list
|
|
|
|
|
int prevValue = (m_operandFirstComboBox->currentText().replace("Ch", "")).toInt();
|
|
|
|
|
m_operandFirstComboBox->clear();
|
|
|
|
|
TQInt16List::iterator it;
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (it = m_firstMathOperandList.begin(); it != m_firstMathOperandList.end(); ++it) {
|
|
|
|
|
m_operandFirstComboBox->insertItem(TQString("Ch%1").arg(*it), i);
|
|
|
|
|
if (prevValue == (*it)) {
|
|
|
|
|
m_operandFirstComboBox->setCurrentItem(i);
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::setSelectedFirstMathOperand(int channel) {
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (i=0;i<m_operandFirstComboBox->count();i++) {
|
|
|
|
|
if ((m_operandFirstComboBox->text(i).replace("Ch", "")).toInt() == channel) {
|
|
|
|
|
m_operandFirstComboBox->setCurrentItem(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::setSecondMathOperandList(TQInt16List list) {
|
|
|
|
|
m_secondMathOperandList = list;
|
|
|
|
|
|
|
|
|
|
// Update drop down list
|
|
|
|
|
int prevValue = (m_operandSecondComboBox->currentText().replace("Ch", "")).toInt();
|
|
|
|
|
m_operandSecondComboBox->clear();
|
|
|
|
|
TQInt16List::iterator it;
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (it = m_secondMathOperandList.begin(); it != m_secondMathOperandList.end(); ++it) {
|
|
|
|
|
m_operandSecondComboBox->insertItem(TQString("Ch%1").arg(*it), i);
|
|
|
|
|
if (prevValue == (*it)) {
|
|
|
|
|
m_operandSecondComboBox->setCurrentItem(i);
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::setSelectedSecondMathOperand(int channel) {
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (i=0;i<m_operandSecondComboBox->count();i++) {
|
|
|
|
|
if ((m_operandSecondComboBox->text(i).replace("Ch", "")).toInt() == channel) {
|
|
|
|
|
m_operandSecondComboBox->setCurrentItem(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::setMathOperatorList(MathOperatorList list) {
|
|
|
|
|
m_mathOperatorList = list;
|
|
|
|
|
|
|
|
|
|
// Update drop down list
|
|
|
|
|
TQString prevValue = m_operatorComboBox->currentText();
|
|
|
|
|
m_operatorComboBox->clear();
|
|
|
|
|
MathOperatorList::iterator it;
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (it = m_mathOperatorList.begin(); it != m_mathOperatorList.end(); ++it) {
|
|
|
|
|
m_operatorComboBox->insertItem((*it).first, i);
|
|
|
|
|
if (prevValue == (*it).first) {
|
|
|
|
|
m_operatorComboBox->setCurrentItem(i);
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::setSelectedMathOperator(TQString op) {
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (i=0;i<m_operatorComboBox->count();i++) {
|
|
|
|
|
if (m_operatorComboBox->text(i) == op) {
|
|
|
|
|
m_operatorComboBox->setCurrentItem(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateMathOperatorOperandVisibility();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::setTraceEnabled(bool enabled) {
|
|
|
|
|
m_channelEnabledCheckBox->setChecked(enabled);
|
|
|
|
|
m_voltsDivComboBox->setEnabled(enabled);
|
|
|
|
|
m_operandFirstComboBox->setEnabled(enabled);
|
|
|
|
|
m_operandSecondComboBox->setEnabled(enabled);
|
|
|
|
|
m_operatorComboBox->setEnabled(enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::setTraceName(TQString name) {
|
|
|
|
|
m_groupBox->setTitle(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::setVerticalUnits(TQString units) {
|
|
|
|
|
m_verticalUnitsLabel->setText(i18n("%1/div").arg(units));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::enableClicked() {
|
|
|
|
|
bool enabled = m_channelEnabledCheckBox->isOn();
|
|
|
|
|
m_voltsDivComboBox->setEnabled(enabled);
|
|
|
|
|
emit(enableChanged(enabled));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::vdivChanged(int index) {
|
|
|
|
|
Q_UNUSED(index)
|
|
|
|
|
double value = m_voltsDivComboBox->currentText().toDouble();
|
|
|
|
|
emit(voltsPerDivChanged(value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::operandFirstChanged(int index) {
|
|
|
|
|
Q_UNUSED(index)
|
|
|
|
|
double value = (m_operandFirstComboBox->currentText().replace("Ch", "")).toInt();
|
|
|
|
|
emit(firstMathOperandChanged(value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::operandSecondChanged(int index) {
|
|
|
|
|
Q_UNUSED(index)
|
|
|
|
|
double value = (m_operandSecondComboBox->currentText().replace("Ch", "")).toInt();
|
|
|
|
|
emit(secondMathOperandChanged(value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::operatorChanged(int index) {
|
|
|
|
|
Q_UNUSED(index)
|
|
|
|
|
updateMathOperatorOperandVisibility();
|
|
|
|
|
emit(mathOperatorChanged(m_operatorComboBox->currentText()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTraceControlWidget::updateMathOperatorOperandVisibility() {
|
|
|
|
|
TQString value = m_operatorComboBox->currentText();
|
|
|
|
|
MathOperatorList::iterator it;
|
|
|
|
|
for (it = m_mathOperatorList.begin(); it != m_mathOperatorList.end(); ++it) {
|
|
|
|
|
if (value == (*it).first) {
|
|
|
|
|
if ((*it).second < 2) {
|
|
|
|
|
m_operandSecondComboBox->hide();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
m_operandSecondComboBox->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimebaseControlWidget::TimebaseControlWidget(TQWidget *parent, const char *name)
|
|
|
|
|
: TQWidget(parent, name)
|
|
|
|
|
{
|
|
|
|
@ -261,9 +474,19 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
|
|
|
|
|
// Initialize data
|
|
|
|
|
m_hdivs = 0;
|
|
|
|
|
m_vdivs = 0;
|
|
|
|
|
m_maxNumberOfTraces = 0;
|
|
|
|
|
m_maxNumberOfMathTraces = 1;
|
|
|
|
|
m_availableMathOperators.append(MathOperator("+", 2));
|
|
|
|
|
m_availableMathOperators.append(MathOperator("-", 2));
|
|
|
|
|
m_availableMathOperators.append(MathOperator("*", 2));
|
|
|
|
|
m_availableMathOperators.append(MathOperator("/", 2));
|
|
|
|
|
#ifdef ENABLE_FFT
|
|
|
|
|
m_availableMathOperators.append(MathOperator("FFT", 1));
|
|
|
|
|
#endif // ENABLE_FFT
|
|
|
|
|
for (int traceno=0; traceno<=MAXTRACES; traceno++) {
|
|
|
|
|
m_samplesInTrace[traceno] = 0;
|
|
|
|
|
m_channelActive[traceno] = false;
|
|
|
|
|
m_traceAllowedVoltsDiv[traceno].clear();
|
|
|
|
|
m_voltsDiv[traceno] = 0;
|
|
|
|
|
m_secsDiv[traceno] = 0;
|
|
|
|
|
m_traceControlWidgetList[traceno] = NULL;
|
|
|
|
@ -271,6 +494,19 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
|
|
|
|
|
m_voltsDivSet[traceno] = false;
|
|
|
|
|
m_channelActiveSet[traceno] = false;
|
|
|
|
|
}
|
|
|
|
|
for (int traceno=0; traceno<=MAXMATHTRACES; traceno++) {
|
|
|
|
|
m_samplesInMathTrace[traceno] = 0;
|
|
|
|
|
m_mathChannelActive[traceno] = false;
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].clear();
|
|
|
|
|
m_mathVoltsDiv[traceno] = 0;
|
|
|
|
|
m_mathSecsDiv[traceno] = 0;
|
|
|
|
|
m_mathFirstOperand[traceno] = 0;
|
|
|
|
|
m_mathSecondOperand[traceno] = 0;
|
|
|
|
|
m_mathOperator[traceno] = TQString::null;
|
|
|
|
|
m_mathHorizontalUnits[traceno] = "s";
|
|
|
|
|
m_mathVerticalUnits[traceno] = "V";
|
|
|
|
|
m_mathTraceControlWidgetList[traceno] = NULL;
|
|
|
|
|
}
|
|
|
|
|
m_triggerLevelSet = false;
|
|
|
|
|
m_triggerChannelSet = false;
|
|
|
|
|
m_horizontalTimebaseSet = false;
|
|
|
|
@ -279,6 +515,7 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
|
|
|
|
|
// Create widgets
|
|
|
|
|
m_base = new ScopeBase(widget());
|
|
|
|
|
m_traceControlWidgetGrid = new TQGridLayout(m_base->traceControlLayoutWidget);
|
|
|
|
|
m_mathTraceControlWidgetGrid = new TQGridLayout(m_base->mathTraceControlLayoutWidget);
|
|
|
|
|
m_timebaseControlWidgetGrid = new TQGridLayout(m_base->timebaseControlLayoutWidget);
|
|
|
|
|
m_timebaseControlWidget = new TimebaseControlWidget(m_base->timebaseControlLayoutWidget);
|
|
|
|
|
connect(m_timebaseControlWidget, SIGNAL(secondsPerDivChanged(double)), this, SLOT(traceControlSDivChanged(double)));
|
|
|
|
@ -943,10 +1180,9 @@ void ScopePart::mainEventLoop() {
|
|
|
|
|
TQString result;
|
|
|
|
|
ds >> result;
|
|
|
|
|
if (result == "ACK") {
|
|
|
|
|
TQDoubleList list;
|
|
|
|
|
ds >> list;
|
|
|
|
|
ds >> m_traceAllowedVoltsDiv[m_currentOpChannel];
|
|
|
|
|
if (m_traceControlWidgetList[m_currentOpChannel-1]) {
|
|
|
|
|
m_traceControlWidgetList[m_currentOpChannel-1]->setVoltsPerDivList(list);
|
|
|
|
|
m_traceControlWidgetList[m_currentOpChannel-1]->setVoltsPerDivList(m_traceAllowedVoltsDiv[m_currentOpChannel]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_socket->clearFrameTail();
|
|
|
|
@ -1324,6 +1560,7 @@ void ScopePart::mainEventLoop() {
|
|
|
|
|
m_base->traceZoomWidget->setSamples(m_currentOpChannel-1, trace);
|
|
|
|
|
m_base->traceZoomWidget->setPositions(m_currentOpChannel-1, positions);
|
|
|
|
|
postProcessTrace();
|
|
|
|
|
processMathTraces();
|
|
|
|
|
m_traceWidget->repaint(false);
|
|
|
|
|
m_base->traceZoomWidget->repaint(false);
|
|
|
|
|
}
|
|
|
|
@ -1839,7 +2076,7 @@ void ScopePart::stopDAQ() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define WAVEFORM_MAGIC_NUMBER 1
|
|
|
|
|
#define WAVEFORM_FILE_VERSION 2
|
|
|
|
|
#define WAVEFORM_FILE_VERSION 3
|
|
|
|
|
|
|
|
|
|
void ScopePart::saveWaveforms() {
|
|
|
|
|
TQString saveFileName = KFileDialog::getSaveFileName(TQString::null, "*.wfm|Waveform Files (*.wfm)", 0, i18n("Save waveforms..."));
|
|
|
|
@ -1854,17 +2091,28 @@ void ScopePart::saveWaveforms() {
|
|
|
|
|
ds << m_hdivs;
|
|
|
|
|
ds << m_vdivs;
|
|
|
|
|
ds << m_maxNumberOfTraces;
|
|
|
|
|
ds << m_maxNumberOfMathTraces;
|
|
|
|
|
for (int traceno=1; traceno<=m_maxNumberOfTraces; traceno++) {
|
|
|
|
|
TQ_UINT8 boolValue;
|
|
|
|
|
boolValue = m_channelActive[traceno];
|
|
|
|
|
ds << boolValue;
|
|
|
|
|
ds << m_samplesInTrace[traceno];
|
|
|
|
|
ds << m_traceAllowedVoltsDiv[traceno];
|
|
|
|
|
ds << m_voltsDiv[traceno];
|
|
|
|
|
ds << m_secsDiv[traceno];
|
|
|
|
|
ds << m_base->traceZoomWidget->traceOffset(traceno-1);
|
|
|
|
|
ds << m_traceWidget->samples(traceno-1);
|
|
|
|
|
ds << m_traceWidget->positions(traceno-1);
|
|
|
|
|
}
|
|
|
|
|
for (int traceno=1; traceno<=m_maxNumberOfMathTraces; traceno++) {
|
|
|
|
|
TQ_UINT8 boolValue;
|
|
|
|
|
boolValue = m_mathChannelActive[traceno];
|
|
|
|
|
ds << boolValue;
|
|
|
|
|
ds << m_mathVoltsDiv[traceno];
|
|
|
|
|
ds << m_mathFirstOperand[traceno];
|
|
|
|
|
ds << m_mathSecondOperand[traceno];
|
|
|
|
|
ds << m_mathOperator[traceno];
|
|
|
|
|
}
|
|
|
|
|
for (int cursorno=0; cursorno<5; cursorno++) {
|
|
|
|
|
ds << m_traceWidget->cursorPosition(cursorno);
|
|
|
|
|
}
|
|
|
|
@ -1887,11 +2135,17 @@ void ScopePart::recallWaveforms() {
|
|
|
|
|
ds >> m_hdivs;
|
|
|
|
|
ds >> m_vdivs;
|
|
|
|
|
ds >> m_maxNumberOfTraces;
|
|
|
|
|
if (version >= 3) {
|
|
|
|
|
ds >> m_maxNumberOfMathTraces;
|
|
|
|
|
}
|
|
|
|
|
for (int traceno=1; traceno<=m_maxNumberOfTraces; traceno++) {
|
|
|
|
|
TQ_UINT8 boolValue;
|
|
|
|
|
ds >> boolValue;
|
|
|
|
|
m_channelActive[traceno] = (boolValue!=0)?true:false;
|
|
|
|
|
ds >> m_samplesInTrace[traceno];
|
|
|
|
|
if (version >= 3) {
|
|
|
|
|
ds >> m_traceAllowedVoltsDiv[traceno];
|
|
|
|
|
}
|
|
|
|
|
ds >> m_voltsDiv[traceno];
|
|
|
|
|
ds >> m_secsDiv[traceno];
|
|
|
|
|
double offset;
|
|
|
|
@ -1908,6 +2162,17 @@ void ScopePart::recallWaveforms() {
|
|
|
|
|
m_base->traceZoomWidget->setPositions(traceno-1, positions);
|
|
|
|
|
m_base->traceZoomWidget->setTraceOffset(traceno-1, offset);
|
|
|
|
|
}
|
|
|
|
|
if (version >= 3) {
|
|
|
|
|
for (int traceno=1; traceno<=m_maxNumberOfMathTraces; traceno++) {
|
|
|
|
|
TQ_UINT8 boolValue;
|
|
|
|
|
ds >> boolValue;
|
|
|
|
|
m_mathChannelActive[traceno] = (boolValue!=0)?true:false;
|
|
|
|
|
ds >> m_mathVoltsDiv[traceno];
|
|
|
|
|
ds >> m_mathFirstOperand[traceno];
|
|
|
|
|
ds >> m_mathSecondOperand[traceno];
|
|
|
|
|
ds >> m_mathOperator[traceno];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int cursorno=0; cursorno<5; cursorno++) {
|
|
|
|
|
double cursorPos;
|
|
|
|
|
ds >> cursorPos;
|
|
|
|
@ -1925,6 +2190,7 @@ void ScopePart::recallWaveforms() {
|
|
|
|
|
m_triggerLevel = 0;
|
|
|
|
|
updateGraticule();
|
|
|
|
|
postProcessTrace();
|
|
|
|
|
processMathTraces();
|
|
|
|
|
m_traceWidget->repaint(false);
|
|
|
|
|
m_base->traceZoomWidget->repaint(false);
|
|
|
|
|
updateTraceControlWidgets();
|
|
|
|
@ -1940,7 +2206,7 @@ void ScopePart::recallWaveforms() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScopePart::updateZoomWidgetLimits(const TQRectF& zoomRect) {
|
|
|
|
|
for (int traceno=0; traceno<m_maxNumberOfTraces; traceno++) {
|
|
|
|
|
for (int traceno=0; traceno<m_maxNumberOfTraces+m_maxNumberOfMathTraces; traceno++) {
|
|
|
|
|
TQRectF fullZoomRect = m_traceWidget->displayLimits(traceno);
|
|
|
|
|
double widthSpan = fullZoomRect.width()-fullZoomRect.x();
|
|
|
|
|
double heightSpan = fullZoomRect.height()-fullZoomRect.y();
|
|
|
|
@ -2009,6 +2275,7 @@ void ScopePart::updateGraticule() {
|
|
|
|
|
if (m_maxNumberOfTraces > 2) m_base->traceZoomWidget->setTraceColor(2, TQColor(255, 255, 128));
|
|
|
|
|
if (m_maxNumberOfTraces > 3) m_base->traceZoomWidget->setTraceColor(3, TQColor(128, 128, 255));
|
|
|
|
|
|
|
|
|
|
TQInt16List activeChannels;
|
|
|
|
|
for (int traceno=1; traceno<=m_maxNumberOfTraces; traceno++) {
|
|
|
|
|
m_traceWidget->setTraceEnabled(traceno-1, m_channelActive[traceno], TraceWidget::FullText, true);
|
|
|
|
|
m_traceWidget->setTraceName(traceno-1, TQString("Channel %1").arg(traceno), true);
|
|
|
|
@ -2025,9 +2292,44 @@ void ScopePart::updateGraticule() {
|
|
|
|
|
|
|
|
|
|
m_traceWidget->setDisplayLimits(traceno-1, TQRectF(0.0, (m_voltsDiv[traceno]*m_vdivs)/2.0, (m_secsDiv[traceno]*m_hdivs), (m_voltsDiv[traceno]*m_vdivs)/-2.0), (traceno<m_maxNumberOfTraces)?true:false);
|
|
|
|
|
if (m_traceControlWidgetList[traceno-1]) {
|
|
|
|
|
m_traceControlWidgetList[traceno-1]->setVoltsPerDivList(m_traceAllowedVoltsDiv[traceno]);
|
|
|
|
|
m_traceControlWidgetList[traceno-1]->setSelectedVoltsPerDiv(m_voltsDiv[traceno]);
|
|
|
|
|
m_traceControlWidgetList[traceno-1]->setTraceEnabled(m_channelActive[traceno]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_channelActive[traceno]) {
|
|
|
|
|
activeChannels.append(traceno);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int traceno=1; traceno<=m_maxNumberOfMathTraces; traceno++) {
|
|
|
|
|
updateMathTraceAllowedVoltsPerDivList(traceno);
|
|
|
|
|
|
|
|
|
|
m_traceWidget->setTraceEnabled(traceno-1+m_maxNumberOfTraces, m_mathChannelActive[traceno], TraceWidget::FullText, true);
|
|
|
|
|
m_traceWidget->setTraceName(traceno-1+m_maxNumberOfTraces, TQString("Math %1").arg(traceno), true);
|
|
|
|
|
m_traceWidget->setTraceHorizontalUnits(traceno-1+m_maxNumberOfTraces, m_mathHorizontalUnits[traceno], true);
|
|
|
|
|
m_traceWidget->setTraceVerticalUnits(traceno-1+m_maxNumberOfTraces, m_mathVerticalUnits[traceno], true);
|
|
|
|
|
|
|
|
|
|
m_base->traceZoomWidget->setTraceEnabled(traceno-1+m_maxNumberOfTraces, m_mathChannelActive[traceno], TraceWidget::SummaryText, true);
|
|
|
|
|
m_base->traceZoomWidget->setTraceName(traceno-1+m_maxNumberOfTraces, TQString("Math %1").arg(traceno), true);
|
|
|
|
|
m_base->traceZoomWidget->setTraceHorizontalUnits(traceno-1+m_maxNumberOfTraces, m_mathHorizontalUnits[traceno], true);
|
|
|
|
|
m_base->traceZoomWidget->setTraceVerticalUnits(traceno-1+m_maxNumberOfTraces, m_mathVerticalUnits[traceno], true);
|
|
|
|
|
|
|
|
|
|
m_traceWidget->setNumberOfSamples(traceno-1+m_maxNumberOfTraces, m_samplesInMathTrace[traceno], true);
|
|
|
|
|
m_base->traceZoomWidget->setNumberOfSamples(traceno-1+m_maxNumberOfTraces, m_samplesInMathTrace[traceno], (traceno<m_maxNumberOfMathTraces)?true:false);
|
|
|
|
|
|
|
|
|
|
m_traceWidget->setDisplayLimits(traceno-1+m_maxNumberOfTraces, TQRectF(0.0, (m_mathVoltsDiv[traceno]*m_vdivs)/2.0, (m_mathSecsDiv[traceno]*m_hdivs), (m_mathVoltsDiv[traceno]*m_vdivs)/-2.0), (traceno<m_maxNumberOfMathTraces)?true:false);
|
|
|
|
|
if (m_mathTraceControlWidgetList[traceno-1]) {
|
|
|
|
|
m_mathTraceControlWidgetList[traceno-1]->setVerticalUnits(m_mathVerticalUnits[traceno]);
|
|
|
|
|
m_mathTraceControlWidgetList[traceno-1]->setVoltsPerDivList(m_mathTraceAllowedVoltsDiv[traceno]);
|
|
|
|
|
m_mathTraceControlWidgetList[traceno-1]->setSelectedVoltsPerDiv(m_mathVoltsDiv[traceno]);
|
|
|
|
|
m_mathTraceControlWidgetList[traceno-1]->setTraceEnabled(m_mathChannelActive[traceno]);
|
|
|
|
|
m_mathTraceControlWidgetList[traceno-1]->setFirstMathOperandList(activeChannels);
|
|
|
|
|
m_mathTraceControlWidgetList[traceno-1]->setSecondMathOperandList(activeChannels);
|
|
|
|
|
m_mathTraceControlWidgetList[traceno-1]->setMathOperatorList(m_availableMathOperators);
|
|
|
|
|
m_mathTraceControlWidgetList[traceno-1]->setSelectedFirstMathOperand(m_mathFirstOperand[traceno]);
|
|
|
|
|
m_mathTraceControlWidgetList[traceno-1]->setSelectedSecondMathOperand(m_mathSecondOperand[traceno]);
|
|
|
|
|
m_mathTraceControlWidgetList[traceno-1]->setSelectedMathOperator(m_mathOperator[traceno]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
updateZoomWidgetLimits(m_traceWidget->zoomBox());
|
|
|
|
|
}
|
|
|
|
@ -2052,6 +2354,25 @@ void ScopePart::updateTraceControlWidgets() {
|
|
|
|
|
delete m_traceControlWidgetList[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (i=0; i<m_maxNumberOfMathTraces;i++) {
|
|
|
|
|
if (!m_mathTraceControlWidgetList[i]) {
|
|
|
|
|
m_mathTraceControlWidgetList[i] = new MathTraceControlWidget(m_base->mathTraceControlLayoutWidget);
|
|
|
|
|
connect(m_mathTraceControlWidgetList[i], SIGNAL(enableChanged(bool)), this, SLOT(mathTraceControlEnableChanged(bool)));
|
|
|
|
|
connect(m_mathTraceControlWidgetList[i], SIGNAL(voltsPerDivChanged(double)), this, SLOT(mathTraceControlVDivChanged(double)));
|
|
|
|
|
connect(m_mathTraceControlWidgetList[i], SIGNAL(firstMathOperandChanged(int)), this, SLOT(mathTraceControlFirstOperandChanged(int)));
|
|
|
|
|
connect(m_mathTraceControlWidgetList[i], SIGNAL(secondMathOperandChanged(int)), this, SLOT(mathTraceControlSecondOperandChanged(int)));
|
|
|
|
|
connect(m_mathTraceControlWidgetList[i], SIGNAL(mathOperatorChanged(TQString)), this, SLOT(mathTraceControlOperatorChanged(TQString)));
|
|
|
|
|
m_mathTraceControlWidgetGrid->addMultiCellWidget(m_mathTraceControlWidgetList[i], i+m_maxNumberOfTraces, i+m_maxNumberOfTraces, 0, 0);
|
|
|
|
|
m_mathTraceControlWidgetList[i]->setTraceName(i18n("Math %1").arg(i+1));
|
|
|
|
|
m_mathTraceControlWidgetList[i]->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (i=m_maxNumberOfMathTraces; i<MAXMATHTRACES;i++) {
|
|
|
|
|
if (m_mathTraceControlWidgetList[i]) {
|
|
|
|
|
m_mathTraceControlWidgetGrid->remove(m_mathTraceControlWidgetList[i]);
|
|
|
|
|
delete m_mathTraceControlWidgetList[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScopePart::traceControlEnableChanged(bool enabled) {
|
|
|
|
@ -2105,6 +2426,344 @@ void ScopePart::traceControlSDivChanged(double sdiv) {
|
|
|
|
|
m_horizontalTimebaseSet = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScopePart::mathTraceControlEnableChanged(bool enabled) {
|
|
|
|
|
int i;
|
|
|
|
|
int channel = -1;
|
|
|
|
|
const MathTraceControlWidget* widget = dynamic_cast<const MathTraceControlWidget*>(sender());
|
|
|
|
|
if (widget) {
|
|
|
|
|
for (i=0; i<MAXMATHTRACES;i++) {
|
|
|
|
|
if (m_mathTraceControlWidgetList[i] == widget) {
|
|
|
|
|
channel = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((channel >= 0) && (channel <=MAXMATHTRACES)) {
|
|
|
|
|
m_mathChannelActive[channel+1] = enabled;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateGraticule();
|
|
|
|
|
m_traceWidget->repaint(false);
|
|
|
|
|
m_base->traceZoomWidget->repaint(false);
|
|
|
|
|
updateTraceControlWidgets();
|
|
|
|
|
processMathTraces();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScopePart::mathTraceControlVDivChanged(double vdiv) {
|
|
|
|
|
int i;
|
|
|
|
|
int channel = -1;
|
|
|
|
|
const MathTraceControlWidget* widget = dynamic_cast<const MathTraceControlWidget*>(sender());
|
|
|
|
|
if (widget) {
|
|
|
|
|
for (i=0; i<MAXTRACES;i++) {
|
|
|
|
|
if (m_mathTraceControlWidgetList[i] == widget) {
|
|
|
|
|
channel = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((channel >= 0) && (channel <=MAXMATHTRACES)) {
|
|
|
|
|
m_mathVoltsDiv[channel+1] = vdiv;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateGraticule();
|
|
|
|
|
m_traceWidget->repaint(false);
|
|
|
|
|
m_base->traceZoomWidget->repaint(false);
|
|
|
|
|
updateTraceControlWidgets();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScopePart::mathTraceControlFirstOperandChanged(int operand) {
|
|
|
|
|
int i;
|
|
|
|
|
int channel = -1;
|
|
|
|
|
const MathTraceControlWidget* widget = dynamic_cast<const MathTraceControlWidget*>(sender());
|
|
|
|
|
if (widget) {
|
|
|
|
|
for (i=0; i<MAXTRACES;i++) {
|
|
|
|
|
if (m_mathTraceControlWidgetList[i] == widget) {
|
|
|
|
|
channel = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((channel >= 0) && (channel <=MAXMATHTRACES)) {
|
|
|
|
|
m_mathFirstOperand[channel+1] = operand;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateGraticule();
|
|
|
|
|
m_traceWidget->repaint(false);
|
|
|
|
|
m_base->traceZoomWidget->repaint(false);
|
|
|
|
|
updateTraceControlWidgets();
|
|
|
|
|
processMathTraces();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScopePart::mathTraceControlSecondOperandChanged(int operand) {
|
|
|
|
|
int i;
|
|
|
|
|
int channel = -1;
|
|
|
|
|
const MathTraceControlWidget* widget = dynamic_cast<const MathTraceControlWidget*>(sender());
|
|
|
|
|
if (widget) {
|
|
|
|
|
for (i=0; i<MAXTRACES;i++) {
|
|
|
|
|
if (m_mathTraceControlWidgetList[i] == widget) {
|
|
|
|
|
channel = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((channel >= 0) && (channel <=MAXMATHTRACES)) {
|
|
|
|
|
m_mathSecondOperand[channel+1] = operand;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateGraticule();
|
|
|
|
|
m_traceWidget->repaint(false);
|
|
|
|
|
m_base->traceZoomWidget->repaint(false);
|
|
|
|
|
updateTraceControlWidgets();
|
|
|
|
|
processMathTraces();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScopePart::mathTraceControlOperatorChanged(TQString op) {
|
|
|
|
|
int i;
|
|
|
|
|
int channel = -1;
|
|
|
|
|
const MathTraceControlWidget* widget = dynamic_cast<const MathTraceControlWidget*>(sender());
|
|
|
|
|
if (widget) {
|
|
|
|
|
for (i=0; i<MAXTRACES;i++) {
|
|
|
|
|
if (m_mathTraceControlWidgetList[i] == widget) {
|
|
|
|
|
channel = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((channel >= 0) && (channel <=MAXMATHTRACES)) {
|
|
|
|
|
m_mathOperator[channel+1] = op;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateGraticule();
|
|
|
|
|
m_traceWidget->repaint(false);
|
|
|
|
|
m_base->traceZoomWidget->repaint(false);
|
|
|
|
|
updateTraceControlWidgets();
|
|
|
|
|
processMathTraces();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScopePart::updateMathTraceAllowedVoltsPerDivList(int traceno) {
|
|
|
|
|
if (m_mathFirstOperand[traceno] < 1) {
|
|
|
|
|
m_mathFirstOperand[traceno] = 1;
|
|
|
|
|
}
|
|
|
|
|
if (m_mathSecondOperand[traceno] < 1) {
|
|
|
|
|
m_mathSecondOperand[traceno] = 1;
|
|
|
|
|
}
|
|
|
|
|
if (m_mathFirstOperand[traceno] > MAXTRACES) {
|
|
|
|
|
m_mathFirstOperand[traceno] = MAXTRACES;
|
|
|
|
|
}
|
|
|
|
|
if (m_mathSecondOperand[traceno] > MAXTRACES) {
|
|
|
|
|
m_mathSecondOperand[traceno] = MAXTRACES;
|
|
|
|
|
}
|
|
|
|
|
if (m_mathOperator[traceno] == "") {
|
|
|
|
|
m_mathOperator[traceno] = "+";
|
|
|
|
|
}
|
|
|
|
|
int firstOperandChannel = m_mathFirstOperand[traceno];
|
|
|
|
|
int secondOperandChannel = m_mathSecondOperand[traceno];
|
|
|
|
|
if ((m_mathOperator[traceno] == "+")
|
|
|
|
|
|| (m_mathOperator[traceno] == "-")
|
|
|
|
|
|| (m_mathOperator[traceno] == "*")
|
|
|
|
|
|| (m_mathOperator[traceno] == "/")) {
|
|
|
|
|
// Compute intersection of both trace operand volt/div lists
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].clear();
|
|
|
|
|
TQDoubleList::iterator it;
|
|
|
|
|
for (it = m_traceAllowedVoltsDiv[firstOperandChannel].begin(); it != m_traceAllowedVoltsDiv[firstOperandChannel].end(); ++it) {
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].append(*it);
|
|
|
|
|
}
|
|
|
|
|
for (it = m_traceAllowedVoltsDiv[secondOperandChannel].begin(); it != m_traceAllowedVoltsDiv[secondOperandChannel].end(); ++it) {
|
|
|
|
|
if (!m_mathTraceAllowedVoltsDiv[traceno].contains(*it)) {
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].append(*it);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i=1; i<=m_maxNumberOfTraces; i++) {
|
|
|
|
|
int vdiv = m_voltsDiv[i];
|
|
|
|
|
if (!m_mathTraceAllowedVoltsDiv[traceno].contains(vdiv)) {
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].append(vdiv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
qHeapSort(m_mathTraceAllowedVoltsDiv[traceno]);
|
|
|
|
|
|
|
|
|
|
// Reset GUI if not set (e.g. after startup)
|
|
|
|
|
if ((m_mathVoltsDiv[traceno] == 0) && (m_mathTraceAllowedVoltsDiv[traceno].count() > 0)) {
|
|
|
|
|
m_mathVoltsDiv[traceno] = m_mathTraceAllowedVoltsDiv[traceno][0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int firstTraceLength = m_samplesInTrace[m_mathFirstOperand[traceno]];
|
|
|
|
|
m_samplesInMathTrace[traceno] = firstTraceLength;
|
|
|
|
|
m_mathSecsDiv[traceno] = m_secsDiv[traceno];
|
|
|
|
|
|
|
|
|
|
m_mathHorizontalUnits[traceno] = "s";
|
|
|
|
|
m_mathVerticalUnits[traceno] = "V";
|
|
|
|
|
}
|
|
|
|
|
#ifdef ENABLE_FFT
|
|
|
|
|
else if (m_mathOperator[traceno] == "FFT") {
|
|
|
|
|
int firstTraceLength = m_samplesInTrace[m_mathFirstOperand[traceno]];
|
|
|
|
|
m_samplesInMathTrace[traceno] = firstTraceLength;
|
|
|
|
|
|
|
|
|
|
// Calculate horizontal steps per division
|
|
|
|
|
// Full scale needs to be the sampling rate
|
|
|
|
|
TQDoubleArray inputPositions = m_traceWidget->positions(m_mathFirstOperand[traceno]-1);
|
|
|
|
|
double fs = 1.0 / (inputPositions[1] - inputPositions[0]);
|
|
|
|
|
fs = fs / 2.0; // Truncate waveform at the Nyquist frequency
|
|
|
|
|
m_mathSecsDiv[traceno] = fs/m_hdivs;
|
|
|
|
|
|
|
|
|
|
// Add several dB/div settings
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].clear();
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].append(0.1);
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].append(1);
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].append(10);
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].append(100);
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].append(1000);
|
|
|
|
|
qHeapSort(m_mathTraceAllowedVoltsDiv[traceno]);
|
|
|
|
|
|
|
|
|
|
m_mathHorizontalUnits[traceno] = "Hz";
|
|
|
|
|
m_mathVerticalUnits[traceno] = "dB";
|
|
|
|
|
|
|
|
|
|
// Get next highest power of 2 for the FFT algorithm
|
|
|
|
|
int fftLength = powf(2, ceilf(log2f(firstTraceLength)));
|
|
|
|
|
m_samplesInMathTrace[traceno] = fftLength;
|
|
|
|
|
}
|
|
|
|
|
#endif // ENABLE_FFT
|
|
|
|
|
else {
|
|
|
|
|
m_mathTraceAllowedVoltsDiv[traceno].clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScopePart::processMathTraces() {
|
|
|
|
|
for (int traceno=1; traceno<=m_maxNumberOfMathTraces; traceno++) {
|
|
|
|
|
if ((m_mathOperator[traceno] == "+")
|
|
|
|
|
|| (m_mathOperator[traceno] == "-")
|
|
|
|
|
|| (m_mathOperator[traceno] == "*")
|
|
|
|
|
|| (m_mathOperator[traceno] == "/")) {
|
|
|
|
|
TQDoubleArray outputValues;
|
|
|
|
|
TQDoubleArray outputPositions;
|
|
|
|
|
TQDoubleArray firstValues = m_traceWidget->samples(m_mathFirstOperand[traceno]-1);
|
|
|
|
|
TQDoubleArray firstPositions = m_traceWidget->positions(m_mathFirstOperand[traceno]-1);
|
|
|
|
|
TQDoubleArray secondValues = m_traceWidget->samples(m_mathSecondOperand[traceno]-1);
|
|
|
|
|
TQDoubleArray secondPositions = m_traceWidget->positions(m_mathSecondOperand[traceno]-1);
|
|
|
|
|
outputValues.resize(m_samplesInMathTrace[traceno]);
|
|
|
|
|
outputPositions = firstPositions;
|
|
|
|
|
|
|
|
|
|
if (m_mathOperator[traceno] == "+") {
|
|
|
|
|
for (int i=0; i < m_samplesInMathTrace[traceno]; i++) {
|
|
|
|
|
outputValues[i] = firstValues[i] + secondValues[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (m_mathOperator[traceno] == "-") {
|
|
|
|
|
for (int i=0; i < m_samplesInMathTrace[traceno]; i++) {
|
|
|
|
|
outputValues[i] = firstValues[i] - secondValues[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (m_mathOperator[traceno] == "*") {
|
|
|
|
|
for (int i=0; i < m_samplesInMathTrace[traceno]; i++) {
|
|
|
|
|
outputValues[i] = firstValues[i] * secondValues[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (m_mathOperator[traceno] == "/") {
|
|
|
|
|
for (int i=0; i < m_samplesInMathTrace[traceno]; i++) {
|
|
|
|
|
if (secondValues[i] == 0) {
|
|
|
|
|
secondValues[i] = 1e-12;
|
|
|
|
|
}
|
|
|
|
|
outputValues[i] = firstValues[i] / secondValues[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (int i=0; i < m_samplesInMathTrace[traceno]; i++) {
|
|
|
|
|
outputValues[i] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_traceWidget->setSamples(m_maxNumberOfTraces-1+m_currentOpChannel, outputValues);
|
|
|
|
|
m_traceWidget->setPositions(m_maxNumberOfTraces-1+m_currentOpChannel, outputPositions);
|
|
|
|
|
m_base->traceZoomWidget->setSamples(m_maxNumberOfTraces-1+m_currentOpChannel, outputValues);
|
|
|
|
|
m_base->traceZoomWidget->setPositions(m_maxNumberOfTraces-1+m_currentOpChannel, outputPositions);
|
|
|
|
|
}
|
|
|
|
|
#ifdef ENABLE_FFT
|
|
|
|
|
else if (m_mathOperator[traceno] == "FFT") {
|
|
|
|
|
TQDoubleArray outputValues;
|
|
|
|
|
TQDoubleArray outputPositions;
|
|
|
|
|
TQDoubleArray inputValues = m_traceWidget->samples(m_mathFirstOperand[traceno]-1);
|
|
|
|
|
TQDoubleArray inputPositions = m_traceWidget->positions(m_mathFirstOperand[traceno]-1);
|
|
|
|
|
int inputLength = m_samplesInTrace[m_mathFirstOperand[traceno]];
|
|
|
|
|
int fftLength = m_samplesInMathTrace[traceno];
|
|
|
|
|
|
|
|
|
|
// Resize arrays
|
|
|
|
|
inputValues.resize(fftLength);
|
|
|
|
|
outputValues.resize(fftLength);
|
|
|
|
|
outputPositions.resize(fftLength);
|
|
|
|
|
|
|
|
|
|
// Generate output positions
|
|
|
|
|
// The FFT starts at 0Hz and goes up in Fs/N steps
|
|
|
|
|
double pos = 0;
|
|
|
|
|
double fs = 1.0 / (inputPositions[1] - inputPositions[0]);
|
|
|
|
|
double step = fs / fftLength;
|
|
|
|
|
for (int i=0; i<fftLength; i++) {
|
|
|
|
|
outputPositions[i] = pos;
|
|
|
|
|
pos = pos + step;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Zero-pad FFT input
|
|
|
|
|
for (int i=inputLength; i<fftLength; i++) {
|
|
|
|
|
inputValues[i] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Allocate buffers
|
|
|
|
|
float __attribute__ ((aligned(32))) *ffts_input = (float*) valloc(2 * fftLength * sizeof(float));
|
|
|
|
|
float __attribute__ ((aligned(32))) *ffts_output = (float*) valloc(2 * fftLength * sizeof(float));
|
|
|
|
|
|
|
|
|
|
// Load data
|
|
|
|
|
for (int i=0; i<fftLength; i++) {
|
|
|
|
|
ffts_input[i*2] = inputValues[i];
|
|
|
|
|
ffts_input[(i*2)+1] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Execute FFT
|
|
|
|
|
ffts_plan_t *p = ffts_init_1d(fftLength, -1);
|
|
|
|
|
if (p) {
|
|
|
|
|
ffts_execute(p, ffts_input, ffts_output);
|
|
|
|
|
|
|
|
|
|
// Save data
|
|
|
|
|
double magnitude;
|
|
|
|
|
// double phase;
|
|
|
|
|
for (int i=0; i<fftLength; i++) {
|
|
|
|
|
magnitude = sqrt(pow(ffts_output[i*2], 2) + pow(ffts_output[(i*2)+1], 2));
|
|
|
|
|
// phase = atan2(ffts_output[(i*2)+1], ffts_output[i*2]);
|
|
|
|
|
outputValues[i] = 10.0*log10(magnitude); // Convert magnitude to dB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ffts_free(p);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("[ERROR] Unable to execute FFT!\n\r");
|
|
|
|
|
for (int i=0; i < fftLength; i++) {
|
|
|
|
|
outputValues[i] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Free buffers
|
|
|
|
|
free(ffts_input);
|
|
|
|
|
free(ffts_output);
|
|
|
|
|
|
|
|
|
|
m_traceWidget->setSamples(m_maxNumberOfTraces-1+m_currentOpChannel, outputValues);
|
|
|
|
|
m_traceWidget->setPositions(m_maxNumberOfTraces-1+m_currentOpChannel, outputPositions);
|
|
|
|
|
m_base->traceZoomWidget->setSamples(m_maxNumberOfTraces-1+m_currentOpChannel, outputValues);
|
|
|
|
|
m_base->traceZoomWidget->setPositions(m_maxNumberOfTraces-1+m_currentOpChannel, outputPositions);
|
|
|
|
|
}
|
|
|
|
|
#endif // ENABLE_FFT
|
|
|
|
|
else {
|
|
|
|
|
TQDoubleArray outputValues;
|
|
|
|
|
TQDoubleArray outputPositions;
|
|
|
|
|
|
|
|
|
|
for (int i=0; i < m_samplesInMathTrace[traceno]; i++) {
|
|
|
|
|
outputValues[i] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_traceWidget->setSamples(m_maxNumberOfTraces-1+m_currentOpChannel, outputValues);
|
|
|
|
|
m_traceWidget->setPositions(m_maxNumberOfTraces-1+m_currentOpChannel, outputPositions);
|
|
|
|
|
m_base->traceZoomWidget->setSamples(m_maxNumberOfTraces-1+m_currentOpChannel, outputValues);
|
|
|
|
|
m_base->traceZoomWidget->setPositions(m_maxNumberOfTraces-1+m_currentOpChannel, outputPositions);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScopePart::cursorLevelChanged(uint cursor, double level) {
|
|
|
|
|
if (cursor == 0) {
|
|
|
|
|
// Trigger level changed
|
|
|
|
|