TApxProtocol.EstimateTransferSecs

TApxProtocol

function EstimateTransferSecs(const Size : LongInt) : LongInt;

Returns the amount of time to transfer a file.

You can call EstimateTransferSecs in a status event handler to obtain the approximate number of seconds required to transfer Size bytes of data. Typically, a status routine calls it in two places. In the first place, which should generally be executed only one time when the status routine is first called, it passes the total size of the file to get the total transfer time. In the second place, which should be executed every time the status routine is called, it passes the number of bytes remaining to get the transfer time remaining.

EstimateTransferSecs automatically accounts for the baud rate of the port's connection and various internal details of the active protocol. The estimated transfer time is also affected by two approximate overhead factors that are specific to the type of protocol. See the Overhead and TurnDelay properties for more information about these factors. If the modem data rate is different from the comport data rate, also see ActualBPS.

To compute the transfer time, EstimateTransferSecs first computes an effective transfer rate using the following formulas:

ActualCPS    = ActualBPS div 10
Efficiency   = ratio of data bytes to highest possible number of
               bytes, calculated as follows:
               BlockLength
-------------------------------------------------
BlockLength + Overhead + ((TurnDelay * ActualCPS)
                 div 1000)
EffectiveCPS = ActualCPS * Efficiency

Then the estimated transfer time is Size divided by EffectiveCPS.

The following example calls EstimateTransferSecs in a status routine to get the total and remaining transfer times:

procedure TForm1.ProtocolStatus(CP : TObject; Options : Word);
var
  TotalTime, RemainingTime : LongInt;
begin
  with TApxProtocol1(CP) do begin
    ...
    TotalTime := EstimateTransferSecs(FileLength);
    RemainingTime := EstimateTransferSecs(BytesRemaining);
    ....
  end;
end;

See also: ActualBPS, OnProtocolStatus, Overhead, TurnDelay