Example #1
0
        void checkForAndValidateFilesNeeded()
        {
            //get initialization settings from the Settings.txt file
            initializationSettings = new SettingsManager();

            //initializationSettings.SaveToFolder is the location of the mission plan folder
            //this is typically set to C://_Waldo_FCS
            FlightPlanFolder = initializationSettings.SaveToFolder;

            //set up the logging procedures for the application
            logFile = new LogFile( ref MissionDateString, initializationSettings);

            logFile.WriteLine("Mission DateString established:  " + MissionDateString);

            //this will be a temporary location for saving the log file
            //this will be revised later after we select the mssion
            //FlightLogFolder = initializationSettings.SaveToFolder + "logs//";

            String[] ProjectFolders = null;
            ProjectFileNames = new List<String>();
            ProjectCoverageTypes = new List<COVERAGE_TYPE>();

            //flight folder location "_Waldo_FS" at top of C drive
            if (!Directory.Exists(FlightPlanFolder))
            {
                DialogResult res = MessageBox.Show("There is no mission plan folder (_Waldo_FCS) at the top of the C drive\n ... Use the default example? ",
                    "NO Mission Folder", MessageBoxButtons.YesNo);
                if (res == DialogResult.No)
                {
                    Environment.Exit(0);
                }
                else
                {
                    FlightPlanFolder = Directory.GetCurrentDirectory() + "\\SampleMission\\";
                    if (Directory.Exists(FlightPlanFolder))
                    {
                        MessageBox.Show("There is no sample mission folder ...", "Terminating ...");
                        Environment.Exit(0);
                    }
                }

            }
            ////////////////////////////////////////////////////////////////////////////////////
            //if we get here, we have located the flight plan folder and created a log folder
            ////////////////////////////////////////////////////////////////////////////////////

            //get the list of projects in the  FlightPlanFolder
            ProjectFolders = Directory.GetFiles(FlightPlanFolder, "*.kml");  //all files ending in .kml
            if (ProjectFolders.Count() == 0)
            {
                MessageBox.Show("There are no Projects in the FlightPlanFolder folder", "Terminating ... ");
                Environment.Exit(0);
            }

            logFile.WriteLine("");
            logFile.WriteLine("Opening Project plans");
            foreach (String pth in ProjectFolders)
            {
                //open each of the .kml files to see if they are valid missions plans
                //and detect either Polygon plans or LinearFeature Plans
                String kmlFilename = FlightPlanFolder + Path.GetFileNameWithoutExtension(pth) + ".kml";
                logFile.WriteLine("Project plan: " + kmlFilename);
                COVERAGE_TYPE coverageType = COVERAGE_TYPE.notSet;
                XmlTextReader tr = new XmlTextReader(kmlFilename);  //associate the textReader with input file
                ProjectKmlReadUtility ps = new ProjectKmlReadUtility(tr, ref coverageType);
                //we will display only input kml files that are detected to be polygon of linearFeature types
                if (coverageType != COVERAGE_TYPE.notSet)
                {
                    //test for a matching Background folder
                    String BackgroundMapFolderName = FlightPlanFolder + Path.GetFileNameWithoutExtension(pth) + "_Background\\";
                    if (!Directory.Exists(BackgroundMapFolderName))
                    {
                        MessageBox.Show("Valid plan: " + pth + ", found but no matching Background maps folder\n skip this plan");
                    }
                    else
                    {
                        int validMaps = 0;
                        String[] mapFiles = Directory.GetFiles(BackgroundMapFolderName, "*.png");  //all files ending in .kml
                        foreach (String st in mapFiles)
                        {
                            String ss = Path.GetFileNameWithoutExtension(st);
                            if (ss == "ProjectMap" || ss == "Background_00")
                            {
                                validMaps++;
                            }
                        }
                        if (validMaps < 2)
                        {
                            MessageBox.Show(pth + ": maps not correct in Background Folder\n skip this plan");
                            break;
                        }

                        //have found a valid mission plan with matching Background maps.
                        ProjectFileNames.Add(Path.GetFileNameWithoutExtension(pth));
                        ProjectCoverageTypes.Add(coverageType);
                    }
                }
                else
                {
                    MessageBox.Show(pth + ":  Invalid mission plan\n id you use latest KML_Reader?\n skip this plan");
                }
            }
            //test for no valid mission plans
            if (ProjectFileNames.Count == 0)
            {
                MessageBox.Show("There are no valid Polygon or LinearFeature projects \nDid you use a valid mission planner?");
                Environment.Exit(0);
            }
            logFile.WriteLine("Completed opening project plans");
            logFile.WriteLine("");
        }
Example #2
0
        private void projectButton_Click(object sender, EventArgs e)
        {
            //////////////////////////////////////////////////////////////////////////////////////////
            //this action is done upon clicking a project name from the project buttons
            //we will then prepare the the Mission Selection Form
            // NOTE: projects can be large and may include multiple missions (indivdual flights)
            //////////////////////////////////////////////////////////////////////////////////////////

            Button b = (Button)sender;  //get the details of the button that was clicked from ProjectSelectionForm
            ProjectName = b.Text;  //this is the project name for the selected Project

            // Read in the kml ProjectSummary for the complete Project
            COVERAGE_TYPE coverageTypeFromKML = COVERAGE_TYPE.notSet;

            //the kml file name with complete path is formed as below ...
            String kmlFilename = FlightPlanFolder + ProjectName + ".kml";
            //access the kml via the xml reader
            XmlTextReader tr = new XmlTextReader(kmlFilename);  //associate the textReader with input file

            //initialize the kml input read process .. opens the xml reader and gets the coverage type.
            ProjectKmlReadUtility ps = new ProjectKmlReadUtility(tr, ref coverageTypeFromKML);

            //finish the reading of the input kml and generate the Mission selection form
            Form missionSelectionForm = null;
            if (coverageTypeFromKML == COVERAGE_TYPE.polygon)
            {

                ProjectSummary projSum = ps.readPolygonCoverageData(tr, ProjectName);
                missionSelectionForm = new MissionSelection(projSum, FlightPlanFolder, logFile, navIF_,
                        canonCamera, hardwareAttached, initializationSettings, MissionDateString);
            }
            else if (coverageTypeFromKML == COVERAGE_TYPE.linearFeature)
            {
                linearFeatureCoverageSummary LFSum = ps.readLinearFeatureCoverageData(tr, ProjectName);
                LFSum.ProjectName = ProjectName;
                missionSelectionForm = new MissionSelection(LFSum, FlightPlanFolder, logFile, navIF_,
                    canonCamera, hardwareAttached, initializationSettings, MissionDateString);
            }

            // TODO:   complete the preflown mission analysis
            //PriorFlownMissions pfm = new PriorFlownMissions(FlightPlanFolder, projSum);
            //ProjectUpdateFlightLines updateFlightLines =  pfm.getProjectUpdateFlightLines();

            //project selection is complete -- show the mission selection form
            //this displays a new form where we will select the individual mission from within a project
            //the mbed and camera objects have been opened here but are passed as arguments ...
            missionSelectionForm.Show();
        }