Example #1
0
 private static void NormaliseStructure(UAVSingleParameter param, List <UAVSingleParameter> remotedata)
 {
     if (param is UAVStructure)
     {
         UAVStructure mystructure = ((UAVStructure)param);
         foreach (UAVSingleParameter myparams in mystructure.values.Values)
         {
             NormaliseStructure(myparams, remotedata);
             UAVSingleParameter structparam = new UAVSingleParameter(param.GetStringPath(), myparams.Value, myparams.Min, myparams.Max);
             if (remotedata.Count(m => m.Name.Equals(structparam.Name)) == 0)
             {
                 remotedata.Add(structparam);
             }
         }
         // UAVSingleParameter param1 = new UAVSingleParameter(param.Name, param.Value, param.Min, param.Max);
         // remotedata.Add(param1);
     }
     else
     if (param is UAVSingleParameter)
     {
         UAVSingleParameter newparam = new UAVSingleParameter(param.Name, param.Value);
         newparam.Name       = param.GetStringPath();
         newparam.Min        = param.Min;
         newparam.Max        = param.Max;
         newparam.Parent     = param.Parent;
         newparam.updateRate = param.updateRate;
         newparam.Value      = param.Value;
         if (remotedata.Count(m => m.Name.Equals(newparam.Name)) == 0)
         {
             remotedata.Add(newparam);
         }
     }
 }
Example #2
0
 /// <summary>
 /// Sieht nach welcher Parameter in wie abgelegt werden soll
 /// </summary>
 /// <param name="param"></param>
 /// <param name="isremote"></param>
 void Source_ValueChanged(UAVSingleParameter param, bool isremote)
 {
     if (param.GetStringPath() == GetStringPath())
     {
         return;
     }
     lock (Syncobj)
     {
         //     Console.WriteLine(param.Name + " " + param.Value);
         if (mapping.ContainsKey(param.Name))
         {
             if (values.ContainsKey(mapping[param.Name]))
             {
                 if (values[mapping[param.Name]].GetStringPath() != param.GetStringPath())
                 {
                     values[mapping[param.Name]].Value = param.Value;
                 }
             }
             else
             {
                 values.Add(mapping[param.Name], new UAVParameter(mapping[param.Name], param.Value, param.Min, param.Max));
                 values[mapping[param.Name]].updateRate = 40;
             }
         }
     }
 }
Example #3
0
        public static void NormaliseStructure(UAVSingleParameter param, List <UAVSingleParameter> remotedata)
        {
            if (param is UAVStructure)
            {
                UAVStructure mystructure = ((UAVStructure)param);
                foreach (UAVSingleParameter myparams in mystructure.values.Values)
                {
                    if (myparams is UAVStructure)
                    {
                        NormaliseStructure(myparams, remotedata);
                        UAVSingleParameter temp = new UAVSingleParameter(myparams.GetStringPath(), myparams.Value);
                        temp.Max        = myparams.Max;
                        temp.Min        = myparams.Min;
                        temp.updateRate = myparams.updateRate;
                        temp.Value      = myparams.Value;
                        remotedata.Add(temp);
                    }
                    else
                    {
                        UAVSingleParameter temp = new UAVSingleParameter(myparams.GetStringPath(), myparams.Value);
                        temp.Max = myparams.Max;
                        temp.Min = myparams.Min;
                        // temp.Value = myparams.Value;
                        temp.updateRate = myparams.updateRate;
                        remotedata.Add(temp);
                    }
                }
                //Eigen Wert

                UAVSingleParameter temp2 = new UAVSingleParameter(param.GetStringPath(), param.Value);
                temp2.Max = param.Max;
                temp2.Min = param.Min;
                // temp.Value = myparams.Value;
                temp2.updateRate = param.updateRate;
                remotedata.Add(temp2);
            }
            else
            if (param is UAVSingleParameter)
            {
                UAVSingleParameter newparam = new UAVSingleParameter(param.Name, param.Value);
                newparam.Name = param.GetStringPath();
                newparam.Min  = param.Min;
                newparam.Max  = param.Max;
                //  if (!(param.Parent is UAVBase))
                //   {
                //      newparam.Parent = param.Parent;
                //    }
                newparam.updateRate = param.updateRate;
                newparam.Value      = param.Value;
                remotedata.Add(newparam);
            }
        }
