Exemplo n.º 1
0
 //---------------------------Ground Station Button----------------
 private void button3_Click(object sender, EventArgs e)
 {
     MainFunctions.sidePanelAction(panel1, groundPanel);
 }
Exemplo n.º 2
0
        /*******************************************************************************************************
        * Form Actions, Interactions and mouse over
        *
        *******************************************************************************************************/

        /*
         * Side Panel Interactions
         *
         */
        //---------------------------Satellite Button----------------
        private void button2_Click(object sender, EventArgs e)
        {
            MainFunctions.sidePanelAction(panel1, satellitePanel);
        }
Exemplo n.º 3
0
 //---------------------------Schedule Button----------------
 private void button1_Click(object sender, EventArgs e)
 {
     MainFunctions.sidePanelAction(panel1, schedulePanel);
 }
Exemplo n.º 4
0
        //! Calculate Schedule

        /*!
         *  Calculates the orbit positions of the selected Satellites for the
         *  given time period and then the contact windows for each selected
         *  ground station. The calculation of the orbits and contact windows
         *  is done in multiple threads to save time. Afterwards the selected
         *  scheduler will compute a solution.
         *  New schedulers can be added inside this function below.
         */
        private void startSchedule(bool useBruteForce = false)
        {
            string logFile = MainFunctions.getLogFileName();

            prepareStart();
            updateLog(logFile, "Starting");
            //Set Start and Stop Time
            One_Sgp4.EpochTime startTime = getStartTime();
            One_Sgp4.EpochTime stopTime  = getStopTime();
            updateLog(logFile, "StartTime: " + startTime.ToString());
            updateLog(logFile, "StartTime: " + stopTime.ToString());

            // create empty Lists and data containers for Data
            satTleData  = new List <One_Sgp4.Tle>();
            stationData = new List <Ground.Station>();
            //check if contacts vector has not been already created or loaded
            //from save file
            bool resetScenario = true;

            if (contactsVector == null || changedParameters == true)
            {
                contactsVector = new Definition.ContactWindowsVector();
                contactsVector.setStartTime(startTime);
                contactsVector.setStopTime(stopTime);
                //get selected Satellites to calculate Orbits
                satTleData  = getSatelliteData(logFile);
                stationData = getStationData(logFile);
                //starting with the orbit calculations
                updateLog(logFile, "Staring Orbit Calculations");
                //Calculate Orbits and Contact Windows
                CalculateContacts(startTime, stopTime, logFile);
            }
            else
            {
                // resuse old ContactWindows
                startTime     = contactsVector.getStartTime();
                stopTime      = contactsVector.getStopTime();
                resetScenario = false;
            }

            AutoSave(logFile);
            updateLog(logFile, "Setting Up Scheduler");
            //Set Scheduling Problem
            //set Objective Function
            setObjectiveFunction();
            string test = objectivefunct.ToString();
            //objectivefunct = new ObjectiveFunction(Global.Structs.ObjectiveEnum.DURATION,
            //    Global.Structs.ObjectiveEnum.FAIRNESSATELITE, Global.Structs.ObjectiveEnum.FAIRNESSTATION,
            //    Global.Structs.ObjectiveEnum.SCHEDULEDCONTACTS);

            SchedulingProblem problem = RunScheduler.setSchedulingProblem(contactsVector, objectivefunct);

            /* Generate the selected Scenarios
             * These are defined in the SchedulingProblem Class
             * Other Scenarios can be selected here if they are added
             */
            if (resetScenario != false)
            {
                getScenario(problem);
            }
            //enable time measurment Class
            TimeMeasurement tm = new Performance.TimeMeasurement();

            startScheduleButton.Enabled = true;
            scheduler = null;
            //create new scheduler object and set settings
            if (radioGenetic.Checked)
            {
                scheduler = RunScheduler.setScheduler(new GeneticScheduler(), this);
            }
            if (radioEFTGreedy.Checked)
            {
                scheduler = RunScheduler.setScheduler(new EftGreedyScheduler(), this);
            }
            if (radioGreedy.Checked)
            {
                scheduler = RunScheduler.setScheduler(new GreedyScheduler(), this);
            }
            if (radioHillClimber.Checked)
            {
                scheduler = RunScheduler.setScheduler(new HillClimberScheduler(), this);
            }
            //-----------------------------------------------------------------
            //---------------------------Add New SCHEDULER HERE-----------------
            //-----------------------------------------------------------------

            /*
             * if (radioNEW.Checked
             * {
             *  scheduler = RunScheduler.setScheduler(new Scheduler.ExampleScheduler(), this);
             * }
             */
            //-----------------------------------------------------------------
            //-----------------------------------------------------------------
            //-----------------------------------------------------------------
            updateLog(logFile, "starting " + scheduler.ToString());
            //start Time Meassurment
            tm.activate();
            if (!useBruteForce)
            {
                RunScheduler.startScheduler(scheduler, problem);
            }
            else
            {
                RunScheduler.startBruteForce(scheduler, problem, this);
            }
            //get Time Measurment
            updateCalculationTime(tm.getValueAndDeactivate());
            //display resulst on main Page
            RunScheduler.displayResults(this, scheduler);
            //finisch clean up and write to logs if necesarry
            finischSchedule(scheduler.ToString(), logFile);
        }
