Esempio n. 1
0
        /// <summary>
        /// The Copy Constructor.
        /// </summary>
        /// <param name="rhs">The Axis object from which to copy</param>
        public Axis( Axis rhs )
        {
            _scale = rhs._scale.Clone( this );

            _cross = rhs._cross;

            _crossAuto = rhs._crossAuto;

            _majorTic = rhs.MajorTic.Clone();
            _minorTic = rhs.MinorTic.Clone();

            _majorGrid = rhs._majorGrid.Clone();
            _minorGrid = rhs._minorGrid.Clone();

            _isVisible = rhs.IsVisible;

            _isAxisSegmentVisible = rhs._isAxisSegmentVisible;

            _title = (AxisLabel) rhs.Title.Clone();

            _axisGap = rhs._axisGap;

            _minSpace = rhs.MinSpace;

            _color = rhs.Color;
        }
Esempio n. 2
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="TextScale" /> object from which to copy</param>
 /// <param name="owner">The <see cref="Axis" /> object that will own the
 /// new instance of <see cref="TextScale" /></param>
 public TextScale(Scale rhs, Axis owner)
     : base(rhs, owner)
 {
 }
Esempio n. 3
0
        /// <summary>
        /// Default constructor for <see cref="Axis"/> that sets all axis properties
        /// to default values as defined in the <see cref="Default"/> class.
        /// </summary>
        public Axis()
        {
            _scale = new LinearScale( this );

            _cross = 0.0;

            _crossAuto = true;

            _majorTic = new MajorTic();
            _minorTic = new MinorTic();

            _majorGrid = new MajorGrid();
            _minorGrid = new MinorGrid();

            _axisGap = Default.AxisGap;

            _minSpace = Default.MinSpace;
            _isVisible = true;

            _isAxisSegmentVisible = Default.IsAxisSegmentVisible;

            _title = new AxisLabel( "", Default.TitleFontFamily, Default.TitleFontSize,
                    Default.TitleFontColor, Default.TitleFontBold,
                    Default.TitleFontUnderline, Default.TitleFontItalic );
            _title.FontSpec.Fill = new Fill( Default.TitleFillColor, Default.TitleFillBrush,
                    Default.TitleFillType );

            _title.FontSpec.Border.IsVisible = false;

            _color = Default.Color;
        }
Esempio n. 4
0
        /// <summary>
        /// Copy Constructor.  Create a new <see cref="Scale" /> object based on the specified
        /// existing one.
        /// </summary>
        /// <param name="rhs">The <see cref="Scale" /> object to be copied.</param>
        /// <param name="owner">The <see cref="Axis" /> object that will own the
        /// new instance of <see cref="Scale" /></param>
        public Scale( Scale rhs, Axis owner )
        {
            _ownerAxis = owner;

            _min = rhs._min;
            _max = rhs._max;
            _majorStep = rhs._majorStep;
            _minorStep = rhs._minorStep;
            _exponent = rhs._exponent;
            _baseTic = rhs._baseTic;

            _minAuto = rhs._minAuto;
            _maxAuto = rhs._maxAuto;
            _majorStepAuto = rhs._majorStepAuto;
            _minorStepAuto = rhs._minorStepAuto;
            _magAuto = rhs._magAuto;
            _formatAuto = rhs._formatAuto;

            _minGrace = rhs._minGrace;
            _maxGrace = rhs._maxGrace;

            _mag = rhs._mag;

            _isUseTenPower = rhs._isUseTenPower;
            _isReverse = rhs._isReverse;
            _isPreventLabelOverlap = rhs._isPreventLabelOverlap;
            _isVisible = rhs._isVisible;
            _isSkipFirstLabel = rhs._isSkipFirstLabel;
            _isSkipLastLabel = rhs._isSkipLastLabel;
            _isSkipCrossLabel = rhs._isSkipCrossLabel;

            _majorUnit = rhs._majorUnit;
            _minorUnit = rhs._minorUnit;

            _format = rhs._format;

            _isLabelsInside = rhs._isLabelsInside;
            _align = rhs._align;
            _alignH = rhs._alignH;

            _fontSpec = (FontSpec) rhs._fontSpec.Clone();

            _labelGap = rhs._labelGap;

            if ( rhs._textLabels != null )
                _textLabels = (string[])rhs._textLabels.Clone();
            else
                _textLabels = null;
        }
