Exemple #1
0
        public Job(FJobRequest fJobRequest, string requestMsgId)
        {
            FJobRequest  = fJobRequest;
            RequestMsgId = requestMsgId;

            FGenJob fGenJob = BuildFGenJob(fJobRequest);

            FGenerator = new FGenerator(fGenJob);

            //_position = new KPoint(fJobRequest.Area.Point.X * FGenerator.BLOCK_WIDTH, fJobRequest.Area.Point.Y * FGenerator.BLOCK_HEIGHT);
            _position = new KPoint(fJobRequest.Area.Point.X, fJobRequest.Area.Point.Y);

            _subJobIterator = new SubJobIterator(this);
            ResetSubJobsRemainingToBeSent();

            _closed = false;

            Debug.WriteLine($"Creating new Repo. Name: {Name}, JobId: {JobId}.");
            _countsRepo = new ValueRecords <KPoint, SubJobResult>(Name);
            ReportRepoContents();

            //Debug.WriteLine($"Starting to get histogram for {Name} at {DateTime.Now.ToString(DiagTimeFormat)}.");
            //Dictionary<int, int> h = GetHistogram();
            //Debug.WriteLine($"Histogram complete for {Name} at {DateTime.Now.ToString(DiagTimeFormat)}.");
        }
Exemple #2
0
        public void DeleteCountsRepo()
        {
            Debug.WriteLine($"Starting to delete the old repo: {RepoFilename} at {DateTime.Now.ToString(DiagTimeFormat)}.");
            if (_countsRepo != null)
            {
                _countsRepo.Dispose();
                _countsRepo = null;
            }

            ValueRecords <RectangleInt, MapSectionWorkResult> .DeleteRepo(RepoFilename);

            Debug.WriteLine($"Completed deleting the old repo: {RepoFilename} at {DateTime.Now.ToString(DiagTimeFormat)}.");
        }
Exemple #3
0
        //public int WorkResultWriteCount = 0;
        //public int WorkResultReWriteCount = 0;


        public Job(SMapWorkRequest sMapWorkRequest) : base(sMapWorkRequest)
        {
            _position    = new KPoint(sMapWorkRequest.Area.SectionAnchor.X, sMapWorkRequest.Area.SectionAnchor.Y);
            SamplePoints = GetSamplePoints(sMapWorkRequest);
            Reset();

            string filename = RepoFilename;

            Debug.WriteLine($"Creating new Repo. Name: {filename}, JobId: {JobId}.");
            _countsRepo = new ValueRecords <KPoint, MapSectionWorkResult>(filename, useHiRezFolder: false);

            //Debug.WriteLine($"Starting to get histogram for {RepoFilename} at {DateTime.Now.ToString(DiagTimeFormat)}.");
            //Dictionary<int, int> h = GetHistogram();
            //Debug.WriteLine($"Histogram complete for {RepoFilename} at {DateTime.Now.ToString(DiagTimeFormat)}.");
        }
        public CountsRepoReader(string repofilename, bool hiRez, int blockWidth, int blockHeight)
        {
            _hiRez      = hiRez;
            _blockWidth = blockWidth;
            int blockLength = blockWidth * blockHeight;

            if (_hiRez)
            {
                _countsRepoHiRez = new ValueRecords <KPoint, SubJobResult>(repofilename, useHiRezFolder: _hiRez);
                _workResultHiRez = SubJobResult.GetEmptySubJobResult(blockLength, "0", false);
            }
            else
            {
                _countsRepo = new ValueRecords <KPoint, MapSectionWorkResult>(repofilename, useHiRezFolder: _hiRez);
                _workResult = new MapSectionWorkResult(blockLength, hiRez: hiRez, includeZValuesOnRead: false);
            }
        }
        public void GetHistogramTest()
        {
            int w = 108;             // blocks
            int h = 72;

            CanvasSize imageSize = new CanvasSize(w * 100, h * 100);

            string fn        = "17";
            string filename  = $"MandlebrodtMapInfo ({fn})";
            string imagePath = Path.Combine(BasePath, $"MBB({fn})_{imageSize.Width}.png");

            IDictionary <int, int> hist = new Dictionary <int, int>();

            ValueRecords <RectangleInt, MapSectionWorkResult> countsRepo = new ValueRecords <RectangleInt, MapSectionWorkResult>(filename, useHiRezFolder: false);

            RectangleInt         key        = new RectangleInt(new PointInt(0, 0), new SizeInt(100, 100));
            MapSectionWorkResult workResult = new MapSectionWorkResult(10000, hiRez: false, includeZValuesOnRead: false);

            for (int vBPtr = 0; vBPtr < h; vBPtr++)
            {
                key.Point.Y = vBPtr * 100;
                for (int hBPtr = 0; hBPtr < w; hBPtr++)
                {
                    key.Point.X = hBPtr * 100;
                    if (countsRepo.ReadParts(key, workResult))
                    {
                        foreach (int cntAndEsc in workResult.Counts)
                        {
                            int cnt = cntAndEsc / 10000;
                            if (hist.TryGetValue(cnt, out int occurances))
                            {
                                hist[cnt] = occurances + 1;
                            }
                            else
                            {
                                hist[cnt] = 1;
                            }
                        }
                    }
                }
            }

            Debug.WriteLine($"The histogram has {hist.Count} entries.");
        }
