Skip to content

Commit 57ab45e

Browse files
authored
Merge pull request #1534 from SmithChart/gude-87
driver/power: Add support for Gude 87-1210-18
2 parents 71bfcd2 + af5a3bf commit 57ab45e

File tree

2 files changed

+41
-38
lines changed

2 files changed

+41
-38
lines changed

doc/configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Currently available are:
182182
Controls *Gude Expert Power Control 8008 PDUs* via a simple HTTP API.
183183

184184
``gude8031``
185-
Controls *Gude Expert Power Control 8031 PDUs* via a simple HTTP API.
185+
Controls *Gude Expert Power Control 8031 PDUs* and *Gude Expert Power Control 87-1210-18 PDUs* via a simple HTTP API.
186186

187187
``gude8225``
188188
Controls *Gude Expert Power Control 8225 PDUs* via a simple HTTP API.

labgrid/driver/power/gude8031.py

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
1-
import requests
2-
3-
# Driver has been tested with:
4-
# Gude Expert Power Control 8031()
5-
6-
# HTTP-GET API is defined in the Gude EPC-HTTP-Interface specification:
7-
# http://wiki.gude.info/EPC_HTTP_Interface
8-
#
9-
# The `components=<N>` parameter defines which status information are
10-
# included into the returned JSON.
11-
# * `components=0` happily returns an empty response but still switches the
12-
# outputs as requestd.
13-
# * `components=1` only includes the output's state into the JSON.
14-
15-
PORT = 80
16-
17-
def power_set(host, port, index, value):
18-
index = int(index)
19-
assert 1 <= index <= 8
20-
# access the web interface...
21-
value = 1 if value else 0
22-
r = requests.get(
23-
f"http://{host}:{port}/status.json?components=0&cmd=1&p={index}&s={value}"
24-
)
25-
r.raise_for_status()
26-
27-
def power_get(host, port, index):
28-
index = int(index)
29-
assert 1 <= index <= 8
30-
31-
# get the component status
32-
r = requests.get(f"http://{host}:{port}/status.json?components=1")
33-
r.raise_for_status()
34-
35-
state = r.json()['outputs'][index - 1]['state']
36-
37-
return state
1+
import requests
2+
3+
# Driver has been tested with:
4+
# * Gude Expert Power Control 8031()
5+
# * Gude Expert Power Control 87-1210-18
6+
# This device needs to be used in 'Basic Compatible' mode for HTTP GET
7+
# to be usable. Do not turn on session authentication.
8+
9+
# HTTP-GET API is defined in the Gude EPC-HTTP-Interface specification:
10+
# http://wiki.gude.info/EPC_HTTP_Interface
11+
#
12+
# The `components=<N>` parameter defines which status information are
13+
# included into the returned JSON.
14+
# * `components=0` happily returns an empty response but still switches the
15+
# outputs as requested.
16+
# * `components=1` only includes the output's state into the JSON.
17+
18+
PORT = 80
19+
20+
21+
def power_set(host, port, index, value):
22+
index = int(index)
23+
assert 1 <= index <= 20
24+
# access the web interface...
25+
value = 1 if value else 0
26+
r = requests.get(f"http://{host}:{port}/status.json?components=0&cmd=1&p={index}&s={value}")
27+
r.raise_for_status()
28+
29+
30+
def power_get(host, port, index):
31+
index = int(index)
32+
assert 1 <= index <= 20
33+
34+
# get the component status
35+
r = requests.get(f"http://{host}:{port}/status.json?components=1")
36+
r.raise_for_status()
37+
38+
state = r.json()["outputs"][index - 1]["state"]
39+
40+
return state

0 commit comments

Comments
 (0)