Rev 2250 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2250 | Rev 2254 | ||
---|---|---|---|
Line 147... | Line 147... | ||
147 | bool _init = true; |
147 | bool _init = true; |
148 | bool _debugDataAutorefresh = true; |
148 | bool _debugDataAutorefresh = true; |
149 | bool _navCtrlDataAutorefresh = true; |
149 | bool _navCtrlDataAutorefresh = true; |
150 | bool _blctrlDataAutorefresh = true; |
150 | bool _blctrlDataAutorefresh = true; |
151 | bool _OSDAutorefresh = true; |
151 | bool _OSDAutorefresh = true; |
- | 152 | bool _bErrorLog = false; |
|
152 | int crcError = 0; |
153 | int crcError = 0; |
153 | int iLableIndex = 0; |
154 | int iLableIndex = 0; |
154 | string filePath = Directory.GetCurrentDirectory(); |
155 | string filePath = Directory.GetCurrentDirectory(); |
155 | string fileName = "NCLabelTexts.txt"; |
156 | string fileName = "NCLabelTexts.txt"; |
156 | int _iCtrlAct = 0; |
157 | int _iCtrlAct = 0; |
Line 175... | Line 176... | ||
175 | byte OSDInterval = 85; |
176 | byte OSDInterval = 85; |
176 | /// <summary> |
177 | /// <summary> |
177 | /// datatable for the debug data array - displayed on settings tabpage in datagridview |
178 | /// datatable for the debug data array - displayed on settings tabpage in datagridview |
178 | /// </summary> |
179 | /// </summary> |
179 | DataTable dtAnalog = new DataTable(); |
180 | DataTable dtAnalog = new DataTable(); |
180 | - | ||
- | 181 | /// <summary> |
|
- | 182 | /// datatable for motordata (current,temp) |
|
- | 183 | /// </summary> |
|
181 | DataTable dtMotors1 = new DataTable(); |
184 | DataTable dtMotors1 = new DataTable(); |
182 | DataTable dtMotors2 = new DataTable(); |
185 | DataTable dtMotors2 = new DataTable(); |
Line 183... | Line 186... | ||
183 | 186 | ||
184 | public MainForm() |
187 | public MainForm() |
Line 322... | Line 325... | ||
322 | { |
325 | { |
323 | OSDInterval = (byte)(Convert.ToInt16(cbTimingOSD.SelectedItem) / 10); |
326 | OSDInterval = (byte)(Convert.ToInt16(cbTimingOSD.SelectedItem) / 10); |
324 | labelTimingOSD.Text = (OSDInterval * 10).ToString(); |
327 | labelTimingOSD.Text = (OSDInterval * 10).ToString(); |
325 | } |
328 | } |
326 | } |
329 | } |
- | 330 | private void rtfError_LinkClicked(object sender, LinkClickedEventArgs e) |
|
- | 331 | { |
|
- | 332 | System.Diagnostics.Process.Start(e.LinkText); |
|
- | 333 | } |
|
327 | #endregion events |
334 | #endregion events |
Line 328... | Line 335... | ||
328 | 335 | ||
329 | /// <summary> Log data to the terminal window. </summary> |
336 | /// <summary> Log data to the terminal window. </summary> |
330 | /// <param name="msgtype"> The type of message to be written. </param> |
337 | /// <param name="msgtype"> The type of message to be written. </param> |
Line 376... | Line 383... | ||
376 | rtfError.SelectionFont = new Font(rtfError.SelectionFont, FontStyle.Regular); |
383 | rtfError.SelectionFont = new Font(rtfError.SelectionFont, FontStyle.Regular); |
377 | rtfError.SelectionColor = LogMsgTypeColor[(int)msgtype]; |
384 | rtfError.SelectionColor = LogMsgTypeColor[(int)msgtype]; |
378 | rtfError.AppendText(msg + Environment.NewLine); |
385 | rtfError.AppendText(msg + Environment.NewLine); |
Line 379... | Line 386... | ||
379 | 386 | ||
- | 387 | })); |
|
380 | })); |
388 | _bErrorLog = true; |
Line 381... | Line 389... | ||
381 | } |
389 | } |
Line 382... | Line 390... | ||
382 | 390 | ||
Line 574... | Line 582... | ||
574 | case 28: //Distance East from saved home position -> calculate distance with distance N + height |
582 | case 28: //Distance East from saved home position -> calculate distance with distance N + height |
575 | dTemp = Math.Pow((double)iAnalogData[index], 2) + Math.Pow((double)iAnalogData[index - 1], 2); |
583 | dTemp = Math.Pow((double)iAnalogData[index], 2) + Math.Pow((double)iAnalogData[index - 1], 2); |
576 | dTemp = Math.Sqrt(dTemp) / (double)10; //'flat' distance from HP with N/E |
584 | dTemp = Math.Sqrt(dTemp) / (double)10; //'flat' distance from HP with N/E |
577 | // lblNCDist.Invoke((Action)(() => lblNCDist.Text = dTemp.ToString("0.00"))); |
585 | // lblNCDist.Invoke((Action)(() => lblNCDist.Text = dTemp.ToString("0.00"))); |
578 | dTemp = Math.Pow(dTemp, 2) + Math.Pow(((double)iAnalogData[4] / (double)10), 2); //adding 'height' into calculation |
586 | dTemp = Math.Pow(dTemp, 2) + Math.Pow(((double)iAnalogData[4] / (double)10), 2); //adding 'height' into calculation |
579 | dTemp = Math.Sqrt(dTemp); |
587 | dTemp = Math.Sqrt(dTemp) / (double)10; |
580 | lblNCDistHP.Invoke((Action)(() => lblNCDistHP.Text = dTemp.ToString("0 m"))); |
588 | lblNCDistHP.Invoke((Action)(() => lblNCDistHP.Text = dTemp.ToString("0.0 m"))); |
581 | break; |
589 | break; |
582 | case 31: //Sats used |
590 | case 31: //Sats used |
583 | lblNCSat.Invoke((Action)(() => lblNCSat.Text = sAnalogData[index])); |
591 | lblNCSat.Invoke((Action)(() => lblNCSat.Text = sAnalogData[index])); |
584 | break; |
592 | break; |
585 | } |
593 | } |
Line 662... | Line 670... | ||
662 | if (adr == 1) |
670 | if (adr == 1) |
663 | ErrorLog(LogMsgType.Error, "FC - HW-Error " + data[6].ToString() + ": " + ((FC_HWError1)data[6]).ToString()); |
671 | ErrorLog(LogMsgType.Error, "FC - HW-Error " + data[6].ToString() + ": " + ((FC_HWError1)data[6]).ToString()); |
664 | if (adr == 2) |
672 | if (adr == 2) |
665 | ErrorLog(LogMsgType.Error, "NC - Unknown HW-ERROR: " + data[6].ToString()); //@moment NC has only one error field |
673 | ErrorLog(LogMsgType.Error, "NC - Unknown HW-ERROR: " + data[6].ToString()); //@moment NC has only one error field |
666 | } |
674 | } |
- | 675 | if((data[5] + data[6] == 0) && _bErrorLog) |
|
- | 676 | _clearErrorLog(adr==1 ? "FC - HW-Error" : "FC - HW-Error"); |
|
Line 667... | Line 677... | ||
667 | 677 | ||
668 | } |
678 | } |
669 | check_HWError = false; |
679 | check_HWError = false; |
670 | } |
680 | } |
Line 743... | Line 753... | ||
743 | i_32 = data[6]; |
753 | i_32 = data[6]; |
744 | iVal += i_32 << 8; |
754 | iVal += i_32 << 8; |
745 | iVal += data[5]; |
755 | iVal += data[5]; |
746 | d = (double)iVal / Math.Pow(10, 7); |
756 | d = (double)iVal / Math.Pow(10, 7); |
747 | lblNCGPSLat.Invoke((Action)(() => lblNCGPSLat.Text = d.ToString("0.######°"))); //GPS-Position: Latitude in decimal degree |
757 | lblNCGPSLat.Invoke((Action)(() => lblNCGPSLat.Text = d.ToString("0.######°"))); //GPS-Position: Latitude in decimal degree |
748 | //lblNCGPSLat.Invoke((Action)(() => lblNCGPSLat.Text = _convertDegree(d))); //GPS-Position: Latitude in minutes, seconds |
758 | //lblNCGPSLat.Invoke((Action)(() => lblNCGPSLat.Text = _convertDegree(d))); //GPS-Position: Latitude in minutes, seconds |
- | 759 | ||
- | 760 | i_16 = data[28]; |
|
- | 761 | i_16 = (Int16)(i_16 << 8); |
|
- | 762 | iVal = data[27] + i_16; |
|
- | 763 | lblNCDistWP.Invoke((Action)(() => lblNCDistWP.Text = ((double)iVal/ (double)10).ToString("0.0 m"))); //Distance to next WP |
|
- | 764 | ||
- | 765 | i_16 = data[45]; |
|
- | 766 | i_16 = (Int16)(i_16 << 8); |
|
- | 767 | iVal = data[44] + i_16; |
|
- | 768 | lblNCDistHP1.Invoke((Action)(() => lblNCDistHP1.Text = ((double)iVal/ (double)10).ToString("0.0 m"))); //Distance to next WP |
|
- | 769 | ||
- | 770 | lblNCWPIndex.Invoke((Action)(() => lblNCWPIndex.Text = data[48].ToString())); //Waypoint index |
|
- | 771 | lblNCWPCount.Invoke((Action)(() => lblNCWPCount.Text = data[49].ToString())); //Waypoints count |
|
Line 749... | Line 772... | ||
749 | 772 | ||
750 | i_16 = data[81]; |
773 | i_16 = data[81]; |
751 | i_16 = (Int16)(i_16 << 8); |
774 | i_16 = (Int16)(i_16 << 8); |
752 | iVal = data[80] + i_16; |
775 | iVal = data[80] + i_16; |
Line 764... | Line 787... | ||
764 | //if (data[69] > 0) |
787 | //if (data[69] > 0) |
765 | // _readNCError(); |
788 | // _readNCError(); |
766 | //break; |
789 | //break; |
767 | if (data[69] > 0 & data[69] < 44) |
790 | if (data[69] > 0 & data[69] < 44) |
768 | ErrorLog(LogMsgType.Error, "NC Error [" + data[69].ToString() + "]: " + NC_Error[data[69]]); |
791 | ErrorLog(LogMsgType.Error, "NC Error [" + data[69].ToString() + "]: " + NC_Error[data[69]]); |
- | 792 | else |
|
- | 793 | if(_bErrorLog) _clearErrorLog("NC Error"); |
|
Line 769... | Line 794... | ||
769 | 794 | ||
770 | } |
795 | } |
771 | /// <summary> |
796 | /// <summary> |
772 | /// OSD Menue 'L' |
797 | /// OSD Menue 'L' |
Line 1095... | Line 1120... | ||
1095 | lblNCGSpeed.Invoke((Action)(() => lblNCGSpeed.Text = "NA")); //GroundSpeed |
1120 | lblNCGSpeed.Invoke((Action)(() => lblNCGSpeed.Text = "NA")); //GroundSpeed |
1096 | lblNCDistHP.Invoke((Action)(() => lblNCDistHP.Text = "NA")); //Distance to HP |
1121 | lblNCDistHP.Invoke((Action)(() => lblNCDistHP.Text = "NA")); //Distance to HP |
1097 | lblNCSat.Invoke((Action)(() => lblNCSat.Text = "NA")); //Sats used |
1122 | lblNCSat.Invoke((Action)(() => lblNCSat.Text = "NA")); //Sats used |
1098 | lblNCGPSLong.Invoke((Action)(() => lblNCGPSLong.Text = "NA")); //GPS position - longitude |
1123 | lblNCGPSLong.Invoke((Action)(() => lblNCGPSLong.Text = "NA")); //GPS position - longitude |
1099 | lblNCGPSLat.Invoke((Action)(() => lblNCGPSLat.Text = "NA")); //GPS position - latitude |
1124 | lblNCGPSLat.Invoke((Action)(() => lblNCGPSLat.Text = "NA")); //GPS position - latitude |
- | 1125 | lblNCDistWP.Invoke((Action)(() => lblNCDistWP.Text = "NA")); //next WP distance |
|
- | 1126 | lblNCWPIndex.Invoke((Action)(() => lblNCWPIndex.Text = "NA")); //index of actual WP |
|
- | 1127 | lblNCWPCount.Invoke((Action)(() => lblNCWPCount.Text = "NA")); //count of items in WP list |
|
1100 | } |
1128 | } |
1101 | /// <summary> |
1129 | /// <summary> |
1102 | /// one time query of the OSD Menue with pagenumber |
1130 | /// one time query of the OSD Menue with pagenumber |
1103 | /// </summary> |
1131 | /// </summary> |
1104 | /// <param name="iMenue">Menue page</param> |
1132 | /// <param name="iMenue">Menue page</param> |
Line 1250... | Line 1278... | ||
1250 | int sec = ts.Seconds; |
1278 | int sec = ts.Seconds; |
1251 | int milli = ts.Milliseconds; |
1279 | int milli = ts.Milliseconds; |
Line 1252... | Line 1280... | ||
1252 | 1280 | ||
1253 | return deg.ToString("0° ") + min.ToString("0") + "' " + sec.ToString("0") + "," + milli.ToString() + "\""; |
1281 | return deg.ToString("0° ") + min.ToString("0") + "' " + sec.ToString("0") + "," + milli.ToString() + "\""; |
- | 1282 | } |
|
- | 1283 | ||
- | 1284 | void _clearErrorLog(string s) |
|
- | 1285 | { |
|
- | 1286 | rtfError.Invoke((Action)(() => |
|
- | 1287 | { |
|
- | 1288 | if (rtfError.Text.Contains(s)) |
|
- | 1289 | { |
|
- | 1290 | int iLength = 0; |
|
- | 1291 | int iStart = rtfError.Text.IndexOf(s); |
|
- | 1292 | int iEnd = rtfError.Text.IndexOf('\n', iStart); |
|
- | 1293 | if (iEnd > 0) |
|
- | 1294 | { |
|
- | 1295 | iLength = iEnd + 1; |
|
- | 1296 | int iHttp = rtfError.Text.IndexOf("http", iEnd); |
|
- | 1297 | if (iHttp == iLength) |
|
- | 1298 | { |
|
- | 1299 | int iEnd2 = rtfError.Text.IndexOf('\n', iLength); |
|
- | 1300 | if (iEnd2 > iLength) |
|
- | 1301 | { |
|
- | 1302 | iLength = iEnd2 + 1; |
|
- | 1303 | rtfError.Select(iStart, iLength); |
|
- | 1304 | rtfError.SelectedText = string.Empty; |
|
- | 1305 | if(rtfError.Text.Length < 2) _bErrorLog = false; |
|
- | 1306 | } |
|
- | 1307 | ||
- | 1308 | } |
|
- | 1309 | else |
|
- | 1310 | { |
|
- | 1311 | rtfError.Select(iStart, iLength); |
|
- | 1312 | rtfError.SelectedText = string.Empty; |
|
- | 1313 | if(rtfError.Text.Length < 2) _bErrorLog = false; |
|
- | 1314 | } |
|
- | 1315 | } |
|
- | 1316 | } |
|
- | 1317 | })); |
|
- | 1318 | ||
1254 | } |
1319 | } |
Line 1255... | Line 1320... | ||
1255 | #endregion functions |
1320 | #endregion functions |
1256 | 1321 | ||
1257 | #region buttons |
1322 | #region buttons |
Line 1372... | Line 1437... | ||
1372 | private void btnOSDEnter_Click(object sender, EventArgs e) |
1437 | private void btnOSDEnter_Click(object sender, EventArgs e) |
1373 | { |
1438 | { |
1374 | _OSDMenueAutoRefresh(4); |
1439 | _OSDMenueAutoRefresh(4); |
1375 | } |
1440 | } |
1376 | #endregion buttons |
1441 | #endregion buttons |
- | 1442 | ||
1377 | } |
1443 | } |
1378 | public class IniFile |
1444 | public class IniFile |
1379 | { |
1445 | { |
1380 | public string path; |
1446 | public string path; |