ngscopeclient v0.2.2
Loading...
Searching...
No Matches
Session.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* ngscopeclient *
4* *
5* Copyright (c) 2012-2026 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
35#ifndef Session_h
36#define Session_h
37
38class MainWindow;
39class WaveformArea;
41
42#include "../xptools/HzClock.h"
43#include "HistoryManager.h"
44#include "PacketManager.h"
45#include "PreferenceManager.h"
46#include "Marker.h"
47#include "TriggerGroup.h"
48
49extern std::atomic<int64_t> g_lastWaveformRenderTime;
50
51class Session;
52
54{
55public:
57 : m_shuttingDown(false)
59 {
60 args.shuttingDown = &m_shuttingDown;
61
62 //Can't initialize this in initializer list because we need args.shuttingDown set first
63 //cppcheck-suppress useInitializationList
64 m_thread = std::make_unique<std::thread>(InstrumentThread, args);
65 }
66
68 { Close(); }
69
70 void Close()
71 {
72 if(m_thread)
73 {
74 //Terminate the thread
75 m_shuttingDown = true;
76 m_thread->join();
77 }
78 m_thread = nullptr;
79 }
80
82 std::atomic<bool> m_shuttingDown;
83
85 std::unique_ptr<std::thread> m_thread;
86
89};
90
95{
96public:
97
98 bool operator()(const std::string& a, const std::string& b) const
99 {
100 size_t len = std::min(a.size(), b.size());
101
102 for(size_t i=0; i<len; i++)
103 {
104 auto ca = tolower(a[i]);
105 auto cb = tolower(b[i]);
106
107 if(ca > cb)
108 return false;
109 if(ca < cb)
110 return true;
111 }
112
113 if(a.size() < b.size())
114 return true;
115 return false;
116 }
117};
118
126{
127public:
129 virtual ~Session();
130
132
133 void ArmTrigger(TriggerGroup::TriggerType type, bool all=false);
134 void StopTrigger(bool all=false);
135 bool HasOnlineScopes();
136 void DownloadWaveforms();
137 bool CheckForWaveforms(vk::raii::CommandBuffer& cmdbuf);
138 void RefreshAllFilters();
141 bool RefreshDirtyFilters();
142 void FlushConfigCache();
143
145
146 void RenderWaveformTextures(
147 vk::raii::CommandBuffer& cmdbuf,
148 std::vector<std::shared_ptr<InputDescriptor> >& channels);
149
150 void Clear();
152
153 bool PreLoadFromYaml(const YAML::Node& node, const std::string& dataDir, bool online);
154 bool LoadFromYaml(const YAML::Node& node, const std::string& dataDir, bool online);
156 YAML::Node SerializeMetadata();
157 YAML::Node SerializeTriggerGroups();
158 bool LoadTriggerGroups(const YAML::Node& node);
159 YAML::Node SerializeFilterConfiguration();
160 YAML::Node SerializeMarkers();
161 bool SerializeWaveforms(const std::string& dataDir);
162 bool SerializeSparseWaveform(SparseWaveformBase* wfm, const std::string& path);
163 bool SerializeSparseWaveformV2(SparseWaveformBase* wfm, const std::string& path);
164 bool SerializeUniformWaveform(UniformWaveformBase* wfm, const std::string& path);
165
166 std::shared_ptr<PacketManager> AddPacketFilter(PacketDecoder* filter);
168
169 void AddInstrument(std::shared_ptr<Instrument> inst, bool createDialogs = true);
170 void RemoveInstrument(std::shared_ptr<Instrument> inst);
171 std::shared_ptr<InstrumentConnectionState> GetInstrumentConnectionState(std::shared_ptr<Instrument> inst) { return m_instrumentStates[inst]; }
172
173 bool IsMultiScope()
174 { return m_multiScope; }
175
176 MainWindow* GetMainWindow()
177 { return m_mainWindow; }
178
182 std::shared_ptr<OscilloscopeState> GetOscilloscopeState(std::shared_ptr<Oscilloscope> scope)
183 {
184 std::lock_guard<std::mutex> lock(m_scopeMutex);
185 if(m_oscilloscopes.find(scope) == m_oscilloscopes.end())
186 return nullptr;
187 return m_oscilloscopes[scope];
188 }
189
193 std::shared_ptr<BERTState> GetBERTState(std::shared_ptr<BERT> bert)
194 {
195 std::lock_guard<std::mutex> lock(m_scopeMutex);
196 if(m_berts.find(bert) == m_berts.end())
197 return nullptr;
198 return m_berts[bert];
199 }
200
204 std::shared_ptr<PowerSupplyState> GetPSUState(std::shared_ptr<SCPIPowerSupply> psu)
205 {
206 std::lock_guard<std::mutex> lock(m_scopeMutex);
207 if(m_psus.find(psu) == m_psus.end())
208 return nullptr;
209 return m_psus[psu];
210 }
211
215 std::shared_ptr<FunctionGeneratorState> GetFunctionGeneratorState(std::shared_ptr<FunctionGenerator> awg)
216 {
217 std::lock_guard<std::mutex> lock(m_scopeMutex);
218 if(m_awgs.find(awg) == m_awgs.end())
219 return nullptr;
220 return m_awgs[awg];
221 }
222
226 std::shared_ptr<MultimeterState> GetDmmState(std::shared_ptr<Multimeter> dmm)
227 {
228 std::lock_guard<std::mutex> lock(m_scopeMutex);
229 if(m_meters.find(dmm) == m_meters.end())
230 return nullptr;
231 return m_meters[dmm];
232 }
233
237 std::shared_ptr<PacketManager> GetPacketManager(PacketDecoder* filter)
238 {
239 std::lock_guard<std::mutex> lock(m_packetMgrMutex);
240
241 auto it = m_packetmgrs.find(filter);
242 if(it != m_packetmgrs.end())
243 return it->second;
244
245 else
246 {
247 LogWarning(
248 "No packet manager found for filter %s (this should never happen). "
249 "Creating a new one to avoid crashing\n",
250 filter->GetDisplayName().c_str());
251
252 auto ret = std::make_shared<PacketManager>(filter, *this);
254 return ret;
255 }
256 }
257
258 void ApplyPreferences(std::shared_ptr<Oscilloscope> scope);
259
260 size_t GetFilterCount();
261
262 bool IsChannelBeingDragged();
263
265
271
277
282 {
283 std::lock_guard<std::mutex> lock(m_perfClockMutex);
284 return m_waveformDownloadRate.GetAverageHz();
285 }
286
290 const std::vector<std::shared_ptr<Oscilloscope>> GetScopes()
291 {
292 std::lock_guard<std::mutex> lock(m_scopeMutex);
293 std::vector<std::shared_ptr<Oscilloscope>> scopes;
294 for(auto it : m_oscilloscopes)
295 {
296 scopes.push_back(it.first);
297 }
298 return scopes;
299 }
300
304 const std::vector<std::shared_ptr<BERT> > GetBERTs()
305 {
306 std::lock_guard<std::mutex> lock(m_scopeMutex);
307 std::vector<std::shared_ptr<BERT> > berts;
308 for(auto& it : m_berts)
309 berts.push_back(it.first);
310 return berts;
311 }
312
316 std::set<std::shared_ptr<SCPIInstrument>> GetSCPIInstruments();
317
321 std::set<std::shared_ptr<Instrument>> GetInstruments();
322
327 { return GetInstruments().size(); }
328
333
337 std::shared_mutex& GetWaveformDataMutex()
338 { return m_waveformDataMutex; }
339
345
349 void AddMarker(Marker m);
350
352
353 void ClearSweeps();
354
360
365
369 std::string m_generalNotes;
370
374 std::string m_setupNotes;
375
376 std::vector<std::shared_ptr<TriggerGroup> > GetTriggerGroups()
377 {
378 std::lock_guard<std::recursive_mutex> lock(m_triggerGroupMutex);
379 return m_triggerGroups;
380 }
381
383
384 void MakeNewTriggerGroup(std::shared_ptr<Oscilloscope> scope);
385 void MakeNewTriggerGroup(PausableFilter* filter);
386
387 int64_t GetDeskew(std::shared_ptr<Oscilloscope> scope)
388 { return m_scopeDeskewCal[scope]; }
389
390 void SetDeskew(std::shared_ptr<Oscilloscope> scope, int64_t skew)
392
393 bool IsPrimaryOfMultiScopeGroup(std::shared_ptr<Oscilloscope> scope);
394 bool IsSecondaryOfMultiScopeGroup(std::shared_ptr<Oscilloscope> scope);
395
396 std::shared_ptr<TriggerGroup> GetTriggerGroupForScope(std::shared_ptr<Oscilloscope> scope);
397 std::shared_ptr<TriggerGroup> GetTriggerGroupForFilter(PausableFilter* filter);
398
399 const ConfigWarningList& GetWarnings()
400 { return m_warnings; }
401
403 std::shared_ptr<LoadState> GetLoadState(std::shared_ptr<Load> load)
404 {
405 auto it = m_loads.find(load);
406 if(it != m_loads.end())
407 return it->second;
408 else
409 return nullptr;
410 }
411
412 std::shared_ptr<TriggerGroup> GetTrendFilterGroup();
413
414 void OnMarkerChanged();
415
417 std::map<FlowGraphNode*, int64_t> GetFilterGraphRuntime()
418 {
419 std::lock_guard<std::mutex> lock(m_lastFilterGraphRuntimeMutex);
421 }
422
423protected:
424 void UpdatePacketManagers(const std::set<FlowGraphNode*>& nodes, bool nodesListIsComplete);
425
426 std::string GetRegisteredTypeOfDriver(const std::string& drivername);
427
428 bool LoadInstruments(int version, const YAML::Node& node, bool online);
429 bool PreLoadInstruments(int version, const YAML::Node& node, bool online);
430 SCPITransport* CreateTransportForNode(const YAML::Node& node);
431 bool VerifyInstrument(const YAML::Node& node, std::shared_ptr<Instrument> inst);
432 bool PreLoadVNA(int version, const YAML::Node& node, bool online);
433 bool PreLoadOscilloscope(int version, const YAML::Node& node, bool online);
434 bool PreLoadPowerSupply(int version, const YAML::Node& node, bool online);
435 bool PreLoadRFSignalGenerator(int version, const YAML::Node& node, bool online);
436 bool PreLoadFunctionGenerator(int version, const YAML::Node& node, bool online);
437 bool PreLoadMultimeter(int version, const YAML::Node& node, bool online);
438 bool PreLoadSpectrometer(int version, const YAML::Node& node, bool online);
439 bool PreLoadSDR(int version, const YAML::Node& node, bool online);
440 bool PreLoadBERT(int version, const YAML::Node& node, bool online);
441 bool PreLoadLoad(int version, const YAML::Node& node, bool online);
442 bool PreLoadMisc(int version, const YAML::Node& node, bool online);
443 bool LoadFilters(int version, const YAML::Node& node);
444 bool LoadInstrumentInputs(int version, const YAML::Node& node);
445 bool LoadWaveformData(int version, const std::string& dataDir);
447 int version,
448 const YAML::Node& node,
449 std::shared_ptr<Oscilloscope> scope,
450 const std::string& dataDir);
452 int version,
453 const YAML::Node& node,
454 const std::string& dataDir);
455 void DoLoadWaveformDataForStream(WaveformBase* cap, const std::string& format, const std::string& fname);
457
460
463
465 std::map<std::shared_ptr<Oscilloscope>, int64_t> m_scopeDeskewCal;
466
468 std::mutex m_scopeMutex;
469
471 std::shared_mutex m_waveformDataMutex;
472
475
478
480 std::atomic<bool> m_shuttingDown;
481
484
486 std::map<std::shared_ptr<Oscilloscope>, std::shared_ptr<OscilloscopeState> > m_oscilloscopes;
487
489 std::map<std::shared_ptr<PowerSupply>, std::shared_ptr<PowerSupplyState> > m_psus;
490
492 std::map<std::shared_ptr<Multimeter>, std::shared_ptr<MultimeterState> > m_meters;
493
495 std::map<std::shared_ptr<Load>, std::shared_ptr<LoadState> > m_loads;
496
498 std::map<std::shared_ptr<BERT>, std::shared_ptr<BERTState> > m_berts;
499
501 std::map<std::shared_ptr<FunctionGenerator>, std::shared_ptr<FunctionGeneratorState> > m_awgs;
502
504 std::vector<std::shared_ptr<TriggerGroup> > m_triggerGroups;
505
507 std::shared_ptr<TriggerGroup> m_trendTriggerGroup;
508
510 std::recursive_mutex m_triggerGroupMutex;
511
513 std::map<std::shared_ptr<Instrument>, std::shared_ptr<InstrumentConnectionState> > m_instrumentStates;
514
516 std::unique_ptr<std::thread> m_waveformThread;
517
519 std::set<std::shared_ptr<Oscilloscope> > m_recentlyTriggeredScopes;
520
522 std::set<std::shared_ptr<TriggerGroup>> m_recentlyTriggeredGroups;
523
526
528 double m_tArm;
529
532
535
538
541
543 std::atomic<int64_t> m_lastFilterGraphExecTime;
544
547
549 std::map<FlowGraphNode*, int64_t> m_lastFilterGraphRuntimeStats;
550
553
556
559
562
564 std::map<PacketDecoder*, std::shared_ptr<PacketManager> > m_packetmgrs;
565
568
571
573 // Markers
574
576 std::map<TimePoint, std::vector<Marker> > m_markers;
577
580
582 // Partial graph refreshes
583
585 std::set<FlowGraphNode*> m_dirtyChannels;
586
589
590public:
591
595 std::string GetNextMarkerName()
596 { return std::string("M") + std::to_string(m_nextMarkerNum ++); }
597
601 std::vector<Marker>& GetMarkers(TimePoint t)
602 { return m_markers[t]; }
603
607 std::vector<TimePoint> GetMarkerTimes();
608
613 { m_markers.erase(t); }
614
616
617 std::set<FlowGraphNode*> GetAllGraphNodes();
618
620 std::optional<TimePoint> GetHoveredPacketTimestamp()
621 { return m_hoverTime; }
622
623 void SetHoveredPacketTimestamp(std::optional<TimePoint> t)
624 { m_hoverTime = t; }
625
626protected:
627 std::optional<TimePoint> m_hoverTime;
628
629public:
631 // End user preferences (persistent across sessions)
632
633 PreferenceManager& GetPreferences()
634 { return PreferenceManager::GetPreferences(); }
635
637 // Reference filters (used to query legal inputs to filters etc)
638
639public:
640
644 Filter* GetReferenceFilter(const std::string& name)
645 { return m_referenceFilters[name]; }
646
647 const std::map<std::string, Filter*, StringLessCaseInsensitive>& GetReferenceFilters()
648 { return m_referenceFilters; }
649
651 const std::vector<std::string>& GetDriverNamesForType(const std::string& type)
652 { return m_driverNamesByType[type]; }
653
655 const std::string& driver,
657 const std::string& nickname);
658
659protected:
662
663 std::map<std::string, Filter*, StringLessCaseInsensitive> m_referenceFilters;
664
666 std::map<std::string, std::vector<std::string> > m_driverNamesByType;
667};
668
669#endif
MemoryPressureLevel
Levels of memory pressure.
Definition AcceleratorBuffer.h:172
MemoryPressureType
Types of memory pressure.
Definition AcceleratorBuffer.h:189
Declaration of HistoryManager.
Declaration of Marker.
Declaration of PacketManager.
Stores and manages preference values.
std::atomic< int64_t > g_lastWaveformRenderTime
Time spent on the last cycle of waveform rendering shaders.
Definition WaveformThread.cpp:53
Declaration of TriggerGroup.
Definition AcceleratorBuffer.h:204
All warnings generated by a configuration we're in the process of loading.
Definition ConfigWarningList.h:90
Context data for a single channel being displayed within a WaveformArea.
Definition WaveformArea.h:204
Execution manager / scheduler for the filter graph.
Definition FilterGraphExecutor.h:107
Abstract base class for all filter graph blocks which are not physical instrument channels.
Definition Filter.h:105
Keeps track of recently acquired waveforms.
Definition HistoryManager.h:73
Clock that measures rate at which it is called; windowed average.
Definition HzClock.h:52
Bidirectional table mapping integer IDs in scopesession files to object pointers.
Definition IDTable.h:49
A single channel of an instrument.
Definition InstrumentChannel.h:63
Definition Session.h:54
std::unique_ptr< std::thread > m_thread
Thread for polling the instrument.
Definition Session.h:85
Oscilloscope::TriggerMode m_lastTriggerState
Cached trigger state, to reflect in the UI.
Definition Session.h:88
std::atomic< bool > m_shuttingDown
Termination flag for shutting down the polling thread.
Definition Session.h:82
Definition ngscopeclient.h:59
Top level application window.
Definition MainWindow.h:168
Data for a marker.
Definition Marker.h:85
TriggerMode
Definition Oscilloscope.h:398
@ TRIGGER_MODE_WAIT
WAIT - not yet fully armed.
Definition Oscilloscope.h:409
Definition PacketDecoder.h:85
A filter which may be started and stopped.
Definition PausableFilter.h:46
Definition PreferenceManager.h:45
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition SCPITransport.h:53
A Session stores all of the instrument configuration and other state the user has open.
Definition Session.h:126
std::map< std::shared_ptr< BERT >, std::shared_ptr< BERTState > > m_berts
BERTs we are currently connected to.
Definition Session.h:498
bool PreLoadFromYaml(const YAML::Node &node, const std::string &dataDir, bool online)
Perform partial loading and check for potentially dangerous configurations.
Definition Session.cpp:353
int64_t GetToneMapTime()
Gets the last execution time of the tone mapping shaders.
Definition Session.cpp:3845
std::shared_ptr< LoadState > GetLoadState(std::shared_ptr< Load > load)
Get the state for a load.
Definition Session.h:403
const std::vector< std::string > & GetDriverNamesForType(const std::string &type)
Get all of the drivers of a given type.
Definition Session.h:651
void RemoveMarkers(TimePoint t)
Deletes markers for a waveform timestamp.
Definition Session.h:612
std::map< PacketDecoder *, std::shared_ptr< PacketManager > > m_packetmgrs
Historical packet data from filters.
Definition Session.h:564
double m_tArm
Time we last armed the global trigger.
Definition Session.h:528
std::unique_ptr< std::thread > m_waveformThread
Processing thread for waveform data.
Definition Session.h:516
std::string GetNextMarkerName()
Generate an automatic name for a newly created marker.
Definition Session.h:595
std::mutex m_recentlyTriggeredScopeMutex
Mutex to synchronize access to m_recentlyTriggeredScopes.
Definition Session.h:525
std::vector< std::shared_ptr< TriggerGroup > > m_triggerGroups
Trigger groups for syncing oscilloscopes.
Definition Session.h:504
std::map< std::shared_ptr< FunctionGenerator >, std::shared_ptr< FunctionGeneratorState > > m_awgs
Function generator we are currently connected to.
Definition Session.h:501
bool HasOnlineScopes()
Returns true if we have at least one scope that isn't offline.
Definition Session.cpp:3475
int64_t GetFilterGraphExecTime()
Gets the last execution time of the filter graph.
Definition Session.h:269
std::shared_ptr< FunctionGeneratorState > GetFunctionGeneratorState(std::shared_ptr< FunctionGenerator > awg)
Returns a pointer to the state for a function generator.
Definition Session.h:215
bool SerializeSparseWaveform(SparseWaveformBase *wfm, const std::string &path)
Saves waveform sample data in the "sparsev1" file format.
Definition Session.cpp:2729
bool LoadFromYaml(const YAML::Node &node, const std::string &dataDir, bool online)
Deserialize a YAML::Node (and associated data directory) to the current session.
Definition Session.cpp:386
HistoryManager & GetHistory()
Get our history manager.
Definition Session.h:343
ConfigWarningList m_warnings
Warnings generated by loading the current file.
Definition Session.h:462
void StartWaveformThreadIfNeeded()
Starts the WaveformThread if we don't already have one.
Definition Session.cpp:3116
HzClock m_waveformDownloadRate
Frequency at which we are pulling waveforms off of scopes.
Definition Session.h:555
void RefreshAllFiltersNonblocking()
Queues a request to refresh all filters the next time we poll stuff.
Definition Session.cpp:3617
std::shared_ptr< PacketManager > AddPacketFilter(PacketDecoder *filter)
Called when a new packet filter is created.
Definition Session.cpp:3820
std::recursive_mutex m_triggerGroupMutex
Mutex controlling access to m_triggerGroups.
Definition Session.h:510
std::shared_ptr< MultimeterState > GetDmmState(std::shared_ptr< Multimeter > dmm)
Returns a pointer to the state for a Digital Multimeter.
Definition Session.h:226
void Clear()
Clears all session state and returns the object to an empty state.
Definition Session.cpp:197
void RefreshDirtyFiltersNonblocking()
Queues a request to refresh dirty filters the next time we poll stuff.
Definition Session.cpp:3627
std::shared_ptr< PowerSupplyState > GetPSUState(std::shared_ptr< SCPIPowerSupply > psu)
Returns a pointer to the state for a power supply.
Definition Session.h:204
std::optional< TimePoint > GetHoveredPacketTimestamp()
Returns the timestamp of the protocol analyzer event that the mouse is over, if any.
Definition Session.h:620
void AddInstrument(std::shared_ptr< Instrument > inst, bool createDialogs=true)
Adds a new instrument to the session.
Definition Session.cpp:3199
bool LoadWaveformDataForFilters(int version, const YAML::Node &node, const std::string &dataDir)
Loads waveform data for filters that need to be preserved.
Definition Session.cpp:563
std::shared_ptr< PacketManager > GetPacketManager(PacketDecoder *filter)
Returns a pointer to the existing packet manager for a protocol decode filter.
Definition Session.h:237
std::mutex m_lastFilterGraphRuntimeMutex
Mutex for controlling access to m_lastFilterGraphRuntimeStats.
Definition Session.h:546
void AddMarker(Marker m)
Adds a marker.
Definition Session.cpp:304
std::set< std::shared_ptr< Instrument > > GetInstruments()
Gets the set of all instruments we're connect to (regardless of type)
Definition Session.cpp:3381
std::mutex m_dirtyChannelsMutex
Mutex controlling access to m_dirtyChannels.
Definition Session.h:588
bool m_multiScope
True if we have >1 oscilloscope.
Definition Session.h:570
FilterGraphExecutor m_graphExecutor
Context for filter graph evaluation.
Definition Session.h:540
void RemovePacketFilter(PacketDecoder *filter)
Removes the packet manager for a filter (typically called when deleting it from the graph editor)
Definition Session.cpp:3806
bool SerializeUniformWaveform(UniformWaveformBase *wfm, const std::string &path)
Saves waveform sample data in the "densev1" file format.
Definition Session.cpp:2879
std::map< FlowGraphNode *, int64_t > GetFilterGraphRuntime()
Return the last filter graph runtime stats.
Definition Session.h:417
bool CheckForPendingWaveforms()
Check if we have data available from all of our scopes.
Definition Session.cpp:3485
void StopTrigger(bool all=false)
Stop the trigger for the session.
Definition Session.cpp:3459
std::atomic< int64_t > m_lastFilterGraphExecTime
Time spent on the last filter graph execution.
Definition Session.h:543
std::map< std::shared_ptr< Oscilloscope >, std::shared_ptr< OscilloscopeState > > m_oscilloscopes
Oscilloscopes we are currently connected to.
Definition Session.h:486
YAML::Node SerializeInstrumentConfiguration()
Serialize the configuration for all oscilloscopes.
Definition Session.cpp:2282
std::shared_mutex & GetWaveformDataMutex()
Get the mutex controlling access to waveform data.
Definition Session.h:337
void GarbageCollectTriggerGroups()
Remove trigger groups with no instruments in them.
Definition Session.cpp:2949
std::vector< TimePoint > GetMarkerTimes()
Get a list of timestamps for markers.
Definition Session.cpp:295
std::set< std::shared_ptr< SCPIInstrument > > GetSCPIInstruments()
Gets the set of all SCPI instruments we're connect to (regardless of type)
Definition Session.cpp:3331
YAML::Node SerializeFilterConfiguration()
Serialize the configuration for all protocol decoders.
Definition Session.cpp:2305
bool m_triggerArmed
Indicates trigger is armed (incoming waveforms are ignored if not armed)
Definition Session.h:534
std::atomic< bool > m_shuttingDown
Flag for shutting down all scope threads when we exit.
Definition Session.h:480
void ClearBackgroundThreads()
Terminate all background threads for instruments.
Definition Session.cpp:131
MainWindow * m_mainWindow
Top level UI window.
Definition Session.h:477
std::set< FlowGraphNode * > m_dirtyChannels
Set of dirty channels.
Definition Session.h:585
std::vector< Marker > & GetMarkers(TimePoint t)
Get the markers for a given waveform timestamp.
Definition Session.h:601
void RemoveInstrument(std::shared_ptr< Instrument > inst)
Removes an instrument from the session.
Definition Session.cpp:3293
void OnMarkerChanged()
Called when a marker is added, removed, or modified.
Definition Session.cpp:328
std::map< std::shared_ptr< Oscilloscope >, int64_t > m_scopeDeskewCal
Deskew correction coefficients for multi-scope.
Definition Session.h:465
std::string m_setupNotes
Session notes about the experimental setup.
Definition Session.h:374
void RemovePackets(TimePoint t)
Deletes packets from our packet managers for a waveform timestamp.
Definition Session.cpp:3833
bool OnMemoryPressure(MemoryPressureLevel level, MemoryPressureType type, size_t requestedSize)
Handler for low memory conditions.
Definition Session.cpp:3894
void DownloadWaveforms()
Pull the waveform data out of the queue and make it current.
Definition Session.cpp:3508
Filter * GetReferenceFilter(const std::string &name)
Gets the reference instance of a given filter.
Definition Session.h:644
bool m_triggerOneShot
If true, trigger is currently armed in single-shot mode.
Definition Session.h:537
std::map< std::shared_ptr< Multimeter >, std::shared_ptr< MultimeterState > > m_meters
Multimeters we are currently connected to.
Definition Session.h:492
YAML::Node SerializeMetadata()
Serializes metadata about the session / software stack.
Definition Session.cpp:2324
std::set< std::shared_ptr< Oscilloscope > > m_recentlyTriggeredScopes
Scopes whose data is currently being processed for history.
Definition Session.h:519
bool CreateAndAddInstrument(const std::string &driver, SCPITransport *transport, const std::string &nickname)
Creates a new instrument and adds it to the session.
Definition Session.cpp:3126
double GetWaveformDownloadRate()
Gets the average rate at which we are pulling waveforms off the scope, in Hz.
Definition Session.h:281
bool ConvertLegacyUniformWaveforms()
Check for any legacy waveforms stored in sparsev1 format that are actually uniform.
Definition Session.cpp:511
std::map< std::shared_ptr< Load >, std::shared_ptr< LoadState > > m_loads
Loads we are currently connected to.
Definition Session.h:495
std::string m_generalNotes
Session notes.
Definition Session.h:369
bool LoadWaveformDataForScope(int version, const YAML::Node &node, std::shared_ptr< Oscilloscope > scope, const std::string &dataDir)
Loads waveform data for a single scope.
Definition Session.cpp:646
std::mutex m_filterUpdatingMutex
Mutex for controlling access to filter graph.
Definition Session.h:474
std::mutex & GetRasterizedWaveformMutex()
Get the mutex controlling access to rasterized waveforms.
Definition Session.h:358
std::mutex m_packetMgrMutex
Mutex for controlling access to m_packetmgrs.
Definition Session.h:561
std::shared_ptr< TriggerGroup > GetTriggerGroupForFilter(PausableFilter *filter)
Gets the trigger group that contains a specified filter.
Definition Session.cpp:3043
std::map< std::string, std::vector< std::string > > m_driverNamesByType
Map of "type" to drivername[].
Definition Session.h:666
std::mutex m_rasterizedWaveformMutex
Mutex for controlling access to rasterized waveforms.
Definition Session.h:567
size_t GetInstrumentCount()
Get the number of instruments we're connected to (regardless of type)
Definition Session.h:326
std::set< FlowGraphNode * > GetAllGraphNodes()
Gets all of our graph nodes (filters plus instrument channels)
Definition Session.cpp:3641
int m_fileLoadVersion
Version of the file being loaded.
Definition Session.h:459
std::shared_ptr< TriggerGroup > m_trendTriggerGroup
Trigger group dedicated to trend filters.
Definition Session.h:507
void MarkChannelDirty(InstrumentChannel *chan)
Flags a single channel as dirty (updated outside of a global trigger event)
Definition Session.cpp:3745
std::shared_ptr< TriggerGroup > GetTriggerGroupForScope(std::shared_ptr< Oscilloscope > scope)
Gets the trigger group that contains a specified scope.
Definition Session.cpp:3020
std::map< FlowGraphNode *, int64_t > m_lastFilterGraphRuntimeStats
Performance stats from last graph execution.
Definition Session.h:549
std::map< std::shared_ptr< PowerSupply >, std::shared_ptr< PowerSupplyState > > m_psus
Power supplies we are currently connected to.
Definition Session.h:489
const std::vector< std::shared_ptr< Oscilloscope > > GetScopes()
Get the set of scopes we're currently connected to.
Definition Session.h:290
int m_nextMarkerNum
Number for next autogenerated waveform name.
Definition Session.h:579
int64_t GetLastWaveformRenderTime()
Gets the last run time of the waveform rendering shaders.
Definition Session.h:275
IDTable m_idtable
ID mapping used for serialization.
Definition Session.h:364
bool CheckForWaveforms(vk::raii::CommandBuffer &cmdbuf)
Check if new waveform data has arrived.
Definition Session.cpp:3551
std::map< TimePoint, std::vector< Marker > > m_markers
Map of waveform timestamps to markers.
Definition Session.h:576
const std::vector< std::shared_ptr< BERT > > GetBERTs()
Get the set of BERTs we're currently connected to.
Definition Session.h:304
void ArmTrigger(TriggerGroup::TriggerType type, bool all=false)
Arms the trigger for all trigger groups.
Definition Session.cpp:3412
void UpdatePacketManagers(const std::set< FlowGraphNode * > &nodes, bool nodesListIsComplete)
Update all of the packet managers when new data arrives.
Definition Session.cpp:3776
std::set< std::shared_ptr< TriggerGroup > > m_recentlyTriggeredGroups
Groups whose data is currently being processed.
Definition Session.h:522
HistoryManager m_history
Historical waveform data.
Definition Session.h:558
std::mutex m_scopeMutex
Mutex for controlling access to scope vectors.
Definition Session.h:468
bool IsSecondaryOfMultiScopeGroup(std::shared_ptr< Oscilloscope > scope)
Check if a scope is a secondary within a multiscope group.
Definition Session.cpp:2999
std::map< std::shared_ptr< Instrument >, std::shared_ptr< InstrumentConnectionState > > m_instrumentStates
Worker threads and other bookkeeping metadata for instruments.
Definition Session.h:513
std::shared_ptr< BERTState > GetBERTState(std::shared_ptr< BERT > bert)
Returns a pointer to the state for a BERT.
Definition Session.h:193
void DestroyReferenceFilters()
Destroys the reference filters.
Definition Session.cpp:3884
bool m_modifiedSinceLastSave
True if the session has been modified since last time it was saved.
Definition Session.h:483
bool SerializeSparseWaveformV2(SparseWaveformBase *wfm, const std::string &path)
Saves waveform sample data in the "sparsev2" file format.
Definition Session.cpp:2676
std::shared_ptr< OscilloscopeState > GetOscilloscopeState(std::shared_ptr< Oscilloscope > scope)
Returns a pointer to the state for a function generator.
Definition Session.h:182
std::string GetRegisteredTypeOfDriver(const std::string &drivername)
Performs an exhaustive search of the driver list to see which type this instrument is.
Definition Session.cpp:1100
void ClearSweeps()
Clear state on all of our filters.
Definition Session.cpp:3754
std::shared_mutex m_waveformDataMutex
Mutex for controlling access to waveform data.
Definition Session.h:471
bool IsPrimaryOfMultiScopeGroup(std::shared_ptr< Oscilloscope > scope)
Check if a scope is the primary of a group containing at least one other scope.
Definition Session.cpp:2985
std::mutex m_perfClockMutex
Mutex for controlling access to performance counters.
Definition Session.h:552
double m_tPrimaryTrigger
Time that the primary scope triggered (in multi-scope setups)
Definition Session.h:531
void CreateReferenceFilters()
Creates one filter of each known type to use as a reference for what inputs are legal to use to a new...
Definition Session.cpp:3861
bool RefreshDirtyFilters()
Refresh dirty filters (and anything in their downstream influence cone)
Definition Session.cpp:3689
Base class for waveforms with nonuniform sample rate.
Definition Waveform.h:293
Case insensitive map helper.
Definition Session.h:95
A timestamp, measured in seconds + femtoseconds.
Definition Marker.h:42
Base class for waveforms with data sampled at uniform intervals.
Definition Waveform.h:376
A WaveformArea is a plot that displays one or more OscilloscopeChannel's worth of data.
Definition WaveformArea.h:464
Base class for all Waveform specializations.
Definition Waveform.h:59