Пример #1
0
class BrickletDualRelay:
    def __init__(self, uid, switch_id, ip, connection, logging_daemon, queue):
        self._bricklet = DualRelay(uid, connection)
        self.uid = uid
        self.switch_id = switch_id
        self.ip = ip
        self._logging_daemon = logging_daemon
        self._queue = queue
        self._logging_daemon.info(
            'Tinkerforge ... DualRelay-Bricklet "%s" initialisiert' % uid)

    def status(self, number):
        _tmp = self._bricklet.get_state()
        return _tmp[number]

    def set_switch(self, switch_to, arg_a, arg_b, arg_c, arg_d):
        self._bricklet.set_selected_state((arg_b + 1), switch_to)

        self._logging_daemon.debug(
            'Tinkerforge ... DualRelay-Bricklet UID "%s" , geschaltet Relais %s , SOLL = %s , IST = %s'
            % (self.uid, arg_b, switch_to, self.status(arg_b)))
        tmp_json = json.dumps({
            "usage": "switch_changed_status",
            "ip": self.ip,
            "id": self.switch_id,
            "value": switch_to
        })
        for consumer in self._queue:
            consumer(tmp_json)
            self._logging_daemon.info(
                'Tinkerforge ... DualRelay-Bricklet UID "%s" Relais %s , send %s -> SocketServer Warteschlange '
                % (self.uid, arg_b, self.status(arg_b)))
Пример #2
0
class BrickletDualRelay:
    def __init__(self, uid, switch_id, ip, connection, logging_daemon, queue):
        self._bricklet = DualRelay(uid, connection)
        self.uid = uid
        self.switch_id = switch_id
        self.ip = ip
        self._logging_daemon = logging_daemon
        self._queue = queue
        self._logging_daemon.info('Tinkerforge ... DualRelay-Bricklet "%s" initialisiert' % uid)

    def status(self, number):
        _tmp = self._bricklet.get_state()
        return _tmp[number]

    def set_switch(self, switch_to, arg_a, arg_b, arg_c, arg_d):
        self._bricklet.set_selected_state((arg_b + 1), switch_to)

        self._logging_daemon.debug(
            'Tinkerforge ... DualRelay-Bricklet UID "%s" , geschaltet Relais %s , SOLL = %s , IST = %s' % (
                self.uid, arg_b, switch_to, self.status(arg_b)))
        tmp_json = json.dumps({
            "usage": "switch_changed_status",
            "ip": self.ip,
            "id": self.switch_id,
            "value": switch_to
        })
        for consumer in self._queue:
            consumer(tmp_json)
            self._logging_daemon.info(
                'Tinkerforge ... DualRelay-Bricklet UID "%s" Relais %s , send %s -> SocketServer Warteschlange ' % (
                    self.uid, arg_b, self.status(arg_b)))