Ejemplo n.º 1
0
def main():
    init_logging('power_controlled_lights.log')

    logging.info('Reading settings configuration file')
    cfg = ConfigParser()
    cfg.read('settings.cfg')

    device_cfg = ConfigParser()
    device_cfg.read('device_settings.cfg')

    logging.info('Initializing LED strip driver')
    color_strip = ColorStrip(device_cfg, LED_FREQ_HZ)

    signal.signal(signal.SIGTERM,
                  lambda: color_strip.set_color(RgbColor(0, 0, 0)))

    logging.info('Creating ANT+ node')
    node = AntPlusNode(NETWORK_KEY)

    try:
        logging.info('Attaching ANT+ power meter')
        pwr_meter = node.attach_power_meter()
        logging.info('Initializing power light controller')
        plc = PowerLightController(node.stop, None, cfg, pwr_meter,
                                   color_strip)
        logging.info('Starting ANT+ node')
        node.start()
    except Exception as e:
        logging.error('Caught exception "%s"' % str(e))
        raise
    finally:
        logging.info('Turning off LED strip')
        color_strip.set_color(RgbColor(0, 0, 0))
        logging.info('Stopping ANT+ node')
        node.stop()
Ejemplo n.º 2
0
def main():
    init_logging('hr_controlled_fan.log')

    logging.info('Reading settings configuration file')
    cfg = ConfigParser()
    cfg.read('settings.cfg')

    device_cfg = ConfigParser()
    device_cfg.read('device_settings.cfg')

    logging.info('Initializing fan driver')
    fan = FourSpeedRealayFan(device_cfg)

    logging.info('Creating ANT+ node')
    node = AntPlusNode(NETWORK_KEY)
    
    try:
        logging.info('Attaching ANT+ heart rate monitor')
        hrm = node.attach_hrm()
        logging.info('Initializing heart rate fan controller')
        hfc = HRFanController(node.stop, None, cfg, hrm, fan)
        logging.info('Starting ANT+ node')        
        node.start()
    except Exception as e:
        logging.error('Caught exception "%s"' % str(e))
        raise
    finally:
        logging.info('Turning off fan')
        fan.select_speed(0)
        logging.info('Stopping ANT+ node')
        node.stop()
def main():
    init_logging('control_fan_and_lights.log')

    logging.info('Reading settings configuration file')
    cfg = ConfigParser()
    cfg.read('settings.cfg')

    device_cfg = ConfigParser()
    device_cfg.read('device_settings.cfg')

    logging.info('Initializing fan driver')
    fan = FourSpeedRealayFan(device_cfg)
    logging.info('Initializing LED strip driver')
    color_strip = ColorStrip(device_cfg, LED_FREQ_HZ)

    signal.signal(signal.SIGTERM,
                  lambda: color_strip.set_color(RgbColor(0, 0, 0)))

    logging.info('Creating ANT+ node')
    node = AntPlusNode(NETWORK_KEY)

    try:
        node_stopper = TwoClientNodeStopper(node)
        logging.info('Attaching ANT+ heart rate monitor')
        hrm = node.attach_hrm()
        logging.info('Initializing heart rate fan controller')
        hfc = HRFanController(node_stopper.stop_client1,
                              node_stopper.cancel_stop_client1, cfg, hrm, fan)
        logging.info('Attaching ANT+ power meter')
        pwr_meter = node.attach_power_meter()
        meter_id = node.check_id_of_power_meter()
        logging.info('Initializing power light controller')
        plc = PowerLightController(node_stopper.stop_client2,
                                   node_stopper.cancel_stop_client2, cfg,
                                   pwr_meter, color_strip)
        logging.info('Starting ANT+ node')
        node.start()
    except Exception as e:
        logging.error('Caught exception "%s"' % str(e))
        raise
    finally:
        logging.info('Turning off fan')
        fan.select_speed(0)
        logging.info('Turning off LED strip')
        color_strip.set_color(RgbColor(0, 0, 0))
        logging.info('Stopping ANT+ node')
        node.stop()
Ejemplo n.º 4
0
#!/usr/bin/env python3
from setup.trainertools import trainer_toolsPackage
from scriptcommon import init_logging

init_logging('trainer_tools.setup.log', debug=True)

pkg = trainer_toolsPackage()

pkg.install()

Ejemplo n.º 5
0
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


from configparser import ConfigParser
from devices.fan import FourSpeedRealayFan
from scriptcommon import init_logging
import argparse
import time
import logging

parser = argparse.ArgumentParser(description='Control a fan')
parser.add_argument('-s', '--speed', default=1, type=int, help='the fan speed to set')
args = parser.parse_args()

init_logging('hr_controlled_fan.log')

device_cfg = ConfigParser()
device_cfg.read('device_settings.cfg')


logging.info('Initializing fan driver')
fan = FourSpeedRealayFan(device_cfg)

logging.info('setting fan speed to %u' % args.speed)
fan.select_speed(args.speed)

logging.info('Press Ctrl-C to quit')
while True:
    time.sleep(1)