init
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.SensorDB.TSF
|
||||
{
|
||||
/// <summary>
|
||||
/// an entry in the DIM Begin section of a TSF
|
||||
/// each entry can contain
|
||||
/// Datachan,Rack,Module,Chan,Description,Serial No,Mode,Inverted,EID,Filename,Scale,Filter Mode,Filter Threshold,ISO CODE,Cable Test
|
||||
/// we currently do nothing with these entries in DataPRO...
|
||||
/// </summary>
|
||||
public class TSFDIMEntry : TSFChannel
|
||||
{
|
||||
private int _dataChan;
|
||||
public int DataChan { get { return _dataChan; } set { _dataChan = value; } }
|
||||
|
||||
private int _rack;
|
||||
public int Rack { get { return _rack; } set { _rack = value; } }
|
||||
|
||||
private int _module;
|
||||
public int Module { get { return _module; } set { _module = value; } }
|
||||
|
||||
private int _chan;
|
||||
public int Chan { get { return _chan; } set { _chan = value; } }
|
||||
|
||||
private string _description;
|
||||
public string Description { get { return Description; } set { _description = value; } }
|
||||
|
||||
private string _serialNumber;
|
||||
public string SerialNumber { get { return _serialNumber; } set { _serialNumber = value; } }
|
||||
|
||||
private string _mode;
|
||||
public string Mode { get { return _mode; } set { _mode = value; } }
|
||||
|
||||
private int _inverted;
|
||||
public int Inverted { get { return _inverted; } set { _inverted = value; } }
|
||||
|
||||
private string _eid;
|
||||
public string EID { get { return _eid; } set { _eid = value; } }
|
||||
|
||||
private string _filename;
|
||||
public string FileName { get { return _filename; } set { _filename = value; } }
|
||||
|
||||
private double _scale;
|
||||
public double Scale { get { return _scale; } set { _scale = value; } }
|
||||
|
||||
private int _filterMode;
|
||||
public int FilterMode { get { return _filterMode; } set { _filterMode = value; } }
|
||||
|
||||
private double _filterThreshold;
|
||||
public double FilterThreshold { get { return _filterThreshold; } set { _filterThreshold = value; } }
|
||||
|
||||
private string _isocode;
|
||||
public string ISOCode { get { return _isocode; } set { _isocode = value; } }
|
||||
|
||||
private int _cableTest;
|
||||
public int CableTest { get { return _cableTest; } set { _cableTest = value; } }
|
||||
|
||||
public enum Fields
|
||||
{
|
||||
Datachan,//i
|
||||
Rack,//i
|
||||
Module,//i
|
||||
Chan, //i
|
||||
Description,//s
|
||||
SerialNo, //s
|
||||
Mode, //i?
|
||||
Inverted, //i
|
||||
EID, //s
|
||||
Filename, //s
|
||||
Scale, //f
|
||||
FilterMode, //i
|
||||
FilterThreshold,//f
|
||||
ISOCODE,//s
|
||||
CableTest//i
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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