/* * 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 { /// /// /// Utility object for serializing s to disk /// in the TSV format /// /// public class Writer : Writer, IWriter { /// /// Initialize an instance of the TSV.File.Writer class. /// /// /// /// The associated object. /// /// internal Writer(File fileType, int encoding) : base(fileType, encoding) { } /// /// The different export modes that should theoretically be supported by this format. /// public enum ExportMode { FtssExcel, Ttc, Standard, } /// /// Get/set the current TSV export format. /// public ExportMode CurrentExportMode { get => _CurrentExportMode.Value; set => _CurrentExportMode.Value = value; } private readonly Property _CurrentExportMode = new Property( typeof(Writer).Namespace + ".File.Writer.CurrentExportMode", ExportMode.FtssExcel, true ); /// /// Get/set the filtered channel data. If this list is supplied, the corresponding test /// channel data values will be supplied from this list. /// public List FilteredChannelData { get => _FilteredChannelData.Value; set => _FilteredChannelData.Value = value; } private readonly Property> _FilteredChannelData = new Property>( "FilteredChannelData", new List(), true ); /// /// 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 NotSupportedException("TSV::File::Writer Write(pathname, id, test, bFiltering) not supported"); } public TSVTest MyTSVTest { 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; 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; } } } }