Beispiel #1
0
def main(mode='straight'):
    the_world = world()
    initialize()

    tk = the_world.tk
    canvas, x_, y_, s_ = tk.canvas, tk.x_, tk.y_, tk.s_

    ###
    ### PRT
    ###
    berths = 6
    psm1 = PRTStationManager(berths)
    psm2 = PRTStationManager(berths)
    activate(psm1, psm1.check(), 0.0)
    activate(psm2, psm2.check(), 0.0)

    s1 = Straight((20., -30.), (20., -5.0))
    s1.next, last_left, last_right, length \
        = station((20.0, -5.0), PRT.max_speed, 'right', berths, psm1)
    last_left.next = last_right.next = s2 \
        = Straight((20., -5. + length), (20., -5. + length + 5.))
    psm1.mainline = last_left
    s2.next, last_left, last_right, length \
        = station((20.0, -5.0 + length + 5), PRT.max_speed, 'right', berths, psm2)
    last_left.next = last_right.next \
        = Straight((20.0, 500.), (20., 10000.))
    psm2.mainline = last_left
    prt_draw(s1, 20.0, -31.0)

    pc = PRTChecker()
    activate(pc, pc.check(s2.members), 0.0)

    p1_ul, p1_lr = prt_platform = s1.next.platform
    prt_platform_center = (p1_ul.y + p1_lr.y) / 2
    psm1.platform = prt_platform
    p2_ul, p2_lr = s2.next.platform

    canvas.create_polygon( ((x_(p1_lr.x), y_(p1_ul.y)), (x_(p1_lr.x + 15), y_(p1_ul.y + 4)),
                            (x_(p1_lr.x + 15), y_(p1_lr.y - 4)), (x_(p1_lr.x), y_(p1_lr.y))),
                           fill='#ccc', outline='#ccc')

    canvas.create_polygon( ((x_(p2_lr.x), y_(p2_ul.y)), (x_(p2_lr.x + 15), y_(p2_ul.y + 4)),
                            (x_(p2_lr.x + 15), y_(p2_lr.y - 4)), (x_(p2_lr.x), y_(p2_lr.y))),
                           fill='#ccc', outline='#ccc')

    tg = PRTGenerator()
    # 75% empty to simulate sending extras to the stadium
    activate(tg, tg.generate(s1, interval, percent_empty=0.75), 0.0)

    ###
    ### Rail
    ###
    rx, ry = 80., 0.

    rsm = RailStationManager()
    activate(rsm, rsm.check(), 0.0)

    rail_stop_center = 100

    rail_draw(rx, ry, rail_stop_center)

    rg = RailcarGenerator(rx, rsm)
    rsm.mode = "stadium"
    activate(rg, rg.generate(), 20.0 + 30)

    rg.waypoint_high = vec3(rx - 4, p1_ul.y + 3)
    rg.waypoint_low = vec3(rx - 4, p1_lr.y - 3)

    canvas.create_polygon( ((x_(rx - 20), y_(rail_stop_center + 20)),
                            (x_(rx - 5), y_(rail_stop_center + Railcar.length)),
                            (x_(rx - 5), y_(rail_stop_center - Railcar.length)),
                            (x_(rx - 20), y_(rail_stop_center - 20))),
                           fill='#ccc', outline='#ccc')
        
    ###
    ### People
    ###
    pg = PersonGenerator(rsm, rx - 20, rail_stop_center - Railcar.length + 2,
                         rail_stop_center + Railcar.length - 2,
                         psm1, p1_lr.x + 15, p1_lr.y - 4, p1_ul.y + 4,
                         psm2, p2_lr.x + 15, p2_lr.y - 4, p2_ul.y + 4)
    activate(pg, pg.generate(), 45.0)

    ###
    ###
    ###
    u = Updater(interval)
    activate(u, u.execute(), 0.0)

    simulate(until=2000)
