init
This commit is contained in:
@@ -0,0 +1,302 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class TestObjectMetaData
|
||||
{
|
||||
public static double Version { get; set; } = 1.06;
|
||||
public const string NOVALUE = "NOVALUE";
|
||||
|
||||
public void SetProperty(MetaData meta)
|
||||
{
|
||||
_properties[meta.Name] = meta;
|
||||
}
|
||||
public MetaData GetProperty(string name)
|
||||
{
|
||||
return _properties.ContainsKey(name) ? _properties[name] : new MetaData(name, true, NOVALUE, Version);
|
||||
}
|
||||
public string GetPropertyValue(CommentFields field)
|
||||
{
|
||||
return GetProperty(field.ToString()).Value;
|
||||
}
|
||||
public string GetPropertyValue(Fields field)
|
||||
{
|
||||
return GetProperty(field.ToString()).Value;
|
||||
}
|
||||
public string GetPropertyValue(OptionFields field)
|
||||
{
|
||||
return GetProperty(field.ToString()).Value;
|
||||
}
|
||||
public void SetPropertyValue(CommentFields field, string value)
|
||||
{
|
||||
GetProperty(field.ToString()).Value = value;
|
||||
}
|
||||
public void SetPropertyValue(Fields field, string value)
|
||||
{
|
||||
GetProperty(field.ToString()).Value = value;
|
||||
}
|
||||
public void SetPropertyValue(string field, string value)
|
||||
{
|
||||
GetProperty(field).Value = value;
|
||||
}
|
||||
public void SetPropertyValue(OptionFields field, string value)
|
||||
{
|
||||
GetProperty(field.ToString()).Value = value;
|
||||
}
|
||||
public enum CommentFields
|
||||
{
|
||||
Comment1,
|
||||
Comment2,
|
||||
Comment3,
|
||||
}
|
||||
public enum Fields
|
||||
{
|
||||
NameOfTestObject,
|
||||
VelocityOfTestObject,
|
||||
MassOfTestObject,
|
||||
DriverPositionObject,
|
||||
ImpactSideTestObject,
|
||||
TypeOfTestObject,
|
||||
ClassOfTestObject,
|
||||
CodeOfTestObject,
|
||||
RefNumberOfTestObject,
|
||||
TestObjectComments,
|
||||
VelocityMeasurementUnit,
|
||||
ExtraProperties
|
||||
}
|
||||
public enum OptionFields
|
||||
{
|
||||
Offset,
|
||||
BarrierWidth,
|
||||
BarrierHeight,
|
||||
YawAngle,
|
||||
ReferenceSystem,
|
||||
OriginX,
|
||||
OriginY,
|
||||
OriginZ,
|
||||
NumberOfLoadCells
|
||||
}
|
||||
private readonly Dictionary<string, MetaData> _properties = new Dictionary<string, MetaData>();
|
||||
|
||||
public TestObjectMetaData(char testobject, int testObjectNumber)
|
||||
{
|
||||
TestObject = testobject;
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
var optional = Enum.GetValues(typeof(OptionFields)).Cast<OptionFields>().ToArray();
|
||||
_properties.Add(CommentFields.Comment1.ToString(), new MetaData(CommentFields.Comment1.ToString(), false, string.Empty, Version));
|
||||
_properties.Add(CommentFields.Comment2.ToString(), new MetaData(CommentFields.Comment2.ToString(), false, $" The following block describes test object '{testobject}'", Version));
|
||||
_properties.Add(CommentFields.Comment3.ToString(), new MetaData(CommentFields.Comment3.ToString(), false, string.Empty, Version));
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case Fields.VelocityOfTestObject:
|
||||
case Fields.MassOfTestObject:
|
||||
case Fields.ImpactSideTestObject:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, string.Empty, Version));
|
||||
break;
|
||||
default:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, NOVALUE, Version));
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (var ofield in optional)
|
||||
{
|
||||
_properties.Add(ofield.ToString(), new MetaData(ofield.ToString(), true, NOVALUE, Version));
|
||||
}
|
||||
}
|
||||
public TestObjectMetaData(char testobject)
|
||||
{
|
||||
TestObject = testobject;
|
||||
var comments = Enum.GetValues(typeof(CommentFields)).Cast<CommentFields>().ToArray();
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
var optional = Enum.GetValues(typeof(OptionFields)).Cast<OptionFields>().ToArray();
|
||||
foreach (var cfield in comments) { _properties.Add(cfield.ToString(), new MetaData(cfield.ToString(), false, NOVALUE, Version)); }
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case Fields.VelocityOfTestObject:
|
||||
case Fields.MassOfTestObject:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, string.Empty, Version));
|
||||
break;
|
||||
default:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, NOVALUE, Version));
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (var ofield in optional)
|
||||
{
|
||||
_properties.Add(ofield.ToString(), new MetaData(ofield.ToString(), true, NOVALUE, Version));
|
||||
}
|
||||
}
|
||||
public TestObjectMetaData(TestObjectMetaData copy)
|
||||
{
|
||||
TestObject = copy.TestObject;
|
||||
foreach (var p in copy._properties)
|
||||
{
|
||||
_properties.Add(p.Key, new MetaData(p.Value));
|
||||
}
|
||||
}
|
||||
|
||||
public TestObjectMetaData(char newTestObject, TestObjectMetaData copy)
|
||||
{
|
||||
TestObject = newTestObject;
|
||||
foreach (var p in copy._properties)
|
||||
{
|
||||
_properties.Add(p.Key, new MetaData(p.Value));
|
||||
}
|
||||
}
|
||||
|
||||
public char TestObject { get; } = '?';
|
||||
|
||||
public MetaData[] Properties => _properties.Values.ToArray();
|
||||
}
|
||||
public class MetaData
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public bool IsOptional { get; } = false;
|
||||
|
||||
public double Version { get; } = 1.06D;
|
||||
|
||||
public string Value { get; set; } = "NOVALUE";
|
||||
|
||||
public MetaData(string name, bool optional, string value, double version)
|
||||
{
|
||||
Name = name;
|
||||
IsOptional = optional;
|
||||
Value = value;
|
||||
Version = version;
|
||||
}
|
||||
public MetaData(MetaData copy)
|
||||
{
|
||||
Name = copy.Name;
|
||||
IsOptional = copy.IsOptional;
|
||||
Value = copy.Value;
|
||||
Version = copy.Version;
|
||||
}
|
||||
}
|
||||
public class TestSetupMetaData
|
||||
{
|
||||
public double Version { get; set; } = 1.06;
|
||||
public const string NOVALUE = "NOVALUE";
|
||||
public const string MEDIADEFAULT = "1/1";
|
||||
|
||||
public void SetProperty(MetaData meta, bool requireXCrashCompatibilityForISOExports)
|
||||
{
|
||||
switch (meta.Name)
|
||||
{
|
||||
case "LaboratoryName":
|
||||
case "LaboratoryContactName":
|
||||
case "LaboratoryTestReferenceNumber":
|
||||
case "CustomerName":
|
||||
case "CustomerTestReferenceNumber":
|
||||
if ((meta.Value == NOVALUE) && requireXCrashCompatibilityForISOExports)
|
||||
{
|
||||
meta.Value = string.Empty;
|
||||
}
|
||||
break;
|
||||
}
|
||||
_properties[meta.Name] = meta;
|
||||
}
|
||||
public MetaData GetProperty(string name)
|
||||
{
|
||||
if (_properties.ContainsKey(name)) { return _properties[name]; }
|
||||
else { return new MetaData(name, true, NOVALUE, Version); }
|
||||
}
|
||||
public string GetPropertyValue(Fields field)
|
||||
{
|
||||
return GetProperty(field.ToString()).Value;
|
||||
}
|
||||
public void SetPropertyValue(Fields field, string value)
|
||||
{
|
||||
GetProperty(field.ToString()).Value = value;
|
||||
}
|
||||
public enum Fields
|
||||
{
|
||||
LabName,
|
||||
LaboratoryContactName,
|
||||
LaboratoryContactPhone,
|
||||
LaboratoryContactFax,
|
||||
LaboratoryContactEmail,
|
||||
LaboratoryName,
|
||||
LaboratoryTestReferenceNumber,
|
||||
LaboratoryProjectReferenceNumber,
|
||||
|
||||
CustName,
|
||||
CustomerName,
|
||||
CustomerTestReferenceNumber,
|
||||
CustomerProjectReferenceNumber,
|
||||
CustomerOrderNumber,
|
||||
CustomerCostUnit,
|
||||
|
||||
TEName,
|
||||
TestEngineerName,
|
||||
TestEngineerPhone,
|
||||
TestEngineerFax,
|
||||
TestEngineerEmail,
|
||||
|
||||
Title,
|
||||
MediumNoNumberOfMedia,
|
||||
TestComment,
|
||||
TypeOfTheTest,
|
||||
ReferenceTemperature,
|
||||
RelativeAirHumidity,
|
||||
Regulation,
|
||||
Subtype,
|
||||
DateOfTheTest
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, MetaData> _properties = new Dictionary<string, MetaData>();
|
||||
public TestSetupMetaData(bool requireXCrashCompatibilityForISOExports)
|
||||
{
|
||||
TestObject = '_';
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case Fields.MediumNoNumberOfMedia:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, MEDIADEFAULT, Version));
|
||||
break;
|
||||
case Fields.LaboratoryName:
|
||||
case Fields.LaboratoryContactName:
|
||||
case Fields.LaboratoryTestReferenceNumber:
|
||||
case Fields.CustomerName:
|
||||
case Fields.CustomerTestReferenceNumber:
|
||||
if (requireXCrashCompatibilityForISOExports)
|
||||
{
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, string.Empty, Version));
|
||||
}
|
||||
else
|
||||
{
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, NOVALUE, Version));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, NOVALUE, Version));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Clear()
|
||||
{
|
||||
_properties.Clear();
|
||||
}
|
||||
public TestSetupMetaData(TestSetupMetaData copy)
|
||||
{
|
||||
TestObject = copy.TestObject;
|
||||
foreach (var p in copy._properties)
|
||||
{
|
||||
_properties.Add(p.Key, new MetaData(p.Value));
|
||||
}
|
||||
}
|
||||
|
||||
public char TestObject { get; } = '_';
|
||||
|
||||
public MetaData[] Properties => _properties.Values.ToArray();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Reference in New Issue
Block a user