예제 #1
0
        public void InitializeProfile(ProfileSession profileSession, List <ProfileSurfacePoint> extremePoints)
        {
            profileChart.Series.Clear();

            foreach (var line in profileSession.ProfileLines)
            {
                profileChart.Series.Add(new Series
                {
                    ChartType         = SeriesChartType.Line,
                    Color             = Color.ForestGreen,
                    Name              = line.Id.ToString(),
                    YValuesPerPoint   = 1,
                    IsVisibleInLegend = false
                });

                var profileSurface =
                    profileSession.ProfileSurfaces.First(surface => surface.LineId == line.Id);

                foreach (var point in profileSurface.ProfileSurfacePoints)
                {
                    profileChart.Series.Last().Points.AddXY(point.Distance, point.Z);
                }
            }

            SetExtremePoints(extremePoints);
        }
        internal void AddProfileToList(ProfileSession profile)
        {
            bool isAddToGraphics = false;

            switch (profile.DefinitionType)
            {
            case ProfileSettingsTypeEnum.Points:
            {
                isAddToGraphics = View.AddSectionProfileNodes(profile);
                View.AddSectionProfileToList(profile);
                break;
            }

            case ProfileSettingsTypeEnum.Fun:
            {
                isAddToGraphics = View.AddFanProfileNode(profile);
                View.AddFanProfileToList(profile);
                break;
            }
            }

            //Add Profile to the working list
            _workingProfiles.Add(profile);

            //Add graphics
            if (isAddToGraphics)
            {
                GraphicsLayerManager.AddLinesToWorkingGraphics(profile.ConvertLinesToEsriPolypile(ArcMap.Document.FocusMap.SpatialReference), profile.SessionId);
            }

            GraphicsLayerManager.EmptyProfileGraphics(MilSpaceGraphicsTypeEnum.Calculating);
        }
예제 #3
0
        internal void AddProfileToList(ProfileSession profile)
        {
            bool isAddToGraphics = false;

            isAddToGraphics = View.AddNodeToTreeView(profile);

            //Add Profile to the working list
            _workingProfiles.Add(profile);

            //Add graphics
            if (isAddToGraphics)
            {
                var spatialReference = ArcMap.Document.FocusMap.SpatialReference;

                if (profile.DefinitionType == ProfileSettingsTypeEnum.Primitives)
                {
                    profile.Segments = ProfileLinesConverter.GetSegmentsFromProfileLine(profile.ProfileSurfaces, spatialReference);
                    GraphicsLayerManager.AddLinesToWorkingGraphics(ProfileLinesConverter.ConvertLineToPrimitivePolylines(profile.ProfileSurfaces[0],
                                                                                                                         spatialReference),
                                                                   profile.SessionId,
                                                                   profile.Segments.First());
                }
                else
                {
                    profile.SetSegments(spatialReference);
                    GraphicsLayerManager.AddLinesToWorkingGraphics(ProfileLinesConverter.ConvertSolidGroupedLinesToEsriPolylines(profile.Segments, spatialReference),
                                                                   profile.SessionId);
                }
            }

            GraphicsLayerManager.EmptyProfileGraphics(MilSpaceGraphicsTypeEnum.Calculating);
        }
예제 #4
0
        /// <summary>
        ///     Creates new profile session.
        ///     If there was already session started - throws an exception.<br />
        ///     Any exceptions this method throws are swallowed and logged to <see cref="IProfilerLogger"/>.
        /// </summary>
        public ProfileSession Start(IDictionary <string, object> additionalSessionData = null)
        {
            try
            {
                if (!this.Configuration.Enabled)
                {
                    return(null);
                }

                if (this.currentSession.Get() != null)
                {
                    throw new SessionAlreadyStartedProfilingException();
                }

                var session = new ProfileSession(this, this.logger);

                if (additionalSessionData != null)
                {
                    session.AddData(additionalSessionData);
                }

                this.currentSession.Set(session);

                return(session);
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex);
                return(null);
            }
        }
