예제 #1
0
 def patternTimeTable(self, series, direction):
     table = markup.HTMLTable('timetable_%d' % direction, ['Station', 'A', 'V', 'meting', '#', 'delta', 'A', 'V'])
     indexes = range(len(series.points))
     if direction == Direction.down: indexes.reverse()
     for index in indexes:
         point = series.points[index]
         station = point.station
         planArrival, planDeparture = point.times_in_direction(direction)
         row = table.add_row()
         row.add_to_cell(0, station.name)
         row.add_to_cell(1, string_from_minutes(planArrival))
         row.add_to_cell(2, string_from_minutes(planDeparture))
         stationDict = self.results[direction].get(station.id, None)
         if stationDict == None:
             departure, count = ('-', '-')
             delta = 0
         else:
             departure, count = mostCommonItem(stationDict['v'])
             delta = departure - planDeparture
             departure = string_from_minutes(departure)
         row.add_to_cell(3, departure)
         row.add_to_cell(4, count)
         row.add_to_cell(5, delta)
         row.add_to_cell(6, markup.input('text', 'arr_%d_%d' % (direction, index), string_from_minutes(planArrival + delta), size=4))
         row.add_to_cell(7, markup.input('text', 'dep_%d_%d' % (direction, index), string_from_minutes(planDeparture + delta), size=4))
     return table
예제 #2
0
    def get(self):
        document = ConsoleDocument('Treinenaapje Console')
        nrOfStations = len(TSStation.all_ids())
        nrOfSeries = len(TASeries.all_ids())

        if nrOfStations == 0:
            document.add_paragraph('Er zijn geen stations beschikbaar.')

        elif nrOfSeries == 0:
            document.add_paragraph('Er zijn geen series beschikbaar.')
            form = markup.form('/TASeries', 'post')
            form.add(markup.input('hidden', 'inst', 'fetch'))
            form.add(markup.input('submit', value='Series laden'))
            document.main.add(form)

        else:
            document.add_paragraph('Er zijn %d stations en %d series' % (nrOfStations, nrOfSeries))

        table = document.add_table('statistics_table', ['naam', 'aantal'])
        row = table.add_row()
        row.add_to_cell(0, 'stations')
        row.add_to_cell(1, nrOfStations)
        row = table.add_row()
        row.add_to_cell(0, 'series')
        row.add_to_cell(1, nrOfSeries)
        for key, value in counter_dict().items():
            row = table.add_row()
            row.add_to_cell(0, key)
            row.add_to_cell(1, str(value))

        self.response.out.write(document.write())
예제 #3
0
 def get(self):
     series =TASeries.get(self.request.get('series'))
     self.results = [{}, {}]
     self.analyzeStops()
     
     self.doc = ToolsDocument('Patroontijden voor serie %s' % series.name)
     
     form = markup.form('/tools/repattern', 'post')
     form.add(markup.input('hidden', 'series', self.request.get('series')))
     form.add(markup.heading(2, 'Heenrichting'))
     form.add(self.patternTimeTable(series, Direction.up))
     form.add(markup.heading(2, 'Terugrichting'))
     form.add(self.patternTimeTable(series, Direction.down))
     form.add(markup.input('submit', value='pas aan'))
     
     self.doc.main.add(form)
     self.response.out.write(self.doc.write())
예제 #4
0
    def get(self):
        station = TSStation.get(self.request.get('station'))
        document = ConsoleDocument(station.name)
        table = document.add_table('departures_table', ['s', 'V', 'dV', 'treinnr.', 'bestemming', 'perron'])
        for the_stop in station.agent.sorted_stops:
            row = table.add_row()
            row.add_to_cell(0, the_stop.status)
            row.add_to_cell(1, the_stop.departure_string)
            row.add_to_cell(2, delay_string(the_stop.delay_dep))
            mission_code = the_stop.mission_id.split('.')[1]
            row.add_link_to_cell(3, '/console/schedule?mission=%s' % the_stop.mission_id, mission_code)
            row.add_to_cell(4, the_stop.destination)
            if the_stop.platformChange:
                row.add_to_cell(5, '%s <<' % the_stop.platform)
            else:
                row.add_to_cell(5, the_stop.platform)

        form = markup.form('/agent/station/%s' % station.id_, 'post')
        form.add(markup.input('hidden', 'inst', 'console'))
        form.add(markup.input('hidden', 'redirect', '/console/departures?station=%s' % station.id_))
        form.add(markup.input('submit', value='Verversen'))
        document.main.add(form)

        self.response.out.write(document.write())
