adjusted custom expressions to handle power sweep data

This commit is contained in:
Jan Käberich 2021-07-10 13:36:25 +02:00
parent dda149f3d5
commit 6fdbaea55f
3 changed files with 27 additions and 6 deletions

View File

@ -41,11 +41,13 @@ void Math::Expression::edit()
exp = ui->expEdit->text();
expressionChanged();
});
// TODO add power domain
if(dataType == DataType::Time) {
// select the label explaining the time domain variables (frequency label is the default)
ui->stackedWidget->setCurrentIndex(1);
switch(dataType) {
case DataType::Frequency: ui->stackedWidget->setCurrentIndex(0); break;
case DataType::Time: ui->stackedWidget->setCurrentIndex(1); break;
case DataType::Power: ui->stackedWidget->setCurrentIndex(2); break;
default: break;
}
d->show();
}
@ -78,6 +80,7 @@ void Math::Expression::inputSamplesChanged(unsigned int begin, unsigned int end)
for(unsigned int i=begin;i<end;i++) {
t = in[i].x;
f = in[i].x;
P = in[i].x;
w = in[i].x * 2 * M_PI;
d = root()->timeToDistance(t);
x = in[i].y;
@ -103,6 +106,7 @@ void Math::Expression::expressionChanged()
parser->RemoveVar("d");
parser->RemoveVar("f");
parser->RemoveVar("w");
parser->RemoveVar("P");
switch(dataType) {
case DataType::Time:
parser->DefineVar("t", Variable(&t));
@ -112,6 +116,9 @@ void Math::Expression::expressionChanged()
parser->DefineVar("f", Variable(&f));
parser->DefineVar("w", Variable(&w));
break;
case DataType::Power:
parser->DefineVar("P", Variable(&P));
break;
default:
break;
}

View File

@ -30,7 +30,7 @@ private slots:
private:
QString exp;
mup::ParserX *parser;
mup::Value t, d, f, w, x;
mup::Value t, d, f, w, x, P;
};
}

View File

@ -44,7 +44,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Available variables:&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;x: the S parameter as a (complex) voltage vector. &lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;f: measurement frequency in Hz&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;w: angular measurement frequency (w = 2πf)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Examples:&lt;br/&gt;Add 10db to the trace (10db = exp10(10/20) = sqrt(10)):&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;x * sqrt(10)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Clip trace at 0db (0db = exp10(0/20) = 1) while preserving phase:&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;abs(x) &amp;lt; 1 ? x : exp(i*arg(x))&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Available variables:&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;x: the S parameter as a (complex) voltage vector. &lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;f: measurement frequency in Hz&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;w: angular measurement frequency (w = 2πf)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Examples:&lt;br/&gt;Add 10db to the trace (10db = exp10(10/20) = sqrt(10)):&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;x * sqrt(10)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Clip trace at 0db (0db = exp10(0/20) = 1) while preserving phase:&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;abs(x) &amp;lt; 1 ? x : exp(i*arg(x))&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
@ -61,6 +61,20 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="powerPage">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Available variables:&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;x: the S parameter as a (complex) voltage vector. &lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;P: power of the stimulus signal in dBm&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Examples:&lt;br/&gt;Add 10db to the trace (10db = exp10(10/20) = sqrt(10)):&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;x * sqrt(10)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Clip trace at 0db (0db = exp10(0/20) = 1) while preserving phase:&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;abs(x) &amp;lt; 1 ? x : exp(i*arg(x))&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>