This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// the G5 Digital Input Channels section entry
/// each entry can contain
/// datachan,rack,mod,chan,descrip,ISOCode,scale,invert
/// </summary>
public class G5DigtalInputChannelTSFEntry : 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 _mod;
public int Module { get { return _mod; } set { _mod = value; } }
private int _chan;
public int Chan { get { return _chan; } set { _chan = value; } }
private string _descripton;
public string Descripton { get { return _descripton; } set { _descripton = value; } }
private string _isocode;
public string ISOCode { get { return _isocode; } set { _isocode = value; } }
private double _scale;
public double Scale { get { return _scale; } set { _scale = value; } }
private bool _invert;
public bool Invert { get { return _invert; } set { _invert = value; } }
public enum Fields
{
datachan,
rack,
mod,
chan,
descrip,
ISOCode,
scale,
invert
}
}
}

View File

@@ -0,0 +1,160 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB.TSF
{
/// <summary>
/// helper class to help returning errors while reading Test Setup Files (TSF)
/// this is to make it easier to handle translations.
/// </summary>
public class ReadTSFError
{
/// <summary>
/// these are all the possible errors returned by ReadTSF
/// </summary>
public enum TSF_ERRORS
{
TSF_FILE_NOT_FOUND,
TSF_FILE_IO_ERROR,
TSFFILE_INCOMPLETE,
TSF_INVALID_VERSION,
TSF_OLD_FILE_VERSION,
TSF_UNEXPECTED_EOF,
TSF_INCOMPLETE_SAMPLING_SECTION,
TSF_INVALID_SAMPLERATE,
TSF_INVALID_PRETRIGGER_TIME,
TSF_INAVLID_POSTTRIGGER_TIME,
TSF_INVALID_AAF,
TSF_SKIPPED_RACK_ENTRY_INCOMPLETE,
TSF_RACK_ENTRY_INVALID_RACK_VALUE,
TSF_RACK_ENTRY_INVALID_ISO_POSITION,
RACK_ENTRY_IWALLTEST_ITROLLEY_FUNCTIONALITY,
RACK_ENTRY_ITROLLEYTEST_IWALL_FUNCTIONALITY,
RACK_ENTRY_INVALID_RACK_INDEX,
RACK_ENTRY_INVALID_EMPTYRACK,
TSF_SKIPPING_MODULE_TOO_FEW_TOKENS,
TSF_MODULE_INVALID_RACK_FIELD,
TSF_MODULE_INVALID_MODULE_FIELD,
TSF_MODULE_INVALID_TRIGGERMODE_FIELD,
TSF_MODULE_INVALID_TRIGGERCHAN_FIELD,
TSF_MODULE_INVALID_TRIGGERDIR_FIELD,
TSF_MODULE_INVALID_TRIGGERLEVEL_FIELD,
TSF_MODULE_INVALID_MODULETYPE_FIELD,
TSF_MODULE_SKIPPED_RACKNOTFOUND,
TSF_SENSORCHANNEL_INVALID_C0,
TSF_SENSORCHANNEL_INVALID_C1,
TSF_SENSORCHANNEL_INVALID_C2,
TSF_SENSORCHANNEL_INVALID_C3,
TSF_SENSORCHANNEL_INVALID_C4,
TSF_SENSORCHANNEL_INVALID_C5,
TSF_SENSORCHANNEL_INVALID_CALDATE,
TSF_SENSORCHANNEL_INVALID_CALSTEP,
TSF_SENSORCHANNEL_INVALID_CHAN,
TSF_SENSOR_CHANNEL_INVALID_DATACHAN,
TSF_SENSOR_CHANNEL_INVALID_DESIREDMAXRANGE,
TSF_SENSOR_CHANNEL_INVALID_DESIREDMAXRANGESCALING,
TSF_SENSOR_CHANNEL_INVALID_DUPLICATESERIALNUMBER,
TSF_SENSOR_CHANNEL_INVALID_EXTVOLT,
TSF_SENSOR_CHANNEL_INVALID_GAIN,
TSF_SENSOR_CHANNEL_INVALID_INITIALEU,
TSF_SENSOR_CHANNEL_INVALID_IRTRACCEXPONENT,
TSF_SENSOR_CHANNEL_INVALID_MODULE,
TSF_SENSOR_CHANNEL_INVALID_OFFSETHIGH,
TSF_SENSOR_CHANNEL_INVALID_OFFSETLOW,
TSF_SENSOR_CHANNEL_INVALID_RACK,
TSF_SENSOR_CHANNEL_INVALID_SENSITIVITY,
TSF_SENSOR_CHANNEL_INVALID_SENSORCATEGORY,
TSF_SENSOR_CHANNEL_INVALID_SHUNTVALUE,
TSF_SENSOR_CHANNEL_INVALID_ZEROREF,
TSF_SENSOR_CHANNEL_INVALIDFIELD,
TSF_READPROTOCOL_AND_NO_SIF,
TSF_ERROR_IN_TSF,
TSF_ERROR_INVALID_BRIDGERESISTANCE,
TSF_CALCULATED_CHANNEL_INVALID_CHAN_FIELD,
TSF_CALCULATED_CHANNEL_INVALID_EXPMAXRANGE,
TSF_CALCULATED_CHANNEL_INVALID_FIRSTCHAN,
TSF_CALCULATED_CHANNEL_INVALID_PROCESSTYPE,
TSF_CALCULATED_CHANNEL_INVALID_PROGRESS2,
TSF_CALCULATED_CHANNEL_INVALID_PROGRESS3,
TSF_CALCULATED_CHANNEL_INVALID_SECONDCHAN,
TSF_CALCULATED_CHANNEL_INVALID_THIRDCHAN,
TSF_CALCULATED_CHANNEL_INVALID_VALUE,
TSF_DIGITALCHANNEL_INVALID_CHAN,
TSF_DIGITALCHANNEL_INVALID_DELAY,
TSF_DIGITALCHANNEL_INVALID_DURATION,
TSF_DIGITALCHANNEL_INVALID_DURATIONON,
TSF_DIGITALCHANNEL_INVALID_MODULE,
TSF_DIGITALCHANNEL_INVALID_RACK,
TSF_DIGITALCHANNEL_INVALID_TYPE,
TSF_SQUIBFIREENTRY_INVALID_CHAN,
TSF_SQUIBFIREENTRY_INVALID_CURRENT,
TSF_SQUIBFIREENTRY_INVALID_DELAY,
TSF_SQUIBFIREENTRY_INVALID_DURATION,
TSF_SQUIBFIREENTRY_INVALID_DURATIONON,
TSF_SQUIBFIREENTRY_INVALID_MODULE,
TSF_SQUIBFIREENTRY_INVALID_OHMHIGH,
TSF_SQUIBFIREENTRY_INVALID_OHMLOW,
TSF_SQUIBFIREENTRY_RACK,
TSF_SQUIBFIREENTRY_TYPE,
TSF_DIM_INVALID_CABLETEST,
TSF_DIM_INVALID_CHAN,
TSF_DIM_INVALID_DATACHAN,
TSF_DIM_INVALID_FILTERMODE,
TSF_DIM_INVALID_FILTERTHRESHOLD,
TSF_DIM_INVALID_INVERTED,
TSF_DIM_INVALID_MODULE,
TSF_DIM_INVALID_RACK,
TSF_DIM_INVALID_SCALE,
TSF_G5DIGITALCHANNEL_INVALID_CHAN,
TSF_G5DIGITALCHANNEL_INVALID_DATACHAN,
TSF_G5DIGITALCHANNEL_INVALID_INVERT,
TSF_G5DIGITALCHANNEL_INVALID_MODULE,
TSF_G5DIGITALCHANNEL_INVALID_RACK,
TSF_G5DIGITALCHANNEL_INVALID_SCALE,
RACKINFORMATIONSECTION_INVALIDHEADER,
RACKINFORMATIONSECTION_INVALIDCOLUMNHEADER,
MODULEINFORMATIONSECTION_BADHEADER,
MODULEINFORMATIONSECTION_BADCOLUMHEADER,
SENSORCHANNELSECTION_INVALIDHEADER,
SENSORCHANNELSECTION_INVALIDCOLUMNHEADER,
CALCULATEDCHANNELSSECTION_INVALIDSECTIONHEADER,
CALCULATEDCHANNELSECTION_INVALIDCOLUMNHEADER,
G5DIGITALINPUTSECTION_START_INVALID_HEADER,
G5DIGITALINPUTSECTION_COLUMN_INVALID_HEADER,
TSF_DIM_INVALID_SECTIONSTARTHEADER,
TSF_DIM_INVALID_COLUMNSECTIONHEADER,
TCF_INVALID_STARTSECTIONHEADER,
TSF_TCF_INVALID_SECTIONENDHEADER,
TSF_TOMCHANNEL_INVALID_SECTIONSTART,
TSF_TOMCHANNEL_INVALID_SQUIBFIREHEADER,
TSF_SQUIBFIRECHANNELS_INVALID_COLUMNSHEADER,
TSF_TOMCHANNEL_INVALID_DIGITALCOLUMNSHEADER,
TSF_SENSOR_CHANNEL_INVALID_FILTER,
TSF_SENSOR_CHANNEL_INVALID_OFFSET
}
private TSF_ERRORS _error;
/// <summary>
/// error in question
/// </summary>
public TSF_ERRORS Error { get { return _error; } }
private int _line = 0;
/// <summary>
/// the line number where error occurred
/// </summary>
public int LineNumber { get { return _line; } }
/// <summary>
/// any additional information for the error
/// </summary>
private string _extraInfo = "";
public string ExtraInfo { get { return _extraInfo; } }
public ReadTSFError(TSF_ERRORS error) { _error = error; }
public ReadTSFError(TSF_ERRORS error, int line) { _error = error; _line = line; }
public ReadTSFError(TSF_ERRORS error, int line, string extraInfo) { _error = error; _line = line; _extraInfo = extraInfo; }
}
}

View File

