Rev 2421 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2421 | Rev 2424 | ||
---|---|---|---|
Line 292... | Line 292... | ||
292 | 292 | ||
293 | string[] sAnalogLabel = new string[32]; |
293 | string[] sAnalogLabel = new string[32]; |
294 | string[] sAnalogData = new string[32]; |
294 | string[] sAnalogData = new string[32]; |
Line 295... | Line 295... | ||
295 | int[] iAnalogData = new int[32]; |
295 | int[] iAnalogData = new int[32]; |
296 | 296 | ||
297 | int[] iTimings = new int[] {100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000 }; |
297 | int[] iTimings = new int[] { 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000 }; |
298 | int[] iMotors = new int[] {3,4,5,6,7,8,9,10,11,12 }; |
298 | int[] iMotors = new int[] { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; |
299 | string[] sLiPoCells = new string[] { "3s", "4s", "5s", "6s" }; |
299 | string[] sLiPoCells = new string[] { "3s", "4s", "5s", "6s" }; |
300 | /// <summary> |
300 | /// <summary> |
301 | /// interval for sending debugdata (multiplied by 10ms) |
301 | /// interval for sending debugdata (multiplied by 10ms) |
Line 337... | Line 337... | ||
337 | DispatcherTimer timer = new DispatcherTimer(); |
337 | DispatcherTimer timer = new DispatcherTimer(); |
Line 338... | Line 338... | ||
338 | 338 | ||
339 | /// <summary> |
339 | /// <summary> |
340 | /// stuff for enabeling touch zoom for the map |
340 | /// stuff for enabeling touch zoom for the map |
341 | /// </summary> |
341 | /// </summary> |
342 | Point pTouch1 = new Point(0,0), pTouch2 = new Point(0,0); |
342 | Point pTouch1 = new Point(0, 0), pTouch2 = new Point(0, 0); |
343 | int iFirstStylusID = -1; |
343 | int iFirstStylusID = -1; |
344 | public string connectButtonText |
344 | public string connectButtonText |
345 | { |
345 | { |
346 | get |
346 | get |
Line 367... | Line 367... | ||
367 | void _initForm() |
367 | void _initForm() |
368 | { |
368 | { |
369 | _readIni(); |
369 | _readIni(); |
370 | if (_bSaveWinStateNormal) |
370 | if (_bSaveWinStateNormal) |
371 | _setScaleSliders(false); |
371 | _setScaleSliders(false); |
372 | cBoxTimingsDebug.ItemsSource = |
372 | cBoxTimingsDebug.ItemsSource = |
373 | cBoxTimingsNav.ItemsSource = |
373 | cBoxTimingsNav.ItemsSource = |
374 | cBoxTimingsBl.ItemsSource = |
374 | cBoxTimingsBl.ItemsSource = |
375 | cBoxTimingsOSD.ItemsSource = |
375 | cBoxTimingsOSD.ItemsSource = |
376 | iTimings; |
376 | iTimings; |
377 | cBoxLiPoCells.ItemsSource = sLiPoCells; |
377 | cBoxLiPoCells.ItemsSource = sLiPoCells; |
378 | cBoxLiPoCells.SelectedItem = _LipoCells.ToString() + "s"; |
378 | cBoxLiPoCells.SelectedItem = _LipoCells.ToString() + "s"; |
379 | _LipoMinMax(); |
379 | _LipoMinMax(); |
380 | sliderThresholdVoltageWarn.Value = _dThresholdVoltageWarn; |
380 | sliderThresholdVoltageWarn.Value = _dThresholdVoltageWarn; |
Line 426... | Line 426... | ||
426 | dtMotors.Columns.Add("Current"); |
426 | dtMotors.Columns.Add("Current"); |
427 | dtMotors.Columns.Add("Temp"); |
427 | dtMotors.Columns.Add("Temp"); |
428 | dgvMotors1.DataContext = dtMotors.DefaultView; |
428 | dgvMotors1.DataContext = dtMotors.DefaultView; |
429 | _initDTMotors(); |
429 | _initDTMotors(); |
Line 430... | Line 430... | ||
430 | 430 | ||
431 | Setter setter = new Setter(ContentControl.PaddingProperty, new Thickness(5,0,5,0)); |
431 | Setter setter = new Setter(ContentControl.PaddingProperty, new Thickness(5, 0, 5, 0)); |
432 | Style style = new Style(typeof(System.Windows.Controls.Primitives.DataGridColumnHeader)); |
432 | Style style = new Style(typeof(System.Windows.Controls.Primitives.DataGridColumnHeader)); |
433 | style.Setters.Add(setter); |
433 | style.Setters.Add(setter); |
434 | setter = new Setter(ContentControl.BackgroundProperty, new SolidColorBrush(Colors.Transparent)); |
434 | setter = new Setter(ContentControl.BackgroundProperty, new SolidColorBrush(Colors.Transparent)); |
435 | style.Setters.Add(setter); |
435 | style.Setters.Add(setter); |
436 | setter = new Setter(ContentControl.ForegroundProperty, new SolidColorBrush(Colors.White)); |
436 | setter = new Setter(ContentControl.ForegroundProperty, new SolidColorBrush(Colors.White)); |
Line 437... | Line 437... | ||
437 | style.Setters.Add(setter); |
437 | style.Setters.Add(setter); |
438 | 438 | ||
439 | dtWaypoints.Columns.Add("Index",typeof(int)); |
439 | dtWaypoints.Columns.Add("Index", typeof(int)); |
440 | dtWaypoints.Columns.Add("Type", typeof(int)); |
440 | dtWaypoints.Columns.Add("Type", typeof(int)); |
441 | dtWaypoints.Columns.Add("Name",typeof(string)); |
441 | dtWaypoints.Columns.Add("Name", typeof(string)); |
442 | dtWaypoints.Columns.Add("Latitude",typeof(double)); |
442 | dtWaypoints.Columns.Add("Latitude", typeof(double)); |
443 | dtWaypoints.Columns.Add("Longitude",typeof(double)); |
443 | dtWaypoints.Columns.Add("Longitude", typeof(double)); |
444 | dtWaypoints.Columns.Add("Altitude",typeof(string)); |
444 | dtWaypoints.Columns.Add("Altitude", typeof(string)); |
445 | dtWaypoints.Columns.Add("Heading",typeof(string)); |
445 | dtWaypoints.Columns.Add("Heading", typeof(string)); |
446 | dtWaypoints.Columns.Add("Speed",typeof(string)); |
446 | dtWaypoints.Columns.Add("Speed", typeof(string)); |
447 | dtWaypoints.Columns.Add("ClimbRate",typeof(string)); |
447 | dtWaypoints.Columns.Add("ClimbRate", typeof(string)); |
448 | dtWaypoints.Columns.Add("Radius",typeof(string)); |
448 | dtWaypoints.Columns.Add("Radius", typeof(string)); |
449 | dtWaypoints.Columns.Add("HoldTime",typeof(string)); |
449 | dtWaypoints.Columns.Add("HoldTime", typeof(string)); |
450 | dtWaypoints.Columns.Add("AutoTrigger",typeof(string)); |
450 | dtWaypoints.Columns.Add("AutoTrigger", typeof(string)); |
451 | dtWaypoints.Columns.Add("CamAngle",typeof(string)); |
451 | dtWaypoints.Columns.Add("CamAngle", typeof(string)); |
452 | dtWaypoints.Columns.Add("Event",typeof(string)); |
452 | dtWaypoints.Columns.Add("Event", typeof(string)); |
453 | dtWaypoints.Columns.Add("Out1Timer",typeof(string)); |
453 | dtWaypoints.Columns.Add("Out1Timer", typeof(string)); |
454 | dtWaypoints.Columns.Add("Status",typeof(string)); |
454 | dtWaypoints.Columns.Add("Status", typeof(string)); |
455 | dtWaypoints.PrimaryKey = new DataColumn[] { dtWaypoints.Columns["Index"] }; |
455 | dtWaypoints.PrimaryKey = new DataColumn[] { dtWaypoints.Columns["Index"] }; |
456 | dgvWP.ItemsSource = dtWaypoints.DefaultView; |
456 | dgvWP.ItemsSource = dtWaypoints.DefaultView; |
Line 457... | Line 457... | ||
457 | dgvWP.ColumnHeaderStyle = new Style(); |
457 | dgvWP.ColumnHeaderStyle = new Style(); |
458 | dgvWP.ColumnHeaderStyle = style; |
458 | dgvWP.ColumnHeaderStyle = style; |
459 | 459 | ||
460 | dtGPX.Columns.Add("Index",typeof(int)); |
460 | dtGPX.Columns.Add("Index", typeof(int)); |
461 | dtGPX.Columns.Add("Latitude",typeof(double)); |
461 | dtGPX.Columns.Add("Latitude", typeof(double)); |
462 | dtGPX.Columns.Add("Longitude",typeof(double)); |
462 | dtGPX.Columns.Add("Longitude", typeof(double)); |
463 | dtGPX.Columns.Add("Elevation",typeof(int)); |
463 | dtGPX.Columns.Add("Elevation", typeof(int)); |
Line 464... | Line 464... | ||
464 | dtGPX.Columns.Add("Time",typeof(string)); |
464 | dtGPX.Columns.Add("Time", typeof(string)); |
465 | dtGPX.PrimaryKey = new DataColumn[] { dtGPX.Columns["Index"] }; |
465 | dtGPX.PrimaryKey = new DataColumn[] { dtGPX.Columns["Index"] }; |
Line 490... | Line 490... | ||
490 | private void serialPortCtrl_PortOpened() |
490 | private void serialPortCtrl_PortOpened() |
491 | { |
491 | { |
492 | Dispatcher.Invoke(() => imageWiFi.Source = new BitmapImage(new Uri("Images/WiFi_G.png", UriKind.Relative))); |
492 | Dispatcher.Invoke(() => imageWiFi.Source = new BitmapImage(new Uri("Images/WiFi_G.png", UriKind.Relative))); |
493 | _getVersion(); |
493 | _getVersion(); |
494 | Thread.Sleep(100); |
494 | Thread.Sleep(100); |
- | 495 | _getLic(); |
|
495 | //_OSDMenue(0); |
496 | //_OSDMenue(0); |
496 | //Thread.Sleep(200); |
497 | //Thread.Sleep(200); |
497 | //_sendSerialData(); |
498 | //_sendSerialData(); |
498 | _readCont(true); |
499 | _readCont(true); |
499 | } |
500 | } |
Line 522... | Line 523... | ||
522 | _OSDMenueAutoRefresh(); |
523 | _OSDMenueAutoRefresh(); |
523 | } |
524 | } |
524 | if (_iLifeCounter > 0) |
525 | if (_iLifeCounter > 0) |
525 | { |
526 | { |
526 | Dispatcher.Invoke(() => imageConn.Source = new BitmapImage(new Uri("Images/Data_G.png", UriKind.Relative))); |
527 | Dispatcher.Invoke(() => imageConn.Source = new BitmapImage(new Uri("Images/Data_G.png", UriKind.Relative))); |
527 | // Dispatcher.Invoke((Action)(() => rctConnection.Fill = Brushes.LightGreen)); |
528 | // Dispatcher.Invoke((Action)(() => rctConnection.Fill = Brushes.LightGreen)); |
528 | _iLifeCounter = 0; |
529 | _iLifeCounter = 0; |
529 | _bConnErr = false; |
530 | _bConnErr = false; |
530 | if(_bAirborne && _bGPXLog) |
531 | if (_bAirborne && _bGPXLog) |
531 | { |
532 | { |
532 | drGPX[0] = dtGPX.Rows.Count; |
533 | drGPX[0] = dtGPX.Rows.Count; |
533 | dtGPX.Rows.Add(new object[] { drGPX[0], drGPX[1], drGPX[2], drGPX[3], drGPX[4] }); |
534 | dtGPX.Rows.Add(new object[] { drGPX[0], drGPX[1], drGPX[2], drGPX[3], drGPX[4] }); |
534 | } |
535 | } |
535 | Dispatcher.Invoke((Action)(() => tbSideBarGPXLog.Background = (_bAirborne && _bGPXLog && _bToggle) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent))); |
536 | Dispatcher.Invoke((Action)(() => tbSideBarGPXLog.Background = (_bAirborne && _bGPXLog && _bToggle) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent))); |
Line 541... | Line 542... | ||
541 | { |
542 | { |
542 | if (!_bConnErr) |
543 | if (!_bConnErr) |
543 | { |
544 | { |
544 | Log(LogMsgType.Error, "No communication to NC/FC!"); |
545 | Log(LogMsgType.Error, "No communication to NC/FC!"); |
545 | Dispatcher.Invoke(() => imageConn.Source = new BitmapImage(new Uri("Images/Data_R.png", UriKind.Relative))); |
546 | Dispatcher.Invoke(() => imageConn.Source = new BitmapImage(new Uri("Images/Data_R.png", UriKind.Relative))); |
546 | // Dispatcher.Invoke((Action)(() => rctConnection.Fill = Brushes.Red)); |
547 | // Dispatcher.Invoke((Action)(() => rctConnection.Fill = Brushes.Red)); |
547 | _bConnErr = true; |
548 | _bConnErr = true; |
548 | } |
549 | } |
549 | } |
550 | } |
550 | } |
551 | } |
551 | } |
552 | } |
Line 625... | Line 626... | ||
625 | } |
626 | } |
Line 626... | Line 627... | ||
626 | 627 | ||
627 | #region thresholds |
628 | #region thresholds |
628 | private void sliderThresholdVoltageWarn_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
629 | private void sliderThresholdVoltageWarn_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
629 | { |
630 | { |
630 | if(!_init) |
631 | if (!_init) |
631 | _dThresholdVoltageWarn = sliderThresholdVoltageWarn.Value; |
632 | _dThresholdVoltageWarn = sliderThresholdVoltageWarn.Value; |
632 | } |
633 | } |
633 | private void sliderThresholdVoltageCrit_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
634 | private void sliderThresholdVoltageCrit_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
634 | { |
635 | { |
635 | if(!_init) |
636 | if (!_init) |
636 | _dThresholdVoltageCrit = sliderThresholdVoltageCrit.Value; |
637 | _dThresholdVoltageCrit = sliderThresholdVoltageCrit.Value; |
637 | } |
638 | } |
638 | private void checkBoxThresholdVoltageVoice_Click(object sender, RoutedEventArgs e) |
639 | private void checkBoxThresholdVoltageVoice_Click(object sender, RoutedEventArgs e) |
639 | { |
640 | { |
640 | _bVoiceVoltPlay = (bool)checkBoxThresholdVoltageVoice.IsChecked; |
641 | _bVoiceVoltPlay = (bool)checkBoxThresholdVoltageVoice.IsChecked; |
Line 641... | Line 642... | ||
641 | } |
642 | } |
642 | 643 | ||
643 | private void sliderThresholdDistanceWarn_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
644 | private void sliderThresholdDistanceWarn_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
644 | { |
645 | { |
645 | if(!_init) |
646 | if (!_init) |
646 | _dThresholdDistanceWarn = sliderThresholdDistanceWarn.Value; |
647 | _dThresholdDistanceWarn = sliderThresholdDistanceWarn.Value; |
647 | } |
648 | } |
648 | private void checkBoxThresholdDistanceVoice_Click(object sender, RoutedEventArgs e) |
649 | private void checkBoxThresholdDistanceVoice_Click(object sender, RoutedEventArgs e) |
Line 679... | Line 680... | ||
679 | _setMotorGridSize(); |
680 | _setMotorGridSize(); |
680 | } |
681 | } |
681 | private void Window_Closing(object sender, CancelEventArgs e) |
682 | private void Window_Closing(object sender, CancelEventArgs e) |
682 | { |
683 | { |
683 | _writeIni(); |
684 | _writeIni(); |
684 | if(_bGPXLog && dtGPX.Rows.Count > 0) |
685 | if (_bGPXLog && dtGPX.Rows.Count > 0) |
685 | _saveGPXLog(); |
686 | _saveGPXLog(); |
686 | } |
687 | } |
687 | private void Window_Closed(object sender, EventArgs e) |
688 | private void Window_Closed(object sender, EventArgs e) |
688 | { |
689 | { |
689 | Application.Current.Shutdown(); |
690 | Application.Current.Shutdown(); |
Line 711... | Line 712... | ||
711 | // acccess mode |
712 | // acccess mode |
712 | comboBoxMode.ItemsSource = Enum.GetValues(typeof(AccessMode)); |
713 | comboBoxMode.ItemsSource = Enum.GetValues(typeof(AccessMode)); |
713 | comboBoxMode.SelectedItem = MainMap.Manager.Mode; |
714 | comboBoxMode.SelectedItem = MainMap.Manager.Mode; |
Line 714... | Line 715... | ||
714 | 715 | ||
715 | } |
716 | } |
716 | 717 | ||
717 | /// <summary> |
718 | /// <summary> |
718 | /// selection of relevant map providers --> if You need more, You can change the line: |
719 | /// selection of relevant map providers --> if You need more, You can change the line: |
719 | /// comboBoxMapType.ItemsSource = providerList; |
720 | /// comboBoxMapType.ItemsSource = providerList; |
720 | /// to: |
721 | /// to: |
Line 731... | Line 732... | ||
731 | private void MainMap_Loaded(object sender, RoutedEventArgs e) |
732 | private void MainMap_Loaded(object sender, RoutedEventArgs e) |
732 | { |
733 | { |
733 | MainMap.Manager.Mode = AccessMode.ServerAndCache; |
734 | MainMap.Manager.Mode = AccessMode.ServerAndCache; |
734 | copter = new GMapMarker(MainMap.Position); |
735 | copter = new GMapMarker(MainMap.Position); |
Line 735... | Line 736... | ||
735 | 736 | ||
736 | copter.Shape = new CustomMarkerCopter(this, copter, MainMap.Position.Lat.ToString("0.#######°") + System.Environment.NewLine + MainMap.Position.Lng.ToString("0.#######°"),"red"); |
737 | copter.Shape = new CustomMarkerCopter(this, copter, MainMap.Position.Lat.ToString("0.#######°") + System.Environment.NewLine + MainMap.Position.Lng.ToString("0.#######°"), "red"); |
737 | if (comboBoxCopterColor.SelectionBoxItem != null) |
738 | if (comboBoxCopterColor.SelectionBoxItem != null) |
738 | { |
739 | { |
739 | string s = comboBoxCopterColor.SelectionBoxItem.ToString(); |
740 | string s = comboBoxCopterColor.SelectionBoxItem.ToString(); |
740 | ((CustomMarkerCopter)(copter.Shape)).setCopterColor(s); |
741 | ((CustomMarkerCopter)(copter.Shape)).setCopterColor(s); |
Line 834... | Line 835... | ||
834 | return null; |
835 | return null; |
835 | } |
836 | } |
836 | void _clearWPMarker(string name) |
837 | void _clearWPMarker(string name) |
837 | { |
838 | { |
838 | GMapMarker p = _findWPMarker(name); |
839 | GMapMarker p = _findWPMarker(name); |
839 | if(p != null) |
840 | if (p != null) |
840 | MainMap.Markers.Remove(p); |
841 | MainMap.Markers.Remove(p); |
841 | } |
842 | } |
842 | void _renameWPMarker(string s1, string s2) |
843 | void _renameWPMarker(string s1, string s2) |
843 | { |
844 | { |
844 | GMapMarker p = _findWPMarker(s1); |
845 | GMapMarker p = _findWPMarker(s1); |
Line 861... | Line 862... | ||
861 | void createCircle(PointLatLng center, double distance) |
862 | void createCircle(PointLatLng center, double distance) |
862 | { |
863 | { |
Line 863... | Line 864... | ||
863 | 864 | ||
864 | GMapMarker it = new GMapMarker(center); |
865 | GMapMarker it = new GMapMarker(center); |
865 | it.ZIndex = -1; |
866 | it.ZIndex = -1; |
866 | 867 | ||
867 | cWPBound.Center = center; |
868 | cWPBound.Center = center; |
868 | cWPBound.Bound = GMap.NET.PureProjection.GetPointFromDistance(center, distance); |
869 | cWPBound.Bound = GMap.NET.PureProjection.GetPointFromDistance(center, distance); |
869 | cWPBound.Tag = it; |
870 | cWPBound.Tag = it; |
870 | cWPBound.IsHitTestVisible = false; |
871 | cWPBound.IsHitTestVisible = false; |
Line 987... | Line 988... | ||
987 | 988 | ||
988 | private void MainMap_OnMapZoomChanged() |
989 | private void MainMap_OnMapZoomChanged() |
989 | { |
990 | { |
990 | if (_bFollowCopter) |
991 | if (_bFollowCopter) |
991 | _setCopterData(MainMap.Position); |
992 | _setCopterData(MainMap.Position); |
992 | if((int)sliderMapZoom.Value != MainMap.Zoom) |
993 | if ((int)sliderMapZoom.Value != MainMap.Zoom) |
993 | sliderMapZoom.Value = MainMap.Zoom; |
994 | sliderMapZoom.Value = MainMap.Zoom; |
994 | if(cWPBound != null && cWPBound.Tag != null) |
995 | if (cWPBound != null && cWPBound.Tag != null) |
995 | UpdateCircle(cWPBound); |
996 | UpdateCircle(cWPBound); |
Line 996... | Line 997... | ||
996 | } |
997 | } |
997 | 998 | ||
Line 1008... | Line 1009... | ||
1008 | { |
1009 | { |
1009 | Dispatcher.Invoke(() => ArtHor.rotateHome = GMapProviders.EmptyProvider.Projection.GetBearing(copter.Position, home.Position)); |
1010 | Dispatcher.Invoke(() => ArtHor.rotateHome = GMapProviders.EmptyProvider.Projection.GetBearing(copter.Position, home.Position)); |
1010 | double d = GMapProviders.EmptyProvider.Projection.GetDistance(home.Position, copter.Position); |
1011 | double d = GMapProviders.EmptyProvider.Projection.GetDistance(home.Position, copter.Position); |
1011 | Dispatcher.Invoke(() => tbTopDistanceHP.Text = (d * 1000).ToString("0.0 m")); |
1012 | Dispatcher.Invoke(() => tbTopDistanceHP.Text = (d * 1000).ToString("0.0 m")); |
Line 1012... | Line 1013... | ||
1012 | 1013 | ||
1013 | if(d*1000 < _dThresholdDistanceWarn) |
1014 | if (d * 1000 < _dThresholdDistanceWarn) |
1014 | { |
1015 | { |
1015 | _iDistanceJitter = 0; _bVoiceDistanceActive = false; |
1016 | _iDistanceJitter = 0; _bVoiceDistanceActive = false; |
1016 | if (stbDistanceWarnAnim != null && _bAnimDistanceActive) |
1017 | if (stbDistanceWarnAnim != null && _bAnimDistanceActive) |
1017 | { |
1018 | { |
Line 1129... | Line 1130... | ||
1129 | #endregion GMap |
1130 | #endregion GMap |
Line 1130... | Line 1131... | ||
1130 | 1131 | ||
1131 | #region settings |
1132 | #region settings |
1132 | private void cBoxTimingsDebug_DropDownClosed(object sender, EventArgs e) |
1133 | private void cBoxTimingsDebug_DropDownClosed(object sender, EventArgs e) |
1133 | { |
1134 | { |
1134 | if(! _bCBInit && cBoxTimingsDebug.SelectedIndex > -1) |
1135 | if (!_bCBInit && cBoxTimingsDebug.SelectedIndex > -1) |
1135 | debugInterval = (byte)(Convert.ToInt16(cBoxTimingsDebug.SelectedItem) / 10); |
1136 | debugInterval = (byte)(Convert.ToInt16(cBoxTimingsDebug.SelectedItem) / 10); |
1136 | } |
1137 | } |
1137 | private void cBoxTimingsNav_DropDownClosed(object sender, EventArgs e) |
1138 | private void cBoxTimingsNav_DropDownClosed(object sender, EventArgs e) |
1138 | { |
1139 | { |
1139 | if(! _bCBInit && cBoxTimingsNav.SelectedIndex > -1) |
1140 | if (!_bCBInit && cBoxTimingsNav.SelectedIndex > -1) |
1140 | navctrlInterval = (byte)(Convert.ToInt16(cBoxTimingsNav.SelectedItem) / 10); |
1141 | navctrlInterval = (byte)(Convert.ToInt16(cBoxTimingsNav.SelectedItem) / 10); |
1141 | } |
1142 | } |
1142 | private void cBoxTimingsBl_DropDownClosed(object sender, EventArgs e) |
1143 | private void cBoxTimingsBl_DropDownClosed(object sender, EventArgs e) |
1143 | { |
1144 | { |
Line 1217... | Line 1218... | ||
1217 | /// <param name="msg"> The string containing the message to be shown. </param> |
1218 | /// <param name="msg"> The string containing the message to be shown. </param> |
1218 | private void Log(LogMsgType msgtype, string msg) |
1219 | private void Log(LogMsgType msgtype, string msg) |
1219 | { |
1220 | { |
1220 | Dispatcher.Invoke(() => |
1221 | Dispatcher.Invoke(() => |
1221 | { |
1222 | { |
1222 | // rtfTerminal.CaretPosition = rtfTerminal.CaretPosition.DocumentEnd; |
1223 | // rtfTerminal.CaretPosition = rtfTerminal.CaretPosition.DocumentEnd; |
1223 | // rtfTerminal.Foreground = new SolidColorBrush(LogMsgTypeColor[(int)msgtype]); |
1224 | // rtfTerminal.Foreground = new SolidColorBrush(LogMsgTypeColor[(int)msgtype]); |
1224 | // rtfTerminal.AppendText(msg + "\r"); |
1225 | // rtfTerminal.AppendText(msg + "\r"); |
1225 | TextRange tr = new TextRange(rtfTerminal.Document.ContentEnd,rtfTerminal.Document.ContentEnd); |
1226 | TextRange tr = new TextRange(rtfTerminal.Document.ContentEnd, rtfTerminal.Document.ContentEnd); |
1226 | tr.Text = msg; |
1227 | tr.Text = msg; |
1227 | tr.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(LogMsgTypeColor[(int)msgtype])); |
1228 | tr.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(LogMsgTypeColor[(int)msgtype])); |
1228 | rtfTerminal.AppendText("\r"); |
1229 | rtfTerminal.AppendText("\r"); |
1229 | rtfTerminal.ScrollToEnd(); |
1230 | rtfTerminal.ScrollToEnd(); |
1230 | }); |
1231 | }); |
1231 | } |
1232 | } |
1232 | private void ErrorLog(LogMsgType msgtype, string msg , string linkURL, string linkName) |
1233 | private void ErrorLog(LogMsgType msgtype, string msg, string linkURL, string linkName) |
1233 | { |
1234 | { |
Line 1234... | Line 1235... | ||
1234 | 1235 | ||
1235 | Dispatcher.Invoke(() => |
1236 | Dispatcher.Invoke(() => |
1236 | { |
1237 | { |
Line 1282... | Line 1283... | ||
1282 | int iLength = 0; |
1283 | int iLength = 0; |
1283 | int iEnd = searchRange.Text.IndexOf('\r', iStart); |
1284 | int iEnd = searchRange.Text.IndexOf('\r', iStart); |
1284 | if (iEnd > 0) |
1285 | if (iEnd > 0) |
1285 | { |
1286 | { |
1286 | iLength = iEnd + 1; |
1287 | iLength = iEnd + 1; |
1287 | int iHttp = searchRange.Text.IndexOf("http", iEnd); |
1288 | int iHttp = searchRange.Text.IndexOf("http", iEnd); |
1288 | if (iHttp == iLength) |
1289 | if (iHttp == iLength) |
1289 | { |
1290 | { |
1290 | int iEnd2 = searchRange.Text.IndexOf('\r', iLength); |
1291 | int iEnd2 = searchRange.Text.IndexOf('\r', iLength); |
1291 | if (iEnd2 > iLength) |
1292 | if (iEnd2 > iLength) |
1292 | { |
1293 | { |
1293 | iLength = iEnd2 + 1; |
1294 | iLength = iEnd2 + 1; |
1294 | // TextRange result = new TextRange(rtfError.Document.ContentStart.GetPositionAtOffset(iStart), GetTextPositionAtOffset(rtfError.Document.ContentStart.GetPositionAtOffset(iStart), iLength)); |
1295 | // TextRange result = new TextRange(rtfError.Document.ContentStart.GetPositionAtOffset(iStart), GetTextPositionAtOffset(rtfError.Document.ContentStart.GetPositionAtOffset(iStart), iLength)); |
Line 1295... | Line 1296... | ||
1295 | 1296 | ||
1296 | rtfError.Selection.Select(rtfError.Document.ContentStart.GetPositionAtOffset(iStart), GetTextPositionAtOffset(rtfError.Document.ContentStart.GetPositionAtOffset(iStart), iLength)); |
1297 | rtfError.Selection.Select(rtfError.Document.ContentStart.GetPositionAtOffset(iStart), GetTextPositionAtOffset(rtfError.Document.ContentStart.GetPositionAtOffset(iStart), iLength)); |
1297 | rtfError.Selection.Text = string.Empty; |
1298 | rtfError.Selection.Text = string.Empty; |
1298 | if (rtfError.Document.ContentEnd.GetTextRunLength(LogicalDirection.Backward) < 2) _bErrorLog = false; |
1299 | if (rtfError.Document.ContentEnd.GetTextRunLength(LogicalDirection.Backward) < 2) _bErrorLog = false; |
Line 1401... | Line 1402... | ||
1401 | _iCtrlAct = adr; |
1402 | _iCtrlAct = adr; |
1402 | switch (adr) |
1403 | switch (adr) |
1403 | { |
1404 | { |
1404 | case 1: |
1405 | case 1: |
1405 | Dispatcher.Invoke(() => tbCtrl.Text = "FC"); |
1406 | Dispatcher.Invoke(() => tbCtrl.Text = "FC"); |
1406 | // Dispatcher.Invoke(() => buttonSwitchNC.Visibility = Visibility.Visible); |
1407 | // Dispatcher.Invoke(() => buttonSwitchNC.Visibility = Visibility.Visible); |
1407 | // Dispatcher.Invoke(() => labelSwitchToNavi.Visibility = Visibility.Visible); |
1408 | // Dispatcher.Invoke(() => labelSwitchToNavi.Visibility = Visibility.Visible); |
1408 | // _setFieldsNA(); //display fields NA for FC |
1409 | // _setFieldsNA(); //display fields NA for FC |
1409 | break; |
1410 | break; |
1410 | case 2: |
1411 | case 2: |
1411 | Dispatcher.Invoke(() => tbCtrl.Text = "NC"); |
1412 | Dispatcher.Invoke(() => tbCtrl.Text = "NC"); |
1412 | //Dispatcher.Invoke(() => buttonSwitchNC.Visibility = Visibility.Hidden); |
1413 | //Dispatcher.Invoke(() => buttonSwitchNC.Visibility = Visibility.Hidden); |
1413 | //Dispatcher.Invoke(() => labelSwitchToNavi.Visibility = Visibility.Hidden); |
1414 | //Dispatcher.Invoke(() => labelSwitchToNavi.Visibility = Visibility.Hidden); |
Line 1420... | Line 1421... | ||
1420 | // break; |
1421 | // break; |
1421 | default: |
1422 | default: |
1422 | Dispatcher.Invoke(() => tbCtrl.Text = "NA"); |
1423 | Dispatcher.Invoke(() => tbCtrl.Text = "NA"); |
1423 | break; |
1424 | break; |
1424 | } |
1425 | } |
1425 | // _loadLabelNames(); |
1426 | // _loadLabelNames(); |
1426 | } |
1427 | } |
1427 | // else |
1428 | // else |
1428 | // Debug.Print("Address == 0?"); |
1429 | // Debug.Print("Address == 0?"); |
Line 1429... | Line 1430... | ||
1429 | 1430 | ||
Line 1448... | Line 1449... | ||
1448 | 1449 | ||
1449 | case 'K'://BL-CTRL data |
1450 | case 'K'://BL-CTRL data |
1450 | _processBLCtrl(data); |
1451 | _processBLCtrl(data); |
Line -... | Line 1452... | ||
- | 1452 | break; |
|
- | 1453 | ||
- | 1454 | case 'M'://License info |
|
- | 1455 | _processLicense(data); |
|
1451 | break; |
1456 | break; |
1452 | 1457 | ||
1453 | case 'O': //NC Data |
1458 | case 'O': //NC Data |
Line 1454... | Line 1459... | ||
1454 | _processNCData(data); |
1459 | _processNCData(data); |
Line 1515... | Line 1520... | ||
1515 | /// <param name="data">the received byte array to process</param> |
1520 | /// <param name="data">the received byte array to process</param> |
1516 | void _processDebugVals(byte adr, byte[] data) |
1521 | void _processDebugVals(byte adr, byte[] data) |
1517 | { |
1522 | { |
1518 | if (data.Length == 66) |
1523 | if (data.Length == 66) |
1519 | { |
1524 | { |
1520 | 1525 | ||
1521 | double v; |
1526 | double v; |
1522 | int index = 0; |
1527 | int index = 0; |
1523 | Int16 i16 = 0; |
1528 | Int16 i16 = 0; |
1524 | double dTemp = 0; |
1529 | double dTemp = 0; |
1525 | for (int i = 2; i < 66; i += 2) |
1530 | for (int i = 2; i < 66; i += 2) |
1526 | { |
1531 | { |
1527 | i16 = data[i + 1]; |
1532 | i16 = data[i + 1]; |
1528 | i16 = (Int16)(i16 << 8); |
1533 | i16 = (Int16)(i16 << 8); |
1529 | iAnalogData[index] = data[i] + i16; |
1534 | iAnalogData[index] = data[i] + i16; |
1530 | sAnalogData[index] = (data[i] + i16).ToString(); |
1535 | sAnalogData[index] = (data[i] + i16).ToString(); |
1531 | // dtAnalog.Rows[index].SetField(1, sAnalogData[index]); |
1536 | // dtAnalog.Rows[index].SetField(1, sAnalogData[index]); |
Line 1532... | Line 1537... | ||
1532 | 1537 | ||
1533 | if (adr == 2) //NC |
1538 | if (adr == 2) //NC |
1534 | { |
1539 | { |
1535 | switch (index) |
1540 | switch (index) |
Line 1543... | Line 1548... | ||
1543 | Dispatcher.Invoke((Action)(() => tbRoll.Text = ((double)iAnalogData[index] / (double)10).ToString("0.0°"))); |
1548 | Dispatcher.Invoke((Action)(() => tbRoll.Text = ((double)iAnalogData[index] / (double)10).ToString("0.0°"))); |
1544 | break; |
1549 | break; |
1545 | case 4: //altitude |
1550 | case 4: //altitude |
1546 | Dispatcher.Invoke(() => tbAlt.Text = ((double)iAnalogData[index] / (double)10).ToString("0.0 m")); |
1551 | Dispatcher.Invoke(() => tbAlt.Text = ((double)iAnalogData[index] / (double)10).ToString("0.0 m")); |
1547 | Dispatcher.Invoke(() => tbTopHeight.Text = ((double)iAnalogData[index] / (double)10).ToString("0.0 m")); |
1552 | Dispatcher.Invoke(() => tbTopHeight.Text = ((double)iAnalogData[index] / (double)10).ToString("0.0 m")); |
1548 | Dispatcher.Invoke(() => { drGPX[3] = (double)iAnalogData[index] / (double)10; }); |
1553 | Dispatcher.Invoke(() => { drGPX[3] = (double)iAnalogData[index] / (double)10; }); |
1549 | break; |
1554 | break; |
1550 | case 7: //Voltage |
1555 | case 7: //Voltage |
1551 | v = (double)iAnalogData[index] / (double)10; |
1556 | v = (double)iAnalogData[index] / (double)10; |
1552 | Dispatcher.Invoke(() => tbVolt.Text = v.ToString("0.0 V")); |
1557 | Dispatcher.Invoke(() => tbVolt.Text = v.ToString("0.0 V")); |
1553 | Dispatcher.Invoke(() => tbTopVoltage.Text = v.ToString("0.0 V")); |
1558 | Dispatcher.Invoke(() => tbTopVoltage.Text = v.ToString("0.0 V")); |
1554 | Dispatcher.Invoke(() => pbTopVoltage.Value = v); |
1559 | Dispatcher.Invoke(() => pbTopVoltage.Value = v); |
1555 | if (v - _dLipoVMin < 1 | v < _dThresholdVoltageWarn) |
1560 | if (v - _dLipoVMin < 1 | v < _dThresholdVoltageWarn) |
1556 | { |
1561 | { |
1557 | if (v == _dVoltLast) |
1562 | if (v == _dVoltLast) |
1558 | if(_iVoltJitter < 20) _iVoltJitter++; |
1563 | if (_iVoltJitter < 20) _iVoltJitter++; |
1559 | else |
1564 | else |
1560 | { |
1565 | { |
1561 | _iVoltJitter = 0; |
1566 | _iVoltJitter = 0; |
1562 | _dVoltLast = v; |
1567 | _dVoltLast = v; |
1563 | } |
1568 | } |
1564 | if (_iVoltJitter == 20) |
1569 | if (_iVoltJitter == 20) |
1565 | { |
1570 | { |
1566 | Dispatcher.Invoke(() => pbTopVoltage.Foreground = Brushes.Orange); |
1571 | Dispatcher.Invoke(() => pbTopVoltage.Foreground = Brushes.Orange); |
Line 1567... | Line 1572... | ||
1567 | 1572 | ||
Line 1632... | Line 1637... | ||
1632 | Dispatcher.Invoke((Action)(() => tbI2C.Text = sAnalogData[index])); |
1637 | Dispatcher.Invoke((Action)(() => tbI2C.Text = sAnalogData[index])); |
1633 | break; |
1638 | break; |
1634 | case 20: //Earthmagnet field |
1639 | case 20: //Earthmagnet field |
1635 | Dispatcher.Invoke((Action)(() => tbMagF.Text = sAnalogData[index] + "%")); |
1640 | Dispatcher.Invoke((Action)(() => tbMagF.Text = sAnalogData[index] + "%")); |
1636 | Dispatcher.Invoke((Action)(() => tbTopEarthMag.Text = sAnalogData[index] + "%")); |
1641 | Dispatcher.Invoke((Action)(() => tbTopEarthMag.Text = sAnalogData[index] + "%")); |
1637 | 1642 | ||
1638 | if (Math.Abs(100 - iAnalogData[index]) < _iThresholdMagField) |
1643 | if (Math.Abs(100 - iAnalogData[index]) < _iThresholdMagField) |
1639 | { |
1644 | { |
1640 | Dispatcher.Invoke(() => imageEarthMag.Source = new BitmapImage(new Uri("Images/EarthMag.png", UriKind.Relative))); |
1645 | Dispatcher.Invoke(() => imageEarthMag.Source = new BitmapImage(new Uri("Images/EarthMag.png", UriKind.Relative))); |
1641 | _iMagneticFieldJitter = 0; _bVoiceMagneticFieldActive = false; |
1646 | _iMagneticFieldJitter = 0; _bVoiceMagneticFieldActive = false; |
1642 | if (stbMagneticFieldAnim != null && _bAnimMagneticFieldActive) |
1647 | if (stbMagneticFieldAnim != null && _bAnimMagneticFieldActive) |
Line 1646... | Line 1651... | ||
1646 | } |
1651 | } |
1647 | } |
1652 | } |
1648 | else |
1653 | else |
1649 | { |
1654 | { |
1650 | Dispatcher.Invoke(() => imageEarthMag.Source = new BitmapImage(new Uri("Images/EarthMag_R.png", UriKind.Relative))); |
1655 | Dispatcher.Invoke(() => imageEarthMag.Source = new BitmapImage(new Uri("Images/EarthMag_R.png", UriKind.Relative))); |
1651 | if(_iMagneticFieldLast >= Math.Abs(100 - iAnalogData[index])) |
1656 | if (_iMagneticFieldLast >= Math.Abs(100 - iAnalogData[index])) |
1652 | { |
1657 | { |
1653 | if (_iMagneticFieldJitter < 20) |
1658 | if (_iMagneticFieldJitter < 20) |
1654 | _iMagneticFieldJitter++; |
1659 | _iMagneticFieldJitter++; |
1655 | } |
1660 | } |
1656 | else |
1661 | else |
1657 | { |
1662 | { |
1658 | _iMagneticFieldJitter = 0; |
1663 | _iMagneticFieldJitter = 0; |
1659 | _iMagneticFieldLast = Math.Abs(100 - iAnalogData[index]); |
1664 | _iMagneticFieldLast = Math.Abs(100 - iAnalogData[index]); |
1660 | } |
1665 | } |
1661 | if(_iMagneticFieldJitter == 20) |
1666 | if (_iMagneticFieldJitter == 20) |
1662 | { |
1667 | { |
1663 | if (stbMagneticFieldAnim != null && !_bAnimMagneticFieldActive) |
1668 | if (stbMagneticFieldAnim != null && !_bAnimMagneticFieldActive) |
1664 | { |
1669 | { |
1665 | Dispatcher.Invoke(() => stbMagneticFieldAnim.Begin()); |
1670 | Dispatcher.Invoke(() => stbMagneticFieldAnim.Begin()); |
1666 | _bAnimMagneticFieldActive = true; |
1671 | _bAnimMagneticFieldActive = true; |
Line 1674... | Line 1679... | ||
1674 | } |
1679 | } |
1675 | } |
1680 | } |
1676 | } |
1681 | } |
1677 | break; |
1682 | break; |
1678 | case 21: //GroundSpeed |
1683 | case 21: //GroundSpeed |
1679 | Dispatcher.Invoke((Action)(() => tbSpeed.Text = ((double)iAnalogData[index] / (double)100).ToString("0.00 m/s"))); |
1684 | Dispatcher.Invoke((Action)(() => tbSpeed.Text = ((double)iAnalogData[index] / (double)100).ToString("0.00 m/s"))); |
1680 | if (!_Simulate) |
1685 | if (!_Simulate) |
1681 | Dispatcher.Invoke((Action)(() => tbTopSpeed.Text = ((double)iAnalogData[index] / (double)100).ToString("0.00 m/s"))); |
1686 | Dispatcher.Invoke((Action)(() => tbTopSpeed.Text = ((double)iAnalogData[index] / (double)100).ToString("0.00 m/s"))); |
1682 | break; |
1687 | break; |
Line 1683... | Line 1688... | ||
1683 | 1688 | ||
1684 | ///********** needs testing --> not sure what position this is *************** |
1689 | ///********** needs testing --> not sure what position this is *************** |
1685 | case 28: //Distance East from saved home position -> calculate distance with distance N + height |
1690 | case 28: //Distance East from saved home position -> calculate distance with distance N + height |
1686 | dTemp = Math.Pow((double)iAnalogData[index], 2) + Math.Pow((double)iAnalogData[index - 1], 2); |
1691 | dTemp = Math.Pow((double)iAnalogData[index], 2) + Math.Pow((double)iAnalogData[index - 1], 2); |
1687 | dTemp = Math.Sqrt(dTemp) / (double)10; //'flat' distance from HP with N/E |
1692 | dTemp = Math.Sqrt(dTemp) / (double)10; //'flat' distance from HP with N/E |
1688 | // lblNCDist.Invoke((Action)(() => lblNCDist.Text = dTemp.ToString("0.00"))); |
1693 | // lblNCDist.Invoke((Action)(() => lblNCDist.Text = dTemp.ToString("0.00"))); |
1689 | dTemp = Math.Pow(dTemp, 2) + Math.Pow(((double)iAnalogData[4] / (double)10), 2); //adding 'height' into calculation |
1694 | dTemp = Math.Pow(dTemp, 2) + Math.Pow(((double)iAnalogData[4] / (double)10), 2); //adding 'height' into calculation |
1690 | dTemp = Math.Sqrt(dTemp) / (double)10; |
1695 | dTemp = Math.Sqrt(dTemp) / (double)10; |
1691 | // Dispatcher.Invoke((Action)(() => tbTopDistanceHP.Text = dTemp.ToString("0.0 m"))); |
1696 | // Dispatcher.Invoke((Action)(() => tbTopDistanceHP.Text = dTemp.ToString("0.0 m"))); |
1692 | Dispatcher.Invoke((Action)(() => tbHP1.Text = dTemp.ToString("0.0 m"))); |
1697 | Dispatcher.Invoke((Action)(() => tbHP1.Text = dTemp.ToString("0.0 m"))); |
Line 1693... | Line 1698... | ||
1693 | break; |
1698 | break; |
1694 | 1699 | ||
1695 | case 31: //Sats used |
1700 | case 31: //Sats used |
1696 | Dispatcher.Invoke((Action)(() => tbSats.Text = sAnalogData[index])); |
1701 | Dispatcher.Invoke((Action)(() => tbSats.Text = sAnalogData[index])); |
1697 | // Dispatcher.Invoke((Action)(() => tbTopSats.Text = sAnalogData[index])); |
1702 | // Dispatcher.Invoke((Action)(() => tbTopSats.Text = sAnalogData[index])); |
1698 | break; |
1703 | break; |
1699 | } |
1704 | } |
1700 | } |
1705 | } |
Line 1726... | Line 1731... | ||
1726 | Log(LogMsgType.Incoming, "BL-Firmware: V" + (data[8] / 100).ToString() + "." + (data[8] % 100).ToString()); |
1731 | Log(LogMsgType.Incoming, "BL-Firmware: V" + (data[8] / 100).ToString() + "." + (data[8] % 100).ToString()); |
1727 | } |
1732 | } |
1728 | if (data[5] > 0) //error0 |
1733 | if (data[5] > 0) //error0 |
1729 | { |
1734 | { |
1730 | if (adr == 1) |
1735 | if (adr == 1) |
1731 | ErrorLog(LogMsgType.Error, " FC - HW-Error " + data[5].ToString() + ": " + ((FC_HWError0)data[5]).ToString(),"",""); |
1736 | ErrorLog(LogMsgType.Error, " FC - HW-Error " + data[5].ToString() + ": " + ((FC_HWError0)data[5]).ToString(), "", ""); |
1732 | if (adr == 2) |
1737 | if (adr == 2) |
1733 | ErrorLog(LogMsgType.Error, " NC - HW-Error " + data[5].ToString() + ": " + ((NC_HWError0)data[5]).ToString(),"",""); |
1738 | ErrorLog(LogMsgType.Error, " NC - HW-Error " + data[5].ToString() + ": " + ((NC_HWError0)data[5]).ToString(), "", ""); |
1734 | } |
1739 | } |
1735 | if (data[6] > 0) //error1 |
1740 | if (data[6] > 0) //error1 |
1736 | { |
1741 | { |
1737 | if (adr == 1) |
1742 | if (adr == 1) |
1738 | ErrorLog(LogMsgType.Error, " FC - HW-Error " + data[6].ToString() + ": " + ((FC_HWError1)data[6]).ToString(),"",""); |
1743 | ErrorLog(LogMsgType.Error, " FC - HW-Error " + data[6].ToString() + ": " + ((FC_HWError1)data[6]).ToString(), "", ""); |
1739 | if (adr == 2) |
1744 | if (adr == 2) |
1740 | ErrorLog(LogMsgType.Error, " NC - Unknown HW-ERROR: " + data[6].ToString(),"",""); //@moment NC has only one error field |
1745 | ErrorLog(LogMsgType.Error, " NC - Unknown HW-ERROR: " + data[6].ToString(), "", ""); //@moment NC has only one error field |
1741 | } |
1746 | } |
1742 | //if ((data[5] + data[6] == 0) && _bErrorLog) |
1747 | //if ((data[5] + data[6] == 0) && _bErrorLog) |
1743 | // _clearErrorLog(adr == 1 ? "FC - HW-Error" : "NC - HW-Error"); |
1748 | // _clearErrorLog(adr == 1 ? "FC - HW-Error" : "NC - HW-Error"); |
Line 1744... | Line 1749... | ||
1744 | 1749 | ||
1745 | } |
1750 | } |
1746 | check_HWError = false; |
1751 | check_HWError = false; |
- | 1752 | } |
|
- | 1753 | ||
- | 1754 | void _processLicense(byte[] data) |
|
- | 1755 | { |
|
- | 1756 | if (data.Length > 480) |
|
- | 1757 | { |
|
- | 1758 | Dispatcher.Invoke(() => { |
|
- | 1759 | tbDataLicenseUser.Text = new string(ASCIIEncoding.ASCII.GetChars(data, 1, 127)); |
|
- | 1760 | tbDataLicenseMail.Text = new string(ASCIIEncoding.ASCII.GetChars(data, 129, 127)); |
|
- | 1761 | tbDataLicenseFeature.Text = new string(ASCIIEncoding.ASCII.GetChars(data, 257, 127)); |
|
- | 1762 | tbDataLicenseExpire.Text = new string(ASCIIEncoding.ASCII.GetChars(data, 385, 11)); |
|
- | 1763 | tbDataLicenseLicense.Text = new string(ASCIIEncoding.ASCII.GetChars(data, 397, 16)); |
|
- | 1764 | }); |
|
- | 1765 | } |
|
1747 | } |
1766 | } |
1748 | /// <summary> |
1767 | /// <summary> |
1749 | /// BL-Ctrl data 'K' |
1768 | /// BL-Ctrl data 'K' |
1750 | /// for FC you have to use a customized firmware |
1769 | /// for FC you have to use a customized firmware |
1751 | /// </summary> |
1770 | /// </summary> |
Line 2303... | Line 2322... | ||
2303 | serialStream.Write(bytes, 0, bytes.Length); |
2322 | serialStream.Write(bytes, 0, bytes.Length); |
Line 2304... | Line 2323... | ||
2304 | 2323 | ||
2305 | Thread.Sleep(100); |
2324 | Thread.Sleep(100); |
2306 | _getVersion(); |
2325 | _getVersion(); |
- | 2326 | Thread.Sleep(100); |
|
2307 | Thread.Sleep(100); |
2327 | _getLic(); |
2308 | // _OSDMenue(0); |
2328 | // _OSDMenue(0); |
2309 | } |
2329 | } |
2310 | else |
2330 | else |
2311 | Log(LogMsgType.Error, "NOT CONNECTED!"); |
2331 | Log(LogMsgType.Error, "NOT CONNECTED!"); |
Line 2354... | Line 2374... | ||
2354 | { |
2374 | { |
2355 | byte interval = auto ? navctrlInterval : (byte)0; |
2375 | byte interval = auto ? navctrlInterval : (byte)0; |
2356 | _sendControllerMessage('o', 2, new byte[1] { interval }); |
2376 | _sendControllerMessage('o', 2, new byte[1] { interval }); |
2357 | } |
2377 | } |
2358 | /// <summary> |
2378 | /// <summary> |
- | 2379 | /// request the license info |
|
- | 2380 | /// </summary> |
|
- | 2381 | void _getLic() |
|
- | 2382 | { |
|
- | 2383 | if (serialPortCtrl.Port.IsOpen) |
|
- | 2384 | { |
|
- | 2385 | Stream serialStream = serialPortCtrl.Port.BaseStream; |
|
- | 2386 | byte[] bytes = FlightControllerMessage.CreateMessage('m', 2, new byte[1] { (byte)1 }); |
|
- | 2387 | serialStream.Write(bytes, 0, bytes.Length); |
|
- | 2388 | } |
|
- | 2389 | else |
|
- | 2390 | Log(LogMsgType.Error, "NOT CONNECTED!"); |
|
- | 2391 | ||
- | 2392 | } |
|
- | 2393 | /// <summary> |
|
2359 | /// get the errortext for pending NC error |
2394 | /// get the errortext for pending NC error |
2360 | /// </summary> |
2395 | /// </summary> |
2361 | private void _readNCError() |
2396 | private void _readNCError() |
2362 | { |
2397 | { |
2363 | _sendControllerMessage('e', 2); |
2398 | _sendControllerMessage('e', 2); |
Line 3673... | Line 3708... | ||
3673 | string sIndex = wp.WPText.Substring(1, wp.WPText.Length - 1); |
3708 | string sIndex = wp.WPText.Substring(1, wp.WPText.Length - 1); |
3674 | int index = Convert.ToInt16(sIndex) -1; |
3709 | int index = Convert.ToInt16(sIndex) -1; |
3675 | GMapMarker p = ((GMapMarker)wp.DataContext); |
3710 | GMapMarker p = ((GMapMarker)wp.DataContext); |
3676 | if (p != null && index < dtWaypoints.Rows.Count) |
3711 | if (p != null && index < dtWaypoints.Rows.Count) |
3677 | { |
3712 | { |
3678 | //dtWaypoints.Rows[index][3] = p.Position.Lat; |
- | |
3679 | //dtWaypoints.Rows[index][4] = p.Position.Lng; |
- | |
3680 | //Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
3713 | //Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
3681 | if(wp.WPType == 0 | wp.WPType == 3) |
3714 | if(wp.WPType == 0 | wp.WPType == 3) |
3682 | { |
3715 | { |
- | 3716 | PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]); |
|
- | 3717 | int wpListIndex = wpList.IndexOf(x); |
|
- | 3718 | if (wpListIndex > -1) |
|
- | 3719 | { |
|
3683 | wpList[index] = p.Position; |
3720 | wpList[wpListIndex] = p.Position; |
3684 | MainMap.Markers.Remove(mRouteWP); |
3721 | MainMap.Markers.Remove(mRouteWP); |
3685 | _routeUpdate(); |
3722 | _routeUpdate(); |
- | 3723 | } |
|
3686 | } |
3724 | } |
- | 3725 | dtWaypoints.Rows[index][3] = p.Position.Lat; |
|
- | 3726 | dtWaypoints.Rows[index][4] = p.Position.Lng; |
|
3687 | } |
3727 | } |
3688 | } |
3728 | } |
3689 | void _updateDTWPPosFin(CustomMarkerWP wp) |
3729 | void _updateDTWPPosFin(CustomMarkerWP wp) |
3690 | { |
3730 | { |
3691 | string sIndex = wp.WPText.Substring(1, wp.WPText.Length - 1); |
3731 | string sIndex = wp.WPText.Substring(1, wp.WPText.Length - 1); |
Line 4148... | Line 4188... | ||
4148 | dtWaypoints.Rows[index][2] = dtWaypoints.Rows[index][2].ToString().Substring(0, 1) + (index+1).ToString(); |
4188 | dtWaypoints.Rows[index][2] = dtWaypoints.Rows[index][2].ToString().Substring(0, 1) + (index+1).ToString(); |
4149 | ((CustomMarkerWP)m2.Shape).text.Text = dtWaypoints.Rows[index][2].ToString(); |
4189 | ((CustomMarkerWP)m2.Shape).text.Text = dtWaypoints.Rows[index][2].ToString(); |
4150 | dgvWP.Items.Refresh(); |
4190 | dgvWP.Items.Refresh(); |
4151 | dgvWP.SelectedIndex = index - 1; |
4191 | dgvWP.SelectedIndex = index - 1; |
4152 | _dgvWPselectEditRow(); |
4192 | _dgvWPselectEditRow(); |
- | 4193 | if (((int)dtWaypoints.Rows[index][1] == 0 | (int)dtWaypoints.Rows[index][1] == 3) && ((int)dtWaypoints.Rows[index - 1][1] == 0 | (int)dtWaypoints.Rows[index - 1][1] == 3))// && wpList.Count > index) |
|
- | 4194 | { |
|
- | 4195 | PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]); |
|
4153 | PointLatLng p = wpList[index]; |
4196 | int wpListIndex = wpList.IndexOf(x); |
- | 4197 | if (wpListIndex > 0) |
|
- | 4198 | { |
|
4154 | wpList.RemoveAt(index); |
4199 | wpList.RemoveAt(wpListIndex); |
4155 | wpList.Insert(index - 1, p); |
4200 | wpList.Insert(wpListIndex - 1, x); |
4156 | MainMap.Markers.Remove(mRouteWP); |
4201 | MainMap.Markers.Remove(mRouteWP); |
4157 | _routeUpdate(); |
4202 | _routeUpdate(); |
- | 4203 | } |
|
- | 4204 | } |
|
4158 | } |
4205 | } |
4159 | } |
4206 | } |
Line 4160... | Line 4207... | ||
4160 | 4207 | ||
4161 | private void btnWPEditmoveDown_Click(object sender, RoutedEventArgs e) |
4208 | private void btnWPEditmoveDown_Click(object sender, RoutedEventArgs e) |
Line 4178... | Line 4225... | ||
4178 | dtWaypoints.Rows[index][2] = dtWaypoints.Rows[index][2].ToString().Substring(0, 1) + (index+1).ToString(); |
4225 | dtWaypoints.Rows[index][2] = dtWaypoints.Rows[index][2].ToString().Substring(0, 1) + (index+1).ToString(); |
4179 | ((CustomMarkerWP)m2.Shape).text.Text = dtWaypoints.Rows[index][2].ToString(); |
4226 | ((CustomMarkerWP)m2.Shape).text.Text = dtWaypoints.Rows[index][2].ToString(); |
4180 | dgvWP.Items.Refresh(); |
4227 | dgvWP.Items.Refresh(); |
4181 | dgvWP.SelectedIndex = index + 1; |
4228 | dgvWP.SelectedIndex = index + 1; |
4182 | _dgvWPselectEditRow(); |
4229 | _dgvWPselectEditRow(); |
- | 4230 | if (((int)dtWaypoints.Rows[index][1] == 0 | (int)dtWaypoints.Rows[index][1] == 3) && ((int)dtWaypoints.Rows[index+1][1] == 0 | (int)dtWaypoints.Rows[index+1][1] == 3))// && wpList.Count > index) |
|
- | 4231 | { |
|
- | 4232 | PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]); |
|
4183 | PointLatLng p = wpList[index]; |
4233 | int wpListIndex = wpList.IndexOf(x); |
- | 4234 | if (wpListIndex > -1) |
|
- | 4235 | { |
|
4184 | wpList.RemoveAt(index); |
4236 | wpList.RemoveAt(wpListIndex); |
- | 4237 | if (wpList.Count > wpListIndex) |
|
4185 | wpList.Insert(index + 1, p); |
4238 | wpList.Insert(wpListIndex + 1, x); |
- | 4239 | else |
|
- | 4240 | wpList.Add(x); |
|
4186 | MainMap.Markers.Remove(mRouteWP); |
4241 | MainMap.Markers.Remove(mRouteWP); |
4187 | _routeUpdate(); |
4242 | _routeUpdate(); |
- | 4243 | } |
|
- | 4244 | } |
|
4188 | } |
4245 | } |
Line 4189... | Line 4246... | ||
4189 | 4246 | ||
Line 4190... | Line 4247... | ||
4190 | } |
4247 | } |