import logging import os import threading import time from model import AccessBaseManager, Mode root = os.path.dirname(__file__) accessbase_path = os.path.join(root, '..', '..', 'state') manager = AccessBaseManager(accessbase_path, ) def wait_ab(ab, name): while True: if ab.wait_for_change(): logging.info(name + " notified") alpha = manager.accessor() bravo = manager.accessor() charlie = manager.accessor() ta = threading.Thread(target=wait_ab, args=(alpha, 'alpha')) tb = threading.Thread(target=wait_ab, args=(bravo, 'bravo')) tc = threading.Thread(target=wait_ab, args=(charlie, 'charlie')) manager.change_watcher() ta.start() tb.start() tc.start() time.sleep(1)
if not GPIO.input(17): if not input_reset: LOG.info("Reset button pressed") trigger_reset() input_reset = True else: input_reset = False time.sleep(0.2) if __name__ == '__main__': root = os.path.dirname(__file__) accessbase_path = os.path.join(root, '..', 'state') access_base = AccessBaseManager(accessbase_path) server_accessor = access_base.accessor('server') effect_accessor = access_base.accessor('effectenbak') interface_accessor = access_base.accessor('interface') # Stop effect_accessor.set_mode(Mode.stop()) access_base.change_watcher() logging.info("Starting effectenbak thread") effectenbak = threading.Thread(target=effectbak_runner, args=(effect_accessor,), name='effectenbak') effectenbak.start() logging.info("Starting interface thread") interface = threading.Thread(target=interface_runner, args=(interface_accessor,), name='interface')