init
This commit is contained in:
173
Common/DTS.Common.Serialization/TSV/TSV.File.Writer.cs
Normal file
173
Common/DTS.Common.Serialization/TSV/TSV.File.Writer.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
55
Common/DTS.Common.Serialization/TSV/TSV.File.cs
Normal file
55
Common/DTS.Common.Serialization/TSV/TSV.File.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* SoMat.File.cs
|
||||
*
|
||||
* Copyright © 2013
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
namespace DTS.Serialization.TSV
|
||||
{
|
||||
///
|
||||
/// <summary>
|
||||
/// File
|
||||
/// </summary>
|
||||
///
|
||||
public partial class File
|
||||
: Serialization.File, IWritable<Test>
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Initialize an instance of the FtssCsv.File class.
|
||||
/// </summary>
|
||||
///
|
||||
public File()
|
||||
: base("TSV")
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get this file format's extension.
|
||||
/// </summary>
|
||||
public static string Extension => ".tsv";
|
||||
|
||||
/// <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;
|
||||
}
|
||||
}
|
||||
144
Common/DTS.Common.Serialization/TSV/TSVChannel.cs
Normal file
144
Common/DTS.Common.Serialization/TSV/TSVChannel.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Serialization.TSV
|
||||
{
|
||||
public class TSVChannel
|
||||
{
|
||||
private readonly TSVTest _parentTest;
|
||||
|
||||
private readonly Dictionary<TSVTest.Fields, string> _values = new Dictionary<TSVTest.Fields, string>();
|
||||
public string GetValue(TSVTest.Fields field)
|
||||
{
|
||||
if (!_values.ContainsKey(field)) { _values.Add(field, "#NOVALUE"); }
|
||||
return _values[field];
|
||||
}
|
||||
public void SetValue(TSVTest.Fields field, string value)
|
||||
{
|
||||
_values[field] = value;
|
||||
switch (field)
|
||||
{
|
||||
case TSVTest.Fields.DataType:
|
||||
if (value == "Raw")
|
||||
{
|
||||
SetValue(TSVTest.Fields.EngineeringUnits, "ADC");
|
||||
SetValue(TSVTest.Fields.DigitalFilterType, "");
|
||||
var actualRange = _parentTest.ActualRangesADC[_channelIndex];
|
||||
|
||||
SetValue(TSVTest.Fields.BitResolution, (2D * actualRange / ushort.MaxValue).ToString());
|
||||
|
||||
FileName = System.IO.Path.Combine(System.IO.Path.Combine(_path, "TSV"), "Raw");
|
||||
FileName = System.IO.Path.Combine(FileName, string.Format("{0}_{1}.TSV", _parentTest.Test.Id, ChannelNumber));
|
||||
}
|
||||
else if (value == "Processed")
|
||||
{
|
||||
SetValue(TSVTest.Fields.EngineeringUnits, _engineeringUnits);
|
||||
SetValue(TSVTest.Fields.DigitalFilterType, string.Format("CFC {0}/{1}", _parentTest.DataFilteredEU[_channelIndex].FilterDescription, _parentTest.DataFilteredEU[_channelIndex].FilterFrequencyHz));
|
||||
var actualRange = _parentTest.ActualRangesEUFiltered[_channelIndex];
|
||||
|
||||
SetValue(TSVTest.Fields.BitResolution, (2D * actualRange / ushort.MaxValue).ToString());
|
||||
FileName = System.IO.Path.Combine(System.IO.Path.Combine(_path, "TSV"), "Processed");
|
||||
FileName = System.IO.Path.Combine(FileName, string.Format("{0}_{1}.TSV", _parentTest.Test.Id, ChannelNumber));
|
||||
}
|
||||
else if (value == "Converted")
|
||||
{
|
||||
SetValue(TSVTest.Fields.EngineeringUnits, _engineeringUnits);
|
||||
SetValue(TSVTest.Fields.DigitalFilterType, "");
|
||||
var actualRange = _parentTest.ActualRangesEUUnfiltered[_channelIndex];
|
||||
|
||||
SetValue(TSVTest.Fields.BitResolution, (2D * actualRange / ushort.MaxValue).ToString());
|
||||
FileName = System.IO.Path.Combine(System.IO.Path.Combine(_path, "TSV"), "Converted");
|
||||
FileName = System.IO.Path.Combine(FileName, string.Format("{0}_{1}.TSV", _parentTest.Test.Id, ChannelNumber));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
private readonly string _engineeringUnits = "";
|
||||
public string FileName { get; set; }
|
||||
|
||||
public void Serialize(TickEventHandler tickHandler)
|
||||
{
|
||||
|
||||
if (!System.IO.Directory.Exists(new System.IO.FileInfo(FileName).Directory.FullName))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(new System.IO.FileInfo(FileName).Directory.FullName);
|
||||
}
|
||||
using (var sw = new System.IO.StreamWriter(FileName, false, Encoding.Default))
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(TSVTest.Fields)).Cast<TSVTest.Fields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
sw.WriteLine("{0}\t{1}", TSVStrings.ResourceManager.GetString(string.Format("{0}_Title", field.ToString())),
|
||||
GetValue(field));
|
||||
}
|
||||
var channel = _parentTest.Test.Channels[_channelIndex] as Test.Module.AnalogInputChannel;
|
||||
|
||||
double dStartTime = channel.ParentModule.StartRecordSampleNumber / channel.ParentModule.SampleRateHz;
|
||||
if (channel.ParentModule.TriggerSampleNumbers.Count > 0)
|
||||
{
|
||||
dStartTime -= channel.ParentModule.TriggerSampleNumbers[0] / channel.ParentModule.SampleRateHz;
|
||||
}
|
||||
//double increment = 1D / channel.ParentModule.SampleRateHz;
|
||||
var current = dStartTime;
|
||||
double percentageComplete = _channelIndex / _parentTest.Channels.Length;
|
||||
var weight = 1D / _parentTest.Channels.Length;
|
||||
var decimalplaces = Convert.ToInt32(Math.Ceiling(Math.Log10(channel.ParentModule.SampleRateHz)));
|
||||
double[] data;
|
||||
if (GetValue(TSVTest.Fields.DataType) == "Raw")
|
||||
{
|
||||
data = _parentTest.DataADC[_channelIndex].Data;
|
||||
}
|
||||
else if (GetValue(TSVTest.Fields.DataType) == "Converted")
|
||||
{
|
||||
data = _parentTest.DataUnfilteredEU[_channelIndex].Data;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _parentTest.DataFilteredEU[_channelIndex].Data;
|
||||
}
|
||||
for (ulong i = 0; i < channel.ParentModule.NumberOfSamples; i++)
|
||||
{
|
||||
current = dStartTime + (double)i / channel.ParentModule.SampleRateHz;
|
||||
current = Truncate(current, decimalplaces);
|
||||
sw.WriteLine("{0}\t{1}", current, data[i]);
|
||||
if (0 == i % 1000)
|
||||
{
|
||||
var percent = 100D * (percentageComplete + i * weight / channel.ParentModule.NumberOfSamples);
|
||||
tickHandler(this, percent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static double Truncate(double value, int decimalplaces)
|
||||
{
|
||||
var d = Math.Pow(10, decimalplaces);
|
||||
var tmp = (int)Math.Truncate(d * value);
|
||||
return tmp / d;
|
||||
}
|
||||
private readonly int _channelIndex = 0;
|
||||
public int ChannelNumber => 1 + _channelIndex;
|
||||
private readonly string _path;
|
||||
public TSVChannel(TSVTest parentTest, int channelIndex, string path)
|
||||
{
|
||||
_path = path;
|
||||
_parentTest = parentTest;
|
||||
_channelIndex = channelIndex;
|
||||
var aic = parentTest.Test.Channels[channelIndex] as Test.Module.AnalogInputChannel;
|
||||
|
||||
_engineeringUnits = aic.EngineeringUnits.TrimEnd();
|
||||
|
||||
SetValue(TSVTest.Fields.EngineeringUnits, aic.EngineeringUnits.TrimEnd());
|
||||
SetValue(TSVTest.Fields.SensorMakeModelSerial, aic.SerialNumber);
|
||||
SetValue(TSVTest.Fields.SensorLocation, aic.Description);
|
||||
|
||||
SetValue(TSVTest.Fields.DigitalFilterType, string.Format("CFC {0}/{1}", _parentTest.DataFilteredEU[_channelIndex].FilterDescription, _parentTest.DataFilteredEU[_channelIndex].FilterFrequencyHz));
|
||||
var actualRange = _parentTest.ActualRangesEUFiltered[_channelIndex];
|
||||
|
||||
SetValue(TSVTest.Fields.BitResolution, (2D * actualRange / ushort.MaxValue).ToString());
|
||||
FileName = System.IO.Path.Combine(System.IO.Path.Combine(path, "TSV"), "Processed");
|
||||
FileName = System.IO.Path.Combine(FileName, string.Format("{0}_{1}.TSV", parentTest.Test.Id, 1 + channelIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
178
Common/DTS.Common.Serialization/TSV/TSVSettingsWindow.Designer.cs
generated
Normal file
178
Common/DTS.Common.Serialization/TSV/TSVSettingsWindow.Designer.cs
generated
Normal file
@@ -0,0 +1,178 @@
|
||||
namespace DTS.Serialization.TSV
|
||||
{
|
||||
partial class TSVSettingsWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TSVSettingsWindow));
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.c1GridGlobal = new C1.Win.C1FlexGrid.C1FlexGrid();
|
||||
this.c1GridChannels = new C1.Win.C1FlexGrid.C1FlexGrid();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.c1GridGlobal)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.c1GridChannels)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 1;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.button1, 0, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.tabControl1, 0, 1);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 3;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 494F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(731, 570);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(3, 544);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "Export";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label1.Location = new System.Drawing.Point(3, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(656, 20);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Use Global tab to set values across all channels. Use Channels tab to set indivi" +
|
||||
"dual channel values.";
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
this.tabControl1.Controls.Add(this.tabPage1);
|
||||
this.tabControl1.Controls.Add(this.tabPage2);
|
||||
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tabControl1.Location = new System.Drawing.Point(3, 50);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new System.Drawing.Size(725, 488);
|
||||
this.tabControl1.TabIndex = 2;
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Controls.Add(this.c1GridGlobal);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(717, 462);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "Global Settings";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.c1GridChannels);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(717, 462);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "Channel Settings";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// c1GridGlobal
|
||||
//
|
||||
this.c1GridGlobal.ColumnInfo = resources.GetString("c1GridGlobal.ColumnInfo");
|
||||
this.c1GridGlobal.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.c1GridGlobal.ExtendLastCol = true;
|
||||
this.c1GridGlobal.Location = new System.Drawing.Point(3, 3);
|
||||
this.c1GridGlobal.Name = "c1GridGlobal";
|
||||
this.c1GridGlobal.Rows.Count = 1;
|
||||
this.c1GridGlobal.Rows.DefaultSize = 19;
|
||||
this.c1GridGlobal.Size = new System.Drawing.Size(711, 456);
|
||||
this.c1GridGlobal.TabIndex = 0;
|
||||
this.c1GridGlobal.CellChanged += new C1.Win.C1FlexGrid.RowColEventHandler(this.c1GridGlobal_CellChanged);
|
||||
this.c1GridGlobal.AfterEdit += new C1.Win.C1FlexGrid.RowColEventHandler(this.c1GridGlobal_AfterEdit);
|
||||
//
|
||||
// c1GridChannels
|
||||
//
|
||||
this.c1GridChannels.AutoGenerateColumns = false;
|
||||
this.c1GridChannels.ColumnInfo = "1,1,0,0,0,95,Columns:";
|
||||
this.c1GridChannels.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.c1GridChannels.Location = new System.Drawing.Point(3, 3);
|
||||
this.c1GridChannels.Name = "c1GridChannels";
|
||||
this.c1GridChannels.Rows.Count = 1;
|
||||
this.c1GridChannels.Rows.DefaultSize = 19;
|
||||
this.c1GridChannels.Size = new System.Drawing.Size(711, 456);
|
||||
this.c1GridChannels.TabIndex = 0;
|
||||
this.c1GridChannels.CellChanged += new C1.Win.C1FlexGrid.RowColEventHandler(this.gridChannels_CellChanged);
|
||||
this.c1GridChannels.AfterEdit += new C1.Win.C1FlexGrid.RowColEventHandler(this.c1GridChannels_AfterEdit);
|
||||
//
|
||||
// TSVSettingsWindow
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(246)))), ((int)(((byte)(253)))));
|
||||
this.ClientSize = new System.Drawing.Size(731, 570);
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.Name = "TSVSettingsWindow";
|
||||
this.Text = "TSV Options";
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
this.tabPage2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.c1GridGlobal)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.c1GridChannels)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TabControl tabControl1;
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private System.Windows.Forms.TabPage tabPage2;
|
||||
private C1.Win.C1FlexGrid.C1FlexGrid c1GridGlobal;
|
||||
private C1.Win.C1FlexGrid.C1FlexGrid c1GridChannels;
|
||||
}
|
||||
}
|
||||
166
Common/DTS.Common.Serialization/TSV/TSVSettingsWindow.cs
Normal file
166
Common/DTS.Common.Serialization/TSV/TSVSettingsWindow.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DTS.Serialization.TSV
|
||||
{
|
||||
public partial class TSVSettingsWindow : Form
|
||||
{
|
||||
protected TSVSettingsWindow() { InitializeComponent(); }
|
||||
|
||||
private volatile bool _bPopulating = false;
|
||||
private TSVTest _test;
|
||||
public TSVSettingsWindow(TSVTest test)
|
||||
{
|
||||
InitializeComponent();
|
||||
_test = test;
|
||||
_bPopulating = true;
|
||||
try
|
||||
{
|
||||
c1GridGlobal.AutoGenerateColumns = false;
|
||||
c1GridGlobal.Styles.Alternate.BackColor = Properties.Settings1.Default.AlternatingRow;
|
||||
c1GridGlobal.Styles.Fixed.BackColor = Properties.Settings1.Default.TableHeader;
|
||||
|
||||
TSVTest.Fields[] fields = Enum.GetValues(typeof(TSVTest.Fields)).Cast<TSVTest.Fields>().ToArray();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case TSVTest.Fields.AAFilterCutoffDescription:
|
||||
case TSVTest.Fields.BitResolution:
|
||||
case TSVTest.Fields.ChannelErrors:
|
||||
case TSVTest.Fields.DataType:
|
||||
case TSVTest.Fields.DigitalFilterType:
|
||||
case TSVTest.Fields.EngineeringUnits:
|
||||
case TSVTest.Fields.SensorAxis:
|
||||
case TSVTest.Fields.SensorLocation:
|
||||
case TSVTest.Fields.SensorMakeModelSerial:
|
||||
case TSVTest.Fields.SensorMountType:
|
||||
//do not display
|
||||
break;
|
||||
default:
|
||||
var row = c1GridGlobal.Rows.Add();
|
||||
row["colField"] = TSVStrings.ResourceManager.GetString(string.Format("{0}_Title", field.ToString()));
|
||||
row["colDescription"] = TSVStrings.ResourceManager.GetString(string.Format("{0}_Description", field.ToString()));
|
||||
row["colValue"] = test.GetValue(field);
|
||||
row.UserData = field;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
c1GridChannels.Styles.Fixed.BackColor = Properties.Settings1.Default.TableHeader;
|
||||
c1GridChannels.Styles.Alternate.BackColor = Properties.Settings1.Default.AlternatingRow;
|
||||
|
||||
var c = c1GridChannels.Cols.Add();
|
||||
c.Caption = "Channel Number";
|
||||
c.AllowEditing = false;
|
||||
c.DataType = typeof(int);
|
||||
c.Name = "colNumber";
|
||||
c.UserData = null;
|
||||
|
||||
c = c1GridChannels.Cols.Add();
|
||||
c.Caption = "File Name";
|
||||
c.AllowEditing = true;
|
||||
c.DataType = typeof(string);
|
||||
c.Name = "colFileName";
|
||||
c.UserData = null;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
c = c1GridChannels.Cols.Add();
|
||||
c.Caption = TSVStrings.ResourceManager.GetString(string.Format("{0}_Title", field.ToString()));
|
||||
c.DataType = typeof(string);
|
||||
c.AllowEditing = true;
|
||||
c.Name = "col" + field.ToString();
|
||||
c.UserData = field;
|
||||
}
|
||||
|
||||
foreach (var channel in test.Channels)
|
||||
{
|
||||
var r = c1GridChannels.Rows.Add();
|
||||
r["colNumber"] = channel.ChannelNumber;
|
||||
r["colFileName"] = channel.FileName;
|
||||
foreach (var field in fields) { r["col" + field.ToString()] = channel.GetValue(field); }
|
||||
r.UserData = channel;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_bPopulating = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void c1GridGlobal_CellChanged(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void gridChannels_CellChanged(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void c1GridChannels_AfterEdit(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
|
||||
{
|
||||
if (_bPopulating) { return; }
|
||||
try
|
||||
{
|
||||
_bPopulating = true;
|
||||
if (null != c1GridChannels.Rows[e.Row].UserData)
|
||||
{
|
||||
TSVChannel channel = c1GridChannels.Rows[e.Row].UserData as TSVChannel;
|
||||
if (null == channel) { return; }
|
||||
|
||||
if (null != c1GridChannels.Cols[e.Col].UserData)
|
||||
{
|
||||
TSVTest.Fields field = (TSVTest.Fields)c1GridChannels.Cols[e.Col].UserData;
|
||||
channel.SetValue(field, c1GridChannels.Rows[e.Row][e.Col] as string);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_bPopulating = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void c1GridGlobal_AfterEdit(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
|
||||
{
|
||||
if (_bPopulating) { return; }
|
||||
try
|
||||
{
|
||||
if (null != c1GridGlobal.Rows[e.Row].UserData)
|
||||
{
|
||||
TSVTest.Fields field = (TSVTest.Fields)c1GridGlobal.Rows[e.Row].UserData;
|
||||
_test.SetValue(field, c1GridGlobal.Rows[e.Row]["colValue"] as string);
|
||||
|
||||
for (int i = 0; i < c1GridChannels.Rows.Count; i++)
|
||||
{
|
||||
if (null != c1GridChannels.Rows[i].UserData)
|
||||
{
|
||||
TSVChannel channel = c1GridChannels.Rows[i].UserData as TSVChannel;
|
||||
if (null != channel)
|
||||
{
|
||||
c1GridChannels.Rows[i]["col" + field.ToString()] = channel.GetValue(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { _bPopulating = false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
123
Common/DTS.Common.Serialization/TSV/TSVSettingsWindow.resx
Normal file
123
Common/DTS.Common.Serialization/TSV/TSVSettingsWindow.resx
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="c1GridGlobal.ColumnInfo" xml:space="preserve">
|
||||
<value>4,1,0,0,0,95,Columns:1{Name:"colField";Caption:"Field";AllowEditing:False;Style:"DataType:System.String;TextAlign:LeftCenter;";} 2{Name:"colValue";Caption:"Value";Style:"DataType:System.String;TextAlign:LeftCenter;";} 3{Name:"colDescription";Caption:"Description";AllowEditing:False;Style:"DataType:System.String;TextAlign:LeftCenter;";} </value>
|
||||
</data>
|
||||
</root>
|
||||
104
Common/DTS.Common.Serialization/TSV/TSVTest.cs
Normal file
104
Common/DTS.Common.Serialization/TSV/TSVTest.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Serialization.TSV
|
||||
{
|
||||
public class TSVTest
|
||||
{
|
||||
public enum Fields
|
||||
{
|
||||
LabName,
|
||||
POCName,
|
||||
POCPhoneAndEmail,
|
||||
TestDate,
|
||||
TestTime,
|
||||
TestNumber,
|
||||
TestType,
|
||||
TestObject,
|
||||
DataType,
|
||||
SensorMakeModelSerial,
|
||||
SensorLocation,
|
||||
SensorAxis,
|
||||
SensorMountType,
|
||||
EngineeringUnits,
|
||||
ChannelErrors,
|
||||
SamplingRate,
|
||||
AAFilterCutoffDescription,
|
||||
BitResolution,
|
||||
DigitalFilterType,
|
||||
Notes
|
||||
}
|
||||
|
||||
private readonly Dictionary<Fields, string> _values = new Dictionary<Fields, string>();
|
||||
public string GetValue(Fields field)
|
||||
{
|
||||
if (!_values.ContainsKey(field)) { _values.Add(field, "#NOVALUE"); }
|
||||
return _values[field];
|
||||
}
|
||||
|
||||
public void SetValue(Fields field, string value)
|
||||
{
|
||||
_values[field] = value;
|
||||
foreach (var channel in _channels) { channel.SetValue(field, value); }
|
||||
switch (field)
|
||||
{
|
||||
case Fields.POCName: Properties.Settings1.Default.TSVPOCNameLastUsed = value; Properties.Settings1.Default.Save(); break;
|
||||
case Fields.POCPhoneAndEmail: Properties.Settings1.Default.TSVPOCPhoneAndEmailLastUsed = value; Properties.Settings1.Default.Save(); break;
|
||||
case Fields.DataType: Properties.Settings1.Default.TSVDataTypeLastUsed = value; Properties.Settings1.Default.Save(); break;
|
||||
case Fields.LabName: Properties.Settings1.Default.TSVLabNameLastUsed = value; Properties.Settings1.Default.Save(); break;
|
||||
case Fields.TestObject: Properties.Settings1.Default.TSVTestObjectLastUsed = value; Properties.Settings1.Default.Save(); break;
|
||||
case Fields.TestType: Properties.Settings1.Default.TSVTestTypeLastUsed = value; Properties.Settings1.Default.Save(); break;
|
||||
}
|
||||
}
|
||||
private readonly List<TSVChannel> _channels = new List<TSVChannel>();
|
||||
public TSVChannel[] Channels
|
||||
{
|
||||
get => _channels.ToArray();
|
||||
set { _channels.Clear(); _channels.AddRange(value); }
|
||||
}
|
||||
public Test Test { get; }
|
||||
public FilteredData[] DataFilteredEU { get; }
|
||||
public FilteredData[] DataUnfilteredEU { get; }
|
||||
public FilteredData[] DataADC { get; }
|
||||
public double[] ActualRangesEUFiltered { get; }
|
||||
public double[] ActualRangesEUUnfiltered { get; }
|
||||
public double[] ActualRangesADC { get; }
|
||||
|
||||
public TSVTest(Test test,
|
||||
FilteredData[] euFiltered,
|
||||
FilteredData[] adc,
|
||||
FilteredData[] euUnfiltered,
|
||||
string path,
|
||||
double[] actualRangesEUFiltered,
|
||||
double[] actualRangesEUUnfiltered,
|
||||
double[] actualRAngesADC)
|
||||
{
|
||||
Test = test;
|
||||
|
||||
DataUnfilteredEU = euUnfiltered;
|
||||
DataFilteredEU = euFiltered;
|
||||
DataADC = adc;
|
||||
|
||||
ActualRangesADC = actualRAngesADC;
|
||||
ActualRangesEUUnfiltered = actualRangesEUUnfiltered;
|
||||
ActualRangesEUFiltered = actualRangesEUFiltered;
|
||||
|
||||
for (var i = 0; i < test.Channels.Count && i < euUnfiltered.Length; i++)
|
||||
{
|
||||
_channels.Add(new TSVChannel(this, i, path));
|
||||
}
|
||||
SetValue(Fields.TestNumber, test.Id);
|
||||
SetValue(Fields.TestDate, test.InceptionDate.ToShortDateString());
|
||||
SetValue(Fields.TestTime, test.InceptionDate.ToShortTimeString());
|
||||
|
||||
SetValue(Fields.POCName, Properties.Settings1.Default.TSVPOCNameLastUsed);
|
||||
SetValue(Fields.POCPhoneAndEmail, Properties.Settings1.Default.TSVPOCPhoneAndEmailLastUsed);
|
||||
SetValue(Fields.DataType, Properties.Settings1.Default.TSVDataTypeLastUsed);
|
||||
SetValue(Fields.LabName, Properties.Settings1.Default.TSVLabNameLastUsed);
|
||||
SetValue(Fields.TestObject, Properties.Settings1.Default.TSVTestObjectLastUsed);
|
||||
SetValue(Fields.TestType, Properties.Settings1.Default.TSVTestTypeLastUsed);
|
||||
SetValue(Fields.SamplingRate, test.Modules.First().SampleRateHz.ToString());
|
||||
SetValue(Fields.AAFilterCutoffDescription, string.Format("{0}hz multipole low pass butterworth", test.Modules.First().AaFilterRateHz.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user