init
This commit is contained in:
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* TDAS.File.BinaryChannelHeader.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utils;
|
||||
|
||||
namespace DTS.Serialization.TDAS
|
||||
{
|
||||
// *** see TDAS.File.cs ***
|
||||
public partial class File
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Representation of the information found in a binary channel header.
|
||||
/// </summary>
|
||||
///
|
||||
public class TDASBinaryChannelHeader
|
||||
: Exceptional,
|
||||
IChannelHeader
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Get/set acquisition rate value.
|
||||
/// </summary>
|
||||
public Double AcquisitionRate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set number of pre-T0 data points.
|
||||
/// </summary>
|
||||
public int NumberOfPreT0DataPoints
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set number of post-T0 data points.
|
||||
/// </summary>
|
||||
public int NumberOfPostT0DataPoints
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
public int PreZeroLevelInCnts
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
public int PreCalLevelInCnts
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
public Double SignalToNoiseRatioInDb
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
public int PostZeroLevelInCnts
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
public int PostCalLevelInCnts
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
public int DataZeroLevelInCnts
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set scale factor MV.
|
||||
/// </summary>
|
||||
public Double ScaleFactorMVPerCnt
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
public Double ScaleFactorEUPerCnt
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the CRC32 for this binary channe header.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="stripEuPadding">
|
||||
/// <see cref="bool"/> option enables/disables automatic stripping of EU padding.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The CRC32 of the binary channel header.
|
||||
/// </returns>
|
||||
///
|
||||
private UInt32 CalculateCrc32(bool stripEuPadding, bool bKeepEuLength)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = new List<byte>();
|
||||
|
||||
data.AddRange(BitConverter.GetBytes(AcquisitionRate));
|
||||
data.AddRange(BitConverter.GetBytes(NumberOfPreT0DataPoints));
|
||||
data.AddRange(BitConverter.GetBytes(NumberOfPostT0DataPoints));
|
||||
data.AddRange(BitConverter.GetBytes(PreZeroLevelInCnts));
|
||||
data.AddRange(BitConverter.GetBytes(PreCalLevelInCnts));
|
||||
data.AddRange(BitConverter.GetBytes(SignalToNoiseRatioInDb));
|
||||
data.AddRange(BitConverter.GetBytes(PostZeroLevelInCnts));
|
||||
data.AddRange(BitConverter.GetBytes(PostCalLevelInCnts));
|
||||
data.AddRange(BitConverter.GetBytes(DataZeroLevelInCnts));
|
||||
data.AddRange(BitConverter.GetBytes(ScaleFactorMVPerCnt));
|
||||
data.AddRange(BitConverter.GetBytes(ScaleFactorEUPerCnt));
|
||||
if (data.Count % 2 > 0) data.Add(0x0);
|
||||
var byteDataArray = data.ToArray();
|
||||
ushort crc = 0xFFFF;
|
||||
for (var i = 0; i < data.Count; i += 2)
|
||||
crc = Utils.Math_DoCRC16Step(BitConverter.ToUInt16(byteDataArray, i), crc);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem calculating CRC 32", ex);
|
||||
}
|
||||
}
|
||||
public UInt32 UnpaddedEuStringPaddedEuLengthCrc32
|
||||
{
|
||||
get
|
||||
{
|
||||
try { return CalculateCrc32(true, true); }
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem getting CRC32 for binary header channel with unpadded EU string and padded EU Length", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Get The CRC for the current state of the header (autostrip padding from EU first).
|
||||
/// </summary>
|
||||
public UInt32 UnpaddedEuCrc32
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return CalculateCrc32(true, false);
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem getting CRC32 for binary header channel with unpadded EU string", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the CRC for the current state of the header.
|
||||
/// </summary>
|
||||
public UInt32 Crc32
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return CalculateCrc32(false, false);
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem generating CRC for binary channel header information", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
114
Common/DTS.Common.Serialization/TDAS/TDAS.File.IChannelHeader.cs
Normal file
114
Common/DTS.Common.Serialization/TDAS/TDAS.File.IChannelHeader.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* DTS.Serialization.TDAS.File.IChannelHeader.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace DTS.Serialization.TDAS
|
||||
{
|
||||
public interface IChannelHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// Get/set acquisition rate value.
|
||||
/// </summary>
|
||||
Double AcquisitionRate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set number of pre-T0 data points.
|
||||
/// </summary>
|
||||
int NumberOfPreT0DataPoints
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set number of post-T0 data points.
|
||||
/// </summary>
|
||||
int NumberOfPostT0DataPoints
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
int PreZeroLevelInCnts
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
int PreCalLevelInCnts
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
Double SignalToNoiseRatioInDb
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
int PostZeroLevelInCnts
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
int PostCalLevelInCnts
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
int DataZeroLevelInCnts
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set scale factor MV.
|
||||
/// </summary>
|
||||
Double ScaleFactorMVPerCnt
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set z.
|
||||
/// </summary>
|
||||
Double ScaleFactorEUPerCnt
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* TDAS.File.PersistentChannel.DataTooBigForArrayException.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace DTS.Serialization.TDAS
|
||||
{
|
||||
// *** see TDAS.File.cs ***
|
||||
public partial class File
|
||||
{
|
||||
|
||||
// *** see TDAS.File.PersistentChannel.cs ***
|
||||
public partial class PersistentChannel
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Representation of an attempt to "arrayify" a large dataset that's too large to be
|
||||
/// safely handled in an array.
|
||||
/// </summary>
|
||||
public class DataTooBigForArrayException : ApplicationException
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Initialize an instance of the DataTooBigForArrayException class.
|
||||
/// </summary>
|
||||
///
|
||||
public DataTooBigForArrayException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the DataTooBigForArrayException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
public DataTooBigForArrayException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the DataTooBigForArrayException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The <see cref="System.Exception"/> responsible for this exception inception.
|
||||
/// </param>
|
||||
///
|
||||
public DataTooBigForArrayException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
} // *** end PersistentChannel ***
|
||||
} // *** end File ***
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* TDAS.File.PersistentChannel.NotInitializedException.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace DTS.Serialization.TDAS
|
||||
{
|
||||
// *** see TDAS.File.cs ***
|
||||
public partial class File
|
||||
{
|
||||
|
||||
// *** see TDAS.File.PersistentChannel.cs ***
|
||||
public partial class PersistentChannel
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Representation of an attempt to get a property that has yet to be initialized.
|
||||
/// </summary>
|
||||
public class NotInitializedException : ApplicationException
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Initialize an instance of the NotInitializedException class.
|
||||
/// </summary>
|
||||
///
|
||||
public NotInitializedException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the NotInitializedException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
public NotInitializedException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the NotInitializedException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The <see cref="System.Exception"/> responsible for this exception inception.
|
||||
/// </param>
|
||||
///
|
||||
public NotInitializedException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
} // *** end PersistentChannel ***
|
||||
} // *** end File ***
|
||||
}
|
||||
1548
Common/DTS.Common.Serialization/TDAS/TDAS.File.PersistentChannel.cs
Normal file
1548
Common/DTS.Common.Serialization/TDAS/TDAS.File.PersistentChannel.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* TDAS.File.Reader.BadCrcException.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
namespace DTS.Serialization.TDAS
|
||||
{
|
||||
// *** see TDAS.File.cs ***
|
||||
public partial class File
|
||||
{
|
||||
// *** see TDAS.File.Reader.cs ***
|
||||
public partial class Reader
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Representation of a bad CRC filer event.
|
||||
/// </summary>
|
||||
///
|
||||
public class BadCrcException : Exception
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Initialize an instance of the BadCrcException class.
|
||||
/// </summary>
|
||||
///
|
||||
public BadCrcException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the BadCrcException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
public BadCrcException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the BadCrcException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The inner <see cref="System.Exception"/> that led to this exception's inception.
|
||||
/// </param>
|
||||
///
|
||||
public BadCrcException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* TDAS.File.Reader.MissingFileException.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
namespace DTS.Serialization.TDAS
|
||||
{
|
||||
// *** see TDAS.File.cs ***
|
||||
public partial class File
|
||||
{
|
||||
// *** see TDAS.File.Reader.cs ***
|
||||
public partial class Reader
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Representation of a missing-file filer event.
|
||||
/// </summary>
|
||||
///
|
||||
public class MissingFileException : Exception
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Initialize an instance of the MissingFileException class.
|
||||
/// </summary>
|
||||
///
|
||||
public MissingFileException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the MissingFileException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
public MissingFileException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the MissingFileException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The inner <see cref="System.Exception"/> that led to this exception's inception.
|
||||
/// </param>
|
||||
///
|
||||
public MissingFileException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* TDAS.File.Reader.TooManyFilesException.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
namespace DTS.Serialization.TDAS
|
||||
{
|
||||
// *** see TDAS.File.cs ***
|
||||
public partial class File
|
||||
{
|
||||
// *** see TDAS.File.Reader.cs ***
|
||||
public partial class Reader
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Representation of too-many-files filer event.
|
||||
/// </summary>
|
||||
///
|
||||
public class TooManyFilesException : Exception
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Initialize an instance of the TooManyFilesException class.
|
||||
/// </summary>
|
||||
///
|
||||
public TooManyFilesException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the TooManyFilesException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
public TooManyFilesException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the TooManyFilesException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The <see cref="System.Exception"/> responsible for this exception inception.
|
||||
/// </param>
|
||||
///
|
||||
public TooManyFilesException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1518
Common/DTS.Common.Serialization/TDAS/TDAS.File.Reader.cs
Normal file
1518
Common/DTS.Common.Serialization/TDAS/TDAS.File.Reader.cs
Normal file
File diff suppressed because it is too large
Load Diff
173
Common/DTS.Common.Serialization/TDAS/TDAS.File.Writer.cs
Normal file
173
Common/DTS.Common.Serialization/TDAS/TDAS.File.Writer.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* TDAS.File.Writer.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Serialization.TDAS
|
||||
{
|
||||
// *** see TDAS.File.cs ***
|
||||
public partial class File
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Utility object for serializing <see cref="DTS.Serialization.Test"/>s to disk
|
||||
/// in the Diadem
|
||||
/// </summary>
|
||||
///
|
||||
public class Writer : Writer<File>, IWriter<Test>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Diadem.File.Writer class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="fileType">
|
||||
/// The associated <see cref="DTS.SErialization.Diadem.File"/> object.
|
||||
/// </param>
|
||||
///
|
||||
internal Writer(File fileType, int encoding)
|
||||
: base(fileType, encoding)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Write the specified test to the specified pathname.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="pathname">
|
||||
/// The <see cref="string"/> pathname to which the specified test should be serialized.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="test">
|
||||
/// The <see cref="DTS.Serialization.Test"/> to be written out.
|
||||
/// </param>
|
||||
///
|
||||
public void Write(string pathname, string id, Test test, bool bFiltering, bool includeGroupNameInISOExport, double minStartTime, int dataCollectionLength)
|
||||
{
|
||||
throw new NotSupportedException("TDAS::File::Writer Write(pathname, id, test, bFiltering) not supported");
|
||||
}
|
||||
private const string TLF_FILE_BACKUP_EXTENSION = ".TLF PreTest Backup";
|
||||
/// <summary>
|
||||
/// Write the representation file/files of the specified DTS.Serialization.Test
|
||||
/// at the given pathname.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="targetPathname">
|
||||
/// The <see cref="string"/> pathname of the specified object's resulting file
|
||||
/// representation.
|
||||
/// </param>
|
||||
///
|
||||
public void Write(string pathname,
|
||||
string id,
|
||||
string dataFolder,
|
||||
Test test,
|
||||
bool bFiltering,
|
||||
bool includeGroupNameInISOExport,
|
||||
FilteredData fd,
|
||||
Test.Module.Channel tmChannel,
|
||||
int channelNumber,
|
||||
BeginEventHandler beginEventHandler,
|
||||
CancelEventHandler cancelEventHandler,
|
||||
EndEventHandler endEventHandler,
|
||||
TickEventHandler tickEventHandler,
|
||||
ErrorEventHandler errorEventHandler,
|
||||
CancelRequested cancelRequested,
|
||||
double minStartTime,
|
||||
int dataCollectionLength)
|
||||
{
|
||||
System.Exception exception = null;
|
||||
try
|
||||
{
|
||||
beginEventHandler?.Invoke(this, Convert.ToUInt32(test.Channels.Count));
|
||||
var tlf = new TLF(pathname, test, id);
|
||||
using (var sw = new StreamWriter(pathname, false, Encoding.Default))
|
||||
{
|
||||
tlf.Serialize(sw);
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
var tlfFileInfo = new FileInfo(pathname);
|
||||
var backupTLFFileName = tlfFileInfo.Name.Replace(tlfFileInfo.Extension, TLF_FILE_BACKUP_EXTENSION);
|
||||
var backupFilePath = Path.Combine(tlfFileInfo.DirectoryName, backupTLFFileName);
|
||||
try
|
||||
{
|
||||
System.IO.File.Copy(tlfFileInfo.FullName, backupFilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log($"Failed to backup file {tlfFileInfo.FullName} to {backupFilePath}", ex);
|
||||
}
|
||||
|
||||
var startingChannel = tlf.LastChannelNumber + 1;
|
||||
var startingSquibChannel = 901;
|
||||
var maxSampleRate = test.Channels.Select(ch => ch.ParentModule.SampleRateHz).Max();
|
||||
for (var i = 0; i < test.Channels.Count; i++)
|
||||
{
|
||||
var fi = new FileInfo(pathname);
|
||||
var newFile = string.Empty;
|
||||
if ((test.Channels[i] as Test.Module.AnalogInputChannel).IsSquibChannel)
|
||||
{
|
||||
newFile = fi.FullName.Replace(fi.Extension, string.Format("{0:000}.BIN", startingSquibChannel));
|
||||
startingSquibChannel++;
|
||||
}
|
||||
else
|
||||
{
|
||||
newFile = fi.FullName.Replace(fi.Extension, string.Format("{0:000}.BIN", startingChannel));
|
||||
startingChannel++;
|
||||
}
|
||||
using (var bw = new BinaryWriter(new FileStream(newFile, FileMode.OpenOrCreate)))
|
||||
{
|
||||
var bin = new TLFBin(test.Channels[i], maxSampleRate);
|
||||
bin.Serialize(bw, test.Channels[i]);
|
||||
bw.Flush();
|
||||
bw.Close();
|
||||
}
|
||||
tickEventHandler?.Invoke(this, Convert.ToDouble(i + 1));
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
APILogger.Log("encountered problem writing TDAS test files", ex);
|
||||
}
|
||||
|
||||
if (null != errorEventHandler && null != exception)
|
||||
{
|
||||
endEventHandler(this);
|
||||
errorEventHandler(this, exception);
|
||||
}
|
||||
else if (null != exception) { throw exception; }
|
||||
else
|
||||
{
|
||||
tickEventHandler?.Invoke(this, 100.0);
|
||||
endEventHandler?.Invoke(this);
|
||||
}
|
||||
}
|
||||
public void Initialize(string pathname,
|
||||
string id,
|
||||
string dataFolder,
|
||||
Test test,
|
||||
bool bFiltering,
|
||||
bool includeGroupNameInISOExport,
|
||||
FilteredData fd,
|
||||
Test.Module.Channel tmChannel,
|
||||
int channelNumber,
|
||||
BeginEventHandler beginEventHandler,
|
||||
CancelEventHandler cancelEventHandler,
|
||||
EndEventHandler endEventHandler,
|
||||
TickEventHandler tickEventHandler,
|
||||
ErrorEventHandler errorEventHandler,
|
||||
CancelRequested cancelRequested)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
145
Common/DTS.Common.Serialization/TDAS/TDAS.File.cs
Normal file
145
Common/DTS.Common.Serialization/TDAS/TDAS.File.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* TDAS.File.cs
|
||||
*
|
||||
* Copyright © 2010
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Serialization.TDAS
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// TDAS File
|
||||
/// </summary>
|
||||
///
|
||||
public partial class File
|
||||
: Serialization.File, IWritable<Test>
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Initialize an instance of the FtssCsv.File class.
|
||||
/// </summary>
|
||||
///
|
||||
public File()
|
||||
: base("TDAS")
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get this file format's extension.
|
||||
/// </summary>
|
||||
public static string Extension => ".tlf";
|
||||
|
||||
/// <summary>
|
||||
/// Get the file writer for this file type.
|
||||
/// </summary>
|
||||
public IWriter<Test> Exporter
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_Exporter == null)
|
||||
_Exporter = new Writer(this, DefaultEncoding);
|
||||
return _Exporter;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem getting exporter", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private IWriter<Test> _Exporter = null;
|
||||
|
||||
/// <summary>
|
||||
/// Get the file reader for this file type.
|
||||
/// </summary>
|
||||
public IReader<Test> Importer
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_Importer == null)
|
||||
_Importer = new Reader(this);
|
||||
return _Importer;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem getting importer", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private IReader<Test> _Importer = null;
|
||||
|
||||
/// <summary>
|
||||
/// File extension for the disk entity that contains the serialized test information.
|
||||
/// </summary>
|
||||
public static string TestFileExtension
|
||||
{
|
||||
get => _TestFileExtension.Value;
|
||||
private set => _TestFileExtension.Value = value;
|
||||
}
|
||||
private static readonly Property<string> _TestFileExtension = new Property<string>("TestFileExtension", ".tlf", true);
|
||||
|
||||
/// <summary>
|
||||
/// File extension for the disk entity that contains serialized channel information.
|
||||
/// </summary>
|
||||
public static string ChannelFileExtension
|
||||
{
|
||||
get => _ChannelFileExtension.Value;
|
||||
private set => _ChannelFileExtension.Value = value;
|
||||
}
|
||||
private static readonly Property<string> _ChannelFileExtension = new Property<string>("ChannelFileExtension", ".BIN", true);
|
||||
|
||||
/// <summary>
|
||||
/// File extension for the disk entity that contains serialized channel information.
|
||||
/// </summary>
|
||||
public static string CalculatedChannelFileExtension
|
||||
{
|
||||
get => _CalculatedChannelFileExtension.Value;
|
||||
private set => _CalculatedChannelFileExtension.Value = value;
|
||||
}
|
||||
private static readonly Property<string> _CalculatedChannelFileExtension = new Property<string>("CalculatedChannelFileExtension", ".cchn", true);
|
||||
|
||||
/// <summary>
|
||||
/// The string that separates the channel numbers from the riffraff.
|
||||
/// </summary>
|
||||
private const string ChannelNumberDelimiter = ".";
|
||||
|
||||
/// <summary>
|
||||
/// Extract the channel number from the specified channel filename.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="channelFileName">
|
||||
/// The channel filename <see cref="string"/> to be converted into a channel number.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="int"/> channel number represented by the specified file.
|
||||
/// </returns>
|
||||
///
|
||||
public override int GetChannelNumberFromChannelFileName(string channelFileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var indexOfExtension = channelFileName.LastIndexOf(ChannelFileExtension);
|
||||
if (indexOfExtension == -1)
|
||||
{
|
||||
indexOfExtension = channelFileName.LastIndexOf(ChannelFileExtension.ToLower());
|
||||
}
|
||||
var indexOfFirstChannelNumberCharacter = indexOfExtension - 3; //901, 001, etc. but could be _C001 (not a problem)
|
||||
var intResult = -1;
|
||||
int.TryParse(channelFileName.Substring(indexOfFirstChannelNumberCharacter, 3), out intResult);
|
||||
return intResult;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem getting channel number from channel file name", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2766
Common/DTS.Common.Serialization/TDAS/TLF.cs
Normal file
2766
Common/DTS.Common.Serialization/TDAS/TLF.cs
Normal file
File diff suppressed because it is too large
Load Diff
208
Common/DTS.Common.Serialization/TDAS/TLFBin.cs
Normal file
208
Common/DTS.Common.Serialization/TDAS/TLFBin.cs
Normal file
@@ -0,0 +1,208 @@
|
||||
using System;
|
||||
using DTS.Common.Constant;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
|
||||
namespace DTS.Serialization.TDAS
|
||||
{
|
||||
public class TLFBin
|
||||
{
|
||||
public double AcquisitionRate { get; set; }
|
||||
public int PreTriggerDataPoints { get; set; }
|
||||
public int PostTriggerDataPoints { get; set; }
|
||||
public int PreZeroLevel { get; set; }
|
||||
public int PreCalLevel { get; set; }
|
||||
public double SignalToNoiseRatio { get; set; }
|
||||
public int PostZeroLevel { get; set; }
|
||||
public int PostCalLevel { get; set; }
|
||||
public double SuperSampleRate { get; set; }
|
||||
|
||||
public TLFBin(Test.Module.Channel channel, double superSampleRate)
|
||||
{
|
||||
SuperSampleRate = superSampleRate;
|
||||
var aic = channel as Test.Module.AnalogInputChannel;
|
||||
AcquisitionRate = aic.ParentModule.SampleRateHz;
|
||||
var rate = Convert.ToInt32(Math.Ceiling(superSampleRate / AcquisitionRate));
|
||||
PreTriggerDataPoints = Convert.ToInt32(rate * ((long)aic.ParentModule.TriggerSampleNumbers[0] - (long)aic.ParentModule.StartRecordSampleNumber));
|
||||
PostTriggerDataPoints = Convert.ToInt32(rate * ((long)aic.ParentModule.NumberOfSamples - ((long)aic.ParentModule.TriggerSampleNumbers[0] - (long)aic.ParentModule.StartRecordSampleNumber)));
|
||||
PreZeroLevel = Convert.ToInt32(aic.PreTestZeroLevelAdc);
|
||||
PreCalLevel = Convert.ToInt32(.7D * short.MaxValue);//we could put in a constant value, but
|
||||
//this makes it clear where the value is coming from
|
||||
|
||||
|
||||
// Noise as a % of full scale is actually std dev noise as percent of full scale?
|
||||
// so by dividing by the full scale (which is in ADC to avoid confusion) we should
|
||||
// have std dev noise back, we don't infact have a precal value in slice, so
|
||||
// maybe using 80% of the full range will give us something reasonable
|
||||
// I used the min value since the equation producing noise as a percent of full scale
|
||||
// is using 32768, which is actually - short.min;
|
||||
var stddev = aic.NoiseAsPercentageOfFullScale / (-1D) * short.MinValue;
|
||||
stddev /= 100D;
|
||||
if (0 == stddev) { SignalToNoiseRatio = 0D; }
|
||||
else
|
||||
{
|
||||
SignalToNoiseRatio = 20D * Math.Log10(-.8D * short.MinValue / stddev);
|
||||
}
|
||||
|
||||
//@TODO - this information isn't currently available
|
||||
//PostZeroLevel = Convert.ToInt32(aic.PreTestZeroLevelAdc);
|
||||
PostZeroLevel = 0;
|
||||
PostCalLevel = 0;
|
||||
|
||||
var excitationVoltage = 5D;
|
||||
if ((!aic.IsSquibChannel) && (aic.Bridge != SensorConstants.BridgeType.DigitalInput))
|
||||
{
|
||||
try
|
||||
{
|
||||
excitationVoltage = aic.FactoryExcitationVoltage;
|
||||
}
|
||||
catch (Exception) { excitationVoltage = aic.MeasuredExcitationVoltage; }
|
||||
}
|
||||
//14251 - TDC export does not respect viewer data modifications for multiply
|
||||
//ScaleFactorEU *= aic.Data.Multiplier;
|
||||
}
|
||||
public void Serialize(System.IO.BinaryWriter bw, Test.Module.Channel channel)
|
||||
{
|
||||
var aic = (Test.Module.AnalogInputChannel)channel;
|
||||
var scaler = SliceRaw.File.Reader.GetDataScaler(aic);
|
||||
|
||||
//147662,112211
|
||||
var rate = Convert.ToInt32(Math.Ceiling(SuperSampleRate / AcquisitionRate));
|
||||
bw.Write(BitConverter.GetBytes(SuperSampleRate), 0, 8);
|
||||
bw.Write(BitConverter.GetBytes(PreTriggerDataPoints), 0, 4);
|
||||
bw.Write(BitConverter.GetBytes(PostTriggerDataPoints), 0, 4);
|
||||
bw.Write(BitConverter.GetBytes(PreZeroLevel), 0, 4);
|
||||
bw.Write(BitConverter.GetBytes(PreCalLevel), 0, 4);
|
||||
bw.Write(BitConverter.GetBytes(SignalToNoiseRatio), 0, 8);
|
||||
bw.Write(BitConverter.GetBytes(PostZeroLevel), 0, 4);
|
||||
bw.Write(BitConverter.GetBytes(PostCalLevel), 0, 4);
|
||||
bw.Write(BitConverter.GetBytes(Convert.ToInt32(scaler.GetDataZeroLevelADC())), 0, 4);
|
||||
bw.Write(BitConverter.GetBytes(scaler.GetScaleFactorMv()), 0, 8);
|
||||
if (!aic.LinearizationFormula.IsValid())
|
||||
{
|
||||
bw.Write(BitConverter.GetBytes(scaler.GetAdcToEuScalingFactor()), 0, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.Write(BitConverter.GetBytes(aic.SensorCapacity / (ushort.MaxValue / 2.0)), 0, 8);
|
||||
}
|
||||
if (((Test.Module.AnalogInputChannel)channel).Bridge == SensorConstants.BridgeType.DigitalInput)
|
||||
{
|
||||
double breakPoint = DigitalInputs.ConstantCurrentBreakPoint;
|
||||
if (aic.DigitalMode == DigitalInputModes.THL || aic.DigitalMode == DigitalInputModes.TLH)
|
||||
{
|
||||
breakPoint = DigitalInputs.VoltageInputBreakPoint;
|
||||
}
|
||||
|
||||
for (ulong i = 0; i < channel.PersistentChannelInfo.NumberOfSamples; i++)
|
||||
{
|
||||
for (var step = 0; step < rate; step++)
|
||||
{
|
||||
var adc = channel.PersistentChannelInfo[i];
|
||||
var increment = 0D;
|
||||
if ((i + 1) < channel.PersistentChannelInfo.NumberOfSamples)
|
||||
{
|
||||
increment = (channel.PersistentChannelInfo[i + 1] - adc) / rate;
|
||||
}
|
||||
else
|
||||
{
|
||||
increment = (adc - channel.PersistentChannelInfo[i - 1]) / rate;
|
||||
}
|
||||
if ((adc + increment * step) > breakPoint)
|
||||
{
|
||||
switch (aic.DigitalMode)
|
||||
{
|
||||
case DigitalInputModes.CCNC:
|
||||
bw.Write(BitConverter.GetBytes((short)aic.DigitalMultiplier.ActiveValue), 0, 2);
|
||||
break;
|
||||
case DigitalInputModes.CCNO:
|
||||
bw.Write(BitConverter.GetBytes((short)aic.DigitalMultiplier.DefaultValue), 0, 2);
|
||||
break;
|
||||
case DigitalInputModes.THL:
|
||||
bw.Write(BitConverter.GetBytes((short)aic.DigitalMultiplier.ActiveValue), 0, 2);
|
||||
break;
|
||||
case DigitalInputModes.TLH:
|
||||
bw.Write(BitConverter.GetBytes((short)aic.DigitalMultiplier.DefaultValue), 0, 2);
|
||||
break;
|
||||
default:
|
||||
bw.Write(BitConverter.GetBytes((short)aic.DigitalMultiplier.ActiveValue), 0, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (aic.DigitalMode)
|
||||
{
|
||||
case DigitalInputModes.CCNC:
|
||||
bw.Write(BitConverter.GetBytes((short)aic.DigitalMultiplier.DefaultValue), 0, 2);
|
||||
break;
|
||||
case DigitalInputModes.CCNO:
|
||||
bw.Write(BitConverter.GetBytes((short)aic.DigitalMultiplier.ActiveValue), 0, 2);
|
||||
break;
|
||||
case DigitalInputModes.THL:
|
||||
bw.Write(BitConverter.GetBytes((short)aic.DigitalMultiplier.DefaultValue), 0, 2);
|
||||
break;
|
||||
case DigitalInputModes.TLH:
|
||||
bw.Write(BitConverter.GetBytes((short)aic.DigitalMultiplier.ActiveValue), 0, 2);
|
||||
break;
|
||||
default:
|
||||
bw.Write(BitConverter.GetBytes((short)aic.DigitalMultiplier.DefaultValue), 0, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ulong i = 0; i < channel.PersistentChannelInfo.NumberOfSamples; i++)
|
||||
{
|
||||
var adc = channel.PersistentChannelInfo[i];
|
||||
for (int step = 0; step < rate; step++)
|
||||
{
|
||||
var increment = 0D;
|
||||
|
||||
if ((i + 1) < channel.PersistentChannelInfo.NumberOfSamples)
|
||||
{
|
||||
increment = (channel.PersistentChannelInfo[i + 1] - adc) / rate;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
increment = (adc - channel.PersistentChannelInfo[i - 1]) / rate;
|
||||
}
|
||||
//Use correct calculation for linear and non linear
|
||||
//http://fogbugz/fogbugz/default.asp?10172
|
||||
if (!aic.LinearizationFormula.IsValid())
|
||||
{
|
||||
bw.Write(BitConverter.GetBytes(Convert.ToInt16(adc + increment * step)), 0, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
//14496 TDAS export ALL failed
|
||||
//newADC was underflowing in the below code that was causing an exception in 14496
|
||||
//the sensor capacity was about 80mm, however there were some datapoints that were out of normal range
|
||||
//(-250 or so EU), this appeared to be from a sig-gen ramp that went out of range for the IR-TRACC equation
|
||||
//per CPB we now constrain newADC to short min/max and so the ADC rails in those spots.
|
||||
var adcperEU = (ushort.MaxValue / 2.0) / aic.SensorCapacity;
|
||||
var newADC = scaler.GetEU(adc) * adcperEU;
|
||||
newADC += increment * step;
|
||||
if (newADC < short.MinValue)
|
||||
{
|
||||
bw.Write(BitConverter.GetBytes(short.MinValue), 0, 2);
|
||||
}
|
||||
else if (newADC > short.MaxValue)
|
||||
{
|
||||
bw.Write(BitConverter.GetBytes(short.MaxValue), 0, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.Write(BitConverter.GetBytes(Convert.ToInt16(newADC)), 0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user