MCPcopy Create free account
hub / github.com/BatchDrake/SigDigger / parseLine

Method parseLine

Components/RMSViewTab.cpp:111–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111bool
112RMSViewTab::parseLine(void)
113{
114 SUFLOAT mag, db;
115 QDateTime date;
116 long sec;
117 qreal usec;
118 qreal rate;
119 std::vector<std::string> fields;
120 std::istringstream iss(this->line);
121
122 // Description line allows commas and stuff
123 if (line.compare(0, 5, "DESC,") == 0) {
124 emit titleChanged(QString(line.c_str() + 5));
125 return true;
126 }
127
128 for (std::string token; std::getline(iss, token, ','); )
129 fields.push_back(std::move(token));
130
131 if (fields.size() == 2) {
132 if (fields[0] == "RATE") {
133 if (sscanf(fields[1].c_str(), "%lf", &rate) < 1)
134 return false;
135
136 this->rate = rate;
137 this->ui->waveform->setSampleRate(rate);
138 } else {
139 return false;
140 }
141 } else if (fields.size() == 4) {
142 if (sscanf(fields[0].c_str(), "%ld", &sec) < 1)
143 return false;
144 if (sscanf(fields[1].c_str(), "%lf", &usec) < 1)
145 return false;
146 if (sscanf(fields[2].c_str(), "%e", &mag) < 1)
147 return false;
148 if (sscanf(fields[3].c_str(), "%g", &db) < 1)
149 return false;
150
151 this->integrateMeasure(
152 static_cast<qreal>(sec) + usec,
153 mag);
154
155 if (this->data.size() > 0) {
156 date.setTime_t(static_cast<unsigned int>(this->last));
157 this->ui->lastLabel->setText("Last: " + date.toString());
158
159 if (this->data.size() == 1) {
160 this->first = this->last;
161 this->ui->sinceLabel->setText("Since: " + date.toString());
162 }
163 }
164 return true;
165 }
166
167 return false;
168}

Callers 1

processSocketDataMethod · 0.95

Calls 3

integrateMeasureMethod · 0.95
sizeMethod · 0.45
setSampleRateMethod · 0.45

Tested by

no test coverage detected