/* * 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 { /// /// Representation of an ISO file test object. /// public class Object : Exceptional { /// /// Get/set this ISO file test object's comment . /// public string[] Comments { get => _Comments.Value; set => _Comments.Value = value; } private readonly Property _Comments = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.Comments", null, false ); /// /// Get/set this ISO file test object's name . /// public string Name { get => _Name.Value; set => _Name.Value = value; } private const string NameLabel = "Name of test object #"; private readonly Property _Name = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.Name", null, false ); /// /// Get/set this ISO file test object's type . /// public string Type { get => _Type.Value; set => _Type.Value = value; } private const string TypeLabel = "Type of test object #"; private readonly Property _Type = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.Type", null, false ); /// /// Get/set this ISO file test object's number . /// public string Number { get => _Number.Value; set => _Number.Value = value; } private const string NumberLabel = "Ref. number of test object #"; private readonly Property _Number = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.Number", null, false ); /// /// Get/set this ISO file test object's number . /// public int MmeNumber { get => _MmeNumber.Value; set => _MmeNumber.Value = value; } private readonly Property _MmeNumber = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.MmeNumber", -1, false ); /// /// Get/set this ISO file test object's velocity value. /// public string Velocity { get => _Velocity.Value; set => _Velocity.Value = value; } private const string VelocityLabel = "Velocity test object #"; private readonly Property _Velocity = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.Velocity", "0.0", false ); /// /// Get/set this ISO file test object's mass value. /// public string Mass { get => _Mass.Value; set => _Mass.Value = value; } private const string MassLabel = "Mass test object #"; private readonly Property _Mass = new Property( 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 _TestObject = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.TestObject", "", false ); /// /// Get/set this ISO file test object's position code. /// public string Position { get => _Position.Value; set => _Position.Value = value; } private const string PositionLabel = "Driver position object #"; private readonly Property _Position = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.Position", "?", false ); /// /// Get/set this ISO file test object's impact side representation. /// public string TestObjectImpactSide { get => _TestObjectImpactSide.Value; set => _TestObjectImpactSide.Value = value; } private const string TestObjectImpactSideLabel = "Impact side test object #"; private readonly Property _TestObjectImpactSide = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.ImpactSide", null, false ); /// /// Get/set this ISO file test object's class . /// public string Class { get => _Class.Value; set => _Class.Value = value; } private const string ClassLabel = "Class of test object #"; private readonly Property _Class = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.Class", null, false ); /// /// Get/set this ISO file's test object code . /// public string Code { get => _Code.Value; set => _Code.Value = value; } private const string CodeLabel = "Code of test object #"; private readonly Property _Code = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.Code", null, false ); /// /// Get/set this ISO file's test object offset . /// public string Offset { get => _Offset.Value; set => _Offset.Value = value; } private const string OffsetLabel = ".Offset #"; private readonly Property _Offset = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.Offset", null, false ); /// /// Get/set this ISO file's test object barrier width . /// public string BarrierWidth { get => _BarrierWidth.Value; set => _BarrierWidth.Value = value; } private const string BarrierWidthLabel = ".Barrier width #"; private readonly Property _BarrierWidth = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.BarrierWidth", null, false ); /// /// Get/set this ISO file's test object barrier height . /// public string BarrierHeight { get => _BarrierHeight.Value; set => _BarrierHeight.Value = value; } private const string BarrierHeightLabel = ".Barrier height #"; private readonly Property _BarrierHeight = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.BarrierHeight", null, false ); /// /// Get/set this ISO file's test object yaw angle . /// public string YawAngle { get => _YawAngle.Value; set => _YawAngle.Value = value; } private const string YawAngleLabel = ".Yaw angle #"; private readonly Property _YawAngle = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.YawAngle", null, false ); /// /// Get/set this ISO file's test object reference system . /// public string ReferenceSystem { get => _ReferenceSystem.Value; set => _ReferenceSystem.Value = value; } private const string ReferenceSystemLabel = ".Reference system #"; private readonly Property _ReferenceSystem = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.ReferenceSystem", null, false ); /// /// Get/set this ISO file's test object Origin X . /// public string OriginX { get => _OriginX.Value; set => _OriginX.Value = value; } private const string OriginXLabel = ".Origin X #"; private readonly Property _OriginX = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.OriginX", null, false ); /// /// Get/set this ISO file's test object Origin Y . /// public string OriginY { get => _OriginY.Value; set => _OriginY.Value = value; } private const string OriginYLabel = ".Origin Y #"; private readonly Property _OriginY = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.OriginY", null, false ); /// /// Get/set this ISO file's test object Origin Z . /// public string OriginZ { get => _OriginZ.Value; set => _OriginZ.Value = value; } private const string OriginZLabel = ".Origin Z #"; private readonly Property _OriginZ = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.OriginZ", null, false ); /// /// Get/set this ISO file's test object Number of Loadcells . /// public string NumberOfLoadcells { get => _NumberOfLoadcells.Value; set => _NumberOfLoadcells.Value = value; } private const string NumberOfLoadcellsLabel = ".Number of loadcells #"; private readonly Property _NumberOfLoadcells = new Property( typeof(File).Namespace + ".Iso.File.Test.Object.NumberOfLoadcells", null, false ); /// /// Get/set the list of s for this test. /// public List ExtraProperties { get => _ExtraProperties.Value; set => _ExtraProperties.Value = value; } private readonly Property> _ExtraProperties = new Property>( typeof(File).Namespace + ".Iso.File.Test.Object.ExtraProperties", new List(), true ); /// /// Generate a string representation for this object. /// /// /// /// A representation of this object. /// /// 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); } } } } } }