Esempio n. 5
0
        private void mainGUI_Load(object sender, EventArgs e)
        {
            //First step, check it gui_settings file is exists or not, if not then start settings wizard
            if (!File.Exists(sGuiSettingsFilename))
            {
                setup_wizard panelSetupWizard = new setup_wizard();
                panelSetupWizard.ShowDialog();

            }

            //Now there must be a valid settings file, so we can continue with normal execution

            splash_screen splash = new splash_screen();
            splash.sVersionLabel = sVersion;
            splash.Show();
            splash.Refresh();
            //Start with Settings file read, and parse exit if unsuccessfull
            gui_settings = new GUI_settings();
            if (!gui_settings.read_from_xml(sGuiSettingsFilename))
            {
                Environment.Exit(-1);
            }

            sOptionsConfigFilename = sOptionsConfigFilename + gui_settings.iSoftwareVersion + ".xml";
            read_options_config();                  //read and parse optionsconfig.xml file. sets iCheckBoxItems

            mw_gui = new mw_data_gui(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion,gui_settings.bSupressI2CErrorData);

            mw_params = new mw_settings(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);

            //Define FC version dependant thingys :D
            if (gui_settings.iSoftwareVersion == 20)
            {
                PID_ROLL = 0; PID_PITCH = 1; PID_YAW = 2; PID_ALT = 3; PID_VEL = 4; PID_GPS = 5; PID_LEVEL = 6; PID_MAG = 7;
                iPacketSizeM = iPacketSizeM20;
                sRelName = sRelName20;
                splash.sFcVersionLabel = "MultiWii version " + sRelName20;
                if (gui_settings.bSupressI2CErrorData)
                {
                    l_i2cdatasupress.Text = "dev20120203 combatibity mode enabled";
                    iPacketSizeM = 153;     //This is hardcoded and eventually will be removed once MultiWii 2.0 is released
                    splash.sFcVersionLabel += Environment.NewLine + "20120203 compatibility mode";
                }
                splash.Refresh();


            }
            if (gui_settings.iSoftwareVersion == 19)
            {
                PID_ROLL = 0; PID_PITCH = 1; PID_YAW = 2; PID_ALT = 3; PID_VEL = 4; PID_LEVEL = 5; PID_MAG = 6;
                iPacketSizeM = iPacketSizeM19;
                sRelName = sRelName19;
                nPID_level_d.Visible = false;
                groupBoxGPS.Visible = false;
                splash.sFcVersionLabel = "MultiWii version " + sRelName19;
                splash.Refresh();

            }

            bSerialBuffer = new byte[iPacketSizeM];

            ToolTip toolTip1 = new ToolTip();
            toolTip1.AutoPopDelay = 5000;
            toolTip1.InitialDelay = 1000;
            toolTip1.ReshowDelay = 500;
            toolTip1.ShowAlways = true;

            rcOptions1 = new byte[iCheckBoxItems];
            rcOptions2 = new byte[iCheckBoxItems];

            //Fill out settings tab
            l_Capture_folder.Text = gui_settings.sCaptureFolder;
            l_LogFolder.Text = gui_settings.sLogFolder;
            l_Settings_folder.Text = gui_settings.sSettingsFolder;

            cb_Logging_enabled.Checked = gui_settings.bEnableLogging;
            switch (gui_settings.iSoftwareVersion)
            {
                case 19:
                    rb_sw19.Checked = true;
                    break;
                case 20:
                    rb_sw20.Checked = true;
                    break;
                default:
                    rb_sw20.Checked = true;
                    break;
            }

            //Set log enties checkboxes
            cb_Log1.Checked = gui_settings.logGraw;
            cb_Log2.Checked = gui_settings.logGatt;
            cb_Log3.Checked = gui_settings.logGmag;
            cb_Log4.Checked = gui_settings.logGrcc;
            cb_Log5.Checked = gui_settings.logGrcx;
            cb_Log6.Checked = gui_settings.logGmot;
            cb_Log7.Checked = gui_settings.logGsrv;
            cb_Log8.Checked = gui_settings.logGnav;
            cb_Log9.Checked = gui_settings.logGpar;
            cb_Log10.Checked = gui_settings.logGdbg;


            //Build the RC control checkboxes structure

            aux = new CheckBoxEx[4, 4, iCheckBoxItems];

            int startx = 200;
            int starty = 60;

            int a, b, c;
            for (c = 0; c < 4; c++)
            {
                for (a = 0; a < 3; a++)
                {
                    for (b = 0; b < iCheckBoxItems; b++)
                    {
                        aux[c, a, b] = new CheckBoxEx();
                        aux[c, a, b].Location = new Point(startx + a * 18 + c * 70, starty + b * 25);
                        aux[c, a, b].Visible = true;
                        aux[c, a, b].Text = "";
                        aux[c, a, b].AutoSize = true;
                        aux[c, a, b].Size = new Size(16, 16);
                        aux[c, a, b].UseVisualStyleBackColor = true;
                        aux[c, a, b].CheckedChanged += new System.EventHandler(this.aux_checked_changed_event);
                        //Set info on the given checkbox position
                        aux[c, a, b].aux = c;           //Which aux channel
                        aux[c, a, b].rclevel = a;       //which rc level
                        aux[c, a, b].item = b;          //Which item
                        this.tabPageRC.Controls.Add(aux[c, a, b]);

                    }
                }
            }

            aux_labels = new System.Windows.Forms.Label[4];
            lmh_labels = new System.Windows.Forms.Label[4, 3];          // aux1-4, L,M,H
            string strlmh = "LMH";
            for (a = 0; a < 4; a++)
            {
                aux_labels[a] = new System.Windows.Forms.Label();
                aux_labels[a].Text = "AUX" + String.Format("{0:0}", a + 1);
                aux_labels[a].Location = new Point(startx + a * 70 + 8, starty - 35);
                aux_labels[a].AutoSize = true;
                aux_labels[a].ForeColor = Color.White;
                this.tabPageRC.Controls.Add(aux_labels[a]);
                for (b = 0; b < 3; b++)
                {
                    lmh_labels[a, b] = new System.Windows.Forms.Label();
                    lmh_labels[a, b].Text = strlmh.Substring(b, 1); ;
                    lmh_labels[a, b].Location = new Point(startx + a * 70 + b * 18, starty - 20);
                    lmh_labels[a, b].AutoSize = true;
                    lmh_labels[a, b].ForeColor = Color.White;
                    this.tabPageRC.Controls.Add(lmh_labels[a, b]);
                }

            }

            cb_labels = new System.Windows.Forms.Label[20];

            for (z = 0; z < iCheckBoxItems; z++)
            {
                cb_labels[z] = new System.Windows.Forms.Label();
                cb_labels[z].Text = option_names[z];
                cb_labels[z].Location = new Point(10, starty + z * 25);
                cb_labels[z].Visible = true;
                cb_labels[z].AutoSize = true;
                cb_labels[z].ForeColor = Color.White;
                cb_labels[z].TextAlign = ContentAlignment.MiddleRight;
                toolTip1.SetToolTip(cb_labels[z], option_desc[z]);
                this.tabPageRC.Controls.Add(cb_labels[z]);
            }


            if (gui_settings.iSoftwareVersion == 19)
            {
                //Hide AUX3-AUX4 settings
                aux_labels[2].Visible = false;
                aux_labels[3].Visible = false;
                lmh_labels[2, 0].Visible = false;
                lmh_labels[2, 1].Visible = false;
                lmh_labels[2, 2].Visible = false;
                lmh_labels[3, 0].Visible = false;
                lmh_labels[3, 1].Visible = false;
                lmh_labels[3, 2].Visible = false;

                for (int i = 0; i < iCheckBoxItems; i++)
                {
                    aux[2, 0, i].Visible = false;
                    aux[2, 1, i].Visible = false;
                    aux[2, 2, i].Visible = false;
                    aux[3, 0, i].Visible = false;
                    aux[3, 1, i].Visible = false;
                    aux[3, 2, i].Visible = false;
                }
            }

            this.Refresh();

            serial_ports_enumerate();
            foreach (string speed in sSerialSpeeds)
            {
                cb_serial_speed.Items.Add(speed);
            }
            cb_serial_speed.SelectedItem = gui_settings.sPreferedSerialSpeed;

            if (cb_serial_port.Items.Count == 0)
            {
                b_connect.Enabled = false;          //Nos serial port, disable connect
            }

            //Init serial port object
            serialPort = new SerialPort();
            //Set up serial port parameters (at least the ones what we know upfront
            serialPort.DataBits = 8;
            serialPort.Parity = Parity.None;
            serialPort.StopBits = StopBits.One;
            serialPort.Handshake = Handshake.None;
            serialPort.DtrEnable = false;               //??

            serialPort.ReadBufferSize = 4096;            //4K byte of read buffer
            serialPort.ReadTimeout = 500;               // 500msec timeout;

            //Init Realtime Monitor panel controls
            foreach (string rate in sRefreshSpeeds)
            {
                cb_monitor_rate.Items.Add(rate);
            }
            cb_monitor_rate.SelectedIndex = 0;              //20Hz is the default

            //Setup timers
            timer_realtime.Tick += new EventHandler(timer_realtime_Tick);
            timer_realtime.Interval = iRefreshIntervals[cb_monitor_rate.SelectedIndex];
            timer_realtime.Enabled = true;
            timer_realtime.Stop();

            timer_rc.Tick += new EventHandler(timer_rc_Tick);
            timer_rc.Interval = 100; //(10Hz)
            timer_rc.Enabled = true;
            timer_rc.Stop();


            //Set up zgMonitor control for real time monitoring
            GraphPane myPane = zgMonitor.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "";
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "";

            //Set up pointlists and curves
            list_acc_roll = new RollingPointPairList(300);
            curve_acc_roll = myPane.AddCurve("acc_roll", list_acc_roll, Color.Red, SymbolType.None);

            list_acc_pitch = new RollingPointPairList(300);
            curve_acc_pitch = myPane.AddCurve("acc_pitch", list_acc_pitch, Color.Green, SymbolType.None);

            list_acc_z = new RollingPointPairList(300);
            curve_acc_z = myPane.AddCurve("acc_z", list_acc_z, Color.Blue, SymbolType.None);

            list_gyro_roll = new RollingPointPairList(300);
            curve_gyro_roll = myPane.AddCurve("gyro_roll", list_gyro_roll, Color.Khaki, SymbolType.None);

            list_gyro_pitch = new RollingPointPairList(300);
            curve_gyro_pitch = myPane.AddCurve("gyro_pitch", list_gyro_pitch, Color.Cyan, SymbolType.None);

            list_gyro_yaw = new RollingPointPairList(300);
            curve_gyro_yaw = myPane.AddCurve("gyro_yaw", list_gyro_yaw, Color.Magenta, SymbolType.None);

            list_mag_roll = new RollingPointPairList(300);
            curve_mag_roll = myPane.AddCurve("mag_roll", list_mag_roll, Color.CadetBlue, SymbolType.None);

            list_mag_pitch = new RollingPointPairList(300);
            curve_mag_pitch = myPane.AddCurve("mag_pitch", list_mag_pitch, Color.MediumPurple, SymbolType.None);

            list_mag_yaw = new RollingPointPairList(300);
            curve_mag_yaw = myPane.AddCurve("mag_yaw", list_mag_yaw, Color.DarkGoldenrod, SymbolType.None);

            list_alt = new RollingPointPairList(300);
            curve_alt = myPane.AddCurve("alt", list_alt, Color.White, SymbolType.None);

            list_head = new RollingPointPairList(300);
            curve_head = myPane.AddCurve("head", list_head, Color.Orange, SymbolType.None);

            list_dbg1 = new RollingPointPairList(300);
            curve_dbg1 = myPane.AddCurve("dbg1", list_dbg1, Color.PaleTurquoise, SymbolType.None);

            list_dbg2 = new RollingPointPairList(300);
            curve_dbg2 = myPane.AddCurve("dbg2", list_dbg2, Color.PaleTurquoise, SymbolType.None);

            list_dbg3 = new RollingPointPairList(300);
            curve_dbg3 = myPane.AddCurve("dbg3", list_dbg3, Color.PaleTurquoise, SymbolType.None);

            list_dbg4 = new RollingPointPairList(300);
            curve_dbg4 = myPane.AddCurve("dbg4", list_dbg4, Color.PaleTurquoise, SymbolType.None);

            // Show the x axis grid
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;

            myPane.XAxis.Scale.IsVisible = false;

            // Make the Y axis scale red
            myPane.YAxis.Scale.FontSpec.FontColor = Color.White;
            myPane.YAxis.Title.FontSpec.FontColor = Color.White;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;
            // Don't display the Y zero line
            myPane.YAxis.MajorGrid.IsZeroLine = true;
            // Align the Y axis labels so they are flush to the axis
            myPane.YAxis.Scale.Align = AlignP.Inside;
            myPane.YAxis.Scale.IsVisible = false;
            // Manually set the axis range
            myPane.YAxis.Scale.Min = -150;
            myPane.YAxis.Scale.Max = 150;

            myPane.Chart.Fill = new Fill(Color.DimGray, Color.DarkGray, 45.0f);
            myPane.Fill = new Fill(Color.DimGray, Color.DimGray, 45.0f);
            myPane.Legend.IsVisible = false;
            myPane.XAxis.Scale.IsVisible = false;
            myPane.YAxis.Scale.IsVisible = true;

            myPane.XAxis.Scale.MagAuto = true;
            myPane.YAxis.Scale.MagAuto = false;

            zgMonitor.IsEnableHPan = true;
            zgMonitor.IsEnableHZoom = true;

            foreach (ZedGraph.LineItem li in myPane.CurveList)
            {
                li.Line.Width = 1;
            }


            myPane.YAxis.Title.FontSpec.FontColor = Color.White;
            myPane.XAxis.Title.FontSpec.FontColor = Color.White;

            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 300;
            myPane.XAxis.Type = AxisType.Linear;
            
            
            
            zgMonitor.ScrollGrace = 0;
            xScale = zgMonitor.GraphPane.XAxis.Scale;
            zgMonitor.AxisChange();

            pictureBox2.BorderStyle = BorderStyle.None;

            //Init video capture dev
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    throw new ApplicationException();

                // add all devices to combo
                foreach (FilterInfo device in videoDevices)
                {
                    dropdown_devices.Items.Add(device.Name);
                }
            }
            catch (ApplicationException)
            {
                dropdown_devices.Items.Add("No local capture devices");
                dropdown_devices.Enabled = false;
                b_video_connect.Enabled = false;
            }

            dropdown_devices.SelectedIndex = 0;
            cb_codec.SelectedIndex = 0;

            //Drawing stuff for OSD
            drawPen = new Pen(Color.White, 1);
            drawFont = new System.Drawing.Font(FontFamily.GenericMonospace, 16.0F);
            drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);

            System.Threading.Thread.Sleep(2000);
            splash.Close();



        } //End of mainGUI_load
Esempio n. 6
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="OrdinalScale" /> object from which to copy</param>
 /// <param name="owner">The <see cref="Axis" /> object that will own the
 /// new instance of <see cref="OrdinalScale" /></param>
 public OrdinalScale( Scale rhs, Axis owner )
     : base(rhs, owner)
 {
 }
