239 lines
10 KiB
Plaintext
239 lines
10 KiB
Plaintext
|
|
using DTS.Common.Classes.DSP;
|
||
|
|
using DTS.Common.Enums;
|
||
|
|
using DTS.Common.Interface.Channels;
|
||
|
|
using DTS.Common.Interface.DASFactory;
|
||
|
|
using DTS.Common.Interface.Sensors;
|
||
|
|
using DTS.Common.Interface.StatusAndProgressBar;
|
||
|
|
using DTS.Common.Interface.TestSetups.TestSetupsList;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Text;
|
||
|
|
|
||
|
|
namespace DTS.DASLib.Service.StateMachine
|
||
|
|
{
|
||
|
|
public class ConfigureStatusParameters : IStatusParameters
|
||
|
|
{
|
||
|
|
#region ResolveChannels
|
||
|
|
public bool RequireIdFoundForSensorsWithIds { get; set; } = true;
|
||
|
|
public bool AllowMissingSensors { get; set; } = false;
|
||
|
|
public bool AllowSensorsOutOfPosition { get; set; } = true;
|
||
|
|
|
||
|
|
public ITestSetup TestSetupConfiguration { get; set; }
|
||
|
|
public delegate ISensorData GetSensorDelegate(IGroupChannel groupChannel);
|
||
|
|
|
||
|
|
public delegate ISensorCalibration GetSensorCalibrationDelegate(ISensorData sensor,
|
||
|
|
ExcitationVoltageOptions.ExcitationVoltageOption excitation);
|
||
|
|
/// <summary>
|
||
|
|
/// delegate allowing us to retrieve the latest sensor calibration given a sensor and an excitation
|
||
|
|
/// </summary>
|
||
|
|
public GetSensorCalibrationDelegate GetCalibrationAction { get; set; }
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// retrieves a sensor given a group channel
|
||
|
|
/// this is handled in DataPRO by DataModel.TestTemplate
|
||
|
|
/// but since that exists in UI land, we'll just define a delegate
|
||
|
|
/// and allow it to be provided by the consumer by whatever mechanism it chooses
|
||
|
|
/// for run test this should be testtemplate, but for testing it could equally
|
||
|
|
/// just come from the db or directly provided
|
||
|
|
/// </summary>
|
||
|
|
public GetSensorDelegate GetSensorAction { get; set; }
|
||
|
|
public bool AllowSensorIdToBlankChannel { get; set; }
|
||
|
|
|
||
|
|
public delegate int GetDatabaseIdDelegate(IDASCommunication das);
|
||
|
|
public GetDatabaseIdDelegate GetDatabaseIdAction { get; set; }
|
||
|
|
|
||
|
|
public delegate void SetSensorCalibrationDelegate(ISensorData sd, ISensorCalibration sc);
|
||
|
|
public SetSensorCalibrationDelegate SetSensorCalibrationAction { get; set; }
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region Configure
|
||
|
|
/// <summary>
|
||
|
|
/// Excitation should be turned off, this flag is reverted as soon as the process to turn off excitation starts
|
||
|
|
/// </summary>
|
||
|
|
public bool TurnOffExcitation { get; set; } = false;
|
||
|
|
/// <summary>
|
||
|
|
/// defines an array of units which configuration should be applied to
|
||
|
|
/// </summary>
|
||
|
|
public IDASCommunication[] UnitsToConfigure { get; set; } = new IDASCommunication[0];
|
||
|
|
/// <summary>
|
||
|
|
/// whether strict check should be used when applying configuration
|
||
|
|
/// </summary>
|
||
|
|
public bool DoStrictCheck { get; set; } = true;
|
||
|
|
/// <summary>
|
||
|
|
/// whether configuration should be written to even or diagnostic file stores
|
||
|
|
/// (this is a legacy feature of sliceware, not all units support it, but SLICE units have multiple file stores
|
||
|
|
/// so configuration could be written to different ones (diagnostic/event)
|
||
|
|
/// </summary>
|
||
|
|
public bool EventConfig { get; set; } = true;
|
||
|
|
/// <summary>
|
||
|
|
/// whether we are configuring units for data collection or just dummy collection (not collecting data)
|
||
|
|
/// </summary>
|
||
|
|
public bool DummyConfig { get; set; } = false;
|
||
|
|
/// <summary>
|
||
|
|
/// the MAX AAF for SLICE and TDAS
|
||
|
|
/// </summary>
|
||
|
|
public double[] MaxAAF { get; set; } = new double[0];
|
||
|
|
/// <summary>
|
||
|
|
/// whether digital outputs should be applied or not when applying configuration
|
||
|
|
/// this allows digital outputs to not be configured for say trigger check
|
||
|
|
/// </summary>
|
||
|
|
public bool ConfigureDigitalOutputs { get; set; } = true;
|
||
|
|
/// <summary>
|
||
|
|
/// the current configure process can occasionally require user input
|
||
|
|
/// [probably to acknowledge AAF errors?] this allows a method of interacting
|
||
|
|
/// during this process
|
||
|
|
/// </summary>
|
||
|
|
public ErrorCallback ErrorRequiringActionAction { get; set; }
|
||
|
|
/// <summary>
|
||
|
|
/// whether AAF should be turned off for realtime or not
|
||
|
|
/// AAF takes up a lot of time for slice realtime, so it's usually desirable to turn off
|
||
|
|
/// </summary>
|
||
|
|
public bool TurnOffAAFRealtime { get; set; } = true;
|
||
|
|
/// <summary>
|
||
|
|
/// whether to reset the hardware event lines before setting the config
|
||
|
|
/// </summary>
|
||
|
|
public bool ResetHardwareEventLines { get; set; } = false;
|
||
|
|
/// <summary>
|
||
|
|
/// whether to prepare for diagnostics (turn on excitation, switches)
|
||
|
|
/// </summary>
|
||
|
|
public bool PrepareForDiagnostics { get; set; } = false;
|
||
|
|
/// <summary>
|
||
|
|
/// lookup serial number to data collection rate
|
||
|
|
/// </summary>
|
||
|
|
public IReadOnlyDictionary<string, double> SampleRateLookup { get; set; } = new Dictionary<string, double>();
|
||
|
|
/// <summary>
|
||
|
|
/// lookup serial number to Anti Alias Filter rate
|
||
|
|
/// </summary>
|
||
|
|
public IReadOnlyDictionary<string, float> AAFRateLookup { get; set; } = new Dictionary<string, float>();
|
||
|
|
/// <summary>
|
||
|
|
/// whether turning on power should be skipped or not
|
||
|
|
/// this can allow excitation to remain off which is sometimes used to keep the units in low power state
|
||
|
|
/// until the user explicitly turns on power
|
||
|
|
/// </summary>
|
||
|
|
public bool SkipTurnOnPower { get; set; } = false;
|
||
|
|
/// <summary>
|
||
|
|
/// whether to apply configuration or not
|
||
|
|
/// </summary>
|
||
|
|
public bool SetConfiguration { get; set; } = true;
|
||
|
|
public DSPFilterType DSPFilterType { get; set; }
|
||
|
|
/// <summary>
|
||
|
|
/// whether to discard diagnostics when setting configuration
|
||
|
|
/// </summary>
|
||
|
|
public bool DiscardDiagnostics { get; set; } = true;
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
public ConfigureStatusParameters()
|
||
|
|
{
|
||
|
|
ResetDSPFilterType();
|
||
|
|
}
|
||
|
|
private void ResetDSPFilterType()
|
||
|
|
{
|
||
|
|
var dsp = DSPFilterCollection.GetDSPFilterCollection();
|
||
|
|
DSPFilterType = dsp.GetFilter(string.Empty);
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// resets all parameters back to defaults
|
||
|
|
/// </summary>
|
||
|
|
public void Reset()
|
||
|
|
{
|
||
|
|
RequireIdFoundForSensorsWithIds = true;
|
||
|
|
AllowMissingSensors = false;
|
||
|
|
AllowSensorsOutOfPosition = true;
|
||
|
|
DoStrictCheck = true;
|
||
|
|
EventConfig = true;
|
||
|
|
DummyConfig = false;
|
||
|
|
MaxAAF = new double[0];
|
||
|
|
ConfigureDigitalOutputs = true;
|
||
|
|
ErrorRequiringActionAction = null;
|
||
|
|
TestSetupConfiguration = null;
|
||
|
|
GetSensorAction = null;
|
||
|
|
AllowSensorIdToBlankChannel = false;
|
||
|
|
ResetHardwareEventLines = false;
|
||
|
|
PrepareForDiagnostics = false;
|
||
|
|
UnitsToConfigure = new IDASCommunication[0];
|
||
|
|
SampleRateLookup = new Dictionary<string, double>();
|
||
|
|
AAFRateLookup = new Dictionary<string, float>();
|
||
|
|
SkipTurnOnPower = false;
|
||
|
|
SetConfiguration = true;
|
||
|
|
TurnOffExcitation = false;
|
||
|
|
DiscardDiagnostics = true;
|
||
|
|
ResetDSPFilterType();
|
||
|
|
}
|
||
|
|
public override string ToString()
|
||
|
|
{
|
||
|
|
var sb = new StringBuilder();
|
||
|
|
sb.AppendLine($"RequireIdFoundForSensorsWithIds={RequireIdFoundForSensorsWithIds.ToString()}");
|
||
|
|
sb.AppendLine($"AllowMissingSensors={AllowMissingSensors.ToString()}");
|
||
|
|
sb.AppendLine($"AllowSensorsOutOfPosition={AllowSensorsOutOfPosition.ToString()}");
|
||
|
|
sb.AppendLine($"DoStrictCheck={DoStrictCheck.ToString()}");
|
||
|
|
sb.AppendLine($"EventConfig={EventConfig.ToString()}");
|
||
|
|
sb.AppendLine($"DummyConfig={DummyConfig.ToString()}");
|
||
|
|
sb.Append("MaxAAF=");
|
||
|
|
for (int i = 0; i < MaxAAF.Length; i++)
|
||
|
|
{
|
||
|
|
if (i > 0)
|
||
|
|
{
|
||
|
|
sb.Append(", ");
|
||
|
|
}
|
||
|
|
sb.Append(MaxAAF[i].ToString());
|
||
|
|
}
|
||
|
|
sb.AppendLine();
|
||
|
|
sb.AppendLine($"ConfigureDigitalOutputs={ConfigureDigitalOutputs.ToString()}");
|
||
|
|
sb.AppendLine($"AllowSensorIdToBlankChannel={AllowSensorIdToBlankChannel.ToString()}");
|
||
|
|
sb.AppendLine($"ResetHardwareEventLines={ResetHardwareEventLines.ToString()}");
|
||
|
|
sb.AppendLine($"PrepareForDiagnostics={PrepareForDiagnostics.ToString()}");
|
||
|
|
sb.Append("UnitsToConfigure=");
|
||
|
|
for (var i = 0; i < UnitsToConfigure.Length; i++)
|
||
|
|
{
|
||
|
|
if (i > 0)
|
||
|
|
{
|
||
|
|
sb.Append(", ");
|
||
|
|
}
|
||
|
|
sb.Append(UnitsToConfigure[i].SerialNumber);
|
||
|
|
}
|
||
|
|
|
||
|
|
sb.AppendLine();
|
||
|
|
sb.Append("SampleRateLookup=");
|
||
|
|
var first = true;
|
||
|
|
using (var enumSampleRate = SampleRateLookup.GetEnumerator())
|
||
|
|
{
|
||
|
|
while (enumSampleRate.MoveNext())
|
||
|
|
{
|
||
|
|
if (!first)
|
||
|
|
{
|
||
|
|
sb.Append(", ");
|
||
|
|
}
|
||
|
|
sb.Append($"{enumSampleRate.Current.Key}={enumSampleRate.Current.Value.ToString()}");
|
||
|
|
first = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
sb.AppendLine();
|
||
|
|
|
||
|
|
sb.Append("AAFLookup=");
|
||
|
|
first = true;
|
||
|
|
using (var enumAAF = AAFRateLookup.GetEnumerator())
|
||
|
|
{
|
||
|
|
while (enumAAF.MoveNext())
|
||
|
|
{
|
||
|
|
if (!first)
|
||
|
|
{
|
||
|
|
sb.Append(", ");
|
||
|
|
}
|
||
|
|
|
||
|
|
sb.Append($"{enumAAF.Current.Key}={enumAAF.Current.Value.ToString()}");
|
||
|
|
first = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
sb.AppendLine();
|
||
|
|
|
||
|
|
sb.AppendLine($"SkipTurnOnPower={SkipTurnOnPower.ToString()}");
|
||
|
|
|
||
|
|
sb.Append("ErrorRequiringActionAction=");
|
||
|
|
sb.AppendLine(null == ErrorRequiringActionAction ? "[null]" : "[defined]");
|
||
|
|
sb.AppendLine($"SetConfiguration={SetConfiguration.ToString()}");
|
||
|
|
sb.AppendLine($"TurnOffExcitation={TurnOffExcitation.ToString()}");
|
||
|
|
sb.AppendLine($"DiscardDiagnostics={DiscardDiagnostics.ToString()}");
|
||
|
|
return sb.ToString();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|