init
This commit is contained in:
142
DataPRO/SensorDB/TSF/TSFRackInformationSection.cs
Normal file
142
DataPRO/SensorDB/TSF/TSFRackInformationSection.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.SensorDB.TSF
|
||||
{
|
||||
/// <summary>
|
||||
/// handles the rack information section of the TSF
|
||||
/// </summary>
|
||||
public class TSFRackInformationSection
|
||||
{
|
||||
private const string START_SECTION_HEADER = "---- Start Rack Information ----";
|
||||
private const string COLUMN_HEADER = "Rack";
|
||||
private const string END_SECTION_HEADER = "---- End Rack Information ----";
|
||||
private List<TSFRackDescription> _racks = new List<TSFRackDescription>();
|
||||
public TSFRackDescription[] Racks
|
||||
{
|
||||
get { return _racks.ToArray(); }
|
||||
set { _racks = new List<TSFRackDescription>(value); }
|
||||
}
|
||||
public TSFRackInformationSection() { }
|
||||
/// <summary>
|
||||
/// reads the section from the TSF assumes currentline is the start of the section
|
||||
/// </summary>
|
||||
/// <param name="lines"></param>
|
||||
/// <param name="currentLine"></param>
|
||||
/// <param name="errors"></param>
|
||||
/// <param name="tsf"></param>
|
||||
/// <param name="system"></param>
|
||||
public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors, TSFFile tsf, TSFSystemDescription system)
|
||||
{
|
||||
var invariant = System.Globalization.CultureInfo.InvariantCulture;
|
||||
_racks.Clear();
|
||||
if (currentLine == lines.Count)
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
|
||||
return;
|
||||
}
|
||||
string startSection = lines[currentLine++];
|
||||
if (startSection != START_SECTION_HEADER)
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.RACKINFORMATIONSECTION_INVALIDHEADER, currentLine, startSection));
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentLine == lines.Count)
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
|
||||
return;
|
||||
}
|
||||
|
||||
string columnHeader = lines[currentLine++];
|
||||
if (false == columnHeader.Contains(COLUMN_HEADER))
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.RACKINFORMATIONSECTION_INVALIDCOLUMNHEADER, currentLine, columnHeader));
|
||||
return;
|
||||
}
|
||||
|
||||
bool done = false;
|
||||
while (!done)
|
||||
{
|
||||
if (currentLine == lines.Count)
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
|
||||
return;
|
||||
}
|
||||
|
||||
string line = lines[currentLine++];
|
||||
if (line != END_SECTION_HEADER)
|
||||
{
|
||||
string[] tokens = line.Split(new char[] { ',' });
|
||||
if (tokens.Length < 1)
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SKIPPED_RACK_ENTRY_INCOMPLETE, currentLine));
|
||||
continue;
|
||||
}
|
||||
|
||||
int rack;
|
||||
try { rack = int.Parse(tokens[0], invariant); }
|
||||
catch (System.Exception)
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_RACK_ENTRY_INVALID_RACK_VALUE, currentLine, tokens[0]));
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
string rackIsoObject = tokens[1];
|
||||
string rackIDummy = tokens[2];
|
||||
|
||||
int iRackIsoPosition;
|
||||
try { iRackIsoPosition = int.Parse(tokens[3], invariant); }
|
||||
catch (System.Exception)
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_RACK_ENTRY_INVALID_ISO_POSITION, currentLine, tokens[3]));
|
||||
continue;
|
||||
}
|
||||
|
||||
int iRackG5DockingStation = int.Parse(tokens[4]);
|
||||
int iRackISOModuleNum = int.Parse(tokens[5]);
|
||||
* */
|
||||
|
||||
if (line.Contains(",B,") && tsf.GetICrashBarrierType() == TSFFile.ICRASH_BARRIER_TYPE.ITROLLEY_BARRIER)
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.RACK_ENTRY_IWALLTEST_ITROLLEY_FUNCTIONALITY, currentLine));
|
||||
continue;
|
||||
}
|
||||
if (line.Contains(",T,") && tsf.GetICrashBarrierType() == TSFFile.ICRASH_BARRIER_TYPE.IWALL_BARRIER)
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.RACK_ENTRY_ITROLLEYTEST_IWALL_FUNCTIONALITY, currentLine));
|
||||
continue;
|
||||
}
|
||||
|
||||
TSFRackDescription r = null;//system.HWRack[rack];
|
||||
foreach (var curRack in system.HWRack)
|
||||
{
|
||||
if (curRack.Number == rack)
|
||||
{
|
||||
r = curRack;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (null == r)
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.RACK_ENTRY_INVALID_RACK_INDEX, currentLine));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (r.HWSerialNumber == TSFFile.EMPTY_RACK_SN)
|
||||
{
|
||||
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.RACK_ENTRY_INVALID_EMPTYRACK, currentLine));
|
||||
continue;
|
||||
}
|
||||
_racks.Add(new TSFRackDescription(r));
|
||||
}
|
||||
else
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user