/*
This software is subject to the license described in the License.txt file
included with this software distribution. You may not use this file except
in compliance with this license.
Copyright (c) Dynastream Innovations Inc. 2016
All rights reserved.
*/
//////////////////////////////////////////////////////////////////////////
// This file contains all the enumerations and constants for general
// use with ANT-FS
//////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
namespace ANT_Managed_Library.ANTFS
{
///
/// Status of an ongoing or completed data transfer
///
public class TransferStatus
{
private uint myByteProgress;
private uint myTotalLength;
private byte myPercentage;
///
/// Constructor initializes status and obtains percentage from parameters
///
/// Current byte progress
/// Expected data length
public TransferStatus(uint Progress, uint Length)
{
this.myByteProgress = Progress;
this.myTotalLength = Length;
if (Length != 0)
this.myPercentage = (byte)Math.Round(((decimal)Progress / (decimal)Length) * 100);
else
this.myPercentage = 0;
}
///
/// Current byte progress of a data transfer
///
public uint ByteProgress
{
get { return myByteProgress; }
}
///
/// Expected length of a data transfer
///
public uint TotalLength
{
get { return myTotalLength; }
}
///
/// Current percentage of completion of a data transfer
///
public byte Percentage
{
get { return myPercentage; }
}
///
/// Provides a string containing the transfer status
///
/// Formatted string with the current byte progress, expected length and percentage
public override string ToString()
{
return "Transfer Status: (" + myByteProgress + "/" + myTotalLength + ") ... " + myPercentage + '%';
}
}
}