Subversion Repositories Projects

Rev

Rev 2372 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2372 Rev 2376
Line 149... Line 149...
149
        bool _OSDAutorefresh = true;
149
        bool _OSDAutorefresh = true;
150
        bool _bErrorLog = false;
150
        bool _bErrorLog = false;
151
        bool _bConnErr = false;
151
        bool _bConnErr = false;
152
        bool _bFollowCopter = false;
152
        bool _bFollowCopter = false;
153
        bool _bGPXLog = false;
153
        bool _bGPXLog = false;
-
 
154
        bool _Simulate = false;
Line 154... Line 155...
154
 
155
 
155
        bool _bSaveWinStateNormal = true;
156
        bool _bSaveWinStateNormal = true;
Line 156... Line 157...
156
        bool _bSaveWinStateFull = true;
157
        bool _bSaveWinStateFull = true;
Line 2252... Line 2253...
2252
                {
2253
                {
2253
                    int k = 1;
2254
                    int k = 1;
2254
                    for (int i = iStart; i < dtWaypoints.Rows.Count; i++)
2255
                    for (int i = iStart; i < dtWaypoints.Rows.Count; i++)
2255
                    {
2256
                    {
2256
                        k = iStart > 0 ? k : -1;
2257
                        k = iStart > 0 ? k : -1;
2257
                        _sendWayPoint(dtWaypoints.Rows[i], k, 'w');
2258
                        _sendWayPoint(dtWaypoints.Rows[i], k, 'w',false);
Line 2258... Line 2259...
2258
 
2259
 
2259
                        _iWPCount = -1;
2260
                        _iWPCount = -1;
2260
                        iTimeout = 0;
2261
                        iTimeout = 0;
2261
                        while (_iWPCount == -1 & iTimeout < _iWPTimeout * 5)
2262
                        while (_iWPCount == -1 & iTimeout < _iWPTimeout * 5)
Line 2275... Line 2276...
2275
            }
2276
            }
2276
            else
2277
            else
2277
                Log(LogMsgType.Error, "NOT CONNECTED!");
2278
                Log(LogMsgType.Error, "NOT CONNECTED!");
Line 2278... Line 2279...
2278
 
2279
 
2279
        }
2280
        }
2280
        bool _sendWayPoint(DataRow dr, int index, char command)
2281
        bool _sendWayPoint(DataRow dr, int index, char command,bool bSim)
Line 2281... Line 2282...
2281
        {
2282
        {
2282
 
2283
 
2283
            if (serialPortCtrl.Port.IsOpen)
2284
            if (serialPortCtrl.Port.IsOpen)
Line 2311... Line 2312...
2311
                iVal = (int)(dVal * 10);
2312
                iVal = (int)(dVal * 10);
2312
                bData[8] = (byte)(iVal & 0xff);
2313
                bData[8] = (byte)(iVal & 0xff);
2313
                bData[9] = (byte)((iVal >> 8) & 0xff);
2314
                bData[9] = (byte)((iVal >> 8) & 0xff);
2314
                bData[10] = (byte)((iVal >> 16) & 0xff);
2315
                bData[10] = (byte)((iVal >> 16) & 0xff);
2315
                bData[11] = (byte)(iVal >> 24);
2316
                bData[11] = (byte)(iVal >> 24);
-
 
2317
                if(bSim)
-
 
2318
                    bData[12] = 3; //Status 'SIMULATE'
2316
                //Status 'NEWDATA'
2319
                //Status 'NEWDATA'
-
 
2320
                else
2317
                bData[12] = 1;
2321
                    bData[12] = 1;
2318
                //heading
2322
                //heading
2319
                iVal = Convert.ToInt16(dr[6]);
2323
                iVal = Convert.ToInt16(dr[6]);
2320
                bData[13] = (byte)(iVal & 0xff);
2324
                bData[13] = (byte)(iVal & 0xff);
2321
                bData[14] = (byte)((iVal >> 8) & 0xff);
2325
                bData[14] = (byte)((iVal >> 8) & 0xff);
2322
                //ToleranceRadius
2326
                //ToleranceRadius
Line 3443... Line 3447...
3443
                        break;
3447
                        break;
3444
                }
3448
                }
3445
            });
3449
            });
Line 3446... Line 3450...
3446
 
3450
 
3447
        }
-
 
3448
        private void comboBoxWPColor_DropDownClosed(object sender, EventArgs e)
-
 
3449
        {
-
 
3450
            _MarkerColorSelection(sender, 0);
-
 
3451
        }
-
 
3452
        private void comboBoxPOIColor_DropDownClosed(object sender, EventArgs e)
-
 
3453
        {
-
 
3454
            _MarkerColorSelection(sender, 1);
-
 
3455
        }
-
 
3456
        private void comboBoxFSColor_DropDownClosed(object sender, EventArgs e)
-
 
3457
        {
-
 
3458
            _MarkerColorSelection(sender, 2);
-
 
3459
        }
-
 
3460
        private void comboBoxLandingColor_DropDownClosed(object sender, EventArgs e)
-
 
3461
        {
-
 
3462
            _MarkerColorSelection(sender,3);
-
 
3463
        }
3451
        }
3464
        void _MarkerColorSelection(object sender,int type)
3452
        void _MarkerColorSelection(object sender,int type)
3465
        {
3453
        {
3466
            Dispatcher.Invoke(() =>
3454
            Dispatcher.Invoke(() =>
3467
            {
3455
            {
Line 3480... Line 3468...
3480
                        }
3468
                        }
3481
                    }
3469
                    }
3482
                }
3470
                }
3483
            });