Esempio n. 7
0
        private void mainGUI_Load(object sender, EventArgs e)
        {
            //First step, check it gui_settings file is exists or not, if not then start settings wizard
            if (!File.Exists(sGuiSettingsFilename))
            {
                setup_wizard panelSetupWizard = new setup_wizard();
                panelSetupWizard.ShowDialog();

            }

            //Now there must be a valid settings file, so we can continue with normal execution

            splash_screen splash = new splash_screen();
            splash.sVersionLabel = sVersion;
            splash.Show();
            splash.Refresh();
            //Start with Settings file read, and parse exit if unsuccessfull
            gui_settings = new GUI_settings();
            if (!gui_settings.read_from_xml(sGuiSettingsFilename))
            {
                Environment.Exit(-1);
            }

            sOptionsConfigFilename = sOptionsConfigFilename + gui_settings.iSoftwareVersion + ".xml";
            read_options_config();                  //read and parse optionsconfig.xml file. sets iCheckBoxItems

            mw_gui = new mw_data_gui(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);
            mw_params = new mw_settings(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);

            splash.sFcVersionLabel = "MultiWii version " + sRelName;
            splash.sStatus = "Connecting to MAP server...";
            splash.Refresh();

            //Quick hack to get pid names to mw_params untill redo the structures
            for (int i = 0; i < iPidItems; i++)
            {
                mw_params.pidnames[i] = Pid[i].name;
            }

            cbMapProviders.SelectedIndex = gui_settings.iMapProviderSelectedIndex;
            MainMap.MapProvider = mapProviders[gui_settings.iMapProviderSelectedIndex];
            tb_mapzoom.Value = MainMap.MaxZoom;
            MainMap.Zoom = MainMap.MaxZoom;

            splash.sStatus = "Building up GUI elements...";
            splash.Refresh();

            bSerialBuffer = new byte[65];
            inBuf = new byte[300];   //init input buffer

            ToolTip toolTip1 = new ToolTip();
            toolTip1.AutoPopDelay = 5000;
            toolTip1.InitialDelay = 1000;
            toolTip1.ReshowDelay = 500;
            toolTip1.ShowAlways = true;

            //rcOptions1 = new byte[iCheckBoxItems];
            //rcOptions2 = new byte[iCheckBoxItems];

            //Fill out settings tab
            l_Capture_folder.Text = gui_settings.sCaptureFolder;
            l_LogFolder.Text = gui_settings.sLogFolder;
            l_Settings_folder.Text = gui_settings.sSettingsFolder;

            cb_Logging_enabled.Checked = gui_settings.bEnableLogging;

            //Set log enties checkboxes
            cb_Log1.Checked = gui_settings.logGraw;
            cb_Log2.Checked = gui_settings.logGatt;
            cb_Log3.Checked = gui_settings.logGmag;
            cb_Log4.Checked = gui_settings.logGrcc;
            cb_Log5.Checked = gui_settings.logGrcx;
            cb_Log6.Checked = gui_settings.logGmot;
            cb_Log7.Checked = gui_settings.logGsrv;
            cb_Log8.Checked = gui_settings.logGnav;
            cb_Log9.Checked = gui_settings.logGpar;
            cb_Log10.Checked = gui_settings.logGdbg;

            //Build PID control structure based on the Pid structure.

            const int iLineSpace = 36;
            const int iRow1 = 30;
            const int iRow2 = 125;
            const int iRow3 = 220;
            const int iTopY = 25;
            Font fontField = new Font("Tahoma", 9, FontStyle.Bold);
            Size fieldSize = new Size(70, 25);

            for (int i = 0; i < iPidItems; i++)
            {
                Pid[i].pidLabel = new System.Windows.Forms.Label();
                Pid[i].pidLabel.Text = Pid[i].name;
                Pid[i].pidLabel.Location = new Point(iRow1, 10 + i * iLineSpace);
                Pid[i].pidLabel.Visible = true;
                Pid[i].pidLabel.AutoSize = true;
                Pid[i].pidLabel.ForeColor = Color.White;
                Pid[i].pidLabel.TextAlign = ContentAlignment.MiddleRight;
                toolTip1.SetToolTip(Pid[i].pidLabel, Pid[i].description);
                this.tabPagePID.Controls.Add(Pid[i].pidLabel);

                if (Pid[i].Pshown)
                {
                    Pid[i].Pfield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Pfield.ValueChanged += new EventHandler(pfield_valuechange);
                    Pid[i].Pfield.Location = new Point(iRow1, iTopY + i * iLineSpace);
                    Pid[i].Pfield.Size = fieldSize;
                    Pid[i].Pfield.Font = fontField;
                    Pid[i].Pfield.BorderStyle = BorderStyle.None;
                    Pid[i].Pfield.Maximum = Pid[i].Pmax;
                    Pid[i].Pfield.Minimum = Pid[i].Pmin;
                    Pid[i].Pfield.DecimalPlaces = decimals(Pid[i].Pprec);
                    Pid[i].Pfield.Increment = 1 / (decimal)Pid[i].Pprec;
                    this.tabPagePID.Controls.Add(Pid[i].Pfield);

                    Pid[i].Plabel = new System.Windows.Forms.Label();
                    Pid[i].Plabel.Text = "P";
                    Pid[i].Plabel.Font = fontField;
                    Pid[i].Plabel.ForeColor = Color.White;
                    Pid[i].Plabel.Location = new Point(iRow1 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Plabel);

                }
                if (Pid[i].Ishown)
                {
                    Pid[i].Ifield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Ifield.ValueChanged += new EventHandler(ifield_valuechange);
                    Pid[i].Ifield.Location = new Point(iRow2, iTopY + i * iLineSpace);
                    Pid[i].Ifield.Size = fieldSize;
                    Pid[i].Ifield.Font = fontField;
                    Pid[i].Ifield.BorderStyle = BorderStyle.None;
                    Pid[i].Ifield.Maximum = Pid[i].Imax;
                    Pid[i].Ifield.Minimum = Pid[i].Imin;
                    Pid[i].Ifield.DecimalPlaces = decimals(Pid[i].Iprec);
                    Pid[i].Ifield.Increment = 1 / (decimal)Pid[i].Iprec;
                    this.tabPagePID.Controls.Add(Pid[i].Ifield);

                    Pid[i].Ilabel = new System.Windows.Forms.Label();
                    Pid[i].Ilabel.Text = "I";
                    Pid[i].Ilabel.Font = fontField;
                    Pid[i].Ilabel.ForeColor = Color.White;
                    Pid[i].Ilabel.Location = new Point(iRow2 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Ilabel);

                }
                if (Pid[i].Dshown)
                {
                    Pid[i].Dfield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Dfield.ValueChanged += new EventHandler(dfield_valuechange);
                    Pid[i].Dfield.Location = new Point(iRow3, iTopY + i * iLineSpace);
                    Pid[i].Dfield.Size = fieldSize;
                    Pid[i].Dfield.Font = fontField;
                    Pid[i].Dfield.BorderStyle = BorderStyle.None;
                    Pid[i].Dfield.Maximum = Pid[i].Dmax;
                    Pid[i].Dfield.Minimum = Pid[i].Dmin;
                    Pid[i].Dfield.DecimalPlaces = decimals(Pid[i].Dprec);
                    Pid[i].Dfield.Increment = 1 / (decimal)Pid[i].Dprec;
                    this.tabPagePID.Controls.Add(Pid[i].Dfield);

                    Pid[i].Dlabel = new System.Windows.Forms.Label();
                    Pid[i].Dlabel.Text = "D";
                    Pid[i].Dlabel.Font = fontField;
                    Pid[i].Dlabel.ForeColor = Color.White;
                    Pid[i].Dlabel.Location = new Point(iRow3 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Dlabel);

                }

            }

            toolTip1.SetToolTip(b_check_all_ACC, "Select all ACC values");
            toolTip1.SetToolTip(b_uncheck_all_ACC, "Deselect all ACC values");

            this.Refresh();

            serial_ports_enumerate();
            foreach (string speed in sSerialSpeeds)
            {
                cb_serial_speed.Items.Add(speed);
            }
            cb_serial_speed.SelectedItem = gui_settings.sPreferedSerialSpeed;

            if (cb_serial_port.Items.Count == 0)
            {
                b_connect.Enabled = false;          //Nos serial port, disable connect
            }

            //Init serial port object
            serialPort = new SerialPort();
            //Set up serial port parameters (at least the ones what we know upfront
            serialPort.DataBits = 8;
            serialPort.Parity = Parity.None;
            serialPort.StopBits = StopBits.One;
            serialPort.Handshake = Handshake.None;
            serialPort.DtrEnable = false;               //??

            serialPort.ReadBufferSize = 4096;            //4K byte of read buffer
            serialPort.ReadTimeout = 500;               // 500msec timeout;

            //Init Realtime Monitor panel controls
            foreach (string rate in sRefreshSpeeds)
            {
                cb_monitor_rate.Items.Add(rate);
            }
            cb_monitor_rate.SelectedIndex = 0;              //20Hz is the default

            //Setup timers
            timer_realtime.Tick += new EventHandler(timer_realtime_Tick);
            timer_realtime.Interval = iRefreshIntervals[cb_monitor_rate.SelectedIndex];
            timer_realtime.Enabled = true;
            timer_realtime.Stop();

            //Set up zgMonitor control for real time monitoring
            GraphPane myPane = zgMonitor.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "";
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "";

            //Set up pointlists and curves
            list_acc_roll = new RollingPointPairList(300);
            curve_acc_roll = myPane.AddCurve("acc_roll", list_acc_roll, Color.Red, SymbolType.None);

            list_acc_pitch = new RollingPointPairList(300);
            curve_acc_pitch = myPane.AddCurve("acc_pitch", list_acc_pitch, Color.Green, SymbolType.None);

            list_acc_z = new RollingPointPairList(300);
            curve_acc_z = myPane.AddCurve("acc_z", list_acc_z, Color.Blue, SymbolType.None);

            list_gyro_roll = new RollingPointPairList(300);
            curve_gyro_roll = myPane.AddCurve("gyro_roll", list_gyro_roll, Color.Khaki, SymbolType.None);

            list_gyro_pitch = new RollingPointPairList(300);
            curve_gyro_pitch = myPane.AddCurve("gyro_pitch", list_gyro_pitch, Color.Cyan, SymbolType.None);

            list_gyro_yaw = new RollingPointPairList(300);
            curve_gyro_yaw = myPane.AddCurve("gyro_yaw", list_gyro_yaw, Color.Magenta, SymbolType.None);

            list_mag_roll = new RollingPointPairList(300);
            curve_mag_roll = myPane.AddCurve("mag_roll", list_mag_roll, Color.CadetBlue, SymbolType.None);

            list_mag_pitch = new RollingPointPairList(300);
            curve_mag_pitch = myPane.AddCurve("mag_pitch", list_mag_pitch, Color.MediumPurple, SymbolType.None);

            list_mag_yaw = new RollingPointPairList(300);
            curve_mag_yaw = myPane.AddCurve("mag_yaw", list_mag_yaw, Color.DarkGoldenrod, SymbolType.None);

            list_alt = new RollingPointPairList(300);
            curve_alt = myPane.AddCurve("alt", list_alt, Color.White, SymbolType.None);

            list_head = new RollingPointPairList(300);
            curve_head = myPane.AddCurve("head", list_head, Color.Orange, SymbolType.None);

            list_dbg1 = new RollingPointPairList(300);
            curve_dbg1 = myPane.AddCurve("dbg1", list_dbg1, Color.PaleTurquoise, SymbolType.None);

            list_dbg2 = new RollingPointPairList(300);
            curve_dbg2 = myPane.AddCurve("dbg2", list_dbg2, Color.PaleTurquoise, SymbolType.None);

            list_dbg3 = new RollingPointPairList(300);
            curve_dbg3 = myPane.AddCurve("dbg3", list_dbg3, Color.PaleTurquoise, SymbolType.None);

            list_dbg4 = new RollingPointPairList(300);
            curve_dbg4 = myPane.AddCurve("dbg4", list_dbg4, Color.PaleTurquoise, SymbolType.None);

            // Show the x axis grid
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;

            myPane.XAxis.Scale.IsVisible = false;

            // Make the Y axis scale red
            myPane.YAxis.Scale.FontSpec.FontColor = Color.White;
            myPane.YAxis.Title.FontSpec.FontColor = Color.White;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;
            // Don't display the Y zero line
            myPane.YAxis.MajorGrid.IsZeroLine = true;
            // Align the Y axis labels so they are flush to the axis
            myPane.YAxis.Scale.Align = AlignP.Inside;
            myPane.YAxis.Scale.IsVisible = false;
            // Manually set the axis range
            myPane.YAxis.Scale.Min = -150;
            myPane.YAxis.Scale.Max = 150;

            myPane.Chart.Fill = new Fill(Color.DimGray, Color.DarkGray, 45.0f);
            myPane.Fill = new Fill(Color.DimGray, Color.DimGray, 45.0f);
            myPane.Legend.IsVisible = false;
            myPane.XAxis.Scale.IsVisible = false;
            myPane.YAxis.Scale.IsVisible = true;

            myPane.XAxis.Scale.MagAuto = true;
            myPane.YAxis.Scale.MagAuto = false;

            zgMonitor.IsEnableHPan = true;
            zgMonitor.IsEnableHZoom = true;

            foreach (ZedGraph.LineItem li in myPane.CurveList)
            {
                li.Line.Width = 1;
            }

            myPane.YAxis.Title.FontSpec.FontColor = Color.White;
            myPane.XAxis.Title.FontSpec.FontColor = Color.White;

            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 300;
            myPane.XAxis.Type = AxisType.Linear;

            zgMonitor.ScrollGrace = 0;
            xScale = zgMonitor.GraphPane.XAxis.Scale;
            zgMonitor.AxisChange();

            //Init video capture dev
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    throw new ApplicationException();

                // add all devices to combo
                foreach (FilterInfo device in videoDevices)
                {
                    dropdown_devices.Items.Add(device.Name);
                }
            }
            catch (ApplicationException)
            {
                dropdown_devices.Items.Add("No local capture devices");
                dropdown_devices.Enabled = false;
                b_video_connect.Enabled = false;
            }

            dropdown_devices.SelectedIndex = 0;
            cb_codec.SelectedIndex = 0;

            //Drawing stuff for OSD
            drawPen = new Pen(Color.White, 1);
            drawFont = new System.Drawing.Font(FontFamily.GenericMonospace, 16.0F);
            drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);

            //Disable buttons that are not working till connected
            b_reset.Enabled = false;
            b_cal_acc.Enabled = false;
            b_cal_mag.Enabled = false;
            b_read_settings.Enabled = false;
            b_write_settings.Enabled = false;

            //System.Threading.Thread.Sleep(2000);
            splash.Close();
        }
