def setUp(self) -> None: self.empire = empire.Empire(races.ORCS, start_resources=100) self.other_empire = empire.Empire(races.ELVES) Interface(self.empire, self.other_empire) Game(self.empire, self.other_empire) self.barrack = self.empire.set_city(name='test city').build_barrack(mouse_pos=(500, 500)) self.assertEqual(self.empire.resources, 80)
def __init__(self): """ Instantiate the plugin and all its modules. """ self._core = Core(self) self._interface = Interface(self) self._network = Network(self)
def test_03_reception(self): """接待""" header = self.token response = Interface().reception(header) result = json.dumps(response, ensure_ascii=False, indent=2) # print(result) print('对返回数据进行断言') print('新增接待成功')
def test_07_verification(self): """核销""" header = self.token response = Interface().verification(header) result = json.dumps(response, ensure_ascii=False, indent=2) # print(result) res = get_result_for_keyword(response, 'msg') # if self.assertEqual(res, "操作成功") == None: print("核销成功")
def test_06_payment(self): """缴费""" header = self.token response = Interface().payment(header) result = json.dumps(response, ensure_ascii=False, indent=2) print("对缴费是否成功进行断言") # print(result) res = get_result_for_keyword(response, 'msg') # if self.assertEqual(res, "操作成功") == None: print("缴费成功")
def test_05_cashier(self): """开单""" header = self.token response = Interface().cashier(header) result = json.dumps(response, ensure_ascii=False, indent=2) # print(result) print("对开单进行断言") # res = get_result_for_keyword(response, 'msg') # if self.assertEqual(res, "新建开单成功") == None: print("开单成功")
def test_02_order(self): """预约""" response = Interface().order() result = json.dumps(response, ensure_ascii=False, indent=2) print(result) res = get_result_for_keyword(response, 'msg') self.assertEqual(res, '新建预约成功') # 对结果进行断言 if self.assertEqual(res, "新建预约成功") == None: print('断言成功,接口正常请求') print("预约成功") else: print('断言失败')
def setUp(self) -> None: self.empire = empire.Empire(races.DWARFS) self.other_empire = empire.Empire(races.ELVES) Interface(self.empire, self.other_empire) Game(self.empire, self.other_empire) self.warrior = warrior.OrcWarrior(empire=self.empire, cost=10, health=11, speed=10, damage=20, fight_distance=300, size=(100, 100), image=image.get_image( self.empire).WARRIOR)
def setUp(self): """ 将登录放在这里,在每次执行用例之前执行 :return: """ print("测试开始") response = Interface().login(method=self.method, url=self.url, data=self.data) # print(type(response)) # print(response) # res = json.loads(response) res = get_result_for_keyword(response, 'token') # res1 = get_results_for_keyword(response, 'id')[-1] # res2 = get_results_for_keyword(response, 'depts')[0][0] self.token = { 'Authorization': res }
def test_04_consultation(self): """ 咨询 :return: """ header = self.token response = Interface().consultation(header) result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'msg') if res == '已经有该客户咨询': self.assertTrue(1) print ("接口请求成功") print ("但是当前已有该客户咨询") elif res== '操作成功': print("接口请求成功") print("返回数据为:",result) else: print('断言失败')
def place_test_orders(self, arbs): interface = Interface() for product in arbs.keys(): bid_ask = arbs[product] quantity = min(bid_ask["bids"]["quantity"], bid_ask["asks"]["quantity"]) # For now just submit a limit order buy and sell at the same time. for key in bid_ask: if key == 'bids': side = 'sell' elif key == 'asks': side = 'buy' data = bid_ask[key] interface.create_test_order(data['exchange'], product, side, 'limit', quantity, price=data['price'])
def __init__(self) -> None: """ Initialize the `Core` object. Unlike the __init__ of `AstParser`, the internal state of _intr and _astp persists between files specified. `self._intr` contains an instance of the `Interface` object and is responsible for providing access to high level file I/O functionality. `self._astp` contains an instance of the `AstParser` object and is responsible for processing and understanding the abstract syntax tree (AST) that PycParser generates. :return: returns nothing """ self._intr = Interface() self._astp = AstParser()
def place_orders(self, arbs): interface = Interface() for product in arbs.keys(): bid_ask = arbs[product] quantity = min(bid_ask["bids"]["quantity"], bid_ask["asks"]["quantity"]) bids = bid_ask["bids"] asks = bid_ask["asks"] # first buy then if the order is filled and the arb is still valid then sell buy_response = interface.create_test_order(bids['exchange'], product, bids['side'], 'limit', quantity, price=bids['price']) buy_order_id = buy_response['id'] order_filled = False while not order_filled: if interface.order_filled(bids['exchange'], buy_order_id): print('bought') order_filled = True else: time.sleep(5) sell_response = interface.create_test_order(asks['exchange'], product, asks['side'], 'limit', quantity, price=asks['price']) sell_order_id = sell_response['id'] order_filled = False while not order_filled: if interface.order_filled(asks['exchange'], sell_order_id): print('sold, arbitrage complete') order_filled = True else: time.sleep(5)
def setUp(self) -> None: self.empire = empire.Empire(races.ORCS) self.other_empire = empire.Empire(races.ELVES) Interface(self.empire, self.other_empire) Game(self.empire, self.other_empire) self.fabric = fabric.Manufacture().create_fabric(self.empire)
def setUp(self) -> None: self.empire = empire.Empire(races.ORCS, start_resources=100) self.other_empire = empire.Empire(races.ELVES) Interface(self.empire, self.other_empire) Game(self.empire, self.other_empire) self.mine = self.empire.set_city(name='test city').build_mine(mouse_pos=(500, 500))
def __init__(self): self.itf = Interface()
def setUp(self) -> None: self.empire = empire.Empire(races.DWARFS) self.other_empire = empire.Empire(races.ELVES) Interface(self.empire, self.other_empire) Game(self.empire, self.other_empire) self.army = army.Army(empire=self.empire)
def main(): interface = Interface("localhost", 20) interface.start_server()
def listener(): """ Listener for commands to execute """ from application.polling import flag, poll # Initialize operations and Janus interface libraries # Enable interrupts immediately obj_cmd = Command() obj_iface = Interface() obj_iface.interrupts_enable() # Send message to JanusESS main to proceed with JanusESS startup procedures MPQ_IFACE_SETUP.put_nowait(obj_iface.error_iface()) stat_cmd_prev = STAT_LVL['not_cfg'] # This while loop has no exit, JanusESS will not function without this # ongoing loop to check the following command queues in priority order: # # MPQ_CMD0: User-initiated command requests # MPQ_CMD1: Checks for neighbor-bus triggers # MPQ_CMD2: User-initiated module sensor polling # MPQ_CMD3: Lane/module initialization and setup routine # MPQ_CMD4: Upload module configuration to module # MPQ_CMD5: Recurring module sensor polling while True: stat_cmd = STAT_LVL['op'] # User-initiated command requests if not MPQ_CMD0.empty(): data_cmd0_in = MPQ_CMD0.get() log = 'Priority 0 command, command #{0} request received.'.\ format(data_cmd0_in['command']) logger.debug(log) log = 'Command {0} called.'.format(data_cmd0_in['command']) logger.info(log) if data_cmd0_in['command'] == 'log_level': if data_cmd0_in['args'][0] == 'DEBUG': logger.setLevel(logging.DEBUG) elif data_cmd0_in['args'][0] == 'INFO': logger.setLevel(logging.INFO) elif data_cmd0_in['args'][0] == 'ERROR': logger.setLevel(logging.ERROR) elif data_cmd0_in['args'][0] == 'WARNING': logger.setLevel(logging.WARNING) elif data_cmd0_in['args'][0] == 'CRITICAL': logger.setLevel(logging.CRITICAL) else: try: th_cmd0 = threading.Thread( target=obj_cmd.exec_cmd, args=( data_cmd0_in['command'], data_cmd0_in['args'], data_cmd0_in['data'], ) ) th_cmd0.start() except threading.ThreadError: stat_cmd = STAT_LVL['op_err'] log = 'Could not start user-initiated command due to threading error.' logger.exception(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'CRITICAL', log ]) log = 'Priority 0 interface request concluded.' logger.info(log) # Checks for neighbor-bus triggers # # This command is only executed if a trigger flag is discovered during # recurring module sensor polling elif not MPQ_CMD1.empty(): MPQ_CMD1.get() log = 'Priority 1 interface request received.' logger.debug(log) # Get all documents from CouchDB lanes database data_cdb_out, stat_cdb, http_cdb = dbase.cdb_request( cdb_cmd='get_all', cdb_name='lanes', logfile=logfile ) if not stat_cdb: # Cycle through lanes, if lane and lane # polling are operational, then continue procedure # to check module triggers for addr_ln in range(0, 4): if (data_cdb_out[addr_ln]['status'] < STAT_LVL['crit']) \ and (data_cdb_out[addr_ln]['poll'] < STAT_LVL['crit']): # Set four-port interface lane. This function # ignores single-port interface devices. stat_iface = obj_iface.i2c_lane_set(addr_ln=addr_ln) if not stat_iface: # Get stat_chan view from CouchDB # modconfig database data_cdb_out, stat_cdb, http_cdb = dbase.cdb_request( cdb_cmd='get_view', cdb_name='modconfig', cdb_doc='stat_chan{0}'.format(addr_ln), logfile=logfile, ) # Cycle through each non-failed module connected # to the lane if not stat_cdb: for dict_mod in data_cdb_out: if dict_mod['value']['status'] < STAT_LVL['crit']: # Call function to check an # individual module'strigger status evt_byte = MMAP[dict_mod['value']['mem_map_ver']]['M_EVT'] stat_mod = flag.interrupt( obj_iface=obj_iface, addr_ln=addr_ln, addr_mod=dict_mod['key'], evt_byte=evt_byte ) MPQ_STAT.put_nowait([ 'module', [ dict_mod['id'], addr_ln, dict_mod['key'], stat_mod ] ]) else: log = 'Could not check module interrupt flag due to CouchDB error.' logger.critical(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'CRITICAL', log ]) stat_cmd = STAT_LVL['op_err'] else: stat_cmd = STAT_LVL['op_err'] log = 'Could not complete priority 1 interface request ' + \ 'on lane {0} due to i2c lane '.format(addr_ln) +\ 'set error.' logger.critical(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'CRITICAL', log ]) obj_iface.interrupt_clear_flag() log = 'Priority 1 interface request concluded.' logger.info(log) else: log = 'Could not complete priority 1 interface request due to CouchDB error.' logger.critical(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'CRITICAL', log ]) stat_cmd = STAT_LVL['op_err'] # User-initiated module sensor polling # # This command only polls one module per request elif not MPQ_CMD2.empty(): data_cmd2_in = MPQ_CMD2.get() uid_mod = data_cmd2_in[0] addr_ln = data_cmd2_in[1] addr_mod = data_cmd2_in[2] log = 'Lane {0} module {1} priority 2 interface request received.'.format(addr_ln, addr_mod) logger.info(log) # Set four-port interface lane. This function ignores # single-port interface devices. stat_iface = obj_iface.i2c_lane_set(addr_ln=addr_ln) if not stat_iface: stat_poll_data, uid_mod_i2c = poll.get_data( obj_iface=obj_iface, uid_mod=uid_mod, addr_ln=addr_ln, addr_mod=addr_mod ) if not stat_poll_data: MPQ_STAT.put_nowait([ 'base', [ 'poll_data', STAT_LVL['op'] ] ]) stat_iface, flag = obj_iface.interrupt_check_flag() if flag: MPQ_CMD1.put(True) if not stat_iface: log = 'Lane {0} module {1} on-demand poll completed.'.format(addr_ln, addr_mod) logger.info(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'INFO', log ]) # USB reset interface board if bad data returned # # TODO: Need higher level tracking of this error # TODO: Do not wish to reset device more than once # TODO: If reset after first time fails, all # TODO: related commands will be bypassed elif (stat_poll_data == STAT_LVL['op_err']) and \ (uid_mod_i2c != uid_mod): obj_iface.setup() obj_iface.interrupts_enable() stat_cmd = STAT_LVL['op_err'] log = 'Resetting interface due to mismatch in module id: ' + \ 'requested={0} vs polled={1}.'.format(uid_mod, uid_mod_i2c) logger.warning(log) else: log = 'Could not complete priority 2 interface request on ' + \ 'lane {0} module {1} '.format(addr_ln, addr_mod) +\ 'due to i2c lane set error.' logger.critical(log) stat_cmd = STAT_LVL['op_err'] log = 'Lane {0} module '.format(addr_ln) +\ '{0} priority 2 interface request concluded.'.format(addr_mod) logger.info(log) # Lane/module initialization and setup routine elif not MPQ_CMD3.empty(): data_cmd3_in = MPQ_CMD3.get() addr_ln = data_cmd3_in[0] # FLAG_LNRST[addr_ln] = True log = 'Lane {0} priority 3 interface request received.'. \ format(addr_ln) logger.debug(log) log = 'Begin lane {0} network reset and initialization.'.\ format(addr_ln) logger.info(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'INFO', log ]) # Call lane reset command to toggle GPIO pins stat_iface = lane.reset( obj_iface=obj_iface, addr_ln=addr_ln ) if not stat_iface: # Call lane init command to setup any modules # connected to the lane stat_ch, stat_cdb = lane.init( obj_iface=obj_iface, addr_ln=addr_ln ) if not stat_ch: # Ensure that all interrupt flags are cleared prior # to any other lane activity. GPIO interrupts may # get triggered during lane setup routines. stat_iface = obj_iface.interrupt_clear_flag() if not stat_iface: log = 'Interrupt flags successfully cleared.' logger.debug(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'DEBUG', log ]) if not stat_cdb: log = 'Lane {0} network reset and initialization complete.'.format(addr_ln) logger.info(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'INFO', log ]) else: stat_cmd = STAT_LVL['op_err'] log = 'Lane {0} network reset and '.format(addr_ln) + \ 'initialization complete with CouchDB errors.' logger.info(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'WARNING', log ]) else: stat_cmd = STAT_LVL['op_err'] log = 'Could not clear interrupt flags from interface due to interface error.' logger.critical(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'WARNING', log ]) else: stat_cmd = STAT_LVL['op_err'] log = 'Lane {0} network reset and initialization failed to complete.'.format(addr_ln) logger.warning(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'CRITICAL', log ]) else: stat_cmd = STAT_LVL['op_err'] log = 'Could not initialize lane {0} network due to Neighbor Bus reset error.'.format(addr_ln) logger.critical(log) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'CRITICAL', log ]) # FLAG_LNRST[addr_ln] = False log = 'Lane {0} priority 3 interface request concluded.'.format(addr_ln) logger.info(log) # Upload module configuration to module elif not MPQ_CMD4.empty(): while not MPQ_CMD4.empty(): data_cmd4_in = MPQ_CMD4.get() uid_mod = data_cmd4_in[0] addr_ln = data_cmd4_in[1] addr_mod = data_cmd4_in[2] addr_mem = data_cmd4_in[3] data_iface_in = data_cmd4_in[4] log = 'Lane {0} module '.format(addr_ln) +\ '{0} priority 4 interface request received.'.format(addr_mod) logger.debug(log) stat_mod = STAT_LVL['op'] # Set four-port interface lane. This function ignores # single-port interface devices. stat_iface = obj_iface.i2c_lane_set(addr_ln=addr_ln) if not stat_iface: stat_iface = obj_iface.i2c_write( addr_ln=addr_ln, addr_mod=addr_mod, addr_mem=addr_mem, data_iface_in=data_iface_in ) if stat_iface: stat_mod = STAT_LVL['crit'] stat_cmd = STAT_LVL['op_err'] log = 'Upload of module settings to lane {0} '.format(addr_ln) +\ 'module {0} unsuccessful.'.format(addr_mod) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'CRITICAL', log ]) else: log = 'Upload of module settings to lane {0} '.format(addr_ln) +\ 'module {0} successful.'.format(addr_mod) MPQ_ACT.put_nowait([ datetime.now().isoformat(' '), 'INFO', log ]) logger.log( logging.INFO if not stat_iface else logging.CRITICAL, log ) print(log) MPQ_STAT.put_nowait([ 'module', [ uid_mod, addr_ln, addr_mod, stat_mod ] ]) else: stat_cmd = STAT_LVL['op_err'] log = 'Could not complete priority 4 interface request on ' + \ 'lane {0}, '.format(addr_ln) +\ 'module {0} due to i2c lane set error.'.format(addr_mod) logger.critical(log) log = 'Lane {0} module '.format(addr_ln) +\ '{0} priority 4 interface request concluded.'.format(addr_mod) logger.info(log) # Recurring module sensor polling # # While this command algorithm is essentially identical # to MPQ_CMD2 algorithm, it remains separate so that any # user-initiated polling request upon an individual # module will receive a much higher priority so that # execution takes place more quickly. elif not MPQ_CMD5.empty(): time_a = time.time() data_cmd5_in = MPQ_CMD5.get() uid_mod = data_cmd5_in[0] addr_ln = data_cmd5_in[1] addr_mod = data_cmd5_in[2] log = 'Lane {0} module {1} '.format(addr_ln, addr_mod) +\ 'priority 5 interface request received.' logger.info(log) # Set four-port interface lane. This function ignores # single-port interface devices. stat_iface = obj_iface.i2c_lane_set(addr_ln=addr_ln) if not stat_iface: time_b = time.time() stat_poll_data, uid_mod_i2c = poll.get_data( obj_iface=obj_iface, uid_mod=uid_mod, addr_ln=addr_ln, addr_mod=addr_mod ) print('Lane {0} module {1} priority 5 get_data time: {2}'. format(addr_ln, addr_mod, round((time.time() - time_b), 3))) # Check for any interrupts on all lanes before polling again if not stat_poll_data: MPQ_STAT.put_nowait([ 'base', [ 'poll_data', STAT_LVL['op'] ] ]) stat_iface, flag = obj_iface.interrupt_check_flag() if flag: MPQ_CMD1.put(True) # USB reset interface board if bad data returned # # TODO: Need higher level tracking of this error # TODO: Do not wish to reset device more than once # TODO: If reset after first time fails, all # TODO: related commands will be bypassed elif (stat_poll_data == STAT_LVL['op_err']) and \ (uid_mod_i2c != uid_mod): obj_iface.setup() obj_iface.interrupts_enable() stat_cmd = STAT_LVL['op_err'] log = 'Resetting interface due to mismatch in module id: ' + \ 'requested={0} vs polled={1}.'.format(uid_mod, uid_mod_i2c) logger.warning(log) MPQ_POLL_COMPLETE.put_nowait([ addr_ln, addr_mod ]) else: stat_cmd = STAT_LVL['op_err'] log = 'Could not complete priority 5 interface request on lane ' + \ '{0} module {1} '.format(addr_ln, addr_mod) +\ 'due to i2c lane set error.' logger.critical(log) log = 'Lane {0} module {1} '.format(addr_ln, addr_mod) +\ 'priority 5 interface request concluded.' logger.info(log) print('Lane {0} module {1} priority 5 time: {2}'. format(addr_ln, addr_mod, round((time.time() - time_a), 3))) time.sleep(0.05) # If command listener status has changed, send heartbeat update if stat_cmd != stat_cmd_prev: stat_cmd_prev = stat_cmd MPQ_STAT.put_nowait([ 'base', [ 'command_listener', stat_cmd ] ])
def setUp(self) -> None: self.empire = empire.Empire(races.ORCS) self.other_empire = empire.Empire(races.ELVES) Interface(self.empire, self.other_empire) Game(self.empire, self.other_empire)
def play_game(): # pygame initialization start pygame.init() screen = pygame.display.set_mode(configs.SCR_SIZE) pygame.display.set_caption("the Lord of the Strategy") icon_surf = img.get_image().ICON pygame.display.set_icon(icon_surf) clock = pygame.time.Clock() if not pygame.font.get_init(): raise SystemExit("Fonts are out-of-service") # pygame initialization finish # game objects initialization start player_empire = empire.Empire(user_configs.EMPIRE_RACE, name=user_configs.EMPIRE_NAME, start_resources=1000) enemy_empire = empire.Empire(races.DWARFS, name='Durden', start_resources=1000) game = Game(player_empire, enemy_empire) interface = Interface(player_empire, enemy_empire) player_empire.set_city("Nevborn") player_default_city = player_empire.get_city("Nevborn") player_default_city.rect.x = 500 player_default_city.rect.centery = world_map.Map().rect.centery enemy_empire.set_city("Nuhen") enemy_default_city = enemy_empire.get_city("Nuhen") enemy_default_city.rect.right = world_map.Map().rect.right - 700 enemy_default_city.rect.centery = world_map.Map().rect.centery StressAI(enemy_empire) # game objects initialization start rendered = None while True: mouse_pressed = False for event in pygame.event.get(): if event.type == pygame.QUIT or \ event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: pygame.quit() quit() if event.type == pygame.MOUSEBUTTONDOWN: mouse_pressed = True key = pygame.key.get_pressed() mouse_pos = pygame.mouse.get_pos() if mouse_pressed: handled = False # check if any of interface windows can handle click if interface.handle_interface_click(mouse_pos): handled = True else: for obj in game.objects: # check if any of game objects can handle click if obj.handle_click(get_global_mouse_pos(mouse_pos)): handled = True if not handled: interface.handle_empty_click(mouse_pos) # AI is singleton, which has initialized before StressAI().play_step() # If any of empires is out of cities, finish the game if not player_empire.alive() or not enemy_empire.alive(): return interface.move_view(key, mouse_pos) # place objects on map if rendered is not None: game.objects.clear(world_map.Map().image, clear_callback) game.objects.update() rendered = game.objects.draw(world_map.Map().image) interface.draw_interface(screen) # show screen pygame.display.flip() # cap the framerate clock.tick(50)
def setUp(self) -> None: self.empire = empire.Empire(races.ORCS) self.other_empire = empire.Empire(races.ELVES) Interface(self.empire, self.other_empire) Game(self.empire, self.other_empire) self.city = self.empire.set_city(name='test city', cost=50)
#!/usr/bin/env python3 from interface.interface import Interface Interface().run()
def initialize(self, model_definition): # get the model stepsize from the model definition self.modeling_stepsize = model_definition['modeling_stepsize'] # get the model name from the model definition self.name = model_definition['name'] # get the model description from the model definition self.description = model_definition['description'] # get the set weight from the model definition self.weight = model_definition['weight'] # intialize a dictionary holding all model elements self.compliances = {} self.time_varying_elastances = {} self.resistors = {} self.valves = {} self.models = {} # process the elements for component in model_definition['components']: # initialize the compliances if component['type'] == 'compliance': # instantiate a compliance object, initialize it's properties and add the object to the compliances dictionary _class = getattr(compliance, "Compliance") self.compliances[component['name']] = _class(self, **component) # initialize the time_varying_compliances if component['type'] == 'time_varying_elastance': # instantiate a time_varying_elastance object, initialize it's properties and add the object to the time_varying_elastance dictionary _class = getattr(time_varying_elastance, "TimeVaryingElastance") self.time_varying_elastances[component['name']] = _class( self, **component) # initialize the connectors if component['type'] == 'resistor': # instantiate a resistor object, initialize it's properties and add the object to the resistors dictionary _class = getattr(resistor, "Resistor") self.resistors[component['name']] = _class(self, **component) # initialize the valves if component['type'] == 'valve': # instantiate a valve object, initialize it's properties and add the object to the valves dictionary _class = getattr(valve, "Valve") self.valves[component['name']] = _class(self, **component) # process models for model in model_definition['models']: # initialize the ecg model if model['subtype'] == 'ecg': # instantiate a ecg model, initialize it's properties and add the object to the models dictionary _class = getattr(ecg, "Ecg") self.models[model['name']] = _class(self, **model) # initialize the heart model if model['subtype'] == 'heart': # instantiate a heart model, initialize it's properties and add the object to the models dictionary _class = getattr(heart, "Heart") self.models[model['name']] = _class(self, **model) # initialize the lung model if model['subtype'] == 'lungs': # instantiate a lung model, initialize it's properties and add the object to the models dictionary _class = getattr(lungs, "Lungs") self.models[model['name']] = _class(self, **model) # initialize the breathing model if model['subtype'] == 'breathing': # instantiate a breathing model, initialize it's properties and add the object to the models dictionary _class = getattr(breathing, "Breathing") self.models[model['name']] = _class(self, **model) # initialize the ans model if model['subtype'] == 'ans': # instantiate an ans model, initialize it's properties and add the object to the models dictionary _class = getattr(ans, "Ans") self.models[model['name']] = _class(self, **model) # initialize the metabolism model if model['subtype'] == 'metabolism': # instantiate a metabolism model, initialize it's properties and add the object to the models dictionary _class = getattr(metabolism, "Metabolism") self.models[model['name']] = _class(self, **model) # initialize the acidbase model if model['subtype'] == 'acidbase': # instantiate an acidbase model, initialize it's properties and add the object to the models dictionary _class = getattr(acidbase, "Acidbase") self.models[model['name']] = _class(self, **model) # initialize the oxygenation model if model['subtype'] == 'oxygenation': # instantiate an oxygenation model, initialize it's properties and add the object to the models dictionary _class = getattr(oxygenation, "Oxygenation") self.models[model['name']] = _class(self, **model) # initialize the blood model if model['subtype'] == 'blood': # instantiate a blood model, initialize it's properties and add the object to the models dictionary _class = getattr(blood, "Blood") self.models[model['name']] = _class(self, **model) # initialize the gas model if model['subtype'] == 'gas': # instantiate a gas model, initialize it's properties and add the object to the models dictionary _class = getattr(gas, "Gas") self.models[model['name']] = _class(self, **model) # initialize the model interface self.io = Interface(self)
from interface.interface import Interface from files.database import Database if __name__ == "__main__": # TODO: handle command line arguments database = Database() interface = Interface(database) interface.start()