Implemented thread calls for callbacks

This commit is contained in:
Maximilian Giller 2021-12-03 16:48:26 +01:00
parent 68f767a9af
commit ee6d000338

View file

@ -1,7 +1,7 @@
from typing import Dict from typing import Dict
from sensor.tof_sensor import ToFSensor, Directions from sensor.tof_sensor import ToFSensor, Directions
from datetime import datetime from datetime import datetime
import logging import threading
COUNTING_CB = "counting" COUNTING_CB = "counting"
@ -137,15 +137,18 @@ class PeopleCounter ():
return return
for cb in self.callbacks[COUNTING_CB]: for cb in self.callbacks[COUNTING_CB]:
cb(countChange) th = threading.Thread(target=cb, args=(countChange,))
th.start()
def handleActivityCallbacks(self, direction: Directions) -> None: def handleActivityCallbacks(self, direction: Directions) -> None:
for cb in self.callbacks[ACTIVITY_CB]: for cb in self.callbacks[ACTIVITY_CB]:
cb(direction) th = threading.Thread(target=cb, args=(direction,))
th.start()
def handleChangeCallbacks(self, countChange: int) -> None: def handleChangeCallbacks(self, countChange: int) -> None:
for cb in self.callbacks[CHANGE_CB]: for cb in self.callbacks[CHANGE_CB]:
cb(countChange, self.directionState) th = threading.Thread(target=cb, args=(countChange, self.directionState))
th.start()
def getDirectionTime(self, direction: Directions, time: str) -> datetime: def getDirectionTime(self, direction: Directions, time: str) -> datetime:
if len(self.directionState[direction]) <= 0: if len(self.directionState[direction]) <= 0: