Skip to content

Commit 94d214f

Browse files
committed
REFACTOR: move each instrument to individual files
1 parent 97b9d45 commit 94d214f

File tree

8 files changed

+108
-105
lines changed

8 files changed

+108
-105
lines changed

examples/example_keysight.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import time
22

3-
from cc.scpi import Keysight81134A
3+
from cc.scpi.keysight import K81134A
44

5-
device = Keysight81134A("128.32.62.102")
5+
device = K81134A("128.32.62.102")
66
device.connect()
77

88
print(device.get_instrument_identification())
99

1010

11-
device.enable_output(Keysight81134A.Channel.CH1)
12-
device.disable_output(Keysight81134A.Channel.CH1)
11+
device.enable_output(K81134A.Channel.CH1)
12+
device.disable_output(K81134A.Channel.CH1)

examples/example_siglent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import time
22

3-
from cc.scpi import SiglentSPD3303X
3+
from cc.scpi.siglent import SPD3303X
44

5-
device = SiglentSPD3303X("128.32.62.100")
5+
device = SPD3303X("128.32.62.100")
66
device.connect()
77

88
print(device.get_instrument_identification())

src/cc/scpi/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
from .keysight import *
2-
from .siglent import *

src/cc/scpi/keysight/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .k33600a import K33600A
2+
from .k81134a import K81134A

src/cc/scpi/keysight/k33600a.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
2+
from ..generic_instrument import GenericInstrument
3+
4+
class K33600A(GenericInstrument):
5+
"""
6+
Keysight 33600A Series Waveform Generator
7+
8+
The Keysight 33600A Series Waveform Generator is a versatile signal generator with the capabilities of generating sine, square, ramp, pulse, and arbitrary waveforms. It can be used to test analog designs, such as filters, amplifiers, etc.
9+
10+
https://www.keysight.com/fr/en/assets/7018-04123/data-sheets-archived/5991-3272.pdf
11+
"""
12+
13+
class Function:
14+
"""
15+
The function of the output waveform.
16+
"""
17+
SQUARE = "SQUARE"
18+
19+
class Channel:
20+
"""
21+
The channel of the output waveform.
22+
"""
23+
CH1 = "1"
24+
CH2 = "2"
25+
26+
def set_function(self, function: Function, channel: Channel):
27+
"""
28+
Set function of both channels
29+
30+
Args:
31+
function: the target function
32+
channel: the target channel
33+
"""
34+
self.command("SOURCE{ch}:FUNCTION {func}".format(ch=channel, func=function))
35+
36+
def set_frequency(self, value: float, channel: Channel):
37+
"""
38+
Set frequency of both channels
39+
40+
Args:
41+
value: the target frequency value in hertz (Hz). The value must be within [100, 600000000] Hz.
42+
channel: the target channel
43+
"""
44+
self.command("SOURCE{ch}:FREQUENCY {val}".format(ch=channel, val=value))
45+
46+
def set_high_voltage(self, value: float, channel: Channel):
47+
"""
48+
Set the voltage level of the high state of the output waveform.
49+
50+
Args:
51+
value: the target voltage value in volts (V).
52+
channel: the target channel
53+
"""
54+
self.command("SOURCE{ch}:VOLTAGE:HIGH {val}".format(ch=channel, val=value))
55+
56+
def set_low_voltage(self, value: float, channel: Channel):
57+
"""
58+
Set the voltage level of the low state of the output waveform.
59+
60+
Args:
61+
value: the target voltage value in volts (V).
62+
channel: the target channel
63+
"""
64+
self.command("SOURCE{ch}:VOLTAGE:LOW {val}".format(ch=channel, val=value))
65+
66+
def set_output_load(self, value: float, channel: Channel):
67+
"""
68+
Set the output load impedance.
69+
70+
Args:
71+
value: the target load value in ohms (Ω). The value must be within [1, 1000000] Ω.
72+
channel: the target channel
73+
"""
74+
if value == float("inf"):
75+
value = "INFINITY"
76+
self.command("OUTPUT{ch}:LOAD {val}".format(ch=channel, val=value))
77+
78+
def disable_output(self, channel: Channel):
79+
"""
80+
Disable the output of the specified channel.
81+
82+
Args:
83+
channel: the target channel
84+
"""
85+
self.command("OUTPUT{ch} OFF".format(ch=channel))
86+
87+
def enable_output(self, channel: Channel):
88+
"""
89+
Enable the output of the specified channel.
90+
91+
Args:
92+
channel: the target channel
93+
"""
94+
self.command("OUTPUT{ch} ON".format(ch=channel))
95+

