This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
/*
* DTS.Slice.Control.DAS.Channel.IFilter.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using DTS.Common.Utilities;
namespace DTS.Slice.Control.DAS.Channel
{
/// <summary>
/// Methodical definition of a slice control event module channel filter.
/// </summary>
public interface IFilter
{
/// <summary>
/// A descriptive <see cref="string"/> designation for the filter.
/// </summary>
string Name
{
get;
}
/// <summary>
/// <see cref="Boolean"/> value indicating whether or not this filter is
/// a cardinal CFC value.
/// </summary>
bool IsCfc
{
get;
}
/// <summary>
/// Get a <see cref="ChannelFilter"/> designation for this filter.
/// </summary>
ChannelFilter Type
{
get;
}
/// <summary>
/// Get the <see cref="double"/> cutoff frequency for this filter.
/// </summary>
double CutoffFrequencyHz
{
get;
}
/// <summary>
/// Apply the filter to the specified input.
/// </summary>
///
/// <param name="input">
/// The input to the filter.
/// </param>
///
/// <param name="displayUnits">
/// The <see cref="Event.Module.Channel.DataDisplayUnits"/> to be
/// filtered from the channel.
/// </param>
/// <param name="bUseLegacyTDCSofwareFilterAdjustment">
/// when true will adjust data one sample to the right to preserve existing TDC filtering behavior
/// </param>
/// <returns>
/// The filtering of the input.
/// </returns>
///
double[] Apply(
Event.Module.Channel input,
Event.Module.Channel.DataDisplayUnits displayUnits,
bool bUseLegacyTDCSofwareFilterAdjustment);
double[] Apply(
double[] data,
double sampleRate,
bool bUseLegacyTDCSoftwareFilterAdjustment
);
/// <summary>
/// the ToString is already overloaded, but we sometimes need the base name, not the decorated name that
/// is returned in ToString.
/// </summary>
/// <returns></returns>
string ToBaseString();
}
}

View File

@@ -0,0 +1,63 @@
/*
* DTS.Slice.Control.DAS.Channel.IFilterable.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System.Collections.Generic;
namespace DTS.Slice.Control.DAS.Channel
{
/// <summary>
/// Methodical definition of a filterable slice control event module channle.
/// </summary>
public interface IFilterable
//: DTS.Common.DAS.ConceptsIFilterable<Event.Module.Channel, short[]>
{
/// <summary>
/// Get/set the <see cref="bool"/> switch to (de)activate filter caching.
/// </summary>
bool UseFilterCaching
{
get;
set;
}
/// <summary>
/// Get the list of available filters for this object.
/// </summary>
List<IFilter> AvailableFilters
{
get;
}
/// <summary>
/// The currently applied filter.
/// </summary>
IFilter CurrentFilter
{
get;
set;
}
/// <summary>
/// Get the specified filtering for this object.
/// </summary>
///
/// <param name="filter">
/// The <see cref="DTS.Slice.Control.CAS.Channel.IFilter"/> to be applied to this object.
/// </param>
///
/// <param name="displayUnits">
/// Choose the output <see cref="DTS.Slice.Control.DAS.Channel.Data.DisplayUnits"/>.
/// </param>
///
/// <returns>
/// An array of <see cref="double"/> data reflecting the specified parameters.
/// </returns>
///
double[] GetDataFilteredBy(IFilter filter, Event.Module.Channel.DataDisplayUnits displayUnits);
}
}

View File

@@ -0,0 +1,27 @@
/*
* DTS.Slice.Control.Event.ChannelAccessor.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using DTS.Common.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
/// <summary>
/// A component object of the Event.DasModuleChannelAccessor.
/// </summary>
public class ChannelAccessor : ExceptionalDictionary<int, Module.Channel> // xxx change this int to DAS.(Module?).Channel.Id?
{
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.ChannelAccessor class.
/// </summary>
public ChannelAccessor() { }
}
}
}

View File

@@ -0,0 +1,26 @@
/*
* DTS.Slice.Control.Event.DasChannelAccessor.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System.Collections.Generic;
using DTS.Common.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
/// <summary>
/// An object returned during Event creation that allows access to the event's channel
/// by DAS ID/DAS channel number pair.
/// </summary>
public class DasChannelAccessor : ExceptionalDictionary<Common.DAS.Concepts.DAS.Id, List<Module.Channel>>
{
public DasChannelAccessor() { }
}
}
}

View File

@@ -0,0 +1,26 @@
/*
* DTS.Slice.Control.Event.DasModuleAccessor.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System.Collections.Generic;
using DTS.Common.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
/// <summary>
/// An object returned during Event creation that allows access to the event's module information
/// by DAS ID/DAS module number pair.
/// </summary>
public class DasModuleAccessor : ExceptionalDictionary<Common.DAS.Concepts.DAS.Id, List<Module>>
{
public DasModuleAccessor() { }
}
}
}

View File

@@ -0,0 +1,28 @@
/*
* DTS.Slice.Control.Event.DasModuleChannelAccessor.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using DTS.Common.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
/// <summary>
/// An object returned during Event creation that allows access to the event's channel information
/// by DAS ID/DAS module number/module channel number triplet.
/// </summary>
public class DasModuleChannelAccessor : ExceptionalDictionary<Common.DAS.Concepts.DAS.Id, ModuleChannelAccessor>
{
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.DasModuleChannelAccessor class.
/// </summary>
public DasModuleChannelAccessor() { }
}
}
}

View File

@@ -0,0 +1,886 @@
/*
* DTS.Slice.Control.Event.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using DTS.DASLib.Service;
using DTS.Serialization;
using DTS.Common.Utilities;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
using DTS.Common.Utilities.Logging;
using DTS.Serialization.StringResources;
namespace DTS.Slice.Control
{
/// <summary>
/// Slice control representation of all information related to a slice event.
/// </summary>
public partial class Event
: Exceptional,
Test.IConvertable
{
/// <summary>
/// Get/set the <see cref="string"/> Id for this event.
/// </summary>
public string Id
{
get => _Id.Value;
set => _Id.Value = value;
}
private readonly Property<string> _Id = new Property<string>("DTS.Slice.Control.Event.Id", null, false);
/// <summary>
/// Get/set the description <see cref="string"/> for this event.
/// </summary>
public string Description
{
get => _Description.Value;
set => _Description.Value = value;
}
private readonly Property<string> _Description = new Property<string>("DTS.Slice.Control.Event.Description", null, false);
/// <summary>
/// The globally unique identification string for this event.
/// </summary>
public Guid Guid
{
get => _Guid.Value;
set => _Guid.Value = value;
}
private readonly Property<Guid> _Guid
= new Property<Guid>(typeof(Event).Namespace + ".Event.Guid", new Guid("00000000-0000-0000-0000-000000000000"), true);
/// <summary>
/// The global Fault Flags for this event.
/// </summary>
public UInt16 FaultFlags
{
get => _FaultFlags.Value;
set => _FaultFlags.Value = value;
}
private readonly Property<UInt16> _FaultFlags
= new Property<UInt16>(typeof(Event).Namespace + ".Event.FaultFlags", 0, true);
/// <summary>
/// Get the date of this object's creation. Expected to be populated with the creation
/// date of the serialization from which this object has been generated.
/// </summary>
public DateTime InceptionDate
{
get => _InceptionDate.Value;
private set => _InceptionDate.Value = value;
}
private readonly Property<DateTime> _InceptionDate
= new Property<DateTime>(
typeof(Event).Namespace + ".Event.InceptionDate",
DateTime.Now,
false
);
/// <summary>
/// Get/set this event's list of <see cref="DTS.Slice.Control.Event.Module"/>s.
/// </summary>
public List<Module> Modules
{
get => _Modules.Value;
set => _Modules.Value = value;
}
private readonly Property<List<Module>> _Modules = new Property<List<Module>>("DTS.Slice.Control.Event.Modules", null, false);
/// <summary>
/// Get/set this event's list of <see cref="DTS.Slice.Control.Event.CalculatedChannelsModule"/>s.
/// </summary>
public List<Module.Channel> CalculatedChannels
{
get => _CalculatedChannels.Value;
set => _CalculatedChannels.Value = value;
}
private readonly Property<List<Module.Channel>> _CalculatedChannels = new Property<List<Module.Channel>>("DTS.Slice.Control.Event.CalculatedChannels", null, false);
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event class.
/// </summary>
public Event()
{
}
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event class.
/// </summary>
///
/// <param name="id">
/// The <see cref="string"/> ID of this event.
/// </param>
///
/// <param name="description">
/// The <see cref="string"/> description of this event.
/// </param>
///
public Event(string id, string description)
{
try
{
Id = id;
Description = description;
}
catch (System.Exception ex)
{
throw new Exception(
string.Format(
Strings.DTS_Slice_Control_Event_ConstructionFailedString, GetType().FullName),
ex);
}
}
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event class.
/// </summary>
///
/// <param name="test">
/// The <see cref="DTS.Serialization.Test"/> to initialize this object with.
/// </param>
///
public Event(Test test, Test.ReportErrors reportErrors)
{
try
{
FromDtsSerializationTest(test, reportErrors);
}
catch (System.Exception ex)
{
/*throw new Exception(
string.Format(
DataPROWin7.Properties.Resources.DTS_Slice_Control_Event_ConstructionFailedString, this.GetType().FullName),
ex);*/
throw ex;
}
}
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event class.
/// </summary>
///
/// <param name="id">
/// The <see cref="string"/> ID of this event.
/// </param>
///
/// <param name="description">
/// The <see cref="string"/> description of this event.
/// </param>
///
/// <param name="modules">
/// The list of <see cref="DTS.Slice.Control.Event.Module"/>s associated with this event.
/// </param>
///
public Event(string id, string description, List<Module> modules)
{
try
{
Id = id;
Description = description;
Modules = modules;
}
catch (System.Exception ex)
{
throw new Exception(
string.Format(
Strings.DTS_Slice_Control_Event_ConstructionFailedString, GetType().FullName),
ex);
}
}
// xxx Event ID, start sample, stop sample,
// xxx Keep a double hash of DAS->Channel... looks like it would probably bypass the
// module concept since the API just returns based on
// Also need to add thread protection.
// xxx Can we set locks in the property accessors for this stuff? At least for the
// data methods... should the constructor need just an enclosure, or a lambda that
// takes a dictionary lookup...
/// <summary>
/// Get a named-DAS/numbered-module accessor to this Event's modules.
/// </summary>
public DasModuleAccessor DasModules
{
get => _DasModules.Value;
private set => _DasModules.Value = value;
}
private readonly Property<DasModuleAccessor> _DasModules
= new Property<DasModuleAccessor>(
typeof(Event).Namespace + ".Event.DasModules",
new DasModuleAccessor(),
true
);
/// <summary>
/// Get a named-DAS/numbered-channel accessor to this Event's channels.
/// </summary>
public DasChannelAccessor DasChannels
{
get => _DasChannels.Value;
private set => _DasChannels.Value = value;
}
private readonly Property<DasChannelAccessor> _DasChannels
= new Property<DasChannelAccessor>(
typeof(Event).Namespace + ".Event.DasChannels",
new DasChannelAccessor(),
true
);
/// <summary>
/// Get a named-DAS/numbered-module/numbered-channel accessor to this Event's channels.
/// </summary>
public DasModuleChannelAccessor DasModuleChannels
{
get => _DasModuleChannels.Value;
private set => _DasModuleChannels.Value = value;
}
private readonly Property<DasModuleChannelAccessor> _DasModuleChannels
= new Property<DasModuleChannelAccessor>(
typeof(Event).Namespace + ".Event.DasModules",
new DasModuleChannelAccessor(),
true
);
public static bool IsG5(IDASCommunication idas)
{
return idas.SerialNumber.StartsWith("5M");
}
const string Slice6DBModule = "slice6db module";
public static bool IsSlice6DBModule(Module module)
{
if (null != module && null != module.Description && module.Description.ToLower() == Slice6DBModule)
{
return true;
}
return false;
}
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event class.
/// </summary>
///
/// <param name="dases">
/// A <see cref="List"/> of <see cref="IConnectedDevice"/>s that will be used
/// to determine the dimensions of the Event's internal structures.
/// </param>
///
public Event(List<IDASCommunication> dases, EventInfoAggregate info)
{
try
{
if (null == dases)
throw new ArgumentNullException(Strings.DTS_Slice_Control_Event_Event_NullDasListString);
if (0 >= dases.Count)
throw new Exception(Strings.DTS_Slice_Control_Event_Event_EmptyDasListString);
Modules = new List<Module>();
var dasTestInformations = new Dictionary<string, TestInformation>();
var absoluteChannelNumber = 0;
foreach (var das in dases)
{
var eventIndex = info.GetEventIndex(das);
if (null == das.SerialNumber)
throw new UserException("Slice API returned no serial number for passed DAS"); // (connect string: " + ( null != das.DASInfo. das.ConnectString ? das.ConnectString : "<NULL>" ) + ")" );
if (null == das.EventInfo)
throw new UserException("Slice API returned no EventInfo for passed DAS");
if (null == das.EventInfo.Events[eventIndex])
throw new UserException("Slice API returned no configuration data for passed DAS"); // \"" + ( null != das.Comm.SensorSerialNumber ? das.Comm.SensorSerialNumber : "<NULL>" ) + "\"" );
var eventInfo = das.EventInfo.Events[eventIndex];
dasTestInformations.Add(das.SerialNumber, new TestInformation(eventInfo.TestID, eventInfo.Description == null ? "" : eventInfo.Description));
DasModules.Add(das.SerialNumber, new List<Module>());
DasChannels.Add(das.SerialNumber, new List<Module.Channel>());
DasModuleChannels.Add(das.SerialNumber, new ModuleChannelAccessor());
if (null != eventInfo.Modules)
{
foreach (var dasModule in new List<DASModule>(eventInfo.Modules))
{
//Add entries for empty slots in a TDAS rack
while (dasModule.ModuleArrayIndex > DasModules[das.SerialNumber].Count)
{
Module emptyModule;
Modules.Add(emptyModule = new Module(this));
DasModules[das.SerialNumber].Add(emptyModule);
}
Module nextModule;
Modules.Add(nextModule = new Module(this));
DasModules[das.SerialNumber].Add(nextModule);
DasModuleChannels[das.SerialNumber].Add(dasModule.ModuleArrayIndex, new ChannelAccessor());
// I think this can be done for everyone (and is the right thing), but for now make it TDAS PRO Rack specific
if (das is EthernetTDAS)
{
// We want module to be the actual SIM or TOM serial number, not the rack serial number
nextModule.DasSerialNumber = das.DASInfo.Modules[dasModule.ModuleArrayIndex].SerialNumber;
}
else
{
nextModule.DasSerialNumber = das.SerialNumber;
}
// This is an important condition if they module property population that occurs after
// this constructor using the dasModules object is going to line thing up right.
Debug.Assert(DasModules[das.SerialNumber].Count - 1 == dasModule.ModuleArrayIndex);
// Maybe these should be getting populated later on using the SetPropertiesFrom(x) after
// the query download successfully returns...?
nextModule.Description = dasModule.Description;
nextModule.AaFilterRateHz = dasModule.AAFilterRateHz;
nextModule.Number = dasModule.ModuleArrayIndex;
nextModule.NumberOfSamples = dasModule.NumberOfSamples;
nextModule.RequestedPostTriggerSeconds = dasModule.RequestedPostTriggerSeconds;
nextModule.RequestedPreTriggerSeconds = dasModule.RequestedPreTriggerSeconds;
nextModule.PostTriggerSeconds = dasModule.PostTriggerSeconds;
nextModule.PreTriggerSeconds = dasModule.PreTriggerSeconds;
nextModule.RecordingMode = dasModule.RecordingMode;
nextModule.SampleRateHz = dasModule.SampleRateHz;
nextModule.StartRecordSampleNumber = dasModule.StartRecordSampleNumber;
nextModule.BaseSerialNumber = dasModule.OwningDAS.SerialNumber;
nextModule.StartRecordTimestampSec = dasModule.StartRecordTimestampSec;
nextModule.StartRecordTimestampNanoSec = dasModule.StartRecordTimestampNanoSec;
nextModule.TriggerTimestampSec = dasModule.TriggerTimestampSec;
nextModule.TriggerTimestampNanoSec = dasModule.StartRecordTimestampNanoSec;
nextModule.PTPMasterSync = dasModule.PTPMasterSync;
nextModule.TiltSensorAxisXDegreesPre = dasModule.TiltSensorAxisXDegreesPre;
nextModule.TiltSensorAxisYDegreesPre = dasModule.TiltSensorAxisYDegreesPre;
nextModule.TiltSensorAxisZDegreesPre = dasModule.TiltSensorAxisZDegreesPre;
nextModule.TiltSensorAxisXDegreesPost = dasModule.TiltSensorAxisXDegreesPost;
nextModule.TiltSensorAxisYDegreesPost = dasModule.TiltSensorAxisYDegreesPost;
nextModule.TiltSensorAxisZDegreesPost = dasModule.TiltSensorAxisZDegreesPost;
nextModule.TemperatureLocation1Pre = dasModule.TemperatureLocation1Pre;
nextModule.TemperatureLocation2Pre = dasModule.TemperatureLocation2Pre;
nextModule.TemperatureLocation3Pre = dasModule.TemperatureLocation3Pre;
nextModule.TemperatureLocation4Pre = dasModule.TemperatureLocation4Pre;
nextModule.TemperatureLocation1Post = dasModule.TemperatureLocation1Post;
nextModule.TemperatureLocation2Post = dasModule.TemperatureLocation2Post;
nextModule.TemperatureLocation3Post = dasModule.TemperatureLocation3Post;
nextModule.TemperatureLocation4Post = dasModule.TemperatureLocation4Post;
nextModule.Channels = new List<Module.Channel>();
var moduleType = dasModule.GetType();
if ((null != dasModule.Channels) && (dasModule.Channels.Length > 0) &&
((dasModule.Channels[0].ConfigurationMode != DASChannel.ConfigMode.DummyArm)|| IsG5(das))
)
{
foreach (var dasChannel in new List<DASChannel>(dasModule.Channels))
{
Module.Channel nextChannel;
nextModule.Channels.Add(nextChannel = Module.Channel.CreateChannel(dasChannel, nextModule, absoluteChannelNumber++));
DasModuleChannels[das.SerialNumber][dasModule.ModuleArrayIndex].Add(dasChannel.ModuleChannelNumber, nextChannel);
nextChannel.Number = dasChannel.ModuleChannelNumber;
nextChannel.Start = dasChannel.EventStartTime;
//Debug.Assert( das.SensorSerialNumber.Equals( dasModule.OwningDAS.SensorSerialNumber, StringComparison.OrdinalIgnoreCase ) );
//if ( null == das.Comm.ChannelDiagnosticsResults )
// throw new DTS.Slice.Control.Event.Exception( "no diagnostics results were received from the API for module " + nextModule.Number.ToString( ) + ", channel " + nextChannel.Number.ToString( ) );
//else
{
nextChannel.UnfilteredData = new List<short>();
DasChannels[das.SerialNumber].Add(nextChannel);
}
}
}
}
}
}
string testId = null;
string testDescription = null;
foreach (var dasId in dasTestInformations.Keys)
{ //
// Walk through the list and verify that all of the test ID and description
// strings are the same.
//
var newTestId = dasTestInformations[dasId].Id;
if (null != testId && !testId.Equals(newTestId, StringComparison.OrdinalIgnoreCase))
throw new Exception(
string.Format(
Strings.DTS_Slice_Control_Event_Event_DASTestIdMismatchString, testId, dasId, newTestId));
testId = newTestId;
var newTestDescription = dasTestInformations[dasId].Description;
if (null != testDescription
&& !testDescription.Equals(newTestDescription, StringComparison.OrdinalIgnoreCase))
{
/*throw new Exception(
string.Format(
Properties.Resources.DTS_Slice_Control_Event_Event_DASTestDescriptionMismatchString, testDescription, dasId, newTestDescription));*/
}
else { testDescription = newTestDescription; }
}
if (null == testId) { testId = "Empty"; }
if (null == testDescription) { testDescription = ""; }
if (null == testId || null == testDescription)
throw new Exception(Strings.DTS_Slice_Control_Event_Event_FailedToDetermineIdOrDescriptionFromConfigurationString);
Id = testId;
Description = testDescription;
}
catch (System.Exception ex)
{
throw new Exception(
string.Format(
Strings.DTS_Slice_Control_Event_ConstructionFailedString, GetType().FullName),
ex);
}
}
private bool IsTom(DASModule module)
{
try
{
if (module.SerialNumber().ToLower().Contains("tom"))
{
return true;
}
if (null != module.Channels && module.Channels.Length > 0)
{
if (module.Channels[0] is OutputSquibChannel) { return true; }
}
}
catch (System.Exception ex) { APILogger.Log("problem getting serial number", ex); }
return false;
}
/// <summary>
/// Get the highest <see cref="int"/> absolute channel number currently in this event.
/// </summary>
public int LastAbsoluteChannelNumberInEvent
{
get
{
try
{
var highestAbsoluteChannelNumberFound = -1;
foreach (var module in Modules)
foreach (var channel in module.Channels)
if (channel.AbsoluteNumber > highestAbsoluteChannelNumberFound)
highestAbsoluteChannelNumberFound = channel.AbsoluteNumber;
//if ( highestAbsoluteChannelNumberFound < 0 )
// throw new Event.Exception( "no absolute channel numbers exist within this event" );
return highestAbsoluteChannelNumberFound;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem getting last absolute channel number in event", ex);
}
}
}
/// <summary>
/// Get the <see cref="double"/> per-sample threshold that when exceeded by the total basic data
/// volume of this event results in Event.IsTooLargeFor32BitVisualization to return true.
/// </summary>
///
/// <remarks>
/// Justification for the current default value:
/// With filter caching disabled, the memory usage is AT LEAST 76.4 bytes/sample, broken down thus:
///
/// Event structure:
/// 1 sample needs 2 bytes ADC representation,
/// 8 bytes mV representation,
/// 8 bytes EU representation. Total: 18 bytes
/// +
/// Filtering procedure: 1 sample needs 8 bytes for initial double-sized "ToArray",
/// and 1.1 * ( 8 * 3 ) bytes for the three 5% padded front & end processing arrays
/// inside the algorithm. Total: 34.4 bytes
/// +
/// Viewer memory: 1 sample needs 8 bytes for the internal viewer representation
/// (at a minimum) + ( 2 * 8 ) bytes for the two arrays required to feed the viewer
/// interface. Total: 24 bytes
///
/// = 76.5 bytes/sample.
///
/// Not sure how much memory the rest of SliceWARE takes when up and running, but using this number
/// we seem to be okay if we stay below 1GB, but run into trouble when we go over if we first do other
/// things that might leave things around in memory, i.e., download. The three sections above pretty
/// much stack while loading a test into the viewer.
/// </remarks>
///
private static readonly double MaximumVisualizationBytesPerSample = 2D;
public double TooLargeFor32BitVisualizationBytesPerSampleThreshold
{
get => _TooLargeFor32BitVisualizationBytesPerSampleThreshold.Value;
private set => _TooLargeFor32BitVisualizationBytesPerSampleThreshold.Value = value;
}
private readonly Property<double> _TooLargeFor32BitVisualizationBytesPerSampleThreshold
= new Property<double>(
typeof(Event).FullName + ".TooLargeFor32BitVisualizationBytesPerSampleThreshold",
MaximumVisualizationBytesPerSample,
true
);
/// <summary>
/// Get <see cref="bool"/> value indicating whether or not this event has more combined data than a 32 bit
/// system could handle all at once.
/// </summary>
public bool IsTooLargeFor32BitVisualization
{
get
{
try
{
ulong totalChannelDataCount = 0;
foreach (var module in Modules)
foreach (var channel in module.Channels)
{
if (channel.UnfilteredData is Serialization.TDAS.File.PersistentChannel)
{
totalChannelDataCount += (channel.UnfilteredData as Serialization.TDAS.File.PersistentChannel).NumberOfSamples;
}
else
{
totalChannelDataCount += (channel.UnfilteredData as Serialization.SliceRaw.File.PersistentChannel).NumberOfSamples;
}
}
return (totalChannelDataCount * TooLargeFor32BitVisualizationBytesPerSampleThreshold) > 0x7FFFFFFF;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem determining whether or not this event's combined data is too big for 32-bit visualization", ex);
}
}
}
/// <summary>
/// Get <see cref="bool"/> value indicating whether or not this event contains channels with average over
/// time zero methods, but have specified an invalid averaging window.
/// </summary>
public bool ContainsChannelsActiveInvalidZeroingWindows => ChannelsWithActiveInvalidZeroingWindows.Count > 0;
/// <summary>
/// we initialize the window average to short min value, which is a valid data value but probably means bad things
/// if your window average is legitimately short min value ...
/// </summary>
private const short InvalidWindowAverage = short.MinValue;
/// <summary>
/// Get the list of all <see cref="DTS.Slice.Control.Event.Module.Channel"/>s that with average over time
/// zero method set, but have specified an invalid averaging window.
/// </summary>
public List<Module.Channel> ChannelsWithActiveInvalidZeroingWindows
{
get
{
try
{
var invalidZeroWindowChannels = new List<Module.Channel>();
foreach (var module in Modules)
foreach (var channel in module.Channels)
if (channel is Module.AnalogInputChannel)
{
var analogChannel = channel as Module.AnalogInputChannel;
if (Common.DAS.Concepts.Test.Module.Channel.Sensor.ZeroMethodType.AverageOverTime == analogChannel.ZeroMethod)
{
//if we have a stored window average for the channel, well then it's definitely not an invalid window average ...
if (analogChannel.WindowAverageADC != InvalidWindowAverage) { continue; }
//otherwise check to see if we have an invalid window average
var windowStart = ((analogChannel.ParentModule.TriggerSampleNumbers.Count > 0) ? (double)analogChannel.ParentModule.TriggerSampleNumbers[0] : 0) + (analogChannel.ZeroAverageWindow.Begin * (double)analogChannel.ParentModule.SampleRateHz);
var windowEnd = ((analogChannel.ParentModule.TriggerSampleNumbers.Count > 0) ? (double)analogChannel.ParentModule.TriggerSampleNumbers[0] : 0) + (analogChannel.ZeroAverageWindow.End * (double)analogChannel.ParentModule.SampleRateHz);
if (0 > windowStart || 0 > windowEnd) { invalidZeroWindowChannels.Add(analogChannel); }
else
{
var dataStart = analogChannel.ParentModule.StartRecordSampleNumber;
var dataEnd = dataStart + analogChannel.ParentModule.NumberOfSamples;
if (dataStart > windowStart || windowStart > dataEnd) { invalidZeroWindowChannels.Add(analogChannel); }
else if (dataEnd < windowEnd || windowEnd < dataStart) { invalidZeroWindowChannels.Add(analogChannel); }
}
}
}
return invalidZeroWindowChannels;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem building list of event channels with active invalid zeroing windows", ex);
}
}
}
private bool IsEmptyModule(Module module)
{
foreach (var channel in module.Channels)
{
if (channel.IsConfigured || !IsDummyChannel(channel)) { return false; }
}
return true;
}
private void PurgeUnconfiguredChannels()
{
foreach (var module in Modules)
{
module.Channels.RemoveAll(channel => !channel.IsConfigured || IsDummyChannel(channel));
}
}
/// <summary>
/// Convert this object to a DTS.Serialization.Test.
/// </summary>
///
/// <returns>
/// A <see cref="DTS.Serialization.Test"/> equivalent to this object.
/// </returns>
///
public Test ToDtsSerializationTest()
{
try
{ //
// Create a test to embody the conversion and copy over all relevant
// test data members.
//
var that = new Test();
PurgeUnconfiguredChannels();
that.Id = Id;
that.Description = Description;
that.Guid = Guid;
that.FaultFlags = FaultFlags;
that.Modules = new List<Test.Module>();
foreach (var thisModule in Modules)
{
//Normally, we don't care about empty modules (no data channels), but if it's
//a SLICE6 Distributor (a null ParentEvent), we want to output a module element to the .dts file.
if (IsEmptyModule(thisModule) && !IsSlice6DBModule(thisModule)) { continue; }
//
// Create a test module to embody each module conversion, and then copy
// over all relevant module data members.
//
that.Modules.Add(thisModule.ToDtsSerializationTestModule(that));
}
return that;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem converting " + GetType().FullName + " to " + typeof(Test).FullName, ex);
}
}
/// <summary>
/// Initialize this object from a DTS.Serialization.Test.
/// </summary>
///
/// <param name="that">
/// A <see cref="DTS.Serialization.Test"/> from which to initialize this object.
/// </param>
///
public void FromDtsSerializationTest(Test that, Test.ReportErrors reportErrors)
{
try
{
if (null == that)
throw new ArgumentNullException("cannot set this object's properties from null serialization test reference");
//
// Create the Slice Control test that will be equivalent to the specified serialization
// test and populate its relevant properties.
//
Id = that.Id;
Description = that.Description;
FaultFlags = that.FaultFlags;
Guid = that.Guid;
InceptionDate = that.InceptionDate;
Modules = new List<Module>();
foreach (var thatModule in that.Modules)
{ //
// Create a Slice Control module corresponding to the specified serialization module
// and populate its relevant properties.
//
Modules.Add(new Module(thatModule, this, reportErrors));
}
}
catch (System.IO.InvalidDataException) { throw; }
catch (System.Exception ex)
{
throw new Exception("encountered problem initializing " + GetType().FullName + " using " + typeof(Test).FullName, ex);
}
}
/// <summary>
/// Method to convert a DTS.Slice.Control.Event object to an equivalent DTS.Serialization.Test object.
/// </summary>
///
/// <param name="sliceControlEvent">
/// The <see cref="DTS.Slice.Control.Event"/> to be converted.
/// </param>
///
/// <returns>
/// A <see cref="DTS.Serialization.Test"/> that is equivalent to the specified Slice Control event.
/// </returns>
///
public static implicit operator Test(Event sliceControlEvent)
{
try
{
return sliceControlEvent.ToDtsSerializationTest();
}
catch (System.Exception ex)
{
throw new Exception("encountered problem implicitly converting " + typeof(Event).FullName + " to " + typeof(Test).FullName, ex);
}
}
/// <summary>
/// this really belongs in the channel object, but for now just abstract the function out of
/// where the logic is needed
/// </summary>
/// <param name="channel"></param>
/// <returns></returns>
private bool IsDummyChannel(Module.Channel channel)
{
if (null != channel && channel.ChannelDescriptionString.ToLower() == "dummy arm channel")
{
return true;
}
return false;
}
/// <summary>
/// Get/set the base serialization directory path <see cref="string"/> for events.
/// </summary>
public static string BaseSerializationDirectory
{
get => _BaseSerializationDirectory.Value;
set => _BaseSerializationDirectory.Value = value;
}
private static readonly Property<string> _BaseSerializationDirectory
= new Property<string>(
typeof(Event).Namespace + ".BaseSerializationDirectory",
null,
false
);
/// <summary>
/// Construct the serialization path for the specified event ID.
/// </summary>
///
/// <param name="eventId">
/// The <see cref="string"/> ID of the event whose serialization path is sought.
/// </param>
///
/// <returns>
/// The <see cref="string"/> path for the specified event's serialization.
/// </returns>
///
public static string GetEventSerializationDirectory(string eventId)
{
try
{
return System.IO.Path.Combine(BaseSerializationDirectory, eventId);
}
catch (System.Exception ex)
{
//throw new ReviewForm.Exception("encountered problem getting target directory for test " + (null != eventId ? "\"" + eventId + "\"" : "<NULL>"), ex);
throw new Exception("encountered problem getting target directory for test " + (null != eventId ? "\"" + eventId + "\"" : "<NULL>"), ex);
}
}
/// <summary>
/// Test the specified object for equality with this object.
/// </summary>
///
/// <param name="obj">
/// The <see cref="object"/> to be tested for equality.
/// </param>
///
/// <returns>
/// <see cref="bool"/> true if the specified object has memberwise equality with
/// this object; false otherwise.
/// </returns>
///
public override bool Equals(object obj)
{
try
{
var that = obj as Event;
return null != that
&& Id.Equals(that.Id)
&& Description.Equals(that.Description)
&& Guid.Equals(that.Guid)
&& ModulesEquals(that.Modules)
&& FaultFlags.Equals(that.FaultFlags);
}
catch (System.Exception ex)
{
throw new Exception(
string.Format(
Strings.DTS_Slice_Control_Equals_ComparisonFailedString, null != obj ? "\"" + obj.ToString() + "\"" : Strings.DTS_Slice_Control_NullIndicatorString),
ex);
}
}
/// <summary>
/// Test the specified object's module list for equality with this object's
/// module list.
/// </summary>
///
/// <param name="thoseModules">
/// The <see cref="List"/> of <see cref="DTS.Slice.Control.Event.Module"/> objects to be
/// compared for equality with this test's equivalent.
/// </param>
///
/// <returns>
/// <see cref="bool"/> true if the two lists contain equivalent-valued members;
/// false otherwise.
/// </returns>
///
private bool ModulesEquals(List<Module> thoseModules)
{
try
{
if (Modules.Count != thoseModules.Count)
return false;
for (var i = 0; i < thoseModules.Count; i++)
if (!Modules[i].Equals(thoseModules[i]))
return false;
return true;
}
catch (System.Exception ex)
{
throw new Exception(Strings.DTS_Slice_Control_Event_ModuleEquals_ComparisonFailedString, ex);
}
}
/// <summary>
/// Return the hash code for this object.
/// </summary>
///
/// <returns>
/// The <see cref="int"/> hash code for this object.
/// </returns>
///
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}

