public static bool IsParking(CarStateModel curr, ref CarStateModel prev) { if (curr == prev || prev == null) { return(false); } var interval = EqualInterval(curr, prev); //Location prevloc = new Location //{ // Latitude = prev.Lt / 10000.0, // Longitude = prev.Ln / 10000.0 //}, curloc = new Location //{ // Latitude = curr.Lt / 10000.0, // Longitude = curr.Ln / 10000.0 //}; if (curr.Spd >= 6) { prev = null; } if (interval) { return(true); } if (curr.Spd < 6 && prev == null) { prev = curr; } return(false); }
private void DisplayParams(CarStateModel model) { if (model == null) { return; } DateTime dt = new DateTime(model.yy, model.Mnth, model.dd, model.hh, model.mm, model.ss); txtDate.Text = dt.ToString("dd.MM.yy hh:mm:ss"); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value.GetType() != typeof(CarStateModel)) { return(""); } CarStateModel data = (CarStateModel)value; DateTime dt = new DateTime(data.yy, data.Mnth, data.dd, data.hh, data.mm, data.ss); return(dt.ToString("dd.MM.yy hh:mm:ss")); }
public PackageViewModel(CarStateModel model) { if (Sensors == null) { Sensors = new ObservableCollection <UserControl>(); } StrDate = string.Format("{0:00}.{1:00}.{2:00} {3:00}:{4:00}:{5:00}", model.dd, model.Mnth, model.yy, model.hh, model.mm, model.ss); Speed = model.Spd / 10.0; CntSatelete = model.St; GSM_Level = model.GSM; }
public PackageViewModel(CarStateModel model, LinesDataModel.LineRow row, List <DevicePresenter.Sensor> sensors) { if (Sensors == null) { Sensors = new ObservableCollection <UserControl>(); } StrDate = string.Format("{0:00}.{1:00}.{2:00} {3:00}:{4:00}:{5:00}", model.dd, model.Mnth, model.yy, model.hh, model.mm, model.ss); Speed = model.Spd / 10.0; CntSatelete = model.St; GSM_Level = model.GSM; FillSensors(row, sensors); }
//public double Calculate(CarStateModel first, CarStateModel item) //{ // double lat1 = first.Lt/10000.0, lat2 = item.Lt/10000.0, lon1 = first.Ln/10000.0, lon2 = item.Ln/10000.0; // double R = 6371; // double dLat = ToRad(lat2 - lat1); // double dLon = ToRad(lon2 - lon1); // double latR1 = ToRad(lat1); // double latR2 = ToRad(lat2); // double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) + Math.Sin(dLon / 2) * Math.Sin(dLon / 2) * Math.Cos(latR1) * Math.Cos(latR2); // double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); // return R * c; //} public double Calculate(CarStateModel first, CarStateModel item) { double deltaLatitude = first.Lt / 10000.0 - item.Lt / 10000.0; double deltaLongitude = first.Ln / 10000.0 - item.Ln / 10000.0; double kmLat = Math.Round(deltaLatitude * 111.1111, 1); double kmLon = Math.Round(deltaLongitude * 111.1111 * GetCos((int)item.Ln), 1); //km x and lm y //Find distance: double dist = Math.Sqrt(kmLat * kmLat + kmLon * kmLon); return(dist); }
private void DisplayData() { lstData.ItemsSource = null; if (_track == null) { return; } if (_data == null) { return; } if (_car == null) { return; } if (_track.Count() < 1) { return; } List <PackageViewModel> pvm = new List <PackageViewModel>(); foreach (var item in _data.Rows) { CarStateModel csm = new CarStateModel(); List <CarStateModel> temp = _track.Where(p => p.hh == item.DT.hh).ToList(); if (temp.Count() == 1) { csm = temp[0]; } else if (temp.Count() > 1) { temp = _track.Where(p => p.hh == item.DT.hh && p.mm == item.DT.mm).ToList(); if (temp.Count() == 1) { csm = temp[0]; } else if (temp.Count() > 1) { temp = _track.Where(p => p.hh == item.DT.hh && p.mm == item.DT.mm && p.ss == item.DT.ss).ToList(); if (temp.Count() > 0) { csm = temp[0]; } } } PackageViewModel pm = new PackageViewModel(csm, item, _car.Device.Sensors); pvm.Add(pm); } lstData.ItemsSource = pvm; }
public static bool EqualInterval(DateTime dt, CarStateModel car, int minutes = 10) { if (car == null) { return(false); } var times = GetTime(car); if (times > dt) { return(times - dt >= new TimeSpan(0, minutes, 0)); } return(dt - times >= new TimeSpan(0, minutes, 0)); }
public static bool EqualInterval(CarStateModel curr, CarStateModel prev, int minutes = 10) { if (curr == null || prev == null) { return(false); } var dt = GetTime(curr); var times = GetTime(prev); if (times > dt) { return(times - dt >= new TimeSpan(0, minutes, 0)); } return(dt - times >= new TimeSpan(0, minutes, 0)); }
public HistoryRow(CarStateModel item) { _model = item; }
public static DateTime GetTime(CarStateModel curr) { // Исправить при изменение времени сервера return(new DateTime(curr.yy, curr.Mnth, curr.dd, curr.hh, curr.mm, curr.ss) + (DateTime.Now - DateTime.UtcNow)); }