init
This commit is contained in:
71
DataPRO/SensorDB/TDCINI/INIIIHSExport.cs
Normal file
71
DataPRO/SensorDB/TDCINI/INIIIHSExport.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.SensorDB.TDCINI
|
||||
{
|
||||
/// <summary>
|
||||
/// helper class for IIHS export section of INI
|
||||
/// </summary>
|
||||
public class INIIIHSExport
|
||||
{
|
||||
/// <summary>
|
||||
/// whether to apply region of interest or not
|
||||
/// </summary>
|
||||
public bool ApplyROI { get; set; }
|
||||
/// <summary>
|
||||
/// start of ROI in seconds
|
||||
/// </summary>
|
||||
public double ROIStartSeconds { get; set; }
|
||||
/// <summary>
|
||||
/// end of ROI in seconds
|
||||
/// </summary>
|
||||
public double ROIEndSeconds { get; set; }
|
||||
|
||||
public bool ReadFrom(string line, int curLine, ref List<TDCINIError> errors)
|
||||
{
|
||||
string[] tokens = line.Split(new char[] { ',' });
|
||||
|
||||
if (3 != tokens.Length)
|
||||
{
|
||||
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_IIHSExport_INVALID, line, curLine));
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (tokens[0])
|
||||
{
|
||||
case "0":
|
||||
case "F":
|
||||
case "N":
|
||||
ApplyROI = false; break;
|
||||
case "1":
|
||||
case "T":
|
||||
case "Y":
|
||||
ApplyROI = true; break;
|
||||
default:
|
||||
{
|
||||
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_IIHSExport_INVALID, tokens[0], curLine));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
double d;
|
||||
if (!double.TryParse(tokens[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_IIHSExport_INVALID, tokens[1], curLine));
|
||||
return false;
|
||||
}
|
||||
else { ROIStartSeconds = d; }
|
||||
|
||||
if (!double.TryParse(tokens[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_IIHSExport_INVALID, tokens[2], curLine));
|
||||
return false;
|
||||
}
|
||||
else { ROIEndSeconds = d; }
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user