Exemple #1
0
// insert a new range starting at the given date extending to the end of the zone currently
// containing that date.  If the start date of that zone is prior to the specified start
// date, then that zone range is shorted.
int HrZones::insertRangeAtDate(QDate date, int lt) {
    assert(date.isValid());
    int rnum;

    if (ranges.empty()) {
        addHrZoneRange();
        rnum = 0;
    }
    else {
        rnum = whichRange(date);
        assert(rnum >= 0);
        QDate date1 = getStartDate(rnum);

        // if the old range has dates before the specified, then truncate
        // the old range and shift up the existing ranges
        if (date > date1) {
            QDate endDate = getEndDate(rnum);
            setEndDate(rnum, date);
            ranges.insert(++ rnum, HrZoneRange(date, endDate));
        }
    }

    if (lt > 0) {
        setLT(rnum, lt);
        setHrZonesFromLT(rnum);
    }

    return rnum;
}
Exemple #2
0
quint16
PaceZones::getFingerprint(QDate forDate) const
{
    quint64 x = 0;

    int i = whichRange(forDate);
    if (i>=0) {

        // from
        x += ranges[i].begin.toJulianDay();

        // to
        x += ranges[i].end.toJulianDay();

        // CV
        x += ranges[i].cv;

        // each zone definition (manual edit/default changed)
        for (int j=0; j<ranges[i].zones.count(); j++) {
            x += ranges[i].zones[j].lo;
        }
    }
    QByteArray ba = QByteArray::number(x);

    return qChecksum(ba, ba.length()); 
}
Exemple #3
0
// get fingerprint just for the range that applies on this date
quint16
Zones::getFingerprint(QDate forDate) const
{
    quint64 x = 0;

    // which range to apply ?
    int i = whichRange(forDate);
    if (i >= 0) {

        // CP
        x += ranges[i].cp;

        // FTP
        x += ranges[i].ftp;

        // W'
        x += ranges[i].wprime;

        // Pmax
        x += ranges[i].pmax;

        // each zone definition (manual edit/default changed)
        for (int j=0; j<ranges[i].zones.count(); j++) {
            x += ranges[i].zones[j].lo;
        }
    }
    QByteArray ba = QByteArray::number(x);

    // limits to only zones now as we sport weight separately
    return qChecksum(ba, ba.length());
}
Exemple #4
0
// insert a new range starting at the given date extending to the end of the zone currently
// containing that date.  If the start date of that zone is prior to the specified start
// date, then that zone range is shorted.
int Zones::insertRangeAtDate(QDate date, int cp) {
    assert(date.isValid());
    int rnum;

    if (ranges.empty()) {
	addZoneRange(cp);
	fprintf(
		stderr,
		"Generating first range with CP = %d\n",
		cp
		);
	rnum = 0;
    }
    
    else {
	rnum = whichRange(date);
	assert(rnum >= 0);
	QDate date1 = getStartDate(rnum);
	fprintf(stderr, "insertRangeAtDate(%s, %d):\n", date.toString().toAscii().constData(), cp);

	// if the old range has dates before the specified, then truncate the old range
	// and shift up the existing ranges
	if (date > date1) {
	    QDate endDate = getEndDate(rnum);
	    setEndDate(rnum, date);
	    fprintf(
		    stderr,
		    "Inserting range\n"
		    "old range %d: from %s to %s\n"
		    "new range %d: from %s to %s\n"
		    "added range %d: from %s to %s\n",
		    rnum + 1, getStartDateString(rnum).toAscii().constData(), getEndDateString(rnum).toAscii().constData(),
		    rnum + 1, getStartDateString(rnum).toAscii().constData(), (date.isNull() ? "END" : date.toString().toAscii().constData()), 
		    rnum + 2, (date.isNull() ? "BEGIN" : date.toString().toAscii().constData()), getEndDateString(rnum).toAscii().constData()
		    );
	    ranges.insert(++ rnum, new ZoneRange(date, endDate));
	}
    }

    if (cp > 0) {
	setCP(rnum, cp);
	setZonesFromCP(rnum);
    }

    return rnum;
}
Exemple #5
0
quint16
PaceZones::getFingerprint(QDate forDate) const
{
    quint64 x = 0;

    int i = whichRange(forDate);
    if (i>=0) {

        // CV
        x += int(double(100.0f * ranges[i].cv));

        // each zone definition (manual edit/default changed)
        for (int j=0; j<ranges[i].zones.count(); j++) {
            x += int(double(100.0f * ranges[i].zones[j].lo));
        }
    }
    QByteArray ba = QByteArray::number(x);

    return qChecksum(ba, ba.length()); 
}
quint16
HrZones::getFingerprint(QDate forDate) const
{
    quint64 x = 0;

    int i = whichRange(forDate);
    if (i >= 0) {

        // zone parameters...
        x += ranges[i].lt;
        x += ranges[i].restHr;
        x += ranges[i].maxHr;

        // each zone definition (manual edit/default changed)
        for (int j=0; j<ranges[i].zones.count(); j++) {
            x += ranges[i].zones[j].lo;
            x += int(double(100.0f * ranges[i].zones[j].trimp));
        }
    }
    QByteArray ba = QByteArray::number(x);
    return qChecksum(ba, ba.length());
}