@@ -0,0 +1,399 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB.TSF
{
/// <summary>
/// helper class for TOM Channel Information section of the TSF
/// </summary>
public class TSFTOMChannelInformationSection
{
private const string START_SECTION_HEADER = "---- Start TOM Channel Information ----";
private const string TOM_SQUIBFIRE_CHANNELS_HEADER = "---- TOM Squib Fire Channels ----";
private const string TOM_SQUIBFIRE_COLUMNS_HEADER = "rack,module,chan,descrip,id,type,current,delay,durationON,duration,OhmLow,OhmHigh";
private const string TOM_DIGITALCHANNELS_HEADER = "---- TOM Digital Channels ----";
private const string TOM_DIGITALCHANNELS_COLUMNS = "rack,module,chan,type,delay,durationON,duration";
private const string END_SECTION_HEADER = "---- End TOM Channel Information ----";
/// <summary>
/// squib fire entries in the section
/// </summary>
private List<TSFSquibFireEntry> _squibFireEntries = new List<TSFSquibFireEntry>();
public TSFSquibFireEntry[] SquibFireEntries
{
get { return _squibFireEntries.ToArray(); }
set { _squibFireEntries = new List<TSFSquibFireEntry>(value); }
}
/// <summary>
/// digital output channels in the section
/// </summary>
private List<TSFTOMDigitalOutputChannel> _digitalChannelEntries = new List<TSFTOMDigitalOutputChannel>();
public TSFTOMDigitalOutputChannel[] DigitalChannelEntries
{
get { return _digitalChannelEntries.ToArray(); }
set { _digitalChannelEntries = new List<TSFTOMDigitalOutputChannel>(value); }
}
/// <summary>
/// reads the section a TSF file
/// assumes currentline is the start of the section
/// </summary>
/// <param name="lines"></param>
/// <param name="currentLine"></param>
/// <param name="errors"></param>
public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors)
{
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.TSF_TOMCHANNEL_INVALID_SECTIONSTART, currentLine, startSection));
return;
}
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string squibFireChannelsHeader = lines[currentLine++];
if (squibFireChannelsHeader != TOM_SQUIBFIRE_CHANNELS_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_TOMCHANNEL_INVALID_SQUIBFIREHEADER, currentLine, squibFireChannelsHeader));
return;
}
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string columnsHeader = lines[currentLine++];
if (false == columnsHeader.Contains(TOM_SQUIBFIRE_COLUMNS_HEADER))
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIRECHANNELS_INVALID_COLUMNSHEADER, currentLine, columnsHeader));
return;
}
bool done = false;
List<TSFSquibFireEntry> squibFireEntries = new List<TSFSquibFireEntry>();
while (!done)
{
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string line = lines[currentLine++];
if (!line.Contains("TOM Digital Channels"))
{
string[] tokens = line.Split(new char[] { ',' });
TSFSquibFireEntry squib = new TSFSquibFireEntry();
for (int iCurField = 0; iCurField < tokens.Length; iCurField++)
{
TSFSquibFireEntry.Fields field = (TSFSquibFireEntry.Fields)iCurField;
string s = tokens[iCurField];
switch (field)
{
case TSFSquibFireEntry.Fields.chan:
try { squib.Chan = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIREENTRY_INVALID_CHAN, currentLine, s)); }
break;
case TSFSquibFireEntry.Fields.current:
try { squib.Current = Convert.ToDouble(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIREENTRY_INVALID_CURRENT, currentLine, s)); }
break;
case TSFSquibFireEntry.Fields.delay:
try { squib.Delay = Convert.ToDouble(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIREENTRY_INVALID_DELAY, currentLine, s)); }
break;
case TSFSquibFireEntry.Fields.descrip:
{
if (string.IsNullOrEmpty(s)) { s = "Squib"; }
squib.Description = s;
}
break;
case TSFSquibFireEntry.Fields.duration:
try { squib.Duration = Convert.ToDouble(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIREENTRY_INVALID_DURATION, currentLine, s)); }
break;
case TSFSquibFireEntry.Fields.durationON:
try
{
switch (s)
{
case "0":
case "F":
case "N": squib.DurationOn = false; break;
case "1":
case "T":
case "Y": squib.DurationOn = true; break;
default:
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIREENTRY_INVALID_DURATIONON, currentLine, s));
break;
}
}
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIREENTRY_INVALID_DURATIONON, currentLine, s)); }
break;
case TSFSquibFireEntry.Fields.id: squib.Id = s; break;
case TSFSquibFireEntry.Fields.ISOcode: squib.ISOcode = s; break;
case TSFSquibFireEntry.Fields.module:
try { squib.Module = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIREENTRY_INVALID_MODULE, currentLine, s)); }
break;
case TSFSquibFireEntry.Fields.OhmHigh:
try { squib.OhmHigh = Convert.ToDouble(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIREENTRY_INVALID_OHMHIGH, currentLine, s)); }
break;
case TSFSquibFireEntry.Fields.OhmLow:
try { squib.OhmLow = Convert.ToDouble(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIREENTRY_INVALID_OHMLOW, currentLine, s)); }
break;
case TSFSquibFireEntry.Fields.rack:
try { squib.Rack = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIREENTRY_RACK, currentLine, s)); }
break;
case TSFSquibFireEntry.Fields.type:
try { squib.Type = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SQUIBFIREENTRY_TYPE, currentLine, s)); }
break;
default: throw new NotSupportedException("TSFFile::ReadTSF unsupported squib field: " + field.ToString());
}
}
squibFireEntries.Add(squib);
// Some code from TDC and HLAPI
// doesn't seem to be needed for datapro, but preserved here
/*
// IF THIS IS A NEW MODULE THEN RESET THE TOM CHANNEL COUNTER
if(r!=tomr || m!=tomm)
{
tomc=0;
}
tomr=r;
tomm=m;
// SET ALL TOM DATA CHANNEL DEFAULTS
for(k=0;k<2;k++)
{
static char firetype[32];
tomc = (c-1)*2+k+1;
TOMDataChannel++;
Sensor_DataChan[r][m][tomc]=TOMDataChannel;
// DETERMINE FIRE TYPE
FillBytes(firetype, 0, sizeof(firetype), 0);
if (TOM_Squib_FireType[r][m][c]==1)
{
strcpy(firetype, "DC Cap Discharge");
}
if (TOM_Squib_FireType[r][m][c]==2)
{
strcpy(firetype, "DC Constant Current");
}
if (TOM_Squib_FireType[r][m][c]==3)
{
strcpy(firetype, "AC Cap Discharge");
}
FillBytes(Sensor_ChanDescription[r][m][tomc], 0, sizeof(Sensor_ChanDescription[r][m][tomc]), 0);
FillBytes(Sensor_EngUnit[r][m][tomc], 0, sizeof(Sensor_EngUnit[r][m][tomc]), 0);
if(k==0)
{
// DESCRIPTION AND ENG UNIT
if(TOM_Recording==0)
{
Fmt(Sensor_ChanDescription[r][m][tomc],"%s<%s - Fire Voltage (%s)", TOM_Squib_Description[r][m][c], firetype);
strcpy(Sensor_EngUnit[r][m][tomc], ( 0 == stricmp (CustomerName, "gm daewoo") ) ? "V" : "Volts");
}
else
{
Fmt(Sensor_ChanDescription[r][m][tomc],"%s<%s - Initiation Pulse (%s)", TOM_Squib_Description[r][m][c], firetype);
strcpy(Sensor_EngUnit[r][m][tomc], "Initiation");
}
}
else
{
// DESCRIPTION AND ENG UNIT
Fmt(Sensor_ChanDescription[r][m][tomc],"%s<%s - Fire Current (%s)", TOM_Squib_Description[r][m][c], firetype);
strcpy(Sensor_EngUnit[r][m][tomc], ( 0 == stricmp (CustomerName, "gm daewoo") ) ? "A" : "Amps" );
}
// ISO CODE
if(k==0)
{
FillBytes(Sensor_ISOCode[r][m][tomc], 0, sizeof(Sensor_ISOCode[r][m][tomc]), 0);
strcpy(Sensor_ISOCode[r][m][tomc], TOM_ISOCode[r][m][c]);
}
else
{
FillBytes(Sensor_ISOCode[r][m][tomc], 0, sizeof(Sensor_ISOCode[r][m][tomc]), 0);
CopyBytes (Sensor_ISOCode[r][m][tomc], 0, TOM_ISOCode[r][m][c], 0, 12);
strcat(Sensor_ISOCode[r][m][tomc], "CU");
FillBytes(dummy, 0, sizeof(dummy), 0);
CopyBytes (dummy, 0, TOM_ISOCode[r][m][c], 14, 2);
strcat(Sensor_ISOCode[r][m][tomc], dummy);
}
Sensor_Sensitivity[r][m][tomc]=1.0;
Sensor_Gain[r][m][tomc]=1.0;
if(SampleRate>8000.)
{
Sensor_Filter[r][m][tomc]=1650;
}
else
{
Sensor_Filter[r][m][tomc]= (int)floor(SampleRate/5.);
}
Sensor_InvertData[r][m][tomc]=0;
Sensor_ZeroRef[r][m][tomc]=1;
Sensor_DesiredMaxRange[r][m][tomc]=20.0;
Sensor_SNRatio[r][m][tomc]=80.0;
}
if(n!=14)
{
ReadError=3;
}*/
}
else { done = true; }
}
SquibFireEntries = squibFireEntries.ToArray();
// READ TOM DIGITAL CHANNELS
List<TSFTOMDigitalOutputChannel> digitalChannels = new List<TSFTOMDigitalOutputChannel>();
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string digitalColumns = lines[currentLine++];
if (digitalColumns != TOM_DIGITALCHANNELS_COLUMNS)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_TOMCHANNEL_INVALID_DIGITALCOLUMNSHEADER, currentLine, digitalColumns));
return;
}
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.Contains("End TOM Channel Information"))
{
string[] tokens = line.Split(new char[] { ',' });
TSFTOMDigitalOutputChannel digital = new TSFTOMDigitalOutputChannel();
for (int iCurField = 0; iCurField < tokens.Length; iCurField++)
{
string s = tokens[iCurField];
TSFTOMDigitalOutputChannel.Fields field = (TSFTOMDigitalOutputChannel.Fields)iCurField;
switch (field)
{
case TSFTOMDigitalOutputChannel.Fields.chan:
try { digital.Chan = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIGITALCHANNEL_INVALID_CHAN, currentLine, s)); }
break;
case TSFTOMDigitalOutputChannel.Fields.delay:
try { digital.Delay = Convert.ToDouble(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIGITALCHANNEL_INVALID_DELAY, currentLine, s)); }
break;
case TSFTOMDigitalOutputChannel.Fields.duration:
try { digital.Duration = Convert.ToDouble(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIGITALCHANNEL_INVALID_DURATION, currentLine, s)); }
break;
case TSFTOMDigitalOutputChannel.Fields.durationON:
try
{
switch (s)
{
case "0":
case "N":
case "F":
digital.DurationOn = false; break;
case "1":
case "T":
case "Y":
digital.DurationOn = true; break;
default:
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIGITALCHANNEL_INVALID_DURATIONON, currentLine, s));
}
break;
}
}
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIGITALCHANNEL_INVALID_DURATIONON, currentLine, s)); }
break;
case TSFTOMDigitalOutputChannel.Fields.module:
try { digital.Module = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIGITALCHANNEL_INVALID_MODULE, currentLine, s)); }
break;
case TSFTOMDigitalOutputChannel.Fields.rack:
try { digital.Rack = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIGITALCHANNEL_INVALID_RACK, currentLine, s)); }
break;
case TSFTOMDigitalOutputChannel.Fields.type:
try
{
switch (s)
{
case "0": digital.Type = TSFTOMDigitalOutputChannel.DigitalOutputTypes.NONE; break;
case "1":
case "5VLH":
digital.Type = TSFTOMDigitalOutputChannel.DigitalOutputTypes.FiveVLH; break;
case "2":
case "5VHL":
digital.Type = TSFTOMDigitalOutputChannel.DigitalOutputTypes.FiveVHL; break;
case "3":
case "CCNO":
digital.Type = TSFTOMDigitalOutputChannel.DigitalOutputTypes.CCNO; break;
case "4":
case "CCNC":
digital.Type = TSFTOMDigitalOutputChannel.DigitalOutputTypes.CCNC; break;
default:
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIGITALCHANNEL_INVALID_TYPE, currentLine, s));
}
break;
}
}
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIGITALCHANNEL_INVALID_TYPE, currentLine, s)); }
break;
default: throw new NotSupportedException("TSFFile::ReadTSF unknown digital channel field: " + field.ToString());
}
}
digitalChannels.Add(digital);
}
else { done = true; }
}
DigitalChannelEntries = digitalChannels.ToArray();
}
}
}

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB.TSF
{
/// <summary>
/// a calculated channel section entry in a TSF
/// each entry can contain
/// chan,descrip,processtype,1stchan,2ndchan,3rdchan,value,EU,expmaxrange
/// we currently do nothing with the entries in DataPRO
/// </summary>
public class TSFCalculatedChannelEntry : TSFChannel
{
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 int _processType;
public int ProcessType { get { return _processType; } set { _processType = value; } }
private int _firstChan;
public int FirstChan { get { return _firstChan; } set { _firstChan = value; } }
private int _secondChan;
public int SecondChan { get { return _secondChan; } set { _secondChan = value; } }
private int _thirdChan;
public int ThirdChan { get { return _thirdChan; } set { _thirdChan = value; } }
private double _value;
public double Value { get { return _value; } set { _value = value; } }
private string _eu;
public string EU { get { return _eu; } set { _eu = value; } }
private double _expMaxRange;
public double ExpMaxRange { get { return _expMaxRange; } set { _expMaxRange = value; } }
private double _progress2;
public double Progress2 { get { return _progress2; } set { _progress2 = value; } }
private double _progress3;
public double Progress3 { get { return _progress3; } set { _progress3 = value; } }
public enum Fields
{
chan,
descrip,
processtype,
firstchan,//%i
secondchan,//%i
thirdchan,//%i
value,//%f
EU,//%s
expmaxrange,//%f
progress2,//%f
progress3 //%f
}
}
}

View File

@@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB.TSF
{
/// <summary>
/// handles the CalculateChannelInformation section of the TSF
/// </summary>
public class TSFCalculatedChannelInformationSection
{
private const string SECTION_START_HEADER = "---- Start Calculated Channel Information ----";
private const string COLUMN_HEADER = "chan,descrip,processtype,1stchan,2ndchan,3rdchan,value,EU,expmaxrange";
private const string SECTION_END_HEADER = "---- End Calculated Channel Information ----";
private List<TSFCalculatedChannelEntry> _calculatedChannels = new List<TSFCalculatedChannelEntry>();
public TSFCalculatedChannelEntry[] CalculatedChannels
{
get { return _calculatedChannels.ToArray(); }
set { _calculatedChannels = new List<TSFCalculatedChannelEntry>(value); }
}
/// <summary>
/// reads section from TSF
/// assumes currentline is the start of the section
/// </summary>
/// <param name="lines"></param>
/// <param name="currentLine"></param>
/// <param name="errors"></param>
public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors)
{
_calculatedChannels.Clear();
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string sectionHeader = lines[currentLine++];
if (sectionHeader != SECTION_START_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.CALCULATEDCHANNELSSECTION_INVALIDSECTIONHEADER, currentLine, sectionHeader));
return;
}
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string columnsHeader = lines[currentLine++];
if (columnsHeader != COLUMN_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.CALCULATEDCHANNELSECTION_INVALIDCOLUMNHEADER, currentLine, columnsHeader));
return;
}
var invariant = System.Globalization.CultureInfo.InvariantCulture;
bool done = false;
List<TSFCalculatedChannelEntry> calculatedChannels = new List<TSFCalculatedChannelEntry>();
while (!done)
{
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string line = lines[currentLine++];
if (!line.Contains("End Calculated Channel Information"))
{
string[] tokens = line.Split(new char[] { ',' });
TSFCalculatedChannelEntry cc = new TSFCalculatedChannelEntry();
for (int iCurField = 0; iCurField < tokens.Length; iCurField++)
{
string s = tokens[iCurField];
TSFCalculatedChannelEntry.Fields field = (TSFCalculatedChannelEntry.Fields)iCurField;
switch (field)
{
case TSFCalculatedChannelEntry.Fields.chan:
try { cc.Chan = Convert.ToInt32(s, invariant); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_CALCULATED_CHANNEL_INVALID_CHAN_FIELD, currentLine, s)); }
break;
case TSFCalculatedChannelEntry.Fields.descrip: cc.Description = s; break;
case TSFCalculatedChannelEntry.Fields.EU: cc.EU = s; break;
case TSFCalculatedChannelEntry.Fields.expmaxrange:
try { cc.ExpMaxRange = Convert.ToDouble(s, invariant); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_CALCULATED_CHANNEL_INVALID_EXPMAXRANGE, currentLine, s)); }
break;
case TSFCalculatedChannelEntry.Fields.firstchan:
try { cc.FirstChan = Convert.ToInt32(s, invariant); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_CALCULATED_CHANNEL_INVALID_FIRSTCHAN, currentLine, s)); }
break;
case TSFCalculatedChannelEntry.Fields.processtype:
try { cc.ProcessType = Convert.ToInt32(s, invariant); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_CALCULATED_CHANNEL_INVALID_PROCESSTYPE, currentLine, s)); }
break;
case TSFCalculatedChannelEntry.Fields.progress2:
try { cc.Progress2 = Convert.ToDouble(s, invariant); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_CALCULATED_CHANNEL_INVALID_PROGRESS2, currentLine, s)); }
break;
case TSFCalculatedChannelEntry.Fields.progress3:
try { cc.Progress3 = Convert.ToDouble(s, invariant); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_CALCULATED_CHANNEL_INVALID_PROGRESS3, currentLine, s)); }
break;
case TSFCalculatedChannelEntry.Fields.secondchan:
try { cc.SecondChan = Convert.ToInt32(s, invariant); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_CALCULATED_CHANNEL_INVALID_SECONDCHAN, currentLine, s)); }
break;
case TSFCalculatedChannelEntry.Fields.thirdchan:
try { cc.ThirdChan = Convert.ToInt32(s, invariant); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_CALCULATED_CHANNEL_INVALID_THIRDCHAN, currentLine, s)); }
break;
case TSFCalculatedChannelEntry.Fields.value:
try { cc.Value = Convert.ToDouble(s, invariant); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_CALCULATED_CHANNEL_INVALID_VALUE, currentLine, s)); }
break;
}
}
calculatedChannels.Add(cc);
}
else { done = true; }
CalculatedChannels = calculatedChannels.ToArray();
}
}
}
}