예제 #5
0
 def proposeChanges(self):
     table = markup.HTMLTable('submit_table', ['', 'Offset', 'Afronden'])
     form = markup.form('/tools/reoffset', 'post')
     form.add(markup.input('hidden', 'series', self.request.get('series')))
     form.add(table)
     self.doc.main.add(form)
     
     row = table.add_row()
     row.add_to_cell(0,'heen')
     row.add_to_cell(1, markup.input('text', 'offset_up', str(self.foundOffset[Direction.up]), size=6))
     row.add_to_cell(2, markup.input('text', 'round_up', '3', size=6))
     
     row = table.add_row()
     row.add_to_cell(0,'terug')
     row.add_to_cell(1, markup.input('text', 'offset_down', str(self.foundOffset[Direction.down]), size=6))
     row.add_to_cell(2, markup.input('text', 'round_down', '3', size=6))
     
     row = table.add_row()
     row.add_to_cell(0, markup.input('submit', value='pas aan'))
예제 #6
0
    def get(self):
        kind = self.request.get('kind')
        if not self.series:
            self.response.out.write('Serie niet gevonden')
            return

        if kind == 'active':
            document = ConsoleDocument('Serie %s' % self.series.name)
            document.main.add(markup.heading(2, 'Heenrichting'))
            document.main.add(self.overviewTable(self.series.current_up_missions))
            document.main.add(markup.heading(2, 'Terugrichting'))
            document.main.add(self.overviewTable(self.series.current_down_missions))
            self.response.out.write(document.write())

        if kind == 'all':
            document = ConsoleDocument('Serie %s' % self.series.name)
            document.main.add(markup.heading(2, 'Heenrichting'))
            document.main.add(self.overviewTable(self.series.up_missions))
            document.main.add(markup.heading(2, 'Terugrichting'))
            document.main.add(self.overviewTable(self.series.down_missions))
            self.response.out.write(document.write())

        elif kind == 'pattern':
            direction = self.request.get('direction')
            up = direction != 'down'
            if up:
                label = 'heen'
                reverse = 'down'
                reverse_label = 'toon terugrichting'
                origin = self.series.first_point.stationName
                destination = self.series.last_point.stationName
                missions = self.series.up_missions
            else:
                label = 'terug'
                reverse = 'up'
                reverse_label = 'toon heenrichting'
                origin = self.series.last_point.stationName
                destination = self.series.first_point.stationName
                missions = self.series.down_missions

            document = ConsoleDocument('Serie %s (%s)' % (self.series.name, label))
            changes = self.request.get('changes')
            if changes: document.add_paragraph('%s missies zijn aangepast.' % changes)
            document.add_paragraph('%d treinen in serie %s %s - %s' % (self.series.nr_of_missions, self.series.name, origin, destination))
            document.add_reference('/console/missions?kind=pattern&series=%s&direction=%s' % (self.series.id, reverse),reverse_label)

            url = '/TASeries/%s' % self.series.id
            form1 = markup.form(url, 'post')
            form1.add(markup.input('hidden', 'inst', 'optimize_odids'))
            form1.add(markup.input('submit', value='Optimaliseer waarden'))
            document.main.add(form1)

            form2 = markup.form('/forms/series', 'post')
            form2.add(markup.input('hidden', 'series', self.series.id))
            form2.add(markup.input('hidden', 'direction', self.request.get('direction')))
            table = markup.HTMLTable('missions_table', ['Trein', 'Offset', 'Bediende traject'])
            form2.add(table)
            form2.add(markup.input('submit', value='Wijzigen'))
            document.main.add(form2)
            for mission in missions:
                row = table.add_row()
                row.add_to_cell(0, mission.number)
                row.add_to_cell(1, markup.input('text', 'offset_%d' % mission.number, mission.offset_string, size=6))
                name = 'odids_%d' % mission.number
                array = []
                for key, value in mission.odIDs_dictionary.iteritems():
                    array.append((key, value))
                array.sort()
                odids = []
                for key, value in array:
                    odids.append('%s: %s-%s' % (dayString(key), value[0], value[1]))
                row.add_to_cell(2, markup.input('text', name, ', '.join(odids), size=75))
            self.response.out.write(document.write())
