updateGoGpsHeader function

void updateGoGpsHeader(
  1. CLCmdGogpsHeaderV2 header,
  2. int bHeaderUpdated
)

Implementation

void updateGoGpsHeader(CLCmdGogpsHeaderV2 header, int bHeaderUpdated){
  int workoutType = header.workoutType;
  int blkIndex = header.blkIndex;
  int timestamp = header.timestamp;

  // int latitude;
//
  // int longitude;
//
  // int calories;

  int lapdistance=header.lapdistance;
  int calories = header.calories;

  slog('updateGoGpsHeader header.blkIndex is $blkIndex');
  slog('updateGoGpsHeader header.workoutType is $workoutType ');
  slog('updateGoGpsHeader header.timestamp is $timestamp');
  slog('updateGoGpsHeader header.lapdistance is $lapdistance');
  slog('updateGoGpsHeader header.calories is $calories');
  if (GoGpsParam.mGogpsUpHeader == null) {
    GoGpsParam.mGogpsUpHeader = CLCmdGogpsHeaderV2(
      workoutType: header.workoutType,
      blkIndex:header.blkIndex,
      timestamp:header.timestamp,
      latitude:header.latitude,//0
      longitude:header.longitude,//0
      calories:header.calories,
      lapdistance:header.lapdistance,
    );
    GoGpsParam.mbNewSession = true;
  } else {
    if (GoGpsParam.mGogpsUpHeader?.timestamp != header.timestamp) {
      GoGpsParam.mbNewSession = true;
    }
    GoGpsParam.mGogpsUpHeader?.workoutType = header.workoutType;
    GoGpsParam.mGogpsUpHeader?.blkIndex = header.blkIndex;
    GoGpsParam.mGogpsUpHeader?.timestamp = header.timestamp;
    GoGpsParam.mGogpsUpHeader?.latitude = 0;
    GoGpsParam.mGogpsUpHeader?.longitude = 0;
    GoGpsParam.mGogpsUpHeader?.calories = header.calories;
    GoGpsParam.mGogpsUpHeader?.lapdistance = header.lapdistance;
  }
  if (GoGpsParam.mbNewSession) {
    // every header provide new start location
    GoGpsParam.mnGogpsReceivedBodyCntInBlk = 0;

    GoGpsParam.mlLastSecIndex = -1;
  }

  if (bHeaderUpdated>0) {
    GoGpsParam.mdGogpsLastLat = GoGpsParam.mGogpsUpHeader!.latitude.toDouble();
    GoGpsParam.mdGogpsLastLng = GoGpsParam.mGogpsUpHeader!.longitude.toDouble();
  }

    // if (ClingDbGoGPSUpTrackInfoUtil.getInstance().getGOGPSTrackInfoByTimestamp(gogpsUpHeader.timestamp) != null) {
    //         mbGogpsTrackSummarized = true;
    // } else {
    //         mbGogpsTrackSummarized = false;
    // }

  if (CLCmdDeviceInfo.info!.gps_blk_count > 0) {
    int blkindex = GoGpsParam.mGogpsUpHeader!.blkIndex ;
    int blkcount = CLCmdDeviceInfo.info!.gps_blk_count;

    double gpsProgress = ((GoGpsParam.mGogpsUpHeader!.blkIndex +1).toDouble()) / (CLCmdDeviceInfo.info!.gps_blk_count).toDouble();
    slog('updateGoGpsHeader blkindex:$blkindex, blkcount:$blkcount, progress: $gpsProgress');
    CLCmdGoGpsUpStreamData.progress.add(gpsProgress);

  // if (onGetGPSProcessListener != null) {
  //     onGetGPSProcessListener.onGpsProcess(gpsProgress);
  // }
  }

}