View File

@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// handles the calibration information section of the TSF
/// </summary>
public class TSFCalibrationInformation
{
private int _version;
public int Version { get { return _version; } set { _version = value; } }
private TSFChannelDescription _parent;
public TSFChannelDescription Parent { get { return _parent; } set { _parent = value; } }
private int _source;
public int Source { get { return _source; } set { _source = value; } }
private ulong _crc32;
public ulong CRC32 { get { return _crc32; } set { _crc32 = value; } }
private bool _calibrationValid;
public bool CalibrationValid { get { return _calibrationValid; } set { _calibrationValid = value; } }
private bool _calPas;
public bool CalPass { get { return _calPas; } set { _calPas = value; } }
private double _calGainErrorPercent;
public double CalGainErrorPercent { get { return _calGainErrorPercent; } set { _calGainErrorPercent = value; } }
private double _calShuntErrorPercent;
public double CalShuntErrorPercent { get { return _calShuntErrorPercent; } set { _calShuntErrorPercent = value; } }
private double _calMeasuredScaleFactorMV;
public double CalMeasuredScaleFactorMV { get { return _calMeasuredScaleFactorMV; } set { _calMeasuredScaleFactorMV = value; } }
private double _calExcitationVolts;
public double CalExcitationVolts { get { return _calExcitationVolts; } set { _calExcitationVolts = value; } }
private int _calChannelOffsetADC;
public int CalChannelOffsetADC { get { return _calChannelOffsetADC; } set { _calChannelOffsetADC = value; } }
private int _calChannelZeroADC;
public int CalChannelZeroADC { get { return _calChannelZeroADC; } set { _calChannelZeroADC = value; } }
private double _calNaturalSensorOffsetMV;
public double CalNaturalSensorOffsetMV { get { return _calNaturalSensorOffsetMV; } set { _calNaturalSensorOffsetMV = value; } }
private int _calNaturalFloorADC;
public int CalNaturalFloorADC { get { return _calNaturalFloorADC; } set { _calNaturalFloorADC = value; } }
private double _calInputRangeMV { get { return _calInputRangeMV; } set { _calInputRangeMV = value; } }
private double _calNoiseFloorADC;
public double CalNoiseFloorADC { get { return _calNoiseFloorADC; } set { _calNoiseFloorADC = value; } }
private double _calNoiseAtRangeADC;
public double CalNoiseAtRangeADC { get { return _calNoiseAtRangeADC; } set { _calNoiseAtRangeADC = value; } }
public TSFCalibrationInformation() { }
public TSFCalibrationInformation(TSFCalibrationInformation copy, TSFChannelDescription channel)
{
_calChannelOffsetADC = copy._calChannelOffsetADC;
_calChannelZeroADC = copy._calChannelZeroADC;
_calExcitationVolts = copy._calExcitationVolts;
_calGainErrorPercent = copy._calGainErrorPercent;
_calibrationValid = copy._calibrationValid;
_calInputRangeMV = copy._calInputRangeMV;
_calMeasuredScaleFactorMV = copy._calMeasuredScaleFactorMV;
_calNaturalFloorADC = copy._calNaturalFloorADC;
_calNaturalSensorOffsetMV = copy._calNaturalSensorOffsetMV;
_calNoiseAtRangeADC = copy._calNoiseAtRangeADC;
_calNoiseFloorADC = copy._calNoiseFloorADC;
_calPas = copy._calPas;
_calShuntErrorPercent = copy._calShuntErrorPercent;
_crc32 = copy._crc32;
_parent = channel;
_source = copy._source;
_version = copy._version;
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// this class just adds TestChannelNumber to all channels in a TSF
/// some sections have a datachannel #, however tom squib fire channels don't, tom digital channels don't, etc
/// it's advantageous to still be able to index those channels as well
/// </summary>
public abstract class TSFChannel
{
public const int NOT_ASSIGNED = -1;
private int _testChannelNumber = NOT_ASSIGNED;
public int TestChannelNumber
{
get { return _testChannelNumber; }
set { _testChannelNumber = value; }
}
}
}

View File

@@ -0,0 +1,148 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// this class is stolen from HLAPI I imported it hoping to steal some of the code from HLAPI
/// however it's only sparsely used right now ...
/// </summary>
public class TSFChannelDescription
{
private int _version;
public int Version { get { return _version; } set { _version = value; } }
/// <summary>
/// See HLAPI_CHANNEL_TYPE_
/// </summary>
private int _type;
public int Type { get { return _type; } set { _type = value; } }
private TSFModuleDescription _parent;
public TSFModuleDescription Parent { get { return _parent; } set { _parent = value; } }
private int _source;
public int Source { get { return _source; } set { _source = value; } }
private ulong _crc32;
public ulong CRC32 { get { return _crc32; } set { _crc32 = value; } }
private bool _sensorInfoValid = false;
public bool SensorInfoValid { get { return _sensorInfoValid; } set { _sensorInfoValid = value; } }
private TSFInputChannelDescription _inputChannel;
public TSFInputChannelDescription InputChannel { get { return _inputChannel; } set { _inputChannel = value; } }
private TSFOutputChannelDescription _outputChannel;
public TSFOutputChannelDescription OutputChannel { get { return _outputChannel; } set { _outputChannel = value; } }
private string _userChannelNumber = "";
public string SensorUserChannelNumber { get { return _userChannelNumber; } set { _userChannelNumber = value; } }
private string _sensorUserChannelDescription = "";
public string SensorUserChannelDescription { get { return _sensorUserChannelDescription; } set { _sensorUserChannelDescription = value; } }
private string _sensorEID = "";
public string SensorEID { get { return _sensorEID; } set { _sensorEID = value; } }
private List<string> _sensorEIDs = new List<string>();
public string[] SensorEIDs { get { return _sensorEIDs.ToArray(); } set { _sensorEIDs = new List<string>(value); } }
private int _numSensorEIDs;
public int NumSensorEIDs { get { return _numSensorEIDs; } set { _numSensorEIDs = value; } }
// Pre-cal results
/// <summary>
/// Is PreCalResults valid?
/// </summary>
private bool _preCalibrationInfoValid;
public bool PreCalibrationInfoValid { get { return _preCalibrationInfoValid; } set { _preCalibrationInfoValid = value; ; } }
/// <summary>
/// The pre-calibration results.
/// </summary>
private TSFCalibrationInformation _preCalResults;
public TSFCalibrationInformation PreCalResults { get { return _preCalResults; } set { _preCalResults = value; } }
/// <summary>
/// When a unit is powered down,
/// this is our saved copy of PreCalResults.
/// It's not NULL if it's valid.
/// </summary>
private TSFCalibrationInformation _savedPreCalResults;
public TSFCalibrationInformation SavedPreCalResults { get { return _savedPreCalResults; } set { _savedPreCalResults = value; } }
// Post-cal results
/// <summary>
/// Is PostCalResults valid?
/// </summary>
private bool _postCalibrationInfoValid;
public bool PostCalibrationInfoValid { get { return _postCalibrationInfoValid; } set { _postCalibrationInfoValid = value; } }
/// <summary>
/// The post-calibration results.
/// </summary>
private TSFCalibrationInformation _postCalResults;
public TSFCalibrationInformation PostCalResults { get { return _postCalResults; } set { _postCalResults = value; } }
/// <summary>
/// Is the Download* variables valid?
/// </summary>
private bool _downloadDataValid;
public bool DownloadDataValid { get { return _downloadDataValid; } set { _downloadDataValid = value; } }
/// <summary>
/// The downloaded data is from this many seconds before t=0
/// </summary>
private double _downloadBeginSeconds;
public double DownloadBeginSeconds { get { return _downloadBeginSeconds; } set { _downloadBeginSeconds = value; } }
/// <summary>
/// The downloaded data is to this many seconds after t=0
/// </summary>
private double _downloadEndSeconds;
public double DownloadEndSeconds { get { return _downloadEndSeconds; } set { _downloadEndSeconds = value; } }
/// <summary>
/// How many elements in DownloadDataADC
/// </summary>
private int _downloadDataCount;
public int DownloadDataCount { get { return _downloadDataCount; } set { _downloadDataCount = value; } }
/// <summary>
/// The filename where the downloaded data is stored
/// </summary>
private string _downloadDataFileName;
public string DownloadDataFileName { get { return _downloadDataFileName; } set { _downloadDataFileName = value; } }
public TSFChannelDescription() { }
public TSFChannelDescription(TSFChannelDescription copy, TSFModuleDescription module)
{
_crc32 = copy._crc32;
_downloadBeginSeconds = copy._downloadBeginSeconds;
_downloadDataCount = copy._downloadDataCount;
_downloadDataFileName = copy._downloadDataFileName;
_downloadDataValid = copy._downloadDataValid;
_downloadEndSeconds = copy._downloadEndSeconds;
if (null != copy._inputChannel) { _inputChannel = new TSFInputChannelDescription(copy._inputChannel, this); }
_numSensorEIDs = copy._numSensorEIDs;
if (null != copy._outputChannel) { _outputChannel = new TSFOutputChannelDescription(copy._outputChannel, this); }
_parent = module;
_postCalibrationInfoValid = copy._postCalibrationInfoValid;
if (null != copy._postCalResults) { _postCalResults = new TSFCalibrationInformation(copy._postCalResults, this); }
_preCalibrationInfoValid = copy._preCalibrationInfoValid;
if (null != copy._preCalResults) { _preCalResults = new TSFCalibrationInformation(copy._preCalResults, this); }
if (null != copy._savedPreCalResults) { _savedPreCalResults = new TSFCalibrationInformation(copy._savedPreCalResults, this); }
_sensorEID = copy._sensorEID;
_sensorEIDs = new List<string>(copy._sensorEIDs.ToArray());
_sensorInfoValid = copy._sensorInfoValid;
_sensorUserChannelDescription = copy._sensorUserChannelDescription;
_source = copy._source;
_type = copy._type;
_userChannelNumber = copy._userChannelNumber;
_version = copy._version;
}
}
}

View File

@@ -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
}
}
}

View File

