init
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Serialization
|
||||
{
|
||||
//[Serializable]
|
||||
public partial class TestSetup : Exceptional
|
||||
{
|
||||
public partial class TestObject : Exceptional
|
||||
{
|
||||
public partial class TOChannel : Exceptional
|
||||
{
|
||||
public TOChannel()
|
||||
{
|
||||
_name.Value = null;
|
||||
_sensorName.Value = null;
|
||||
_version.Value = "1.0.0.0";
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name.Value;
|
||||
set => _name.Value = value;
|
||||
}
|
||||
private readonly Property<string> _name
|
||||
= new Property<string>(typeof(TOChannel).Namespace + ".Channel.Name", "", false);
|
||||
|
||||
public string SensorName
|
||||
{
|
||||
get => _sensorName.Value;
|
||||
set => _sensorName.Value = value;
|
||||
}
|
||||
private readonly Property<string> _sensorName
|
||||
= new Property<string>(typeof(TOChannel).Namespace + ".Channel.SensorName", "", false);
|
||||
|
||||
public string Version
|
||||
{
|
||||
get => _version.Value;
|
||||
set => _version.Value = value;
|
||||
}
|
||||
private readonly Property<string> _version
|
||||
= new Property<string>(typeof(TOChannel).Namespace + ".Channel.Version", "", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using DTS.Serialization.IRIGCH10.Enums;
|
||||
using DTS.Serialization.IRIGCH10.Packets;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Serialization.IRIGCH10
|
||||
{
|
||||
/// <summary>
|
||||
/// the TMATS packet in the ch10 file is
|
||||
/// a packet containing the setup file, a description of
|
||||
/// what channels, das, time formats, etc are used in the file
|
||||
/// </summary>
|
||||
public class TMATSPacket : AbstractDataPacket, IDataPacket
|
||||
{
|
||||
/// <summary>
|
||||
/// whether the TMATS is in XML or ASCII format
|
||||
/// </summary>
|
||||
public bool XMLFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
var b = new BitArray(BitConverter.GetBytes(ChannelSpecificDataWord));
|
||||
return b.Get(9);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// whether the setup record has changed or not
|
||||
/// </summary>
|
||||
public bool SetupRecordConfigurationChange
|
||||
{
|
||||
get
|
||||
{
|
||||
var b = new BitArray(BitConverter.GetBytes(ChannelSpecificDataWord));
|
||||
return b.Get(8);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// the chapter 10 version of the TMATS file
|
||||
/// </summary>
|
||||
public RCCChapter10Versions Chapter10Version
|
||||
{
|
||||
get
|
||||
{
|
||||
var b = new BitArray(BitConverter.GetBytes(ChannelSpecificDataWord));
|
||||
var ver = Utils.Utils.BitArrayToInt32(b, 0, 7);
|
||||
switch (ver)
|
||||
{
|
||||
case 0x07: return RCCChapter10Versions.RCC_106_07;
|
||||
case 0x08: return RCCChapter10Versions.RCC_106_09;
|
||||
case 0x09: return RCCChapter10Versions.RCC_106_11;
|
||||
case 0x0A: return RCCChapter10Versions.RCC_106_13;
|
||||
case 0x0B: return RCCChapter10Versions.RCC_106_15;
|
||||
default: return RCCChapter10Versions.RESERVED;
|
||||
}
|
||||
}
|
||||
}
|
||||
public enum RCCChapter10Versions
|
||||
{
|
||||
RESERVED,
|
||||
RCC_106_07,
|
||||
RCC_106_09,
|
||||
RCC_106_11,
|
||||
RCC_106_13,
|
||||
RCC_106_15
|
||||
}
|
||||
private const byte DataVersionNoSecondaryHeader = 0x01;
|
||||
private const byte DataVersionSecondaryHeader = 0x09;
|
||||
public TMATSPacket(int nanoseconds, int seconds, string tmatsDoc, bool secondaryHeaderPresent)
|
||||
: base(DataFileDataTypes.ComputerGeneratedDataFormat1, secondaryHeaderPresent)
|
||||
{
|
||||
var tmatsBytes = Encoding.ASCII.GetBytes(tmatsDoc);
|
||||
var dataLength = Convert.ToUInt32(4 + tmatsBytes.Length); ;
|
||||
var offset = CommonHeaderWork(0, secondaryHeaderPresent ? DataVersionSecondaryHeader : DataVersionNoSecondaryHeader,
|
||||
1, BASE_RTC, dataLength, nanoseconds, seconds);
|
||||
Buffer.BlockCopy(tmatsBytes, 0, _dataBytes, offset, tmatsBytes.Length);
|
||||
}
|
||||
|
||||
public TMATSPacket(byte[] bytes) : base(bytes)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// the TMATS document
|
||||
/// </summary>
|
||||
public string TMATSDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
//the document is prepended by a ChannelSpecificDataWord and potentially a time header
|
||||
var prepend = 4; //CSDW
|
||||
if (PacketHeader.SecondaryHeaderPresent) { prepend += SecondaryTimeFormatHeader.SECONDARY_TIME_HEADER_LENGTH; }
|
||||
var length = PacketHeader.DataLength - prepend;
|
||||
var bytes = new byte[length];
|
||||
Buffer.BlockCopy(_dataBytes, prepend, bytes, 0, bytes.Length);
|
||||
return Encoding.ASCII.GetString(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user