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 } /// /// this class handles the transducer information section of the TMAT packet (see chapter 9.pdf) /// public class TransducerInformationSection : TMATSSection { public TransducerInformationSection(int number) : base(AttributeIdentifiers.DataConversionAttributes, number) { } /// /// GIVE THE MEASUREMENT NAME. /// public string MeasurementName { get => GetValue(TransducerInformation.MeasurementName); set => SetValueWithLength(TransducerInformation.MeasurementName, value); } /// /// TYPE OF SENSOR, IF APPROPRIATE /// public string Type { get => GetValue(TransducerInformation.Type); set => SetValueWithLength(TransducerInformation.Type, value); } /// /// IF APPROPRIATE /// public string ModelNumber { get => GetValue(TransducerInformation.ModelNumber); set => SetValueWithLength(TransducerInformation.ModelNumber, value); } /// /// IF APPLICABLE /// public string SerialNumber { get => GetValue(TransducerInformation.SerialNumber); set => SetValueWithLength(TransducerInformation.SerialNumber, value); } /// /// ENTER THE SECURITY CLASSIFICATION OF THIS MEASURAND. /// /// /// /// 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); } /// /// DATE OF ORIGINATION OF THIS DATA FILE. DD – DAY MM – MONTH /// YYYY – YEAR (MM-DD-YYYY) /// 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}"); } } } /// /// SPECIFY THE REVISION NUMBER OF THE DATA PROVIDED. /// public string RevisionNumber { get => GetValue(TransducerInformation.RevisionNumber); set => SetValueWithLength(TransducerInformation.RevisionNumber, value); } /// /// DESCRIBE THE PHYSICAL ORIENTATION OF THE SENSOR. /// public string Orientation { get => GetValue(TransducerInformation.Orientation); set => SetValueWithLength(TransducerInformation.Orientation, value); } /// /// POINT OF CONTACT WITH THE ORGANIZATION THAT PROVIDED THE CALIBRATION DATA /// 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); } } } /// /// Point Of Contact structure /// 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() { } } }