Пример #1
0
 private static void GenerateOutput(EFD_Msg Message_Data)
 {
     Common.Generate_Output(Message_Data);
     EFD.Generate_Output(Message_Data);
     Main_Status.Generate_Output(Message_Data);
     EFD_Status.Generate_Output(Message_Data);
 }
Пример #2
0
        ///var/cbs/prediction/flights/ACID_IFPLID_DATETIME/status/EFD_{Status}_{DATETIME}.kml
        //<?xml version="1.0" encoding="UTF-8"?>
        //<kml xmlns="http://www.opengis.net/kml/2.2">
        //<Document>
        //<Placemark>
        //    <name>EFD Status {Inflight}</name>
        //    <TimeStamp> <!-- required TimeStamp or TimeSpan block -->
        //        <when>2013-02-20T00:05:20Z</when>
        //    </TimeStamp>
        //    <ExtendedData>
        //      <Data name="markerType">
        //          <value> timelineItem</value>
        //      </Data>
        //     <Data name="dataSourceName">
        //          <value>EFD</value>
        //      </Data>
        //    </ExtendedData>
        //</Placemark>
        //</Document>
        //</kml>
        public static void Generate_Output(EFD_Msg Message_Data)
        {
            string TIME_AS_YYYYMMDDHHMMSS = CBS_Main.GetDate_Time_AS_YYYYMMDDHHMMSS(DateTime.UtcNow);
            string Time_Stamp             = KML_Common.Get_KML_Time_Stamp();
            string KML_File_Content       =
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + Environment.NewLine +
                "<kml xmlns=\"http://www.opengis.net/kml/2.2\">" + Environment.NewLine +
                "<Document>" + Environment.NewLine +
                "<Placemark>" + Environment.NewLine +
                "<name>EFD Status " + Message_Data.FL_STATUS + "</name>" + Environment.NewLine +
                "<TimeStamp> <!-- required TimeStamp or TimeSpan block -->" + Environment.NewLine +
                "<when>" + Time_Stamp + "</when>" + Environment.NewLine +
                "</TimeStamp>" + Environment.NewLine +
                "<ExtendedData>" + Environment.NewLine +
                "<Data name=\"markerType\">" + Environment.NewLine +
                "<value> timelineItem</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +
                "<Data name=\"dataSourceName\">" + Environment.NewLine +
                "<value>EFD</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +
                "</ExtendedData>" + Environment.NewLine +
                "</Placemark>" + Environment.NewLine +
                "</Document>" + Environment.NewLine +
                "</kml>";

            // Get the final data path
            string File_Path = Get_Dir_By_ACID_AND_IFPLID(Message_Data.ACID, Message_Data.IFPLID);

            File_Path = Path.Combine(File_Path, ("EFD_" + Message_Data.FL_STATUS + '_' + TIME_AS_YYYYMMDDHHMMSS + ".kml"));

            // Save data in the tmp directory first
            string Tmp = Path.Combine(CBS_Main.Get_Temp_Dir(), ("EFD_" + Message_Data.FL_STATUS + '_' + TIME_AS_YYYYMMDDHHMMSS + ".kml"));

            // create a writer and open the file
            TextWriter tw = new StreamWriter(Tmp);

            try
            {
                // write a line of text to the file
                tw.Write(KML_File_Content);
                CBS_Main.WriteToLogFile("Generating: " + File_Path);
            }
            catch
            {
                CBS_Main.WriteToLogFile("Exception in EFD_Status.cs, Saving " + File_Path);
            }

            // close the stream
            tw.Close();

            // Now move it to the final destination
            File.Move(Tmp, File_Path);
        }