3471
            });
3484
        }
3472
        }
-
 
3473
       private void comboBoxWPColor_DropDownClosed(object sender, EventArgs e)
-
 
3474
        {
-
 
3475
            _MarkerColorSelection(sender, 0);
-
 
3476
        }
-
 
3477
        private void comboBoxPOIColor_DropDownClosed(object sender, EventArgs e)
-
 
3478
        {
-
 
3479
            _MarkerColorSelection(sender, 1);
-
 
3480
        }
-
 
3481
        private void comboBoxFSColor_DropDownClosed(object sender, EventArgs e)
-
 
3482
        {
-
 
3483
            _MarkerColorSelection(sender, 2);
-
 
3484
        }
-
 
3485
        private void comboBoxLandingColor_DropDownClosed(object sender, EventArgs e)
-
 
3486
        {
-
 
3487
            _MarkerColorSelection(sender,3);
-
 
3488
        }
3485
        private void comboBoxCopterColor_DropDownClosed(object sender, EventArgs e)
3489
         private void comboBoxCopterColor_DropDownClosed(object sender, EventArgs e)
3486
        {
3490
        {
3487
            Dispatcher.Invoke(() => {
3491
            Dispatcher.Invoke(() => {
3488
                if (comboBoxCopterColor.SelectionBoxItem != null)
3492
                if (comboBoxCopterColor.SelectionBoxItem != null)
3489
                {
3493
                {
3490
                    string s = comboBoxCopterColor.SelectionBoxItem.ToString();
3494
                    string s = comboBoxCopterColor.SelectionBoxItem.ToString();
Line 3551... Line 3555...
3551
        private void btnSendActiveWP_Click(object sender, RoutedEventArgs e)
3555
        private void btnSendActiveWP_Click(object sender, RoutedEventArgs e)
3552
        {
3556
        {
3553
            if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
3557
            if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
3554
            {
3558
            {
3555
                if (_wpCount > 0)
3559
                if (_wpCount > 0)
3556
                    _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], -1, 's');
3560
                    _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], -1, 's',false);
3557
                else
3561
                else
3558
                    _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], 1, 's');
3562
                    _sendWayPoint(dtWaypoints.Rows[dgvWP.SelectedIndex], 1, 's',false);
Line 3559... Line 3563...
3559
 
3563
 
3560
                //int index = dgvWP.SelectedIndex;
3564
                //int index = dgvWP.SelectedIndex;
3561
                //Thread t = new Thread(() => _sendWPList(index));
3565
                //Thread t = new Thread(() => _sendWPList(index));
Line 3567... Line 3571...
3567
                    {
3571
                    {
3568
                        row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpEdit);
3572
                        row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpEdit);
3569
                        row.Background = new SolidColorBrush(Colors.Transparent);
3573
                        row.Background = new SolidColorBrush(Colors.Transparent);
3570
                        row.BorderBrush = new SolidColorBrush(Colors.Transparent);
3574
                        row.BorderBrush = new SolidColorBrush(Colors.Transparent);
3571
                        row.BorderThickness = new Thickness(0);
3575
                        row.BorderThickness = new Thickness(0);
-
 
3576
                        dgvWP.UpdateLayout();
3572
                    }
3577
                    }
3573
                    _wpEdit = dgvWP.SelectedIndex;
3578
                    //_wpEdit = dgvWP.SelectedIndex;
3574
                    row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpEdit);
3579
                    //row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpEdit);
3575
                    row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 255, 100));
3580
                    //row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 255, 100));
3576
                    row.BorderBrush = new SolidColorBrush(Colors.SpringGreen);
3581
                    //row.BorderBrush = new SolidColorBrush(Colors.SpringGreen);
3577
                    row.BorderThickness = new Thickness(2);
3582
                    //row.BorderThickness = new Thickness(2);
3578
                    dgvWP.UpdateLayout();
-
 
3579
                });
3583
                });
3580
            }
3584
            }
3581
        }
3585
        }
-
 
3586
        private void btnWPSimulateStart_Click(object sender, RoutedEventArgs e)
-
 
3587
        {
-
 
3588
            _Simulate = !_Simulate;
-
 
3589
            if (dtWaypoints.Rows.Count > 0)
-
 
3590
            {
-
 
3591
                DataRow dr = dtWaypoints.Rows[0];
-
 
3592
                dr[13] = _Simulate ? 3 : 0;
-
 
3593
                _sendWayPoint(dr, 1, 's', true);
-
 
3594
                rectSimulate.Visibility = _Simulate ? Visibility.Visible : Visibility.Hidden;
-
 
3595
            }
-
 
3596
        }
3582
        private void dgvWP_MouseUp(object sender, MouseButtonEventArgs e)
3597
        private void dgvWP_MouseUp(object sender, MouseButtonEventArgs e)
3583
        {
3598
        {
3584
            _dgvWPselectEditRow();
3599
            _dgvWPselectEditRow();
3585
        }
3600
        }
3586
        private void dgvWP_MouseDoubleClick(object sender, MouseButtonEventArgs e)
3601
        private void dgvWP_MouseDoubleClick(object sender, MouseButtonEventArgs e)
Line 4076... Line 4091...
4076
                    myXmlTextWriter.Close();
4091
                    myXmlTextWriter.Close();
4077
                }
4092
                }
4078
            }
4093
            }
4079
        }
4094
        }
Line -... Line 4095...
-
 
4095
 
4080
 
4096
 
4081
        private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e)
4097
        private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e)
4082
        {
4098
        {
4083
            _loadGPXLog();
4099
            _loadGPXLog();
4084
        }
4100
        }