From a23795773ab7769cf84bfa6da3c1ee045139d2cf Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 25 Jan 2018 23:17:26 +0100 Subject: generating inputs works now --- src/flufigut.py | 91 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 79 insertions(+), 12 deletions(-) (limited to 'src/flufigut.py') diff --git a/src/flufigut.py b/src/flufigut.py index 42406d3..03dd084 100755 --- a/src/flufigut.py +++ b/src/flufigut.py @@ -48,10 +48,10 @@ class Description: def __init__(self): self.globals = {} - self.input = {} - self.mux = {} - self.stream = {} - self.record = {} + self.inputs = {} + self.muxes = {} + self.streams = {} + self.records = {} def _sanity_check(self): # TODO: add more sanity checks @@ -69,11 +69,11 @@ class Description: cf.close() self.globals = config['globals'] - self.input = config['input'] - self.mux = config['mux'] - self.stream = config['stream'] - if 'record' in config: - self.record = config['record'] + self.inputs = config['inputs'] + self.muxs = config['muxes'] + self.streams = config['streams'] + if 'records' in config: + self.records = config['records'] return self._sanity_check() @@ -86,6 +86,45 @@ class Planet: def __init__(self): self.atmosphere = {} self.flow = {} + self._workers = {} + self._components = {} + + def __set_input_properties(self, name, props, globals): + for prop in props.keys(): + if prop == 'resolution': + self.flow['inputs'][name]['properties']['width'] = globals['resolutions'][props[prop]]['width'] + self.flow['inputs'][name]['properties']['height'] = globals['resolutions'][props[prop]]['height'] + self.flow['inputs'][name]['properties']['framerate'] = globals['resolutions'][props[prop]]['rate'] + else: + self.flow['inputs'][name]['properties'][prop] = props[prop] + + def _generate_inputs(self, inputs, globals): + self.flow['inputs'] = {} + master_cnt = 0 + for source, input in inputs.items(): + name = 'input-%s' % source + if name not in self._components: + self._components[name] = -1 + else: + self._components[name] = 1 + self.flow['inputs'][name] = { + 'type': input['type'], + 'desc': "capture raw data from %s" % (source), + 'worker': name, + 'master': input['master'], + 'properties': {}, + } + if input['master']: + master_cnt += 1 + self.__set_input_properties(name, input['properties'], globals) + + if master_cnt == 0: + raise exception("You have not configured any master clock device!") + elif master_cnt > 1: + raise exception("You have configured multiple master clock devices!") + + def generate(self, desc): + self._generate_inputs(desc.inputs, desc.globals) # Main ######################################################## @@ -103,12 +142,40 @@ if __name__ == '__main__': ret = 0 try: - desc = Description() - desc.parse(config_file) + d = Description() + d.parse(config_file) + + p = Planet() + p.generate(d) + + print("****************************************************") + print("** atmosphere **") + print("**") + __pp.pprint(p.atmosphere) + + print("**") + print("**************************") + print("** planet **") + print("**") + __pp.pprint(p.flow) + + print("**") + print("****************************************************") + print("** _workers **") + print("**") + __pp.pprint(p._workers) + + print("**") + print("**************************") + print("** _components **") + print("**") + __pp.pprint(p._components) + print("**") + print("****************************************************") except Exception as e: print("ERROR: while running app: %s" % e) - # print(traceback.format_exc()) + print(traceback.format_exc()) sys.exit(1) sys.exit(ret) -- cgit v1.2.3