/// <summary> /// Saves the Given UAV to a given Stream /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public static Stream Save(Stream target, UAVBase source) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(target, source); return(target); }
public static HierachyItem GetItembyPath(UAVBase core, string path) { List <UAVParameter> uavData = new List <UAVParameter>(); string key = path; string newpath = ""; MonitoredDictionary <string, UAVParameter> .GetKeyPath(ref key, ref newpath); foreach (UAVParameter param in core.uavData.Values) { if (param.Name == key) { if (newpath == key) { return(param); } if (param is UAVStructure) { return(GetItembyPath(param, newpath)); } } } return(null); }
public GroundControlCore(IntPtr handle) { XmlConfigurator.Configure(); logger = LogManager.GetLogger(""); logger.Info(new UAVCommons.Logging.ParameterLogEvent()); currentUAV = new UAV(); try { stick = new FlightControlCommons.UAVJoystick("Joystickunmapped", "", handle); stick.ConnectHardware(); currentUAV.uavData.Add(stick); mapping = new UAVCommons.UAVDataMapping("Joystick", "", stick); foreach (string key in stick.values.Keys) { if (!mapping.Mapping.ContainsKey(key)) { mapping.Mapping.Add(key, key); } } currentUAV.uavData.Add(mapping); } catch (Exception ex) { // currentUAV.WriteToLog("GroundLog","Error on Adding Joystick"); } // currentUAV.uavData.Add("Joystick", new FlightControlCommons.UAVJoystick("Joystick",0)); // currentUAV.uavData.Add("Keyboard", new FlightControlCommons.UAVKeyboard("Keyboard", 0)); }
public EFISViewer(GroundControlCore.GroundControlCore uAVBase) { // TODO: Complete member initialization this.mycore = uAVBase; this.uAVBase = uAVBase.currentUAV; InitializeComponent(); }
public EFISViewer(GroundControlCore.GroundControlCore uAVBase) { // TODO: Complete member initialization this.mycore = uAVBase; this.uAVBase = uAVBase.currentUAV; InitializeComponent(); }
public GroundControlCore(IntPtr handle) { XmlConfigurator.Configure(); logger = LogManager.GetLogger(""); logger.Info(new UAVCommons.Logging.ParameterLogEvent()); currentUAV = new UAV(); try { stick = new FlightControlCommons.UAVJoystick("Joystickunmapped", "", handle); stick.ConnectHardware(); currentUAV.uavData.Add(stick); mapping = new UAVCommons.UAVDataMapping("Joystick", "", stick); foreach (string key in stick.values.Keys) { if (!mapping.Mapping.ContainsKey(key)) { mapping.Mapping.Add(key, key); } } currentUAV.uavData.Add(mapping); } catch (Exception ex) { // currentUAV.WriteToLog("GroundLog","Error on Adding Joystick"); } // currentUAV.uavData.Add("Joystick", new FlightControlCommons.UAVJoystick("Joystick",0)); // currentUAV.uavData.Add("Keyboard", new FlightControlCommons.UAVKeyboard("Keyboard", 0)); }
/// <summary> /// Loads an Instance of a UAV from file /// </summary> /// <param name="filename"></param> /// <returns></returns> public static UAVBase Load(string filename) { using (FileStream filestream = File.OpenRead(filename)) { BinaryFormatter formatter = new BinaryFormatter(); UAVBase uav = (UAVBase)formatter.Deserialize(filestream); uav.OnLoad(); return(uav); } }
public static List <UAVSingleParameter> NormaliseUavData(UAVBase core) { List <UAVSingleParameter> uavData = new List <UAVSingleParameter>(); foreach (UAVSingleParameter param in core.uavData.Values) { HierachyItem.NormaliseStructure(param, uavData); } return(uavData); }
public static void LoadValues(XmlElement elem, UAVBase target) { if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != "en-US") { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); } foreach (XmlElement val in elem.ChildNodes) { LoadValues(val, target); } string value = null; string path = null; try { path = elem.GetAttribute("Path"); if (elem.HasAttribute("Value")) { string strval = elem.GetAttribute("Value"); if (strval == "[[NULL]]") { value = null; } else { value = strval; } } if (path == "") { return; } UAVSingleParameter param = target.uavData.SilentUpdate(path, value, false); param.LoadValues(elem); if (elem.HasAttribute("Max")) { param.Max = elem.GetAttribute("Max"); } if (elem.HasAttribute("Min")) { param.Min = elem.GetAttribute("Min"); } if (elem.HasAttribute("URate")) { param.updateRate = Convert.ToInt32(elem.GetAttribute("URate")); } } catch (Exception ex) { Console.WriteLine("Error on loading Values for " + path + " value was " + value); throw ex; } }
public static HierachyItem GetItembyPath(UAVBase core,string path) { List<UAVParameter> uavData = new List<UAVParameter>(); string key = path; string newpath = ""; MonitoredDictionary<string, UAVParameter>.GetKeyPath(ref key, ref newpath); foreach (UAVParameter param in core.uavData.Values) { if (param.Name == key){ if (newpath == key) return param; if (param is UAVStructure) return GetItembyPath(param,newpath); } } return null; }
public static void SaveValues(Stream target, UAVBase source) { if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != "en-US") { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); } XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("UAVData"); doc.AppendChild(root); foreach (var key in source.uavData.Keys) { source.uavData[key].SavetoXML(root, doc); } doc.Save(target); }
public static void LoadValues(Stream source, UAVBase target) { if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != "en-US") { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); } if (source.Length == 0) { return; } XmlDocument doc = new XmlDocument(); doc.Load(source); XmlElement elem = (XmlElement)doc.SelectSingleNode("UAVData"); LoadValues(elem, target); }
public static List<UAVSingleParameter> NormaliseUavData(UAVBase core) { List<UAVSingleParameter> uavData = new List<UAVSingleParameter>(); foreach (UAVSingleParameter param in core.uavData.Values) { HierachyItem.NormaliseStructure(param, uavData); } return uavData; }
static void Main(string[] args) { if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != "en-US") { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); } Double i = -49; object test = i; Console.Write ("Running on "+Convert.ToDouble(test)); if (FlightControlCommons.UsbHelper.IsLinux) { Console.WriteLine ("Linux"); } else { Console.WriteLine ("Windows"); } Console.WriteLine ("Flight Control Service"); Console.WriteLine ("Controls the UAV"); Console.WriteLine (""); string autosavetimestr = ConfigurationSettings.AppSettings ["AutoSaveTime"]; if (Int32.TryParse (autosavetimestr, out autoSaveTime)) { autoSaveTimer = new Timer (new TimerCallback (Program.AutoSave), null, 10000, autoSaveTime); Console.WriteLine ("AutoSaveTimer Set from Config File!"); } filename = ConfigurationSettings.AppSettings ["UAVFilename"]; bool loadFromFile = false; try { loadFromFile = Convert.ToBoolean (ConfigurationSettings.AppSettings ["LoadSettingsFromFile"]); } catch (Exception ex) { Console.WriteLine ("Can not parse LoadSettingsFromFile in Config File"); } uav = new VTOLUAV (); Console.WriteLine ("Connecting to GroundControl.."); if (Convert.ToBoolean (ConfigurationSettings.AppSettings ["WLAN"])) { // Baue Kommunikationskanal für Befehle in beide Richtungen auf TCPCommunicationEndPoint controlconnection = new TCPCommunicationEndPoint (); controlconnection.commType = CommunicationEndpoint.Communicationtype.Command; controlconnection.endpointAdress = ConfigurationSettings.AppSettings ["GroundIP"]; // IP Addresse der Gegenstelle (Groundkontroll) controlconnection.endpointPort = Convert.ToInt32 (ConfigurationSettings.AppSettings ["GroundCommandPort"]); /// Kommunikationskanal muss auf beiden seiten gleich sein controlconnection.endpointSpeedType = CommunicationEndpoint.SpeedType.Wifi; // Geschwindigkeit controlconnection.listen = false; // einer muss verbindungen annehmen (Server) der andere hinverbinden (Connect) controlconnection.cmdHandler = uav; uav.knownEndpoints.Add (controlconnection); // Aktiviere Kommunikationskanal } if (Convert.ToBoolean (ConfigurationSettings.AppSettings ["VPN"])) { // Baue Kommunikationskanal für Empfang von Werten von der Bodenstation TCPCommunicationEndPoint recieveConnection1 = new TCPCommunicationEndPoint (); recieveConnection1.commType = CommunicationEndpoint.Communicationtype.Send; recieveConnection1.endpointAdress = ConfigurationSettings.AppSettings ["VPNGroundIP"]; recieveConnection1.endpointPort = Convert.ToInt32 (ConfigurationSettings.AppSettings ["VPNSendPort"]); recieveConnection1.endpointSpeedType = CommunicationEndpoint.SpeedType.Gprs3G; recieveConnection1.listen = false; uav.knownEndpoints.Add (recieveConnection1); // Baue Kommunikationskanal für das Senden von Werten zur Bodenstation auf TCPCommunicationEndPoint sendConnection1 = new TCPCommunicationEndPoint (); sendConnection1.commType = CommunicationEndpoint.Communicationtype.Recieve; sendConnection1.endpointAdress = ConfigurationSettings.AppSettings ["VPNGroundIP"]; sendConnection1.endpointPort = Convert.ToInt32 (ConfigurationSettings.AppSettings ["VPNRecievePort"]); sendConnection1.endpointSpeedType = CommunicationEndpoint.SpeedType.Gprs3G; sendConnection1.listen = false; uav.knownEndpoints.Add (sendConnection1); } if (Convert.ToBoolean (ConfigurationSettings.AppSettings ["WLAN"])) { TCPCommunicationEndPoint recieveConnection = new TCPCommunicationEndPoint (); recieveConnection.commType = CommunicationEndpoint.Communicationtype.Send; recieveConnection.endpointAdress = ConfigurationSettings.AppSettings ["GroundIP"]; recieveConnection.endpointPort = Convert.ToInt32 (ConfigurationSettings.AppSettings ["SendPort"]); recieveConnection.endpointSpeedType = CommunicationEndpoint.SpeedType.Wifi; recieveConnection.listen = false; uav.knownEndpoints.Add (recieveConnection); // Baue Kommunikationskanal für das Senden von Werten zur Bodenstation auf TCPCommunicationEndPoint sendConnection = new TCPCommunicationEndPoint (); sendConnection.commType = CommunicationEndpoint.Communicationtype.Recieve; sendConnection.endpointAdress = ConfigurationSettings.AppSettings ["GroundIP"]; sendConnection.endpointPort = Convert.ToInt32 (ConfigurationSettings.AppSettings ["RecievePort"]); sendConnection.endpointSpeedType = CommunicationEndpoint.SpeedType.Wifi; sendConnection.listen = false; uav.knownEndpoints.Add (sendConnection); } if (loadFromFile) { if (File.Exists(filename)) { try { Console.WriteLine("Load Values from File"); using (FileStream stream = File.OpenRead(filename)) { UAVBase.LoadValues(stream, uav); } } catch (Exception ex) { Console.WriteLine("Fehler beim Einlesen der Config Datei " + filename); File.Delete(filename); throw ex; } } } uav.OnLoad(); //Load all non serialised objects from uav and connect to hardware uav.run (); }
public void UAVBase_CommunicationStatusChanged(UAVBase source, CommunicationEndpoint arg, string state) { }
public static void SaveValues(Stream target, UAVBase source) { if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != "en-US") { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); } XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("UAVData"); doc.AppendChild(root); foreach (var key in source.uavData.Keys) { source.uavData[key].SavetoXML(root,doc); } doc.Save(target); }
public override void Send(UAVBase core) { base.Send(core); }
public static void LoadValues(XmlElement elem, UAVBase target) { if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != "en-US") { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); } foreach (XmlElement val in elem.ChildNodes) { LoadValues(val,target); } string value = null; string path = null; try { path = elem.GetAttribute("Path"); if (elem.HasAttribute("Value")) { string strval = elem.GetAttribute("Value"); if (strval == "[[NULL]]"){ value = null; }else{ value = strval; } } if (path == "") return; UAVSingleParameter param = target.uavData.SilentUpdate(path, value, false); param.LoadValues(elem); if (elem.HasAttribute("Max")) param.Max = elem.GetAttribute("Max"); if (elem.HasAttribute("Min")) param.Min = elem.GetAttribute("Min"); if (elem.HasAttribute("URate")) param.updateRate = Convert.ToInt32(elem.GetAttribute("URate")); } catch (Exception ex) { Console.WriteLine("Error on loading Values for "+path+ " value was "+ value); throw ex; } }
public static void LoadValues(Stream source,UAVBase target) { if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != "en-US") { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); } if (source.Length == 0) return; XmlDocument doc = new XmlDocument(); doc.Load(source); XmlElement elem = (XmlElement)doc.SelectSingleNode("UAVData"); LoadValues(elem,target); }
static void Main(string[] args) { // PWM test = new PWM("",0,"",0); // return; Console.Write ("Running on "); if (FlightControlCommons.UsbHelper.IsLinux) { Console.WriteLine ("Linux"); } else { Console.WriteLine ("Windows"); } Console.WriteLine ("Flight Control Service"); Console.WriteLine ("Controls the UAV"); Console.WriteLine (""); string autosavetimestr = ConfigurationSettings.AppSettings ["AutoSaveTime"]; if (Int32.TryParse (autosavetimestr, out autoSaveTime)) { autoSaveTimer = new Timer (new TimerCallback (Program.AutoSave), null, 10000, autoSaveTime); Console.WriteLine ("AutoSaveTimer Set from Config File!"); } filename = ConfigurationSettings.AppSettings ["UAVFilename"]; bool loadFromFile = false; try { loadFromFile = Convert.ToBoolean (ConfigurationSettings.AppSettings ["LoadSettingsFromFile"]); } catch (Exception ex) { Console.WriteLine ("Can not parse LoadSettingsFromFile in Config File"); } uav = new VTOLUAV (); Console.WriteLine ("Connecting to GroundControl.."); if (Convert.ToBoolean (ConfigurationSettings.AppSettings ["WLAN"])) { // Baue Kommunikationskanal für Befehle in beide Richtungen auf TCPCommunicationEndPoint controlconnection = new TCPCommunicationEndPoint (); controlconnection.commType = CommunicationEndpoint.Communicationtype.Command; controlconnection.endpointAdress = ConfigurationSettings.AppSettings ["GroundIP"]; // IP Addresse der Gegenstelle (Groundkontroll) controlconnection.endpointPort = Convert.ToInt32 (ConfigurationSettings.AppSettings ["GroundCommandPort"]); /// Kommunikationskanal muss auf beiden seiten gleich sein controlconnection.endpointSpeedType = CommunicationEndpoint.SpeedType.Wifi; // Geschwindigkeit controlconnection.listen = false; // einer muss verbindungen annehmen (Server) der andere hinverbinden (Connect) controlconnection.cmdHandler = uav; uav.knownEndpoints.Add (controlconnection); // Aktiviere Kommunikationskanal } if (Convert.ToBoolean (ConfigurationSettings.AppSettings ["VPN"])) { // Baue Kommunikationskanal für Empfang von Werten von der Bodenstation TCPCommunicationEndPoint recieveConnection1 = new TCPCommunicationEndPoint (); recieveConnection1.commType = CommunicationEndpoint.Communicationtype.Send; recieveConnection1.endpointAdress = ConfigurationSettings.AppSettings ["VPNGroundIP"]; recieveConnection1.endpointPort = Convert.ToInt32 (ConfigurationSettings.AppSettings ["VPNSendPort"]); recieveConnection1.endpointSpeedType = CommunicationEndpoint.SpeedType.Gprs3G; recieveConnection1.listen = false; uav.knownEndpoints.Add (recieveConnection1); // Baue Kommunikationskanal für das Senden von Werten zur Bodenstation auf TCPCommunicationEndPoint sendConnection1 = new TCPCommunicationEndPoint (); sendConnection1.commType = CommunicationEndpoint.Communicationtype.Recieve; sendConnection1.endpointAdress = ConfigurationSettings.AppSettings ["VPNGroundIP"]; sendConnection1.endpointPort = Convert.ToInt32 (ConfigurationSettings.AppSettings ["VPNRecievePort"]); sendConnection1.endpointSpeedType = CommunicationEndpoint.SpeedType.Gprs3G; sendConnection1.listen = false; uav.knownEndpoints.Add (sendConnection1); } if (Convert.ToBoolean (ConfigurationSettings.AppSettings ["WLAN"])) { TCPCommunicationEndPoint recieveConnection = new TCPCommunicationEndPoint (); recieveConnection.commType = CommunicationEndpoint.Communicationtype.Send; recieveConnection.endpointAdress = ConfigurationSettings.AppSettings ["GroundIP"]; recieveConnection.endpointPort = Convert.ToInt32 (ConfigurationSettings.AppSettings ["SendPort"]); recieveConnection.endpointSpeedType = CommunicationEndpoint.SpeedType.Wifi; recieveConnection.listen = false; uav.knownEndpoints.Add (recieveConnection); // Baue Kommunikationskanal für das Senden von Werten zur Bodenstation auf TCPCommunicationEndPoint sendConnection = new TCPCommunicationEndPoint (); sendConnection.commType = CommunicationEndpoint.Communicationtype.Recieve; sendConnection.endpointAdress = ConfigurationSettings.AppSettings ["GroundIP"]; sendConnection.endpointPort = Convert.ToInt32 (ConfigurationSettings.AppSettings ["RecievePort"]); sendConnection.endpointSpeedType = CommunicationEndpoint.SpeedType.Wifi; sendConnection.listen = false; uav.knownEndpoints.Add (sendConnection); } uav.OnLoad (); //Load all non serialised objects from uav and connect to hardware uav.run (); }
public override void RemoteExecute(UAVBase core) { base.RemoteExecute(core); // ((FlightControlCommons.components.WaypointMissionControl)core.uavData[MissionControlName]).Waypoints = waypoints; }
public _3DViewer(UAVCommons.UAVBase uAVBase) { this.mycore = uAVBase; InitializeComponent(); }
/// <summary> /// Saves the Given UAV to a given Stream /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public static Stream Save(Stream target, UAVBase source) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(target, source); return target; }
public void UAVBase_CommunicationStatusChanged(UAVBase source, CommunicationEndpoint arg, string state) { }
public _3DViewer(UAVCommons.UAVBase uAVBase) { this.mycore = uAVBase; InitializeComponent(); }