pvblocks 0.0.1__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.

Potentially problematic release.


This version of pvblocks might be problematic. Click here for more details.

pvblocks/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ VERSION = '0.0.1'
2
+ __version__ = VERSION
pvblocks/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ import os
2
+ import argparse
3
+
4
+ from datetime import datetime
5
+
6
+ from . import VERSION
pvblocks/constants.py 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
+
pvblocks/exceptions.py ADDED
@@ -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,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.
@@ -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,10 @@
1
+ pvblocks/__init__.py,sha256=zcN732L9esRapW_Ntqw0NDmCJtHlHywlKzRPn8d2Rlg,40
2
+ pvblocks/__main__.py,sha256=fhvwtf6NzUeUsjP_ARtvxcmYjAvfwqz9_K1bHFwEjUg,84
3
+ pvblocks/constants.py,sha256=Wdp6NcBqOcEYjaz0PjKG0P8sh03zi6PAZdZD8WMHiMo,811
4
+ pvblocks/exceptions.py,sha256=yCxzusmdwVpaoXA-NKEFODGqWa5S-umYCuL7WZ8sje8,570
5
+ pvblocks/pvblocks_system.py,sha256=mQLmaliU7Xc_e90a4OCpcZQlLBF6h-XzC0bVUPYQBxw,4807
6
+ pvblocks-0.0.1.dist-info/LICENSE,sha256=8xnw0w04bL1ekO1BTZPbMkUbonvCNWVu6G6k4QIFRns,1091
7
+ pvblocks-0.0.1.dist-info/METADATA,sha256=-4KllHggt5l0t8Jv7leF18RnEZbmWdMTGq4VljX5rO4,536
8
+ pvblocks-0.0.1.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
9
+ pvblocks-0.0.1.dist-info/top_level.txt,sha256=3jm7rpxZDuLfYKWbVj6i1IZJib2hTFVYxbsR68po7O8,9
10
+ pvblocks-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (72.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ pvblocks