public Station() { Id = ++idCnt; random = new Random(); Humen = new MvxObservableCollection <Human>(); Buses = new MvxObservableCollection <Bus>(); Roads = new MvxObservableCollection <Road>(); datas = new List <Data>(); lastLogetTime = ShellViewModel.FullTime; Stations.Add(this); }
//public static Timer operator --(Timer t) //{ // var res = new Timer(); // res.min = t.min - 1; // res.hour = t.hour; // if (res.min < 0) // { // res.min = 0; // res.hour++; // if (res.hour > 24) // { // res.hour = 0; // } // } // return res; //} public static SimulationTimer operator -(SimulationTimer a, SimulationTimer b) { var res = new SimulationTimer(); res.hour = a.Hour - b.Hour; if (a.min < b.min) { res.hour--; res.min = a.min - b.min + 60; } else { res.min = a.min - b.min; } return(res); }
public static SimulationTimer operator ++(SimulationTimer t) { var res = new SimulationTimer(); res.min = t.min + 1; res.hour = t.hour; if (res.min > 59) { res.min = 0; res.hour++; if (res.hour > 23) { res.hour = 0; } } return(res); }
private void LogData(int hour) { if (lastLogetTime.Hour == hour) { return; } Datas.Add(new Data()); lastLogetTime = ShellViewModel.FullTime; var dataIndex = datas.Count - 1; datas[dataIndex].HumanCount = Humen.Count; int avr = 0; foreach (var human in Humen) { avr += human.WaitingTime; } avr = datas[dataIndex].HumanCount > 0 ? avr / Datas[dataIndex].HumanCount : avr; datas[dataIndex].AverageHumanWaitingTime = avr; }