396 lines
14 KiB
Plaintext
396 lines
14 KiB
Plaintext
using System;
|
||
using System.ComponentModel;
|
||
using System.ComponentModel.DataAnnotations;
|
||
using System.Linq;
|
||
using System.Text;
|
||
|
||
namespace IRIGCh10
|
||
{
|
||
public enum GeneralTags
|
||
{
|
||
[Description("PN")]
|
||
[MaxLength(16)]
|
||
ProgramName,
|
||
[Description("TA")]
|
||
[MaxLength(64)]
|
||
TestItem
|
||
}
|
||
public class GeneralInformationGroup : TMATSSection<GeneralTags>
|
||
{
|
||
/// <summary>
|
||
/// Name of program
|
||
/// </summary>
|
||
public string ProgramName
|
||
{
|
||
get => GetValue(GeneralTags.ProgramName);
|
||
set => SetValueWithLength(GeneralTags.ProgramName, value);
|
||
}
|
||
|
||
/// <summary>
|
||
/// TEST ITEM DESCRIPTION IN TERMS OF NAME, MODEL, PLATFORM, OR
|
||
/// IDENTIFICATION CODE, AS APPROPRIATE
|
||
/// </summary>
|
||
public string TestItem
|
||
{
|
||
get => GetValue(GeneralTags.TestItem);
|
||
set => SetValueWithLength(GeneralTags.TestItem, value);
|
||
}
|
||
|
||
/// <summary>
|
||
/// VERSION OF IRIG 106 STANDARD USED TO GENERATE THIS TMATS FILE
|
||
/// </summary>
|
||
public string IRIG106RevisionLevel
|
||
{
|
||
get => _information.GetValue(InformationTags.IRIG106RevisionLevel);
|
||
set => _information.SetValueWithLength(InformationTags.IRIG106RevisionLevel, value);
|
||
}
|
||
|
||
/// <summary>
|
||
/// DATE OF ORIGINATION OF THIS MISSION CONFIGURATION.
|
||
/// </summary>
|
||
public DateTime? OriginationDate
|
||
{
|
||
get => _information.GetDate(InformationTags.OriginationDate);
|
||
set => _information.SetDate(InformationTags.OriginationDate, value);
|
||
}
|
||
|
||
/// <summary>
|
||
/// REVISION NUMBER ASSOCIATED WITH THIS MISSION CONFIGURATION
|
||
/// </summary>
|
||
public string RevisionNumber
|
||
{
|
||
get => _information.GetValue(InformationTags.RevisionNumber);
|
||
set => _information.SetValueWithLength(InformationTags.RevisionNumber, value);
|
||
}
|
||
/// <summary>
|
||
/// DATE OF REVISION.
|
||
/// </summary>
|
||
public DateTime? RevisionDate
|
||
{
|
||
get => _information.GetDate(InformationTags.RevisionDate);
|
||
set => _information.SetDate(InformationTags.RevisionDate, value);
|
||
}
|
||
/// <summary>
|
||
/// UPDATE NUMBER OF CURRENT CHANGE WHICH HAS NOT BEEN INCORPORATED
|
||
/// AS A REVISION
|
||
/// </summary>
|
||
public string UpdateNumber
|
||
{
|
||
get => _information.GetValue(InformationTags.UpdateNumber);
|
||
set => _information.SetValueWithLength(InformationTags.UpdateNumber, value);
|
||
}
|
||
/// <summary>
|
||
/// DATE OF UPDATE.
|
||
/// </summary>
|
||
public DateTime? UpdateDate
|
||
{
|
||
get => _information.GetDate(InformationTags.UpdateDate);
|
||
set => _information.SetDate(InformationTags.UpdateDate, value);
|
||
}
|
||
/// <summary>
|
||
/// TEST IDENTIFICATION
|
||
/// </summary>
|
||
public string TestNumber
|
||
{
|
||
get => _information.GetValue(InformationTags.TestNumber);
|
||
set => _information.SetValue(InformationTags.TestNumber, value);
|
||
}
|
||
|
||
public int NumberOfPointsOfContact
|
||
{
|
||
get => _information.GetContactCount();
|
||
set => _information.SetContactCount(value);
|
||
}
|
||
/// <summary>
|
||
/// SPECIFY THE NUMBER OF DATA SOURCES: FOR RF TELEMETRY
|
||
/// SYSTEMS, GIVE THE NUMBER OF CARRIERS; FOR TAPE OR STORAGE
|
||
/// RECORDED DATA, IDENTIFY THE NUMBER OF TAPE OR STORAGE
|
||
/// SOURCES.
|
||
/// </summary>
|
||
public int NumberOfDataSources
|
||
{
|
||
get => _information.GetDataSourceCount();
|
||
set => _information.SetDataSourceCount(value);
|
||
}
|
||
/// <summary>
|
||
/// APPROXIMATE DURATION OF TEST IN HOURS.
|
||
/// </summary>
|
||
public string TestDuration
|
||
{
|
||
get => _information.GetValue(Information.TestInformationTags.TestDuration);
|
||
set => _information.SetValue(Information.TestInformationTags.TestDuration, value);
|
||
}
|
||
/// <summary>
|
||
/// INDICATE WHETHER A PRE-TEST REQUIREMENT IS APPLICABLE (‘Y’ OR
|
||
/// ‘N’). PROVIDE DETAILS IN COMMENTS RECORD.
|
||
/// </summary>
|
||
public bool PreTestRequirement
|
||
{
|
||
get
|
||
{
|
||
var val = _information.GetValue(Information.TestInformationTags.PreTestRequirement);
|
||
if (string.IsNullOrWhiteSpace(val)) { return false; }
|
||
if (val == "Y") { return true; }
|
||
return false;
|
||
}
|
||
set => _information.SetValue(Information.TestInformationTags.PreTestRequirement, value ? "Y" : "N");
|
||
}
|
||
/// <summary>
|
||
/// INDICATE WHETHER A PRE-TEST REQUIREMENT IS APPLICABLE (‘Y’ OR
|
||
/// ‘N’). PROVIDE DETAILS IN COMMENTS RECORD.
|
||
/// </summary>
|
||
public bool PostTestRequirement
|
||
{
|
||
get
|
||
{
|
||
var val = _information.GetValue(Information.TestInformationTags.PostTestRequirement);
|
||
if (string.IsNullOrWhiteSpace(val)) { return false; }
|
||
if (val == "Y") { return true; }
|
||
return false;
|
||
}
|
||
set => _information.SetValue(Information.TestInformationTags.PostTestRequirement, value ? "Y" : "N");
|
||
}
|
||
|
||
public void SetDataSourceField(int number, Information.DataSourceIdentificationTags tag,
|
||
string value)
|
||
{
|
||
_information.SetDataSourceField(number, tag, value);
|
||
}
|
||
|
||
public void SetDataSourceType(int number, Information.DataSourceTypes sourceType)
|
||
{
|
||
_information.SetDataSourceType(number, sourceType);
|
||
}
|
||
public SecurityClassifications SecurityClassification
|
||
{
|
||
get
|
||
{
|
||
var val = _securitySection.GetValue(SecurityTags.SecurityClassification);
|
||
if (string.IsNullOrWhiteSpace(val))
|
||
{
|
||
return SecurityClassifications.Unclassified;
|
||
}
|
||
|
||
var classes = Enum.GetValues(typeof(SecurityClassifications))
|
||
.Cast<SecurityClassifications>().ToArray();
|
||
foreach (var item in classes)
|
||
{
|
||
if (DescriptionDecoder.GetDescription(item) == val)
|
||
{
|
||
return item;
|
||
}
|
||
}
|
||
return SecurityClassifications.Unclassified;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// PROVIDE THE ADDITIONAL INFORMATION REQUESTED OR ANY OTHER INFORMATION DESIRED.
|
||
/// </summary>
|
||
public string Comments
|
||
{
|
||
get => _comments.GetValue(CommentTags.Comments);
|
||
set => _comments.SetValueWithLength(CommentTags.Comments, value);
|
||
}
|
||
|
||
#region infrastructure
|
||
|
||
public override string Serialize()
|
||
{
|
||
var sb = new StringBuilder();
|
||
sb.Append(_information.Serialize());
|
||
|
||
sb.Append(base.Serialize());
|
||
return sb.ToString();
|
||
}
|
||
private CommentSection _comments = new CommentSection();
|
||
public class CommentSection : TMATSSection<CommentTags>
|
||
{
|
||
}
|
||
public enum CommentTags
|
||
{
|
||
[Description("COM")]
|
||
[MaxLength(1600)]
|
||
Comments
|
||
}
|
||
public enum SecurityClassifications
|
||
{
|
||
[Description("U")]
|
||
Unclassified,
|
||
[Description("C")]
|
||
Confidential,
|
||
[Description("S")]
|
||
Secret,
|
||
[Description("T")]
|
||
TopSecret,
|
||
[Description("O")]
|
||
Other
|
||
}
|
||
public enum SecurityTags
|
||
{
|
||
[Description("SC")]
|
||
[MaxLength(1)]
|
||
SecurityClassification
|
||
}
|
||
|
||
public class SecuritySection : TMATSSection<SecurityTags>
|
||
{
|
||
}
|
||
private SecuritySection _securitySection = new SecuritySection();
|
||
|
||
private Information _information = new Information();
|
||
|
||
public enum InformationTags
|
||
{
|
||
[Description("106")]
|
||
[MaxLength(2)]
|
||
IRIG106RevisionLevel,
|
||
[Description("OD")]
|
||
[MaxLength(10)]
|
||
OriginationDate,
|
||
[Description("RN")]
|
||
[MaxLength(4)]
|
||
RevisionNumber,
|
||
[Description("RD")]
|
||
[MaxLength(10)]
|
||
RevisionDate,
|
||
[Description("UN")]
|
||
[MaxLength(2)]
|
||
UpdateNumber,
|
||
[Description("UD")]
|
||
[MaxLength(10)]
|
||
UpdateDate,
|
||
[MaxLength(16)]
|
||
[Description("TN")]
|
||
TestNumber
|
||
}
|
||
public class Information : TMATSSection<InformationTags>
|
||
{
|
||
#region Contacts
|
||
public int GetContactCount()
|
||
{
|
||
return _contacts.GetCount();
|
||
}
|
||
|
||
public void SetContactCount(int count)
|
||
{
|
||
_contacts.SetCount(count);
|
||
}
|
||
|
||
public void SetContactField(int number, PointOfContactTags tag, string value) => _contacts.SetValue(number, tag, value);
|
||
public string GetContactField(int number, PointOfContactTags tag) => _contacts.GetValue(number, tag);
|
||
|
||
public enum PointOfContactTags
|
||
{
|
||
[Description("POC1-")]
|
||
[MaxLength(24)]
|
||
Name,
|
||
[Description("POC2-")]
|
||
[MaxLength(48)]
|
||
Agency,
|
||
[Description("POC3-")]
|
||
[MaxLength(48)]
|
||
Address,
|
||
[Description("POC4-")]
|
||
[MaxLength(20)]
|
||
Telephone
|
||
}
|
||
|
||
private TMATSectionNumberedArray<PointOfContactTags> _contacts =
|
||
new TMATSectionNumberedArray<PointOfContactTags>("POC\\N", 9);
|
||
#endregion Contacts
|
||
|
||
#region DataSourceIdentification
|
||
|
||
public int GetDataSourceCount() => _datasources.GetCount();
|
||
public void SetDataSourceCount(int value) => _datasources.SetCount(value);
|
||
|
||
public void SetDataSourceField(int number, DataSourceIdentificationTags tag,
|
||
string value)
|
||
{
|
||
if (tag == DataSourceIdentificationTags.DataSourceID)
|
||
{
|
||
//must be unique
|
||
for (var i = 1; i < _datasources.GetCount(); i++)
|
||
{
|
||
if( i == number ){ continue; }
|
||
|
||
if (_datasources.GetValue(number, tag) == value)
|
||
{
|
||
throw new Exception($"Datasource ID must be unique");
|
||
}
|
||
}
|
||
}
|
||
_datasources.SetValue(number, tag, value);
|
||
}
|
||
|
||
public void SetDataSourceType(int number, DataSourceTypes type)
|
||
{
|
||
SetDataSourceField(number, DataSourceIdentificationTags.DataSourceType,
|
||
DescriptionDecoder.GetDescription(type));
|
||
}
|
||
|
||
public string GetDataSourceField(int number, DataSourceIdentificationTags tag) =>
|
||
_datasources.GetValue(number, tag);
|
||
public enum DataSourceIdentificationTags
|
||
{
|
||
[MaxLength(32)]
|
||
[Description("DSI-")]
|
||
DataSourceID,
|
||
[MaxLength(3)]
|
||
[Description("DST-")]
|
||
DataSourceType
|
||
}
|
||
|
||
public enum DataSourceTypes
|
||
{
|
||
[Description("RF")]
|
||
RF,
|
||
[Description("STO")]
|
||
Storage,
|
||
[Description("TAP")]
|
||
Tape,
|
||
[Description("OTH")]
|
||
Other
|
||
}
|
||
private TMATSectionNumberedArray<DataSourceIdentificationTags> _datasources =
|
||
new TMATSectionNumberedArray<DataSourceIdentificationTags>("DSI\\N");
|
||
|
||
#endregion
|
||
|
||
public enum TestInformationTags
|
||
{
|
||
[Description("TI1")]
|
||
[MaxLength(4)]
|
||
TestDuration,
|
||
[Description("TI2")]
|
||
[MaxLength(1)]
|
||
PreTestRequirement,
|
||
[Description("TI3")]
|
||
[MaxLength(1)]
|
||
PostTestRequirement
|
||
}
|
||
|
||
public class TestInformation : TMATSSection<TestInformationTags>
|
||
{
|
||
}
|
||
|
||
private TestInformation _testInformation = new TestInformation();
|
||
|
||
public void SetValue(TestInformationTags tag, string value) => _testInformation.SetValueWithLength(tag, value);
|
||
|
||
public string GetValue(TestInformationTags tag) => _testInformation.GetValue(tag);
|
||
|
||
public override string Serialize()
|
||
{
|
||
var sb = new StringBuilder();
|
||
sb.Append(base.Serialize());
|
||
sb.Append(_contacts.Serialize());
|
||
sb.Append(_datasources.Serialize());
|
||
sb.Append(_testInformation.Serialize());
|
||
return sb.ToString();
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
}
|