public void sendParamUpdate(string parameterName, float parameterValue, MAVLink.MAV_PARAM_TYPE type)
        {
            MAVLink.mavlink_param_set_t paramset = new MAVLink.mavlink_param_set_t();
            paramset.target_component = (byte)this.componentId;
            paramset.target_system    = (byte)this.systemId;
            paramset.param_value      = parameterValue;

            // have to set fixed 16 byte value for param_id
            byte[] byteArray = new byte[16];
            for (int i = 0; i < 16; i++)
            {
                if (i < parameterName.Length)
                {
                    byteArray[i] = (byte)parameterName[i];
                }
                else
                {
                    byteArray[i] = (byte)'\0';
                }
            }
            paramset.param_id = byteArray;

            paramset.param_type = (byte)type;

            byte[] packet = this.mavlinkParse.GenerateMAVLinkPacket(MAVLink.MAVLINK_MSG_ID.PARAM_SET, paramset);

            this.port.Write(packet, 0, packet.Length);
        }
Ejemplo n.º 2
0
        public void setup(string paramname, MAVLink.MAVLinkParamList paramlist)
        {
            this.ParamName = paramname;

            if (paramlist.ContainsKey(paramname))
            {
                this.Enabled = true;

                list = ParameterMetaDataRepository.GetParameterBitMaskInt(ParamName,
                                                                          MainV2.comPort.MAV.cs.firmware.ToString());
                chkcount = list.Count;

                int leftside = 9;
                int top      = 9;

                uint value = (uint)paramlist[paramname].Value;

                Type = paramlist[paramname].TypeAP;

                for (int a = 0; a < chkcount; a++)
                {
                    CheckBox chk = new CheckBox();
                    chk.AutoSize = true;
                    chk.Text     = list[a].Value.ToString();
                    chk.Location = new System.Drawing.Point(leftside, top);

                    chk.CheckedChanged -= MavlinkCheckBoxBitMask_CheckedChanged;

                    if ((value & (1 << list[a].Key)) > 0)
                    {
                        chk.Checked = true;
                    }

                    chklist.Add(new KeyValuePair <int, CheckBox>(list[a].Key, chk));
                    panel1.Controls.Add(chk);

                    chk.CheckedChanged += MavlinkCheckBoxBitMask_CheckedChanged;

                    //this.Controls.Add(new Label() { Location = chk.Location, Text = "test" });

                    leftside += chk.Width + 5;
                    if (leftside > 500)
                    {
                        top     += chk.Height + 5;
                        leftside = 9;
                    }
                }


                this.panel1.Height = top + 25;

                //this.Height = top + 25;
            }
            else
            {
                this.Enabled = false;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Set Parameter on target device.
        /// </summary>
        /// <param name="parameterName">String unique identifier for parameter</param>
        /// <param name="parameterValue">Parameter value in string format</param>
        /// <param name="type">Parameter type, enumerated in MAV_PARAM_TYPE</param>
        public Boolean setParameter(string parameterName, Single parameterValue, MAVLink.MAV_PARAM_TYPE type)
        {
            if (this.isConnected())
            {
                // don't send updates for same values
                if (this.Parameters.ContainsKey(parameterName))
                {
                    if (this.parameters[parameterName].param_value.Equals(parameterValue))
                    {
                        return(true);
                    }
                }

                // wait here on multiple parameter set requests
                lock (parameterSetLock)
                {
                    connection.sendParamUpdate(parameterName, parameterValue, type);
                    return(fetchParameterSetAck(parameterName));
                }
            }
            return(false);
        }
        public void setup(string paramname, MAVLink.MAVLinkParamList paramlist)
        {
            this.ParamName = paramname;

            if (paramlist.ContainsKey(paramname))
            {
                this.Enabled = true;

                list = ParameterMetaDataRepository.GetParameterBitMaskInt(ParamName,
                    MainV2.comPort.MAV.cs.firmware.ToString());
                chkcount = list.Count;

                int leftside = 9;
                int top = 9;
                int bottom = 0;

                uint value = (uint) paramlist[paramname].Value;

                Type = paramlist[paramname].TypeAP;

                for (int a = 0; a < chkcount; a++)
                {
                    CheckBox chk = new CheckBox();
                    chk.AutoSize = true;
                    chk.Text = list[a].Value.ToString();
                    chk.Location = new System.Drawing.Point(leftside, top);

                    bottom = chk.Bottom;

                    chk.CheckedChanged -= MavlinkCheckBoxBitMask_CheckedChanged;

                    if ((value & (1 << list[a].Key)) > 0)
                    {
                        chk.Checked = true;
                    }

                    chklist.Add(new KeyValuePair<int, CheckBox>(list[a].Key, chk));
                    panel1.Controls.Add(chk);

                    chk.CheckedChanged += MavlinkCheckBoxBitMask_CheckedChanged;

                    //this.Controls.Add(new Label() { Location = chk.Location, Text = "test" });

                    leftside += chk.Width + 5;
                    if (leftside > 500)
                    {
                        top += chk.Height + 5;
                        leftside = 9;
                    }
                }


                this.panel1.Height = bottom;

                this.Height = myLabel1.Height + tableLayoutPanel1.Height + 25;
            }
            else
            {
                this.Enabled = false;
            }
        }