Ejemplo n.º 1
0
        void createValueControl(KeyValuePair<string,string> x)
        {
            ParameterMetaDataRepository _parameterMetaDataRepository = new ParameterMetaDataRepository();

            string value = ((float)MainV2.comPort.MAV.param[x.Key]).ToString("0.###", CultureInfo.InvariantCulture);
            string description = _parameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.Description);
            string displayName = _parameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.DisplayName) +" (" + x.Key + ")";
            string units = _parameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.Units);

            var valueControl = new ValuesControl();
            valueControl.Name = x.Key;
            valueControl.DescriptionText = FitDescriptionText(units, description);
            valueControl.LabelText = displayName;

            ThemeManager.ApplyThemeTo(valueControl);

            valueControl.ComboBoxControl.DisplayMember = "Value";
            valueControl.ComboBoxControl.ValueMember = "Key";
            valueControl.ComboBoxControl.DataSource = _parameterMetaDataRepository.GetParameterOptionsInt(x.Key);
            valueControl.ComboBoxControl.SelectedItem = value;

            valueControl.ValueChanged += valueControl_ValueChanged;

            flowLayoutPanel1.Controls.Add(valueControl);
        }
Ejemplo n.º 2
0
        public ConfigFriendlyParams()
        {
            InitializeComponent();
            tableLayoutPanel1.Height = this.Height;
            _parameterMetaDataRepository = new ParameterMetaDataRepository();

            Resize += this_Resize;

            BUT_rerequestparams.Click += BUT_rerequestparams_Click;
            BUT_writePIDS.Click += BUT_writePIDS_Click;
        }
Ejemplo n.º 3
0
        public void Activate()
        {
            if (!MainV2.comPort.BaseStream.IsOpen)
            {
                this.Enabled = false;
                return;
            }
            else
            {
                if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduCopter2 || MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduHeli)
                {
                    this.Enabled = true;
                }
                else
                {
                    this.Enabled = false;
                    return;
                }
            }

            startup = true;

            changes.Clear();

            // read tooltips
            if (tooltips.Count == 0)
                readToolTips();

            ParameterMetaDataRepository param = new ParameterMetaDataRepository();

            // ensure the fields are populated before setting them
            CH7_OPT.DataSource = param.GetParameterOptionsInt("CH7_OPT").ToList();
            CH7_OPT.DisplayMember = "Value";
            CH7_OPT.ValueMember = "Key";

            CH8_OPT.DataSource = param.GetParameterOptionsInt("CH8_OPT").ToList();
            CH8_OPT.DisplayMember = "Value";
            CH8_OPT.ValueMember = "Key";

            TUNE.DataSource = param.GetParameterOptionsInt("TUNE").ToList();
            TUNE.DisplayMember = "Value";
            TUNE.ValueMember = "Key";

            // prefill all fields
            processToScreen();

            if (MainV2.comPort.MAV.param["H_SWASH_TYPE"] != null)
            {
                CHK_lockrollpitch.Checked = false;
            }

            startup = false;
        }
        public ConfigParamParams()
        {
            InitializeComponent();
            tableLayoutPanel1.Height = this.Height;
            _parameterMetaDataRepository = new ParameterMetaDataRepository();

            MainV2.comPort.ParamListChanged += comPort_ParamListChanged;
            Resize += this_Resize;

            BUT_rerequestparams.Click += BUT_rerequestparams_Click;
            BUT_writePIDS.Click += BUT_writePIDS_Click;
        }
Ejemplo n.º 5
0
        public static List<KeyValuePair<int, string>> getModesList(CurrentState cs)
        {
            log.Info("getModesList Called");

            // ensure we get the correct list
            MainV2.comPort.MAV.cs.firmware = cs.firmware;

            Utilities.ParameterMetaDataRepository parm = new ParameterMetaDataRepository();

            if (cs.firmware == MainV2.Firmwares.ArduPlane)
            {
                var flightModes = parm.GetParameterOptionsInt("FLTMODE1");
                flightModes.Add(new KeyValuePair<int,string>(16,"INITIALISING"));
                return flightModes;
            }
            else if (cs.firmware == MainV2.Firmwares.Ateryx)
            {
                var flightModes = parm.GetParameterOptionsInt("FLTMODE1"); //same as apm
                return flightModes;
            }
            else if (cs.firmware == MainV2.Firmwares.ArduCopter2 || MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduHeli)
            {
                var flightModes = parm.GetParameterOptionsInt("FLTMODE1");
                return flightModes;
            }
            else if (cs.firmware == MainV2.Firmwares.ArduRover)
            {
                var flightModes = parm.GetParameterOptionsInt("MODE1");
                return flightModes;
            }

            return null;
        }
