106 lines
4.5 KiB
C#
106 lines
4.5 KiB
C#
using System;
|
|
using DTS.Common.Enums;
|
|
using DTS.Common.Interface.TestSetups.Imports.TTS.LevelTrigger;
|
|
using DTS.Common.Interface.TestSetups.Imports.TTS.ReadFile;
|
|
using System.Security.Cryptography;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DTS.Common.Interface.Sensors;
|
|
|
|
namespace TTSImport.Model
|
|
{
|
|
public class TTSTestSetup : ITTSSetup
|
|
{
|
|
public double SampleRate { get; set; }
|
|
public RecordingModes Mode { get; set; }
|
|
public double TestLength => PreTrigger + PostTrigger;
|
|
public double PreTrigger { get; set; }
|
|
public double PostTrigger { get; set; }
|
|
public double ROIStart { get; set; }
|
|
public double ROIEnd { get; set; }
|
|
public string Filename { get; set; }
|
|
public string TestId { get; set; }
|
|
/// <summary>
|
|
/// The first 4 lines of the .csv file are needed if a new .csv is to be created
|
|
/// </summary>
|
|
public string Line1 { get; set; }
|
|
public string Line2 { get; set; }
|
|
public string Line3 { get; set; }
|
|
public string Line4 { get; set; }
|
|
public string[] DummyList { get; set; }
|
|
public ITTSChannelRecord[] Channels { get; set; }
|
|
public ILevelTrigger[] LevelTriggers { get; set; }
|
|
public string OriginalImportFile { get; set; }
|
|
/// <summary>
|
|
/// If True, HybridRecorder is added to CircularBuffer and Recorder as choices.
|
|
/// </summary>
|
|
public bool AllowAdvancedRecordingModes { get; set; }
|
|
/// <summary>
|
|
/// if True, Active Ram and Active Ram Multiple events are valid modes
|
|
/// http://manuscript.dts.local/f/cases/31841/Add-support-for-Active-RAM-mode
|
|
/// </summary>
|
|
public bool AllowActiveRecordingModes { get; set; }
|
|
public bool AllowTSRAIRRecordingModes { get; set; }
|
|
/// <inheritdoc />
|
|
/// <summary>
|
|
/// allows consumers to specify whether EIDs must be found for sensors to be used
|
|
/// </summary>
|
|
public bool RequireEIDFound { get; set; }
|
|
/// <summary>
|
|
/// The value from DataPRO.config.exe
|
|
/// </summary>
|
|
public string DefaultDigitalInputMode { get; set; }
|
|
public ISquibSettingDefaults SquibDefaults { get; set; }
|
|
/// <summary>
|
|
/// The value from DataPRO.config.exe
|
|
/// </summary>
|
|
public double DefaultSquibFireDurationMs { get; set; }
|
|
/// <summary>
|
|
/// this holds sensor to hardware assignments that are pre-existing before the user even scans hardware
|
|
/// this can only happen through the XML import
|
|
/// the assignments are removed once they are made, but persist across hardware scans until they are made (for instance if the hardware
|
|
/// is not present in the first hardwarescan the assignments will remain till the hardware is found).
|
|
/// this is not true if the user has already manually assigned the channel
|
|
/// </summary>
|
|
public Tuple<string, string>[] PreAssignedSensorIdAndHwId { get; set; }
|
|
|
|
private const int NUM_LEVEL_TRIGGERS = 6;
|
|
public TTSTestSetup()
|
|
{
|
|
DummyList = new string[8];
|
|
Channels = new ITTSChannelRecord[0];
|
|
LevelTriggers = new ILevelTrigger[NUM_LEVEL_TRIGGERS];
|
|
for (var i = 0; i < NUM_LEVEL_TRIGGERS; i++)
|
|
{
|
|
LevelTriggers[i] = new TTSLevelTriggerRecord(this);
|
|
}
|
|
}
|
|
|
|
public new string GetHashCode()
|
|
{
|
|
var bytes = new List<byte>();
|
|
bytes.AddRange(BitConverter.GetBytes(SampleRate));
|
|
bytes.AddRange(BitConverter.GetBytes((int)Mode));
|
|
bytes.AddRange(BitConverter.GetBytes(PreTrigger));
|
|
bytes.AddRange(BitConverter.GetBytes(PostTrigger));
|
|
bytes.AddRange(BitConverter.GetBytes(ROIStart));
|
|
bytes.AddRange(BitConverter.GetBytes(ROIEnd));
|
|
bytes.AddRange(Encoding.UTF8.GetBytes(TestId ?? ""));
|
|
|
|
foreach (var ch in Channels)
|
|
{
|
|
bytes.AddRange(ch.GetBytes());
|
|
}
|
|
|
|
foreach (var lt in LevelTriggers)
|
|
{
|
|
bytes.AddRange(lt.GetBytes());
|
|
}
|
|
var sha = new SHA256Managed();
|
|
var hash = sha.ComputeHash(bytes.ToArray());
|
|
var hashString = BitConverter.ToString(hash).Replace("-", string.Empty);
|
|
return hashString;
|
|
}
|
|
}
|
|
}
|