Skip to content

Commit

Permalink
driver/power/gude8031: Add Support for Gude 87-1210-18
Browse files Browse the repository at this point in the history
The Gude Expert Power Control 87-1210-18 is a vertical 20 port power
distribution unit:
https://gude-systems.com/en/products/expert-power-control-87-1210/

It uses the same HTTP-API, as the Gude Power Control 80831 - but simply
has more ports.
This commit adds support and documentation for this device.

Loosing the restrictions on the `index` makes it possible to re-use this
driver.

Setting a non-existent port fails silently.
But getting a non-existent port will cause an exception.
I deem this behavior acceptable, since a new device will be testet
during hardware setup anyway.
So we do not need to check the actual number of ports during normal
operation.

Signed-off-by: Chris Fiege <[email protected]>
  • Loading branch information
SmithChart committed Oct 30, 2024
1 parent 4b8a0d2 commit de5415d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Currently available are:
Controls *Gude Expert Power Control 8008 PDUs* via a simple HTTP API.

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

``gude8225``
Controls *Gude Expert Power Control 8225 PDUs* via a simple HTTP API.
Expand Down
11 changes: 7 additions & 4 deletions labgrid/driver/power/gude8031.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import requests

# Driver has been tested with:
# Gude Expert Power Control 8031()
# * Gude Expert Power Control 8031()
# * Gude Expert Power Control 87-1210-18
# This device needs to be used in 'Basic Compatible' mode for HTTP GET
# to be usable. Do not turn on session authentication.

# HTTP-GET API is defined in the Gude EPC-HTTP-Interface specification:
# http://wiki.gude.info/EPC_HTTP_Interface
#
# The `components=<N>` parameter defines which status information are
# included into the returned JSON.
# * `components=0` happily returns an empty response but still switches the
# outputs as requestd.
# outputs as requested.
# * `components=1` only includes the output's state into the JSON.

PORT = 80


def power_set(host, port, index, value):
index = int(index)
assert 1 <= index <= 8
assert 1 <= index <= 20
# access the web interface...
value = 1 if value else 0
r = requests.get(f"http://{host}:{port}/status.json?components=0&cmd=1&p={index}&s={value}")
Expand All @@ -26,7 +29,7 @@ def power_set(host, port, index, value):

def power_get(host, port, index):
index = int(index)
assert 1 <= index <= 8
assert 1 <= index <= 20

# get the component status
r = requests.get(f"http://{host}:{port}/status.json?components=1")
Expand Down

0 comments on commit de5415d

Please sign in to comment.