updateGoGPSUpBodyEntrySwim function
Implementation
CLCmdGoGpsUpStreamData? updateGoGPSUpBodyEntrySwim(CLCmdGogpsBodyPeakSwim bodyItem){
slog('updateGoGPSUpBodyEntrySwim entered');
int type = bodyItem.type; //
int timestamp = bodyItem.timestamp;
int heartrate = bodyItem.heartrate;
int swimtime = bodyItem.swimtime;
int strokes = bodyItem.strokes;
int swimtype = bodyItem.swimtype;
int avgstrokefreq = bodyItem.avgstrokefreq;
int maxstrokefreq = bodyItem.maxstrokefreq;
final int swolf = bodyItem.swolf;
final int avgpace = bodyItem.avgpace;;
final int lapindex = bodyItem.lapindex;
slog('updateGoGPSUpBodyEntrySwim bodyItem.type is $type');
slog('updateGoGPSUpBodyEntrySwim bodyItem.timestamp is $timestamp');
slog('updateGoGPSUpBodyEntrySwim bodyItem.heartrate is $heartrate');
slog('updateGoGPSUpBodyEntrySwim bodyItem.swimtime is $swimtime');
slog('updateGoGPSUpBodyEntrySwim bodyItem.swolf is $swolf');
slog('updateGoGPSUpBodyEntrySwim bodyItem.lapindex is $lapindex');
if (GoGpsParam.mbNewSession) {
GoGpsParam.mbNewSession = false;
// every track initializes these parameters only once
GoGpsParam.mfGOGPSPreDis = 0;
GoGpsParam.mlGOGPSTrailStartTime = bodyItem.timestamp;
GoGpsParam.mlGOGPSTrailEndTime = 0;
GoGpsParam.mnGogpsLastSwimLapIndex = 0;
GoGpsParam.mnGogpsLastSwimLapBegintime = bodyItem.timestamp;
}
GoGpsParam.mnGogpsReceivedBodyCntInBlk++;
int lastswimlapindex = GoGpsParam.mnGogpsLastSwimLapIndex;
slog('lastswimlapindex:$lastswimlapindex');
if ((bodyItem.lapindex == GoGpsParam.mnGogpsLastSwimLapIndex) || (bodyItem.lapindex == 0)) {
// Dlog.d(TAG, "updateGoGPSUpBodyEntrySwim Filter same and 0" + bodyItem.toString());
slog('return entered');
return null;
}
// Dlog.d(TAG, "updateGoGPSUpBodyEntrySwim update: " + gogpsUpBody.toString());
final pgu = CLCmdGoGpsUpStreamData(
timestamp:GoGpsParam.mnGogpsLastSwimLapBegintime,
heartrate:bodyItem.heartrate,
swimtimeonelap: bodyItem.swimtime,
swimstrokeonelap: bodyItem.strokes,
swimtype: bodyItem.swimtype,
swimavgstrokefreqonelap: bodyItem.avgstrokefreq,
swimmaxstrokefreqonelap: bodyItem.maxstrokefreq,
swimswolfonelap: bodyItem.swolf,
swimavgpaceonelap: bodyItem.avgpace,
speed: 3600.toDouble()/bodyItem.avgpace.toDouble(),
swimlapindex: bodyItem.lapindex,
distance_km: bodyItem.lapindex * GoGpsParam.mGogpsUpHeader!.lapdistance,
kcal: GoGpsParam.mGogpsUpHeader!.calories*16,
);
GoGpsParam.mnGogpsLastSwimLapIndex = bodyItem.lapindex;
GoGpsParam.mnGogpsLastSwimLapBegintime = GoGpsParam.mnGogpsLastSwimLapBegintime + bodyItem.swimtime;
//test code
int pgutimestamp = pgu.timestamp;
int pguswimtype = pgu.swimtype;
int pguswimswolf = pgu.swimswolfonelap;
int pguswimlapindex = pgu.swimlapindex;
int pguswimdis = pgu.distance_km;
int pguswimcal = pgu.kcal;
slog('updateGoGPSUpBodyEntrySwim pgutimestamp: $pgutimestamp, pguswimtype: $pguswimtype');
slog('updateGoGPSUpBodyEntrySwim pguswimswolf: $pguswimswolf, pguswimlapindex: $pguswimlapindex');
slog('updateGoGPSUpBodyEntrySwim pguswimdis: $pguswimdis, pguswimcal: $pguswimcal');
return pgu;
}