Rev 2425 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2425 | Rev 2428 | ||
---|---|---|---|
Line 1455... | Line 1455... | ||
1455 | case 'M'://License info |
1455 | case 'M'://License info |
1456 | _processLicense(data); |
1456 | _processLicense(data); |
1457 | break; |
1457 | break; |
Line 1458... | Line 1458... | ||
1458 | 1458 | ||
- | 1459 | case 'O': //NC Data |
|
1459 | case 'O': //NC Data |
1460 | if (data[0] < 10) |
- | 1461 | _processNCData(data); |
|
- | 1462 | else |
|
1460 | _processNCData(data); |
1463 | _processNCDataV2(data); |
Line 1461... | Line 1464... | ||
1461 | break; |
1464 | break; |
1462 | 1465 | ||
1463 | //case 'E': //NC error-string |
1466 | //case 'E': //NC error-string |
Line 1815... | Line 1818... | ||
1815 | /// <summary> |
1818 | /// <summary> |
1816 | /// Navi-Ctrl data 'O' |
1819 | /// Navi-Ctrl data 'O' |
1817 | /// GPS-Position, capacatiy, flying time... |
1820 | /// GPS-Position, capacatiy, flying time... |
1818 | /// </summary> |
1821 | /// </summary> |
1819 | /// <param name="data">the received byte array to process</param> |
1822 | /// <param name="data">the received byte array to process</param> |
- | 1823 | ||
- | 1824 | ||
- | 1825 | byte OSD_FLAG_MASK1 = 0x04 + 0x20 + 0x40 + 0x80; |
|
- | 1826 | byte OSD_FLAG_MASK2 = 0x01 + 0x02 + 0x08 + 0x10; |
|
- | 1827 | int FCSTATUSFLAGS1 = 0; |
|
- | 1828 | int FCSTATUSFLAGS2 = 0; |
|
- | 1829 | byte OSDSTATUSFLAGS1 = 0; |
|
- | 1830 | byte OSDSTATUSFLAGS2 = 0; |
|
- | 1831 | void _processNCDataV2(byte[] data) |
|
- | 1832 | { |
|
- | 1833 | int i_32, i_16, iVal; |
|
- | 1834 | double d; |
|
- | 1835 | OSD_Base_Data_t osd = new OSD_Base_Data_t(data); |
|
- | 1836 | OSDSTATUSFLAGS1 = osd.OSDSTATUSFLAGS1(); |
|
- | 1837 | FCSTATUSFLAGS1 = (OSDSTATUSFLAGS1 & OSD_FLAG_MASK1) | (OSDSTATUSFLAGS2 & ~OSD_FLAG_MASK1); |
|
- | 1838 | FCSTATUSFLAGS2 = (OSDSTATUSFLAGS1 & OSD_FLAG_MASK2) | (OSDSTATUSFLAGS2 & ~OSD_FLAG_MASK2); |
|
- | 1839 | Dispatcher.Invoke(() => { drGPX[2] = osd.Pos().Lng; }); |
|
- | 1840 | Dispatcher.Invoke(() => { drGPX[1] = osd.Pos().Lat; }); |
|
- | 1841 | Dispatcher.Invoke(() => { drGPX[4] = DateTime.UtcNow.ToString("u", System.Globalization.CultureInfo.InvariantCulture); }); //2011-01-14T01:59:01Z }); |
|
- | 1842 | Dispatcher.Invoke((Action)(() => tbNCGrSpeed.Text = osd.Speed().ToString("0.0 m/s"))); |
|
- | 1843 | if (_Simulate) |
|
- | 1844 | Dispatcher.Invoke((Action)(() => tbTopSpeed.Text = osd.Speed().ToString("0.0 m/s"))); |
|
- | 1845 | ||
- | 1846 | switch ((int)data[0]) |
|
- | 1847 | { |
|
- | 1848 | case 10: |
|
- | 1849 | break; |
|
- | 1850 | case 11: |
|
- | 1851 | //---------------NC-Flags-------------------------- |
|
- | 1852 | Dispatcher.Invoke((Action)(() => NC1_2.Background = ((data[14] & 2) == 2) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// NC_FLAG_PH 0x02 |
|
- | 1853 | Dispatcher.Invoke((Action)(() => NC1_3.Background = ((data[14] & 4) == 4) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// NC_FLAG_CH 0x04 |
|
- | 1854 | Dispatcher.Invoke((Action)(() => NC1_4.Background = ((data[14] & 8) == 8) ? new SolidColorBrush(Colors.LightCoral) : new SolidColorBrush(Colors.Transparent)));// NC_FLAG_RANGE_LIMIT 0x08 |
|
- | 1855 | Dispatcher.Invoke((Action)(() => NC1_5.Background = ((data[14] & 16) == 16) ? new SolidColorBrush(Colors.LightCoral) : new SolidColorBrush(Colors.Transparent)));// NC_FLAG_NOSERIALLINK 0x10 |
|
- | 1856 | Dispatcher.Invoke((Action)(() => NC1_6.Background = ((data[14] & 32) == 32) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// NC_FLAG_TARGET_REACHED 0x20 |
|
- | 1857 | Dispatcher.Invoke((Action)(() => NC1_7.Background = ((data[14] & 64) == 64) ? new SolidColorBrush(Colors.DodgerBlue) : new SolidColorBrush(Colors.Transparent)));// NC_FLAG_MANUAL_CONTROL 0x40 |
|
- | 1858 | Dispatcher.Invoke((Action)(() => NC1_8.Background = ((data[14] & 128) == 128) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// NC_FLAG_GPS_OK 0x80 |
|
- | 1859 | ||
- | 1860 | Dispatcher.Invoke((Action)(() => tbSideBarStatusPH.Text = ((data[14] & 4) == 4) ? "CH" : "PH"));// NC_FLAG_PH 0x02 / NC_FLAG_CH 0x04 |
|
- | 1861 | Dispatcher.Invoke((Action)(() => tbSideBarStatusPH.Background = (((data[14] & 2) == 2) | ((data[14] & 4) == 4)) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// NC_FLAG_PH 0x02 / NC_FLAG_CH 0x04 |
|
- | 1862 | Dispatcher.Invoke((Action)(() => tbSideBarStatusPH.Foreground = (((data[14] & 2) == 2) | ((data[14] & 4) == 4)) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Color.FromArgb(255, 211, 210, 210))));// NC_FLAG_PH 0x02 / NC_FLAG_CH 0x04 |
|
- | 1863 | Dispatcher.Invoke((Action)(() => tbSideBarStatusPH.BorderBrush = (((data[14] & 2) == 2) | ((data[14] & 4) == 4)) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Color.FromArgb(255, 211, 210, 210))));// NC_FLAG_PH 0x02 / NC_FLAG_CH 0x04 |
|
- | 1864 | ||
- | 1865 | //--------------- NC Error ------------------------ |
|
- | 1866 | Dispatcher.Invoke((Action)(() => tbNCErr.Text = data[16].ToString())); //NC Errornumber |
|
- | 1867 | if (data[16] > 0) |
|
- | 1868 | _readNCError(); |
|
- | 1869 | if (data[16] > 0 & data[16] < 44) |
|
- | 1870 | ErrorLog(LogMsgType.Error, " NC Error [" + data[16].ToString() + "]: ", NC_Error_Link[data[16]], NC_Error[data[16]]); |
|
- | 1871 | ||
- | 1872 | break; |
|
- | 1873 | case 12: |
|
- | 1874 | //--------------- RC quality ------------------------ |
|
- | 1875 | Dispatcher.Invoke((Action)(() => tbRCQ.Text = data[23].ToString())); |
|
- | 1876 | Dispatcher.Invoke((Action)(() => tbTopRC.Text = data[23].ToString())); |
|
- | 1877 | ||
- | 1878 | if (data[23] > _iThresholdRC) |
|
- | 1879 | { |
|
- | 1880 | _iRCLevelJitter = 0; _bVoiceRCLevelActive = false; |
|
- | 1881 | if (stbRCLevelAnim != null && _bAnimRCLevelActive) |
|
- | 1882 | { |
|
- | 1883 | Dispatcher.Invoke(() => stbRCLevelAnim.Stop()); |
|
- | 1884 | _bAnimRCLevelActive = false; |
|
- | 1885 | } |
|
- | 1886 | } |
|
- | 1887 | else |
|
- | 1888 | { |
|
- | 1889 | if (_iRCLevelJitter < 20) _iRCLevelJitter++; |
|
- | 1890 | if (_iRCLevelJitter == 20) |
|
- | 1891 | { |
|
- | 1892 | if (stbRCLevelAnim != null && !_bAnimRCLevelActive) |
|
- | 1893 | { |
|
- | 1894 | Dispatcher.Invoke(() => stbRCLevelAnim.Begin()); |
|
- | 1895 | _bAnimRCLevelActive = true; |
|
- | 1896 | } |
|
- | 1897 | if (_bVoiceRCLevelPlay && !_bVoiceRCLevelActive) |
|
- | 1898 | { |
|
- | 1899 | _bVoiceRCLevelActive = true; |
|
- | 1900 | ThreadPool.QueueUserWorkItem(new WaitCallback(_mediaPlayer), "Voice\\MagneticField.mp3"); |
|
- | 1901 | //Thread th = new Thread(() => _mediaPlayer("Voice\\RCLevel.mp3")); |
|
- | 1902 | //th.Start(); |
|
- | 1903 | } |
|
- | 1904 | _iRCLevelJitter++; |
|
- | 1905 | } |
|
- | 1906 | } |
|
- | 1907 | break; |
|
- | 1908 | case 13: |
|
- | 1909 | //-------------------------Waypoint max range (by license)------------------------------ |
|
- | 1910 | i_32 = data[24]; |
|
- | 1911 | iVal = i_32 << 8; |
|
- | 1912 | iVal += data[23]; |
|
- | 1913 | ||
- | 1914 | if (dWPMaxRange != iVal) |
|
- | 1915 | { |
|
- | 1916 | dWPMaxRange = iVal; |
|
- | 1917 | if (home != null && checkBoxShowWPMaxRange.IsChecked == true) |
|
- | 1918 | { |
|
- | 1919 | if (cWPBound != null && cWPBound.Tag != null) |
|
- | 1920 | MainMap.Markers.Remove(cWPBound.Tag as GMapMarker); |
|
- | 1921 | ||
- | 1922 | createCircle(home.Position, dWPMaxRange); |
|
- | 1923 | Dispatcher.Invoke(() => |
|
- | 1924 | { |
|
- | 1925 | if (comboBoxWPMaxRangeColor.SelectionBoxItem != null) |
|
- | 1926 | { |
|
- | 1927 | string s = comboBoxWPMaxRangeColor.SelectionBoxItem.ToString(); |
|
- | 1928 | cWPBound.setColor(s); |
|
- | 1929 | } |
|
- | 1930 | }); |
|
- | 1931 | } |
|
- | 1932 | Dispatcher.Invoke((Action)(() => tbWPMaxRange.Text = iVal.ToString() + " m")); |
|
- | 1933 | } |
|
- | 1934 | ||
- | 1935 | OSDSTATUSFLAGS2 = osd.OSDSTATUSFLAGS2(); |
|
- | 1936 | FCSTATUSFLAGS1 = (OSDSTATUSFLAGS1 & OSD_FLAG_MASK1) | (OSDSTATUSFLAGS2 & ~OSD_FLAG_MASK1); |
|
- | 1937 | FCSTATUSFLAGS2 = (OSDSTATUSFLAGS1 & OSD_FLAG_MASK2) | (OSDSTATUSFLAGS2 & ~OSD_FLAG_MASK2); |
|
- | 1938 | break; |
|
- | 1939 | ||
- | 1940 | case 14: |
|
- | 1941 | //--------------- Flying time ------------------------ |
|
- | 1942 | i_16 = data[14]; |
|
- | 1943 | i_16 = (Int16)(i_16 << 8); |
|
- | 1944 | iVal = data[13] + i_16; |
|
- | 1945 | TimeSpan t = TimeSpan.FromSeconds(iVal); |
|
- | 1946 | string Text = t.Hours.ToString("D2") + ":" + t.Minutes.ToString("D2") + ":" + t.Seconds.ToString("D2"); |
|
- | 1947 | Dispatcher.Invoke((Action)(() => tbFTime.Text = Text.ToString())); |
|
- | 1948 | Dispatcher.Invoke((Action)(() => tbTopFTime.Text = Text.ToString())); |
|
- | 1949 | ||
- | 1950 | //--------------------------------Distance HP------------------------------------ |
|
- | 1951 | i_16 = data[16]; |
|
- | 1952 | i_16 = (Int16)(i_16 << 8); |
|
- | 1953 | iVal = data[15] + i_16; |
|
- | 1954 | Dispatcher.Invoke((Action)(() => tbHP.Text = ((double)iVal / (double)10).ToString("0.0 m"))); |
|
- | 1955 | ||
- | 1956 | //--------------------------Distance to next WP-------------------------------- |
|
- | 1957 | i_16 = data[19]; |
|
- | 1958 | i_16 = (Int16)(i_16 << 8); |
|
- | 1959 | iVal = data[18] + i_16; |
|
- | 1960 | Dispatcher.Invoke((Action)(() => tbWP.Text = ((double)iVal / (double)10).ToString("0.0 m"))); |
|
- | 1961 | Dispatcher.Invoke((Action)(() => lblWPRouteDistanceWP.Content = ((double)iVal / (double)10).ToString("0.0 m"))); |
|
- | 1962 | Dispatcher.Invoke((Action)(() => tbWPStatusDistanceWP.Text = ((double)iVal / (double)10).ToString("0.0 m"))); |
|
- | 1963 | ||
- | 1964 | //-------------------Satellites---------------------------------- |
|
- | 1965 | Dispatcher.Invoke((Action)(() => tbTopSats.Text = data[23].ToString())); |
|
- | 1966 | ||
- | 1967 | if (data[23] > 4)//if more than 4 sats in use . otherwise the map would jump and scroll insane at beginning |
|
- | 1968 | { |
|
- | 1969 | _bSatFix = true; _iSatsJitter = 0; _bVoiceSatFixActive = false; |
|
- | 1970 | if (_bAutoHome && !_bFirstSatFix) |
|
- | 1971 | { |
|
- | 1972 | if (_iFirstSatFix < 3) |
|
- | 1973 | _iFirstSatFix++; |
|
- | 1974 | else |
|
- | 1975 | { |
|
- | 1976 | _bFirstSatFix = true; |
|
- | 1977 | Dispatcher.Invoke(() => _setHomePos()); |
|
- | 1978 | } |
|
- | 1979 | } |
|
- | 1980 | if (stbSatFixLostAnim != null && _bAnimSatFixActive) |
|
- | 1981 | { |
|
- | 1982 | Dispatcher.Invoke(() => stbSatFixLostAnim.Stop()); |
|
- | 1983 | _bAnimSatFixActive = false; |
|
- | 1984 | } |
|
- | 1985 | if (!_bFollowCopter) |
|
- | 1986 | { |
|
- | 1987 | _setCopterData(osd.Pos()); |
|
- | 1988 | if (!MainMap.ViewArea.Contains(osd.Pos())) |
|
- | 1989 | Dispatcher.Invoke(() => MainMap.Position = osd.Pos()); |
|
- | 1990 | ||
- | 1991 | } |
|
- | 1992 | else |
|
- | 1993 | Dispatcher.Invoke(() => MainMap.Position = osd.Pos()); |
|
- | 1994 | } |
|
- | 1995 | else |
|
- | 1996 | { |
|
- | 1997 | if (_bSatFix) |
|
- | 1998 | { |
|
- | 1999 | if (data[23] == _iSatsLast) |
|
- | 2000 | { |
|
- | 2001 | if (_iSatsJitter < 20) _iSatsJitter++; |
|
- | 2002 | } |
|
- | 2003 | else |
|
- | 2004 | { |
|
- | 2005 | _iSatsJitter = 0; |
|
- | 2006 | _iSatsLast = data[23]; |
|
- | 2007 | } |
|
- | 2008 | ||
- | 2009 | if (_iSatsJitter == 20) |
|
- | 2010 | { |
|
- | 2011 | if (stbSatFixLostAnim != null && !_bAnimSatFixActive) |
|
- | 2012 | { |
|
- | 2013 | Dispatcher.Invoke(() => stbSatFixLostAnim.Begin()); |
|
- | 2014 | _bAnimSatFixActive = true; |
|
- | 2015 | } |
|
- | 2016 | if (_bVoiceSatFixPlay && !_bVoiceSatFixActive) |
|
- | 2017 | { |
|
- | 2018 | _bVoiceSatFixActive = true; |
|
- | 2019 | ThreadPool.QueueUserWorkItem(new WaitCallback(_mediaPlayer), "Voice\\SatFixLost.mp3"); |
|
- | 2020 | //Thread th = new Thread(() => _mediaPlayer("Voice\\SatFixLost.mp3")); |
|
- | 2021 | //th.Start(); |
|
- | 2022 | } |
|
- | 2023 | ||
- | 2024 | _bSatFix = false; |
|
- | 2025 | } |
|
- | 2026 | } |
|
- | 2027 | } |
|
- | 2028 | ||
- | 2029 | break; |
|
- | 2030 | ||
- | 2031 | case 15: |
|
- | 2032 | //--------------------------------Waypoint index------------------------------------ |
|
- | 2033 | Dispatcher.Invoke((Action)(() => tbWPIndex.Text = data[13].ToString())); |
|
- | 2034 | Dispatcher.Invoke((Action)(() => lblWPIndexNC.Content = data[13].ToString())); |
|
- | 2035 | Dispatcher.Invoke((Action)(() => lblWPStatusIndexNC.Content = data[13].ToString())); |
|
- | 2036 | if (data[13] > 0 && _wpIndex != data[13]-1 && wpList.Count >= data[13]-1) |
|
- | 2037 | { |
|
- | 2038 | _setActiveWP(data[13]-1); |
|
- | 2039 | if ((FCSTATUSFLAGS1 & 2) == 2) |
|
- | 2040 | Dispatcher.Invoke(() => { |
|
- | 2041 | DataGridRow row; |
|
- | 2042 | if (_wpIndex > -1) |
|
- | 2043 | { |
|
- | 2044 | row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(wpOffset[_wpIndex]); |
|
- | 2045 | row.Background = new SolidColorBrush(Colors.Transparent); |
|
- | 2046 | row.BorderBrush = new SolidColorBrush(Colors.Transparent); |
|
- | 2047 | row.BorderThickness = new Thickness(0); |
|
- | 2048 | } |
|
- | 2049 | ||
- | 2050 | _wpIndex = data[13]-1; |
|
- | 2051 | row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(wpOffset[_wpIndex]); |
|
- | 2052 | row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 255, 100)); |
|
- | 2053 | row.BorderBrush = new SolidColorBrush(Colors.SpringGreen); |
|
- | 2054 | row.BorderThickness = new Thickness(2); |
|
- | 2055 | dgvWP.UpdateLayout(); |
|
- | 2056 | }); |
|
- | 2057 | _wpIndex = data[13]-1; |
|
- | 2058 | } |
|
- | 2059 | else |
|
- | 2060 | { |
|
- | 2061 | if ((data[13] == 0 || wpList.Count == 0) & MainMap.Markers.Contains(wpActiveMarker)) |
|
- | 2062 | { |
|
- | 2063 | Dispatcher.Invoke(() => MainMap.Markers.Remove(wpActiveMarker)); |
|
- | 2064 | Dispatcher.Invoke(() => |
|
- | 2065 | { |
|
- | 2066 | DataGridRow row; |
|
- | 2067 | if (_wpIndex > -1 && data[13] == 0 && wpList.Count > _wpIndex) |
|
- | 2068 | { |
|
- | 2069 | row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(wpOffset[_wpIndex]); |
|
- | 2070 | row.Background = new SolidColorBrush(Colors.Transparent); |
|
- | 2071 | row.BorderBrush = new SolidColorBrush(Colors.Transparent); |
|
- | 2072 | row.BorderThickness = new Thickness(0); |
|
- | 2073 | _wpIndex = -1; |
|
- | 2074 | } |
|
- | 2075 | }); |
|
- | 2076 | ||
- | 2077 | } |
|
- | 2078 | } |
|
- | 2079 | //----------------Waypoints count---------------------- |
|
- | 2080 | Dispatcher.Invoke((Action)(() => tbWPCount.Text = data[14].ToString())); //Waypoints count |
|
- | 2081 | Dispatcher.Invoke((Action)(() => lblWPCountNC.Content = data[14].ToString())); //Waypoints count |
|
- | 2082 | Dispatcher.Invoke((Action)(() => lblWPStatusCountNC.Content = data[14].ToString())); //Waypoints count |
|
- | 2083 | _wpCount = data[14]; |
|
- | 2084 | ||
- | 2085 | //---------------------------------Target hold time------------------------------ |
|
- | 2086 | Dispatcher.Invoke((Action)(() => lblWPHoldTime.Content = data[15].ToString() + " s")); |
|
- | 2087 | Dispatcher.Invoke((Action)(() => tbWPStatusHoldTime.Text = data[15].ToString() + " s")); |
|
- | 2088 | ||
- | 2089 | break; |
|
- | 2090 | ||
- | 2091 | case 16: |
|
- | 2092 | //--------------- Capacity used ------------------------ |
|
- | 2093 | i_16 = data[18]; |
|
- | 2094 | i_16 = (Int16)(i_16 << 8); |
|
- | 2095 | iVal = data[17] + i_16; |
|
- | 2096 | Dispatcher.Invoke((Action)(() => tbCapacity.Text = iVal.ToString() + " mAh")); |
|
- | 2097 | Dispatcher.Invoke((Action)(() => tbTopCapacity.Text = iVal.ToString() + " mAh")); |
|
- | 2098 | ||
- | 2099 | //--------------- Heading compass ------------------------ |
|
- | 2100 | i_16 = data[21]; |
|
- | 2101 | iVal = 2 * i_16; |
|
- | 2102 | Dispatcher.Invoke((Action)(() => tbHeadingCompass.Text = iVal.ToString() + " °")); |
|
- | 2103 | if (_Simulate) |
|
- | 2104 | { |
|
- | 2105 | Dispatcher.Invoke(() => ArtHor.rotate = iVal); |
|
- | 2106 | Dispatcher.Invoke(() => ((CustomMarkerCopter)(copter.Shape)).rotate = iVal); |
|
- | 2107 | } |
|
- | 2108 | ||
- | 2109 | break; |
|
- | 2110 | case 17: |
|
- | 2111 | ||
- | 2112 | break; |
|
- | 2113 | case 18: |
|
- | 2114 | ||
- | 2115 | break; |
|
- | 2116 | default: |
|
- | 2117 | break; |
|
- | 2118 | } |
|
- | 2119 | //-------------------------------------------------------------------------------- |
|
- | 2120 | //-----------------------------FC Status Flags------------------------------- |
|
- | 2121 | //-------------------------------------------------------------------------------- |
|
- | 2122 | Dispatcher.Invoke((Action)(() => FC1_1.Background = ((FCSTATUSFLAGS1 & 1) == 1) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_MOTOR_RUN 0x01 |
|
- | 2123 | Dispatcher.Invoke((Action)(() => FC1_2.Background = ((FCSTATUSFLAGS1 & 2) == 2) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_FLY 0x02 |
|
- | 2124 | Dispatcher.Invoke((Action)(() => FC1_3.Background = ((FCSTATUSFLAGS1 & 4) == 4) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_CALIBRATE 0x04 |
|
- | 2125 | Dispatcher.Invoke((Action)(() => FC1_4.Background = ((FCSTATUSFLAGS1 & 8) == 8) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_START 0x08 |
|
- | 2126 | Dispatcher.Invoke((Action)(() => FC1_5.Background = ((FCSTATUSFLAGS1 & 16) == 16) ? new SolidColorBrush(Colors.LightCoral) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_EMERGENCY_LANDING 0x10 |
|
- | 2127 | Dispatcher.Invoke((Action)(() => FC1_6.Background = ((FCSTATUSFLAGS1 & 32) == 32) ? new SolidColorBrush(Colors.LightCoral) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_LOWBAT 0x20 |
|
- | 2128 | ||
- | 2129 | Dispatcher.Invoke((Action)(() => FC2_1.Background = ((FCSTATUSFLAGS2 & 1) == 1) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS2_CAREFREE 0x01 |
|
- | 2130 | Dispatcher.Invoke((Action)(() => FC2_2.Background = ((FCSTATUSFLAGS2 & 2) == 2) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS2_ALTITUDE_CONTROL 0x02 |
|
- | 2131 | Dispatcher.Invoke((Action)(() => FC2_3.Background = ((FCSTATUSFLAGS2 & 4) == 4) ? new SolidColorBrush(Colors.LightCoral) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS2_RC_FAILSAVE_ACTIVE 0x04 |
|
- | 2132 | Dispatcher.Invoke((Action)(() => FC2_4.Background = ((FCSTATUSFLAGS2 & 8) == 8) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS2_OUT1_ACTIVE 0x08 |
|
- | 2133 | Dispatcher.Invoke((Action)(() => FC2_5.Background = ((FCSTATUSFLAGS2 & 16) == 16) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS2_OUT2_ACTIVE 0x10 |
|
- | 2134 | Dispatcher.Invoke((Action)(() => FC2_6.Background = ((FCSTATUSFLAGS2 & 32) == 32) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS2_WAIT_FOR_TAKEOFF 0x20 // Motor Running, but still on the ground |
|
- | 2135 | Dispatcher.Invoke((Action)(() => FC2_7.Background = ((FCSTATUSFLAGS2 & 64) == 64) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS2_AUTO_STARTING 0x40 |
|
- | 2136 | Dispatcher.Invoke((Action)(() => FC2_8.Background = ((FCSTATUSFLAGS2 & 128) == 128) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS2_AUTO_LANDING 0x80 |
|
- | 2137 | ||
- | 2138 | //Sidebar StatusSymbols |
|
- | 2139 | Dispatcher.Invoke((Action)(() => tbSideBarStatusMotors.Background = ((FCSTATUSFLAGS1 & 1) == 1) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_MOTOR_RUN 0x01 |
|
- | 2140 | Dispatcher.Invoke((Action)(() => tbSideBarStatusMotors.Foreground = ((FCSTATUSFLAGS1 & 1) == 1) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Color.FromArgb(255, 211, 210, 210))));// FC_STATUS_MOTOR_RUN 0x01 |
|
- | 2141 | Dispatcher.Invoke((Action)(() => tbSideBarStatusMotors.BorderBrush = ((FCSTATUSFLAGS1 & 1) == 1) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Color.FromArgb(255, 211, 210, 210))));// FC_STATUS_MOTOR_RUN 0x01 |
|
- | 2142 | ||
- | 2143 | Dispatcher.Invoke((Action)(() => tbSideBarStatusCF.Background = ((FCSTATUSFLAGS2 & 1) == 1) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS2_CAREFREE 0x01 |
|
- | 2144 | Dispatcher.Invoke((Action)(() => tbSideBarStatusCF.Foreground = ((FCSTATUSFLAGS2 & 1) == 1) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Color.FromArgb(255, 211, 210, 210))));// FC_STATUS2_CAREFREE 0x01 |
|
- | 2145 | Dispatcher.Invoke((Action)(() => tbSideBarStatusCF.BorderBrush = ((FCSTATUSFLAGS2 & 1) == 1) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Color.FromArgb(255, 211, 210, 210))));// FC_STATUS2_CAREFREE 0x01 |
|
- | 2146 | ||
- | 2147 | Dispatcher.Invoke((Action)(() => tbSideBarStatusEmergencyLanding.Background = ((FCSTATUSFLAGS1 & 16) == 16) ? new SolidColorBrush(Colors.LightCoral) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_EMERGENCY_LANDING 0x10 |
|
- | 2148 | Dispatcher.Invoke((Action)(() => tbSideBarStatusEmergencyLanding.Foreground = ((FCSTATUSFLAGS1 & 16) == 16) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Color.FromArgb(255, 211, 210, 210))));// FC_STATUS_EMERGENCY_LANDING 0x10 |
|
- | 2149 | Dispatcher.Invoke((Action)(() => tbSideBarStatusEmergencyLanding.BorderBrush = ((FCSTATUSFLAGS1 & 16) == 16) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Color.FromArgb(255, 211, 210, 210))));// FC_STATUS_EMERGENCY_LANDING 0x10 |
|
- | 2150 | ||
- | 2151 | Dispatcher.Invoke((Action)(() => tbSideBarStatusAC.Background = ((FCSTATUSFLAGS2 & 2) == 2) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS2_ALTITUDE_CONTROL 0x02 |
|
- | 2152 | Dispatcher.Invoke((Action)(() => tbSideBarStatusAC.Foreground = ((FCSTATUSFLAGS2 & 2) == 2) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Color.FromArgb(255, 211, 210, 210))));// FC_STATUS2_ALTITUDE_CONTROL 0x02 |
|
- | 2153 | Dispatcher.Invoke((Action)(() => tbSideBarStatusAC.BorderBrush = ((FCSTATUSFLAGS2 & 2) == 2) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Color.FromArgb(255, 211, 210, 210))));// FC_STATUS2_ALTITUDE_CONTROL 0x02 |
|
- | 2154 | ||
- | 2155 | _bAirborne = (FCSTATUSFLAGS1 & 2) == 2 ? true : false; |
|
- | 2156 | ||
- | 2157 | ||
- | 2158 | } |
|
- | 2159 | public class OSD_Base_Data_t |
|
- | 2160 | { |
|
- | 2161 | byte[] data; |
|
- | 2162 | ||
- | 2163 | public OSD_Base_Data_t(byte [] _data) |
|
- | 2164 | { |
|
- | 2165 | data = _data; |
|
- | 2166 | } |
|
- | 2167 | ||
- | 2168 | public PointLatLng Pos() |
|
- | 2169 | { |
|
- | 2170 | PointLatLng p = new PointLatLng(); |
|
- | 2171 | int i_32, iVal; |
|
- | 2172 | double d; |
|
- | 2173 | ||
- | 2174 | i_32 = data[4]; |
|
- | 2175 | iVal = i_32 << 24; |
|
- | 2176 | i_32 = data[3]; |
|
- | 2177 | iVal += i_32 << 16; |
|
- | 2178 | i_32 = data[2]; |
|
- | 2179 | iVal += i_32 << 8; |
|
- | 2180 | iVal += data[1]; |
|
- | 2181 | d = (double)iVal / Math.Pow(10, 7); |
|
- | 2182 | p.Lng = d; |
|
- | 2183 | ||
- | 2184 | i_32 = data[8]; |
|
- | 2185 | iVal = i_32 << 24; |
|
- | 2186 | i_32 = data[7]; |
|
- | 2187 | iVal += i_32 << 16; |
|
- | 2188 | i_32 = data[6]; |
|
- | 2189 | iVal += i_32 << 8; |
|
- | 2190 | iVal += data[5]; |
|
- | 2191 | d = (double)iVal / Math.Pow(10, 7); |
|
- | 2192 | p.Lat = d; |
|
- | 2193 | ||
- | 2194 | return p; |
|
- | 2195 | ||
- | 2196 | } |
|
- | 2197 | ||
- | 2198 | public int Height() |
|
- | 2199 | { |
|
- | 2200 | int i_32, iVal; |
|
- | 2201 | i_32 = data[10]; |
|
- | 2202 | iVal = i_32 << 8; |
|
- | 2203 | iVal += data[9]; |
|
- | 2204 | ||
- | 2205 | return iVal; |
|
- | 2206 | } |
|
- | 2207 | ||
- | 2208 | public double Speed() |
|
- | 2209 | { |
|
- | 2210 | return (double)data[11]/10; |
|
- | 2211 | } |
|
- | 2212 | ||
- | 2213 | public byte OSDSTATUSFLAGS1() |
|
- | 2214 | { |
|
- | 2215 | return data[12]; |
|
- | 2216 | } |
|
- | 2217 | public byte OSDSTATUSFLAGS2() |
|
- | 2218 | { |
|
- | 2219 | return data[13]; |
|
- | 2220 | } |
|
- | 2221 | } |
|
1820 | void _processNCData(byte[] data) |
2222 | void _processNCData(byte[] data) |
1821 | { |
2223 | { |
1822 | int i_32, i_16, iVal; |
2224 | int i_32, i_16, iVal; |
1823 | double d; |
2225 | double d; |
- | 2226 | ||
- | 2227 | //----------------------------POSITION------------------------------------ |
|
1824 | i_32 = data[4]; |
2228 | i_32 = data[4]; |
1825 | iVal = i_32 << 24; |
2229 | iVal = i_32 << 24; |
1826 | i_32 = data[3]; |
2230 | i_32 = data[3]; |
1827 | iVal += i_32 << 16; |
2231 | iVal += i_32 << 16; |
1828 | i_32 = data[2]; |
2232 | i_32 = data[2]; |
Line 1847... | Line 2251... | ||
1847 | d = (double)iVal / Math.Pow(10, 7); |
2251 | d = (double)iVal / Math.Pow(10, 7); |
1848 | Dispatcher.Invoke(() => { drGPX[1] = d; }); |
2252 | Dispatcher.Invoke(() => { drGPX[1] = d; }); |
1849 | Dispatcher.Invoke(() => { drGPX[4] = DateTime.UtcNow.ToString("u", System.Globalization.CultureInfo.InvariantCulture); }); //2011-01-14T01:59:01Z }); |
2253 | Dispatcher.Invoke(() => { drGPX[4] = DateTime.UtcNow.ToString("u", System.Globalization.CultureInfo.InvariantCulture); }); //2011-01-14T01:59:01Z }); |
1850 | p.Lat = d; |
2254 | p.Lat = d; |
Line -... | Line 2255... | ||
- | 2255 | ||
1851 | 2256 | //---------------------------SATS------------------------------------------------- |
|
1852 | if (data[50] > 4)//if more than 4 sats in use . otherwise the map would jump and scroll insane at beginning |
2257 | if (data[50] > 4)//if more than 4 sats in use . otherwise the map would jump and scroll insane at beginning |
1853 | { |
2258 | { |
1854 | _bSatFix = true; _iSatsJitter = 0; _bVoiceSatFixActive = false; |
2259 | _bSatFix = true; _iSatsJitter = 0; _bVoiceSatFixActive = false; |
1855 | if(_bAutoHome && !_bFirstSatFix) |
2260 | if(_bAutoHome && !_bFirstSatFix) |
Line 1909... | Line 2314... | ||
1909 | _bSatFix = false; |
2314 | _bSatFix = false; |
1910 | } |
2315 | } |
1911 | } |
2316 | } |
1912 | } |
2317 | } |
Line 1913... | Line 2318... | ||
1913 | 2318 | ||
1914 | //Distance to next WP |
2319 | //--------------------------Distance to next WP-------------------------------- |
1915 | i_16 = data[28]; |
2320 | i_16 = data[28]; |
1916 | i_16 = (Int16)(i_16 << 8); |
2321 | i_16 = (Int16)(i_16 << 8); |
1917 | iVal = data[27] + i_16; |
2322 | iVal = data[27] + i_16; |
1918 | Dispatcher.Invoke((Action)(() => tbWP.Text = ((double)iVal / (double)10).ToString("0.0 m"))); |
2323 | Dispatcher.Invoke((Action)(() => tbWP.Text = ((double)iVal / (double)10).ToString("0.0 m"))); |
1919 | Dispatcher.Invoke((Action)(() => lblWPRouteDistanceWP.Content = ((double)iVal / (double)10).ToString("0.0 m"))); |
2324 | Dispatcher.Invoke((Action)(() => lblWPRouteDistanceWP.Content = ((double)iVal / (double)10).ToString("0.0 m"))); |
Line -... | Line 2325... | ||
- | 2325 | Dispatcher.Invoke((Action)(() => tbWPStatusDistanceWP.Text = ((double)iVal / (double)10).ToString("0.0 m"))); |
|
1920 | Dispatcher.Invoke((Action)(() => tbWPStatusDistanceWP.Text = ((double)iVal / (double)10).ToString("0.0 m"))); |
2326 | |
1921 | 2327 | //-------------------------Distance to HP set by GPS on---------------------------------- |
|
1922 | i_16 = data[45]; |
2328 | i_16 = data[45]; |
1923 | i_16 = (Int16)(i_16 << 8); |
- | |
1924 | iVal = data[44] + i_16; |
2329 | i_16 = (Int16)(i_16 << 8); |
Line -... | Line 2330... | ||
- | 2330 | iVal = data[44] + i_16; |
|
1925 | // Dispatcher.Invoke((Action)(() => tbTopDistanceHP.Text = ((double)iVal / (double)10).ToString("0.0 m"))); //Distance to HP set by GPS on |
2331 | Dispatcher.Invoke((Action)(() => tbHP.Text = ((double)iVal / (double)10).ToString("0.0 m"))); |
1926 | Dispatcher.Invoke((Action)(() => tbHP.Text = ((double)iVal / (double)10).ToString("0.0 m"))); //Distance to HP set by GPS on |
2332 | |
1927 | 2333 | //--------------------------------Waypoint index------------------------------------ |
|
1928 | Dispatcher.Invoke((Action)(() => tbWPIndex.Text = data[48].ToString())); //Waypoint index |
2334 | Dispatcher.Invoke((Action)(() => tbWPIndex.Text = data[48].ToString())); |
1929 | Dispatcher.Invoke((Action)(() => lblWPIndexNC.Content = data[48].ToString())); |
2335 | Dispatcher.Invoke((Action)(() => lblWPIndexNC.Content = data[48].ToString())); |
1930 | Dispatcher.Invoke((Action)(() => lblWPStatusIndexNC.Content = data[48].ToString())); |
2336 | Dispatcher.Invoke((Action)(() => lblWPStatusIndexNC.Content = data[48].ToString())); |
Line 1969... | Line 2375... | ||
1969 | } |
2375 | } |
1970 | }); |
2376 | }); |
Line 1971... | Line 2377... | ||
1971 | 2377 | ||
1972 | } |
2378 | } |
1973 | } |
- | |
- | 2379 | } |
|
1974 | 2380 | //----------------Waypoints count---------------------- |
|
1975 | Dispatcher.Invoke((Action)(() => tbWPCount.Text = data[49].ToString())); //Waypoints count |
2381 | Dispatcher.Invoke((Action)(() => tbWPCount.Text = data[49].ToString())); //Waypoints count |
1976 | Dispatcher.Invoke((Action)(() => lblWPCountNC.Content = data[49].ToString())); //Waypoints count |
2382 | Dispatcher.Invoke((Action)(() => lblWPCountNC.Content = data[49].ToString())); //Waypoints count |
1977 | Dispatcher.Invoke((Action)(() => lblWPStatusCountNC.Content = data[49].ToString())); //Waypoints count |
2383 | Dispatcher.Invoke((Action)(() => lblWPStatusCountNC.Content = data[49].ToString())); //Waypoints count |
- | 2384 | _wpCount = data[49]; |
|
1978 | _wpCount = data[49]; |
2385 | //-------------------Satellites---------------------------------- |
Line 1979... | Line 2386... | ||
1979 | Dispatcher.Invoke((Action)(() => tbTopSats.Text = data[50].ToString())); //Satellites |
2386 | Dispatcher.Invoke((Action)(() => tbTopSats.Text = data[50].ToString())); |
1980 | 2387 | ||
1981 | //--------------- Capacity used ------------------------ |
2388 | //--------------- Capacity used ------------------------ |
1982 | i_16 = data[81]; |
2389 | i_16 = data[81]; |
Line 2050... | Line 2457... | ||
2050 | } |
2457 | } |
2051 | _iRCLevelJitter++; |
2458 | _iRCLevelJitter++; |
2052 | } |
2459 | } |
2053 | } |
2460 | } |
Line 2054... | Line 2461... | ||
2054 | 2461 | ||
2055 | //Waypoint max range (by license) |
2462 | //-------------------------Waypoint max range (by license)------------------------------ |
2056 | if(dWPMaxRange != (double)data[70]) |
2463 | if(dWPMaxRange != (double)data[70]) |
2057 | { |
2464 | { |
2058 | dWPMaxRange = (double)data[70]; |
2465 | dWPMaxRange = (double)data[70]; |
2059 | if (home != null && checkBoxShowWPMaxRange.IsChecked == true) |
2466 | if (home != null && checkBoxShowWPMaxRange.IsChecked == true) |
Line 2071... | Line 2478... | ||
2071 | } |
2478 | } |
2072 | }); |
2479 | }); |
2073 | } |
2480 | } |
2074 | Dispatcher.Invoke((Action)(() => tbWPMaxRange.Text = data[70].ToString() + " m")); |
2481 | Dispatcher.Invoke((Action)(() => tbWPMaxRange.Text = data[70].ToString() + " m")); |
2075 | } |
2482 | } |
2076 | //Target hold time |
2483 | //---------------------------------Target hold time------------------------------ |
2077 | Dispatcher.Invoke((Action)(() => lblWPHoldTime.Content = data[73].ToString()+ " s")); |
2484 | Dispatcher.Invoke((Action)(() => lblWPHoldTime.Content = data[73].ToString()+ " s")); |
2078 | Dispatcher.Invoke((Action)(() => tbWPStatusHoldTime.Text = data[73].ToString()+ " s")); |
2485 | Dispatcher.Invoke((Action)(() => tbWPStatusHoldTime.Text = data[73].ToString()+ " s")); |
Line 2079... | Line 2486... | ||
2079 | 2486 | ||
2080 | //--------------- NC Error ------------------------ |
2487 | //--------------- NC Error ------------------------ |
Line 2084... | Line 2491... | ||
2084 | if (data[69] > 0 & data[69] < 44) |
2491 | if (data[69] > 0 & data[69] < 44) |
2085 | ErrorLog(LogMsgType.Error," NC Error [" + data[69].ToString() + "]: ",NC_Error_Link[data[69]], NC_Error[data[69]]); |
2492 | ErrorLog(LogMsgType.Error," NC Error [" + data[69].ToString() + "]: ",NC_Error_Link[data[69]], NC_Error[data[69]]); |
2086 | //else |
2493 | //else |
2087 | // if (_bErrorLog) _clearErrorLog("NC Error"); |
2494 | // if (_bErrorLog) _clearErrorLog("NC Error"); |
Line -... | Line 2495... | ||
- | 2495 | ||
2088 | 2496 | //-------------------------------------------------------------------------------- |
|
- | 2497 | //-----------------------------FC / NC Status Flags------------------------------- |
|
2089 | //-------------FC / NC Status Flags |
2498 | //-------------------------------------------------------------------------------- |
2090 | Dispatcher.Invoke((Action)(() => FC1_1.Background = ((data[67] & 1) ==1) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_MOTOR_RUN 0x01 |
2499 | Dispatcher.Invoke((Action)(() => FC1_1.Background = ((data[67] & 1) ==1) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_MOTOR_RUN 0x01 |
2091 | Dispatcher.Invoke((Action)(() => FC1_2.Background = ((data[67] & 2) ==2) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_FLY 0x02 |
2500 | Dispatcher.Invoke((Action)(() => FC1_2.Background = ((data[67] & 2) ==2) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_FLY 0x02 |
2092 | Dispatcher.Invoke((Action)(() => FC1_3.Background = ((data[67] & 4) ==4) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_CALIBRATE 0x04 |
2501 | Dispatcher.Invoke((Action)(() => FC1_3.Background = ((data[67] & 4) ==4) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_CALIBRATE 0x04 |
2093 | Dispatcher.Invoke((Action)(() => FC1_4.Background = ((data[67] & 8) ==8) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_START 0x08 |
2502 | Dispatcher.Invoke((Action)(() => FC1_4.Background = ((data[67] & 8) ==8) ? new SolidColorBrush(Colors.LightSeaGreen) : new SolidColorBrush(Colors.Transparent)));// FC_STATUS_START 0x08 |
Line 2374... | Line 2783... | ||
2374 | /// </summary> |
2783 | /// </summary> |
2375 | /// <param name="auto"> onetimequery(false) or autoupdate(true) with set timing interval </param> |
2784 | /// <param name="auto"> onetimequery(false) or autoupdate(true) with set timing interval </param> |
2376 | private void _readNavData(bool auto) |
2785 | private void _readNavData(bool auto) |
2377 | { |
2786 | { |
2378 | byte interval = auto ? navctrlInterval : (byte)0; |
2787 | byte interval = auto ? navctrlInterval : (byte)0; |
2379 | _sendControllerMessage('o', 2, new byte[1] { interval }); |
2788 | // _sendControllerMessage('o', 2, new byte[1] { interval }); |
- | 2789 | _sendControllerMessage('o', 2, new byte[3] { interval,4,0 }); |
|
2380 | } |
2790 | } |
2381 | /// <summary> |
2791 | /// <summary> |
2382 | /// request the license info |
2792 | /// request the license info |
2383 | /// </summary> |
2793 | /// </summary> |
2384 | void _getLic() |
2794 | void _getLic() |
Line 3750... | Line 4160... | ||
3750 | }); |
4160 | }); |
Line 3751... | Line 4161... | ||
3751 | 4161 | ||
Line 3752... | Line 4162... | ||
3752 | } |
4162 | } |
- | 4163 | ||
3753 | 4164 | } |
|
3754 | } |
4165 | |
3755 | /// <summary> |
4166 | /// <summary> |
3756 | /// find the index of of a wp from datatable in the waypointlist wpList |
4167 | /// find the index of of a wp from datatable in the waypointlist wpList |
3757 | /// </summary> |
4168 | /// </summary> |
Line 3948... | Line 4359... | ||
3948 | { |
4359 | { |
3949 | if (mRouteWP != null) |
4360 | if (mRouteWP != null) |
3950 | MainMap.Markers.Remove(mRouteWP); |
4361 | MainMap.Markers.Remove(mRouteWP); |
3951 | } |
4362 | } |
3952 | } |
4363 | } |
- | 4364 | ||
3953 | private void btnLoadWPLFile_Click(object sender, RoutedEventArgs e) |
4365 | private void btnLoadWPLFile_Click(object sender, RoutedEventArgs e) |
3954 | { |
4366 | { |
3955 | _readWPLFile(); |
4367 | _readWPLFile(); |
3956 | } |
4368 | } |
3957 | private void btnClearWPList_Click(object sender, RoutedEventArgs e) |
4369 | private void btnClearWPList_Click(object sender, RoutedEventArgs e) |
Line 4091... | Line 4503... | ||
4091 | dr[13] = _Simulate ? 3 : 0; |
4503 | dr[13] = _Simulate ? 3 : 0; |
4092 | _sendWayPoint(dr, 0, 's', true); |
4504 | _sendWayPoint(dr, 0, 's', true); |
4093 | rectSimulate.Visibility = lblSimu.Visibility = _Simulate ? Visibility.Visible : Visibility.Hidden; |
4505 | rectSimulate.Visibility = lblSimu.Visibility = _Simulate ? Visibility.Visible : Visibility.Hidden; |
4094 | } |
4506 | } |
4095 | } |
4507 | } |
- | 4508 | ||
4096 | private void dgvWP_MouseUp(object sender, MouseButtonEventArgs e) |
4509 | private void dgvWP_MouseUp(object sender, MouseButtonEventArgs e) |
4097 | { |
4510 | { |
4098 | _dgvWPselectEditRow(); |
4511 | _dgvWPselectEditRow(); |
4099 | } |
4512 | } |
4100 | private void dgvWP_MouseDoubleClick(object sender, MouseButtonEventArgs e) |
4513 | private void dgvWP_MouseDoubleClick(object sender, MouseButtonEventArgs e) |
Line 4212... | Line 4625... | ||
4212 | } |
4625 | } |
4213 | iVal = Convert.ToInt16(dtWaypoints.Rows[index][14]); |
4626 | iVal = Convert.ToInt16(dtWaypoints.Rows[index][14]); |
4214 | tbWPEditOut1.Text = iVal.ToString(); |
4627 | tbWPEditOut1.Text = iVal.ToString(); |
Line 4215... | Line 4628... | ||
4215 | 4628 | ||
4216 | } |
- | |
4217 | private void btnWPEditmoveUp_Click(object sender, RoutedEventArgs e) |
- | |
4218 | { |
- | |
4219 | if (dgvWP.SelectedIndex > 0 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count) |
- | |
4220 | { |
- | |
4221 | int index = dgvWP.SelectedIndex; |
- | |
4222 | 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) |
- | |
4223 | { |
- | |
4224 | PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]); |
- | |
4225 | int wpListIndex = wpList.IndexOf(x); |
- | |
4226 | if (wpListIndex > 0) |
- | |
4227 | { |
- | |
4228 | wpList.RemoveAt(wpListIndex); |
- | |
4229 | wpList.Insert(wpListIndex - 1, x); |
- | |
4230 | MainMap.Markers.Remove(mRouteWP); |
- | |
4231 | _routeUpdate(); |
- | |
4232 | } |
- | |
4233 | } |
- | |
4234 | DataRow dr = dtWaypoints.Rows[index]; |
- | |
4235 | DataRow newRow = dtWaypoints.NewRow(); |
- | |
4236 | newRow.ItemArray = dr.ItemArray; |
- | |
4237 | dtWaypoints.Rows.Remove(dr); |
- | |
4238 | dtWaypoints.Rows.InsertAt(newRow, index - 1); |
- | |
4239 | dtWaypoints.Rows[index][0] = 100; |
- | |
4240 | dtWaypoints.Rows[index - 1][0] = index; |
- | |
4241 | GMapMarker m1 = _findWPMarker(dtWaypoints.Rows[index - 1][2].ToString()); |
- | |
4242 | GMapMarker m2 = _findWPMarker(dtWaypoints.Rows[index][2].ToString()); |
- | |
4243 | dtWaypoints.Rows[index - 1][2] = dtWaypoints.Rows[index - 1][2].ToString().Substring(0, 1) + index.ToString(); |
- | |
4244 | ((CustomMarkerWP)m1.Shape).text.Text = dtWaypoints.Rows[index - 1][2].ToString(); |
- | |
4245 | dtWaypoints.Rows[index][0] = index + 1; |
- | |
4246 | dtWaypoints.Rows[index][2] = dtWaypoints.Rows[index][2].ToString().Substring(0, 1) + (index+1).ToString(); |
- | |
4247 | ((CustomMarkerWP)m2.Shape).text.Text = dtWaypoints.Rows[index][2].ToString(); |
- | |
4248 | dgvWP.Items.Refresh(); |
- | |
4249 | dgvWP.SelectedIndex = index - 1; |
- | |
4250 | _dgvWPselectEditRow(); |
- | |
4251 | if (wpOffset.Contains(index)) // calculating offset for wpList (index is 0-based - offset starts with index 1) |
- | |
4252 | { |
- | |
4253 | int iOffset = wpOffset.IndexOf(index); |
- | |
4254 | if (iOffset > 0) // if not first element |
- | |
4255 | { |
- | |
4256 | if (wpOffset[iOffset - 1] < index-1) //if previous element is not immediately before actual offset |
- | |
4257 | wpOffset[iOffset] = index-1; //then decrease offset value by one |
- | |
4258 | } |
- | |
4259 | else |
- | |
4260 | wpOffset[iOffset] = index-1; //if first element, decrease offset by one |
- | |
4261 | } |
- | |
4262 | else //selected line is POI |
- | |
4263 | { |
- | |
4264 | if (wpOffset.Contains(index - 1)) // if next point is WP |
- | |
4265 | { |
- | |
4266 | int iOffset = wpOffset.IndexOf(index - 1); |
- | |
4267 | wpOffset[iOffset] = index; //decrease linenumber of following WP |
- | |
4268 | } |
- | |
4269 | } |
- | |
4270 | - | ||
4271 | } |
- | |
4272 | } |
- | |
4273 | - | ||
4274 | private void btnWPEditmoveDown_Click(object sender, RoutedEventArgs e) |
- | |
4275 | { |
- | |
4276 | if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count - 1) |
- | |
4277 | { |
- | |
4278 | int index = dgvWP.SelectedIndex; |
- | |
4279 | 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) |
- | |
4280 | { |
- | |
4281 | PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]); |
- | |
4282 | int wpListIndex = wpList.IndexOf(x); |
- | |
4283 | if (wpListIndex > -1) |
- | |
4284 | { |
- | |
4285 | wpList.RemoveAt(wpListIndex); |
- | |
4286 | if (wpList.Count > wpListIndex) |
- | |
4287 | wpList.Insert(wpListIndex + 1, x); |
- | |
4288 | else |
- | |
4289 | wpList.Add(x); |
- | |
4290 | MainMap.Markers.Remove(mRouteWP); |
- | |
4291 | _routeUpdate(); |
- | |
4292 | } |
- | |
4293 | } |
- | |
4294 | DataRow dr = dtWaypoints.Rows[index]; |
- | |
4295 | DataRow newRow = dtWaypoints.NewRow(); |
- | |
4296 | newRow.ItemArray = dr.ItemArray; |
- | |
4297 | dtWaypoints.Rows.Remove(dr); |
- | |
4298 | dtWaypoints.Rows.InsertAt(newRow, index + 1); |
- | |
4299 | dtWaypoints.Rows[index][0] = 100; |
- | |
4300 | dtWaypoints.Rows[index + 1][0] = index + 2; |
- | |
4301 | GMapMarker m1 = _findWPMarker(dtWaypoints.Rows[index + 1][2].ToString()); |
- | |
4302 | GMapMarker m2 = _findWPMarker(dtWaypoints.Rows[index][2].ToString()); |
- | |
4303 | dtWaypoints.Rows[index + 1][2] = dtWaypoints.Rows[index + 1][2].ToString().Substring(0, 1) + (index+2).ToString(); |
- | |
4304 | ((CustomMarkerWP)m1.Shape).text.Text = dtWaypoints.Rows[index + 1][2].ToString(); |
- | |
4305 | dtWaypoints.Rows[index][0] = index + 1; |
- | |
4306 | dtWaypoints.Rows[index][2] = dtWaypoints.Rows[index][2].ToString().Substring(0, 1) + (index+1).ToString(); |
- | |
4307 | ((CustomMarkerWP)m2.Shape).text.Text = dtWaypoints.Rows[index][2].ToString(); |
- | |
4308 | dgvWP.Items.Refresh(); |
- | |
4309 | dgvWP.SelectedIndex = index + 1; |
- | |
4310 | _dgvWPselectEditRow(); |
- | |
4311 | if(wpOffset.Contains(index)) // If selected line is WP |
- | |
4312 | { |
- | |
4313 | int iOffset = wpOffset.IndexOf(index); |
- | |
4314 | if(iOffset < wpOffset.Count -1) // if not last element |
- | |
4315 | { |
- | |
4316 | if (wpOffset[iOffset + 1] > index + 1) //if next element is not immediately after actual offset |
- | |
4317 | wpOffset[iOffset] = index + 1; //then increase offset value by one |
- | |
4318 | } |
- | |
4319 | else |
- | |
4320 | wpOffset[iOffset] = index + 1; //if last element increase offset by one |
- | |
4321 | } |
- | |
4322 | else //selected line is POI |
- | |
4323 | { |
- | |
4324 | if (wpOffset.Contains(index + 1)) // if next point is WP |
- | |
4325 | { |
- | |
4326 | int iOffset = wpOffset.IndexOf(index + 1); |
- | |
4327 | wpOffset[iOffset] = index; //decrease linenumber of following WP |
- | |
4328 | } |
- | |
4329 | } |
- | |
4330 | } |
- | |
4331 | - | ||
4332 | } |
- | |
4333 | 4629 | } |
|
4334 | private void btnEditWPSave_Click(object sender, RoutedEventArgs e) |
4630 | private void btnEditWPSave_Click(object sender, RoutedEventArgs e) |
4335 | { |
4631 | { |
4336 | if(dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count) |
4632 | if(dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count) |
4337 | { |
4633 | { |
Line 4630... | Line 4926... | ||
4630 | dgvWP.SelectedIndex = (int)o[0] -1; |
4926 | dgvWP.SelectedIndex = (int)o[0] -1; |
4631 | dgvWP.UpdateLayout(); |
4927 | dgvWP.UpdateLayout(); |
4632 | _dgvWPselectEditRow(); |
4928 | _dgvWPselectEditRow(); |
4633 | }); |
4929 | }); |
4634 | } |
4930 | } |
- | 4931 | ||
- | 4932 | private void btnWPEditmoveUp_Click(object sender, RoutedEventArgs e) |
|
- | 4933 | { |
|
- | 4934 | if (dgvWP.SelectedIndex > 0 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count) |
|
- | 4935 | { |
|
- | 4936 | int index = dgvWP.SelectedIndex; |
|
- | 4937 | 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) |
|
- | 4938 | { |
|
- | 4939 | PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]); |
|
- | 4940 | int wpListIndex = wpList.IndexOf(x); |
|
- | 4941 | if (wpListIndex > 0) |
|
- | 4942 | { |
|
- | 4943 | wpList.RemoveAt(wpListIndex); |
|
- | 4944 | wpList.Insert(wpListIndex - 1, x); |
|
- | 4945 | MainMap.Markers.Remove(mRouteWP); |
|
- | 4946 | _routeUpdate(); |
|
- | 4947 | } |
|
- | 4948 | } |
|
- | 4949 | DataRow dr = dtWaypoints.Rows[index]; |
|
- | 4950 | DataRow newRow = dtWaypoints.NewRow(); |
|
- | 4951 | newRow.ItemArray = dr.ItemArray; |
|
- | 4952 | dtWaypoints.Rows.Remove(dr); |
|
- | 4953 | dtWaypoints.Rows.InsertAt(newRow, index - 1); |
|
- | 4954 | dtWaypoints.Rows[index][0] = 100; |
|
- | 4955 | dtWaypoints.Rows[index - 1][0] = index; |
|
- | 4956 | GMapMarker m1 = _findWPMarker(dtWaypoints.Rows[index - 1][2].ToString()); |
|
- | 4957 | GMapMarker m2 = _findWPMarker(dtWaypoints.Rows[index][2].ToString()); |
|
- | 4958 | dtWaypoints.Rows[index - 1][2] = dtWaypoints.Rows[index - 1][2].ToString().Substring(0, 1) + index.ToString(); |
|
- | 4959 | ((CustomMarkerWP)m1.Shape).text.Text = dtWaypoints.Rows[index - 1][2].ToString(); |
|
- | 4960 | dtWaypoints.Rows[index][0] = index + 1; |
|
- | 4961 | dtWaypoints.Rows[index][2] = dtWaypoints.Rows[index][2].ToString().Substring(0, 1) + (index+1).ToString(); |
|
- | 4962 | ((CustomMarkerWP)m2.Shape).text.Text = dtWaypoints.Rows[index][2].ToString(); |
|
- | 4963 | dgvWP.Items.Refresh(); |
|
- | 4964 | dgvWP.SelectedIndex = index - 1; |
|
- | 4965 | _dgvWPselectEditRow(); |
|
- | 4966 | if (wpOffset.Contains(index)) // calculating offset for wpList (index is 0-based - offset starts with index 1) |
|
- | 4967 | { |
|
- | 4968 | int iOffset = wpOffset.IndexOf(index); |
|
- | 4969 | if (iOffset > 0) // if not first element |
|
- | 4970 | { |
|
- | 4971 | if (wpOffset[iOffset - 1] < index-1) //if previous element is not immediately before actual offset |
|
- | 4972 | wpOffset[iOffset] = index-1; //then decrease offset value by one |
|
- | 4973 | } |
|
- | 4974 | else |
|
- | 4975 | wpOffset[iOffset] = index-1; //if first element, decrease offset by one |
|
- | 4976 | } |
|
- | 4977 | else //selected line is POI |
|
- | 4978 | { |
|
- | 4979 | if (wpOffset.Contains(index - 1)) // if next point is WP |
|
- | 4980 | { |
|
- | 4981 | int iOffset = wpOffset.IndexOf(index - 1); |
|
- | 4982 | wpOffset[iOffset] = index; //decrease linenumber of following WP |
|
- | 4983 | } |
|
- | 4984 | } |
|
- | 4985 | ||
- | 4986 | } |
|
- | 4987 | } |
|
- | 4988 | private void btnWPEditmoveDown_Click(object sender, RoutedEventArgs e) |
|
- | 4989 | { |
|
- | 4990 | if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count - 1) |
|
- | 4991 | { |
|
- | 4992 | int index = dgvWP.SelectedIndex; |
|
- | 4993 | 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) |
|
- | 4994 | { |
|
- | 4995 | PointLatLng x = new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]); |
|
- | 4996 | int wpListIndex = wpList.IndexOf(x); |
|
- | 4997 | if (wpListIndex > -1) |
|
- | 4998 | { |
|
- | 4999 | wpList.RemoveAt(wpListIndex); |
|
- | 5000 | if (wpList.Count > wpListIndex) |
|
- | 5001 | wpList.Insert(wpListIndex + 1, x); |
|
- | 5002 | else |
|
- | 5003 | wpList.Add(x); |
|
- | 5004 | MainMap.Markers.Remove(mRouteWP); |
|
- | 5005 | _routeUpdate(); |
|
- | 5006 | } |
|
- | 5007 | } |
|
- | 5008 | DataRow dr = dtWaypoints.Rows[index]; |
|
- | 5009 | DataRow newRow = dtWaypoints.NewRow(); |
|
- | 5010 | newRow.ItemArray = dr.ItemArray; |
|
- | 5011 | dtWaypoints.Rows.Remove(dr); |
|
- | 5012 | dtWaypoints.Rows.InsertAt(newRow, index + 1); |
|
- | 5013 | dtWaypoints.Rows[index][0] = 100; |
|
- | 5014 | dtWaypoints.Rows[index + 1][0] = index + 2; |
|
- | 5015 | GMapMarker m1 = _findWPMarker(dtWaypoints.Rows[index + 1][2].ToString()); |
|
- | 5016 | GMapMarker m2 = _findWPMarker(dtWaypoints.Rows[index][2].ToString()); |
|
- | 5017 | dtWaypoints.Rows[index + 1][2] = dtWaypoints.Rows[index + 1][2].ToString().Substring(0, 1) + (index+2).ToString(); |
|
- | 5018 | ((CustomMarkerWP)m1.Shape).text.Text = dtWaypoints.Rows[index + 1][2].ToString(); |
|
- | 5019 | dtWaypoints.Rows[index][0] = index + 1; |
|
- | 5020 | dtWaypoints.Rows[index][2] = dtWaypoints.Rows[index][2].ToString().Substring(0, 1) + (index+1).ToString(); |
|
- | 5021 | ((CustomMarkerWP)m2.Shape).text.Text = dtWaypoints.Rows[index][2].ToString(); |
|
- | 5022 | dgvWP.Items.Refresh(); |
|
- | 5023 | dgvWP.SelectedIndex = index + 1; |
|
- | 5024 | _dgvWPselectEditRow(); |
|
- | 5025 | if(wpOffset.Contains(index)) // If selected line is WP |
|
- | 5026 | { |
|
- | 5027 | int iOffset = wpOffset.IndexOf(index); |
|
- | 5028 | if(iOffset < wpOffset.Count -1) // if not last element |
|
- | 5029 | { |
|
- | 5030 | if (wpOffset[iOffset + 1] > index + 1) //if next element is not immediately after actual offset |
|
- | 5031 | wpOffset[iOffset] = index + 1; //then increase offset value by one |
|
- | 5032 | } |
|
- | 5033 | else |
|
- | 5034 | wpOffset[iOffset] = index + 1; //if last element increase offset by one |
|
- | 5035 | } |
|
- | 5036 | else //selected line is POI |
|
- | 5037 | { |
|
- | 5038 | if (wpOffset.Contains(index + 1)) // if next point is WP |
|
- | 5039 | { |
|
- | 5040 | int iOffset = wpOffset.IndexOf(index + 1); |
|
- | 5041 | wpOffset[iOffset] = index; //decrease linenumber of following WP |
|
- | 5042 | } |
|
- | 5043 | } |
|
- | 5044 | } |
|
- | 5045 | ||
- | 5046 | } |
|
- | 5047 | ||
4635 | private void checkBoxShowWPStatus_Click(object sender, RoutedEventArgs e) |
5048 | private void checkBoxShowWPStatus_Click(object sender, RoutedEventArgs e) |
4636 | { |
5049 | { |
4637 | if (WPStatus.Visibility == Visibility.Visible) |
5050 | if (WPStatus.Visibility == Visibility.Visible) |
4638 | GridOSD.Margin = new Thickness(GridOSD.Margin.Left, 36 * UIScaleTopSlider.Value + 36, GridOSD.Margin.Right, GridOSD.Margin.Bottom); |
5051 | GridOSD.Margin = new Thickness(GridOSD.Margin.Left, 36 * UIScaleTopSlider.Value + 36, GridOSD.Margin.Right, GridOSD.Margin.Bottom); |
4639 | else |
5052 | else |