Example #4
0
 public void Send(UAVSingleParameter param)
 {
     if (param.Value == null)
     {
         return;
     }
     lock (SendSync)
     {
         if (client != null)
         {
             UTF8Encoding encoder = new UTF8Encoding();
             byte[]       buffer  = encoder.GetBytes(param.GetStringPath() + "|" + DateTime.UtcNow.Ticks.ToString() + "|" + param.Value.ToString() + "\n");
             client.Send(buffer, buffer.Length);
         }
     }
 }
Example #5
0
 public void Send(UAVSingleParameter param)
 {
     if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != "en-US")
     {
         System.Threading.Thread.CurrentThread.CurrentCulture = new
                                                                System.Globalization.CultureInfo("en-US");
     }
     if (param.Value == null)
     {
         return;
     }
     lock (SendSync)
     {
         if (clientStream != null)
         {
             UTF8Encoding encoder = new UTF8Encoding();
             byte[]       buffer  = encoder.GetBytes(param.GetStringPath() + "|" + DateTime.UtcNow.Ticks.ToString() + "|" + param.Value.ToString() + "\n");
             clientStream.Write(buffer, 0, buffer.Length);
             clientStream.Flush();
         }
     }
 }
Example #6
0
        public ParameterControl(GroundControlCore.GroundControlCore core, UAVCommons.UAVSingleParameter parameter)
            : base()
        {
            InitializeComponent();
            this.core = core;
            core.currentUAV.uavData.NewValue += new UAVCommons.MonitoredDictionary <string, UAVCommons.UAVSingleParameter> .NewValueHandler(uavData_NewValue);

            if (parameter != null)
            {
                selectedParameter = parameter;
            }


            Update_Combobox();
            if (parameter != null)
            {
                cb_Parameter.SelectedItem = parameter.GetStringPath();
            }
            btn_output.ForeColor = Color.Blue;
            btn_output.Text      = "Input";
            output = false;

            if (parameter != null)
            {
                ValueBar.Step = 1;
                valueTracker.TickFrequency = 10;
                valueTracker.TickStyle     = TickStyle.Both;
                valueTracker.Maximum       = Convert.ToDecimal(parameter.Max);
                valueTracker.Minimum       = Convert.ToDecimal(parameter.Min);
                ValueBar.Minimum           = valueTracker.Minimum;
                ValueBar.Maximum           = valueTracker.Maximum;


                if (parameter.Max != null)
                {
                    tb_max.Text = parameter.Max.ToString();
                }
                if (parameter.Min != null)
                {
                    tb_min.Text = parameter.Min.ToString();
                }
                if ((parameter.Value != null) && (parameter.Value.ToString() != ""))
                {
                    if ((parameter.DoubleValue >= parameter.MinDoubleValue) &&
                        (parameter.DoubleValue <= parameter.MaxDoubleValue))
                    {
                        valueTracker.Value = Convert.ToDecimal(parameter.Value);
                        ValueBar.Value     = Convert.ToDecimal(valueTracker.Value);
                        lbl_value.Text     = parameter.Value.ToString();
                    }
                    else
                    {
                        lbl_value.Text = "Value out of Bounds " + parameter.Value.ToString();
                    }
                }
            }
            else
            {
                ValueBar.Minimum     = 0;
                valueTracker.Minimum = 0;
                ValueBar.Maximum     = 100;
                valueTracker.Maximum = 100;
                ValueBar.Value       = 50;
                valueTracker.Value   = 50;

                lbl_value.Text = "50";
            }
            this.valueTracker.Factor = 0.0001m;
        }