194 lines
6.8 KiB
Plaintext
194 lines
6.8 KiB
Plaintext
using IRIGCh10;
|
||
using System;
|
||
using System.ComponentModel;
|
||
using System.ComponentModel.DataAnnotations;
|
||
|
||
namespace DTS.Serialization.IRIGCH10.TMATS.DataConversion
|
||
{
|
||
public enum TransducerInformation
|
||
{
|
||
[Description("DCN")] [MaxLength(32)] MeasurementName,
|
||
[Description("TRD1")] [MaxLength(32)] Type,
|
||
[Description("TRD2")] [MaxLength(32)] ModelNumber,
|
||
[Description("TRD3")] [MaxLength(32)] SerialNumber,
|
||
[Description("TRD4")] [MaxLength(2)] SecurityClassification,
|
||
[Description("TRD5")] [MaxLength(10)] OriginationDate,
|
||
[Description("TRD6")] [MaxLength(4)] RevisionNumber,
|
||
[MaxLength(32)] [Description("TRD7")] Orientation,
|
||
[MaxLength(24)] [Description("POC1")] PointOfContactName,
|
||
[MaxLength(48)] [Description("POC2")] PointOfContactAgency,
|
||
[MaxLength(48)] [Description("POC3")] PointOfContectAddress,
|
||
[MaxLength(20)] [Description("POC4")] PointOfContactTelephone,
|
||
}
|
||
|
||
public enum ClassificationTypes
|
||
{
|
||
[Description("U")] Unclassified,
|
||
[Description("C")] Confidential,
|
||
[Description("S")] Secret,
|
||
[Description("T")] TopSecret,
|
||
[Description("O")] Other
|
||
}
|
||
/// <summary>
|
||
/// this class handles the transducer information section of the TMAT packet (see chapter 9.pdf)
|
||
/// </summary>
|
||
public class TransducerInformationSection : TMATSSection<TransducerInformation>
|
||
{
|
||
public TransducerInformationSection(int number) : base(AttributeIdentifiers.DataConversionAttributes, number)
|
||
{
|
||
}
|
||
|
||
/// <summary>
|
||
/// GIVE THE MEASUREMENT NAME.
|
||
/// </summary>
|
||
public string MeasurementName
|
||
{
|
||
get => GetValue(TransducerInformation.MeasurementName);
|
||
set => SetValueWithLength(TransducerInformation.MeasurementName, value);
|
||
}
|
||
|
||
/// <summary>
|
||
/// TYPE OF SENSOR, IF APPROPRIATE
|
||
/// </summary>
|
||
public string Type
|
||
{
|
||
get => GetValue(TransducerInformation.Type);
|
||
set => SetValueWithLength(TransducerInformation.Type, value);
|
||
}
|
||
/// <summary>
|
||
/// IF APPROPRIATE
|
||
/// </summary>
|
||
public string ModelNumber
|
||
{
|
||
get => GetValue(TransducerInformation.ModelNumber);
|
||
set => SetValueWithLength(TransducerInformation.ModelNumber, value);
|
||
}
|
||
/// <summary>
|
||
/// IF APPLICABLE
|
||
/// </summary>
|
||
public string SerialNumber
|
||
{
|
||
get => GetValue(TransducerInformation.SerialNumber);
|
||
set => SetValueWithLength(TransducerInformation.SerialNumber, value);
|
||
}
|
||
/// <summary>
|
||
/// ENTER THE SECURITY CLASSIFICATION OF THIS MEASURAND.
|
||
/// </summary>
|
||
/// <param name="type"></param>
|
||
/// <param name="signalClassified"></param>
|
||
/// <param name="measurandClassified"></param>
|
||
public void SetSecurityClassification(ClassificationTypes type,
|
||
bool signalClassified, bool measurandClassified)
|
||
{
|
||
var val = DescriptionDecoder.GetDescription(type);
|
||
if (signalClassified && measurandClassified)
|
||
{
|
||
val = $"{val}B";
|
||
}
|
||
else if (signalClassified)
|
||
{
|
||
val = $"{val}R";
|
||
}
|
||
else if (measurandClassified)
|
||
{
|
||
val = $"{val}E";
|
||
}
|
||
|
||
SetValueWithLength(TransducerInformation.SecurityClassification, val);
|
||
}
|
||
/// <summary>
|
||
/// DATE OF ORIGINATION OF THIS DATA FILE. DD – DAY MM – MONTH
|
||
/// YYYY – YEAR (MM-DD-YYYY)
|
||
/// </summary>
|
||
public DateTime? OriginationDate
|
||
{
|
||
get
|
||
{
|
||
var val = GetValue(TransducerInformation.OriginationDate);
|
||
if (string.IsNullOrWhiteSpace(val))
|
||
{
|
||
return null;
|
||
}
|
||
|
||
if (DateTime.TryParse(val, out var dt))
|
||
{
|
||
return dt;
|
||
}
|
||
|
||
return null;
|
||
}
|
||
set
|
||
{
|
||
if (null == value)
|
||
{
|
||
SetValueWithLength(TransducerInformation.OriginationDate, string.Empty);
|
||
}
|
||
else
|
||
{
|
||
var dt = (DateTime) value;
|
||
SetValueWithLength(TransducerInformation.OriginationDate,
|
||
$"{dt.Month:00}-{dt.Day:00}-{dt.Year:0000}");
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// SPECIFY THE REVISION NUMBER OF THE DATA PROVIDED.
|
||
/// </summary>
|
||
public string RevisionNumber
|
||
{
|
||
get => GetValue(TransducerInformation.RevisionNumber);
|
||
set => SetValueWithLength(TransducerInformation.RevisionNumber, value);
|
||
}
|
||
/// <summary>
|
||
/// DESCRIBE THE PHYSICAL ORIENTATION OF THE SENSOR.
|
||
/// </summary>
|
||
public string Orientation
|
||
{
|
||
get => GetValue(TransducerInformation.Orientation);
|
||
set => SetValueWithLength(TransducerInformation.Orientation, value);
|
||
}
|
||
/// <summary>
|
||
/// POINT OF CONTACT WITH THE ORGANIZATION THAT PROVIDED THE CALIBRATION DATA
|
||
/// </summary>
|
||
public POC PointOfContact
|
||
{
|
||
get => new POC()
|
||
{
|
||
Name = GetValue(TransducerInformation.PointOfContactName),
|
||
Agency = GetValue(TransducerInformation.PointOfContactAgency),
|
||
Address = GetValue(TransducerInformation.PointOfContectAddress),
|
||
Telephone = GetValue(TransducerInformation.PointOfContectAddress)
|
||
};
|
||
set
|
||
{
|
||
SetValueWithLength(TransducerInformation.PointOfContactName, value.Name);
|
||
SetValueWithLength(TransducerInformation.PointOfContactAgency, value.Agency);
|
||
SetValueWithLength(TransducerInformation.PointOfContectAddress, value.Address);
|
||
SetValueWithLength(TransducerInformation.PointOfContactTelephone, value.Telephone);
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// Point Of Contact structure
|
||
/// </summary>
|
||
public class POC
|
||
{
|
||
public string Name { get; set; }
|
||
public string Agency { get; set; }
|
||
public string Address { get; set; }
|
||
public string Telephone { get; set; }
|
||
|
||
public POC(string name, string agency, string address, string telephone)
|
||
{
|
||
Name = name;
|
||
Agency = agency;
|
||
Address = address;
|
||
Telephone = telephone;
|
||
}
|
||
|
||
public POC()
|
||
{
|
||
}
|
||
}
|
||
}
|