Exemplo n.º 1
0
        private void UpdateData()
        {
            speedPresenter.SetData((int)_currentCar.Navigation.Current_Speed);
            sattelitePresenter.SetData(_currentCar.Data.Navigation.Sattelites);
            if (_currentCar.OBD.Where(p => p.Key == "0C").FirstOrDefault() != null)
            {
                int vol = 0;
                Int32.TryParse(_currentCar.OBD.Where(p => p.Key == "0C").First().Value, out vol);
                engineRPMPresenter.SetData(vol);
            }
            txtDateUpdate.Text = _currentCar.Navigation.DateLastUpdate.ToString("dd.MM.yyyy");
            txtTimeUpdate.Text = _currentCar.Navigation.DateLastUpdate.ToString("HH:mm:ss");

            var converter = new PIDConverter();

            stkOBD.Children.Clear();
            stkOBD.RowDefinitions.Clear();
            txtCar.Text = _currentCar.Mark + " " + _currentCar.Model;
            for (var i = 0; i < _currentCar.OBD.Count; i++)
            {
                stkOBD.RowDefinitions.Add(new RowDefinition());
                var item    = _currentCar.OBD[i];
                var txtText = new TextBlock {
                    TextWrapping = TextWrapping.Wrap, VerticalAlignment = VerticalAlignment.Center, Foreground = new SolidColorBrush(Colors.White),
                    Text         = converter.GetPidInfo(item.Key), Margin = new Thickness(2)
                };
                txtText.SetValue(Grid.RowProperty, i); txtText.SetValue(Grid.ColumnProperty, 0);
                stkOBD.Children.Add(txtText);

                var outBorder = new Border
                {
                    Tag    = item.Value,
                    Uid    = item.Key,
                    Height = 6,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    BorderThickness     = new Thickness(1), Margin = new Thickness(2, 2, 10, 2),
                    BorderBrush         = new SolidColorBrush(Colors.White)
                };
                outBorder.SetValue(Grid.RowProperty, i);
                outBorder.SetValue(Grid.ColumnProperty, 1);
                outBorder.SizeChanged += outBorder_SizeChanged;
                stkOBD.Children.Add(outBorder);
            }
        }
Exemplo n.º 2
0
        private void DisplayOBD(DISP_Car car)
        {
            if (car.OBD == null)
            {
                return;
            }
            stkOBDParams.Children.Clear();
            PIDConverter converter   = new PIDConverter();
            bool         errorfinded = false;

            if (car.OBD.Count() > 0)
            {
                foreach (var item in car.OBD)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append(item.Value);
                    sb.Append(" - ");
                    sb.Append(converter.GetPidInfo(item.Key));
                    int min = converter.GetMinVol(item.Key);
                    int max = converter.GetMaxVol(item.Key);
                    int vol = 0;
                    Int32.TryParse(item.Value, out vol);
                    TextBlock text = new TextBlock();
                    text.Text = sb.ToString();
                    if (vol < min || vol > max)
                    {
                        errorfinded     = true;
                        text.Foreground = new SolidColorBrush(Colors.DarkRed);
                        text.FontWeight = FontWeights.Bold;
                    }
                    stkOBDParams.Children.Add(text);
                }
                if (errorfinded)
                {
                    brdrOBDStatus.Background = new SolidColorBrush(Colors.Orange);
                }
                else
                {
                    brdrOBDStatus.Background = new SolidColorBrush(Colors.White);
                }
            }
        }
        private void BuildVertical(List <string> pids)
        {
            stkHeader.Children.Add(new Border
            {
                Width = 100
            });
            PIDConverter converter = new PIDConverter();

            foreach (var item in pids)
            {
                TextBlock txt = new TextBlock();
                txt.Width             = 80;
                txt.Margin            = new Thickness(5, 0, 5, 0);
                txt.TextWrapping      = TextWrapping.Wrap;
                txt.FontSize          = 10;
                txt.Text              = converter.GetPidInfo(item);
                txt.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                stkHeader.Children.Add(txt);
            }
        }
        private void Instance_OBDLoaded(OBDHistoryDataModel model)
        {
            if (model == null || !CarSelector.SelectedCar.Car.Id.Equals(model.DevID) || !model.Data.Any() ||
                !Date.Equals(model.DT.ToDate))
            {
                return;
            }
            HistoryHandler.Instance.OBDLoaded -= Instance_OBDLoaded;
            var converter = new PIDConverter();

            DispatherThreadRun(delegate
            {
                OBDList.AddRange(model.Data.GroupBy(g => g.Code).Select(n => new MinMidMaxValues
                {
                    Name = converter.GetPidInfo(n.Key),
                    Min  = n.Min(o => o.Vol),
                    Mid  = n.Average(o => o.Vol),
                    Max  = n.Max(o => o.Vol)
                }));
            });
            OnPropertyChanged("OBDList");
        }
Exemplo n.º 5
0
        private void DisplayOBD(DISP_Car car)
        {
            if (car.OBD == null)
            {
                return;
            }
            stkOBDParams.Children.Clear();
            var converter   = new PIDConverter();
            var errorfinded = false;

            if (!car.OBD.Any())
            {
                return;
            }
            foreach (var item in car.OBD)
            {
                var sb = new StringBuilder();
                sb.Append(item.Value);
                sb.Append(" - ");
                sb.Append(converter.GetPidInfo(item.Key));
                var min = converter.GetMinVol(item.Key);
                var max = converter.GetMaxVol(item.Key);
                var vol = 0;
                int.TryParse(item.Value, out vol);
                var text = new TextBlock {
                    Text = sb.ToString()
                };
                if (vol < min || vol > max)
                {
                    errorfinded     = true;
                    text.Foreground = new SolidColorBrush(Colors.DarkRed);
                    text.FontWeight = FontWeights.Bold;
                }
                stkOBDParams.Children.Add(text);
            }
            //brdrOBDStatus.Background = errorfinded ? new SolidColorBrush(Colors.Orange) : new SolidColorBrush(Colors.White);
        }
Exemplo n.º 6
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            PIDConverter converter = new PIDConverter();

            txtName.Text = converter.GetPidInfo(_pid);
            int v = 0;

            Int32.TryParse(_vol, out v);
            txtVol.Text = _vol;
            int max = converter.GetMaxVol(_pid);

            if (max == -1)
            {
                pgrs.Visibility = Visibility.Collapsed;
                return;
            }
            pgrs.Maximum = max;
            int min = converter.GetMinVol(_pid);

            pgrs.Minimum = min;
            pgrs.Value   = v;

            if (_previos.Count() < 20 && max != min)
            {
                double step = 50.0f / (double)(max - min);
                foreach (var item in _previos)
                {
                    int h = 0;
                    Int32.TryParse(item, out h);
                    if (h >= min && h <= max)
                    {
                        double b = (double)(h - min) * step;
                        b = Math.Round(b, 2);
                        b = Math.Abs(b);
                        if (b < 2)
                        {
                            b = 2;
                        }
                        Border b1 = new Border()
                        {
                            Width             = 10,
                            Height            = b,
                            VerticalAlignment = System.Windows.VerticalAlignment.Bottom
                        };
                        Border b2 = new Border()
                        {
                            Background        = new SolidColorBrush(Colors.Blue),
                            VerticalAlignment = System.Windows.VerticalAlignment.Top,
                            Height            = 2
                        };
                        b1.Child = b2;
                        cnvChart.Children.Add(b1);
                    }
                    else
                    {
                        cnvChart.Children.Add(new Border
                        {
                            Width = 10
                        });
                    }
                }
            }
        }