Subversion Repositories Projects

Rev

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

Rev 2545 Rev 2554
Line 3466... Line 3466...
3466
            int iTimeout = 0;
3466
            int iTimeout = 0;
3467
            if (serialPortCtrl.Port.IsOpen)
3467
            if (serialPortCtrl.Port.IsOpen)
3468
            {
3468
            {
3469
                if (_clearCopterWPList())
3469
                if (_clearCopterWPList())
3470
                {
3470
                {
-
 
3471
                    bool bError = false;
3471
                    int k = 1;
3472
                    int k = 1;
3472
                    for (int i = iStart; i < dtWaypoints.Rows.Count; i++)
3473
                    for (int i = iStart; i < dtWaypoints.Rows.Count; i++)
3473
                    {
3474
                    {
3474
                        k = iStart > 0 ? k : -1;
3475
                        k = iStart > 0 ? k : -1;
3475
                        _sendWayPoint(dtWaypoints.Rows[i], k, 'w',false);
3476
                        _sendWayPoint(dtWaypoints.Rows[i], k, 'w',false);
Line 3482... Line 3483...
3482
                            iTimeout++;
3483
                            iTimeout++;
3483
                        }
3484
                        }
3484
                        if (_iWPCount == -1)
3485
                        if (_iWPCount == -1)
3485
                        {
3486
                        {
3486
                            Log(LogMsgType.Error, "Timeout while sending list!");
3487
                            Log(LogMsgType.Error, "Timeout while sending list!");
-
 
3488
                            bError = true;
3487
                            break;
3489
                            break;
3488
                        }
3490
                        }
3489
                        Dispatcher.Invoke(() => lblWPCount.Content = _iWPCount.ToString());
3491
                        Dispatcher.Invoke(() => lblWPCount.Content = _iWPCount.ToString());
3490
                        k++;
3492
                        k++;
3491
                    }
3493
                    }
-
 
3494
                    if(!bError)
-
 
3495
                        Log(LogMsgType.Normal, dtWaypoints.Rows.Count.ToString() + " WP sent to Copter");
3492
                }
3496
                }
3493
            }
3497
            }
3494
            else
3498
            else
3495
                Log(LogMsgType.Error, "NOT CONNECTED!");
3499
                Log(LogMsgType.Error, "NOT CONNECTED!");
Line 5448... Line 5452...
5448
            }
5452
            }
Line 5449... Line 5453...
5449
 
5453
 
5450
        }
5454
        }
5451
        private void btnEditWPAdd_Click(object sender, RoutedEventArgs e)
5455
        private void btnEditWPAdd_Click(object sender, RoutedEventArgs e)
-
 
