| 255 | #endif |
| 256 | |
| 257 | int VectorBLFFilterPrivate::readDataFromFileCommonTime(const QString& fileName, int lines) { |
| 258 | PERFTRACE(QLatin1String(Q_FUNC_INFO)); |
| 259 | |
| 260 | if (!isValid(fileName)) { |
| 261 | q->setLastError(i18n("Invalid file.")); |
| 262 | return 0; |
| 263 | } |
| 264 | |
| 265 | const auto validStatus = m_dbcParser.isValid(); |
| 266 | if (validStatus != DbcParser::ParseStatus::Success) { |
| 267 | addWarningError({DBCParserParseStatusToVectorBLFStatus(validStatus), 0}); |
| 268 | return 0; |
| 269 | } |
| 270 | |
| 271 | if (m_parseState.ready && m_parseState.requestedLines == lines) |
| 272 | return m_parseState.readLines; |
| 273 | |
| 274 | m_DataContainer.clear(); |
| 275 | |
| 276 | #ifdef HAVE_VECTOR_BLF |
| 277 | Vector::BLF::File file; |
| 278 | file.open(fileName.toLocal8Bit().data()); |
| 279 | |
| 280 | // 1. Reading in messages |
| 281 | QVector<const Vector::BLF::ObjectHeaderBase*> objectHeaders; |
| 282 | QVector<uint32_t> ids; |
| 283 | int message_counter = 0; |
| 284 | { |
| 285 | PERFTRACE(QLatin1String(Q_FUNC_INFO) + QLatin1String("Parsing BLF file")); |
| 286 | Vector::BLF::ObjectHeaderBase* objectHeader = nullptr; |
| 287 | while (file.good() && ((lines >= 0 && message_counter < lines) || lines < 0)) { |
| 288 | try { |
| 289 | objectHeader = file.read(); |
| 290 | } catch (std::runtime_error& e) { DEBUG("Exception: " << e.what() << std::endl); } |
| 291 | if (objectHeader == nullptr) |
| 292 | break; |
| 293 | |
| 294 | if (objectHeader->objectType != Vector::BLF::ObjectType::CAN_MESSAGE2) |
| 295 | continue; |
| 296 | |
| 297 | int id; |
| 298 | if (objectHeader->objectType == Vector::BLF::ObjectType::CAN_MESSAGE2) { |
| 299 | const auto message = reinterpret_cast<Vector::BLF::CanMessage2*>(objectHeader); |
| 300 | id = message->id; |
| 301 | } else |
| 302 | return 0; |
| 303 | |
| 304 | objectHeaders.append(objectHeader); |
| 305 | if (!ids.contains(id)) |
| 306 | ids.append(id); |
| 307 | message_counter++; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | // 2. Create vector names |
| 312 | QHash<uint32_t, int> idIndexTable; |
| 313 | m_dbcParser.getSignals(ids, DbcParser::PrefixType::None, DbcParser::SuffixType::Unit, idIndexTable, m_signals); |
| 314 |
nothing calls this directly
no test coverage detected