Exemplo n.º 5
0
        //! Update Log file

        /*!
         *  calls the updateLog function in MainFunctison
         */
        private void updateLog(string file, string data)
        {
            MainFunctions.updateLog(file, data, this);
        }
Exemplo n.º 6
0
        //! set the progress bar

        /*!
         *  /param value to update the progress bar
         */
        public void setProgressBar(int val)
        {
            MainFunctions.setProgressBar(progressBar1, val);
        }
Exemplo n.º 7
0
        //! Updates the Progressbar

        /*!
         *  /param int value to set progressbar
         */
        public void updateProgressBar(int val)
        {
            MainFunctions.updateProgressBar(progressBar1, val);
        }
Exemplo n.º 8
0
        //! Resets the progress bar on main Form

        /*!
         *
         */
        public void resetProgressBar()
        {
            MainFunctions.resetProgressBar(progressBar1);
        }
Exemplo n.º 9
0
        /*******************************************************************************************************
        * Public Funkction
        *
        *******************************************************************************************************/

        //! increment Progress Bar on Main form

        /*!
         *
         */
        public void incrementProgressBar()
        {
            MainFunctions.incrementProgressBar(progressBar1);
        }
Exemplo n.º 10
0
        //! Calculate Contact windows

        /*!
         * /param List<TLE> list of Tle data
         * /param List<Statons> list of Stations
         * /param EpochTime starting time
         * /param Epoch Time stoping time
         * /param string Logfile = null
         * /param Main mainform to update = null
         * cacluated the orbits of selected satellites and then the contact windows
         * for each station in the given time frame
         */
        public static ContactWindowsVector calculateContactWindows(List <Tle> tleData,
                                                                   List <Station> stations, EpochTime start, EpochTime stop, string logfile = null,
                                                                   Main mainform = null)
        {
            ContactWindowsVector contacts = new ContactWindowsVector();
            double accuracy = Properties.Settings.Default.orbit_Calculation_Accuracy;

            //Calculate Orbits of the selected Satellites

            Sgp4[] tasks   = new Sgp4[tleData.Count()];
            Task[] threads = new Task[tleData.Count()];
            for (int i = 0; i < tleData.Count(); i++)
            {
                tasks[i] = new One_Sgp4.Sgp4(tleData[i], Properties.Settings.Default.orbit_Wgs);
                tasks[i].setStart(start, stop, accuracy / 60.0);
                threads[i] = new Task(tasks[i].starThread);
            }
            for (int i = 0; i < threads.Count(); i++)
            {
                //start each Thread
                threads[i].Start();
            }
            try
            {
                //wait till all threads are finished
                Task.WaitAll(threads);
            }
            catch (AggregateException ae)
            {
                //Logg any exceptions thrown
                if (logfile != null)
                {
                    MainFunctions.updateLog(logfile, "Orbit Predictions Exception: " + ae.InnerExceptions[0].Message, mainform);
                }
            }

            //Calculate Contact Windows
            if (logfile != null)
            {
                MainFunctions.updateLog(logfile, "Starting Contact Window Calculation:", mainform);
            }
            for (int i = 0; i < tleData.Count(); i++)
            {
                Ground.InView[] inViews   = new Ground.InView[stations.Count()];
                Task[]          inThreads = new Task[stations.Count()];
                for (int k = 0; k < stations.Count(); k++)
                {
                    inViews[k]   = new Ground.InView(stations[k], start, tasks[i].getRestults(), tleData[i].getName(), accuracy);
                    inThreads[k] = new Task(inViews[k].calcContactWindows);
                }
                for (int k = 0; k < stations.Count(); k++)
                {
                    //start every thread
                    inThreads[k].Start();
                }
                try
                {
                    //whait for all threads to finish
                    Task.WaitAll(inThreads);
                }
                catch (AggregateException ae)
                {
                    if (logfile != null)
                    {
                        MainFunctions.updateLog(logfile, "Contact Windows Calculation Exception: " + ae.InnerExceptions[0].Message, mainform);
                    }
                }
                for (int k = 0; k < stations.Count(); k++)
                {
                    contacts.add(inViews[k].getResults());
                }
            }
            contacts.setStartTime(start);
            contacts.setStopTime(stop);
            return(contacts);
        }