53d14a439b
Create setup.py (pip install kwapi). Config filename as argument. Ability to hit "control-c" to quit. Multiple improvements (bug fixes, best code organization).
30 lines
970 B
Python
30 lines
970 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
from random import randrange
|
|
import time
|
|
|
|
from driver import Driver
|
|
|
|
class Dummy(Driver):
|
|
"""Dummy driver derived from Driver class. Usefull for tests."""
|
|
|
|
def __init__(self, probe_ids, **kwargs):
|
|
"""Initializes the dummy driver.
|
|
|
|
Keyword arguments:
|
|
probe_ids -- list containing the probes IDs (a wattmeter monitor sometimes several probes
|
|
kwargs -- keywords (min_value and max_value) defining the random value interval
|
|
|
|
"""
|
|
Driver.__init__(self, probe_ids, kwargs)
|
|
self.min_value = int(kwargs.get('min', 75))
|
|
self.max_value = int(kwargs.get('max', 100))
|
|
|
|
def run(self):
|
|
"""Starts the driver thread."""
|
|
while not self.stop_request_pending():
|
|
for probe_id in self.probe_ids:
|
|
value = randrange(self.min_value, self.max_value)
|
|
self.update_value(probe_id, value)
|
|
time.sleep(1)
|