init
This commit is contained in:
74
Common/DTS.Common.Serialization/Iso/Report/ChannelData.cs
Normal file
74
Common/DTS.Common.Serialization/Iso/Report/ChannelData.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using DTS.Common;
|
||||
|
||||
namespace DTS.Serialization.Iso.Report
|
||||
{
|
||||
/// <summary>
|
||||
/// this class encapsulates a single line in the iso test summary report
|
||||
/// </summary>
|
||||
internal class ChannelData
|
||||
{
|
||||
/// <summary>
|
||||
/// the number of the channel among all channels in the data
|
||||
/// </summary>
|
||||
public int ChannelNumber { get; set; } = 1;
|
||||
/// <summary>
|
||||
/// the iso code for a channel
|
||||
/// </summary>
|
||||
public string ISOCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// the name of the channel (iso channel name)
|
||||
/// </summary>
|
||||
public string ChannelName { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// the channel filter class for the channel (as in test setup, does not need to match exported data)
|
||||
/// </summary>
|
||||
public string SAEFilterClass { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// the electronic id at test setup time for the channel
|
||||
/// </summary>
|
||||
public string SetupEID { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// the electronic id at run test time on channel
|
||||
/// </summary>
|
||||
public string DataCollectionEID { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// any data flags present on channel
|
||||
/// </summary>
|
||||
public DataFlag DataFlag { get; set; } = DataFlag.None;
|
||||
|
||||
public const string NAME_OF_CHANNEL = "Name of channel";
|
||||
public string GetLine()
|
||||
{
|
||||
return $"{NAME_OF_CHANNEL} {(1 + ChannelNumber):000} :{ISOCode} / {ChannelName} / {SAEFilterClass} / {SetupEID} / {DataCollectionEID} / {(int)DataFlag}";
|
||||
}
|
||||
/// <summary>
|
||||
/// creates a channeldata instance given a test data channel
|
||||
/// </summary>
|
||||
/// <param name="channel"></param>
|
||||
/// <returns></returns>
|
||||
public static ChannelData CreateChannel(Test.Module.Channel channel)
|
||||
{
|
||||
var isoCode = string.Empty;
|
||||
var isoChannelName = string.Empty;
|
||||
string filter = string.Empty;
|
||||
if ( channel is Test.Module.AnalogInputChannel analog)
|
||||
{
|
||||
isoCode = analog.IsoCode;
|
||||
filter = analog.SoftwareFilter.Replace(" ", "");
|
||||
isoChannelName = analog.IsoChannelName;
|
||||
}
|
||||
var channelData = new ChannelData()
|
||||
{
|
||||
ChannelName = isoChannelName,
|
||||
ChannelNumber = channel.AbsoluteDisplayOrder,
|
||||
DataCollectionEID = channel.DataCollectionEID,
|
||||
DataFlag = (DataFlag)channel.DataFlag,
|
||||
ISOCode = isoCode,
|
||||
SAEFilterClass = filter,
|
||||
SetupEID = channel.SetupEID
|
||||
};
|
||||
return channelData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
57
Common/DTS.Common.Serialization/Iso/Report/SummaryReport.cs
Normal file
57
Common/DTS.Common.Serialization/Iso/Report/SummaryReport.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Serialization.Iso.Report
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a class to simplify outputting a summary report
|
||||
/// http://manuscript.dts.local/f/cases/43495/Add-Summary-report-text-file-in-import-wizard
|
||||
/// http://manuscript.dts.local/f/cases/43833/SW-Test-Summary-Report-for-data-collection-THF
|
||||
/// </summary>
|
||||
public class SummaryReport
|
||||
{
|
||||
private readonly List<ChannelData> _channels = new List<ChannelData>();
|
||||
|
||||
private const string NUMBER_OF_CHANNELS = "Number of channels";
|
||||
public string GetLines()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"{NUMBER_OF_CHANNELS} :{_channels.Count:000} / / / / /");
|
||||
|
||||
foreach (var channel in _channels)
|
||||
{
|
||||
sb.AppendLine(channel.GetLine());
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
protected void AddChannels(Test.Module.Channel[] channels)
|
||||
{
|
||||
foreach( var channel in channels)
|
||||
{
|
||||
_channels.Add(ChannelData.CreateChannel(channel));
|
||||
}
|
||||
_channels.Sort((a, b) => a.ChannelNumber.CompareTo(b.ChannelNumber));
|
||||
}
|
||||
/// <summary>
|
||||
/// creates a test summary report given test data
|
||||
/// </summary>
|
||||
/// <param name="test"></param>
|
||||
/// <returns></returns>
|
||||
public static SummaryReport CreateSummaryReport(Test test)
|
||||
{
|
||||
var report = new SummaryReport();
|
||||
report.AddChannels([.. test.Channels]);
|
||||
return report;
|
||||
}
|
||||
/// <summary>
|
||||
/// outputs to path given test setup summary
|
||||
/// can throw exceptions
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="summary"></param>
|
||||
public static void OutputToPath(string path, SummaryReport summary)
|
||||
{
|
||||
System.IO.File.WriteAllText(System.IO.Path.Combine(path, "TestNo_FilterList.txt"), summary.GetLines());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user