Esempio n. 8
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see cref="LogScale" /> object from which to copy</param>
		/// <param name="owner">The <see cref="Axis" /> object that will own the
		/// new instance of <see cref="LogScale" /></param>
		public LogScale( Scale rhs, Axis owner )
			: base( rhs, owner )
		{
		}
Esempio n. 9
0
        private void mainGUI_Load(object sender, EventArgs e)
        {
            //First step, check it gui_settings file is exists or not, if not then start settings wizard
            if (!File.Exists(sGuiSettingsFilename))
            {
                setup_wizard panelSetupWizard = new setup_wizard();
                panelSetupWizard.ShowDialog();

            }

            //Now there must be a valid settings file, so we can continue with normal execution

            splash_screen splash = new splash_screen();
            splash.sVersionLabel = sVersion;
            splash.Show();
            splash.Refresh();
            //Start with Settings file read, and parse exit if unsuccessfull
            gui_settings = new GUI_settings();
            if (!gui_settings.read_from_xml(sGuiSettingsFilename))
            {
                Environment.Exit(-1);
            }

            //fill out relevant variables
            cbGUISpeechEnabled.Checked = gui_settings.speech_enabled;
            sOptionsConfigFilename = sOptionsConfigFilename + ".xml";
            read_options_config();                  //read and parse optionsconfig.xml file. sets iCheckBoxItems
            iCheckBoxItems = 24;                    //Theoretical maximum

            splash.sStatus = "Building internal data structures...";
            splash.Refresh();

            mw_gui = new mw_data_gui(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);
            mw_params = new mw_settings(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);
            mission_step = new mission_step_structure();

            //Quick hack to get pid names to mw_params untill redo the structures
            for (int i = 0; i < iPidItems; i++)
            {
                mw_params.pidnames[i] = Pid[i].name;
            }

            splash.sFcVersionLabel = "MultiWii version " + sRelName;
            splash.sStatus = "Connecting to MAP server...";
            splash.Refresh();

            MainMap.Manager.Mode = AccessMode.ServerAndCache;
            if (!Stuff.PingNetwork("pingtest.com"))
            {
                MainMap.Manager.Mode = AccessMode.CacheOnly;
                MessageBox.Show("No internet connection available, going to CacheOnly mode.", "GMap.NET - Demo.WindowsForms", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }



            cbMapProviders.SelectedIndex = gui_settings.iMapProviderSelectedIndex;
            MainMap.MapProvider = mapProviders[gui_settings.iMapProviderSelectedIndex];
            MainMap.Zoom = 18;

            splash.sStatus = "Building up GUI elements...";
            splash.Refresh();

            bSerialBuffer = new byte[65];
            inBuf = new byte[300];   //init input buffer

            ToolTip toolTip1 = new ToolTip();
            toolTip1.AutoPopDelay = 5000;
            toolTip1.InitialDelay = 1000;
            toolTip1.ReshowDelay = 500;
            toolTip1.ShowAlways = true;

            //rcOptions1 = new byte[iCheckBoxItems];
            //rcOptions2 = new byte[iCheckBoxItems];

            //Fill out settings tab
            l_Capture_folder.Text = gui_settings.sCaptureFolder;
            l_LogFolder.Text = gui_settings.sLogFolder;
            l_Settings_folder.Text = gui_settings.sSettingsFolder;

            cb_Logging_enabled.Checked = gui_settings.bEnableLogging;

            //Set log enties checkboxes
            cb_Log1.Checked = gui_settings.logGraw;
            cb_Log2.Checked = gui_settings.logGatt;
            cb_Log3.Checked = gui_settings.logGmag;
            cb_Log4.Checked = gui_settings.logGrcc;
            cb_Log5.Checked = gui_settings.logGrcx;
            cb_Log6.Checked = gui_settings.logGmot;
            cb_Log7.Checked = gui_settings.logGsrv;
            cb_Log8.Checked = gui_settings.logGnav;
            cb_Log9.Checked = gui_settings.logGpar;
            cb_Log10.Checked = gui_settings.logGdbg;

            cbCellcount.SelectedIndex = gui_settings.cellcount - 1;
            cbGUISpeechEnabled.Checked = gui_settings.speech_enabled;
            cbSpeakAlt.Checked = gui_settings.announce_alt_enabled;
            cbSpeakBattery.Checked = gui_settings.announce_vbat_enabled;
            cbSpeakDist.Checked = gui_settings.announce_dist_enabled;
            comboSpeakInterval.SelectedIndex = gui_settings.announce_interval;

            b_save_gui_settings.BackColor = Color.Transparent;

            splash.sStatus = "Build PID structures...";
            splash.Refresh();


            //Build servo control arrays
            // It is a mess and not an elegant solution BUT WORKS
            servo_text = new System.Windows.Forms.Label[8];
            servo_text[0] = lSrvName1;
            servo_text[1] = lSrvName2;
            servo_text[2] = lSrvName3;
            servo_text[3] = lSrvName4;
            servo_text[4] = lSrvName5;
            servo_text[5] = lSrvName6;
            servo_text[6] = lSrvName7;
            servo_text[7] = lSrvName8;

            servo_reverse = new CheckBoxEx[8];
            servo_reverse[0] = cbSrvRev1;
            servo_reverse[1] = cbSrvRev2;
            servo_reverse[2] = cbSrvRev3;
            servo_reverse[3] = cbSrvRev4;
            servo_reverse[4] = cbSrvRev5;
            servo_reverse[5] = cbSrvRev6;
            servo_reverse[6] = cbSrvRev7;
            servo_reverse[7] = cbSrvRev8;

            servo_rate = new System.Windows.Forms.NumericUpDown[8];
            servo_rate[0] = nSrvRate1;
            servo_rate[1] = nSrvRate2;
            servo_rate[2] = nSrvRate3;
            servo_rate[3] = nSrvRate4;
            servo_rate[4] = nSrvRate5;
            servo_rate[5] = nSrvRate6;
            servo_rate[6] = nSrvRate7;
            servo_rate[7] = nSrvRate8;

            servo_min = new System.Windows.Forms.NumericUpDown[8];
            servo_min[0] = nSrvMin1;
            servo_min[1] = nSrvMin2;
            servo_min[2] = nSrvMin3;
            servo_min[3] = nSrvMin4;
            servo_min[4] = nSrvMin5;
            servo_min[5] = nSrvMin6;
            servo_min[6] = nSrvMin7;
            servo_min[7] = nSrvMin8;

            servo_mid = new System.Windows.Forms.NumericUpDown[8];
            servo_mid[0] = nSrvMid1;
            servo_mid[1] = nSrvMid2;
            servo_mid[2] = nSrvMid3;
            servo_mid[3] = nSrvMid4;
            servo_mid[4] = nSrvMid5;
            servo_mid[5] = nSrvMid6;
            servo_mid[6] = nSrvMid7;
            servo_mid[7] = nSrvMid8;

            servo_max = new System.Windows.Forms.NumericUpDown[8];
            servo_max[0] = nSrvMax1;
            servo_max[1] = nSrvMax2;
            servo_max[2] = nSrvMax3;
            servo_max[3] = nSrvMax4;
            servo_max[4] = nSrvMax5;
            servo_max[5] = nSrvMax6;
            servo_max[6] = nSrvMax7;
            servo_max[7] = nSrvMax8;


            //Build PID control structure based on the Pid structure.

            const int iLineSpace = 36;
            const int iRow1 = 30;
            const int iRow2 = 130;
            const int iRow3 = 230;
            const int iTopY = 25;
            Font fontField = new Font("Tahoma", 9, FontStyle.Bold);
            Size fieldSize = new Size(70, 25);

            for (int i = 0; i < iPidItems; i++)
            {
                Pid[i].pidLabel = new System.Windows.Forms.Label();
                Pid[i].pidLabel.Text = Pid[i].name;
                Pid[i].pidLabel.Location = new Point(iRow1, 10 + i * iLineSpace);
                Pid[i].pidLabel.Visible = true;
                Pid[i].pidLabel.AutoSize = true;
                Pid[i].pidLabel.ForeColor = Color.White;
                Pid[i].pidLabel.TextAlign = ContentAlignment.MiddleRight;
                toolTip1.SetToolTip(Pid[i].pidLabel, Pid[i].description);
                this.tabPagePID.Controls.Add(Pid[i].pidLabel);

                if (Pid[i].Pshown)
                {
                    Pid[i].Pfield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Pfield.ValueChanged += new EventHandler(pfield_valuechange);
                    Pid[i].Pfield.Location = new Point(iRow1, iTopY + i * iLineSpace);
                    Pid[i].Pfield.Size = fieldSize;
                    Pid[i].Pfield.Font = fontField;
                    Pid[i].Pfield.BorderStyle = BorderStyle.None;
                    Pid[i].Pfield.Maximum = Pid[i].Pmax;
                    Pid[i].Pfield.Minimum = Pid[i].Pmin;
                    Pid[i].Pfield.DecimalPlaces = decimals(Pid[i].Pprec);
                    Pid[i].Pfield.Increment = 1 / (decimal)Pid[i].Pprec;
                    this.tabPagePID.Controls.Add(Pid[i].Pfield);

                    Pid[i].Plabel = new System.Windows.Forms.Label();
                    Pid[i].Plabel.Text = "P";
                    Pid[i].Plabel.Font = fontField;
                    Pid[i].Plabel.ForeColor = Color.White;
                    Pid[i].Plabel.Location = new Point(iRow1 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Plabel);

                }
                if (Pid[i].Ishown)
                {
                    Pid[i].Ifield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Ifield.ValueChanged += new EventHandler(ifield_valuechange);
                    Pid[i].Ifield.Location = new Point(iRow2, iTopY + i * iLineSpace);
                    Pid[i].Ifield.Size = fieldSize;
                    Pid[i].Ifield.Font = fontField;
                    Pid[i].Ifield.BorderStyle = BorderStyle.None;
                    Pid[i].Ifield.Maximum = Pid[i].Imax;
                    Pid[i].Ifield.Minimum = Pid[i].Imin;
                    Pid[i].Ifield.DecimalPlaces = decimals(Pid[i].Iprec);
                    Pid[i].Ifield.Increment = 1 / (decimal)Pid[i].Iprec;
                    this.tabPagePID.Controls.Add(Pid[i].Ifield);

                    Pid[i].Ilabel = new System.Windows.Forms.Label();
                    Pid[i].Ilabel.Text = "I";
                    Pid[i].Ilabel.Font = fontField;
                    Pid[i].Ilabel.ForeColor = Color.White;
                    Pid[i].Ilabel.Location = new Point(iRow2 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Ilabel);



                }
                if (Pid[i].Dshown)
                {
                    Pid[i].Dfield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Dfield.ValueChanged += new EventHandler(dfield_valuechange);
                    Pid[i].Dfield.Location = new Point(iRow3, iTopY + i * iLineSpace);
                    Pid[i].Dfield.Size = fieldSize;
                    Pid[i].Dfield.Font = fontField;
                    Pid[i].Dfield.BorderStyle = BorderStyle.None;
                    Pid[i].Dfield.Maximum = Pid[i].Dmax;
                    Pid[i].Dfield.Minimum = Pid[i].Dmin;
                    Pid[i].Dfield.DecimalPlaces = decimals(Pid[i].Dprec);
                    Pid[i].Dfield.Increment = 1 / (decimal)Pid[i].Dprec;
                    this.tabPagePID.Controls.Add(Pid[i].Dfield);

                    Pid[i].Dlabel = new System.Windows.Forms.Label();
                    Pid[i].Dlabel.Text = "D";
                    Pid[i].Dlabel.Font = fontField;
                    Pid[i].Dlabel.ForeColor = Color.White;
                    Pid[i].Dlabel.Location = new Point(iRow3 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Dlabel);

                }


                //Set up stuff at the mission palane
                txtDefAlt.Text = iDefAlt.ToString();        //Set up default altitude
                txtGTCAlt.Text = iGTCAlt.ToString();        //Set up default Go to Click altitude


            }


            //Tooltips (needs improvement)

            toolTip1.SetToolTip(b_check_all_ACC, "Select all ACC values");
            toolTip1.SetToolTip(b_uncheck_all_ACC, "Deselect all ACC values");
            toolTip1.SetToolTip(lDefAlt, "Default waypoint altitude (in Above Ground Level where Home position Ground level is zero)");
            toolTip1.SetToolTip(txtDefAlt, "Default waypoint altitude (in Above Ground Level where Home position Ground level is zero)");






            this.Refresh();

            splash.sStatus = "Check serial ports...";
            splash.Refresh();



            serial_ports_enumerate();
            foreach (string speed in sSerialSpeeds)
            {
                cb_serial_speed.Items.Add(speed);
            }
            cb_serial_speed.SelectedItem = gui_settings.sPreferedSerialSpeed;

            if (cb_serial_port.Items.Count == 0)
            {
                b_connect.Enabled = false;          //Nos serial port, disable connect
            }

            //Init serial port object
            serialPort = new SerialPort();
            //Set up serial port parameters (at least the ones what we know upfront
            serialPort.DataBits = 8;
            serialPort.Parity = Parity.None;
            serialPort.StopBits = StopBits.One;
            serialPort.Handshake = Handshake.None;
            serialPort.DtrEnable = false;               //??

            serialPort.ReadBufferSize = 4096;            //4K byte of read buffer
            serialPort.ReadTimeout = 500;               // 500msec timeout;




            //Init Realtime Monitor panel controls
            foreach (string rate in sRefreshSpeeds)
            {
                cb_monitor_rate.Items.Add(rate);
            }
            cb_monitor_rate.SelectedIndex = 1;              //10Hz is the default

            splash.sStatus = "Setup Timers...";
            splash.Refresh();



            //Setup timers
            timer_realtime.Tick += new EventHandler(timer_realtime_Tick);
            timer_realtime.Interval = iRefreshIntervals[cb_monitor_rate.SelectedIndex];
            timer_realtime.Enabled = true;
            timer_realtime.Stop();


            splash.sStatus = "Setup zgMonitor control...";
            splash.Refresh();


            //Set up zgMonitor control for real time monitoring
            GraphPane myPane = zgMonitor.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "";
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "";

            //Set up pointlists and curves
            list_acc_roll = new RollingPointPairList(300);
            curve_acc_roll = myPane.AddCurve("acc_roll", list_acc_roll, Color.Red, SymbolType.None);

            list_acc_pitch = new RollingPointPairList(300);
            curve_acc_pitch = myPane.AddCurve("acc_pitch", list_acc_pitch, Color.Green, SymbolType.None);

            list_acc_z = new RollingPointPairList(300);
            curve_acc_z = myPane.AddCurve("acc_z", list_acc_z, Color.Blue, SymbolType.None);

            list_gyro_roll = new RollingPointPairList(300);
            curve_gyro_roll = myPane.AddCurve("gyro_roll", list_gyro_roll, Color.Khaki, SymbolType.None);

            list_gyro_pitch = new RollingPointPairList(300);
            curve_gyro_pitch = myPane.AddCurve("gyro_pitch", list_gyro_pitch, Color.Cyan, SymbolType.None);

            list_gyro_yaw = new RollingPointPairList(300);
            curve_gyro_yaw = myPane.AddCurve("gyro_yaw", list_gyro_yaw, Color.Magenta, SymbolType.None);

            list_mag_roll = new RollingPointPairList(300);
            curve_mag_roll = myPane.AddCurve("mag_roll", list_mag_roll, Color.CadetBlue, SymbolType.None);

            list_mag_pitch = new RollingPointPairList(300);
            curve_mag_pitch = myPane.AddCurve("mag_pitch", list_mag_pitch, Color.MediumPurple, SymbolType.None);

            list_mag_yaw = new RollingPointPairList(300);
            curve_mag_yaw = myPane.AddCurve("mag_yaw", list_mag_yaw, Color.DarkGoldenrod, SymbolType.None);

            list_alt = new RollingPointPairList(300);
            curve_alt = myPane.AddCurve("alt", list_alt, Color.White, SymbolType.None);

            list_head = new RollingPointPairList(300);
            curve_head = myPane.AddCurve("head", list_head, Color.Orange, SymbolType.None);

            list_dbg1 = new RollingPointPairList(300);
            curve_dbg1 = myPane.AddCurve("dbg1", list_dbg1, Color.PaleTurquoise, SymbolType.None);

            list_dbg2 = new RollingPointPairList(300);
            curve_dbg2 = myPane.AddCurve("dbg2", list_dbg2, Color.PaleTurquoise, SymbolType.None);

            list_dbg3 = new RollingPointPairList(300);
            curve_dbg3 = myPane.AddCurve("dbg3", list_dbg3, Color.PaleTurquoise, SymbolType.None);

            list_dbg4 = new RollingPointPairList(300);
            curve_dbg4 = myPane.AddCurve("dbg4", list_dbg4, Color.PaleTurquoise, SymbolType.None);

            // Show the x axis grid
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.MajorGrid.Color = Color.DarkGray;
            myPane.YAxis.MajorGrid.Color = Color.DarkGray;


            myPane.XAxis.Scale.IsVisible = false;

            // Make the Y axis scale red
            myPane.YAxis.Scale.FontSpec.FontColor = Color.DarkGray;
            myPane.YAxis.Title.FontSpec.FontColor = Color.DarkGray;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;
            // Don't display the Y zero line
            myPane.YAxis.MajorGrid.IsZeroLine = true;
            // Align the Y axis labels so they are flush to the axis
            myPane.YAxis.Scale.Align = AlignP.Inside;
            myPane.YAxis.Color = Color.DarkGray;
            myPane.YAxis.Scale.IsVisible = false;
            // Manually set the axis range
            myPane.YAxis.Scale.Min = -300;
            myPane.YAxis.Scale.Max = 300;
            myPane.XAxis.Color = Color.DarkGray;

            myPane.Border.Color = Color.FromArgb(64, 64, 64);

            myPane.Chart.Fill = new Fill(Color.Black, Color.Black, 45.0f);
            myPane.Fill = new Fill(Color.FromArgb(64, 64, 64), Color.FromArgb(64, 64, 64), 45.0f);
            myPane.Legend.IsVisible = false;
            myPane.XAxis.Scale.IsVisible = false;
            myPane.YAxis.Scale.IsVisible = true;

            myPane.XAxis.Scale.MagAuto = true;
            myPane.YAxis.Scale.MagAuto = false;

            zgMonitor.IsEnableHPan = true;
            zgMonitor.IsEnableHZoom = true;

            foreach (ZedGraph.LineItem li in myPane.CurveList)
            {
                li.Line.Width = 1;
            }


            myPane.YAxis.Title.FontSpec.FontColor = Color.DarkGray;
            myPane.XAxis.Title.FontSpec.FontColor = Color.DarkGray;

            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 300;
            myPane.XAxis.Type = AxisType.Linear;



            zgMonitor.ScrollGrace = 0;
            xScale = zgMonitor.GraphPane.XAxis.Scale;
            zgMonitor.AxisChange();


            splash.sStatus = "Init video capture structures...";
            splash.Refresh();



            //Init video capture dev
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    throw new ApplicationException();

                // add all devices to combo
                foreach (FilterInfo device in videoDevices)
                {
                    dropdown_devices.Items.Add(device.Name);
                }
            }
            catch (ApplicationException)
            {
                dropdown_devices.Items.Add("No local capture devices");
                dropdown_devices.Enabled = false;
                b_video_connect.Enabled = false;
            }

            dropdown_devices.SelectedIndex = 0;
            cb_codec.SelectedIndex = 0;

            //Drawing stuff for OSD
            drawPen = new Pen(Color.White, 1);
            drawFont = new System.Drawing.Font(FontFamily.GenericMonospace, 16.0F);
            drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);


            //Disable buttons that are not working till connected
            b_reset.Enabled = false;
            b_cal_acc.Enabled = false;
            b_cal_mag.Enabled = false;
            b_read_settings.Enabled = false;
            b_write_settings.Enabled = false;
            b_write_to_file.Enabled = false;
            b_load_from_file.Enabled = false;
            btnDownLoadMission.Enabled = false;
            btnUploadMission.Enabled = false;



            //init instrument panels
            altitude_meter1.SetAlimeterParameters(0);
            vertical_speed_indicator1.SetVerticalSpeedIndicatorParameters(0);


            System.Threading.Thread.Sleep(2000);
            splash.Close();
            MainMap.Invalidate(false);

            int w = MainMap.Size.Width;
            MainMap.Width = w +1 ;
            MainMap.Width = w;
            MainMap.ShowCenter = false;


            mw_gui.max_wp_number = gui_settings.max_wp_number;
            mw_gui.wp_radius = gui_settings.wp_radius;

            //Welcome message from Anna
            if (gui_settings.speech_enabled)
            {
                speech = new SpeechSynthesizer();
                speech.Rate = -2;
                speech.SpeakAsync("Initialisation completed. Have a good flight!");
            }

        }
