namespace SWModules
{
    /// <summary>
    /// Data Structure that holds converted values of information stored
    /// in the battery pack managers employed by Inspired Energy. See
    /// <see href="https://www.inspired-energy.com/">Inspired Energy's website</see>
    /// </summary>
    public struct BatteryState
    {

        public ushort RemainingCapAlarm, //Remaining Capacity Alarm Threshold mAh
            RemainingTimeAlarm, //Remaining Time Alarm Threshold minutes
            BatteryMode, //Battery Operational Modes (bitflags)
            AtRate, //first half of a 2 function call-set used to set the AtRate value used in calculations makde by the other AT functions (mA)
            AtRateTimeToFull, //returns the pericted remaining time to fully charge at the the atrate() value (minutes)
            AtRateTimeToEmpty, //Returns the predicted remaining operating time at the atrate() value (minutes)
            AtRateOK, //Returns a bool that indicates whether the batt can deliver the atrae()  value of energy for 10 more seconds
            Temperature, //Returns Internal temperature (0.1 degK)
            Voltage,
            SerialNumber; //Returns the battery's voltage (mV)
        public short Current, //Returns the current moving through the batt's terminals (mA)
            AverageCurrent; //Returns a rolling average based upon the last 64 samples (mA)
        public ushort MaxError, //Returns the expected margin of error
            RelStateOfCharge, //Returns the predicted remaining battery capacity in % of Full
            AbsStateOfCharge, //Returns the predicted remaining battery capacity as a % of Design
            RemainingCapacity, //Returns the predicted remaining battery capacity (mAh)
            FullChargeCapacity, //Returns the predicted battery capacity when fully charged (mAh)
            RunTimeToEmpty, //Returns the predicted remaining battery life at the present rate of discharge (minutes)
            AverageTimeToEmpty, //Returns the rolloing average of the predicted remaining battery life (minutes)
            AverageTimeToFull, //Returns the rolling average of the predicted remaining time until the battery reaches full charge (minutes)
            ChargingCurrent, //Returns the battery's desired charging rate (mA)
            ChargingVoltage, //Returns the battery's desired charging voltage (mV)
            BatteryStatus, //Returns the battery's status word (bit flags)
            CycleCount, //Returns the number of cycles the battery has experienced. A cycle is defined as: an amount of discharge approximately equal to the value of the DesignCapacity (cycles)
            DesignCapacity, //Returns the theoretical capacity of the new battery (mA)
            DesignVoltage; //Return the theoretical voltage of a new battery (mV)

        public bool Charging;

            public override string ToString()
            {
                return "SN: "+ SerialNumber.ToString("D3") + 
                       " Voltage: " + Voltage.ToString("D5") + 
                       " Current: " + Current.ToString("D5") + 
                       "\tCapacity: " + RemainingCapacity.ToString("D5") + 
                       " Temp: " + Temperature.ToString("D5") + 
                       " Status: " + BatteryStatus.ToString("X4") +
                        " Mode: " + BatteryMode.ToString("X4") +
                    " Charge: " + Charging;
            }
    }
}