Example #1
0
 def __init__(self, dsn):
     self.trunk = Trunk(dsn)
Example #2
0
    ################################################################################
    #Make trunk segments that will connect the nodes
    ################################################################################
    #a list of specific attachment points overrides the number of nodes argument
    if(config['attach_points']):
        config['nodes'] = len(config['attach_points'])
   
    #this object figures out how many cable segments are needed and what length each segment
    #should be.
    #trunk object figures out a list of attach_points after this object is instantiated
    trunk=Trunk( length=config['length']
            , nodes=config['nodes']
            , start_pad=config['start_pad']
            , end_pad=config['end_pad']
            , separation_min=config['separation_min']
            , start_attach=config['start_attach']
            , end_attach=config['end_attach']
            , random_attach=config['random_attach']
            , attach_error=config['attach_error']
            , attach_points=config['attach_points']
            , max_seg_length=(1/config['segments_per_meter'])
            )

    #feed back precise attach points into json data structure
    config['attach_points'] = trunk.attach_points

    #Prepare a data structure to hold cable models and trunk segment parameters
    #actual number of cables segments is between nnodes-1 and nnodes+1
    #add an extra cable segment if attach_point[0] != 0
    #add an extra cable segment if attach_point[-1] != config['length']
    #always declare space for segment[0] and segment[nodes+1] 
    #expect that segment[0] and segment[nodes+1] will be ignored later if they are not needed
Example #3
0
 def setUp(self):
     dsn = os.environ.get("DATABASE_URL")
     self.listener = Trunk(dsn or "postgres://localhost/trunk")
     self.notifier = Trunk(dsn or "postgres://localhost/trunk")