Ejemplo n.º 1
0
 public SimulationService(string path)
 {
     _depPath = path;
     _mapReader = new DepartmentMapReader(_depPath);
     _mapReader.IsWritingEnabled = false;
     _cancellationTokenSource = new CancellationTokenSource();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads the information out of
        /// the given file and sets the
        /// corresponding values.
        /// </summary>
        /// <param name="filePath">The path to the .dep-file.</param>
        /// <exception cref="IOException">Might be thrown.</exception>
        public void InitializeFromFile(string filePath)
        {
            var reader = new DepartmentMapReader(filePath);
            reader.IterationPassed += ReadFileIterationPassed.Raise;

            DepartmentInfo[] deps = reader.ReadFile();

            Image img = reader.ReadImage();
            ImageWidth = img.Width;
            ImageHeight = img.Height;

            WriteMessage("Calculating Total-Population...");
            int maxPopulation = deps.Sum(x => x.GetTotal());        // getting maximum population
            Humans = new Human[(int)(maxPopulation * 1.05f)];       // adding 5% :)

            WriteMessage("Generating Matrix...");
            Cells = new PopulationCell[ImageWidth * ImageHeight];

            MatrixGenerator mg = new MatrixGenerator(false);
            mg.DepartmentCalculationFinished += DepartmentCalculated.Raise;
            mg.GenerateMatrix(Cells, Humans, deps, ImageWidth, ImageHeight);

            WriteMessage("...Matrix generated.");
        }
Ejemplo n.º 3
0
 public void StartUp()
 {
     _reader = new DepartmentMapReader(DEFAULT_PATH);
 }