예제 #5
0
 public static bool SaveProfileSession(ProfileSession session)
 {
     using (var accessor = new SemanticDataAccess())
     {
         return(accessor.SaveProfileSession(session));
     }
 }
        /// <summary>
        ///     Determines if completed session is needs to be processed.
        /// </summary>
        public bool ShouldProcess(ProfileSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            var should_process = this.completedSessionFilter.ShouldProcess(session);

            if (should_process != null)
            {
                return(should_process.Value);
            }

            if (session.Operations.Count == 0)
            {
                return(false);
            }

            if (session.HasOperationLongerThanNormal)
            {
                return(true);
            }

            if (session.Duration < this.configuration.SessionMinimalDuration)
            {
                return(false);
            }

            return(true);
        }
        internal void CallGraphsHandle(ProfileSession profileSession, ProfileSettingsTypeEnum profileType)
        {
            var winImpl = AddIn.FromID <DockableWindowMilSpaceProfileGraph.AddinImpl>(ThisAddIn.IDs.DockableWindowMilSpaceProfileGraph);

            winImpl.MilSpaceProfileCalsController.ShowWindow();
            winImpl.MilSpaceProfileCalsController.AddSession(profileSession);
        }
        internal void AddSession(ProfileSession profileSession)
        {
            _surfaceProfileChartController.SetSession(profileSession);
            SurfaceProfileChart surfaceProfileChart = _surfaceProfileChartController.CreateProfileChart();

            View.AddNewTab(surfaceProfileChart, profileSession.SessionName);
        }
예제 #9
0
        internal static Dictionary <ProfileSurface, bool> GetLinesSegments(ProfileSession profileSession)
        {
            if (profileSession == null || profileSession.ProfileLines == null)
            {
                return(null);
            }

            var lines = new Dictionary <ProfileSurface, bool>();

            foreach (var line in profileSession.ProfileLines)
            {
                var surface       = profileSession.ProfileSurfaces.First(profileSurface => profileSurface.LineId == line.Id);
                var visibility    = surface.ProfileSurfacePoints.First().Visible;
                var segmentPoints = new List <ProfileSurfacePoint>();

                var points = surface.ProfileSurfacePoints;

                for (int i = 1; i < points.Length; i++)
                {
                    segmentPoints.Add(points[i]);
                    if (visibility != surface.ProfileSurfacePoints[i].Visible || surface.ProfileSurfacePoints[i].isVertex || i == surface.ProfileSurfacePoints.Length - 1)
                    {
                        lines.Add(new ProfileSurface()
                        {
                            ProfileSurfacePoints = segmentPoints.ToArray()
                        }, visibility);
                        visibility    = !visibility;
                        segmentPoints = new List <ProfileSurfacePoint>();
                        segmentPoints.Add(points[i]);
                    }
                }
            }

            return(lines);
        }
예제 #10
0
파일: DataPreparator.cs 프로젝트: VsPun/DPP
        public static ProfileSession Get()
        {
            ProfileSession session = null;

            XmlSerializer serializer = new XmlSerializer(typeof(ProfileSession));

            using (var fileStream = File.OpenRead("TestData.xml"))
            {
                //using (var writer = new StreamWriter(fileStream))
                {
                    // Various for loops etc as necessary that will ultimately do this:


                    try
                    {
                        if (serializer.Deserialize(fileStream) is ProfileSession result)
                        {
                            session = result;
                        }
                    }
                    catch (Exception ex)
                    {
                        //TODO: log the error
                    }
                }
            }

            return(session);
        }
예제 #11
0
        internal static List <ProfileSurface> GetPrimitiveSegments(ProfileSession profileSession)
        {
            var segmentSurfaces = new List <ProfileSurface>();

            foreach (var line in profileSession.ProfileLines)
            {
                var surface = profileSession.ProfileSurfaces.First(profileSurface => profileSurface.LineId == line.Id);
                var segment = new List <ProfileSurfacePoint>();

                foreach (var point in surface.ProfileSurfacePoints)
                {
                    segment.Add(point);

                    if (point.isVertex)
                    {
                        if (point.Distance != 0)
                        {
                            segmentSurfaces.Add(new ProfileSurface
                            {
                                LineId = surface.LineId,
                                ProfileSurfacePoints = segment.ToArray()
                            });

                            segment = new List <ProfileSurfacePoint>();
                            segment.Add(point);
                        }
                    }
                }
            }

            return(segmentSurfaces);
        }
