546 lines
19 KiB
Plaintext
546 lines
19 KiB
Plaintext
using DTS.Common.Attributes;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
|
|
namespace DTS.Common.Enums.Sensors
|
|
{
|
|
/// <summary>
|
|
/// holds information for all CSV import/export fields and their versions
|
|
/// </summary>
|
|
public abstract class CSVImportTags
|
|
{
|
|
public const int MIN_VALID_VERSION = 0;
|
|
public const int MAX_VALID_VERSION = 6;
|
|
private static readonly object MY_LOCK = new object();
|
|
private static HashSet<int> _SensorTagsVersions = new HashSet<int>()
|
|
{
|
|
0, 2, 3, 4
|
|
};
|
|
public static bool IsSensorTag(int version)
|
|
{
|
|
return _SensorTagsVersions.Contains(version);
|
|
}
|
|
private static string TagToDisplayString(Tags tag)
|
|
{
|
|
var enumType = tag.GetType();
|
|
var name = Enum.GetName(enumType, tag);
|
|
if (string.IsNullOrEmpty(name)) { return string.Empty; }
|
|
var fieldInfo = enumType.GetField(name);
|
|
if (null == fieldInfo || 0 == fieldInfo.CustomAttributes.Count()) { return string.Empty; }
|
|
var attributes = fieldInfo.GetCustomAttributes(false).OfType<DisplayAttribute>();
|
|
if (null == attributes || !attributes.Any()) { return string.Empty; }
|
|
return attributes.FirstOrDefault().Name;
|
|
}
|
|
private static int TagToVersion(Tags tag)
|
|
{
|
|
var enumType = tag.GetType();
|
|
var name = Enum.GetName(enumType, tag);
|
|
if (string.IsNullOrEmpty(name)) { return int.MaxValue; }
|
|
var fieldInfo = enumType.GetField(name);
|
|
if (null == fieldInfo || 0 == fieldInfo.CustomAttributes.Count()) { return int.MaxValue; }
|
|
var attributes = fieldInfo.GetCustomAttributes(false).OfType<VersionAttribute>();
|
|
if (null == attributes || !attributes.Any()) { return int.MaxValue; }
|
|
return attributes.FirstOrDefault().Version;
|
|
}
|
|
/// <summary>
|
|
/// gets all tags for a given version of import
|
|
/// </summary>
|
|
/// <param name="version"></param>
|
|
/// <returns></returns>
|
|
public static Tags [] GetVersionTags(int version)
|
|
{
|
|
lock (MY_LOCK)
|
|
{
|
|
if (null == _versionToTags) { PopulateLookups(); }
|
|
return _versionToTags.ContainsKey(version) ? _versionToTags[version].ToArray() : new Tags[0];
|
|
}
|
|
}
|
|
private static Dictionary<string, Tags> _stringToTag = null;
|
|
private static Dictionary<Tags, string> _tagToString = null;
|
|
private static Dictionary<int, List<Tags>> _versionToTags = null;
|
|
private static Dictionary<Tags, int> _tagToVersion = null;
|
|
/// <summary>
|
|
/// gets a display string given a tag
|
|
/// </summary>
|
|
/// <param name="tag"></param>
|
|
/// <returns></returns>
|
|
public static string GetStringForTag(Tags tag)
|
|
{
|
|
lock (MY_LOCK)
|
|
{
|
|
if (null == _tagToString) { PopulateLookups(); }
|
|
return _tagToString.ContainsKey(tag) ? _tagToString[tag] : string.Empty;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// returns a tag given a display string
|
|
/// </summary>
|
|
/// <param name="s"></param>
|
|
/// <returns></returns>
|
|
public static Tags GetTagForString(string s)
|
|
{
|
|
lock (MY_LOCK)
|
|
{
|
|
if (null == _stringToTag) { PopulateLookups(); }
|
|
return _stringToTag.ContainsKey(s) ? _stringToTag[s] : Tags.Unknown;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// returns a version the tag was used in given a tag
|
|
/// </summary>
|
|
/// <param name="t"></param>
|
|
/// <returns></returns>
|
|
public static int GetVersionForTag(Tags t)
|
|
{
|
|
lock (MY_LOCK)
|
|
{
|
|
if (null == _tagToVersion) { PopulateLookups(); }
|
|
return _tagToVersion.ContainsKey(t) ? _tagToVersion[t] : int.MaxValue;
|
|
}
|
|
}
|
|
|
|
private static void PopulateLookups()
|
|
{
|
|
var lookup1 = new Dictionary<string, Tags>();
|
|
var lookup2 = new Dictionary<Tags, string>();
|
|
var lookup3 = new Dictionary<int, List<Tags>>();
|
|
var lookup4 = new Dictionary<Tags, int>();
|
|
|
|
var allTags = Enum.GetValues(typeof(Tags)).Cast<Tags>().ToArray();
|
|
foreach (var tag in allTags)
|
|
{
|
|
var s = TagToDisplayString(tag);
|
|
var version = TagToVersion(tag);
|
|
lookup1[s] = tag;
|
|
lookup2[tag] = s;
|
|
if(!lookup3.ContainsKey(version))
|
|
{
|
|
lookup3.Add(version, new List<Tags>());
|
|
}
|
|
lookup3[version].Add(tag);
|
|
lookup4[tag] = version;
|
|
}
|
|
lock (MY_LOCK)
|
|
{
|
|
_stringToTag = lookup1;
|
|
_tagToString = lookup2;
|
|
_versionToTags = lookup3;
|
|
_tagToVersion = lookup4;
|
|
}
|
|
}
|
|
public enum Tags
|
|
{
|
|
[Display(Name = "Database Reference Number")]
|
|
[Version(0)]
|
|
DatabaseReferenceNumber,
|
|
[Display(Name = "Sensor SN")]
|
|
[Version(0)]
|
|
SensorSN,
|
|
[Display(Name = "Channel Name")]
|
|
[Version(0)]
|
|
ChannelName,
|
|
[Display(Name = "Location")]
|
|
[Version(0)]
|
|
Location,
|
|
[Display(Name = "Laboratory Code")]
|
|
[Version(0)]
|
|
LaboratoryCode,
|
|
[Display(Name = "Customer Code")]
|
|
[Version(0)]
|
|
CustomerCode,
|
|
[Display(Name = "Partial ISO Code")]
|
|
[Version(0)]
|
|
PartialISOCode,
|
|
[Display(Name = "Comment Field")]
|
|
[Version(0)]
|
|
CommentField,
|
|
[Display(Name = "Sensor Type")]
|
|
[Version(0)]
|
|
SensorType,
|
|
[Display(Name = "Manufacturer")]
|
|
[Version(0)]
|
|
Manufacturer,
|
|
[Display(Name = "Model")]
|
|
[Version(0)]
|
|
Model,
|
|
[Display(Name = "Axis (X, Y, Z)")]
|
|
[Version(0)]
|
|
Axis,
|
|
[Display(Name = "Dimension")]
|
|
[Version(0)]
|
|
Dimension,
|
|
[Display(Name = "EU")]
|
|
[Version(0)]
|
|
EU,
|
|
[Display(Name = "Full Scale (EU)")]
|
|
[Version(0)]
|
|
FullScale,
|
|
[Display(Name = "Exc (VDC)")]
|
|
[Version(0)]
|
|
Exc,
|
|
[Display(Name = "Output @ EXC & FS (mV)")]
|
|
[Version(0)]
|
|
OutputAtEXCFSmV,
|
|
[Display(Name = "Sensitivity (mV/V/EU)")]
|
|
[Version(0)]
|
|
Sensitivity,
|
|
[Display(Name = "Output Proportional to EXC? (Yes, No)")]
|
|
[Version(0)]
|
|
Proportional,
|
|
[Display(Name = "Desired Range (EU)")]
|
|
[Version(0)]
|
|
DesiredRange,
|
|
[Display(Name = "BRIDGE (Full, Half)")]
|
|
[Version(0)]
|
|
BRIDGE,
|
|
[Display(Name = "Use Shunt Cal? (Yes, No)")]
|
|
[Version(0)]
|
|
UseShuntCal,
|
|
[Display(Name = "Bridge Res. (Ohm)")]
|
|
[Version(0)]
|
|
BridgeResistance,
|
|
[Display(Name = "Shunt Resistor Value (Ohms)")]
|
|
[Version(0)]
|
|
ShuntResistorValue,
|
|
[Display(Name = "Equivalent EU for Shunt Resistor")]
|
|
[Version(0)]
|
|
EquivalentEUShuntResistor,
|
|
[Display(Name = "Bypass AA Filter? (Yes, No)")]
|
|
[Version(0)]
|
|
BypassAAFilter,
|
|
[Display(Name = "Invert Signal? (Yes, No)")]
|
|
[Version(0)]
|
|
InvertSignal,
|
|
[Display(Name = "Remove Sensor Offset? (Yes, No)")]
|
|
[Version(0)]
|
|
RemoveOffset,
|
|
[Display(Name = "Sensor Offset Low (mV)")]
|
|
[Version(0)]
|
|
OffsetToleranceLow,
|
|
[Display(Name = "Sensor Offset High (mV)")]
|
|
[Version(0)]
|
|
OffsetToleranceHigh,
|
|
[Display(Name = "SAE Filter Class")]
|
|
[Version(0)]
|
|
FilterClass,
|
|
[Display(Name = "Software Zero Reference (Pre, Avg, 0mV)")]
|
|
[Version(0)]
|
|
SoftwareZeroReference,
|
|
[Display(Name = "Software Zero Equivalent EU")]
|
|
[Version(0)]
|
|
SoftwareZeroEquivalentEU,
|
|
[Display(Name = "16 Byte Dallas Sensor ID")]
|
|
[Version(0)]
|
|
SensorID,
|
|
[Display(Name = "Received")]
|
|
[Version(0)]
|
|
Received,
|
|
[Display(Name = "Last Cal")]
|
|
[Version(0)]
|
|
LastCal,
|
|
[Display(Name = "Due Cal")]
|
|
[Version(0)]
|
|
DueCal,
|
|
[Display(Name = "Due")]
|
|
[Version(0)]
|
|
Due,
|
|
[Display(Name = "Tech")]
|
|
[Version(0)]
|
|
Tech,
|
|
[Display(Name = "Group 1")]
|
|
[Version(0)]
|
|
Group1,
|
|
[Display(Name = "Group 2")]
|
|
[Version(0)]
|
|
Group2,
|
|
[Display(Name = "Group 3")]
|
|
[Version(0)]
|
|
Group3,
|
|
[Display(Name = "Group 4")]
|
|
[Version(0)]
|
|
Group4,
|
|
[Display(Name = "Group 5")]
|
|
[Version(0)]
|
|
Group5,
|
|
[Display(Name = "Category")]
|
|
[Version(0)]
|
|
Category,
|
|
[Display(Name = "IRTRACC Exponent")]
|
|
[Version(0)]
|
|
IRTRACCExponent,
|
|
[Display(Name = "unknown")]
|
|
[Version(0)]
|
|
Unknown,
|
|
[Display(Name = "Version")]
|
|
[Version(1)]
|
|
Version,
|
|
[Display(Name = "Test Setup Name")]
|
|
[Version(1)]
|
|
TestSetupName,
|
|
[Display(Name = "Test Setup Description")]
|
|
[Version(1)]
|
|
TestSetupDescription,
|
|
[Display(Name = "Recording Mode")]
|
|
[Version(1)]
|
|
RecordingMode,
|
|
[Display(Name = "SampleRate")]
|
|
[Version(1)]
|
|
SampleRate,
|
|
[Display(Name = "PreTriggerSec")]
|
|
[Version(1)]
|
|
PreTriggerSec,
|
|
[Display(Name = "PostTriggerSec")]
|
|
[Version(1)]
|
|
PostTriggerSec,
|
|
[Display(Name = "Tags")]
|
|
[Version(1)]
|
|
Tags,
|
|
[Display(Name = "Two Volt Exc.")]
|
|
[Version(2)]
|
|
TwoVoltExcSensitivity,
|
|
[Display(Name = "Five Volt Exc.")]
|
|
[Version(2)]
|
|
FiveVoltExcSensitivity,
|
|
[Display(Name = "Ten Volt Exc.")]
|
|
[Version(2)]
|
|
TenVoltExcSensitivity,
|
|
[Display(Name = "Range Low")]
|
|
[Version(2)]
|
|
RangeLow,
|
|
[Display(Name = "Range Medium")]
|
|
[Version(2)]
|
|
RangeMedium,
|
|
[Display(Name = "Range High")]
|
|
[Version(2)]
|
|
RangeHigh,
|
|
[Display(Name = "Supported Excitation")]
|
|
[Version(2)]
|
|
SupportedExcitation,
|
|
[Display(Name = "Bridge Type")]
|
|
[Version(2)]
|
|
BridgeType,
|
|
[Display(Name = "Unipolar")]
|
|
[Version(2)]
|
|
Unipolar,
|
|
[Display(Name = "Axis Number")]
|
|
[Version(2)]
|
|
AxisNumber,
|
|
[Display(Name = "Number of Axes")]
|
|
[Version(2)]
|
|
NumberOfAxes,
|
|
[Display(Name = "Cal Interval")]
|
|
[Version(2)]
|
|
CalInterval,
|
|
[Display(Name = "Polarity")]
|
|
[Version(2)]
|
|
Polarity,
|
|
[Display(Name = "Physical Dimension")]
|
|
[Version(2)]
|
|
PhysicalDimension,
|
|
[Display(Name = "Direction")]
|
|
[Version(2)]
|
|
Direction,
|
|
[Display(Name = "InitialOffset")]
|
|
[Version(2)]
|
|
InitialOffset,
|
|
[Display(Name = "NonLinear")]
|
|
[Version(2)]
|
|
NonLinear,
|
|
[Display(Name = "Software Zero Method")]
|
|
[Version(2)]
|
|
ZeroMethod,
|
|
[Display(Name = "Zero Averaging Window Start")]
|
|
[Version(2)]
|
|
ZeroMethodStart,
|
|
[Display(Name = "Zero Averaging Window End")]
|
|
[Version(2)]
|
|
ZeroMethodEnd,
|
|
[Display(Name = "Bridge Leg Mode")]
|
|
[Version(2)]
|
|
BridgeLegMode,
|
|
[Display(Name = "Created")]
|
|
[Version(2)]
|
|
Created,
|
|
[Display(Name = "Times Used")]
|
|
[Version(2)]
|
|
TimesUsed,
|
|
[Display(Name = "IEPE Coupling Mode")]
|
|
[Version(2)]
|
|
CouplingMode,
|
|
[Display(Name = "DelayMS")]
|
|
[Version(2)]
|
|
DelayMS,
|
|
[Display(Name = "DigitalOutputDelayMS")]
|
|
[Version(2)]
|
|
DigitalOutputDelayMS,
|
|
[Display(Name = "DurationMS")]
|
|
[Version(2)]
|
|
DurationMS,
|
|
[Display(Name = "DigitalOutputDurationMS")]
|
|
[Version(2)]
|
|
DigitalOutputDurationMS,
|
|
[Display(Name = "Digital Output Mode")]
|
|
[Version(2)]
|
|
DigitalOutputMode,
|
|
[Display(Name = "LimitDuration")]
|
|
[Version(2)]
|
|
LimitDuration,
|
|
[Display(Name = "Squib Fire Mode")]
|
|
[Version(2)]
|
|
SquibFireMode,
|
|
[Display(Name = "Squib Measurement Type")]
|
|
[Version(2)]
|
|
SquibMeasurementType,
|
|
[Display(Name = "Squib Output Current")]
|
|
[Version(2)]
|
|
SquibOutputCurrent,
|
|
[Display(Name = "Digital Scale Multiplier")]
|
|
[Version(2)]
|
|
DigitalScaleMultiplier,
|
|
[Display(Name = "Digital Input Mode")]
|
|
[Version(2)]
|
|
DigitalInputMode,
|
|
[Display(Name = "NonLinear Cal")]
|
|
[Version(2)]
|
|
NonLinearCalibration,
|
|
[Display(Name = "DisplayUnits")]
|
|
[Version(2)]
|
|
DisplayUnits,
|
|
[Display(Name = "At Capacity")]
|
|
[Version(2)]
|
|
AtCapacity,
|
|
[Display(Name = "Capacity Ouptut Is Based On")]
|
|
[Version(2)]
|
|
CapacityOutputIsBasedOn,
|
|
[Display(Name = "Sensitivity Units")]
|
|
[Version(2)]
|
|
SensitivityUnits,
|
|
[Display(Name = "CheckOffset")]
|
|
[Version(2)]
|
|
CheckOffset,
|
|
[Display(Name = "Broken")]
|
|
[Version(2)]
|
|
Broken,
|
|
[Display(Name = "Do Not Use")]
|
|
[Version(2)]
|
|
DoNotUse,
|
|
[Display(Name = "ISOChannelName")]
|
|
[Version(2)]
|
|
ISOChannelName,
|
|
[Display(Name = "UserCode")]
|
|
[Version(2)]
|
|
UserCode,
|
|
[Display(Name = "UserChannelName")]
|
|
[Version(2)]
|
|
UserChannelName,
|
|
[Display(Name = "Addl Linear Sensitivity")]
|
|
[Version(2)]
|
|
AdditionalLinearSensitivity,
|
|
[Display(Name = "Addl Linear Zero Method")]
|
|
[Version(2)]
|
|
AdditionalLinearZeroMethod,
|
|
[Display(Name = "Addl Linear Zero Method Start")]
|
|
[Version(2)]
|
|
AdditionalLinearZeroMethodStart,
|
|
[Display(Name = "Addl Linear Zero Method End")]
|
|
[Version(2)]
|
|
AdditionalLinearZeroMethodEnd,
|
|
[Display(Name = "Addl Initial Offsets")]
|
|
[Version(2)]
|
|
AdditionalInitialOffsets,
|
|
[Display(Name = "Group Name")]
|
|
[Version(3)]
|
|
GroupName,
|
|
[Display(Name = "Group Type")]
|
|
[Version(3)]
|
|
GroupType,
|
|
[Display(Name = "DAS serial number")]
|
|
[Version(4)]
|
|
DASSerialNumber,
|
|
[Display(Name = "DAS channel index")]
|
|
[Version(4)]
|
|
DASChannelIndex,
|
|
[Display(Name = "Stream profile")]
|
|
[Version(4)]
|
|
StreamProfile,
|
|
[Display(Name = "UDP address")]
|
|
[Version(4)]
|
|
UDPAddress,
|
|
[Display(Name = "Time channel Id")]
|
|
[Version(4)]
|
|
TimeChannelId,
|
|
[Display(Name = "Data channel Id")]
|
|
[Version(4)]
|
|
DataChannelId,
|
|
[Display(Name = "Stream output configuration")]
|
|
[Version(4)]
|
|
TmNSConfig,
|
|
[Display(Name = "IRIG time packet interval ms")]
|
|
[Version(4)]
|
|
IRIGTimeDataPacketIntervalMS,
|
|
[Display(Name = "TMATS packet interval ms")]
|
|
[Version(4)]
|
|
TMATSIntervalMS,
|
|
[Display(Name = "Baud rate")]
|
|
[Version(4)]
|
|
BaudRate,
|
|
[Display(Name = "Data bits")]
|
|
[Version(4)]
|
|
DataBits,
|
|
[Display(Name = "Stop bits")]
|
|
[Version(4)]
|
|
StopBits,
|
|
[Display(Name = "Parity")]
|
|
[Version(4)]
|
|
Parity,
|
|
[Display(Name = "Data format")]
|
|
[Version(4)]
|
|
DataFormat,
|
|
[Display(Name = "Test user code")]
|
|
[Version(4)]
|
|
TestUserCode,
|
|
[Display(Name = "Test user channel name")]
|
|
[Version(4)]
|
|
TestUserChannelName,
|
|
[Display(Name = "Test isocode")]
|
|
[Version(4)]
|
|
TestIsoCode,
|
|
[Display(Name = "Test iso channel name")]
|
|
[Version(4)]
|
|
TestIsoChannelName,
|
|
[Display(Name = "Clock master input type")]
|
|
[Version(5)]
|
|
ClockMasterInputType,
|
|
[Display(Name = "Clock master output type")]
|
|
[Version(5)]
|
|
ClockMasterOutputType,
|
|
[Display(Name = "Manage master clocks outside of DP")]
|
|
[Version(5)]
|
|
ManageClocksOutsideDPMaster,
|
|
[Display(Name = "Manage slave clocks outside of DP")]
|
|
[Version(5)]
|
|
ManageClocksOutsideDPSlave,
|
|
[Display(Name = "Clock slave input type")]
|
|
[Version(5)]
|
|
ClockSlaveInputType,
|
|
[Display(Name = "Clock slave output type")]
|
|
[Version(5)]
|
|
ClockSlaveOutputType,
|
|
[Display(Name = "DAS serial")]
|
|
[Version(6)]
|
|
DASSerial,
|
|
[Display(Name = "DAS sample rate")]
|
|
[Version(6)]
|
|
DASSampleRate,
|
|
[Display(Name = "PTP domain id")]
|
|
[Version(6)]
|
|
PTPDomainId,
|
|
[Display(Name = "Clock master")]
|
|
[Version(6)]
|
|
ClockMaster
|
|
}
|
|
}
|
|
}
|