diff --git a/script/local.py b/script/local.py index 970a31a..8bc7e64 100644 --- a/script/local.py +++ b/script/local.py @@ -106,4 +106,46 @@ def dont_exit(status): print ("System Exit status: ", status) sys.exit = dont_exit - + + +DEFAULT_PIPELINE_PORT = 5005 +stop_event = None +parameter_queue = None +statistics =None +current_pipeline = None + +def start_pipeline(name, pars, port=DEFAULT_PIPELINE_PORT): + global stop_event, parameter_queue, statistics + if name is None: + raise Exception("Pipeline name undefined") + stop_pipeline(); + current_pipeline = name + stop_event = threading.Event() + parameter_queue = queue.Queue() + statistics = Namespace() + def send(port): + print ("Startint pipeline ", name, " on port: ", port) + try: + processing_pipeline(stop_event, statistics, parameter_queue, camera_client, pipeline_config, port, MockBackgroundManager()) + except: + traceback.print_exc() + thread = Thread(target=send, args=(port,)) + thread.start() + +def stop_pipeline(): + global stop_event, parameter_queue, statistics + if get_pipeline(): + try: + stop_event.set() + thread.join(5.0) + except: + traceback.print_exc() + current_pipeline = None + stop_event = None + parameter_queue = None + statistics =None + + + +def get_pipeline(): + return current_pipeline \ No newline at end of file