/// <summary>Handles the <see cref="RawCall"/> that was removed and removes its delegate from the Publisher's matching event(s)</summary> /// <param name="tCall">RawCall that was removed</param> /// <param name="tIndex">Index of the RawCall that was removed</param> protected virtual void effectsCallRemoved(RawCall tCall, int tIndex) { Action tempDelegate = tCall.delegateInstance as Action; if (tempDelegate != null) { onVoid -= tempDelegate; } }
/// <summary>Handles the <see cref="RawCall"/> that was added and registers its delegate to the Publisher's matching event(s)</summary> /// <param name="tCall">RawCall that was added</param> protected virtual void effectsCallAdded(RawCall tCall) { Action tempDelegate = tCall.delegateInstance as Action; if (tempDelegate != null) { onVoid += tempDelegate; } }
public BatCall Merge(List <RawCall> rawCalls) { BatCall mergedCall = new BatCall(); RawCall firstCall = rawCalls[0]; mergedCall.StartTimeMs = firstCall.StartTimeMs; mergedCall.ClippedSamples = 0; mergedCall.MissedSamples = 0; List <byte> powerData = new List <byte>(); ulong lastEndTime = firstCall.EndTimeMs; uint[] tempFftData = new uint[256]; foreach (RawCall rawCall in rawCalls) { if (lastEndTime < rawCall.StartTimeMs) { int delta = (int)Math.Round((rawCall.StartTimeMs - lastEndTime) / 0.251); powerData.AddRange(Enumerable.Repeat((byte)0, delta)); } powerData.AddRange(rawCall.PowerData); lastEndTime = rawCall.EndTimeMs; // We currently have a sample rate of 231kHz and a Buffer of 1024. // That means we get data from 0Hz to 115.5kHz within 256 buckets. // We'll combine 8 buckets together to get a range of about 3.6kHz per Bucket. // The fist and the last Bucket are omitted ushort[] fftData = rawCall.FftData; if (fftData.Length != 256) { return(mergedCall); } for (int i = 0; i < rawCall.FftData.Length; i++) { tempFftData[i] += rawCall.FftData[i]; } mergedCall.Duration += rawCall.Duration; mergedCall.ClippedSamples += rawCall.ClippedSamples; mergedCall.MissedSamples += rawCall.MissedSamples; } AnalyzeFftData(mergedCall, tempFftData, rawCalls.Count); mergedCall.PowerData = powerData.ToArray(); mergedCall.AveragePower = (byte)Math.Round(mergedCall.PowerData.Where(p => p > 20).DefaultIfEmpty().Average(p => p)); mergedCall.MergeCount = rawCalls.Count; return(mergedCall); }
private void ReadCallRecordV1(RawNodeData log, BinaryReader reader) { RawCall rawCall = new RawCall(); rawCall.Duration = reader.ReadUInt32(); rawCall.StartTimeMs = reader.ReadUInt32(); rawCall.ClippedSamples = reader.ReadUInt16(); // Ignore Max Power reader.ReadUInt16(); rawCall.MissedSamples = reader.ReadUInt16(); rawCall.FftData = ReadUInt16Array(reader, 256); log.Calls.Add(rawCall); }
private void ReadCallRecordV2(RawNodeData log, BinaryReader reader) { RawCall rawCall = new RawCall(); rawCall.Duration = reader.ReadUInt32(); rawCall.StartTimeMs = reader.ReadUInt32(); rawCall.ClippedSamples = reader.ReadUInt16(); rawCall.MissedSamples = reader.ReadUInt16(); int powerDataLength = reader.ReadUInt16(); rawCall.PowerData = reader.ReadBytes(powerDataLength); rawCall.FftData = ReadUInt16Array(reader, 256); log.Calls.Add(rawCall); }
/// <summary>Attempts to add a <see cref="RawCall"/> to the Publisher's internal array and event(s)</summary> /// <param name="tCall">RawCall to add</param> /// <returns>True if successful</returns> public bool addCall(RawCall tCall) { if (tCall != null) { if (_calls == null) { _calls = new List <RawCall>(); } _calls.Add(tCall); effectsCallAdded(tCall); return(true); } return(false); }
/// <summary>Attempts to remove a <see cref="RawCall"/> from the Publisher's internal array</summary> /// <param name="tIndex">Index of <see cref="_calls"/> array to remove</param> /// <returns>True if successful</returns> public bool removeCall(int tIndex) { if (tIndex >= 0 && _calls != null && tIndex < _calls.Count) { RawCall tempCall = _calls[tIndex]; _calls.RemoveAt(tIndex); if (_calls.Count == 0) { _calls = null; } effectsCallRemoved(tempCall, tIndex); return(true); } return(false); }
/// <summary>Attempts to remove a <see cref="RawCall"/> from the Publisher's internal array and event(s)</summary> /// <param name="tCall">RawCall to remove</param> /// <returns>True if successful</returns> public bool removeCall(RawCall tCall) { return(tCall != null && _calls != null && removeCall(_calls.IndexOf(tCall))); }