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

Function cpp_example

lib/mdflib/mdflibrary_example/src/test.cpp:194–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192#include <mdflibrary/MdfReader.h>
193#include <mdflibrary/MdfWriter.h>
194void cpp_example() {
195 std::cout << "C++ example" << std::endl;
196 {
197
198 std::cout << "Write Basic" << std::endl;
199 MdfWriter Writer(MdfWriterType::Mdf4Basic, "test_cpp.mf4");
200 MdfHeader Header = Writer.GetHeader();
201 Header.SetAuthor("Caller");
202 Header.SetDepartment("Home Alone");
203 Header.SetDescription("Testing i");
204 Header.SetProject("Mdf3WriteHD");
205 Header.SetStartTime(1000);
206 Header.SetSubject("PXY");
207 MdfFileHistory History = Header.CreateFileHistory();
208 History.SetTime(1000000);
209 History.SetDescription("Initial stuff");
210 History.SetToolName("Unit Test");
211 History.SetToolVendor("ACME");
212 History.SetToolVersion("2.3");
213 History.SetUserName("Ducky");
214
215 MdfDataGroup dg = Writer.CreateDataGroup();
216 MdfChannelGroup cg = dg.CreateChannelGroup();
217 cg.SetName("Test");
218 cg.SetDescription("Test channel group");
219
220 MdfSourceInformation si = cg.CreateSourceInformation();
221 si.SetName("SI-Name");
222 si.SetPath("SI-Path");
223 si.SetDescription("SI-Desc");
224 si.SetType(SourceType::Bus);
225 si.SetBus(BusType::Can);
226
227 {
228 MdfChannel cn = cg.CreateChannel();
229 cn.SetName("Time");
230 cn.SetDescription("Time channel");
231 cn.SetType(ChannelType::Master);
232 cn.SetSync(ChannelSyncType::Time);
233 cn.SetDataType(ChannelDataType::FloatLe);
234 cn.SetDataBytes(4);
235 cn.SetUnit("s");
236 cn.SetRange(0, 100);
237 }
238
239 {
240 MdfChannel cn = cg.CreateChannel();
241 cn.SetName("SignedLe");
242 cn.SetDescription("int32_t");
243 cn.SetType(ChannelType::FixedLength);
244 cn.SetDataType(ChannelDataType::SignedIntegerLe);
245 cn.SetDataBytes(sizeof(int32_t));
246 }
247 {
248 MdfChannel cn = cg.CreateChannel();
249 cn.SetName("SignedBe");
250 cn.SetDescription("int8_t");
251 cn.SetType(ChannelType::FixedLength);

Callers 1

mainFunction · 0.85

Calls 15

MdfChannelObserverClass · 0.85
SetAuthorMethod · 0.80
SetDepartmentMethod · 0.80
SetProjectMethod · 0.80
SetStartTimeMethod · 0.80
SetSubjectMethod · 0.80
SetToolNameMethod · 0.80
SetToolVendorMethod · 0.80
SetToolVersionMethod · 0.80
SetUserNameMethod · 0.80
SetPathMethod · 0.80
SetBusMethod · 0.80

Tested by

no test coverage detected