Skip to content

Commit

Permalink
add measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-demin committed Sep 10, 2016
1 parent 7d9457d commit 2bca5dc
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 17 deletions.
31 changes: 25 additions & 6 deletions PyQtScope.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,14 @@ def read_data(self):
# 10: NR_Pt <NR1> - number of points
# Xn = XZEro + XINcr * n
# Yn = YZEro + YMUlt * (yn - YOFf)
self.transmit_command(b'CH1:SCA?')
self.transmit_command(b'CH1:SCA?;:CH2:SCA?;:HOR:MAI:SCA?')
sca = self.receive_result()[:-1].decode("utf-8").rsplit(';')
if self.sca1: self.sca1.remove()
self.sca1 = self.axes.text(0, -110, 'CH1 %sV' % metric_prefix(float(self.receive_result()[:-1])), color = '#EEDD00')
self.transmit_command(b'CH2:SCA?')
self.sca1 = self.axes.text(0, -110, 'CH1 %sV' % metric_prefix(float(sca[0])), color = '#EEDD00')
if self.sca2: self.sca2.remove()
self.sca2 = self.axes.text(750, -110, 'CH2 %sV' % metric_prefix(float(self.receive_result()[:-1])), color = '#00DDEE')
self.transmit_command(b'HOR:MAI:SCA?')
self.sca2 = self.axes.text(750, -110, 'CH2 %sV' % metric_prefix(float(sca[1])), color = '#00DDEE')
if self.scam: self.scam.remove()
self.scam = self.axes.text(1500, -110, 'M %ss' % metric_prefix(float(self.receive_result()[:-1])))
self.scam = self.axes.text(1500, -110, 'M %ss' % metric_prefix(float(sca[2])))
self.transmit_command(b'WFMPre:CH1?')
self.format1 = self.receive_result()[:-1].decode("utf-8").rsplit(';')
self.transmit_command(b'WFMPre:CH2?')
Expand All @@ -175,6 +174,26 @@ def read_data(self):
self.buffer2[:] = self.receive_result()[6:-1]
self.curve2.set_ydata(self.data2)
self.canvas.draw()
self.transmit_command(b'MEASU:MEAS1?;:MEASU:MEAS1:VAL?;:MEASU:MEAS2?;:MEASU:MEAS2:VAL?;:MEASU:MEAS3?;:MEASU:MEAS3:VAL?')
result = self.receive_result()[:-1] + b';'
self.transmit_command(b'MEASU:MEAS4?;:MEASU:MEAS4:VAL?;:MEASU:MEAS5?;:MEASU:MEAS5:VAL?')
result += self.receive_result()[:-1]
meas = result.decode("utf-8").rsplit(';')
for i in range(0, 5):
typ = meas[i * 4 + 0]
uni = meas[i * 4 + 1]
sou = meas[i * 4 + 2]
val = meas[i * 4 + 3]
if typ == 'NONE':
val = ''
uni = ''
elif val == '9.9E37':
val = '?'
uni = ''
else:
val = metric_prefix(float(meas[i * 4 + 3]))
uni = uni.strip('"')
getattr(self, 'meas%d' % (i + 1)).setText('%s %s %s%s' % (sou, typ, val, uni))

def save_data(self):
dialog = QFileDialog(self, 'Write csv file', '.', '*.csv')
Expand Down
83 changes: 72 additions & 11 deletions PyQtScope.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>900</width>
<width>800</width>
<height>600</height>
</rect>
</property>
Expand Down Expand Up @@ -48,7 +48,7 @@
</property>
<property name="minimumSize">
<size>
<width>300</width>
<width>200</width>
<height>0</height>
</size>
</property>
Expand All @@ -58,36 +58,97 @@
</font>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<spacer name="spacer2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="0">
<widget class="QLabel" name="meas5">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="meas3">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="meas4">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="meas2">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="readButton">
<property name="text">
<string>Read data</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="freqLabel">
<item row="3" column="0">
<widget class="QLabel" name="measLabel">
<property name="text">
<string>Frequency, Hz</string>
<string>MEASUREMENTS</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="peakLabel">
<item row="10" column="0">
<widget class="QLabel" name="cursLabel">
<property name="text">
<string>CURSORS</string>
</property>
</widget>
</item>
<item row="11" column="0">
<spacer name="spacer1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="meas1">
<property name="text">
<string>Peak-to-peak, V</string>
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="0">
<widget class="QPushButton" name="saveButton">
<property name="text">
<string>Save data</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="spacer">
<item row="9" column="0">
<spacer name="spacer3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
Expand Down

0 comments on commit 2bca5dc

Please sign in to comment.