View File

@@ -0,0 +1,59 @@
/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableCfcAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTS.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
// *** see DTS.Slice.Control.Event.Module.AnalogInputChannel.cs ***
public partial class AnalogInputChannel
{
/// <summary>
/// A reviewable CFC attribute attached to a specific channel.
/// </summary>
public class ReviewableCfcAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableCfcAttribute(Event.Module.Channel channel)
: base("CFC",
delegate
{
//return ( new CfcValueAttributeCoder( ).DecodeAttributeValue( ( channel.CurrentFilter as SaeJ211Filter ).Type ) ).ToString( );
if (channel.CurrentFilter.Type == ChannelFilter.AdHoc) { return "N/A"; }
else { return (new CfcValueAttributeCoder().DecodeAttributeValue((channel.CurrentFilter as SaeJ211Filter).Type)).ToString(); }
}
)
{
}
}
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,52 @@
/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableCfcAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTS.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
// *** see DTS.Slice.Control.Event.Module.AnalogInputChannel.cs ***
public partial class AnalogInputChannel
{
/// <summary>
/// A reviewable CFC attribute attached to a specific channel.
/// </summary>
public class ReviewableDescriptionAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableDescriptionAttribute(Event.Module.Channel channel)
: base("Description", delegate { return channel.ChannelDescriptionString; })
{
}
}
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,49 @@
/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableFilterFrequencyAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTS.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event {
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module {
// *** see DTS.Slice.Control.Event.Module.AnalogInputChannel.cs ***
public partial class AnalogInputChannel {
/// <summary>
/// A reviewable filter frequency attribute attached to a specific channel.
/// </summary>
public class ReviewableFilterFrequencyAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableFilterFrequencyAttribute( Event.Module.Channel channel )
: base( "Filter Frequency", delegate { return ( ( int )( channel.CurrentFilter as SaeJ211Filter ).CutoffFrequencyHz ).ToString("N"); } )
{
}
}
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,50 @@
/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableIsoCodeAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
// *** see DTS.Slice.Control.Event.Module.AnalogInputChannel.cs ***
public partial class AnalogInputChannel
{
/// <summary>
/// A reviewable serial number attribute attached to a specific channel.
/// </summary>
public class ReviewableIsoCodeAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableIsoCodeAttribute(Event.Module.Channel channel)
: base("ISO Code", delegate { return (channel as AnalogInputChannel).IsoCode.ToString(); })
{
}
}
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,70 @@
/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableMeasuredShuntDeflectionAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
// *** see DTS.Slice.Control.Event.Module.AnalogInputChannel.cs ***
public partial class AnalogInputChannel
{
/// <summary>
/// A reviewable measured shunt deflection attribute attached to a specific channel.
/// </summary>
public class ReviewableMeasuredShuntDeflectionAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableMeasuredShuntDeflectionAttribute(Event.Module.Channel channel)
: base("Measured Shunt Deflection (mV)", delegate { return (channel as DTS.DAS.Concepts.DAS.Channel.IShuntAware).MeasuredShuntDeflectionMv.ToString("F1"); })
{
}
}
/// <summary>
/// A reviewable measured shunt deflection attribute attached to a specific channel.
/// </summary>
public class ReviewableMeasuredCalSignalAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableMeasuredCalSignalAttribute(Event.Module.Channel channel)
: base("Measured Calibration Signal (mV)", delegate { return (channel as DTS.DAS.Concepts.DAS.Channel.ICalSignalAware).MeasuredCalSignalMv.ToString("F1"); })
{
}
}
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,52 @@
/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableMinMaxEuAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTS.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
// *** see DTS.Slice.Control.Event.Module.AnalogInputChannel.cs ***
public partial class AnalogInputChannel
{
/// <summary>
/// A reviewable min/max EU attribute attached to a specific channel.
/// </summary>
public class ReviewableMinMaxEuAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableMinMaxEuAttribute(Event.Module.Channel channel)
: base("Max/Min (EU)", delegate { return channel.DataMaxFilteredEu.ToString("F1") + "/" + channel.DataMinFilteredEu.ToString("F1"); })
{
}
}
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,50 @@
/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableSerialNumberAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
// *** see DTS.Slice.Control.Event.Module.AnalogInputChannel.cs ***
public partial class AnalogInputChannel
{
/// <summary>
/// A reviewable serial number attribute attached to a specific channel.
/// </summary>
public class ReviewableSerialNumberAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableSerialNumberAttribute(Event.Module.Channel channel)
: base("Serial Number", delegate { return (channel as AnalogInputChannel).SerialNumber.ToString(); })
{
}
}
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,47 @@
/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableShuntDeflectionAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event {
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module {
// *** see DTS.Slice.Control.Event.Module.AnalogInputChannel.cs ***
public partial class AnalogInputChannel {
/// <summary>
/// A reviewable shunt deflection attribute attached to a specific channel.
/// </summary>
public class ReviewableShuntDeflectionAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableShuntDeflectionAttribute( Event.Module.Channel channel )
: base( "Shunt Deflection (mV)", delegate { return ( channel as DTS.DAS.Concepts.DAS.Channel.IShuntAware ).MeasuredShuntDeflectionMv.ToString( "F1" ); } )
{
}
}
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,69 @@
/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableShuntDeflectionPercentageAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
// *** see DTS.Slice.Control.Event.Module.AnalogInputChannel.cs ***
public partial class AnalogInputChannel
{
/// <summary>
/// A reviewable shunt deflection attribute attached to a specific channel.
/// </summary>
public class ReviewableShuntDeflectionPercentageAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableShuntDeflectionPercentageAttribute(Event.Module.Channel channel)
: base("Shunt Error (%)", delegate { return (100.0 * ((channel as DTS.DAS.Concepts.DAS.Channel.IShuntAware).MeasuredShuntDeflectionMv - (channel as DTS.DAS.Concepts.DAS.Channel.IShuntAware).TargetShuntDeflectionMv) / (channel as DTS.DAS.Concepts.DAS.Channel.IShuntAware).TargetShuntDeflectionMv).ToString("F1"); })
{
}
}
/// <summary>
/// A reviewable shunt deflection attribute attached to a specific channel.
/// </summary>
public class ReviewableCalSignalPercentageAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableCalSignalPercentageAttribute(Event.Module.Channel channel)
: base("Calibration Signal Error (%)", delegate { return (100.0 * ((channel as DTS.DAS.Concepts.DAS.Channel.ICalSignalAware).MeasuredCalSignalMv - (channel as DTS.DAS.Concepts.DAS.Channel.ICalSignalAware).TargetCalSignalMv) / (channel as DTS.DAS.Concepts.DAS.Channel.ICalSignalAware).TargetCalSignalMv).ToString("F1"); })
{
}
}
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,69 @@
/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableTargetShuntDeflectionAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
// *** see DTS.Slice.Control.Event.Module.AnalogInputChannel.cs ***
public partial class AnalogInputChannel
{
/// <summary>
/// A reviewable target shunt deflection attribute attached to a specific channel.
/// </summary>
public class ReviewableTargetShuntDeflectionAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableTargetShuntDeflectionAttribute(Event.Module.Channel channel)
: base("Target Shunt Deflection (mV)", delegate { return (channel as DTS.DAS.Concepts.DAS.Channel.IShuntAware).TargetShuntDeflectionMv.ToString("F1"); })
{
}
}
/// <summary>
/// A reviewable target shunt deflection attribute attached to a specific channel.
/// </summary>
public class ReviewableTargetCalSignalAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableTargetCalSignalAttribute(Event.Module.Channel channel)
: base("Target Calibration Signal (mV)", delegate { return (channel as DTS.DAS.Concepts.DAS.Channel.ICalSignalAware).TargetCalSignalMv.ToString("F1"); })
{
}
}
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,51 @@
/*
* DTS.Slice.Control.Event.Module.AnalogInputChannel.ReviewableUnitsAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
// *** see DTS.Slice.Control.Event.Module.AnalogInputChannel.cs ***
public partial class AnalogInputChannel
{
/// <summary>
/// A reviewable engineering units attribute attached to a specific channel.
/// </summary>
public class ReviewableUnitsAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableUnitsAttribute(Event.Module.Channel channel)
: base("Units", delegate { return (channel as DTS.DAS.Concepts.DAS.Channel.IEngineeringUnitAware).EngineeringUnits.ToString(); })
{
}
}
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,414 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DTS.Common.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
public partial class Channel
{
public abstract class CalculatedChannel : Channel, Common.DAS.Concepts.DAS.Channel.IEngineeringUnitAware
{
public enum Operation
{
Integral,
//DefiniteIntegral,
Derivative,
HeadInjuryCriteria,
FFT,
ImportedCSV,
Resultant,
TSR,
Scale,
Offset,
Sine,
Cosine,
}
private readonly Operation _operation;
public Operation CalculationType => _operation;
private readonly List<double> _x = new List<double>();
public double[] X => _x.ToArray();
private readonly List<double> _y = new List<double>();
public double[] Y => _y.ToArray();
private readonly XUnits _xAxis;
public XUnits XAxis => _xAxis;
public string XUnitsString
{
get
{
switch (_xAxis)
{
case XUnits.Hz: return "Hz";
case XUnits.msec: return "ms";
case XUnits.samples: return "samples";
case XUnits.sec: return "s";
default: return "N/A";
}
}
}
private string _yAxis;
public string EngineeringUnits { get => _yAxis;
set => _yAxis = value;
}
public override bool SupportsADC => false;
public override bool SupportsEU => true;
public override bool SupportsmV => false;
public override double ActualMaxRangeEu => _y.Max();
public override double ActualMaxRangeMv => throw new NotSupportedException();
public override double ActualMinRangeEu => _y.Min();
public override double ActualMinRangeMv => throw new NotImplementedException();
public override double DataHalfRangeValueEu => .5D * (_y.Min() + _y.Max());
public override double DataMaxEu => _y.Max();
public override double DataMinEu => _y.Min();
public override double DataRangeEu => (Math.Max(Math.Abs(_y.Min()), Math.Abs(_y.Max())));
public override short DataZeroLevelAdc => 0;
public override bool IsConfigured
{
get => true;
set => throw new NotSupportedException();
}
public override void FromDtsSerializationTestModuleChannel(Serialization.Test.Module.Channel that)
{
throw new NotSupportedException();
}
public override List<double> GetUnfilteredDataEu()
{
return new List<double>(_y);
}
/*
protected override void InitializeReviewableAttributes(List<ReviewableAttribute> reviewableAttributes)
{
switch (CalculationType)
{
case Operation.HeadInjuryCriteria:
break;
case Operation.ImportedCSV:
break;
case Operation.TSR:
break;
}
} */
public override void SetPropertyValuesFrom(DASLib.Service.DASChannel dasChannel)
{
throw new NotSupportedException();
}
public override void SetPropertyValuesFrom(DASLib.Service.DiagnosticsResult diagResults)
{
throw new NotSupportedException();
}
public override Serialization.Test.Module.Channel ToDtsSerializationTestModuleChannel(Serialization.Test.Module parentModule)
{
throw new NotSupportedException();
}
public override double SensorCapacityEU => throw new NotImplementedException();
public override List<double> GetUnfilteredDataMV()
{
throw new NotImplementedException();
}
public override double DesiredRangeEU => throw new NotImplementedException();
public enum XUnits
{
msec,
sec,
Hz,
samples
}
public CalculatedChannel(string name,
XUnits xAxis,
string yAxis,
double[] xValues,
double[] yValues,
Operation calcType,
int number,
Module parentModule
)
{
_x = new List<double>(xValues);
_y = new List<double>(yValues);
_xAxis = xAxis;
_yAxis = yAxis;
ChannelDescriptionString = name;
_operation = calcType;
Number = number;
CurrentFilter = new DefaultSaeJ211Filter(ChannelFilter.Unfiltered);
ParentModule = parentModule;
_UnfilteredDataEu = new List<double>(yValues);
DataCount = yValues.Length;
}
/// <summary>
/// Generate a <see cref="string"/> representation for this object.
/// </summary>
///
/// <returns>
/// The <see cref="string"/> representation of this object.
/// </returns>
///
public override string ToString()
{
try
{
return !string.IsNullOrEmpty(ChannelDescriptionString) ? ChannelDescriptionString : "N/A";
}
catch (System.Exception ex)
{
throw new Exception("encountered problem getting string representation", ex);
}
}
}
public class FFTCalculatedChannel : CalculatedChannel
{
private readonly double _peakFrequency;
public double PeakFrequency => _peakFrequency;
public FFTCalculatedChannel(string name,
XUnits xAxis,
string yAxis,
double[] xValues,
double[] yValues,
Operation calcType,
int number,
Module parentModule,
double peakFrequency)
: base(name, xAxis, yAxis, xValues, yValues, calcType, number, parentModule)
{
_peakFrequency = peakFrequency;
}
/*
protected override void InitializeReviewableAttributes(List<ReviewableAttribute> reviewableAttributes)
{
base.InitializeReviewableAttributes(reviewableAttributes);
//try { reviewableAttributes.Add(new ReviewablePeakFrequencyAttribute(this)); }
//catch { }
}
public class ReviewablePeakFrequencyAttribute : Slice.Control.Event.Module.Channel.ReviewableAttribute
{
public ReviewablePeakFrequencyAttribute(Event.Module.Channel channel)
: base("Peak (Hz)",
delegate { return (channel as FFTCalculatedChannel).PeakFrequency.ToString("N"); }) { }
}*/
}
public class IntegralCalculatedChannel : CalculatedChannel
{
public IntegralCalculatedChannel(string name,
XUnits xAxis,
string yAxis,
double[] xValues,
double[] yValues,
Operation calcType,
int number,
Module parentModule
)
: base(name, xAxis, yAxis, xValues, yValues, calcType, number, parentModule)
{ }
}
public class DerivativeCalculatedChannel : CalculatedChannel
{
public DerivativeCalculatedChannel(string name,
XUnits xAxis,
string yAxis,
double[] xValues,
double[] yValues,
Operation calcType,
int number,
Module parentModule
)
: base(name, xAxis, yAxis, xValues, yValues, calcType, number, parentModule)
{ }
}
public class ScaleCalculatedChannel : CalculatedChannel
{
public ScaleCalculatedChannel(string name,
XUnits xAxis,
string yAxis,
double[] xValues,
double[] yValues,
Operation calcType,
int number,
Module parentModule)
: base(name, xAxis, yAxis, xValues, yValues, calcType, number, parentModule)
{ }
}
public class OffsetCalculatedChannel : CalculatedChannel
{
public OffsetCalculatedChannel(string name,
XUnits xAxis,
string yAxis,
double[] xValues,
double[] yVAlues,
Operation calcType,
int number,
Module parentModule)
: base(name, xAxis, yAxis, xValues, yVAlues, calcType, number, parentModule)
{ }
}
public class ResultantCalculatedChannel : CalculatedChannel
{
public ResultantCalculatedChannel(string name,
XUnits xAxis,
string yAxis,
double[] xValues,
double[] yValues,
Operation calcType,
int number,
Module parentModule)
: base(name, xAxis, yAxis, xValues, yValues, calcType, number, parentModule)
{ }
}
public class AdditiveVectorCalculatedChannel : CalculatedChannel
{
public AdditiveVectorCalculatedChannel(string name,
XUnits xAxis,
string yAxis,
double[] xValues,
double[] yValues,
Operation calcType,
int number,
Module parentModule)
: base(name, xAxis, yAxis, xValues, yValues, calcType, number, parentModule)
{ }
}
public class SineCalculatedChannel : CalculatedChannel
{
public SineCalculatedChannel(string name,
XUnits xAxis,
string yAxis,
double[] xValues,
double[] yValues,
Operation calcType,
int number,
Module parentModule
)
: base(name, xAxis, yAxis, xValues, yValues, calcType, number, parentModule)
{ }
}
public class CosineCalculatedChannel : CalculatedChannel
{
public CosineCalculatedChannel(string name,
XUnits xAxis,
string yAxis,
double[] xValues,
double[] yValues,
Operation calcType,
int number,
Module parentModule
)
: base(name, xAxis, yAxis, xValues, yValues, calcType, number, parentModule)
{ }
}
/*
public class HICCalculatedChannel : CalculatedChannel
{
public double GetT1(bool ms)
{
double start = (double)HIC.StartSample - (double)ParentModule.TriggerSampleNumbers[0] +
(double)ParentModule.StartRecordSampleNumber;
start /= (double)ParentModule.SampleRateHz;
if (ms) { start *= 1000; }
return start;
}
public double GetT2(bool ms)
{
double end = (double)HIC.EndSample - (double)ParentModule.TriggerSampleNumbers[0]
+ (double)ParentModule.StartRecordSampleNumber;
end /= (double)ParentModule.SampleRateHz;
if (ms) { end *= 1000; }
return end;
}
public HICCalculatedChannel(string name,
XUnits xAxis,
string yAxis,
double[] xValues,
double[] yValues,
Operation calcType,
int number,
Module parentModule,
DTS.Calculations.HeadInjuryCriterion.HICResult hic
)
: base(name, xAxis, yAxis, xValues, yValues, calcType, number, parentModule)
{
_hic = hic;
}
private DTS.Calculations.HeadInjuryCriterion.HICResult _hic;
public DTS.Calculations.HeadInjuryCriterion.HICResult HIC { get { return _hic; } }
protected override void InitializeReviewableAttributes(List<ReviewableAttribute> reviewableAttributes)
{
base.InitializeReviewableAttributes(reviewableAttributes);
try { reviewableAttributes.Add(new ReviewableHICAttribute(this)); }
catch {}
try { reviewableAttributes.Add(new ReviewableHICLengthAttribute(this)); }
catch { }
try { reviewableAttributes.Add(new ReviewableHICT1T2Attribute(this)); }
catch { }
}
public class ReviewableHICLengthAttribute : Slice.Control.Event.Module.Channel.ReviewableAttribute
{
public ReviewableHICLengthAttribute(Event.Module.Channel channel)
: base("Clip Length",
delegate { return (channel as HICCalculatedChannel).HIC.HicLengthMS.ToString(); }) { }
}
public class ReviewableHICAttribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableHICAttribute(Event.Module.Channel channel)
: base("HIC",
delegate { return (channel as HICCalculatedChannel).HIC.HIC.ToString("N1"); })
{
}
}
public class ReviewableHICT1T2Attribute
: Slice.Control.Event.Module.Channel.ReviewableAttribute
{
public ReviewableHICT1T2Attribute(Event.Module.Channel channel)
: base("T1/T2",
delegate
{
HICCalculatedChannel hic = channel as HICCalculatedChannel;
if (null == hic) { return ""; }
else { return string.Format("{0}s/{1}s", hic.GetT1(false), hic.GetT2(false)); }
})
{
}
}
}
* */
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,123 @@
/*
* DTS.Slice.Control.Event.Module.Channel.SaeJ211Filter.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using DTS.Common.Utilities;
namespace DTS.Slice.Control
{
public partial class Event
{ // *** see DTS.Slice.Control.Event.cs ***
public partial class Module
{ // *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Channel
{ // *** see DTS.Slice.Control.Event.Module.Channel.cs ***
/// <summary>
/// Base class for all SaeJ211-based event module channel filters. It is intended
/// that fixed-filter-setting filters be derived from this class that will set their
/// filter setting using the protected constructor.
/// </summary>
public class DefaultSaeJ211Filter
: SaeJ211Filter
{
public DefaultSaeJ211Filter(SaeJ211Filter filter)
: base(filter)
{
}
/// <summary>
/// Initialize an instance of the DefaultSaeJ211Filter class.
/// </summary>
///
/// <param name="filter">
/// The <see cref="ChannelFilter"/> to be applied by this filter.
/// </param>
///
public DefaultSaeJ211Filter(ChannelFilter filterType)
: base(filterType)
{
}
/// <summary>
/// Initialize an instance of the DefaultSaeJ211Filter class.
/// </summary>
///
///<param name="adHocFrequency">
///The <see cref="double"/> ad hoc frequency of this filter.
/// </param>
///
public DefaultSaeJ211Filter(double adHocFrequency)
: base(adHocFrequency)
{
}
/// <summary>
/// The <see cref="string"/> name of this filter.
/// </summary>
public override string Name
{
get
{
try
{
return "Default (" + base.Name + ")";
}
catch (System.Exception ex)
{
throw new Exception("encountered problem generating name string for " + GetType().FullName, ex);
}
}
}
/// <summary>
/// Generate a string representation of this object.
/// </summary>
///
/// <returns>
/// A <see cref="string"/> representation of this object.
/// </returns>
///
public override string ToBaseString()
{
try
{
return base.Name;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem generating the string value for " + GetType().FullName, ex);
}
}
/// <summary>
/// Generate a string representation of this object.
/// </summary>
///
/// <returns>
/// A <see cref="string"/> representation of this object.
/// </returns>
///
public override string ToString()
{
try
{
return Name;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem generating the string value for " + GetType().FullName, ex);
}
}
}
}
}
}
}

View File

@@ -0,0 +1,81 @@
/*
* DTS.Slice.Control.Event.Module.Channel.DataValues.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using DTS.Common.Utilities;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event {
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module {
// *** see DTS.Slice.Control.Event.Module.Channel.cs ***
public partial class Channel {
/// <summary>
/// Representation of a channel's data.
/// </summary>
public class DataValues : Exceptional
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
public DataValues( )
: this( true )
{
}
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="useMemoryMappedFile">
/// A <see cref="bool"/> determining whether or not this data class will use memory mapped files
/// to store data (necessary for data sets that exceed internal process memory limitations).
/// </param>
///
public DataValues( bool useMemoryMappedFile )
{
try
{
UseMemoryMappedFile = useMemoryMappedFile;
if ( UseMemoryMappedFile )
{
}
}
catch ( System.Exception ex )
{
throw new Exception( "encountered problem constructing " + GetType( ).FullName, ex );
}
}
/// <summary>
/// Get/set the switch that will cause this class to use memory mapped files in lieu
/// of in-memory list.
/// </summary>
public bool UseMemoryMappedFile
{
get => _UseMemoryMappedFile.Value;
set => _UseMemoryMappedFile.Value = value;
}
private readonly Property<bool> _UseMemoryMappedFile =
new Property<bool>(
typeof( DataValues ).Namespace + ".UseMemoryMappedFile",
false,
false
);
}
} // *** End Event.Module.Channel ***
} // *** End Event.Module ***
} // *** End Event ***
}

View File

@@ -0,0 +1,99 @@
/*
* DTS.Slice.Control.Event.Module.Channel.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using DTS.Common.Utilities;
using DTS.Slice.Control.DAS.Channel;
namespace DTS.Slice.Control
{
public partial class Event
{ // *** see DTS.Slice.Control.Event.cs ***
public partial class Module
{ // *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Channel
{ // *** see DTS.Slice.Control.Event.Module.Channel.cs ***
/// <summary>
/// A filter for DTS.Slice.Control.Event.Module.Channels.
/// </summary>
public abstract class Filter
: Exceptional,
IFilter
{
/// <summary>
/// A descriptive <see cref="string"/> designation for the filter.
/// </summary>
public abstract string Name
{
get;
}
/// <summary>
/// Get the <see cref="Boolean"/> value indicating whether or not this filter
/// corresponds to a CFC value.
/// </summary>
public abstract bool IsCfc
{
get;
}
/// <summary>
/// Get a <see cref="ChannelFilter"/> designation for this filter.
/// </summary>
public abstract ChannelFilter Type
{
get;
}
/// <summary>
/// Get the <see cref="double"/> cutoff frequency for this filter.
/// </summary>
public abstract double CutoffFrequencyHz
{
get;
}
/// <summary>
/// Apply the filter to the specified input.
/// </summary>
///
/// <param name="input">
/// The input to the filter.
/// </param>
///
/// <param name="displayUnits">
/// The <see cref="DTS.Slice.Control.Event.Module.Channel.DataDisplayUnits"/> to be
/// filtered from the channel.
/// </param>
/// <param name="bUseLegacyTDCSoftwareFilterAdjustment">
/// controls whether filtered data is adjusted by one sample to match TDC behavior
/// 8747
/// </param>
/// <returns>
/// The filtering of the input.
/// </returns>
///
public abstract double[] Apply(
Channel input,
DataDisplayUnits displayUnits,
bool bUseLegacyTDCSoftwareFilterAdjustment);
public abstract double[] Apply(
double[] data,
double sampleRate,
bool bUseLegacyTDCSoftwareFilterAdjustment);
/// <summary>
/// the ToString is already overloaded, but we sometimes need the base name, not the decorated name that
/// is returned in ToString.
/// </summary>
/// <returns></returns>
public abstract string ToBaseString();
}
}
}
}
}

View File

@@ -0,0 +1,81 @@
/*
* DTS.Slice.Control.Event.Module.Channel.ReviewableAttribute.NotApplicableException.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
// *** see DTS.Slice.Control.Event.Module.Channel.cs ***
public partial class Channel
{
// *** see DTS.Slice.Control.Event.Module.Channel.ReviewableAttribute.cs ***
public partial class ReviewableAttribute
{
/// <summary>
/// Representation of an attempt to use a channel attribute that is not
/// applicable to the associated channel.
/// </summary>
public class NotApplicableException : ApplicationException
{ ///
/// <summary>
/// Initialize an instance of the NotApplicableException class.
/// </summary>
///
public NotApplicableException()
{
}
/// <summary>
/// Initialize an instance of the NotApplicableException class.
/// </summary>
///
/// <param name="msg">
/// The <see cref="string"/> message to be associated with this exception.
/// </param>
///
public NotApplicableException(string msg)
: base(msg)
{
}
/// <summary>
/// Initialize an instance of the NotApplicableException class.
/// </summary>
///
/// <param name="msg">
/// The <see cref="string"/> message to be associated with this exception.
/// </param>
///
/// <param name="innerEx">
/// The <see cref="System.Exception"/> responsible for this exception inception.
/// </param>
///
public NotApplicableException(string msg, System.Exception innerEx)
: base(msg, innerEx)
{
}
}
} // *** end ReviewableAttribute ***
} // *** end Channel ***
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,515 @@
/*
* DTS.Slice.Control.Event.Module.Channel.SaeJ211Filter.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using DTS.Common.DAS.Concepts.DAS.Channel;
using DTS.Common.Utilities;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
using DTS.Common.Utilities.Logging;
using DTS.Common.Utilities.SaeJ211;
namespace DTS.Slice.Control
{
public partial class Event
{ // *** see DTS.Slice.Control.Event.cs ***
public partial class Module
{ // *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Channel
{ // *** see DTS.Slice.Control.Event.Module.Channel.cs ***
/// <summary>
/// Base class for all SaeJ211-based event module channel filters. It is intended
/// that fixed-filter-setting filters be derived from this class that will set their
/// filter setting using the protected constructor.
/// </summary>
public class SaeJ211Filter
: Filter
{
public SaeJ211Filter(SaeJ211Filter originalFilter)
{
OriginalType = originalFilter.OriginalType;
_CutoffFrequencyHz.Value = originalFilter.CutoffFrequencyHz;
}
/// <summary>
/// Initialize an instance of the DTS.Utility.SaeJ211Filter class.
/// </summary>
///
/// <param name="originalType">
/// The <see cref="ChannelFilter"/> to be applied by this filter (ad hoc
/// filters that correspond to CFC values will be converted to the CFC, hence the
/// "original" qualification).
/// </param>
///
public SaeJ211Filter(ChannelFilter originalType)
{
try
{
switch (OriginalType = originalType)
{ //
// Try to set the frequency value according to type. Note that we can't set to
// "ad hoc" using this particular constructor as we don't know what frequency
// should be associated with it.
//
case ChannelFilter.AdHoc:
throw new Exception("cannot initialize SaeJ211 filter using only ChannelFilter of type " + OriginalType.ToString());
default:
_CutoffFrequencyHz.Value = (double)originalType;
break;
}
}
catch (System.Exception ex)
{
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// Initialize an instance of the DTS.Utility.SaeJ211Filter class.
/// </summary>
///
///<param name="adHocFrequency">
///The <see cref="double"/> ad hoc frequency of this filter.
/// </param>
///
public SaeJ211Filter(double cutoffFrequencyHz)
{
try
{
OriginalType = ChannelFilter.AdHoc;
_CutoffFrequencyHz.Value = cutoffFrequencyHz;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// Get <see cref="Boolean"/> value indicating whether or not this filter matches one of the
/// specified CFC values.
/// </summary>
override public bool IsCfc
{
get
{
try
{ //
// If we're not unfiltered and we're not ad hoc, then we
// must be CFC-compliant.
//
return Type != ChannelFilter.Unfiltered
&& Type != ChannelFilter.AdHoc;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem determining whether or not filter corresponds to a CFC value", ex);
}
}
}
/// <summary>
/// Convert the specified frequency into a ChannelFilter type.
/// </summary>
///
/// <param name="frequency">
/// The <see cref="double"/> frequency to be converted.
/// </param>
///
/// <returns>
/// The best matching <see cref="ChannelFilter"/> type. A CFC match is preferred;
/// if one does not exist, "ad hoc" will be selected (if frequency > 0).
/// </returns>
///
private ChannelFilter ConvertFrequencyToChannelFilter(double frequency)
{
try
{
var matchingFilterType = ChannelFilter.Unfiltered;
if (frequency > 0)
{
matchingFilterType = ChannelFilter.AdHoc;
var cfcCoder = new CfcValueAttributeCoder();
foreach (int filterValue in Enum.GetValues(typeof(ChannelFilter)))
if (frequency == filterValue)
matchingFilterType = (ChannelFilter)filterValue;
}
return matchingFilterType;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem trying to match frequency to CRC value", ex);
}
}
/// <summary>
/// Get the "best fitting" <see cref="ChannelFilter"/> value for this filter.
/// </summary>
override public ChannelFilter Type
{
get
{
try
{
var actualType = OriginalType;
switch (OriginalType)
{
case ChannelFilter.AdHoc:
actualType = ConvertFrequencyToChannelFilter(CutoffFrequencyHz);
break;
default:
//
// Don't waste time on stuff we don't need to convert.
//
actualType = OriginalType;
break;
}
return actualType;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem determining filter type", ex);
}
}
}
public char IsoDescription => new IsoDescriptionAttributeCoder().DecodeAttributeValue(OriginalType)[0];
/// <summary>
/// Get the <see cref="double"/> cutoff frequency value.
/// </summary>
override public double CutoffFrequencyHz => _CutoffFrequencyHz.Value;
private readonly Property<double> _CutoffFrequencyHz
= new Property<double>(
typeof(SaeJ211Filter).Namespace + ".SaeJ211Filter.CutoffFrequencyHz",
-1,
true
);
/// <summary>
/// The <see cref="ChannelFilter"/>ing done by this object.
/// </summary>
public ChannelFilter OriginalType
{
get => _OriginalType.Value;
private set => _OriginalType.Value = value;
}
private readonly Property<ChannelFilter> _OriginalType
= new Property<ChannelFilter>(
typeof(SaeJ211Filter).Namespace + ".SaeJ211Filter.OriginalType",
ChannelFilter.Unfiltered,
false
);
private const string CutoffFrequencyUnitString = "Hz";
/// <summary>
/// The <see cref="string"/> name of this filter.
/// </summary>
public override string Name
{
get
{
try
{
if (null == _Name)
{
var cult = new System.Globalization.CultureInfo("");
_Name = ChannelFilter.AdHoc == Type
? CutoffFrequencyHz.ToString(cult) + CutoffFrequencyUnitString
: new DescriptionAttributeCoder<ChannelFilter>().DecodeAttributeValue(Type);
}
return _Name;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem generating name string for " + GetType().FullName, ex);
}
}
}
private string _Name = null;
/// <summary>
/// Apply this filter to the specified channel.
/// </summary>
///
/// <param name="channel">
/// The <see cref="DTS.Slice.Control.Event.Module.Channel"/> to be filtered.
/// </param>
///
/// <returns>
/// The array of filtered <see cref="double"/> EU data.
/// </returns>
///
public override double[] Apply
(
Channel channel,
DataDisplayUnits displayUnits,
bool bUseLegacyTDCSoftwareFilterAdjustment
)
{
try
{
var filterUtility = new FilterUtility();
filterUtility.Cfc = Type;
filterUtility.AdHocFrequency = CutoffFrequencyHz;
filterUtility.SampleRate = channel.ParentModule.SampleRateHz;
double[] data;
switch (displayUnits)
{
case DataDisplayUnits.Adc:
if (channel.UnfilteredData is Serialization.SliceRaw.File.PersistentChannel)
{
if (channel.UnfilteredData is ILargeDataAware)
if (!(channel.UnfilteredData as ILargeDataAware).IsDataArraySized)
throw new Serialization.SliceRaw.File.PersistentChannel.DataTooBigForArrayException("Data is too big to be viewed or filtered.");
using (var persistentUnfilteredData =
channel.UnfilteredData as Serialization.SliceRaw.File.PersistentChannel)// ;
{
var dataCount = persistentUnfilteredData.Count;
data = new double[dataCount];
for (var i = 0; i < dataCount; i++)
data[i] = persistentUnfilteredData[(ulong) i];
}
//persistentUnfilteredData.Dispose();
}
else if (channel.UnfilteredData is Serialization.TDAS.File.PersistentChannel)
{
if (channel.UnfilteredData is ILargeDataAware)
if (!(channel.UnfilteredData as ILargeDataAware).IsDataArraySized)
throw new Serialization.TDAS.File.PersistentChannel.DataTooBigForArrayException("Data is too big to be viewed or filtered.");
using (var persistentUnfilteredData =
channel.UnfilteredData as Serialization.TDAS.File.PersistentChannel)// ;
{
var dataCount = persistentUnfilteredData.Count;
data = new double[dataCount];
for (var i = 0; i < dataCount; i++)
data[i] = persistentUnfilteredData[(ulong)i];
}
//persistentUnfilteredData.Dispose();
}
else data = channel.UnfilteredData.ConvertAll<double>(delegate(short datum) { return (double)datum; }).ToArray();
break;
case DataDisplayUnits.Eu:
data = channel.UnfilteredDataEu.ToArray();
break;
case DataDisplayUnits.Mv:
data = channel.UnfilteredDataMv.ToArray();
break;
default:
throw new NotImplementedException("handling for display unit type \"" + displayUnits.ToString() + "\" has not been implemented");
}
return filterUtility.ApplyFilter(data, new FilterUtility.InvalidDataDelegate(delegate()
{
var msg = string.Format("Invalid data in channel: {0}.", channel.ChannelDescriptionString);
//var dr = System.Windows.Forms.MessageBox.Show(msg, "Warning", System.Windows.Forms.MessageBoxButtons.OK);
APILogger.Log(msg);
throw new Exception(msg);
}), bUseLegacyTDCSoftwareFilterAdjustment);
}
catch ( System.Exception ex )
{
throw new Exception( "encountered problem applying filter \"" + Name + "\" to channel", ex );
}
}
/// <summary>
/// Apply this filter to the specified channel.
/// </summary>
///
/// <param name="channel">
/// The <see cref="DTS.Slice.Control.Event.Module.Channel"/> to be filtered.
/// </param>
/// <param name="bUseLegacyTDCSoftwareFilterAdjustment">
/// controls whether filtered data is adjusted by one sample to match TDC behavior
/// 8747
/// </param>
/// <returns>
/// The array of filtered <see cref="double"/> EU data.
/// </returns>
public override double[] Apply
(
double [] data,
double sampleRate,
bool bUseLegacyTDCSoftwareFilterAdjustment
)
{
try
{
var filterUtility = new FilterUtility();
filterUtility.Cfc = Type;
filterUtility.AdHocFrequency = CutoffFrequencyHz;
filterUtility.SampleRate = sampleRate;
return filterUtility.ApplyFilter(data, new FilterUtility.InvalidDataDelegate(delegate()
{
var msg = string.Format("Invalid data in channel.");
//var dr = System.Windows.Forms.MessageBox.Show(msg, "Warning", System.Windows.Forms.MessageBoxButtons.OK);
APILogger.Log(msg);
throw new Exception(msg);
}), bUseLegacyTDCSoftwareFilterAdjustment);
}
catch (System.Exception ex)
{
throw new Exception("encountered problem applying filter \"" + Name + "\" to channel", ex);
}
}
/// <summary>
/// Generate a string representation of this object.
/// </summary>
///
/// <returns>
/// A <see cref="string"/> representation of this object.
/// </returns>
///
public override string ToString( )
{
try
{
return Name;
}
catch ( System.Exception ex )
{
throw new Exception( "encountered problem generating the string value for " + GetType( ).FullName, ex );
}
}
/// <summary>
/// Generate a string representation of this object.
/// </summary>
///
/// <returns>
/// A <see cref="string"/> representation of this object.
/// </returns>
///
public override string ToBaseString()
{
try
{
return Name;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem generating the string value for " + GetType().FullName, ex);
}
}
/// <summary>
/// Determines whether this filter and the specified filter are the same.
/// </summary>
///
/// <param name="obj">
/// The filter <see cref="object"/> to be compared with this one.
/// </param>
///
/// <returns>
/// <see cref="bool"/> true if the filters are the same, false otherwise.
/// </returns>
///
public override bool Equals( object obj )
{
try
{
if (null == obj as SaeJ211Filter) { return false; }
return Name.Equals( ( obj as SaeJ211Filter ).Name, StringComparison.OrdinalIgnoreCase );
}
catch ( System.Exception ex )
{
throw new Exception(
"encountered problem equality checking filter \""
+ Name
+ "\" with filter "
+ ( null != obj && obj is SaeJ211Filter && null != ( obj as SaeJ211Filter ).Name ? "\"" + ( obj as SaeJ211Filter ).Name + "\"" : "<null>" ), ex );
}
}
/// <summary>
/// provides an index for a given <see cref="DTS.Slice.Control.Event.Module.Channel.SaeJ211Filter"/>
/// since we override Equals we should override get hashcode to ensure that any to objects considered
/// "Equal" are also hashed to the same location, however the result index does not need to be unique
/// between non equal objects.
/// 6/10/2010 - dtm
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return Name.ToLower().GetHashCode();
}
/// <summary>
/// Create a filter from the specified string.
/// </summary>
///
/// <param name="serialization">
/// The <see cref="string"/> representation of the filter to be instantiated.
/// </param>
///
/// <returns>
/// A <see cref="DTS.Slice.Control.Event.Module.Channel.Filter"/> equivalent of the
/// specified string. Throws an exception if object could not be created.
/// </returns>
///
static public Filter Parse( string serialization )
{
try
{
Filter filter = null;
if ( !string.IsNullOrEmpty( serialization ) )
{
if ( serialization.Contains( CutoffFrequencyUnitString ) )
{
var cult = new System.Globalization.CultureInfo("");
filter = new DefaultSaeJ211Filter(double.Parse(serialization.Replace(CutoffFrequencyUnitString, ""), cult));
}
else
{
foreach ( ChannelFilter filterType in Enum.GetValues( typeof( ChannelFilter ) ) )
{
var coder = new DescriptionAttributeCoder<ChannelFilter>( );
if ( coder.DecodeAttributeValue( filterType ).Equals( serialization, StringComparison.OrdinalIgnoreCase ) )
filter = new DefaultSaeJ211Filter( filterType );
}
}
}
return ( null != filter ? filter : new SaeJ211Filter( ChannelFilter.Unfiltered ) );
}
catch ( System.Exception ex )
{
throw new Exception( "encountered problem parsing string " + ( null != serialization ? "\"" + serialization + "\"" : "<NULL>" ) + " into filter", ex );
}
}
}
}
}
}
}

View File

@@ -0,0 +1,902 @@
/*
* DTS.Slice.Control.Event.Module.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using DTS.Common.DAS.Concepts;
using DTS.Serialization.StringResources;
using DTS.Common.Utilities;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using DTS.Common.Utilities.Logging;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
/// <summary>
/// Representation of a Slice Control event module.
/// </summary>
public partial class Module
: Exceptional,
Serialization.Test.Module.IConvertable
{
public Module()
{
try
{
//this.InitializeReviewableAttributes(this.ReviewableAttributes);
}
catch (System.Exception ex)
{
throw new Exception("encountered problem zero-parameter constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.Module class.
/// </summary>
///
/// <param name="parentEvent">
/// The parent <see cref="DTS.Slice.Control.Event"/> of this module.
/// </param>
///
//TODO: this() is not base class
public Module(Event parentEvent)
: this()
{
try
{
ParentEvent = parentEvent;
}
catch (System.Exception ex)
{
throw new Exception("encounterd problem 1-parameter constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.Module class.
/// </summary>
///
/// <param name="that">
/// A <see cref="DTS.Serialization.Test.Module"/> with which to initialize this object.
/// </param>
///
/// <param name="parentEvent">
/// The parent <see cref="DTS.Slice.Control.Event"/> of this module.
/// </param>
///
public Module(Serialization.Test.Module that, Event parent, Serialization.Test.ReportErrors reportErrors)
: this(parent)
{
try
{
FromDtsSerializationTestModule(that, reportErrors);
}
catch (System.IO.InvalidDataException ex) { throw ex; }
catch (System.Exception ex)
{
throw new Exception("encountered problem 2-parameter constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// The <see cref="Event"/> that contains this module.
/// </summary>
public Event ParentEvent
{
get => _ParentEvent.Value;
private set => _ParentEvent.Value = value;
}
private readonly Property<Event> _ParentEvent
= new Property<Event>(
typeof(Module).Namespace + ".Event.Module.ParentEvent",
null,
false
);
public void SetParentEvent(Event e) { _ParentEvent.Value = e; }
/// <summary>
/// Get/set the list of channels on this event module.
/// </summary>
public List<Channel> Channels
{
get => _Channels.Value;
set => _Channels.Value = value;
}
private readonly Property<List<Channel>> _Channels = new Property<List<Channel>>("Event.Module.Channels", new List<Channel>(), true);
/// <summary>
/// Get/set the <see cref="int"/> module number of this event module.
/// </summary>
public int Number
{
get => _Number.Value;
set => _Number.Value = value;
}
private readonly Property<int> _Number = new Property<int>("Event.Module.Number", 0, false);
/// <summary>
/// Get/set the serial number <see cref="string"/> for this DAS.
/// </summary>
public string DasSerialNumber
{
get => _dasSerialNumber.Value;
set => _dasSerialNumber.Value = value;
}
private readonly Property<string> _dasSerialNumber = new Property<string>(typeof(Module).Namespace + ".Event.Module.DasSerialNumber", "", true);
/// <summary>
/// Get/set the serial number <see cref="string"/> for this DAS.
/// </summary>
public string Description
{
get => _Description.Value;
set => _Description.Value = value;
}
private readonly Property<string> _Description
= new Property<string>(
typeof(Module).Namespace + ".Event.Module.Description",
"",
true
);
public bool IsSlice6DBModule()
{
return (Description == "slice6db module");
}
/// <summary>
/// Get/set the base serial number <see cref="string"/> for this DAS.
/// </summary>
public string BaseSerialNumber
{
get => _BaseSerialNumber.Value;
set => _BaseSerialNumber.Value = value;
}
private readonly Property<string> _BaseSerialNumber
= new Property<string>(
typeof(Module).Namespace + ".Event.Module.BaseSerialNumber",
"",
true
);
/// <summary>
/// Get/set the <see cref="double"/> number of requested seconds pre-trigger for this event module.
/// </summary>
public double RequestedPreTriggerSeconds
{
get => _RequestedPreTriggerSeconds.Value;
set => _RequestedPreTriggerSeconds.Value = value;
}
private readonly Property<double> _RequestedPreTriggerSeconds = new Property<double>("Event.Module.RequestedPreTriggerSeconds", 0.0, false);
/// <summary>
/// Get/set the <see cref="double"/> number of requested seconds post-trigger for this event module.
/// </summary>
public double RequestedPostTriggerSeconds
{
get => _RequestedPostTriggerSeconds.Value;
set => _RequestedPostTriggerSeconds.Value = value;
}
private readonly Property<double> _RequestedPostTriggerSeconds = new Property<double>("Event.Module.RequestedPostTriggerSeconds", 0.0, false);
/// <summary>
/// Get/set the <see cref="double"/> number of seconds pre-trigger for this event module.
/// </summary>
public double PreTriggerSeconds
{
get => _PreTriggerSeconds.Value;
set => _PreTriggerSeconds.Value = value;
}
private readonly Property<double> _PreTriggerSeconds = new Property<double>("Event.Module.PreTriggerSeconds", 0.0, false);
/// <summary>
/// Get/set the <see cref="double"/> number of seconds post-trigger for this event module.
/// </summary>
public double PostTriggerSeconds
{
get => _PostTriggerSeconds.Value;
set => _PostTriggerSeconds.Value = value;
}
private readonly Property<double> _PostTriggerSeconds = new Property<double>("Event.Module.PostTriggerSeconds", 0.0, false);
/// <summary>
/// Get/set the number of <see cref="UInt64"/> samples in this event modules.
/// </summary>
public UInt64 NumberOfSamples
{
get => _NumberOfSamples.Value;
set => _NumberOfSamples.Value = value;
}
private readonly Property<UInt64> _NumberOfSamples = new Property<UInt64>("Event.Module.NumberOfSamples", 0, false);
/// <summary>
/// Get/set the number of unsubsampled <see cref="UInt64"/> samples in this event modules.
/// </summary>
public UInt64 UnsubsampledNumberOfSamples
{
get => _UnsubsampledNumberOfSamples.Value;
set => _UnsubsampledNumberOfSamples.Value = value;
}
private readonly Property<UInt64> _UnsubsampledNumberOfSamples = new Property<UInt64>("Event.Module.UnsubsampledNumberOfSamples", 0, true);
/// <summary>
/// Get/set the <see cref="UInt64"/> trigger sample numbers for this event module.
/// </summary>
public List<UInt64> TriggerSampleNumbers
{
get => _TriggerSampleNumbers.Value;
set => _TriggerSampleNumbers.Value = value;
}
private readonly Property<List<UInt64>> _TriggerSampleNumbers = new Property<List<UInt64>>("Event.Module.TriggerSampleNumbers", null, false);
/// <summary>
/// Get/set the <see cref="UInt64"/> unsubsampled trigger sample numbers for this event module.
/// </summary>
public List<UInt64> UnsubsampledTriggerSampleNumbers
{
get => _UnsubsampledTriggerSampleNumbers.Value;
set => _UnsubsampledTriggerSampleNumbers.Value = value;
}
private readonly Property<List<UInt64>> _UnsubsampledTriggerSampleNumbers = new Property<List<UInt64>>("Event.Module.UnsubsampledTriggerSampleNumbers", new List<UInt64>(), true);
/// <summary>
/// Get/set the <see cref="UInt64"/> start record sample number for this event module.
/// </summary>
public UInt64 StartRecordSampleNumber
{
get => _StartRecordSampleNumber.Value;
set => _StartRecordSampleNumber.Value = value;
}
private readonly Property<UInt64> _StartRecordSampleNumber = new Property<UInt64>("Event.Module.StartRecordSampleNumber", 0, false);
/// <summary>
/// Get/set the <see cref="float"/> sample rate for this event module.
/// </summary>
public float SampleRateHz
{
get => _SampleRateHz.Value;
set => _SampleRateHz.Value = value;
}
private readonly Property<float> _SampleRateHz = new Property<float>("Event.Module.SampleRateHz", 0, false);
/// <summary>
/// Get/set the <see cref="double"/> start record timestamp in seconds for this event module.
/// </summary>
public double StartRecordTimestampSec
{
get => _StartRecordTimestampSec.Value;
set => _StartRecordTimestampSec.Value = value;
}
private readonly Property<double> _StartRecordTimestampSec = new Property<double>("Event.Module.StartRecordTimestampSec", 0, false);
/// <summary>
/// Get/set the <see cref="double"/> start record timestamp in nanoseconds for this event module.
/// </summary>
public double StartRecordTimestampNanoSec
{
get => _StartRecordTimestampNanoSec.Value;
set => _StartRecordTimestampNanoSec.Value = value;
}
private readonly Property<double> _StartRecordTimestampNanoSec = new Property<double>("Event.Module.StartRecordTimestampNanoSec", 0, false);
/// <summary>
/// Get/set the <see cref="double"/> trigger timestamp in seconds for this event module.
/// </summary>
public double TriggerTimestampSec
{
get => _TriggerTimestampSec.Value;
set => _TriggerTimestampSec.Value = value;
}
private readonly Property<double> _TriggerTimestampSec = new Property<double>("Event.Module.TriggerTimestampSec", 0, false);
/// <summary>
/// Get/set the <see cref="double"/> trigger timestamp in nanoseconds for this event module.
/// </summary>
public double TriggerTimestampNanoSec
{
get => _TriggerTimestampNanoSec.Value;
set => _TriggerTimestampNanoSec.Value = value;
}
private readonly Property<double> _TriggerTimestampNanoSec = new Property<double>("Event.Module.TriggerTimestampNanoSec", 0, false);
/// <summary>
/// Get/set the <see cref="bool"/> whether or not PTP master sync is used for this event module.
/// </summary>
public bool PTPMasterSync
{
get => _PTPMasterSync.Value;
set => _PTPMasterSync.Value = value;
}
private readonly Property<bool> _PTPMasterSync = new Property<bool>("Event.Module.PTPMasterSync", false, false);
/// <summary>
/// Get/set the tilt sensor X axis value.
/// </summary>
public double TiltSensorAxisXDegreesPre
{
get => _TiltSensorAxisXDegreesPre.Value;
set => _TiltSensorAxisXDegreesPre.Value = value;
}
private readonly Property<double> _TiltSensorAxisXDegreesPre = new Property<double>("Event.Module.TiltSensorAxisXDegreesPre", 0, false);
/// <summary>
/// Get/set the tilt sensor Y axis value.
/// </summary>
public double TiltSensorAxisYDegreesPre
{
get => _TiltSensorAxisYDegreesPre.Value;
set => _TiltSensorAxisYDegreesPre.Value = value;
}
private readonly Property<double> _TiltSensorAxisYDegreesPre = new Property<double>("Event.Module.TiltSensorAxis2DegreesPre", 0, false);
/// <summary>
/// Get/set the tilt sensor Z axis value.
/// </summary>
public double TiltSensorAxisZDegreesPre
{
get => _TiltSensorAxisZDegreesPre.Value;
set => _TiltSensorAxisZDegreesPre.Value = value;
}
private readonly Property<double> _TiltSensorAxisZDegreesPre = new Property<double>("Event.Module.TiltSensorAxisZDegreesPre", 0, false);
/// <summary>
/// Get/set the tilt sensor X axis value.
/// </summary>
public double TiltSensorAxisXDegreesPost
{
get => _TiltSensorAxisXDegreesPost.Value;
set => _TiltSensorAxisXDegreesPost.Value = value;
}
private readonly Property<double> _TiltSensorAxisXDegreesPost = new Property<double>("Event.Module.TiltSensorAxisXDegreesPost", 0, false);
/// <summary>
/// Get/set the tilt sensor Y axis value.
/// </summary>
public double TiltSensorAxisYDegreesPost
{
get => _TiltSensorAxisYDegreesPost.Value;
set => _TiltSensorAxisYDegreesPost.Value = value;
}
private readonly Property<double> _TiltSensorAxisYDegreesPost = new Property<double>("Event.Module.TiltSensorAxisYDegreesPost", 0, false);
/// <summary>
/// Get/set the tilt sensor Z axis value.
/// </summary>
public double TiltSensorAxisZDegreesPost
{
get => _TiltSensorAxisZDegreesPost.Value;
set => _TiltSensorAxisZDegreesPost.Value = value;
}
private readonly Property<double> _TiltSensorAxisZDegreesPost = new Property<double>("Event.Module.TiltSensorAxisZDegreesPost", 0, false);
/// <summary>
/// Get/set the temperature sensor location 1 value.
/// </summary>
public float TemperatureLocation1Pre
{
get => _TemperatureLocation1Pre.Value;
set => _TemperatureLocation1Pre.Value = value;
}
private readonly Property<float> _TemperatureLocation1Pre = new Property<float>("Event.Module.TemperatureLocation1Pre", 0, false);
/// <summary>
/// Get/set the temperature sensor location 2 value.
/// </summary>
public float TemperatureLocation2Pre
{
get => _TemperatureLocation2Pre.Value;
set => _TemperatureLocation2Pre.Value = value;
}
private readonly Property<float> _TemperatureLocation2Pre = new Property<float>("Event.Module.TemperatureLocation2Pre", 0, false);
/// <summary>
/// Get/set the temperature sensor location 3 value.
/// </summary>
public float TemperatureLocation3Pre
{
get => _TemperatureLocation3Pre.Value;
set => _TemperatureLocation3Pre.Value = value;
}
private readonly Property<float> _TemperatureLocation3Pre = new Property<float>("Event.Module.TemperatureLocation3Pre", 0, false);
/// <summary>
/// Get/set the temperature sensor location 4 value.
/// </summary>
public float TemperatureLocation4Pre
{
get => _TemperatureLocation4Pre.Value;
set => _TemperatureLocation4Pre.Value = value;
}
private readonly Property<float> _TemperatureLocation4Pre = new Property<float>("Event.Module.TemperatureLocation4Pre", 0, false);
/// <summary>
/// Get/set the temperature sensor location 1 post value.
/// </summary>
public float TemperatureLocation1Post
{
get => _TemperatureLocation1Post.Value;
set => _TemperatureLocation1Post.Value = value;
}
private readonly Property<float> _TemperatureLocation1Post = new Property<float>("Event.Module.TemperatureLocation1Post", 0, false);
/// <summary>
/// Get/set the temperature sensor location 2 value.
/// </summary>
public float TemperatureLocation2Post
{
get => _TemperatureLocation2Post.Value;
set => _TemperatureLocation2Post.Value = value;
}
private readonly Property<float> _TemperatureLocation2Post = new Property<float>("Event.Module.TemperatureLocation2Post", 0, false);
/// <summary>
/// Get/set the temperature sensor location 3 post value.
/// </summary>
public float TemperatureLocation3Post
{
get => _TemperatureLocation3Post.Value;
set => _TemperatureLocation3Post.Value = value;
}
private readonly Property<float> _TemperatureLocation3Post = new Property<float>("Event.Module.TemperatureLocation3Post", 0, false);
/// <summary>
/// Get/set the temperature sensor location 4 post value.
/// </summary>
public float TemperatureLocation4Post
{
get => _TemperatureLocation4Post.Value;
set => _TemperatureLocation4Post.Value = value;
}
private readonly Property<float> _TemperatureLocation4Post = new Property<float>("Event.Module.TemperatureLocation4Post", 0, false);
/// <summary>
/// Get/set the <see cref="float"/> AA filter rate for this event module.
/// </summary>
public float AaFilterRateHz
{
get => _AaFilterRateHz.Value;
set => _AaFilterRateHz.Value = value;
}
private readonly Property<float> _AaFilterRateHz = new Property<float>("Event.Module.AaFilterRateHz", 0, false);
/// <summary>
/// Get/set the <see cref="Test.Module.Channel.Sensor.ExcitationVoltageOption"/> nominal
/// excitation voltage of this module.
/// </summary>
public Test.Module.Channel.Sensor.ExcitationVoltageOption NominalExcitationVoltage
{
get => _NominalExcitationVoltage.Value;
set => _NominalExcitationVoltage.Value = value;
}
private readonly Property<Test.Module.Channel.Sensor.ExcitationVoltageOption> _NominalExcitationVoltage
= new Property<Test.Module.Channel.Sensor.ExcitationVoltageOption>(
typeof(Module).Namespace + ".Event.Module.NominalExcitationVoltage",
Test.Module.Channel.Sensor.ExcitationVoltageOption.Volt5,
true
);
/// <summary>
/// Get/set the <see cref="Test.Module.RecordingMode"/> of this module.
/// </summary>
public Test.Module.RecordingMode RecordingMode
{
get => _RecordingMode.Value;
set => _RecordingMode.Value = value;
}
private readonly Property<Test.Module.RecordingMode> _RecordingMode = new Property<Test.Module.RecordingMode>("Event.Module.RecordingMode", Test.Module.RecordingMode.CircularBuffer, false);
/// <summary>
/// Set the applicable properties of this object from the specified target object.
/// </summary>
///
/// <param name="that">
/// The <see cref="DTS.DASLib.Service.DASModule"/> that is to have the information it
/// shares with this object copied.
/// </param>
///
public void SetPropertyValuesFrom(DASLib.Service.DASModule that)
{
try
{
TriggerSampleNumbers = new List<ulong>(null != that.TriggerSampleNumbers ? that.TriggerSampleNumbers : new ulong[] { });
NumberOfSamples = that.NumberOfSamples;
ParentEvent.Guid = that.OwningDAS.EventGuids[0];
ushort faultFlag = 0;
try { faultFlag = ParentEvent.FaultFlags; }
//TODO: handle exception!!!
catch (System.Exception) { }
ParentEvent.FaultFlags = Convert.ToUInt16(faultFlag | that.OwningDAS.FaultFlags[0]);
// that.Description
}
catch (System.Exception ex)
{
throw new Exception("encountered problem setting property from target object " + (null != that ? "\"" + that.ToString() + "\"" : "<NULL>"), ex);
}
}
/// <summary>
/// Test the specified object for equality with this object.
/// </summary>
///
/// <param name="obj">
/// The <see cref="object"/> to be tested for equality.
/// </param>
///
/// <returns>
/// <see cref="bool"/> true if the specified object has memeberwise equality with
/// this object; false otherwise.
/// </returns>
///
public override bool Equals(object obj)
{
try
{
var that = obj as Module;
return null != that
&& Description.Equals(that.Description)
&& AaFilterRateHz.Equals(that.AaFilterRateHz)
&& Number.Equals(that.Number)
&& DasSerialNumber.Equals(that.DasSerialNumber)
&& NumberOfSamples.Equals(that.NumberOfSamples)
&& UnsubsampledNumberOfSamples.Equals(that.UnsubsampledNumberOfSamples)
&& RequestedPostTriggerSeconds.Equals(that.RequestedPostTriggerSeconds)
&& RequestedPreTriggerSeconds.Equals(that.RequestedPreTriggerSeconds)
&& PostTriggerSeconds.Equals(that.PostTriggerSeconds)
&& PreTriggerSeconds.Equals(that.PreTriggerSeconds)
&& RecordingMode.Equals(that.RecordingMode)
&& SampleRateHz.Equals(that.SampleRateHz)
&& StartRecordSampleNumber.Equals(that.StartRecordSampleNumber)
&& TriggerSampleNumbersEquals(that.TriggerSampleNumbers)
&& UnsubsampledTriggerSampleNumbersEquals(that.UnsubsampledTriggerSampleNumbers)
&& ChannelsEquals(that.Channels);
}
catch (System.Exception ex)
{
throw new Exception(
string.Format(
Strings.DTS_Slice_Control_Equals_ComparisonFailedString, null != obj ? "\"" + obj.ToString() + "\"" : Strings.DTS_Slice_Control_NullIndicatorString),
ex);
}
}
/// <summary>
/// Test the specified object's trigger sample number list for equality with this
/// object's module list.
/// </summary>
///
/// <param name="thoseTriggerSampleNumbers">
/// The <see cref="List"/> of <see cref="UInt64"/> object to be
/// compared for equality with this event's equivalent.
/// </param>
///
/// <returns>
/// <see cref="bool"/> true if the two lists contain equivalent-valued members;
/// false otherwise.
/// </returns>
///
private bool TriggerSampleNumbersEquals(List<UInt64> thoseTriggerSampleNumbers)
{
try
{
if (null == thoseTriggerSampleNumbers || TriggerSampleNumbers.Count != thoseTriggerSampleNumbers.Count)
return false;
return !thoseTriggerSampleNumbers.Where((t, i) => !TriggerSampleNumbers[i].Equals(t)).Any();
}
catch (System.Exception ex)
{
throw new Exception(Strings.DTS_Slice_Control_Event_Module_TriggerSampleNumbersEquals_ComparisonFailedString, ex);
}
}
/// <summary>
/// Test the specified object's unsubsampled trigger sample number list for equality with this
/// object's module list.
/// </summary>
///
/// <param name="thoseUnsubsampledTriggerSampleNumbers">
/// The <see cref="List"/> of <see cref="UInt64"/> object to be
/// compared for equality with this event's equivalent.
/// </param>
///
/// <returns>
/// <see cref="bool"/> true if the two lists contain equivalent-valued members;
/// false otherwise.
/// </returns>
///
private bool UnsubsampledTriggerSampleNumbersEquals(List<UInt64> thoseUnsubsampledTriggerSampleNumbers)
{
try
{
if (null == thoseUnsubsampledTriggerSampleNumbers || UnsubsampledTriggerSampleNumbers.Count != thoseUnsubsampledTriggerSampleNumbers.Count)
return false;
return !thoseUnsubsampledTriggerSampleNumbers.Where((t, i) => !UnsubsampledTriggerSampleNumbers[i].Equals(t)).Any();
}
catch (System.Exception ex)
{
throw new Exception("unsubsampled trigger sample number arrays do not match", ex);
}
}
/// <summary>
/// Test the specified object's module list for equality with this object's
/// module list.
/// </summary>
///
/// <param name="thoseChannels">
/// The <see cref="List"/> of <see cref="DTS.Slice.Control.Event.Module.Channel"/> objects to be
/// compared for equality with this module's equivalent.
/// </param>
///
/// <returns>
/// <see cref="bool"/> true if the two lists contain equivalent-valued members;
/// false otherwise.
/// </returns>
///
private bool ChannelsEquals(List<Channel> thoseChannels)
{
try
{
if (null == thoseChannels || Channels.Count != thoseChannels.Count)
return false;
return !thoseChannels.Where((t, i) => !Channels[i].Equals(t)).Any();
}
catch (System.Exception ex)
{
throw new Exception(Strings.DTS_Slice_Control_Event_Module_ChannelsEquals_ComparisonFailedString, ex);
}
}
/// <summary>
/// Return the hash code for this object.
/// </summary>
///
/// <returns>
/// The <see cref="int"/> hash code for this object.
/// </returns>
///
public override int GetHashCode()
{
return base.GetHashCode();
}
/// <summary>
/// Convert this object into a DTS.Serialization.Test.Module.
/// </summary>
///
/// <returns>
/// A <see cref="DTS.Serialization.Test.Module"/> equivalent to this object.
/// </returns>
///
public Serialization.Test.Module ToDtsSerializationTestModule(Serialization.Test parentTest)
{
try
{
var that = new Serialization.Test.Module(parentTest)
{
Description = Description,
AaFilterRateHz = AaFilterRateHz,
Number = Number,
SerialNumber = DasSerialNumber,
NumberOfSamples = NumberOfSamples,
UnsubsampledNumberOfSamples = UnsubsampledNumberOfSamples,
RequestedPostTriggerSeconds = RequestedPostTriggerSeconds,
RequestedPreTriggerSeconds = RequestedPreTriggerSeconds,
PostTriggerSeconds = PostTriggerSeconds,
PreTriggerSeconds = PreTriggerSeconds,
RecordingMode = RecordingMode,
SampleRateHz = SampleRateHz,
StartRecordSampleNumber = StartRecordSampleNumber,
TriggerSampleNumbers = TriggerSampleNumbers,
UnsubsampledTriggerSampleNumbers = UnsubsampledTriggerSampleNumbers,
BaseSerialNumber = BaseSerialNumber,
StartRecordTimestampSec = StartRecordTimestampSec,
StartRecordTimestampNanoSec = StartRecordTimestampNanoSec,
TriggerTimestampSec = TriggerTimestampSec,
TriggerTimestampNanoSec = TriggerTimestampNanoSec,
PTPMasterSync = PTPMasterSync,
TiltSensorAxisXDegreesPre = TiltSensorAxisXDegreesPre,
TiltSensorAxisYDegreesPre = TiltSensorAxisYDegreesPre,
TiltSensorAxisZDegreesPre = TiltSensorAxisZDegreesPre,
TiltSensorAxisXDegreesPost = TiltSensorAxisXDegreesPost,
TiltSensorAxisYDegreesPost = TiltSensorAxisYDegreesPost,
TiltSensorAxisZDegreesPost = TiltSensorAxisZDegreesPost,
TemperatureLocation1Pre = TemperatureLocation1Pre,
TemperatureLocation2Pre = TemperatureLocation2Pre,
TemperatureLocation3Pre = TemperatureLocation3Pre,
TemperatureLocation4Pre = TemperatureLocation4Pre,
TemperatureLocation1Post = TemperatureLocation1Post,
TemperatureLocation2Post = TemperatureLocation2Post,
TemperatureLocation3Post = TemperatureLocation3Post,
TemperatureLocation4Post = TemperatureLocation4Post,
Channels = new List<Serialization.Test.Module.Channel>()
};
// Create a test module channel to embody each channel conversion, and then
// copy over all relevant channel data members.
foreach (var thisChannel in Channels)
{
//10988 Do not download/write/purge unneeded files; Only write required channels
if (thisChannel.IsConfigured)
{
//
// Create a test module channel to embody each channel conversion, and then
// copy over all relevant channel data members.
//
that.Channels.Add(thisChannel.ToDtsSerializationTestModuleChannel(that));
}
}
return that;
}
catch (System.Exception ex)
{
throw new Exception("encountered problem converting " + GetType().FullName + " to " + typeof(Serialization.Test.Module).FullName, ex);
}
}
/// <summary>
/// Initialize this object from a DTS.Serialization.Test.Module.
/// </summary>
///
/// <param name="that">
/// A <see cref="DTS.Serialization.Test.Module"/> from which to initialize this object.
/// </param>
/// <param name="reportErrors"></param>
//TODO: use more descriptive variable names
public void FromDtsSerializationTestModule(Serialization.Test.Module that, Serialization.Test.ReportErrors reportErrors)
{
var errors = new List<string>();
try
{
if (null == that) { throw new ArgumentNullException( $"cannot set this object's properties from null serialization test module reference"); }
Description = that.Description;
AaFilterRateHz = that.AaFilterRateHz;
Number = that.Number;
DasSerialNumber = that.SerialNumber;
NumberOfSamples = that.NumberOfSamples;
UnsubsampledNumberOfSamples = that.UnsubsampledNumberOfSamples;
RequestedPostTriggerSeconds = that.RequestedPostTriggerSeconds;
RequestedPreTriggerSeconds = that.RequestedPreTriggerSeconds;
PostTriggerSeconds = that.PostTriggerSeconds;
PreTriggerSeconds = that.PreTriggerSeconds;
RecordingMode = that.RecordingMode;
SampleRateHz = that.SampleRateHz;
StartRecordSampleNumber = that.StartRecordSampleNumber;
TriggerSampleNumbers = that.TriggerSampleNumbers;
UnsubsampledTriggerSampleNumbers = that.UnsubsampledTriggerSampleNumbers;
BaseSerialNumber = that.BaseSerialNumber;
try
{
StartRecordTimestampSec = that.StartRecordTimestampSec;
}
catch (System.Exception ex)
{
APILogger.Log("failed to get StartRecordTimestampSec", ex);
}
//TODO: inappropriate using try/catch!!!
try
{
StartRecordTimestampNanoSec = that.StartRecordTimestampNanoSec;
}
catch (System.Exception ex)
{
APILogger.Log("failed to get StartRecordTimestampSec", ex);
}
//TODO: inappropriate using try/catch!!!
try
{
TriggerTimestampSec = that.TriggerTimestampSec;
}
catch (System.Exception ex)
{
APILogger.Log("failed to get TriggerTimestampSec", ex);
}
//TODO: inappropriate using try/catch!!!
try
{
TriggerTimestampNanoSec = that.StartRecordTimestampNanoSec;
}
catch (System.Exception ex)
{
APILogger.Log("failed to get TriggerTimestampNanoSec", ex);
}
//TODO: inappropriate using try/catch!!!
try
{
PTPMasterSync = that.PTPMasterSync;
}
catch (System.Exception ex)
{
APILogger.Log("failed to get PTPMasterSync", ex);
}
//TODO: inappropriate using try/catch!!!
try
{
TiltSensorAxisXDegreesPre = that.TiltSensorAxisXDegreesPre;
TiltSensorAxisYDegreesPre = that.TiltSensorAxisYDegreesPre;
TiltSensorAxisZDegreesPre = that.TiltSensorAxisZDegreesPre;
TiltSensorAxisXDegreesPost = that.TiltSensorAxisXDegreesPost;
TiltSensorAxisYDegreesPost = that.TiltSensorAxisYDegreesPost;
TiltSensorAxisZDegreesPost = that.TiltSensorAxisZDegreesPost;
}
catch (System.Exception ex)
{
APILogger.Log("failed to get tilt information", ex);
}
//TODO: inappropriate using try/catch!!!
try
{
TemperatureLocation1Pre = that.TemperatureLocation1Pre;
TemperatureLocation2Pre = that.TemperatureLocation2Pre;
TemperatureLocation3Pre = that.TemperatureLocation3Pre;
TemperatureLocation4Pre = that.TemperatureLocation4Pre;
TemperatureLocation1Post = that.TemperatureLocation1Post;
TemperatureLocation2Post = that.TemperatureLocation2Post;
TemperatureLocation3Post = that.TemperatureLocation3Post;
TemperatureLocation4Post = that.TemperatureLocation4Post;
}
catch (System.Exception ex)
{
APILogger.Log("failed to get temperature information", ex);
}
//APILogger.DoPerformanceLog("DTS.Slice.Control.Event.Module:FromDTSSerializationTestModule:6");
var absoluteChannelNumber = ParentEvent.LastAbsoluteChannelNumberInEvent + 1;
Channels.Clear();
foreach (var thatChannel in that.Channels)
{ //
// Create a Slice Control channel corresponding to the specified serialization
// channel and populate its relevant properties.
//
try
{
if (thatChannel.AbsoluteDisplayOrder != -2)
{
//Have to count the channels this way as the module isn't a part of the event yet.
var emc = Channel.CreateChannel(thatChannel, this, absoluteChannelNumber++);
Channels.Add(emc);
thatChannel.emc = emc;
Trace.WriteLine("Created EMC: " + absoluteChannelNumber.ToString());
}
}
catch (System.IO.InvalidDataException ex) { errors.Add(ex.Message); }
}
foreach (var thatCalculatedChannel in that.CalculatedChannels)
{
//Have to count the channels this way as the module isn't a part of the event yet.
var emc = Channel.CreateChannel(thatCalculatedChannel, this, absoluteChannelNumber++);
Trace.WriteLine("Created EMC: " + absoluteChannelNumber.ToString());
Channels.Add(emc);
thatCalculatedChannel.emc = emc;
}
}
catch (System.Exception ex)
{
throw new Exception("encountered problem initializing " + GetType().FullName + " using " + typeof(Serialization.Test.Module).FullName, ex);
}
if (errors.Count > 0 && null != reportErrors) { reportErrors(errors); }
}
}
}
}

View File

@@ -0,0 +1,74 @@
/*
* DTS.Slice.Control.Event.Module.ReviewableAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
/// <summary>
/// A reviewable attribute attached to a specific channel.
/// </summary>
abstract public partial class ReviewableAttribute
: Slice.Control.ReviewableAttribute
{
/// <summary>
/// The concrete class should implement this constructor.
/// </summary>
///
/// <param name="channel">
/// The <see cref="DTS.Slice.Control.Event.Module"/> to which a specific instance
/// of this reviewable attribute class is attached. It should be used by this class' subclass'
/// DetermineAttributeValueString method.
/// </param>
///
public ReviewableAttribute(Event.Module channel)
: this(null, null)
{
try
{
throw new NotImplementedException("cannot initialize " + this.GetType().FullName + " with this constructor; must call parameterized version");
}
catch (System.Exception ex)
{
throw new Module.ReviewableAttribute.Exception("encountered problem constructing " + this.GetType().FullName, ex);
}
}
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="name">
/// The <see cref="string"/> name of the attribute represented by this class.
/// </param>
///
/// <param name="calculateValue">
/// The <see cref="DTS.Slice.Control.ReviewableAttribute.DetermineValueString"/>
/// </param>
///
protected ReviewableAttribute(string name, DetermineValueString calculateValue)
: base(name, calculateValue)
{
}
}
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,46 @@
/*
* DTS.Slice.Control.Event.Module.ReviewableDasSerialNumberAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTS.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module
{
/// <summary>
/// A reviewable filter frequency attribute attached to a specific channel.
/// </summary>
public class ReviewableDasSerialNumberAttribute
: Slice.Control.Event.Module.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module"/> to which this attribute is attached.
/// </param>
///
public ReviewableDasSerialNumberAttribute(Event.Module module)
: base("DAS Serial Number", delegate { return module.DasSerialNumber; })
{
}
}
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,81 @@
/*
* DTS.Slice.Control.Event.Module.ReviewableSampleRateAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTS.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event {
// *** see DTS.Slice.Control.Event.Module.cs ***
public partial class Module {
/// <summary>
/// A reviewable filter frequency attribute attached to a specific channel.
/// </summary>
public class ReviewableSampleRateAttribute
: Slice.Control.Event.Module.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module"/> to which this attribute is attached.
/// </param>
///
public ReviewableSampleRateAttribute(Event.Module module)
: base("Sample Rate", delegate { return module.SampleRateHz.ToString("N"); })
{
}
}
/// <summary>
/// A reviewable filter frequency attribute attached to a specific channel.
/// </summary>
public class ReviewableTestDescriptionAttribute
: Slice.Control.Event.Module.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module"/> to which this attribute is attached.
/// </param>
///
public ReviewableTestDescriptionAttribute(Event.Module module)
: base("Test Description", delegate { return module.ParentEvent.Description; })
{
}
}
public class ReviewableHardwareFrequencyAttribute
: Slice.Control.Event.Module.ReviewableAttribute
{
/// <summary>
/// Initialize an instance of this class.
/// </summary>
///
/// <param name="channel">
/// The <see cref="Event.Module.Channel"/> to which this attribute is attached.
/// </param>
///
public ReviewableHardwareFrequencyAttribute(Event.Module module)
: base("HW AAF", delegate { return module.AaFilterRateHz.ToString("N2"); })
{
}
}
} // *** end Module ***
} // *** end Event ***
}

View File

@@ -0,0 +1,27 @@
/*
* DTS.Slice.Control.Event.ModuleChannelAccessor.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using DTS.Common.Utilities;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.Event.cs ***
public partial class Event
{
/// <summary>
/// A component object of the Event.DasModuleChannelAccessor.
/// </summary>
public class ModuleChannelAccessor : ExceptionalDictionary<int, ChannelAccessor> // xxx change this int to DAS.Module.Id?
{
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.ModuleChannelAccessor class.
/// </summary>
public ModuleChannelAccessor() { }
}
}
}

View File

@@ -0,0 +1,81 @@
/*
* DTS.Slice.Control.Event.TestInformation.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using DTS.Common.Utilities;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
namespace DTS.Slice.Control
{
// *** see DTS.Slice.Control.DAS.Event.cs ***
public partial class Event
{
/// <summary>
/// Internal representation of DAS event test information.
/// </summary>
private class TestInformation : Exceptional
{
/// <summary>
/// Get/set the <see cref="string"/> ID of the test associated with this DAS event.
/// </summary>
public string Id
{
get => _Id.Value;
set => _Id.Value = value;
}
private readonly Property<string> _Id = new Property<string>("DTS.Slice.Control.Event.TestInformation.Id", null, false);
/// <summary>
/// Get/set the <see cref="string"/> description of the test associated with this DAS event.
/// </summary>
public string Description
{
get => _Description.Value;
set => _Description.Value = value;
}
private readonly Property<string> _Description = new Property<string>("DTS.Slice.Control.Event.TestInformation.Description", null, false);
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.TestInformation class.
/// </summary>
public TestInformation()
{ //
// NOTE that the invocation of this constructor will leave this class'
// properties uninitialized.
} //
/// <summary>
/// Initialize an instance of the DTS.Slice.Control.Event.TestInformation class.
/// </summary>
///
/// <param name="id">
/// The <see cref="string"/> ID of the test associated with this DAS event.
/// </param>
///
/// <param name="description">
/// The <see cref="string"/> description of the test associated with this DAS event.
/// </param>
///
public TestInformation(string id, string description)
{
try
{
Id = id;
Description = description;
}
catch (System.Exception ex)
{
throw new Exception(
string.Format(
Serialization.StringResources.Strings.DTS_Slice_Control_Event_ConstructionFailedString, GetType().FullName),
ex);
}
}
}
}
}

View File

@@ -0,0 +1,181 @@
/*
DTS.Slice.Control.IntervalSec.cs
Copyright © 2008
Diversified Technical Systems, Inc.
All Rights Reserved
*/
using DTS.Common.Utilities;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
namespace DTS.Slice.Control
{
/// <summary>
/// Get/set the begin value.
/// </summary>
public class IntervalSec : Exceptional
{
/// <summary>
/// Create an instance of the IntervalSec class.
/// </summary>
public IntervalSec()
{ //
// Note that calling the parameterless constructor will leave the begin and
// end properties "uninitialized".
} //
/// <summary>
/// Create an instance of the IntervalSec class.
/// </summary>
///
/// <param name="begin">
/// The <see cref="double"/> begin time of this interval.
/// </param>
///
/// <param name="end">
/// The <see cref="double"/> end time of this interval.
/// </param>
///
public IntervalSec(double begin, double end)
{
try
{
Begin = begin;
End = end;
}
catch (System.Exception ex)
{
throw new Exception(
"encountered problem constructing " + GetType().FullName, ex);
}
}
/// <summary>
/// Get/set the <see cref="double"/> begin time of the interval.
/// </summary>
public double Begin
{
get => _Begin.Value;
set => _Begin.Value = value;
}
private readonly Property<double> _Begin
= new Property<double>(
typeof(IntervalSec).Namespace + ".IntervalSec.Begin", 0, false);
/// <summary>
/// Get/set the <see cref="double"/> end time of the interval.
/// </summary>
public double End
{
get => _End.Value;
set => _End.Value = value;
}
private readonly Property<double> _End
= new Property<double>(
typeof(IntervalSec).Namespace + ".IntervalSec.End", 0, false);
/// <summary>
/// Method to implicitly convert this type into a DTS.Serialization.Test.IntervalSec.
/// </summary>
///
/// <param name="thisInterval">
/// The <see cref="DTS.Slice.Control.IntervalSec"/> to be converted.
/// </param>
///
/// <returns>
/// A <see cref="DTS.Serialization.Test.IntervalSec"/> equivalent to the speceified interval
/// object.
/// </returns>
///
public static implicit operator Serialization.Test.IntervalSec(IntervalSec thisInterval)
{
try
{
return new Serialization.Test.IntervalSec(thisInterval.Begin, thisInterval.End);
}
catch (System.Exception ex)
{
throw new Exception("encountered problem implicitly converting " + typeof(IntervalSec).FullName + " to " + typeof(Serialization.Test.IntervalSec).FullName, ex);
}
}
/// <summary>
/// Method to implicitly convert a DTS.Serialization.Test.IntervalSec object into this type.
/// </summary>
///
/// <param name="thatInterval">
/// The <see cref="DTS.Serialization.Test.IntervalSec"/> to be converted.
/// </param>
///
/// <returns>
/// A <see cref="DTS.Slice.Control.IntervalSec"/> equivalent to the specified interval
/// object.
/// </returns>
///
public static implicit operator IntervalSec(Serialization.Test.IntervalSec thatInterval)
{
try
{
return new IntervalSec(thatInterval.Begin, thatInterval.End);
}
catch (System.Exception ex)
{
throw new Exception("encountered problem implicitly converting " + typeof(Serialization.Test.IntervalSec).FullName + " to " + typeof(IntervalSec).FullName, ex);
}
}
/// <summary>
/// Test the specified object for equality with this object.
/// </summary>
///
/// <param name="obj">
/// The <see cref="object"/> to be tested for equality.
/// </param>
///
/// <returns>
/// <see cref="bool"/> true if the specified object has memeberwise equality with
/// this object; false otherwise.
/// </returns>
///
public override bool Equals(object obj)
{
try
{
var that = obj as IntervalSec;
return null != obj
&& Begin.Equals(that.Begin)
&& End.Equals(that.End);
}
catch (System.Exception ex)
{
throw new Exception("encountered problem equality-testing the object " + (null != obj ? "\"" + obj.ToString() + "\"" : "<<NULL>>"), ex);
}
}
/// <summary>
/// Get has code for this object.
/// </summary>
///
/// <returns>
/// The <see cref="int"/> hash code for this object.
/// </returns>
///
public override int GetHashCode()
{
try
{
return base.GetHashCode();
}
catch (System.Exception ex)
{
throw new Exception("encountered problem generating hash code for " + GetType().FullName, ex);
}
}
}
}