src/cc/scpi/keysight.py renamed to src/cc/scpi/keysight/k81134a.py

Lines changed: 2 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,7 @@
11

2-
from .generic_instrument import GenericInstrument
2+
from ..generic_instrument import GenericInstrument
33

4-
class Keysight33600A(GenericInstrument):
5-
"""
6-
Keysight 33600A Series Waveform Generator
7-
8-
The Keysight 33600A Series Waveform Generator is a versatile signal generator with the capabilities of generating sine, square, ramp, pulse, and arbitrary waveforms. It can be used to test analog designs, such as filters, amplifiers, etc.
9-
10-
https://www.keysight.com/fr/en/assets/7018-04123/data-sheets-archived/5991-3272.pdf
11-
"""
12-
13-
class Function:
14-
"""
15-
The function of the output waveform.
16-
"""
17-
SQUARE = "SQUARE"
18-
19-
class Channel:
20-
"""
21-
The channel of the output waveform.
22-
"""
23-
CH1 = "1"
24-
CH2 = "2"
25-
26-
def set_function(self, function: Function, channel: Channel):
27-
"""
28-
Set function of both channels
29-
30-
Args:
31-
function: the target function
32-
channel: the target channel
33-
"""
34-
self.command("SOURCE{ch}:FUNCTION {func}".format(ch=channel, func=function))
35-
36-
def set_frequency(self, value: float, channel: Channel):
37-
"""
38-
Set frequency of both channels
39-
40-
Args:
41-
value: the target frequency value in hertz (Hz). The value must be within [100, 600000000] Hz.
42-
channel: the target channel
43-
"""
44-
self.command("SOURCE{ch}:FREQUENCY {val}".format(ch=channel, val=value))
45-
46-
def set_high_voltage(self, value: float, channel: Channel):
47-
"""
48-
Set the voltage level of the high state of the output waveform.
49-
50-
Args:
51-
value: the target voltage value in volts (V).
52-
channel: the target channel
53-
"""
54-
self.command("SOURCE{ch}:VOLTAGE:HIGH {val}".format(ch=channel, val=value))
55-
56-
def set_low_voltage(self, value: float, channel: Channel):
57-
"""
58-
Set the voltage level of the low state of the output waveform.
59-
60-
Args:
61-
value: the target voltage value in volts (V).
62-
channel: the target channel
63-
"""
64-
self.command("SOURCE{ch}:VOLTAGE:LOW {val}".format(ch=channel, val=value))
65-
66-
def set_output_load(self, value: float, channel: Channel):
67-
"""
68-
Set the output load impedance.
69-
70-
Args:
71-
value: the target load value in ohms (Ω). The value must be within [1, 1000000] Ω.
72-
channel: the target channel
73-
"""
74-
if value == float("inf"):
75-
value = "INFINITY"
76-
self.command("OUTPUT{ch}:LOAD {val}".format(ch=channel, val=value))
77-
78-
def disable_output(self, channel: Channel):
79-
"""
80-
Disable the output of the specified channel.
81-
82-
Args:
83-
channel: the target channel
84-
"""
85-
self.command("OUTPUT{ch} OFF".format(ch=channel))
86-
87-
def enable_output(self, channel: Channel):
88-
"""
89-
Enable the output of the specified channel.
90-
91-
Args:
92-
channel: the target channel
93-
"""
94-
self.command("OUTPUT{ch} ON".format(ch=channel))
95-
96-
97-
class Keysight81134A(GenericInstrument):
4+
class K81134A(GenericInstrument):
985
"""
996
Keysight 81134A Pulse Pattern Generator, Dual-Channel
1007

src/cc/scpi/siglent/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .spd3303x import SPD3303X

src/cc/scpi/siglent.py renamed to src/cc/scpi/siglent/spd3303x.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
from .generic_instrument import GenericInstrument
2+
from ..generic_instrument import GenericInstrument
33

4-
class SiglentSPD3303X(GenericInstrument):
4+
class SPD3303X(GenericInstrument):
55
"""
66
Siglent SPD3303X Programmable DC Power Supply
77

0 commit comments

Comments
 (0)