Пример #1
0
 void run_selected_script()
 {
     script = new Script(checkBoxRedirectOutput.Checked);
     script.runScript(selectedscript);
     scriptrunning = false;
 }
        void ScriptStart()
        {
            string myscript = @"
            # cs.???? = currentstate, any variable on the status tab in the planner can be used.
            # Script = options are
            # Script.Sleep(ms)
            # Script.ChangeParam(name,value)
            # Script.GetParam(name)
            # Script.ChangeMode(mode) - same as displayed in mode setup screen 'AUTO'
            # Script.WaitFor(string,timeout)
            # Script.SendRC(channel,pwm,sendnow)
            #

            print 'Start Script'
            for chan in range(1,9):
            Script.SendRC(chan,1500,False)
            Script.SendRC(3,Script.GetParam('RC3_MIN'),True)

            Script.Sleep(5000)
            while cs.lat == 0:
            print 'Waiting for GPS'
            Script.Sleep(1000)
            print 'Got GPS'
            jo = 10 * 13
            print jo
            Script.SendRC(3,1000,False)
            Script.SendRC(4,2000,True)
            cs.messages.Clear()
            Script.WaitFor('ARMING MOTORS',30000)
            Script.SendRC(4,1500,True)
            print 'Motors Armed!'

            Script.SendRC(3,1700,True)
            while cs.alt < 50:
            Script.Sleep(50)

            Script.SendRC(5,2000,True) # acro

            Script.SendRC(1,2000,False) # roll
            Script.SendRC(3,1370,True) # throttle
            while cs.roll > -45: # top hald 0 - 180
            Script.Sleep(5)
            while cs.roll < -45: # -180 - -45
            Script.Sleep(5)

            Script.SendRC(5,1500,False) # stabalise
            Script.SendRC(1,1500,True) # level roll
            Script.Sleep(2000) # 2 sec to stabalise
            Script.SendRC(3,1300,True) # throttle back to land

            thro = 1350 # will decend

            while cs.alt > 0.1:
            Script.Sleep(300)

            Script.SendRC(3,1000,False)
            Script.SendRC(4,1000,True)
            Script.WaitFor('DISARMING MOTORS',30000)
            Script.SendRC(4,1500,True)

            print 'Roll complete'

            ";

            CustomMessageBox.Show("This is Very ALPHA");

            Form scriptedit = new Form();

            scriptedit.Size = new System.Drawing.Size(500,500);

            TextBox tb = new TextBox();

            tb.Dock = DockStyle.Fill;

            tb.ScrollBars = ScrollBars.Both;
            tb.Multiline = true;

            tb.Location = new Point(0,0);
            tb.Size = new System.Drawing.Size(scriptedit.Size.Width-30,scriptedit.Size.Height-30);

            scriptedit.Controls.Add(tb);

            tb.Text = myscript;

            scriptedit.ShowDialog();

            if (DialogResult.Yes == CustomMessageBox.Show("Run Script", "Run this script?", MessageBoxButtons.YesNo))
            {

                Script scr = new Script();

                scr.runScript(tb.Text);
            }
        }
Пример #3
0
        private void updateCameraLensIris()
        {
            //auto close camera lens for Canon S110

            //check to see if 20 meters has been reached
            if (MainV2.comPort.MAV.cs.alt > 20)
            {
                Reached50M = true;
                CameraClosed = false; //assume the camera is open anytime above 50m..
                                      //...fixes the issue of the camera not closing on any flight after the first because the program already thinks it is closed.
            }

            //close camera lens based on parameters
            if (MainV2.comPort.MAV.cs.connected && MainV2.comPort.MAV.cs.alt < 10
                && CameraClosed == false && Reached50M == true
                && playingLog == false)
            {
                CameraClosed = true;
                Script script = new Script();
                script.runScript("ShutCamtrig.py");
                //CustomMessageBox.Show("Camera lens closed because of low altitude!!!");
            }
        }
Пример #4
0
 private void BUT_CloseLens_Click(object sender, EventArgs e)
 {
     if (!MainV2.comPort.MAV.cs.connected)
     {
         CustomMessageBox.Show("Please connect first");
     }
     else
     {
         if (File.Exists("ShutCamtrig.py"))
         {
             //string closeLens = File.ReadAllText("ShutCamtrig.py");
             Script script = new Script();
             //MessageBox.Show(closeLens); //--test code
             script.runScript("ShutCamtrig.py");
         }
         else
             CustomMessageBox.Show("ERROR in BUT_CloseLens function (ShutCamtrig.py file was not found)");
     }
 }
Пример #5
0
        void ScriptStart()
        {
            string myscript = @"
            print 'Start Script'
            for chan in range(1,9):
            Script.SendRC(chan,1500,False)
            Script.SendRC(3,Script.GetParam('RC3_MIN'),True)

            Script.Sleep(5000)
            while cs.lat == 0:
            print 'Waiting for GPS'
            Script.Sleep(1000)
            print 'Got GPS'
            jo = 10 * 13
            print jo
            Script.SendRC(3,1000,False)
            Script.SendRC(4,2000,True)
            cs.messages.Clear()
            Script.WaitFor('ARMING MOTORS',30000)
            Script.SendRC(4,1500,True)
            print 'Motors Armed!'

            Script.SendRC(3,1700,True)
            while cs.alt < 50:
            Script.Sleep(50)

            Script.SendRC(5,2000,True) # acro

            Script.SendRC(1,2000,False) # roll
            Script.SendRC(3,1370,True) # throttle
            while cs.roll > -45: # top hald 0 - 180
            Script.Sleep(5)
            while cs.roll < -45: # -180 - -45
            Script.Sleep(5)

            Script.SendRC(5,1500,False) # stabalise
            Script.SendRC(1,1500,True) # level roll
            Script.Sleep(2000) # 2 sec to stabalise
            Script.SendRC(3,1300,True) # throttle back to land

            thro = 1350 # will decend

            while cs.alt > 0.1:
            Script.Sleep(300)

            Script.SendRC(3,1000,False)
            Script.SendRC(4,1000,True)
            Script.WaitFor('DISARMING MOTORS',30000)
            Script.SendRC(4,1500,True)

            print 'Roll complete'

            ";

            MessageBox.Show("This is Very ALPHA");

            Form scriptedit = new Form();

            scriptedit.Size = new System.Drawing.Size(500,500);

            TextBox tb = new TextBox();

            tb.Dock = DockStyle.Fill;

            tb.ScrollBars = ScrollBars.Both;
            tb.Multiline = true;

            tb.Location = new Point(0,0);
            tb.Size = new System.Drawing.Size(scriptedit.Size.Width-30,scriptedit.Size.Height-30);

            scriptedit.Controls.Add(tb);

            tb.Text = myscript;

            scriptedit.ShowDialog();

            if (DialogResult.Yes == MessageBox.Show("Run Script", "Run this script?", MessageBoxButtons.YesNo))
            {

                Script scr = new Script();

                scr.runScript(tb.Text);
            }
        }