Rev 2333 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2333 | Rev 2335 | ||
---|---|---|---|
Line 695... | Line 695... | ||
695 | } |
695 | } |
696 | void clearHomePos() |
696 | void clearHomePos() |
697 | { |
697 | { |
698 | MainMap.Markers.Remove(home); |
698 | MainMap.Markers.Remove(home); |
699 | } |
699 | } |
- | 700 | void _clearMapMarkers(Type markerType) |
|
- | 701 | { |
|
- | 702 | for (int k = 0; k < MainMap.Markers.Count;) |
|
- | 703 | { |
|
- | 704 | GMapMarker p = MainMap.Markers[k]; |
|
- | 705 | if (p.GetType() == markerType | p.Shape.GetType() == markerType) |
|
- | 706 | MainMap.Markers.Remove(p); |
|
- | 707 | else |
|
- | 708 | k++; |
|
- | 709 | } |
|
- | 710 | ||
- | 711 | } |
|
Line 700... | Line 712... | ||
700 | 712 | ||
701 | // access mode |
713 | // access mode |
702 | private void comboBoxMode_DropDownClosed(object sender, EventArgs e) |
714 | private void comboBoxMode_DropDownClosed(object sender, EventArgs e) |
703 | { |
715 | { |
Line 1653... | Line 1665... | ||
1653 | Dispatcher.Invoke(() => stbSatFixLostAnim.Begin()); |
1665 | Dispatcher.Invoke(() => stbSatFixLostAnim.Begin()); |
1654 | _bAnimSatFixActive = true; |
1666 | _bAnimSatFixActive = true; |
1655 | } |
1667 | } |
1656 | if (_bVoiceSatFixPlay && !_bVoiceSatFixActive) |
1668 | if (_bVoiceSatFixPlay && !_bVoiceSatFixActive) |
1657 | { |
1669 | { |
1658 | Thread th = new Thread(() => _mediaPlayer("Voice\\CriticalBattery.mp3")); |
1670 | Thread th = new Thread(() => _mediaPlayer("Voice\\SatFixLost.mp3")); |
1659 | th.Start(); |
1671 | th.Start(); |
1660 | _bVoiceSatFixActive = true; |
1672 | _bVoiceSatFixActive = true; |
1661 | } |
1673 | } |
Line 1662... | Line 1674... | ||
1662 | 1674 | ||
Line 1837... | Line 1849... | ||
1837 | _setMarkerColor(wp, (int)dr[1]); |
1849 | _setMarkerColor(wp, (int)dr[1]); |
1838 | MainMap.Markers.Add(wp); |
1850 | MainMap.Markers.Add(wp); |
1839 | }); |
1851 | }); |
1840 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
1852 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
1841 | Dispatcher.Invoke(() => _iWPIndex = data[1]); |
1853 | Dispatcher.Invoke(() => _iWPIndex = data[1]); |
- | 1854 | if ((int)dr[1] == 0) |
|
1842 | wpList.Add(new PointLatLng((double)dr[3], (double)dr[4])); |
1855 | wpList.Add(new PointLatLng((double)dr[3], (double)dr[4])); |
1843 | if (data[1] == data[0]) |
1856 | if (data[1] == data[0]) |
1844 | { |
1857 | { |
1845 | _bGetWP = false; |
1858 | _bGetWP = false; |
1846 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
1859 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
Line 2084... | Line 2097... | ||
2084 | Log(LogMsgType.Error, "NOT CONNECTED!"); |
2097 | Log(LogMsgType.Error, "NOT CONNECTED!"); |
Line 2085... | Line 2098... | ||
2085 | 2098 | ||
2086 | } |
2099 | } |
2087 | void _getWP() |
2100 | void _getWP() |
- | 2101 | { |
|
2088 | { |
2102 | int iTimeout = 0; |
2089 | _bGetWPCount = true; |
2103 | _bGetWPCount = true; |
2090 | _getpWP(1); //get the itemscount of wp |
2104 | _getpWP(1); //get the itemscount of wp |
- | 2105 | while (_bGetWPCount & iTimeout < _iWPTimeout * 5) |
|
2091 | while (_bGetWPCount) |
2106 | { |
- | 2107 | Thread.Sleep(10); |
|
- | 2108 | iTimeout++; |
|
2092 | Thread.Sleep(100); |
2109 | } |
2093 | if (_iWPCount > 0) |
2110 | if (_iWPCount > 0 & !_bGetWPCount) |
2094 | _getWPList(); |
2111 | _getWPList(); |
2095 | } |
2112 | } |
2096 | void _getWPList() |
2113 | void _getWPList() |
2097 | { |
2114 | { |
Line 2108... | Line 2125... | ||
2108 | } |
2125 | } |
2109 | } |
2126 | } |
2110 | } |
2127 | } |
2111 | void _sendWPList() |
2128 | void _sendWPList() |
2112 | { |
2129 | { |
- | 2130 | int iTimeout = 0; |
|
2113 | if (serialPortCtrl.Port.IsOpen) |
2131 | if (serialPortCtrl.Port.IsOpen) |
2114 | { |
2132 | { |
2115 | byte[] bData = new byte[30]; |
2133 | byte[] bData = new byte[30]; |
2116 | for (int i = 0; i < 30; i++) |
2134 | for (int i = 0; i < 30; i++) |
2117 | bData[i] = 0; |
2135 | bData[i] = 0; |
2118 | Stream serialStream = serialPortCtrl.Port.BaseStream; |
2136 | Stream serialStream = serialPortCtrl.Port.BaseStream; |
2119 | byte[] bytes = FlightControllerMessage.CreateMessage('w', 2, bData); //delete all WP on Copter by sending 'invalid'(==0) at index 0 |
2137 | byte[] bytes = FlightControllerMessage.CreateMessage('w', 2, bData); //delete all WP on Copter by sending 'invalid'(==0) at index 0 |
2120 | serialStream.Write(bytes, 0, bytes.Length); |
2138 | serialStream.Write(bytes, 0, bytes.Length); |
Line 2121... | Line 2139... | ||
2121 | 2139 | ||
2122 | _iWPCount = -1; |
2140 | _iWPCount = -1; |
- | 2141 | while (_iWPCount == -1 & iTimeout < _iWPTimeout * 5) |
|
2123 | while (_iWPCount == -1) |
2142 | { |
- | 2143 | Thread.Sleep(10); |
|
- | 2144 | iTimeout++; |
|
2124 | Thread.Sleep(10); |
2145 | } |
- | 2146 | Dispatcher.Invoke(() => lblWPCount.Content = _iWPCount.ToString()); |
|
- | 2147 | if (_iWPCount > -1) |
|
Line 2125... | Line 2148... | ||
2125 | Dispatcher.Invoke(() => lblWPCount.Content = _iWPCount.ToString()); |
2148 | { |
2126 | 2149 | ||
2127 | int iVal; |
2150 | int iVal; |
2128 | double dVal; |
2151 | double dVal; |
Line 2186... | Line 2209... | ||
2186 | 2209 | ||
2187 | bytes = FlightControllerMessage.CreateMessage('w', 2, bData); |
2210 | bytes = FlightControllerMessage.CreateMessage('w', 2, bData); |
Line 2188... | Line 2211... | ||
2188 | serialStream.Write(bytes, 0, bytes.Length); |
2211 | serialStream.Write(bytes, 0, bytes.Length); |
2189 | 2212 | ||
- | 2213 | _iWPCount = -1; |
|
- | 2214 | iTimeout = 0; |
|
2190 | _iWPCount = -1; |
2215 | while (_iWPCount == -1 & iTimeout < _iWPTimeout * 5) |
- | 2216 | { |
|
- | 2217 | Thread.Sleep(10); |
|
- | 2218 | iTimeout++; |
|
- | 2219 | } |
|
- | 2220 | if (_iWPCount == -1) |
|
- | 2221 | { |
|
- | 2222 | Log(LogMsgType.Error, "Timeout while sending list!"); |
|
2191 | while (_iWPCount == -1) |
2223 | break; |
2192 | Thread.Sleep(10); |
2224 | } |
2193 | Dispatcher.Invoke(() => lblWPCount.Content = _iWPCount.ToString()); |
2225 | Dispatcher.Invoke(() => lblWPCount.Content = _iWPCount.ToString()); |
2194 | } |
2226 | } |
- | 2227 | } |
|
- | 2228 | else |
|
- | 2229 | Log(LogMsgType.Error, "Timeout while sending list!"); |
|
2195 | } |
2230 | } |
Line 2196... | Line 2231... | ||
2196 | else |
2231 | else |
Line 2197... | Line 2232... | ||
2197 | Log(LogMsgType.Error, "NOT CONNECTED!"); |
2232 | Log(LogMsgType.Error, "NOT CONNECTED!"); |
Line 2975... | Line 3010... | ||
2975 | } |
3010 | } |
2976 | private void btnLoadWPLFile_Click(object sender, RoutedEventArgs e) |
3011 | private void btnLoadWPLFile_Click(object sender, RoutedEventArgs e) |
2977 | { |
3012 | { |
2978 | _readWPLFile(); |
3013 | _readWPLFile(); |
2979 | } |
3014 | } |
- | 3015 | private void btnClearWPList_Click(object sender, RoutedEventArgs e) |
|
- | 3016 | { |
|
- | 3017 | _clearMapMarkers(typeof(CustomMarkerWP)); |
|
- | 3018 | wpList.Clear(); |
|
- | 3019 | if (mRouteWP != null) |
|
- | 3020 | MainMap.Markers.Remove(mRouteWP); |
|
- | 3021 | dtWaypoints.Rows.Clear(); |
|
- | 3022 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
|
- | 3023 | Dispatcher.Invoke(() => lblWPIndex.Content = 0); |
|
- | 3024 | Dispatcher.Invoke(() => lblWPCount.Content = 0); |
|
- | 3025 | Dispatcher.Invoke(() => lblWPRouteDistance.Content = "0 m"); |
|
- | 3026 | } |
|
2980 | #endregion WP |
3027 | #endregion WP |
- | 3028 | ||
2981 | #region GPX |
3029 | #region GPX |
2982 | private void checkBoxGPXLog_Click(object sender, RoutedEventArgs e) |
3030 | private void checkBoxGPXLog_Click(object sender, RoutedEventArgs e) |
2983 | { |
3031 | { |
2984 | _bGPXLog = (bool)checkBoxGPXLog.IsChecked; |
3032 | _bGPXLog = (bool)checkBoxGPXLog.IsChecked; |
2985 | } |
3033 | } |
Line 3054... | Line 3102... | ||
3054 | 3102 | ||
3055 | private void btnClearRoute_Click(object sender, RoutedEventArgs e) |
3103 | private void btnClearRoute_Click(object sender, RoutedEventArgs e) |
3056 | { |
3104 | { |
3057 | _clearMapMarkers(typeof(GMapRoute)); |
3105 | _clearMapMarkers(typeof(GMapRoute)); |
3058 | } |
- | |
3059 | void _clearMapMarkers(Type markerType) |
- | |
3060 | { |
- | |
3061 | for (int k = 0; k < MainMap.Markers.Count;) |
- | |
3062 | { |
- | |
3063 | GMapMarker p = MainMap.Markers[k]; |
- | |
3064 | if (p.GetType() == markerType | p.Shape.GetType() == markerType) |
- | |
3065 | MainMap.Markers.Remove(p); |
- | |
3066 | else |
- | |
3067 | k++; |
- | |
Line 3068... | Line -... | ||
3068 | } |
- | |
3069 | 3106 | } |
|
3070 | } |
3107 | |
Line 3071... | Line 3108... | ||
3071 | void _loadGPXLog() |
3108 | void _loadGPXLog() |
3072 | { |
3109 | { |