Skip to content

Commit

Permalink
add popbuffer draft to eventually switchover to 3_9_0
Browse files Browse the repository at this point in the history
  • Loading branch information
sfstar committed Jan 30, 2025
1 parent 2077443 commit 9e455b3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions custom_components/victron/popBuffer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from const.py import UINT16, INT16, UINT32, INT32, STRING


class PopBuffer:
"""A buffer wrapper class that allows for positional awareness in buffer for decoding register data."""

def __init__(self, size):
self.buffer = [None] * size
self.size = size
self.position = 0

def getItemInBuffer(self, dataType):
"""Get the item in the buffer."""
match dataType:
case UINT16:
# Handle UINT16
pass

Check failure on line 17 in custom_components/victron/popBuffer.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

custom_components/victron/popBuffer.py:17:13: SyntaxError: Expected an indented block after `case` block
case UINT32:

Check failure on line 18 in custom_components/victron/popBuffer.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

custom_components/victron/popBuffer.py:18:18: SyntaxError: Simple statements must be separated by newlines or semicolons
# Handle UINT32

Check failure on line 19 in custom_components/victron/popBuffer.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

custom_components/victron/popBuffer.py:18:25: SyntaxError: Expected an expression
pass
case INT16:

Check failure on line 21 in custom_components/victron/popBuffer.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

custom_components/victron/popBuffer.py:21:18: SyntaxError: Simple statements must be separated by newlines or semicolons
# Handle INT16

Check failure on line 22 in custom_components/victron/popBuffer.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

custom_components/victron/popBuffer.py:21:24: SyntaxError: Expected an expression
pass
case INT32:

Check failure on line 24 in custom_components/victron/popBuffer.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

custom_components/victron/popBuffer.py:24:18: SyntaxError: Simple statements must be separated by newlines or semicolons
# Handle INT32

Check failure on line 25 in custom_components/victron/popBuffer.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

custom_components/victron/popBuffer.py:24:24: SyntaxError: Expected an expression
pass
case _:

Check failure on line 27 in custom_components/victron/popBuffer.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

custom_components/victron/popBuffer.py:27:18: SyntaxError: Simple statements must be separated by newlines or semicolons
raise ValueError(f"Unsupported data type: {dataType}")

Check failure on line 28 in custom_components/victron/popBuffer.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

custom_components/victron/popBuffer.py:27:20: SyntaxError: Expected an expression
item = self.buffer[self.position]
self.position += 1
return item

0 comments on commit 9e455b3

Please sign in to comment.