init
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using IRIGCh10;
|
||||
using System;
|
||||
|
||||
namespace DTS.Serialization.IRIGCH10
|
||||
{
|
||||
//public class WriteTest
|
||||
//{
|
||||
// public static void Write()
|
||||
// {
|
||||
// var ch10File = new Chapter10File();
|
||||
|
||||
// ch10File.AddPacket(CreateTMATSPacket());
|
||||
// ch10File.AddPacket(CreateTimePacket());
|
||||
// ch10File.AddPacket(CreateUserDefinedPacket());
|
||||
// ch10File.AddPacket(CreatePCMPacket());
|
||||
// }
|
||||
|
||||
// private const long REFERENCE_RTC = 141989612500056;
|
||||
// private const long SECOND_RTC = 141989612612992;
|
||||
// private const long THIRD_RTC = 141989612606736;
|
||||
// private static IDataPacket CreateTMATSPacket()
|
||||
// {
|
||||
// var tmats = new TMATSPacket();
|
||||
// tmats.SetRTC(REFERENCE_RTC);
|
||||
// var s = TMATSCreationTest.CreateTMATS();
|
||||
// tmats.SetTMATSDocument(s);
|
||||
// return tmats;
|
||||
// }
|
||||
|
||||
// private static IDataPacket CreatePCMPacket()
|
||||
// {
|
||||
// var pcmPacket = new PCMPacket();
|
||||
// pcmPacket.SetRTC(THIRD_RTC);
|
||||
// pcmPacket.SetChannelID(BitConverter.ToUInt16(new byte[] { 0x00, 0x0A}, 0));
|
||||
// pcmPacket.SetDataVersion(Enums.DataTypeVersion.TG78);
|
||||
// pcmPacket.SetSequenceNumber(0);
|
||||
// pcmPacket.SetPacketFlags(false, false, false, false, Enums.SecondaryHeaderTimeFormat.IRIG106Chapter4,
|
||||
// Enums.DataCheckSumType.ThirtyTwoBit);
|
||||
// var data = new ushort[625];
|
||||
|
||||
// var amplitude = .25 * short.MaxValue;
|
||||
// var frequency = 1000;
|
||||
// for (var i = 0; i < data.Length; i++)
|
||||
// {
|
||||
// var val = (ushort)(0x8000 + amplitude * Math.Sin(2 * Math.PI * i * frequency) / 625);
|
||||
// }
|
||||
// //pcmPacket.SetThroughputData(data);
|
||||
// return pcmPacket;
|
||||
// }
|
||||
// private static IDataPacket CreateTimePacket()
|
||||
// {
|
||||
// var timePacket = new TimeDataPacket();
|
||||
// timePacket.SetRTC(SECOND_RTC);
|
||||
// timePacket.SetTime(new DateTime(2018, 11, 20, 22, 51, 11, 320));
|
||||
// timePacket.SetTimeFormat(Enums.TimeFormats.IRIGB);
|
||||
// timePacket.SetTimeSource(0x03);
|
||||
// timePacket.SetChannelID(BitConverter.ToUInt16(new byte[] {0xFF, 0xFF}, 0));
|
||||
// timePacket.SetDataVersion(Enums.DataTypeVersion.TG78);
|
||||
// timePacket.SetPacketFlags(false, false, false, false, Enums.SecondaryHeaderTimeFormat.IRIG106Chapter4,
|
||||
// Enums.DataCheckSumType.ThirtyTwoBit);
|
||||
// timePacket.SetSequenceNumber(1);
|
||||
// var bytes = timePacket.GetBytes();
|
||||
// return timePacket;
|
||||
// }
|
||||
|
||||
// private static IDataPacket CreateUserDefinedPacket()
|
||||
// {
|
||||
// var userPacket = new UserDefinedPacket();
|
||||
// return userPacket;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* SoMat.File.Writer.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace DTS.Serialization.DDAS
|
||||
{
|
||||
// *** see DDAS.File.Writer.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 SoMat.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 NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of data samples that need to be written for a "tick" to be dispatched.
|
||||
/// </summary>
|
||||
private int DataSamplesPerTick => 1000;
|
||||
|
||||
/// <summary>
|
||||
/// Return the number of data to be written per "tick".
|
||||
/// </summary>
|
||||
/// <param name="channel"></param>
|
||||
/// <returns></returns>
|
||||
private uint GetChannelTicks(Test.Module.Channel channel)
|
||||
{
|
||||
try
|
||||
{ //
|
||||
// Most of our wait time will be spent writing data, so we need to give
|
||||
// the process a little finer granularity.
|
||||
//
|
||||
return (uint)(channel.PersistentChannelInfo.Length / DataSamplesPerTick);
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem determining number of status ticks for channel " + (null != channel ? "\"" + channel.Number.ToString() + "\"" : "<NULL>"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string ExtensionPrefix { get; set; } = string.Empty;
|
||||
public DDASTest MyTVTTest { 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;
|
||||
uint totalWriteTicksNeeded = 0;
|
||||
if (test.Channels.Count > 0)
|
||||
totalWriteTicksNeeded = GetChannelTicks(test.Channels[0]);
|
||||
try
|
||||
{
|
||||
beginEventHandler?.Invoke(this, totalWriteTicksNeeded); foreach (var channel in MyTVTTest.Channels) { channel.Serialize(tickEventHandler); }
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
exception = 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user