< Summary - ReFlex - Library

Information
Class: ReFlex.Core.Interactivity.Components.RemoteInteractionProcessor
Assembly: ReFlex.Core.Interactivity
File(s): D:\a\reflex\reflex\library\src\Core\Interactivity\Components\RemoteInteractionProcessor.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 60
Coverable lines: 60
Total lines: 93
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 20
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
get_Type()100%210%
get_PointCloud()100%210%
get_VectorField()100%210%
Update()0%420200%

File(s)

D:\a\reflex\reflex\library\src\Core\Interactivity\Components\RemoteInteractionProcessor.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Diagnostics;
 4using System.Linq;
 5using System.Threading.Tasks;
 6using ReFlex.Core.Common.Components;
 7using ReFlex.Core.Common.Util;
 8using ReFlex.Core.Interactivity.Interfaces;
 9
 10namespace ReFlex.Core.Interactivity.Components;
 11
 12public class RemoteInteractionProcessor: InteractionObserverBase
 13{
 14    private readonly IRemoteInteractionProcessorService _service;
 015    private readonly Stopwatch _stopWatch = new();
 16
 017    public RemoteInteractionProcessor(IRemoteInteractionProcessorService service)
 018    {
 019        _service = service;
 020    }
 21
 022    public override ObserverType Type { get; } = ObserverType.Remote;
 023    public override PointCloud3 PointCloud { get; set; }
 024    public override VectorField2 VectorField { get; set; }
 25
 26    public override event EventHandler<IList<Interaction>> NewInteractions;
 27
 28    public override async Task<ProcessingResult> Update()
 029    {
 030        if (!_service.IsConnected)
 031        {
 032            var success = await _service.Connect();
 033            if (!success)
 034            {
 035                return new ProcessingResult(ProcessServiceStatus.Error);
 36            }
 037        }
 38
 039        if (_service.IsBusy)
 040            return new ProcessingResult();
 41
 042        var result = new ProcessingResult(ProcessServiceStatus.Available);
 43
 044        var processed = await _service.Update(PointCloud, result.PerformanceMeasurement, MeasurePerformance);
 45
 046        var candidates = processed.Item1;
 047        var perfItem = new ProcessPerformance { Preparation = processed.Item2.Preparation, Update = processed.Item2.Upda
 048        var start = DateTime.Now.Ticks;
 049        if (MeasurePerformance)
 050        {
 051            _stopWatch.Start();
 052        }
 53
 054        var interactions = ConvertDepthValue(candidates.ToList());
 55
 056        if (MeasurePerformance)
 057        {
 058            _stopWatch.Stop();
 059            perfItem.ConvertDepthValue = _stopWatch.Elapsed;
 060            _stopWatch.Reset();
 061        }
 62
 063        if (MeasurePerformance)
 064        {
 065            _stopWatch.Start();
 066        }
 067        var frame = ComputeSmoothingValue(interactions);
 068        if (MeasurePerformance)
 069        {
 070            _stopWatch.Stop();
 071            perfItem.Smoothing = _stopWatch.Elapsed;
 072            _stopWatch.Reset();
 073        }
 74
 075        if (MeasurePerformance)
 076        {
 077            _stopWatch.Start();
 078        }
 079        var processedInteractions = ComputeExtremumType(frame.Interactions, PointCloud.AsJaggedArray());
 080        if (MeasurePerformance)
 081        {
 082            _stopWatch.Stop();
 083            perfItem.ComputeExtremumType = _stopWatch.Elapsed;
 084            _stopWatch.Reset();
 085        }
 86
 087        UpdatePerformanceMetrics(perfItem, start);
 88
 089        NewInteractions?.Invoke(this, processedInteractions);
 90
 091        return result;
 092    }
 93}