Ejemplo n.º 1
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.º 2
0
        void RNG_ValueChanged(object sender, string Name, string Value)
        {
            TXT_info.Clear();

            float value = float.Parse(Value, CultureInfo.InvariantCulture);

            ArdupilotMega.Controls.RangeControl rc = ((ArdupilotMega.Controls.RangeControl)sender);
            log.Info(rc.Name + " " + rc.Value);

            List <relationitem> relitems = ((configitem)rc.Tag).relations;

            MainV2.comPort.setParam(rc.Name, value);
            TXT_info.AppendText("set " + rc.Name + " " + rc.Value + "\r\n");

            foreach (var item in relitems)
            {
                MainV2.comPort.setParam(item.paramaname, (float)(value * item.multiplier));
                TXT_info.AppendText("set " + item.paramaname + " " + (float)(value * item.multiplier) + "\r\n");
            }
        }
Ejemplo n.º 3
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()); }
        }