Ejemplo n.º 1
0
        void NewDataArrived(Object sender, NewDataEventArgs e)
        {
            switch (e.DataType)
            {
                case DataKey.FREQUENCY:
                    Globals.graphManager.timeStep = 1000 / e.IntData;

                    if (Globals.showDataInDebug)
                        Debug.Print("Freq={0}", 1000 / e.IntData);

                    break;
                case DataKey.SENSOR:
                    for (int i = 0; i < 3; ++i)
                        data[i] = Math.Round(smooth[i].Process(e.ArrayData[i]));

                    if (MouseEnabled)
                        Win32.MouseMouse((int)(-HandHorizontalSensivity * (data[1] - preData[1])), (int)(HandVerticalSensivity * (data[0] - preData[0])));

                    if (preData == null)
                        preData = (double[])data.Clone();
                    else Array.Copy(data, preData, 3);

                    if (Globals.showGraph)
                        Globals.graphManager.Update(data);

                    if (Globals.showDataInDebug)
                        Debug.Print("{0:0.00} {1:0.00} {2:0.00} {3:0.00} {4:0.00} {5:0.00}"
                            , data[0], data[1], data[2], e.ArrayData[0], e.ArrayData[1], e.ArrayData[2]);

                    break;
                case DataKey.COMMAND:
                    if (MouseEnabled)
                        Win32.PerformClick(e.IntData);

                    break;
            }
        }
Ejemplo n.º 2
0
        void NewDataArrived(Object sender, NewDataEventArgs e)
        {
            switch (e.DataType)
            {
                case DataKey.FREQUENCY:
                    Globals.graphManager.timeStep = 1000 / e.IntData;

                    if (Globals.showDataInDebug)
                        Debug.Print("Freq={0}", 1000 / e.IntData);

                    break;
                case DataKey.SENSOR:
                    for (int i = 0; i < 3; ++i)
                        data[i] = Math.Round(smooth[i].Process(e.ArrayData[i]));

                    if (isCalibrating)
                        Calibrate();

                    for (int i = 0; i < 3; ++i)
                        data[i] -= StillData[i];

                    if (startQuadcopter && !isCalibrating)
                        PerformFly();

                    if (Globals.showGraph)
                        Globals.graphManager.Update(data);

                    if (Globals.showDataInDebug)
                        Debug.Print("{0:0.00} {1:0.00} {2:0.00}", data[0], data[1], data[2]);

                    break;
                case DataKey.COMMAND:
                    switch (e.IntData)
                    {
                        case ButtonCommand.UP_CLICK:
                            quadControlWindow.PerformButtonClick(quadControlWindow.btnStartQuadcopter);

                            break;
                        case ButtonCommand.DOWN_CLICK:
                            quadControlWindow.PerformButtonClick(quadControlWindow.btnStillCalibration);

                            break;
                    }

                    break;
            }
        }
Ejemplo n.º 3
0
        public void OnNewFrequencyArrived(int frequency)
        {
            NewDataArrivedEventHandler handler = NewFrequencyArrived;
            if (handler != null)
            {
                NewDataEventArgs e = new NewDataEventArgs();
                e.IntData = frequency;
                e.DataType = DataKey.FREQUENCY;

                handler(this, e);
            }
        }
Ejemplo n.º 4
0
        private void OnNewSensorDataArrived(int[] data)
        {
            NewDataArrivedEventHandler handler = NewSensorDataArrived;
            if (handler != null)
            {
                NewDataEventArgs e = new NewDataEventArgs();
                e.DataType = DataKey.SENSOR;
                e.ArrayData = (int[])data.Clone();

                handler(this, e);
            }
        }
Ejemplo n.º 5
0
        public void OnNewCommandArrived(int command)
        {
            NewDataArrivedEventHandler handler = NewCommandArrived;
            if (handler != null)
            {
                NewDataEventArgs e = new NewDataEventArgs();
                e.IntData = command;
                e.DataType = DataKey.COMMAND;

                handler(this, e);
            }
        }