Ejemplo n.º 6
0
 public ConfigRawParams()
 {
     InitializeComponent();
     _parameterMetaDataRepository = new ParameterMetaDataRepository();
 }
        void updateDropDown(ComboBox ctl, string param)
        {
            ParameterMetaDataRepository parm = new ParameterMetaDataRepository();

            ctl.DataSource = parm.GetParameterOptionsInt(param).ToList();
            ctl.DisplayMember = "Value";
            ctl.ValueMember = "Key";
        }
Ejemplo n.º 8
0
        void ProcessItem(configitem item)
        {
            try
            {
                float value = (float)MainV2.comPort.param[item.paramname];

                if (value < item.min)
                    item.min = value;
                if (value > item.max)
                    item.max = value;

                ParameterMetaDataRepository _parameterMetaDataRepository = new ParameterMetaDataRepository();

                string range = _parameterMetaDataRepository.GetParameterMetaData(item.paramname, ParameterMetaDataConstants.Range);
                string increment = _parameterMetaDataRepository.GetParameterMetaData(item.paramname, ParameterMetaDataConstants.Increment);

                string[] rangeopt = range.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                if (rangeopt.Length > 1)
                {
                    item.min = float.Parse(rangeopt[0], System.Globalization.CultureInfo.InvariantCulture);
                    item.max = float.Parse(rangeopt[1], System.Globalization.CultureInfo.InvariantCulture);
                }

                float incrementf = 0.01f;
                if (increment.Length > 0)
                    float.TryParse(increment, out incrementf);

                ArdupilotMega.Controls.RangeControl RNG = new ArdupilotMega.Controls.RangeControl(item.paramname, item.desc, item.title, incrementf, 1, item.min, item.max, value.ToString());
                RNG.Tag = item;

                RNG.Location = new Point(10, y);

                RNG.AttachEvents();

                RNG.ValueChanged += RNG_ValueChanged;

                ThemeManager.ApplyThemeTo(RNG);

                panel1.Controls.Add(RNG);

                y += RNG.Height;
            }
            catch (Exception ex) { CustomMessageBox.Show("Failed to process " + item.paramname + "\n" + ex.ToString()); }
        }
Ejemplo n.º 9
0
Archivo: Common.cs Proyecto: nitbot/pos
        /*
        public enum apmmodes
        {
            [DisplayText("Manual")]
            MANUAL = 0,
            [DisplayText("Circle")]
            CIRCLE = 1,
            [DisplayText("Stabilize")]
            STABILIZE = 2,
            [DisplayText("Training")]
            TRAINING = 3,
            [DisplayText("FBW A")]
            FLY_BY_WIRE_A = 5,
            [DisplayText("FBW B")]
            FLY_BY_WIRE_B = 6,
            [DisplayText("Auto")]
            AUTO = 10,
            [DisplayText("RTL")]
            RTL = 11,
            [DisplayText("Loiter")]
            LOITER = 12,
            [DisplayText("Guided")]
            GUIDED = 15,

            TAKEOFF = 99
        }

        public enum aprovermodes
        {
            [DisplayText("Manual")]
            MANUAL = 0,
            [DisplayText("Learning")]
            LEARNING = 2,
            [DisplayText("Steering")]
            STEERING = 3,
            [DisplayText("Hold")]
            HOLD = 4,
            [DisplayText("Auto")]
            AUTO = 10,
            [DisplayText("RTL")]
            RTL = 11,
            [DisplayText("Guided")]
            GUIDED = 15,
            [DisplayText("Initialising")]
            INITIALISING = 16
        }

        public enum ac2modes
        {
            [DisplayText("Stabilize")]
            STABILIZE = 0,			// hold level position
            [DisplayText("Acro")]
            ACRO = 1,			// rate control
            [DisplayText("Alt Hold")]
            ALT_HOLD = 2,		// AUTO control
            [DisplayText("Auto")]
            AUTO = 3,			// AUTO control
            [DisplayText("Guided")]
            GUIDED = 4,		// AUTO control
            [DisplayText("Loiter")]
            LOITER = 5,		// Hold a single location
            [DisplayText("RTL")]
            RTL = 6,				// AUTO control
            [DisplayText("Circle")]
            CIRCLE = 7,
            [DisplayText("Pos Hold")]
            POSITION = 8,
            [DisplayText("Land")]
            LAND = 9,				// AUTO control
            OF_LOITER = 10,
            [DisplayText("Toy")]
            TOY = 11
        }
        */
        /// <summary>
        /// use .ToList() to a datasource
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public static Dictionary<int, string> getOptions(string param)
        {
            Dictionary<int, string> options = new Dictionary<int, string>();

            ParameterMetaDataRepository _parameterMetaDataRepository = new ParameterMetaDataRepository();

            string paramoptions = _parameterMetaDataRepository.GetParameterMetaData(param, ParameterMetaDataConstants.Values);

            string[] values = paramoptions.Split(new char[] {',' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var opt in values)
            {
                string[] split = opt.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                try
                {
                    options.Add(int.Parse(split[0].Trim()), split[1].Trim());
                }
                catch { }
            }

            return options;
        }