def __init__(self, rootname, name_scenario='myscenario', description='', parent=None, workdirpath=None, **kwargs): self._init_objman(ident='scenario', parent=parent, name='Scenario', info='Main scenario instance.', version=0.2, **kwargs) attrsman = self.set_attrsman(cm.Attrsman(self)) if workdirpath is not None: # create a directory if path is given, but does not exist if not os.path.isdir(workdirpath): os.mkdir(workdirpath) else: workdirpath = os.getcwd() #workdirpath = os.path.expanduser("~") self.name_scenario = attrsman.add(cm.AttrConf('name_scenario', name_scenario, groupnames=['options'], perm='rw', name='Name', info='Scenario name, used for documentation purposes only.', )) self.description = attrsman.add(cm.AttrConf('description', description, groupnames=['options'], perm='rw', name='Description', info='Short, free description of Scenario.', )) self.rootname = attrsman.add(cm.AttrConf('rootname', rootname, groupnames=['options'], perm='r', is_save=True, name='Shortname', info='Short name for scenario. This string is defined when saving the scenario. It is used as rootname for all files produced by this scenario. Please avoid special charracters, whitespace, accents etc. ASCII is recommented in order to remain compatible between operating systems.', )) self.workdirpath = attrsman.add(cm.AttrConf('workdirpath', workdirpath, groupnames=['options'], perm='r', is_save=True, name='Workdir', metatype='dirpath', info='Working directory for this scenario and can be changed when saving the scenario. Please avoid special charracters, whitespace, accents etc. ASCII is recommented in order to remain compatible between operating systems.', )) self.net = attrsman.add(cm.ObjConf(network.Network(self))) self.landuse = attrsman.add(cm.ObjConf(landuse.Landuse(self, self.net))) self.demand = attrsman.add(cm.ObjConf(demand.Demand(self))) # if self.get_version()<0.2: # self.delete('simulation') self._init_attributes()
def _init_attributes(self): attrsman = self.get_attrsman() self.net = attrsman.add(cm.ObjConf(network.Network(self))) self.landuse = attrsman.add(cm.ObjConf(landuse.Landuse(self, self.net))) self.demand = attrsman.add(cm.ObjConf(demand.Demand(self)))
# print ' ids_trip',ids_trip ids_routes, ids_trips = self._trips.make_routes(self.ids_vtype, is_generate_ids=is_generate_ids, routes=self.routes, ids_trip=ids_trip, **self._get_kwargs()) return ids_routes, ids_trips if __name__ == '__main__': ########################################################################## # print 'sys.path',sys.path from agilepy.lib_wx.objpanel import objbrowser from agilepy.lib_base.logger import Logger #from coremodules.scenario import scenario from coremodules.network import network logger = Logger() NETPATH = os.path.join(SUMOPYDIR, 'coremodules', 'network', 'testnet') net = network.Network(logger=logger) rootname = 'facsp2' net.import_xml(rootname, NETPATH) # net.read_sumonodes(os.path.join(NETPATH,'facsp2.nod.xml')) # net.read_sumoedges(os.path.join(NETPATH,'facsp2.edg.xml')) demand = Demand(net=net, logger=logger) # demand.set_net(net) # landuse.facilities.import_poly(os.path.join(NETPATH,'facsp2.poly.xml')) #landuse.import_xml(rootname, NETPATH) objbrowser(demand)