Пример #3
0
        //<FPL_data>
        //        <CLS>BAW905U</CLS>
        //        <ADEP>EDDF</ADEP>
        //        <ADES>EGLL</ADES>
        //        <EOBT>HHMM</EOBT>
        //        <EOBD>YYMMDD</EOBD>
        //        <IFPLID>AA92346961</IFPLID>
        //</FPL_data>

        public static void Generate_Output(EFD_Msg Message_Data)
        {
            XmlDocument XDoc = new XmlDocument();

            // Create root node.
            XmlElement XElemRoot = XDoc.CreateElement("FPL_Data");

            //Add the node to the document.
            XDoc.AppendChild(XElemRoot);

            //////////////////////////////////////////////////
            // Create Nodes
            //
            XmlElement XTemp = XDoc.CreateElement("CLS");

            XTemp.InnerText = Message_Data.ACID;
            XElemRoot.AppendChild(XTemp);

            XTemp           = XDoc.CreateElement("ADEP");
            XTemp.InnerText = Message_Data.ADEP;
            XElemRoot.AppendChild(XTemp);

            XTemp           = XDoc.CreateElement("ADES");
            XTemp.InnerText = Message_Data.ADES;
            XElemRoot.AppendChild(XTemp);

            XTemp           = XDoc.CreateElement("EOBT");
            XTemp.InnerText = Message_Data.EOBT;
            XElemRoot.AppendChild(XTemp);

            XTemp           = XDoc.CreateElement("EOBD");
            XTemp.InnerText = Message_Data.EOBD;
            XElemRoot.AppendChild(XTemp);

            XTemp           = XDoc.CreateElement("IFPLID");
            XTemp.InnerText = Message_Data.IFPLID;
            XElemRoot.AppendChild(XTemp);

            string TIME_AS_YYYYMMDDHHMMSS = CBS_Main.GetDate_Time_AS_YYYYMMDDHHMMSS(DateTime.UtcNow);

            string File_Path = Get_Dir_By_ACID_AND_IFPLID(Message_Data.ACID, Message_Data.IFPLID);

            File_Path = Path.Combine(File_Path, ("Flight_Data_EFD_" + TIME_AS_YYYYMMDDHHMMSS + ".xml"));

            string Tmp = Path.Combine(CBS_Main.Get_Temp_Dir(), ("Flight_Data_EFD_" + TIME_AS_YYYYMMDDHHMMSS + ".xml"));

            XDoc.Save(Tmp);
            File.Move(Tmp, File_Path);
        }
Пример #4
0
        public static void Generate(EFD_Msg Message_Data)
        {
            // First check if directory already exists
            string IFPLID_DIR_NAME = Message_Data.ACID + "_" + Message_Data.IFPLID + "_*";

            string[] DestDirectory = Directory.GetDirectories(CBS_Main.Get_Destination_Dir(), IFPLID_DIR_NAME);

            // This is first time the data for this particular flight has arrived, so lets just
            // create the directory structure and create set of files.
            if (DestDirectory.Length == 0)
            {
                // This must be a new flight, so lets create applicable directory
                IFPLID_DIR_NAME = Message_Data.ACID + "_" + Message_Data.IFPLID + "_";
                IFPLID_DIR_NAME = IFPLID_DIR_NAME + CBS_Main.GetDate_Time_AS_YYYYMMDDHHMMSS(DateTime.UtcNow);
                Directory.CreateDirectory(CBS_Main.Get_Destination_Dir() + IFPLID_DIR_NAME);
                // Now when it is created, lets get it again so it can be used
                DestDirectory = Directory.GetDirectories(CBS_Main.Get_Destination_Dir(), IFPLID_DIR_NAME);

                // Now create subdirectories within new directory
                Directory.CreateDirectory(Path.Combine(DestDirectory[0], "common"));
                Directory.CreateDirectory(Path.Combine(DestDirectory[0], "EFD"));
                Directory.CreateDirectory(Path.Combine(DestDirectory[0], "status"));
                CBS_Main.WriteToLogFile("Generate Output: Creating dir structure for: " + IFPLID_DIR_NAME);

                GenerateOutput(Message_Data);
                Message_Data.SaveDataSet();
            }
            else
            {
                // Check if this is a new data set
                // If true generate a new set of files
                // and then save the new data set.
                if (Message_Data.Is_New_Data_Set() == true)
                {
                    GenerateOutput(Message_Data);
                    Message_Data.SaveDataSet();
                }
            }
        }
