ngscopeclient 0.1-dev+51fbda87c
Waveform.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2024 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
158 virtual void Resize(size_t size) =0;
159
161 virtual size_t size() const =0;
162
164 virtual bool empty()
165 { return size() == 0; }
166
174 virtual std::string GetText([[maybe_unused]] size_t i)
175 {
176 return "(unimplemented)";
177 }
178
186 virtual std::string GetColor(size_t /*i*/)
187 {
188 return StandardColors::colors[StandardColors::COLOR_ERROR];
189 }
190
198 virtual uint32_t GetColorCached(size_t i)
199 { return m_protocolColors[i]; }
200
206 virtual void PrepareForCpuAccess() =0;
207
213 virtual void PrepareForGpuAccess() =0;
214
218 virtual void MarkSamplesModifiedFromCpu() =0;
219
223 virtual void MarkSamplesModifiedFromGpu() =0;
224
228 virtual void MarkModifiedFromCpu() =0;
229
233 virtual void MarkModifiedFromGpu() =0;
234
235 virtual void CacheColors();
236
238 virtual void FreeGpuMemory() =0;
239
241 virtual bool HasGpuBuffer() =0;
242
243protected:
244
247
250};
251
252template<class S> class SparseWaveform;
253
266{
267public:
268
273 {
274 //Default timestamps to CPU/GPU mirror
277
280
283 }
284
285 virtual ~SparseWaveformBase()
286 {}
287
290
293
302 {
303 m_offsets.CopyFrom(rhs->m_offsets);
304 m_durations.CopyFrom(rhs->m_durations);
305 }
306
307 void MarkTimestampsModifiedFromCpu()
308 {
311 }
312
313 void MarkTimestampsModifiedFromGpu()
314 {
317 }
318
319 virtual void MarkModifiedFromCpu() override
320 {
322 MarkTimestampsModifiedFromCpu();
323 }
324
325 virtual void MarkModifiedFromGpu() override
326 {
328 MarkTimestampsModifiedFromGpu();
329 }
330};
331
337{
338public:
340 {}
341
350 : WaveformBase(rhs)
351 {}
352
353 virtual ~UniformWaveformBase()
354 {}
355};
356
363template<class S>
365{
366public:
367
373 UniformWaveform(const std::string& name = "")
374 {
375 Rename(name);
376
377 //Default data to CPU/GPU mirror
381 }
382
383 virtual void Rename(const std::string& name = "") override
384 {
385 if(name.empty())
386 m_samples.SetName(std::string("UniformWaveform<") + typeid(S).name() + ">.m_samples");
387 else
388 m_samples.SetName(name + ".m_samples");
389 }
390
400 {
401 m_samples.SetName(std::string("UniformWaveform<") + typeid(S).name() + ">.m_samples");
402
403 m_samples.CopyFrom(rhs.m_samples);
404 }
405
406 virtual ~UniformWaveform()
407 {}
408
411
412 virtual void FreeGpuMemory() override
414
415 virtual bool HasGpuBuffer() override
416 { return m_samples.HasGpuBuffer(); }
417
418 virtual void Resize(size_t size) override
419 { m_samples.resize(size); }
420
421 virtual size_t size() const override
422 { return m_samples.size(); }
423
424 virtual void clear() override
425 { m_samples.clear(); }
426
427 virtual void PrepareForCpuAccess() override
429
430 virtual void PrepareForGpuAccess() override
432
433 virtual void MarkSamplesModifiedFromCpu() override
435
436 virtual void MarkSamplesModifiedFromGpu() override
438
439 virtual void MarkModifiedFromCpu() override
441
442 virtual void MarkModifiedFromGpu() override
444
451 { m_samples.SetGpuAccessHint(hint); }
452};
453
458template<class S>
460{
461public:
462
468 SparseWaveform(const std::string& name = "")
469 {
470 Rename(name);
471
472 //Default data to CPU/GPU mirror
476 }
477
478 virtual void Rename(const std::string& name = "") override
479 {
480 if(name.empty())
481 {
482 m_samples.SetName(std::string("UniformWaveform<") + typeid(S).name() + ">.m_samples");
483 m_offsets.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_offsets");
484 m_durations.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_durations");
485 }
486 else
487 {
488 m_samples.SetName(name + ".m_samples");
489 m_offsets.SetName(name + ".m_offsets");
490 m_durations.SetName(name + ".m_durations");
491 }
492 }
493
498 {
499 m_samples.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_samples");
500 m_offsets.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_offsets");
501 m_durations.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_durations");
502
506
507 //Copy sample data
508 Resize(rhs.size());
509 m_samples.CopyFrom(rhs.m_samples);
510
511 //Generate offset/duration values
512 //TODO: is it worth vectorizing this since this is mostly meant to be a compatibility layer?
513 for(size_t i=0; i<m_offsets.size(); i++)
514 {
515 m_offsets[i] = i;
516 m_durations[i] = 1;
517 }
518 }
519
520 virtual ~SparseWaveform()
521 {}
522
525
526 virtual void FreeGpuMemory() override
527 {
531 }
532
533 virtual bool HasGpuBuffer() override
535
536 virtual void Resize(size_t size) override
537 {
541 }
542
543 virtual size_t size() const override
544 { return m_samples.size(); }
545
546 virtual void clear() override
547 {
551 }
552
553 virtual void PrepareForCpuAccess() override
554 {
558 }
559
560 virtual void PrepareForGpuAccess() override
561 {
565 }
566
567 virtual void MarkSamplesModifiedFromCpu() override
569
570 virtual void MarkSamplesModifiedFromGpu() override
572
579 {
583 }
584};
585
591
592//Make sure inline helpers aren't warned about if unused
593#pragma GCC diagnostic push
594#pragma GCC diagnostic ignored "-Wunused-function"
595
596//Helper methods for identifying what a waveform is at compile time
597static bool IsWaveformUniform(const SparseWaveformBase* /*unused*/);
598static bool IsWaveformUniform(const UniformWaveformBase* /*unused*/);
599static int64_t GetOffset(const SparseWaveformBase* wfm, size_t i);
600static int64_t GetOffset(const UniformWaveformBase* /*wfm*/, size_t i);
601static int64_t GetDuration(const SparseWaveformBase* wfm, size_t i);
602static int64_t GetDuration(const UniformWaveformBase* /*wfm*/, size_t /*i*/);
603
608bool IsWaveformUniform(const SparseWaveformBase* /*unused*/)
609{ return false; }
610
615bool IsWaveformUniform(const UniformWaveformBase* /*unused*/)
616{ return true; }
617
618//Helper methods for weighted averaging of samples
619static float GetSampleTimesIndex(const UniformAnalogWaveform* wfm, ssize_t i);
620static float GetSampleTimesIndex(const SparseAnalogWaveform* wfm, ssize_t i);
621
629float GetSampleTimesIndex(const UniformAnalogWaveform* wfm, ssize_t i)
630{ return wfm->m_samples[i] * i; }
631
639float GetSampleTimesIndex(const SparseAnalogWaveform* wfm, ssize_t i)
640{ return wfm->m_samples[i] * wfm->m_offsets[i]; }
641
652int64_t GetOffset(const SparseWaveformBase* wfm, size_t i)
653{ return wfm->m_offsets[i]; }
654
665int64_t GetOffset(const UniformWaveformBase* /*wfm*/, size_t i)
666{ return i; }
667
677int64_t GetDuration(const SparseWaveformBase* wfm, size_t i)
678{ return wfm->m_durations[i]; }
679
689int64_t GetDuration(const UniformWaveformBase* /*wfm*/, size_t /*i*/)
690{ return 1; }
691
701template<class T>
702int64_t GetOffsetScaled(T* wfm, size_t i)
703{ return (GetOffset(wfm, i) * wfm->m_timescale) + wfm->m_triggerPhase; }
704
714template<class T>
715int64_t GetDurationScaled(T* wfm, size_t i)
716{ return GetDuration(wfm, i) * wfm->m_timescale; }
717
724static int64_t GetOffset(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
725
732static int64_t GetDuration(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
733
740static int64_t GetOffsetScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
741
748static int64_t GetDurationScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
749
750int64_t GetOffset(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
751{
752 if(sparse)
753 return GetOffset(sparse, i);
754 else
755 return GetOffset(uniform, i);
756}
757
758int64_t GetDuration(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
759{
760 if(sparse)
761 return GetDuration(sparse, i);
762 else
763 return GetDuration(uniform, i);
764}
765
766int64_t GetOffsetScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
767{
768 if(sparse)
769 return GetOffsetScaled(sparse, i);
770 else
771 return GetOffsetScaled(uniform, i);
772}
773
774int64_t GetDurationScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
775{
776 if(sparse)
777 return GetDurationScaled(sparse, i);
778 else
779 return GetDurationScaled(uniform, i);
780}
781
788template<class T>
789static T GetValue(const SparseWaveform<T>* sparse, const UniformWaveform<T>* uniform, size_t i)
790{
791 if(sparse)
792 return sparse->m_samples[i];
793 else
794 return uniform->m_samples[i];
795}
796
797//Template helper methods for validating that an input is the correct type
798static void AssertTypeIsSparseWaveform(const SparseWaveformBase* /*unused*/);
799static void AssertTypeIsUniformWaveform(const UniformWaveformBase* /*unused*/);
800static void AssertTypeIsAnalogWaveform(const SparseAnalogWaveform* /*unused*/);
801static void AssertTypeIsAnalogWaveform(const UniformAnalogWaveform* /*unused*/);
802static void AssertTypeIsDigitalWaveform(const SparseDigitalWaveform* /*unused*/);
803static void AssertTypeIsDigitalWaveform(const UniformDigitalWaveform* /*unused*/);
804
805void AssertTypeIsSparseWaveform(const SparseWaveformBase* /*unused*/){}
806void AssertTypeIsUniformWaveform(const UniformWaveformBase* /*unused*/){}
807void AssertTypeIsAnalogWaveform(const SparseAnalogWaveform* /*unused*/){}
808void AssertTypeIsAnalogWaveform(const UniformAnalogWaveform* /*unused*/){}
809void AssertTypeIsDigitalWaveform(const SparseDigitalWaveform* /*unused*/){}
810void AssertTypeIsDigitalWaveform(const UniformDigitalWaveform* /*unused*/){}
811
812//Template helper methods for validating that two waveforms are the same sample type
813//(but either may be sparse or uniform)
814template<class T>
815void AssertSampleTypesAreSame(const SparseWaveform<T>* /*a*/, const SparseWaveform<T>* /*b*/)
816{}
817
818template<class T>
819void AssertSampleTypesAreSame(const SparseWaveform<T>* /*a*/, const UniformWaveform<T>* /*b*/)
820{}
821
822template<class T>
823void AssertSampleTypesAreSame(const UniformWaveform<T>* /*a*/, const SparseWaveform<T>* /*b*/)
824{}
825
826template<class T>
827void AssertSampleTypesAreSame(const UniformWaveform<T>* /*a*/, const UniformWaveform<T>* /*b*/)
828{}
829
834template<class T>
835size_t BinarySearchForGequal(T* buf, size_t len, T value);
836
847size_t GetIndexNearestAtOrBeforeTimestamp(WaveformBase* wfm, int64_t time_fs, bool& out_of_bounds);
848
854std::optional<float> GetValueAtTime(WaveformBase* waveform, int64_t time_fs, bool zero_hold_behavior);
855
860std::optional<bool> GetDigitalValueAtTime(WaveformBase* waveform, int64_t time_fs);
861
866std::optional<std::string> GetProtocolValueAtTime(WaveformBase* waveform, int64_t time_fs);
867
868#pragma GCC diagnostic pop
869
870#endif
Declaration of AcceleratorBuffer.
Declaration of AlignedAllocator.
void MarkModifiedFromGpu()
Marks the GPU-side copy of the buffer as modified.
Definition: AcceleratorBuffer.h:863
void MarkModifiedFromCpu()
Marks the CPU-side copy of the buffer as modified.
Definition: AcceleratorBuffer.h:852
void PrepareForCpuAccess()
Prepares the buffer to be accessed from the CPU.
Definition: AcceleratorBuffer.h:877
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:832
void resize(size_t size)
Change the usable size of the container.
Definition: AcceleratorBuffer.h:457
void PrepareForGpuAccess(bool outputOnly=false)
Prepares the buffer to be accessed from the GPU.
Definition: AcceleratorBuffer.h:899
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:818
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:1083
void SetName(std::string name)
Sets the debug name for this buffer.
Definition: AcceleratorBuffer.h:1444
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:266
SparseWaveformBase()
Constructs a new empty sparse waveform.
Definition: Waveform.h:272
AcceleratorBuffer< int64_t > m_offsets
Start timestamps of each sample, in multiples of m_timescale.
Definition: Waveform.h:289
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:325
void CopyTimestamps(const SparseWaveformBase *rhs)
Copies offsets/durations from another waveform into this one.
Definition: Waveform.h:301
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:319
AcceleratorBuffer< int64_t > m_durations
Durations of each sample, in multiples of m_timescale.
Definition: Waveform.h:292
A waveform sampled at irregular intervals.
Definition: Waveform.h:460
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:526
virtual void PrepareForCpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:553
virtual void clear() override
Remove all samples from this waveform.
Definition: Waveform.h:546
SparseWaveform(const std::string &name="")
Creates a new sparse waveform.
Definition: Waveform.h:468
virtual size_t size() const override
Returns the number of samples in this waveform.
Definition: Waveform.h:543
virtual void Rename(const std::string &name="") override
Assings a human readable name to the waveform for debug purposes.
Definition: Waveform.h:478
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:570
AcceleratorBuffer< S > m_samples
Sample data.
Definition: Waveform.h:524
virtual void PrepareForGpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:560
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:578
virtual void Resize(size_t size) override
Reallocates buffers so the waveform contains the specified number of samples.
Definition: Waveform.h:536
virtual bool HasGpuBuffer() override
Returns true if we have at least one buffer resident on the GPU.
Definition: Waveform.h:533
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:497
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:567
Base class for waveforms with data sampled at uniform intervals.
Definition: Waveform.h:337
UniformWaveformBase(const SparseWaveformBase &rhs)
Creates a uniform waveform as a copy of a sparse one.
Definition: Waveform.h:349
A waveform sampled at uniform intervals.
Definition: Waveform.h:365
AcceleratorBuffer< S > m_samples
Sample data.
Definition: Waveform.h:410
virtual void PrepareForCpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:427
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:436
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:450
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:398
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:442
UniformWaveform(const std::string &name="")
Creates a new uniform waveform.
Definition: Waveform.h:373
virtual void PrepareForGpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:430
virtual void clear() override
Remove all samples from this waveform.
Definition: Waveform.h:424
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:433
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:439
virtual size_t size() const override
Returns the number of samples in this waveform.
Definition: Waveform.h:421
virtual void Rename(const std::string &name="") override
Assings a human readable name to the waveform for debug purposes.
Definition: Waveform.h:383
virtual void Resize(size_t size) override
Reallocates buffers so the waveform contains the specified number of samples.
Definition: Waveform.h:418
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:412
virtual bool HasGpuBuffer() override
Returns true if we have at least one buffer resident on the GPU.
Definition: Waveform.h:415
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:198
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:246
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:186
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:164
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:249
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:174
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:715
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:702
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