Changeset 27 for trunk


Ignore:
Timestamp:
Apr 6, 2016, 7:45:46 AM (9 years ago)
Author:
chronos
Message:
  • Modified: Improved average value in speed measurement.
  • Added: Show Min and Max values with different colors in speed chart.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Form/UFormMain.lfm

    r25 r27  
    397397        Align = alClient
    398398        BorderSpacing.Around = 4
    399         object ChartSpeedLineSeries1: TLineSeries
    400           LinePen.Color = clWhite
     399        object ChartSpeedLineSeriesAvg: TLineSeries
     400          LinePen.Color = clGreen
     401        end
     402        object ChartSpeedLineSeriesMin: TLineSeries
     403          LinePen.Color = clBlue
     404        end
     405        object ChartSpeedLineSeriesMax: TLineSeries
     406          LinePen.Color = clRed
    401407        end
    402408      end
  • trunk/Form/UFormMain.pas

    r26 r27  
    3939    ButtonScan2: TButton;
    4040    ChartSpeed: TChart;
    41     ChartSpeedLineSeries1: TLineSeries;
     41    ChartSpeedLineSeriesAvg: TLineSeries;
     42    ChartSpeedLineSeriesMin: TLineSeries;
     43    ChartSpeedLineSeriesMax: TLineSeries;
    4244    ComboBoxDrive: TComboBox;
    4345    Image1: TImage;
     
    540542    ChartSpeed.BottomAxis.Range.UseMax := True;
    541543    ChartSpeed.BottomAxis.Range.Max := Length(SpeedSteps);
    542     ChartSpeedLineSeries1.Clear;
     544    ChartSpeedLineSeriesAvg.Clear;
     545    ChartSpeedLineSeriesMin.Clear;
     546    ChartSpeedLineSeriesMax.Clear;
    543547    for I := 0 to Length(SpeedSteps) - 1 do
    544     if not SpeedSteps[I].Null then
    545       ChartSpeedLineSeries1.AddXY(I, SpeedSteps[I].Average / (1024 * 1024));
     548    if not SpeedSteps[I].Null then begin
     549      ChartSpeedLineSeriesAvg.AddXY(I, SpeedSteps[I].Average / (1024 * 1024));
     550      ChartSpeedLineSeriesMin.AddXY(I, SpeedSteps[I].Min / (1024 * 1024));
     551      ChartSpeedLineSeriesMax.AddXY(I, SpeedSteps[I].Max / (1024 * 1024));
     552    end;
    546553  end;
    547554end;
  • trunk/UDriveScan.pas

    r25 r27  
    5050
    5151  TSpeedValue = record
     52  public
    5253    Null: Boolean;
    5354    Max: Int64;
    5455    Average: Int64;
     56    Values: array of Int64;
    5557    Min: Int64;
    5658    procedure Reset;
     
    132134
    133135procedure TSpeedValue.UpdateValue(Value: Int64);
     136var
     137  Sum: Double;
     138  I: Integer;
    134139begin
    135140  if Null then begin
    136141    Min := High(Int64);
    137142    Max := Low(Int64);
    138     Average := 0;
     143    SetLength(Values, 0);
    139144  end;
    140145  Null := False;
    141146  if Value > Max then Max := Value;
    142147  // TODO: Computer average
    143   Average := Value;
     148  SetLength(Values, Length(Values) + 1);
     149  Values[Length(Values) - 1] := Value;
     150  Sum := 0;
     151  for I := 0 to Length(Values) - 1 do
     152    Sum := Sum + Values[I];
     153  Average := Trunc(Sum / Length(Values));
    144154  if Value < Min then Min := Value;
    145155end;
     
    344354  SpeedTimeCurrent: TDateTime;
    345355  Index: Integer;
     356  Value: Int64;
    346357begin
    347358  SpeedTimeCurrent := Now;
    348359  Index := Trunc(SectorCurrent / SectorCount * SpeedStepsCount);
    349360  if Index >= Length(SpeedSteps) then Index := Length(SpeedSteps) - 1;
    350   SpeedSteps[Index].UpdateValue(
    351     Trunc((SectorCurrent - SectorLast) * SectorSize / ((SpeedTimeCurrent - SpeedTimeLast) / OneSecond)));
     361  Value := Trunc((SectorCurrent - SectorLast) * SectorSize / ((SpeedTimeCurrent - SpeedTimeLast) / OneSecond));
     362  if Value < 0 then Value := 0;
     363  SpeedSteps[Index].UpdateValue(Value);
    352364  SpeedTimeLast := SpeedTimeCurrent;
    353365  SectorLast := SectorCurrent;
     
    389401  SpeedTimer.Enabled := False;
    390402  SpeedTimer.OnTimer := SpeedTimerExecute;
    391   SpeedStepsCount := 1000;
     403  SpeedStepsCount := 500;
    392404  SectorSize := 4096;
    393405  Terminated := True;
Note: See TracChangeset for help on using the changeset viewer.