예제 #7
0
    def get(self):

        if self.series is None:
            nrOfSeries = len(TASeries.all_ids())
            seriesPerPage = 20
            currentPage = int(self.request.get('page', '1'))
            lastPage = int(math.ceil(float(nrOfSeries) / seriesPerPage))

            document = ConsoleDocument('Treinseries')
            if nrOfSeries == 0:
                document.add_paragraph('Er zijn geen treinseries beschikbaar')
                document.add_reference('/TASeries?inst=fetch', 'Klik om treinseries op te halen')
            else:
                document.add_paragraph('%d treinseries beschikbaar.' % nrOfSeries)
                table = document.add_table('stations_table', ['serie', 'van', 'naar', 'actief', 'tools'])
                for series in TASeries.paginatedObjects(currentPage, seriesPerPage):
                    row = table.add_row()
                    row.add_link_to_cell(0, '/console/series?id=%s' % series.id, series.name)
                    row.add_to_cell(1, series.origin)
                    row.add_to_cell(2, series.destination)
                    number = series.nr_of_missions
                    if number > 0:
                        cell_text = '%d treinen' % number
                    else:
                        cell_text = '-'
                    row.add_link_to_cell(3, '/console/missions?kind=active&series=%s' % series.id, cell_text)
                    row.add_link_to_cell(4, '/console/missions?kind=pattern&series=%s&direction=up' % series.id, 'H')
                    row.add_to_cell(4, '|')
                    row.add_link_to_cell(4, '/console/missions?kind=pattern&series=%s&direction=down' % series.id, 'T')
                    row.add_to_cell(4, '|')
                    row.add_link_to_cell(4, '/tools/reoffset?series=%s' % series.id, 'O')
                    row.add_to_cell(4, '|')
                    row.add_link_to_cell(4, '/TASeries/%s?format=xml' % series.id, 'X')
                document.add_page_navigator(currentPage, lastPage, '/console/series?page=%d')
            self.response.out.write(document.write())

        else:
            document = ConsoleDocument('Serie %s' % self.series.name)
            url = '/TASeries/%s' % self.series.id
            form = markup.form(url, 'post')
            form.add(markup.input('hidden', 'inst', 'fetch'))
            form.add(markup.input('submit', value='Serie opnieuw laden'))
            document.main.add(form)

            if self.series.points:
                form = markup.form('/some_url', 'post')
                form.add(markup.input('hidden', 'series', self.series.id))
                form.add(markup.input('text', 'van', self.series.first_point.station_code, size=4))
                form.add(markup.input('text', 'naar', self.series.last_point.station_code, size=4))
                form.add(markup.input('submit', value='Tijden checken'))
                document.main.add(form)

            table = document.add_table('up_timetable', ['km', 'station', 'A', 'V', 'perron', 'tools'])
            for point in self.series.points:
                row = table.add_row()
                row.add_to_cell(0, '%.1f' % point.km)
                row.add_to_cell(1, self.series.name_for_point(point))
                if point.upArrival != point.upDeparture:
                    row.add_to_cell(2, string_from_minutes(point.upArrival))
                row.add_to_cell(3, string_from_minutes(point.upDeparture))
                row.add_to_cell(4, point.platform_string(Direction.up))

                form = markup.form(url, 'post')
                form.add(markup.input('hidden', 'inst', 'delete_point'))
                form.add(markup.input('hidden', 'sender', point.station_id))
                form.add(markup.input('submit', value='Verwijder'))
                row.add_to_cell(5, form)

            table = document.add_table('down_timetable', ['km', 'station', 'A', 'V', 'perron'])
            for point in reversed(self.series.points):
                row = table.add_row()
                row.add_to_cell(0, '%.1f' % point.km)
                row.add_to_cell(1, point.stationName)
                if point.downArrival != point.downDeparture:
                    row.add_to_cell(2, string_from_minutes(point.downArrival))
                row.add_to_cell(3, string_from_minutes(point.downDeparture))
                row.add_to_cell(4, point.platform_string(Direction.down))

            self.response.out.write(document.write())