Пример #5
0
        // ARCID
        // IFPLID
        // FLTSTATE
        // ADEP
        // ADES
        // ARCTYP
        // ETI
        // XTI
        // LASTUPD
        // TSTARTTIME
        // TENDTIME
        // TPOINTS
        // POINTS
        public static void Write_One_Message(EFD_Msg Message)
        {
            // Lets build SEQMUAC string
            // FORMAT:
            // //RH1,1515,1522//RH2,1515,1522
            string SEQMUAC = "";

            foreach (EFD_Msg.Sector Msg in Message.Sector_List)
            {
                SEQMUAC = SEQMUAC + "//" + Msg.ID + ',' + GetTimeAS_HHMM(Msg.SECTOR_ENTRY_TIME) + ',' + GetTimeAS_HHMM(Msg.SECTOR_EXIT_TIME) + ',' + Msg.EFL + ',' + Msg.XFL;
            }

            // Lets build TPOINTS string
            //tpoints (LON,LAT,FL,broj sekundi u odnosu na tstarttime) u formatu:
            //51.28083,6.75722,0,0;51.59056,6.69417,11900,431

            string   TPOINTS = "";
            int      Index   = 0;
            TimeSpan TS      = new TimeSpan(0);

            foreach (EFD_Msg.Waypoint WPT in Message.TrajectoryPoints)
            {
                if (Index > 0)
                {
                    TS = CBS_Main.GetDate_Time_From_YYMMDDHHMMSS(WPT.ETO) - CBS_Main.GetDate_Time_From_YYMMDDHHMMSS(Message.TrajectoryPoints[0].ETO);
                }

                TPOINTS = TPOINTS + string.Format("{0:0.0000}", WPT.Position.GetLatLongDecimal().LatitudeDecimal) + ',' + string.Format("{0:0.0000}", WPT.Position.GetLatLongDecimal().LongitudeDecimal)
                          + ',' + WPT.Flight_Level + ',' + TS.TotalSeconds.ToString() + ";";

                Index++;
            }

            // LASTUPD
            DateTime T_Now   = DateTime.UtcNow;
            string   LASTUPD = T_Now.Year.ToString("0000") + T_Now.Month.ToString("00") + T_Now.Day.ToString("00") +
                               T_Now.Hour.ToString("00") + T_Now.Minute.ToString("00") + T_Now.Second.ToString("00");

            string TSTARTTIME = ConvertToUNIXTimestamp(CBS_Main.GetDate_Time_From_YYMMDDHHMMSS(Message.TrajectoryPoints[0].ETO)).ToString();
            string TENDTIME   = ConvertToUNIXTimestamp(CBS_Main.GetDate_Time_From_YYMMDDHHMMSS(Message.TrajectoryPoints[Message.TrajectoryPoints.Count - 1].ETO)).ToString();

            string query = "INSERT INTO " + MySQLConnetionString.table_name +
                           " (IFPLID, ARCID, FLTSTATE, ADEP, ADES, ARCTYP, ETI, XTI, LASTUPD, TSTARTTIME, TENDTIME, TPOINTS, ENTRIES) " +
                           " VALUES (" + Get_With_Quitation(Message.IFPLID) + "," +
                           Get_With_Quitation(Message.ACID) + "," +
                           Get_With_Quitation(Message.FLTSTATE) + "," +
                           Get_With_Quitation(Message.ADEP) + "," +
                           Get_With_Quitation(Message.ADES) + "," +
                           Get_With_Quitation(Message.ARCTYP) + "," +
                           Get_With_Quitation(CBS_Main.GetDate_Time_AS_YYYYMMDDHHMMSS(Message.AOI_ENTRY_TIME)) + "," +
                           Get_With_Quitation(CBS_Main.GetDate_Time_AS_YYYYMMDDHHMMSS(Message.AOI_EXIT_TIME)) + "," +
                           Get_With_Quitation(LASTUPD) + "," +
                           Get_With_Quitation(TSTARTTIME) + "," +
                           Get_With_Quitation(TENDTIME) + "," +
                           Get_With_Quitation(TPOINTS) + "," +
                           Get_With_Quitation(SEQMUAC) + ")";



            // First delete the data for the flight (if already exists)
            string delete_query = "DELETE FROM " + MySQLConnetionString.table_name + " WHERE IFPLID= " + Get_With_Quitation(Message.IFPLID) + "AND ARCID= " + Get_With_Quitation(Message.ACID);
            //create command and assign the query and connection from the constructor
            MySqlCommand cmd = new MySqlCommand(delete_query, MySQLconn);

            try
            {
                //Execute command
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            //create command and assign the query and connection from the constructor
            cmd = new MySqlCommand(query, MySQLconn);

            try
            {
                //Execute command
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #6
0
        // /var/cbs/prediction/status/MAIN_{Status}_{DATETIME}.kml

        // If the Status=closed, no new files are written for this flight.
        // ( This part is not fully designed yet.  The idea is to inform other modules that
        // a flight has left AOI and the MAIN is going to close the directory.
        // It is not so important for EFD, since EFD has the IFPLID as the key.
        // ADS-B module, Message modul can see this flight hours after it leaves AOI.)
        public static void Generate_Output(EFD_Msg Message_Data)
        {
        }
Пример #7
0
        public static void Handle_New_File()
        {
            string[] filePaths = Directory.GetFiles(CBS_Main.Get_Source_Data_Path(), "*.log*",
                                                    SearchOption.AllDirectories);

            foreach (string Path in filePaths)
            {
                try
                {
                    using (MyStreamReader = System.IO.File.OpenText(Path))
                    {
                        if (MyStreamReader != null)
                        {
                            //// Pass in stream reader and initialise new
                            //// EFD message.
                            EFD_Msg EDF_MESSAGE = new EFD_Msg(MyStreamReader);

                            MyStreamReader.Close();
                            MyStreamReader.Dispose();

                            try
                            {
                                //// Generate output
                                Generate_Output.Generate(EDF_MESSAGE);
                            }
                            catch (Exception e1)
                            {
                                CBS_Main.WriteToLogFile("Error in Generate_Output.Generate " + e1.Message);
                            }

                            try
                            {
                                // Write data to the MySqlDatabase
                                MySqlWriter.Write_One_Message(EDF_MESSAGE);
                            }

                            catch (Exception e2)
                            {
                                CBS_Main.WriteToLogFile("Error in MySqlWriter.Write_One_Message " + e2.Message);
                            }

                            // Let the status handler know that the
                            // message has arrived...
                            try
                            {
                                CBS_Main.Notify_EFD_Message_Recived();
                            }
                            catch (Exception e3)
                            {
                                CBS_Main.WriteToLogFile("Error in CBS_Main.Notify_EFD_Message_Recived " + e3.Message);
                            }

                            //// Once done with the file,
                            //// lets delete it as we do not
                            //// needed it any more
                            try
                            {
                                System.IO.File.Delete(Path);
                            }
                            catch
                            {
                                CBS_Main.WriteToLogFile("Error in EFD_File_Handler, can't delete file " + Path);
                            }

                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    CBS_Main.WriteToLogFile("Exception EFD_Handler: " + ex.Message);
                }
            }
        }
Пример #8
0
        // /var/cbs/prediction/flights/ACID_IFPLID_DATETIME/EFD/EFD_AOI_Entry_DATETIME.kml

        //<?xml version="1.0" encoding="UTF-8"?>
        //<kml xmlns="http://www.opengis.net/kml/2.2">
        //<Document>
        //    <Placemark>
        //        <name>EFD AOI Entry</name>
        //        <TimeStamp>
        //            <when>2013-02-20T00:05:20Z</when>
        //        </TimeStamp>
        //        <ExtendedData>
        //            <Data name="dataSourceName">
        //                <value>EFD</value>
        //            </Data>
        //            <Data name="markerType">
        //                <value>customMarker</value>
        //            </Data>
        //            <Data name="customIcon">
        //                <value>imageGoogleYellow.png</value>
        //            </Data>
        //            <Data name="popupLine1">
        //                <value>Time:{TIME}</value>
        //            </Data>
        //            <Data name="popupLine2">
        //                <value>Point:{LON,LAT}</value>
        //            </Data>
        //            <Data name="popupLine3">
        //                <value>Altitude:{Altitude}</value>
        //            </Data>
        //            <Data name="fileLocation">
        //                <value>flights/ACID_IFPLID_DATETIME/EFD/EFD_AOI_Entry_DATETIME.kml</value>
        //            </Data>
        //        </ExtendedData>
        //        <Point>
        //            <coordinates>12.09607,51.41915,1201,20130305003900</coordinates>
        //        </Point>
        //    </Placemark>
        //</Document>
        //</kml>
        public static void Generate_Output(EFD_Msg Message_Data)
        {
            string TIME_AS_YYYYMMDDHHMMSS = CBS_Main.GetDate_Time_AS_YYYYMMDDHHMMSS(DateTime.UtcNow);
            string Time_Stamp             = KML_Common.Get_KML_Time_Stamp();
            string Entry_LON_DEGMINSEC;
            string Entry_LAT_DEGMINSEC;

            Message_Data.ENTRY_AOI_POINT.GetDegMinSecStringFormat(out Entry_LAT_DEGMINSEC, out Entry_LON_DEGMINSEC);

            string KML_File_Content =
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + Environment.NewLine +
                "<kml xmlns=\"http://www.opengis.net/kml/2.2\">" + Environment.NewLine +
                "<Document>" + Environment.NewLine +
                "<Placemark>" + Environment.NewLine +
                "<name>EFD AOI Entry</name>" + Environment.NewLine +

                "<TimeStamp>" + Environment.NewLine +
                "<when>" + Time_Stamp + "</when>" + Environment.NewLine +
                "</TimeStamp>" + Environment.NewLine +

                "<ExtendedData>" + Environment.NewLine +

                "<Data name=\"dataSourceName\">" + Environment.NewLine +
                "<value>EFD</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +
                "<Data name=\"markerType\">" + Environment.NewLine +
                "<value>customMarker</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +
                "<Data name=\"customIcon\">" + Environment.NewLine +
                "<value>imageGoogleYellow.png</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +

                "<Data name=\"popupLine1\">" + Environment.NewLine +
                "<value>Time:" + Message_Data.AOI_ENTRY_TIME.ToShortDateString() + "/" + Message_Data.AOI_ENTRY_TIME.ToShortTimeString() + "</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +

                "<Data name=\"popupLine2\">" + Environment.NewLine +
                "<value>Point:" + Entry_LON_DEGMINSEC + "'" + Entry_LAT_DEGMINSEC + "</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +

                "<Data name=\"popupLine3\">" + Environment.NewLine +
                "<value>Altitude:" + Message_Data.AOI_ENTRY_FL + "</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +

                "<Data name=\"fileLocation\">" + Environment.NewLine +
                "<value>flights/ACID_IFPLID_DATETIME/EFD/EFD_AOI_Entry_" + TIME_AS_YYYYMMDDHHMMSS + ".kml</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +

                "</ExtendedData>" + Environment.NewLine +
                "<Point>" + Environment.NewLine +
                "<coordinates>" + string.Format("{0:0.0000}", Message_Data.ENTRY_AOI_POINT.GetLatLongDecimal().LongitudeDecimal) + "," + string.Format("{0:0.0000}", Message_Data.ENTRY_AOI_POINT.GetLatLongDecimal().LatitudeDecimal) + "," + Message_Data.AOI_ENTRY_FL + "," + Message_Data.AOI_ENTRY_TIME_YYMMDDHHMMSS + "</coordinates>" + Environment.NewLine +
                "</Point>" + Environment.NewLine +

                "</Placemark>" + Environment.NewLine +
                "</Document>" + Environment.NewLine +
                "</kml>";



            // Get the final data path
            string File_Path = Get_Dir_By_ACID_AND_IFPLID(Message_Data.ACID, Message_Data.IFPLID);

            File_Path = Path.Combine(File_Path, ("EFD_AOI_Entry_" + TIME_AS_YYYYMMDDHHMMSS + ".kml"));

            // Save data in the tmp directory first
            string Tmp = Path.Combine(CBS_Main.Get_Temp_Dir(), ("EFD_AOI_Entry_" + TIME_AS_YYYYMMDDHHMMSS + ".kml"));

            // create a writer and open the file
            TextWriter tw = new StreamWriter(Tmp);

            try
            {
                // write a line of text to the file
                tw.Write(KML_File_Content);
                CBS_Main.WriteToLogFile("Generating: " + File_Path);
            }
            catch
            {
                CBS_Main.WriteToLogFile("Exception in EFD_AOI_Entry.cs, Saving " + File_Path);
            }

            // close the stream
            tw.Close();

            // Now move it to the final destination
            File.Move(Tmp, File_Path);
        }
Пример #9
0
        // EFD_Trajetory_DATETIME.kml

        //<?xml version="1.0" encoding="UTF-8"?>
        //<kml xmlns="http://www.opengis.net/kml/2.2">
        //<Document>
        //<Placemark>
        //    <name>DLH2394 Trajectory</name>
        //<TimeStamp>
        //    <when>2013-02-20T00:05:20Z</when>
        //</TimeStamp>
        //<ExtendedData>
        //    <Data name="dataSourceName">
        //         <value>EFD</value>
        //      </Data>
        //    <Data name="markerType">
        //        <value>polyline</value>
        //    </Data>
        //    <Data name="lineColor">
        //        <value>ffff00</value>
        //    </Data>
        //    <Data name="popupLine1">
        //        <value>Callsign,ADEP,ADES</value>
        //      </Data>
        //      <Data name="popupLine2">
        //            <value>EOBD, EOBT</value>
        //      </Data>
        //      <Data name="popupLine3">
        //            <value>IFPLID</value>
        //      </Data>
        //      <Data name="fileLocation">
        //            <value>flights/ACID_IFPLID_DATETIME/EFD/EFD_Trajectory_DATETIME.kml</value>
        //      </Data>
        //</ExtendedData>
        //     <LineString>
        //            <coordinates>
        //            12.17152,51.41049,646,20130305003800
        //            12.09607,51.41915,1201,20130305003900
        //            12.05830,51.48931,1762,20130305004000
        //        </coordinates>
        //      </LineString>
        //  </Placemark>
        //</Document>
        //</kml>
        public static void Generate_Output(EFD_Msg Message_Data)
        {
            string TIME_AS_YYYYMMDDHHMMSS = CBS_Main.GetDate_Time_AS_YYYYMMDDHHMMSS(DateTime.UtcNow);
            string Time_Stamp             = KML_Common.Get_KML_Time_Stamp();

            // Here build the trajectory string
            // "12.17152,51.41049,646,20130305003800" + Environment.NewLine +
            // "12.09607,51.41915,1201,20130305003900" + Environment.NewLine +
            string Trajectory_String = "";

            foreach (EFD_Msg.Waypoint WPT in Message_Data.TrajectoryPoints)
            {
                Trajectory_String = Trajectory_String + string.Format("{0:0.0000}", WPT.Position.GetLatLongDecimal().LongitudeDecimal) + "," +
                                    string.Format("{0:0.0000}", WPT.Position.GetLatLongDecimal().LatitudeDecimal) + "," +
                                    WPT.Flight_Level + "," + WPT.ETO + Environment.NewLine;
            }

            string KML_File_Content =
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + Environment.NewLine +
                "<kml xmlns=\"http://www.opengis.net/kml/2.2\">" + Environment.NewLine +
                "<Document>" + Environment.NewLine +
                "<Placemark>" + Environment.NewLine +
                "<name>" + Message_Data.ACID + " Trajectory" + "</name>" + Environment.NewLine +
                "<TimeStamp>" + Environment.NewLine +
                "<when>" + Time_Stamp + "</when>" + Environment.NewLine +
                "</TimeStamp>" + Environment.NewLine +
                "<ExtendedData>" + Environment.NewLine +
                "<Data name=\"dataSourceName\">" + Environment.NewLine +
                "<value>EFD</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +
                "<Data name=\"markerType\">" + Environment.NewLine +
                " <value>polyline</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +
                "<Data name=\"lineColor\">" + Environment.NewLine +
                "<value>ffff00</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +
                "<Data name=\"popupLine1\">" + Environment.NewLine +
                "<value>" + Message_Data.ACID + ',' + Message_Data.ADEP + ',' + Message_Data.ADES + "</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +
                "<Data name=\"popupLine2\">" + Environment.NewLine +
                "<value>" + Message_Data.EOBT + ',' + Message_Data.EOBD + "</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +
                "<Data name=\"popupLine3\">" + Environment.NewLine +
                "<value>" + Message_Data.IFPLID + "</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +
                "<Data name=\"fileLocation\">" + Environment.NewLine +
                "<value>flights/ACID_IFPLID_DATETIME/EFD/EFD_Trajectory_" + TIME_AS_YYYYMMDDHHMMSS + ".kml</value>" + Environment.NewLine +
                "</Data>" + Environment.NewLine +
                "</ExtendedData>" + Environment.NewLine +
                "<LineString>" + Environment.NewLine +
                "<coordinates>" + Environment.NewLine +
                Trajectory_String +
                "</coordinates>" + Environment.NewLine +
                "</LineString>" + Environment.NewLine +
                "</Placemark>" + Environment.NewLine +
                "</Document>" + Environment.NewLine +
                "</kml>";

            // Get the final data path
            string File_Path = Get_Dir_By_ACID_AND_IFPLID(Message_Data.ACID, Message_Data.IFPLID);

            File_Path = Path.Combine(File_Path, ("EFD_Trajectory_" + TIME_AS_YYYYMMDDHHMMSS + ".kml"));

            // Save data in the tmp directory first
            string Tmp = Path.Combine(CBS_Main.Get_Temp_Dir(), ("EFD_Trajectory_" + TIME_AS_YYYYMMDDHHMMSS + ".kml"));

            // create a writer and open the file
            TextWriter tw = new StreamWriter(Tmp);

            try
            {
                // write a line of text to the file
                tw.Write(KML_File_Content);
                CBS_Main.WriteToLogFile("Generating: " + File_Path);
            }
            catch
            {
                CBS_Main.WriteToLogFile("Exception in EFD_Trajectory.cs, Saving " + File_Path);
            }

            // close the stream
            tw.Close();

            // Now move it to the final destination
            File.Move(Tmp, File_Path);
        }