mirror of
https://github.com/bckelley/tconnectsync.git
synced 2026-08-24 03:34:12 -05:00
eventparser: move baseevent
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user