Example #1
0
        public void doTestCheckPoint(frmInput inForm)
        {
            bool ans = AnimalManager.save("animalmanager.dat", mAnimalManager);

            if (!ans)
            {
                Console.WriteLine("Failed to serialize");
            }
        }
Example #2
0
 public SimulatonManager()
 {
     mLog.Debug("making new animal manager ");
     mAnimalManager = new AnimalManager();
     mLog.Debug("getting the hourly manager collection");
     myHourlyModifiers           = HourlyModifierCollection.GetUniqueInstance();
     myDailyModifiers            = DailyModiferCollection.GetUniqueInstance();
     mElapsedTimeBetweenTimeStep = 0;
     mLog.Debug("back in sim manager with a modifier Count of " + myHourlyModifiers.Count.ToString());
 }
Example #3
0
        // toto
        public static bool save(string filename, AnimalManager animalManager)
        {
            FileStream fos = File.Create(filename);

            try
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(fos, animalManager);
                fos.Close();
                return(true);
            }catch (Exception e) {
                fos.Close();
                return(false); // something bad happened
            }
        }
Example #4
0
        public void setUpNewYearDispersalMap(DateTime now, AnimalManager am)
        {
            //Because this is happening at the yearly time change the simulation
            //manager will handle making the new animal maps.
            try
            {
                mLog.Debug("inside setUpNewYearDispersalMap(DateTime now, AnimalManager am) calling changeMap(now)");
                this.changeMap(now);
                if (changeMaps == true)
                {
                    InitialAnimalAttributes[] inIAA;
                    MapManager.GetUniqueInstance().GetInitialAnimalAttributes(out inIAA);
                    am.addNewDispersers(inIAA, now);
                }
            }
            catch (System.Exception ex)
            {
                eLog.Debug(ex);
#if (DEBUG)
                System.Windows.Forms.MessageBox.Show(ex.Message);
#endif
            }
        }
Example #5
0
        //todo
        public static AnimalManager load(string filename)
        {
            if (!File.Exists(filename))
            {
                return(null);
            }
            FileStream fis = File.OpenRead(filename);

            try
            {
                BinaryFormatter bf = new BinaryFormatter();
                AnimalManager   am = (SEARCH.AnimalManager)bf.Deserialize(fis);
                fis.Close();
                return(am);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                // something bad happened.
                fis.Close();
                return(null);
            }
        }
Example #6
0
        public void changeMap(DateTime now, AnimalManager am)
        {
            try
            {
                mLog.Debug("inside changeMap(DateTime now, AnimalManager am) calling changeMap(now)");
                string previousMapName = MapManager.GetUniqueInstance().SocialMap.FullFileName;
                this.changeMap(now);
                if (this.mMapType == "Social" && changeMaps == true)
                {
                    am.adjustNewSocialMap(MapManager.GetUniqueInstance().SocialMap);
                }
                else if (this.mMapType == "Dispersal" && changeMaps == true)
                {
                    mLog.Debug("MapType is Dispersal and changeMaps == true so need to make newly released animals");
                    InitialAnimalAttributes[] inIAA;
                    MapManager.GetUniqueInstance().GetInitialAnimalAttributes(out inIAA);
                    //int numNewDispersers = inIAA.Length;
                    int numNewDispersers = 0;
                    for (int animal = 0; animal < inIAA.Length; animal++)
                    {
                        numNewDispersers += inIAA[animal].NumToMake;
                    }

                    am.addNewDispersers(inIAA, now);
                    mLog.Debug("Back from the animal manager making new animals");
                    mLog.Debug("trigger type is " + this.mMyTriggers[0].MyTriggerType.ToString());
                    MapManager.GetUniqueInstance().makeNewDisperserAnimalMaps(numNewDispersers);
                }
            }
            catch (System.Exception ex)
            {
                eLog.Debug(ex);
#if (DEBUG)
                System.Windows.Forms.MessageBox.Show(ex.Message);
#endif
            }
        }