コード例 #1
0
        private void Params_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == Value.Index)
            {
                var check = Params[e.ColumnIndex, e.RowIndex].EditedFormattedValue;
                var name  = Params[Command.Index, e.RowIndex].Value.ToString();

                var availableBitMask =
                    ParameterMetaDataRepository.GetParameterBitMaskInt(name, MainV2.comPort.MAV.cs.firmware.ToString());
                if (availableBitMask.Count > 0)
                {
                    var mcb  = new MavlinkCheckBoxBitMask();
                    var list = new MAVLink.MAVLinkParamList();
                    list.Add(new MAVLink.MAVLinkParam(name, double.Parse(check.ToString(), CultureInfo.InvariantCulture),
                                                      MAVLink.MAV_PARAM_TYPE.INT32));
                    mcb.setup(name, list);
                    mcb.ValueChanged += (o, s, value) =>
                    {
                        Params[e.ColumnIndex, e.RowIndex].Value = value;
                        Params.Invalidate();
                        mcb.Focus();
                    };
                    var frm = mcb.ShowUserControl();
                    frm.TopMost = true;
                }
            }
        }
コード例 #2
0
ファイル: parampck.cs プロジェクト: ducat595/MissionPlanner
        /*
         * packed format:
         * uint8_t type:4;         // AP_Param type NONE=0, INT8=1, INT16=2, INT32=3, FLOAT=4
         * uint8_t type_len:4;     // number of bytes in type
         * uint8_t common_len:4;   // number of name bytes in common with previous entry, 0..15
         * uint8_t name_len:4;     // non-common length of param name -1 (0..15)
         * uint8_t name[name_len]; // name
         * uint8_t data[];         // value, may be truncated by record_length
         */
        public static MAVLink.MAVLinkParamList unpack(byte[] data)
        {
            MAVLink.MAVLinkParamList list = new MAVLink.MAVLinkParamList();

            var magic2 = BitConverter.ToInt32(data.Take(4).ToArray(), 0);

            if (magic != magic)
            {
                return(null);
            }

            data = data.Skip(4).ToArray();

            var last_name = "";

            while (true)
            {
                while (len(data) > 0 && ord(data[0]) == 0)
                {
                    data = data.Skip(1).ToArray();
                }
                if (len(data) == 0)
                {
                    break;
                }
                var ptype    = data[0];
                var plen     = data[1];
                var type_len = (ptype >> 4) & 0x0F;
                ptype &= 0x0F;
                var name_len   = ((plen >> 4) & 0x0F) + 1;
                var common_len = (plen & 0x0F);
                var name       = new StringBuilder().Append(last_name.Take(common_len).ToArray())
                                 .Append(data.Skip(2).Take(name_len).Select(a => (char)a).ToArray()).ToString();
                var vdata = data.Skip(2 + name_len).Take(type_len);
                last_name = name;
                data      = data.Skip(2 + name_len + type_len).ToArray();
                var v = decode_value(ptype, vdata);
                Console.WriteLine("{0,-16} {1}", name, v);
                //print("%-16s %f" % (name, float (v)))

                list.Add(new MAVLink.MAVLinkParam(name, vdata.ToArray().MakeSize(4),
                                                  (ptype == 1 ? MAVLink.MAV_PARAM_TYPE.INT8 :
                                                   ptype == 2 ? MAVLink.MAV_PARAM_TYPE.INT16 :
                                                   ptype == 3 ? MAVLink.MAV_PARAM_TYPE.INT32 :
                                                   ptype == 4 ? MAVLink.MAV_PARAM_TYPE.REAL32 : (MAVLink.MAV_PARAM_TYPE) 0),
                                                  (ptype == 1 ? MAVLink.MAV_PARAM_TYPE.INT8 :
                                                   ptype == 2 ? MAVLink.MAV_PARAM_TYPE.INT16 :
                                                   ptype == 3 ? MAVLink.MAV_PARAM_TYPE.INT32 :
                                                   ptype == 4 ? MAVLink.MAV_PARAM_TYPE.REAL32 : (MAVLink.MAV_PARAM_TYPE) 0)));
            }

            return(list);
        }
