ngscopeclient v0.1
Waveform.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
37#ifndef Waveform_h
38#define Waveform_h
39
40#include <vector>
41#include <optional>
42#include <AlignedAllocator.h>
43
44#include "StandardColors.h"
45#include "AcceleratorBuffer.h"
46
59{
60public:
61
66 : m_timescale(0)
70 , m_flags(0)
71 , m_revision(0)
73 {
74 }
75
84 , m_flags(rhs.m_flags)
86 {}
87
88 //empty virtual destructor in case any derived classes need one
89 virtual ~WaveformBase()
90 {}
91
98 virtual void Rename(const std::string& name = "") = 0;
99
106 int64_t m_timescale;
107
110
113
126
130 uint8_t m_flags;
131
139 uint64_t m_revision;
140
143 {
146 };
147
149 virtual void clear() =0;
150
159 virtual void Resize(size_t size) =0;
160
164 virtual void Reserve(size_t size) =0;
165
167 virtual size_t size() const =0;
168
170 virtual bool empty()
171 { return size() == 0; }
172
180 virtual std::string GetText([[maybe_unused]] size_t i)
181 {
182 return "(unimplemented)";
183 }
184
192 virtual std::string GetColor(size_t /*i*/)
193 {
194 return StandardColors::colors[StandardColors::COLOR_ERROR];
195 }
196
204 virtual uint32_t GetColorCached(size_t i)
205 { return m_protocolColors[i]; }
206
212 virtual void PrepareForCpuAccess() =0;
213
219 virtual void PrepareForGpuAccess() =0;
220
224 virtual void MarkSamplesModifiedFromCpu() =0;
225
229 virtual void MarkSamplesModifiedFromGpu() =0;
230
234 virtual void MarkModifiedFromCpu() =0;
235
239 virtual void MarkModifiedFromGpu() =0;
240
241 virtual void CacheColors();
242
244 virtual void FreeGpuMemory() =0;
245
247 virtual bool HasGpuBuffer() =0;
248
249protected:
250
253
256};
257
258template<class S> class SparseWaveform;
259
272{
273public:
274
279 {
280 //Default timestamps to CPU/GPU mirror
283
286
289 }
290
291 virtual ~SparseWaveformBase()
292 {}
293
297 virtual void SetCpuOnlyHint()
298 {
301
304 }
305
308
311
320 {
321 m_offsets.CopyFrom(rhs->m_offsets);
322 m_durations.CopyFrom(rhs->m_durations);
323 }
324
325 void MarkTimestampsModifiedFromCpu()
326 {
329 }
330
331 void MarkTimestampsModifiedFromGpu()
332 {
335 }
336
337 virtual void MarkModifiedFromCpu() override
338 {
340 MarkTimestampsModifiedFromCpu();
341 }
342
343 virtual void MarkModifiedFromGpu() override
344 {
346 MarkTimestampsModifiedFromGpu();
347 }
348};
349
355{
356public:
358 {}
359
368 : WaveformBase(rhs)
369 {}
370
371 virtual ~UniformWaveformBase()
372 {}
373};
374
381template<class S>
383{
384public:
385
391 UniformWaveform(const std::string& name = "")
392 {
393 Rename(name);
394
395 //Default data to CPU/GPU mirror
399 }
400
401 virtual void Rename(const std::string& name = "") override
402 {
403 if(name.empty())
404 m_samples.SetName(std::string("UniformWaveform<") + typeid(S).name() + ">.m_samples");
405 else
406 m_samples.SetName(name + ".m_samples");
407 }
408
418 {
419 m_samples.SetName(std::string("UniformWaveform<") + typeid(S).name() + ">.m_samples");
420
421 m_samples.CopyFrom(rhs.m_samples);
422 }
423
424 virtual ~UniformWaveform()
425 {}
426
429
430 virtual void FreeGpuMemory() override
432
433 virtual bool HasGpuBuffer() override
434 { return m_samples.HasGpuBuffer(); }
435
436 virtual void Resize(size_t size) override
437 { m_samples.resize(size); }
438
439 virtual void Reserve(size_t size) override
441
442 virtual size_t size() const override
443 { return m_samples.size(); }
444
445 virtual void clear() override
446 { m_samples.clear(); }
447
448 virtual void PrepareForCpuAccess() override
450
451 virtual void PrepareForGpuAccess() override
453
454 virtual void MarkSamplesModifiedFromCpu() override
456
457 virtual void MarkSamplesModifiedFromGpu() override
459
460 virtual void MarkModifiedFromCpu() override
462
463 virtual void MarkModifiedFromGpu() override
465
472 { m_samples.SetGpuAccessHint(hint); }
473};
474
479template<class S>
481{
482public:
483
489 SparseWaveform(const std::string& name = "")
490 {
491 Rename(name);
492
493 //Default data to CPU/GPU mirror
497 }
498
499 virtual void Rename(const std::string& name = "") override
500 {
501 if(name.empty())
502 {
503 m_samples.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_samples");
504 m_offsets.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_offsets");
505 m_durations.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_durations");
506 }
507 else
508 {
509 m_samples.SetName(name + ".m_samples");
510 m_offsets.SetName(name + ".m_offsets");
511 m_durations.SetName(name + ".m_durations");
512 }
513 }
514
519 {
520 m_samples.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_samples");
521 m_offsets.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_offsets");
522 m_durations.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_durations");
523
527
528 //Copy sample data
529 Resize(rhs.size());
530 m_samples.CopyFrom(rhs.m_samples);
531
532 //Generate offset/duration values
533 //TODO: is it worth vectorizing this since this is mostly meant to be a compatibility layer?
534 for(size_t i=0; i<m_offsets.size(); i++)
535 {
536 m_offsets[i] = i;
537 m_durations[i] = 1;
538 }
539 }
540
541 virtual ~SparseWaveform()
542 {}
543
547 virtual void SetCpuOnlyHint() override
548 {
550
553 }
554
557
558 virtual void FreeGpuMemory() override
559 {
563 }
564
565 virtual bool HasGpuBuffer() override
567
568 virtual void Resize(size_t size) override
569 {
573 }
574
575 virtual void Reserve(size_t size) override
576 {
580 }
581
582 virtual size_t size() const override
583 { return m_samples.size(); }
584
585 virtual void clear() override
586 {
590 }
591
592 virtual void PrepareForCpuAccess() override
593 {
597 }
598
599 virtual void PrepareForGpuAccess() override
600 {
604 }
605
606 virtual void MarkSamplesModifiedFromCpu() override
608
609 virtual void MarkSamplesModifiedFromGpu() override
611
618 {
622 }
623};
624
630
631//Make sure inline helpers aren't warned about if unused
632#pragma GCC diagnostic push
633#pragma GCC diagnostic ignored "-Wunused-function"
634
635//Helper methods for identifying what a waveform is at compile time
636static bool IsWaveformUniform(const SparseWaveformBase* /*unused*/);
637static bool IsWaveformUniform(const UniformWaveformBase* /*unused*/);
638static int64_t GetOffset(const SparseWaveformBase* wfm, size_t i);
639static int64_t GetOffset(const UniformWaveformBase* /*wfm*/, size_t i);
640static int64_t GetDuration(const SparseWaveformBase* wfm, size_t i);
641static int64_t GetDuration(const UniformWaveformBase* /*wfm*/, size_t /*i*/);
642
647bool IsWaveformUniform(const SparseWaveformBase* /*unused*/)
648{ return false; }
649
654bool IsWaveformUniform(const UniformWaveformBase* /*unused*/)
655{ return true; }
656
657//Helper methods for weighted averaging of samples
658static float GetSampleTimesIndex(const UniformAnalogWaveform* wfm, ssize_t i);
659static float GetSampleTimesIndex(const SparseAnalogWaveform* wfm, ssize_t i);
660
668float GetSampleTimesIndex(const UniformAnalogWaveform* wfm, ssize_t i)
669{ return wfm->m_samples[i] * i; }
670
678float GetSampleTimesIndex(const SparseAnalogWaveform* wfm, ssize_t i)
679{ return wfm->m_samples[i] * wfm->m_offsets[i]; }
680
691int64_t GetOffset(const SparseWaveformBase* wfm, size_t i)
692{ return wfm->m_offsets[i]; }
693
704int64_t GetOffset(const UniformWaveformBase* /*wfm*/, size_t i)
705{ return i; }
706
716int64_t GetDuration(const SparseWaveformBase* wfm, size_t i)
717{ return wfm->m_durations[i]; }
718
728int64_t GetDuration(const UniformWaveformBase* /*wfm*/, size_t /*i*/)
729{ return 1; }
730
740template<class T>
741int64_t GetOffsetScaled(T* wfm, size_t i)
742{ return (GetOffset(wfm, i) * wfm->m_timescale) + wfm->m_triggerPhase; }
743
753template<class T>
754int64_t GetDurationScaled(T* wfm, size_t i)
755{ return GetDuration(wfm, i) * wfm->m_timescale; }
756
763static int64_t GetOffset(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
764
771static int64_t GetDuration(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
772
779static int64_t GetOffsetScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
780
787static int64_t GetDurationScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
788
789int64_t GetOffset(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
790{
791 if(sparse)
792 return GetOffset(sparse, i);
793 else
794 return GetOffset(uniform, i);
795}
796
797int64_t GetDuration(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
798{
799 if(sparse)
800 return GetDuration(sparse, i);
801 else
802 return GetDuration(uniform, i);
803}
804
805int64_t GetOffsetScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
806{
807 if(sparse)
808 return GetOffsetScaled(sparse, i);
809 else
810 return GetOffsetScaled(uniform, i);
811}
812
813int64_t GetDurationScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
814{
815 if(sparse)
816 return GetDurationScaled(sparse, i);
817 else
818 return GetDurationScaled(uniform, i);
819}
820
827template<class T>
828static T GetValue(const SparseWaveform<T>* sparse, const UniformWaveform<T>* uniform, size_t i)
829{
830 if(sparse)
831 return sparse->m_samples[i];
832 else
833 return uniform->m_samples[i];
834}
835
836//Template helper methods for validating that an input is the correct type
837static void AssertTypeIsSparseWaveform(const SparseWaveformBase* /*unused*/);
838static void AssertTypeIsUniformWaveform(const UniformWaveformBase* /*unused*/);
839static void AssertTypeIsAnalogWaveform(const SparseAnalogWaveform* /*unused*/);
840static void AssertTypeIsAnalogWaveform(const UniformAnalogWaveform* /*unused*/);
841static void AssertTypeIsDigitalWaveform(const SparseDigitalWaveform* /*unused*/);
842static void AssertTypeIsDigitalWaveform(const UniformDigitalWaveform* /*unused*/);
843
844void AssertTypeIsSparseWaveform(const SparseWaveformBase* /*unused*/){}
845void AssertTypeIsUniformWaveform(const UniformWaveformBase* /*unused*/){}
846void AssertTypeIsAnalogWaveform(const SparseAnalogWaveform* /*unused*/){}
847void AssertTypeIsAnalogWaveform(const UniformAnalogWaveform* /*unused*/){}
848void AssertTypeIsDigitalWaveform(const SparseDigitalWaveform* /*unused*/){}
849void AssertTypeIsDigitalWaveform(const UniformDigitalWaveform* /*unused*/){}
850
851//Template helper methods for validating that two waveforms are the same sample type
852//(but either may be sparse or uniform)
853template<class T>
854void AssertSampleTypesAreSame(const SparseWaveform<T>* /*a*/, const SparseWaveform<T>* /*b*/)
855{}
856
857template<class T>
858void AssertSampleTypesAreSame(const SparseWaveform<T>* /*a*/, const UniformWaveform<T>* /*b*/)
859{}
860
861template<class T>
862void AssertSampleTypesAreSame(const UniformWaveform<T>* /*a*/, const SparseWaveform<T>* /*b*/)
863{}
864
865template<class T>
866void AssertSampleTypesAreSame(const UniformWaveform<T>* /*a*/, const UniformWaveform<T>* /*b*/)
867{}
868
873template<class T>
874size_t BinarySearchForGequal(T* buf, size_t len, T value);
875
886size_t GetIndexNearestAtOrBeforeTimestamp(WaveformBase* wfm, int64_t time_fs, bool& out_of_bounds);
887
893std::optional<float> GetValueAtTime(WaveformBase* waveform, int64_t time_fs, bool zero_hold_behavior);
894
899std::optional<bool> GetDigitalValueAtTime(WaveformBase* waveform, int64_t time_fs);
900
905std::optional<std::string> GetProtocolValueAtTime(WaveformBase* waveform, int64_t time_fs);
906
907#pragma GCC diagnostic pop
908
909#endif
Declaration of AcceleratorBuffer.
Declaration of AlignedAllocator.
void MarkModifiedFromGpu()
Marks the GPU-side copy of the buffer as modified.
Definition: AcceleratorBuffer.h:905
void MarkModifiedFromCpu()
Marks the CPU-side copy of the buffer as modified.
Definition: AcceleratorBuffer.h:894
void PrepareForCpuAccess()
Prepares the buffer to be accessed from the CPU.
Definition: AcceleratorBuffer.h:919
void SetGpuAccessHint(UsageHint hint, bool reallocateImmediately=false)
Sets a hint to the buffer on how often we expect to use it on the GPU in the future.
Definition: AcceleratorBuffer.h:874
void resize(size_t size)
Change the usable size of the container.
Definition: AcceleratorBuffer.h:457
void reserve(size_t size)
Reallocates buffers so that at least size elements of storage are available.
Definition: AcceleratorBuffer.h:484
void PrepareForGpuAccess(bool outputOnly=false)
Prepares the buffer to be accessed from the GPU.
Definition: AcceleratorBuffer.h:941
void SetCpuAccessHint(UsageHint hint, bool reallocateImmediately=false)
Sets a hint to the buffer on how often we expect to use it on the CPU in the future.
Definition: AcceleratorBuffer.h:860
bool HasGpuBuffer() const
Returns true if there is currently a GPU-side buffer.
Definition: AcceleratorBuffer.h:415
void FreeGpuBuffer(bool dataLossOK=false)
Free the GPU-side buffer and underlying physical memory.
Definition: AcceleratorBuffer.h:1131
void SetName(std::string name)
Sets the debug name for this buffer.
Definition: AcceleratorBuffer.h:1497
void clear()
Resize the container to be empty (but don't free memory)
Definition: AcceleratorBuffer.h:478
Base class for waveforms with nonuniform sample rate.
Definition: Waveform.h:272
virtual void SetCpuOnlyHint()
Helper function to indicate this waveform will only be used on the CPU.
Definition: Waveform.h:297
SparseWaveformBase()
Constructs a new empty sparse waveform.
Definition: Waveform.h:278
AcceleratorBuffer< int64_t > m_offsets
Start timestamps of each sample, in multiples of m_timescale.
Definition: Waveform.h:307
virtual void MarkModifiedFromGpu() override
Indicates that this waveform's sample data and timestamps have been modified on the GPU and the CPU-s...
Definition: Waveform.h:343
void CopyTimestamps(const SparseWaveformBase *rhs)
Copies offsets/durations from another waveform into this one.
Definition: Waveform.h:319
virtual void MarkModifiedFromCpu() override
Indicates that this waveform's sample data and timestamps have been modified on the CPU and the GPU-s...
Definition: Waveform.h:337
AcceleratorBuffer< int64_t > m_durations
Durations of each sample, in multiples of m_timescale.
Definition: Waveform.h:310
A waveform sampled at irregular intervals.
Definition: Waveform.h:481
virtual void Reserve(size_t size) override
Preallocates buffers without changing the usable size of the waveform.
Definition: Waveform.h:575
virtual void FreeGpuMemory() override
Free GPU-side memory if we are short on VRAM or do not anticipate using this waveform for a while.
Definition: Waveform.h:558
virtual void PrepareForCpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:592
virtual void SetCpuOnlyHint() override
Helper function to indicate this waveform will only be used on the CPU.
Definition: Waveform.h:547
virtual void clear() override
Remove all samples from this waveform.
Definition: Waveform.h:585
SparseWaveform(const std::string &name="")
Creates a new sparse waveform.
Definition: Waveform.h:489
virtual size_t size() const override
Returns the number of samples in this waveform.
Definition: Waveform.h:582
virtual void Rename(const std::string &name="") override
Assings a human readable name to the waveform for debug purposes.
Definition: Waveform.h:499
virtual void MarkSamplesModifiedFromGpu() override
Indicates that this waveform's sample data has been modified on the GPU and the CPU-side copy is no l...
Definition: Waveform.h:609
AcceleratorBuffer< S > m_samples
Sample data.
Definition: Waveform.h:556
virtual void PrepareForGpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:599
void SetGpuAccessHint(enum AcceleratorBuffer< S >::UsageHint hint)
Passes a hint to the memory allocator about where our sample data is expected to be used.
Definition: Waveform.h:617
virtual void Resize(size_t size) override
Reallocates buffers so the waveform contains the specified number of samples.
Definition: Waveform.h:568
virtual bool HasGpuBuffer() override
Returns true if we have at least one buffer resident on the GPU.
Definition: Waveform.h:565
SparseWaveform(UniformWaveform< S > &rhs)
Constructs a sparse waveform as a copy of a uniform waveform, marking all samples as 1 timebase unit ...
Definition: Waveform.h:518
virtual void MarkSamplesModifiedFromCpu() override
Indicates that this waveform's sample data has been modified on the CPU and the GPU-side copy is no l...
Definition: Waveform.h:606
Base class for waveforms with data sampled at uniform intervals.
Definition: Waveform.h:355
UniformWaveformBase(const SparseWaveformBase &rhs)
Creates a uniform waveform as a copy of a sparse one.
Definition: Waveform.h:367
A waveform sampled at uniform intervals.
Definition: Waveform.h:383
AcceleratorBuffer< S > m_samples
Sample data.
Definition: Waveform.h:428
virtual void PrepareForCpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:448
virtual void MarkSamplesModifiedFromGpu() override
Indicates that this waveform's sample data has been modified on the GPU and the CPU-side copy is no l...
Definition: Waveform.h:457
void SetGpuAccessHint(enum AcceleratorBuffer< S >::UsageHint hint)
Passes a hint to the memory allocator about where our sample data is expected to be used.
Definition: Waveform.h:471
UniformWaveform(const SparseWaveform< S > &rhs)
Creates a uniform waveform as a copy of a sparse one which happens to be sampled at uniform rate.
Definition: Waveform.h:416
virtual void MarkModifiedFromGpu() override
Indicates that this waveform's sample data and timestamps have been modified on the GPU and the CPU-s...
Definition: Waveform.h:463
virtual void Reserve(size_t size) override
Preallocates buffers without changing the usable size of the waveform.
Definition: Waveform.h:439
UniformWaveform(const std::string &name="")
Creates a new uniform waveform.
Definition: Waveform.h:391
virtual void PrepareForGpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:451
virtual void clear() override
Remove all samples from this waveform.
Definition: Waveform.h:445
virtual void MarkSamplesModifiedFromCpu() override
Indicates that this waveform's sample data has been modified on the CPU and the GPU-side copy is no l...
Definition: Waveform.h:454
virtual void MarkModifiedFromCpu() override
Indicates that this waveform's sample data and timestamps have been modified on the CPU and the GPU-s...
Definition: Waveform.h:460
virtual size_t size() const override
Returns the number of samples in this waveform.
Definition: Waveform.h:442
virtual void Rename(const std::string &name="") override
Assings a human readable name to the waveform for debug purposes.
Definition: Waveform.h:401
virtual void Resize(size_t size) override
Reallocates buffers so the waveform contains the specified number of samples.
Definition: Waveform.h:436
virtual void FreeGpuMemory() override
Free GPU-side memory if we are short on VRAM or do not anticipate using this waveform for a while.
Definition: Waveform.h:430
virtual bool HasGpuBuffer() override
Returns true if we have at least one buffer resident on the GPU.
Definition: Waveform.h:433
Base class for all Waveform specializations.
Definition: Waveform.h:59
uint64_t m_revision
Revision number.
Definition: Waveform.h:139
virtual size_t size() const =0
Returns the number of samples in this waveform.
virtual uint32_t GetColorCached(size_t i)
Returns the packed RGBA32 color of a given protocol sample calculated by CacheColors()
Definition: Waveform.h:204
virtual void MarkModifiedFromCpu()=0
Indicates that this waveform's sample data and timestamps have been modified on the CPU and the GPU-s...
AcceleratorBuffer< uint32_t > m_protocolColors
Cache of packed RGBA32 data with colors for each protocol decode event. Empty for non-protocol wavefo...
Definition: Waveform.h:252
virtual void FreeGpuMemory()=0
Free GPU-side memory if we are short on VRAM or do not anticipate using this waveform for a while.
time_t m_startTimestamp
Start time of the acquisition, integer part.
Definition: Waveform.h:109
virtual void Rename(const std::string &name="")=0
Assings a human readable name to the waveform for debug purposes.
virtual void CacheColors()
Updates the cache of packed colors to avoid string parsing every frame.
Definition: Waveform.cpp:312
virtual void PrepareForCpuAccess()=0
Indicates that this waveform is going to be used by the CPU in the near future.
virtual void MarkSamplesModifiedFromCpu()=0
Indicates that this waveform's sample data has been modified on the CPU and the GPU-side copy is no l...
WaveformBase()
Creates an empty waveform.
Definition: Waveform.h:65
int64_t m_startFemtoseconds
Start time of the acquisition, fractional part (femtoseconds since since the UTC second)
Definition: Waveform.h:112
virtual std::string GetColor(size_t)
Returns the displayed color (in HTML #rrggbb or #rrggbbaa notation) of a given protocol sample.
Definition: Waveform.h:192
int64_t m_triggerPhase
Offset, in X axis units (usually femtoseconds), from the trigger to the sampling clock.
Definition: Waveform.h:125
virtual void Resize(size_t size)=0
Reallocates buffers so the waveform contains the specified number of samples.
virtual void clear()=0
Remove all samples from this waveform.
virtual bool HasGpuBuffer()=0
Returns true if we have at least one buffer resident on the GPU.
uint8_t m_flags
Flags that apply to this waveform. Bitfield containing zero or more WaveformFlags_t values.
Definition: Waveform.h:130
int64_t m_timescale
The time scale, in X axis units (usually femtoseconds) per timestep, used by this channel.
Definition: Waveform.h:106
virtual bool empty()
Returns true if this waveform contains no samples, false otherwise.
Definition: Waveform.h:170
WaveformBase(const WaveformBase &rhs)
Creates a waveform, copying metadata from another.
Definition: Waveform.h:79
WaveformFlags_t
Flags which may apply to m_flags.
Definition: Waveform.h:143
@ WAVEFORM_CLIPPING
Waveform amplitude exceeded ADC range, values were clipped.
Definition: Waveform.h:145
uint64_t m_cachedColorRevision
Revision we last cached colors of.
Definition: Waveform.h:255
virtual void Reserve(size_t size)=0
Preallocates buffers without changing the usable size of the waveform.
virtual void MarkModifiedFromGpu()=0
Indicates that this waveform's sample data and timestamps have been modified on the GPU and the CPU-s...
virtual std::string GetText(size_t i)
Returns the text representation of a given protocol sample.
Definition: Waveform.h:180
virtual void MarkSamplesModifiedFromGpu()=0
Indicates that this waveform's sample data has been modified on the GPU and the CPU-side copy is no l...
virtual void PrepareForGpuAccess()=0
Indicates that this waveform is going to be used by the CPU in the near future.
std::optional< bool > GetDigitalValueAtTime(WaveformBase *waveform, int64_t time_fs)
Gets the value of our channel at the specified timestamp (absolute, not waveform ticks).
Definition: Waveform.cpp:200
int64_t GetDurationScaled(T *wfm, size_t i)
Returns the duration of a sample, in X axis units.
Definition: Waveform.h:754
std::optional< std::string > GetProtocolValueAtTime(WaveformBase *waveform, int64_t time_fs)
Gets the value of our channel at the specified timestamp (absolute, not waveform ticks).
Definition: Waveform.cpp:230
size_t GetIndexNearestAtOrBeforeTimestamp(WaveformBase *wfm, int64_t time_fs, bool &out_of_bounds)
Find the index of the sample in a (possibly sparse) waveform that COULD include the time time_fs.
Definition: Waveform.cpp:94
size_t BinarySearchForGequal(T *buf, size_t len, T value)
Look for a value greater than or equal to "value" in buf and return the index.
Definition: Waveform.cpp:44
int64_t GetOffsetScaled(T *wfm, size_t i)
Returns the offset of a sample from the start of the waveform, in X axis units.
Definition: Waveform.h:741
std::optional< float > GetValueAtTime(WaveformBase *waveform, int64_t time_fs, bool zero_hold_behavior)
Gets the value of our channel at the specified timestamp (absolute, not waveform ticks) and interpola...
Definition: Waveform.cpp:159