-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add popbuffer draft to eventually switchover to 3_9_0
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
case UINT32: | ||
# Handle UINT32 | ||
pass | ||
case INT16: | ||
# Handle INT16 | ||
pass | ||
case INT32: | ||
# Handle INT32 | ||
pass | ||
case _: | ||
raise ValueError(f"Unsupported data type: {dataType}") | ||
item = self.buffer[self.position] | ||
self.position += 1 | ||
return item |