View File

@@ -0,0 +1,118 @@
/*
* DTS.Slice.Control.ReviewableAttribute.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTS.Utilities;
using DTS.Utilities.DotNetProgrammingConstructs;
namespace DTS.Slice.Control
{
/// <summary>
/// Representation of a "reviewable" attribute.
/// </summary>
abstract public class ReviewableAttribute : Exceptional
{ ///
/// <summary>
/// Initialize an instance of the ReviewableAttribute class.
/// </summary>
///
/// <param name="name">
/// The <see cref="string"/> name of the attribute represented by this object.
/// </param>
///
/// <param name="value">
/// The value of the attribute represented by this object.
/// </param>
///
public ReviewableAttribute(string name, DetermineValueString calculateValue)
{
try
{
this.Name = name;
this.CalculateValue = calculateValue;
}
catch (System.Exception ex)
{
throw new ReviewableAttribute.Exception("encountered problem constructing " + this.GetType().FullName, ex);
}
}
/// <summary>
/// The <see cref="string"/> name associated with this review tab-displayable attribute.
/// </summary>
public string Name
{
get { return _Name.Value; }
private set { _Name.Value = value; }
}
private Property<string> _Name
= new Property<string>(
typeof(ReviewableAttribute).Namespace + ".ReviewableAttribute.Name",
null,
false
);
/// <summary>
/// Get the value <see cref="string"/> for this attribute.
/// </summary>
public string Value
{
get
{
try
{
return CalculateValue();
}
catch (System.Exception ex)
{
Utilities.Logging.APILogger.Log("encountered problem getting ReviewableAttribute value", ex);
return "N/A";
//throw new ReviewableAttribute.Exception( "encountered problem getting ReviewableAttribute value", ex );
}
}
}
// Need to attach the list of attribute "accessors" to the channel in a similar way
// we do with filters. Have an "available" list. And then an "active" list.
public delegate string DetermineValueString();
/// <summary>
/// Determine the value associated with this review tab-displayable attribute.
/// </summary>
private DetermineValueString CalculateValue
{
get
{
try
{
if (!_CalculateValueIsInitialized)
throw new ApplicationException("method property \"CalculateValue\" has not been initialized");
else return _CalculateValue;
}
catch (System.Exception ex)
{
throw new ReviewableAttribute.Exception("encountered problem getting property value", ex);
}
}
set
{
_CalculateValue = value;
_CalculateValueIsInitialized = true;
}
}
private DetermineValueString _CalculateValue;
private bool _CalculateValueIsInitialized = false;
}
}