コード例 #1
0
ファイル: server.py プロジェクト: SirWojtek/romek
 def __init__(self, bus):
     self._bus_name = dbus.service.BusName(self.service_name, bus)
     self._current_settings = CurrentSettings()
     self._current_status = CurrentStatus()
     self._scheduler = Scheduler(self._current_settings)
     self._serial_port_manager = SerialPortManager(
         self._current_settings.temperature, self._current_status)
     self._temp_history = TemperatureHistory(self._current_status)
     self._set_defaults()
     dbus.service.Object.__init__(self, bus, self.service_object)
コード例 #2
0
def par1():
    scheduler = Scheduler()
    scheduler.schedule()
コード例 #3
0
    # loop forever
    scheduler.loopForever()

    log.info("Stopping pi contoller")


if __name__ == '__main__':
    log = setupLogging()
    log.info("Starting pi controller")

    config = getConfig()
    log.info("Using config : " + str(config))

    # connect to aws iot
    plantMQTTClient = setupIotClient(config)
    log.info("IOT client connected sucessfully!")

    # Connect to db
    dbmanager = DBManager(config)

    # Set driver
    driver = None
    if not debug:
        from device.driver import Driver
        driver = Driver(config)

    # Global scheduler object
    scheduler = Scheduler(debug, config, dbmanager, driver)

    main()
コード例 #4
0
ファイル: cli.py プロジェクト: adWharf/dc
def schedule():
    from schedule.scheduler import Scheduler
    s = Scheduler()
    s.run()
コード例 #5
0
 def setUp(self):
     self.scheduler = Scheduler()
コード例 #6
0
class TestSchedule(unittest.TestCase):
    def setUp(self):
        self.scheduler = Scheduler()

    def test_run(self):
        self.scheduler.schedule()
コード例 #7
0
ファイル: __init__.py プロジェクト: pirroman/schedule
    'Job',
    'ScheduleError',
    'ScheduleValueError',
    'CancelJob',
    'Scheduler']

if sys.version_info >= (3, 5, 0):
    from schedule.async_scheduler import AsyncScheduler

    __all__ += ['AsyncScheduler']

# The following methods are shortcuts for not having to
# create a Scheduler instance:

#: Default :class:`Scheduler <Scheduler>` object
default_scheduler = Scheduler()

#: Default :class:`Jobs <Job>` list
jobs = default_scheduler.jobs  # todo: should this be a copy, e.g. jobs()?


def every(interval=1):
    """Calls :meth:`every <Scheduler.every>` on the
    :data:`default scheduler instance <default_scheduler>`.
    """
    return default_scheduler.every(interval)


def run_pending():
    """Calls :meth:`run_pending <Scheduler.run_pending>` on the
    :data:`default scheduler instance <default_scheduler>`.
コード例 #8
0
ファイル: server.py プロジェクト: SirWojtek/romek
class RomekServer(dbus.service.Object):
    service_name = 'org.romek.service'
    service_object = '/org/romek/service'
    interface_name = 'org.romek.interface'

    task_signature = 's(uu)s(uu)u'
    task_tuple_signature = '(%s)' % task_signature
    edit_task_signature = '(%s%s)' % (task_tuple_signature, task_tuple_signature)
    task_list_signature = 'a%s' % task_tuple_signature
    temperature_history_signature = 'a(uuuuuuu)'

    def __init__(self, bus):
        self._bus_name = dbus.service.BusName(self.service_name, bus)
        self._current_settings = CurrentSettings()
        self._current_status = CurrentStatus()
        self._scheduler = Scheduler(self._current_settings)
        self._serial_port_manager = SerialPortManager(
            self._current_settings.temperature, self._current_status)
        self._temp_history = TemperatureHistory(self._current_status)
        self._set_defaults()
        dbus.service.Object.__init__(self, bus, self.service_object)

    def _set_defaults(self):
        self._current_settings.temperature.value = defaults['temperature_settings']
        self._current_settings.manual_mode.value = defaults['manual_mode']
        self._current_status.temperature = defaults['temperature_status']

    ###################### dbus methods ###########################################

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = '', out_signature = 's')
    def hello_world(self):
        return 'Hello World!'

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = task_tuple_signature, out_signature = 'b')
    def add_schedule_task(self, task):
        Printer.write('add_schedule_task: ')
        Printer.write(task)
        return safe_schedule_call(partial(self._scheduler.add_task, task))

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = edit_task_signature, out_signature = 'b')
    def update_schedule_task(self, tasks):
        Printer.write('update_schedule_task: ')
        Printer.write(tasks)
        return safe_schedule_call(partial(self._scheduler.update_task, tasks))

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = task_tuple_signature, out_signature = 'b')
    def remove_schedule_task(self, task):
        Printer.write('remove_schedule_task: ')
        Printer.write(task)
        return safe_schedule_call(partial(self._scheduler.remove_task, task))

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = '', out_signature = task_list_signature)
    def list_schedule_task(self):
        Printer.write('list_schedule_task')
        return self._scheduler.list_tasks()

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = '', out_signature = 'b')
    def get_driver_status(self):
        try:
            self._serial_port_manager.send_and_receive(StatusMessage())
            return True
        except ATErrorException:
            Printer.write('Received AT+ERROR')
            return False

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = 'u', out_signature = 'b')
    def set_temperature_settings(self, temperature):
        Printer.write('set_temperature_settings: ')
        Printer.write(temperature)
        try:
            self._current_settings.temperature.update_temperature_manual(temperature)
            return True
        except ATErrorException:
            Printer.write('Received AT+ERROR')
            return False

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = '', out_signature = 'u')
    def get_temperature_settings(self):
        Printer.write('get_temperature_settings')
        return self._current_settings.temperature.value

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = '', out_signature = 'b')
    def get_manual_mode(self):
        Printer.write('get_manual_mode')
        return self._current_settings.manual_mode.value

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = 'b', out_signature = 'b')
    def set_manual_mode(self, manual_mode):
        Printer.write('set_manual_mode')
        self._current_settings.manual_mode.update(manual_mode)
        return True

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = '', out_signature = 'u')
    def get_temperature_status(self):
        Printer.write('get_temperature_status')
        temp_status = self._serial_port_manager.send_and_receive(
            TemperatureGetMessage())
        self._current_status.update(temp_status)
        return temp_status

    @dbus.service.method(dbus_interface = interface_name,
        in_signature = '', out_signature = temperature_history_signature)
    def get_temperature_history(self):
        Printer.write('get_temperature_history')
        return self._temp_history.get_list()