Beispiel #2
0
def main(mode='straight'):
    the_world = world()
    initialize()

    rx, ry = 35., 0.

    berths = 9
    psm1 = PRTStationManager(berths)
    activate(psm1, psm1.check(), 0.0)

    door_width = 4.0
    stair_width = door_width

    s1 = Straight((20., -30.), (20., 35.0))
    s1.next, last_left, last_right, length = station((20.0, 35.0), PRT.max_speed, 'right', berths, psm1)
    last_left.next = last_right.next = c1 = Straight((20., 35. + length), (20., 10000.))
    #last_left.next = last_right.next = c1 = Curve(0, pi/2, (-10., 35.0 + length), 30.)
    #c1.next = Straight((-10., 35.0 + length + 30.), (-10000., 35.0 + length + 30.))
    psm1.mainline = last_left
    prt_draw(s1, 20.0, -31.0)

    pc = PRTChecker()
    activate(pc, pc.check(c1.members), 0.0)

    pp_ul, pp_lr = prt_platform = s1.next.platform
    prt_platform_center = (pp_ul.y + pp_lr.y) / 2
    psm1.platform = prt_platform

    if mode in ('straight', 'doorway'):
        rail_stop_center = prt_platform_center
    elif mode == 'stair':
        platform_height = 6
        step_height = 0.19
        step_length = 0.28
        steps = platform_height / step_height
        stair_length = steps * step_length
        rail_stop_center = prt_platform_center - stair_length - door_width

    #rail_draw(rx, ry, prt_platform_center_y)
    rail_draw(rx, ry, rail_stop_center)

    rail_headway = 450
    rg = RailcarGenerator(mode, rail_stop_center, door_width, s1.next, rx, rail_headway)
    activate(rg, rg.generate(), 20.0 + 30)

    # prt platform walls, clockwise from top left
    the_world.add_wall( (pp_lr.x, pp_ul.y), (pp_ul.x, pp_ul.y),       # top right and left
                        (pp_ul.x, pp_lr.y), (pp_lr.x, pp_lr.y) )       # bottom left and right

    railside_x = rx - Railcar.width / 2
    r1_top = rg.rail_destination[0] + Railcar.length / 2
    r2_top = rg.rail_destination[1] + Railcar.length / 2
    r1_doors = []
    r2_doors = []
    for door in Railcar.doors:
        r1_doors.append( ((railside_x, r1_top - door + 1), (railside_x, r1_top - door - 1)) )
        r2_doors.append( ((railside_x, r2_top - door + 1), (railside_x, r2_top - door - 1)) )

    railside_x = rx - Railcar.width / 2

    # rail platform walls
    the_world.add_wall( (rx - 5, ry + 155), (railside_x, ry + 155), # top left and right
                        r1_doors[0][0] )                            # first car, top door
    the_world.add_wall( r1_doors[0][1], r1_doors[1][0] )
    the_world.add_wall( r1_doors[1][1], r1_doors[2][0] )
    the_world.add_wall( r1_doors[2][1], r1_doors[3][0] )
    the_world.add_wall( r1_doors[3][1], r2_doors[0][0] )
    the_world.add_wall( r2_doors[0][1], r2_doors[1][0] )
    the_world.add_wall( r2_doors[1][1], r2_doors[2][0] )
    the_world.add_wall( r2_doors[2][1], r2_doors[3][0] )
    the_world.add_wall( r2_doors[3][1],                             # second car, bottom door
                        (railside_x, ry + 45), (rx - 5, ry + 45))   # bottom right and left

    tk = the_world.tk
    canvas, x_, y_, s_ = tk.canvas, tk.x_, tk.y_, tk.s_
    if mode == 'straight':
        the_world.add_wall( (rx - 5, pp_ul.y + 4),                 # prt/rail door top
                            (rx - 5, ry + 155) )                    # top right
        the_world.add_wall( (rx - 5, ry + 45),                      # bottom left
                            (rx - 5, pp_lr.y - 4) )                # prt/rail door bottom

        rg.waypoint_high = vec3(rx - 4, pp_ul.y + 3)
        rg.waypoint_low = vec3(rx - 4, pp_lr.y - 3)

        # between rail and prt platforms
        the_world.add_wall((pp_lr.x, pp_ul.y), (rx - 5, pp_ul.y + 4))
        the_world.add_wall((rx - 5, pp_lr.y - 4), (pp_lr.x, pp_lr.y))

        canvas.create_polygon( ((x_(pp_lr.x), y_(pp_ul.y)), (x_(rx - 5), y_(pp_ul.y + 4)),
                                (x_(rx - 5), y_(pp_lr.y - 4)), (x_(pp_lr.x), y_(pp_lr.y))),
                               fill='#ccc', outline='#ccc')

    elif mode == 'doorway':
        the_world.add_wall( (pp_lr.x, pp_ul.y), (pp_lr.x, prt_platform_center + door_width / 2),
                            (rx - 5, prt_platform_center + door_width / 2),
                            (rx - 5, ry + 155) )
        the_world.add_wall( (rx - 5, ry + 45), (rx - 5, prt_platform_center - door_width / 2),
                            (pp_lr.x, prt_platform_center - door_width / 2),
                            (pp_lr.x, pp_lr.y) )
        rg.waypoint_high = vec3(rx - 4, prt_platform_center + door_width / 3)
        rg.waypoint_low = vec3(rx - 4, prt_platform_center - door_width / 3)
        canvas.create_polygon( ((x_(pp_lr.x), y_(prt_platform_center + door_width / 2)),
                                (x_(rx - 5), y_(prt_platform_center + door_width / 2)),
                                (x_(rx - 5), y_(prt_platform_center - door_width / 2)),
                                (x_(pp_lr.x), y_(prt_platform_center - door_width / 2))),
                               fill='#ccc', outline='#ccc')
    elif mode == 'stair':
        epd = extra_platform_depth = 3
        wall1 = ( (pp_lr.x, pp_ul.y), (pp_lr.x + epd, prt_platform_center + door_width / 2),
                  (pp_lr.x + epd + stair_width, prt_platform_center + door_width / 2),
                  (pp_lr.x + epd + stair_width, prt_platform_center - door_width / 2),
                  (rx - 5, prt_platform_center - door_width / 2 - stair_length), 
                  (rx - 5, ry + 155) )
        wall2 = ( (rx - 5, ry + 45), (rx - 5, prt_platform_center - door_width / 2 - stair_length - door_width),
                  (rx - 5 - door_width, prt_platform_center - door_width / 2 - stair_length - door_width),
                  (rx - 5 - door_width, prt_platform_center - door_width / 2 - stair_length),
                  (pp_lr.x + epd, prt_platform_center - door_width / 2),
                  (pp_lr.x, pp_lr.y) )
        the_world.add_wall( *wall1 )
        the_world.add_wall( *wall2 )
        rg.waypoint_low = vec3(rx - 4, prt_platform_center - stair_length - door_width)
        rg.waypoint_prt_door = vec3(pp_lr.x + door_width / 2, prt_platform_center)
        points = []
        for point in wall1 + wall2:
            points.append(x_(point[0]))
            points.append(y_(point[1]))
        canvas.create_polygon(points, fill='gray')
        
    tg = PRTGenerator()
    # 50% empty to simulate sending extras to the transit station
    activate(tg, tg.generate(s1, interval, percent_empty=0.50), 0.0)

    clock = Clock()
    # "0" time taken from when Railcar called station_manager.doors_open
    activate(clock, clock.execute(), 43.684 + 30)

    u = Updater(interval)
    activate(u, u.execute(), 0.0)

    simulate(until=2000)
Beispiel #3
0
        sys.exit(0)

    side = 'right'
    if len(sys.argv) == 2:
        berths = int(sys.argv[1])
    else:
        berths = 9
    queue_berths = berths
    psm1 = PRTStationManager(berths, queue_berths)
    psm1.launch_statistics = True
    activate(psm1, psm1.check(), 0.0)
    s1 = Straight((30., 10.), (30., 50.))
    s1.next, last_left, last_right, length = station((30.0, 50.0), PRT.max_speed, side, berths, psm1, queue_berths)
    last_left.next = last_right.next = Straight((30., 50. + length), (30., 10000.))
    psm1.mainline = last_left
    prt_draw(s1, 30.0, 0.0)

    tg = PRTGenerator()
    activate(tg, tg.generate(s1, interval, percent_empty=1.0), 0.0)

    pg = PersonGenerator(psm1)
    activate(pg, pg.execute(), 0.0)

    pc = PRTChecker()
    activate(pc, pc.check(last_left.next.members), 0.0)

    u = Updater(interval)
    activate(u, u.execute(), 0.0)
    # extra minute to allow for start when first PRT leaves berth
    simulate(until=sample_time + 60)