48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace DTS.SensorDB.TDCINI
|
|
{
|
|
/// <summary>
|
|
/// helper class for SmartBatteryThreshold section in ini
|
|
/// </summary>
|
|
public class INISmartBatteryThresholds
|
|
{
|
|
/// <summary>
|
|
/// time in minutes for Yellow battery warning
|
|
/// </summary>
|
|
public int Yellow { get; set; }
|
|
/// <summary>
|
|
/// time in minutes for Red battery warning
|
|
/// </summary>
|
|
public int Red { get; set; }
|
|
public bool ReadFrom(string line, int curLine, ref List<TDCINIError> errors)
|
|
{
|
|
string[] tokens = line.Split(new char[] { ',' });
|
|
if (2 != tokens.Length)
|
|
{
|
|
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_SmartBatteryStatusThresholds, line, curLine));
|
|
return false;
|
|
}
|
|
|
|
int temp;
|
|
if (!int.TryParse(tokens[0], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out temp))
|
|
{
|
|
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_SmartBatteryStatusThresholds, line, curLine));
|
|
return false;
|
|
}
|
|
else { Yellow = temp; }
|
|
|
|
if (!int.TryParse(tokens[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out temp))
|
|
{
|
|
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_SmartBatteryStatusThresholds, line, curLine));
|
|
return false;
|
|
}
|
|
else { Red = temp; }
|
|
return true;
|
|
}
|
|
}
|
|
}
|