eventparser: move baseevent

This commit is contained in:
James Woglom
2024-12-10 17:44:32 -05:00
parent 9a2a4ca771
commit e82d311fd6
3 changed files with 32 additions and 15 deletions
+1 -7
View File
@@ -3,18 +3,12 @@ import struct
import logging
from dataclasses import dataclass
from enum import Enum, IntFlag
from .raw_event import RawEvent
from .raw_event import RawEvent, BaseEvent
logger = logging.getLogger(__name__)
EVENT_LEN = 26
@dataclass
class BaseEvent:
@staticmethod
def build(raw):
raise NotImplemented
'''
TYPE_TO_STRUCT = {
+1 -7
View File
@@ -3,18 +3,12 @@ import struct
import logging
from dataclasses import dataclass
from enum import Enum, IntFlag
from .raw_event import RawEvent
from .raw_event import RawEvent, BaseEvent
logger = logging.getLogger(__name__)
EVENT_LEN = 26
@dataclass
class BaseEvent:
@staticmethod
def build(raw):
raise NotImplemented
UINT8 = '>B'
INT8 = '>b'
UINT16 = '>H'
+30 -1
View File
@@ -10,8 +10,23 @@ UINT16 = '>H'
UINT32 = '>I'
TANDEM_EPOCH = 1199145600
@dataclass
class RawEvent:
class BaseEvent:
@staticmethod
def build(raw):
raise NotImplemented
@property
def eventTimestamp(self):
raise NotImplemented
@property
def eventId(self):
raise NotImplemented
@dataclass
class RawEvent(BaseEvent):
source: int
id: int
timestampRaw: int
@@ -39,3 +54,17 @@ class RawEvent:
# referenced on them, but force the timezone to what the user
# requests via the TZ secret.
return arrow.get(TANDEM_EPOCH + self.timestampRaw, tzinfo='UTC').replace(tzinfo=TIMEZONE_NAME)
@property
def eventId(self):
return self.id
@property
def eventTimestamp(self):
return self.timestamp
@property
def raw(self):
return self