Rev 2355 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2355 | Rev 2356 | ||
---|---|---|---|
Line 1695... | Line 1695... | ||
1695 | _bSatFix = false; |
1695 | _bSatFix = false; |
1696 | } |
1696 | } |
1697 | } |
1697 | } |
1698 | } |
1698 | } |
Line 1699... | Line -... | ||
1699 | - | ||
1700 | // lblNCGPSLat.Invoke((Action)(() => lblNCGPSLat.Text = d.ToString("0.######°"))); //GPS-Position: Latitude in decimal degree |
- | |
1701 | //lblNCGPSLat.Invoke((Action)(() => lblNCGPSLat.Text = _convertDegree(d))); //GPS-Position: Latitude in minutes, seconds |
- | |
1702 | 1699 | ||
1703 | i_16 = data[28]; |
1700 | i_16 = data[28]; |
1704 | i_16 = (Int16)(i_16 << 8); |
1701 | i_16 = (Int16)(i_16 << 8); |
1705 | iVal = data[27] + i_16; |
1702 | iVal = data[27] + i_16; |
Line 1754... | Line 1751... | ||
1754 | }); |
1751 | }); |
Line 1755... | Line 1752... | ||
1755 | 1752 | ||
1756 | } |
1753 | } |
Line 1757... | Line -... | ||
1757 | } |
- | |
1758 | - | ||
1759 | if(wpList.Count > 0 && ((data[67] & 2) == 2)) |
- | |
1760 | { |
- | |
1761 | //if (_wpIndex > -1) |
- | |
1762 | //{ |
- | |
1763 | // row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex); |
- | |
1764 | // row.Background = new SolidColorBrush(Colors.Transparent); |
- | |
1765 | // row.BorderBrush = new SolidColorBrush(Colors.Transparent); |
- | |
1766 | // row.BorderThickness = new Thickness(0); |
- | |
1767 | //} |
- | |
1768 | //_wpIndex = dgvWP.SelectedIndex; |
- | |
1769 | //row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex); |
- | |
1770 | //row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 100, 255)); |
- | |
1771 | //row.BorderBrush = new SolidColorBrush(Colors.Aqua); |
- | |
1772 | //row.BorderThickness = new Thickness(2); |
- | |
1773 | //dgvWP.UpdateLayout(); |
- | |
1774 | - | ||
1775 | - | ||
1776 | // Dispatcher.Invoke(() => |
- | |
1777 | // { |
- | |
1778 | // if(data[48] < wpList.Count) |
- | |
1779 | // { |
- | |
1780 | // DataGridRow row; |
- | |
1781 | // if (data[48] > 0) |
- | |
1782 | // { |
- | |
1783 | // row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(data[48] - 1); |
- | |
1784 | // row.Background = new SolidColorBrush(Colors.Transparent); |
- | |
1785 | // } |
- | |
1786 | // row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(data[48]); |
- | |
1787 | // row.Background = new SolidColorBrush(Color.FromArgb(50, 0, 100, 255)); |
- | |
1788 | // } |
- | |
1789 | // }); |
1754 | } |
1790 | } |
1755 | |
1791 | Dispatcher.Invoke((Action)(() => tbWPCount.Text = data[49].ToString())); //Waypoints count |
1756 | Dispatcher.Invoke((Action)(() => tbWPCount.Text = data[49].ToString())); //Waypoints count |
1792 | Dispatcher.Invoke((Action)(() => lblWPCountNC.Content = data[49].ToString())); //Waypoints count |
1757 | Dispatcher.Invoke((Action)(() => lblWPCountNC.Content = data[49].ToString())); //Waypoints count |
Line 1915... | Line 1880... | ||
1915 | Dispatcher.Invoke(() => lblWPCount.Content = data[0].ToString()); |
1880 | Dispatcher.Invoke(() => lblWPCount.Content = data[0].ToString()); |
1916 | if (_bGetWP) |
1881 | if (_bGetWP) |
1917 | { |
1882 | { |
1918 | if (data[1] == 1) |
1883 | if (data[1] == 1) |
1919 | { |
1884 | { |
1920 | if(mRouteWP != null) |
- | |
1921 | Dispatcher.Invoke(() => MainMap.Markers.Remove(mRouteWP)); |
- | |
1922 | wpList.Clear(); |
- | |
1923 | - | ||
1924 | Dispatcher.Invoke(() => lblWPRouteDistance.Content = "0 m"); |
- | |
1925 | dtWaypoints.Rows.Clear(); |
- | |
1926 | Dispatcher.Invoke(() => |
1885 | Dispatcher.Invoke(() => |
1927 | { |
1886 | { |
- | 1887 | wpList.Clear(); |
|
1928 | for (int k = 0; k < MainMap.Markers.Count;) |
1888 | _clearMapMarkers(typeof(CustomMarkerWP)); |
1929 | { |
1889 | if (mRouteWP != null) |
1930 | GMapMarker p = MainMap.Markers[k]; |
1890 | MainMap.Markers.Remove(mRouteWP); |
1931 | if (p.Shape.GetType() == typeof(CustomMarkerWP)) |
1891 | if (wpActiveMarker != null) |
1932 | MainMap.Markers.Remove(p); |
1892 | MainMap.Markers.Remove(wpActiveMarker); |
1933 | else |
1893 | lblWPRouteDistance.Content = "0 m"; |
1934 | k++; |
1894 | dtWaypoints.Rows.Clear(); |
1935 | } |
1895 | _wpEdit = -1; |
1936 | }); |
1896 | }); |
1937 | } |
1897 | } |
1938 | DataRow dr = dtWaypoints.NewRow(); |
1898 | DataRow dr = dtWaypoints.NewRow(); |
1939 | dr = Waypoints.toDataRow(data, dr); |
1899 | dr = Waypoints.toDataRow(data, dr); |
1940 | dtWaypoints.Rows.Add(dr); |
1900 | dtWaypoints.Rows.Add(dr); |
Line 2262... | Line 2222... | ||
2262 | { |
2222 | { |
2263 | if (_clearCopterWPList()) |
2223 | if (_clearCopterWPList()) |
2264 | { |
2224 | { |
2265 | for (int i = 0; i < dtWaypoints.Rows.Count; i++) |
2225 | for (int i = 0; i < dtWaypoints.Rows.Count; i++) |
2266 | { |
2226 | { |
2267 | _sendWayPoint(dtWaypoints.Rows[i],-1); |
2227 | _sendWayPoint(dtWaypoints.Rows[i],-1,'w'); |
Line 2268... | Line 2228... | ||
2268 | 2228 | ||
2269 | _iWPCount = -1; |
2229 | _iWPCount = -1; |
2270 | iTimeout = 0; |
2230 | iTimeout = 0; |
2271 | while (_iWPCount == -1 & iTimeout < _iWPTimeout * 5) |
2231 | while (_iWPCount == -1 & iTimeout < _iWPTimeout * 5) |
Line 2284... | Line 2244... | ||
2284 | } |
2244 | } |
2285 | else |
2245 | else |
2286 | Log(LogMsgType.Error, "NOT CONNECTED!"); |
2246 | Log(LogMsgType.Error, "NOT CONNECTED!"); |
Line 2287... | Line 2247... | ||
2287 | 2247 | ||
2288 | } |
2248 | } |
2289 | bool _sendWayPoint(DataRow dr, int index) |
2249 | bool _sendWayPoint(DataRow dr, int index, char command) |
Line 2290... | Line 2250... | ||
2290 | { |
2250 | { |
2291 | 2251 | ||
2292 | if (serialPortCtrl.Port.IsOpen) |
2252 | if (serialPortCtrl.Port.IsOpen) |
Line 2353... | Line 2313... | ||
2353 | bData[26] = name.Length > 2 ? name[2] : (byte)0; |
2313 | bData[26] = name.Length > 2 ? name[2] : (byte)0; |
2354 | bData[27] = name.Length > 3 ? name[3] : (byte)0; |
2314 | bData[27] = name.Length > 3 ? name[3] : (byte)0; |
2355 | //Autotrigger |
2315 | //Autotrigger |
2356 | bData[28] = Convert.ToByte(dr[11]); |
2316 | bData[28] = Convert.ToByte(dr[11]); |
Line 2357... | Line 2317... | ||
2357 | 2317 | ||
2358 | bytes = FlightControllerMessage.CreateMessage('w', 2, bData); |
2318 | bytes = FlightControllerMessage.CreateMessage(command, 2, bData); |
Line 2359... | Line 2319... | ||
2359 | serialStream.Write(bytes, 0, bytes.Length); |
2319 | serialStream.Write(bytes, 0, bytes.Length); |
2360 | 2320 | ||
Line 3198... | Line 3158... | ||
3198 | string wp; |
3158 | string wp; |
3199 | int i; |
3159 | int i; |
3200 | NumberFormatInfo nfi = new NumberFormatInfo(); |
3160 | NumberFormatInfo nfi = new NumberFormatInfo(); |
3201 | nfi.NumberDecimalSeparator = "."; |
3161 | nfi.NumberDecimalSeparator = "."; |
3202 | dtWaypoints.Rows.Clear(); |
3162 | dtWaypoints.Rows.Clear(); |
3203 | //for(int k = 0; k < MainMap.Markers.Count;) |
- | |
3204 | //{ |
- | |
3205 | // GMapMarker p = MainMap.Markers[k]; |
- | |
3206 | // if (p.Shape.GetType() == typeof(CustomMarkerWP)) |
- | |
3207 | // MainMap.Markers.Remove(p); |
- | |
3208 | // else |
- | |
3209 | // k++; |
3163 | _wpEdit = -1; |
3210 | //} |
- | |
3211 | _clearMapMarkers(typeof(CustomMarkerWP)); |
3164 | _clearMapMarkers(typeof(CustomMarkerWP)); |
3212 | wpList.Clear(); |
3165 | wpList.Clear(); |
3213 | if (mRouteWP != null) |
3166 | if (mRouteWP != null) |
3214 | MainMap.Markers.Remove(mRouteWP); |
3167 | MainMap.Markers.Remove(mRouteWP); |
3215 | if (wpActiveMarker != null) |
3168 | if (wpActiveMarker != null) |
Line 3555... | Line 3508... | ||
3555 | if (mRouteWP != null) |
3508 | if (mRouteWP != null) |
3556 | MainMap.Markers.Remove(mRouteWP); |
3509 | MainMap.Markers.Remove(mRouteWP); |
3557 | //if (wpActiveMarker != null) |
3510 | //if (wpActiveMarker != null) |
3558 | // MainMap.Markers.Remove(wpActiveMarker); |
3511 | // MainMap.Markers.Remove(wpActiveMarker); |
3559 | dtWaypoints.Rows.Clear(); |
3512 | dtWaypoints.Rows.Clear(); |
- | 3513 | _wpEdit = -1; |
|
3560 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
3514 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
3561 | Dispatcher.Invoke(() => lblWPIndex.Content = 0); |
3515 | Dispatcher.Invoke(() => lblWPIndex.Content = 0); |
3562 | Dispatcher.Invoke(() => lblWPCount.Content = 0); |
3516 | Dispatcher.Invoke(() => lblWPCount.Content = 0); |
3563 | Dispatcher.Invoke(() => lblWPRouteDistance.Content = "0 m"); |
3517 | Dispatcher.Invoke(() => lblWPRouteDistance.Content = "0 m"); |
3564 | } |
3518 | } |
Line 3570... | Line 3524... | ||
3570 | private void btnSendActiveWP_Click(object sender, RoutedEventArgs e) |
3524 | private void btnSendActiveWP_Click(object sender, RoutedEventArgs e) |
3571 | { |
3525 | { |
3572 | if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count) |
3526 | if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count) |
3573 | { |
3527 | { |
3574 | if (_wpCount > 0) |
3528 | if (_wpCount > 0) |
3575 | _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], -1); |
3529 | _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], -1,'s'); |
3576 | else |
3530 | else |
3577 | _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], 1); |
3531 | _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], 1,'s'); |
Line 3578... | Line 3532... | ||
3578 | 3532 | ||
3579 | Dispatcher.Invoke(() => { |
3533 | Dispatcher.Invoke(() => { |
- | 3534 | DataGridRow row; |
|
- | 3535 | if (_wpIndex > -1 && _wpIndex < dgvWP.ItemContainerGenerator.Items.Count) |
|
- | 3536 | { |
|
- | 3537 | row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex); |
|
- | 3538 | row.Background = new SolidColorBrush(Colors.Transparent); |
|
- | 3539 | row.BorderBrush = new SolidColorBrush(Colors.Transparent); |
|
- | 3540 | row.BorderThickness = new Thickness(0); |
|
- | 3541 | } |
|
- | 3542 | _wpIndex = dgvWP.SelectedIndex; |
|
- | 3543 | row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex); |
|
- | 3544 | row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 100, 255)); |
|
- | 3545 | row.BorderBrush = new SolidColorBrush(Colors.Aqua); |
|
- | 3546 | row.BorderThickness = new Thickness(2); |
|
- | 3547 | dgvWP.UpdateLayout(); |
|
- | 3548 | }); |
|
- | 3549 | } |
|
- | 3550 | } |
|
- | 3551 | private void btnSendActiveWP2_Click(object sender, RoutedEventArgs e) |
|
- | 3552 | { |
|
- | 3553 | if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count) |
|
3580 | DataGridRow row; |
3554 | { |
- | 3555 | if (_wpCount > 0) |
|
- | 3556 | _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], _wpCount,'s'); |
|
- | 3557 | else |
|
- | 3558 | _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], 1,'s'); |
|
- | 3559 | ||
- | 3560 | Dispatcher.Invoke(() => { |
|
- | 3561 | DataGridRow row; |
|
3581 | if (_wpIndex > -1) |
3562 | if (_wpIndex > -1 && _wpIndex < dgvWP.ItemContainerGenerator.Items.Count) |
3582 | { |
3563 | { |
3583 | row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex); |
3564 | row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex); |
3584 | row.Background = new SolidColorBrush(Colors.Transparent); |
3565 | row.Background = new SolidColorBrush(Colors.Transparent); |
3585 | row.BorderBrush = new SolidColorBrush(Colors.Transparent); |
3566 | row.BorderBrush = new SolidColorBrush(Colors.Transparent); |
Line 3708... | Line 3689... | ||
3708 | iVal = Convert.ToInt16(dtWaypoints.Rows[index][14]); |
3689 | iVal = Convert.ToInt16(dtWaypoints.Rows[index][14]); |
3709 | tbWPEditOut1.Text = iVal.ToString(); |
3690 | tbWPEditOut1.Text = iVal.ToString(); |
Line 3710... | Line 3691... | ||
3710 | 3691 | ||
Line -... | Line 3692... | ||
- | 3692 | } |
|
- | 3693 | ||
- | 3694 | private void tbWPEditHeading_KeyDown(object sender, KeyEventArgs e) |
|
- | 3695 | { |
|
- | 3696 | if(!tbWPEditHeading.IsReadOnly) |
|
- | 3697 | { |
|
- | 3698 | //var x = KeyInterop.VirtualKeyFromKey(e.Key); |
|
- | 3699 | KeyConverter x = new KeyConverter(); |
|
- | 3700 | string s = x.ConvertToString(e.Key); |
|
- | 3701 | ||
- | 3702 | if ("1234567890,\b".IndexOf(s) < 0) //general check for valid chars(0-9) and backspace (\b) |
|
- | 3703 | e.Handled = true; |
|
- | 3704 | else |
|
- | 3705 | if ("\b".IndexOf(s) < 0) |
|
- | 3706 | if (Convert.ToInt16(((TextBox)sender).Text + s) > 360) //if valid and not backspace, check for upper limit of the resulting number |
|
- | 3707 | e.Handled = true; |
|
- | 3708 | ||
- | 3709 | } |
|
- | 3710 | } |
|
- | 3711 | private void btnWPEditAddCurrentPos_Click(object sender, RoutedEventArgs e) |
|
- | 3712 | { |
|
- | 3713 | cbWPEditType.SelectedIndex = dgvWP.ItemContainerGenerator.Items.Count; |
|
- | 3714 | tbWPEditPrefix.Text = "P"; |
|
- | 3715 | tbWPEditLat.Text = copter.Position.Lat.ToString(); |
|
- | 3716 | tbWPEditLon.Text = copter.Position.Lng.ToString(); |
|
- | 3717 | tbWPEditAlt.Text = ((double)iAnalogData[4] / (double)10).ToString(); |
|
- | 3718 | ||
- | 3719 | cbWPEditHeading.SelectedIndex = 2; |
|
- | 3720 | tbWPEditHeading.Text = iAnalogData[10].ToString(); |
|
- | 3721 | tbWPEditHeading.IsReadOnly = false; |
|
- | 3722 | ||
- | 3723 | cbWPEditSpeed.SelectedIndex = 1; |
|
- | 3724 | tbWPEditSpeed.Text = "5.0"; |
|
- | 3725 | tbWPEditSpeed.IsReadOnly = false; |
|
- | 3726 | ||
- | 3727 | cbWPEditClimbrate.SelectedIndex = 1; |
|
- | 3728 | tbWPEditClimbrate.Text = "5.0"; |
|
- | 3729 | tbWPEditClimbrate.IsReadOnly = false; |
|
- | 3730 | ||
- | 3731 | tbWPEditRadius.Text = "10"; |
|
- | 3732 | tbWPEditHoldtime.Text = "5"; |
|
- | 3733 | tbWPEditAutoTrigger.Text = "0"; |
|
- | 3734 | ||
- | 3735 | cbWPEditCamAngle.SelectedIndex = 1; |
|
- | 3736 | tbWPEditCamAngle.Text = "AUTO"; |
|
- | 3737 | tbWPEditCamAngle.IsReadOnly = true; |
|
- | 3738 | ||
- | 3739 | tbWPEditOut1.Text = "0"; |
|
3711 | } |
3740 | } |
3712 | 3741 | ||
3713 | #endregion WP |
3742 | #endregion WP |
3714 | #region GPX |
3743 | #region GPX |
3715 | private void checkBoxGPXLog_Click(object sender, RoutedEventArgs e) |
3744 | private void checkBoxGPXLog_Click(object sender, RoutedEventArgs e) |
Line 3777... | Line 3806... | ||
3777 | { |
3806 | { |
3778 | myXmlTextWriter.Close(); |
3807 | myXmlTextWriter.Close(); |
3779 | } |
3808 | } |
3780 | } |
3809 | } |
3781 | } |
3810 | } |
- | 3811 | ||
- | 3812 | ||
3782 | private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
3813 | private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
3783 | { |
3814 | { |
3784 | _loadGPXLog(); |
3815 | _loadGPXLog(); |
3785 | } |
3816 | } |
3786 | private void btnClearRoute_Click(object sender, RoutedEventArgs e) |
3817 | private void btnClearRoute_Click(object sender, RoutedEventArgs e) |