Ejemplo n.º 1
0
 //send takeoff with altitue 160
 private void debug1(object sender, EventArgs e)
 {
     parentSerialTerminal.Send_takeoff_packet(160);
 }
Ejemplo n.º 2
0
        /**
         * Submit flight plan to drone.
         * @author Joe Higley
         **/
        private void SubmitFlightPlan(object sender, EventArgs e)
        {
            if (!Takeoff)
            {
                parentSerialTerminal.Send_takeoff_packet(4);
                //Commented for snapshot demo, uncomment when this is encountered
                //Takeoff = true;
            }

            //parentSerialTerminal.SendString_LCD("0,0,TestData");

            if (instructionP.Controls.Count == 0)
            {
                return; //nothing to submit
            }
            //Animate the submition.
            Control p = instructionP.Controls[0];

            if (checkInstructCompletion(p))
            {
                p.BackColor = Color.LightCoral;
                if (p.Controls[1] is Button) // only remove - button if this is a button
                {
                    p.Controls.Remove(p.Controls[1]);
                }
            }

            //Send data to drone
            for (int i = 0; i < instructionP.Controls.Count; i++)
            {
                p = instructionP.Controls[i];
                if (checkInstructCompletion(p))  //Only submit complete instructions
                {
                    int j = 1;                   //Starting control of parsed data
                    if (p.Controls[1] is Button) //If control is not first control
                    {
                        j = 2;
                    }

                    //Parse data and send to drone
                    String field0, field1, field2, field3;
                    field0 = p.Controls[0].Text;        // Packet Type
                    field1 = p.Controls[j].Text;        // Move/Rotate: direction  ... GPS Longitude
                    field2 = p.Controls[j + 1].Text;    // Move/Rotate: value ... GPS Latitude

                    switch (field0)
                    {
                    case "Move":
                        /** Create Move Packet to send to drone **/
                        switch (field1)
                        {
                        case "Up":
                            //calculate new coords.
                            break;

                        case "Down":
                            //calculate new coords.
                            break;

                        case "Forward":
                            parentSerialTerminal.Send_move_specifc((int)DRONE_movement_dir.MOVE_FORWARD,
                                                                   (int)DRONE_movement_metric.METRIC_METERS,
                                                                   Int32.Parse(field2));
                            break;

                        case "Back":
                            parentSerialTerminal.Send_move_specifc((int)DRONE_movement_dir.MOVE_BACKWARD,
                                                                   (int)DRONE_movement_metric.METRIC_METERS,
                                                                   Int32.Parse(field2));
                            break;

                        case "Left":
                            parentSerialTerminal.Send_move_specifc((int)DRONE_movement_dir.MOVE_LEFT,
                                                                   (int)DRONE_movement_metric.METRIC_METERS,
                                                                   Int32.Parse(field2));
                            break;

                        case "Right":
                            parentSerialTerminal.Send_move_specifc((int)DRONE_movement_dir.MOVE_RIGHT,
                                                                   (int)DRONE_movement_metric.METRIC_METERS,
                                                                   Int32.Parse(field2));
                            break;
                        }
                        break;


                    case "Rotate":
                        /** Create Rotate Packet to send to drone **/
                        switch (field1)
                        {
                        case "Left":
                            parentSerialTerminal.Send_move_specifc((int)DRONE_movement_dir.MOVE_ROTATE_CLOCKWISE,
                                                                   (int)DRONE_movement_metric.METRIC_DEGREES,
                                                                   Int32.Parse("-" + field2));
                            break;

                        case "Right":
                            parentSerialTerminal.Send_move_specifc((int)DRONE_movement_dir.MOVE_ROTATE_CLOCKWISE,
                                                                   (int)DRONE_movement_metric.METRIC_DEGREES,
                                                                   Int32.Parse(field2));
                            break;
                        }
                        break;


                    case "GPS":
                        field3 = p.Controls[j + 2].Text;     //only used for GPS packet.
                        /** Create GPS Packet to send to drone **/
                        break;

                    default:
                        break;
                    }

                    // FORM/SEND PACKET
                }
            }
        }