Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
DIOT reliability studies project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Projects
DIOT reliability studies project
Commits
8aca4beb
Commit
8aca4beb
authored
Mar 23, 2022
by
Alén Arias Vázquez
😎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change name functions
parent
2ddfff19
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
cpx400dp.py
cpx400dp/cpx400dp.py
+15
-10
No files found.
cpx400dp/cpx400dp.py
View file @
8aca4beb
...
...
@@ -25,24 +25,24 @@ class CPX400DP(object):
def
recv_cmd
(
self
):
return
self
.
serial
.
readline
()
def
set
V
oltage
(
self
,
volts
,
chan
=
1
):
def
set
_v
oltage
(
self
,
volts
,
chan
=
1
):
self
.
log
.
info
(
"Set oltage {}V in channel {}"
.
format
(
volts
,
chan
))
cmd
=
'V'
+
str
(
chan
)
+
' '
+
str
(
volts
)
+
'
\n
'
self
.
send_cmd
(
cmd
)
def
get
V
oltage
(
self
,
chan
=
1
):
def
get
_v
oltage
(
self
,
chan
=
1
):
cmd
=
'V'
+
str
(
chan
)
+
'O?
\n
'
self
.
send_cmd
(
cmd
)
answer
=
self
.
recv_cmd
()
self
.
log
.
info
(
"Channel {} ---- {}}V"
.
format
(
chan
,
float
(
answer
[:
-
3
])))
return
float
(
answer
[:
-
3
])
def
set
C
urrent
(
self
,
amps
,
chan
=
1
):
def
set
_c
urrent
(
self
,
amps
,
chan
=
1
):
self
.
log
.
info
(
"Set current to {}A in channel {}"
.
format
(
amps
,
chan
))
cmd
=
'I'
+
str
(
chan
)
+
' '
+
str
(
amps
)
+
'
\n
'
self
.
send_cmd
(
cmd
)
def
get
C
urrent
(
self
,
chan
=
1
):
def
get
_c
urrent
(
self
,
chan
=
1
):
cmd
=
'I'
+
str
(
chan
)
+
'O?
\n
'
self
.
send_cmd
(
cmd
)
answer
=
self
.
recv_cmd
()
...
...
@@ -57,20 +57,25 @@ class CPX400DP(object):
cmd
=
'IFLOCK
\n
'
self
.
send_cmd
(
cmd
)
def
switchO
n
(
self
,
chan
=
1
):
def
turn_o
n
(
self
,
chan
=
1
):
cmd
=
'OP'
+
str
(
chan
)
+
' 1
\n
'
self
.
log
.
info
(
"Turning ON Channel {}"
.
format
(
chan
))
self
.
send_cmd
(
cmd
)
def
switchO
ff
(
self
,
chan
=
1
):
def
turn_o
ff
(
self
,
chan
=
1
):
cmd
=
'OP'
+
str
(
chan
)
+
' 0
\n
'
self
.
log
.
info
(
"Turning OFF Channel {}"
.
format
(
chan
))
self
.
send_cmd
(
cmd
)
def
setup
(
self
,
chan
=
1
,
volts
=
10.0
,
amps
=
0.3
):
self
.
setVoltage
(
volts
=
volts
,
chan
=
chan
)
self
.
setCurrent
(
amps
=
amps
,
chan
=
chan
)
self
.
switchOn
(
chan
=
chan
)
self
.
set_voltage
(
volts
=
volts
,
chan
=
chan
)
self
.
set_current
(
amps
=
amps
,
chan
=
chan
)
self
.
turn_on
(
chan
=
chan
)
def
get_values
(
self
,
chan
=
1
,
volts
=
10.0
,
amps
=
0.3
):
self
.
set_voltage
(
volts
=
volts
,
chan
=
chan
)
self
.
set_current
(
amps
=
amps
,
chan
=
chan
)
self
.
turn_on
(
chan
=
chan
)
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Control CPX400DP from USB'
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
...
...
@@ -85,7 +90,7 @@ def main():
if
args
.
powerup
:
psu
.
setup
(
chan
=
args
.
chan
,
volts
=
args
.
volts
,
amps
=
args
.
amps
)
else
:
psu
.
switchO
ff
(
chan
=
args
.
chan
)
psu
.
turn_o
ff
(
chan
=
args
.
chan
)
psu
.
close
()
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment