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

View File

@ -30,7 +30,7 @@ private slots:
private: private:
QString exp; QString exp;
mup::ParserX *parser; 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> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <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> </property>
</widget> </widget>
</item> </item>
@ -61,6 +61,20 @@
</item> </item>
</layout> </layout>
</widget> </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> </widget>
</item> </item>
<item> <item>