@@ -0,0 +1,121 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB.TSF
{
/// <summary>
/// the DIM section of a TSF
/// we currently do nothing with the DIM section other than parse it
/// DIMs are not officially supported in DataPRO yet
/// </summary>
public class TSFDIMSection
{
private const string SECTION_START_HEADER = "---- DIM Begin (1.0) ----";
private const string COLUMN_HEADER = "Datachan,Rack,Module,Chan,Description,Serial No,Mode,Inverted,EID,Filename,Scale,Filter Mode,Filter Threshold,ISO CODE,Cable Test";
private const string SECTION_END_HEADER = "---- DIM End ----";
private List<TSFDIMEntry> _dimEntries = new List<TSFDIMEntry>();
public TSFDIMEntry[] DIMEntries
{
get { return _dimEntries.ToArray(); }
set { _dimEntries = new List<TSFDIMEntry>(value); }
}
public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors)
{
if (currentLine == lines.Count)
{
//errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string sectionStart = lines[currentLine++];
if (false == sectionStart.Contains(SECTION_START_HEADER))
{
//DIM Section may not be defined for this TSF. Bail and dont error.
currentLine--;
return;
}
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string columnHeaders = lines[currentLine++];
if (columnHeaders != COLUMN_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIM_INVALID_COLUMNSECTIONHEADER, currentLine, columnHeaders));
return;
}
bool done = false;
List<TSFDIMEntry> dims = new List<TSFDIMEntry>();
while (!done)
{
if (currentLine == lines.Count) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine)); return; }
string line = lines[currentLine++];
if (!line.Contains("DIM End"))
{
TSFDIMEntry entry = new TSFDIMEntry();
string[] tokens = line.Split(new char[] { ',' });
for (int iCurField = 0; iCurField < tokens.Length; iCurField++)
{
string s = tokens[iCurField];
TSFDIMEntry.Fields field = (TSFDIMEntry.Fields)iCurField;
switch (field)
{
case TSFDIMEntry.Fields.CableTest:
try { entry.CableTest = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIM_INVALID_CABLETEST, currentLine, s)); }
break;
case TSFDIMEntry.Fields.Chan:
try { entry.Chan = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIM_INVALID_CHAN, currentLine, s)); }
break;
case TSFDIMEntry.Fields.Datachan:
try { entry.DataChan = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIM_INVALID_DATACHAN, currentLine, s)); }
break;
case TSFDIMEntry.Fields.Description: entry.Description = s; break;
case TSFDIMEntry.Fields.EID: entry.EID = s; break;
case TSFDIMEntry.Fields.Filename: entry.FileName = s; break;
case TSFDIMEntry.Fields.FilterMode:
try { entry.FilterMode = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIM_INVALID_FILTERMODE, currentLine, s)); }
break;
case TSFDIMEntry.Fields.FilterThreshold:
try { entry.FilterThreshold = Convert.ToDouble(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIM_INVALID_FILTERTHRESHOLD, currentLine, s)); }
break;
case TSFDIMEntry.Fields.Inverted:
try { entry.Inverted = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIM_INVALID_INVERTED, currentLine, s)); }
break;
case TSFDIMEntry.Fields.ISOCODE: entry.ISOCode = s; break;
case TSFDIMEntry.Fields.Mode: entry.Mode = s; break;
case TSFDIMEntry.Fields.Module:
try { entry.Module = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIM_INVALID_MODULE, currentLine, s)); }
break;
case TSFDIMEntry.Fields.Rack:
try { entry.Rack = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIM_INVALID_RACK, currentLine, s)); }
break;
case TSFDIMEntry.Fields.Scale:
try { entry.Scale = Convert.ToDouble(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_DIM_INVALID_SCALE, currentLine, s)); }
break;
case TSFDIMEntry.Fields.SerialNo: entry.SerialNumber = s; break;
default: throw new NotSupportedException("TSFFile::ReadTSF unknown DIM field: " + field.ToString());
}
}
dims.Add(entry);
}
else { done = true; }
}
DIMEntries = dims.ToArray();
}
}
}

View File

@@ -0,0 +1,80 @@
using DTS.Common.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// an entry in TOM Digital Channels portion of TOM Channel Information section
/// each entry can contain
/// rack,module,chan,type,delay,durationON,duration
/// These are Output Channels
/// </summary>
public class TSFTOMDigitalOutputChannel : TSFChannel
{
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; } }
public enum DigitalOutputTypes
{
NONE = 0,
FiveVLH = 1,
FiveVHL = 2,
CCNO = 3,
CCNC = 4
}
public static DigitalOutputModes GetDigitalOutputMode(DigitalOutputTypes outputType)
{
switch (outputType)
{
case TSFTOMDigitalOutputChannel.DigitalOutputTypes.CCNC:
return DigitalOutputModes.CCNC;
case TSFTOMDigitalOutputChannel.DigitalOutputTypes.CCNO:
return DigitalOutputModes.CCNO;
case TSFTOMDigitalOutputChannel.DigitalOutputTypes.FiveVHL:
return DigitalOutputModes.FVHL;
case TSFTOMDigitalOutputChannel.DigitalOutputTypes.FiveVLH:
return DigitalOutputModes.FVLH;
case TSFTOMDigitalOutputChannel.DigitalOutputTypes.NONE:
default:
return DigitalOutputModes.NONE;
}
}
private DigitalOutputTypes _type = DigitalOutputTypes.NONE;
public DigitalOutputTypes Type { get { return _type; } set { _type = value; } }
private double _delay;
public double Delay { get { return _delay; } set { _delay = value; } }
private bool _DurationOn;
public bool DurationOn { get { return _DurationOn; } set { _DurationOn = value; } }
private double _duration;
public double Duration { get { return _duration; } set { _duration = value; } }
private string _description = "N/A";
public string Description { get { return _description; } set { _description = value; } }
public enum Fields
{
rack, //%i
module, //%i
chan, //%i
type, //%i
delay, //%f
durationON, //%i
duration //%f
}
}
}

View File

@@ -0,0 +1,239 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTS.SensorDB.TSF;
namespace DTS.SensorDB
{
/// <summary>
/// helper class to read/write TSF files
/// mostly taken from TDC code
/// </summary>
public class TSFFile
{
private const double MINIMUM_BRIDGE_RESISTANCE_OHMS = 100D;
private const double MAXIMUM_BRIDGE_RESISTANCE_OHMS = 16000.0D;
/// <summary>
/// cribbed from tdc, the string to indicate an empty rack
/// </summary>
public const string EMPTY_RACK_SN = "NONE";
/// <summary>
/// cribbed from TDC, crash barrier types
/// </summary>
public enum ICRASH_BARRIER_TYPE
{
IWALL_BARRIER = 0,
ITROLLEY_BARRIER = 1
};
/// <summary>
/// this is a replacement function for TDC functionality
/// we don't really have this functionality in datapro yet, so we have
/// a filler function for now
/// </summary>
/// <returns></returns>
public ICRASH_BARRIER_TYPE GetICrashBarrierType()
{
return ICRASH_BARRIER_TYPE.IWALL_BARRIER;
}
/// <summary>
/// set progress, value should be 0-1 (so multiply by 100 to get percent)
/// </summary>
/// <param name="value"></param>
public delegate void RegisterProgressDelgate(double value);
private string _softwareVersion;
public string SoftwareVersion { get { return _softwareVersion; } set { _softwareVersion = value; } }
private double _versionNumber;
public double VersionNumber { get { return _versionNumber; } set { _versionNumber = value; } }
private string _tsfName;
public string TSFName { get { return _tsfName; } set { _tsfName = value; } }
private string _sysDate;
public string SysDate { get { return _sysDate; } set { _sysDate = value; } }
private string _sysTime;
public string SysTime { get { return _sysTime; } set { _sysTime = value; } }
private string _testDescription;
public string TestDescription { get { return _testDescription; } set { _testDescription = value; } }
public enum Tags
{
SoftwareVersion,
VersionNumber,
TSFName,
SysDate,
SysTime,
TestDescription,
SamplingInformationSection,
RackInformationSection,
ModuleInformationSection,
SensorChannelSection,
CalculatedChannelSection,
TOMChannelSection,
TCFSection
}
private TSFTCFSection _tcfSection = new TSFTCFSection();
public TSFTCFSection TCFSection
{
get { return _tcfSection; }
set { _tcfSection = value; }
}
private TSFTOMChannelInformationSection _tomChannelSection = new TSFTOMChannelInformationSection();
public TSFTOMChannelInformationSection TOMChannelSection
{
get { return _tomChannelSection; }
set { _tomChannelSection = value; }
}
private TSFCalculatedChannelInformationSection _calculatedChannelSection = new TSFCalculatedChannelInformationSection();
public TSFCalculatedChannelInformationSection CalculatedChannelSection
{
get { return _calculatedChannelSection; }
set { _calculatedChannelSection = value; }
}
private TSFSensorChannelInformationSection _sensorChannelSection = new TSFSensorChannelInformationSection();
public TSFSensorChannelInformationSection SensorChannelSection
{
get { return _sensorChannelSection; }
set { _sensorChannelSection = value; }
}
private TSFModuleInformationSection _moduleInformationSection = new TSFModuleInformationSection();
public TSFModuleInformationSection ModuleInformationSection
{
get { return _moduleInformationSection; }
set { _moduleInformationSection = value; }
}
private TSFRackInformationSection _rackInformationSection = new TSFRackInformationSection();
public TSFRackInformationSection RackInformationSection
{
get { return _rackInformationSection; }
set { _rackInformationSection = value; }
}
private TSFSamplingInformationSection _samplingSection;
public TSFSamplingInformationSection SamplingInformationSection
{
get { return _samplingSection; }
set { _samplingSection = value; }
}
private TSFDIMSection _dimSection = new TSFDIMSection();
public TSFDIMSection DIMSection
{
get { return _dimSection; }
set { _dimSection = value; }
}
private TSFG5DigitalInputSection _g5DigitalInputSection = new TSFG5DigitalInputSection();
public TSFG5DigitalInputSection G5DigitalInputSection
{
get { return _g5DigitalInputSection; }
set { _g5DigitalInputSection = value; }
}
/// <summary>
/// read a TSF file, extract out all the different components
/// </summary>
/// <param name="filename"></param>
/// <param name="system"></param>
/// <param name="tsfReadProtocol"></param>
/// <param name="workingSIFDirectory"></param>
/// <param name="defaultAveWindowStart"></param>
/// <param name="defaultAveWindowStop"></param>
public void ReadTSF(string filename, TDCINIFile ini, string tsfReadProtocol, string workingSIFDirectory,
double defaultAveWindowStart, double defaultAveWindowStop, out List<ReadTSFError> errors, RegisterProgressDelgate setProgress)
{
errors = new List<ReadTSFError>();
var invariant = System.Globalization.CultureInfo.InvariantCulture;
// CHECK IF FILE EXISTS
if (!System.IO.File.Exists(filename))
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_FILE_NOT_FOUND));
return;
}
// TDC does this, it doesn't seem to be necessary for us
// DETERMINE DIRECTORY FROM WHICH TSF OPENED
//var fileInfo = new System.IO.FileInfo(filename);
//string location = fileInfo.DirectoryName;
// READ IN VALUES FROM TSF
List<string> lines = new List<string>();
try
{
lines.AddRange(System.IO.File.ReadAllLines(filename));
}
catch (System.Exception ex) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_FILE_IO_ERROR, 0, ex.Message)); return; }
if (lines.Count < 5) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSFFILE_INCOMPLETE)); return; }
SoftwareVersion = lines[0];
try { VersionNumber = double.Parse(SoftwareVersion.Substring(0, 3), invariant); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_INVALID_VERSION, 0, SoftwareVersion)); return; }
//tdc sets some static variables for rack sizes based on the soft version, it doesn't seem to be necessary for our purposes?
List<string> temp = new List<string>();
temp.AddRange(lines);
lines.Clear();
foreach (string l in temp)
{
string s = l.TrimEnd();
s = s.Replace('\t', ',');
lines.Add(s);
}
int currentLine = 1;
TSFName = lines[currentLine++];
SysDate = lines[currentLine++];
SysTime = lines[currentLine++];
TestDescription = lines[currentLine++];
// CHECK VERSION, IF OLDER THEN 6.3 THEN BAIL
if (VersionNumber < 6.3) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_OLD_FILE_VERSION, 0, VersionNumber.ToString())); return; }
try
{
SamplingInformationSection = new TSFSamplingInformationSection(lines, ref currentLine);
}
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine)); return; }
var systemDescription = ini.GetSystemDescription();
RackInformationSection.ReadFrom(lines, ref currentLine, ref errors, this, systemDescription);
setProgress(currentLine / (double)lines.Count);
ModuleInformationSection.ReadFrom(lines, ref currentLine, ref errors, systemDescription, RackInformationSection);
setProgress(currentLine / (double)lines.Count);
SensorChannelSection.ReadFrom(lines, ref currentLine, ref errors);
CalculatedChannelSection.ReadFrom(lines, ref currentLine, ref errors);
TOMChannelSection.ReadFrom(lines, ref currentLine, ref errors);
TCFSection.ReadFrom(lines, ref currentLine, ref errors);
DIMSection.ReadFrom(lines, ref currentLine, ref errors);
G5DigitalInputSection.ReadFrom(lines, ref currentLine, ref errors);
}
}
}

View File

