pvblocks 0.0.1__tar.gz
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.
Potentially problematic release.
This version of pvblocks might be problematic. Click here for more details.
- pvblocks-0.0.1/LICENSE +21 -0
- pvblocks-0.0.1/PKG-INFO +16 -0
- pvblocks-0.0.1/README.md +3 -0
- pvblocks-0.0.1/pyproject.toml +17 -0
- pvblocks-0.0.1/setup.cfg +4 -0
- pvblocks-0.0.1/src/pvblocks/__init__.py +2 -0
- pvblocks-0.0.1/src/pvblocks/__main__.py +6 -0
- pvblocks-0.0.1/src/pvblocks/constants.py +32 -0
- pvblocks-0.0.1/src/pvblocks/exceptions.py +22 -0
- pvblocks-0.0.1/src/pvblocks/pvblocks_system.py +138 -0
- pvblocks-0.0.1/src/pvblocks.egg-info/PKG-INFO +16 -0
- pvblocks-0.0.1/src/pvblocks.egg-info/SOURCES.txt +13 -0
- pvblocks-0.0.1/src/pvblocks.egg-info/dependency_links.txt +1 -0
- pvblocks-0.0.1/src/pvblocks.egg-info/top_level.txt +1 -0
- pvblocks-0.0.1/tests/test.py +17 -0
pvblocks-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 rerasolutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pvblocks-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pvblocks
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Python package to directly control pvblocks modules
|
|
5
|
+
Author-email: Erik Haverkamp <erik@rera.nl>
|
|
6
|
+
Project-URL: Homepage, https://github.com/rerasolutions/pvblocks-python
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
|
|
14
|
+
### pvblocks
|
|
15
|
+
|
|
16
|
+
Package to control pvblocks modules directly
|
pvblocks-0.0.1/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pvblocks"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
authors = [
|
|
5
|
+
{ name="Erik Haverkamp", email="erik@rera.nl" },
|
|
6
|
+
]
|
|
7
|
+
description = "Python package to directly control pvblocks modules"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.8"
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Operating System :: OS Independent",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[project.urls]
|
|
17
|
+
Homepage = "https://github.com/rerasolutions/pvblocks-python"
|
pvblocks-0.0.1/setup.cfg
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from enum import IntEnum
|
|
2
|
+
|
|
3
|
+
class Rr1700Command(IntEnum):
|
|
4
|
+
IdleCommand = 0,
|
|
5
|
+
BlinkCommand = 1,
|
|
6
|
+
VoltageCommand = 2,
|
|
7
|
+
MppCommand = 3,
|
|
8
|
+
ReadCommand = 4,
|
|
9
|
+
CurveCommand = 5,
|
|
10
|
+
TransferCurveCommand = 6,
|
|
11
|
+
ExternalMppCommand = 7,
|
|
12
|
+
TriggeredCurveCommand = 8,
|
|
13
|
+
GetStatus = 13,
|
|
14
|
+
WriteEepromCommand = 14,
|
|
15
|
+
SetTriggerCommand = 15,
|
|
16
|
+
ReadEepromCommand = 16,
|
|
17
|
+
UpdateConfigCommand = 17,
|
|
18
|
+
GetConfigCommand = 18,
|
|
19
|
+
StartFirmwareUpdate = 19,
|
|
20
|
+
EnableFastCommunications = 20,
|
|
21
|
+
DisableBroadcast = 21,
|
|
22
|
+
TriggeredReadCommand = 50,
|
|
23
|
+
Alive = 100,
|
|
24
|
+
ListModules = 101,
|
|
25
|
+
OpenModule = 106,
|
|
26
|
+
CloseModule = 107,
|
|
27
|
+
ResetModule = 108,
|
|
28
|
+
ResetController = 109,
|
|
29
|
+
TriggerAll = 110,
|
|
30
|
+
BroadcastThresholdExceeded = 111,
|
|
31
|
+
CurveRunning = 250
|
|
32
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class NoResponseException(Exception):
|
|
2
|
+
'''No response from system.'''
|
|
3
|
+
def __str__(self):
|
|
4
|
+
return self.__doc__
|
|
5
|
+
|
|
6
|
+
class UnexpectedResponseException(Exception):
|
|
7
|
+
'''Unexpected response from system.'''
|
|
8
|
+
def __str__(self):
|
|
9
|
+
return self.__doc__
|
|
10
|
+
|
|
11
|
+
class NoReadDataImplementedException(Exception):
|
|
12
|
+
'''No read_data implemented for this blocktype.'''
|
|
13
|
+
|
|
14
|
+
def __str__(self):
|
|
15
|
+
return self.__doc__
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CannotOpenBlockException(Exception):
|
|
19
|
+
'''Cannot open PVBlock.'''
|
|
20
|
+
|
|
21
|
+
def __str__(self):
|
|
22
|
+
return self.__doc__
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
from . import VERSION
|
|
2
|
+
from . import exceptions
|
|
3
|
+
from . import constants
|
|
4
|
+
import serial
|
|
5
|
+
import uuid
|
|
6
|
+
from time import sleep
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def show_version():
|
|
10
|
+
return VERSION
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def ReadSerial(ser):
|
|
14
|
+
out = []
|
|
15
|
+
while ser.inWaiting() > 0:
|
|
16
|
+
out.append(ser.read(1)[0])
|
|
17
|
+
return out
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class PvBlocks(object):
|
|
21
|
+
TYPES = {
|
|
22
|
+
20: 'IV/MPP IV-Curve control and measure PvBlock',
|
|
23
|
+
30: 'PV-IRR 4x analog voltage readout block',
|
|
24
|
+
40: 'PV-TEMP 4x Pt100 readout block'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
def __init__(self, serialport):
|
|
28
|
+
# type: (UART_Adapter) -> None
|
|
29
|
+
self.uart = serial.Serial(serialport,
|
|
30
|
+
baudrate=115200,
|
|
31
|
+
bytesize=serial.EIGHTBITS,
|
|
32
|
+
parity=serial.PARITY_NONE,
|
|
33
|
+
stopbits=serial.STOPBITS_ONE,
|
|
34
|
+
timeout=1)
|
|
35
|
+
|
|
36
|
+
def init_system(self):
|
|
37
|
+
self.uart.write(serial.to_bytes([1, constants.Rr1700Command.Alive]))
|
|
38
|
+
sleep(0.5)
|
|
39
|
+
bts = ReadSerial(self.uart)
|
|
40
|
+
if len(bts) != 2:
|
|
41
|
+
raise exceptions.NoResponseException()
|
|
42
|
+
return bts[0] == 3 and bts[1] == constants.Rr1700Command.Alive
|
|
43
|
+
|
|
44
|
+
def scanblocks(self):
|
|
45
|
+
self.uart.write(serial.to_bytes([1, constants.Rr1700Command.ListModules]))
|
|
46
|
+
sleep(2)
|
|
47
|
+
bts = ReadSerial(self.uart)
|
|
48
|
+
|
|
49
|
+
if (bts[0] != 3) or (bts[1] != constants.Rr1700Command.ListModules):
|
|
50
|
+
raise exceptions.UnexpectedResponseException()
|
|
51
|
+
|
|
52
|
+
module_count = bts[3]
|
|
53
|
+
self.Blocks = []
|
|
54
|
+
for index in range(module_count):
|
|
55
|
+
blck = PvBlock(bts[(index * 9) + 4: (index * 9) + 13])
|
|
56
|
+
self.Blocks.append(blck)
|
|
57
|
+
|
|
58
|
+
return module_count > 0
|
|
59
|
+
|
|
60
|
+
def open_block(self, pvblock):
|
|
61
|
+
self.uart.write(serial.to_bytes([1,
|
|
62
|
+
constants.Rr1700Command.OpenModule,
|
|
63
|
+
0,
|
|
64
|
+
pvblock.bytes[0],
|
|
65
|
+
pvblock.bytes[1],
|
|
66
|
+
pvblock.bytes[2],
|
|
67
|
+
pvblock.bytes[3],
|
|
68
|
+
pvblock.bytes[4],
|
|
69
|
+
pvblock.bytes[5],
|
|
70
|
+
pvblock.bytes[6],
|
|
71
|
+
pvblock.bytes[7]]))
|
|
72
|
+
sleep(0.5)
|
|
73
|
+
bts = ReadSerial(self.uart)
|
|
74
|
+
|
|
75
|
+
return len(bts) == 3
|
|
76
|
+
|
|
77
|
+
def close_block(self, pvblock):
|
|
78
|
+
self.uart.write(serial.to_bytes([1,
|
|
79
|
+
constants.Rr1700Command.CloseModule,
|
|
80
|
+
pvblock.bytes[0],
|
|
81
|
+
pvblock.bytes[1],
|
|
82
|
+
pvblock.bytes[2],
|
|
83
|
+
pvblock.bytes[3],
|
|
84
|
+
pvblock.bytes[4],
|
|
85
|
+
pvblock.bytes[5],
|
|
86
|
+
pvblock.bytes[6],
|
|
87
|
+
pvblock.bytes[7]]))
|
|
88
|
+
sleep(0.5)
|
|
89
|
+
bts = ReadSerial(self.uart)
|
|
90
|
+
|
|
91
|
+
return len(bts) == 3
|
|
92
|
+
|
|
93
|
+
def read_data(self, pvblock):
|
|
94
|
+
try:
|
|
95
|
+
if pvblock.Type == 20:
|
|
96
|
+
return self.read_ivpoint(pvblock)
|
|
97
|
+
if pvblock.Type == 30:
|
|
98
|
+
return self.read_irradiances(pvblock)
|
|
99
|
+
except:
|
|
100
|
+
print("Exception raised")
|
|
101
|
+
finally:
|
|
102
|
+
self.close_block(pvblock)
|
|
103
|
+
|
|
104
|
+
raise exceptions.NoReadDataImplementedException()
|
|
105
|
+
|
|
106
|
+
def read_irradiances(self, pvblock):
|
|
107
|
+
if self.open_block(pvblock):
|
|
108
|
+
self.uart.write(serial.to_bytes([2, constants.Rr1700Command.ReadCommand]))
|
|
109
|
+
sleep(0.5)
|
|
110
|
+
bts = ReadSerial(self.uart)
|
|
111
|
+
if len(bts) < 10:
|
|
112
|
+
raise exceptions.UnexpectedResponseException()
|
|
113
|
+
|
|
114
|
+
r1 = int.from_bytes(bts[3:7], "little") / 1000.0
|
|
115
|
+
r2 = int.from_bytes(bts[7:11], "little") / 1000.0
|
|
116
|
+
if bts[2] == 16:
|
|
117
|
+
r3 = int.from_bytes(bts[11:15], "little") / 1000.0
|
|
118
|
+
r4 = int.from_bytes(bts[15:19], "little") / 1000.0
|
|
119
|
+
return r1, r2, r3, r4
|
|
120
|
+
else:
|
|
121
|
+
return r1, r2
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
else:
|
|
125
|
+
raise exceptions.CannotOpenBlockException()
|
|
126
|
+
|
|
127
|
+
return (0, 0, 0, 0)
|
|
128
|
+
|
|
129
|
+
def read_ivpoint(self, pvblock):
|
|
130
|
+
return (0, 0)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class PvBlock(object):
|
|
134
|
+
def __init__(self, bytes):
|
|
135
|
+
self.bytes = bytes[0:8]
|
|
136
|
+
id = int.from_bytes(bytearray(self.bytes), 'little')
|
|
137
|
+
self.Guid = uuid.UUID(int=id)
|
|
138
|
+
self.Type = bytes[8]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pvblocks
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Python package to directly control pvblocks modules
|
|
5
|
+
Author-email: Erik Haverkamp <erik@rera.nl>
|
|
6
|
+
Project-URL: Homepage, https://github.com/rerasolutions/pvblocks-python
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
|
|
14
|
+
### pvblocks
|
|
15
|
+
|
|
16
|
+
Package to control pvblocks modules directly
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/pvblocks/__init__.py
|
|
5
|
+
src/pvblocks/__main__.py
|
|
6
|
+
src/pvblocks/constants.py
|
|
7
|
+
src/pvblocks/exceptions.py
|
|
8
|
+
src/pvblocks/pvblocks_system.py
|
|
9
|
+
src/pvblocks.egg-info/PKG-INFO
|
|
10
|
+
src/pvblocks.egg-info/SOURCES.txt
|
|
11
|
+
src/pvblocks.egg-info/dependency_links.txt
|
|
12
|
+
src/pvblocks.egg-info/top_level.txt
|
|
13
|
+
tests/test.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pvblocks
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
from pvblocks_io_rera import pvblocks_system
|
|
3
|
+
|
|
4
|
+
print(pvblocks_system.show_version())
|
|
5
|
+
|
|
6
|
+
pvblock = pvblocks_system.PvBlocks('COM16')
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
print(pvblock.init_system())
|
|
10
|
+
print(pvblock.scanblocks())
|
|
11
|
+
|
|
12
|
+
for b in pvblock.Blocks:
|
|
13
|
+
print(b.Guid)
|
|
14
|
+
print(pvblocks_system.PvBlocks.TYPES[b.Type])
|
|
15
|
+
|
|
16
|
+
for b in pvblock.Blocks:
|
|
17
|
+
print(pvblock.read_data(b))
|