Exemple #1
0
	TrackData load (const CylHead &cylhead, bool /*first_read*/) override
	{
		FluxData flux_revs;

		auto it = m_data.find(cylhead);
		if (it == m_data.end())
			return TrackData(cylhead);

		for (auto &rev_times : it->second)
		{
			std::vector<uint32_t> flux_times;
			flux_times.reserve(rev_times.size());

			uint32_t total_time = 0;
			for (auto time : rev_times)	// note: big endian times!
			{
				if (!time)
					total_time += 0x10000;
				else
				{
					total_time += util::betoh(time);
					flux_times.push_back(total_time * 25);	// 25ns sampling time
					total_time = 0;
				}
			}

			flux_revs.push_back(std::move(flux_times));
		}

		return TrackData(cylhead, std::move(flux_revs));
	}
Exemple #2
0
bool IGCParser::loadFile(QFile *file)
{
	qint64 len;
	char line[76 + 2 + 1 + 1];
	bool route = false, track = false;


	_errorLine = 1;
	_errorString.clear();

	while (!file->atEnd()) {
		len = file->readLine(line, sizeof(line));

		if (len < 0) {
			_errorString = "I/O error";
			return false;
		} else if (len > (qint64)sizeof(line) - 1) {
			_errorString = "Line limit exceeded";
			return false;
		}

		if (_errorLine == 1) {
			if (!readARecord(line, len)) {
				_errorString = "Invalid/missing A record";
				return false;
			}
		} else {
			if (line[0] == 'H') {
				if (!readHRecord(line, len))
					return false;
			} else if (line[0] == 'C') {
				if (route) {
					if (!readCRecord(line, len))
						return false;
				} else {
					route = true;
					_routes.append(RouteData());
				}
			} else if (line[0] == 'B') {
				if (_date.isNull()) {
					_errorString = "Missing date header";
					return false;
				}
				if (!track) {
					_tracks.append(TrackData());
					_time = QTime(0, 0);
					track = true;
				}
				if (!readBRecord(line, len))
					return false;
			}
		}

		_errorLine++;
	}

	return true;
}
Exemple #3
0
void TCXParser::activities()
{
	while (_reader.readNextStartElement()) {
		if (_reader.name() == "Activity") {
			_tracks.append(TrackData());
			activity(_tracks.back());
		} else
			_reader.skipCurrentElement();
	}
}
Exemple #4
0
void TCXParser::courses()
{
	while (_reader.readNextStartElement()) {
		if (_reader.name() == "Course") {
			_tracks.append(TrackData());
			course(_tracks.back());
		} else
			_reader.skipCurrentElement();
	}
}