@@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB.TSF
{
/// <summary>
/// the G5 Digital Input Channels section of the TSF
/// </summary>
public class TSFG5DigitalInputSection
{
private const string SECTION_START_HEADER = "---- G5 Digital Input Channels Begin ----";
private const string COLUMN_HEADER = "datachan,rack,mod,chan,descrip,ISOCode,scale,invert";
private const string SECTION_END_HEADER = "---- G5 Digital Input Channels End ----";
private List<G5DigtalInputChannelTSFEntry> _digitalInputChannels = new List<G5DigtalInputChannelTSFEntry>();
public G5DigtalInputChannelTSFEntry[] DigitalInputChannels
{
get { return _digitalInputChannels.ToArray(); }
set { _digitalInputChannels = new List<G5DigtalInputChannelTSFEntry>(value); }
}
public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors)
{
if (currentLine == lines.Count)
{
//errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string sectionStart = lines[currentLine++];
if (sectionStart != SECTION_START_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.G5DIGITALINPUTSECTION_START_INVALID_HEADER, currentLine, sectionStart));
return;
}
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string columnHeader = lines[currentLine++];
if (columnHeader != COLUMN_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.G5DIGITALINPUTSECTION_COLUMN_INVALID_HEADER, currentLine, columnHeader));
return;
}
List<G5DigtalInputChannelTSFEntry> g5DigitalInputChannels = new List<G5DigtalInputChannelTSFEntry>();
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.Contains("G5 Digital Input Channels End"))
{
G5DigtalInputChannelTSFEntry ichan = new G5DigtalInputChannelTSFEntry();
string[] tokens = line.Split(new char[] { ',' });
for (int iCurField = 0; iCurField < tokens.Length; iCurField++)
{
string s = tokens[iCurField];
G5DigtalInputChannelTSFEntry.Fields field = (G5DigtalInputChannelTSFEntry.Fields)iCurField;
switch (field)
{
case G5DigtalInputChannelTSFEntry.Fields.chan:
try { ichan.Chan = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_G5DIGITALCHANNEL_INVALID_CHAN, currentLine, s)); }
break;
case G5DigtalInputChannelTSFEntry.Fields.datachan:
try { ichan.DataChan = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_G5DIGITALCHANNEL_INVALID_DATACHAN, currentLine, s)); }
break;
case G5DigtalInputChannelTSFEntry.Fields.descrip: ichan.Descripton = s; break;
case G5DigtalInputChannelTSFEntry.Fields.invert:
try
{
switch (s)
{
case "0":
case "F":
case "N":
ichan.Invert = false; break;
case "1":
case "T":
case "Y":
ichan.Invert = true; break;
default:
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_G5DIGITALCHANNEL_INVALID_INVERT, currentLine, s));
}
break;
}
}
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_G5DIGITALCHANNEL_INVALID_INVERT, currentLine, s)); }
break;
case G5DigtalInputChannelTSFEntry.Fields.ISOCode: ichan.ISOCode = s; break;
case G5DigtalInputChannelTSFEntry.Fields.mod:
try { ichan.Module = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_G5DIGITALCHANNEL_INVALID_MODULE, currentLine, s)); }
break;
case G5DigtalInputChannelTSFEntry.Fields.rack:
try { ichan.Rack = Convert.ToInt32(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_G5DIGITALCHANNEL_INVALID_RACK, currentLine, s)); }
break;
case G5DigtalInputChannelTSFEntry.Fields.scale:
try { ichan.Scale = Convert.ToDouble(s); }
catch (System.Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_G5DIGITALCHANNEL_INVALID_SCALE, currentLine, s)); }
break;
default: throw new NotSupportedException("TSFFile::ReadTSF invalid G5DigitalInput field: " + field.ToString());
}
}
g5DigitalInputChannels.Add(ichan);
}
else { done = true; }
}
DigitalInputChannels = g5DigitalInputChannels.ToArray();
}
}
}

View File

@@ -0,0 +1,131 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// stolen from HLAPI
/// this is only sparsely used in DataPRO currently and is mostly reference
/// </summary>
public class TSFInputChannelDescription
{
private int _version;
public int Version { get { return _version; } set { _version = value; } }
private TSFChannelDescription _parent;
public TSFChannelDescription Parent { get { return _parent; } set { _parent = value; } }
private int _source;
public int Source { get { return _source; } set { _source = value; } }
private ulong _crc32;
public ulong CRC32 { get { return _crc32; } set { _crc32 = value; } }
private bool _analogInfoValid;
public bool AnalogInfoValid { get { return _analogInfoValid; } set { _analogInfoValid = value; } }
/// <summary>
/// HLAPI_INPUT_TYPE
/// </summary>
private char _analogChannelType;
public char AnalogChannelType { get { return _analogChannelType; } set { _analogChannelType = value; } }
/// <summary>
/// See HLAPI_INPUT_FILTER_MODE
/// </summary>
private char _analogChannelFilterMode;
public char AnalogChannelFilterMode { get { return _analogChannelFilterMode; } set { _analogChannelFilterMode = value; } }
/// <summary>
/// See HLAPI_INPUT_OFFSET_MODE
/// </summary>
private char _analogChannelOffsetMode;
public char AnalogChannelOffsetMode { get { return _analogChannelOffsetMode; } set { _analogChannelOffsetMode = value; } }
/// <summary>
/// See HLAPI_INPUT_SHUNT_MODE
/// </summary>
private char _analogChannelShuntMode;
public char AnalogChannelShuntMode { get { return _analogChannelShuntMode; } set { _analogChannelShuntMode = value; } }
private double _analogExcitationVoltage;
public double AnalogExcitationVoltage { get { return _analogExcitationVoltage; } set { _analogExcitationVoltage = value; } }
private double _analogGain;
public double AnalogGain { get { return _analogGain; } set { _analogGain = value; } }
private int _analogShuntResistanceOhms;
public int AnalogShuntResistanceOhms { get { return _analogShuntResistanceOhms; } set { _analogShuntResistanceOhms = value; } }
private int _analogShuntEmulationOhms;
public int AnalogShuntEmulationOhms { get { return _analogShuntEmulationOhms; } set { _analogShuntEmulationOhms = value; } }
private double _analogShuntEU;
public double AnalogShuntEU { get { return _analogShuntEU; } set { _analogShuntEU = value; } }
private double _analogSensitivity;
public double AnalogSensitivity { get { return _analogSensitivity; } set { _analogSensitivity = value; } }
private char _analogSensitivityUnits;
public char AnalogSensitivityUnits { get { return _analogSensitivityUnits; } set { _analogSensitivityUnits = value; } }
private string _analogEULabel;
public string AnalogEULabel { get { return _analogEULabel; } set { _analogEULabel = value; } }
private bool _analogInvertData;
public bool AnalogInvertData { get { return _analogInvertData; } set { _analogInvertData = value; } }
private bool _digitalInfoValid;
public bool DigitalInfoValid { get { return _digitalInfoValid; } set { _digitalInfoValid = value; } }
private bool _realtimeInfoValid;
public bool RealtimeInfoValid { get { return _realtimeInfoValid; } set { _realtimeInfoValid = value; } }
private bool _useForRealtime;
public bool UseForRealtime { get { return _useForRealtime; } set { _useForRealtime = value; } }
private static object MyLock = new object();
private List<short> _realtimeADC = new List<short>();
public short[] RealtimeADC
{
get { lock (MyLock) { return _realtimeADC.ToArray(); } }
set { lock (MyLock) { _realtimeADC = new List<short>(value); } }
}
public int RealtimeSamples
{
get { lock (MyLock) { return RealtimeADC.Length; } }
}
public TSFInputChannelDescription() { }
public TSFInputChannelDescription(TSFInputChannelDescription copy, TSFChannelDescription channel)
{
_analogChannelFilterMode = copy._analogChannelFilterMode;
_analogChannelOffsetMode = copy._analogChannelOffsetMode;
_analogChannelShuntMode = copy._analogChannelShuntMode;
_analogChannelType = copy._analogChannelType;
_analogEULabel = copy._analogEULabel;
_analogExcitationVoltage = copy._analogExcitationVoltage;
_analogGain = copy._analogGain;
_analogInfoValid = copy._analogInfoValid;
_analogInvertData = copy._analogInvertData;
_analogSensitivity = copy._analogSensitivity;
_analogSensitivityUnits = copy._analogSensitivityUnits;
_analogShuntEmulationOhms = copy._analogShuntEmulationOhms;
_analogShuntEU = copy._analogShuntEU;
_analogShuntResistanceOhms = copy._analogShuntResistanceOhms;
_crc32 = copy._crc32;
_digitalInfoValid = copy._digitalInfoValid;
_parent = channel;
_realtimeADC = new List<short>();
_realtimeInfoValid = false;
_source = copy._source;
_useForRealtime = copy._useForRealtime;
_version = copy._version;
}
}
}

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// stolen from HLAPI in the hope of bringing in some of the HLAPI code, however is very, very sparsely used
/// we may want to remove these HLAPI derived classes soon
/// </summary>
public class TSFModuleDescription
{
private int _version;
public int Version { get { return _version; } set { _version = value; } }
/// <summary>
/// See HLAPI_MODULE_TYPE_
/// </summary>
private int _type;
public int Type { get { return _type; } set { _type = value; } }
private TSFRackDescription _parent;
public TSFRackDescription Parent { get { return _parent; } set { _parent = value; } }
private int _source;
public int Source { get { return _source; } set { _source = value; } }
private int _slot;
public int Slot { get { return _slot; } set { _slot = value; } }
private ulong _crc32;
public ulong CRC32 { get { return _crc32; } set { _crc32 = value; } }
private bool _hardwareInfoValid;
public bool HardwareInfoValid { get { return _hardwareInfoValid; } set { _hardwareInfoValid = value; } }
private string _hwSerialNumber;
public string HWSerialNumber { get { return _hwSerialNumber; } set { _hwSerialNumber = value; } }
/// <summary>
/// See HLAPI_MODULE_TOM_TIGGER_
/// </summary>
private int _hwTOMTriggerType;
public int HWTOMTriggerType { get { return _hwTOMTriggerType; } set { _hwTOMTriggerType = value; } }
private int _hwRackPosition;
public int HWRackPosition { get { return _hwRackPosition; } set { _hwRackPosition = value; } }
private int _hwChannelCount;
public int HWChannelCount { get { return _hwChannelCount; } set { _hwChannelCount = value; } }
private List<TSFChannelDescription> _hwChannelList = new List<TSFChannelDescription>();
public TSFChannelDescription[] HWChannelList { get { return _hwChannelList.ToArray(); } set { _hwChannelList = new List<TSFChannelDescription>(value); } }
//The following values are valid after TestTrigger and DownloadData
private bool _downloadDescriptionValid;
public bool DownloadDescriptionValid { get { return _downloadDescriptionValid; } set { _downloadDescriptionValid = value; } }
private bool _downloadTriggerDetected;
public bool DownloadTriggerDetected { get { return _downloadTriggerDetected; } set { _downloadTriggerDetected = value; } }
//The following fields are used for the download process
private char _downloadDataFlag;
public char DownloadDataFlag { get { return _downloadDataFlag; } set { _downloadDataFlag = value; } }
private double _downloadBeginSeconds;
public double DownloadBeginSeconds { get { return _downloadBeginSeconds; } set { _downloadBeginSeconds = value; } }
private double _downloadEndSeconds;
public double DownloadEndSeconds { get { return _downloadEndSeconds; } set { _downloadEndSeconds = value; } }
private double _moduleBatteryVolts;
public double ModuleBatteryVolts { get { return _moduleBatteryVolts; } set { _moduleBatteryVolts = value; } }
public TSFModuleDescription() { }
public TSFModuleDescription(TSFModuleDescription copy, TSFRackDescription rack)
{
_crc32 = copy._crc32;
_downloadBeginSeconds = copy._downloadBeginSeconds;
_downloadDataFlag = copy._downloadDataFlag;
_downloadDescriptionValid = copy._downloadDescriptionValid;
_downloadEndSeconds = copy._downloadEndSeconds;
_downloadTriggerDetected = copy._downloadTriggerDetected;
_hardwareInfoValid = copy._hardwareInfoValid;
_hwChannelCount = copy._hwChannelCount;
_hwChannelList = new List<TSFChannelDescription>();
foreach (var ch in copy._hwChannelList) { _hwChannelList.Add(new TSFChannelDescription(ch, this)); }
_hwRackPosition = copy._hwRackPosition;
_hwSerialNumber = copy._hwSerialNumber;
_hwTOMTriggerType = copy._hwTOMTriggerType;
_moduleBatteryVolts = copy._moduleBatteryVolts;
_parent = rack;
_slot = copy._slot;
_source = copy._source;
_type = copy._type;
_version = copy._version;
}
}
}

View File

@@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB.TSF
{
/// <summary>
/// handles the module information section of a TSF
/// </summary>
public class TSFModuleInformationSection
{
private const string SECTION_START_HEADER = "---- Start Module Information ----";
private const string COLUMN_HEADER = "rack,module,trigmode,trigchan,trigdir,triglevel,moduletype";
private const string SECTION_END_HEADER = "---- End Module Information ----";
/// <summary>
/// reads the section from a TSF
/// assumes currentline is the start of the section
/// </summary>
/// <param name="lines"></param>
/// <param name="currentLine"></param>
/// <param name="errors"></param>
/// <param name="system"></param>
/// <param name="rackSection"></param>
public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors, TSFSystemDescription system, TSFRackInformationSection rackSection)
{
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string sectionHeader = lines[currentLine++];
if (sectionHeader != SECTION_START_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.MODULEINFORMATIONSECTION_BADHEADER, currentLine, sectionHeader));
return;
}
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string columnHeader = lines[currentLine++];
if (columnHeader != COLUMN_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.MODULEINFORMATIONSECTION_BADCOLUMHEADER, currentLine, columnHeader));
return;
}
var invariant = System.Globalization.CultureInfo.InvariantCulture;
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.Contains("End Module Information"))
{
string[] tokens = line.Split(new char[] { ',' });
if (tokens.Length < 7)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SKIPPING_MODULE_TOO_FEW_TOKENS, currentLine));
continue;
}
int r;
try { r = int.Parse(tokens[0], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_RACK_FIELD, currentLine, tokens[0]));
continue;
}
int m;
try { m = int.Parse(tokens[1], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_MODULE_FIELD, currentLine, tokens[1]));
continue;
}
int trigMode;
try { trigMode = int.Parse(tokens[2], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_TRIGGERMODE_FIELD, currentLine, tokens[2]));
continue;
}
int trigChan;
try { trigChan = int.Parse(tokens[3], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_TRIGGERCHAN_FIELD, currentLine, tokens[3]));
continue;
}
int trigDir;
try { trigDir = int.Parse(tokens[4], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_TRIGGERDIR_FIELD, currentLine, tokens[4]));
continue;
}
double trigLevel;
try { trigLevel = double.Parse(tokens[5], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_TRIGGERLEVEL_FIELD, currentLine, tokens[5]));
continue;
}
int moduleType;
try { moduleType = int.Parse(tokens[6], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_MODULETYPE_FIELD, currentLine, tokens[6]));
continue;
}
//var rackHW = system.HWRack[r];
bool bFound = false;
foreach (var curRack in rackSection.Racks)
{
if (curRack.Number == r)
{
curRack.SetModule(m, trigMode, trigChan, trigDir, trigLevel, moduleType);
bFound = true;
break;
}
}
if (!bFound)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_SKIPPED_RACKNOTFOUND, currentLine));
continue;
}
}
else { done = true; }
}
}
}
}

