ngscopeclient v0.1-rc1
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
296
299
308 {
309 m_offsets.CopyFrom(rhs->m_offsets);
310 m_durations.CopyFrom(rhs->m_durations);
311 }
312
313 void MarkTimestampsModifiedFromCpu()
314 {
317 }
318
319 void MarkTimestampsModifiedFromGpu()
320 {
323 }
324
325 virtual void MarkModifiedFromCpu() override
326 {
328 MarkTimestampsModifiedFromCpu();
329 }
330
331 virtual void MarkModifiedFromGpu() override
332 {
334 MarkTimestampsModifiedFromGpu();
335 }
336};
337
343{
344public:
346 {}
347
356 : WaveformBase(rhs)
357 {}
358
359 virtual ~UniformWaveformBase()
360 {}
361};
362
369template<class S>
371{
372public:
373
379 UniformWaveform(const std::string& name = "")
380 {
381 Rename(name);
382
383 //Default data to CPU/GPU mirror
387 }
388
389 virtual void Rename(const std::string& name = "") override
390 {
391 if(name.empty())
392 m_samples.SetName(std::string("UniformWaveform<") + typeid(S).name() + ">.m_samples");
393 else
394 m_samples.SetName(name + ".m_samples");
395 }
396
406 {
407 m_samples.SetName(std::string("UniformWaveform<") + typeid(S).name() + ">.m_samples");
408
409 m_samples.CopyFrom(rhs.m_samples);
410 }
411
412 virtual ~UniformWaveform()
413 {}
414
417
418 virtual void FreeGpuMemory() override
420
421 virtual bool HasGpuBuffer() override
422 { return m_samples.HasGpuBuffer(); }
423
424 virtual void Resize(size_t size) override
425 { m_samples.resize(size); }
426
427 virtual void Reserve(size_t size) override
429
430 virtual size_t size() const override
431 { return m_samples.size(); }
432
433 virtual void clear() override
434 { m_samples.clear(); }
435
436 virtual void PrepareForCpuAccess() override
438
439 virtual void PrepareForGpuAccess() override
441
442 virtual void MarkSamplesModifiedFromCpu() override
444
445 virtual void MarkSamplesModifiedFromGpu() override
447
448 virtual void MarkModifiedFromCpu() override
450
451 virtual void MarkModifiedFromGpu() override
453
460 { m_samples.SetGpuAccessHint(hint); }
461};
462
467template<class S>
469{
470public:
471
477 SparseWaveform(const std::string& name = "")
478 {
479 Rename(name);
480
481 //Default data to CPU/GPU mirror
485 }
486
487 virtual void Rename(const std::string& name = "") override
488 {
489 if(name.empty())
490 {
491 m_samples.SetName(std::string("UniformWaveform<") + typeid(S).name() + ">.m_samples");
492 m_offsets.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_offsets");
493 m_durations.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_durations");
494 }
495 else
496 {
497 m_samples.SetName(name + ".m_samples");
498 m_offsets.SetName(name + ".m_offsets");
499 m_durations.SetName(name + ".m_durations");
500 }
501 }
502
507 {
508 m_samples.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_samples");
509 m_offsets.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_offsets");
510 m_durations.SetName(std::string("SparseWaveform<") + typeid(S).name() + ">.m_durations");
511
515
516 //Copy sample data
517 Resize(rhs.size());
518 m_samples.CopyFrom(rhs.m_samples);
519
520 //Generate offset/duration values
521 //TODO: is it worth vectorizing this since this is mostly meant to be a compatibility layer?
522 for(size_t i=0; i<m_offsets.size(); i++)
523 {
524 m_offsets[i] = i;
525 m_durations[i] = 1;
526 }
527 }
528
529 virtual ~SparseWaveform()
530 {}
531
534
535 virtual void FreeGpuMemory() override
536 {
540 }
541
542 virtual bool HasGpuBuffer() override
544
545 virtual void Resize(size_t size) override
546 {
550 }
551
552 virtual void Reserve(size_t size) override
553 {
557 }
558
559 virtual size_t size() const override
560 { return m_samples.size(); }
561
562 virtual void clear() override
563 {
567 }
568
569 virtual void PrepareForCpuAccess() override
570 {
574 }
575
576 virtual void PrepareForGpuAccess() override
577 {
581 }
582
583 virtual void MarkSamplesModifiedFromCpu() override
585
586 virtual void MarkSamplesModifiedFromGpu() override
588
595 {
599 }
600};
601
607
608//Make sure inline helpers aren't warned about if unused
609#pragma GCC diagnostic push
610#pragma GCC diagnostic ignored "-Wunused-function"
611
612//Helper methods for identifying what a waveform is at compile time
613static bool IsWaveformUniform(const SparseWaveformBase* /*unused*/);
614static bool IsWaveformUniform(const UniformWaveformBase* /*unused*/);
615static int64_t GetOffset(const SparseWaveformBase* wfm, size_t i);
616static int64_t GetOffset(const UniformWaveformBase* /*wfm*/, size_t i);
617static int64_t GetDuration(const SparseWaveformBase* wfm, size_t i);
618static int64_t GetDuration(const UniformWaveformBase* /*wfm*/, size_t /*i*/);
619
624bool IsWaveformUniform(const SparseWaveformBase* /*unused*/)
625{ return false; }
626
631bool IsWaveformUniform(const UniformWaveformBase* /*unused*/)
632{ return true; }
633
634//Helper methods for weighted averaging of samples
635static float GetSampleTimesIndex(const UniformAnalogWaveform* wfm, ssize_t i);
636static float GetSampleTimesIndex(const SparseAnalogWaveform* wfm, ssize_t i);
637
645float GetSampleTimesIndex(const UniformAnalogWaveform* wfm, ssize_t i)
646{ return wfm->m_samples[i] * i; }
647
655float GetSampleTimesIndex(const SparseAnalogWaveform* wfm, ssize_t i)
656{ return wfm->m_samples[i] * wfm->m_offsets[i]; }
657
668int64_t GetOffset(const SparseWaveformBase* wfm, size_t i)
669{ return wfm->m_offsets[i]; }
670
681int64_t GetOffset(const UniformWaveformBase* /*wfm*/, size_t i)
682{ return i; }
683
693int64_t GetDuration(const SparseWaveformBase* wfm, size_t i)
694{ return wfm->m_durations[i]; }
695
705int64_t GetDuration(const UniformWaveformBase* /*wfm*/, size_t /*i*/)
706{ return 1; }
707
717template<class T>
718int64_t GetOffsetScaled(T* wfm, size_t i)
719{ return (GetOffset(wfm, i) * wfm->m_timescale) + wfm->m_triggerPhase; }
720
730template<class T>
731int64_t GetDurationScaled(T* wfm, size_t i)
732{ return GetDuration(wfm, i) * wfm->m_timescale; }
733
740static int64_t GetOffset(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
741
748static int64_t GetDuration(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
749
756static int64_t GetOffsetScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
757
764static int64_t GetDurationScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i);
765
766int64_t GetOffset(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
767{
768 if(sparse)
769 return GetOffset(sparse, i);
770 else
771 return GetOffset(uniform, i);
772}
773
774int64_t GetDuration(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
775{
776 if(sparse)
777 return GetDuration(sparse, i);
778 else
779 return GetDuration(uniform, i);
780}
781
782int64_t GetOffsetScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
783{
784 if(sparse)
785 return GetOffsetScaled(sparse, i);
786 else
787 return GetOffsetScaled(uniform, i);
788}
789
790int64_t GetDurationScaled(const SparseWaveformBase* sparse, const UniformWaveformBase* uniform, size_t i)
791{
792 if(sparse)
793 return GetDurationScaled(sparse, i);
794 else
795 return GetDurationScaled(uniform, i);
796}
797
804template<class T>
805static T GetValue(const SparseWaveform<T>* sparse, const UniformWaveform<T>* uniform, size_t i)
806{
807 if(sparse)
808 return sparse->m_samples[i];
809 else
810 return uniform->m_samples[i];
811}
812
813//Template helper methods for validating that an input is the correct type
814static void AssertTypeIsSparseWaveform(const SparseWaveformBase* /*unused*/);
815static void AssertTypeIsUniformWaveform(const UniformWaveformBase* /*unused*/);
816static void AssertTypeIsAnalogWaveform(const SparseAnalogWaveform* /*unused*/);
817static void AssertTypeIsAnalogWaveform(const UniformAnalogWaveform* /*unused*/);
818static void AssertTypeIsDigitalWaveform(const SparseDigitalWaveform* /*unused*/);
819static void AssertTypeIsDigitalWaveform(const UniformDigitalWaveform* /*unused*/);
820
821void AssertTypeIsSparseWaveform(const SparseWaveformBase* /*unused*/){}
822void AssertTypeIsUniformWaveform(const UniformWaveformBase* /*unused*/){}
823void AssertTypeIsAnalogWaveform(const SparseAnalogWaveform* /*unused*/){}
824void AssertTypeIsAnalogWaveform(const UniformAnalogWaveform* /*unused*/){}
825void AssertTypeIsDigitalWaveform(const SparseDigitalWaveform* /*unused*/){}
826void AssertTypeIsDigitalWaveform(const UniformDigitalWaveform* /*unused*/){}
827
828//Template helper methods for validating that two waveforms are the same sample type
829//(but either may be sparse or uniform)
830template<class T>
831void AssertSampleTypesAreSame(const SparseWaveform<T>* /*a*/, const SparseWaveform<T>* /*b*/)
832{}
833
834template<class T>
835void AssertSampleTypesAreSame(const SparseWaveform<T>* /*a*/, const UniformWaveform<T>* /*b*/)
836{}
837
838template<class T>
839void AssertSampleTypesAreSame(const UniformWaveform<T>* /*a*/, const SparseWaveform<T>* /*b*/)
840{}
841
842template<class T>
843void AssertSampleTypesAreSame(const UniformWaveform<T>* /*a*/, const UniformWaveform<T>* /*b*/)
844{}
845
850template<class T>
851size_t BinarySearchForGequal(T* buf, size_t len, T value);
852
863size_t GetIndexNearestAtOrBeforeTimestamp(WaveformBase* wfm, int64_t time_fs, bool& out_of_bounds);
864
870std::optional<float> GetValueAtTime(WaveformBase* waveform, int64_t time_fs, bool zero_hold_behavior);
871
876std::optional<bool> GetDigitalValueAtTime(WaveformBase* waveform, int64_t time_fs);
877
882std::optional<std::string> GetProtocolValueAtTime(WaveformBase* waveform, int64_t time_fs);
883
884#pragma GCC diagnostic pop
885
886#endif
Declaration of AcceleratorBuffer.
Declaration of AlignedAllocator.
void MarkModifiedFromGpu()
Marks the GPU-side copy of the buffer as modified.
Definition: AcceleratorBuffer.h:895
void MarkModifiedFromCpu()
Marks the CPU-side copy of the buffer as modified.
Definition: AcceleratorBuffer.h:884
void PrepareForCpuAccess()
Prepares the buffer to be accessed from the CPU.
Definition: AcceleratorBuffer.h:909
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:864
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:931
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:850
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:1121
void SetName(std::string name)
Sets the debug name for this buffer.
Definition: AcceleratorBuffer.h:1487
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
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:295
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:331
void CopyTimestamps(const SparseWaveformBase *rhs)
Copies offsets/durations from another waveform into this one.
Definition: Waveform.h:307
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:325
AcceleratorBuffer< int64_t > m_durations
Durations of each sample, in multiples of m_timescale.
Definition: Waveform.h:298
A waveform sampled at irregular intervals.
Definition: Waveform.h:469
virtual void Reserve(size_t size) override
Preallocates buffers without changing the usable size of the waveform.
Definition: Waveform.h:552
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:535
virtual void PrepareForCpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:569
virtual void clear() override
Remove all samples from this waveform.
Definition: Waveform.h:562
SparseWaveform(const std::string &name="")
Creates a new sparse waveform.
Definition: Waveform.h:477
virtual size_t size() const override
Returns the number of samples in this waveform.
Definition: Waveform.h:559
virtual void Rename(const std::string &name="") override
Assings a human readable name to the waveform for debug purposes.
Definition: Waveform.h:487
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:586
AcceleratorBuffer< S > m_samples
Sample data.
Definition: Waveform.h:533
virtual void PrepareForGpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:576
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:594
virtual void Resize(size_t size) override
Reallocates buffers so the waveform contains the specified number of samples.
Definition: Waveform.h:545
virtual bool HasGpuBuffer() override
Returns true if we have at least one buffer resident on the GPU.
Definition: Waveform.h:542
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:506
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:583
Base class for waveforms with data sampled at uniform intervals.
Definition: Waveform.h:343
UniformWaveformBase(const SparseWaveformBase &rhs)
Creates a uniform waveform as a copy of a sparse one.
Definition: Waveform.h:355
A waveform sampled at uniform intervals.
Definition: Waveform.h:371
AcceleratorBuffer< S > m_samples
Sample data.
Definition: Waveform.h:416
virtual void PrepareForCpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:436
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:445
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:459
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:404
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:451
virtual void Reserve(size_t size) override
Preallocates buffers without changing the usable size of the waveform.
Definition: Waveform.h:427
UniformWaveform(const std::string &name="")
Creates a new uniform waveform.
Definition: Waveform.h:379
virtual void PrepareForGpuAccess() override
Indicates that this waveform is going to be used by the CPU in the near future.
Definition: Waveform.h:439
virtual void clear() override
Remove all samples from this waveform.
Definition: Waveform.h:433
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:442
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:448
virtual size_t size() const override
Returns the number of samples in this waveform.
Definition: Waveform.h:430
virtual void Rename(const std::string &name="") override
Assings a human readable name to the waveform for debug purposes.
Definition: Waveform.h:389
virtual void Resize(size_t size) override
Reallocates buffers so the waveform contains the specified number of samples.
Definition: Waveform.h:424
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:418
virtual bool HasGpuBuffer() override
Returns true if we have at least one buffer resident on the GPU.
Definition: Waveform.h:421
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:731
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:718
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