Пример #1
0
    def generate(self):
        sm = RailStationManager()
        activate(sm, sm.check(), 0.0)
        rows = self.rows
        compactness = self.compactness
        while True:
            cars = []
            for kk in (0, 1):
                r = Railcar('railcar', interval)
                cars.append(r)
                r.x = self.rail_x
                r.position = self.rail_position[kk]
                r.destination = self.rail_destination[kk]
                r.station_manager = sm
                for ii in range(0, len(Railcar.doors)):
                    for jj in range(0, rows):
                        door = self.rail_destination[kk] + Railcar.length/2 - Railcar.doors[ii]
                        yy = door - (jj - (rows - 1) / 2) * (Person.average_radius * 2.0 * compactness)
                        self.person(r, yy, self.rail_waypoints[kk][ii])
                activate(r, r.execute(), 0.0)

            yield hold, self, 100
            self.cancel(cars[0])
            self.cancel(cars[1])
            yield hold, self, self.headway - 100
Пример #2
0
            yield hold, self, 7


if __name__ == "__main__":
    initialize()

    rail_draw(30.0, 0.0)

    # PRT segments
    psm1 = PRTStationManager(3)
    activate(psm1, psm1.check(), 0.0)
    psm2 = PRTStationManager(3)
    activate(psm2, psm2.check(), 0.0)

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

    pg = PersonGenerator(psm1, psm2, rsm)
    activate(pg, pg.generate(), 0.0)

    s1 = Straight((70.0, -30.0), (70.0, 5.0))
    s1.next, last_left, last_right, length = station((70.0, 5.0), PRT.max_speed, "right", 3, psm1)
    last_left.next = last_right.next = s2 = Straight((70.0, 5.0 + length), (70.0, 125.0))
    psm1.mainline = last_left
    s2.next, last_left, last_right, length = station((70.0, 125.0), PRT.max_speed, "right", 3, psm2)
    last_left.next = last_right.next = s7 = Straight((70.0, 125.0 + length), (70.0, 10000.0))
    psm2.mainline = last_left
    prt_draw(s1, 70.0, -31.0)
    pg.destination1 = vec3(s1.next.destinations[0].x + 2.2, s1.next.destinations[0].y)
Пример #3
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)