예제 #12
0
        internal static Dictionary <ProfileSurface, bool> GetLinesSegments(ProfileSession profileSession)
        {
            if (profileSession == null || profileSession.ProfileLines == null)
            {
                return(null);
            }

            var lines = new Dictionary <ProfileSurface, bool>();

            foreach (var line in profileSession.ProfileLines)
            {
                var surface = profileSession.ProfileSurfaces.First(profileSurface => profileSurface.LineId == line.Id);

                var points = new List <ProfileSurfacePoint>(surface.ProfileSurfacePoints);

                while (points.Count > 0)
                {
                    var surfaceSegment = new ProfileSurface();
                    var visibility     = points.First().Visible;
                    surfaceSegment.ProfileSurfacePoints = points.TakeWhile(point =>
                                                                           point.Visible == visibility &&
                                                                           (!point.isVertex || point == points.First() || point == points.Last())).ToArray();

                    lines.Add(surfaceSegment, visibility);
                    points.RemoveRange(0, surfaceSegment.ProfileSurfacePoints.Length);
                }
            }

            return(lines);
        }
예제 #13
0
 public void SetSession(ProfileSession session)
 {
     _session = session;
     Show();
     ((ProfilingProgressWindowContent)Content).SetSession(session);
     // listener shall be added after SetSession to allow ProfilingProgressWindowContent processing events first
     session.AddListener(_listener);
     Show(); // why double Show: trying to fix the problem - window not visible
 }
        /// <summary>
        ///     Sets current profile session.
        /// </summary>
        /// <exception cref="ArgumentNullException"><paramref name="session"/> is <see langword="null" />.</exception>
        public void Set(ProfileSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            this.SetCurrentSession(session);
        }
예제 #15
0
        public ProfilerTests()
        {
            this.fixture = new FixtureBuilder().Build();

            this.configuration          = this.fixture.FreezeMock <IProfilerConfiguration>();
            this.currentSessionProvider = this.fixture.FreezeMock <ICurrentSessionProvider>();

            this.session = this.fixture.Create <ProfileSession>();
            this.currentSessionProvider.Setup(x => x.Get()).Returns(this.session);
        }
예제 #16
0
        internal bool?ShareProfileSession(ProfileSession profile)
        {
            if (profile.CreatedBy == Environment.UserName)
            {
                profile.Shared = true;
                return(SaveProfileSet(profile));
            }

            logger.ErrorEx("You are not allowed to share this Profile.");
            return(null);
        }
