532 lines
16 KiB
Plaintext
532 lines
16 KiB
Plaintext
using System;
|
||
using System.ComponentModel;
|
||
using System.ComponentModel.DataAnnotations;
|
||
using System.Linq;
|
||
using System.Text;
|
||
|
||
namespace IRIGCh10
|
||
{
|
||
public enum PCMCodes
|
||
{
|
||
[Description("NRZ-L")]
|
||
NRZL,
|
||
[Description("NRZ-M")]
|
||
NRZM,
|
||
[Description("NRZ-S")]
|
||
NRZS,
|
||
[Description("BIO-L")]
|
||
BIOL,
|
||
[Description("BIO-M")]
|
||
BIOM,
|
||
[Description("BIO-S")]
|
||
BIOS,
|
||
[Description("RNRZ-L")]
|
||
RNRZL,
|
||
[Description("OTHER")]
|
||
Other
|
||
}
|
||
|
||
public enum Polarities
|
||
{
|
||
[Description("N")]
|
||
Normal,
|
||
[Description("I")]
|
||
Inverted
|
||
}
|
||
|
||
public enum PCMDataDirections
|
||
{
|
||
[Description("N")]
|
||
Normal,
|
||
[Description("R")]
|
||
Reversed
|
||
}
|
||
public enum PCMAttributes
|
||
{
|
||
[Description("DLN")]
|
||
[MaxLength(32)]
|
||
DataLinkName,
|
||
[MaxLength(6)]
|
||
[Description("D1")]
|
||
PCMCode,
|
||
[Description("D2")]
|
||
[MaxLength(9)]
|
||
Bitrate,
|
||
[Description("D3")]
|
||
Encrypted,
|
||
[Description("D4")]
|
||
[MaxLength(1)]
|
||
Polarity,
|
||
[Description("D5")]
|
||
AutoPolarityCorrection,
|
||
[Description("D6")]
|
||
DataDirection,
|
||
[Description("D7")]
|
||
DataRandomized,
|
||
[MaxLength(1)]
|
||
[Description("D8")]
|
||
RandomizerLength
|
||
}
|
||
|
||
public class PCM : TMATSSection<PCMAttributes>
|
||
{
|
||
/// <summary>
|
||
/// IDENTIFY THE DATA LINK NAME CONSISTENT WITH THE MUX/MOD
|
||
/// GROUP.
|
||
/// </summary>
|
||
public string DataLinkName
|
||
{
|
||
get => GetValue(PCMAttributes.DataLinkName);
|
||
set => SetValueWithLength(PCMAttributes.DataLinkName, value);
|
||
}
|
||
|
||
/// <summary>
|
||
/// DEFINE THE DATA FORMAT CODE:
|
||
/// </summary>
|
||
public PCMCodes? PCMCode
|
||
{
|
||
get
|
||
{
|
||
var val = GetValue(PCMAttributes.PCMCode);
|
||
if (string.IsNullOrWhiteSpace(val))
|
||
{
|
||
return null;
|
||
}
|
||
|
||
var codes = Enum.GetValues(typeof(PCMCodes))
|
||
.Cast<PCMCodes>().ToArray();
|
||
foreach (var code in codes)
|
||
{
|
||
if (DescriptionDecoder.GetDescription(code) == val)
|
||
{
|
||
return code;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
set
|
||
{
|
||
if (null == value)
|
||
{
|
||
SetValueWithLength(PCMAttributes.PCMCode, string.Empty);
|
||
}
|
||
else
|
||
{
|
||
SetValueWithLength(PCMAttributes.PCMCode,
|
||
DescriptionDecoder.GetDescription(value));
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// DATA RATE IN BITS PER SECOND. SCIENTIFIC NOTATION MAY BE
|
||
/// USED.
|
||
/// </summary>
|
||
public string BitsPerSecond
|
||
{
|
||
get => GetValue(PCMAttributes.Bitrate);
|
||
set => SetValueWithLength(PCMAttributes.Bitrate, value);
|
||
}
|
||
/// <summary>
|
||
/// DATA RANDOMIZED
|
||
/// </summary>
|
||
public bool DataRandomized
|
||
{
|
||
get
|
||
{
|
||
var val = GetValue(PCMAttributes.DataRandomized);
|
||
if( string.IsNullOrWhiteSpace(val) ){ return false; }
|
||
if( val == "N" ){ return false; }
|
||
return true;
|
||
}
|
||
set { SetValueWithLength(PCMAttributes.DataRandomized, value ? "Y" : "N"); }
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// DATA POLARITY:
|
||
/// </summary>
|
||
public Polarities Polarity
|
||
{
|
||
get
|
||
{
|
||
var val = GetValue(PCMAttributes.Polarity);
|
||
if (string.IsNullOrWhiteSpace(val))
|
||
{
|
||
return Polarities.Normal;
|
||
}
|
||
return val == "I" ? Polarities.Inverted : Polarities.Normal;
|
||
}
|
||
set
|
||
{
|
||
SetValueWithLength(PCMAttributes.Polarity,
|
||
DescriptionDecoder.GetDescription(value));
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// TIME SEQUENCE OF DATA:
|
||
/// </summary>
|
||
public PCMDataDirections DataDirection
|
||
{
|
||
get
|
||
{
|
||
var val = GetValue(PCMAttributes.DataDirection);
|
||
if (string.IsNullOrWhiteSpace(val))
|
||
{
|
||
return PCMDataDirections.Normal;
|
||
}
|
||
|
||
return val == "R" ? PCMDataDirections.Reversed : PCMDataDirections.Normal;
|
||
}
|
||
set
|
||
{
|
||
SetValueWithLength(PCMAttributes.DataDirection,
|
||
DescriptionDecoder.GetDescription(value));
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// TYPE OF PCM FORMAT: CLASS I - ‘ONE’ CLASS II – ‘TWO’
|
||
/// 1553 BUS - ‘1553’ BUS – ‘BUS’ ALTERNATE TAG AND DATA-‘ALTD’
|
||
/// PACKET TELEMETRY – ‘PKTM’ OTHER - ‘OTHR’, DESCRIBE IN
|
||
/// COMMENTS RECORD.
|
||
/// </summary>
|
||
public PCMTypeFormats TypeFormat
|
||
{
|
||
get
|
||
{
|
||
var val = _typeFormat.GetValue(TypeFormatTags.TypeFormat);
|
||
if (string.IsNullOrWhiteSpace(val))
|
||
{
|
||
return PCMTypeFormats.Other;
|
||
}
|
||
var formats = Enum.GetValues(typeof(PCMTypeFormats))
|
||
.Cast<PCMTypeFormats>().ToArray();
|
||
foreach (var format in formats)
|
||
{
|
||
if (DescriptionDecoder.GetDescription(format) == val)
|
||
{
|
||
return format;
|
||
}
|
||
}
|
||
|
||
return PCMTypeFormats.Other;
|
||
}
|
||
set
|
||
{
|
||
_typeFormat.SetValueWithLength(TypeFormatTags.TypeFormat,
|
||
DescriptionDecoder.GetDescription(value));
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// NUMBER OF BITS IN COMMON WORD LENGTH
|
||
/// </summary>
|
||
public ushort NumberOfBitsInCommonWordLength
|
||
{
|
||
get
|
||
{
|
||
var val = _typeFormat.GetValue(TypeFormatTags.CommonWordLength);
|
||
if (string.IsNullOrWhiteSpace(val))
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
if (ushort.TryParse(val, out var uTmp))
|
||
{
|
||
return uTmp;
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
set
|
||
{
|
||
_typeFormat.SetValueWithLength(TypeFormatTags.CommonWordLength,
|
||
value.ToString());
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// DEFINE THE DEFAULT FOR THE FIRST BIT TRANSFERRED IN
|
||
/// NORMAL TIME SEQUENCE:
|
||
/// </summary>
|
||
public PCMWordTransferOrders WordTransferOrder
|
||
{
|
||
get
|
||
{
|
||
var val = _typeFormat.GetValue(TypeFormatTags.WordTransferOrder);
|
||
if (string.IsNullOrWhiteSpace(val))
|
||
{
|
||
return PCMWordTransferOrders.MostSignificantBit;
|
||
}
|
||
|
||
var orders = Enum.GetValues(typeof(PCMWordTransferOrders))
|
||
.Cast<PCMWordTransferOrders>().ToArray();
|
||
foreach (var order in orders)
|
||
{
|
||
if (DescriptionDecoder.GetDescription(order) == val)
|
||
{
|
||
return order;
|
||
}
|
||
}
|
||
return PCMWordTransferOrders.MostSignificantBit;
|
||
}
|
||
set => _typeFormat.SetValueWithLength(TypeFormatTags.WordTransferOrder,
|
||
DescriptionDecoder.GetDescription(value));
|
||
}
|
||
|
||
public PCMWordParities PCMWordParity
|
||
{
|
||
get
|
||
{
|
||
var value = _typeFormat.GetValue(TypeFormatTags.Parity);
|
||
if (string.IsNullOrWhiteSpace(value))
|
||
{
|
||
return PCMWordParities.None;
|
||
}
|
||
|
||
var parities = Enum.GetValues(typeof(PCMWordParities)).Cast<PCMWordParities>().ToArray();
|
||
foreach (var parity in parities)
|
||
{
|
||
if( DescriptionDecoder.GetDescription(parity) == value){ return parity; }
|
||
}
|
||
|
||
return PCMWordParities.None;
|
||
}
|
||
set => _typeFormat.SetValueWithLength(TypeFormatTags.Parity,
|
||
DescriptionDecoder.GetDescription(value));
|
||
}
|
||
|
||
private PCMTypeFormat _typeFormat;
|
||
|
||
public override string Serialize()
|
||
{
|
||
var sb = new StringBuilder();
|
||
sb.Append(_typeFormat.Serialize());
|
||
sb.Append(base.Serialize());
|
||
return sb.ToString();
|
||
}
|
||
public PCM(int number) : base(AttributeIdentifiers.PCMFormatAttributes, number)
|
||
{
|
||
_typeFormat = new PCMTypeFormat(number);
|
||
}
|
||
}
|
||
|
||
public enum PCMWordTransferOrders
|
||
{
|
||
[Description("M")]
|
||
MostSignificantBit,
|
||
[Description("L")]
|
||
LeastSignificantBit
|
||
}
|
||
|
||
public enum PCMWordParities
|
||
{
|
||
[Description("EV")]
|
||
Even,
|
||
[Description("OD")]
|
||
Odd,
|
||
[Description("NO")]
|
||
None
|
||
}
|
||
public enum TypeFormatTags
|
||
{
|
||
[Description("TF")]
|
||
[MaxLength(4)]
|
||
TypeFormat,
|
||
[Description("F1")]
|
||
[MaxLength(2)]
|
||
CommonWordLength,
|
||
[Description("F2")]
|
||
[MaxLength(1)]
|
||
WordTransferOrder,
|
||
[Description("F3")]
|
||
Parity,
|
||
[Description("F4")]
|
||
ParityTransferOrder
|
||
}
|
||
|
||
public enum PCMTypeFormats
|
||
{
|
||
[Description("ONE")]
|
||
ClassI,
|
||
[Description("TWO")]
|
||
ClassII,
|
||
[Description("1553")]
|
||
Bus1553,
|
||
[Description("BUS")]
|
||
Bus,
|
||
[Description("ALTD")]
|
||
AlternateTagAndData,
|
||
[Description("PKTM")]
|
||
PacketTelemetry,
|
||
[Description("OTHR")]
|
||
Other
|
||
}
|
||
public class PCMTypeFormat : TMATSSection<TypeFormatTags>
|
||
{
|
||
public PCMTypeFormat(int number) : base(AttributeIdentifiers.PCMFormatAttributes,
|
||
number)
|
||
{
|
||
}
|
||
}
|
||
public enum MinorFrameTags
|
||
{
|
||
[Description("MF\\N")]
|
||
[MaxLength(3)]
|
||
NumberOfMinorFramesInMajorFrame,
|
||
[Description("MF1")]
|
||
[MaxLength(4)]
|
||
NumberOfWordsInMinorFrame,
|
||
[Description("MF2")]
|
||
[MaxLength(5)]
|
||
NumberOfBitsInMinorFrame,
|
||
[Description("MF3")]
|
||
[MaxLength(3)]
|
||
SyncType,
|
||
[MaxLength(2)]
|
||
[Description("MF4")]
|
||
SyncLength,
|
||
[MaxLength(33)]
|
||
[Description("MF5")]
|
||
SyncPattern
|
||
}
|
||
|
||
public class MinorFrameSection : TMATSSection<MinorFrameTags>
|
||
{
|
||
public ushort NumberOfMinorFramesInAMajorFrame
|
||
{
|
||
get
|
||
{
|
||
var value = GetValue(MinorFrameTags.NumberOfMinorFramesInMajorFrame);
|
||
if (string.IsNullOrWhiteSpace(value))
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
if (ushort.TryParse(value, out var s))
|
||
{
|
||
return s;
|
||
}
|
||
return 0;
|
||
}
|
||
set => SetValueWithLength(MinorFrameTags.NumberOfMinorFramesInMajorFrame, value.ToString());
|
||
}
|
||
/// <summary>
|
||
/// SPECIFIES THE NUMBER OF WORDS IN A MINOR FRAME, AS DEFINED IN
|
||
/// CHAPTER 4, PARAGRAPH 4.3. (THE MINOR FRAME SYNCHRONIZATION
|
||
/// PATTERN IS ALWAYS CONSIDERED AS ONE WORD, REGARDLESS OF ITS
|
||
/// LENGTH.)
|
||
/// </summary>
|
||
public int NumberOfWordsInMinorFrame
|
||
{
|
||
get
|
||
{
|
||
var val = GetValue(MinorFrameTags.NumberOfWordsInMinorFrame);
|
||
if (string.IsNullOrWhiteSpace(val))
|
||
{
|
||
return 0;
|
||
}
|
||
if( int.TryParse( val, out var iTmp)){ return iTmp; }
|
||
return 0;
|
||
}
|
||
set => SetValueWithLength(MinorFrameTags.NumberOfWordsInMinorFrame, value.ToString());
|
||
}
|
||
|
||
/// <summary>
|
||
/// NUMBER OF BITS IN A MINOR FRAME INCLUDING MINOR FRAME
|
||
/// SYNCHRONIZATION PATTERN
|
||
/// </summary>
|
||
public int NumberOfBitsInMinorFrame
|
||
{
|
||
get
|
||
{
|
||
var val = GetValue(MinorFrameTags.NumberOfBitsInMinorFrame);
|
||
if (string.IsNullOrEmpty(val))
|
||
{
|
||
return 0;
|
||
}
|
||
if( int.TryParse( val, out var iTmp)){ return iTmp; }
|
||
return 0;
|
||
}
|
||
set => SetValueWithLength(MinorFrameTags.NumberOfBitsInMinorFrame,
|
||
value.ToString());
|
||
}
|
||
/// <summary>
|
||
/// SPECIFY THE MINOR FRAME SYNCHRONIZATION PATTERN LENGTH
|
||
/// IN NUMBER OF BITS.
|
||
/// </summary>
|
||
public ushort SyncLength
|
||
{
|
||
get
|
||
{
|
||
var val = GetValue(MinorFrameTags.SyncLength);
|
||
if (string.IsNullOrWhiteSpace(val))
|
||
{
|
||
return 0;
|
||
}
|
||
if( ushort.TryParse( val, out var s)){ return s; }
|
||
|
||
return 0;
|
||
}
|
||
set => SetValueWithLength(MinorFrameTags.SyncLength, value.ToString());
|
||
}
|
||
/// <summary>
|
||
/// DEFINE MINOR FRAME SYNCHRONIZATION PATTERN IN BITS
|
||
/// (“1”s and “0”s) WITH THE LEFT MOST BIT
|
||
/// AS THE “FIRST BIT TRANSMITTED”
|
||
/// </summary>
|
||
public string SynchronizationPattern
|
||
{
|
||
get => GetValue(MinorFrameTags.SyncPattern);
|
||
set => SetValueWithLength(MinorFrameTags.SyncPattern, value);
|
||
}
|
||
|
||
public MinorFrameSection(int number=1) : base(AttributeIdentifiers.PCMFormatAttributes, number)
|
||
{
|
||
}
|
||
}
|
||
public enum SynchronizationCriteriaTags
|
||
{
|
||
[Description("SYNC1")]
|
||
InSyncCriteria,
|
||
[Description("SYNC2")]
|
||
InSyncSyncPatternCriteria,
|
||
[Description("SYNC3")]
|
||
NumberOfDisagrees,
|
||
[Description("SYNC4")]
|
||
OutOfSyncSyncPatternCriteria
|
||
}
|
||
|
||
public enum MinorFrameFormatTags
|
||
{
|
||
[Description("MFW1-")]
|
||
WordNumber,
|
||
[Description("MFW2-")]
|
||
NumberOfBitsInWord
|
||
}
|
||
|
||
public enum SubFrameSynchronizationTags
|
||
{
|
||
SubframeIDCounterName,
|
||
SubframeSyncType,
|
||
SubFrameIDCounterLocation,
|
||
IDCounterWordLength,
|
||
IDCounterMSBStartingBitLocation,
|
||
IDCounterLength,
|
||
IDCounterTransferOrder,
|
||
IDCounterInitialValue,
|
||
InitialCountSubframeNumber,
|
||
IDCounterEndValue,
|
||
EndCountSubframeNumber,
|
||
CountDirection
|
||
}
|
||
|
||
public enum SubFrameDefinitionTags
|
||
{
|
||
SubFrameName,
|
||
SuperCom,
|
||
LocationDefinition,
|
||
SubframeLocation,
|
||
Interval,
|
||
SubframeDepth
|
||
}
|
||
}
|