-
Notifications
You must be signed in to change notification settings - Fork 0
/
esa_screen.py
38 lines (31 loc) · 1.18 KB
/
esa_screen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from Devices import Device
from Lab import Lab
from datetime import datetime
if __name__ == '__main__':
dev = Lab.connectByType(Device.Type.SPECTRUM_ANALYZER, hint='E4407',
verbose=True)
if dev is None:
exit(1)
dev.timeout = 10000
menu_on = dev.query(':DISP:MENU:STAT?').strip() == '1'
if menu_on:
dev.write(':DISP:MENU:STAT 0')
dev.write(':DISP:WIND:ANN:ALL 1')
dev.write(":DISP:ANN:TITL:DATA 'GPIB Playground by Mankan Gustafsson'")
dev.write(":MMEM:DEL 'R:SCREEN.GIF';*CLS")
for i in range(1):
dev.write(":MMEM:STOR:SCR 'R:SCREEN.GIF'")
data = dev.query_binary_values(":MMEM:DATA? 'R:SCREEN.GIF'",
is_big_endian=True, datatype='c')
filename = datetime.now().strftime('%Y-%m-%d_%H%M%S_') + str(i) + '-SCREEN.GIF'
try:
with open(filename, "wb") as im:
im.write(b''.join(data))
im.close()
except OSError:
print(f'failed to save file: {filename}')
print(filename)
dev.write(":MMEM:DEL 'R:SCREEN.GIF'")
if menu_on:
dev.write(':DISP:MENU:STAT 1')
dev.close()