Exemplo n.º 1
0
//        /// <summary>
//        /// The maximum size out packet should be. It isn't related to the operating system's MTU
//        /// Increasing it will allow larger packets to be sent out but won't guarantee performance boost.
//        /// Having a missmatch between 2 ends may cause issues.
//        /// </summary>
//        public const int MTU = 1440;

//        #region "Static Variables"
//        /// <summary>
//        /// We store module information here. Module packets are sent and received via IDs.
//        /// This stores that ID and a pointer to a class that handles that data.
//        /// </summary>
//        protected static Dictionary<ushort, IComModule> _moduleActions = new Dictionary<ushort, IComModule>();
//        #endregion

//        #region "Static Methods"
//        /// <summary>
//        /// Add a Packet ID and handler to the connection.
//        /// </summary>
//        /// <param name="ID">A unique ID that identifies the Module.</param>
//        /// <param name="module">A class that contains methods to call when data is received.</param>
        public static void AddModuleHandle(ushort ID, IComModule module)
        {
//            //Because the basis of the Module system is on unique IDs, we
//            //need to check that it IS unique. Also because its a logic error
//            //we throw a generic Exception.
//            if (module == null)
//                throw new ArgumentNullException("module");
//            if (_moduleActions.ContainsKey(ID))
//                throw new ArgumentNullException("ID already exists!");
//            _moduleActions.Add(ID, module);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Explores Martian terrain, might be salvaged by a potato farmer in the future.
 /// </summary>
 /// <param name="name">Name of the rover.</param>
 /// <param name="position">Starting position of the rover</param>
 /// <param name="orientation">Starting orientation of the rover</param>
 /// <param name="comModule">Communication module used by the rover.</param>
 /// <param name="terrain">Martian terrain the rover is stationed on</param>
 public Rover(string name, IPosition position, OrientationEnum orientation, IComModule comModule, ITerrain terrain)
 {
     ComModule = comModule;
     Terrain = terrain;
     ComModule.Rover = this;
     Name = name;
     Position = position;
     Orientation = orientation;
     if (Terrain.IsEmpty(Position.X, Position.Y))
     {
         Terrain.Grid[Position.X, Position.Y] = this;
     }
     else
     {
         //There is an obstacle at the coordinates rover was meant to be placed
         throw new ObstacleInTheWayException(Terrain.Grid[Position.X, Position.Y]);
     }
 }
Exemplo n.º 3
0
 public MockRover(IComModule comModule)
 {
     ComModule = comModule;
     ComModule.Rover = this;
 }