Esempio n. 1
0
        private void loop()
        {
            // Logging
            var logging = new Logging();

            // Start location class
            var location = new Location();

            location.start();

            // Start RTTY Audio
            var rtty = new RTTY(Convert.ToDouble(settings["rttySineFreq"]), Convert.ToInt32(settings["rttySampleRate"]), Convert.ToInt32(settings["rttyBaud"]), 0, Convert.ToDouble(settings["rttyLow"]), Convert.ToDouble(settings["rttyHigh"]), Convert.ToInt32(settings["rttyStopBits"])); // Defaults are fine

            if ((bool)settings["rttyRTTYToggle"])
            {
                rtty.Start(); rtty.transmitSentence("Tranmission started!");
            }

            // Start habitat & couch
            var habitat = new Habitat((string)settings["habitatCouchURL"], (string)settings["habitatCouchDB"], (string)settings["sentenceCallsign"]);

            // Start Twitter
            var twitter = new Twitter((string)settings["twitterUsername"], (string)settings["twitterConsumerKey"], (string)settings["twitterConsumerSecret"], (string)settings["twitterAccessToken"], (string)settings["twitterAccessSecret"]);


            if (settings.Contains("sentenceID"))
            {
                sentenceID = Convert.ToInt32(settings["sentenceID"]);
            }
            else
            {
                sentenceID = 0;
            }

            OnPropertyChanged("dataSentenceID");

            int tweeti = 0;

            while (_isRunning == true)
            {
                /////////////////////////////////////
                // Main Loop Here. Yay. Whoop. No. //
                /////////////////////////////////////

                sentenceID++;
                settings["sentenceID"] = sentenceID;
                dataSentenceID         = sentenceID.ToString();
                OnPropertyChanged("dataSentenceID");

                bool hasNetworkConnection = NetworkInterface.GetIsNetworkAvailable();
                statusDataConnection = hasNetworkConnection.ToString();
                OnPropertyChanged("statusDataConnection");

                // Collect Data into Sentence object
                var sentence = new Sentence((string)settings["sentenceCallsign"], sentenceID, location.latitude, location.longitude, location.altitude);
                sentence.sentenceData.Add(location.speed);
                if (hasNetworkConnection)
                {
                    sentence.sentenceData.Add("1");
                }
                else
                {
                    sentence.sentenceData.Add("0");
                }

                dataAltitude = location.altitude;
                OnPropertyChanged("dataAltitude");
                dataLat = location.latitude;
                OnPropertyChanged("dataLat");
                dataLong = location.longitude;
                OnPropertyChanged("dataLong");
                dataSpeed = location.speed;
                OnPropertyChanged("dataSpeed");
                dataTime = System.DateTime.Now.ToString("HH:mm:ss");
                OnPropertyChanged("dataTime");

                if (location.status)
                {
                    System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        updateMap(location.currentlocation);
                    });
                }

                // Construct sentence
                if (sentence.compileSentence())
                {
                    // Log sentence & data
                    sentence.logSentence();

                    // Upload to habitat, if internet
                    if (hasNetworkConnection && (bool)settings["habitatHabitatToggle"])
                    {
                        habitat.uploadTelemetry(sentence.wholeSentence);
                        statusHabitat = habitat.status.ToString();
                        OnPropertyChanged("statusHabitat");
                    }
                    else
                    {
                        statusHabitat = "False";
                        OnPropertyChanged("statusHabitat");
                    }

                    // Transmit sentence
                    if (rtty.isRunning)
                    {
                        rtty.transmitSentence(sentence.wholeSentence);
                        statusTransmit = "True";
                        OnPropertyChanged("statusTransmit");
                    }
                    else
                    {
                        statusTransmit = "False";
                        OnPropertyChanged("statusTransmit");
                    }
                }

                // Twitter, if internet
                if (hasNetworkConnection && (bool)settings["twitterTwitterToggle"])
                {
                    if (tweeti >= Convert.ToInt32(settings["twitterInterval"]))
                    {
                        string tweet = "I'm at " + location.latitude + ", " + location.longitude + " at an altitude of " + location.altitude + "m #apexhab #ukhas";
                        twitter.newStatusAsync(tweet, location.latitude, location.longitude);
                        statusTwitter = twitter.status.ToString();
                        OnPropertyChanged("statusTwitter");
                        tweeti = 0;
                    }
                }
                else
                {
                    statusTwitter = "False";
                    OnPropertyChanged("statusTwitter");
                }
                tweeti++;

                // Upload photos to SkyDrive

                // Probably wait a bit
                Thread.Sleep(2000);
            }

            // End & Close stuff, possibly not necessary

            location.stop();
            rtty.Stop();
        }
