Browse Source

Reformat tab to spaces

RoGeorge 8 years ago
parent
commit
be1d17b5d2
1 changed files with 55 additions and 56 deletions
  1. 55
    56
      Rigol_functions.py

+ 55
- 56
Rigol_functions.py View File

@@ -2,70 +2,69 @@ __author__ = 'RoGeorge'
2 2
 
3 3
 import time
4 4
 
5
+
5 6
 def get_memory_depth(tn):
6
-	# Define number of horizontal grid divisions for DS1054Z
7
-	h_grid = 12
7
+    # Define number of horizontal grid divisions for DS1054Z
8
+    h_grid = 12
8 9
 
9
-	# ACQuire:MDEPth
10
-	tn.write("ACQ:MDEP?")
11
-	mdep = tn.read_until("\n", 1)
10
+    # ACQuire:MDEPth
11
+    tn.write("ACQ:MDEP?")
12
+    mdep = tn.read_until("\n", 1)
12 13
 
13
-	# if mdep is "AUTO"
14
-	if mdep == "AUTO\n":
15
-		# ACQuire:SRATe
16
-		tn.write("ACQ:SRAT?")
17
-		srate = tn.read_until("\n", 1)
14
+    # if mdep is "AUTO"
15
+    if mdep == "AUTO\n":
16
+        # ACQuire:SRATe
17
+        tn.write("ACQ:SRAT?")
18
+        srate = tn.read_until("\n", 1)
18 19
 
19
-		# TIMebase[:MAIN]:SCALe
20
-		tn.write("TIM:SCAL?")
21
-		scal = tn.read_until("\n", 1)
20
+        # TIMebase[:MAIN]:SCALe
21
+        tn.write("TIM:SCAL?")
22
+        scal = tn.read_until("\n", 1)
22 23
 
23
-		# mdep = h_grid * scal * srate
24
-		mdep = h_grid * float(scal) * float(srate)
24
+        # mdep = h_grid * scal * srate
25
+        mdep = h_grid * float(scal) * float(srate)
25 26
 
26
-	# return mdep
27
-	return float(mdep)
27
+    # return mdep
28
+    return float(mdep)
28 29
 
29 30
 
30 31
 # return maximum achieved stop point, or 0 for wrong input parameters
31 32
 # if achieved == requested, then set the start and stop waveform as n1_d and n2_d
32 33
 def is_waveform_from_to(tn, n1_d, n2_d):
33
-	# read current
34
-	# WAVeform:STARt
35
-	tn.write("WAV:STAR?")
36
-	n1_c = float(tn.read_until("\n", 1))
37
-
38
-	# WAVeform:STOP
39
-	tn.write("WAV:STOP?")
40
-	n2_c = float(tn.read_until("\n", 1))
41
-
42
-	if (n1_d > n2_d) or (n1_d < 1) or (n2_d < 1):
43
-		# wrong parameters
44
-		return 0
45
-
46
-	elif n2_d < n1_c:
47
-		# first set n1_d then set n2_d
48
-		tn.write("WAV:STAR " + str(n1_d))
49
-		time.sleep(1)
50
-		tn.write("WAV:STOP " + str(n2_d))
51
-		time.sleep(1)
52
-
53
-	else:
54
-		# first set n2_d then set n1_d
55
-		tn.write("WAV:STOP " + str(n2_d))
56
-		time.sleep(1)
57
-		tn.write("WAV:STAR " + str(n1_d))
58
-		time.sleep(1)
59
-
60
-	# read achieved n2
61
-	tn.write("WAV:STOP?")
62
-	n2_a = float(tn.read_until("\n", 1))
63
-
64
-	if n2_a < n2_d:
65
-		# restore n1_c, n2_c
66
-		is_waveform_from_to(tn, n1_c, n2_c)
67
-
68
-	# return n2_a
69
-	return n2_a
70
-
71
-
34
+    # read current
35
+    # WAVeform:STARt
36
+    tn.write("WAV:STAR?")
37
+    n1_c = float(tn.read_until("\n", 1))
38
+
39
+    # WAVeform:STOP
40
+    tn.write("WAV:STOP?")
41
+    n2_c = float(tn.read_until("\n", 1))
42
+
43
+    if (n1_d > n2_d) or (n1_d < 1) or (n2_d < 1):
44
+        # wrong parameters
45
+        return 0
46
+
47
+    elif n2_d < n1_c:
48
+        # first set n1_d then set n2_d
49
+        tn.write("WAV:STAR " + str(n1_d))
50
+        time.sleep(1)
51
+        tn.write("WAV:STOP " + str(n2_d))
52
+        time.sleep(1)
53
+
54
+    else:
55
+        # first set n2_d then set n1_d
56
+        tn.write("WAV:STOP " + str(n2_d))
57
+        time.sleep(1)
58
+        tn.write("WAV:STAR " + str(n1_d))
59
+        time.sleep(1)
60
+
61
+    # read achieved n2
62
+    tn.write("WAV:STOP?")
63
+    n2_a = float(tn.read_until("\n", 1))
64
+
65
+    if n2_a < n2_d:
66
+        # restore n1_c, n2_c
67
+        is_waveform_from_to(tn, n1_c, n2_c)
68
+
69
+    # return n2_a
70
+    return n2_a

Loading…
Cancel
Save