View File

@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// stolen from HLAPI
/// not really used in DataPRO
/// </summary>
public class TSFOutputChannelDescription
{
private int _version;
public int Version { get { return _version; } set { _version = value; } }
private TSFChannelDescription _parent;
public TSFChannelDescription Parent { get { return _parent; } set { _parent = value; } }
private int _source;
public int Source { get { return _source; } set { _source = value; } }
private ulong _crc32;
public ulong CRC32 { get { return _crc32; } set { _crc32 = value; } }
private bool _squibInfoValid;
public bool SquibInfoValid { get { return _squibInfoValid; } set { _squibInfoValid = value; } }
/// <summary>
/// See HLAPI_OUTPUT_FIRE_MODE
/// </summary>
private char _squibFireMode;
public char SquibFireMode { get { return _squibFireMode; } set { _squibFireMode = value; } }
/// <summary>
/// See HLAPI_OUTPUT_MEASUREMENT_TYPE
/// </summary>
private char _squibMeasurementType;
public char SquibMeasurementType { get { return _squibMeasurementType; } set { _squibMeasurementType = value; } }
private bool _squibBypassCurrentFilter;
public bool SquibBypassCurrentFilter { get { return _squibBypassCurrentFilter; } set { _squibBypassCurrentFilter = value; } }
private bool _squibBypassVoltageFilter;
public bool SquibBypassVoltageFilter { get { return _squibBypassVoltageFilter; } set { _squibBypassVoltageFilter = value; } }
private double _squibToleranceLow;
public double SquibToleranceLow { get { return _squibToleranceLow; } set { _squibToleranceLow = value; } }
private double _squibToleranceHigh;
public double SquibToleranceHigh { get { return _squibToleranceHigh; } set { _squibToleranceHigh = value; } }
private double _squibOutputCurrent;
public double SquibOutputCurrent { get { return _squibOutputCurrent; } set { _squibOutputCurrent = value; } }
private bool _digitalInfoValid;
public bool DigitalInfoValid { get { return _digitalInfoValid; } set { _digitalInfoValid = value; } }
/// <summary>
/// HLAPI_OUTPUT_DIGITAL_MODE
/// </summary>
private char _digitalOutputMode;
public char DigitalOutputMode { get { return _digitalOutputMode; } set { _digitalOutputMode = value; } }
private bool _squibMeasurementValid;
public bool SquibMeasurementValid { get { return _squibMeasurementValid; } set { _squibMeasurementValid = value; } }
private double _squibMeasuredOhms;
public double SquibMeasuredOhms { get { return _squibMeasuredOhms; } set { _squibMeasuredOhms = value; } }
private bool _squibFireValid;
public bool SquibFireValid { get { return _squibFireValid; } set { _squibFireValid = value; } }
private bool _squibFirePassed;
public bool SquibFirePassed { get { return _squibFirePassed; } set { _squibFirePassed = value; } }
private bool _commonInfoValid;
public bool CommonInfoValid { get { return _commonInfoValid; } set { _commonInfoValid = value; } }
private double _commonDelayMS;
public double CommonDelayMS { get { return _commonDelayMS; } set { _commonDelayMS = value; } }
private double _commonDurationMS;
public double CommonDurationMS { get { return _commonDurationMS; } set { _commonDurationMS = value; } }
public TSFOutputChannelDescription() { }
public TSFOutputChannelDescription(TSFOutputChannelDescription copy, TSFChannelDescription channel)
{
_commonDelayMS = copy._commonDelayMS;
_commonDurationMS = copy._commonDurationMS;
_commonInfoValid = copy._commonInfoValid;
_crc32 = copy._crc32;
_digitalInfoValid = copy._digitalInfoValid;
_digitalOutputMode = copy._digitalOutputMode;
_parent = channel;
_source = copy._source;
_squibBypassCurrentFilter = copy._squibBypassCurrentFilter;
_squibBypassVoltageFilter = copy._squibBypassVoltageFilter;
_squibFireMode = copy._squibFireMode;
_squibFirePassed = copy._squibFirePassed;
_squibFireValid = copy._squibFireValid;
_squibInfoValid = copy._squibInfoValid;
_squibMeasuredOhms = copy._squibMeasuredOhms;
_squibMeasurementType = copy._squibMeasurementType;
_squibMeasurementValid = copy._squibMeasurementValid;
_squibOutputCurrent = copy._squibOutputCurrent;
_squibToleranceHigh = copy._squibToleranceHigh;
_squibToleranceLow = copy._squibToleranceLow;
_version = copy._version;
}
}
}

View File

@@ -0,0 +1,260 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// stolen from HLApi
/// used only sparsely in DataPRO
/// </summary>
public class TSFRackDescription
{
/// <summary>
/// the number specified in the .INI file
/// </summary>
private int _number;
public int Number { get { return _number; } set { _number = value; } }
private int _version;
public int Version { get { return _version; } set { _version = value; } }
private int _type;
public int Type { get { return _type; } set { _type = value; } }
private TSFSystemDescription _parent;
public TSFSystemDescription Parent { get { return _parent; } set { _parent = value; } }
/// <summary>
/// ??
/// </summary>
private int _flags;
public int Flags;
/// <summary>
/// ??
/// </summary>
private int _source;
public int Source { get { return _source; } set { _source = value; } }
/// <summary>
/// The calculated CRC for this struct
/// </summary>
private ulong _crc32;
public ulong CRC32 { get { return _crc32; } set { _crc32 = value; } }
// Variables to describe the HW configuration of this rack.
/// <summary>
/// Are the HW* valiables valid?
/// </summary>
private bool _hwInfoValid;
public bool HardwareInfoValid { get { return _hwInfoValid; } set { _hwInfoValid = value; } }
/// <summary>
/// How many SIM's do we have?
/// </summary>
private int _hwSIMCount;
private int HWSIMCount { get { return _hwSIMCount; } set { _hwSIMCount = value; } }
/// <summary>
/// How many TOM's do we have?
/// </summary>
private int _hwTOMCount;
public int HWTOMCount { get { return _hwTOMCount; } set { _hwTOMCount = value; } }
/// <summary>
/// How many analog channels do we have?
/// </summary>
private int _hwAnalogChannelCount;
public int HWAnalogChannelCount { get { return _hwAnalogChannelCount; } set { _hwAnalogChannelCount = value; } }
/// <summary>
/// How many squib channels do we have?
/// </summary>
private int _hwSquibChannelCount;
public int HWSquibChannelCount { get { return _hwSquibChannelCount; } set { _hwSquibChannelCount = value; } }
/// <summary>
/// How many digital outputs do we have?
/// </summary>
private int _hwDigitalOutputChannelCount;
public int HWDigitalOutputChannelCount { get { return _hwDigitalOutputChannelCount; } set { _hwDigitalOutputChannelCount = value; } }
/// <summary>
/// How many digital inputs do we have?
/// </summary>
private int _hwDigitalInputChannelCount;
public int HWDigitalInputChannelCount { get { return _hwDigitalInputChannelCount; } set { _hwDigitalInputChannelCount = value; } }
/// <summary>
/// The serial number of this rack
/// </summary>
private string _hwSerialNumber;
public string HWSerialNumber { get { return _hwSerialNumber; } set { _hwSerialNumber = value.Trim(); } }
/// <summary>
/// The IP address of this rack
/// </summary>
private string _hwIPAddress;
public string HWIPAddress { get { return _hwIPAddress; } set { _hwIPAddress = value; } }
/// <summary>
/// How many entries is there in the HWModuleList?
/// </summary>
public int HWModuleCount { get { return HWModuleList.Length; } }
/// <summary>
/// The address to an array of ModuleDescription's
/// </summary>
private List<TSFModuleDescription> _hwModuleList = new List<TSFModuleDescription>();
public TSFModuleDescription[] HWModuleList { get { return _hwModuleList.ToArray(); } set { _hwModuleList = new List<TSFModuleDescription>(value); } }
// This represents the different power sources for this rack
/// <summary>
/// Are the Power* and Battery* variables valid?
/// </summary>
private bool _powerInfoValid = false;
public bool PowerInfoValid { get { return _powerInfoValid; } set { _powerInfoValid = value; } }
/// <summary>
/// Current voltage of source 1
/// </summary>
private double _powerSource1Volts;
public double PowerSource1Volts { get { return _powerSource1Volts; } set { _powerSource1Volts = value; } }
/// <summary>
/// Current voltage of source 2
/// </summary>
private double _powerSource2Volts;
public double PowerSource2Volts { get { return _powerSource2Volts; } set { _powerSource2Volts = value; } }
/// <summary>
/// Not really a state, current charge voltage maybe?
/// </summary>
private double _batteryChargeState;
public double BatteryChargeState { get { return _batteryChargeState; } set { _batteryChargeState = value; } }
/// <summary>
/// Is it charging or draining?
/// </summary>
private int _batteryChargeDirection;
public int BatteryChargeDirection { get { return _batteryChargeDirection; } set { _batteryChargeDirection = value; } }
// This represents the digital inputs on this rack
/// <summary>
/// Is the DigitalInputBits valid?
/// </summary>
private bool _digitalInputBitsValid;
public bool DigitalInputBitsValid { get { return _digitalInputBitsValid; } set { _digitalInputBitsValid = value; } }
/// <summary>
/// One bit for each digital input
/// </summary>
private ulong _digitalInputBits;
public ulong DigitalInputBits { get { return _digitalInputBits; } set { _digitalInputBits = value; } }
// Current info about this racks LED's and fault/trigger lines.
/// <summary>
/// Is the LED/Fault/Trigger info below valid?
/// </summary>
private bool _LEDInfoValid;
public bool LEDInfoValid { get { return _LEDInfoValid; } set { _LEDInfoValid = value; } }
/// <summary>
/// What color is the cal LED? See HLAPI_LED_*
/// </summary>
private char _calLED;
public char CalLED { get { return _calLED; } set { _calLED = value; } }
/// <summary>
/// What color is the armed LED? See HLAPI_LED_*
/// </summary>
private char _armLED;
public char ArmLED { get { return _armLED; } set { _armLED = value; } }
/// <summary>
/// What color is the start record LED? See HLAPI_LED_*
/// </summary>
private char _statLED;
public char StatLED { get { return _statLED; } set { _statLED = value; } }
/// <summary>
/// Current state of trigger fault
/// </summary>
private bool _triggerFault;
public bool TriggerFault { get { return _triggerFault; } set { _triggerFault = value; } }
/// <summary>
/// Current state of the level trigger
/// </summary>
private bool _levelTrigger;
public bool LevelTrigger { get { return _levelTrigger; } set { _levelTrigger = value; } }
/// <summary>
/// This boolean indicates if this rack is currently powered down and should be ignored for all operations.
/// </summary>
private bool _isPoweredDown;
public bool IsPoweredDown { get { return _isPoweredDown; } set { _isPoweredDown = value; } }
/// <summary>
/// this boolean indicates if this rack (G5) is in a docking station or not
/// </summary>
private bool _isInDockingStation;
public bool IsInDockingStation { get { return _isInDockingStation; } set { _isInDockingStation = value; } }
public TSFRackDescription() { }
public TSFRackDescription(TSFRackDescription copy)
{
_armLED = copy.ArmLED;
_batteryChargeDirection = copy._batteryChargeDirection;
_batteryChargeState = copy._batteryChargeState;
_calLED = copy._calLED;
_crc32 = copy._crc32;
_digitalInputBits = copy._digitalInputBits;
_digitalInputBitsValid = copy._digitalInputBitsValid;
_flags = copy._flags;
_hwAnalogChannelCount = copy._hwAnalogChannelCount;
_hwDigitalInputChannelCount = copy._hwDigitalInputChannelCount;
_hwDigitalOutputChannelCount = copy._hwDigitalOutputChannelCount;
_hwInfoValid = copy._hwInfoValid;
_hwIPAddress = copy._hwIPAddress;
_hwModuleList = new List<TSFModuleDescription>();
foreach (var m in copy._hwModuleList) { _hwModuleList.Add(new TSFModuleDescription(m, this)); }
_hwSerialNumber = copy._hwSerialNumber;
_hwSIMCount = copy._hwSIMCount;
_hwSquibChannelCount = copy._hwSquibChannelCount;
_hwTOMCount = copy._hwTOMCount;
_isInDockingStation = copy._isInDockingStation;
_isPoweredDown = copy._isPoweredDown;
_LEDInfoValid = copy._LEDInfoValid;
_levelTrigger = copy._levelTrigger;
_parent = copy._parent;
_powerInfoValid = copy._powerInfoValid;
_powerSource1Volts = copy._powerSource1Volts;
_powerSource2Volts = copy._powerSource2Volts;
_source = copy._source;
_statLED = copy._statLED;
_triggerFault = copy._triggerFault;
_type = copy._type;
_version = copy._version;
_number = copy.Number;
}
public void SetModule(int moduleIndex, int trigMode, int trigChan, int trigDir, double trigLevel, int moduleType)
{
for (int i = _hwModuleList.Count; i <= moduleIndex; i++)
{
TSFModuleDescription hwModule = null;
if (i == moduleIndex)
{
hwModule = new TSFModuleDescription();
hwModule.Parent = this;
hwModule.Slot = moduleIndex;
hwModule.Type = moduleType;
}
_hwModuleList.Add(hwModule);
}
}
}
}

