private void calibratingCurrentElement(long difference,float isig,byte[] readData,int index,MedtronicSensorRecord record,int num,Date currentTime){
  boolean calibrated=false;
  if (isCalibrating) {
    if (num > 0) {
      calculateCalibration(difference,isig,readData[index]);
      if (calibrationFactor > 0) {
        if (!isCalibrating) {
          if (calibrationStatus != MedtronicConstants.WITHOUT_ANY_CALIBRATION && calibrationStatus != MedtronicConstants.LAST_CALIBRATION_FAILED_USING_PREVIOUS && calibrationStatus != MedtronicConstants.CALIBRATION_MORE_THAN_12H_OLD) {
            record.setBGValue(((int)lastGlucometerValue) + "");
            record.setUnfilteredGlucose(lastGlucometerValue);
            record.calibrationFactor=calibrationFactor;
            record.isCalibrating=false;
            record.calibrationStatus=calibrationStatus;
            lastCalibrationDate=currentTime.getTime();
            SharedPreferences.Editor editor=settings.edit();
            log.debug("change lastCalibrationDate");
            editor.putLong("lastCalibrationDate",lastCalibrationDate);
            editor.commit();
            calibrated=true;
          }
        }
      }
    }
  }
  if (calibrationFactor > 0 && !calibrated) {
    List<Record> auxList=null;
synchronized (lastRecordsListLock) {
      auxList=lastRecordsInMemory.getListFromTail(2);
    }
    if (calibrationStatus != MedtronicConstants.WITHOUT_ANY_CALIBRATION) {
      record.setUnfilteredGlucose(isig * calibrationFactor);
      record.setBGValue((applyFilterToRecord(record,auxList)) + "");
      record.isCalibrating=false;
      record.calibrationFactor=calibrationFactor;
      record.calibrationStatus=calibrationStatus;
    }
 else {
      record.setUnfilteredGlucose(isig * calibrationFactor);
      record.setBGValue((applyFilterToRecord(record,auxList)) + "");
      record.isCalibrating=false;
      record.calibrationFactor=calibrationFactor;
      record.calibrationStatus=MedtronicConstants.LAST_CALIBRATION_FAILED_USING_PREVIOUS;
    }
  }
  calculateDate(record,currentTime,0);
  previousRecord=record;
}

private void calibratingCurrentElement ( long difference , float isig , byte [ ] readData , int index , MedtronicSensorRecord record , int num , Date currentTime ) { boolean calibrated = false ; if ( isCalibrating ) { if ( num > 0 ) { calculateCalibration ( difference , isig , readData [ index ] ) ; if ( calibrationFactor > 0 ) { if ( ! isCalibrating ) { if ( calibrationStatus != MedtronicConstants . WITHOUT_ANY_CALIBRATION && calibrationStatus != MedtronicConstants . LAST_CALIBRATION_FAILED_USING_PREVIOUS && calibrationStatus != MedtronicConstants . CALIBRATION_MORE_THAN_12H_OLD ) { record . setBGValue ( ( ( int ) lastGlucometerValue ) + "" ) ; record . setUnfilteredGlucose ( lastGlucometerValue ) ; record . calibrationFactor = calibrationFactor ; record . isCalibrating = false ; record . calibrationStatus = calibrationStatus ; lastCalibrationDate = currentTime . getTime ( ) ; SharedPreferences . Editor editor = settings . edit ( ) ; log . debug ( "change lastCalibrationDate" ) ; editor . putLong ( "lastCalibrationDate" , lastCalibrationDate ) ; editor . commit ( ) ; calibrated = true ; } } } } } if ( calibrationFactor > 0 && ! calibrated ) { List < Record > auxList = null ; synchronized ( lastRecordsListLock ) { auxList = lastRecordsInMemory . getListFromTail ( 2 ) ; } if ( calibrationStatus != MedtronicConstants . WITHOUT_ANY_CALIBRATION ) { record . setUnfilteredGlucose ( isig * calibrationFactor ) ; record . setBGValue ( ( applyFilterToRecord ( record , auxList ) ) + "" ) ; record . isCalibrating = false ; record . calibrationFactor = calibrationFactor ; record . calibrationStatus = calibrationStatus ; } else { record . setUnfilteredGlucose ( isig * calibrationFactor ) ; record . setBGValue ( ( applyFilterToRecord ( record , auxList ) ) + "" ) ; record . isCalibrating = false ; record . calibrationFactor = calibrationFactor ; record . calibrationStatus = MedtronicConstants . LAST_CALIBRATION_FAILED_USING_PREVIOUS ; } } calculateDate ( record , currentTime , 0 ) ; previousRecord = record ; }
apply calibration to the " current " value of the sensor message
