-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
dump_luxtronik.py
executable file
·64 lines (50 loc) · 1.72 KB
/
dump_luxtronik.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /usr/bin/env python3
# pylint: disable=invalid-name
"""Script to dump all available values from Luxtronik controller"""
import argparse
from luxtronik import Luxtronik
from luxtronik.constants import LUXTRONIK_DEFAULT_PORT
def dump_luxtronik():
# pylint: disable=duplicate-code
"""Dump all available data from the Luxtronik controller."""
parser = argparse.ArgumentParser(
description="Dumps all values from Luxtronik controller"
)
parser.add_argument("ip", help="IP address of Luxtronik controller to connect to")
parser.add_argument(
"port",
nargs="?",
type=int,
default=LUXTRONIK_DEFAULT_PORT,
help="Port to use to connect to Luxtronik controller",
)
args = parser.parse_args()
client = Luxtronik(args.ip, args.port)
calculations, parameters, visibilities = client.read()
# pylint: enable=duplicate-code
print("=" * 80)
print(f"{' Parameter ': ^80}")
print("=" * 80)
for number, param in parameters:
print(
f"Number: {number:<5} Name: {param.name:<60} "
+ f"Type: {param.__class__.__name__:<20} Value: {param}"
)
print("=" * 80)
print(f"{' Calculations ': ^80}")
print("=" * 80)
for number, calc in calculations:
print(
f"Number: {number:<5} Name: {calc.name:<60} "
+ f"Type: {calc.__class__.__name__:<20} Value: {calc}"
)
print("=" * 80)
print(f"{' Visibilities ': ^80}")
print("=" * 80)
for number, visi in visibilities:
print(
f"Number: {number:<5} Name: {visi.name:<60} "
+ f"Type: {visi.__class__.__name__:<20} Value: {visi}"
)
if __name__ == "__main__":
dump_luxtronik()