MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / Init

Method Init

lib/mdflib/mdflib/src/writecache.cpp:30–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30void WriteCache::Init() {
31 StopWorkThread();
32 cache_.clear();
33 writer_.State( WriteState::Init);
34
35 const auto* header = writer_.Header();
36 if (header == nullptr) {
37 MDF_ERROR() << "No MDF header. Invalid use of function.";
38 return;
39 }
40
41 std::vector<const IDataGroup*> active_list;
42 for (IDataGroup* data_group : header->DataGroups()) {
43 if (data_group == nullptr) {
44 continue;
45 }
46 for (IChannelGroup* channel_group : data_group->ChannelGroups()) {
47 if (channel_group == nullptr ||
48 (channel_group->Flags() & CgFlag::VlsdChannel) != 0 ||
49 channel_group->NofSamples() > 0 ) {
50 continue;
51 }
52
53 switch( writer_.TypeOfWriter()) {
54 case MdfWriterType::MdfConverter:
55 cache_.emplace(data_group,
56 std::make_unique<ConverterSampleQueue>(writer_, *data_group));
57 break;
58
59 case MdfWriterType::MdfBusLogger:
60 case MdfWriterType::Mdf4Basic:
61 cache_.emplace(data_group,
62 std::make_unique<Writer4SampleQueue>(writer_, *data_group));
63 break;
64
65 case MdfWriterType::Mdf3Basic:
66 default:
67 cache_.emplace(data_group,
68 std::make_unique<SampleQueue>(writer_, *data_group));
69 break;
70 }
71 active_list.emplace_back();
72 break; // No need to check more CG groups
73 }
74 }
75
76 for (auto& [data_group1, sample_queue1] : cache_) {
77 if (sample_queue1) {
78 sample_queue1->NofDgBlocks(active_list.size());
79 }
80 }
81
82 // Start the working thread that handles the samples
83 writer_.State(WriteState::Init); // Waits for new samples
84 work_thread_ = std::thread(&WriteCache::WorkThread, this);
85
86}
87

Callers

nothing calls this directly

Calls 10

TypeOfWriterMethod · 0.80
NofDgBlocksMethod · 0.80
clearMethod · 0.45
StateMethod · 0.45
HeaderMethod · 0.45
DataGroupsMethod · 0.45
ChannelGroupsMethod · 0.45
FlagsMethod · 0.45
NofSamplesMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected