init
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.Utils;
|
||||
|
||||
namespace DTS.Serialization.SliceRaw
|
||||
{
|
||||
public partial class File
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Representation of the information found in a binary module timestamp header.
|
||||
/// </summary>
|
||||
///
|
||||
public class BinaryDasTimestampHeader
|
||||
: Exceptional,
|
||||
IDasTimestampHeader
|
||||
{
|
||||
///
|
||||
/// <summary>
|
||||
/// "Magic Key" required for our binary file type.
|
||||
/// </summary>
|
||||
///
|
||||
public static uint RequiredMagicKey => 0xF15363C2; //persistentchannel's backwards
|
||||
|
||||
public static uint CurrentVersionNumber => 0x01;
|
||||
|
||||
/// <summary>
|
||||
/// Header version number required for our binary file type.
|
||||
/// </summary>
|
||||
public static List<uint> KnownHeaderVersionNumbers => new List<uint>(new uint[] { 0x01 });
|
||||
|
||||
/// <summary>
|
||||
/// "Magic Key" relatively-UID <see cref="UInt32"/> for our binary file type.
|
||||
/// </summary>
|
||||
public uint MagicKey
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="UInt32"/> header version number for our binary file type.
|
||||
/// </summary>
|
||||
public uint HeaderVersionNumber
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set offset of sample data start value.
|
||||
/// </summary>
|
||||
public ulong OffsetOfSampleDataStart
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set number of samples.
|
||||
/// </summary>
|
||||
public ulong NumberOfSamples
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// Get/set sample rate value.
|
||||
/// </summary>
|
||||
public uint NumberOfBitsPerSample
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the CRC32 for this binary channe header.
|
||||
/// </summary>
|
||||
///
|
||||
/// <returns>
|
||||
/// The CRC32 of the binary channel header.
|
||||
/// </returns>
|
||||
///
|
||||
private uint CalculateCrc32()
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = new List<byte>();
|
||||
|
||||
data.AddRange(BitConverter.GetBytes(MagicKey));
|
||||
data.AddRange(BitConverter.GetBytes(HeaderVersionNumber));
|
||||
data.AddRange(BitConverter.GetBytes(OffsetOfSampleDataStart));
|
||||
data.AddRange(BitConverter.GetBytes(NumberOfSamples));
|
||||
data.AddRange(BitConverter.GetBytes(NumberOfBitsPerSample));
|
||||
|
||||
if (data.Count % 2 > 0) data.Add(0x0);
|
||||
var byteDataArray = data.ToArray();
|
||||
//APILogger.Log($"[DTM]: data array for CRC: {BitConverter.ToString(byteDataArray)}");
|
||||
ushort crc = 0xFFFF;
|
||||
for (var i = 0; i < data.Count; i += 2)
|
||||
crc = Utils.Math_DoCRC16Step(BitConverter.ToUInt16(byteDataArray, i), crc);
|
||||
//APILogger.Log($"[DTM]: crc {crc}");
|
||||
return crc;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem calculating CRC 32", ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Get the CRC for the current state of the header.
|
||||
/// </summary>
|
||||
public uint Crc32
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return CalculateCrc32();
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem generating CRC for binary channel header information", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* TSV.File.Writer.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Serialization.TSV
|
||||
{
|
||||
// *** see TSV.File.Writer.cs ***
|
||||
public partial class File
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Utility object for serializing <see cref="Test"/>s to disk
|
||||
/// in the TSV format
|
||||
/// </summary>
|
||||
///
|
||||
public class Writer : Writer<File>, IWriter<Test>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the TSV.File.Writer class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="fileType">
|
||||
/// The associated <see cref="DTS.SErialization.TSV.File"/> object.
|
||||
/// </param>
|
||||
///
|
||||
internal Writer(File fileType, int encoding)
|
||||
: base(fileType, encoding)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The different export modes that should theoretically be supported by this format.
|
||||
/// </summary>
|
||||
public enum ExportMode
|
||||
{
|
||||
FtssExcel,
|
||||
Ttc,
|
||||
Standard,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the current TSV export format.
|
||||
/// </summary>
|
||||
public ExportMode CurrentExportMode
|
||||
{
|
||||
get => _CurrentExportMode.Value;
|
||||
set => _CurrentExportMode.Value = value;
|
||||
}
|
||||
private readonly Property<ExportMode> _CurrentExportMode
|
||||
= new Property<ExportMode>(
|
||||
typeof(Writer).Namespace + ".File.Writer.CurrentExportMode",
|
||||
ExportMode.FtssExcel,
|
||||
true
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the filtered channel data. If this list is supplied, the corresponding test
|
||||
/// channel data values will be supplied from this list.
|
||||
/// </summary>
|
||||
public List<FilteredData> FilteredChannelData
|
||||
{
|
||||
get => _FilteredChannelData.Value;
|
||||
set => _FilteredChannelData.Value = value;
|
||||
}
|
||||
private readonly Property<List<FilteredData>> _FilteredChannelData
|
||||
= new Property<List<FilteredData>>(
|
||||
"FilteredChannelData",
|
||||
new List<FilteredData>(),
|
||||
true
|
||||
);
|
||||
|
||||
/// <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="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("TSV::File::Writer Write(pathname, id, test, bFiltering) not supported");
|
||||
}
|
||||
|
||||
public TSVTest MyTSVTest { get; set; }
|
||||
/// <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(100)); foreach (var channel in MyTSVTest.Channels) { channel.Serialize(tickEventHandler); }
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
APILogger.Log("encountered problem writing TSV test files", ex);
|
||||
}
|
||||
tickEventHandler?.Invoke(this, 100D);
|
||||
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)
|
||||
{
|
||||
}
|
||||
public double Start { get; set; } = 0D;
|
||||
public double Stop { get; set; } = 0D;
|
||||
public ushort SubSampleInterval { get; set; }
|
||||
public bool Filtered { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user