View 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;
}
}
}
}
}

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB.TSF
{
/// <summary>
/// handles the sampling information section of the TSF
/// can contain rate(Hz),pretrigtime(sec),posttrigtime(sec),AdjAAfilter(Hz),postcaltime(sec)
/// </summary>
public class TSFSamplingInformationSection
{
private const string START_SECTION_HEADER = "---- Start Sampling Information ----";
private const string COLUMN_HEADER = "rate(Hz),pretrigtime(sec),posttrigtime(sec),AdjAAfilter(Hz),postcaltime(sec)";
private const string END_SECTION_HEADER = "---- End Sampling Information ----";
private double _sampleRateHz;
public double SampleRateHz { get { return _sampleRateHz; } set { _sampleRateHz = value; } }
private double _preTriggerSeconds;
/// <summary>
/// pre trigger seconds (always positive)
/// </summary>
public double PreTriggerSeconds { get { return _preTriggerSeconds; } set { _preTriggerSeconds = value; } }
private double _postTriggerSeconds;
/// <summary>
/// post trigger seconds (always positive)
/// </summary>
public double PostTriggerSeconds { get { return _postTriggerSeconds; } set { _postTriggerSeconds = value; } }
private double _aaf;
public double AAF { get { return _aaf; } set { _aaf = value; } }
private double _postCalTimeSeconds;
public double PostCalTimeSeconds { get { return _postCalTimeSeconds; } set { _postCalTimeSeconds = value; } }
public TSFSamplingInformationSection(List<string> lines, ref int currentLine)
{
if (currentLine == lines.Count) { throw new System.IO.EndOfStreamException(); }
string startSection = lines[currentLine++];
if (startSection != START_SECTION_HEADER) { throw new System.IO.InvalidDataException(startSection); }
if (currentLine == lines.Count) { throw new System.IO.EndOfStreamException(); }
string columnHeader = lines[currentLine++];
if (columnHeader != COLUMN_HEADER) { throw new System.IO.InvalidDataException(columnHeader); }
// READ IN SAMPLING VALUES
if (currentLine == lines.Count) { throw new System.IO.EndOfStreamException(); }
string[] tokens = lines[currentLine++].Split(new string[] { "," }, StringSplitOptions.None);
if (tokens.Length < 5) { throw new System.IO.InvalidDataException(lines[currentLine - 1]); }
try { SampleRateHz = double.Parse(tokens[0], System.Globalization.CultureInfo.InvariantCulture); }
catch (System.Exception) { throw new System.IO.InvalidDataException(tokens[0]); }
try { PreTriggerSeconds = double.Parse(tokens[1], System.Globalization.CultureInfo.InvariantCulture); }
catch (System.Exception) { throw new System.IO.InvalidDataException(tokens[1]); }
try { PostTriggerSeconds = double.Parse(tokens[2], System.Globalization.CultureInfo.InvariantCulture); }
catch (System.Exception) { throw new System.IO.InvalidDataException(tokens[2]); }
try { AAF = double.Parse(tokens[3], System.Globalization.CultureInfo.InvariantCulture); }
catch (System.Exception) { throw new System.IO.InvalidDataException(tokens[3]); }
// IF PRETRIGTIME IS >0 THEN THIS IS PRE VER. 6.4A AND NEEDS TO BE CONVERTED TO A NEGATIVE NUMBER
PreTriggerSeconds = System.Math.Abs(PreTriggerSeconds);
PostTriggerSeconds = System.Math.Abs(PostTriggerSeconds);
if (currentLine == lines.Count) { throw new System.IO.EndOfStreamException(); }
string endSection = lines[currentLine++];
if (endSection != END_SECTION_HEADER)
{
throw new System.IO.InvalidDataException(endSection);
}
}
}
}

View File

@@ -0,0 +1,332 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DTS.Common.Classes.Sensors;
namespace DTS.SensorDB.TSF
{
/// <summary>
/// handles the sensor channel information section of the TSF
/// can contain
/// datachan,rack,mod,chan,descrip,s/n,offsetlow,offsethigh,calmode,calstep(ohm/volt),shuntval(eu),proptoext,sens(mv/eu or mv/v/eu),gain,extvolt,EU,filter,invert,zeroref,desiredmaxrange,commentfield,caldate,Offset?,InitialEU,sensorID,ISOcode,IRTRACC exponent,sensor category,desired max range scaling,C0,C1,C2,C3,C4,C5
/// these appear to be only analog sensors
/// </summary>
public class TSFSensorChannelInformationSection
{
private const string SECTION_START_HEADER = "---- Start Sensor Channel Information ----";
private const string COLUMNS_HEADER = "datachan,rack,mod,chan,descrip,s/n,offsetlow,offsethigh,calmode,calstep(ohm/volt),shuntval(eu),proptoext,sens(mv/eu or mv/v/eu),gain,extvolt,EU,filter,invert,zeroref,desiredmaxrange,commentfield,caldate,Offset?,InitialEU,sensorID";
private const string COLUMNS_HEADER_POLY = "C0,C1,C2,C3,C4,C5";
private const string SECTION_END_HEADER = "---- End Sensor Channel Information ----";
private List<TSFSensorEntry> _entries = new List<TSFSensorEntry>();
public TSFSensorEntry[] Entries
{
get => _entries.ToArray();
set => _entries = new List<TSFSensorEntry>(value);
}
public TSFSensorChannelInformationSection() { }
/// <summary>
/// reads the section from the TSF
/// assumes currentline points to the start of the section
/// </summary>
/// <param name="lines"></param>
/// <param name="currentLine"></param>
/// <param name="errors"></param>
public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors)
{
// READ IN SENSOR CHANNEL VALUES
if (currentLine == lines.Count) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine)); return; }
var sectionHeader = lines[currentLine++];
if (sectionHeader != SECTION_START_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.SENSORCHANNELSECTION_INVALIDHEADER, currentLine, sectionHeader));
return;
}
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
var columnHeader = lines[currentLine++];
var hasPolynomials = false;
if (columnHeader.Contains(COLUMNS_HEADER))
{
// Valid header
hasPolynomials = columnHeader.Contains(COLUMNS_HEADER_POLY);
}
else
{
// Invalid Header
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.SENSORCHANNELSECTION_INVALIDCOLUMNHEADER, currentLine, columnHeader));
return;
}
var done = false;
var sensorEntries = new List<TSFSensorEntry>();
var invariant = System.Globalization.CultureInfo.InvariantCulture;
#region Process entries
while (!done)
{
if (currentLine == lines.Count) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine)); return; }
var line = lines[currentLine++];
if (!line.Contains("End Sensor Channel Information"))
{
var tokens = line.Split(',');
var entry = new TSFSensorEntry();
for (var iCurField = 0; iCurField < tokens.Length; iCurField++)
{
var s = tokens[iCurField];
try
{
var field = (TSFSensorEntry.Fields)iCurField;
switch (field)
{
case TSFSensorEntry.Fields.caldate:
try
{
var dateTokens = s.Split('_');
entry.CalDate = new DateTime(Convert.ToInt32(dateTokens[2], invariant), Convert.ToInt32(dateTokens[0], invariant), Convert.ToInt32(dateTokens[1], invariant));
}
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSORCHANNEL_INVALID_CALDATE, currentLine, s)); }
break;
case TSFSensorEntry.Fields.calmode:
{
entry.CalMode = new CalMode(s);
}
break;
case TSFSensorEntry.Fields.calstep:
try { entry.CalStep = Convert.ToDouble(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSORCHANNEL_INVALID_CALSTEP, currentLine, s)); }
break;
case TSFSensorEntry.Fields.chan:
try { entry.Chan = Convert.ToInt32(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSORCHANNEL_INVALID_CHAN, currentLine, s)); }
break;
case TSFSensorEntry.Fields.commentfield: entry.CommentField = s; break;
case TSFSensorEntry.Fields.datachan:
try { entry.DataChan = Convert.ToInt32(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_DATACHAN, currentLine, s)); }
break;
case TSFSensorEntry.Fields.descrip:
entry.Description = s;
break;
case TSFSensorEntry.Fields.desiredmaxrange:
try { entry.DesiredMaxRange = Convert.ToDouble(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_DESIREDMAXRANGE, currentLine, s)); }
break;
case TSFSensorEntry.Fields.desiredmaxrangescaling:
try { entry.DesiredMaxRangeScaling = Convert.ToDouble(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_DESIREDMAXRANGESCALING, currentLine, s)); }
break;
case TSFSensorEntry.Fields.EU: entry.EU = s; break;
case TSFSensorEntry.Fields.extvolt:
try { entry.ExtVolt = Convert.ToDouble(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_EXTVOLT, currentLine, s)); }
break;
case TSFSensorEntry.Fields.filter:
{
double d;
if (!double.TryParse(s, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_FILTER, currentLine, s));
}
else { entry.Filter = d; }
}
break;
case TSFSensorEntry.Fields.gain:
try { entry.Gain = Convert.ToDouble(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_GAIN, currentLine, s)); }
break;
case TSFSensorEntry.Fields.InitialEU:
try { entry.InitialEU = Convert.ToDouble(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_INITIALEU, currentLine, s)); }
break;
case TSFSensorEntry.Fields.invert: entry.Invert = !(s == "0" || s == "N" || s == "F"); break;
case TSFSensorEntry.Fields.IRTRACCexponent:
try { entry.IRTRACCexponent = Convert.ToDouble(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_IRTRACCEXPONENT, currentLine, s)); }
break;
case TSFSensorEntry.Fields.ISOcode:
// The TDC SIF ISOcode feild is notoriously abused with holding non-iso information and cannot be trusted to be unique
// This if statement catches some easy to identify signs of abuse and an empty ISO code
if (s.Count() != (new IsoCode(string.Empty)).StringRepresentation.Count() // http://fogbugz/fogbugz/default.asp?9254
|| s.Equals("0000000000000000"))
{
// Stomp on the incorrect ISO Code from the import because we cant trust it.
s = string.Empty;
}
entry.ISOCode = s;
break;
case TSFSensorEntry.Fields.mod:
try { entry.Module = Convert.ToInt32(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_MODULE, currentLine, s)); }
break;
case TSFSensorEntry.Fields.Offset:
{
switch (s)
{
case "0":
case "F":
case "N": entry.RemoveOffset = false; break;
case "1":
case "T":
case "Y": entry.RemoveOffset = true; break;
default:
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_OFFSET, currentLine, s));
}
break;
}
}
break;
case TSFSensorEntry.Fields.offsethigh:
try { entry.OffsetHigh = Convert.ToDouble(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_OFFSETHIGH, currentLine, s)); }
break;
case TSFSensorEntry.Fields.offsetlow:
try { entry.OffsetLow = Convert.ToDouble(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_OFFSETLOW, currentLine, s)); }
break;
case TSFSensorEntry.Fields.proptoext: entry.ProportionalToExcitation = !(s == "0" || s == "N" || s == "F"); break;
case TSFSensorEntry.Fields.rack:
try { entry.Rack = Convert.ToInt32(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_RACK, currentLine, s)); }
break;
case TSFSensorEntry.Fields.sens:
try { entry.Sensitivity = Convert.ToDouble(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_SENSITIVITY, currentLine, s)); }
break;
case TSFSensorEntry.Fields.sensorcategory:
{
switch (s)
{
case "0": entry.SensorCategory = SensorInformationFile.TDCSensorCategory.Normal; break;
case "1": entry.SensorCategory = SensorInformationFile.TDCSensorCategory.POT; break;
case "2": entry.SensorCategory = SensorInformationFile.TDCSensorCategory.IRTracc; break;
case "3": entry.SensorCategory = SensorInformationFile.TDCSensorCategory.Polynomial; break;
default:
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_SENSORCATEGORY, currentLine, s));
break;
}
}
}
break;
case TSFSensorEntry.Fields.sensorID:
if (s.Equals("NONE")) { s = string.Empty; }
entry.SensorId = s;
break;
case TSFSensorEntry.Fields.serialNumber:
if (sensorEntries.Select(x => x.SerialNumber).Contains(s))
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_DUPLICATESERIALNUMBER, currentLine, s));
}
if (string.IsNullOrEmpty(entry.Description))
{
entry.Description = s;
}
entry.SerialNumber = s;
break;
case TSFSensorEntry.Fields.shuntval:
try { entry.ShuntValue = Convert.ToDouble(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_SHUNTVALUE, currentLine, s)); }
break;
case TSFSensorEntry.Fields.zeroref:
try
{
entry.ZeroRef = new ZeroRef(s);
}
catch (Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALID_ZEROREF, currentLine, s));
}
break;
case TSFSensorEntry.Fields.C0:
case TSFSensorEntry.Fields.C1:
case TSFSensorEntry.Fields.C2:
case TSFSensorEntry.Fields.C3:
case TSFSensorEntry.Fields.C4:
case TSFSensorEntry.Fields.C5:
// Nothing to do yet.
break;
default:
throw new NotSupportedException("TSFFile::ReadTSF unknown field: " + field);
}
if (true == hasPolynomials)
{
switch (field)
{
case TSFSensorEntry.Fields.C0:
try { entry.C0 = double.Parse(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSORCHANNEL_INVALID_C0, currentLine, s)); }
break;
case TSFSensorEntry.Fields.C1:
try { entry.C1 = double.Parse(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSORCHANNEL_INVALID_C1, currentLine, s)); }
break;
case TSFSensorEntry.Fields.C2:
try { entry.C2 = double.Parse(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSORCHANNEL_INVALID_C2, currentLine, s)); }
break;
case TSFSensorEntry.Fields.C3:
try { entry.C3 = double.Parse(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSORCHANNEL_INVALID_C3, currentLine, s)); }
break;
case TSFSensorEntry.Fields.C4:
try { entry.C4 = double.Parse(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSORCHANNEL_INVALID_C4, currentLine, s)); }
break;
case TSFSensorEntry.Fields.C5:
try { entry.C5 = double.Parse(s, invariant); }
catch (Exception) { errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSORCHANNEL_INVALID_C5, currentLine, s)); }
break;
}
}
}
catch (Exception)
{
//errors.Add("TSF_INVALID_SENSOR_CHANNEL_INFO_FIELD" + iCurField.ToString());
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SENSOR_CHANNEL_INVALIDFIELD, currentLine, iCurField.ToString()));
continue;
}
}
sensorEntries.Add(entry);
//tdc has some additional logic to do some scaling over what the desired max range is ... we don't do that yet ...
/*
// Store unscaled desired max range values, and then scale.
Sensor_UnscaledDesiredMaxRange[r][m][c] = Sensor_DesiredMaxRange[r][m][c];
Sensor_DesiredMaxRange[r][m][c] *= Sensor_DesiredMaxRangeScaling;
if (0.0 == Sensor_IRTRACC_Exponent[r][m][c])
{
Sensor_IRTRACC_Exponent[r][m][c] = IRTRACC_DEFAULT_EXPONENT;
}
// DETERMINE GAIN BASED ON DESIRED MAX RANGE
DetermineMaxRangeandGain(r, m, c, Sensor_DesiredMaxRange[r][m][c], &gain[3], &gain[5], &range[3], &range[5]);
if(IsG5 (Rack_SN[r])) //G5
{
Sensor_Gain[r][m][c]=gain[5];
}
else //PRO
{
Sensor_Gain[r][m][c]=gain[3];
}
*/
}
else { done = true; }
}
#endregion
Entries = sensorEntries.ToArray();
}
}
}

