Esempio n. 1
0
 private void ArmReady()
 {
     cYaw  = 0.5;
     state = ERAState.ThrottleUp;
     joystick.SetBtn(false, id, 1);
     allownoise = true;
 }
Esempio n. 2
0
        private void processStickMovement()
        {
            count += ((double)timer1.Interval) / 1000.0;
            double wf = generateStickWaveform(count * 2);

            cPitch -= (cPitch - 0.5) * 0.05;
            cRoll  -= (cRoll - 0.5) * 0.05;
            cThr   -= (cThr - centerThrottle * conv_mul) * 0.05;
            cYaw   -= (cYaw - 0.5) * 0.05;

            switch (state)
            {
            case ERAState.PitchUp:
                label2.Text = "ТАНГАЖ+";
                cPitch      = 0.5 + wf * 0.25;
                break;

            case ERAState.PitchDown:
                label2.Text = "ТАНГАЖ-";
                cPitch      = 0.5 - wf * 0.25;
                break;

            case ERAState.RollUp:
                label2.Text = "КРЕН+";
                cRoll       = 0.5 + wf * 0.25;
                break;

            case ERAState.RollDown:
                label2.Text = "КРЕН-";
                cRoll       = 0.5 - wf * 0.25;
                break;

            case ERAState.YawRight:
                label2.Text = "РЫСК+";
                if (!checkBox1.Checked)
                {
                    cYaw = 0.5 + wf * 0.25;
                }
                break;

            case ERAState.YawLeft:
                label2.Text = "РЫСК-";
                if (!checkBox1.Checked)
                {
                    cYaw = 0.5 - wf * 0.25;
                }
                break;

            default:
                break;
            }
            if (count > 1.5)
            {
                cPitch = cRoll = cYaw = 0.5;
                cThr   = centerThrottle * conv_mul;
                state  = ERAState.Idle;
            }
        }
Esempio n. 3
0
 private void Arm()
 {
     cPitch = cRoll = 0.5;
     cThr   = 0;
     cYaw   = 0.5;
     joystick.SetBtn(true, id, 1);
     count = 1.0f;
     state = ERAState.Arming;
 }
Esempio n. 4
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (timer1.Enabled == true)
     {
         state    = ERAState.StopProcess;
         conv_mul = 1;
         cThr     = centerThrottle * conv_mul;
     }
 }
Esempio n. 5
0
 private void button2_Click(object sender, EventArgs e)
 {
     cPitch = cRoll = cYaw = 0.5;
     cThr   = 0;
     setAxes();
     allownoise     = false;
     state          = ERAState.Disarmed;
     timer1.Enabled = false;
     label2.Text    = "СТОП";
 }
Esempio n. 6
0
 private void StartupThrottle()
 {
     cThr = cThr + pParam * (centerThrottle - cThr) / 2.0 * ((double)timer1.Interval) / 1000.0;
     if (Math.Abs(cThr - centerThrottle) < 0.01)
     {
         count  = 0;
         cThr   = centerThrottle;
         desThr = centerThrottle * conv_mul;
         state  = ERAState.Idle;
     }
 }
Esempio n. 7
0
 private void performConversion()
 {
     count += ((double)timer1.Interval) / 1000.0;
     if (copter)
     {
         cConv = count;
     }
     else
     {
         cConv = 1 - count;
     }
     conv_mul = 1 - cConv * 0.3;
     if (count > 1)
     {
         state  = ERAState.Idle;
         copter = !copter;
         count  = 0;
     }
 }
Esempio n. 8
0
        //EditorTabItem TextBox_InvariantTab = new EditorTabItem(LTSTabItem);


        public ERAStateEditingForm(ERAState stateItem)
        {
            InitializeComponent();
            StateItem         = stateItem;
            TextBox_Name.Text = stateItem.Name;

            ////
            //// TextBox_Guard
            ////
            //TextBox_InvariantTab.Controls.Clear();
            //this.TextBox_InvariantTab.CodeEditor.Dock = DockStyle.None;
            //this.TextBox_InvariantTab.CodeEditor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
            //            | System.Windows.Forms.AnchorStyles.Right)));
            //this.TextBox_InvariantTab.CodeEditor.Location = new System.Drawing.Point(61, 58);
            //this.TextBox_InvariantTab.CodeEditor.Name = "TextBox_Guard";
            //this.TextBox_InvariantTab.CodeEditor.Size = new System.Drawing.Size(317, 91);
            //this.TextBox_InvariantTab.CodeEditor.TabIndex = 2;
            //this.Controls.Add(TextBox_InvariantTab.CodeEditor);

            TextBox_Invariant.Text        = stateItem.Invariant;
            CheckBox_Error.Checked        = stateItem.IsError;
            CheckBox_IsAcceptance.Checked = stateItem.IsAcceptance;
        }
Esempio n. 9
0
 private void FeederForm_Load(object sender, EventArgs e)
 {
     r             = new Random(DateTime.Now.Millisecond);
     DiscPovNumber = joystick.GetVJDDiscPovNumber(id);
     ContPovNumber = joystick.GetVJDContPovNumber(id);
     joystick.GetVJDAxisMax(id, HID_USAGES.HID_USAGE_X, ref maxval);
     // Reset this device to default values
     joystick.ResetVJD(id);
     X           = 20;
     Y           = 30;
     Z           = 40;
     XR          = 60;
     ZR          = 80;
     cPitch      = cRoll = cYaw = 0.5;
     desPitch    = desRoll = desYaw = 0.5;
     cThr        = 0;
     desThr      = 0;
     cConv       = 0;
     state       = ERAState.Disarmed;
     label2.Text = "НЕ ВЗВЕДЕНО";
     joystick.SetBtn(false, id, 1);
     pParam   = 2;
     waitTime = 1.5;
 }
Esempio n. 10
0
        private void WhatsNext()
        {
            count  += ((double)timer1.Interval) / 1000.0;
            cPitch -= (cPitch - desPitch) * 0.05 * pParam;
            cRoll  -= (cRoll - desRoll) * 0.05 * pParam;
            cThr   -= (cThr - desThr) * 0.05 * pParam;
            cYaw   -= (cYaw - desYaw) * 0.05 * pParam;
            if (count > waitTime)
            {
                count = 0;
                int rnd_num = (int)Math.Floor(r.NextDouble() * 10);
                switch (rnd_num)
                {
                case 8:
                    state = ERAState.Conversion;
                    break;

                default:
                    state = ERAState.Idle;
                    makeNewRandomSticks();
                    break;
                }
            }
        }