5456
        {
-
 
5457
            if (tbWPEditLat.Text != "" && tbWPEditLon.Text !="")
5452
        {
5458
            {
5453
            DataRow dr = dtWaypoints.NewRow();
5459
                DataRow dr = dtWaypoints.NewRow();
5454
            dr[0] = dtWaypoints.Rows.Count+1;
5460
                dr[0] = dtWaypoints.Rows.Count + 1;
5455
            dr[1] = cbWPEditType.SelectedIndex;
5461
                dr[1] = cbWPEditType.SelectedIndex;
5456
            dr[2] = tbWPEditPrefix.Text + dr[0].ToString();
5462
                dr[2] = tbWPEditPrefix.Text + dr[0].ToString();
5457
            dr[3] = Convert.ToDouble(tbWPEditLat.Text.Replace('.', ',')) + 0.00000001;
5463
                dr[3] = Convert.ToDouble(tbWPEditLat.Text.Replace('.', ',')) + 0.00000001;
5458
            dr[4] = Convert.ToDouble(tbWPEditLon.Text.Replace('.', ',')) + 0.00000001;
5464
                dr[4] = Convert.ToDouble(tbWPEditLon.Text.Replace('.', ',')) + 0.00000001;
5459
            dr[5] = lblWPEditAlt.Content;
5465
                dr[5] = lblWPEditAlt.Content;
5460
            switch (cbWPEditHeading.SelectedIndex)
5466
                switch (cbWPEditHeading.SelectedIndex)
5461
            {
5467
                {
5462
                case 0:
5468
                    case 0:
5463
                    dr[6] = "0";
5469
                        dr[6] = "0";
5464
                    break;
5470
                        break;
5465
                case 1:
5471
                    case 1:
5466
                    dr[6] = "-" + lblWPEditHeading.Content;
5472
                        dr[6] = "-" + lblWPEditHeading.Content;
5467
                    break;
5473
                        break;
5468
                case 2:
5474
                    case 2:
5469
                    dr[6] = lblWPEditHeading.Content;
5475
                        dr[6] = lblWPEditHeading.Content;
5470
                    break;
5476
                        break;
5471
            }
5477
                }
5472
            switch (cbWPEditSpeed.SelectedIndex)
5478
                switch (cbWPEditSpeed.SelectedIndex)
5473
            {
5479
                {
5474
                case 0:
5480
                    case 0:
5475
                    dr[7] = "0";
5481
                        dr[7] = "0";
5476
                    break;
5482
                        break;
5477
                case 1:
5483
                    case 1:
5478
                    dr[7] = (System.Convert.ToDouble(lblWPEditSpeed.Content.ToString().Replace('.', ',')) * 10).ToString("0");
5484
                        dr[7] = (System.Convert.ToDouble(lblWPEditSpeed.Content.ToString().Replace('.', ',')) * 10).ToString("0");
5479
                    break;
5485
                        break;
5480
                case 2:
5486
                    case 2:
5481
                    dr[7] = (256 - Convert.ToInt16(lblWPEditSpeed.Content)).ToString();
5487
                        dr[7] = (256 - Convert.ToInt16(lblWPEditSpeed.Content)).ToString();
5482
                    break;
5488
                        break;
5483
            }
5489
                }
5484
            switch (cbWPEditClimbrate.SelectedIndex)
5490
                switch (cbWPEditClimbrate.SelectedIndex)
5485
            {
5491
                {
5486
                case 0:
5492
                    case 0:
5487
                    dr[8] = "255";
5493
                        dr[8] = "255";
5488
                    break;
5494
                        break;
5489
                case 1:
5495
                    case 1:
5490
                    dr[8] = (System.Convert.ToDouble(lblWPEditClimbrate.Content.ToString().Replace('.', ',')) * 10).ToString("0");
5496
                        dr[8] = (System.Convert.ToDouble(lblWPEditClimbrate.Content.ToString().Replace('.', ',')) * 10).ToString("0");
5491
                    break;
5497
                        break;
5492
            }
5498
                }
5493
            dr[9] = lblWPEditRadius.Content;
5499
                dr[9] = lblWPEditRadius.Content;
5494
            dr[10] = lblWPEditHoldtime.Content;
5500
                dr[10] = lblWPEditHoldtime.Content;
5495
            dr[11] = lblWPEditAutoTrigger.Content;
5501
                dr[11] = lblWPEditAutoTrigger.Content;
5496
            switch (cbWPEditCamAngle.SelectedIndex)
5502
                switch (cbWPEditCamAngle.SelectedIndex)
5497
            {
5503
                {
5498
                case 0:
5504
                    case 0:
5499
                    dr[12] = "0";
5505
                        dr[12] = "0";
5500
                    break;
5506
                        break;
5501
                case 1:
5507
                    case 1:
5502
                    dr[12] = "255";
5508
                        dr[12] = "255";
5503
                    break;
5509
                        break;
5504
                case 2:
5510
                    case 2:
5505
                    dr[12] = lblWPEditCamAngle.Content;
5511
                        dr[12] = lblWPEditCamAngle.Content;
5506
                    break;
5512
                        break;
5507
            }
5513
                }
5508
            dr[13] = "";
5514
                dr[13] = "";
5509
            dr[14] = lblWPEditOut1.Content;
5515
                dr[14] = lblWPEditOut1.Content;
5510
            dr[15] = "";
5516
                dr[15] = "";
5511
            _createWP(new PointLatLng((double)dr[3], (double)dr[4]),(string) dr[2], (int)dr[1], (int)dr[0]);
5517
                _createWP(new PointLatLng((double)dr[3], (double)dr[4]), (string)dr[2], (int)dr[1], (int)dr[0]);
5512
            if (mRouteWP != null)
5518
                if (mRouteWP != null)
5513
                MainMap.Markers.Remove(mRouteWP);
5519
                    MainMap.Markers.Remove(mRouteWP);
5514
            _routeUpdate();
5520
                _routeUpdate();
5515
            dtWaypoints.Rows.Add(dr);
5521
                dtWaypoints.Rows.Add(dr);
-
 
5522
                dgvWP.Items.Refresh();
5516
            dgvWP.Items.Refresh();
5523
            }
5517
        }
5524
        }
5518
        private void btnEditWPDel_Click(object sender, RoutedEventArgs e)
5525
        private void btnEditWPDel_Click(object sender, RoutedEventArgs e)
5519
        {
5526
        {
5520
            if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
5527
            if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)