示例#1
0
        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();
        }
示例#2
0
        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();
        }
示例#3
0
        /// <summary>
        /// Initialise Object
        /// </summary>
        public UAV()
        {
            if (Convert.ToBoolean(ConfigurationSettings.AppSettings["WLAN"]))
            {
                TCPCommunicationEndPoint controlconnection = new TCPCommunicationEndPoint();
                controlconnection.commType          = CommunicationEndpoint.Communicationtype.Command;
                controlconnection.endpointAdress    = ConfigurationSettings.AppSettings["GroundIP"];
                controlconnection.endpointPort      = Convert.ToInt32(ConfigurationSettings.AppSettings["GroundCommandPort"]);
                controlconnection.endpointSpeedType = CommunicationEndpoint.SpeedType.Wifi;
                controlconnection.listen            = true;
                controlconnection.cmdHandler        = this;
                this.knownEndpoints.Add(controlconnection);
                if (NewGroundLogMessage != null)
                {
                    NewGroundLogMessage("GroundCommandEndpoint: " + controlconnection.endpointAdress + ":" + controlconnection.endpointPort);
                }
            }
            if (Convert.ToBoolean(ConfigurationSettings.AppSettings["VPN"]))
            {
                TCPCommunicationEndPoint recieveConnection = new TCPCommunicationEndPoint();
                recieveConnection.commType          = CommunicationEndpoint.Communicationtype.Send;
                recieveConnection.endpointAdress    = ConfigurationSettings.AppSettings["VPNGroundIP"];
                recieveConnection.endpointPort      = Convert.ToInt32(ConfigurationSettings.AppSettings["VPNGroundSendPort"]);
                recieveConnection.endpointSpeedType = CommunicationEndpoint.SpeedType.Gprs3G;
                recieveConnection.listen            = true;
                if (NewGroundLogMessage != null)
                {
                    NewGroundLogMessage("VPNCommandEndpoint: " + recieveConnection.endpointAdress + ":" + recieveConnection.endpointPort);
                }

                this.knownEndpoints.Add(recieveConnection);


                TCPCommunicationEndPoint recieveConnection1 = new TCPCommunicationEndPoint();
                recieveConnection1.commType          = CommunicationEndpoint.Communicationtype.Recieve;
                recieveConnection1.endpointAdress    = ConfigurationSettings.AppSettings["VPNGroundIP"];
                recieveConnection1.endpointPort      = Convert.ToInt32(ConfigurationSettings.AppSettings["VPNGroundRecievePort"]);
                recieveConnection1.endpointSpeedType = CommunicationEndpoint.SpeedType.Gprs3G;
                recieveConnection1.listen            = true;
                if (NewGroundLogMessage != null)
                {
                    NewGroundLogMessage("VPNGroundRecievePort: " + recieveConnection1.endpointAdress + ":" + recieveConnection1.endpointPort);
                }

                this.knownEndpoints.Add(recieveConnection1);
            }
            if (Convert.ToBoolean(ConfigurationSettings.AppSettings["WLAN"]))
            {
                TCPCommunicationEndPoint sendConnection1 = new TCPCommunicationEndPoint();
                sendConnection1.commType          = CommunicationEndpoint.Communicationtype.Send;
                sendConnection1.endpointAdress    = ConfigurationSettings.AppSettings["GroundIP"];
                sendConnection1.endpointPort      = Convert.ToInt32(ConfigurationSettings.AppSettings["GroundSendPort"]);
                sendConnection1.endpointSpeedType = CommunicationEndpoint.SpeedType.Wifi;
                sendConnection1.listen            = true;
                if (NewGroundLogMessage != null)
                {
                    NewGroundLogMessage("GroundSend: " + sendConnection1.endpointAdress + ":" + sendConnection1.endpointPort);
                }

                this.knownEndpoints.Add(sendConnection1);


                TCPCommunicationEndPoint sendConnection = new TCPCommunicationEndPoint();
                sendConnection.commType          = CommunicationEndpoint.Communicationtype.Recieve;
                sendConnection.endpointAdress    = ConfigurationSettings.AppSettings["GroundIP"];
                sendConnection.endpointPort      = Convert.ToInt32(ConfigurationSettings.AppSettings["GroundRecievePort"]);
                sendConnection.endpointSpeedType = CommunicationEndpoint.SpeedType.Wifi;
                sendConnection.listen            = true;
                if (NewGroundLogMessage != null)
                {
                    NewGroundLogMessage("GroundRecieve: " + sendConnection.endpointAdress + ":" + sendConnection.endpointPort);
                }
                this.knownEndpoints.Add(sendConnection);
            }
            NewGroundLogMessage += new NewGroundLogMessageHandler(UAV_NewGroundLogMessage);
        }