예제 #17
0
        /// <summary>
        /// Insert or Update the profile set in DB
        /// </summary>
        /// <param name="profileSet"></param>
        internal bool SaveProfileSet(ProfileSession profileSet)
        {
            //Write to DB
            bool res = MilSpaceProfileFacade.SaveProfileSession(profileSet);

            if (!res)
            {
                MessageBox.Show(LocalizationConstants.ErrorOnDataAccessTextMessage, "MilSpace", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(res);
        }
예제 #18
0
 private void StateChangedHandler(ProfileSessionState newState)
 {
     if (newState == ProfileSessionState.Finished || newState == ProfileSessionState.Failed)
     {
         ProfileSession s = _currentSession;
         _currentSession = null;
         if (s != null)
         {
             s.Destroy();
         }
     }
 }
예제 #19
0
        internal void SetSession(ProfileSession profileSession)
        {
            _profileSession = profileSession;

            if (_profileSession.ProfileLines != null && _profileSession.ProfileLines.Length > 0)
            {
                for (int i = 0; i < _profileSession.ProfileLines.Length; i++)
                {
                    _profileSession.ProfileLines[i].SessionId = _profileSession.SessionId;
                }
            }
        }
        private void SetCurrentSession([CanBeNull] ProfileSession session)
        {
            var http_context = this.httpContextFactory();

            if (http_context != null)
            {
                http_context.Items[HttpContextCurrentSessionKey] = session;
                return;
            }

            CurrentSession.Value = session;
        }
예제 #21
0
        public void StartSession(ProfileSession session)
        {
            if (SessionActive)
            {
                throw new InvalidOperationException();
            }

            _currentSession = session;
            _currentSession.AddListener(new ProfileSessionListener {
                OnStateChanged = StateChangedHandler
            });
            _currentSession.Start();
        }
예제 #22
0
        internal void InitializeProfile(ProfileSession profileSession)
        {
            profileChart.Series.Clear();

            foreach (var line in profileSession.ProfileLines)
            {
                var profileSurface =
                    profileSession.ProfileSurfaces.First(surface => surface.LineId == line.Id);

                AddSerie(profileSurface);
            }

            _profileId = profileSession.SessionId;
        }
        /// <summary>
        /// Set a current session for <see cref="ProfilingProgressWindowContent"/>.
        /// </summary>
        /// <param name="session">The session interface.</param>
        public void SetSession(ProfileSession session)
        {
            ClearSession(false);

            _session = session;

            session.AddListener(_sessionListener);

            _sysInfoProcessor = new QueuedAsynchronousProcessor <SysInfoItem>(ProcessTargetSysInfo);
            _eventsProcessor  = new QueuedAsynchronousProcessor <Event>(ProcessProfilerEvent);

            CaptionText.Text = Path.GetFileName(session.Configuration.TargetDll);

            LegendItemDebug.Visibility = (session.IsLiveProfiling ? Visibility.Visible : Visibility.Collapsed);
        }
예제 #24
0
        internal void AddSession(ProfileSession profileSession)
        {
            _surfaceProfileChartController = new SurfaceProfileChartController();

            _surfaceProfileChartController.OnProfileGraphClicked    += OnProfileGraphClicked;
            _surfaceProfileChartController.InvisibleZonesChanged    += InvokeInvisibleZonesChanged;
            _surfaceProfileChartController.ProfileRemoved           += InvokeProfileRemoved;
            _surfaceProfileChartController.SelectedProfileChanged   += InvokeSelectedProfileChanged;
            _surfaceProfileChartController.IntersectionLinesDrawing += InvokeIntersectionLinesDrawing;

            _surfaceProfileChartController.SetSession(profileSession);
            SurfaceProfileChart surfaceProfileChart = _surfaceProfileChartController.CreateProfileChart(profileSession.ObserverHeight);

            View.AddNewTab(surfaceProfileChart, profileSession.SessionId);
        }
예제 #25
0
        /// <summary>
        ///     Add results from completed profiling session.
        /// </summary>
        /// <exception cref="ResultsProcessorOverflowProfilingException">Results buffer size limit reached.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="session"/> is <see langword="null" />.</exception>
        public void Add(ProfileSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            if (this.dataToProcess.IsAddingCompleted)
            {
                return;
            }

            try
            {
                if (!this.processorService.ShouldProcess(session))
                {
                    return;
                }

                this.EnsureProcessingTaskStarted();

                var retries = this.configuration.ResultsBufferAddRetriesCount;
                while (true)
                {
                    if (this.dataToProcess.TryAdd(session))
                    {
                        return;
                    }

                    var overflow_exception = new ResultsProcessorOverflowProfilingException();
                    this.logger.LogWarning(overflow_exception.Message, overflow_exception);

                    retries--;
                    if (retries < 0)
                    {
                        throw overflow_exception;
                    }

                    ProfileSession tmp;
                    this.dataToProcess.TryTake(out tmp);
                }
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex);
            }
        }
예제 #26
0
        private ProfileSession GetEmptyProfileSession()
        {
            var newProfileId = GenerateProfileId();

            var session = new ProfileSession()
            {
                DefinitionType   = ProfileSettingsTypeEnum.Composed,
                SessionId        = newProfileId,
                SessionName      = GenerateProfileName(newProfileId),
                ObserverHeight   = 0,
                SurfaceLayerName = View.DemLayerName,
                CreatedBy        = Environment.UserName,
                CreatedOn        = DateTime.Now,
                Shared           = false
            };

            return(session);
        }
예제 #27
0
        private void StopSession(IDictionary <string, object> additionalSessionData, ProfileSession session)
        {
            if (additionalSessionData != null)
            {
                session.AddData(additionalSessionData);
            }

            this.completedSessionsProcessorQueue.Add(session);

            try
            {
                this.eventsHandler.OnSessionEnded(session);
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex);
            }
        }
