MCPcopy Create free account
hub / github.com/Beckhoff/ADS / Print

Method Print

AdsLib/MasterDcStatAccess.cpp:36–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36long MasterDcStatAccess::Print(std::ostream &os) const
37{
38 uint32_t bytesRead;
39
40 struct {
41 uint32_t count;
42 uint32_t pos;
43 uint32_t neg;
44 uint32_t maxDiff;
45 uint32_t posArr[10];
46 uint32_t negArr[10];
47 } stat;
48
49 const auto status = device.ReadReqEx2(ECADS_IGRP_MASTER_DC_STAT, 0,
50 sizeof(stat), &stat, &bytesRead);
51
52 if (status == ADSERR_DEVICE_INVALIDSTATE) {
53 LOG_ERROR(
54 "Reading DC diagnosis failed with 0x"
55 << std::hex << status
56 << ". Try activating it first ('adstool dc-diag activate').");
57 return status;
58 } else if (status != ADSERR_NOERR) {
59 LOG_ERROR("Reading DC diagnosis failed with 0x" << std::hex
60 << status);
61 return status;
62 } else if (bytesRead != sizeof(stat)) {
63 LOG_ERROR(__FUNCTION__
64 << "Corrupt ECAT_DC_TIMING_STAT length.\n");
65 throw AdsException(ADSERR_DEVICE_INVALIDDATA);
66 }
67
68 const std::array<const std::string,
69 sizeof(stat.posArr) / sizeof(stat.posArr[0])>
70 rowNames{ {
71 "1", "2", "5", "10", "20", "50", "100", "200", "500",
72 "\u221E" // infinity symbol
73 } };
74
75 os << "Deviation <" << " | " << "Count (neg)" << " | " << "Count (pos)"
76 << '\n';
77 for (size_t i = 0; i < rowNames.size(); i++) {
78 os << rowNames[i] << " | " << stat.negArr[i] << " | "
79 << stat.posArr[i] << '\n';
80 }
81 os << "Sum" << " | " << stat.neg << " | " << stat.pos << '\n';
82
83 return status;
84}
85
86long MasterDcStatAccess::RunCommand(ECADS_IOFFS_MASTER_DC_STAT command) const
87{

Callers 1

RunDCDiagFunction · 0.80

Calls 3

AdsExceptionClass · 0.85
ReadReqEx2Method · 0.80
sizeMethod · 0.80

Tested by

no test coverage detected