/// <summary>
 /// set the display's mdf
 /// </summary>
 /// <param name="mdf"></param>
 public void SetMdf(Mdf mdf)
 {
     if (mdf != null)
         this.roadDisplay1.mdf = mdf;
     else
         RemoraOutput.WriteLine("Received Null Rndf");
 }
        public void MessageArrived(string channelName, object message)
        {
            if (channelName == "RndfNetworkChannel")
            {
                this.rndfNetwork = (Common.RndfNetwork.RndfNetwork)message;
                Console.WriteLine("   > Rndf Received");
            }
            else if (channelName == "MdfChannel")
            {
                this.mdf = (Common.RndfNetwork.Mdf)message;
                Console.WriteLine("   > Mdf Received");
            }
            else if (channelName == "PositionChannel")
            {
                this.vehicleState = (VehicleState) message;
                Console.WriteLine("   > Position Received: " + this.vehicleState.ToString());
            }
            else if (channelName == "TestStringChannel")
            {
                Console.WriteLine("Received String On TestStringChannel: " + ((string)message));
            }
            else
            {
                throw new ArgumentException("Unknown Channel", channelName);

            }
        }
        /// <summary>
        /// De-Serialize this byte-string and cast as a Mdf object
        /// </summary>
        /// <param name="b"></param>
        /// <returns></returns>
        public Mdf DeSerialize(byte[] b)
        {
            Mdf s = new Mdf();

            try
            {
                MemoryStream    str = new MemoryStream(b);
                BinaryFormatter bf  = new BinaryFormatter();
                s = (Mdf)bf.Deserialize(str);
                str.Close();
            }
            catch (SerializationException e)
            {
                Console.WriteLine("");
                Console.WriteLine("LOAD ERROR");
                Console.WriteLine("Serialization Error: " + e.ToString());
            }

            return(s);
        }
        /// <summary>
        /// De-Serialize this byte-string and cast as a Mdf object
        /// </summary>
        /// <param name="b"></param>
        /// <returns></returns>
        public Mdf DeSerialize(byte[] b)
        {
            Mdf s = new Mdf();

            try
            {
                MemoryStream str = new MemoryStream(b);
                BinaryFormatter bf = new BinaryFormatter();
                s = (Mdf)bf.Deserialize(str);
                str.Close();
            }
            catch (SerializationException e)
            {
                Console.WriteLine("");
                Console.WriteLine("LOAD ERROR");
                Console.WriteLine("Serialization Error: " + e.ToString());
            }

            return s;
        }
        /// <summary>
        /// Deserialize the roadNetwork from a file
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public Mdf Load(string filename)
        {
            Mdf s = new Mdf();

            try
            {
                FileStream      str = File.OpenRead(filename);
                BinaryFormatter bf  = new BinaryFormatter();
                s = (Mdf)bf.Deserialize(str);
                str.Close();
            }
            catch (SerializationException e)
            {
                Console.WriteLine("");
                Console.WriteLine("LOAD ERROR");
                Console.WriteLine("Serialization Error: " + e.ToString());
            }

            mdf = s;
            return(s);
        }
        /// <summary>
        /// Deserialize the roadNetwork from a file
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public Mdf Load(string filename)
        {
            Mdf s = new Mdf();

            try
            {
                FileStream str = File.OpenRead(filename);
                BinaryFormatter bf = new BinaryFormatter();
                s = (Mdf)bf.Deserialize(str);
                str.Close();
            }
            catch (SerializationException e)
            {
                Console.WriteLine("");
                Console.WriteLine("LOAD ERROR");
                Console.WriteLine("Serialization Error: " + e.ToString());
            }

            mdf = s;
            return s;
        }
 /// <summary>
 /// Singleton pattern. Static read-only instance property.
 /// </summary>
 public static TestServerFacade Instance(RndfNetwork rndfNetwork, Mdf mdf, VehicleState vehicleState)
 {
     if (instance == null)
         instance = new TestDataServerFacadeImpl(rndfNetwork, mdf, vehicleState);
     return instance;
 }
 /// <summary>
 /// Private constructor (singleton pattern). (Can add fields as needed to constructor)
 /// </summary>
 /// <param name="rndfNetwork">the rndf network</param>
 private TestDataServerFacadeImpl(RndfNetwork rndfNetwork, Mdf mdf, VehicleState vehicleState)
 {
     this.rndfNetwork = rndfNetwork;
     this.mdf = mdf;
     this.vehicleState = vehicleState;
 }
 /// <summary>
 /// Attempts to set an mdf
 /// </summary>
 /// <param name="mdf"></param>
 /// <returns>true if mdf set successfully</returns>
 /// <remarks>needs to be in pause</remarks>
 public abstract bool SetMdf(Mdf mdf);
 public abstract void Restart(RndfNetwork rndf, Mdf mdf, ArbiterMode mode);
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="mdf">Network object to handle</param>
 public MdfHandler(Mdf mdf)
 {
     this.mdf = mdf;
 }
        public bool UpdateMdf(Mdf mdf)
        {
            if (arbiterRemote != null)
            {
                try
                {
                    return this.arbiterRemote.SetMdf(mdf);
                }
                catch (Exception e)
                {
                    RemoraOutput.WriteLine(e.ToString());
                }
            }
            else
            {
                RemoraOutput.WriteLine("Arbter Remote does not exist");
            }

            return false;
        }
 public void RestartArbiter(RndfNetwork rndfNetwork, Mdf mdf)
 {
     if (arbiterRemote != null)
     {
         try
         {
             this.arbiterRemote.Restart(rndfNetwork, mdf, UrbanChallenge.Arbiter.ArbiterCommon.ArbiterMode.Debug);
         }
         catch (Exception e)
         {
             RemoraOutput.WriteLine(e.ToString());
         }
     }
     else
     {
         RemoraOutput.WriteLine("Arbter Remote does not exist");
     }
 }
 public void SetMdf(Mdf mdf)
 {
     this.mdf = mdf;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="mdf">Network object to handle</param>
 public MdfHandler(Mdf mdf)
 {
     this.mdf = mdf;
 }