Skip to content
Snippets Groups Projects
Commit 07325fec authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Store the overall progress in percent in the status.

Refers to #26
parent 539b9831
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,8 @@ namespace ATxCommon.Serializables
private long _transferredBytesCompleted;
private long _transferredBytesCurrentFile;
private int _currentTransferPercent;
#region constructor, serializer and deserializer
......@@ -44,6 +46,7 @@ namespace ATxCommon.Serializables
_transferInProgress = false;
_transferredBytesCompleted = 0;
_transferredBytesCurrentFile = 0;
_currentTransferPercent = 0;
}
public void Serialize() {
......@@ -254,6 +257,18 @@ namespace ATxCommon.Serializables
}
}
/// <summary>
/// The progress of the current transfer in percent.
/// </summary>
public int CurrentTransferPercent {
get { return _currentTransferPercent; }
set {
_currentTransferPercent = value;
Log.Trace("CurrentTransferPercent was updated ({0}).", value);
Serialize();
}
}
#endregion getter / setter methods
......
......@@ -159,6 +159,7 @@ namespace ATxService
_transferState = TxState.Stopped;
_status.TransferredBytesCompleted = 0;
_status.TransferredBytesCurrentFile = 0;
_status.CurrentTransferPercent = 0;
_txCurFileSize = 0;
_txCurFileProgress = 0;
_roboCommand.Dispose();
......@@ -180,12 +181,14 @@ namespace ATxService
_txCurFileProgress = progress;
_status.TransferredBytesCurrentFile = (long) (_txCurFileSize * e.CurrentFileProgress / 100);
var overallProgress = ((double)(_status.TransferredBytesCompleted + _status.TransferredBytesCurrentFile) /
_status.CurrentTransferSize) * 100;
Log.Info("Current transfer at {0:0}%", overallProgress);
// NOTE: the (double) is required to make the division work on float which can then
// eventually be cast into an (int) after multiplying it by 100:
_status.CurrentTransferPercent = (int)((_status.TransferredBytesCompleted + _status.TransferredBytesCurrentFile) * 100 /
_status.CurrentTransferSize);
Log.Info("Current transfer at {0}%", _status.CurrentTransferPercent);
Log.Trace("Tx progress: complete [{0}] - current [{1}] - combined {2:0}%",
_status.TransferredBytesCompleted, _status.TransferredBytesCurrentFile,
overallProgress);
_status.CurrentTransferPercent);
Log.Trace("Current file transfer progress {0}%", progress);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment