Files
DP44/Common/DTS.Common.Serialization/Iso/Iso.File.Test.Object.cs
2026-04-17 14:55:32 -04:00

441 lines
21 KiB
C#

/*
* Iso.File.Test.Object.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTS.Common.Utilities;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
namespace DTS.Serialization.Iso
{
// *** see Iso.File.cs ***
public partial class File
{
// *** see Iso.File.Test.cs ***
public partial class Test
{
/// <summary>
/// Representation of an ISO file test object.
/// </summary>
public class Object : Exceptional
{
/// <summary>
/// Get/set this ISO file test object's comment <see cref="string"/>.
/// </summary>
public string[] Comments
{
get => _Comments.Value;
set => _Comments.Value = value;
}
private readonly Property<string[]> _Comments
= new Property<string[]>(
typeof(File).Namespace + ".Iso.File.Test.Object.Comments",
null,
false
);
/// <summary>
/// Get/set this ISO file test object's name <see cref="int"/>.
/// </summary>
public string Name
{
get => _Name.Value;
set => _Name.Value = value;
}
private const string NameLabel = "Name of test object #";
private readonly Property<string> _Name
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.Name",
null,
false
);
/// <summary>
/// Get/set this ISO file test object's type <see cref="int"/>.
/// </summary>
public string Type
{
get => _Type.Value;
set => _Type.Value = value;
}
private const string TypeLabel = "Type of test object #";
private readonly Property<string> _Type
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.Type",
null,
false
);
/// <summary>
/// Get/set this ISO file test object's number <see cref="string"/>.
/// </summary>
public string Number
{
get => _Number.Value;
set => _Number.Value = value;
}
private const string NumberLabel = "Ref. number of test object #";
private readonly Property<string> _Number
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.Number",
null,
false
);
/// <summary>
/// Get/set this ISO file test object's number <see cref="string"/>.
/// </summary>
public int MmeNumber
{
get => _MmeNumber.Value;
set => _MmeNumber.Value = value;
}
private readonly Property<int> _MmeNumber
= new Property<int>(
typeof(File).Namespace + ".Iso.File.Test.Object.MmeNumber",
-1,
false
);
/// <summary>
/// Get/set this ISO file test object's <see cref="double"/> velocity value.
/// </summary>
public string Velocity
{
get => _Velocity.Value;
set => _Velocity.Value = value;
}
private const string VelocityLabel = "Velocity test object #";
private readonly Property<string> _Velocity
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.Velocity",
"0.0",
false
);
/// <summary>
/// Get/set this ISO file test object's <see cref="double"/> mass value.
/// </summary>
public string Mass
{
get => _Mass.Value;
set => _Mass.Value = value;
}
private const string MassLabel = "Mass test object #";
private readonly Property<string> _Mass
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.Mass",
"",
false
);
public string TestObject
{
get => _TestObject.Value;
set => _TestObject.Value = value;
}
private const string TestObjectLabel = "Test Object #";
private readonly Property<string> _TestObject =
new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.TestObject",
"",
false
);
/// <summary>
/// Get/set this ISO file test object's <see cref="int"/> position code.
/// </summary>
public string Position
{
get => _Position.Value;
set => _Position.Value = value;
}
private const string PositionLabel = "Driver position object #";
private readonly Property<string> _Position
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.Position",
"?",
false
);
/// <summary>
/// Get/set this ISO file test object's impact side <see cref="string"/> representation.
/// </summary>
public string TestObjectImpactSide
{
get => _TestObjectImpactSide.Value;
set => _TestObjectImpactSide.Value = value;
}
private const string TestObjectImpactSideLabel = "Impact side test object #";
private readonly Property<string> _TestObjectImpactSide
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.ImpactSide",
null,
false
);
/// <summary>
/// Get/set this ISO file test object's class <see cref="string"/>.
/// </summary>
public string Class
{
get => _Class.Value;
set => _Class.Value = value;
}
private const string ClassLabel = "Class of test object #";
private readonly Property<string> _Class
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.Class",
null,
false
);
/// <summary>
/// Get/set this ISO file's test object code <see cref="string"/>.
/// </summary>
public string Code
{
get => _Code.Value;
set => _Code.Value = value;
}
private const string CodeLabel = "Code of test object #";
private readonly Property<string> _Code
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.Code",
null,
false
);
/// <summary>
/// Get/set this ISO file's test object offset <see cref="string"/>.
/// </summary>
public string Offset
{
get => _Offset.Value;
set => _Offset.Value = value;
}
private const string OffsetLabel = ".Offset #";
private readonly Property<string> _Offset
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.Offset",
null,
false
);
/// <summary>
/// Get/set this ISO file's test object barrier width <see cref="string"/>.
/// </summary>
public string BarrierWidth
{
get => _BarrierWidth.Value;
set => _BarrierWidth.Value = value;
}
private const string BarrierWidthLabel = ".Barrier width #";
private readonly Property<string> _BarrierWidth
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.BarrierWidth",
null,
false
);
/// <summary>
/// Get/set this ISO file's test object barrier height <see cref="string"/>.
/// </summary>
public string BarrierHeight
{
get => _BarrierHeight.Value;
set => _BarrierHeight.Value = value;
}
private const string BarrierHeightLabel = ".Barrier height #";
private readonly Property<string> _BarrierHeight
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.BarrierHeight",
null,
false
);
/// <summary>
/// Get/set this ISO file's test object yaw angle <see cref="string"/>.
/// </summary>
public string YawAngle
{
get => _YawAngle.Value;
set => _YawAngle.Value = value;
}
private const string YawAngleLabel = ".Yaw angle #";
private readonly Property<string> _YawAngle
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.YawAngle",
null,
false
);
/// <summary>
/// Get/set this ISO file's test object reference system <see cref="string"/>.
/// </summary>
public string ReferenceSystem
{
get => _ReferenceSystem.Value;
set => _ReferenceSystem.Value = value;
}
private const string ReferenceSystemLabel = ".Reference system #";
private readonly Property<string> _ReferenceSystem
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.ReferenceSystem",
null,
false
);
/// <summary>
/// Get/set this ISO file's test object Origin X <see cref="string"/>.
/// </summary>
public string OriginX
{
get => _OriginX.Value;
set => _OriginX.Value = value;
}
private const string OriginXLabel = ".Origin X #";
private readonly Property<string> _OriginX
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.OriginX",
null,
false
);
/// <summary>
/// Get/set this ISO file's test object Origin Y <see cref="string"/>.
/// </summary>
public string OriginY
{
get => _OriginY.Value;
set => _OriginY.Value = value;
}
private const string OriginYLabel = ".Origin Y #";
private readonly Property<string> _OriginY
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.OriginY",
null,
false
);
/// <summary>
/// Get/set this ISO file's test object Origin Z <see cref="string"/>.
/// </summary>
public string OriginZ
{
get => _OriginZ.Value;
set => _OriginZ.Value = value;
}
private const string OriginZLabel = ".Origin Z #";
private readonly Property<string> _OriginZ
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.OriginZ",
null,
false
);
/// <summary>
/// Get/set this ISO file's test object Number of Loadcells <see cref="string"/>.
/// </summary>
public string NumberOfLoadcells
{
get => _NumberOfLoadcells.Value;
set => _NumberOfLoadcells.Value = value;
}
private const string NumberOfLoadcellsLabel = ".Number of loadcells #";
private readonly Property<string> _NumberOfLoadcells
= new Property<string>(
typeof(File).Namespace + ".Iso.File.Test.Object.NumberOfLoadcells",
null,
false
);
/// <summary>
/// Get/set the list of <see cref="ExtraProperty"/>s for this test.
/// </summary>
public List<ExtraProperty> ExtraProperties
{
get => _ExtraProperties.Value;
set => _ExtraProperties.Value = value;
}
private readonly Property<List<ExtraProperty>> _ExtraProperties
= new Property<List<ExtraProperty>>(
typeof(File).Namespace + ".Iso.File.Test.Object.ExtraProperties",
new List<ExtraProperty>(),
true
);
/// <summary>
/// Generate a string representation for this object.
/// </summary>
///
/// <returns>
/// A <see cref="string"/> representation of this object.
/// </returns>
///
public override string ToString()
{
try
{
var builder = new StringBuilder();
string line = null;
var PositionCode = Position;
var TestObjectImpactSideCode = TestObjectImpactSide;
if (Position.ToUpper() != "NOVALUE")
{
PositionCode = Position.Substring(0, Position.IndexOf('-') - 1);
}
if ((TestObjectImpactSide.ToUpper() != "NOVALUE") && (TestObjectImpactSide != string.Empty))
{
TestObjectImpactSideCode = TestObjectImpactSide.Substring(0, TestObjectImpactSide.IndexOf('-') - 1);
}
foreach (var comment in Comments)
{
builder.Append(CommentsLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = comment) + (null != line ? Eol : ""));
}
if (Comments.Any() && (Comments.Last() != string.Empty))
{
builder.Append(CommentsLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = string.Empty) + (null != line ? Eol : ""));
}
builder.Append(NameLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Name)) + (null != line ? Eol : ""));
builder.Append(VelocityLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Velocity)) + (null != line ? Eol : ""));
builder.Append(MassLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Mass)) + (null != line ? Eol : ""));
builder.Append(PositionLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => PositionCode)) + (null != line ? Eol : ""));
builder.Append(TestObjectImpactSideLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => TestObjectImpactSideCode)) + (null != line ? Eol : ""));
builder.Append(TypeLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Type)) + (null != line ? Eol : ""));
builder.Append(ClassLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Class)) + (null != line ? Eol : ""));
builder.Append(CodeLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Code)) + (null != line ? Eol : ""));
builder.Append(NumberLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Number)) + (null != line ? Eol : ""));
builder.Append(OffsetLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => Offset)) + (null != line ? Eol : ""));
if (Type == "B")
{
builder.Append(BarrierWidthLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => BarrierWidth)) + (null != line ? Eol : ""));
builder.Append(BarrierHeightLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => BarrierHeight)) + (null != line ? Eol : ""));
builder.Append(YawAngleLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => YawAngle)) + (null != line ? Eol : ""));
builder.Append(ReferenceSystemLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => ReferenceSystem)) + (null != line ? Eol : ""));
builder.Append(OriginXLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => OriginX)) + (null != line ? Eol : ""));
builder.Append(OriginYLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => OriginY)) + (null != line ? Eol : ""));
builder.Append(OriginZLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => OriginZ)) + (null != line ? Eol : ""));
builder.Append(NumberOfLoadcellsLabel.Replace("#", MmeNumber.ToString()).PadRight(SeparatorOffset) + Separator + (line = GetFieldString(() => NumberOfLoadcells)) + (null != line ? Eol : ""));
}
return builder.ToString();
}
catch (System.Exception ex)
{
throw new Exception("encountered problem generating string representation for " + GetType().FullName, ex);
}
}
}
}
}
}