Esempio n. 10
0
		/// <summary>
		/// Calculate a step size for a <see cref="AxisType.Date"/> scale.
		/// This method is used by <see cref="PickScale"/>.
		/// </summary>
		/// <param name="range">The range of data in units of days</param>
		/// <param name="targetSteps">The desired "typical" number of steps
		/// to divide the range into</param>
		/// <param name="scale">
		/// The <see cref="Scale" /> object on which to calculate the Date step size.</param>
		/// <returns>The calculated step size for the specified data range.  Also
		/// calculates and sets the values for <see cref="Scale.MajorUnit"/>,
		/// <see cref="Scale.MinorUnit"/>, <see cref="Scale.MinorStep"/>, and
		/// <see cref="Scale.Format"/></returns>
		internal static double CalcDateStepSize(double range, double targetSteps, Scale scale)
		{
			// Calculate an initial guess at step size
			double tempStep = range/targetSteps;

			if (range > Default.RangeYearYear) {
				scale._majorUnit = DateUnit.Year;
				if (scale._formatAuto)
					scale._format = Default.FormatYearYear;

				tempStep = Math.Ceiling(tempStep/365.0);

				if (scale._minorStepAuto) {
					scale._minorUnit = DateUnit.Year;
					if (tempStep == 1.0)
						scale._minorStep = 0.25;
					else
						scale._minorStep = Scale.CalcStepSize(tempStep, targetSteps);
				}
			}
			else if (range > Default.RangeYearMonth) {
				scale._majorUnit = DateUnit.Year;
				if (scale._formatAuto)
					scale._format = Default.FormatYearMonth;
				tempStep = Math.Ceiling(tempStep/365.0);

				if (scale._minorStepAuto) {
					scale._minorUnit = DateUnit.Month;
					// Calculate the minor steps to give an estimated 4 steps
					// per major step.
					scale._minorStep = Math.Ceiling(range/(targetSteps*3)/30.0);
					// make sure the minorStep is 1, 2, 3, 6, or 12 months
					if (scale._minorStep > 6)
						scale._minorStep = 12;
					else if (scale._minorStep > 3)
						scale._minorStep = 6;
				}
			}
			else if (range > Default.RangeMonthMonth) {
				scale._majorUnit = DateUnit.Month;
				if (scale._formatAuto)
					scale._format = Default.FormatMonthMonth;
				tempStep = Math.Ceiling(tempStep/30.0);

				if (scale._minorStepAuto) {
					scale._minorUnit = DateUnit.Month;
					scale._minorStep = tempStep*0.25;
				}
			}
			else if (range > Default.RangeDayDay) {
				scale._majorUnit = DateUnit.Day;
				if (scale._formatAuto)
					scale._format = Default.FormatDayDay;
				tempStep = Math.Ceiling(tempStep);

				if (scale._minorStepAuto) {
					scale._minorUnit = DateUnit.Day;
					scale._minorStep = tempStep*0.25;
					// make sure the minorStep is 1, 2, 3, 6, or 12 hours
				}
			}
			else if (range > Default.RangeDayHour) {
				scale._majorUnit = DateUnit.Day;
				if (scale._formatAuto)
					scale._format = Default.FormatDayHour;
				tempStep = Math.Ceiling(tempStep);

				if (scale._minorStepAuto) {
					scale._minorUnit = DateUnit.Hour;
					// Calculate the minor steps to give an estimated 4 steps
					// per major step.
					scale._minorStep = Math.Ceiling(range/(targetSteps*3)*XDate.HoursPerDay);
					// make sure the minorStep is 1, 2, 3, 6, or 12 hours
					if (scale._minorStep > 6)
						scale._minorStep = 12;
					else if (scale._minorStep > 3)
						scale._minorStep = 6;
					else
						scale._minorStep = 1;
				}
			}
			else if (range > Default.RangeHourHour) {
				scale._majorUnit = DateUnit.Hour;
				tempStep = Math.Ceiling(tempStep*XDate.HoursPerDay);
				if (scale._formatAuto)
					scale._format = Default.FormatHourHour;

				if (tempStep > 12.0)
					tempStep = 24.0;
				else if (tempStep > 6.0)
					tempStep = 12.0;
				else if (tempStep > 2.0)
					tempStep = 6.0;
				else if (tempStep > 1.0)
					tempStep = 2.0;
				else
					tempStep = 1.0;

				if (scale._minorStepAuto) {
					scale._minorUnit = DateUnit.Hour;
					if (tempStep <= 1.0)
						scale._minorStep = 0.25;
					else if (tempStep <= 6.0)
						scale._minorStep = 1.0;
					else if (tempStep <= 12.0)
						scale._minorStep = 2.0;
					else
						scale._minorStep = 4.0;
				}
			}
			else if (range > Default.RangeHourMinute) {
				scale._majorUnit = DateUnit.Hour;
				tempStep = Math.Ceiling(tempStep*XDate.HoursPerDay);

				if (scale._formatAuto)
					scale._format = Default.FormatHourMinute;

				if (scale._minorStepAuto) {
					scale._minorUnit = DateUnit.Minute;
					// Calculate the minor steps to give an estimated 4 steps
					// per major step.
					scale._minorStep = Math.Ceiling(range/(targetSteps*3)*XDate.MinutesPerDay);
					// make sure the minorStep is 1, 5, 15, or 30 minutes
					if (scale._minorStep > 15.0)
						scale._minorStep = 30.0;
					else if (scale._minorStep > 5.0)
						scale._minorStep = 15.0;
					else if (scale._minorStep > 1.0)
						scale._minorStep = 5.0;
					else
						scale._minorStep = 1.0;
				}
			}
			else if (range > Default.RangeMinuteMinute) {
				scale._majorUnit = DateUnit.Minute;
				if (scale._formatAuto)
					scale._format = Default.FormatMinuteMinute;

				tempStep = Math.Ceiling(tempStep*XDate.MinutesPerDay);
				// make sure the minute step size is 1, 5, 15, or 30 minutes
				if (tempStep > 15.0)
					tempStep = 30.0;
				else if (tempStep > 5.0)
					tempStep = 15.0;
				else if (tempStep > 1.0)
					tempStep = 5.0;
				else
					tempStep = 1.0;

				if (scale._minorStepAuto) {
					scale._minorUnit = DateUnit.Minute;
					if (tempStep <= 1.0)
						scale._minorStep = 0.25;
					else if (tempStep <= 5.0)
						scale._minorStep = 1.0;
					else
						scale._minorStep = 5.0;
				}
			}
			else if (range > Default.RangeMinuteSecond) {
				scale._majorUnit = DateUnit.Minute;
				tempStep = Math.Ceiling(tempStep*XDate.MinutesPerDay);

				if (scale._formatAuto)
					scale._format = Default.FormatMinuteSecond;

				if (scale._minorStepAuto) {
					scale._minorUnit = DateUnit.Second;
					// Calculate the minor steps to give an estimated 4 steps
					// per major step.
					scale._minorStep = Math.Ceiling(range/(targetSteps*3)*XDate.SecondsPerDay);
					// make sure the minorStep is 1, 5, 15, or 30 seconds
					if (scale._minorStep > 15.0)
						scale._minorStep = 30.0;
					else if (scale._minorStep > 5.0)
						scale._minorStep = 15.0;
					else if (scale._minorStep > 1.0)
						scale._minorStep = 5.0;
					else
						scale._minorStep = 1.0;
				}
			}
			else if (range > Default.RangeSecondSecond) // SecondSecond
			{
				scale._majorUnit = DateUnit.Second;
				if (scale._formatAuto)
					scale._format = Default.FormatSecondSecond;

				tempStep = Math.Ceiling(tempStep*XDate.SecondsPerDay);
				// make sure the second step size is 1, 5, 15, or 30 seconds
				if (tempStep > 15.0)
					tempStep = 30.0;
				else if (tempStep > 5.0)
					tempStep = 15.0;
				else if (tempStep > 1.0)
					tempStep = 5.0;
				else
					tempStep = 1.0;

				if (scale._minorStepAuto) {
					scale._minorUnit = DateUnit.Second;
					if (tempStep <= 1.0)
						scale._minorStep = 0.25;
					else if (tempStep <= 5.0)
						scale._minorStep = 1.0;
					else
						scale._minorStep = 5.0;
				}
			}
			else // MilliSecond
			{
				scale._majorUnit = DateUnit.Millisecond;
				if (scale._formatAuto)
					scale._format = Default.FormatMillisecond;

				tempStep = CalcStepSize(range*XDate.MillisecondsPerDay, Default.TargetXSteps);

				if (scale._minorStepAuto) {
					scale._minorStep = CalcStepSize(tempStep,
					                                (scale._ownerAxis is XAxis || scale._ownerAxis is X2Axis)
					                                	? Default.TargetMinorXSteps
					                                	: Default.TargetMinorYSteps);
					scale._minorUnit = DateUnit.Millisecond;
				}
			}

			return tempStep;
		}
