def create_system_from_xml(input_file): """ Reads system configuration from param:`xml_system` and returns cls:`System` instances. """ from lxml import objectify root = objectify.fromstring(input_file.read()) for s in root.iterfind('system'): system = System(**dict(s.items())) for c in s.iterfind('component'): component = Component(**dict(c.items())) for t in c.iterfind('task'): task = Task(**dict(t.items())) component.addTask(task) system.addComponent(component) if args.path: system.path = args.path yield system if args.communication_server: yield add_server( system, component_period=args.communication_server_period, component_priority=args.communication_server_priority, component_budget=args.communication_server_budget, tasks=tasks)
def create_system_from_xml(xml_system, output=True): """ Reads system configuration from param:`xml_system` and returns cls:`System` instance. """ system = System(scheduler=xml_system.global_sched, resolution=xml_system.resolution) for c in xml_system.iterfind('component'): component = Component(c.cname, c.cperiod, c.cpriority, float(str(c.budget).replace(',', '.')), c.localsched, cargs.payback) system.addComponent(component) if output: print 'Component:' print 'name', 'period', 'budget', 'priority' print c.cname, c.cperiod, c.budget, c.cpriority print 'Tasks:' print 'name', 'period', 'priority', 'execution time' for t in c.iterfind('task'): if output: print t.tname, t.tperiod, t.tpriority, t.texetime component.addTask(Task(t.tname, float(str(t.tperiod).replace(',', '.')), int(t.tpriority), float(str(t.texetime).\ replace(',', '.')))) if output: print '------------------------------------' system.path = cargs.path if len(cargs.path) > 0 \ else range(len(system.tasks)) return system