public async Task <GetPoolStatsResponse> GetPoolPerformanceAsync(string poolId, [FromQuery(Name = "r")] SampleRange range = SampleRange.Day, [FromQuery(Name = "i")] SampleInterval interval = SampleInterval.Hour) { var pool = GetPool(poolId); // set range var end = clock.Now; DateTime start; switch (range) { case SampleRange.Day: start = end.AddDays(-1); break; case SampleRange.Month: start = end.AddDays(-30); break; default: throw new ApiException("invalid interval"); } var stats = await cf.Run(con => statsRepo.GetPoolPerformanceBetweenAsync( con, pool.Id, interval, start, end)); var response = new GetPoolStatsResponse { Stats = stats.Select(mapper.Map <AggregatedPoolStats>).ToArray() }; return(response); }
void MouseMoveHandler(MouseEventArgs e) { if (Wave == null) { return; } var x = e.GetPosition(ClickedElement).X; if (ClickedElement == IndicatorMoveArea) { IndicatorPosition = Math.Min((int)Math.Round(x / IndicatorMoveArea.ActualWidth * SampleRange.Length) + SampleRange.Begin, Wave.SampleCount - 1); if (x > IndicatorMoveArea.ActualWidth) { SampleRange = SampleRange.MoveTo(IndicatorPosition - SampleRange.Length); } else if (x < 0.0) { SampleRange = SampleRange.MoveTo(IndicatorPosition); } OnIndicatorMoved(); } else if (ClickedElement == HandScrollArea) { var move = x - ClickPosition.X; SampleRange = SampleRange.MoveTo(PrevSampleRange.Begin - (int)(move / HandScrollArea.ActualWidth * SampleRange.Length)); } }
public void ScrollToIndicatorIfOutOfScreen() { if (!IndicatorIsVisible) { SampleRange = SampleRange.MoveTo(IndicatorPosition); } }
void TimeScrollBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (Wave == null) { return; } SampleRange = SampleRange.MoveTo((int)e.NewValue); }
private async Task <Responses.WorkerPerformanceStatsContainer[]> GetMinerPerformanceInternal( SampleRange mode, PoolConfig pool, string address) { Persistence.Model.Projections.WorkerPerformanceStatsContainer[] stats = null; var end = clock.UtcNow; DateTime start; switch (mode) { case SampleRange.Day: // NEW from CF-master // set range if (end.Minute < 30) { end = end.AddHours(-1); } end = end.AddMinutes(-end.Minute); end = end.AddSeconds(-end.Second); // <<<<<<<<------- start = end.AddDays(-1); stats = await cf.Run(con => statsRepo.GetMinerPerformanceBetweenHourlyAsync( con, pool.Id, address, start, end)); break; case SampleRange.Month: // NEW from CF-master if (end.Hour < 12) { end = end.AddDays(-1); } end = end.Date; // <<<<<<<<------- // set range start = end.AddMonths(-1); stats = await cf.Run(con => statsRepo.GetMinerPerformanceBetweenDailyAsync( con, pool.Id, address, start, end)); break; default: throw new ApiException("invalid interval"); } // map var result = mapper.Map <Responses.WorkerPerformanceStatsContainer[]>(stats); return(result); }
public static int Bake(Curve curve, float frameRate, Curve outCurve, SampleRange sampleRange) { NativeArray <Keyframe> keys = curve.Keys; NativeArray <Keyframe> outKeys = outCurve.Keys; int bakedFrames = Bake(keys, frameRate, outKeys, sampleRange); // KeyframeUtilities.AlignTangentsSmooth(outKeys, sampleRange); return(bakedFrames); }
public static BakeJob ConfigureBake(Curve[] curves, float frameRate, Curve[] outCurves, Allocator alloc) { SampleRange sampleRange = new SampleRange() { startFrameIndex = 0, numFrames = curves[0].Length }; return(ConfigureBake(curves, frameRate, outCurves, alloc, sampleRange)); }
public async Task <Responses.WorkerPerformanceStatsContainer[]> GetMinerPerformanceAsync( string poolId, string address, [FromQuery] SampleRange mode = SampleRange.Day) { var pool = GetPool(poolId); if (string.IsNullOrEmpty(address)) { throw new ApiException($"Invalid or missing miner address", HttpStatusCode.NotFound); } return(await GetMinerPerformanceInternal(mode, pool, address)); }
public async Task <Responses.WorkerPerformanceStatsContainer[]> GetMinerPerformanceAsync( string poolId, string address, [FromQuery] SampleRange mode = SampleRange.Day) { var pool = GetPool(poolId); if (string.IsNullOrEmpty(address)) { throw new ApiException($"Invalid or missing miner address", HttpStatusCode.NotFound); } var result = await GetMinerPerformanceInternal(mode, pool, address); Response.Headers.Add("x-total-count", result.Length.ToString()); return(result); }
public async Task <Responses.MinerStats> GetMinerInfoAsync( string poolId, string address, [FromQuery] SampleRange perfMode = SampleRange.Day) { var pool = GetPool(poolId); if (string.IsNullOrEmpty(address)) { throw new ApiException($"Invalid or missing miner address", HttpStatusCode.NotFound); } var statsResult = await cf.RunTx((con, tx) => statsRepo.GetMinerStatsAsync(con, tx, pool.Id, address), true, IsolationLevel.Serializable); Responses.MinerStats stats = null; if (statsResult != null) { stats = mapper.Map <Responses.MinerStats>(statsResult); // optional fields if (statsResult.LastPayment != null) { // Set timestamp of last payment stats.LastPayment = statsResult.LastPayment.Created; // Compute info link var baseUrl = pool.Template.ExplorerTxLink; if (!string.IsNullOrEmpty(baseUrl)) { stats.LastPaymentLink = string.Format(baseUrl, statsResult.LastPayment.TransactionConfirmationData); } } stats.PerformanceSamples = await GetMinerPerformanceInternal(perfMode, pool, address); var shareEnd = clock.Now; var shareStart = shareEnd.AddDays(-1); stats.Shares = await cf.Run(con => shareRepo.CountSharesBetweenCreatedAsync(con, pool.Id, address, shareStart, shareEnd)); stats.InvalidShares = await cf.Run(con => invalidShareRepo.CountInvalidSharesBetweenCreated(con, pool.Id, address, shareStart, shareEnd)); } return(stats); }
public async Task <Responses.MinerStats> GetMinerInfoAsync( string poolId, string address, [FromQuery] SampleRange perfMode = SampleRange.Day) { var pool = GetPool(poolId); if (string.IsNullOrEmpty(address)) { throw new ApiException("Invalid or missing miner address", HttpStatusCode.NotFound); } if (pool.Template.Family == CoinFamily.Ethereum) { address = address.ToLower(); } var statsResult = await cf.RunTx((con, tx) => statsRepo.GetMinerStatsAsync(con, tx, pool.Id, address), true, IsolationLevel.Serializable); Responses.MinerStats stats = null; if (statsResult != null) { stats = mapper.Map <Responses.MinerStats>(statsResult); // optional fields if (statsResult.LastPayment != null) { // Set timestamp of last payment stats.LastPayment = statsResult.LastPayment.Created; // Compute info link var baseUrl = pool.Template.ExplorerTxLink; if (!string.IsNullOrEmpty(baseUrl)) { stats.LastPaymentLink = string.Format(baseUrl, statsResult.LastPayment.TransactionConfirmationData); } } stats.PerformanceSamples = await GetMinerPerformanceInternal(perfMode, pool, address); } return(stats); }
public async Task <Responses.WorkerPerformanceStatsContainer[]> GetMinerPerformanceAsync( string poolId, string address, [FromQuery] SampleRange mode = SampleRange.Day) { var pool = GetPool(poolId); if (string.IsNullOrEmpty(address)) { throw new ApiException("Invalid or missing miner address", HttpStatusCode.NotFound); } if (pool.Template.Family == CoinFamily.Ethereum) { address = address.ToLower(); } var result = await GetMinerPerformanceInternal(mode, pool, address); return(result); }
private void exportResults(string outFilename) { StringBuilder result = new StringBuilder(); var sampleCollection = session.CurrentSampleFile.TestSamples; sampleCollection.Sort(); result.Append("SampleID\tRange\tHaplogroup\tQuality\tPolymorphisms\n"); if (sampleCollection != null) { foreach (TestSample sample in sampleCollection) { result.Append(sample.SampleID + "\t"); SampleRange range = sample.SampleRanges; var startRange = range.Starts; var endRange = range.Ends; string resultRange = ""; for (int i = 0; i < startRange.Count; i++) { if (startRange[i] == endRange[i]) { resultRange = resultRange + startRange[i] + ";"; } else { resultRange = resultRange + startRange[i] + "-" + endRange[i] + ";"; } } result.Append(resultRange + "\t"); result.Append(sample.RecognizedHaplogroup + "\t"); result.Append(sample.ResultQuality + "\t"); getPolysUsed(result, session.getClassificationResults(sample.SampleID)); getPolysNotUsed(result, session.getClassificationResults(sample.SampleID)); getPolysUnused(result, session.getClassificationResults(sample.SampleID)); result.Append("\n"); } } StreamWriter fileWriter = new StreamWriter(outFilename); fileWriter.Write(result.ToString()); fileWriter.Close(); }
public IEnumerator BuildTransforms() { // // Now re-sample all animations according to the target // sample rate and adjust the segment information to // reference the transforms array. // // // Calculate total number of poses to be generated // (based on previously generated segments) // int numJoints = rig.NumJoints; if (numJoints < 2) { throw new ArgumentException($"Rig does not have enough joints. Only {numJoints} present."); } if (numFrames == 0) { throw new Exception("No animation frame to process, please make sure there is at least one single non-empty tag in your Kinematica asset."); } int numTransforms = numFrames * numJoints; using (NativeArray <AffineTransform> transforms = new NativeArray <AffineTransform>(numTransforms, Allocator.Persistent)) { int globalSegmentIndex = 0; int destinationFrameIndex = 0; for (int clipIndex = 0; clipIndex < clipSegments.Count; ++clipIndex) { ClipSegments segments = clipSegments[clipIndex]; AnimationClip clip = segments.Clip.GetOrLoadClipSync(); using (AnimationSampler animSampler = new AnimationSampler(rig, clip)) { float sourceSampleRate = clip.frameRate; float targetSampleRate = asset.SampleRate; float sampleRateRatio = sourceSampleRate / targetSampleRate; int numFrameResampledClip = (int)math.ceil(targetSampleRate * segments.Clip.DurationInSeconds); for (int segmentIndex = 0; segmentIndex < segments.NumSegments; ++segmentIndex, ++globalSegmentIndex) { Segment segment = segments[segmentIndex]; int firstFrame = Missing.roundToInt(segment.source.FirstFrame / sampleRateRatio); firstFrame = math.min(firstFrame, numFrameResampledClip - 1); SampleRange sampleRange = new SampleRange() { startFrameIndex = firstFrame, numFrames = segment.destination.NumFrames }; using (AnimationSampler.RangeSampler rangeSampler = animSampler.PrepareRangeSampler(asset.SampleRate, sampleRange, destinationFrameIndex, transforms)) { rangeSampler.Schedule(); progressFeedback?.Invoke(new ProgressInfo() { title = $"Sample clip {clip.name}", progress = (float)globalSegmentIndex / numSegments }); while (!rangeSampler.IsComplete) { yield return(null); if (bCancel) { rangeSampler.Complete(); yield break; } } rangeSampler.Complete(); } destinationFrameIndex += segment.destination.NumFrames; } } } WriteTransformsToBinary(transforms); } }
public static int Bake(NativeArray <Keyframe> keyframes, float frameRate, NativeArray <Keyframe> bakedFrames, SampleRange sampleRange) { int numKeys = keyframes.Length; float start = keyframes[0].time; float end = keyframes[numKeys - 1].time; float duration = end - start; float frame = 1 / frameRate; int numFrames = bakedFrames.Length; for (int i = 0; i < sampleRange.numFrames; i++) { int frameIndex = sampleRange.startFrameIndex + i; float time = math.clamp(start + frameIndex * frame, start, end); float value = CurveSampling.ThreadSafe.EvaluateWithinRange(keyframes, time, 0, numKeys - 1); bakedFrames[frameIndex] = new Keyframe(time, value); } return(sampleRange.numFrames); }
void MoveSampleRange(double mouseX) { var targetSample = (int)Math.Round(mouseX / ActualWidth * SampleCount); SampleRange = SampleRange.MoveTo(targetSample - SampleRange.Length / 2); }
public static BakeJob ConfigureBake(Curve[] curves, float frameRate, Curve[] outCurves, Allocator alloc, SampleRange sampleRange) { var job = new BakeJob(); job.curves = new NativeArray <CurveData>(curves.Length, alloc); job.frameRate = frameRate; job.outCurves = new NativeArray <CurveData>(curves.Length, alloc); job.sampleRange = sampleRange; for (int i = 0; i < curves.Length; i++) { job.curves[i] = new CurveData(curves[i], alloc); int frameCount = (int)math.ceil(frameRate * curves[i].Duration); //var outCurve = new Curve(frameCount, alloc); //outCurves[i] = outCurve; job.outCurves[i] = new CurveData(outCurves[i], alloc); } return(job); }