Exemple #1
0
        //! Calculate Contact windows

        /*!
         * /param EpochTime starting time
         * /param Epoch Time stoping time
         * /param string Logfile
         * cacluated the orbits of selected satellites and then the contact windows
         * for each station in the given time frame
         */
        private void CalculateContacts(One_Sgp4.EpochTime start, One_Sgp4.EpochTime stop, string logfile)
        {
            TimeMeasurement timeMessurmentOribt = new Performance.TimeMeasurement();

            timeMessurmentOribt.activate();

            contactsVector = MainFunctions2.calculateContactWindows(satTleData, stationData, start, stop, logfile, this);

            string perfResCalc = timeMessurmentOribt.getValueAndDeactivate();

            updateLog(logfile, "Contact Windows Calculated in: " + perfResCalc + "sec.");
        }
Exemple #2
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);
        }