PyBLNET 0.9.2__py3-none-any.whl → 0.9.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {PyBLNET-0.9.2.dist-info → PyBLNET-0.9.4.dist-info}/METADATA +1 -1
- {PyBLNET-0.9.2.dist-info → PyBLNET-0.9.4.dist-info}/RECORD +11 -10
- {PyBLNET-0.9.2.dist-info → PyBLNET-0.9.4.dist-info}/WHEEL +1 -1
- pyblnet/__init__.py +1 -1
- pyblnet/blnet_conn.py +1 -1
- pyblnet/blnet_parser.py +17 -7
- pyblnet/blnet_web.py +2 -0
- pyblnet/tests/test_parser.py +24 -0
- pyblnet/tests/test_web.py +10 -10
- {PyBLNET-0.9.2.dist-info → PyBLNET-0.9.4.dist-info}/LICENSE.txt +0 -0
- {PyBLNET-0.9.2.dist-info → PyBLNET-0.9.4.dist-info}/top_level.txt +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
pyblnet/__init__.py,sha256=
|
|
1
|
+
pyblnet/__init__.py,sha256=mrQFIL48ZfLgZXghJWisLX8o4PMUiPC6lDzbNlWSx1g,499
|
|
2
2
|
pyblnet/blnet.py,sha256=t4NKLZib_kV-S8ZEnNim8ML52gE99nrWzlt_GZCjxC4,7570
|
|
3
|
-
pyblnet/blnet_conn.py,sha256=
|
|
4
|
-
pyblnet/blnet_parser.py,sha256=
|
|
5
|
-
pyblnet/blnet_web.py,sha256=
|
|
3
|
+
pyblnet/blnet_conn.py,sha256=6ji91hnm7X5W6v6rHAMNYmwOjTPtyeSxAriYwQdcWks,12612
|
|
4
|
+
pyblnet/blnet_parser.py,sha256=b8NLSAbxnCYZ5uUIDTeMuwA1LrsiiPdyXOSDzafK0oE,5195
|
|
5
|
+
pyblnet/blnet_web.py,sha256=1fQ8PRkv2RW6ikdTUm7s_eSFDK_pp5MQenJWhzB-n5k,11776
|
|
6
6
|
pyblnet/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
pyblnet/tests/
|
|
7
|
+
pyblnet/tests/test_parser.py,sha256=sVy3pR-G0ZE9pOhnFxurce_Ygzjh6zaZebhA504KDlI,1115
|
|
8
|
+
pyblnet/tests/test_web.py,sha256=8ypDQhkgzR2PDg0lYaRwFYDlk1x3niJY7xOTk6KZCmM,7039
|
|
8
9
|
pyblnet/tests/test_structure/580500.alternative.htm,sha256=yN1OE4EJDpTk-vAFjI-OXYYSJIWRIikiQLRsf8rF3LQ,6968
|
|
9
10
|
pyblnet/tests/test_structure/580500.htm,sha256=T1xwHQlvqZBEG72HX7trw4f-UaiO9zY9f1-mNbDAx9I,6992
|
|
10
11
|
pyblnet/tests/test_structure/580600.htm,sha256=MxVwje142sbAYzP7ia_GAN8xqjz5nc67Xzj07JdyaKA,8421
|
|
@@ -16,8 +17,8 @@ pyblnet/tests/test_structure/par.htm,sha256=i-VuEEaeAuEy6JmHEZVJIyNisOFBT6s6LLF5
|
|
|
16
17
|
pyblnet/tests/test_structure/server_control.py,sha256=4lvHzqph-8steCaOJlOwdbz4X7mS6LIwXNoGyc8Uh-0,1650
|
|
17
18
|
pyblnet/tests/web_raw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
19
|
pyblnet/tests/web_raw/web_state.py,sha256=RQdSu8S6LsEg8kkqpLVnhOv_tL0Pn8c2MCb8qXT2Dxk,5234
|
|
19
|
-
PyBLNET-0.9.
|
|
20
|
-
PyBLNET-0.9.
|
|
21
|
-
PyBLNET-0.9.
|
|
22
|
-
PyBLNET-0.9.
|
|
23
|
-
PyBLNET-0.9.
|
|
20
|
+
PyBLNET-0.9.4.dist-info/LICENSE.txt,sha256=qLriK0Yi_eGmEwdftMY0hOmBLuYbPHMXDqzc7GZCAps,1077
|
|
21
|
+
PyBLNET-0.9.4.dist-info/METADATA,sha256=DGBMx5cFky_-9vuzc0O7dtX7G9l98QHQlgwGikQALfs,3850
|
|
22
|
+
PyBLNET-0.9.4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
23
|
+
PyBLNET-0.9.4.dist-info/top_level.txt,sha256=kgkmudEmlKVRznWy4MId7Gz3z075jYSz3Z88Vc6oGm0,8
|
|
24
|
+
PyBLNET-0.9.4.dist-info/RECORD,,
|
pyblnet/__init__.py
CHANGED
pyblnet/blnet_conn.py
CHANGED
pyblnet/blnet_parser.py
CHANGED
|
@@ -80,19 +80,29 @@ class BLNETParser:
|
|
|
80
80
|
|
|
81
81
|
self.speed = {}
|
|
82
82
|
for channel in range(0, 4):
|
|
83
|
-
|
|
83
|
+
speed = self._convert_speed(speed[channel])
|
|
84
|
+
if speed:
|
|
85
|
+
self.speed[channel + 1] = round(speed, 3)
|
|
86
|
+
else:
|
|
87
|
+
break
|
|
84
88
|
|
|
85
89
|
self.energy = {}
|
|
86
90
|
for channel in range(0, 2):
|
|
87
|
-
self.
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
energy = self._convert_energy(MWh[channel], kWh[channel], active, channel)
|
|
92
|
+
if energy:
|
|
93
|
+
self.energy[channel + 1] = round(energy, 3)
|
|
94
|
+
else:
|
|
95
|
+
break
|
|
90
96
|
|
|
91
97
|
self.power = {}
|
|
92
98
|
for channel in range(0, 2):
|
|
93
|
-
self.power[channel
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
power = self._convert_power(power[channel], active, channel)
|
|
100
|
+
if power:
|
|
101
|
+
self.power[channel + 1] = round(
|
|
102
|
+
self._convert_power(power[channel], active, channel), 3
|
|
103
|
+
)
|
|
104
|
+
else:
|
|
105
|
+
break
|
|
96
106
|
|
|
97
107
|
def to_dict(self):
|
|
98
108
|
"""
|
pyblnet/blnet_web.py
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from pyblnet.blnet_parser import BLNETParser
|
|
2
|
+
import unittest
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TestParser(unittest.TestCase):
|
|
6
|
+
|
|
7
|
+
def test_parser_ok(self):
|
|
8
|
+
data = b'} \xb5"f"\x03"~!\x8e"\x16!\xe0 \xff \xf3 \xf8 \x00\x00=!\x01\x00\x00`\xe2!\x00\x00\x80\x00\x00\x00\x00,\x00\xa4(\x06\x00DhI\x82\x1d\x04Ce\xc0\x00'
|
|
9
|
+
parser = BLNETParser(data)
|
|
10
|
+
parsed_values = parser.to_dict()
|
|
11
|
+
expected_values = {
|
|
12
|
+
'analog': {1: 12.5, 2: 69.3, 3: 61.4, 4: 51.5, 5: 38.2, 6: 65.4, 7: 27.8, 8: 22.4, 9: 25.5, 10: 24.3, 11: 24.8, 12: 0, 13: 31.7, 14: 1, 15: 0, 16: 48.2},
|
|
13
|
+
'digital': {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0},
|
|
14
|
+
'speed': {},
|
|
15
|
+
'energy': {},
|
|
16
|
+
'power': {}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
assert parsed_values == expected_values
|
|
20
|
+
|
|
21
|
+
def test_parser_not_ok(self):
|
|
22
|
+
data = b'broken} \xb5"f"\x03"~!\x8e"\x16!\xe0 \xff \xf3 \xf8 \x00\x00=!\x01\x00\x00`\xe2!\x00\x00\x80\x00\x00\x00\x00,\x00\xa4(\x06\x00DhI\x82\x1d\x04Ce\xc0\x00'
|
|
23
|
+
with self.assertRaises(ValueError):
|
|
24
|
+
parser = BLNETParser(data)
|
pyblnet/tests/test_web.py
CHANGED
|
@@ -21,7 +21,7 @@ class OfflineTest(unittest.TestCase):
|
|
|
21
21
|
url = ADDRESS
|
|
22
22
|
|
|
23
23
|
def test_blnet(self):
|
|
24
|
-
"""
|
|
24
|
+
"""Test finding the blnet"""
|
|
25
25
|
self.assertFalse(test_blnet(self.url, timeout=10))
|
|
26
26
|
|
|
27
27
|
def test_blnet_web(self):
|
|
@@ -65,7 +65,7 @@ class BLNETWebTest(unittest.TestCase):
|
|
|
65
65
|
self.server_control.start_server()
|
|
66
66
|
|
|
67
67
|
def test_blnet(self):
|
|
68
|
-
"""
|
|
68
|
+
"""Test finding the blnet"""
|
|
69
69
|
self.assertTrue(test_blnet(self.url, timeout=10))
|
|
70
70
|
self.server.set_blocked()
|
|
71
71
|
self.assertTrue(test_blnet(self.url, timeout=10))
|
|
@@ -85,7 +85,7 @@ class BLNETWebTest(unittest.TestCase):
|
|
|
85
85
|
self.assertTrue(blnet.logged_in())
|
|
86
86
|
|
|
87
87
|
def test_blnet_fetch(self):
|
|
88
|
-
"""
|
|
88
|
+
"""Test fetching data in higher level class"""
|
|
89
89
|
self.assertEqual(
|
|
90
90
|
BLNET(
|
|
91
91
|
ADDRESS, password=PASSWORD, timeout=10, use_ta=False, web_port=self.port
|
|
@@ -94,7 +94,7 @@ class BLNETWebTest(unittest.TestCase):
|
|
|
94
94
|
)
|
|
95
95
|
|
|
96
96
|
def test_blnet_fetch_fine_grained(self):
|
|
97
|
-
"""
|
|
97
|
+
"""Test fetching data in higher level class"""
|
|
98
98
|
fetched = STATE
|
|
99
99
|
|
|
100
100
|
def scratch_tuple(type, id, ret):
|
|
@@ -125,7 +125,7 @@ class BLNETWebTest(unittest.TestCase):
|
|
|
125
125
|
)
|
|
126
126
|
|
|
127
127
|
def test_blnet_turn(self):
|
|
128
|
-
"""
|
|
128
|
+
"""Test higher level turn methods"""
|
|
129
129
|
blnet = BLNET(
|
|
130
130
|
ADDRESS, password=PASSWORD, timeout=10, use_ta=False, web_port=self.port
|
|
131
131
|
)
|
|
@@ -139,7 +139,7 @@ class BLNETWebTest(unittest.TestCase):
|
|
|
139
139
|
self.assertEqual(self.server.get_node("1"), "1")
|
|
140
140
|
|
|
141
141
|
def test_blnet_fetch_error(self):
|
|
142
|
-
"""
|
|
142
|
+
"""Test fetching data in higher level class with missing password (or otherwise denied access to the data)"""
|
|
143
143
|
self.assertEqual(
|
|
144
144
|
BLNET(
|
|
145
145
|
ADDRESS, password=None, timeout=10, use_ta=False, web_port=self.port
|
|
@@ -148,17 +148,17 @@ class BLNETWebTest(unittest.TestCase):
|
|
|
148
148
|
)
|
|
149
149
|
|
|
150
150
|
def test_blnet_web_analog(self):
|
|
151
|
-
"""
|
|
151
|
+
"""Test reading analog values"""
|
|
152
152
|
with BLNETWeb(self.url, password=PASSWORD, timeout=10) as blnet:
|
|
153
153
|
self.assertEqual(blnet.read_analog_values(), STATE_ANALOG)
|
|
154
154
|
|
|
155
155
|
def test_blnet_web_digital(self):
|
|
156
|
-
"""
|
|
156
|
+
"""Test reading digital values"""
|
|
157
157
|
with BLNETWeb(self.url, password=PASSWORD, timeout=10) as blnet:
|
|
158
158
|
self.assertEqual(blnet.read_digital_values(), STATE_DIGITAL)
|
|
159
159
|
|
|
160
160
|
def test_blnet_web_set_digital(self):
|
|
161
|
-
"""
|
|
161
|
+
"""Test setting digital values"""
|
|
162
162
|
with BLNETWeb(self.url, password=PASSWORD, timeout=10) as blnet:
|
|
163
163
|
blnet.set_digital_value(10, "2")
|
|
164
164
|
self.assertEqual(self.server.get_node("A"), "2")
|
|
@@ -188,7 +188,7 @@ class BLNETWebTest(unittest.TestCase):
|
|
|
188
188
|
pass
|
|
189
189
|
|
|
190
190
|
def test_blnet_web_log_out(self):
|
|
191
|
-
"""
|
|
191
|
+
"""Test setting digital values"""
|
|
192
192
|
blnet = BLNETWeb(self.url, password=PASSWORD, timeout=10)
|
|
193
193
|
self.assertFalse(blnet.logged_in())
|
|
194
194
|
with blnet as blnet:
|
|
File without changes
|
|
File without changes
|