/// <summary>
        /// Generates mission
        /// </summary>
        /// <param name="mdf"></param>
        /// <returns></returns>
        public ArbiterMissionDescription GenerateMission(IMdf mdf, ArbiterRoadNetwork arn)
        {
            Queue<ArbiterCheckpoint> checks = new Queue<ArbiterCheckpoint>();
            List<ArbiterSpeedLimit> speeds = new List<ArbiterSpeedLimit>();

            // checkpoints
            foreach (string s in mdf.CheckpointOrder)
            {
                int num = int.Parse(s);
                checks.Enqueue(new ArbiterCheckpoint(num, arn.Checkpoints[num].AreaSubtypeWaypointId));
            }

            // speeds
            foreach (SpeedLimit sl in mdf.SpeedLimits)
            {
                ArbiterSpeedLimit asl = new ArbiterSpeedLimit();
                asl.MaximumSpeed = sl.MaximumVelocity * 0.44704;
                asl.MinimumSpeed = sl.MinimumVelocity * 0.44704;
                asl.Traveled = false;

                ArbiterSegmentId asi = new ArbiterSegmentId(int.Parse(sl.SegmentID));
                ArbiterZoneId azi = new ArbiterZoneId(int.Parse(sl.SegmentID));

                if (arn.ArbiterZones.ContainsKey(azi))
                    asl.Area = azi;
                else if (arn.ArbiterSegments.ContainsKey(asi))
                    asl.Area = asi;
                else
                    throw new Exception("Unknown area id: " + sl.SegmentID);

                speeds.Add(asl);
            }

            // return
            return new ArbiterMissionDescription(checks, speeds);
        }
        // Creates Mdf from an input FileStream
        public IMdf createMdf(FileStream fileStream)
        {
            // File in Read Only mode, convert to stream
            StreamReader r = new StreamReader(fileStream, Encoding.UTF8);

            // Create new queue for input buffer
            Queue q = new Queue();
            string word = "";

            // Create the Mdf
            IMdf mdf = new IMdf();
            mdf.SpeedLimits = new List<SpeedLimit>();
            mdf.CheckpointOrder = new List<string>();

            // Loop until reach end of file marker
            while ((word.Length < 8) || (word.Substring(0, 8) != "end_file"))
            {
                // get next word
                word = parseWord(r, q);

                if (word == "MDF_name")
                {
                    word = parseWord(r, q);
                    mdf.Name = word;
                }
                else if (word == "RNDF")
                {
                    word = parseWord(r, q);
                    mdf.RndfName = word;
                }
                else if (word == "format_version")
                {
                    word = parseWord(r, q);
                    mdf.Version = word;
                }
                else if (word == "creation_date")
                {
                    word = parseWord(r, q);
                    mdf.CreationDate = word;
                }
                else if (word == "checkpoints")
                {
                    // get number of checkpoints
                    word = parseWord(r, q);
                    word = parseWord(r, q);
                    mdf.NumberCheckpoints = word;

                    // create checkpoint list
                    word = parseWord(r, q);

                    // loop until end of checkpoints
                    while (word != "end_checkpoints")
                    {
                        // add checkpoint
                        mdf.CheckpointOrder.Add(word);

                        // get next word
                        word = parseWord(r, q);
                    }
                }
                else if (word == "speed_limits")
                {
                    // set number of speed limits
                    word = parseWord(r, q);
                    word = parseWord(r, q);
                    mdf.NumberSpeedLimits = word;

                    // get next word
                    word = parseWord(r, q);

                    // loop until end of speedlimits
                    while (word != "end_speed_limits")
                    {
                        // create new speed limit
                        SpeedLimit sl = new SpeedLimit();

                        // id
                        sl.SegmentID = word;

                        // min speed
                        word = parseWord(r, q);
                        sl.MinimumVelocity = Double.Parse(word);

                        // max speed
                        word = parseWord(r, q);
                        sl.MaximumVelocity = Double.Parse(word);

                        // add speed limit to list of speed limits
                        mdf.SpeedLimits.Add(sl);

                        // get next word
                        word = parseWord(r, q);
                    }
                }
                else if (word == "end_file")
                {
                    Console.WriteLine("Mdf Parse :: Successful");
                }
                else
                {
                    Console.WriteLine("Unknown identifier: " + word);
                }
            }
            return mdf;
        }