Esempio n. 11
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see cref="DateScale" /> object from which to copy</param>
		/// <param name="owner">The <see cref="Axis" /> object that will own the
		/// new instance of <see cref="DateScale" /></param>
		public DateScale(Scale rhs, Axis owner)
			: base(rhs, owner)
		{
		}
Esempio n. 12
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="LinearScale" /> object from which to copy</param>
 /// <param name="owner">The <see cref="Axis" /> object that will own the
 /// new instance of <see cref="LinearScale" /></param>
 public LinearScale(Scale rhs, Axis owner)
     : base(rhs, owner)
 {
 }
Esempio n. 13
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see cref="ExponentScale" /> object from which to copy</param>
		/// <param name="owner">The <see cref="Axis" /> object that will own the
		/// new instance of <see cref="ExponentScale" /></param>
		public ExponentScale( Scale rhs, Axis owner )
			: base( rhs, owner )
		{
		}
Esempio n. 14
0
        private void mainGUI_Load(object sender, EventArgs e)
        {
            //First step, check it gui_settings file is exists or not, if not then start settings wizard
            //if (!File.Exists(sGuiSettingsFilename))
            //{
            //    setup_wizard panelSetupWizard = new setup_wizard();
            //    panelSetupWizard.ShowDialog();

            //}

            //Now there must be a valid settings file, so we can continue with normal execution
            //Start with Settings file read, and parse exit if unsuccessfull
            gui_settings = new GUI_settings();
            //if (!gui_settings.read_from_xml(sGuiSettingsFilename))
            //{
            //    Environment.Exit(-1);
               // }

            sOptionsConfigFilename = sOptionsConfigFilename + gui_settings.iSoftwareVersion + ".xml";
            read_options_config();                  //read and parse optionsconfig.xml file. sets iCheckBoxItems

            mw_gui = new mw_data_gui(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);
            mw_params = new mw_settings(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);

            //Quick hack to get pid names to mw_params untill redo the structures
            for (int i = 0; i < iPidItems; i++)
            {
                mw_params.pidnames[i] = Pid[i].name;
            }

            bSerialBuffer = new byte[65];
            inBuf = new byte[300];   //init input buffer

            ToolTip toolTip1 = new ToolTip();
            toolTip1.AutoPopDelay = 5000;
            toolTip1.InitialDelay = 1000;
            toolTip1.ReshowDelay = 500;
            toolTip1.ShowAlways = true;

            //rcOptions1 = new byte[iCheckBoxItems];
            //rcOptions2 = new byte[iCheckBoxItems];

            //Fill out settings tab
            //l_Settings_folder.Text = gui_settings.sSettingsFolder;

            #region Indicator_Struct
            //Build indicator lamps array
            indicators = new indicator_lamp[iCheckBoxItems];
            int row = 0; int col = 0;
            int startx = 468; int starty = 269;
            for (int i = 0; i < iCheckBoxItems; i++)
            {
                indicators[i] = new indicator_lamp();
                indicators[i].Location = new Point(startx + col * 52, starty + row * 19);
                indicators[i].Visible = true;
                indicators[i].Text = option_indicators[i];
                indicators[i].indicator_color = 1;
                indicators[i].Anchor = AnchorStyles.Right;
                this.splitContainer1.Panel2.Controls.Add(indicators[i]);
                //this.panel1.Controls.Add(indicators[i]);
                col++;
                if (col == 2) { col = 0; row++; }
            }
            #endregion

            #region AUX_Checkbox_Struct
            //Build the RC control checkboxes structure

            aux = new CheckBoxEx[4, 4, iCheckBoxItems];

            startx = 80;
            starty = 60;

            int a, b, c;
            for (c = 0; c < 4; c++)
            {
                for (a = 0; a < 3; a++)
                {
                    for (b = 0; b < iCheckBoxItems; b++)
                    {
                        aux[c, a, b] = new CheckBoxEx();
                        aux[c, a, b].Location = new Point(startx + a * 18 + c * 70, starty + b * 25);
                        aux[c, a, b].Visible = true;
                        aux[c, a, b].Text = "";
                        aux[c, a, b].AutoSize = true;
                        aux[c, a, b].Size = new Size(16, 16);
                        aux[c, a, b].UseVisualStyleBackColor = true;
                        aux[c, a, b].CheckedChanged += new System.EventHandler(this.aux_checked_changed_event);
                        //Set info on the given checkbox position
                        aux[c, a, b].aux = c;           //Which aux channel
                        aux[c, a, b].rclevel = a;       //which rc level
                        aux[c, a, b].item = b;          //Which item
                        this.groupBox5.Controls.Add(aux[c, a, b]);

                    }
                }
            }

            aux_labels = new System.Windows.Forms.Label[4];
            lmh_labels = new System.Windows.Forms.Label[4, 3];          // aux1-4, L,M,H
            string strlmh = "LMH";
            for (a = 0; a < 4; a++)
            {
                aux_labels[a] = new System.Windows.Forms.Label();
                aux_labels[a].Text = "AUX" + String.Format("{0:0}", a + 1);
                aux_labels[a].Location = new Point(startx + a * 70 + 8, starty - 35);
                aux_labels[a].AutoSize = true;
                aux_labels[a].ForeColor = Color.Black;
                this.groupBox5.Controls.Add(aux_labels[a]);
                for (b = 0; b < 3; b++)
                {
                    lmh_labels[a, b] = new System.Windows.Forms.Label();
                    lmh_labels[a, b].Text = strlmh.Substring(b, 1); ;
                    lmh_labels[a, b].Location = new Point(startx + a * 70 + b * 18, starty - 20);
                    lmh_labels[a, b].AutoSize = true;
                    lmh_labels[a, b].ForeColor = Color.Black;
                    this.groupBox5.Controls.Add(lmh_labels[a, b]);
                }

            }

            cb_labels = new System.Windows.Forms.Label[20];

            for (z = 0; z < iCheckBoxItems; z++)
            {
                cb_labels[z] = new System.Windows.Forms.Label();
                cb_labels[z].Text = option_names[z];
                cb_labels[z].Location = new Point(10, starty + z * 25);
                cb_labels[z].Visible = true;
                cb_labels[z].AutoSize = true;
                cb_labels[z].ForeColor = Color.Black;
                cb_labels[z].TextAlign = ContentAlignment.MiddleRight;
                toolTip1.SetToolTip(cb_labels[z], option_desc[z]);
                this.groupBox5.Controls.Add(cb_labels[z]);
            }
            #endregion

            //Build PID control structure based on the Pid structure.
            #region PID_Struct
            const int iLineSpace = 36;
            const int iRow1 = 25;
            const int iRow2 = 125;
            const int iRow3 = 220;
            const int iTopY = 30;
            Font fontField = new Font("Arial", 9, FontStyle.Regular);
            Size fieldSize = new Size(70, 25);

            for (int i = 0; i < iPidItems; i++)
            {
                Pid[i].pidLabel = new System.Windows.Forms.Label();
                Pid[i].pidLabel.Text = Pid[i].name;
                Pid[i].pidLabel.Location = new Point(iRow1, 15 + i * iLineSpace);
                Pid[i].pidLabel.Visible = true;
                Pid[i].pidLabel.AutoSize = true;
                Pid[i].pidLabel.ForeColor = Color.Black;
                Pid[i].pidLabel.TextAlign = ContentAlignment.MiddleRight;
                toolTip1.SetToolTip(Pid[i].pidLabel, Pid[i].description);
                this.groupBox4.Controls.Add(Pid[i].pidLabel);

                if (Pid[i].Pshown)
                {
                    Pid[i].Pfield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Pfield.ValueChanged += new EventHandler(pfield_valuechange);
                    Pid[i].Pfield.Location = new Point(iRow1, iTopY + i * iLineSpace);
                    Pid[i].Pfield.Size = fieldSize;
                    Pid[i].Pfield.Font = fontField;
                    Pid[i].Pfield.BorderStyle = BorderStyle.FixedSingle;
                    Pid[i].Pfield.TextAlign = HorizontalAlignment.Center;
                    Pid[i].Pfield.Maximum = Pid[i].Pmax;
                    Pid[i].Pfield.Minimum = Pid[i].Pmin;
                    Pid[i].Pfield.DecimalPlaces = decimals(Pid[i].Pprec);
                    Pid[i].Pfield.Increment = 1 / (decimal)Pid[i].Pprec;
                    this.groupBox4.Controls.Add(Pid[i].Pfield);

                    Pid[i].Plabel = new System.Windows.Forms.Label();
                    Pid[i].Plabel.Text = "P";
                    Pid[i].Plabel.Font = fontField;
                    Pid[i].Plabel.ForeColor = Color.Black;
                    Pid[i].Plabel.Location = new Point(iRow1 - 20, iTopY + i * iLineSpace);
                    this.groupBox4.Controls.Add(Pid[i].Plabel);

                }
                if (Pid[i].Ishown)
                {
                    Pid[i].Ifield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Ifield.ValueChanged += new EventHandler(ifield_valuechange);
                    Pid[i].Ifield.Location = new Point(iRow2, iTopY + i * iLineSpace);
                    Pid[i].Ifield.Size = fieldSize;
                    Pid[i].Ifield.Font = fontField;
                    Pid[i].Ifield.BorderStyle = BorderStyle.FixedSingle;
                    Pid[i].Ifield.TextAlign = HorizontalAlignment.Center;
                    Pid[i].Ifield.Maximum = Pid[i].Imax;
                    Pid[i].Ifield.Minimum = Pid[i].Imin;
                    Pid[i].Ifield.DecimalPlaces = decimals(Pid[i].Iprec);
                    Pid[i].Ifield.Increment = 1 / (decimal)Pid[i].Iprec;
                    this.groupBox4.Controls.Add(Pid[i].Ifield);

                    Pid[i].Ilabel = new System.Windows.Forms.Label();
                    Pid[i].Ilabel.Text = "I";
                    Pid[i].Ilabel.Font = fontField;
                    Pid[i].Ilabel.ForeColor = Color.Black;
                    Pid[i].Ilabel.Location = new Point(iRow2 - 20, iTopY + i * iLineSpace);
                    this.groupBox4.Controls.Add(Pid[i].Ilabel);

                }
                if (Pid[i].Dshown)
                {
                    Pid[i].Dfield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Dfield.ValueChanged += new EventHandler(dfield_valuechange);
                    Pid[i].Dfield.Location = new Point(iRow3, iTopY + i * iLineSpace);
                    Pid[i].Dfield.Size = fieldSize;
                    Pid[i].Dfield.Font = fontField;
                    Pid[i].Dfield.BorderStyle = BorderStyle.FixedSingle;
                    Pid[i].Dfield.TextAlign = HorizontalAlignment.Center;
                    Pid[i].Dfield.Maximum = Pid[i].Dmax;
                    Pid[i].Dfield.Minimum = Pid[i].Dmin;
                    Pid[i].Dfield.DecimalPlaces = decimals(Pid[i].Dprec);
                    Pid[i].Dfield.Increment = 1 / (decimal)Pid[i].Dprec;
                    this.groupBox4.Controls.Add(Pid[i].Dfield);

                    Pid[i].Dlabel = new System.Windows.Forms.Label();
                    Pid[i].Dlabel.Text = "D";
                    Pid[i].Dlabel.Font = fontField;
                    Pid[i].Dlabel.ForeColor = Color.Black;
                    Pid[i].Dlabel.Location = new Point(iRow3 - 18, iTopY + i * iLineSpace);
                    this.groupBox4.Controls.Add(Pid[i].Dlabel);

                }

            }
            #endregion

            this.Refresh();

            serial_ports_enumerate();
            foreach (string speed in sSerialSpeeds)
            {
                cb_serial_speed.Items.Add(speed);
            }
            cb_serial_speed.SelectedItem = "115200";

            if (cb_serial_port.Items.Count == 0)
            {
                b_connect.Enabled = false;          //Nos serial port, disable connect
            }

            //Init serial port object
            serialPort = new SerialPort();
            //Set up serial port parameters (at least the ones what we know upfront
            serialPort.DataBits = 8;
            serialPort.Parity = Parity.None;
            serialPort.StopBits = StopBits.One;
            serialPort.Handshake = Handshake.None;
            serialPort.DtrEnable = false;               //??

            serialPort.ReadBufferSize = 4096;            //4K byte of read buffer
            serialPort.ReadTimeout = 500;               // 500msec timeout;

            //Init Realtime Monitor panel controls
            foreach (string rate in sRefreshSpeeds)
            {
                cb_monitor_rate.Items.Add(rate);
            }
            cb_monitor_rate.SelectedIndex = 0;              //20Hz is the default
            //cb_serial_speed.SelectedItem = "115200";

            //Setup timers
            timer_realtime.Tick += new EventHandler(timer_realtime_Tick);
            timer_realtime.Interval = iRefreshIntervals[cb_monitor_rate.SelectedIndex];
            timer_realtime.Enabled = true;
            timer_realtime.Stop();

            //Set up zgMonitor control for real time monitoring
            GraphPane myPane = zgMonitor.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "";
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "";

            #region Zed_Points_Curves
            //Set up pointlists and curves
            list_acc_roll = new RollingPointPairList(300);
            curve_acc_roll = myPane.AddCurve("acc_roll", list_acc_roll, Color.Red, SymbolType.None);

            list_acc_pitch = new RollingPointPairList(300);
            curve_acc_pitch = myPane.AddCurve("acc_pitch", list_acc_pitch, Color.Green, SymbolType.None);

            list_acc_z = new RollingPointPairList(300);
            curve_acc_z = myPane.AddCurve("acc_z", list_acc_z, Color.Blue, SymbolType.None);

            list_gyro_roll = new RollingPointPairList(300);
            curve_gyro_roll = myPane.AddCurve("gyro_roll", list_gyro_roll, Color.Gold, SymbolType.None);

            list_gyro_pitch = new RollingPointPairList(300);
            curve_gyro_pitch = myPane.AddCurve("gyro_pitch", list_gyro_pitch, Color.DarkCyan, SymbolType.None);

            list_gyro_yaw = new RollingPointPairList(300);
            curve_gyro_yaw = myPane.AddCurve("gyro_yaw", list_gyro_yaw, Color.Magenta, SymbolType.None);

            list_mag_roll = new RollingPointPairList(300);
            curve_mag_roll = myPane.AddCurve("mag_roll", list_mag_roll, Color.CadetBlue, SymbolType.None);

            list_mag_pitch = new RollingPointPairList(300);
            curve_mag_pitch = myPane.AddCurve("mag_pitch", list_mag_pitch, Color.MediumPurple, SymbolType.None);

            list_mag_yaw = new RollingPointPairList(300);
            curve_mag_yaw = myPane.AddCurve("mag_yaw", list_mag_yaw, Color.DarkGoldenrod, SymbolType.None);

            list_alt = new RollingPointPairList(300);
            curve_alt = myPane.AddCurve("alt", list_alt, Color.Maroon, SymbolType.None);

            list_head = new RollingPointPairList(300);
            curve_head = myPane.AddCurve("head", list_head, Color.Orange, SymbolType.None);

            // Show the x axis grid
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;

            // Make the Y axis scale red
            myPane.YAxis.Scale.FontSpec.FontColor = Color.Black;
            myPane.YAxis.Title.FontSpec.FontColor = Color.Black;

            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;

            // Don't display the Y zero line
            myPane.YAxis.MajorGrid.IsZeroLine = true;

            // Align the Y axis labels so they are flush to the axis
            myPane.YAxis.Scale.Align = AlignP.Inside;
            myPane.YAxis.Scale.IsVisible = false;

            // Manually set the axis range
            myPane.YAxis.Scale.Min = -150;
            myPane.YAxis.Scale.Max = 150;

            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(123, 194, 205), 45.0f);
            myPane.Fill = new Fill(Color.White, Color.White, 45.0f);
            myPane.Legend.IsVisible = false;

            myPane.Border.IsVisible = false;

            myPane.XAxis.Scale.IsVisible = false;
            myPane.YAxis.Scale.IsVisible = true;

            myPane.XAxis.Scale.MagAuto = true;
            myPane.YAxis.Scale.MagAuto = false;

            zgMonitor.IsEnableHPan = true;
            zgMonitor.IsEnableHZoom = true;

            foreach (ZedGraph.LineItem li in myPane.CurveList)
            {
                li.Line.Width = 1;
            }

            myPane.YAxis.Title.FontSpec.FontColor = Color.Black;
            myPane.XAxis.Title.FontSpec.FontColor = Color.Black;

            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 300;
            myPane.XAxis.Type = AxisType.Linear;

            zgMonitor.ScrollGrace = 0;
            xScale = zgMonitor.GraphPane.XAxis.Scale;
            zgMonitor.AxisChange();
            #endregion

            //Disable buttons that are not working till connected
            b_reset.Enabled = false;
            b_cal_acc.Enabled = false;
            b_cal_mag.Enabled = false;
            b_read_settings.Enabled = false;
            b_write_settings.Enabled = false;
        }
