using System.Collections.Generic; namespace DTS.Serialization.SoMat { public class SoMatTestHeader { public string TestTitle { get; set; } = ""; public string Operator { get; set; } = ""; public string RunDateTime { get; set; } = ""; private readonly List _channels = new List(); public int NumLogChannels => _channels.Count; public SoMatChannel[] Channels => _channels.ToArray(); public int NumDataModes { get; set; } = 1; public void Serialize(System.IO.StreamWriter sw) { sw.Write("DM_TestTitle="); sw.WriteLine(TestTitle); sw.Write("DM_Operator="); sw.WriteLine(Operator); sw.Write("RUNDATETIME="); sw.WriteLine(RunDateTime); sw.Write("DM_NumLogChans="); sw.WriteLine(NumLogChannels.ToString()); sw.Write("DM_NumDataModes="); sw.WriteLine(NumDataModes.ToString()); sw.WriteLine(); } public SoMatTestHeader(Test test, FilteredData[] filteredData) { TestTitle = test.Id; RunDateTime = string.Format("{0} {1}", test.InceptionDate.ToShortDateString(), test.InceptionDate.ToShortTimeString()); try { Operator = System.Security.Principal.WindowsIdentity.GetCurrent().Name; } catch (System.Exception) { } for (var i = 0; i < test.Channels.Count && i < filteredData.Length; i++) { var moduleArrayIndex = 0; for (moduleArrayIndex = 0; moduleArrayIndex < test.Modules.Count; moduleArrayIndex++) { if (test.Channels[i].ParentModule.SerialNumber == test.Modules[moduleArrayIndex].SerialNumber) { break; } } _channels.Add(new SoMatChannel(test.Channels[i], 1 + i, filteredData[i], moduleArrayIndex, 3, test.InceptionDate)); } } } }