init
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class Tags
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// represents a single tag, which is composed of an ID and a string of text
|
||||
/// we don't currently let you obsolete, delete, or edit tags, just add
|
||||
/// </summary>
|
||||
public class Tag : ICloneable
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Text { get; set; }
|
||||
public bool IsObsolete { get; set; }
|
||||
public Tag(Tag copy)
|
||||
{
|
||||
ID = copy.ID;
|
||||
Text = copy.Text;
|
||||
IsObsolete = copy.IsObsolete;
|
||||
}
|
||||
|
||||
public Tag(IDataRecord reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
ID = Convert.ToInt32(reader[DbOperations.Tags.TagFields.TagId.ToString()]);
|
||||
IsObsolete = Convert.ToBoolean(reader[DbOperations.Tags.TagFields.Obsolete.ToString()]);
|
||||
Text = Convert.ToString(reader[DbOperations.Tags.TagFields.TagText.ToString()]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
public object Clone()
|
||||
{
|
||||
return new Tag(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <inheritdoc cref="TestObjectTemplateChannel" />
|
||||
/// <summary>
|
||||
/// this class represents a more simpilized version of the group/test object channel
|
||||
/// this is closer tied to what's in the database
|
||||
/// It extends a template channel adds more meta data
|
||||
/// </summary>
|
||||
public class TestObjectChannel : TestObjectTemplateChannel, IComparable<TestObjectChannel>
|
||||
{
|
||||
/// <summary>
|
||||
/// controls whether channel should be used when collecting data or not
|
||||
/// Disabled channels are not used in run test
|
||||
/// </summary>
|
||||
public bool Disabled { get; set; }
|
||||
public int ChannelIdx { get; set; } = CHANNEL_IDX_UNKNOWN;
|
||||
/// <summary>
|
||||
/// the serial number of the sensor associated with this channel (if any)
|
||||
/// </summary>
|
||||
public string SensorSerialNumber
|
||||
{
|
||||
get => GetProperty("SensorSerialNumber", "") as string;
|
||||
set => SetProperty("SensorSerialNumber", value);
|
||||
}
|
||||
/// <summary>
|
||||
/// the physical hardware channel associated with this channel (if any)
|
||||
/// </summary>
|
||||
public string HardwareId
|
||||
{
|
||||
get => GetProperty("HardwareId", "") as string;
|
||||
set
|
||||
{
|
||||
var tokens = value?.Split('_');
|
||||
if (3 == tokens?.Length)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendFormat("{0}_{1}", tokens[0], tokens[1]);
|
||||
var index = tokens[2].IndexOf(CHANNEL_SEPARATOR);
|
||||
if (index >= 0) { sb.Append(tokens[2].Substring(index)); }
|
||||
value = sb.ToString();
|
||||
}
|
||||
SetProperty("HardwareId", value);
|
||||
}
|
||||
}
|
||||
public SquibChannelTypes SquibChannelType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// the test object this channel belongs to
|
||||
/// </summary>
|
||||
public ISO.TestObject TestObject { get; }
|
||||
private const char CHANNEL_SEPARATOR = 'x';
|
||||
public const int CHANNEL_IDX_UNKNOWN = -1;
|
||||
public enum SquibChannelTypes
|
||||
{
|
||||
None, //Non-squib channels
|
||||
Voltage,
|
||||
Current
|
||||
}
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// compares one channel to another, used for sorting
|
||||
/// order is determined by 1) display order, 2) name of the channels, 3) test object serial number (or original serial number)
|
||||
/// </summary>
|
||||
/// <param name="right"></param>
|
||||
/// <returns></returns>
|
||||
public int CompareTo(TestObjectChannel right)
|
||||
{
|
||||
if (null == right) { return 1; }
|
||||
if (this == right) { return 0; }
|
||||
var comp = DisplayOrder.CompareTo(right.DisplayOrder);
|
||||
if (0 != comp) { return comp; }
|
||||
|
||||
comp = string.Compare(Name, right.Name, StringComparison.Ordinal);
|
||||
if (0 != comp) { return comp; }
|
||||
|
||||
if (null == TestObject || null == right.TestObject) return 0;
|
||||
comp = string.Compare(TestObject.SerialNumberOrOriginalSerialNumber, right.TestObject.SerialNumberOrOriginalSerialNumber, StringComparison.Ordinal);
|
||||
return 0 != comp ? comp : 0;
|
||||
}
|
||||
|
||||
public string GetGraphId()
|
||||
{
|
||||
return SquibChannelType == SquibChannelTypes.Current ? GetId() + DTS.Common.Constants.CURRENT_SUFFIX : GetId();
|
||||
}
|
||||
public string GetId()
|
||||
{
|
||||
return GetIdWithSpecificChannelId(Channel.Id);
|
||||
}
|
||||
public string GetIdWithSpecificChannelId(long id)
|
||||
{
|
||||
return $"{TestObject.SerialNumber}_{Channel.MMEChannelType}_{id}";
|
||||
}
|
||||
public TestObjectChannel(TestObjectTemplateChannel copy, ISO.TestObject testObject, ISO.TestObjectTemplate template)
|
||||
: base(copy, template)
|
||||
{
|
||||
TestObject = testObject;
|
||||
if (copy is TestObjectChannel channel)
|
||||
{
|
||||
Disabled = channel.Disabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user