Esempio n. 15
0
        /// <summary>
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data
        /// </param>
        protected Axis( SerializationInfo info, StreamingContext context )
        {
            // The schema value is just a file version parameter.  You can use it to make future versions
            // backwards compatible as new member variables are added to classes
            int sch = info.GetInt32( "schema" );

            _cross = info.GetDouble( "cross" );
            _crossAuto = info.GetBoolean( "crossAuto" );

            _majorTic = (MajorTic)info.GetValue( "MajorTic", typeof( MajorTic ) );
            _minorTic = (MinorTic)info.GetValue( "MinorTic", typeof( MinorTic ) );
            _majorGrid = (MajorGrid)info.GetValue( "majorGrid", typeof( MajorGrid ) );
            _minorGrid = (MinorGrid)info.GetValue( "minorGrid", typeof( MinorGrid ) );

            _isVisible = info.GetBoolean( "isVisible" );

            _title = (AxisLabel) info.GetValue( "title", typeof( AxisLabel ) );

            _minSpace = info.GetSingle( "minSpace" );

            _color = (Color)info.GetValue( "color", typeof( Color ) );

            _isAxisSegmentVisible = info.GetBoolean( "isAxisSegmentVisible" );

            _axisGap = info.GetSingle( "axisGap" );

            _scale = (Scale)info.GetValue( "scale", typeof( Scale ) );
            _scale._ownerAxis = this;
        }
