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); }
void uavData_ValueChanged(UAVCommons.UAVParameter param, bool isremote) { //if (Lastupdate.AddMilliseconds(-100) < DateTime.Now) //{ // Lastupdate = DateTime.Now; // LoadDatafromAHRS(); //} }
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); } } } }
/// <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); }
/// <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? } }
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); } }
/// <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); }
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"]); }
void currentUAV_DataArrived(UAVCommons.CommunicationEndpoint source, UAVCommons.UAVParameter arg) { LoadDatafromAHRS(); }