Examples of Timetable


Examples of trams.data.Timetable

                    String[] validFromDates = timetableElement.getAttribute("validFrom").split("-");
                    Calendar validFrom = new GregorianCalendar(Integer.parseInt(validFromDates[0]), Integer.parseInt(validFromDates[1])-1, Integer.parseInt(validFromDates[2]));
                    String[] validToDates = timetableElement.getAttribute("validTo").split("-");
                    Calendar validTo = new GregorianCalendar(Integer.parseInt(validToDates[0]), Integer.parseInt(validToDates[1])-1, Integer.parseInt(validToDates[2]));
                    //Create timetable object.
                    Timetable myTimetable = new Timetable(timetableElement.getAttribute("name"), validFrom, validTo);
                    //Now add all service patterns.
                    NodeList serviceNodes = timetableElement.getElementsByTagName("servicePattern");
                    for ( int k = 0; k < serviceNodes.getLength(); k++ ) {
                        Element serviceElement = (Element) serviceNodes.item(k);
                        //Get service information.
                        String daysOfOperation = serviceElement.getAttribute("days");
                        String[] timeFrom = serviceElement.getAttribute("startTime").split(":");
                        Calendar startTime = new GregorianCalendar(2009,Calendar.AUGUST,5,Integer.parseInt(timeFrom[0]),Integer.parseInt(timeFrom[1]));
                        String[] timeTo = serviceElement.getAttribute("endTime").split(":");
                        Calendar endTime = new GregorianCalendar(2009,Calendar.AUGUST,5,Integer.parseInt(timeTo[0]),Integer.parseInt(timeTo[1]));
                        //Create service object.
                        ServicePattern myService = new ServicePattern(serviceElement.getAttribute("name"), daysOfOperation, serviceElement.getAttribute("returnTerminus"), serviceElement.getAttribute("outgoingTerminus"), startTime, endTime, Integer.parseInt(serviceElement.getAttribute("frequency")), Integer.parseInt(serviceElement.getAttribute("duration")));
                        //Add to timetable.
                        myTimetable.addServicePattern(serviceElement.getAttribute("name"), myService);
                    }
                    //Finally add this timetable to the route.
                    logger.debug("Adding " + myTimetable.getName() + " to " + route.getRouteNumber());
                    route.addTimetable(timetableElement.getAttribute("name"), myTimetable);
                }
                //Generate timetables.
                List<Service> outgoingServices = route.generateServiceTimetables(getSimulator().getCurrentSimTime(), myScenario, Route.OUTWARDSTOPS);
                List<Service> returnServices = route.generateServiceTimetables(getSimulator().getCurrentSimTime(), myScenario, Route.RETURNSTOPS);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.