Implemented platform specific stuff
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-09-30 03:35:20 +02:00
parent 561dea69ba
commit 3a129f8518
4 changed files with 38 additions and 7 deletions

View File

@ -1,9 +1,13 @@
#!/usr/bin/env python3
import logging
import requests
from sensor import SoundSensor
from sender import SoundSender
from preprocessor import SoundPreProcessor
from .abcsignalprocessor import AbcSignalProcessor
from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformStatusDriver
"""
Abstract base class for signalprocessor
"""
@ -33,5 +37,20 @@ class SoundSignalProcessor(AbcSignalProcessor):
:return:
"""
soundsample_name = self.soundsensor.getvalue()
sample_decision = self.soundpreprocessor.preprocesssignal(soundsample_name)
self.soundsender.sendvalue(soundsample_name, sample_decision)
try:
sample_decision = self.soundpreprocessor.preprocesssignal(soundsample_name)
except Exception as e:
logging.exception(e)
BirbnetesIoTPlatformStatusDriver.enqueue_pattern('red', [1, 1, 1])
return
if sample_decision:
BirbnetesIoTPlatformStatusDriver.enqueue_pattern('green', [1, 0, 1])
try:
self.soundsender.sendvalue(soundsample_name, sample_decision)
except (ConnectionError, requests.HTTPError) as e:
logging.exception(e)
BirbnetesIoTPlatformStatusDriver.enqueue_pattern('red', [1, 0, 1, 0, 1])
return