Exemple #6
0
        //public IEnumerable<Tuple<MapSectionResult, bool>> ReplayResults()
        //{
        //	SubJob subJob = GetNextSubJob();

        //	while (subJob != null)
        //	{
        //		MapSection ms = subJob.MapSectionWorkRequest.MapSection;
        //		RectangleInt riKey = ms.GetRectangleInt();
        //		MapSectionWorkResult workResult = GetEmptyResult(riKey);

        //		if (RetrieveWorkResultFromRepo(riKey, workResult))
        //		{
        //			MapSectionResult msr = new MapSectionResult(JobId, ms, workResult.Counts);

        //			Tuple<MapSectionResult, bool> item = new Tuple<MapSectionResult, bool>(msr, IsLastSubJob);
        //			DecrementSubJobsRemainingToBeSent();

        //			subJob = GetNextSubJob();
        //			yield return item;
        //		}
        //		else
        //		{
        //			yield return null;
        //		}
        //	}
        //}

        private void CloseCountsRepo(bool deleteRepo)
        {
            Debug.WriteLine($"Starting to close the repo: {RepoFilename} at {DateTime.Now.ToString(DiagTimeFormat)}.");
            if (_countsRepo != null)
            {
                ValueRecords <KPoint, SubJobResult> repo = _countsRepo;
                _countsRepo = null;
                repo.Dispose();
            }
            if (deleteRepo)
            {
                ValueRecords <KPoint, SubJobResult> .DeleteRepo(RepoFilename);

                Debug.WriteLine($"Completed deleting the repo: {RepoFilename} at {DateTime.Now.ToString(DiagTimeFormat)}.");
            }
            else
            {
                Debug.WriteLine($"Completed closing the repo: {RepoFilename} at {DateTime.Now.ToString(DiagTimeFormat)}.");
            }
        }
        public void TestMethod1()
        {
            string filename = "Center1";

            using (ValueRecords <RectangleInt, MapSectionWorkResult> repo = new ValueRecords <RectangleInt, MapSectionWorkResult>(filename, useHiRezFolder: false))
            {
                RectangleInt         key = new RectangleInt(new PointInt(0, 0), new SizeInt(100, 100));
                MapSectionWorkResult val = BuildMSWR(100 * 100);

                repo.Add(key, val);

                MapSectionWorkResult val2 = new MapSectionWorkResult(100 * 100, hiRez: false, includeZValuesOnRead: true);
                repo.ReadParts(key, val2);
            }

            using (ValueRecords <RectangleInt, MapSectionWorkResult> repo = new ValueRecords <RectangleInt, MapSectionWorkResult>(filename, useHiRezFolder: false))
            {
                RectangleInt         key  = new RectangleInt(new PointInt(0, 0), new SizeInt(100, 100));
                MapSectionWorkResult val2 = new MapSectionWorkResult(100 * 100, hiRez: false, includeZValuesOnRead: true);

                repo.ReadParts(key, val2);
            }
        }