Simplified SensorBackend implementations

This commit is contained in:
Fabio Manganiello 2018-06-11 23:49:37 +02:00
parent f8506d6d25
commit 33a507f047
2 changed files with 1 additions and 9 deletions

View file

@ -29,6 +29,7 @@ class SensorBackend(Backend):
def run(self): def run(self):
super().run() super().run()
self.logger.info('Initialized {} sensor backend'.format(self.__class__.__name__))
while not self.should_stop(): while not self.should_stop():
new_data = self.get_measurement() new_data = self.get_measurement()

View file

@ -1,21 +1,12 @@
import serial
from platypush.backend.sensor import SensorBackend from platypush.backend.sensor import SensorBackend
from platypush.context import get_plugin from platypush.context import get_plugin
class SensorSerialBackend(SensorBackend): class SensorSerialBackend(SensorBackend):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def get_measurement(self): def get_measurement(self):
plugin = get_plugin('serial') plugin = get_plugin('serial')
return plugin.get_data().output return plugin.get_data().output
def run(self):
self.logger.info('Initialized serial backend')
super().run()
# vim:sw=4:ts=4:et: # vim:sw=4:ts=4:et: