57 lines
2.0 KiB
C#
57 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace DTS.SensorDB.TDCINI
|
|
{
|
|
/// <summary>
|
|
/// helper class for region of interest section of INI
|
|
/// </summary>
|
|
public class TSFINIRegionOfInterest
|
|
{
|
|
/// <summary>
|
|
/// Start in seconds of ROI relative to T0
|
|
/// </summary>
|
|
public double StartSeconds { get; set; }
|
|
/// <summary>
|
|
/// end in seconds of ROI relative to T0
|
|
/// </summary>
|
|
public double EndSeconds { get; set; }
|
|
/// <summary>
|
|
/// reads section from a line,
|
|
/// returns true if read successfully
|
|
/// false if there were errors
|
|
/// </summary>
|
|
/// <param name="line"></param>
|
|
/// <param name="currentLine"></param>
|
|
/// <param name="errors"></param>
|
|
/// <returns></returns>
|
|
public bool ReadFrom(string line, int currentLine, ref List<TDCINIError> errors)
|
|
{
|
|
string[] tokens = line.Split(new char[] { ',' });
|
|
if (2 != tokens.Length)
|
|
{
|
|
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ROI_INVALID, line, currentLine));
|
|
return false;
|
|
}
|
|
double d;
|
|
|
|
if (!double.TryParse(tokens[0], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
|
{
|
|
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ROI_INVALID, line, currentLine));
|
|
return false;
|
|
}
|
|
else { StartSeconds = d; }
|
|
|
|
if (!double.TryParse(tokens[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
|
{
|
|
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ROI_INVALID, line, currentLine));
|
|
return false;
|
|
}
|
|
else { EndSeconds = d; }
|
|
return true;
|
|
}
|
|
}
|
|
}
|