Esempio n. 2
0
        private void loop()
        {
            // Logging
            var logging = new Logging();

            // Start location class
            var location = new Location();
            location.start();

            // Start RTTY Audio
            var rtty = new RTTY(Convert.ToDouble(settings["rttySineFreq"]), Convert.ToInt32(settings["rttySampleRate"]), Convert.ToInt32(settings["rttyBaud"]), 0, Convert.ToDouble(settings["rttyLow"]), Convert.ToDouble(settings["rttyHigh"]), Convert.ToInt32(settings["rttyStopBits"])); // Defaults are fine
            if ((bool)settings["rttyRTTYToggle"]) { rtty.Start(); rtty.transmitSentence("Tranmission started!"); }

            // Start habitat & couch
            var habitat = new Habitat((string)settings["habitatCouchURL"], (string)settings["habitatCouchDB"], (string)settings["sentenceCallsign"]);

            // Start Twitter
            var twitter = new Twitter((string)settings["twitterUsername"], (string)settings["twitterConsumerKey"], (string)settings["twitterConsumerSecret"], (string)settings["twitterAccessToken"], (string)settings["twitterAccessSecret"]);

            if (settings.Contains("sentenceID"))
            {
                sentenceID = Convert.ToInt32(settings["sentenceID"]);
            }
            else
            {
                sentenceID = 0;
            }

            OnPropertyChanged("dataSentenceID");

            int tweeti = 0;

            while (_isRunning == true)
            {
                /////////////////////////////////////
                // Main Loop Here. Yay. Whoop. No. //
                /////////////////////////////////////

                sentenceID++;
                settings["sentenceID"] = sentenceID;
                dataSentenceID = sentenceID.ToString();
                OnPropertyChanged("dataSentenceID");

                bool hasNetworkConnection = NetworkInterface.GetIsNetworkAvailable();
                statusDataConnection = hasNetworkConnection.ToString();
                OnPropertyChanged("statusDataConnection");

                // Collect Data into Sentence object
                var sentence = new Sentence((string)settings["sentenceCallsign"], sentenceID, location.latitude, location.longitude, location.altitude);
                sentence.sentenceData.Add(location.speed);
                if (hasNetworkConnection) { sentence.sentenceData.Add("1"); } else { sentence.sentenceData.Add("0"); }

                dataAltitude = location.altitude;
                OnPropertyChanged("dataAltitude");
                dataLat = location.latitude;
                OnPropertyChanged("dataLat");
                dataLong = location.longitude;
                OnPropertyChanged("dataLong");
                dataSpeed = location.speed;
                OnPropertyChanged("dataSpeed");
                dataTime = System.DateTime.Now.ToString("HH:mm:ss");
                OnPropertyChanged("dataTime");

                if (location.status)
                {
                    System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        updateMap(location.currentlocation);
                    });
                }

                // Construct sentence
                if(sentence.compileSentence()){

                    // Log sentence & data
                    sentence.logSentence();

                    // Upload to habitat, if internet
                    if (hasNetworkConnection && (bool)settings["habitatHabitatToggle"])
                    {
                        habitat.uploadTelemetry(sentence.wholeSentence);
                        statusHabitat = habitat.status.ToString();
                        OnPropertyChanged("statusHabitat");
                    }
                    else
                    {
                        statusHabitat = "False";
                        OnPropertyChanged("statusHabitat");
                    }

                    // Transmit sentence
                    if (rtty.isRunning)
                    {
                        rtty.transmitSentence(sentence.wholeSentence);
                        statusTransmit = "True";
                        OnPropertyChanged("statusTransmit");
                    }
                    else
                    {
                        statusTransmit = "False";
                        OnPropertyChanged("statusTransmit");
                    }
                }

                // Twitter, if internet
                if (hasNetworkConnection && (bool)settings["twitterTwitterToggle"])
                {
                    if (tweeti >= Convert.ToInt32(settings["twitterInterval"]))
                    {
                        string tweet = "I'm at " + location.latitude + ", " + location.longitude + " at an altitude of " + location.altitude + "m #apexhab #ukhas";
                        twitter.newStatusAsync(tweet, location.latitude, location.longitude);
                        statusTwitter = twitter.status.ToString();
                        OnPropertyChanged("statusTwitter");
                        tweeti = 0;
                    }
                }
                else
                {
                    statusTwitter = "False";
                    OnPropertyChanged("statusTwitter");
                }
                tweeti++;

                // Upload photos to SkyDrive

                // Probably wait a bit
                Thread.Sleep(2000);

            }

            // End & Close stuff, possibly not necessary

            location.stop();
            rtty.Stop();
        }