private void AddFleetDemoHistory() { var c = 0; foreach (var transportTruck in _fleet) { var journeys = DemoFleetDataFactory.ReadNextJourneyHistory(c++); foreach (var journey in journeys) { transportTruck.Departure( journey.DepartureLocation, 0, journey.WeatherCode, WeatherServiceFacade.IsGoodWeather(journey.WeatherCode), journey.DepartureTime); transportTruck.Arrival( journey.ArrivalLocation, journey.FatigueScore, journey.WeatherCode, WeatherServiceFacade.IsGoodWeather(journey.WeatherCode), journey.ArrivalTime, journey.Accident, journey.Delay ); } } }
public WeatherInformation Read() { var weatherServiceFacade = new WeatherServiceFacade(); var weatherInformation = new WeatherInformation { StormInformation = weatherServiceFacade.GetStormInformation( Locations.Brasilia, ForecastPeriodDays), TemperatureCelsius = weatherServiceFacade.GetAirTemperaturCelsius( Locations.Brasilia) }; return(weatherInformation); }
public void GenerateDemoDataFile() { var data = new List <List <DemoHistory> >(); for (var i = 0; i < FleetSize; i++) { var elemData = new List <DemoHistory>(); var eventsNum = _random.Next(MinHistoryNum, MaxHistoryNum); var startNode = _map.Data[_random.Next(0, _map.Data.Count)]; var arrivalNode = GetNextHopRandomly(startNode); var startTime = DateTime.UtcNow; for (var e = 0; e < eventsNum; e++) { var startLocation = startNode.State; var arrivalLocation = arrivalNode.State; var arrTime = GetJourneyDurationByPathCost(startTime, PathCost(startLocation, arrivalLocation), out var delay); elemData.Add(new DemoHistory { DepartureLocation = startLocation.Name, ArrivalLocation = arrivalLocation.Name, Accident = false, // Manually set WeatherCode = WeatherServiceFacade.Forecast(), FatigueScore = FatigueMeasurementFacade.Measure(elemData), Delay = delay, DepartureTime = startTime, ArrivalTime = arrTime }); startNode = arrivalNode; arrivalNode = GetNextHopRandomly(startNode); // Add rest time before next journey startTime += arrTime - startTime + GetRealisticRestTime(); } data.Add(elemData); } var jsonData = JsonConvert.SerializeObject(data, Formatting.Indented); File.WriteAllText($"../../../demo_history{DateTime.Now.Ticks:x8}.json", jsonData); }