/// <summary> /// Creates the train stops. /// </summary> /// <param name="data">The data.</param> /// <param name="line">The line.</param> /// <returns>The train stops.</returns> private static List <TrainStop> createTrainStops(List <String[]> data, TrainLine line, out Time originalDepartureTime) { List <TrainStop> trainStops = new List <TrainStop>(); TrainStationCache stationCache = TrainStationCache.getInstance(); Int16 orderInLine = 0; String nameStation; Time departure; Time arrival; int kmFromStart; Time timeStart = Time.ToTime(data[0][2]);//Time.MinValue; // set original departure time originalDepartureTime = new Time(timeStart); Time timePrev = Time.MinValue; int kmPrev = 0; // foreach string[] createConstraintSet specific trainStop foreach (String[] str in data) { // if not correct number of stop details, take next stop if (str.Length != NUMBER_OF_STOP_DETAILS) { continue; } // createConstraintSet new stop TrainStop stop = new TrainStop(); // extract information about stop nameStation = str[0]; arrival = Time.ToTime(str[1]); departure = Time.ToTime(str[2]); kmFromStart = Convert.ToInt32(str[3]); // try toStation find out if throughStation already exists, if not, createConstraintSet appropriate throughStation if (!stationCache.doesStationExist(nameStation)) { // calculate new ID for new throughStation int id = stationCache.getCacheContent().Count; stationCache.addTrainStation(new TrainStation(id, nameStation)); // download new throughStation //stationCache = } // find appropriate throughStation TrainStation trainStation = stationCache.getCacheContentOnName(nameStation); // addConstraint linked line_ toStation throughStation trainStation.addTrainLine(line); stop.KmFromPreviousStop = kmFromStart - kmPrev; stop.KmFromStart = kmFromStart; stop.OrderInTrainLine = orderInLine; stop.TrainStation = trainStation; stop.TimeArrival = arrival - timeStart; stop.TimeDeparture = departure - timeStart; // if no arrival time_, count with departure if (arrival.Equals(Time.MinValue)) { stop.TimeFromPreviousStop = stop.TimeDeparture - timePrev; } //if arrival time_, use it else { stop.TimeFromPreviousStop = stop.TimeArrival - timePrev; } // set time_ and km for next stop timePrev = stop.TimeDeparture; kmPrev = stop.KmFromStart; orderInLine++; // addConstraint into final stops trainStops.Add(stop); } return(trainStops); }
/// <summary> /// Adds the connected line. /// </summary> /// <param name="line">The new connected line.</param> public void addConnectedLine(TrainLine line) { connectedTrainLInes.Add(line); }
/// <summary> /// Gets the content on select. /// </summary> /// <param name="trainLine1">The train line1.</param> /// <param name="trainLine2">The train line2.</param> /// <returns></returns> public Constraint getContentOnSelect(TrainLine trainLine1, TrainLine trainLine2) { throw new System.NotImplementedException(); }
/// <summary> /// Adds the train line into cache. /// </summary> /// <param name="line">The train line.</param> public void addTrainLine(TrainLine line) { cacheContent.Add(line); }
public static List <Edge> createEdges(TrainLine line, TrainStation from, TrainStation to) { return(createEdges(line, from.Id, to.Id)); }
public void addLineAtConnection(TrainLine line) { linesOfConnection.Add(line); }