// a private common initilization function
 private void InitClass(string ID, cSuperCell SuperCell, double K, double XLoc,
                        double YLoc)
 {
     // check the parameters to make sure that they are valid.  Throw exceptions if
     // they are not.
     // ID must not be 0 length.
     if (ID.Length == 0)
     {
         throw new ArgumentException("ID must not be an empty string.", "ID");
     }
     // SuperCell must be a valid reference
     if (SuperCell == null)
     {
         ThrowSuperCellException();
     }
     // K must be greater than or equal to 0
     if (K < 0)
     {
         ThrowKException();
     }
     // set the ID value and K
     mvarID = ID;
     mvarK  = K;
     // add this cell to the supercell
     SuperCell.Add(this);
     // set the x,y location
     mvarXLoc = XLoc;
     mvarYLoc = YLoc;
     // create the neighbours array
     mvarNeighbours = new cCell[6];
     // create the list of animals
     mvarAnimals = new cAnimalList(null);
 }
 // ************************ Methods **********************************************
 /// <summary>
 ///		Add a supercell to the supercell list.  The supercell will be keyed by
 ///		its ID.  If another cell in the list already has this ID, an ArgumentException
 ///		exception will be raised.  If item is null, an ArgumentNullException exception
 ///		is raised.
 /// </summary>
 /// <param name="item">The supercell to add to the list.</param>
 public void Add(cSuperCell item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item", "Cannot add a null item to the list");
     }
     Values.Add(item.ID, item);
 }
 // ***************** internal methods *********************************************
 /// <summary>
 ///		Set the supercell of this cell.  This is an internal function and can only
 ///		be called by objects within the Rabies_Model_Core namespace.
 /// </summary>
 /// <param name="SuperCell">
 ///		The reference to the desired super cell.  An ArgumentException exception is
 ///		raised if this value is null.
 /// </param>
 internal void SetSuperCell(cSuperCell SuperCell)
 {
     // make sure passed supercell is not null
     if (SuperCell == null)
     {
         ThrowSuperCellException();
     }
     // set the value
     mvarSuperCell = SuperCell;
 }
Esempio n. 4
0
        /// <summary>
        ///		Read supercell data from the data source and fill the passed supercell
        ///		list.
        /// </summary>
        /// <param name="Supercells">
        ///		The cell list to fill.  The cells are added to any that are already in the
        ///		list. An ArgumentNullException exception is raised if Supercells is null.
        /// </param>
        public void GetSuperCellData(cSuperCellList Supercells)
        {
            // make sure Supercells is not null
            if (Supercells == null)
            {
                ThrowSupercellsException();
            }
            // reset the supercell recordset
            this.ResetSupercells();
            string Name = "";
            int    InResistance = 0, OutResistance = 0;

            while (this.GetNextSupercellRecord(ref Name, ref InResistance,
                                               ref OutResistance))
            {
                // create a new supercell
                cSuperCell SuperCell = new cSuperCell(Name, InResistance, OutResistance);
                // add the new supercell to the supercell list
                Supercells.Add(SuperCell);
            }
        }
 /// <summary>
 ///		Initiliaze a cell object with a passed K value.
 /// </summary>
 /// <param name="ID">
 ///		The ID of this cell.  If the ID is zero length, an ArgumentException
 ///		exception is raised.
 ///	</param>
 /// <param name="SuperCell">
 ///		A reference to the supercell that this cell belongs to.  If SuperCell is
 ///		null, an ArgumentException is raised.
 /// </param>
 /// <param name="K">
 ///		The "carrying capacity" of this cell. If K is set to less than zero, an
 ///		ArgumnetOutOfRangeException exception is raised.
 ///	</param>
 public cCell(string ID, cSuperCell SuperCell, double K)
 {
     InitClass(ID, SuperCell, K, 0, 0);
 }
 // ******************** constructors **********************************************
 /// <summary>
 ///		Initialize a cell object.  K is set to 0.
 /// </summary>
 /// <param name="ID">
 ///		The ID of this cell.  If the ID is zero length, an ArgumentException
 ///		exception is raised.
 ///	</param>
 /// <param name="SuperCell">
 ///		A reference to the supercell that this cell belongs to.  If SuperCell is
 ///		null, an ArgumentException is raised.
 /// </param>
 public cCell(string ID, cSuperCell SuperCell)
 {
     InitClass(ID, SuperCell, 0, 0, 0);
 }
 /// <summary>
 ///		Initilaize a cell object with a passed K value and a geographic location.
 ///		Note that the geographic location is for reference only.  It does not
 ///		affect the operation of the model and does not restrict which cells can
 ///		be neighbours of which cells.
 /// </summary>
 /// <param name="ID">
 ///		The ID of this cell.  If the ID is zero length, an ArgumentException
 ///		exception is raised.
 ///	</param>
 /// <param name="SuperCell">
 ///		A reference to the supercell that this cell belongs to.  If SuperCell is
 ///		null, an ArgumentException is raised.
 /// </param>
 /// <param name="K">
 ///		The "carrying capacity" of this cell. If K is set to less than zero, an
 ///		ArgumnetOutOfRangeException exception is raised.
 ///	</param>
 /// <param name="XLoc">The "X" geographic coordinate.</param>
 /// <param name="YLoc">The "Y" geographic coordinate.</param>
 public cCell(string ID, cSuperCell SuperCell, double K, double XLoc, double YLoc)
 {
     InitClass(ID, SuperCell, K, XLoc, YLoc);
 }