Exemple #1
0
import argparse
import os

parser = argparse.ArgumentParser(
    description='OpenHeating: DBus switch service')
parser.add_argument('--config', help='Configuration file')
parser.add_argument(
    '--simulation-dir',
    metavar='DIR',
    help='Create "switch" files in DIR, and read/write states from/to there.')
dbusutil.argparse_add_bus(parser)
logutil.add_log_options(parser)
args = parser.parse_args()

logutil.configure_from_argparse(args, componentname=names.Bus.SWITCHES)
bus = dbusutil.bus_from_argparse(args)

if args.simulation_dir is not None:
    os.makedirs(args.simulation_dir, exist_ok=True)
config = SwitchesConfig(simulation_dir=args.simulation_dir)
config.parse(args.config, bus=bus)

switch_objects = []  # for center to know
path_and_objects = []  # [(path, object)], to publish

for name, description, switch in config.get_switches():
    swobj = Switch_Server(name=name, description=description, switch=switch)
    switch_objects.append(swobj)
    path_and_objects.append(('/switches/' + name, swobj))
Exemple #2
0
from openheating.dbus import lifecycle
from openheating.dbus.circuit import Circuit_Server
from openheating.dbus.circuit_center import CircuitCenter_Server

from gi.repository import GLib

import argparse

parser = argparse.ArgumentParser(
    description='OpenHeating: DBus circuit service')
parser.add_argument('--config', help='Configuration file')
dbusutil.argparse_add_bus(parser)
logutil.add_log_options(parser)
args = parser.parse_args()

logutil.configure_from_argparse(args, componentname=names.Bus.CIRCUITS)
bus = dbusutil.bus_from_argparse(args)

config = CircuitsConfig()
config.parse(args.config, bus=bus)

circuit_objects = []  # for center to know
path_and_objects = []  # [(path, object)], to publish

for name, description, circuit in config.get_circuits():
    cobj = Circuit_Server(name=name, description=description, circuit=circuit)
    circuit_objects.append(cobj)
    path_and_objects.append(('/circuits/' + name, cobj))

path_and_objects.append(('/', CircuitCenter_Server(objects=circuit_objects)))
Exemple #3
0
import logging

parser = argparse.ArgumentParser(
    description='OpenHeating: run a plant manually (for testing and simulating)'
)
parser.add_argument('--config', help='Configuration file')
parser.add_argument(
    '--simulation-dir',
    metavar='DIR',
    help='Create switch and thermometer files in subdirectories of DIR')
dbusutil.argparse_add_bus(parser)
logutil.add_log_options(parser)
args = parser.parse_args()

logutil.configure_from_argparse(
    args,
    # not being a dbus object, we simply identify as argv[0]
    componentname=os.path.basename(sys.argv[0]))

loop = GLib.MainLoop()
buskind = dbusutil.buskind_from_argparse(args)
bus = dbusutil.bus_from_argparse(args)

the_plant = plant.create_plant_with_main(args.config)
if args.simulation_dir is not None:
    thermometer_dir, switch_dir = the_plant.enable_simulation_mode(
        args.simulation_dir)
    print('starting in simulation mode:', file=sys.stderr)
    print('    thermometers in ', thermometer_dir, file=sys.stderr)
    print('    switches     in ', switch_dir, file=sys.stderr)

try:
Exemple #4
0
from openheating.dbus import names
from openheating.dbus import lifecycle
from openheating.dbus.main import Main_Server

from gi.repository import GLib

import argparse

parser = argparse.ArgumentParser(
    description='OpenHeating: DBus circuit service')
parser.add_argument('--config', help='Main/plant configuration file')
dbusutil.argparse_add_bus(parser)
logutil.add_log_options(parser)
args = parser.parse_args()

logutil.configure_from_argparse(args, componentname=names.Bus.MAIN)
bus = dbusutil.bus_from_argparse(args)

config = PlantConfig()
config.parse(args.config)

main_object = Main_Server(bus=bus,
                          servicedefs=config.get_servicedefs(),
                          interval=5)

lifecycle.run_server(
    loop=GLib.MainLoop(),
    bus=bus,
    busname=names.Bus.MAIN,
    objects=[('/', main_object)],
)
from gi.repository import GLib

import datetime
import argparse
import os


parser = argparse.ArgumentParser(description='OpenHeating: DBus thermometer service')
parser.add_argument('--config', help='Configuration file')
parser.add_argument('--simulation-dir', metavar='DIR', 
                    help='Create "thermometer" files in DIR, and read temperatures from there.')
dbusutil.argparse_add_bus(parser)
logutil.add_log_options(parser)
args = parser.parse_args()

logutil.configure_from_argparse(args, componentname=names.Bus.THERMOMETERS)
bus = dbusutil.bus_from_argparse(args)

if args.simulation_dir is not None:
    os.makedirs(args.simulation_dir, exist_ok=True)
config = ThermometersConfig(simulation_dir=args.simulation_dir)
config.parse(args.config, bus=bus)

thermometer_objects = [] # for center to know
path_and_objects = [] # [(path, object)], to publish

for name, description, thermometer in config.get_thermometers():
    history = History(duration=datetime.timedelta(days=1))
    thobj = Thermometer_Server(
        name=name,
        description=description,