Esempio n. 16
0
 private void InitScale( Scale scale, bool isBoundedRanges )
 {
     scale._rangeMin = double.MaxValue;
     scale._rangeMax = double.MinValue;
     scale._lBound = ( isBoundedRanges && !scale._minAuto ) ?
         scale._min : double.MinValue;
     scale._uBound = ( isBoundedRanges && !scale._maxAuto ) ?
         scale._max : double.MaxValue;
 }
Esempio n. 17
0
        internal static void PickScale( GraphPane pane, Graphics g, float scaleFactor, Scale scale )
        {
            // Test for trivial condition of range = 0 and pick a suitable default
            if ( scale._max - scale._min < 1.0 )
            {
                if ( scale._maxAuto )
                    scale._max = scale._min + 0.5;
                else
                    scale._min = scale._max - 0.5;
            }
            else
            {
                // Calculate the new step size
                if ( scale._majorStepAuto )
                {
                    // Calculate the step size based on targetSteps
                    scale._majorStep = Scale.CalcStepSize( scale._max - scale._min,
                        ( scale._ownerAxis is XAxis || scale._ownerAxis is X2Axis ) ?
                                Default.TargetXSteps : Default.TargetYSteps );

                    if ( scale.IsPreventLabelOverlap )
                    {
                        // Calculate the maximum number of labels
                        double maxLabels = (double) scale.CalcMaxLabels( g, pane, scaleFactor );

                        // Calculate a step size based on the width of the labels
                        double tmpStep = Math.Ceiling( ( scale._max - scale._min ) / maxLabels );

                        // Use the greater of the two step sizes
                        if ( tmpStep > scale._majorStep )
                            scale._majorStep = tmpStep;
                    }

                }

                scale._majorStep = (int)scale._majorStep;
                if ( scale._majorStep < 1.0 )
                    scale._majorStep = 1.0;

                // Calculate the new minor step size
                if ( scale._minorStepAuto )
                    scale._minorStep = Scale.CalcStepSize( scale._majorStep,
                        ( scale._ownerAxis is XAxis || scale._ownerAxis is X2Axis ) ?
                                Default.TargetMinorXSteps : Default.TargetMinorYSteps );

                if ( scale._minAuto )
                    scale._min -= 0.5;
                if ( scale._maxAuto )
                    scale._max += 0.5;
            }
        }
Esempio n. 18
0
 /*
 /// <summary>
 /// Implement the <see cref="ICloneable" /> interface in a typesafe manner by just
 /// calling the typed version of Clone />
 /// </summary>
 /// <remarks>
 /// Note that this method must be called with an explicit cast to ICloneable, and
 /// that it is inherently virtual.  For example:
 /// <code>
 /// ParentClass foo = new ChildClass();
 /// ChildClass bar = (ChildClass) ((ICloneable)foo).Clone();
 /// </code>
 /// Assume that ChildClass is inherited from ParentClass.  Even though foo is declared with
 /// ParentClass, it is actually an instance of ChildClass.  Calling the ICloneable implementation
 /// of Clone() on foo actually calls ChildClass.Clone() as if it were a virtual function.
 /// </remarks>
 /// <returns>A deep copy of this object</returns>
 object ICloneable.Clone()
 {
     throw new NotImplementedException( "Can't clone an abstract base type -- child types must implement ICloneable" );
     //return new PaneBase( this );
 }
 */
 /// <summary>
 /// A construction method that creates a new <see cref="Scale"/> object using the
 /// properties of an existing <see cref="Scale"/> object, but specifying a new
 /// <see cref="AxisType"/>.
 /// </summary>
 /// <remarks>
 /// This constructor is used to change the type of an existing <see cref="Axis" />.
 /// By specifying the old <see cref="Scale"/> object, you are giving a set of properties
 /// (which encompasses all fields associated with the scale, since the derived types
 /// have no fields) to be used in creating a new <see cref="Scale"/> object, only this
 /// time having the newly specified object type.</remarks>
 /// <param name="oldScale">The existing <see cref="Scale" /> object from which to
 /// copy the field data.</param>
 /// <param name="type">An <see cref="AxisType"/> representing the type of derived type
 /// of new <see cref="Scale" /> object to create.</param>
 /// <returns>The new <see cref="Scale"/> object.</returns>
 public Scale MakeNewScale( Scale oldScale, AxisType type )
 {
     switch ( type )
     {
         case AxisType.Linear:
             return new LinearScale( oldScale, _ownerAxis );
         case AxisType.Date:
             return new DateScale( oldScale, _ownerAxis );
         case AxisType.Log:
             return new LogScale( oldScale, _ownerAxis );
         case AxisType.Exponent:
             return new ExponentScale( oldScale, _ownerAxis );
         case AxisType.Ordinal:
             return new OrdinalScale( oldScale, _ownerAxis );
         case AxisType.Text:
             return new TextScale( oldScale, _ownerAxis );
         case AxisType.DateAsOrdinal:
             return new DateAsOrdinalScale( oldScale, _ownerAxis );
         case AxisType.LinearAsOrdinal:
             return new LinearAsOrdinalScale( oldScale, _ownerAxis );
         default:
             throw new Exception( "Implementation Error: Invalid AxisType" );
     }
 }
Esempio n. 19
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see cref="LinearAsOrdinalScale" /> object from which to copy</param>
		/// <param name="owner">The <see cref="Axis" /> object that will own the
		/// new instance of <see cref="LinearAsOrdinalScale" /></param>
		public LinearAsOrdinalScale(Scale rhs, Axis owner)
			: base(rhs, owner)
		{
		}
Esempio n. 20
0
 /// <summary>
 /// Local dispose method
 /// </summary>
 /// <param name="bDisposing">if disposing is required</param>
 protected virtual void Dispose(bool bDisposing)
 {
     if (!m_bDisposed)
     {
         if (bDisposing)
         {
             if (_title != null)
             {
                 _title.Dispose();
                 _title = null;
             }
             if (_scale != null)
             {
                 _scale.Dispose();
                 _scale = null;
             }
         }
         m_bDisposed = true;
     }
 }