Esempio n. 1
0
        public static HierachyItem GetItembyPath(UAVParameter param, string path)
        {
            string key     = path;
            string newpath = "";

            MonitoredDictionary <string, UAVParameter> .GetKeyPath(ref key, ref newpath);

            if (param is UAVStructure)
            {
                UAVStructure mystructure = ((UAVStructure)param);
                foreach (UAVParameter myparams in mystructure.values.Values)
                {
                    if (myparams.Name == key)
                    {
                        GetItembyPath(myparams, newpath);
                    }
                }
            }
            else
            if (param is UAVParameter)
            {
                if (param.Name == key)
                {
                    return(param);
                }
                //   remotedata.Add(newparam);
            }

            return(null);
        }
Esempio n. 2
0
 void uavData_ValueChanged(UAVCommons.UAVParameter param, bool isremote)
 {
     //if (Lastupdate.AddMilliseconds(-100) < DateTime.Now)
     //{
     //    Lastupdate = DateTime.Now;
     //    LoadDatafromAHRS();
     //}
 }
Esempio n. 3
0
 public UAVSingleParameter this[string key]
 {
     get
     {
         return(uavData[key]);
     }
     set
     {
         lock (SyncObj)
         {
             try{
                 if (uavData.ContainsKey(key))
                 {
                     if (value is UAVStructure)
                     {
                         ((UAVStructure)(value)).ValueChanged += new UAVStructure.ValueChangedHandler(MonitoredDictionary_ValueChanged);
                     }
                     else
                     {
                         value.ValueChanged += new UAVSingleParameter.ValueChangedHandler(Value_ValueChanged);
                     }
                     uavData[key] = value;
                 }
                 else
                 {
                     UAVParameter param = new UAVParameter(key, value);
                     param.Min = null;
                     param.Max = null;
                     uavData.Add(key, value);
                 }
                 if (ValueChanged != null)
                 {
                     ValueChanged(value, false);
                 }
             }catch (Exception ex)
             {
                 ;
                 throw new Exception("Error on key: " + key, ex);
             }
         }
     }
 }
Esempio n. 4
0
        /// <summary>
        /// creates a duplicate of the Parameter
        /// </summary>
        /// <returns></returns>
        public virtual object Clone()
        {
            UAVParameter newParam = null;

            if (this.value is double)
            {
                newParam = new UAVParameter((string)this.name.Clone(),
                                            Convert.ToDouble(value.ToString()));
            }
            else
            {
                newParam = new UAVParameter((string)this.name.Clone(),
                                            ObjectCopier.Clone <object> (this.value));
            }
            newParam.updateRate = this.updateRate;
            newParam.Min        = this.Min;
            newParam.Max        = this.Max;
            newParam.parent     = this.parent;
            return(newParam);
        }
Esempio n. 5
0
        /// <summary>
        ///  Calculate Distance to current Waypoint and if overhead call event
        /// </summary>
        /// <param name="param"></param>
        /// <param name="isremote"></param>
        void gps_ValueChanged(UAVCommons.UAVParameter param, bool isremote)
        {
            if (currentWaypoint != null)
            {
                if (Distance((UAVStructure)this.gps, currentWaypoint) < Convert.ToDouble(performanceData["WayPointThreshold"].Value))
                {
                    if (PassingWayPoint != null)
                    {
                        PassingWayPoint(currentWaypoint);
                    }
                }

                values["TargetPsi"].Value = this.GetDirection((FlightControlCommons.GPS)gps, currentWaypoint);

                values["TargetAltitude"].Value = currentWaypoint.Altitude;
            }
            else
            {
                // What todo if there is no current WayPoint Set?
            }
        }
Esempio n. 6
0
        public UAVSingleParameter SilentUpdate(string key, object value, bool isremote)
        {
            string newpath = "";

            GetKeyPath(ref key, ref newpath);

            if (uavData.ContainsKey(key))
            {
                // Cut away current level
                return(uavData[key].SilentUpdate(newpath, value, isremote));
            }
            else
            {
                UAVSingleParameter parameter;
                if (newpath == key)
                {
                    if (owner is UAVParameter)
                    {
                        parameter = new UAVSingleParameter(key, value);
                    }
                    else
                    {
                        if ((key == "Min") || (key == "Max") || (key == "UpdateRate"))
                        {
                            parameter = new UAVSingleParameter(key, value);
                        }
                        else
                        {
                            if (owner.Name != key)
                            {
                                parameter = new UAVParameter(key, value);
                            }
                            else
                            {
                                return((UAVSingleParameter)owner);
                            }
                        }
                    }
                }
                else
                {
                    parameter               = new UAVStructure(key, "");
                    parameter.Parent        = owner;
                    parameter.ValueChanged += new UAVSingleParameter.ValueChangedHandler(parameter_ValueChanged);

                    uavData.Add(key, parameter);
                    UAVSingleParameter child = parameter.SilentUpdate(newpath, value, isremote);
                    child.Parent        = parameter;
                    child.ValueChanged += new UAVSingleParameter.ValueChangedHandler(parameter_ValueChanged);
                    return(child);
                }
                parameter.ValueChanged += new UAVSingleParameter.ValueChangedHandler(parameter_ValueChanged);

                parameter.Parent = owner;
                uavData.Add(key, parameter);
                if (NewValue != null)
                {
                    NewValue(parameter, isremote);
                }
                return(parameter);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// To be Implemented
 /// Schlussrechnung
 /// </summary>
 /// <param name="oldValueandRange"></param>
 /// <param name="newValueandRange"></param>
 /// <returns></returns>
 public static Double TransformToRange(UAVParameter oldValueandRange, UAVParameter newValueandRange)
 {
     return(0);
 }
Esempio n. 8
0
 public virtual void ahrs_ValueChanged(UAVCommons.UAVParameter param, bool isremote)
 {
     //lastphi = Convert.ToDouble(ahrs.values["phi"]);
     //lastpsi = Convert.ToDouble(ahrs.values["psi"]);
     //lasttheta = Convert.ToDouble(ahrs.values["theta"]);
 }
Esempio n. 9
0
 void currentUAV_DataArrived(UAVCommons.CommunicationEndpoint source, UAVCommons.UAVParameter arg)
 {
     LoadDatafromAHRS();
 }