コード例 #3
0
        private void Params_CellClick(object sender, CellClickEventArgs e)
        {
            // Only process the Description column
            if (e.RowIndex == -1 || startup)
            {
                return;
            }

            if (e.ColumnIndex == olvColumn2.Index)
            {
                var it    = ((data)e.Model);
                var check = it.Value;
                var name  = it.paramname;

                var availableBitMask =
                    ParameterMetaDataRepository.GetParameterBitMaskInt(name, MainV2.comPort.MAV.cs.firmware.ToString());
                if (availableBitMask.Count > 0)
                {
                    var mcb  = new MavlinkCheckBoxBitMask();
                    var list = new MAVLink.MAVLinkParamList();
                    list.Add(new MAVLink.MAVLinkParam(name, double.Parse(check.ToString(), CultureInfo.InvariantCulture),
                                                      MAVLink.MAV_PARAM_TYPE.INT32));
                    mcb.setup(name, list);
                    mcb.ValueChanged += (o, s, value) =>
                    {
                        paramCompareForm_dtlvcallback(s, int.Parse(value));
                        ((data)e.HitTest.RowObject).Value = value;
                        Params.RefreshItem(e.HitTest.Item);
                        e.HitTest.SubItem.Text = value;
                        Params.CancelCellEdit();
                        e.Handled = true;
                        mcb.Focus();
                    };
                    var frm = mcb.ShowUserControl();
                    frm.TopMost = true;
                }
            }


            try
            {
                string descStr = e.SubItem.ModelValue.ToString();
                ConfigRawParams.CheckForUrlAndLaunchInBrowser(descStr);
            }
            catch { }
        }
コード例 #4
0
        private void Params_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            // Only process the Description column
            if (e.RowIndex == -1 || startup)
            {
                return;
            }

            if (e.ColumnIndex == 4)
            {
                try
                {
                    string descStr = Params[e.ColumnIndex, e.RowIndex].Value.ToString();
                    CheckForUrlAndLaunchInBrowser(descStr);
                }
                catch
                {
                }
            }

            if (e.ColumnIndex == Value.Index)
            {
                var check = Params[e.ColumnIndex, e.RowIndex].EditedFormattedValue;
                var name  = Params[Command.Index, e.RowIndex].Value.ToString();

                var availableBitMask =
                    ParameterMetaDataRepository.GetParameterBitMaskInt(name, MainV2.comPort.MAV.cs.firmware.ToString());
                if (availableBitMask.Count > 0)
                {
                    var mcb  = new MavlinkCheckBoxBitMask();
                    var list = new MAVLink.MAVLinkParamList();
                    list.Add(new MAVLink.MAVLinkParam(name, double.Parse(check.ToString(), CultureInfo.InvariantCulture),
                                                      MAVLink.MAV_PARAM_TYPE.INT32));
                    mcb.setup(name, list);
                    mcb.ValueChanged += (o, s, value) =>
                    {
                        Params[e.ColumnIndex, e.RowIndex].Value = value;
                        Params.Invalidate();
                        mcb.Focus();
                    };
                    var frm = mcb.ShowUserControl();
                    frm.TopMost = true;
                }
            }

            if (e.ColumnIndex == 5)
            {
                var check = Params[e.ColumnIndex, e.RowIndex].EditedFormattedValue;
                var name  = Params[Command.Index, e.RowIndex].Value.ToString();

                if (check != null && (bool)check)
                {
                    // add entry
                    Settings.Instance.AppendList("fav_params", name);
                }
                else
                {
                    // remove entry
                    var list = Settings.Instance.GetList("fav_params");
                    Settings.Instance.SetList("fav_params", list.Where(s => s != name));
                }

                Params.Sort(Command, ListSortDirection.Ascending);
            }
        }