-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.py
56 lines (46 loc) · 1.72 KB
/
event.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from models import Event, LinpotEvent
import logging
class parser():
def __init__(self, event: Event) -> None:
self.event = event
def parse(self)-> Event:
if self.event["name"] == "linpot":
DataTransformer(self.event).handle_linpot()
name = self.event['name']
if self.event["name"] == "acclgyro":
DataTransformer(self.event).handle_acclgyro()
if self.event["name"] == "ecu":
DataTransformer(self.event).handle_ecu()
class DataTransformer():
def __init__(self, event: Event):
self.event = event
def handle_linpot(self) -> Event:
"""
apply displacement calculations to the event fields.
this method is to handle all linpot transformations specifically
"""
# for key in list of keys
try:
linpot_event = LinpotEvent(
FrontLeft=self.event.fields['front_left'],
FrontRight=self.event.fields['front_right'],
RearLeft=self.event.fields['rear_left'],
RearRight=self.event.fields['rear_right']
)
linpot_event.calculate_displacements_mm()
except KeyError as e:
logging.error("KeyError: %s", e)
logging.error("Fields: %s", self.event.fields)
return
def handle_acclgyro(self) -> Event:
"""
apply acceleration calculations to the event fields.
this method is to handle all acclgyro transformations specifically
"""
pass
def handle_ecu(self) -> Event:
"""
apply ecu calculations to the event fields.
this method is to handle all ecu transformations specifically
"""
pass