def run(self): for c,i in enumerate(self.n_list): self.cortix = Cortix(use_mpi=False) self.net = Network() self.cortix.network = self.net self.plot = Plot(self.shape,modules=self.procs,runtime=self.runtime) self.plot.fps = self.fps self.net.add_module(self.plot) print(c,'iterations') self.balls = i self.balleach = int(self.balls/self.procs) self.mod_list = [] for i in range(self.procs): if i <5: app = BallHandler(self.shape, balls=self.balleach,runtime = self.runtime,bn=[2,2,28,28],color='r') if i>=5: app = BallHandler(self.shape, balls=self.balleach,runtime = self.runtime,bn=[43,-38,83,-22],color='b') self.mod_list.append(app) self.net.add_module(app) for c,i in enumerate(self.mod_list): self.net.connect([i,'plot-send{}'.format(c)],[self.plot,'plot-receive{}'.format(c)]) for j in self.mod_list: if i == j: continue name = '{}{}'.format(i.name,j.name) name2 = '{}{}'.format(j.name,i.name) self.net.connect([i,name], [j,name2]) self.cortix.run() del self.cortix print('finished sim')
def main(): ''' Description of the run file. ''' # Parameters time_step = 0.1 ir_7040 = Cortix(splash=True) ir_7040.network = Network() ir_7040_net = ir_7040.network # DADOS module. dados = Dados() ir_7040_net.module(dados) dados.rs232_filename = 'ir-7040' dados.rs232_request_string = '\r\nP0001 01245689BCDMNVWYZaOdghin 55}' # DataPlot module. data_plot = DataPlot() data_plot.title = 'IR-7040 Data Acquisition' data_plot.dpi = 300 # Network connectivity ir_7040_net.connect( [dados,'rs-232'], [data_plot,'viz-data'] ) rs232_port.connect(plot_port) ir_7040_net.draw() # Run application ir_7040.run()
class Simulation: def __init__(self): self.n_list = [15,] self.procs = 15 self.runtime=30 self.t_step = 0.01 self.r=1 self.mod_list = [] self.shape = geo.Polygon([(0, 0), (0, 100), (100, 100),(100,0)]) self.fps = 60 def run(self): for c,i in enumerate(self.n_list): self.cortix = Cortix(use_mpi=False) self.net = Network() self.cortix.network = self.net self.plot = Plot(self.shape,modules=self.procs,runtime=self.runtime) self.plot.fps = self.fps self.net.add_module(self.plot) print(c,'iterations') self.balls = i self.balleach = int(self.balls/self.procs) self.mod_list = [] for i in range(self.procs): app = BallHandler(self.shape, balls=self.balleach,runtime = self.runtime) app.r=self.r app.t_step = 0.01 self.mod_list.append(app) self.net.add_module(app) for c,i in enumerate(self.mod_list): self.net.connect([i,'plot-send{}'.format(c)],[self.plot,'plot-receive{}'.format(c)]) for j in self.mod_list: if i == j: continue name = '{}{}'.format(i.name,j.name) name2 = '{}{}'.format(j.name,i.name) self.net.connect([i,name], [j,name2]) self.cortix.run() del self.cortix print('finished sim')
def __setup_networks(self): ''' A helper function used by the Application constructor to setup the networks portion of the Application. ''' self.__log.debug('start __setup_networks()') for net_node in self.__config_node.get_all_sub_nodes("network"): net_config_node = ConfigTree(net_node) assert net_config_node.get_node_name() == net_node.get( 'name'), 'check failed' network = Network(net_config_node) self.__networks.append(network) self.__log.debug("appended network %s", net_node.get("name")) self.__log.debug("end __setup_networks()")
def test_cortix_add_module(): # Init the Cortix object c = Cortix() c.network = Network() num_modules = 100 module_list = list() # Add 100 modules to the Cortix object for i in range(num_modules): # Initialize the module m = DummyModule() c.network.add_module(m) # Get ports p1 = m.get_port('test1-{}'.format(i)) p2 = m.get_port('test2-{}'.format(i)) # Make sure we have the correct modules assert len(c.network.modules) == num_modules for mod in c.network.modules: assert isinstance(mod, Module) assert len(mod.ports) == 2