/*
* 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
{ ///
///
/// Utility object for serializing s to disk
/// in the Diadem
///
///
public class Writer : Writer, IWriter
{
///
/// Initialize an instance of the SoMat.File.Writer class.
///
///
///
/// The associated object.
///
///
internal Writer(File fileType, int encoding)
: base(fileType, encoding)
{
}
///
/// Write the specified test to the specified pathname.
///
///
///
/// The pathname to which the specified test should be serialized.
///
///
///
/// The to be written out.
///
///
public void Write(string pathname, string id, Test test, bool bFiltering, bool includeGroupNameInISOExport, double minStartTime, int dataCollectionLength)
{
throw new NotImplementedException();
}
///
/// The number of data samples that need to be written for a "tick" to be dispatched.
///
private int DataSamplesPerTick => 1000;
///
/// Return the number of data to be written per "tick".
///
///
///
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() + "\"" : ""), ex);
}
}
public string ExtensionPrefix { get; set; } = string.Empty;
public DDASTest MyTVTTest { get; set; }
///
/// Write the representation file/files of the specified DTS.Serialization.Test
/// at the given pathname.
///
///
///
/// The pathname of the specified object's resulting file
/// representation.
///
///
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)
{
}
}
}
}