예제 #28
0
        /// <summary>
        /// Start a profiling session.
        /// </summary>
        /// <remarks>
        /// A run profiler dialog is shown (if not starting a live profiling session). The dialog allows a user to edit
        /// different profiling options.
        /// </remarks>
        /// <param name="isLiveProfiling">
        /// true in case of live profiling (i.e. combined debugging and profiling), false otherwise
        /// </param>
        /// <returns>true if profiling has been started successfully, false otherwise</returns>
        public bool StartProfiler(bool isLiveProfiling)
        {
            Project project;

            if (!CanStartProfiler(out project) || (project == null))
            {
                return(false);
            }

            var sessionConfiguration = new ProfileSessionConfiguration(project, GeneralOptions);

            if (isLiveProfiling)
            {
                var preset = ProfilingPreset.CpuSampling;
                preset.ProfilingSettings.TraceSourceLines = false; // TODO!! example
                sessionConfiguration.ProfilingPreset      = preset;
            }
            else
            {
                var dlg = new RunProfilerDialog(sessionConfiguration);
                dlg.ShowDialog();
                if (!(dlg.DialogResult ?? false))
                {
                    return(false);
                }
            }

            SDBDeviceInfo device = GetAndCheckSelectedDevice(isLiveProfiling ? RunMode.LiveProfiler : RunMode.CoreProfiler);

            if (device == null)
            {
                return(false);
            }

            ProfileSession session = ProfileLauncher.CreateSession(device, sessionConfiguration, isLiveProfiling);

            if (session == null)
            {
                return(false);
            }
            ProfilingProgressWindow.SetSession(session);
            ProfileLauncher.StartSession(session);
            return(true);
        }
        private void ClearSession(bool hideScrollbar)
        {
            if (_session != null)
            {
                _session.RemoveListener(_sessionListener);
                _session = null;
            }

            DisposeHelper.SafeDispose(ref _sysInfoProcessor);
            DisposeHelper.SafeDispose(ref _eventsProcessor);

            ViewPortMinValue = 0;
            ViewPortMaxValue = ViewPortSize;

            _chartValues.Clear();

            _jitSeriesValues.Clear();
            _jitEventProcessor.Clear();

            _gcSeriesValues.Clear();
            _gcEventProcessor.Clear();

            LiveTimeline.AxisX[0].Sections.Clear();
            LiveTimeline.AxisY[1].MaxValue = 1000;
            LiveTimeline.Update(true, true);

            _rangeMaxValue               = ViewPortSize;
            _sysInfoStartTimeSeconds     = -1;
            _profilingEventsDeltaSeconds = 0;
            _sysInfoEventsDeltaSeconds   = 0;
            _areDeltasSet             = false;
            _previousSysInfo          = null;
            _previousChartData        = null;
            _currentPausedSection     = null;
            _currentDebugBreakSection = null;

            UpdateScrollBar(hideScrollbar);

            SessionControlButton.Visibility = Visibility.Collapsed;
            SessionControlButton.IsEnabled  = false;

            _session = null;
        }
예제 #30
0
        public void OnModeChange(DBGMODE dbgmodeLast, DBGMODE dbgmodeNew)
        {
            Debug.WriteLine(String.Format($"{GetType().Name}.OnModeChange: {dbgmodeLast}=>{dbgmodeNew}"));

            ProfileSession session = _currentSession;

            if (session != null)
            {
                switch (dbgmodeNew)
                {
                case DBGMODE.DBGMODE_Break:
                    session.OnDebugStateChanged(true);
                    break;

                case DBGMODE.DBGMODE_Run:
                    session.OnDebugStateChanged(false);
                    break;
                }
            }
        }