View File

@@ -0,0 +1,139 @@
using System;
using DTS.Common.Classes.Sensors;
namespace DTS.SensorDB
{
/// <summary>
/// an entry in the Start Sensor Channel Information section of a TSF
/// can contain
/// datachan,rack,mod,chan,descrip,s/n,offsetlow,offsethigh,calmode,calstep(ohm/volt),shuntval(eu),proptoext,sens(mv/eu or mv/v/eu),gain,extvolt,EU,filter,invert,zeroref,desiredmaxrange,commentfield,caldate,Offset?,InitialEU,sensorID,ISOcode,IRTRACC exponent,sensor category,desired max range scaling,C0,C1,C2,C3,C4,C5
/// these entries are analog sensor channels
/// </summary>
public class TSFSensorEntry : TSFChannel
{
public enum Fields
{
datachan,
rack,
mod,
chan,
descrip,
serialNumber,
offsetlow,
offsethigh,
calmode,
calstep,//(ohm/volt),
shuntval,//(eu)
proptoext,
sens,//(mv/eu or mv/v/eu),
gain,
extvolt,
EU,
filter,
invert,
zeroref,
desiredmaxrange,
commentfield,
caldate,
Offset,//?,
InitialEU,
sensorID,
ISOcode,
IRTRACCexponent,
sensorcategory,
desiredmaxrangescaling,
C0,
C1,
C2,
C3,
C4,
C5
}
public int DataChan { get; set; }
public int Rack { get; set; }
public int Module { get; set; }
public int Chan { get; set; }
public string Description { get; set; }
public string SerialNumber { get; set; }
public double OffsetLow { get; set; }
public double OffsetHigh { get; set; }
public bool RemoveOffset { get; set; } = true;
public CalMode CalMode { get; set; } = new CalMode();
public double CalStep { get; set; }
public double ShuntValue { get; set; }
public bool ProportionalToExcitation { get; set; }
public double Sensitivity { get; set; }
public double Gain { get; set; }
public double ExtVolt { get; set; }
public string EU { get; set; }
/*private string _filter;
public string Filter { get { return _filter; } set { _filter = value; } }
*/
public double Filter { get; set; }
public bool Invert { get; set; }
public ZeroRef ZeroRef { get; set; }
public double DesiredMaxRange { get; set; }
public string CommentField { get; set; }
public DateTime CalDate { get; set; }
public bool Offset { get; set; }
public double InitialEU { get; set; }
private string _sensorId;
public string SensorId
{
get { return _sensorId; }
set
{
if (value.ToLower() == "none") { value = ""; }
_sensorId = value;
}
}
public string ISOCode { get; set; }
public double IRTRACCexponent { get; set; }
public SensorInformationFile.TDCSensorCategory SensorCategory { get; set; } = SensorInformationFile.TDCSensorCategory.Normal;
public double DesiredMaxRangeScaling { get; set; }
public double C0 { get; set; }
public double C1 { get; set; }
public double C2 { get; set; }
public double C3 { get; set; }
public double C4 { get; set; }
public double C5 { get; set; }
public double C6 { get; set; }
}
}

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// an entry in the TOM Squib Fire Channels portion of the Start TOM Channel Information section of a TSF
/// an entry can contain
/// rack,module,chan,descrip,id,type,current,delay,durationON,duration,OhmLow,OhmHigh,ISOcode
/// TSF starts number with 1 and squibs are numbered as channels 1-4 on a tom
/// </summary>
public class TSFSquibFireEntry : TSFChannel
{
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 _desc;
public string Description { get { return _desc; } set { _desc = value; } }
private string _id;
public string Id
{
get { return _id; }
set
{
if (value.ToLower() == "none") { value = ""; }
_id = value;
}
}
private int _type;
public int Type { get { return _type; } set { _type = value; } }
private double _current;
public double Current { get { return _current; } set { _current = value; } }
private double _delay;
public double Delay { get { return _delay; } set { _delay = value; } }
private bool _durationOn;
public bool DurationOn { get { return _durationOn; } set { _durationOn = value; } }
private double _duration;
public double Duration { get { return _duration; } set { _duration = value; } }
private double _ohmLow;
public double OhmLow { get { return _ohmLow; } set { _ohmLow = value; } }
private double _ohmHigh;
public double OhmHigh { get { return _ohmHigh; } set { _ohmHigh = value; } }
private string _isocode;
public string ISOcode { get { return _isocode; } set { _isocode = value; } }
public enum Fields
{
rack, //%i
module, //%i
chan, //%i
descrip,//%s
id, //%s
type, //%i
current,// %f
delay, //%f
durationON, //%i
duration, //%f
OhmLow, //%f
OhmHigh, //%f
ISOcode//%s
}
}
}

View File

@@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// stolen from HLAPI
/// used sparsely ... do not expect most fields to be filled out as we use very few fields from it ...
/// </summary>
public class TSFSystemDescription
{
private int _version;
public int Version { get { return _version; } set { _version = value; } }
private int _systemState;
public int SystemState { get { return _systemState; } set { _systemState = value; } }
private int _source;
public int Source { get { return _source; } set { _source = value; } }
private ulong _crc32;
public ulong CRC32 { get { return _crc32; } set { _crc32 = value; } }
// The following fields describe the static hardware system
/// <summary>
/// Are the HW* variables valid?
/// </summary>
private bool _hardwareDescriptionValid = false;
public bool HardwareDescriptionValid { get { return _hardwareDescriptionValid; } set { _hardwareDescriptionValid = value; } }
/// <summary>
/// How many SIM's in the whole system?
/// </summary>
private int _hwSIMCount;
public int HWSIMCount { get { return _hwSIMCount; } set { _hwSIMCount = value; } }
/// <summary>
/// How many TOM's in the whole system?
/// </summary>
private int _hwTOMCount;
public int HWTOMCount { get { return _hwTOMCount; } set { _hwTOMCount = value; } }
/// <summary>
/// How many G5's in the whole system?
/// </summary>
private int _hwG5Count;
public int HWG5Count { get { return _hwG5Count; } set { _hwG5Count = value; } }
/// <summary>
/// How many analog channels in the whole system?
/// </summary>
private int _hwAnalogChannelCount;
public int HWAnalogChannelCount { get { return _hwAnalogChannelCount; } set { _hwAnalogChannelCount = value; } }
/// <summary>
/// How many squib channels in the whole system?
/// </summary>
private int _hwSquibChannelCount;
public int HWSquibChannelCount { get { return _hwSquibChannelCount; } set { _hwSquibChannelCount = value; } }
/// <summary>
/// How many digital output channels in the whole system?
/// </summary>
private int _hwDigitalOutputChannelCount;
public int HWDigitalOutputChannelCount { get { return _hwDigitalOutputChannelCount; } set { _hwDigitalOutputChannelCount = value; } }
/// <summary>
/// How many digital input channels in the whole system?
/// </summary>
private int _hwDigitalInputChannelCount;
public int HWDigitalInputChannelCount { get { return _hwDigitalInputChannelCount; } set { _hwDigitalInputChannelCount = value; } }
/// <summary>
/// Number of elements in HWRack array?
/// </summary>
public int HWRackCount { get { return HWRack.Length; } }
/// <summary>
/// List of racks and their children
/// </summary>
List<TSFRackDescription> _hwRack = new List<TSFRackDescription>();
public TSFRackDescription[] HWRack { get { return _hwRack.ToArray(); } set { _hwRack = new List<TSFRackDescription>(value); } }
//The following fields describe the test system parameters
private bool _testDescriptionValid = false;
public bool TestDescriptionValid { get { return _testDescriptionValid; } set { _testDescriptionValid = value; } }
private double _testSampleRate;
public double TestSampleRate { get { return _testSampleRate; } set { _testSampleRate = value; } }
private double _testPreTriggerSeconds;
public double TestPreTriggerSeconds { get { return _testPreTriggerSeconds; } set { _testPreTriggerSeconds = value; } }
private double _testPostTriggerSeconds;
public double TestPostTriggerSeconds { get { return _testPostTriggerSeconds; } set { _testPostTriggerSeconds = value; } }
private string _testConfigurationId;
public string TestConfigurationId { get { return _testConfigurationId; } set { _testConfigurationId = value; } }
private char _testArmMode;
public char TestArmMode { get { return _testArmMode; } set { _testArmMode = value; } }
private double _testAdjustibleAAFilter;
public double TestAdjustibleAAFilter { get { return _testAdjustibleAAFilter; } set { _testAdjustibleAAFilter = value; } }
private double _testCapacitorDischargeFrequency;
public double TestCapacitorDischargeFrequency { get { return _testCapacitorDischargeFrequency; } set { _testCapacitorDischargeFrequency = value; } }
private DateTime _testModifiedDateTime;
public DateTime TestModifiedDateTime { get { return _testModifiedDateTime; } set { _testModifiedDateTime = value; } }
private double _testTZeroOffset = 0D;
public double TestTZeroOffset { get { return _testTZeroOffset; } set { _testTZeroOffset = value; } }
private int _testLTOffset = 0;
public int TestLTOffset { get { return _testLTOffset; } set { _testLTOffset = value; } }
//The following fields describe the current state of the system
private bool _bSystemInfoValid = false;
public bool SystemInfoValid { get { return _bSystemInfoValid; } set { _bSystemInfoValid = value; } }
private int _sysArmStatus;
public int SysArmStatus { get { return _sysArmStatus; } set { _sysArmStatus = value; } }
private bool _sysLowPowerDetected;
public bool SysLowPowerDetected { get { return _sysLowPowerDetected; } set { _sysLowPowerDetected = value; } }
private bool _sysTriggerFaultDetected;
public bool SysTriggerFaultDetected { get { return _sysTriggerFaultDetected; } set { _sysTriggerFaultDetected = value; } }
private bool _sysStartRecordDetected;
public bool SysStartRecordDected { get { return _sysStartRecordDetected; } set { _sysStartRecordDetected = value; } }
}
}

View File

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB.TSF
{
/// <summary>
/// handles the TCF section of the TSF
/// note that the TCF is not used in Datapro yet.
/// </summary>
public class TSFTCFSection
{
private const string SECTION_START_HEADER = "---- TCF Info Begin ----";
private const string SECTION_END_HEADER = "---- TCF Info End ----";
private string _tcfPath = "";
public string TCFPath
{
get { return _tcfPath; }
set { _tcfPath = value; }
}
/// <summary>
/// reads the section from the TSF
/// assumes currentline points to the start of the section
/// </summary>
/// <param name="lines"></param>
/// <param name="currentLine"></param>
/// <param name="errors"></param>
public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors)
{
if (currentLine == lines.Count)
{
//errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string sectionStart = lines[currentLine++];
if (sectionStart != SECTION_START_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TCF_INVALID_STARTSECTIONHEADER, currentLine, sectionStart));
return;
}
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
TCFPath = lines[currentLine++];
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string sectionEnd = lines[currentLine++];
if (sectionEnd != SECTION_END_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_TCF_INVALID_SECTIONENDHEADER, currentLine, sectionEnd));
}
}
}
}