init
This commit is contained in:
@@ -0,0 +1 @@
|
||||
12
|
||||
@@ -0,0 +1 @@
|
||||
12
|
||||
@@ -0,0 +1,182 @@
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport.ISO
|
||||
{
|
||||
public class IsoCode
|
||||
{
|
||||
private char[] _isoCodeFull = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' };
|
||||
private char _TestObject
|
||||
{
|
||||
get => _isoCodeFull[0];
|
||||
set => _isoCodeFull[0] = value;
|
||||
}
|
||||
public string TestObject
|
||||
{
|
||||
get => new string(new[] { _TestObject });
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) { _TestObject = '?'; }
|
||||
else { _TestObject = value[0]; }
|
||||
}
|
||||
}
|
||||
|
||||
private char _Position
|
||||
{
|
||||
get => _isoCodeFull[1];
|
||||
set => _isoCodeFull[1] = value;
|
||||
}
|
||||
public string Position
|
||||
{
|
||||
get => new string(new[] { _Position });
|
||||
set => _Position = string.IsNullOrEmpty(value) ? '?' : value[0];
|
||||
}
|
||||
|
||||
private char[] _MainLocation
|
||||
{
|
||||
get => new[] { _isoCodeFull[2], _isoCodeFull[3], _isoCodeFull[4], _isoCodeFull[5] };
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
if (value.Length <= i) { _isoCodeFull[i + 2] = '0'; }
|
||||
else { _isoCodeFull[i + 2] = value[i]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
private char[] _FineLocation1
|
||||
{
|
||||
get => new[] { _isoCodeFull[6], _isoCodeFull[7] };
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
if (value.Length < i) { _isoCodeFull[i + 6] = '0'; }
|
||||
else { _isoCodeFull[i + 6] = value[i]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
private char[] _FineLocation2
|
||||
{
|
||||
get => new[] { _isoCodeFull[8], _isoCodeFull[9] };
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
if (value.Length < i) { _isoCodeFull[i + 8] = '0'; }
|
||||
else { _isoCodeFull[i + 8] = value[i]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
private char[] _FineLocation3
|
||||
{
|
||||
get => new[] { _isoCodeFull[10], _isoCodeFull[11] };
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
if (value.Length < i) { _isoCodeFull[i + 10] = '0'; }
|
||||
else { _isoCodeFull[i + 10] = value[i]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
private char[] _PhysicalDimension
|
||||
{
|
||||
get => new[] { _isoCodeFull[12], _isoCodeFull[13] };
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
if (value.Length < i) { _isoCodeFull[i + 12] = '0'; }
|
||||
else { _isoCodeFull[i + 12] = value[i]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
private char _Direction
|
||||
{
|
||||
get => _isoCodeFull[14];
|
||||
set => _isoCodeFull[14] = value;
|
||||
}
|
||||
private char _FilterClass
|
||||
{
|
||||
get => _isoCodeFull[15];
|
||||
set => _isoCodeFull[15] = value;
|
||||
}
|
||||
public string FilterClass
|
||||
{
|
||||
get => new string(new[] { _FilterClass });
|
||||
set => _FilterClass = string.IsNullOrEmpty(value) ? '?' : value[0];
|
||||
}
|
||||
|
||||
public IsoCode(string isoCode)
|
||||
{
|
||||
if (null == isoCode) { isoCode = ""; }
|
||||
if (isoCode.Length > 16) { isoCode = isoCode.Substring(0, 16); }
|
||||
if (isoCode.Length < 16)
|
||||
{
|
||||
isoCode = isoCode.PadRight(16, '?');
|
||||
}
|
||||
for (var i = 0; i < 16; i++) { _isoCodeFull[i] = isoCode[i]; }
|
||||
}
|
||||
public string StringRepresentation
|
||||
{
|
||||
get
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var c in _isoCodeFull) { sb.Append(c); }
|
||||
return sb.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 16; i++)
|
||||
{
|
||||
if (i >= value.Length) { _isoCodeFull[i] = '0'; }
|
||||
else { _isoCodeFull[i] = value[i]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
public static string GetString(MMEPossibleChannels channel, MMETestObjects container, MMEPositions position, MMEFilterClasses fc)
|
||||
{
|
||||
var iso = new IsoCode("");
|
||||
iso._Direction = channel.Direction[0];
|
||||
iso._FilterClass = channel.Default_Filter_Class[0];
|
||||
iso._FineLocation1 = channel.Fine_Loc_1.ToCharArray();
|
||||
iso._FineLocation2 = channel.Fine_Loc_2.ToCharArray();
|
||||
iso._FineLocation3 = channel.Fine_Loc_3.ToCharArray();
|
||||
iso._MainLocation = channel.Trans_Main_Loc.ToCharArray();
|
||||
iso._PhysicalDimension = channel.Physical_Dimension.ToCharArray();
|
||||
iso._Position = null == position ? '?' : position.Position[0];
|
||||
iso._TestObject = null == container ? '?' : container.Test_Object[0];
|
||||
iso._FilterClass = null == fc ? '?' : fc.Filter_Class[0];
|
||||
return iso.StringRepresentation;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns the isocode for a channel
|
||||
/// considers whether it should mask the test time fields in the isocode
|
||||
/// test time fields are test object, and filterclass
|
||||
/// returns isocode
|
||||
/// </summary>
|
||||
/// <param name="channel"></param>
|
||||
/// <param name="careAboutTestTimeFields"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetString(MMEPossibleChannels channel, bool careAboutTestTimeFields)
|
||||
{
|
||||
var iso = new IsoCode("")
|
||||
{
|
||||
_Direction = channel.Direction[0],
|
||||
_FineLocation1 = channel.Fine_Loc_1.ToCharArray(),
|
||||
_FineLocation2 = channel.Fine_Loc_2.ToCharArray(),
|
||||
_FineLocation3 = channel.Fine_Loc_3.ToCharArray(),
|
||||
_MainLocation = channel.Trans_Main_Loc.ToCharArray(),
|
||||
_PhysicalDimension = channel.Physical_Dimension.ToCharArray(),
|
||||
_Position = channel.Position[0],
|
||||
_TestObject = careAboutTestTimeFields ? channel.Test_Object[0] : '?',
|
||||
_FilterClass = careAboutTestTimeFields ? channel.Default_Filter_Class[0] : '?'
|
||||
};
|
||||
return iso.StringRepresentation;
|
||||
}
|
||||
public static string GetString(string testObject, string position, string main, string floc1, string floc2, string floc3, string physdim, string dir, string fc)
|
||||
{
|
||||
return string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}", testObject, position, main, floc1, floc2, floc3, physdim, dir, fc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class HardwareChannel : System.IComparable<HardwareChannel> //: Common.BindableBase, System.IComparable<HardwareChannel>
|
||||
{
|
||||
private readonly ISOHardwareChannel _isoChannel;
|
||||
public ISOHardwareChannel GetISOChannel() { return _isoChannel; }
|
||||
public int CompareTo(HardwareChannel right)
|
||||
{
|
||||
if (this == right) { return 0; }
|
||||
if (null == right) { return 0; }
|
||||
|
||||
var order = GetISOChannel().DASDisplayOrder.CompareTo(right.GetISOChannel().DASDisplayOrder);
|
||||
if (0 != order) { return order; }
|
||||
return GetISOChannel().ChannelIdx.CompareTo(right.GetISOChannel().ChannelIdx);
|
||||
}
|
||||
public string GetId()
|
||||
{
|
||||
return string.Format("{0}x{1}", Hardware.GetHardware().GetId(), 1 + ChannelNumber);
|
||||
}
|
||||
|
||||
public TestObjectChannel TestObjectChannel { get; set; }
|
||||
|
||||
public HardwareChannel(HardwareChannel copy)
|
||||
{
|
||||
ChannelNumber = copy.ChannelNumber;
|
||||
if (null != copy.Sensor) { Sensor = new SensorData(copy.Sensor); }
|
||||
TestObjectChannel = copy.TestObjectChannel;
|
||||
Hardware = copy.Hardware;
|
||||
_isoChannel = copy._isoChannel;
|
||||
}
|
||||
public HardwareChannel(ISOHardwareChannel channel, DASHardware hardware)
|
||||
{
|
||||
ChannelNumber = channel.ChannelIdx;
|
||||
Hardware = hardware;
|
||||
_isoChannel = channel;
|
||||
}
|
||||
|
||||
public DASHardware Hardware { get; }
|
||||
public int ChannelNumber { get; } = 0;
|
||||
public SensorData Sensor { get; set; } = null;
|
||||
|
||||
public bool IsSupportedBridgeType(Test.Module.Channel.Sensor.BridgeType bridgeType)
|
||||
{
|
||||
return (GetISOChannel().SupportedBridges & (int)bridgeType) == (int)bridgeType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// this class encapsulates a single user
|
||||
/// </summary>
|
||||
public class User : TagAwareBase
|
||||
{
|
||||
public enum DefaultRoles
|
||||
{
|
||||
Administrator = 0,
|
||||
PowerUser = 1,
|
||||
User = 2,
|
||||
Guest = 3
|
||||
}
|
||||
public enum UserPermissionLevels
|
||||
{
|
||||
Deny = 0,
|
||||
Read = 1,
|
||||
ReadAndExecute = 2,
|
||||
Edit = 3,
|
||||
Admin = 4
|
||||
}
|
||||
public enum Tags
|
||||
{
|
||||
User,
|
||||
Role,
|
||||
Version,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
Name,
|
||||
UserName,
|
||||
Password,
|
||||
LocalOnly,
|
||||
Permissions,
|
||||
Visibility,
|
||||
Id
|
||||
}
|
||||
public enum XmlFields
|
||||
{
|
||||
ID,
|
||||
UserName,
|
||||
DisplayName,
|
||||
Password,
|
||||
// ReSharper disable once InconsistentNaming
|
||||
IUIItemPermissions,
|
||||
// ReSharper disable once InconsistentNaming
|
||||
IUIItemVisibility,
|
||||
Role,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
Version,
|
||||
LocalOnly,
|
||||
UserTags
|
||||
}
|
||||
|
||||
private const string DEFAULT_LAST_MODIFIED_BY = "---";
|
||||
private const string DEFAULT_ADMIN_USERNAME = "Admin";
|
||||
private const string DEFAULT_GUEST_USERNAME = "Guest";
|
||||
private const string DEFAULT_POWERUSER_USERNAME = "PowerUser";
|
||||
private const string DEFAULT_USER_USERNAME = "User";
|
||||
private const int INVALID_ID = -1;
|
||||
/// <summary>
|
||||
/// a default user is a user with one of the default roles and names, like Admin or Guest
|
||||
/// return true if is a default user
|
||||
/// </summary>
|
||||
public bool IsADefaultUser => UserName == GetDefaultUserName(Role);
|
||||
|
||||
/// <summary>
|
||||
/// hash of password is seeded and stored in xml
|
||||
/// hash is seeded with computable information known about the user
|
||||
/// hash is base64encoding for xml niceness
|
||||
/// xml is encrypted prior to writing to file
|
||||
/// </summary>
|
||||
private string _password = "";
|
||||
/// <summary>
|
||||
/// the user friendly name for a user, a display name
|
||||
/// </summary>
|
||||
private string _name;
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => SetProperty(ref _name, value, Tags.Name.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
/// the user name for the user, a short unique name for the user
|
||||
/// </summary>
|
||||
private string _userName = string.Empty;
|
||||
public string UserName
|
||||
{
|
||||
get => _userName;
|
||||
set => SetProperty(ref _userName, value, Tags.UserName.ToString());
|
||||
}
|
||||
|
||||
private int _id = INVALID_ID;
|
||||
public int Id
|
||||
{
|
||||
get => _id;
|
||||
set => SetProperty(ref _id, value, Tags.Id.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the default role for the user, if a permission is not explicitly set for the user
|
||||
/// it will use this default role to determine the effect permission
|
||||
/// </summary>
|
||||
private DefaultRoles _myRole = DefaultRoles.Guest;
|
||||
public DefaultRoles Role
|
||||
{
|
||||
get => _myRole;
|
||||
set
|
||||
{
|
||||
if (IsADefaultUser && _myRole != value) { throw new NotSupportedException(); }
|
||||
SetProperty(ref _myRole, value, Tags.Role.ToString());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// right now the version field is updated whenever the user is updated, so it keeps
|
||||
/// track of how many times it has been modified
|
||||
/// </summary>
|
||||
private int _version;
|
||||
public int Version
|
||||
{
|
||||
get => _version;
|
||||
set => SetProperty(ref _version, value, Tags.Version.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
/// the time the user was last modified or commited to the db
|
||||
/// </summary>
|
||||
private DateTime _lastModified = DateTime.MinValue;
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => SetProperty(ref _lastModified, value, Tags.LastModified.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the user that last modified the user
|
||||
/// </summary>
|
||||
private string _lastModifiedBy = DEFAULT_LAST_MODIFIED_BY;
|
||||
public string LastModifiedBy
|
||||
{
|
||||
get => _lastModifiedBy;
|
||||
set => SetProperty(ref _lastModifiedBy, value, Tags.LastModifiedBy.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
/// a remnant of the multiple database era, this was to mark a user as being local to this db and should never
|
||||
/// be pushed to the central db
|
||||
/// </summary>
|
||||
private bool _bLocalOnly;
|
||||
public bool LocalOnly
|
||||
{
|
||||
get => _bLocalOnly;
|
||||
set => SetProperty(ref _bLocalOnly, value, Tags.LocalOnly.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// lookup of permissions by UI item
|
||||
/// </summary>
|
||||
private readonly Dictionary<IUIItems, UserPermissionLevels> _tabPermissions = new Dictionary<IUIItems, UserPermissionLevels>();
|
||||
/// <summary>
|
||||
/// lookup of visibility by UI item
|
||||
/// </summary>
|
||||
private readonly Dictionary<IUIItems, bool> _showTabs = new Dictionary<IUIItems, bool>();
|
||||
/// <summary>
|
||||
/// lock for accessing tab permissions or visibility
|
||||
/// </summary>
|
||||
private static readonly object TabPermissionsLock = new object();
|
||||
|
||||
// #endregion properties
|
||||
|
||||
public override ConstraintHelper[] GetConstraints()
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
new ConstraintHelper
|
||||
{
|
||||
ColumnName = DbOperations.Users.UserFields.UserName.ToString(),
|
||||
DbType = SqlDbType.NVarChar,
|
||||
DbValue = UserName
|
||||
}
|
||||
};
|
||||
}
|
||||
public override string LookupTable => DbOperations.Users.USERS_TABLE;
|
||||
public User(DataRow row)
|
||||
{
|
||||
Id = Convert.ToInt32(row[DbOperations.Users.UserFields.ID.ToString()]);
|
||||
UserName = (string)row[DbOperations.Users.UserFields.UserName.ToString()];
|
||||
Name = (string)row[DbOperations.Users.UserFields.DisplayName.ToString()];
|
||||
_password = (string)row[DbOperations.Users.UserFields.Password.ToString()];
|
||||
_myRole = (DefaultRoles)Convert.ToInt32(row[DbOperations.Users.UserFields.Role.ToString()]);
|
||||
LastModified = (DateTime)row[DbOperations.Users.UserFields.LastModified.ToString()];
|
||||
LastModifiedBy = (string)row[DbOperations.Users.UserFields.LastModifiedBy.ToString()];
|
||||
LocalOnly = Convert.ToBoolean(row[DbOperations.Users.UserFields.LocalOnly.ToString()]);
|
||||
}
|
||||
public string GetPermissionSerialized()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
lock (TabPermissionsLock)
|
||||
{
|
||||
var i = _tabPermissions.GetEnumerator();
|
||||
while (i.MoveNext())
|
||||
{
|
||||
if (sb.Length > 0) { sb.Append(","); }
|
||||
sb.Append(i.Current.Key.GetName());
|
||||
sb.Append("=");
|
||||
sb.Append(((int)i.Current.Value).ToString());
|
||||
}
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
public static string GetDefaultUserName(DefaultRoles role)
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case DefaultRoles.Administrator:
|
||||
return DEFAULT_ADMIN_USERNAME;
|
||||
case DefaultRoles.Guest:
|
||||
return DEFAULT_GUEST_USERNAME;
|
||||
case DefaultRoles.PowerUser:
|
||||
return DEFAULT_POWERUSER_USERNAME;
|
||||
case DefaultRoles.User:
|
||||
return DEFAULT_USER_USERNAME;
|
||||
default:
|
||||
throw new NotSupportedException("Unknown role " + role);
|
||||
}
|
||||
}
|
||||
public string GetVisibilitySerialized()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var i2 = _showTabs.GetEnumerator();
|
||||
while (i2.MoveNext())
|
||||
{
|
||||
if (sb.Length > 0) { sb.Append(","); }
|
||||
sb.Append(i2.Current.Key.GetName());
|
||||
sb.Append("=");
|
||||
sb.Append(i2.Current.Value ? "1" : "0");
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
public Dictionary<string, string> GetValues()
|
||||
{
|
||||
var elementNameValuePairs = new Dictionary<string, string>();
|
||||
|
||||
elementNameValuePairs[XmlFields.ID.ToString()] = Id.ToString();
|
||||
elementNameValuePairs[XmlFields.UserName.ToString()] = UserName;
|
||||
elementNameValuePairs[XmlFields.DisplayName.ToString()] = Name;
|
||||
elementNameValuePairs[XmlFields.Password.ToString()] = _password;
|
||||
elementNameValuePairs[XmlFields.IUIItemPermissions.ToString()] = GetPermissionSerialized();
|
||||
elementNameValuePairs[XmlFields.IUIItemVisibility.ToString()] = GetVisibilitySerialized();
|
||||
elementNameValuePairs[XmlFields.Role.ToString()] = Role.ToString();
|
||||
elementNameValuePairs[XmlFields.LastModified.ToString()] = LastModified.ToString(CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[XmlFields.LastModifiedBy.ToString()] = LastModifiedBy;
|
||||
elementNameValuePairs[XmlFields.Version.ToString()] = Version.ToString(CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[XmlFields.LocalOnly.ToString()] = LocalOnly.ToString(CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[XmlFields.UserTags.ToString()] = GetTagsCommaSeperatedString();
|
||||
|
||||
return elementNameValuePairs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class MMEFineLocations1 : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Fine_Loc_1 { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
|
||||
public MMEFineLocations1(string sGuid, string fineLoc1, string textL1, string textL2, long version, DateTime date,
|
||||
string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText, string history,
|
||||
MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
Fine_Loc_1 = fineLoc1;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
public static MMEFineLocations1[] GetFineLocations1()
|
||||
{
|
||||
var fineLocations1 = new List<MMEFineLocations1>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandType = CommandType.Text;
|
||||
cmd.CommandText = "SELECT * FROM MMEFineLocations1";
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string sFineLoc1 = ISOReader["FINE_LOC_1"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = Convert.ToInt64(ISOReader["VERSION"]);
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
fineLocations1.Add(new MMEFineLocations1(sGuid, sFineLoc1, textL1, textL2, version, date,
|
||||
remarks, expired, sortkey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * FROM {0}", DbOperations.MMETables.MMEFineLocations1Table);
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var date = DateTime.Now;
|
||||
var expired = false;
|
||||
var fineLoc1 = "??";
|
||||
var history = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var lastChangeText = "";
|
||||
var remarks = "";
|
||||
var sGuid = "";
|
||||
var sortKey = "";
|
||||
var text1 = "";
|
||||
var text2 = "";
|
||||
var version = 0;
|
||||
var fields = Enum.GetValues(typeof(DbOperations.MMETables.MMEFineLocations1Fields))
|
||||
.Cast<DbOperations.MMETables.MMEFineLocations1Fields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()])) { continue; }
|
||||
try
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.DATE:
|
||||
date = Convert.ToDateTime(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.EXPIRED:
|
||||
expired = Convert.ToBoolean(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.FINE_LOC_1:
|
||||
fineLoc1 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.HISTORY:
|
||||
history = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.LAST_CHANGE:
|
||||
lastChange = Convert.ToDateTime(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.REMARKS:
|
||||
remarks = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.s_GUID:
|
||||
sGuid = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.SORTKEY:
|
||||
sortKey = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.TEXT_L1:
|
||||
text1 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.TEXT_L2:
|
||||
text2 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations1Fields.VERSION:
|
||||
version = Convert.ToInt32(dr[field.ToString()]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
var fineLoc = new MMEFineLocations1(sGuid.ToString(), fineLoc1, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortKey, lastChange, lastChangeText,
|
||||
history, MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
fineLocations1.Add(fineLoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
return fineLocations1.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,581 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class Region
|
||||
{
|
||||
private TestObjectTemplate _template;
|
||||
public TestObjectTemplate Template
|
||||
{
|
||||
get => _template;
|
||||
set
|
||||
{
|
||||
_template = value;
|
||||
DetermineAvailableISOSettings();
|
||||
}
|
||||
}
|
||||
private void InvalidateVisual()
|
||||
{
|
||||
_adorner?.InvalidateVisual();
|
||||
}
|
||||
private string _name;
|
||||
public string RegionName
|
||||
{
|
||||
get => _name;
|
||||
set { _name = value; InvalidateVisual(); }
|
||||
}
|
||||
|
||||
private string _regionDescription;
|
||||
public string RegionDescription
|
||||
{
|
||||
get => _regionDescription;
|
||||
set { _regionDescription = value; InvalidateVisual(); }
|
||||
}
|
||||
|
||||
public Point RegionUpperLeft { get; set; }
|
||||
|
||||
public Point RegionBottomRight { get; set; }
|
||||
|
||||
private MMEDirections _direction;
|
||||
public MMEDirections RegionDirection
|
||||
{
|
||||
get => _direction;
|
||||
set
|
||||
{
|
||||
_direction = value;
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMEFilterClasses _filterClass;
|
||||
public MMEFilterClasses RegionFilterClass
|
||||
{
|
||||
get => _filterClass;
|
||||
set
|
||||
{
|
||||
_filterClass = value;
|
||||
if (null != value)
|
||||
{
|
||||
_filterClassIndex = _filterClasses.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_filterClassIndex = -1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
private MMEFineLocations1 _fineLocation1;
|
||||
public MMEFineLocations1 RegionFineLocation1
|
||||
{
|
||||
get => _fineLocation1;
|
||||
set
|
||||
{
|
||||
_fineLocation1 = value;
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMEFineLocations2 _fineLocation2;
|
||||
public MMEFineLocations2 RegionFineLocation2
|
||||
{
|
||||
get => _fineLocation2;
|
||||
set
|
||||
{
|
||||
_fineLocation2 = value;
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMEFineLocations3 _fineLocation3;
|
||||
public MMEFineLocations3 RegionFineLocation3
|
||||
{
|
||||
get => _fineLocation3;
|
||||
set
|
||||
{
|
||||
_fineLocation3 = value;
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMETransducerMainLocation _mainLocation;
|
||||
public MMETransducerMainLocation RegionMainLocation
|
||||
{
|
||||
get => _mainLocation;
|
||||
set
|
||||
{
|
||||
if (_mainLocation != value)
|
||||
{
|
||||
_mainLocation = value;
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void FilterRegionChannels()
|
||||
{
|
||||
_regionChannels = new List<TestObjectTemplateChannel>(Template.TemplateAllChannels);
|
||||
_regionUIChannels = new List<TemplateChannelUI>(Template.TemplateAllUIChannels);
|
||||
for (var i = _regionChannels.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var channel = _regionChannels[i];
|
||||
var mmeChannel = channel.Channel;
|
||||
|
||||
if (RegionMainLocation != null && RegionMainLocation.Trans_Main_Loc != mmeChannel.Trans_Main_Loc)
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionDirection != null && RegionDirection.Direction != mmeChannel.Direction && RegionDirection.Direction != "?")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionFilterClass != null && RegionFilterClass.Filter_Class != mmeChannel.Default_Filter_Class && RegionFilterClass.Filter_Class != "?")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionFineLocation1 != null && RegionFineLocation1.Fine_Loc_1 != mmeChannel.Fine_Loc_1 && RegionFineLocation1.Fine_Loc_1 != "??")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionFineLocation2 != null && RegionFineLocation2.FINE_LOC_2 != mmeChannel.Fine_Loc_2 && RegionFineLocation2.FINE_LOC_2 != "??")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionFineLocation3 != null && RegionFineLocation3.FINE_LOC_3 != mmeChannel.Fine_Loc_3 && RegionFineLocation3.FINE_LOC_3 != "??")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionPhysicalDimension != null && RegionPhysicalDimension.Physical_Dimension != mmeChannel.Physical_Dimension && RegionPhysicalDimension.Physical_Dimension != "??")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionPosition != null && RegionPosition.Position != mmeChannel.Position && RegionPosition.Position != "?")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
RegionChannels = _regionChannels.ToArray();
|
||||
RegionUIChannels = _regionUIChannels.ToArray();
|
||||
SetISOCode();
|
||||
}
|
||||
private MMEPhysicalDimensions _physicalDimension;
|
||||
public MMEPhysicalDimensions RegionPhysicalDimension
|
||||
{
|
||||
get => _physicalDimension;
|
||||
set
|
||||
{
|
||||
_physicalDimension = value;
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMEPositions _position;
|
||||
public MMEPositions RegionPosition
|
||||
{
|
||||
get => _position;
|
||||
set
|
||||
{
|
||||
_position = value;
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
public MMETestObjects RegionTestObject { get; set; }
|
||||
|
||||
|
||||
private readonly RegionAdorner _adorner;
|
||||
public Region(RegionAdorner adorner, TestObjectTemplate template)
|
||||
{
|
||||
_adorner = adorner;
|
||||
RegionName = "New region";
|
||||
RegionDescription = "Describe region";
|
||||
Template = template;
|
||||
RegionTestObject = template.TestObject;
|
||||
RegionChannels = template.TemplateAllChannels;
|
||||
RegionUIChannels = template.TemplateAllUIChannels;
|
||||
DetermineAvailableISOSettings();
|
||||
}
|
||||
|
||||
public Region(TestObjectTemplate template, TemplateRegion r)
|
||||
{
|
||||
RegionName = r.RegionName;
|
||||
RegionDescription = r.RegionDescription;
|
||||
Template = template;
|
||||
RegionChannels = template.TemplateAllChannels;
|
||||
RegionUIChannels = template.TemplateAllUIChannels;
|
||||
RegionTestObject = ISO13499FileDb.IsoDb.GetTestObjectByIso(r.TestObject);
|
||||
RegionBottomRight = new Point(r.LowerRight.X, r.LowerRight.Y);
|
||||
RegionUpperLeft = new Point(r.UpperLeft.X, r.UpperLeft.Y);
|
||||
RegionDirection = ISO13499FileDb.IsoDb.GetDirectionByIso(r.Direction);
|
||||
RegionFilterClass = ISO13499FileDb.IsoDb.GetFilterClassByIso(r.FilterClass);
|
||||
RegionFineLocation1 = ISO13499FileDb.IsoDb.GetFineLocation1ByIso(r.FineLocation1);
|
||||
RegionFineLocation2 = ISO13499FileDb.IsoDb.GetFineLocation2ByIso(r.FineLocation2);
|
||||
RegionFineLocation3 = ISO13499FileDb.IsoDb.GetFineLocation3ByIso(r.FineLocation3);
|
||||
RegionMainLocation = ISO13499FileDb.IsoDb.GetMainLocationByIso(r.MainLocation);
|
||||
RegionPhysicalDimension = ISO13499FileDb.IsoDb.GetPhysicalDimensionByIso(r.PhysicalDimension);
|
||||
RegionPosition = ISO13499FileDb.IsoDb.GetPosition(r.Position);
|
||||
FilterRegionChannels();
|
||||
SetISOCode();
|
||||
}
|
||||
|
||||
public Visibility RegionAddVisibility { get; set; } = Visibility.Visible;
|
||||
|
||||
public Visibility RegionDeleteVisibility { get; set; } = Visibility.Hidden;
|
||||
|
||||
private List<MMEDirections> _allDirections = new List<MMEDirections>();
|
||||
public MMEDirections[] AllDirections
|
||||
{
|
||||
get => _allDirections.ToArray();
|
||||
set
|
||||
{
|
||||
_allDirections = new List<MMEDirections>(value);
|
||||
var directions = new List<string>();
|
||||
foreach (var dir in _allDirections)
|
||||
{
|
||||
if (null == dir) { directions.Add("?"); }
|
||||
else { directions.Add(dir.Text_L1); }
|
||||
}
|
||||
AllDirectionsStrings = directions.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allDirectionsStrings = new List<string>();
|
||||
public string[] AllDirectionsStrings
|
||||
{
|
||||
get => _allDirectionsStrings.ToArray();
|
||||
set => _allDirectionsStrings = new List<String>(value);
|
||||
}
|
||||
|
||||
private List<MMEFilterClasses> _filterClasses = new List<MMEFilterClasses>();
|
||||
public MMEFilterClasses[] AllFilterClasses
|
||||
{
|
||||
get => _filterClasses.ToArray();
|
||||
set
|
||||
{
|
||||
_filterClasses = new List<MMEFilterClasses>(value);
|
||||
var filterclasses = new List<string>();
|
||||
foreach (var fc in _filterClasses) { filterclasses.Add(fc.Text_L1); }
|
||||
AllFilterClassStrings = filterclasses.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allFilterClassStrings = new List<string>();
|
||||
public string[] AllFilterClassStrings
|
||||
{
|
||||
get => _allFilterClassStrings.ToArray();
|
||||
set => _allFilterClassStrings = new List<string>(value);
|
||||
}
|
||||
public int _filterClassIndex = -1;
|
||||
private List<MMEFineLocations1> _fineLocations1 = new List<MMEFineLocations1>();
|
||||
public MMEFineLocations1[] AllFineLocations1
|
||||
{
|
||||
get => _fineLocations1.ToArray();
|
||||
set
|
||||
{
|
||||
_fineLocations1 = new List<MMEFineLocations1>(value);
|
||||
var fineLocations1 = new List<string>();
|
||||
foreach (var loc in _fineLocations1)
|
||||
{
|
||||
fineLocations1.Add(null == loc ? "??" : loc.Text_L1);
|
||||
}
|
||||
AllFineLocations1Strings = fineLocations1.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allFineLocations1Strings = new List<string>();
|
||||
public string[] AllFineLocations1Strings
|
||||
{
|
||||
get => _allFineLocations1Strings.ToArray();
|
||||
set => _allFineLocations1Strings = new List<string>(value);
|
||||
}
|
||||
|
||||
private List<MMEFineLocations2> _fineLocations2 = new List<MMEFineLocations2>();
|
||||
public MMEFineLocations2[] AllFineLocations2
|
||||
{
|
||||
get => _fineLocations2.ToArray();
|
||||
set
|
||||
{
|
||||
_fineLocations2 = new List<MMEFineLocations2>(value);
|
||||
var locations = new List<string>();
|
||||
foreach (var loc in _fineLocations2) { locations.Add(loc.Text_L1); }
|
||||
AllFineLocations2Strings = locations.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allFineLocations2Strings = new List<string>();
|
||||
public string[] AllFineLocations2Strings
|
||||
{
|
||||
get => _allFineLocations2Strings.ToArray();
|
||||
set => _allFineLocations2Strings = new List<string>(value);
|
||||
}
|
||||
|
||||
private List<MMEFineLocations3> _fineLocations3 = new List<MMEFineLocations3>();
|
||||
public MMEFineLocations3[] AllFineLocations3
|
||||
{
|
||||
get => _fineLocations3.ToArray();
|
||||
set
|
||||
{
|
||||
_fineLocations3 = new List<MMEFineLocations3>(value);
|
||||
var locations = new List<string>();
|
||||
foreach (var l in _fineLocations3) { locations.Add(l.Text_L1); }
|
||||
AllFineLocations3Strings = locations.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allFineLocations3Strings = new List<string>();
|
||||
public string[] AllFineLocations3Strings
|
||||
{
|
||||
get => _allFineLocations3Strings.ToArray();
|
||||
set => _allFineLocations3Strings = new List<String>(value);
|
||||
}
|
||||
|
||||
private List<MMETransducerMainLocation> _mainLocations = new List<MMETransducerMainLocation>();
|
||||
public MMETransducerMainLocation[] AllMainLocations
|
||||
{
|
||||
get => _mainLocations.ToArray();
|
||||
set
|
||||
{
|
||||
_mainLocations = new List<MMETransducerMainLocation>(value);
|
||||
var locations = new List<string>();
|
||||
foreach (var loc in _mainLocations)
|
||||
{
|
||||
if (null == loc)
|
||||
{
|
||||
locations.Add("????");
|
||||
}
|
||||
else { locations.Add(loc.Text_L1); }
|
||||
}
|
||||
AllMainLocationsStrings = locations.ToArray();
|
||||
}
|
||||
}
|
||||
private List<String> _allMainLocationsStrings = new List<string>();
|
||||
public string[] AllMainLocationsStrings
|
||||
{
|
||||
get => _allMainLocationsStrings.ToArray();
|
||||
set => _allMainLocationsStrings = new List<string>(value);
|
||||
}
|
||||
|
||||
private List<MMEPhysicalDimensions> _physicalDimensions = new List<MMEPhysicalDimensions>();
|
||||
public MMEPhysicalDimensions[] AllPhysicalDimensions
|
||||
{
|
||||
get => _physicalDimensions.ToArray();
|
||||
set
|
||||
{
|
||||
_physicalDimensions = new List<MMEPhysicalDimensions>(value);
|
||||
var dimensions = new List<string>();
|
||||
foreach (var dim in _physicalDimensions)
|
||||
{
|
||||
if (null == dim) { dimensions.Add("??"); }
|
||||
else { dimensions.Add(dim.Text_L1); }
|
||||
}
|
||||
AllPhysicalDimensionStrings = dimensions.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allPhysicalDimensionStrings = new List<string>();
|
||||
public string[] AllPhysicalDimensionStrings
|
||||
{
|
||||
get => _allPhysicalDimensionStrings.ToArray();
|
||||
set => _allPhysicalDimensionStrings = new List<String>(value);
|
||||
}
|
||||
|
||||
private List<MMEPositions> _positions = new List<MMEPositions>();
|
||||
public MMEPositions[] AllPositions
|
||||
{
|
||||
get => _positions.ToArray();
|
||||
set
|
||||
{
|
||||
_positions = new List<MMEPositions>(value);
|
||||
var positions = new List<string>();
|
||||
foreach (var pos in _positions) { positions.Add(pos.Text_L1); }
|
||||
AllPositionStrings = positions.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allPositionsStrings = new List<string>();
|
||||
public string[] AllPositionStrings
|
||||
{
|
||||
get => _allPositionsStrings.ToArray();
|
||||
set => _allPositionsStrings = new List<string>(value);
|
||||
}
|
||||
|
||||
public string ISOCode { get; set; } = "????????????????";
|
||||
|
||||
private void SetISOCode()
|
||||
{
|
||||
var testObject = "?";
|
||||
if (null != RegionTestObject) { testObject = RegionTestObject.Test_Object; }
|
||||
var position = "?";
|
||||
if (null != RegionPosition) { position = RegionPosition.Position; }
|
||||
var main = "????";
|
||||
if (null != RegionMainLocation) { main = RegionMainLocation.Trans_Main_Loc; }
|
||||
var floc1 = "??";
|
||||
if (null != RegionFineLocation1) { floc1 = RegionFineLocation1.Fine_Loc_1; }
|
||||
var floc2 = "??";
|
||||
if (null != RegionFineLocation2) { floc2 = RegionFineLocation2.FINE_LOC_2; }
|
||||
var floc3 = "??";
|
||||
if (null != RegionFineLocation3) { floc3 = RegionFineLocation3.FINE_LOC_3; }
|
||||
var physdim = "??";
|
||||
if (null != RegionPhysicalDimension) { physdim = RegionPhysicalDimension.Physical_Dimension; }
|
||||
var dir = "?";
|
||||
if (null != RegionDirection) { dir = RegionDirection.Direction; }
|
||||
var fc = "?";
|
||||
if (null != RegionFilterClass) { fc = RegionFilterClass.Filter_Class; }
|
||||
ISOCode = ISO.IsoCode.GetString(testObject, position, main, floc1, floc2, floc3, physdim, dir, fc);
|
||||
}
|
||||
private List<TestObjectTemplateChannel> _regionChannels = new List<TestObjectTemplateChannel>();
|
||||
public TestObjectTemplateChannel[] RegionChannels
|
||||
{
|
||||
get => _regionChannels.ToArray();
|
||||
set
|
||||
{
|
||||
_regionChannels = new List<TestObjectTemplateChannel>(value);
|
||||
DetermineAvailableISOSettings();
|
||||
}
|
||||
}
|
||||
private void DetermineAvailableISOSettings()
|
||||
{
|
||||
|
||||
var regionChannels = RegionChannels;
|
||||
var templateChannels = Template.TemplateAllChannels;
|
||||
|
||||
var testObjects = (from pc in regionChannels.AsParallel() select pc.Channel.Test_Object).Distinct().ToArray();
|
||||
if (testObjects.Length < 1) { return; }
|
||||
RegionTestObject = ISO13499FileDb.IsoDb.GetTestObjectByIso(testObjects[0]);
|
||||
|
||||
|
||||
var dirs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Direction).Distinct().ToArray());
|
||||
dirs.Sort();
|
||||
var directions = new List<MMEDirections>();
|
||||
foreach (var dir in dirs) { directions.Add(ISO13499FileDb.IsoDb.GetDirectionByIso(dir)); }
|
||||
var d = ISO13499FileDb.IsoDb.GetDirectionByIso("?");
|
||||
if (!directions.Contains(d)) { directions.Add(d); }
|
||||
AllDirections = directions.ToArray();
|
||||
dirs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Direction).Distinct().ToArray());
|
||||
if (1 == dirs.Count) { RegionDirection = (ISO13499FileDb.IsoDb.GetDirectionByIso(dirs[0])); }
|
||||
else if (0 == dirs.Count) { RegionDirection = null; }
|
||||
|
||||
var fcs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Default_Filter_Class).Distinct().ToArray());
|
||||
fcs.Sort();
|
||||
var filterclasses = new List<MMEFilterClasses>();
|
||||
foreach (var fc in fcs) { filterclasses.Add(ISO13499FileDb.IsoDb.GetFilterClassByIso(fc)); }
|
||||
var fc2 = ISO13499FileDb.IsoDb.GetFilterClassByIso("?");
|
||||
if (!filterclasses.Contains(fc2)) { filterclasses.Add(fc2); }
|
||||
AllFilterClasses = filterclasses.ToArray();
|
||||
fcs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Default_Filter_Class).Distinct().ToArray());
|
||||
if (1 == fcs.Count) { RegionFilterClass = (ISO13499FileDb.IsoDb.GetFilterClassByIso(fcs[0])); }
|
||||
else if (0 == fcs.Count) { RegionFilterClass = null; }
|
||||
|
||||
var locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Fine_Loc_1).Distinct().ToArray());
|
||||
locs.Sort();
|
||||
var finelocations1 = new List<MMEFineLocations1>();
|
||||
foreach (var loc in locs) { finelocations1.Add(ISO13499FileDb.IsoDb.GetFineLocation1ByIso(loc)); }
|
||||
var f = ISO13499FileDb.IsoDb.GetFineLocation1ByIso("??");
|
||||
if (!finelocations1.Contains(f)) { finelocations1.Add(f); }
|
||||
AllFineLocations1 = finelocations1.ToArray();
|
||||
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Fine_Loc_1).Distinct().ToArray());
|
||||
if (1 == locs.Count) { RegionFineLocation1 = (ISO13499FileDb.IsoDb.GetFineLocation1ByIso(locs[0])); }
|
||||
else if (0 == locs.Count) { RegionFineLocation1 = null; }
|
||||
|
||||
locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Fine_Loc_2).Distinct().ToArray());
|
||||
locs.Sort();
|
||||
var finelocations2 = new List<MMEFineLocations2>();
|
||||
foreach (var loc in locs) { finelocations2.Add(ISO13499FileDb.IsoDb.GetFineLocation2ByIso(loc)); }
|
||||
AllFineLocations2 = finelocations2.ToArray();
|
||||
var f2 = ISO13499FileDb.IsoDb.GetFineLocation2ByIso("??");
|
||||
if (!finelocations2.Contains(f2)) { finelocations2.Add(f2); }
|
||||
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Fine_Loc_2).Distinct().ToArray());
|
||||
if (1 == locs.Count) { RegionFineLocation2 = (ISO13499FileDb.IsoDb.GetFineLocation2ByIso(locs[0])); }
|
||||
else if (0 == locs.Count) { RegionFineLocation2 = null; }
|
||||
|
||||
|
||||
locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Fine_Loc_3).Distinct().ToArray());
|
||||
locs.Sort();
|
||||
var finelocations3 = new List<MMEFineLocations3>();
|
||||
foreach (var loc in locs) { finelocations3.Add(ISO13499FileDb.IsoDb.GetFineLocation3ByIso(loc)); }
|
||||
var f3 = ISO13499FileDb.IsoDb.GetFineLocation3ByIso("??");
|
||||
if (!finelocations3.Contains(f3)) { finelocations3.Add(f3); }
|
||||
AllFineLocations3 = finelocations3.ToArray();
|
||||
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Fine_Loc_3).Distinct().ToArray());
|
||||
if (1 == locs.Count) { RegionFineLocation3 = (ISO13499FileDb.IsoDb.GetFineLocation3ByIso(locs[0])); }
|
||||
else if (0 == locs.Count) { RegionFineLocation3 = null; }
|
||||
|
||||
locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Trans_Main_Loc).Distinct().ToArray());
|
||||
locs.Sort();
|
||||
var mains = new List<MMETransducerMainLocation>();
|
||||
foreach (var loc in locs) { mains.Add(ISO13499FileDb.IsoDb.GetMainLocationByIso(loc)); }
|
||||
var m = ISO13499FileDb.IsoDb.GetMainLocationByIso("????");
|
||||
if (!mains.Contains(m)) { mains.Add(m); }
|
||||
AllMainLocations = mains.ToArray();
|
||||
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Trans_Main_Loc).Distinct().ToArray());
|
||||
if (1 == locs.Count) { RegionMainLocation = (ISO13499FileDb.IsoDb.GetMainLocationByIso(locs[0])); }
|
||||
else if (0 == locs.Count) { RegionMainLocation = null; }
|
||||
|
||||
var dims = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Physical_Dimension).Distinct().ToArray());
|
||||
dims.Sort();
|
||||
var dimensions = new List<MMEPhysicalDimensions>();
|
||||
foreach (var dim in dims) { dimensions.Add(ISO13499FileDb.IsoDb.GetPhysicalDimensionByIso(dim)); }
|
||||
var pd = ISO13499FileDb.IsoDb.GetPhysicalDimensionByIso("??");
|
||||
if (!dimensions.Contains(pd)) { dimensions.Add(pd); }
|
||||
AllPhysicalDimensions = dimensions.ToArray();
|
||||
dims = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Physical_Dimension).Distinct().ToArray());
|
||||
if (1 == dims.Count) { RegionPhysicalDimension = (ISO13499FileDb.IsoDb.GetPhysicalDimensionByIso(dims[0])); }
|
||||
else if (0 == dims.Count) { RegionPhysicalDimension = null; }
|
||||
|
||||
var poss = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Position).Distinct().ToArray());
|
||||
poss.Sort();
|
||||
var positions = new List<MMEPositions>();
|
||||
foreach (var pos in poss) { positions.Add(ISO13499FileDb.IsoDb.GetPositionByISO(pos)); }
|
||||
AllPositions = positions.ToArray();
|
||||
poss = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Position).Distinct().ToArray());
|
||||
if (1 == poss.Count) { RegionPosition = positions[0]; }
|
||||
else if (0 == poss.Count) { RegionPosition = null; }
|
||||
|
||||
}
|
||||
|
||||
public TemplateRegion ToISORegion(TestObjectTemplate template, Zone zone, int number)
|
||||
{
|
||||
var region = new TemplateRegion(template.TemplateName, zone.Name, template.IsLocalOnly);
|
||||
region.Direction = null == RegionDirection ? "?" : RegionDirection.Direction;
|
||||
region.FilterClass = null == RegionFilterClass ? "?" : RegionFilterClass.Filter_Class;
|
||||
region.FineLocation1 = null == RegionFineLocation1 ? "??" : RegionFineLocation1.Fine_Loc_1;
|
||||
region.FineLocation2 = null == RegionFineLocation2 ? "??" : RegionFineLocation2.FINE_LOC_2;
|
||||
region.FineLocation3 = null == RegionFineLocation3 ? "??" : RegionFineLocation3.FINE_LOC_3;
|
||||
region.LowerRight = new System.Drawing.Point(Convert.ToInt32(RegionBottomRight.X), Convert.ToInt32(RegionBottomRight.Y));
|
||||
region.MainLocation = null == RegionMainLocation ? "????" : RegionMainLocation.Trans_Main_Loc;
|
||||
region.PhysicalDimension = null == RegionPhysicalDimension ? "??" : RegionPhysicalDimension.Physical_Dimension;
|
||||
region.Position = null == RegionPosition ? "?" : RegionPosition.Position;
|
||||
region.RegionDescription = RegionDescription;
|
||||
region.RegionName = RegionName;
|
||||
region.RegionNumber = number;
|
||||
region.TestObject = null == RegionTestObject ? "?" : RegionTestObject.Test_Object;
|
||||
region.UpperLeft = new System.Drawing.Point(Convert.ToInt32(RegionUpperLeft.X), Convert.ToInt32(RegionUpperLeft.Y));
|
||||
return region;
|
||||
}
|
||||
|
||||
private List<TemplateChannelUI> _regionUIChannels = new List<TemplateChannelUI>();
|
||||
public TemplateChannelUI[] RegionUIChannels
|
||||
{
|
||||
get => _regionUIChannels.ToArray();
|
||||
set => _regionUIChannels = new List<TemplateChannelUI>(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class DbOperationsEnum
|
||||
{
|
||||
public enum StoredProcedure
|
||||
{
|
||||
sp_DbVersionGet,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class DASHardware : DbTimeStampBase, IComparable<DASHardware>
|
||||
{
|
||||
public override ConstraintHelper[] GetConstraints()
|
||||
{
|
||||
return new ConstraintHelper[]
|
||||
{
|
||||
new ConstraintHelper()
|
||||
{
|
||||
ColumnName = DbOperations.DAS.Fields.SerialNumber.ToString(),
|
||||
DbType = System.Data.SqlDbType.NVarChar,
|
||||
DbValue = SerialNumber
|
||||
}
|
||||
};
|
||||
}
|
||||
public override string LookupTable => "tblDAS";
|
||||
|
||||
public enum Tags
|
||||
{
|
||||
MeasuredBatteryVoltage,
|
||||
MeasuredInputVoltage,
|
||||
Channels,
|
||||
ChannelCount,
|
||||
Selected,
|
||||
BackgroundColor,
|
||||
SerialNumber,
|
||||
DASTypeEnum,
|
||||
Connection,
|
||||
FirmwareVersion,
|
||||
MaxModules,
|
||||
ChannelTypes,
|
||||
Reprogramable,
|
||||
Reconfigurable,
|
||||
LocalOnly
|
||||
}
|
||||
public int CompareTo(DASHardware right)
|
||||
{
|
||||
if (null == right) { return 1; }
|
||||
if (this == right) { return 0; }
|
||||
return SerialNumber == right.SerialNumber ? Connection.CompareTo(right.Connection) : SerialNumber.CompareTo(right.SerialNumber);
|
||||
}
|
||||
|
||||
private List<HardwareChannel> _channels = new List<HardwareChannel>();
|
||||
public HardwareChannel[] Channels
|
||||
{
|
||||
get => _channels.ToArray();
|
||||
set
|
||||
{
|
||||
var channels = new List<HardwareChannel>(value);
|
||||
channels.Sort();
|
||||
SetProperty(ref _channels, channels, Tags.Channels.ToString());
|
||||
OnPropertyChanged(Tags.ChannelCount.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _hardware.SerialNumber;
|
||||
set
|
||||
{
|
||||
_hardware.SerialNumber = value;
|
||||
OnPropertyChanged(Tags.SerialNumber.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int GetHardwareTypeInt() { return _hardware.DASType; }
|
||||
public Hardware.HardwareTypes GetHardwareTypeEnum() { return (Hardware.HardwareTypes)GetHardwareTypeInt(); }
|
||||
|
||||
public string Connection
|
||||
{
|
||||
get => _hardware.IPAddress;
|
||||
set
|
||||
{
|
||||
_hardware.IPAddress = value;
|
||||
OnPropertyChanged(Tags.Connection.ToString());
|
||||
}
|
||||
}
|
||||
public DateTime CalDate => _hardware.CalDate;
|
||||
|
||||
public long GetMaxMemoryLong() { return _hardware.MaxMemory; }
|
||||
|
||||
public bool LocalOnly
|
||||
{
|
||||
get => _hardware.LocalOnly;
|
||||
set
|
||||
{
|
||||
_hardware.LocalOnly = value;
|
||||
OnPropertyChanged(Tags.LocalOnly.ToString());
|
||||
}
|
||||
}
|
||||
public DASHardware()
|
||||
{
|
||||
}
|
||||
public Dictionary<string, string> GetValues()
|
||||
{
|
||||
var elementNameValuePairs = new Dictionary<string, string>();
|
||||
|
||||
var isoH = GetHardware();
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.SerialNumber.ToString()] = isoH.SerialNumber;
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.Type.ToString()] = isoH.DASType.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.MaxModules.ToString()] = isoH.MaxModules.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.MaxMemory.ToString()] = isoH.MaxMemory.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.MaxSampleRate.ToString()] = isoH.MaxSampleRate.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.MinSampleRate.ToString()] = isoH.MinSampleRate.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.FirmwareVersion.ToString()] = isoH.FirmwareVersion;
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.CalDate.ToString()] = CalDate.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.ProtocolVersion.ToString()] = isoH.ProtocolVersion.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.LastModified.ToString()] = isoH.LastModified.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.LastModifiedBy.ToString()] = isoH.LastModifiedBy;
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.Version.ToString()] = isoH.Version.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.LocalOnly.ToString()] = isoH.LocalOnly.ToString();
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.LastUsed.ToString()] = isoH.LastUsed.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.LastUsedBy.ToString()] = isoH.LastUsedBy;
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.Connection.ToString()] = isoH.IPAddress;
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.Channels.ToString()] = isoH.Channels.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.Position.ToString()] = isoH.Position;
|
||||
|
||||
var channeltypes = new List<string>();
|
||||
foreach (var ct in isoH.ChannelTypes) { channeltypes.Add(ct.ToString(System.Globalization.CultureInfo.InvariantCulture)); }
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.ChannelTypes.ToString()] = string.Join(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, channeltypes.ToArray());
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.Reprogramable.ToString()] = isoH.IsProgrammable.ToString();
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.Reconfigurable.ToString()] = isoH.IsReconfigurable.ToString();
|
||||
elementNameValuePairs[DbOperations.DAS.Fields.IsModule.ToString()] = isoH.IsModule.ToString();
|
||||
|
||||
return elementNameValuePairs;
|
||||
}
|
||||
public Dictionary<string, string> GetChannelValues(HardwareChannel channel)
|
||||
{
|
||||
var elementNameValuePairs = new Dictionary<string, string>();
|
||||
|
||||
var isoH = GetHardware();
|
||||
var isoChannel = channel.GetISOChannel();
|
||||
|
||||
elementNameValuePairs[DbOperations.DAS.DASChannelFields.HardwareId.ToString()] = isoH.GetId();
|
||||
elementNameValuePairs[DbOperations.DAS.DASChannelFields.ChannelIdx.ToString()] = isoChannel.ChannelIdx.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.DASChannelFields.SupportedBridges.ToString()] = isoChannel.SupportedBridges.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.DASChannelFields.SupportedExcitations.ToString()] = isoChannel.SupportedExcitations.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.DASChannelFields.DASDisplayOrder.ToString()] = isoChannel.DASDisplayOrder.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.DASChannelFields.LocalOnly.ToString()] = isoChannel.LocalOnly.ToString();
|
||||
elementNameValuePairs[DbOperations.DAS.DASChannelFields.SupportedDigitalInputModes.ToString()] = isoChannel.SupportedDigitalInputModes.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.DASChannelFields.SupportedSquibFireModes.ToString()] = isoChannel.SupportedSquibFireModes.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.DASChannelFields.SupportedDigitalOutputModes.ToString()] = isoChannel.SupportedDigitalOutputModes.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.DAS.DASChannelFields.ModuleSerialNumber.ToString()] = isoChannel.ModuleSerialNumber;
|
||||
elementNameValuePairs[DbOperations.DAS.DASChannelFields.ModuleArrayIndex.ToString()] = isoChannel.ModuleArrayIndex.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
return elementNameValuePairs;
|
||||
}
|
||||
public DASHardware(DASHardware copy, DASHardware parentDAS)
|
||||
{
|
||||
if (null != copy.Channels)
|
||||
{
|
||||
var channels = new List<HardwareChannel>();
|
||||
foreach (var ch in copy.Channels) { channels.Add(new HardwareChannel(ch)); }
|
||||
Channels = channels.ToArray();
|
||||
}
|
||||
|
||||
_hardware = new Hardware(copy.GetHardware());
|
||||
DbTimeStamp = copy.DbTimeStamp;
|
||||
}
|
||||
private Hardware _hardware = new Hardware();
|
||||
public Hardware GetHardware() { return _hardware; }
|
||||
/// <summary>
|
||||
/// note that if you use this constructor, you should set
|
||||
/// TimeStampDb explicitly
|
||||
/// </summary>
|
||||
/// <param name="hardware"></param>
|
||||
public DASHardware(Hardware hardware)
|
||||
{
|
||||
_hardware = new Hardware(hardware);
|
||||
_hardware.IPAddress = Connection;
|
||||
|
||||
var channels = new List<HardwareChannel>();
|
||||
foreach (var channel in hardware.ISOChannels)
|
||||
{
|
||||
channels.Add(new HardwareChannel(channel, this));
|
||||
}
|
||||
Channels = channels.ToArray();
|
||||
}
|
||||
public bool IsDummy()
|
||||
{
|
||||
return SerialNumber.Contains("Dummy");
|
||||
}
|
||||
|
||||
}
|
||||
public class DASHardwareList //: Common.BindableBase
|
||||
{
|
||||
private static DASHardwareList _list;
|
||||
public static DASHardwareList GetList()
|
||||
{
|
||||
if (null == _list)
|
||||
{
|
||||
_list = new DASHardwareList();
|
||||
_list.PopulateHardware();
|
||||
}
|
||||
|
||||
return _list;
|
||||
}
|
||||
|
||||
public DASHardware GetHardware(string id)
|
||||
{
|
||||
bool bNotUsed;
|
||||
return GetHardware(id, true, out bNotUsed);
|
||||
}
|
||||
public DASHardware GetHardware(string id, bool bThrowExceptionIfChanged, out bool changed)
|
||||
{
|
||||
changed = false;
|
||||
if (_hardware.ContainsKey(id)) { return _hardware[id]; }
|
||||
else
|
||||
{
|
||||
var matchingSerial = from h in _hardware where h.Value.SerialNumber == id select h.Value;
|
||||
if (matchingSerial.Count() > 0) { return matchingSerial.First(); }
|
||||
else
|
||||
{
|
||||
//check to see if the type changed?
|
||||
var index = id.IndexOf('_');
|
||||
if (index >= 0)
|
||||
{
|
||||
id = id.Substring(0, index);
|
||||
}
|
||||
var match2 = from h in _hardware where h.Value.SerialNumber == id select h.Value;
|
||||
|
||||
if (match2.Count() > 0)
|
||||
{
|
||||
if (bThrowExceptionIfChanged)
|
||||
{
|
||||
throw new HardwareTypeChangedException();
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class HardwareTypeChangedException : Exception
|
||||
{
|
||||
public HardwareTypeChangedException() { }
|
||||
}
|
||||
private DASHardware[] GetAllHardware()
|
||||
{
|
||||
var hardware = new List<DASHardware>();
|
||||
var temp = new DASHardware();
|
||||
var allTimeStamps = temp.GetAllTimeStampDb();
|
||||
foreach (var hw in DatabaseExport.Hardware.GetAllDAS())
|
||||
{
|
||||
if (hw.Position == "Prototype" /*DbOperations.DAS.PROTOTYPE_POSITION*/) { continue; } //fix this
|
||||
else
|
||||
{
|
||||
var newH = new DASHardware(hw);
|
||||
newH.SetTimeStampMemory(newH.GetTimeStampDb(allTimeStamps));
|
||||
hardware.Add(newH);
|
||||
}
|
||||
}
|
||||
|
||||
return hardware.ToArray();
|
||||
}
|
||||
|
||||
private Dictionary<string, DASHardware> _hardware = null;
|
||||
public DASHardware[] Hardware
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == _hardware)
|
||||
{
|
||||
PopulateHardware();
|
||||
}
|
||||
return _hardware.Values.ToArray();
|
||||
}
|
||||
}
|
||||
private void PopulateHardware()
|
||||
{
|
||||
_hardware = new Dictionary<string, DASHardware>();
|
||||
foreach (var h in GetAllHardware())
|
||||
{
|
||||
if (!_hardware.ContainsKey(h.GetHardware().GetId())) { _hardware.Add(h.GetHardware().GetId(), h); }
|
||||
else { _hardware[h.GetHardware().GetId()] = h; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TabPageItem : TabPageCommon
|
||||
{
|
||||
public UserControl Content { get; set; } = null;
|
||||
}
|
||||
|
||||
public class TabPageItemGroup : TabPageCommon
|
||||
{
|
||||
public ObservableCollection<TabPageItem> Items { get; } = new ObservableCollection<TabPageItem>();
|
||||
}
|
||||
|
||||
public class TabPageSource
|
||||
{
|
||||
private static TabPageSource _source = new TabPageSource();
|
||||
|
||||
public ObservableCollection<TabPageItemGroup> AllGroups { get; } = new ObservableCollection<TabPageItemGroup>();
|
||||
|
||||
public static IEnumerable<TabPageItemGroup> GetGroups(string uniqueid)
|
||||
{
|
||||
if (!uniqueid.Equals("AllGroups")) throw new ArgumentException("Only 'AllGroups' is supported as a collection of groups");
|
||||
return _source.AllGroups;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a simplified class to represent a row in the tblTestTemplates table for tables
|
||||
/// it was designed as a short term alternative to TestTempalte itself
|
||||
/// </summary>
|
||||
public class TestTemplateTableObject
|
||||
{
|
||||
public TestTemplateTableObject(string name,
|
||||
string description,
|
||||
RecordingModes recordingMode,
|
||||
DateTime lastModified,
|
||||
string lastModifiedBy,
|
||||
bool isComplete,
|
||||
string completionErrorMessage,
|
||||
bool useCustomerDetails,
|
||||
string customerDetails,
|
||||
int[] tagIds)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
RecordingMode = recordingMode;
|
||||
LastModified = lastModified;
|
||||
LastModifiedBy = lastModifiedBy;
|
||||
IsComplete = isComplete;
|
||||
CompletionErrorMessage = completionErrorMessage;
|
||||
UseCustomerDetails = useCustomerDetails;
|
||||
CustomerDetails = customerDetails;
|
||||
TagIds = tagIds;
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public RecordingModes RecordingMode { get; private set; }
|
||||
public DateTime LastModified { get; private set; }
|
||||
public string LastModifiedBy { get; private set; }
|
||||
public bool IsComplete { get; private set; }
|
||||
public string CompletionErrorMessage { get; private set; }
|
||||
public bool UseCustomerDetails { get; private set; }
|
||||
public string CustomerDetails { get; private set; }
|
||||
public int[] TagIds { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a class for holding das specific settings in a test, for example sample rate or aaf
|
||||
/// it is serialized into tblTestSetupDASSettings
|
||||
/// </summary>
|
||||
public class DASSettings //: Common.BindableBase
|
||||
{
|
||||
public string DASSerialNumber { get; set; }
|
||||
|
||||
public double SampleRate { get; set; }
|
||||
|
||||
public int ExcitationWarmupTimeMS { get; set; }
|
||||
|
||||
public double HardwareAAF { get; set; }
|
||||
|
||||
public double PreTriggerSeconds { get; set; }
|
||||
|
||||
public double PostTriggerSeconds { get; set; }
|
||||
|
||||
public bool StatusLineCheck { get; set; }
|
||||
|
||||
public bool BatteryCheck { get; set; }
|
||||
|
||||
public double InputVoltageMin { get; set; }
|
||||
|
||||
public double InputVoltageMax { get; set; }
|
||||
|
||||
public double BatteryVoltageMin { get; set; }
|
||||
|
||||
public double BatteryVoltageMax { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Exceptional.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// "Ultimate" base class for all DTS classes that expect to throw exceptions.
|
||||
/// Deriving classes from this class allows exceptions to be trapped based on
|
||||
/// the class type that threw them.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Sample usage:
|
||||
/// public class A : Exceptional
|
||||
/// {
|
||||
/// public void ScrewItUp( )
|
||||
/// {
|
||||
/// private bool error = true;
|
||||
/// if ( error ) throw new A.Exception( "Class A-specific screwup." );
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// ...
|
||||
///
|
||||
/// try
|
||||
/// {
|
||||
/// A.ScrewItUp( );
|
||||
/// B.ScrewItUp( );
|
||||
/// C.ScrewItUp( );
|
||||
/// }
|
||||
/// catch ( A.Exception ex )
|
||||
/// {
|
||||
/// // Can pick A's exceptions out of a crowd, or not and just treat it
|
||||
/// // polymorphically as a System.Exception.
|
||||
/// }
|
||||
/// </remarks>
|
||||
///
|
||||
[Serializable]
|
||||
public abstract class Exceptional
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class RegionAdorner : Adorner
|
||||
{
|
||||
public Point GetUpperLeft()
|
||||
{
|
||||
var p = SelectRect.TopLeft;
|
||||
|
||||
var i = AdornedElement as Image;
|
||||
|
||||
var s = new Size(i.Source.Width, i.Source.Height);
|
||||
var difX = (s.Width - _MeasuredSize.Width);
|
||||
var difY = s.Height - _MeasuredSize.Height;
|
||||
var scaleX = difX / _MeasuredSize.Width;
|
||||
var scaleY = difY / _MeasuredSize.Height;
|
||||
p = new Point(p.X + p.X * scaleX, p.Y + p.Y * scaleY);
|
||||
|
||||
|
||||
return p;
|
||||
}
|
||||
public Point GetLowerRight()
|
||||
{
|
||||
var p = SelectRect.BottomRight;
|
||||
|
||||
var i = AdornedElement as Image;
|
||||
if (null == i.Source) { return new Point(0, 0); }
|
||||
var s = new Size(i.Source.Width, i.Source.Height);
|
||||
var difX = (s.Width - _MeasuredSize.Width);
|
||||
var difY = s.Height - _MeasuredSize.Height;
|
||||
var scaleX = difX / _MeasuredSize.Width;
|
||||
var scaleY = difY / _MeasuredSize.Height;
|
||||
|
||||
p = new Point(p.X + p.X * scaleX, p.Y + p.Y * scaleY);
|
||||
return p;
|
||||
}
|
||||
public delegate void RegionSelectedHandler(RegionAdorner r, MouseButtonEventArgs e);
|
||||
public event RegionSelectedHandler OnRegionSelected;
|
||||
|
||||
private bool _bNew = true;
|
||||
public bool IsNew
|
||||
{
|
||||
get => _bNew;
|
||||
set
|
||||
{
|
||||
_bNew = value;
|
||||
if (_bNew)
|
||||
{
|
||||
MyRegion.RegionAddVisibility = Visibility.Visible;
|
||||
MyRegion.RegionDeleteVisibility = Visibility.Hidden;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyRegion.RegionDeleteVisibility = Visibility.Visible;
|
||||
MyRegion.RegionAddVisibility = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Point __anchorPoint;
|
||||
public Point AnchorPoint
|
||||
{
|
||||
get => __anchorPoint;
|
||||
set => __anchorPoint = value;
|
||||
}
|
||||
private UIElement _adornedElement;
|
||||
private Path _path;
|
||||
private Rect __selectRect;
|
||||
public Rect SelectRect
|
||||
{
|
||||
get => __selectRect;
|
||||
set
|
||||
{
|
||||
__selectRect = value;
|
||||
MyRegion.RegionUpperLeft = GetUpperLeft();
|
||||
MyRegion.RegionBottomRight = GetLowerRight();
|
||||
}
|
||||
}
|
||||
private RectangleGeometry _geometry;
|
||||
|
||||
private Region _region;
|
||||
public Region MyRegion
|
||||
{
|
||||
get => _region;
|
||||
set => _region = value;
|
||||
}
|
||||
public RegionAdorner(UIElement adornedElement, TestObjectTemplate template, Contexts context)
|
||||
: base(adornedElement)
|
||||
{
|
||||
_region = new Region(this, template);
|
||||
_adornedElement = adornedElement;
|
||||
SelectRect = new Rect();
|
||||
_geometry = new RectangleGeometry();
|
||||
_path = new Path();
|
||||
_path.Data = _geometry;
|
||||
_path.StrokeThickness = 5;
|
||||
_path.Stroke = Brushes.AliceBlue;
|
||||
_path.Opacity = .6;
|
||||
_path.Visibility = Visibility.Hidden;
|
||||
MouseLeftButtonUp += new MouseButtonEventHandler(Region_MouseLeftButtonUp);
|
||||
MouseMove += new MouseEventHandler(Region_MouseMove);
|
||||
MouseLeftButtonDown += new MouseButtonEventHandler(Region_MouseLeftButtonDown);
|
||||
_MeasuredSize = adornedElement.RenderSize;
|
||||
//_region.PropertyChanged += new PropertyChangedEventHandler(_region_PropertyChanged);
|
||||
Context = context;
|
||||
}
|
||||
void Region_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
EndSelection(sender, e);
|
||||
}
|
||||
public enum Contexts { EditTestObject, EditTestObjectTemplate };
|
||||
private Contexts _context;
|
||||
public Contexts Context
|
||||
{
|
||||
get => _context;
|
||||
set => _context = value;
|
||||
}
|
||||
void Region_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (null != OnRegionSelected) { OnRegionSelected(this, e); }
|
||||
}
|
||||
private Size __MeasuredSize;
|
||||
private Size _MeasuredSize
|
||||
{
|
||||
get => __MeasuredSize;
|
||||
set => __MeasuredSize = value;
|
||||
}
|
||||
private Point p1;
|
||||
public void Region_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
if (IsNew) { DrawSelection(sender, e, _adornedElement); }
|
||||
else { MoveSelection(sender, e, _adornedElement); }
|
||||
|
||||
var layer = AdornerLayer.GetAdornerLayer(_adornedElement);
|
||||
InvalidateVisual();
|
||||
layer.InvalidateVisual();
|
||||
}
|
||||
}
|
||||
public void DrawSelection(object sender, MouseEventArgs e, UIElement adornedElement)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
var mousePosition = e.GetPosition(adornedElement);
|
||||
var r = SelectRect;
|
||||
if (mousePosition.X < AnchorPoint.X) { r.X = mousePosition.X; }
|
||||
else { r.X = AnchorPoint.X; }
|
||||
if (mousePosition.Y < AnchorPoint.Y) { r.Y = mousePosition.Y; }
|
||||
else { r.Y = AnchorPoint.Y; }
|
||||
r.Width = Math.Abs(mousePosition.X - AnchorPoint.X);
|
||||
r.Height = Math.Abs(mousePosition.Y - AnchorPoint.Y);
|
||||
SelectRect = r;
|
||||
_geometry.Rect = SelectRect;
|
||||
}
|
||||
}
|
||||
public void MoveSelection(object sender, MouseEventArgs e, UIElement adornedElement)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
var mousePosition = e.GetPosition(adornedElement);
|
||||
var r = SelectRect;
|
||||
r.X -= /*p1.X -*/ (p1.X - mousePosition.X);
|
||||
r.Y -= /*p1.Y -*/(p1.Y - mousePosition.Y);
|
||||
SelectRect = r;
|
||||
p1 = mousePosition;
|
||||
_geometry.Rect = SelectRect;
|
||||
}
|
||||
}
|
||||
public delegate void EndSelectionHandler(RegionAdorner r);
|
||||
public event EndSelectionHandler OnEndSelection;
|
||||
|
||||
public void EndSelection(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ReleaseMouseCapture();
|
||||
if (null != OnEndSelection) { OnEndSelection(this); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DatabaseExport.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("ISO\\mme_code.mdb")]
|
||||
public string ISOMMEDbLocation {
|
||||
get {
|
||||
return ((string)(this["ISOMMEDbLocation"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool AllowAutoArm {
|
||||
get {
|
||||
return ((bool)(this["AllowAutoArm"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("7")]
|
||||
public int CalWarningPeriodDays {
|
||||
get {
|
||||
return ((int)(this["CalWarningPeriodDays"]));
|
||||
}
|
||||
set {
|
||||
this["CalWarningPeriodDays"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("1")]
|
||||
public int DBType {
|
||||
get {
|
||||
return ((int)(this["DBType"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultSuppressMissingSensorsWarning {
|
||||
get {
|
||||
return ((bool)(this["DefaultSuppressMissingSensorsWarning"]));
|
||||
}
|
||||
set {
|
||||
this["DefaultSuppressMissingSensorsWarning"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool DefaultTestAllowMissingSensors {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestAllowMissingSensors"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestAllowSensorIdToBlankChannel {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestAllowSensorIdToBlankChannel"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool DefaultTestArmCheckListStep {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestArmCheckListStep"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestCheckListBatteryVoltageCheck {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestCheckListBatteryVoltageCheck"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestCheckListInputVoltageCheck {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestCheckListInputVoltageCheck"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool DefaultTestCheckListMustPass {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestCheckListMustPass"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestCheckListSensorIDCheck {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestCheckListSensorIDCheck"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestCheckListSquibResistanceCheck {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestCheckListSquibResistanceCheck"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestCheckListTriggerStartCheck {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestCheckListTriggerStartCheck"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestDownloadAll {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestDownloadAll"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestDownloadROI {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestDownloadROI"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("6000")]
|
||||
public int DefaultTestExcitationWarmupMS {
|
||||
get {
|
||||
return ((int)(this["DefaultTestExcitationWarmupMS"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool DefaultTestExport {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestExport"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool DefaultTestQuitTestWithoutWarning {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestQuitTestWithoutWarning"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("6")]
|
||||
public int DefaultTestRealtimeModeGraphCount {
|
||||
get {
|
||||
return ((int)(this["DefaultTestRealtimeModeGraphCount"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("0")]
|
||||
public ulong DefaultTestExportFormat {
|
||||
get {
|
||||
return ((ulong)(this["DefaultTestExportFormat"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestRequireAllUnitsPassDiagnostics {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestRequireAllUnitsPassDiagnostics"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestRequireUserConfirmationOnErrors {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestRequireUserConfirmationOnErrors"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("1")]
|
||||
public double DefaultTestROIEnd {
|
||||
get {
|
||||
return ((double)(this["DefaultTestROIEnd"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("-1")]
|
||||
public double DefaultTestROIStart {
|
||||
get {
|
||||
return ((double)(this["DefaultTestROIStart"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool DefaultTestRunPostTestDiagnostics {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestRunPostTestDiagnostics"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("10000")]
|
||||
public double DefaultTestSampleRate {
|
||||
get {
|
||||
return ((double)(this["DefaultTestSampleRate"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool DefaultTestSuppressNotAllChannelsViewedWarningRealTime {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestSuppressNotAllChannelsViewedWarningRealTime"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestTriggerCheckStep {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestTriggerCheckStep"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool DefaultTestSuppressNotAllChannelsViewedWarningViewer {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestSuppressNotAllChannelsViewedWarningViewer"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool DefaultTestViewAll {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestViewAll"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool DefaultTestViewROI {
|
||||
get {
|
||||
return ((bool)(this["DefaultTestViewROI"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool DefaultUploadEnabled {
|
||||
get {
|
||||
return ((bool)(this["DefaultUploadEnabled"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("..\\Data")]
|
||||
public string DownloadFolder {
|
||||
get {
|
||||
return ((string)(this["DownloadFolder"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool RequireXCrashCompatibilityForISOExports {
|
||||
get {
|
||||
return ((bool)(this["RequireXCrashCompatibilityForISOExports"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("InstallerCustomActions")]
|
||||
public string InstallerCustomActions {
|
||||
get {
|
||||
return ((string)(this["InstallerCustomActions"]));
|
||||
}
|
||||
set {
|
||||
this["InstallerCustomActions"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// a test object is a top level object in the ISO database
|
||||
/// given a test object, it is possible to find all possible channels as defined in ISO
|
||||
/// note there is a ? test object ...
|
||||
/// I'll use these to build templates
|
||||
/// </summary>
|
||||
public class MMETestObjects : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Test_Object { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
|
||||
public MMETestObjects(string sGuid, string testObject, string textL1, string textL2, long version,
|
||||
DateTime date, string remarks, bool expired, string sortkey, DateTime lastChange, string lastChangeText,
|
||||
string history, MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
Test_Object = testObject;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortkey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
public static MMETestObjects GetTestObject(OleDbConnection connection, string sGUID)
|
||||
{
|
||||
var testObjects = new List<MMETestObjects>();
|
||||
try
|
||||
{
|
||||
using (var command = new OleDbCommand())
|
||||
{
|
||||
command.Connection = connection;
|
||||
var param = new OleDbParameter("@SGuid", sGUID);
|
||||
command.Parameters.Add(param);
|
||||
command.CommandText = "SELECT * from [MME_TEST_OBJECTS] WHERE [s_GUID]=@SGuid";
|
||||
|
||||
using (var reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
var sGuid = reader["s_GUID"].ToString();
|
||||
var testObject = reader["TEST_OBJECT"].ToString();
|
||||
var textL1 = reader["TEXT_L1"].ToString();
|
||||
var textL2 = reader["TEXT_L2"].ToString();
|
||||
var version = AbstractOLEDbWrapper.GetLong(reader, "VERSION");
|
||||
var date = (DateTime)reader["DATE"];
|
||||
var remarks = reader["REMARKS"].ToString();
|
||||
var expired = (bool)reader["EXPIRED"];
|
||||
var sortkey = reader["SORTKEY"].ToString();
|
||||
var lastChange = AbstractOLEDbWrapper.GetDate(reader, "LAST_CHANGE");
|
||||
var lastChangeText = reader["LAST_CHANGE_TEXT"].ToString();
|
||||
var history = reader["HISTORY"].ToString();
|
||||
testObjects.Add(new MMETestObjects(sGuid, testObject, textL1, textL2, version, date, remarks, expired,
|
||||
sortkey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
}
|
||||
}
|
||||
long l;
|
||||
if (long.TryParse(sGUID, out l))
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * from {0} where {1}=@{1}", DbOperations.MMETables.MMETestObjectsTable,
|
||||
DbOperations.MMETables.MMETestObjectsFields.s_GUID.ToString());
|
||||
DbOperations.CreateParam(cmd, string.Format("@{0}", DbOperations.MMETables.MMETestObjectsFields.s_GUID.ToString()),
|
||||
System.Data.SqlDbType.BigInt, l);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.MMETables.MMETestObjectsFields))
|
||||
.Cast<DbOperations.MMETables.MMETestObjectsFields>().ToArray();
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var version = 0;
|
||||
var text2 = "";
|
||||
var text1 = "";
|
||||
var testObject = "?";
|
||||
var sortkey = "";
|
||||
var remarks = "";
|
||||
var lastChangeText = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var history = "";
|
||||
var expired = false;
|
||||
var date = DateTime.Now;
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()])) { continue; }
|
||||
|
||||
var o = dr[field.ToString()];
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMETestObjectsFields.DATE:
|
||||
date = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.EXPIRED:
|
||||
expired = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.HISTORY:
|
||||
history = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.LAST_CHANGE:
|
||||
lastChange = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.REMARKS:
|
||||
remarks = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.s_GUID:
|
||||
//this was part of the where ... we don't need it
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.SORTKEY:
|
||||
sortkey = Convert.ToString(sortkey);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.TEST_OBJECT:
|
||||
testObject = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.TEXT_L1:
|
||||
text1 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.TEXT_L2:
|
||||
text2 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.VERSION:
|
||||
version = Convert.ToInt32(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
testObjects.Add(new MMETestObjects(sGUID, testObject, text1, text2, Convert.ToInt64(version), date, remarks, expired, sortkey,
|
||||
lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
if (testObjects.Count > 0) { return testObjects[0]; }
|
||||
else { return null; }
|
||||
}
|
||||
public static MMETestObjects[] GetTestObjects()
|
||||
{
|
||||
var testObjects = new List<MMETestObjects>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMETestObjects";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string testObject = ISOReader["TEST_OBJECT"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = GetLong(ISOReader, "VERSION");
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
testObjects.Add(new MMETestObjects(sGuid, testObject, textL1, textL2, version, date, remarks, expired,
|
||||
sortkey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * FROM {0}", DbOperations.MMETables.MMETestObjectsTable);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.MMETables.MMETestObjectsFields))
|
||||
.Cast<DbOperations.MMETables.MMETestObjectsFields>().ToArray();
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var version = 0;
|
||||
var text2 = "";
|
||||
var text1 = "";
|
||||
var textObject = "?";
|
||||
var sortKey = "";
|
||||
var sGuid = "";
|
||||
var remarks = "";
|
||||
var lastChangeText = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var history = "";
|
||||
var expired = false;
|
||||
var date = DateTime.Now;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var o = dr[field.ToString()];
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMETestObjectsFields.DATE:
|
||||
date = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.EXPIRED:
|
||||
expired = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.HISTORY:
|
||||
history = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.LAST_CHANGE:
|
||||
lastChange = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.REMARKS:
|
||||
remarks = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.s_GUID:
|
||||
sGuid = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.SORTKEY:
|
||||
sortKey = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.TEST_OBJECT:
|
||||
textObject = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.TEXT_L1:
|
||||
text1 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.TEXT_L2:
|
||||
text2 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMETestObjectsFields.VERSION:
|
||||
version = Convert.ToInt32(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
testObjects.Add(new MMETestObjects(sGuid.ToString(), textObject, text1, text2, Convert.ToInt64(version), date, remarks, expired, sortKey,
|
||||
lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
return testObjects.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public sealed class SerializedSettings
|
||||
{
|
||||
public enum Keys
|
||||
{
|
||||
IgnorePowerMode,
|
||||
UseUserCodes,
|
||||
NumberRealtimeCharts,
|
||||
UseCircBufTriggerCheck,
|
||||
TriggerCheckPostRealtime,
|
||||
DeriveROIFromAll,
|
||||
// ReSharper disable once InconsistentNaming
|
||||
CRIBCOM,
|
||||
LastEventStartTime,
|
||||
ExportINIFile,
|
||||
ShowISOCodes,
|
||||
UseMeterModeTable,
|
||||
AutoArmDiagLevel,
|
||||
AutoArmDiagDelayMS,
|
||||
RealtimeSampleRates,
|
||||
RealtimeSampleRate,
|
||||
OverheadPercent,
|
||||
AutozeroRealtime,
|
||||
AllowCalculatedChannels,
|
||||
AllowLevelTriggerUI,
|
||||
TDASCalPeriod,
|
||||
G5CalPeriod,
|
||||
Slice1CalPeriod,
|
||||
Slice1_5CalPeriod,
|
||||
Slice2_CalPeriod,
|
||||
CalWarningPeriod,
|
||||
CalHWGracePeriod,
|
||||
HardwareCalPolicy,
|
||||
DefaultRecordingMode,
|
||||
DefaultIsoChannelSensorCompatibilityLevel,
|
||||
AllowAdvancedRecordingModes,
|
||||
IncludeGroupNameInISOExport,
|
||||
WarnIfTestCancelledWithoutExport,
|
||||
DiademChannelName200Option,
|
||||
DiademUserComment201Option,
|
||||
StartingTestSetup,
|
||||
SensitivityDisplayFormat,
|
||||
TriggerSecondsDisplayFormat,
|
||||
NonLinearDisplayFormat,
|
||||
TestSetupDefaultAutomaticMode,
|
||||
CommonStatusLine,
|
||||
AutomaticModeDelayMS,
|
||||
IsoSupportLevel,
|
||||
TriggerCheckQuickMode,
|
||||
Diagnostics_TDAS_TimeoutSec,
|
||||
Diagnostics_SLICE_TimeoutSec,
|
||||
ResolveChannels_TDAS_QueryDownloadTimeoutSec,
|
||||
ResolveChannels_SLICE_QueryDownloadTimeoutSec,
|
||||
ResolveChannels_TDAS_QueryConfigTimeoutSec,
|
||||
ResolveChannels_SLICE_QueryConfigTimeoutSec,
|
||||
SLICE_CONNECT_ALLOWED_SECONDS,
|
||||
TDAS_CONNECT_ALLOWED_SECONDS,
|
||||
ISOSupport_Allow_Transitional,
|
||||
ISOSupport_Allow_NonISO,
|
||||
TestSetup_AllowQuickTestSetup,
|
||||
Graphs_PFSZoomValues,
|
||||
AutoAdd_ArmChecklist,
|
||||
TESTSETUP_WARNBATFAIL,
|
||||
TESTSETUPDEFAULT_DONTALLOWOUTOFCALSENSOR,
|
||||
SPSINDICE_COUNT,
|
||||
TDAS_MAXAAFRATE,
|
||||
G5_MAXAAFRATE,
|
||||
DefaultDigitalOutMode,
|
||||
DownloadMode,
|
||||
SLICE_Distributor_PowerSetting,
|
||||
TDAS_Pro_Rack_PowerSetting,
|
||||
G5VDS_PowerSetting,
|
||||
SLICE1_5_Nano_Base_PowerSetting,
|
||||
SLICE_Micro_Base_PowerSetting,
|
||||
SLICE_NANO_Base_PowerSetting,
|
||||
SLICE2_SIM_PowerSetting,
|
||||
SLICE2_DIM_PowerSetting,
|
||||
SLICE2_TOM_PowerSetting,
|
||||
G5INDUMMY_PowerSetting,
|
||||
SLICE_EthernetController_PowerSetting,
|
||||
SLICE1_5_Micro_Base_PowerSetting,
|
||||
SLICE_LabEthernet_PowerSetting,
|
||||
SLICE2_SLS_PowerSetting,
|
||||
SLICE1_G5Stack_PowerSetting,
|
||||
SLICE2_SLT_PowerSetting,
|
||||
SLICE2_SLD_PowerSetting,
|
||||
RealtimeSampleRateSliceUSB,
|
||||
RealtimeSampleRateSliceIP,
|
||||
RealtimeSampleRateTDASG5,
|
||||
MaxParallelTDASDownloads,
|
||||
UseTestSetupNameForTestIDHeaderInCSVExport,
|
||||
TestIDPrefixSuffixValues,
|
||||
SLICE6_PowerSetting,
|
||||
SLICE6_CalPeriod,
|
||||
WarnOnEIDPositionSwap,
|
||||
AllowEIDSensorsOutOfPlace,
|
||||
SLICE6MulticastResponsePort,
|
||||
SLICE6MulticastCommandPort,
|
||||
SLICE6MulticastAddress,
|
||||
ClearDBBeforeTSFImport,
|
||||
//Valid Sample Rates
|
||||
SPSINDEX_0,
|
||||
SPSINDEX_1,
|
||||
SPSINDEX_2,
|
||||
SPSINDEX_3,
|
||||
SPSINDEX_4,
|
||||
SPSINDEX_5,
|
||||
SPSINDEX_6,
|
||||
SPSINDEX_7,
|
||||
SPSINDEX_8,
|
||||
SPSINDEX_9,
|
||||
SPSINDEX_10,
|
||||
SPSINDEX_11,
|
||||
SPSINDEX_12,
|
||||
SPSINDEX_13,
|
||||
SPSINDEX_14,
|
||||
SPSINDEX_15,
|
||||
SPSINDEX_16,
|
||||
SPSINDEX_17,
|
||||
SPSINDEX_18,
|
||||
SPSINDEX_19,
|
||||
SPSINDEX_20,
|
||||
SPSINDEX_21,
|
||||
SPSINDEX_22,
|
||||
SPSINDEX_23,
|
||||
POWERPRO_CalPeriod,
|
||||
SLICE6Air_CalPeriod,
|
||||
SLICE6DB_CalPeriod,
|
||||
TSRAir_CalPeriod
|
||||
}
|
||||
public const string ExportINIFileDefault = "";
|
||||
/// <summary>
|
||||
/// the location of the export INI file in use.
|
||||
/// This is used by GMMilford to control the directories of some export files
|
||||
/// </summary>
|
||||
public static string ExportINIFile
|
||||
{
|
||||
get => SettingsDB.GetGlobalValue(Keys.ExportINIFile.ToString(), ExportINIFileDefault);
|
||||
set => SettingsDB.SetGlobalValue(Keys.ExportINIFile.ToString(), value);
|
||||
}
|
||||
public static IsoChannelSensorCompatibilityLevels IsoChannelSensorCompatibilityLevelDefault = IsoChannelSensorCompatibilityLevels.Warn;
|
||||
public static IsoChannelSensorCompatibilityLevels IsoChannelSensorCompatibilityLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
var s = SettingsDB.GetGlobalValue(Keys.DefaultIsoChannelSensorCompatibilityLevel.ToString(), IsoChannelSensorCompatibilityLevelDefault.ToString());
|
||||
return !Enum.TryParse(s, out IsoChannelSensorCompatibilityLevels isoChannelSensorCompatibilityLevel) ? IsoChannelSensorCompatibilityLevelDefault : isoChannelSensorCompatibilityLevel;
|
||||
}
|
||||
set => SettingsDB.SetGlobalValue(Keys.DefaultIsoChannelSensorCompatibilityLevel.ToString(), value.ToString());
|
||||
}
|
||||
public const bool TestSetupAutomaticModeDefault = false;
|
||||
public static bool TestSetupAutomaticMode
|
||||
{
|
||||
get => SettingsDB.GetGlobalValueBool(Keys.TestSetupDefaultAutomaticMode.ToString(), TestSetupAutomaticModeDefault);
|
||||
set => SettingsDB.SetGlobalValueBoolean(Keys.TestSetupDefaultAutomaticMode.ToString(), value);
|
||||
}
|
||||
|
||||
|
||||
public const bool TestSetupDefault_CommonStatusLineDefault = true;
|
||||
public static bool TestSetupDefaultCommonStatusLine
|
||||
{
|
||||
get => SettingsDB.GetGlobalValueBool(Keys.CommonStatusLine.ToString(), TestSetupDefault_CommonStatusLineDefault);
|
||||
set => SettingsDB.SetGlobalValueBoolean(Keys.CommonStatusLine.ToString(), value);
|
||||
}
|
||||
|
||||
|
||||
public const int TestSetupAutomaticProgressDelayMSDefault = 0;
|
||||
public static int TestSetupAutomaticProgressDelayMS
|
||||
{
|
||||
get => SettingsDB.GetGlobalValueInt(Keys.AutomaticModeDelayMS.ToString(), TestSetupAutomaticProgressDelayMSDefault);
|
||||
set => SettingsDB.SetGlobalValueInt(Keys.AutomaticModeDelayMS.ToString(), value);
|
||||
}
|
||||
|
||||
public enum ISOSupportLevels
|
||||
{
|
||||
ISO_ONLY, //channels named by iso
|
||||
TRANSITORY, //UserValue1 for JCODE/Chimchim/etc, which takes the place of isocode in multiple places
|
||||
NO_ISO //channels named by user only
|
||||
}
|
||||
|
||||
|
||||
public const ISOSupportLevels ISOSupportLevelDefault = ISOSupportLevels.ISO_ONLY;
|
||||
public static ISOSupportLevels ISOSupportLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
var s = SettingsDB.GetGlobalValue(Keys.IsoSupportLevel.ToString(), ISOSupportLevelDefault.ToString());
|
||||
return !Enum.TryParse(s, out ISOSupportLevels level) ? ISOSupportLevels.ISO_ONLY : level;
|
||||
}
|
||||
set => SettingsDB.SetGlobalValue(Keys.IsoSupportLevel.ToString(), value.ToString());
|
||||
}
|
||||
public const bool TestSetupDefaultWarnOnBatteryFailDefault = false;
|
||||
public static bool TestSetupDefaultWarnOnBatteryFail
|
||||
{
|
||||
get => SettingsDB.GetGlobalValueBool(Keys.TESTSETUP_WARNBATFAIL.ToString(), TestSetupDefaultWarnOnBatteryFailDefault);
|
||||
set => SettingsDB.SetGlobalValueBoolean(Keys.TESTSETUP_WARNBATFAIL.ToString(), value);
|
||||
}
|
||||
|
||||
|
||||
public const bool TestSetupDefaultDontAllowOutOfCalSensorsDefault = false;
|
||||
public static bool TestSetupDefaultDontAllowOutOfCalSensors
|
||||
{
|
||||
get => SettingsDB.GetGlobalValueBool(Keys.TESTSETUPDEFAULT_DONTALLOWOUTOFCALSENSOR.ToString(), TestSetupDefaultDontAllowOutOfCalSensorsDefault);
|
||||
set => SettingsDB.SetGlobalValueBoolean(Keys.TESTSETUPDEFAULT_DONTALLOWOUTOFCALSENSOR.ToString(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public abstract class TagAwareBase : DbTimeStampBase
|
||||
{
|
||||
public byte[] TagsBlobBytes
|
||||
{
|
||||
get
|
||||
{
|
||||
byte[] result = new byte[TagIDs.Length * sizeof(int)];
|
||||
Buffer.BlockCopy(TagIDs, 0, result, 0, result.Length);
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
var tagsBlob = new int[value.Length / sizeof(int)];
|
||||
try
|
||||
{
|
||||
Buffer.BlockCopy(value, 0, tagsBlob, 0, value.Length);
|
||||
TagIDs = tagsBlob;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//Utilities.Logging.APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int[] _tagIDs = new int[0];
|
||||
public int[] TagIDs
|
||||
{
|
||||
get => _tagIDs;
|
||||
set => _tagIDs = value ?? new int[0];
|
||||
}
|
||||
public string GetTagsCommaSeperatedString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var s in GetTagsArray())
|
||||
{
|
||||
if (sb.Length > 0) { sb.Append(","); }
|
||||
sb.Append(s);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public virtual string[] GetTagsArray()
|
||||
{
|
||||
return Tags.GetTagTextFromIDs(TagIDs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class ZeroMethod //: INotifyPropertyChanged
|
||||
{
|
||||
public Test.Module.Channel.Sensor.ZeroMethodType Method { get; set; }
|
||||
|
||||
public double Start { get; set; }
|
||||
|
||||
public double End { get; set; }
|
||||
|
||||
public ZeroMethod(Test.Module.Channel.Sensor.ZeroMethodType zm, double _start, double _end)
|
||||
{
|
||||
Method = zm;
|
||||
Start = _start;
|
||||
End = _end;
|
||||
}
|
||||
public ZeroMethod(string zm)
|
||||
{
|
||||
Initialize(zm, System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
/// <summary>
|
||||
/// do a deep copy
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public ZeroMethod(ZeroMethod copy)
|
||||
{
|
||||
Method = copy.Method;
|
||||
Start = copy.Start;
|
||||
End = copy.End;
|
||||
}
|
||||
private void Initialize(string zm, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = zm.Split(',');
|
||||
if (tokens.Length < 3) { return; }
|
||||
Start = Convert.ToDouble(tokens[1], culture);
|
||||
End = Convert.ToDouble(tokens[2], culture);
|
||||
Method = (Test.Module.Channel.Sensor.ZeroMethodType)
|
||||
Enum.Parse(typeof(Test.Module.Channel.Sensor.ZeroMethodType), tokens[0]);
|
||||
}
|
||||
public string ToDbString()
|
||||
{
|
||||
return string.Format("{0},{1},{2}", Method.ToString(), Start, End);
|
||||
}
|
||||
public string ToSerializeString()
|
||||
{
|
||||
return string.Format("{0},{1},{2}",
|
||||
Method.ToString(),
|
||||
Start.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
End.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// we will want to remove or add hardware overriding what hardware would be in the test
|
||||
/// based solely on groups in the test
|
||||
/// this way we can have dasless groups
|
||||
/// </summary>
|
||||
public class HardwareInclusionInstruction
|
||||
{
|
||||
public string HardwareId { get; }
|
||||
|
||||
public enum Actions
|
||||
{
|
||||
Remove, //hardware may be included in test by a group, but ignore it and don't include the hardware...
|
||||
Add //hardware is not included in test by a group, but add it anyhow
|
||||
}
|
||||
|
||||
public Actions Action { get; }
|
||||
|
||||
public HardwareInclusionInstruction(string hardwareId, Actions action)
|
||||
{
|
||||
HardwareId = hardwareId;
|
||||
Action = action;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TestObjectMetaData
|
||||
{
|
||||
public double Version { get; set; } = 1.06;
|
||||
|
||||
public const string NOVALUE = "NOVALUE";
|
||||
|
||||
public void SetProperty(MetaData meta)
|
||||
{
|
||||
_properties[meta.Name] = meta;
|
||||
}
|
||||
public enum CommentFields
|
||||
{
|
||||
Comment1,
|
||||
Comment2,
|
||||
Comment3,
|
||||
}
|
||||
public enum Fields
|
||||
{
|
||||
NameOfTestObject,
|
||||
VelocityOfTestObject,
|
||||
MassOfTestObject,
|
||||
DriverPositionObject,
|
||||
ImpactSideTestObject,
|
||||
TypeOfTestObject,
|
||||
ClassOfTestObject,
|
||||
CodeOfTestObject,
|
||||
RefNumberOfTestObject,
|
||||
TestObjectComments
|
||||
}
|
||||
public enum OptionFields
|
||||
{
|
||||
Offset,
|
||||
BarrierWidth,
|
||||
BarrierHeight,
|
||||
YawAngle,
|
||||
ReferenceSystem,
|
||||
OriginX,
|
||||
OriginY,
|
||||
OriginZ,
|
||||
NumberOfLoadCells
|
||||
}
|
||||
private Dictionary<string, MetaData> _properties = new Dictionary<string, MetaData>();
|
||||
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 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 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 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 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 char TestObject { get; } = '_';
|
||||
|
||||
public MetaData[] Properties => _properties.Values.ToArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// generic base class for settings
|
||||
/// </summary>
|
||||
public abstract class Setting
|
||||
{
|
||||
protected string _propertyId;
|
||||
/// <summary>
|
||||
/// string id of property
|
||||
/// </summary>
|
||||
public string PropertyId => _propertyId;
|
||||
protected int _propertyType;
|
||||
// /// <summary>
|
||||
// /// type of property (global or user specific)
|
||||
// /// </summary>
|
||||
// public PropertyTypes PropertyType { get { return (PropertyTypes)_propertyType; } }
|
||||
protected string _propertyValue;
|
||||
/// <summary>
|
||||
/// value of property
|
||||
/// does not currently do length checking and there is a max length
|
||||
/// </summary>
|
||||
public string PropertyValue => _propertyValue;
|
||||
protected string _userId;
|
||||
// /// <summary>
|
||||
// /// User for user specific settings
|
||||
// /// </summary>
|
||||
// public string UserId { get { return _userId; } }
|
||||
|
||||
public enum PropertyTypes
|
||||
{
|
||||
User = 1 << 0,
|
||||
Global = 1 << 1
|
||||
}
|
||||
|
||||
public Setting(string id, PropertyTypes type, string defaultPropertyValue, string userId)
|
||||
{
|
||||
_userId = userId;
|
||||
_propertyId = id;
|
||||
_propertyType = (int)type;
|
||||
GetPropertyValue(defaultPropertyValue);
|
||||
}
|
||||
|
||||
protected abstract void GetPropertyValue(string defaultValue);
|
||||
|
||||
public void SetValue(string value)
|
||||
{
|
||||
_propertyValue = value;
|
||||
//StoreInDB();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a class for storing directly in and out of the db
|
||||
/// it's simplified and doesn't know about sensors and is just a wrapper for a row in the db
|
||||
/// </summary>
|
||||
public class LevelTriggerChannel
|
||||
{
|
||||
public string TestSetupName { get; set; } = "";
|
||||
|
||||
public string GroupSerialNumber { get; set; } = "";
|
||||
|
||||
public string TestObjectChannelId { get; set; } = "";
|
||||
|
||||
public string HardwareChannelId { get; set; } = "";
|
||||
|
||||
public string SensorSerialNumber { get; set; } = "";
|
||||
|
||||
public bool GreaterThanEnabled { get; set; } = true;
|
||||
|
||||
public double GreaterThanThresholdEU { get; set; } = 0D;
|
||||
|
||||
public bool LessThanEnabled { get; set; } = false;
|
||||
|
||||
public bool TriggerBetweenBounds { get; set; } = false;
|
||||
|
||||
public bool TriggerOutsideBounds { get; set; } = false;
|
||||
|
||||
public double InsideUpperLevelEU { get; set; } = 0D;
|
||||
|
||||
public double InsideLowerLevelEU { get; set; } = 0D;
|
||||
|
||||
public double OutsideUpperLevelEU { get; set; } = 0D;
|
||||
|
||||
public double OutsideLowerLevelEU { get; set; } = 0D;
|
||||
|
||||
public double LessThanThresholdEU { get; set; } = 0D;
|
||||
|
||||
public LevelTriggerChannel(LevelTriggerChannel copy)
|
||||
{
|
||||
TestSetupName = copy.TestSetupName;
|
||||
GroupSerialNumber = copy.GroupSerialNumber;
|
||||
TestObjectChannelId = copy.TestObjectChannelId;
|
||||
HardwareChannelId = copy.HardwareChannelId;
|
||||
SensorSerialNumber = copy.SensorSerialNumber;
|
||||
GreaterThanEnabled = copy.GreaterThanEnabled;
|
||||
GreaterThanThresholdEU = copy.GreaterThanThresholdEU;
|
||||
LessThanEnabled = copy.LessThanEnabled;
|
||||
LessThanThresholdEU = copy.LessThanThresholdEU;
|
||||
InsideUpperLevelEU = copy.InsideUpperLevelEU;
|
||||
InsideLowerLevelEU = copy.InsideLowerLevelEU;
|
||||
OutsideUpperLevelEU = copy.OutsideUpperLevelEU;
|
||||
OutsideLowerLevelEU = copy.OutsideLowerLevelEU;
|
||||
TriggerBetweenBounds = copy.TriggerBetweenBounds;
|
||||
TriggerOutsideBounds = copy.TriggerOutsideBounds;
|
||||
}
|
||||
public LevelTriggerChannel(System.Data.DataRow dr)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.LevelTriggers.Fields))
|
||||
.Cast<DbOperations.LevelTriggers.Fields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
var o = dr[field.ToString()];
|
||||
if (DBNull.Value.Equals(o)) { continue; }
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.LevelTriggers.Fields.GreaterThanEnabled: GreaterThanEnabled = Convert.ToBoolean(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.GreaterThanEU: GreaterThanThresholdEU = Convert.ToDouble(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.GroupSerialNumber: GroupSerialNumber = Convert.ToString(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.HardwareChannelId: HardwareChannelId = Convert.ToString(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.LessThanEnabled: LessThanEnabled = Convert.ToBoolean(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.LessThanEU: LessThanThresholdEU = Convert.ToDouble(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.SensorSerialNumber: SensorSerialNumber = Convert.ToString(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.TestObjectChannelId: TestObjectChannelId = Convert.ToString(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.TestSetupName: TestSetupName = Convert.ToString(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.TriggerInside: TriggerBetweenBounds = Convert.ToBoolean(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.TriggerOutside: TriggerOutsideBounds = Convert.ToBoolean(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.OutsideUpperEU: OutsideUpperLevelEU = Convert.ToDouble(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.OutsideLowerEU: OutsideLowerLevelEU = Convert.ToDouble(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.InsideUpperEU: InsideUpperLevelEU = Convert.ToDouble(o); break;
|
||||
case DbOperations.LevelTriggers.Fields.InsideLowerEU: InsideLowerLevelEU = Convert.ToDouble(o); break;
|
||||
default: throw new NotSupportedException("unknown level trigger field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*DTS.Utilities.Logging.APILogger.Log(ex);*/ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class MMEFineLocations2 : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string FINE_LOC_2 { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
|
||||
public MMEFineLocations2(string sGuid, string fineLoc2, string textL1, string textL2, long version, DateTime date,
|
||||
string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText, string history,
|
||||
MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
FINE_LOC_2 = fineLoc2;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
public static MMEFineLocations2[] GetFineLocations2()
|
||||
{
|
||||
var fineLocations2 = new List<MMEFineLocations2>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMEFineLocations2";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string sFineLoc2 = ISOReader["FINE_LOC_2"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = Convert.ToInt64(ISOReader["VERSION"]);
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
fineLocations2.Add(new MMEFineLocations2(sGuid, sFineLoc2, textL1, textL2, version, date,
|
||||
remarks, expired, sortkey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * from {0}", DbOperations.MMETables.MMEFineLocations2Table);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.MMETables.MMEFineLocations2Fields))
|
||||
.Cast<DbOperations.MMETables.MMEFineLocations2Fields>().ToArray();
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var version = 0;
|
||||
var text2 = "";
|
||||
var text1 = "";
|
||||
var sortkey = "";
|
||||
var sGuid = "";
|
||||
var remarks = "";
|
||||
var lastChangeText = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var history = "";
|
||||
var fineLoc2 = "??";
|
||||
var expired = false;
|
||||
var date = DateTime.Now;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.DATE:
|
||||
date = Convert.ToDateTime(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.EXPIRED:
|
||||
expired = Convert.ToBoolean(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.FINE_LOC_2:
|
||||
fineLoc2 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.HISTORY:
|
||||
history = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.LAST_CHANGE:
|
||||
lastChange = Convert.ToDateTime(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.REMARKS:
|
||||
remarks = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.s_GUID:
|
||||
sGuid = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.SORTKEY:
|
||||
sortkey = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.TEXT_L1:
|
||||
text1 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.TEXT_L2:
|
||||
text2 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations2Fields.VERSION:
|
||||
version = Convert.ToInt32(dr[field.ToString()]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
|
||||
}
|
||||
fineLocations2.Add(new MMEFineLocations2(sGuid.ToString(), fineLoc2, text1, text2, Convert.ToInt64(version),
|
||||
date, remarks, expired, sortkey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
return fineLocations2.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
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 const int INVALID_ID = -1;
|
||||
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(System.Data.DataRow dr)
|
||||
{
|
||||
DbOperations.Tags.TagFields[] fields = Enum.GetValues(typeof(DbOperations.Tags.TagFields)).Cast<DbOperations.Tags.TagFields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
object o = dr[field.ToString()];
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.Tags.TagFields.Obsolete: IsObsolete = Convert.ToBoolean(o); break;
|
||||
case DbOperations.Tags.TagFields.TagId: ID = Convert.ToInt32(o); break;
|
||||
case DbOperations.Tags.TagFields.TagText: Text = Convert.ToString(o); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
public object Clone()
|
||||
{
|
||||
return new Tag(this);
|
||||
}
|
||||
}
|
||||
private static Tags _tagsInstance;
|
||||
public static Tags TagsInstance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == _tagsInstance) { _tagsInstance = new Tags(); }
|
||||
return _tagsInstance;
|
||||
}
|
||||
}
|
||||
private static object MyLock = new object();
|
||||
public Tags()
|
||||
{
|
||||
_tagsLookup = new Dictionary<string, Tag>();
|
||||
UpdateList();
|
||||
}
|
||||
/// <summary>
|
||||
/// holds a cached collection of tags. This collection however is currently only populated on startup
|
||||
/// and not updated except explicitly when a user adds a tag
|
||||
/// </summary>
|
||||
private Dictionary<string, Tag> _tagsLookup = null;
|
||||
|
||||
/// <summary>
|
||||
/// retrieves a string text associated with an ID FROM CACHED copies
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
private string GetTagTextFromId(int id)
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
var e = _tagsLookup.GetEnumerator();
|
||||
while (e.MoveNext())
|
||||
{
|
||||
if (e.Current.Value.ID == id)
|
||||
{
|
||||
return e.Current.Value.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a string for a given id from memory cache
|
||||
/// returns null if it doesn't exist or is an invalid id
|
||||
/// </summary>
|
||||
/// <param name="tagID"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetTagTextFromID(int tagID)
|
||||
{
|
||||
if (0 > tagID || tagID == Tag.INVALID_ID)
|
||||
{
|
||||
// Not a valid ID
|
||||
return null;
|
||||
}
|
||||
return TagsInstance.GetTagTextFromId(tagID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns an array of tag text given an array of tag ids.
|
||||
/// skips invalid tags or tag text
|
||||
/// </summary>
|
||||
/// <param name="tagID"></param>
|
||||
/// <returns></returns>
|
||||
public static string[] GetTagTextFromIDs(int[] tagID)
|
||||
{
|
||||
if (null == tagID || 0 == tagID.Length) { return new string[0]; }
|
||||
List<string> rv = new List<string>();
|
||||
|
||||
foreach (int i in tagID)
|
||||
{
|
||||
if (i == Tag.INVALID_ID) { continue; }
|
||||
var tag = GetTagTextFromID(i);
|
||||
if (string.IsNullOrWhiteSpace(tag)) { continue; }
|
||||
else { rv.Add(tag); }
|
||||
}
|
||||
return rv.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieves all tags and updates the cached dictionary of tags
|
||||
/// </summary>
|
||||
private void UpdateList()
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
_tagsLookup.Clear();
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
sql.CommandText = string.Format("SELECT * FROM {0}", DbOperations.Tags.Table);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
foreach (System.Data.DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
Tag t = new Tag(row);
|
||||
_tagsLookup[t.Text] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{0E52DF76-B8A7-4C69-981C-CDC27B7EE5A9}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DatabaseExport</RootNamespace>
|
||||
<AssemblyName>DatabaseExport</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SQLite">
|
||||
<HintPath>..\..\..\..\SQLite\System.Data.SQLite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Classes\Hardware\DASSettings.cs" />
|
||||
<Compile Include="Classes\RegionsAndZones\Region.cs" />
|
||||
<Compile Include="Classes\RegionsAndZones\RegionAdorner.cs" />
|
||||
<Compile Include="Classes\RegionsAndZones\Zone.cs" />
|
||||
<Compile Include="Classes\Enums.cs" />
|
||||
<Compile Include="Classes\TabPage\TabPageCommon.cs" />
|
||||
<Compile Include="Classes\TabPage\TabPage.cs" />
|
||||
<Compile Include="Classes\TestMetaData\CustomerDetails.cs" />
|
||||
<Compile Include="Classes\TestMetaData\LabratoryDetails.cs" />
|
||||
<Compile Include="Classes\TestMetaData\TestEngineerDetails.cs" />
|
||||
<Compile Include="Classes\TestObject\GroupTemplateTableInfo.cs" />
|
||||
<Compile Include="Classes\TestObject\TemplateChannelUI.cs" />
|
||||
<Compile Include="Classes\TestObject\TestTestObject.cs" />
|
||||
<Compile Include="Classes\TestObject\TestObject.cs" />
|
||||
<Compile Include="Classes\TestObject\TestObjectList.cs" />
|
||||
<Compile Include="Classes\TestObject\TestObjectTemplate.cs" />
|
||||
<Compile Include="Classes\TestObject\TestObjectTemplateCollection.cs" />
|
||||
<Compile Include="Classes\TestTemplate\HardwareInclusionInstruction.cs" />
|
||||
<Compile Include="Classes\TestTemplate\TestTemplateLite.cs" />
|
||||
<Compile Include="Classes\TestTemplate\TestTemplate.cs" />
|
||||
<Compile Include="Classes\TestTemplate\TestTemplateTableObject.cs" />
|
||||
<Compile Include="Classes\TestTemplate\TestTemplateList.cs" />
|
||||
<Compile Include="DASConcepts\Test.Module.Channel.Sensor.Bridge.cs" />
|
||||
<Compile Include="DASConcepts\Test.Module.Channel.Sensor.ExcitationVoltage.cs" />
|
||||
<Compile Include="DASConcepts\LinearizationFormula.cs" />
|
||||
<Compile Include="DASConcepts\Test.Module.Channel.Sensor.SensorUnits.cs" />
|
||||
<Compile Include="DASConcepts\Test.Module.Channel.Sensor.ZeroMethod.cs" />
|
||||
<Compile Include="DASConcepts\InitialOffset.cs" />
|
||||
<Compile Include="Classes\Hardware\DASHardware.cs" />
|
||||
<Compile Include="ISO\LabratoryDetails.cs" />
|
||||
<Compile Include="ISO\TestObjectMetaData.cs" />
|
||||
<Compile Include="SensorDB\IsoCode.cs" />
|
||||
<Compile Include="Serialization\Control\DAS\IFilterable.cs" />
|
||||
<Compile Include="Serialization\Control\Event\Module\Channel\Channel.cs" />
|
||||
<Compile Include="Serialization\SliceRaw\SliceRaw.File.PersistentChannel.cs" />
|
||||
<Compile Include="CustomChannel.cs" />
|
||||
<Compile Include="Storage\DbOperationsEnum.cs" />
|
||||
<Compile Include="Storage\DbVersion.cs" />
|
||||
<Compile Include="TestGraph.cs" />
|
||||
<Compile Include="ISO\CalculatedValueClass.cs" />
|
||||
<Compile Include="ISO\LevelTriggerChannel.cs" />
|
||||
<Compile Include="ISO\TestSetting.cs" />
|
||||
<Compile Include="ISO\TestEngineerDetails.cs" />
|
||||
<Compile Include="ISO\ISO13499FileDb.cs" />
|
||||
<Compile Include="ISO\MMEDirections.cs" />
|
||||
<Compile Include="ISO\MMEPossibleChannels.cs" />
|
||||
<Compile Include="ISO\MMEFilterClasses.cs" />
|
||||
<Compile Include="ISO\MMEFigures.cs" />
|
||||
<Compile Include="ISO\MMEFineLocations1.cs" />
|
||||
<Compile Include="ISO\MMEFineLocations2.cs" />
|
||||
<Compile Include="ISO\MMEFineLocations3.cs" />
|
||||
<Compile Include="ISO\MMEPhysicalDimensions.cs" />
|
||||
<Compile Include="ISO\MMEPositions.cs" />
|
||||
<Compile Include="ISO\MMETestObjects.cs" />
|
||||
<Compile Include="ISO\MMETransducerMainLocation.cs" />
|
||||
<Compile Include="ISO\AbstractOLEDbWrapper.cs" />
|
||||
<Compile Include="ISO\TemplateZone.cs" />
|
||||
<Compile Include="ISO\TemplateRegion.cs" />
|
||||
<Compile Include="ISO\CustomerDetails.cs" />
|
||||
<Compile Include="ISO\TestObject.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SensorDB\SensorsCollection.cs" />
|
||||
<Compile Include="SensorDB\DigitalInputSetting.cs" />
|
||||
<Compile Include="SensorDB\SquibSetting.cs" />
|
||||
<Compile Include="SensorDB\DigitalOutputSetting.cs" />
|
||||
<Compile Include="SettingsDB\SettingsDB.cs" />
|
||||
<Compile Include="SettingsDB\Setting.cs" />
|
||||
<Compile Include="SettingsDB\GlobalSetting.cs" />
|
||||
<Compile Include="Storage\IDbTimeStampAware.cs" />
|
||||
<Compile Include="ISO\Hardware.cs" />
|
||||
<Compile Include="ISO\HardwareChannel.cs" />
|
||||
<Compile Include="ISO\TestObjectTemplate.cs" />
|
||||
<Compile Include="SensorDB\SensorData.cs" />
|
||||
<Compile Include="SensorDB\SensorModel.cs" />
|
||||
<Compile Include="IServicePublic.cs" />
|
||||
<Compile Include="DASConcepts\DigitalInputScaleMultiplier.cs" />
|
||||
<Compile Include="SensorDB\SensorCalibration.cs" />
|
||||
<Compile Include="SensorDB\CalibrationRecords.cs" />
|
||||
<Compile Include="SensorDB\SensorDB.cs" />
|
||||
<Compile Include="SensorDB\FilterClass.cs" />
|
||||
<Compile Include="ISO\IsoCode.cs" />
|
||||
<Compile Include="SensorDB\SensorRange.cs" />
|
||||
<Compile Include="SensorDB\ZeroMethod.cs" />
|
||||
<Compile Include="Classes\Hardware\HardwareChannel.cs" />
|
||||
<Compile Include="SerializedSettings.cs" />
|
||||
<Compile Include="Storage\DbOperations.cs" />
|
||||
<Compile Include="DbExporter.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ISO\TestObjectChannel.cs" />
|
||||
<Compile Include="ISO\TestObjectTemplateChannel.cs" />
|
||||
<Compile Include="Users\IUIItems.cs" />
|
||||
<Compile Include="Users\ITagAware.cs" />
|
||||
<Compile Include="Users\User.cs" />
|
||||
<Compile Include="Users\Tags.cs" />
|
||||
<Compile Include="Utilities\DiskUtility.cs" />
|
||||
<Compile Include="Utilities\AttributeCoder.cs" />
|
||||
<Compile Include="Utilities\ExceptionalList.cs" />
|
||||
<Compile Include="Utilities\Exceptional.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,702 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class LinearizationFormula
|
||||
{
|
||||
private bool _bIsValid;
|
||||
public bool IsValid() { return _bIsValid; }
|
||||
public void MarkValid(bool bValid)
|
||||
{
|
||||
_bIsValid = bValid;
|
||||
}
|
||||
public enum Styles
|
||||
{
|
||||
IRTraccManual,
|
||||
IRTraccDiagnosticsZero,
|
||||
IRTraccZeroMMmV,
|
||||
IRTraccAverageOverTime,
|
||||
Polynomial,
|
||||
IRTraccCalFactor
|
||||
}
|
||||
// public enum SLICEWareStyles
|
||||
// {
|
||||
// Manual,
|
||||
// DiagnosticZeroMMmV,
|
||||
// ZeroMMmV,
|
||||
// AverageOverTime,
|
||||
// Polynomial
|
||||
// }
|
||||
|
||||
// // Translation
|
||||
// public SLICEWareStyles SLICEWareStyle
|
||||
// {
|
||||
// get { return (SLICEWareStyles)_style; }
|
||||
// set { _style = (Styles)value; }
|
||||
// }
|
||||
|
||||
public Styles Style { get; set; } = Styles.IRTraccDiagnosticsZero;
|
||||
|
||||
public double PolynomialSensitivity { get; set; } = 1D;
|
||||
|
||||
public double LinearizationExponent { get; set; } = 1D;
|
||||
|
||||
// THIS IS MM/V, (UI has already been updated, we need to update the variable name)
|
||||
public double MMPerV { get; set; }
|
||||
|
||||
public double MVAt0MM { get; set; }
|
||||
|
||||
public double Slope { get; set; }
|
||||
|
||||
public double Intercept { get; set; }
|
||||
|
||||
public double CalibrationFactor { get; set; }
|
||||
|
||||
public double ZeroPositionIntercept { get; set; }
|
||||
|
||||
public LinearizationFormula()
|
||||
{
|
||||
ZeroPositionIntercept = 0D;
|
||||
CalibrationFactor = 0D;
|
||||
Intercept = 0D;
|
||||
_coefficients = new List<double>(new double[] { 0, 0, 0, 0 });
|
||||
_exponents = new List<double>(new double[] { 0, 1, 2, 3 });
|
||||
}
|
||||
|
||||
public LinearizationFormula(LinearizationFormula copy)
|
||||
{
|
||||
UsemVOverVForPolys = copy.UsemVOverVForPolys;
|
||||
_bIsValid = copy._bIsValid;
|
||||
_coefficients = new List<double>(copy._coefficients.ToArray());
|
||||
_exponents = new List<double>(copy._exponents.ToArray());
|
||||
Intercept = copy.Intercept;
|
||||
LinearizationExponent = copy.LinearizationExponent;
|
||||
MMPerV = copy.MMPerV;
|
||||
MVAt0MM = copy.MVAt0MM;
|
||||
Slope = copy.Slope;
|
||||
Style = copy.Style;
|
||||
_coefficients = new List<double>(copy._coefficients);
|
||||
_exponents = new List<double>(copy._exponents);
|
||||
PolynomialSensitivity = copy.PolynomialSensitivity;
|
||||
ZeroPositionIntercept = copy.ZeroPositionIntercept;
|
||||
CalibrationFactor = copy.CalibrationFactor;
|
||||
}
|
||||
// public double GetCoefficient(double exponent)
|
||||
// {
|
||||
// for (int i = 0; i < _exponents.Count && i < _coefficients.Count; i++)
|
||||
// {
|
||||
// if (_exponents[i] == exponent) { return _coefficients[i]; }
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
// public void SetCoefficient(double exponent, double coefficient)
|
||||
// {
|
||||
// for (int i = 0; i < _exponents.Count && i < _coefficients.Count; i++)
|
||||
// {
|
||||
// if (_exponents[i] == exponent) { _coefficients[i] = coefficient; return; }
|
||||
// }
|
||||
// }
|
||||
// public double GetLinearizedValue(double input, double excitation)
|
||||
// {
|
||||
// if (Style != Styles.Polynomial && input <= 0)
|
||||
// {
|
||||
// //ir-tracc should never be < 0, however we may get readings less than zero due to
|
||||
// //noise and other factors, treat these as positive near to zero
|
||||
// input = .001;
|
||||
// }
|
||||
// //first linearize
|
||||
// input /= 1000D;//assume input is in mV and we want it in Volts
|
||||
// input = Math.Pow(input, LinearizationExponent);
|
||||
|
||||
// switch (Style)
|
||||
// {
|
||||
// case Styles.IRTraccDiagnosticsZero:
|
||||
// return GetEUDiagnosticsZero(input);
|
||||
// case Styles.IRTraccManual:
|
||||
// return GetEUIRTraccManual(input);
|
||||
// case Styles.IRTraccZeroMMmV:
|
||||
// return GetEUZeroMMmV(input);
|
||||
// case Styles.IRTraccAverageOverTime:
|
||||
// return GetEUAverageOverTime(input);
|
||||
// case Styles.Polynomial:
|
||||
// return GetEUPolynomial(input, excitation);
|
||||
// case Styles.IRTraccCalFactor:
|
||||
// return GetEUIRTraccCalFactor(input);
|
||||
// default:
|
||||
// throw new NotSupportedException("unknown format: " + Style.ToString());
|
||||
// }
|
||||
// }
|
||||
// private double GetEUIRTraccCalFactor(double volts)
|
||||
// {
|
||||
// return volts * CalibrationFactor + ZeroPositionIntercept;
|
||||
// }
|
||||
// private double GetEUIRTraccManual(double volts)
|
||||
// {
|
||||
// return (volts - Intercept) / Slope;
|
||||
// }
|
||||
public bool UsemVOverVForPolys { get; set; } = true;
|
||||
// private double GetEUZeroMMmV(double volts)
|
||||
// {
|
||||
// double input = MVAt0MM / 1000D;
|
||||
// input = Math.Pow(input, LinearizationExponent);
|
||||
// if (double.IsNaN(input) || double.IsNegativeInfinity(input) || double.IsPositiveInfinity(input))
|
||||
// {
|
||||
// return volts * MMPerV;
|
||||
// }
|
||||
// else { return (volts * MMPerV - MMPerV * input); }
|
||||
// }
|
||||
private List<double> _coefficients = new List<double>();
|
||||
private List<double> _exponents = new List<double>();
|
||||
// private double GetEUPolynomial(double volts, double excitation)
|
||||
// {
|
||||
// //per J2517
|
||||
// //3.4 Use of the Calibration Coefficients
|
||||
// //The potentiometer assembly should be re-installed in the dummy without any mechanical adjustment of the
|
||||
// //potentiometer. Prior to a crash test, the original zero offset level must be preserved by either not zeroing the
|
||||
// //potentiometer (by signal conditioning or post-processing) or the amount that was zeroed must be added during postprocessing.
|
||||
// //During the test the absolute voltage output time history should be recorded. This voltage signal is then
|
||||
// //converted to engineering units by:
|
||||
// //1. Convert voltage signal to mV/V at the sensor. This is the sensor reading S.
|
||||
// //2. Convert the sensor reading S to displacement D by using the equation:
|
||||
// //D = A*S^3 + B*S^2 + C*S + M (Eq. 2)
|
||||
// //where:
|
||||
// //D is the displacement relative to the thorax design position in mm
|
||||
// //S is the sensor output reading in mV/V
|
||||
// //A, B, C, and M are the calibration coefficients
|
||||
// //NOTE: Make sure to use sufficient significant digits on all coefficients to assure accuracy of the conversion to
|
||||
// //engineering units. It is recommended to use 5 significant digits (example 0.000012345).
|
||||
|
||||
// //double mV = volts * 1000D;
|
||||
// //double gain = 1D;
|
||||
// //mV = mV / (gain * excitation);
|
||||
|
||||
// //if (0 != PolynomialSensitivity && 1!= PolynomialSensitivity) { mV /= PolynomialSensitivity; }
|
||||
// //double eu = 0D;
|
||||
// //for (int i = 0; i < _coefficients.Count && i < _exponents.Count; i++)
|
||||
// //{
|
||||
// // eu += _coefficients[i] * Math.Pow(mV, _exponents[i]);
|
||||
// //}
|
||||
// //return eu;
|
||||
|
||||
// //CHANGED FOR GM TESTING
|
||||
|
||||
// if (0 != PolynomialSensitivity && 1 != PolynomialSensitivity)
|
||||
// {
|
||||
// volts /= PolynomialSensitivity;
|
||||
// }
|
||||
|
||||
// double voltsOverV = 0D;
|
||||
// if (UsemVOverVForPolys)
|
||||
// {
|
||||
// //convert to mV first
|
||||
// voltsOverV = (volts * 1000D) / excitation;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //used by GM
|
||||
// voltsOverV = volts / excitation;
|
||||
// }
|
||||
// double eu = 0;
|
||||
|
||||
// for (int i = 0; i < _coefficients.Count && i < _exponents.Count; i++)
|
||||
// {
|
||||
// if (_exponents[i] != 0)
|
||||
// {
|
||||
// eu += _coefficients[i] * Math.Pow(voltsOverV, _exponents[i]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// eu += _coefficients[i];
|
||||
// }
|
||||
// }
|
||||
// return eu;
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// MvAt0MM set at diagnostics
|
||||
// /// </summary>
|
||||
// /// <param name="volts"></param>
|
||||
// /// <returns></returns>
|
||||
// private double GetEUDiagnosticsZero(double volts)
|
||||
// {
|
||||
// //double input = MVAt0MM/1000D;
|
||||
// //input = System.Math.Pow(input,LinearizationExponent);
|
||||
// double input = double.NaN;
|
||||
// if (double.IsNaN(input) || double.IsPositiveInfinity(input) || double.IsNegativeInfinity(input))
|
||||
// {
|
||||
// return volts * MMPerV;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return volts * MMPerV - MMPerV * input;
|
||||
// }
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// MVAt0MM set by diagnostics and then later on at
|
||||
// /// Average Over Time
|
||||
// /// </summary>
|
||||
// /// <param name="volts"></param>
|
||||
// /// <returns></returns>
|
||||
// private double GetEUAverageOverTime(double volts)
|
||||
// {
|
||||
// //double input = MVAt0MM / 1000D;
|
||||
// //input = System.Math.Pow(input, LinearizationExponent);
|
||||
// double input = double.NaN;
|
||||
// if (double.IsNaN(input) || double.IsNegativeInfinity(input) || double.IsPositiveInfinity(input))
|
||||
// {
|
||||
// return volts * MMPerV;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return volts * MMPerV - MMPerV * input;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// public string ToSLICEWareSerializeString()
|
||||
// {
|
||||
// if (!_bIsValid) { return ""; }
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.AppendFormat("{0}_", Style.ToString());
|
||||
|
||||
// switch (Style)
|
||||
// {
|
||||
// case Styles.IRTraccDiagnosticsZero:
|
||||
// sb.Append(ToIRTraccDiagnosticZeroString());
|
||||
// break;
|
||||
// case Styles.IRTraccManual:
|
||||
// sb.Append(ToIRTraccManualString());
|
||||
// break;
|
||||
// case Styles.IRTraccZeroMMmV:
|
||||
// sb.Append(ToIRTraccZeroMMmVString());
|
||||
// break;
|
||||
// case Styles.IRTraccAverageOverTime:
|
||||
// sb.Append(ToIRTraccAverageOverTimeString());
|
||||
// break;
|
||||
// case Styles.Polynomial:
|
||||
// sb.Append(ToSLICEWarePolynomialString());
|
||||
// break;
|
||||
// case Styles.IRTraccCalFactor:
|
||||
// throw new NotSupportedException("CalFactor not supported in SLICEWare");
|
||||
// default:
|
||||
// throw new NotSupportedException("unknown type: " + Style.ToString());
|
||||
// }
|
||||
|
||||
// return sb.ToString();
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// serializes to a string of the format "c0xe0 c1xe1...cnxen"
|
||||
/// this will allow us arbitrary length polynomials and fractional exponents.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ToSerializeString()
|
||||
{
|
||||
if (!_bIsValid) { return ""; }
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendFormat("{0}_", Style.ToString());
|
||||
|
||||
switch (Style)
|
||||
{
|
||||
case Styles.IRTraccDiagnosticsZero:
|
||||
sb.Append(ToIRTraccDiagnosticZeroString());
|
||||
break;
|
||||
case Styles.IRTraccManual:
|
||||
sb.Append(ToIRTraccManualString());
|
||||
break;
|
||||
case Styles.IRTraccZeroMMmV:
|
||||
sb.Append(ToIRTraccZeroMMmVString());
|
||||
break;
|
||||
case Styles.IRTraccAverageOverTime:
|
||||
sb.Append(ToIRTraccAverageOverTimeString());
|
||||
break;
|
||||
case Styles.Polynomial:
|
||||
sb.Append(ToPolynomialString());
|
||||
break;
|
||||
case Styles.IRTraccCalFactor:
|
||||
sb.Append(ToIRTraccCalFactorString());
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("unknown type: " + Style.ToString());
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
public string ToIRTraccDiagnosticZeroString()
|
||||
{
|
||||
return string.Format("{0}x{1}", MMPerV.ToString(System.Globalization.CultureInfo.InvariantCulture), LinearizationExponent
|
||||
.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
public string ToIRTraccCalFactorString()
|
||||
{
|
||||
return string.Format("{0}x{1}x{2}", CalibrationFactor.ToString(System.Globalization.CultureInfo.InvariantCulture), LinearizationExponent.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
ZeroPositionIntercept.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
public void FromIRTraccCalFactorString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = s.Split('x');
|
||||
if (tokens.Length < 3) { throw new NotSupportedException("Invalid CalFactor format: " + s); }
|
||||
|
||||
CalibrationFactor = double.Parse(tokens[0], culture);
|
||||
LinearizationExponent = double.Parse(tokens[1], culture);
|
||||
ZeroPositionIntercept = double.Parse(tokens[2], culture);
|
||||
}
|
||||
public void FromIRTraccDiagnosticZeroString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = s.Split('x');
|
||||
if (tokens.Length < 2) { throw new NotSupportedException("Invalid DiagnosticsZero format: " + s); }
|
||||
MMPerV = double.Parse(tokens[0], culture);
|
||||
LinearizationExponent = double.Parse(tokens[1], culture);
|
||||
}
|
||||
public string ToIRTraccManualString()
|
||||
{
|
||||
return string.Format("{0}x{1}x{2}", Slope.ToString(System.Globalization.CultureInfo.InvariantCulture), Intercept.ToString
|
||||
(System.Globalization.CultureInfo.InvariantCulture), LinearizationExponent.ToString(
|
||||
System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
public void FromIRTraccManualString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = s.Split('x');
|
||||
if (tokens.Length < 3) { throw new NotSupportedException("Invalid IRTraccManual format: " + s); }
|
||||
Slope = double.Parse(tokens[0], culture);
|
||||
Intercept = double.Parse(tokens[1], culture);
|
||||
LinearizationExponent = double.Parse(tokens[2], culture);
|
||||
}
|
||||
public string ToIRTraccZeroMMmVString()
|
||||
{
|
||||
return string.Format("{0}x{1}x{2}", MMPerV.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
MVAt0MM.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
LinearizationExponent.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
// public string ToSLICEWarePolynomialString()
|
||||
// {
|
||||
// //SLICEWare is the reverse order of our DataPRO Database
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// for (int i = _exponents.Count - 1; i >= 0; i--)
|
||||
// {
|
||||
// if (i != _exponents.Count - 1) { sb.Append(","); }
|
||||
// sb.AppendFormat("{0}x{1}", _coefficients[i].ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
// _exponents[i].ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
// }
|
||||
|
||||
// sb.AppendFormat(",S={0}", PolynomialSensitivity.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
// return sb.ToString();
|
||||
// }
|
||||
public string ToPolynomialString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < _coefficients.Count && i < _exponents.Count; i++)
|
||||
{
|
||||
if (i > 0) { sb.Append(","); }
|
||||
sb.AppendFormat("{0}x{1}", _coefficients[i].ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
_exponents[i].ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
sb.AppendFormat(",S={0},mV={1}",
|
||||
PolynomialSensitivity.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
UsemVOverVForPolys.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
// public double[] PolynomialCoefficients
|
||||
// {
|
||||
// get { return _coefficients.ToArray(); }
|
||||
// set { _coefficients = new List<double>(value); }
|
||||
// }
|
||||
// public double[] PolynomialExponents
|
||||
// {
|
||||
// get { return _exponents.ToArray(); }
|
||||
// set { _exponents = new List<double>(value); }
|
||||
// }
|
||||
public string ToIRTraccAverageOverTimeString()
|
||||
{
|
||||
return string.Format("{0}x{1}", MMPerV.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
LinearizationExponent.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
public void FromIRTraccAverageOverTimeString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = s.Split('x');
|
||||
if (tokens.Length < 2) { throw new NotSupportedException("Invalid IRTRaccAverageOverTime format: " + s); }
|
||||
MMPerV = double.Parse(tokens[0], culture);
|
||||
LinearizationExponent = double.Parse(tokens[1], culture);
|
||||
}
|
||||
public void FromIRTraccZeroMMmVString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = s.Split('x');
|
||||
if (tokens.Length < 3) { throw new NotSupportedException("Invalid IRTraccZeroMMmV format: " + s); }
|
||||
MMPerV = double.Parse(tokens[0], culture);
|
||||
MVAt0MM = double.Parse(tokens[1], culture);
|
||||
LinearizationExponent = double.Parse(tokens[2], culture);
|
||||
}
|
||||
public void FromPolynomialString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
_coefficients.Clear();
|
||||
_exponents.Clear();
|
||||
|
||||
var tokens = s.Split(',');
|
||||
foreach (var t in tokens)
|
||||
{
|
||||
var subtokens = t.Split('x');
|
||||
if (2 == subtokens.Length)
|
||||
{
|
||||
double d;
|
||||
if (double.TryParse(subtokens[0], System.Globalization.NumberStyles.Float, culture, out d))
|
||||
{
|
||||
_coefficients.Add(d);
|
||||
_exponents.Add(double.Parse(subtokens[1], culture));
|
||||
}
|
||||
else
|
||||
{
|
||||
PolynomialSensitivity = double.Parse(subtokens[1], culture);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
subtokens = t.Split('=');
|
||||
if (subtokens.Length == 2)
|
||||
{
|
||||
switch (subtokens[0])
|
||||
{
|
||||
case "S":
|
||||
PolynomialSensitivity = double.Parse(subtokens[1], culture);
|
||||
break;
|
||||
case "mV":
|
||||
UsemVOverVForPolys = Convert.ToBoolean(subtokens[1], culture);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void FromSerializeString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s)) { _bIsValid = false; return; }
|
||||
if (s.Equals("1") || s.Equals("0") || s.Equals("1 ")) { _bIsValid = false; return; }
|
||||
|
||||
var tokens = s.Split('_');
|
||||
if (tokens.Length < 2) { throw new NotSupportedException("unsupported Linearization Formula Format"); }
|
||||
var style = (Styles)Enum.Parse(typeof(Styles), tokens[0], true);
|
||||
Style = style;
|
||||
switch (Style)
|
||||
{
|
||||
case Styles.IRTraccDiagnosticsZero:
|
||||
FromIRTraccDiagnosticZeroString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case Styles.IRTraccManual:
|
||||
FromIRTraccManualString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case Styles.IRTraccZeroMMmV:
|
||||
FromIRTraccZeroMMmVString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case Styles.Polynomial:
|
||||
FromPolynomialString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case Styles.IRTraccAverageOverTime:
|
||||
FromIRTraccAverageOverTimeString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case Styles.IRTraccCalFactor:
|
||||
FromIRTraccCalFactorString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("Unknown format: " + Style.ToString());
|
||||
}
|
||||
}
|
||||
public void FromSerializeString(string s)
|
||||
{
|
||||
FromSerializeString(s, System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
// public void FromTDCSerializeString()
|
||||
// {
|
||||
// _bIsValid = true;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Will return a display string for a nonlinear calibration based on N4 formating
|
||||
// /// </summary>
|
||||
// public string ToDisplayString()
|
||||
// {
|
||||
// return ToDisplayString("N4");
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// Will return a display string for a nonlinear calibration based on 1st paramater formating string
|
||||
// /// </summary>
|
||||
// /// <param name="nonlinearFormat"></param>
|
||||
// /// <returns></returns>
|
||||
// public string ToDisplayString(string nonlinearFormat)
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(nonlinearFormat)) { nonlinearFormat = "N4"; }
|
||||
// switch (Style)
|
||||
// {
|
||||
// case Styles.Polynomial:
|
||||
// {
|
||||
// return ToPolynomial(nonlinearFormat);
|
||||
// }
|
||||
// case Styles.IRTraccZeroMMmV:
|
||||
// {
|
||||
// return string.Format("mV = {0:n4}, {1:n4}*(V^{2})", MVAt0MM, MMPerV, ToSuperScript(LinearizationExponent.ToString(nonlinearFormat)));
|
||||
// }
|
||||
// case Styles.IRTraccManual:
|
||||
// {
|
||||
// return string.Format("((V^{0})-{1:n4})/{2:n4}", ToSuperScript(LinearizationExponent.ToString(nonlinearFormat)), Intercept, Slope);
|
||||
// }
|
||||
// case Styles.IRTraccDiagnosticsZero:
|
||||
// {
|
||||
// return string.Format("{0:n4}*(V^{1})", MMPerV, ToSuperScript(LinearizationExponent.ToString(nonlinearFormat)));
|
||||
// }
|
||||
// case Styles.IRTraccAverageOverTime:
|
||||
// {
|
||||
// return string.Format("{0:n4}*(V^{1})", MMPerV, ToSuperScript(LinearizationExponent.ToString(nonlinearFormat)));
|
||||
// }
|
||||
// case Styles.IRTraccCalFactor:
|
||||
// {
|
||||
// return string.Format("{2:n4}+{1:n4}*(V^{0})", ToSuperScript(LinearizationExponent.ToString(nonlinearFormat)), CalibrationFactor, ZeroPositionIntercept);
|
||||
// }
|
||||
// default:
|
||||
// return string.Empty;
|
||||
// }
|
||||
// }
|
||||
// private string ToPolynomial(string nonlinearFormat)
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(nonlinearFormat)) { nonlinearFormat = "N4"; }
|
||||
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
|
||||
// int termNumber = PolynomialCoefficients.Length - 1;
|
||||
// foreach (var x in PolynomialCoefficients)
|
||||
// {
|
||||
// if (PolynomialCoefficients[termNumber] != 0)
|
||||
// {
|
||||
// double coeff = PolynomialCoefficients[termNumber];
|
||||
|
||||
// // Let the appended math symbol handle sign unless we're the first term.
|
||||
// if (termNumber != PolynomialCoefficients.Length - 1)
|
||||
// {
|
||||
// coeff = Math.Abs(coeff);
|
||||
// }
|
||||
// sb.Append(coeff.ToString(nonlinearFormat));
|
||||
// if (PolynomialExponents[termNumber] != 0)
|
||||
// {
|
||||
// sb.Append("x");
|
||||
// if (PolynomialExponents[termNumber] != 1)
|
||||
// {
|
||||
// sb.Append(ToSuperScript(PolynomialExponents[termNumber].ToString("N0")));
|
||||
// }
|
||||
// }
|
||||
// if (termNumber > 0)
|
||||
// {
|
||||
// // Coerricients are Displayed in absolute value. We need to combine the sign with the addition symbol
|
||||
// sb.Append(PolynomialCoefficients[termNumber - 1] > 0 ? " + " : " - ");
|
||||
// }
|
||||
// }
|
||||
// termNumber--;
|
||||
// }
|
||||
|
||||
// return sb.ToString();
|
||||
// }
|
||||
// private string ToSuperScript(string source)
|
||||
// {
|
||||
// StringBuilder superScript = new StringBuilder();
|
||||
|
||||
// foreach (char c in source)
|
||||
// {
|
||||
// switch (c)
|
||||
// {
|
||||
// case '-':
|
||||
// superScript.Append('\u207B');
|
||||
// break;
|
||||
// case '.':
|
||||
// superScript.Append('\u00B7');
|
||||
// break;
|
||||
// case '1':
|
||||
// superScript.Append('\u00B9');
|
||||
// break;
|
||||
// case '2':
|
||||
// superScript.Append('\u00B2');
|
||||
// break;
|
||||
// case '3':
|
||||
// superScript.Append('\u00B3');
|
||||
// break;
|
||||
// case '4':
|
||||
// superScript.Append('\u2074');
|
||||
// break;
|
||||
// case '5':
|
||||
// superScript.Append('\u2075');
|
||||
// break;
|
||||
// case '6':
|
||||
// superScript.Append('\u2076');
|
||||
// break;
|
||||
// case '7':
|
||||
// superScript.Append('\u2077');
|
||||
// break;
|
||||
// case '8':
|
||||
// superScript.Append('\u2078');
|
||||
// break;
|
||||
// case '9':
|
||||
// superScript.Append('\u2079');
|
||||
// break;
|
||||
// case '0':
|
||||
// superScript.Append('\u2070');
|
||||
// break;
|
||||
// case '\'':
|
||||
// superScript.Append('\u02C8');
|
||||
// break;
|
||||
// case ',':
|
||||
// superScript.Append('\u22C5'); // there is no unicode superscript comma. this comes close
|
||||
// break;
|
||||
// case '\u00A0':
|
||||
// superScript.Append('\u2009'); // unicode 'thin' space
|
||||
// break;
|
||||
// default:
|
||||
// superScript.Append('\u207F');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return superScript.ToString();
|
||||
// }
|
||||
// /*
|
||||
// * we are given an equation in the form of y = ax^1 + b, except x and y are backwards for us (y=V where we'd prefer X was voltage, so we switch it)
|
||||
// * y/a - b/a = x, and then switch y and x, (1/a)x^1 -(b/a)x^0 = y
|
||||
// * now we want to get the coefficient of the first equation, which is "a", we get this by taking the inverse
|
||||
// * we get b on the other hand by taking -1 * (b/a)*a. if we have the "coefficient", we have a
|
||||
// */
|
||||
// /*
|
||||
// public double GetIRTraccCoefficient()
|
||||
// {
|
||||
// foreach (Factor f in Factors)
|
||||
// {
|
||||
// if (f.Exponent == 1D) { return System.Math.Pow(f.Coefficient, -1); }
|
||||
// }
|
||||
// return 1D; //0 doesn't make sense for ir
|
||||
// }
|
||||
// public double GetIRTraccConstant()
|
||||
// {
|
||||
// foreach (Factor f in Factors)
|
||||
// {
|
||||
// if (f.Exponent == 0D) { return -1D * GetIRTraccCoefficient() * f.Coefficient; }
|
||||
// }
|
||||
// return 0D;
|
||||
// }
|
||||
// public void SetIRTraccFactor(double coefficient, double constant)
|
||||
// {
|
||||
// if (0 == coefficient)
|
||||
// {
|
||||
// //well this doesn't make any sense ...
|
||||
// coefficient = 1;
|
||||
// }
|
||||
// Factors = new Factor[]
|
||||
// {
|
||||
// new Factor(1/coefficient,1),
|
||||
// new Factor(-constant/coefficient,0),
|
||||
// };
|
||||
// }*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public abstract class DbTimeStampBase : IDbTimeStampAware, INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected bool SetProperty<T>(ref T storage, T value, String propertyName = null)
|
||||
{
|
||||
if (Equals(storage, value)) return false;
|
||||
|
||||
storage = value;
|
||||
OnPropertyChanged(propertyName);
|
||||
return true;
|
||||
}
|
||||
protected void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
var eventHandler = PropertyChanged;
|
||||
if (eventHandler != null)
|
||||
{
|
||||
eventHandler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
protected long DbTimeStamp;
|
||||
public long GetTimeStampMemory()
|
||||
{
|
||||
return DbTimeStamp;
|
||||
}
|
||||
public void SetTimeStampMemory(long value) { DbTimeStamp = value; }
|
||||
public void SetTimeStampMemory(System.Data.DataRow row)
|
||||
{
|
||||
DbTimeStamp = 0;
|
||||
}
|
||||
|
||||
public void SetTimeStampMemory(IDataReader reader)
|
||||
{
|
||||
DbTimeStamp = 0;
|
||||
}
|
||||
public long GetTimeStampDb(Dictionary<string, long> lookup)
|
||||
{
|
||||
//var constraints = GetConstraints();
|
||||
return 0; //lookup.ContainsKey(constraints[0].DbValue.ToString()) ? lookup[constraints[0].DbValue.ToString()] : GetTimeStampDb();
|
||||
}
|
||||
|
||||
public Dictionary<string, long> GetAllTimeStampDb()
|
||||
{
|
||||
var lookup = new Dictionary<string, long>();
|
||||
return lookup;
|
||||
//try
|
||||
//{
|
||||
// var constraints = GetConstraints();
|
||||
// if (1 == constraints.Length)
|
||||
// {
|
||||
// using (var cmd = DbOperations.GetSQLCommand())
|
||||
// {
|
||||
// cmd.CommandText = string.Format("SELECT [{0}], DbTimeStamp from {1}", constraints[0].ColumnName, LookupTable);
|
||||
// using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
// {
|
||||
// foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
// {
|
||||
// var s = Convert.ToString(dr[constraints[0].ColumnName]);
|
||||
// if (DBNull.Value.Equals(dr["DbTimeStamp"])) { continue; }
|
||||
// var res = BitConverter.ToInt64((dr["DbTimeStamp"] as byte[]), 0);
|
||||
// lookup[s] = res;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex) { APILogger.Log(ex); }
|
||||
//return lookup;
|
||||
}
|
||||
public long GetTimeStampDb()
|
||||
{
|
||||
return 0;
|
||||
//using (var sql = DbOperations.GetSQLCommand())
|
||||
//{
|
||||
// var sb = new StringBuilder(50);
|
||||
// sb.AppendFormat("SELECT DbTimeStamp as A FROM {0} ", LookupTable);
|
||||
|
||||
// var constraints = GetConstraints();
|
||||
// for (var i = 0; i < constraints.Length; i++)
|
||||
// {
|
||||
// sb.Append(0 == i ? "WHERE " : " AND ");
|
||||
// sb.AppendFormat("{0}=@{1}", constraints[i].ColumnName, i);
|
||||
// DbOperations.CreateParam(sql, string.Format("@{0}", i), constraints[i].DbType, constraints[i].DbValue);
|
||||
// }
|
||||
// sql.CommandText = sb.ToString();
|
||||
// using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
// {
|
||||
// if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) return 0;
|
||||
// if (DBNull.Value.Equals(ds.Tables[0].Rows[0]["A"])) return 0;
|
||||
// try
|
||||
// {
|
||||
// var res = BitConverter.ToInt64(ds.Tables[0].Rows[0]["A"] as byte[], 0);
|
||||
// System.Diagnostics.Trace.WriteLine(string.Format("Db: {0}", res));
|
||||
// return res;
|
||||
// }
|
||||
// catch (Exception ex) { APILogger.Log(ex); return 0; }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
public abstract string LookupTable
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public class ConstraintHelper
|
||||
{
|
||||
public string ColumnName { get; set; }
|
||||
public System.Data.SqlDbType DbType { get; set; }
|
||||
public object DbValue { get; set; }
|
||||
}
|
||||
|
||||
public abstract ConstraintHelper[] GetConstraints();
|
||||
|
||||
public bool IsNotInDb()
|
||||
{
|
||||
return GetTimeStampDb() == 0;
|
||||
}
|
||||
|
||||
public bool IsOutOfDate()
|
||||
{
|
||||
var db = GetTimeStampDb();
|
||||
var mem = GetTimeStampMemory();
|
||||
//if there's no record in the db, don't mark as out of date
|
||||
if (db == 0) { return false; }
|
||||
//if is in db, but in memory is new, allow overwrite...
|
||||
if (mem == 0 && db != 0) { mem = db; SetTimeStampMemory(db); }
|
||||
return db != mem;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IDbTimeStampAware
|
||||
{
|
||||
long GetTimeStampMemory();
|
||||
void SetTimeStampMemory(long value);
|
||||
long GetTimeStampDb();
|
||||
bool IsOutOfDate();
|
||||
}
|
||||
public class DbItemOutOfDateException : Exception
|
||||
{
|
||||
public DbItemOutOfDateException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,488 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Data.OleDb;
|
||||
using DatabaseExport.Properties;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a helper class wrapping access to the iso13499 access db
|
||||
/// it also now makes use of datapro database tables which mimic the access db
|
||||
/// </summary>
|
||||
public class ISO13499FileDb
|
||||
{
|
||||
public class ExpiredISOFieldException : System.Exception
|
||||
{
|
||||
public ExpiredISOFieldException(string remark) : base(remark) { }
|
||||
}
|
||||
#region dictionaries
|
||||
/// <summary>
|
||||
/// list of directions, populated when first loaded
|
||||
/// </summary>
|
||||
private Dictionary<string, MMEDirections> _directionsDictionary = new Dictionary<string, MMEDirections>();
|
||||
/// <summary>
|
||||
/// list of filter classes, populated when first loaded
|
||||
/// </summary>
|
||||
private Dictionary<string, MMEFilterClasses> _filterClassesDictionary = new Dictionary<string, MMEFilterClasses>();
|
||||
/// <summary>
|
||||
/// list of figures, populated when first loaded
|
||||
/// </summary>
|
||||
private List<MMEFigures> _figures = new List<MMEFigures>();
|
||||
/// <summary>
|
||||
/// list of all known fine 1 locations, populated when first loaded
|
||||
/// </summary>
|
||||
private Dictionary<string, MMEFineLocations1> _fineLoc1Dictionary = new Dictionary<string, MMEFineLocations1>();
|
||||
/// <summary>
|
||||
/// list of all known fine 2 locations, populated when first loaded
|
||||
/// </summary>
|
||||
private Dictionary<string, MMEFineLocations2> _fineLoc2Dictionary = new Dictionary<string, MMEFineLocations2>();
|
||||
/// <summary>
|
||||
/// list of all known fine 3 locations, populated when first loaded
|
||||
/// </summary>
|
||||
private Dictionary<string, MMEFineLocations3> _fineLoc3Dictionary = new Dictionary<string, MMEFineLocations3>();
|
||||
/// <summary>
|
||||
/// list of all known physical dimensions, populated when first loaded
|
||||
/// </summary>
|
||||
private Dictionary<string, MMEPhysicalDimensions> _physicalDimensionsDictionary = new Dictionary<string, MMEPhysicalDimensions>();
|
||||
/// <summary>
|
||||
/// list of all known positions, populated when first loaded
|
||||
/// </summary>
|
||||
private Dictionary<string, MMEPositions> _positionsDictionary = new Dictionary<string, MMEPositions>();
|
||||
/// <summary>
|
||||
/// list of all known possible channels, populated when first loaded
|
||||
/// </summary>
|
||||
private List<MMEPossibleChannels> _possibleChannels = new List<MMEPossibleChannels>();
|
||||
/// <summary>
|
||||
/// list of possible test objects, populated when first loaded
|
||||
/// </summary>
|
||||
private Dictionary<string, MMETestObjects> _testObjectsDictionary = new Dictionary<string, MMETestObjects>();
|
||||
/// <summary>
|
||||
/// list of all possible transducer locations, populated when first loaded
|
||||
/// </summary>
|
||||
private Dictionary<string, MMETransducerMainLocation> _transducerMainLoc = new Dictionary<string, MMETransducerMainLocation>();
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// connection string for the iso13499 database
|
||||
/// you must also call refreshall to load data
|
||||
/// </summary>
|
||||
public string ConnectionStr { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// constructs an iso13499file db, you must still set the connection str
|
||||
/// </summary>
|
||||
public ISO13499FileDb()
|
||||
{
|
||||
}
|
||||
|
||||
public static bool Is646bitProcess { get; } = (IntPtr.Size == 8);
|
||||
|
||||
private static ISO13499FileDb _isoDb;
|
||||
public static ISO13499FileDb IsoDb
|
||||
{
|
||||
get
|
||||
{
|
||||
var log = new System.Diagnostics.EventLog { Source = "DataPROInstaller" };
|
||||
if (null == _isoDb)
|
||||
{
|
||||
log.WriteEntry("_isoDb is null");
|
||||
_isoDb = new ISO13499FileDb();
|
||||
log.WriteEntry("Got a new ISO13499FileDb");
|
||||
|
||||
_isoDb.RefreshAllData();
|
||||
log.WriteEntry("Back from RefreshAllData");
|
||||
}
|
||||
//log.WriteEntry("Returning from IsoDb get");
|
||||
return _isoDb;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// scans all possible channels for unique types, returns the list of unique types
|
||||
/// </summary>
|
||||
private List<string> _uniquePossibleChannelTypes = null;
|
||||
public string[] GetUniquePossibleChannelTypes()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
if (null == _uniquePossibleChannelTypes)
|
||||
{
|
||||
_uniquePossibleChannelTypes = new List<string>();
|
||||
var uniquetypes = (from pc in _possibleChannels where !pc.Expired orderby pc.Text_L1 select pc.Type).Distinct().ToArray();
|
||||
if (null != uniquetypes && uniquetypes.Length > 0)
|
||||
{
|
||||
_uniquePossibleChannelTypes.AddRange(uniquetypes);
|
||||
_uniquePossibleChannelTypes.Sort();
|
||||
}
|
||||
}
|
||||
return _uniquePossibleChannelTypes.ToArray();
|
||||
}
|
||||
public string[] GetUniquePossibleChannelTypes(string typeToRemove)
|
||||
{
|
||||
return GetUniquePossibleChannelTypes().Where(uniquePossibleChannelType => !uniquePossibleChannelType.StartsWith(typeToRemove)).ToArray();
|
||||
}
|
||||
private void RefreshIfNeeded()
|
||||
{
|
||||
lock (RefreshLock)
|
||||
{
|
||||
if (!_bLoaded) { RefreshAllData(); }
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// gets a list of all possible channels given a type
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public MMEPossibleChannels[] GetPossibleChannelsForType(string type)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
//Don't include 2535, the Thoracic Compression Criterion channel which contains an expired main location (TCCR), but isn't itself marked as expired (FB 9891).
|
||||
return (from pc in _possibleChannels.AsParallel() where pc.Type == type && pc.Id != 2535 && (pc.Direction != "R" || pc.Text_L1.ToLower().Contains("seat") || pc.Text_L1.ToLower().Contains("load")) && !pc.Expired && pc.Default_Filter_Class != "V" orderby pc.Text_L1 select pc).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets the possible channels just from DataPRO exclusive (so excluding ISO13499 origined channels)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEPossibleChannels[] GetSQLPossibleChannels()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
var list = (from pc in _possibleChannels.AsParallel() where pc.MMEChannelType == (int)MMEPossibleChannels.MMEChannelTypes.SQL select pc).ToArray();
|
||||
|
||||
if (null != list && list.Any())
|
||||
{
|
||||
return list.Select(li => new MMEPossibleChannels(li)).ToArray();
|
||||
}
|
||||
return new MMEPossibleChannels[0];
|
||||
}
|
||||
/// <summary>
|
||||
/// gets the "type" field from all possible channels where the channel test object matchines the input string in to
|
||||
/// </summary>
|
||||
/// <param name="to"></param>
|
||||
/// <returns></returns>
|
||||
public string[] GetTestObjectTypeForTestObject(string to)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return (from pc in _possibleChannels.AsParallel() where pc.Test_Object == to orderby pc.Type select pc.Type).Distinct().ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dictionary of possible channels keyed by id, there's a separate dictionary for iso13499 origined channels
|
||||
/// and DataPRO origined channels
|
||||
/// </summary>
|
||||
private Dictionary<long, MMEPossibleChannels> _mmePossibleChannelsDict = null;
|
||||
private Dictionary<long, MMEPossibleChannels> _mmePossibleChannelsDictOurs = null;
|
||||
public MMEPossibleChannels GetPossibleChannel(long id, int channelType)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
if (1 == channelType)
|
||||
{
|
||||
if (null == _mmePossibleChannelsDictOurs)
|
||||
{
|
||||
_mmePossibleChannelsDictOurs = new Dictionary<long, MMEPossibleChannels>();
|
||||
foreach (var channel in _possibleChannels)
|
||||
{
|
||||
if (channel.MMEChannelType != channelType) { continue; }
|
||||
if (!_mmePossibleChannelsDictOurs.ContainsKey(channel.Id)) { _mmePossibleChannelsDictOurs.Add(channel.Id, channel); }
|
||||
}
|
||||
}
|
||||
return _mmePossibleChannelsDictOurs.ContainsKey(id) ? _mmePossibleChannelsDictOurs[id] : null;
|
||||
}
|
||||
if (null == _mmePossibleChannelsDict)
|
||||
{
|
||||
_mmePossibleChannelsDict = new Dictionary<long, MMEPossibleChannels>();
|
||||
foreach (var channel in _possibleChannels)
|
||||
{
|
||||
if (channel.MMEChannelType != channelType) { continue; }
|
||||
if (!_mmePossibleChannelsDict.ContainsKey(channel.Id)) { _mmePossibleChannelsDict.Add(channel.Id, channel); }
|
||||
}
|
||||
}
|
||||
return _mmePossibleChannelsDict.ContainsKey(id) ? _mmePossibleChannelsDict[id] : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets all possible test objects from test object tables
|
||||
/// </summary>
|
||||
/// <param name="bIncludeExpired"></param>
|
||||
/// <returns></returns>
|
||||
public MMETestObjects[] GetTestObjects(bool bIncludeExpired)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return bIncludeExpired ? _testObjectsDictionary.Values.ToArray() : (from to in _testObjectsDictionary.Values.ToArray().AsParallel() where !to.Expired select to).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns any test objects which match test object test object iso code.
|
||||
/// returns null if not found
|
||||
/// </summary>
|
||||
/// <param name="iso"></param>
|
||||
/// <returns></returns>
|
||||
public MMETestObjects GetTestObjectByIso(string iso)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _testObjectsDictionary.ContainsKey(iso) ? _testObjectsDictionary[iso] : null;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a position if any that has a matching iso code position field
|
||||
/// returns null if not found
|
||||
/// </summary>
|
||||
/// <param name="key">position code to look for</param>
|
||||
/// <returns></returns>
|
||||
public MMEPositions GetPositionByISO(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _positionsDictionary.ContainsKey(key) ? _positionsDictionary[key] : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns the first position with a guid which matches the requested guid
|
||||
/// returns null if not found
|
||||
/// </summary>
|
||||
/// <param name="GUID">guid to look for</param>
|
||||
/// <returns></returns>
|
||||
public MMEPositions GetPosition(string GUID)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
var positions = (from p in _positionsDictionary.Values.ToArray().AsParallel() where p.S_GUID == GUID select p);
|
||||
if (null != positions && positions.Any()) { return positions.First(); }
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// gets all possible filter classes
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEFilterClasses[] GetFilterClasses()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _filterClassesDictionary.Values.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// returns filter class matching the iso code filter class field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEFilterClasses GetFilterClassByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _filterClassesDictionary.ContainsKey(key) ? _filterClassesDictionary[key] : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets all possible directions
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEDirections[] GetDirections()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _directionsDictionary.Values.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a direction given the isocode direction field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEDirections GetDirectionByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _directionsDictionary.ContainsKey(key) ? _directionsDictionary[key] : null;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns all possible fine location 1
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEFineLocations1[] GetFineLocations1()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _fineLoc1Dictionary.Values.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a fine location 1, given a matching iso fine location field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEFineLocations1 GetFineLocation1ByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _fineLoc1Dictionary.ContainsKey(key) ? _fineLoc1Dictionary[key] : null;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns all possible fine location 2
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEFineLocations2[] GetFineLocations2()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _fineLoc2Dictionary.Values.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a fine location 2 based on fine location 2 iso code field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEFineLocations2 GetFineLocation2ByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _fineLoc2Dictionary.ContainsKey(key) ? _fineLoc2Dictionary[key] : null;
|
||||
}
|
||||
/// <summary>
|
||||
/// gets all possible fine locations 3
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEFineLocations3[] GetFineLocations3()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _fineLoc3Dictionary.Values.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// gets fine location 3 based on fine location 3 isocode field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEFineLocations3 GetFineLocation3ByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
if (_fineLoc3Dictionary.ContainsKey(key)) { return _fineLoc3Dictionary[key]; }
|
||||
else { return null; }
|
||||
}
|
||||
/// <summary>
|
||||
/// gets all possible physical dimensions
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEPhysicalDimensions[] GetPhysicalDimensions()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _physicalDimensionsDictionary.Values.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// gets physical dimension by isocode physical dimension field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEPhysicalDimensions GetPhysicalDimensionByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _physicalDimensionsDictionary.ContainsKey(key) ? _physicalDimensionsDictionary[key] : null;
|
||||
}
|
||||
public MMEPositions[] GetPositions()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _positionsDictionary.Values.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// gets all possible main locations
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMETransducerMainLocation[] GetMainLocations()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _transducerMainLoc.Values.ToArray();
|
||||
}
|
||||
|
||||
Dictionary<string, MMETransducerMainLocation> _expiredMainLocations = new Dictionary<string, MMETransducerMainLocation>();
|
||||
/// <summary>
|
||||
/// gets a main location given an isocode main location field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMETransducerMainLocation GetMainLocationByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
if (_transducerMainLoc.ContainsKey(key)) { return _transducerMainLoc[key]; }
|
||||
if (_expiredMainLocations.ContainsKey(key)) { throw new Exception(/*ExpiredISOFieldException*/_expiredMainLocations[key].Remarks); }
|
||||
return null;
|
||||
}
|
||||
private bool _bLoaded = false;
|
||||
private static readonly object RefreshLock = new object();
|
||||
/// <summary>
|
||||
/// loads all data from iso13499 and datapro databases
|
||||
/// </summary>
|
||||
public void RefreshAllData()
|
||||
{
|
||||
var log = new System.Diagnostics.EventLog { Source = "DataPROInstaller" };
|
||||
log.WriteEntry("In RefreshAllData");
|
||||
lock (RefreshLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mmePossibleChannelsDict = new Dictionary<long, MMEPossibleChannels>();
|
||||
_mmePossibleChannelsDictOurs = new Dictionary<long, MMEPossibleChannels>();
|
||||
_uniquePossibleChannelTypes = null;
|
||||
_directionsDictionary.Clear();
|
||||
_figures.Clear();
|
||||
_filterClassesDictionary.Clear();
|
||||
_fineLoc1Dictionary.Clear();
|
||||
_fineLoc2Dictionary.Clear();
|
||||
_fineLoc3Dictionary.Clear();
|
||||
_physicalDimensionsDictionary.Clear();
|
||||
_positionsDictionary.Clear();
|
||||
_possibleChannels.Clear();
|
||||
_testObjectsDictionary.Clear();
|
||||
_transducerMainLoc.Clear();
|
||||
_expiredMainLocations.Clear();
|
||||
|
||||
log.WriteEntry("Entering try");
|
||||
try
|
||||
{
|
||||
foreach (var dir in MMEDirections.GetDirections()) { if (!_directionsDictionary.ContainsKey(dir.Direction)) { _directionsDictionary.Add(dir.Direction, dir); } }
|
||||
|
||||
_figures.AddRange(MMEFigures.GetFigures());
|
||||
|
||||
foreach (var fc in MMEFilterClasses.GetFilterClasses()) { if (!_filterClassesDictionary.ContainsKey(fc.Filter_Class)) { _filterClassesDictionary.Add(fc.Filter_Class, fc); } }
|
||||
|
||||
foreach (var loc in MMEFineLocations1.GetFineLocations1()) { if (!_fineLoc1Dictionary.ContainsKey(loc.Fine_Loc_1)) { _fineLoc1Dictionary.Add(loc.Fine_Loc_1, loc); } }
|
||||
|
||||
foreach (var loc in MMEFineLocations2.GetFineLocations2()) { if (!_fineLoc2Dictionary.ContainsKey(loc.FINE_LOC_2)) { _fineLoc2Dictionary.Add(loc.FINE_LOC_2, loc); } }
|
||||
|
||||
foreach (var loc in MMEFineLocations3.GetFineLocations3()) { if (!_fineLoc3Dictionary.ContainsKey(loc.FINE_LOC_3)) { _fineLoc3Dictionary.Add(loc.FINE_LOC_3, loc); } }
|
||||
|
||||
foreach (var pd in MMEPhysicalDimensions.GetPhysicalDimensions()) { if (!_physicalDimensionsDictionary.ContainsKey(pd.Physical_Dimension)) { _physicalDimensionsDictionary.Add(pd.Physical_Dimension, pd); } }
|
||||
|
||||
foreach (var pos in MMEPositions.GetPositions()) { if (!_positionsDictionary.ContainsKey(pos.Position)) { _positionsDictionary.Add(pos.Position, pos); } }
|
||||
|
||||
_possibleChannels.AddRange(MMEPossibleChannels.GetPossibleChannels());
|
||||
|
||||
log.WriteEntry("Getting TestObjects");
|
||||
foreach (var to in MMETestObjects.GetTestObjects())
|
||||
{
|
||||
log.WriteEntry("Checking " + to.ToString());
|
||||
if (!_testObjectsDictionary.ContainsKey(to.Test_Object))
|
||||
{
|
||||
log.WriteEntry("Adding " + to.ToString());
|
||||
_testObjectsDictionary.Add(to.Test_Object, to);
|
||||
}
|
||||
}
|
||||
log.WriteEntry("Done Getting TestObjects");
|
||||
foreach (var mainloc in MMETransducerMainLocation.GetTransducerMainLocations())
|
||||
{
|
||||
if (mainloc.Expired)
|
||||
{
|
||||
if (!_expiredMainLocations.ContainsKey(mainloc.Trans_Main_Loc)) { _expiredMainLocations.Add(mainloc.Trans_Main_Loc, mainloc); }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_transducerMainLoc.ContainsKey(mainloc.Trans_Main_Loc)) { _transducerMainLoc.Add(mainloc.Trans_Main_Loc, mainloc); }
|
||||
}
|
||||
}
|
||||
foreach (var pc in _possibleChannels)
|
||||
{
|
||||
if (pc.MMEChannelType == (int)MMEPossibleChannels.MMEChannelTypes.SQL) { _mmePossibleChannelsDictOurs[pc.Id] = pc; }
|
||||
else { _mmePossibleChannelsDict[pc.Id] = pc; }
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.WriteEntry("Exception before setting _bLoaded to True: " + ex.Message);
|
||||
//DTS.Utilities.Logging.APILogger.Log("failure to load ISO tables", ex);
|
||||
}
|
||||
_bLoaded = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.WriteEntry("Exception before setting _bLoaded to False: " + ex.Message);
|
||||
_bLoaded = false;
|
||||
//DTS.Utilities.Logging.APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="DatabaseExport.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="DatabaseExport.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<applicationSettings>
|
||||
<DatabaseExport.Properties.Settings>
|
||||
<setting name="ISOMMEDbLocation" serializeAs="String">
|
||||
<value>ISO\mme_code.mdb</value>
|
||||
</setting>
|
||||
<setting name="AllowAutoArm" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DBType" serializeAs="String">
|
||||
<value>1</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestAllowMissingSensors" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestAllowSensorIdToBlankChannel" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestArmCheckListStep" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestCheckListBatteryVoltageCheck" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestCheckListInputVoltageCheck" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestCheckListMustPass" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestCheckListSensorIDCheck" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestCheckListSquibResistanceCheck" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestCheckListTriggerStartCheck" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestDownloadAll" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestDownloadROI" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestExcitationWarmupMS" serializeAs="String">
|
||||
<value>6000</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestExport" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestQuitTestWithoutWarning" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestRealtimeModeGraphCount" serializeAs="String">
|
||||
<value>6</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestExportFormat" serializeAs="String">
|
||||
<value>0</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestRequireAllUnitsPassDiagnostics" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestRequireUserConfirmationOnErrors" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestROIEnd" serializeAs="String">
|
||||
<value>1</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestROIStart" serializeAs="String">
|
||||
<value>-1</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestRunPostTestDiagnostics" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestSampleRate" serializeAs="String">
|
||||
<value>10000</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestSuppressNotAllChannelsViewedWarningRealTime"
|
||||
serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestTriggerCheckStep" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestSuppressNotAllChannelsViewedWarningViewer"
|
||||
serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestViewAll" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DefaultTestViewROI" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="DefaultUploadEnabled" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DownloadFolder" serializeAs="String">
|
||||
<value>..\Data</value>
|
||||
</setting>
|
||||
<setting name="RequireXCrashCompatibilityForISOExports" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
</DatabaseExport.Properties.Settings>
|
||||
</applicationSettings>
|
||||
<userSettings>
|
||||
<DatabaseExport.Properties.Settings>
|
||||
<setting name="CalWarningPeriodDays" serializeAs="String">
|
||||
<value>7</value>
|
||||
</setting>
|
||||
<setting name="DefaultSuppressMissingSensorsWarning" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="InstallerCustomActions" serializeAs="String">
|
||||
<value>InstallerCustomActions</value>
|
||||
</setting>
|
||||
</DatabaseExport.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class GroupTemplateTableInfo
|
||||
{
|
||||
public GroupTemplateTableInfo(string templateName, SerializedSettings.ISOSupportLevels isoSupportLevel, bool sysBuilt, string templateDescription, DateTime lastModified, string lastModifiedBy, bool embedded)
|
||||
{
|
||||
TemplateName = templateName;
|
||||
ISOSupportLevel = isoSupportLevel;
|
||||
SysBuilt = sysBuilt;
|
||||
TemplateDescription = templateDescription;
|
||||
LastModified = lastModified;
|
||||
LastModifiedBy = lastModifiedBy;
|
||||
Embedded = embedded;
|
||||
}
|
||||
|
||||
public string TemplateName { get; private set; }
|
||||
public SerializedSettings.ISOSupportLevels ISOSupportLevel { get; private set; }
|
||||
public bool SysBuilt { get; private set; }
|
||||
public string TemplateDescription { get; private set; }
|
||||
public DateTime LastModified { get; private set; }
|
||||
public string LastModifiedBy { get; private set; }
|
||||
public bool Embedded { get; private set; }
|
||||
public override string ToString()
|
||||
{
|
||||
return TemplateName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class LabratoryDetails
|
||||
{
|
||||
ISO.LabratoryDetails _lab = null;
|
||||
public string Name
|
||||
{
|
||||
get => _lab.Name;
|
||||
set => _lab.Name = value;
|
||||
}
|
||||
public LabratoryDetails()
|
||||
{
|
||||
_lab = new ISO.LabratoryDetails();
|
||||
_lab.Name = "(none)";
|
||||
}
|
||||
public LabratoryDetails(ISO.LabratoryDetails lab) { _lab = new ISO.LabratoryDetails(lab); }
|
||||
public ISO.LabratoryDetails GetIsoLab() { return _lab; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class LabratoryDetailsList
|
||||
{
|
||||
protected LabratoryDetailsList()
|
||||
{
|
||||
}
|
||||
private static LabratoryDetailsList _list = new LabratoryDetailsList();
|
||||
public static LabratoryDetailsList LabratoryList => _list;
|
||||
private Dictionary<string, LabratoryDetails> _labs = null;
|
||||
|
||||
private void PopulateList()
|
||||
{
|
||||
if (null != _labs) return;
|
||||
_labs = new Dictionary<string, LabratoryDetails>();
|
||||
foreach (var l in GetAllLabs())
|
||||
{
|
||||
if (!_labs.ContainsKey(l.Name))
|
||||
{
|
||||
_labs.Add(l.Name, l);
|
||||
}
|
||||
else
|
||||
{
|
||||
_labs[l.Name] = l;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static object _LabLock = new object();
|
||||
|
||||
public LabratoryDetails[] Labs
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_LabLock)
|
||||
{
|
||||
PopulateList();
|
||||
}
|
||||
var labs = new List<LabratoryDetails>(_labs.Values);
|
||||
labs.Sort(CompareLabs);
|
||||
return labs.ToArray();
|
||||
}
|
||||
}
|
||||
private static int CompareLabs(LabratoryDetails a, LabratoryDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
return null == b ? 1 : string.Compare(a.Name, b.Name, StringComparison.Ordinal);
|
||||
}
|
||||
public LabratoryDetails GetLab(string name)
|
||||
{
|
||||
try { lock (_LabLock) { return _labs != null ? _labs.ContainsKey(name) ? _labs[name] : null : null; } }
|
||||
catch (Exception) {/* DTS.Utilities.Logging.APILogger.Log("failed to get labratories", ex); */}
|
||||
return null;
|
||||
}
|
||||
|
||||
private LabratoryDetails[] GetAllLabs()
|
||||
{
|
||||
var list = new List<LabratoryDetails>();
|
||||
try
|
||||
{
|
||||
list.Add(new LabratoryDetails()); //This is the "(none)" entry
|
||||
list.AddRange(ISO.LabratoryDetails.GetAllLabratoryDetails().Select(lab => new LabratoryDetails(lab)));
|
||||
}
|
||||
catch (Exception) {/* DTS.Utilities.Logging.APILogger.Log("failed to get labratories", ex);*/ }
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// a custom channel is a wrapper for MMEPossibleChannels that are defined by the user rather than ISO13499
|
||||
/// they have mirror tables to the actual db and let us define new channels without disrupting the existing 1so13499 db
|
||||
/// </summary>
|
||||
public class CustomChannel : /*BindableBase,*/ IComparable<CustomChannel>
|
||||
{
|
||||
public MMEPossibleChannels Channel { get; private set; }
|
||||
private MMETestObjects _testObject;
|
||||
public MMETestObjects TestObject
|
||||
{
|
||||
get => _testObject;
|
||||
set { _testObject = value; if (null != Channel && null != value) { Channel.Set_Test_Object(value.Test_Object); } }
|
||||
}
|
||||
|
||||
private MMEPositions _position;
|
||||
public MMEPositions Position
|
||||
{
|
||||
get => _position;
|
||||
set { _position = value; if (null != Channel && null != value) { Channel.Set_Position(value.Position); } }
|
||||
}
|
||||
|
||||
private MMETransducerMainLocation _mainLocation;
|
||||
public MMETransducerMainLocation MainLocation
|
||||
{
|
||||
get => _mainLocation;
|
||||
set { _mainLocation = value; if (null != Channel && null != value) { Channel.Set_Main_Loc(value.Trans_Main_Loc); } }
|
||||
}
|
||||
|
||||
private MMEFineLocations1 _finLoc1;
|
||||
|
||||
public MMEFineLocations1 FinLoc1
|
||||
{
|
||||
get => _finLoc1;
|
||||
set { _finLoc1 = value; if (null != Channel && null != value) { Channel.Set_Fine_Loc_1(value.Fine_Loc_1); } }
|
||||
}
|
||||
|
||||
private MMEFineLocations2 _finLoc2;
|
||||
public MMEFineLocations2 FinLoc2
|
||||
{
|
||||
get => _finLoc2;
|
||||
set { _finLoc2 = value; if (null != Channel && null != value) { Channel.Set_Fine_Loc_2(value.FINE_LOC_2); } }
|
||||
}
|
||||
|
||||
private MMEFineLocations3 _finLoc3;
|
||||
public MMEFineLocations3 FinLoc3
|
||||
{
|
||||
get => _finLoc3;
|
||||
set { _finLoc3 = value; if (null != Channel && null != value) { Channel.Set_Fine_Loc_3(value.FINE_LOC_3); } }
|
||||
}
|
||||
|
||||
private MMEPhysicalDimensions _physicalDimension;
|
||||
public MMEPhysicalDimensions PhysicalDimension
|
||||
{
|
||||
get => _physicalDimension;
|
||||
set { _physicalDimension = value; if (null != Channel && null != value) { Channel.Set_Physical_Dimension(value.Physical_Dimension); } }
|
||||
}
|
||||
|
||||
private MMEDirections _direction;
|
||||
public MMEDirections Direction
|
||||
{
|
||||
get => _direction;
|
||||
set { _direction = value; if (null != Channel && null != value) { Channel.Set_Direction(value.Direction); } }
|
||||
}
|
||||
|
||||
private MMEFilterClasses _filterClass;
|
||||
public MMEFilterClasses FilterClass
|
||||
{
|
||||
get => _filterClass;
|
||||
set { _filterClass = value; if (null != Channel && null != value) { Channel.Set_Default_Filter_Class(value.Filter_Class); } }
|
||||
}
|
||||
public string Text1
|
||||
{
|
||||
get => Channel.Text_L1;
|
||||
set => Channel.SetText1(value);
|
||||
}
|
||||
|
||||
public string Remarks
|
||||
{
|
||||
get => Channel.Remarks;
|
||||
set => Channel.SetRemarks(value);
|
||||
}
|
||||
private readonly List<ISO13499FileDb.ExpiredISOFieldException> _expiredErrors = new List<ISO13499FileDb.ExpiredISOFieldException>();
|
||||
|
||||
public CustomChannel(MMEPossibleChannels channel, bool newChannel = true)
|
||||
{
|
||||
Channel = newChannel ? new MMEPossibleChannels(channel) : channel;
|
||||
|
||||
_direction = ISO13499FileDb.IsoDb.GetDirectionByIso(channel.Direction);
|
||||
_filterClass = ISO13499FileDb.IsoDb.GetFilterClassByIso(channel.Default_Filter_Class);
|
||||
_finLoc1 = ISO13499FileDb.IsoDb.GetFineLocation1ByIso(channel.Fine_Loc_1);
|
||||
_finLoc2 = ISO13499FileDb.IsoDb.GetFineLocation2ByIso(channel.Fine_Loc_2);
|
||||
_finLoc3 = ISO13499FileDb.IsoDb.GetFineLocation3ByIso(channel.Fine_Loc_3);
|
||||
|
||||
try { _mainLocation = ISO13499FileDb.IsoDb.GetMainLocationByIso(channel.Trans_Main_Loc); }
|
||||
catch (ISO13499FileDb.ExpiredISOFieldException ex) { _expiredErrors.Add(ex); }
|
||||
|
||||
_physicalDimension = ISO13499FileDb.IsoDb.GetPhysicalDimensionByIso(channel.Physical_Dimension);
|
||||
_position = ISO13499FileDb.IsoDb.GetPositionByISO(channel.Position);
|
||||
_testObject = ISO13499FileDb.IsoDb.GetTestObjectByIso(channel.Test_Object);
|
||||
}
|
||||
public int CompareTo(CustomChannel other)
|
||||
{
|
||||
return Equals(this, other) ? 0 : string.Compare(Text1, other.Text1, StringComparison.Ordinal);
|
||||
}
|
||||
public Dictionary<string, string> GetValues()
|
||||
{
|
||||
var elementNameValuePairs = new Dictionary<string, string>
|
||||
{
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.ID.ToString()] = Channel.Id.ToString(CultureInfo.InvariantCulture),
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.TYPE.ToString()] = Channel.Type,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.TEST_OBJECT.ToString()] = TestObject.Test_Object,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.POSITION.ToString()] = Position.Position,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.TRANS_MAIN_LOC.ToString()] = MainLocation.Trans_Main_Loc,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.FINE_LOC_1.ToString()] = FinLoc1.Fine_Loc_1,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.FINE_LOC_2.ToString()] = FinLoc2.FINE_LOC_2,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.FINE_LOC_3.ToString()] = FinLoc3.FINE_LOC_3,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.PHYSICAL_DIMENSION.ToString()] = PhysicalDimension.Physical_Dimension,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.DIRECTION.ToString()] = Direction.Direction,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.DEFAULT_FILTER_CLASS.ToString()] = FilterClass.Filter_Class,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.TEXT_L1.ToString()] = Text1,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.TEXT_L2.ToString()] = Channel.Text_L2,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.VERSION.ToString()] = Channel.Version.ToString(CultureInfo.InvariantCulture),
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.DATE.ToString()] = Channel.Date.ToString(CultureInfo.InvariantCulture),
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.REMARKS.ToString()] = Remarks,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.EXPIRED.ToString()] = Channel.Expired.ToString(),
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.SORTKEY.ToString()] = Channel.SortKey,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.PICTURE_SHORTNAME.ToString()] = Channel.Picture_ShortName,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.LAST_CHANGE.ToString()] = Channel.Last_Change.ToString(CultureInfo.InvariantCulture),
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.LAST_CHANGE_TEXT.ToString()] = Channel.Last_Change_Text,
|
||||
[DbOperations.MMETables.MMEPossibleChannelsFields.HISTORY.ToString()] = Channel.History
|
||||
};
|
||||
|
||||
return elementNameValuePairs;
|
||||
}
|
||||
}
|
||||
public class CustomChannelList
|
||||
{
|
||||
private static readonly object MyLock = new object();
|
||||
private static CustomChannelList _list;
|
||||
public static CustomChannelList List
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (null == _list)
|
||||
{
|
||||
_list = new CustomChannelList();
|
||||
}
|
||||
}
|
||||
return _list;
|
||||
}
|
||||
}
|
||||
private List<CustomChannel> _listChannels;
|
||||
public CustomChannel[] AllChannels
|
||||
{
|
||||
get
|
||||
{
|
||||
PopulateChannelsIfNecessary();
|
||||
return _listChannels.ToArray();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// loads all calculated channels, if necessary
|
||||
/// </summary>
|
||||
private void PopulateChannelsIfNecessary()
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (null != _listChannels) return;
|
||||
_listChannels = new List<CustomChannel>();
|
||||
//_dictChannels = new Dictionary<string, CustomChannel>();
|
||||
foreach (var channel in ISO13499FileDb.IsoDb.GetSQLPossibleChannels())
|
||||
{
|
||||
var ch = new CustomChannel(channel);
|
||||
//var iso = ISO.IsoCode.GetString(ch.Channel, false);
|
||||
//if (_dictChannels.ContainsKey(iso)) continue;
|
||||
_listChannels.Add(ch);
|
||||
//_dictChannels[iso] = ch;
|
||||
}
|
||||
_listChannels.Sort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class DigitalOutputSetting : SensorData
|
||||
{
|
||||
public string ChannelDescription
|
||||
{
|
||||
get => SerialNumber;
|
||||
set
|
||||
{
|
||||
SerialNumber = value;
|
||||
OnPropertyChanged("ChannelDescription");
|
||||
}
|
||||
}
|
||||
|
||||
// public DigitalOutputSetting(DigitalOutputSetting copy) : base(copy)
|
||||
// {
|
||||
// SetDefaults(this);
|
||||
// }
|
||||
|
||||
public DigitalOutputSetting()
|
||||
{
|
||||
SetDefaults(this);
|
||||
}
|
||||
|
||||
public static void SetDefaults(SensorData sd)
|
||||
{
|
||||
sd.SupportedExcitation = new Test.Module.Channel.Sensor.ExcitationVoltageOption[]
|
||||
{Test.Module.Channel.Sensor.ExcitationVoltageOption.Volt5};
|
||||
sd.Bridge = Test.Module.Channel.Sensor.BridgeType.TOMDigital;
|
||||
sd.AxisNumber = 0;
|
||||
sd.NumberOfAxes = 1;
|
||||
sd.Capacity = 1;
|
||||
sd.DisplayUnit = "V";
|
||||
sd.BridgeResistance = double.NaN;
|
||||
sd.CheckOffset = false;
|
||||
sd.Manufacturer = "Generic";
|
||||
sd.OffsetToleranceHigh = 2500;
|
||||
sd.OffsetToleranceLow = 2500;
|
||||
sd.Model = "Digital Output Setting";
|
||||
sd.Shunt = ShuntMode.None;
|
||||
sd.MeasureExcitation = false;
|
||||
sd.MeasureNoise = false;
|
||||
}
|
||||
|
||||
public DigitalOutputSetting(System.Data.DataRow dr)
|
||||
{
|
||||
Bridge = Test.Module.Channel.Sensor.BridgeType.TOMDigital;
|
||||
|
||||
var fields = Enum.GetValues(typeof(DbOperations.DigitalOutputSettings.Fields))
|
||||
.Cast<DbOperations.DigitalOutputSettings.Fields>().ToArray();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
var o = dr[field.ToString()];
|
||||
if (DBNull.Value.Equals(o))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.DigitalOutputSettings.Fields.Version:
|
||||
Version = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DigitalOutputSettings.Fields.OutputMode:
|
||||
DigitalOutputMode = (OutputTOMDigitalChannel.DigitalOutputMode)Convert.ToInt16(o);
|
||||
break;
|
||||
case DbOperations.DigitalOutputSettings.Fields.LocalOnly:
|
||||
_localOnly = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.DigitalOutputSettings.Fields.LimitDuration:
|
||||
DigitalOutputLimitDuration = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.DigitalOutputSettings.Fields.LastModifiedBy:
|
||||
LastUpdatedBy = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.DigitalOutputSettings.Fields.LastModified:
|
||||
LastModified = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.DigitalOutputSettings.Fields.DurationMS: //obsolete, but non-null, field
|
||||
//DigitalOutputDurationMS = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.DigitalOutputSettings.Fields.DurationMSFloat:
|
||||
DigitalOutputDurationMS = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.DigitalOutputSettings.Fields.DelayMS:
|
||||
DigitalOutputDelayMS = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.DigitalOutputSettings.Fields.ChannelDescription:
|
||||
ChannelDescription = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.DigitalOutputSettings.Fields.UserTags:
|
||||
TagsBlobBytes = (byte[])o;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to process: ", field.ToString(), ex);
|
||||
}
|
||||
}
|
||||
SetDefaults(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a lightweight version of test TestTemplate, holding just the essential information
|
||||
/// [updated]: this concept is already present in testtemplate,
|
||||
/// by default it only loads information in the tblTestSetup, and then uses the IsLoaded flag to
|
||||
/// check whether it's populated information from other tables or not.
|
||||
/// I'll leave the class here for now in case we want to expand on it in the future, also I cleaned up a few things in the process anyhow
|
||||
/// </summary>
|
||||
public class TestTemplateLite
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
public RecordingModes RecordingMode { get; set; }
|
||||
private double _preTriggerSeconds;
|
||||
public double PreTriggerSeconds
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (RecordingMode)
|
||||
{
|
||||
case RecordingModes.Recorder:
|
||||
case RecordingModes.HybridRecorder:
|
||||
return 0D;
|
||||
case RecordingModes.CircularBuffer:
|
||||
return _preTriggerSeconds;
|
||||
default:
|
||||
return _preTriggerSeconds;
|
||||
}
|
||||
}
|
||||
set => _preTriggerSeconds = value;
|
||||
}
|
||||
|
||||
public double PostTriggerSeconds { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public string LastModifiedBy { get; set; }
|
||||
public bool IsComplete { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TestObjectTemplateCollection
|
||||
{
|
||||
|
||||
private static volatile TestObjectTemplateCollection _testObjectCollection;
|
||||
public static TestObjectTemplateCollection TemplateCollection => _testObjectCollection ?? (_testObjectCollection = new TestObjectTemplateCollection());
|
||||
|
||||
public GroupTemplateTableInfo[] GetAllTemplates(bool bIncludeEmbeddedAndSysBuilt = true)
|
||||
{
|
||||
var templates = new List<GroupTemplateTableInfo>();
|
||||
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
if (bIncludeEmbeddedAndSysBuilt)
|
||||
{
|
||||
sql.CommandText =
|
||||
"SELECT TemplateName, Description, LastModifiedBy, TestObjectType, LastModified, SysBuilt, Embedded from tblTestObjectTemplates";
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.CommandText = "SELECT TemplateName, Description, LastModifiedBy, TestObjectType, LastModified, SysBuilt, Embedded from tblTestObjectTemplates WHERE (Embedded=0 OR Embedded is NULL) AND SysBuilt=0";
|
||||
}
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var templateName = (string)dr["TemplateName"];
|
||||
var templateDescription = (string)dr["Description"];
|
||||
var lastModifiedBy = (string)dr["LastModifiedBy"];
|
||||
var testObjectType = (string)dr["TestObjectType"];
|
||||
var lastModified = Convert.ToDateTime(dr["LastModified"]);
|
||||
var sysBuilt = Convert.ToBoolean(dr["SysBuilt"]);
|
||||
var embeddedValue = dr["Embedded"];
|
||||
var embedded = false;
|
||||
if (!DBNull.Value.Equals(embeddedValue))
|
||||
{
|
||||
embedded = Convert.ToBoolean(dr["Embedded"]);
|
||||
}
|
||||
|
||||
var isoSupportLevel =
|
||||
(testObjectType.Contains(TestObjectTemplate.NON_ISO_TESTOBJECT_CHANNEL_TYPE) ||
|
||||
testObjectType.Contains(TestObjectTemplateChannel.NONISOCHANNELTYPE))
|
||||
? SerializedSettings.ISOSupportLevels.NO_ISO
|
||||
: SerializedSettings.ISOSupportLevels.ISO_ONLY;
|
||||
|
||||
templates.Add(new GroupTemplateTableInfo(templateName, isoSupportLevel, sysBuilt,
|
||||
templateDescription, lastModified, lastModifiedBy, embedded));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return templates.ToArray();
|
||||
}
|
||||
private static volatile TestObjectTemplate _sysBuiltTestObjectTemplate;
|
||||
public TestObjectTemplate SysBuiltTestObjectTemplate => _sysBuiltTestObjectTemplate;
|
||||
|
||||
public TestObjectTemplate GetTemplate(string templateId)
|
||||
{
|
||||
//if (null == Application.Current) { return null; }
|
||||
var db = ISO13499FileDb.IsoDb;
|
||||
var template = ISO.TestObjectTemplate.GetTemplate(ref db, templateId);
|
||||
if (null == template)
|
||||
{
|
||||
return new TestObjectTemplate();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TestObjectTemplate(template, ref db);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Test.Module.Channel.Sensor.ExcitationVoltage.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
// *** see Test.cs ***
|
||||
public partial class Test
|
||||
{
|
||||
/// <summary>
|
||||
/// A container for DTS generic module concepts.
|
||||
/// </summary>
|
||||
public sealed partial class Module
|
||||
{
|
||||
// *** see Test.Module.Channel.cs ***
|
||||
public partial class Channel
|
||||
{
|
||||
//*** see Test.Module.Channel.Sensor.cs ***
|
||||
public partial class Sensor
|
||||
{
|
||||
/// <summary>
|
||||
/// All available Sensitivity Unit types.
|
||||
/// </summary>
|
||||
public enum SensUnits
|
||||
{
|
||||
/// <summary>
|
||||
/// No Sensitivity Units (Polynomial Sensor)
|
||||
/// </summary>
|
||||
[Description("NONE")]
|
||||
NONE = 0,
|
||||
/// <summary>
|
||||
/// Sensitivity expressed in mV with output at Capacity EU
|
||||
/// </summary>
|
||||
[Description("mV")]
|
||||
mV = 1,
|
||||
/// <summary>
|
||||
/// Excitation proportional sensitivity expressed in mV/V with output at Capacity EU
|
||||
/// </summary>
|
||||
[Description("mV/V")]
|
||||
mVperV = 2,
|
||||
/// <summary>
|
||||
/// Excitation proportional sensitivity expressed in mV/V/EU
|
||||
/// </summary>
|
||||
[Description("mV/V/EU")]
|
||||
mVperVperEU = 3,
|
||||
/// <summary>
|
||||
/// Sensitivity expressed in mV/EU
|
||||
/// </summary>
|
||||
[Description("mV/EU")]
|
||||
mVperEU = 4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// InitialOffset is the replacement for InitialEU
|
||||
/// it encompasses the old InitialOffset specified in EU with a method of specifying it in mV @EU
|
||||
/// Initial EU is a post data collection adjustment to engineering units recorded
|
||||
/// </summary>
|
||||
public class InitialOffset
|
||||
{
|
||||
/// <summary>
|
||||
/// copy constructor
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public InitialOffset(InitialOffset copy)
|
||||
{
|
||||
if (null == copy) { return; }
|
||||
_eu = copy.EU;
|
||||
_mv = copy.MV;
|
||||
_form = copy.Form;
|
||||
}
|
||||
/// <summary>
|
||||
/// default constructor
|
||||
/// </summary>
|
||||
public InitialOffset()
|
||||
{
|
||||
_form = Forms.None;
|
||||
_eu = 0D;
|
||||
_mv = 0D;
|
||||
}
|
||||
// /// <summary>
|
||||
// /// constructor for the old format Initial EU (a single double represting offset in EU)
|
||||
// /// </summary>
|
||||
// /// <param name="d"></param>
|
||||
// public InitialOffset(double d)
|
||||
// {
|
||||
// _form = Forms.EU;
|
||||
// _eu = d;
|
||||
// _mv = 0D;
|
||||
// }
|
||||
/// <summary>
|
||||
/// serializes to a db safe string
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ToDbSerializeString()
|
||||
{
|
||||
var s = new List<string>();
|
||||
s.Add(Form.ToString());
|
||||
s.Add(EU.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
s.Add(MV.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
return string.Join(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, s.ToArray());
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// deserializes from a string suitable for db storage
|
||||
// /// </summary>
|
||||
// /// <param name="input"></param>
|
||||
public void FromDbSerializeString(string input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
{
|
||||
Form = Forms.None;
|
||||
EU = 0;
|
||||
MV = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
var tokens = input.Split(new string[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
|
||||
Forms form;
|
||||
|
||||
if (Enum.TryParse(tokens[0], out form))
|
||||
{
|
||||
_form = form;
|
||||
double d;
|
||||
if (tokens.Length < 3)
|
||||
{
|
||||
throw new System.IO.InvalidDataException("Invalid InitialOffset number of parameters: " + input);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (double.TryParse(tokens[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
_eu = d;
|
||||
}
|
||||
else { throw new FormatException("Invalid InitialOffset EU format: " + tokens[1]); }
|
||||
if (double.TryParse(tokens[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
_mv = d;
|
||||
}
|
||||
else { throw new FormatException("Invalid InitialOffset MV format: " + tokens[2]); }
|
||||
}
|
||||
}
|
||||
else { throw new System.IO.InvalidDataException("Invalid InitialOffset form: " + tokens[0]); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the format Initial Offset is in
|
||||
/// </summary>
|
||||
public enum Forms
|
||||
{
|
||||
None = 0,
|
||||
EU = 1,
|
||||
EUAtMV = 2
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// the format this intial offset instance is in
|
||||
// /// </summary>
|
||||
private Forms _form;
|
||||
public Forms Form
|
||||
{
|
||||
get => _form;
|
||||
set => _form = value;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// EU value. In the case of Form == EU, this is the offset in EU
|
||||
/// In. the form of EU@mV, this is the EU@mV value, and offset in EU still needs to be calculated
|
||||
/// GetInitialEUValue calculates the offset in eu
|
||||
/// this value is not used for InitialOffset format None
|
||||
/// </summary>
|
||||
private double _eu = 0;
|
||||
public double EU
|
||||
{
|
||||
get => _eu;
|
||||
set => _eu = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// mV value, only applies for the format EU@mV
|
||||
/// this is the value in mV that The value in EU is observed at by a calibrated instrument
|
||||
/// </summary>
|
||||
private double _mv = 0;
|
||||
public double MV
|
||||
{
|
||||
get => _mv;
|
||||
set => _mv = value;
|
||||
}
|
||||
|
||||
// private enum Fields
|
||||
// {
|
||||
// Form,
|
||||
// EU,
|
||||
// MV
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Displays initial offset structure to string
|
||||
// /// created for FB5429
|
||||
// /// </summary>
|
||||
// /// <param name="NONEFormatString">string resource similar to "None"</param>
|
||||
// /// <param name="EUFormatString">string resource similar to "EU"</param>
|
||||
// /// <param name="mVFormatString">string resource similar to "mV"</param>
|
||||
// /// <returns></returns>
|
||||
// public string ToDisplayString(string NONEFormatString, string EUFormatString, string mVFormatString)
|
||||
// {
|
||||
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// switch (Form)
|
||||
// {
|
||||
// case Forms.EU:
|
||||
// sb.AppendFormat("{0} {1}", EU, EUFormatString);
|
||||
// break;
|
||||
// case Forms.EUAtMV:
|
||||
// sb.AppendFormat("{0} {1} @ {2} {3}", EU, EUFormatString, MV, mVFormatString);
|
||||
// break;
|
||||
// case Forms.None:
|
||||
// sb.AppendFormat("{0}", NONEFormatString);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// return sb.ToString();
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Compares attributes to another InitialOffset object
|
||||
// /// created for FB5429
|
||||
// /// </summary>
|
||||
// /// <param name="obj">an InitialOffset object</param>
|
||||
// /// <returns>if contents are equal</returns>
|
||||
// public override bool Equals(object obj)
|
||||
// {
|
||||
// if (obj is InitialOffset)
|
||||
// {
|
||||
// InitialOffset io = obj as InitialOffset;
|
||||
// Fields[] fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
// foreach (var field in fields)
|
||||
// {
|
||||
// switch (field)
|
||||
// {
|
||||
// case Fields.Form: if (io.Form != Form) { return false; } break;
|
||||
// case Fields.EU: if (io.EU != EU) { return false; } break;
|
||||
// case Fields.MV: if (io.MV != MV) { return false; } break;
|
||||
// default:
|
||||
// throw new NotSupportedException("InitialOffset::Equals Unknown field " + field.ToString());
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// return base.Equals(obj);
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseExport.ISO
|
||||
{
|
||||
[Serializable()]
|
||||
public class CustomerDetails //: ISerializableFile
|
||||
{
|
||||
private enum Fields
|
||||
{
|
||||
Name,
|
||||
CustomerName,
|
||||
CustomerTestRefNumber,
|
||||
ProjectRefNumber,
|
||||
CustomerOrderNumber,
|
||||
CustomerCostUnit,
|
||||
LocalOnly,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
Version
|
||||
}
|
||||
public Dictionary<string, string> GetValues()
|
||||
{
|
||||
var elementNameValuePairs = new Dictionary<string, string>();
|
||||
|
||||
elementNameValuePairs[Fields.Name.ToString()] = Name;
|
||||
elementNameValuePairs[Fields.CustomerName.ToString()] = CustomerName;
|
||||
elementNameValuePairs[Fields.CustomerTestRefNumber.ToString()] = CustomerTestRefNumber;
|
||||
elementNameValuePairs[Fields.ProjectRefNumber.ToString()] = ProjectRefNumber;
|
||||
elementNameValuePairs[Fields.CustomerOrderNumber.ToString()] = CustomerOrderNumber;
|
||||
elementNameValuePairs[Fields.CustomerCostUnit.ToString()] = CustomerCostUnit;
|
||||
elementNameValuePairs[Fields.LocalOnly.ToString()] = LocalOnly.ToString();
|
||||
elementNameValuePairs[Fields.LastModified.ToString()] = LastModified.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[Fields.LastModifiedBy.ToString()] = LastModifiedBy;
|
||||
elementNameValuePairs[Fields.Version.ToString()] = Version.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
return elementNameValuePairs;
|
||||
}
|
||||
private string _customerName = string.Empty;
|
||||
public string CustomerName
|
||||
{
|
||||
get => _customerName;
|
||||
set => _customerName = value;
|
||||
}
|
||||
|
||||
private string _customerTestRefNumber = string.Empty;
|
||||
public string CustomerTestRefNumber
|
||||
{
|
||||
get => _customerTestRefNumber;
|
||||
set => _customerTestRefNumber = value;
|
||||
}
|
||||
|
||||
private string _projectRefNumber = "NOVALUE";
|
||||
public string ProjectRefNumber
|
||||
{
|
||||
get => _projectRefNumber;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
_projectRefNumber = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _customerOrderNumber = "NOVALUE";
|
||||
public string CustomerOrderNumber
|
||||
{
|
||||
get => _customerOrderNumber;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
_customerOrderNumber = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _customerCostUnit = "NOVALUE";
|
||||
public string CustomerCostUnit
|
||||
{
|
||||
get => _customerCostUnit;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
_customerCostUnit = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool _localOnly = false;
|
||||
public bool LocalOnly
|
||||
{
|
||||
get => _localOnly;
|
||||
set => _localOnly = value;
|
||||
}
|
||||
|
||||
private string _name = "";
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => _name = value;
|
||||
}
|
||||
|
||||
private DateTime _lastModified;
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => _lastModified = value;
|
||||
}
|
||||
|
||||
private string _lastModifiedBy;
|
||||
public string LastModifiedBy
|
||||
{
|
||||
get => _lastModifiedBy;
|
||||
set => _lastModifiedBy = value;
|
||||
}
|
||||
private int _version = 1;
|
||||
public int Version
|
||||
{
|
||||
get => _version;
|
||||
set => _version = value;
|
||||
}
|
||||
|
||||
public CustomerDetails()
|
||||
{
|
||||
}
|
||||
public CustomerDetails(DataRow dr)
|
||||
{
|
||||
_name = (string)dr["Name"];
|
||||
CustomerName = (string)dr["CustomerName"];
|
||||
CustomerTestRefNumber = (string)dr["CustomerTestRefNumber"];
|
||||
ProjectRefNumber = (string)dr["ProjectRefNumber"];
|
||||
CustomerOrderNumber = (string)dr["CustomerOrderNumber"];
|
||||
CustomerCostUnit = (string)dr["CustomerCostUnit"];
|
||||
_localOnly = Convert.ToBoolean(dr["LocalOnly"]);
|
||||
_lastModified = Convert.ToDateTime(dr["LastModified"]);
|
||||
_lastModifiedBy = (string)dr["LastModifiedBy"];
|
||||
_version = Convert.ToInt32(dr["Version"]);
|
||||
}
|
||||
public CustomerDetails(CustomerDetails copy)
|
||||
{
|
||||
_name = copy.Name;
|
||||
CustomerName = copy.CustomerName;
|
||||
CustomerTestRefNumber = copy.CustomerTestRefNumber;
|
||||
ProjectRefNumber = copy.ProjectRefNumber;
|
||||
CustomerOrderNumber = copy.CustomerOrderNumber;
|
||||
CustomerCostUnit = copy.CustomerCostUnit;
|
||||
_localOnly = copy.LocalOnly;
|
||||
_lastModified = copy.LastModified;
|
||||
_lastModifiedBy = copy.LastModifiedBy;
|
||||
_version = copy.Version;
|
||||
}
|
||||
public static CustomerDetails[] GetAllCustomerDetails()
|
||||
{
|
||||
var list = new List<CustomerDetails>();
|
||||
try
|
||||
{
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
/* always optimize sql statement! */
|
||||
sql.CommandText = @"SELECT Name" +
|
||||
",CustomerName" +
|
||||
",CustomerTestRefNumber" +
|
||||
",ProjectRefNumber" +
|
||||
",CustomerOrderNumber" +
|
||||
",CustomerCostUnit" +
|
||||
",LocalOnly" +
|
||||
",LastModified" +
|
||||
",LastModifiedBy" +
|
||||
",Version " +
|
||||
"from [tblCustomerDetails]";
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
list.Add(new CustomerDetails(dr));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("failed to get customer details", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to retrieve customer details", ex);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class CustomerDetails
|
||||
{
|
||||
private readonly ISO.CustomerDetails _customerDetails;
|
||||
public string Name
|
||||
{
|
||||
get => _customerDetails.Name;
|
||||
set => _customerDetails.Name = value;
|
||||
}
|
||||
public CustomerDetails()
|
||||
{
|
||||
_customerDetails = new ISO.CustomerDetails();
|
||||
_customerDetails.Name = "(none)";
|
||||
}
|
||||
public CustomerDetails(ISO.CustomerDetails customerDetails)
|
||||
{
|
||||
_customerDetails = new ISO.CustomerDetails(customerDetails);
|
||||
}
|
||||
public ISO.CustomerDetails GetISOCustomer()
|
||||
{
|
||||
return _customerDetails;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class CustomerDetailsList
|
||||
{
|
||||
private static readonly CustomerDetailsList _customerList = new CustomerDetailsList();
|
||||
public static CustomerDetailsList CustomerList => _customerList;
|
||||
|
||||
private void PopulateCustomers()
|
||||
{
|
||||
if (null != _customers) return;
|
||||
_customers = new Dictionary<string, CustomerDetails>();
|
||||
foreach (var c in _customerList.GetAllCustomers())
|
||||
{
|
||||
if (!_customers.ContainsKey(c.Name))
|
||||
{
|
||||
_customers.Add(c.Name, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static readonly object _customerLock = new object();
|
||||
private Dictionary<string, CustomerDetails> _customers = null;
|
||||
public CustomerDetails[] Customers
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_customerLock)
|
||||
{
|
||||
PopulateCustomers();
|
||||
}
|
||||
var customers = new List<CustomerDetails>(_customers.Values);
|
||||
customers.Sort(CompareCustomers);
|
||||
return customers.ToArray();
|
||||
}
|
||||
}
|
||||
private static int CompareCustomers(CustomerDetails a, CustomerDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
return null == b ? 1 : String.Compare(a.Name, b.Name, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public CustomerDetails[] GetAllCustomers()
|
||||
{
|
||||
var list = new List<CustomerDetails>();
|
||||
list.Add(new CustomerDetails()); //This is the "(none)" entry
|
||||
list.AddRange(ISO.CustomerDetails.GetAllCustomerDetails().Select(cs => new CustomerDetails(cs)));
|
||||
return list.ToArray();
|
||||
}
|
||||
public CustomerDetails GetCustomerDetail(string name)
|
||||
{
|
||||
var customers = from c in Customers.AsParallel() where c.Name == name select c;
|
||||
return customers.Any() ? customers.First() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// list that holds groups
|
||||
/// </summary>
|
||||
public class TestObjectList
|
||||
{
|
||||
private static readonly object MyLock = new object();
|
||||
|
||||
private static TestObjectList _testObjectList;
|
||||
|
||||
public static TestObjectList TestObjectsList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (null == _testObjectList)
|
||||
{
|
||||
_testObjectList = new TestObjectList();
|
||||
}
|
||||
}
|
||||
return _testObjectList;
|
||||
}
|
||||
}
|
||||
public List<string> GetAllGroupSerialNumbers()
|
||||
{
|
||||
var serialNumbers = new List<string>();
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
sql.CommandText = "SELECT A.SerialNumber from tblTestObjects as A";
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var groupSerialNumber = (string)dr["SerialNumber"];
|
||||
if (!serialNumbers.Contains(groupSerialNumber))
|
||||
{
|
||||
serialNumbers.Add(groupSerialNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return serialNumbers;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a given test object if it is in the list,
|
||||
/// returns null otherwise
|
||||
/// </summary>
|
||||
/// <param name="serialNumber">serialnumber of group to look for</param>
|
||||
/// <returns></returns>
|
||||
public TestObject GetTestObject(string serialNumber)
|
||||
{
|
||||
var db = ISO13499FileDb.IsoDb;
|
||||
var testObject = ISO.TestObject.GetTestObject(serialNumber, ref db);
|
||||
if (null == testObject) { return null; }
|
||||
return new TestObject(testObject, testObject.SysBuilt);
|
||||
}
|
||||
|
||||
public TestObject GetAddedGroup(string serialNumber)
|
||||
{
|
||||
return GetTestObject(serialNumber);
|
||||
}
|
||||
protected TestObjectList()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class DbVersion
|
||||
{
|
||||
public DbVersion(System.Data.DataRow dr)
|
||||
{
|
||||
_version = Convert.ToInt32(dr["Version"]);
|
||||
_step = Convert.ToInt32(dr["Step"]);
|
||||
_date = Convert.ToDateTime(dr["Date"]);
|
||||
_remarks = (string)dr["Remarks"];
|
||||
_userField = (string)dr["UserField"];
|
||||
}
|
||||
private int _version;
|
||||
|
||||
public int Version
|
||||
{
|
||||
get => _version;
|
||||
set => _version = value;
|
||||
}
|
||||
|
||||
private int _step;
|
||||
public int Step
|
||||
{
|
||||
get => _step;
|
||||
set => _step = value;
|
||||
}
|
||||
|
||||
private DateTime _date;
|
||||
public DateTime Date
|
||||
{
|
||||
get => _date;
|
||||
set => _date = value;
|
||||
}
|
||||
|
||||
private string _remarks;
|
||||
public string Remarks
|
||||
{
|
||||
get => _remarks;
|
||||
set => _remarks = value;
|
||||
}
|
||||
|
||||
private string _userField;
|
||||
public string UserField
|
||||
{
|
||||
get => _userField;
|
||||
set => _userField = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public abstract class TabPageCommon : IUIItems
|
||||
{
|
||||
public virtual string GetName() { return UniqueId; }
|
||||
public string UniqueId { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// handles storing/retrieving settings from a db
|
||||
/// assumes DB connection is already established or connection information has already been set for db
|
||||
/// </summary>
|
||||
public class SettingsDB
|
||||
{
|
||||
private static SettingsDB _instance = null;
|
||||
private static object _MyLock = new object();
|
||||
|
||||
private static SettingsDB Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_MyLock)
|
||||
{
|
||||
if (null == _instance)
|
||||
{
|
||||
_instance = new SettingsDB();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, Setting> _SettingsLookup = new Dictionary<string, Setting>();
|
||||
|
||||
private SettingsDB()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieves a global value, creates using default value if property doesn't exist yet
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetGlobalValue(string id, string defaultValue)
|
||||
{
|
||||
lock (_MyLock)
|
||||
{
|
||||
if (!Instance._SettingsLookup.ContainsKey(id))
|
||||
{
|
||||
Instance._SettingsLookup[id] = new GlobalSetting(id, defaultValue);
|
||||
}
|
||||
return Instance._SettingsLookup[id].PropertyValue;
|
||||
}
|
||||
}
|
||||
public static int GetGlobalValueInt(string id, int defaultValue)
|
||||
{
|
||||
string sValue = GetGlobalValue(id, defaultValue.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
int d = defaultValue;
|
||||
if (!int.TryParse(sValue, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
else { return d; }
|
||||
}
|
||||
/// <summary>
|
||||
/// returns the global value for given property, or the default value if no value currently exists
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public static bool GetGlobalValueBool(string id, bool defaultValue)
|
||||
{
|
||||
string sValue = GetGlobalValue(id, defaultValue.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
bool b = defaultValue;
|
||||
if (!Boolean.TryParse(sValue, out b))
|
||||
{
|
||||
return b;
|
||||
}
|
||||
else { return b; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stores an application global property in the database
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="value"></param>
|
||||
public static void SetGlobalValue(string id, string value)
|
||||
{
|
||||
lock (_MyLock)
|
||||
{
|
||||
if (!Instance._SettingsLookup.ContainsKey(id))
|
||||
{
|
||||
Instance._SettingsLookup[id] = new GlobalSetting(id, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Instance._SettingsLookup[id].SetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void SetGlobalValueInt(string id, int value)
|
||||
{
|
||||
lock (_MyLock)
|
||||
{
|
||||
if (!Instance._SettingsLookup.ContainsKey(id))
|
||||
{
|
||||
Instance._SettingsLookup[id] = new GlobalSetting(id, value.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
else
|
||||
{
|
||||
Instance._SettingsLookup[id].SetValue(value.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// stores an application global property value in the database
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="value"></param>
|
||||
public static void SetGlobalValueBoolean(string id, bool value)
|
||||
{
|
||||
lock (_MyLock)
|
||||
{
|
||||
if (!Instance._SettingsLookup.ContainsKey(id))
|
||||
{
|
||||
Instance._SettingsLookup[id] = new GlobalSetting(id, value.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
else
|
||||
{
|
||||
Instance._SettingsLookup[id].SetValue(value.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a "possible" channel, once we know what iso object we are dealing with there can be a number of channels
|
||||
/// defined for the object. We might not care about all of them ...
|
||||
/// this is also a template channel, in that some fields will not be known yet (direction, dimension maybe, position, etc)
|
||||
/// TestObjectChannel will consume this channel and then allow setting the locations as needed
|
||||
/// </summary>
|
||||
public class MMEPossibleChannels : AbstractOLEDbWrapper
|
||||
{
|
||||
public long Id { get; private set; }
|
||||
|
||||
public void ClearId() { Id = -1; }
|
||||
public void SetId(long id) { Id = id; }
|
||||
|
||||
public string Type { get; private set; }
|
||||
|
||||
public void SetType(string type) { Type = type; }
|
||||
|
||||
public string Test_Object { get; private set; }
|
||||
|
||||
public void Set_Test_Object(string val)
|
||||
{
|
||||
Test_Object = val;
|
||||
}
|
||||
|
||||
public string Position { get; private set; }
|
||||
|
||||
public void Set_Position(string val)
|
||||
{
|
||||
Position = val;
|
||||
}
|
||||
|
||||
public string Trans_Main_Loc { get; private set; }
|
||||
|
||||
public void Set_Main_Loc(string val)
|
||||
{
|
||||
Trans_Main_Loc = val;
|
||||
}
|
||||
|
||||
public string Fine_Loc_1 { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the fine location 1
|
||||
/// the property doesn't seem to have a set
|
||||
/// so not sure if it was omitted or on purpose
|
||||
/// See all othe "Set_*" functions
|
||||
/// </summary>
|
||||
/// <param name="val"></param>
|
||||
public void Set_Fine_Loc_1(string val)
|
||||
{
|
||||
Fine_Loc_1 = val;
|
||||
}
|
||||
|
||||
|
||||
public string Fine_Loc_2 { get; private set; }
|
||||
|
||||
public void Set_Fine_Loc_2(string val)
|
||||
{
|
||||
Fine_Loc_2 = val;
|
||||
}
|
||||
|
||||
public string Fine_Loc_3 { get; private set; }
|
||||
|
||||
public void Set_Fine_Loc_3(string val)
|
||||
{
|
||||
Fine_Loc_3 = val;
|
||||
}
|
||||
|
||||
public string Physical_Dimension { get; private set; }
|
||||
|
||||
public void Set_Physical_Dimension(string val)
|
||||
{
|
||||
Physical_Dimension = val;
|
||||
}
|
||||
|
||||
public string Direction { get; private set; }
|
||||
|
||||
public void Set_Direction(string val)
|
||||
{
|
||||
Direction = val;
|
||||
}
|
||||
|
||||
public string Default_Filter_Class { get; private set; }
|
||||
|
||||
public void Set_Default_Filter_Class(string val)
|
||||
{
|
||||
Default_Filter_Class = val;
|
||||
}
|
||||
|
||||
public string Text_L1 { get; private set; }
|
||||
|
||||
public void SetText1(string text1) { Text_L1 = text1; }
|
||||
|
||||
public string Text_L2 { get; private set; }
|
||||
|
||||
public void SetText2(string text2) { Text_L2 = text2; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; private set; }
|
||||
|
||||
public void SetRemarks(string remarks) { Remarks = remarks; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public string Picture_ShortName { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public int MMEChannelType { get; }
|
||||
|
||||
public MMEPossibleChannels(MMEPossibleChannels copy)
|
||||
{
|
||||
Id = copy.Id;
|
||||
Type = copy.Type;
|
||||
Test_Object = copy.Test_Object;
|
||||
Position = copy.Position;
|
||||
Trans_Main_Loc = copy.Trans_Main_Loc;
|
||||
Fine_Loc_1 = copy.Fine_Loc_1;
|
||||
Fine_Loc_2 = copy.Fine_Loc_2;
|
||||
Fine_Loc_3 = copy.Fine_Loc_3;
|
||||
Physical_Dimension = copy.Physical_Dimension;
|
||||
Direction = copy.Direction;
|
||||
Default_Filter_Class = copy.Default_Filter_Class;
|
||||
Text_L1 = copy.Text_L1;
|
||||
Text_L2 = copy.Text_L2;
|
||||
Version = copy.Version;
|
||||
Date = copy.Date;
|
||||
Remarks = copy.Remarks;
|
||||
Expired = copy.Expired;
|
||||
SortKey = copy.SortKey;
|
||||
Picture_ShortName = copy.Picture_ShortName;
|
||||
Last_Change = copy.Last_Change;
|
||||
Last_Change_Text = copy.Last_Change_Text;
|
||||
History = copy.History;
|
||||
MMEChannelType = copy.MMEChannelType;
|
||||
}
|
||||
public MMEPossibleChannels(long id, string type, string textObject, string position, string transMainLoc,
|
||||
string fineLoc1, string fineLoc2, string fineLoc3, string physicalDimension, string direction, string defaultFilterClass,
|
||||
string textL1, string textL2, long version, DateTime date, string remarks, bool expired, string sortkey,
|
||||
string pictureShortName, DateTime lastChange, string lastChangeText, string history, int mmeChannelType)
|
||||
{
|
||||
Id = id;
|
||||
Type = type;
|
||||
Test_Object = textObject;
|
||||
Position = position;
|
||||
Trans_Main_Loc = transMainLoc;
|
||||
Fine_Loc_1 = fineLoc1;
|
||||
Fine_Loc_2 = fineLoc2;
|
||||
Fine_Loc_3 = fineLoc3;
|
||||
Physical_Dimension = physicalDimension;
|
||||
Direction = direction;
|
||||
Default_Filter_Class = defaultFilterClass;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortkey;
|
||||
Picture_ShortName = pictureShortName;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
MMEChannelType = mmeChannelType;
|
||||
}
|
||||
public enum MMEChannelTypes
|
||||
{
|
||||
ISO13499_106,
|
||||
SQL
|
||||
}
|
||||
public static MMEPossibleChannels[] GetPossibleChannels()
|
||||
{
|
||||
var possibleChannels = new List<MMEPossibleChannels>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMEPossibleChannels";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
long id = GetLong(ISOReader, "ID");
|
||||
string type = ISOReader["TYPE"].ToString();
|
||||
string testObject = ISOReader["TEST_OBJECT"].ToString();
|
||||
string position = ISOReader["POSITION"].ToString();
|
||||
string transMainLoc = ISOReader["TRANS_MAIN_LOC"].ToString();
|
||||
string fineLoc1 = ISOReader["FINE_LOC_1"].ToString();
|
||||
string fineLoc2 = ISOReader["FINE_LOC_2"].ToString();
|
||||
string fineLoc3 = ISOReader["FINE_LOC_3"].ToString();
|
||||
string physicalDimension = ISOReader["PHYSICAL_DIMENSION"].ToString();
|
||||
string direction = ISOReader["DIRECTION"].ToString();
|
||||
string defaultFilterClass = ISOReader["DEFAULT_FILTER_CLASS"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = GetLong(ISOReader, "VERSION");
|
||||
DateTime date = GetDate(ISOReader, "DATE");
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
string pictureShortName = ISOReader["PICTURE_SHORTNAME"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
|
||||
possibleChannels.Add(new MMEPossibleChannels(id, type, testObject, position,
|
||||
transMainLoc, fineLoc1, fineLoc2,
|
||||
fineLoc3, physicalDimension, direction, defaultFilterClass, textL1, textL2,
|
||||
version, date, remarks, expired, sortkey, pictureShortName, lastChange,
|
||||
lastChangeText, history, (int)MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = "SELECT * from [tblMMEPossibleChannels]";
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var id = Convert.ToInt64(dr["ID"]);
|
||||
var type = Convert.ToString(dr["TYPE"]);
|
||||
var testobject = Convert.ToString(dr["TEST_OBJECT"]);
|
||||
var position = Convert.ToString(dr["POSITION"]);
|
||||
var mainloc = Convert.ToString(dr["TRANS_MAIN_LOC"]);
|
||||
var fineloc1 = Convert.ToString(dr["FINE_LOC_1"]);
|
||||
var fineloc2 = Convert.ToString(dr["FINE_LOC_2"]);
|
||||
var fineloc3 = Convert.ToString(dr["FINE_LOC_3"]);
|
||||
var dimension = Convert.ToString(dr["PHYSICAL_DIMENSION"]);
|
||||
var direction = Convert.ToString(dr["DIRECTION"]);
|
||||
var filter = Convert.ToString(dr["DEFAULT_FILTER_CLASS"]);
|
||||
var textL1 = Convert.ToString(dr["TEXT_L1"]);
|
||||
var textL2 = Convert.ToString(dr["TEXT_L2"]);
|
||||
var version = Convert.ToInt32(dr["VERSION"]);
|
||||
var date = Convert.ToDateTime(dr["DATE"]);
|
||||
var remarks = Convert.ToString(dr["REMARKS"]);
|
||||
var expired = Convert.ToBoolean(dr["EXPIRED"]);
|
||||
var sortkey = Convert.ToString(dr["SORTKEY"]);
|
||||
var pictureShortName = Convert.ToString(dr["PICTURE_SHORTNAME"]);
|
||||
var lastChange = Convert.ToDateTime(dr["LAST_CHANGE"]);
|
||||
var lastChangeText = Convert.ToString(dr["LAST_CHANGE_TEXT"]);
|
||||
var history = Convert.ToString(dr["HISTORY"]);
|
||||
possibleChannels.Add(new MMEPossibleChannels(id, type, testobject, position, mainloc, fineloc1, fineloc2,
|
||||
fineloc3, dimension, direction, filter, textL1, textL2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortkey, pictureShortName, lastChange, lastChangeText, history, (int)MMEChannelTypes.SQL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
return possibleChannels.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TestObjectChannel : TestObjectTemplateChannel, /*INotifyPropertyChanged,*/ IComparable<TestObjectChannel>
|
||||
{
|
||||
private const string CURRENT_SUFFIX = "_CU";
|
||||
public const int CHANNEL_IDX_UNKNOWN = -1;
|
||||
public enum SquibChannelTypes
|
||||
{
|
||||
None, //Non-squib channels
|
||||
Voltage,
|
||||
Current
|
||||
}
|
||||
// #endregion
|
||||
public string GetGraphID()
|
||||
{
|
||||
return SquibChannelType == SquibChannelTypes.Current ? GetId() + CURRENT_SUFFIX : GetId();
|
||||
}
|
||||
public string GetId()
|
||||
{
|
||||
return GetIdWithSpecificChannelId(Channel.Id);
|
||||
}
|
||||
public string GetIdWithSpecificChannelId(long id)
|
||||
{
|
||||
return $"{TestObject.SerialNumber}_{Channel.MMEChannelType}_{id}";
|
||||
}
|
||||
public SquibChannelTypes SquibChannelType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
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 = Name.CompareTo(right.Name);
|
||||
if (0 != comp) { return comp; }
|
||||
|
||||
if (null != TestObject && null != right.TestObject)
|
||||
{
|
||||
comp = TestObject.SerialNumberOrOriginalSerialNumber.CompareTo(right.TestObject.SerialNumberOrOriginalSerialNumber);
|
||||
if (0 != comp) { return comp; }
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public string SensorSerialNumber
|
||||
{
|
||||
get => GetProperty("SensorSerialNumber", "") as string;
|
||||
set => SetProperty("SensorSerialNumber", value);
|
||||
}
|
||||
private const char ChannelSeparator = 'x';
|
||||
public string HardwareId
|
||||
{
|
||||
get => GetProperty("HardwareId", "") as string;
|
||||
set
|
||||
{
|
||||
if (null != value)
|
||||
{
|
||||
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(ChannelSeparator);
|
||||
if (index >= 0) { sb.Append(tokens[2].Substring(index)); }
|
||||
value = sb.ToString();
|
||||
}
|
||||
}
|
||||
SetProperty("HardwareId", value);
|
||||
}
|
||||
}
|
||||
|
||||
private ISO.TestObject _testObject = null;
|
||||
public ISO.TestObject TestObject => _testObject;
|
||||
|
||||
public TestObjectChannel(TestObjectTemplateChannel copy, ISO.TestObject testObject, ISO.TestObjectTemplate template)
|
||||
: base(copy, template)
|
||||
{
|
||||
_testObject = testObject;
|
||||
}
|
||||
|
||||
public string GetID()
|
||||
{
|
||||
return GetIDWithSpecificChannelId(Channel.Id);
|
||||
}
|
||||
public string GetIDWithSpecificChannelId(long id)
|
||||
{
|
||||
return string.Format("{0}_{1}_{2}", _testObject.SerialNumber, Channel.MMEChannelType, id);
|
||||
}
|
||||
private int _channelIDX = CHANNEL_IDX_UNKNOWN;
|
||||
public int ChannelIDX
|
||||
{
|
||||
get => _channelIDX;
|
||||
set => _channelIDX = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,509 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TestTemplateList //: BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// this property is to hold a template in memory temporarily
|
||||
/// without committing it to the db, but to still act as if it is in the db
|
||||
/// </summary>
|
||||
public TestTemplate TemporaryTemplate { get; set; }
|
||||
protected TestTemplateList() { }
|
||||
public TestTemplate GetTemplate(string name)
|
||||
{
|
||||
if (name == "Quick checkout") // StringResources.QuickSensorCheck_DefaultTestName)
|
||||
{
|
||||
return TemporaryTemplate;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(name)) { return null; }
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * FROM [{0}] WHERE [{1}]=@1",
|
||||
DbOperations.TestSetups.TestSetupsTable, DbOperations.TestSetups.Fields.SetupName);
|
||||
DbOperations.CreateParam(cmd, "@1", SqlDbType.NVarChar, name);
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) return null;
|
||||
var dr = ds.Tables[0].Rows[0];
|
||||
|
||||
var tt = new TestTemplate();
|
||||
tt.SetTimeStampMemory(dr);
|
||||
//make sure this template is marked as unloaded, because we
|
||||
//are only going to load the essentials here...
|
||||
tt._bIsLoaded = false;
|
||||
|
||||
var fields =
|
||||
Enum.GetValues(typeof(DbOperations.TestSetups.Fields))
|
||||
.Cast<DbOperations.TestSetups.Fields>()
|
||||
.ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var o = dr[field.ToString()];
|
||||
|
||||
#region DbOperations.TestSetups.Fields
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.TestSetups.Fields.AllowMissingSensors:
|
||||
tt.AllowMissingSensors = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.AllowSensorIdToBlankChannel:
|
||||
tt.AllowSensorIdToBlankChannel = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.AutomaticProgressionDelayMS:
|
||||
tt.AutomaticProgressionDelayMS = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.AutomaticTestProgression:
|
||||
tt.AutomaticProgression = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.AutoVerifyChannels:
|
||||
tt.AutoVerifyChannels = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.CommonStatusLine:
|
||||
tt.CommonLine = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.UploadData:
|
||||
tt.UploadData = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.UploadDataFolder:
|
||||
tt.UploadFolder = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.CustomerDetails:
|
||||
tt.CustomerDetails =
|
||||
CustomerDetailsList.CustomerList.GetCustomerDetail(Convert.ToString(o));
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.TestEngineerDetails:
|
||||
tt.TestEngineerDetails =
|
||||
TestEngineerDetailsList.TestEngineerList.GetTestEngineerDetail(
|
||||
Convert.ToString(o));
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.DownloadAll:
|
||||
tt.DownloadAll = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.DownloadFolder:
|
||||
tt.DownloadFolder = Properties.Settings.Default.DownloadFolder;
|
||||
// Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.Export:
|
||||
tt.ViewExport = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.ExportFolder:
|
||||
tt.ExportFolder = Properties.Settings.Default.DownloadFolder;
|
||||
//Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.ExportFormat:
|
||||
tt.ExportFormats = (SupportedExportFormatBitFlags)Convert.ToUInt64(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.InvertStart:
|
||||
tt.InvertStartRecordCompletion = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.TriggerCheckRealtime:
|
||||
tt.TriggerCheckRealtime = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.TriggerCheckStep:
|
||||
tt.TriggerCheckStep = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.PostTestDiagnostics:
|
||||
tt.PostTestDiagnosticsLevel = (0 != Convert.ToInt32(o));
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.InvertTrigger:
|
||||
tt.InvertTriggerCompletion = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.LabDetails:
|
||||
tt.LabDetails = LabratoryDetailsList.LabratoryList.GetLab(Convert.ToString(o));
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.LastModified:
|
||||
tt.LastModified = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.LastModifiedBy:
|
||||
tt.LastModifiedBy = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.LocalOnly:
|
||||
tt.LocalOnly = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.PostTriggerSeconds:
|
||||
tt.PostTriggerSeconds = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.PreTriggerSeconds:
|
||||
tt.PreTriggerSeconds = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.RealtimePlotCount:
|
||||
tt.DefaultNumberRealtimeGraphs = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.RecordingMode:
|
||||
tt.RecordingMode = (RecordingModes)Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.RequireConfirmationOnErrors:
|
||||
tt.RequireUserConfirmationOnErrors = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.ROIDownload:
|
||||
tt.DoROIDownload = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.ROIEnd:
|
||||
tt.ROIEnd = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.ROIStart:
|
||||
tt.ROIStart = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.SameAsDownloadFolder:
|
||||
tt.SameAsDownloadFolder = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.SamplesPerSecond:
|
||||
tt.SamplesPerSecond = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.Settings:
|
||||
tt.LoadSettings(Convert.ToString(o));
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.WarnOnBatteryFail:
|
||||
tt.WarnOnFailedBattery = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.SetupDescription:
|
||||
tt.Description = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.SetupName:
|
||||
tt.Name = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.StrictDiagnostics:
|
||||
tt.StrictDiagnostics = (Convert.ToInt32(o)) != 0;
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.UseCustomerDetails:
|
||||
tt.UseCustomerDetails = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.UseTestEngineerDetails:
|
||||
tt.UseTestEngineerDetails = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.TurnOffExcitation:
|
||||
tt.TurnOffExcitation = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.UseLabDetails:
|
||||
tt.UseLabratoryDetails = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.VerifyChannels:
|
||||
tt.VerifyChannels = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.VerifyChannelsDelayMS:
|
||||
tt.AutoVerifyDelaySeconds = Convert.ToDouble(o) / 1000D;
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.ViewDiagnostics:
|
||||
tt.ViewDiagnostics = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.ViewDownloadAll:
|
||||
tt.ViewDownloadAll = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.ViewRealtime:
|
||||
tt.ViewRealtime = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.ViewROIDownload:
|
||||
tt.ViewROIDownload = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.Dirty:
|
||||
tt.SetIsDirty(Convert.ToBoolean(o));
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.Complete:
|
||||
tt.SetIsComplete(Convert.ToBoolean(o));
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.ISFFile:
|
||||
tt.ISFFile = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.ErrorMessage:
|
||||
tt.SetCompletionErrorMessage(Convert.ToString(o));
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.CheckoutMode:
|
||||
tt.CheckoutMode = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.QuitTestWithoutWarning:
|
||||
tt.QuitTestWithoutWarning = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.SuppressMissingSensorsWarning:
|
||||
tt.SuppressMissingSensorsWarning = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.NotAllChannelsRealTime:
|
||||
tt.NotAllChannelsRealTime = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.NotAllChannelsViewer:
|
||||
tt.NotAllChannelsViewer = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.UserTags:
|
||||
tt.TagsBlobBytes = (byte[])o;
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.DoAutoArm:
|
||||
tt.DoAutoArm = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.TestSetups.Fields.DoStreaming:
|
||||
tt.DoStreaming = Convert.ToBoolean(o);
|
||||
break;
|
||||
}
|
||||
|
||||
#endregion DbOperations.TestSetups.Fields
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process: ", field.ToString(), ex);
|
||||
}
|
||||
}
|
||||
return tt;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static SensorData GetSensorFromSettings(string settings, string serial, Dictionary<string, SensorData> lookup)
|
||||
{
|
||||
SensorData sd = null;
|
||||
if (null != lookup && lookup.ContainsKey(serial)) { sd = lookup[serial]; }
|
||||
if (null == sd) { sd = SensorsCollection.SensorsList.GetSensorBySerialNumber(serial); }
|
||||
|
||||
if (string.IsNullOrWhiteSpace(serial))
|
||||
{
|
||||
sd = new SensorData { SerialNumber = "" };
|
||||
}
|
||||
if (null == sd) { return null; }
|
||||
sd = new SensorData(sd);
|
||||
var tokens = settings.Split(',');
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
var subtokens = token.Split('=');
|
||||
var setting = (ISO.TestObject.SensorSettings)int.Parse(subtokens[0]);
|
||||
switch (setting)
|
||||
{
|
||||
case ISO.TestObject.SensorSettings.CFC:
|
||||
sd.FilterClassIso = subtokens[1];
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Position:
|
||||
sd.Position = subtokens[1];
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Polarity:
|
||||
sd.Invert = subtokens[1] == "-";
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Range:
|
||||
sd.Capacity = double.Parse(subtokens[1], CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Delay:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.DelayMS = double.Parse(subtokens[1], CultureInfo.InvariantCulture); sd.DigitalOutputDelayMS = sd.DelayMS; }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Duration:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.DurationMS = double.Parse(subtokens[1], CultureInfo.InvariantCulture); sd.DigitalOutputDurationMS = sd.DurationMS; }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.OutputMode:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.DigitalOutputMode = (OutputTOMDigitalChannel.DigitalOutputMode)Convert.ToInt32(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.SQMode:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.SquibFireMode = (OutputSquibChannel.SquibFireMode)Convert.ToInt32(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DIMode:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.InputMode = (DigitalInputScaleMultiplier.InputModes)Convert.ToInt32(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.LimitDuration:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.LimitDuration = bool.Parse(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.ActiveValue:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.ScaleMultiplier.ActiveValue = Convert.ToDouble(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DefaultValue:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.ScaleMultiplier.DefaultValue = Convert.ToDouble(subtokens[1]); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sd;
|
||||
}
|
||||
public static SensorData GetSensorFromSettings(string settings, string serial)
|
||||
{
|
||||
return GetSensorFromSettings(settings, serial, null);
|
||||
}
|
||||
public static string GetSensorSettings(SensorData sd)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var settings = Enum.GetValues(typeof(ISO.TestObject.SensorSettings)).Cast<ISO.TestObject.SensorSettings>().ToArray();
|
||||
var bNeedComma = false;
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
if (bNeedComma) { sb.Append(","); }
|
||||
bNeedComma = true;
|
||||
sb.AppendFormat("{0}=", (int)setting);
|
||||
switch (setting)
|
||||
{
|
||||
case ISO.TestObject.SensorSettings.CFC:
|
||||
sb.Append(sd.FilterClassIso);
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Position:
|
||||
sb.Append(sd.Position);
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Polarity:
|
||||
sb.Append(sd.Invert ? "-" : "+");
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Range:
|
||||
sb.Append(sd.Capacity.ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.SQMode:
|
||||
sb.Append(((int)sd.SquibFireMode).ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.LimitDuration:
|
||||
sb.Append(sd.LimitDuration.ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Duration:
|
||||
sb.Append(sd.DurationMS.ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.OutputMode:
|
||||
sb.Append(((int)sd.DigitalOutputMode).ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Delay:
|
||||
sb.Append(sd.DelayMS.ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DIMode:
|
||||
sb.Append(((int)sd.InputMode).ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DefaultValue:
|
||||
sb.Append(sd.ScaleMultiplier.DefaultValue.ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.ActiveValue:
|
||||
sb.Append(
|
||||
sd.ScaleMultiplier.ActiveValue.ToString(CultureInfo.InvariantCulture));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static TestTemplateList _list;
|
||||
private static readonly object ObjectLock = new object();
|
||||
public static TestTemplateList TestTemplatesList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (ObjectLock)
|
||||
{
|
||||
if (null == _list) { _list = new TestTemplateList(); }
|
||||
}
|
||||
return _list;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SysBuiltObject(string serialNumber)
|
||||
{
|
||||
var temp = false;
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * FROM [tblTestObjects] where [SerialNumber]=@{0}", "SerialNumber");
|
||||
DbOperations.CreateParam(cmd, string.Format("@{0}", "SerialNumber"), SqlDbType.NVarChar, serialNumber);
|
||||
|
||||
using (var ds2 = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds2.Tables.Count <= 0 || ds2.Tables[0].Rows.Count <= 0) return false;
|
||||
foreach (DataRow row in ds2.Tables[0].Rows)
|
||||
{
|
||||
//really only 1 row
|
||||
temp = Convert.ToBoolean(row["SysBuilt"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
public static void ConvertToDictionary(DataTable dt, ref Dictionary<string, List<Dictionary<string, object>>> lookup, string key)
|
||||
{
|
||||
var count = dt.Columns.Count;
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
var thiskey = Convert.ToString(dr[key]);
|
||||
if (!lookup.ContainsKey(thiskey)) { lookup.Add(thiskey, new List<Dictionary<string, object>>()); }
|
||||
var properties = new Dictionary<string, object>(count);
|
||||
foreach (DataColumn c in dt.Columns)
|
||||
{
|
||||
properties[c.ColumnName] = dr[c.ColumnName];
|
||||
}
|
||||
lookup[thiskey].Add(properties);
|
||||
}
|
||||
}
|
||||
public TestTemplateTableObject[] GetAllTemplates()
|
||||
{
|
||||
var objects = new List<TestTemplateTableObject>();
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
cmd.CommandText =
|
||||
"SELECT SetupName, SetupDescription, RecordingMode, Dirty, Complete, LastModified, LastModifiedBy, ErrorMessage, CustomerDetails, UseCustomerDetails, UserTags FROM tblTestSetups";
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
var setupName = (string)dr["SetupName"];
|
||||
var setupDescription = (string)dr["SetupDescription"];
|
||||
var recordingMode = Convert.ToInt32(dr["RecordingMode"]);
|
||||
var dirty = Convert.ToBoolean(dr["Dirty"]);
|
||||
var complete = Convert.ToBoolean(dr["Complete"]);
|
||||
var lastModified = Convert.ToDateTime(dr["LastModified"]);
|
||||
var lastModifiedBy = (string)dr["LastModifiedBy"];
|
||||
var errorMessage = Convert.ToString(dr["ErrorMessage"]);
|
||||
var customerDetails = (string)dr["CustomerDetails"];
|
||||
var useCustomerDetails = Convert.ToBoolean(dr["UseCustomerDetails"]);
|
||||
var tagBlobObj = dr["UserTags"];
|
||||
byte[] tagBlob = null;
|
||||
int[] tagIds = null;
|
||||
if (DBNull.Value.Equals(tagBlobObj))
|
||||
{
|
||||
tagBlob = new byte[0];
|
||||
tagIds = new int[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
tagBlob = (byte[])dr["UserTags"];
|
||||
tagIds = GetTagIds(tagBlob);
|
||||
}
|
||||
|
||||
if (dirty)
|
||||
{
|
||||
var tt = TestTemplatesList.GetTemplate(setupName);
|
||||
complete = tt.IsComplete;
|
||||
}
|
||||
|
||||
objects.Add(new TestTemplateTableObject(setupName, setupDescription,
|
||||
(RecordingModes)recordingMode, lastModified, lastModifiedBy, complete,
|
||||
errorMessage, useCustomerDetails, customerDetails, tagIds));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return objects.ToArray();
|
||||
}
|
||||
|
||||
private int[] GetTagIds(byte[] bytes)
|
||||
{
|
||||
var tagsBlob = new int[bytes.Length / sizeof(int)];
|
||||
try
|
||||
{
|
||||
Buffer.BlockCopy(bytes, 0, tagsBlob, 0, bytes.Length);
|
||||
return tagsBlob;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
return new int[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* DTS.Slice.Control.Event.Module.Channel.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
// *** see DTS.Slice.Control.Event.cs ***
|
||||
public partial class Event
|
||||
{
|
||||
// *** see DTS.Slice.Control.Event.Module.cs ***
|
||||
public partial class Module
|
||||
{
|
||||
/// <summary>
|
||||
/// Representation of the DTS.Slice.Control.Event.Module.Channel class.
|
||||
/// </summary>
|
||||
public abstract partial class Channel
|
||||
: Exceptional,
|
||||
IFilterable, IDisposable
|
||||
{
|
||||
public void Dispose() { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class ISOHardwareChannel //: INotifyPropertyChanged
|
||||
{
|
||||
public Hardware ParentDAS { get; set; }
|
||||
|
||||
public int SupportedBridges { get; set; } = 12;
|
||||
|
||||
public int SupportedSquibFireModes { get; set; } = 16;
|
||||
|
||||
public int SupportedExcitations { get; set; } = 16;
|
||||
|
||||
public int SupportedDigitalInputModes { get; set; } = 16;
|
||||
|
||||
public int SupportedDigitalOutputModes { get; set; } = 16;
|
||||
|
||||
public int ChannelIdx { get; set; }
|
||||
|
||||
public int DASDisplayOrder { get; set; }
|
||||
|
||||
public string ModuleSerialNumber { get; set; } = "";
|
||||
|
||||
public int ModuleArrayIndex { get; set; } = 0;
|
||||
|
||||
public ISOHardwareChannel(ISOHardwareChannel copy, Hardware h)
|
||||
{
|
||||
SupportedSquibFireModes = copy.SupportedSquibFireModes;
|
||||
SupportedExcitations = copy.SupportedExcitations;
|
||||
SupportedDigitalOutputModes = copy.SupportedDigitalOutputModes;
|
||||
SupportedDigitalInputModes = copy.SupportedDigitalInputModes;
|
||||
SupportedBridges = copy.SupportedBridges;
|
||||
ParentDAS = h;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
DASDisplayOrder = copy.DASDisplayOrder;
|
||||
ChannelIdx = copy.ChannelIdx;
|
||||
ModuleArrayIndex = copy.ModuleArrayIndex;
|
||||
ModuleSerialNumber = copy.ModuleSerialNumber;
|
||||
}
|
||||
|
||||
public ISOHardwareChannel(DataRow dr, Hardware hardware)
|
||||
{
|
||||
ParentDAS = hardware;
|
||||
|
||||
var fields = Enum.GetValues(typeof(DbOperations.DAS.DASChannelFields)).Cast<DbOperations.DAS.DASChannelFields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var o = dr[field.ToString()];
|
||||
if (DBNull.Value.Equals(o)) { continue; }
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.DAS.DASChannelFields.ChannelIdx:
|
||||
ChannelIdx = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DAS.DASChannelFields.HardwareId:
|
||||
//don't need, it gets it from the hardware passed in
|
||||
break;
|
||||
case DbOperations.DAS.DASChannelFields.SupportedBridges:
|
||||
SupportedBridges = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DAS.DASChannelFields.SupportedExcitations:
|
||||
SupportedExcitations = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DAS.DASChannelFields.SupportedDigitalInputModes:
|
||||
SupportedDigitalInputModes = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DAS.DASChannelFields.SupportedDigitalOutputModes:
|
||||
SupportedDigitalOutputModes = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DAS.DASChannelFields.SupportedSquibFireModes:
|
||||
SupportedSquibFireModes = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DAS.DASChannelFields.DASDisplayOrder:
|
||||
DASDisplayOrder = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DAS.DASChannelFields.ModuleSerialNumber:
|
||||
ModuleSerialNumber = o as string;
|
||||
break;
|
||||
case DbOperations.DAS.DASChannelFields.LocalOnly:
|
||||
LocalOnly = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.DAS.DASChannelFields.ModuleArrayIndex:
|
||||
ModuleArrayIndex = Convert.ToInt32(o);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("Unknown field:" + field.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool LocalOnly { get; set; } = false;
|
||||
|
||||
public static int PhysicalCompare(ISOHardwareChannel left, ISOHardwareChannel right)
|
||||
{
|
||||
if (left == right) { return 0; }
|
||||
if (null == left) { return -1; }
|
||||
if (null == right) { return 1; }
|
||||
return left.ChannelIdx.CompareTo(right.ChannelIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TestGraph //: BindableBase
|
||||
{
|
||||
private const string SEPARATOR = "§";
|
||||
private const string CURRENT_SUFFIX = "_CU";
|
||||
public string GetThresholdsSQL()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("{");
|
||||
|
||||
int count = 0;
|
||||
foreach (var t in Thresholds)
|
||||
{
|
||||
if (count > 0) { sb.Append(SEPARATOR); }
|
||||
//for now thresholds are only doubles, we'll probably want more complicated ones in the future
|
||||
sb.Append("(");
|
||||
sb.Append(t.ToString(CultureInfo.InvariantCulture));
|
||||
sb.Append(")");
|
||||
count++;
|
||||
}
|
||||
sb.Append("}");
|
||||
return sb.ToString();
|
||||
}
|
||||
public void SetThresholdsFromSQL(string sThresholds)
|
||||
{
|
||||
//for now we take an easy parse
|
||||
sThresholds = sThresholds.Replace("{", "").Replace("}", "");
|
||||
var sTokens = sThresholds.Split(new[] { SEPARATOR }, StringSplitOptions.None);
|
||||
foreach (var token in sTokens)
|
||||
{
|
||||
double d;
|
||||
if (double.TryParse(token, out d))
|
||||
{
|
||||
_thresholds.Add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetChannelsFromSQL(string sChannels)
|
||||
{
|
||||
var lookup = new Dictionary<string, TestObjectChannel>();
|
||||
if (null == AvailableChannels)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var channel in AvailableChannels)
|
||||
{
|
||||
lookup[channel.GetGraphID()] = channel;
|
||||
}
|
||||
sChannels = sChannels.Replace("{", "").Replace("}", "");
|
||||
var tokens = sChannels.Split(new[] { SEPARATOR }, StringSplitOptions.None);
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
var sChannelId = token.Replace("(", "").Replace(")", "");
|
||||
if (lookup.ContainsKey(sChannelId)) { AddChannel(lookup[sChannelId]); }
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Generate a key like <groupName>_<channelName>_<channelType> and if the channel is squib "current", "_CU"
|
||||
/// </summary>
|
||||
/// <param name="ch"></param>
|
||||
/// <returns></returns>
|
||||
private string GetTestGraphKey(TestObjectChannel ch)
|
||||
{
|
||||
var key = string.Format("{0}_{1}_{2}", ch.TestObject.SerialNumber, ch.Name, ch.Channel.MMEChannelType);
|
||||
|
||||
var sd = SensorsCollection.SensorsList.GetSensorBySerialNumber(ch.SensorSerialNumber);
|
||||
if (null == sd || !sd.IsDigitalOutput())
|
||||
{
|
||||
if ((sd != null) && (sd.Bridge == Test.Module.Channel.Sensor.BridgeType.SQUIB))
|
||||
{
|
||||
if (ch.SquibChannelType == TestObjectChannel.SquibChannelTypes.Current)
|
||||
{
|
||||
key += CURRENT_SUFFIX;
|
||||
}
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
public string GetChannelsForSQL()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("{");
|
||||
var bNeedSep = false;
|
||||
|
||||
//we must "refresh" the channels we have as they are snapshotted from when the graph was created and the channels may have new ids
|
||||
//6991 Clicking save removes sensors from graph in test setup.
|
||||
var channelLookup = new Dictionary<string, TestObjectChannel>();
|
||||
foreach (var ch in _channels)
|
||||
{
|
||||
channelLookup[GetTestGraphKey(ch)] = ch;
|
||||
}
|
||||
foreach (var ch in AvailableChannels)
|
||||
{
|
||||
channelLookup[GetTestGraphKey(ch)] = ch;
|
||||
}
|
||||
var channelsAfterResolve = new List<TestObjectChannel>();
|
||||
|
||||
foreach (var ch in _channels)
|
||||
{
|
||||
if (channelLookup.ContainsKey(GetTestGraphKey(ch)))
|
||||
{
|
||||
channelsAfterResolve.Add(ch);
|
||||
}
|
||||
}
|
||||
|
||||
_channels = channelsAfterResolve;
|
||||
foreach (var ch in Channels)
|
||||
{
|
||||
if (bNeedSep) { sb.Append(SEPARATOR); }
|
||||
else { bNeedSep = true; }
|
||||
sb.AppendFormat("({0})", ch.GetGraphID());
|
||||
}
|
||||
sb.Append("}");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private List<TestObjectChannel> _channels = new List<TestObjectChannel>();
|
||||
private readonly Dictionary<string, TestObjectChannel> _lookup = new Dictionary<string, TestObjectChannel>();
|
||||
|
||||
public TestObjectChannel[] Channels
|
||||
{
|
||||
get
|
||||
{
|
||||
var toBeRemoved = new List<TestObjectChannel>();
|
||||
|
||||
foreach (var ch in _channels)
|
||||
{
|
||||
var found = false;
|
||||
foreach (var group in _groups)
|
||||
{
|
||||
if (group.SerialNumber == ch.TestObject.SerialNumber)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
foreach (var addedGroup in _addedGroups)
|
||||
{
|
||||
if (addedGroup.SerialNumber == ch.TestObject.SerialNumber)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
toBeRemoved.Add(ch);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var ch in toBeRemoved)
|
||||
{
|
||||
_channels.Remove(ch);
|
||||
}
|
||||
|
||||
return _channels.ToArray();
|
||||
}
|
||||
}
|
||||
private void AddGroup(TestTestObject group)
|
||||
{
|
||||
_groups.Add(group);
|
||||
}
|
||||
private void AddAddedGroup(TestTestObject addedGroup)
|
||||
{
|
||||
_addedGroups.Add(addedGroup);
|
||||
}
|
||||
private void AddChannel(TestObjectChannel channel)
|
||||
{
|
||||
_channels.Add(channel);
|
||||
_lookup[channel.GetGraphID()] = channel;
|
||||
//OnPropertyChanged("Channels");
|
||||
//OnPropertyChanged("AvailableChannels");
|
||||
}
|
||||
private bool ContainsChannel(TestObjectChannel channel)
|
||||
{
|
||||
return _lookup.ContainsKey(channel.GetGraphID());
|
||||
}
|
||||
private bool ContainsCurrentChannel(TestObjectChannel channel)
|
||||
{
|
||||
if (channel.SquibChannelType == TestObjectChannel.SquibChannelTypes.Current)
|
||||
{
|
||||
return ContainsChannel(channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
return _lookup.ContainsKey(channel.GetGraphID() + CURRENT_SUFFIX);
|
||||
}
|
||||
}
|
||||
private bool ContainsVoltageChannel(TestObjectChannel channel)
|
||||
{
|
||||
return ContainsChannel(channel);
|
||||
}
|
||||
public TestObjectChannel[] AvailableChannels
|
||||
{
|
||||
get
|
||||
{
|
||||
_lookup.Clear();
|
||||
foreach (var setChannel in _channels)
|
||||
{
|
||||
_lookup[setChannel.GetGraphID()] = setChannel;
|
||||
}
|
||||
var channels = new List<TestObjectChannel>();
|
||||
if (_groups.Exists(to => !AddChannels(to, channels)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (_addedGroups.Where(to => to.Hardware.Any()).Any(to => !AddChannels(to, channels)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
channels.Sort();
|
||||
return channels.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private bool AddChannels(TestTestObject to, List<TestObjectChannel> channels)
|
||||
{
|
||||
var isoTestObject = to.GetISOTestObject();
|
||||
if (null == isoTestObject)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach (var channel in isoTestObject.AllChannels)
|
||||
{
|
||||
if (!channel.Required) { continue; }
|
||||
if (string.IsNullOrWhiteSpace(channel.SensorSerialNumber)) { continue; }
|
||||
var sd = SensorsCollection.SensorsList.GetSensorBySerialNumber(channel.SensorSerialNumber);
|
||||
if (null == sd || !sd.IsDigitalOutput())
|
||||
{
|
||||
if ((sd != null) && (sd.Bridge == Test.Module.Channel.Sensor.BridgeType.SQUIB))
|
||||
{
|
||||
//Put squib channels (Current and/or Voltage) in the
|
||||
//Available list if and only if they are not in the graph
|
||||
if (!ContainsCurrentChannel(channel))
|
||||
{
|
||||
var currentChannel = new TestObjectChannel(channel, isoTestObject, new TestObjectTemplate().ToISOTestObjectTemplate())
|
||||
{
|
||||
SquibChannelType = TestObjectChannel.SquibChannelTypes.Current,
|
||||
NameOfTheChannel = channel.Name + " " + "(Current)" //Strings.StringResources.Graph_SquibCurrent
|
||||
};
|
||||
channels.Add(currentChannel);
|
||||
}
|
||||
|
||||
if (!ContainsVoltageChannel(channel))
|
||||
{
|
||||
channel.SquibChannelType = TestObjectChannel.SquibChannelTypes.Voltage;
|
||||
channel.NameOfTheChannel = channel.Name + " " + "(Voltage)"; //Strings.StringResources.Graph_SquibVoltage;
|
||||
channels.Add(channel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ContainsChannel(channel)) { continue; }
|
||||
channels.Add(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public string GraphName { get; set; } = "";
|
||||
public string GraphDescription { get; set; } = "";
|
||||
public bool UseDomainMin { get; set; }
|
||||
public double DomainMin { get; set; } = double.MinValue;
|
||||
public bool UseDomainMax { get; set; }
|
||||
public double DomainMax { get; set; } = double.MaxValue;
|
||||
public bool UseRangeMin { get; set; }
|
||||
public double RangeMin { get; set; } = double.MinValue;
|
||||
public bool UseRangeMax { get; set; }
|
||||
public double RangeMax { get; set; } = double.MaxValue;
|
||||
|
||||
private List<double> _thresholds = new List<double>();
|
||||
public double[] Thresholds
|
||||
{
|
||||
get => _thresholds.ToArray();
|
||||
set => _thresholds = new List<double>(value);
|
||||
}
|
||||
|
||||
private readonly TestTemplate _template;
|
||||
private List<TestTestObject> _groups = new List<TestTestObject>();
|
||||
private List<TestTestObject> _addedGroups = new List<TestTestObject>();
|
||||
public TestGraph(TestTemplate template)
|
||||
{
|
||||
_template = template;
|
||||
foreach (var group in _template.TestObjectsWithChannels)
|
||||
{
|
||||
AddGroup(new TestTestObject(group));
|
||||
}
|
||||
foreach (var addedGroup in _template.AddedGroups)
|
||||
{
|
||||
AddAddedGroup(new TestTestObject(addedGroup));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,17 @@
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class SensorRange //: INotifyPropertyChanged
|
||||
{
|
||||
public double Low { get; set; }
|
||||
|
||||
public double Medium { get; set; }
|
||||
|
||||
public double High { get; set; }
|
||||
public SensorRange(double _low, double _medium, double _high)
|
||||
{
|
||||
Low = _low;
|
||||
Medium = _medium;
|
||||
High = _high;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="DatabaseExport.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="ISOMMEDbLocation" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">ISO\mme_code.mdb</Value>
|
||||
</Setting>
|
||||
<Setting Name="AllowAutoArm" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="CalWarningPeriodDays" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">7</Value>
|
||||
</Setting>
|
||||
<Setting Name="DBType" Type="System.Int32" Scope="Application">
|
||||
<Value Profile="(Default)">1</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultSuppressMissingSensorsWarning" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestAllowMissingSensors" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestAllowSensorIdToBlankChannel" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestArmCheckListStep" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestCheckListBatteryVoltageCheck" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestCheckListInputVoltageCheck" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestCheckListMustPass" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestCheckListSensorIDCheck" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestCheckListSquibResistanceCheck" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestCheckListTriggerStartCheck" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestDownloadAll" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestDownloadROI" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestExcitationWarmupMS" Type="System.Int32" Scope="Application">
|
||||
<Value Profile="(Default)">6000</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestExport" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestQuitTestWithoutWarning" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestRealtimeModeGraphCount" Type="System.Int32" Scope="Application">
|
||||
<Value Profile="(Default)">6</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestExportFormat" Type="System.UInt64" Scope="Application">
|
||||
<Value Profile="(Default)">0</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestRequireAllUnitsPassDiagnostics" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestRequireUserConfirmationOnErrors" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestROIEnd" Type="System.Double" Scope="Application">
|
||||
<Value Profile="(Default)">1</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestROIStart" Type="System.Double" Scope="Application">
|
||||
<Value Profile="(Default)">-1</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestRunPostTestDiagnostics" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestSampleRate" Type="System.Double" Scope="Application">
|
||||
<Value Profile="(Default)">10000</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestSuppressNotAllChannelsViewedWarningRealTime" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestTriggerCheckStep" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestSuppressNotAllChannelsViewedWarningViewer" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestViewAll" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultTestViewROI" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="DefaultUploadEnabled" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DownloadFolder" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">..\Data</Value>
|
||||
</Setting>
|
||||
<Setting Name="RequireXCrashCompatibilityForISOExports" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="InstallerCustomActions" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">InstallerCustomActions</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class MMEDirections : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Direction { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; }
|
||||
|
||||
public MMEDirections(string sGuid, string direction, string textL1, string textL2, DateTime date, long version,
|
||||
bool bExpired, string remarks, DateTime lastChange, string lastChangeText, string history, string sortkey,
|
||||
MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
Direction = direction;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Date = date;
|
||||
Version = version;
|
||||
Expired = bExpired;
|
||||
Remarks = remarks;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
SortKey = sortkey;
|
||||
}
|
||||
|
||||
public static MMEDirections[] GetDirections()
|
||||
{
|
||||
var directions = new List<MMEDirections>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMEDirections";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
var version = Convert.ToInt32(ISOReader[DbOperations.MMETables.MMEDirectionsFields.VERSION.ToString()]);
|
||||
var text2 = Convert.ToString(ISOReader[DbOperations.MMETables.MMEDirectionsFields.TEXT_L2.ToString()]);
|
||||
var text1 = Convert.ToString(ISOReader[DbOperations.MMETables.MMEDirectionsFields.TEXT_L1.ToString()]);
|
||||
var sortKey = Convert.ToString(ISOReader[DbOperations.MMETables.MMEDirectionsFields.SORTKEY.ToString()]);
|
||||
var sGuid = Convert.ToString(ISOReader[DbOperations.MMETables.MMEDirectionsFields.s_GUID.ToString()]);
|
||||
var remarks = Convert.ToString(ISOReader[DbOperations.MMETables.MMEDirectionsFields.REMARKS.ToString()]);
|
||||
var lastChangeText = Convert.ToString(ISOReader[DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE_TEXT.ToString()]);
|
||||
var lastChange = GetDate(ISOReader, DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE.ToString());
|
||||
var history = Convert.ToString(ISOReader[DbOperations.MMETables.MMEDirectionsFields.HISTORY.ToString()]);
|
||||
var expired = Convert.ToBoolean(ISOReader[DbOperations.MMETables.MMEDirectionsFields.EXPIRED.ToString()]);
|
||||
var direction = Convert.ToString(ISOReader[DbOperations.MMETables.MMEDirectionsFields.DIRECTION.ToString()]);
|
||||
var date = Convert.ToDateTime(ISOReader[DbOperations.MMETables.MMEDirectionsFields.DATE.ToString()]);
|
||||
var mmedirection = new MMEDirections(sGuid, direction, text1, text2, date, Convert.ToInt64(version), expired, remarks, lastChange,
|
||||
lastChangeText, history, sortKey, MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
||||
directions.Add(mmedirection);
|
||||
}
|
||||
catch (Exception )
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
|
||||
ISOReader.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * from {0}", DbOperations.MMETables.MMEDirectionsTable);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(
|
||||
DbOperations.MMETables.MMEDirectionsFields)).Cast<DbOperations.MMETables.MMEDirectionsFields>().ToArray();
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
|
||||
var date = DateTime.Now;
|
||||
var direction = "?";
|
||||
var expired = false;
|
||||
var history = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var lastChangeText = "";
|
||||
var remarks = "";
|
||||
var sGuid = "";
|
||||
var sortKey = "";
|
||||
var text1 = "";
|
||||
var text2 = "";
|
||||
var version = 0;
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()])) { continue; }
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMEDirectionsFields.VERSION:
|
||||
version = Convert.ToInt32(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.TEXT_L2:
|
||||
text2 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.TEXT_L1:
|
||||
text1 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.SORTKEY:
|
||||
sortKey = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.s_GUID:
|
||||
sGuid = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.REMARKS:
|
||||
remarks = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE:
|
||||
lastChange = Convert.ToDateTime(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.HISTORY:
|
||||
history = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.EXPIRED:
|
||||
expired = Convert.ToBoolean(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.DIRECTION:
|
||||
direction = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.DATE:
|
||||
date = Convert.ToDateTime(dr[field.ToString()]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
directions.Add(new MMEDirections(sGuid.ToString(), direction, text1, text2, date, Convert.ToInt64(version),
|
||||
expired, remarks, lastChange, lastChangeText, history, sortKey, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
return directions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Test.Module.Channel.Sensor.Bridge.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
// *** see Test.cs ***
|
||||
public partial class Test
|
||||
{
|
||||
/// <summary>
|
||||
/// A container for DTS generic module concepts.
|
||||
/// </summary>
|
||||
public sealed partial class Module
|
||||
{
|
||||
// *** see Test.Module.Channel.cs ***
|
||||
public partial class Channel
|
||||
{
|
||||
//*** see Test.Module.Channel.Sensor.cs ***
|
||||
public partial class Sensor
|
||||
{
|
||||
/// <summary>
|
||||
/// All available bridge types.
|
||||
/// </summary>
|
||||
public enum BridgeType
|
||||
{
|
||||
/// <summary>
|
||||
/// sensor uses IEPE setup
|
||||
/// </summary>
|
||||
[Description("IEPE")]
|
||||
IEPE = 1 << 0,
|
||||
/// <summary>
|
||||
/// sensor uses quarter bridge setup
|
||||
/// </summary>
|
||||
[Description("Quarter")]
|
||||
QuarterBridge = 1 << 1,
|
||||
/// <summary>
|
||||
/// sensor uses half bridge setup
|
||||
/// </summary>
|
||||
[Description("Bridge-Half")]
|
||||
HalfBridge = 1 << 2,
|
||||
/// <summary>
|
||||
/// sensor has a full bridge setup
|
||||
/// </summary>
|
||||
[Description("Bridge-Full")]
|
||||
FullBridge = 1 << 3,
|
||||
[Description("DigitalInput")]
|
||||
DigitalInput = 1 << 4,
|
||||
[Description("SQUIB")]
|
||||
SQUIB = 1 << 5,
|
||||
[Description("TOMDigital")]
|
||||
TOMDigital = 1 << 6
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
AttributeCoder.cs
|
||||
|
||||
* 12/18/2008 Relo'd from Dave to SVN-controlled utilities project.
|
||||
|
||||
$Log: AttributeCoder.cs,v $
|
||||
Revision 1.1 2006/09/14 18:41:54 Paul Hrissikopoulos
|
||||
Moved AttributeCoder files from Dave solution.
|
||||
|
||||
Revision 1.3 2006/09/07 20:43:08 Paul Hrissikopoulos
|
||||
Expanded commentary.
|
||||
|
||||
Revision 1.2 2006/08/17 23:44:46 Paul Hrissikopoulos
|
||||
Removed freeloading DCX XML prototype code.
|
||||
|
||||
Revision 1.1 2006/08/17 23:05:11 Paul Hrissikopoulos
|
||||
Added generically-derived SelectionCriterion.ComparisonType enumeration attributes.
|
||||
|
||||
Copyright © 2006
|
||||
Diversified Technical Systems
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// Object for manipulating object-attached attributes and attribute values.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="TargetType">
|
||||
/// The type of <see cref="object"/> the attributes we are concerned with are
|
||||
/// are attached to.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <typeparam name="AttributeType">
|
||||
/// The type of attribute to be manipulated.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <typeparam name="AttributeValueType">
|
||||
/// The type of value contained by the attribute to be manipulated.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <remarks>
|
||||
/// This class was created to make it easier to "match" attributes and the data
|
||||
/// types they're attached to in a somewhat generic manner. It is intended that
|
||||
/// attribute coder classes that deal with specific attribute types be derived
|
||||
/// from this one.
|
||||
/// </remarks>
|
||||
///
|
||||
public class AttributeCoder<TargetType, AttributeType, AttributeValueType> : Exceptional
|
||||
{
|
||||
/// <summary>
|
||||
/// Method that specifies how to access the value of a given "AttributeType".
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="attribute">
|
||||
/// The "AttributeType" attribute to have its value extracted.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The "AttributeValueType" value of the specified attribute.
|
||||
/// </returns>
|
||||
///
|
||||
public delegate AttributeValueType AttributeValueExtractionMethod(AttributeType attribute);
|
||||
|
||||
/// <summary>
|
||||
/// Method for determining the equality of two "AttributeValueType" values.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value1">
|
||||
/// A "AttributeValueType" to be equality-compared.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="value2">
|
||||
/// A "AttributeValueType" to be equality-compared.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True if the two values are equal; false otherwise.
|
||||
/// </returns>
|
||||
///
|
||||
public delegate bool AttributeValueEqualityComparisonMethod(AttributeValueType value1, AttributeValueType value2);
|
||||
|
||||
private readonly AttributeValueExtractionMethod _extractAttributeValue;
|
||||
private readonly AttributeValueEqualityComparisonMethod _areAttributeValuesEqual;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an instance of the AttributeCoder class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="attributeValueExtractionMethod">
|
||||
/// A <see cref="AttributeValueExtractionMethod"/> that defines how "AttributeValueType"
|
||||
/// values are to be extracted from "AttributeType" attributes.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="attributeValueEqualityComparisonMethod">
|
||||
/// Optional parameter for specifying a custom comparison method to override default
|
||||
/// "AttributeValueType" equality determination. Pass null to use default
|
||||
/// comparison.
|
||||
/// </param>
|
||||
///
|
||||
public AttributeCoder(AttributeValueExtractionMethod attributeValueExtractionMethod,
|
||||
AttributeValueEqualityComparisonMethod attributeValueEqualityComparisonMethod)
|
||||
{
|
||||
try
|
||||
{
|
||||
_extractAttributeValue = attributeValueExtractionMethod ?? throw new Exception("cannot use null attribute value extraction method reference");
|
||||
if (null != attributeValueEqualityComparisonMethod)
|
||||
_areAttributeValuesEqual = attributeValueEqualityComparisonMethod;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format("encountered problem constructing {0}", /*fix this Resources.Generic_EncounteredProblemConstructingClassString,*/ GetType().FullName), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the "AttributeValueType" of the "AttributeType" attribute
|
||||
/// attached to the specified "TargetType".
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="target">
|
||||
/// The "TargetType" object whose "AttributeType" attribute is to be
|
||||
/// evaluated.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The "AttributeValueType" of the "AttributeType" attribute attached
|
||||
/// to the specified "TargetType".
|
||||
/// </returns>
|
||||
///
|
||||
public AttributeValueType DecodeAttributeValue(TargetType target)
|
||||
{
|
||||
try
|
||||
{
|
||||
var attributes = DecodeAttributeValues(target);
|
||||
Debug.Assert(1 == attributes.Count);
|
||||
if (attributes.Count > 0) return attributes[0];
|
||||
throw new Exception("no attributes of specified type found on designated target"); //fix this Resources.AttributeCoder_NoTypeAttributesFoundOnTargetString);
|
||||
}
|
||||
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception("encountered problem decoding attribute value"); //fix this Resources.AttributeCoder_DecodeAttributeExceptionString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the <see cref="T:List"/> of "AttributeValueType"s of the
|
||||
/// "AttributeType" attached to the specified "TargetType".
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="target">
|
||||
/// The "TargetType" object whose "AttributeType" attribute is to be
|
||||
/// evaluated.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The "AttributeValueType" of the "AttributeType" attribute attached
|
||||
/// to the specified "TargetType".
|
||||
/// </returns>
|
||||
///
|
||||
public List<AttributeValueType> DecodeAttributeValues(TargetType target)
|
||||
{
|
||||
try
|
||||
{
|
||||
var info = target.GetType().GetField(target.ToString());
|
||||
var attributes = (info.GetCustomAttributes(typeof(AttributeType), false) as AttributeType[]);
|
||||
var attributeList = new List<AttributeValueType>();
|
||||
if (attributes != null)
|
||||
{
|
||||
attributeList.AddRange(attributes.Select(t => _extractAttributeValue(t)));
|
||||
}
|
||||
return attributeList;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"encountered problem decoding attribute values {ex.Message}"); //fix this Resources.AttributeCoder_DecodeAttributesExceptionString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the "TargetType" value that has the "AttributeType"
|
||||
/// attribute with the specified "AttributeValueType" value attached
|
||||
/// to it.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="attributeValue">
|
||||
/// The value of the "AttributeType" attribute attached to the
|
||||
/// "TargetType" target object we're looking for.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The "TargetType" target object that has the "AttributeType"
|
||||
/// attribute attached to it that has a "AttributeValueType" value of
|
||||
/// attributeValue.
|
||||
/// </returns>
|
||||
///
|
||||
public TargetType EncodeAttributeValue(AttributeValueType attributeValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var targets = DehashAttributeValue(attributeValue);
|
||||
Debug.Assert(1 == targets.Count, "unable to find unique target type mapping for the specified attribute value"); //fix this Resources.AttributeCoder_UnableToFindTargetTypeMappingString);
|
||||
if (1 != targets.Count)
|
||||
throw new Exception("unable to find unique target type mapping for the specified attribute value"); //fix this Resources.AttributeCoder_UnableToFindTargetTypeMappingString);
|
||||
return targets[0];
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem encoding attribute value", ex); //fix this Resources.AttributeCoder_EncodeAttributeExceptionString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a list of "TargetType" values that have the
|
||||
/// "AttributeType" attribute with the specified
|
||||
/// "AttributeValueType" value attached to them.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="attributeValue">
|
||||
/// The value of the "AttributeType" attribute attached to the
|
||||
/// "TargetType" target object we're looking for.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="T:List"/> of "TargetType" target objects that has
|
||||
/// the "AttributeType" attribute attached to it that has a
|
||||
/// "AttributeValueType" value of attributeValue.
|
||||
/// </returns>
|
||||
///
|
||||
public List<TargetType> DehashAttributeValue(AttributeValueType attributeValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var targets = Enum.GetValues(typeof(TargetType)).Cast<TargetType>()
|
||||
.Where(target => (null != _areAttributeValuesEqual) ?
|
||||
_areAttributeValuesEqual(DecodeAttributeValue(target), attributeValue) : DecodeAttributeValue(target).Equals(attributeValue)).ToList();
|
||||
if (targets.Count <= 0)
|
||||
throw new Exception("unable to match attribute value with an actual target type"); // fix this Resources.AttributeCoder_DehashAttributeValue_UnableToMatchAttributeValueWithTargetString);
|
||||
return targets;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem dehashing attribute value", ex); // fix this Resources.AttributeCoder_DehashAttributeValue_DehashAttributeValueExceptionString, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a test object that belongs to a test, it's different in that it can have test specific settings ...
|
||||
/// </summary>
|
||||
public class TestTestObject : TestObject
|
||||
{
|
||||
public TestTestObject(TestObject obj)
|
||||
: base(obj)
|
||||
{
|
||||
}
|
||||
private string _position = ChannelDefaultsKey;
|
||||
public MMEPositions Position
|
||||
{
|
||||
get => GetGroupPosition(_position);
|
||||
set
|
||||
{
|
||||
SetProperty(ref _position, value.Position, "Position");
|
||||
if (_position == UserSetKey)
|
||||
{
|
||||
GroupPositionComboBoxVisible = System.Windows.Visibility.Hidden;
|
||||
GroupPositionButtonVisible = System.Windows.Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupPositionComboBoxVisible = System.Windows.Visibility.Visible;
|
||||
GroupPositionButtonVisible = System.Windows.Visibility.Hidden;
|
||||
//set the position for every sensor in the test object using this position
|
||||
var isoTO = GetISOTestObject();
|
||||
foreach (var ch in isoTO.AllChannels)
|
||||
{
|
||||
if (!ch.Required) { continue; }
|
||||
if (string.IsNullOrWhiteSpace(ch.SensorSerialNumber)) { continue; }
|
||||
var sd = GetSensor(ch.Name, ch.SensorSerialNumber); // now using ch.Name instead of ch.GetID(); FB 7391 - Group sensor settings not in test when you set the test obj. and position.
|
||||
if (null == sd) { continue; }
|
||||
sd.Position = value.Position;
|
||||
SetSensor(ch.GetID(), sd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public const string ChannelDefaultsKey = "#";
|
||||
public const string UserSetKey = "@";
|
||||
|
||||
private MMEPositions GetGroupPosition(string groupPositionKey)
|
||||
{
|
||||
foreach (var position in AvailableGroupPositions)
|
||||
{
|
||||
if (position.Position == groupPositionKey)
|
||||
{
|
||||
return position;
|
||||
}
|
||||
}
|
||||
return _userSetGUID;
|
||||
}
|
||||
|
||||
private System.Windows.Visibility _groupPositionComboBoxVisible = System.Windows.Visibility.Visible;
|
||||
public System.Windows.Visibility GroupPositionComboBoxVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_groupPositionComboBoxVisible == System.Windows.Visibility.Visible)
|
||||
{
|
||||
if (SerializedSettings.ISOSupportLevel == SerializedSettings.ISOSupportLevels.NO_ISO) { return System.Windows.Visibility.Collapsed; }
|
||||
return _groupPositionComboBoxVisible;
|
||||
}
|
||||
return _groupPositionComboBoxVisible;
|
||||
}
|
||||
set => _groupPositionComboBoxVisible = value;
|
||||
}
|
||||
|
||||
private System.Windows.Visibility _groupPositionButtonVisible = System.Windows.Visibility.Hidden;
|
||||
public System.Windows.Visibility GroupPositionButtonVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_groupPositionButtonVisible == System.Windows.Visibility.Visible)
|
||||
{
|
||||
if (SerializedSettings.ISOSupportLevel == SerializedSettings.ISOSupportLevels.NO_ISO) { return System.Windows.Visibility.Collapsed; }
|
||||
return _groupPositionButtonVisible;
|
||||
}
|
||||
return _groupPositionButtonVisible;
|
||||
}
|
||||
set => _groupPositionButtonVisible = value;
|
||||
}
|
||||
|
||||
private string _testObject = "?";
|
||||
public MMETestObjects TestObject
|
||||
{
|
||||
get => ISO13499FileDb.IsoDb.GetTestObjectByIso(_testObject);
|
||||
set
|
||||
{
|
||||
if (value == null) return;
|
||||
SetProperty(ref _testObject, value.Test_Object, "TestObject");
|
||||
//also set the test object for all sensors!
|
||||
|
||||
var isoTO = GetISOTestObject();
|
||||
foreach (var ch in isoTO.AllChannels)
|
||||
{
|
||||
if (!ch.Required) { continue; }
|
||||
if (string.IsNullOrWhiteSpace(ch.SensorSerialNumber)) { continue; }
|
||||
var sd = GetSensor(ch.GetID(), ch.SensorSerialNumber);
|
||||
if (null == sd) { continue; }
|
||||
sd.TestObject = value.Test_Object;
|
||||
SetSensor(ch.GetID(), sd);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetTestObject(string s)
|
||||
{
|
||||
_testObject = s;
|
||||
OnPropertyChanged("TestObject");
|
||||
}
|
||||
public void SetPosition(string s)
|
||||
{
|
||||
_position = s;
|
||||
OnPropertyChanged("Position");
|
||||
if (s == UserSetKey)
|
||||
{
|
||||
GroupPositionComboBoxVisible = System.Windows.Visibility.Hidden;
|
||||
GroupPositionButtonVisible = System.Windows.Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupPositionComboBoxVisible = System.Windows.Visibility.Visible;
|
||||
GroupPositionButtonVisible = System.Windows.Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
public MMEPositions[] AvailablePositions => ISO13499FileDb.IsoDb.GetPositions();
|
||||
|
||||
private const string DATAPRO_DEFINED = "DataPRO-defined";
|
||||
public static MMEPositions _channelDefaultsGUID = new MMEPositions(Guid.NewGuid().ToString(), ChannelDefaultsKey, "(channel defaults)", "(channel defaults)", 1, DateTime.Now, DATAPRO_DEFINED, false, "", DateTime.Now,
|
||||
DATAPRO_DEFINED, "", MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
||||
private MMEPositions _userSetGUID = new MMEPositions(Guid.NewGuid().ToString(), UserSetKey, "(multiple)", "(multiple)", 1, DateTime.Now, DATAPRO_DEFINED, false, "", DateTime.Now,
|
||||
DATAPRO_DEFINED, "", MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
||||
public MMEPositions[] AvailableGroupPositions
|
||||
{
|
||||
get
|
||||
{
|
||||
var availableGroupPositions = new List<MMEPositions>();
|
||||
availableGroupPositions.Add(_channelDefaultsGUID);
|
||||
foreach (var position in AvailablePositions)
|
||||
{
|
||||
availableGroupPositions.Add(position);
|
||||
}
|
||||
|
||||
return availableGroupPositions.ToArray();
|
||||
}
|
||||
}
|
||||
private int _excitationWarmupTime = Properties.Settings.Default.DefaultTestExcitationWarmupMS;
|
||||
public int ExcitationWarmupTimeMS
|
||||
{
|
||||
get => _excitationWarmupTime;
|
||||
set => SetProperty(ref _excitationWarmupTime, value, "ExcitationWarmupTimeMS");
|
||||
}
|
||||
private double _targetSampleRate;
|
||||
public double TargetSampleRate
|
||||
{
|
||||
get => _targetSampleRate;
|
||||
set => SetProperty(ref _targetSampleRate, value, "TargetSampleRate");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class Zone //: Common.BindableBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public string Image { get; set; }
|
||||
|
||||
public TemplateZone ISODllZone { get; }
|
||||
|
||||
public Zone(TemplateZone z, TestObjectTemplate template)
|
||||
{
|
||||
ISODllZone = z;
|
||||
|
||||
if (null == z || null == z.Description)
|
||||
{
|
||||
Description = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
Description = z.Description;
|
||||
}
|
||||
Image = z.Picture;
|
||||
var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZonePictures");
|
||||
|
||||
//if (string.IsNullOrEmpty(Image)) { Image = "H3_2_11.png"; }
|
||||
if (!string.IsNullOrEmpty(Image))
|
||||
{
|
||||
path = System.IO.Path.Combine(path, Image);
|
||||
if (!System.IO.File.Exists(path))
|
||||
{
|
||||
PictureIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
var src = new System.Windows.Media.Imaging.BitmapImage();
|
||||
src.BeginInit();
|
||||
src.UriSource = new Uri(path, UriKind.Absolute);
|
||||
try
|
||||
{
|
||||
src.EndInit();
|
||||
PictureSource = src;
|
||||
_pictureIndex = AllPictures.ToList().IndexOf(Image);
|
||||
}
|
||||
catch
|
||||
{
|
||||
PictureIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Name = z.ZoneName;
|
||||
_regions = new List<Region>();
|
||||
foreach (var r in z.TemplateRegions)
|
||||
{
|
||||
var region = new Region(template, r);
|
||||
_regions.Add(region);
|
||||
}
|
||||
}
|
||||
|
||||
public class FileInfoComparer : IComparer<System.IO.FileInfo>
|
||||
{
|
||||
int IComparer<System.IO.FileInfo>.Compare(System.IO.FileInfo left, System.IO.FileInfo right)
|
||||
{
|
||||
if (left == right)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (left == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (right == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return left.FullName.CompareTo(right.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
private List<System.IO.FileInfo> _fileNames = null;
|
||||
|
||||
public string[] AllPictures
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == _fileNames)
|
||||
{
|
||||
var files = new List<string>();
|
||||
files.AddRange(System.IO.Directory.EnumerateFiles(
|
||||
System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZonePictures")));
|
||||
_fileNames = new List<System.IO.FileInfo>();
|
||||
foreach (var file in files)
|
||||
{
|
||||
_fileNames.Add(new System.IO.FileInfo(file));
|
||||
}
|
||||
_fileNames.Sort(new FileInfoComparer());
|
||||
}
|
||||
var l = new List<string>();
|
||||
foreach (var fi in _fileNames)
|
||||
{
|
||||
l.Add(fi.Name);
|
||||
}
|
||||
return l.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private int _pictureIndex = -1;
|
||||
|
||||
public int PictureIndex
|
||||
{
|
||||
get => _pictureIndex;
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
PictureSource = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var src = new System.Windows.Media.Imaging.BitmapImage();
|
||||
src.BeginInit();
|
||||
src.UriSource = new Uri(_fileNames[value].FullName, UriKind.Absolute);
|
||||
src.EndInit();
|
||||
PictureSource = src;
|
||||
}
|
||||
_pictureIndex = value;
|
||||
//if (null != _template) { _template.MarkChanged(Tags.PictureIndex.ToString()); }
|
||||
}
|
||||
}
|
||||
|
||||
public string GetPictureName()
|
||||
{
|
||||
return _pictureIndex < 0 ? "" : _fileNames[_pictureIndex].Name;
|
||||
}
|
||||
|
||||
public System.Windows.Media.ImageSource PictureSource { get; set; } = null;
|
||||
|
||||
private List<Region> _regions = new List<Region>();
|
||||
|
||||
public Region[] Regions
|
||||
{
|
||||
get => _regions.ToArray();
|
||||
set => _regions = new List<Region>(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TestEngineerDetails
|
||||
{
|
||||
private readonly ISO.TestEngineerDetails _testEngineerDetails;
|
||||
public string Name
|
||||
{
|
||||
get => _testEngineerDetails.Name;
|
||||
set => _testEngineerDetails.Name = value;
|
||||
}
|
||||
public TestEngineerDetails()
|
||||
{
|
||||
_testEngineerDetails = new ISO.TestEngineerDetails();
|
||||
_testEngineerDetails.Name = "(none)"; // Strings.StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public TestEngineerDetails(ISO.TestEngineerDetails testEngineerDetails)
|
||||
{
|
||||
_testEngineerDetails = new ISO.TestEngineerDetails(testEngineerDetails);
|
||||
}
|
||||
public ISO.TestEngineerDetails GetISOTestEngineer()
|
||||
{
|
||||
return _testEngineerDetails;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class TestEngineerDetailsList
|
||||
{
|
||||
private static TestEngineerDetailsList _testEngineerList = new TestEngineerDetailsList();
|
||||
public static TestEngineerDetailsList TestEngineerList => _testEngineerList;
|
||||
private static object _testEngineerLock = new object();
|
||||
private Dictionary<string, TestEngineerDetails> _testEngineers = null;
|
||||
public TestEngineerDetails[] TestEngineers
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
if (null == _testEngineers)
|
||||
{
|
||||
PopulateEngineers();
|
||||
}
|
||||
}
|
||||
var testEngineers = new List<TestEngineerDetails>(_testEngineers.Values);
|
||||
testEngineers.Sort(CompareTestEngineers);
|
||||
return testEngineers.ToArray();
|
||||
}
|
||||
}
|
||||
private void PopulateEngineers()
|
||||
{
|
||||
_testEngineers = new Dictionary<string, TestEngineerDetails>();
|
||||
foreach (var t in _testEngineerList.GetAllTestEngineers())
|
||||
{
|
||||
if (!_testEngineers.ContainsKey(t.Name)) { _testEngineers.Add(t.Name, t); }
|
||||
}
|
||||
}
|
||||
private static int CompareTestEngineers(TestEngineerDetails a, TestEngineerDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
if (null == b) { return 1; }
|
||||
return a.Name.CompareTo(b.Name);
|
||||
}
|
||||
|
||||
private TestEngineerDetails[] GetAllTestEngineers()
|
||||
{
|
||||
var list = new List<TestEngineerDetails>();
|
||||
list.Add(new TestEngineerDetails()); //This is the "(none)" entry
|
||||
foreach (var ts in ISO.TestEngineerDetails.GetAllTestEngineerDetails())
|
||||
{
|
||||
list.Add(new TestEngineerDetails(ts));
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
public TestEngineerDetails GetTestEngineerDetail(string name)
|
||||
{
|
||||
var testEngineers = from t in TestEngineers.AsParallel() where t.Name == name select t;
|
||||
if (null != testEngineers && testEngineers.Count() > 0) { return testEngineers.First(); }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,514 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TestObjectTemplate
|
||||
{
|
||||
private enum GroupTemplateChannelFields
|
||||
{
|
||||
TestObjectNumber,
|
||||
NameOfTheChannel,
|
||||
LaboratoryChannelCode,
|
||||
CustomerChannelCode,
|
||||
Comments1,
|
||||
Location,
|
||||
Dimension,
|
||||
Direction,
|
||||
ChannelFrequencyClass,
|
||||
Unit,
|
||||
ReferenceSystem,
|
||||
TransducerType,
|
||||
TransducerId,
|
||||
PreFilterType,
|
||||
CutOffFrequency,
|
||||
ChannelAmplitudeClass,
|
||||
ReferenceChannel,
|
||||
ReferenceChannelName,
|
||||
DataSource,
|
||||
DataStatus,
|
||||
SamplingInterval,
|
||||
BitResolution,
|
||||
TimeOfFirstSample,
|
||||
NumberOfSamples,
|
||||
OffsetPostTest,
|
||||
TransducerNaturalFrequency,
|
||||
TransducerDampingRatio,
|
||||
Comments,
|
||||
FirstGlobalMaximumValue,
|
||||
TimeOfMaximumValue,
|
||||
FirstGlobalMinimumValue,
|
||||
TimeOfMinimumValue,
|
||||
StartOffsetInterval,
|
||||
EndOffsetInterval,
|
||||
MMEChannelId,
|
||||
MMEChannelType,
|
||||
Required,
|
||||
DisplayOrder,
|
||||
LocalOnly
|
||||
}
|
||||
private enum GroupTemplateFields
|
||||
{
|
||||
TemplateName,
|
||||
Icon,
|
||||
Description,
|
||||
LocalOnly,
|
||||
Version,
|
||||
LastModifiedBy,
|
||||
LastModified,
|
||||
CRC32,
|
||||
TestObjectType,
|
||||
TestObject,
|
||||
ParentTemplate,
|
||||
SysBuilt,
|
||||
OriginalTemplateName,
|
||||
Embedded
|
||||
};
|
||||
public const string NON_ISO_TESTOBJECT_CHANNEL_TYPE = "x_NonISOTestObjectType_x";
|
||||
public const string NON_ISO_TESTOBJECT_NAME = "x_NonISOTestObjectName_x";
|
||||
public string LastModifiedBy { get; set; } = "N/A";
|
||||
|
||||
public DateTime LastModified { get; set; } = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
|
||||
|
||||
private int _currentZoneIndex = -1;
|
||||
public int CurrentZoneIndex
|
||||
{
|
||||
get => _currentZoneIndex;
|
||||
set
|
||||
{
|
||||
if (value >= 0)
|
||||
{
|
||||
CurrentZone = TemplateZones[value];
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentZone = null;
|
||||
}
|
||||
_currentZoneIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Zone _currentZone = null;//Zone.DummyZone;
|
||||
public Zone CurrentZone
|
||||
{
|
||||
get => _currentZone;
|
||||
set
|
||||
{
|
||||
//if (null != _currentZone && _currentZone != value) { _currentZone.PropertyChanged -= CurrentZone_PropertyChanged; }
|
||||
_currentZone = value;
|
||||
|
||||
//if (null != _currentZone) { _currentZone.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(CurrentZone_PropertyChanged); }
|
||||
if (null == value) { AreZoneControlsEnabled = false; }
|
||||
else { AreZoneControlsEnabled = true; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool AreZoneControlsEnabled { get; set; } = false;
|
||||
|
||||
private ISO.TestObjectTemplate _template = null;
|
||||
public List<TestObjectTemplateChannel> RequiredChannels { get; set; } = new List<TestObjectTemplateChannel>();
|
||||
|
||||
public string TemplateParent { get; set; } = "";
|
||||
|
||||
public bool SysBuilt { get; set; } = false;
|
||||
|
||||
private bool _embedded = false;
|
||||
public bool Embedded
|
||||
{
|
||||
get => _embedded;
|
||||
set
|
||||
{
|
||||
_embedded = value;
|
||||
if (null != _template) { _template.Embedded = value; }
|
||||
}
|
||||
}
|
||||
private string _originalTemplateName = "";
|
||||
public string OriginalTemplateName
|
||||
{
|
||||
get => _originalTemplateName;
|
||||
set
|
||||
{
|
||||
_originalTemplateName = value;
|
||||
if (null != _template) { _template.OriginalTemplateName = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public string TemplateName { get; set; }
|
||||
|
||||
public string TemplateDescription { get; set; }
|
||||
|
||||
public bool IsLocalOnly { get; set; }
|
||||
|
||||
private MMETestObjects _testObject;
|
||||
public MMETestObjects TestObject
|
||||
{
|
||||
get => _testObject;
|
||||
set
|
||||
{
|
||||
_testObject = value;
|
||||
if (null != _testObject)
|
||||
{
|
||||
AvailableTestObjectTypes = ISO13499FileDb.IsoDb.GetUniquePossibleChannelTypes(TestObjectTemplateChannel.NONISOCHANNELTYPE);
|
||||
if (AvailableTestObjectTypes.Length > 0) { TestObjectTypeIndex = 0; }
|
||||
else { TestObjectTypeIndex = -1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _testObjectType;
|
||||
public string TestObjectType
|
||||
{
|
||||
get => _testObjectType;
|
||||
set
|
||||
{
|
||||
_testObjectType = value;
|
||||
//if (null != _template) { _template.TestObjectType = value; }//we did this so that _template.TestObjectType gets set, however during initialization _template can be null
|
||||
_channels = new List<MMEPossibleChannels>(ISO13499FileDb.IsoDb.GetPossibleChannelsForType(_testObjectType));
|
||||
var all = new List<TestObjectTemplateChannel>();
|
||||
var db = ISO13499FileDb.IsoDb;
|
||||
foreach (var pc in _channels) { all.Add(new TestObjectTemplateChannel(new TestObjectTemplateChannel(pc), /*ref db,*/ _template)); }
|
||||
TemplateAllChannels = all.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private List<MMEPossibleChannels> _channels = new List<MMEPossibleChannels>();
|
||||
|
||||
private List<TestObjectTemplateChannel> _allChannels = new List<TestObjectTemplateChannel>();
|
||||
public TestObjectTemplateChannel[] TemplateAllChannels
|
||||
{
|
||||
get { _allChannels.Sort(new Comparison<TestObjectTemplateChannel>(CompareChannels)); return _allChannels.ToArray(); }
|
||||
set
|
||||
{
|
||||
_allChannels = new List<TestObjectTemplateChannel>(value);
|
||||
|
||||
var channels = new List<TemplateChannelUI>();
|
||||
foreach (var c in value)
|
||||
{
|
||||
var channel = new TemplateChannelUI(c);
|
||||
channels.Add(channel);
|
||||
}
|
||||
TemplateAllUIChannels = channels.ToArray();
|
||||
}
|
||||
}
|
||||
private List<TemplateChannelUI> _allUIChannels = new List<TemplateChannelUI>();
|
||||
public TemplateChannelUI[] TemplateAllUIChannels
|
||||
{
|
||||
get => _allUIChannels.ToArray();
|
||||
set => _allUIChannels = new List<TemplateChannelUI>(value);
|
||||
}
|
||||
|
||||
private List<Zone> _zones = new List<Zone>();
|
||||
public Zone[] TemplateZones
|
||||
{
|
||||
get => _zones.ToArray();
|
||||
set { _zones = new List<Zone>(value); var j = CurrentZoneIndex; }
|
||||
}
|
||||
private List<string> _availableTestObjectTypes = null;
|
||||
public string[] AvailableTestObjectTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == _availableTestObjectTypes)
|
||||
{
|
||||
if (null == TestObject) { return new string[0]; }
|
||||
_availableTestObjectTypes = new List<string>(ISO13499FileDb.IsoDb.GetTestObjectTypeForTestObject(TestObject.Test_Object));
|
||||
}
|
||||
return _availableTestObjectTypes.ToArray();
|
||||
}
|
||||
set => _availableTestObjectTypes = new List<string>(value);
|
||||
}
|
||||
private int _testObjectTypeIndex = -1;
|
||||
public int TestObjectTypeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(TestObjectType)) { return -1; }
|
||||
return _availableTestObjectTypes.IndexOf(TestObjectType);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value >= 0) { TestObjectType = _availableTestObjectTypes[value]; }
|
||||
else { TestObjectType = null; }
|
||||
_testObjectTypeIndex = value;
|
||||
|
||||
var all = new List<TestObjectTemplateChannel>();
|
||||
var db = ISO13499FileDb.IsoDb;
|
||||
foreach (var pc in _channels) { all.Add(new TestObjectTemplateChannel(new TestObjectTemplateChannel(pc), /*ref db,*/ _template)); }
|
||||
TemplateAllChannels = all.ToArray();
|
||||
}
|
||||
}
|
||||
public static MMETestObjects GetNonISOTestObject()
|
||||
{
|
||||
var existingobjects = ISO13499FileDb.IsoDb.GetTestObjects(false);
|
||||
|
||||
var codes = new List<string>();
|
||||
|
||||
foreach (var existingobject in existingobjects)
|
||||
{
|
||||
if (existingobject.Text_L1 == NON_ISO_TESTOBJECT_NAME)
|
||||
{
|
||||
return existingobject;
|
||||
}
|
||||
else { codes.Add(existingobject.Test_Object); }
|
||||
}
|
||||
|
||||
//first try to find a suitable alpha character that isn't in use
|
||||
for (var i = (int)('A'); i <= 'Z'; i++)
|
||||
{
|
||||
var s = new string(new char[] { (char)i });
|
||||
if (!codes.Contains(s))
|
||||
{
|
||||
var to = new MMETestObjects(Guid.NewGuid().ToString(), s, NON_ISO_TESTOBJECT_NAME, NON_ISO_TESTOBJECT_NAME, 1,
|
||||
DateTime.Now, "SYSTEM", false, "", DateTime.Now, "created", "", MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
//ISO13499FileDb.IsoDb.Commit(to);
|
||||
return to;
|
||||
}
|
||||
}
|
||||
//didn't find one, now try for a suitable numeric character
|
||||
for (var i = (int)'0'; i <= '9'; i++)
|
||||
{
|
||||
var s = new string(new char[] { (char)i });
|
||||
if (!codes.Contains(s))
|
||||
{
|
||||
var to = new MMETestObjects(Guid.NewGuid().ToString(), s, NON_ISO_TESTOBJECT_NAME, NON_ISO_TESTOBJECT_NAME, 1,
|
||||
DateTime.Now, "SYSTEM", false, "", DateTime.Now, "created", "", MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
//(App.Current as App).IsoDb.Commit(to);
|
||||
return to;
|
||||
}
|
||||
}
|
||||
throw new NotSupportedException("Could not create system Non-ISO Group" /*Strings.StringResources.TestObjectTemplate_CouldNotCreateNONISOTESTOBJECT*/);
|
||||
}
|
||||
public ISO.TestObjectTemplate ToISOTestObjectTemplate()
|
||||
{
|
||||
var log = new System.Diagnostics.EventLog();
|
||||
log.Source = "DataPROInstaller";
|
||||
|
||||
log.WriteEntry("Getting a new ISO.TestObjectTemplate using " + TemplateName);
|
||||
var template = new ISO.TestObjectTemplate(TemplateName, IsLocalOnly);
|
||||
log.WriteEntry("Got a new ISO.TestObjectTemplate");
|
||||
template.Description = TemplateDescription;
|
||||
log.WriteEntry("Set template.Description to " + TemplateDescription);
|
||||
template.OriginalTemplateName = OriginalTemplateName;
|
||||
log.WriteEntry("Set template.OriginalTemplateName to " + OriginalTemplateName);
|
||||
template.Embedded = Embedded;
|
||||
log.WriteEntry("Set template.Embedded to " + Embedded);
|
||||
template.Icon = "";
|
||||
log.WriteEntry("Set template.Icon to " + "");
|
||||
template.LocalOnly = IsLocalOnly;
|
||||
log.WriteEntry("Set LocalOnly to " + IsLocalOnly);
|
||||
if (TestObject == null)
|
||||
{
|
||||
log.WriteEntry("TestObject is null");
|
||||
}
|
||||
else if (TestObject.Test_Object == null)
|
||||
{
|
||||
log.WriteEntry("TestObject.Test_Object is null");
|
||||
}
|
||||
log.WriteEntry("Setting template.TestObject to " + TestObject.Test_Object);
|
||||
template.TestObject = TestObject.Test_Object;
|
||||
log.WriteEntry("Set template.TestObject successfully");
|
||||
template.TestObjectType = TestObjectType;
|
||||
var zones = new List<TemplateZone>();
|
||||
foreach (var zone in TemplateZones)
|
||||
{
|
||||
var isoZone = new TemplateZone(TemplateName, zone.Name, zone.GetPictureName(), zone.Description);
|
||||
|
||||
var zoneRegions = new List<TemplateRegion>();
|
||||
var i = 0;
|
||||
foreach (var region in zone.Regions)
|
||||
{
|
||||
var isoRegion = region.ToISORegion(this, zone, i++);
|
||||
zoneRegions.Add(isoRegion);
|
||||
}
|
||||
isoZone.TemplateRegions = zoneRegions.ToArray();
|
||||
zones.Add(isoZone);
|
||||
}
|
||||
template.TemplateParent = TemplateParent;
|
||||
log.WriteEntry("Setting template.Channels to TemplateAllChannels");
|
||||
template.Channels = TemplateAllChannels;
|
||||
log.WriteEntry("Set template.Channels successfully");
|
||||
template.Zones = zones.ToArray();
|
||||
template.SysBuilt = SysBuilt;
|
||||
log.WriteEntry("Returning");
|
||||
return template;
|
||||
}
|
||||
private int CompareChannels(TestObjectTemplateChannel left, TestObjectTemplateChannel right)
|
||||
{
|
||||
if (left == right) { return 0; }
|
||||
if (null == left) { return -1; }
|
||||
if (null == right) { return 1; }
|
||||
return left.DisplayOrder.CompareTo(right.DisplayOrder);
|
||||
}
|
||||
public TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)
|
||||
{
|
||||
if (null != copy._template) { _template = new ISO.TestObjectTemplate(copy._template, ref db); }
|
||||
TemplateDescription = copy.TemplateDescription;
|
||||
TemplateParent = copy.TemplateParent;
|
||||
TemplateName = copy.TemplateName;
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
TestObject = copy.TestObject;
|
||||
TestObjectType = copy.TestObjectType;
|
||||
var channels = new List<TestObjectTemplateChannel>();
|
||||
foreach (var c in copy.TemplateAllChannels)
|
||||
{
|
||||
channels.Add(new TestObjectTemplateChannel(c, /*ref db,*/ _template));
|
||||
}
|
||||
foreach (var c in copy.RequiredChannels)
|
||||
{
|
||||
RequiredChannels.Add(new TestObjectTemplateChannel(c, /*ref db,*/ _template));
|
||||
}
|
||||
TemplateAllChannels = channels.ToArray();
|
||||
|
||||
var zones = new List<Zone>();
|
||||
foreach (var z in copy.TemplateZones)
|
||||
{
|
||||
zones.Add(new Zone(z.ISODllZone, this));
|
||||
}
|
||||
TemplateZones = zones.ToArray();
|
||||
SysBuilt = copy.SysBuilt;
|
||||
Embedded = copy.Embedded;
|
||||
OriginalTemplateName = copy.OriginalTemplateName;
|
||||
}
|
||||
public TestObjectTemplate(ISO.TestObjectTemplate template, ref ISO13499FileDb db)
|
||||
{
|
||||
Initialize(template, ref db, null);
|
||||
}
|
||||
private void Initialize(ISO.TestObjectTemplate template, ref ISO13499FileDb db, List<MMETestObjects> testObjects)
|
||||
{
|
||||
_template = template;
|
||||
TemplateDescription = template.Description;
|
||||
TemplateName = template.TemplateName;
|
||||
LastModified = template.LastModified;
|
||||
LastModifiedBy = template.LastModifiedBy;
|
||||
|
||||
//if a list of test objects is provided, check if the test object we wish is in the list, if so use it
|
||||
var bFoundTestObject = false;
|
||||
if (null != testObjects)
|
||||
{
|
||||
var matches = from to in testObjects where to.Test_Object == template.TestObject select to;
|
||||
if (matches.Count() > 0)
|
||||
{
|
||||
TestObject = matches.First();
|
||||
bFoundTestObject = true;
|
||||
}
|
||||
}
|
||||
if (!bFoundTestObject)
|
||||
{
|
||||
TestObject = (ISO13499FileDb.IsoDb.GetTestObjectByIso(template.TestObject));
|
||||
}
|
||||
TestObjectType = template.TestObjectType;
|
||||
OriginalTemplateName = template.OriginalTemplateName;
|
||||
Embedded = template.Embedded;
|
||||
|
||||
var channels = new List<TestObjectTemplateChannel>();
|
||||
foreach (var c in template.Channels)
|
||||
{
|
||||
channels.Add(new TestObjectTemplateChannel(c, /*ref db,*/ _template));
|
||||
}
|
||||
TemplateAllChannels = channels.ToArray();
|
||||
TemplateZones = template.Zones.Select(z => new Zone(z, this)).ToArray();
|
||||
TemplateParent = template.TemplateParent;
|
||||
SysBuilt = template.SysBuilt;
|
||||
}
|
||||
public TestObjectTemplate()
|
||||
{
|
||||
TemplateName = string.Empty;
|
||||
TemplateDescription = string.Empty;
|
||||
TemplateParent = string.Empty;
|
||||
|
||||
|
||||
switch (SerializedSettings.ISOSupportLevel)
|
||||
{
|
||||
case SerializedSettings.ISOSupportLevels.ISO_ONLY:
|
||||
TestObject = ISO13499FileDb.IsoDb.GetTestObjects(false).FirstOrDefault();
|
||||
break;
|
||||
case SerializedSettings.ISOSupportLevels.NO_ISO:
|
||||
//need to create a template just for this object!
|
||||
InitializeNonISO();
|
||||
break;
|
||||
case SerializedSettings.ISOSupportLevels.TRANSITORY:
|
||||
TestObject = ISO13499FileDb.IsoDb.GetTestObjects(false).FirstOrDefault();
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void InitializeNonISO()
|
||||
{
|
||||
//create template, set template channel type to NONISOTYPE
|
||||
TemplateName = (Guid.NewGuid()).ToString();
|
||||
|
||||
TestObject = GetNonISOTestObject();
|
||||
TestObjectType = NON_ISO_TESTOBJECT_CHANNEL_TYPE;
|
||||
}
|
||||
public Dictionary<string, string> GetValues()
|
||||
{
|
||||
var elementNameValuePairs = new Dictionary<string, string>();
|
||||
var isoTemplate = ToISOTestObjectTemplate();
|
||||
|
||||
elementNameValuePairs[GroupTemplateFields.TemplateName.ToString()] = isoTemplate.TemplateName;
|
||||
elementNameValuePairs[GroupTemplateFields.Icon.ToString()] = isoTemplate.Icon;
|
||||
elementNameValuePairs[GroupTemplateFields.Description.ToString()] = isoTemplate.Description;
|
||||
elementNameValuePairs[GroupTemplateFields.LocalOnly.ToString()] = isoTemplate.LocalOnly.ToString();
|
||||
elementNameValuePairs[GroupTemplateFields.Version.ToString()] = isoTemplate.Version.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[GroupTemplateFields.LastModifiedBy.ToString()] = /*isoTemplate.*/LastModifiedBy;
|
||||
elementNameValuePairs[GroupTemplateFields.LastModified.ToString()] = /*isoTemplate.*/LastModified.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[GroupTemplateFields.CRC32.ToString()] = isoTemplate.CRC32.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[GroupTemplateFields.TestObjectType.ToString()] = isoTemplate.TestObjectType;
|
||||
elementNameValuePairs[GroupTemplateFields.TestObject.ToString()] = isoTemplate.TestObject;
|
||||
elementNameValuePairs[GroupTemplateFields.ParentTemplate.ToString()] = isoTemplate.TemplateParent;
|
||||
elementNameValuePairs[GroupTemplateFields.SysBuilt.ToString()] = isoTemplate.SysBuilt.ToString();
|
||||
elementNameValuePairs[GroupTemplateFields.OriginalTemplateName.ToString()] = isoTemplate.OriginalTemplateName;
|
||||
elementNameValuePairs[GroupTemplateFields.Embedded.ToString()] = isoTemplate.Embedded.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
return elementNameValuePairs;
|
||||
}
|
||||
public Dictionary<string, string> GetTemplateChannelValues(TestObjectTemplateChannel channel)
|
||||
{
|
||||
var elementNameValuePairs = new Dictionary<string, string>();
|
||||
|
||||
elementNameValuePairs[GroupTemplateChannelFields.TestObjectNumber.ToString()] = channel.TestObjectNumber;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.NameOfTheChannel.ToString()] = channel.NameOfTheChannel;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.LaboratoryChannelCode.ToString()] = channel.LaboratoryCode;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.CustomerChannelCode.ToString()] = channel.CustomerChannelCode;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.Comments1.ToString()] = channel.Comments2;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.Location.ToString()] = channel.Location;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.Dimension.ToString()] = channel.Dimension;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.Direction.ToString()] = channel.Direction;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.ChannelFrequencyClass.ToString()] = channel.ChannelFrequencyClass;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.Unit.ToString()] = channel.Unit;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.ReferenceSystem.ToString()] = channel.ReferenceSystem;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.TransducerType.ToString()] = channel.TransducerType;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.TransducerId.ToString()] = channel.TransducerId;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.PreFilterType.ToString()] = channel.PreFilterType;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.CutOffFrequency.ToString()] = channel.CutOffFrequency;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.ChannelAmplitudeClass.ToString()] = channel.ChannelAmplitudeClass;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.ReferenceChannel.ToString()] = channel.ReferenceChannel.ToString();
|
||||
elementNameValuePairs[GroupTemplateChannelFields.ReferenceChannelName.ToString()] = channel.ReferenceChannelName;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.DataSource.ToString()] = channel.DataSource.ToString();
|
||||
elementNameValuePairs[GroupTemplateChannelFields.DataStatus.ToString()] = channel.DataStatus.ToString();
|
||||
elementNameValuePairs[GroupTemplateChannelFields.SamplingInterval.ToString()] = channel.SamplingInterval;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.BitResolution.ToString()] = channel.BitResolution;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.TimeOfFirstSample.ToString()] = channel.TimeOfFirstSample;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.NumberOfSamples.ToString()] = channel.NumberOfSamples;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.OffsetPostTest.ToString()] = channel.OffsetPostTest;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.TransducerNaturalFrequency.ToString()] = channel.TransducerNaturalFrequency;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.TransducerDampingRatio.ToString()] = channel.TransducerDampingRatio;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.Comments.ToString()] = channel.Comments1;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.FirstGlobalMaximumValue.ToString()] = channel.FirstGlobalMaximumValue;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.TimeOfMaximumValue.ToString()] = channel.TimeOfMaximumValue;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.FirstGlobalMinimumValue.ToString()] = channel.FirstGlobalMinimumValue;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.TimeOfMinimumValue.ToString()] = channel.TimeOfMinimumValue;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.StartOffsetInterval.ToString()] = channel.StartOffsetInterval;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.EndOffsetInterval.ToString()] = channel.EndOffsetInterval;
|
||||
elementNameValuePairs[GroupTemplateChannelFields.MMEChannelId.ToString()] = channel.Channel.Id.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[GroupTemplateChannelFields.MMEChannelType.ToString()] = channel.Channel.MMEChannelType.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[GroupTemplateChannelFields.Required.ToString()] = channel.Required.ToString();
|
||||
elementNameValuePairs[GroupTemplateChannelFields.DisplayOrder.ToString()] = channel.DisplayOrder.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[GroupTemplateChannelFields.LocalOnly.ToString()] = channel.LocalOnly.ToString();
|
||||
|
||||
return elementNameValuePairs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
Test.Module.Channel.Sensor.ZeroMethod.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
// *** see Test.cs ***
|
||||
public partial class Test
|
||||
{
|
||||
/// <summary>
|
||||
/// A container for DTS generic module concepts.
|
||||
/// </summary>
|
||||
public sealed partial class Module
|
||||
{
|
||||
// *** see Test.Module.Channel.cs ***
|
||||
public partial class Channel
|
||||
{
|
||||
//*** see Test.Module.Channel.Sensor.cs ***
|
||||
public partial class Sensor
|
||||
{
|
||||
/// <summary>
|
||||
/// All available zero method types.
|
||||
/// </summary>
|
||||
public enum ZeroMethodType
|
||||
{
|
||||
// Lots of legacy compatibility (e.g. importing GM ISF) depends on the order/value of this enum.
|
||||
|
||||
/// <summary>
|
||||
/// calculate electrical zero using an average over time
|
||||
/// </summary>
|
||||
[Description("Average Over Time")]
|
||||
AverageOverTime = 0,
|
||||
/// <summary>
|
||||
/// calculate zero using time in pre-event
|
||||
/// </summary>
|
||||
[Description("Use Diagnostics Zero")]
|
||||
UsePreEventDiagnosticsZero = 1,
|
||||
/// <summary>
|
||||
/// calculate zero using injected value
|
||||
/// </summary>
|
||||
[Description("Absolute Zero")]
|
||||
None = 2
|
||||
}
|
||||
/// <summary>
|
||||
/// Original version of all available zero method types.
|
||||
/// </summary>
|
||||
public enum OriginalZeroMethodType
|
||||
{
|
||||
/// <summary>
|
||||
/// calculate electrical zero using an average over time
|
||||
/// </summary>
|
||||
[Description("Average Over Time")]
|
||||
AverageOverTime,
|
||||
/// <summary>
|
||||
/// calculate zero using time in pre-event
|
||||
/// </summary>
|
||||
[Description("Use Diagnostics Zero")]
|
||||
UsePreCalZero,
|
||||
/// <summary>
|
||||
/// calculate zero using injected value
|
||||
/// </summary>
|
||||
[Description("Absolute Zero")]
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class MMEFineLocations3 : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string FINE_LOC_3 { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public string Picture_ShortName { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; }
|
||||
|
||||
public MMEFineLocations3(string sGuid, string fineLoc3, string textL1, string textL2, long version, DateTime date,
|
||||
string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText, string history, string picturesShortName,
|
||||
MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
FINE_LOC_3 = fineLoc3;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
Picture_ShortName = picturesShortName;
|
||||
}
|
||||
public static MMEFineLocations3[] GetFineLocations3()
|
||||
{
|
||||
var fineLocations3 = new List<MMEFineLocations3>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandType = CommandType.Text;
|
||||
cmd.CommandText = "SELECT * FROM MMEFineLocations3";
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string sFineLoc3 = ISOReader["FINE_LOC_3"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = Convert.ToInt64(ISOReader["VERSION"]);
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
string pictureShortName = ISOReader["PICTURE_SHORTNAME"].ToString();
|
||||
fineLocations3.Add(new MMEFineLocations3(sGuid, sFineLoc3, textL1, textL2, version, date,
|
||||
remarks, expired, sortkey, lastChange, lastChangeText, history, pictureShortName, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * FROM {0}", DbOperations.MMETables.MMEFineLocations3Table);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.MMETables.MMEFineLocations3Fields))
|
||||
.Cast<DbOperations.MMETables.MMEFineLocations3Fields>().ToArray();
|
||||
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
|
||||
var date = DateTime.Now;
|
||||
var expired = false;
|
||||
var fineLoc3 = "??";
|
||||
var history = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var lastChangeText = "";
|
||||
var pictureShortName = "";
|
||||
var remarks = "";
|
||||
var sGuid = "";
|
||||
var sortKey = "";
|
||||
var text1 = "";
|
||||
var text2 = "";
|
||||
var version = 0;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var o = dr[field.ToString()];
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.DATE:
|
||||
date = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.EXPIRED:
|
||||
expired = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.FINE_LOC_3:
|
||||
fineLoc3 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.HISTORY:
|
||||
history = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.LAST_CHANGE:
|
||||
lastChange = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.PICTURE_SHORTNAME:
|
||||
pictureShortName = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.REMARKS:
|
||||
remarks = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.s_GUID:
|
||||
sGuid = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.SORTKEY:
|
||||
sortKey = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.TEXT_L1:
|
||||
text1 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.TEXT_L2:
|
||||
text2 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFineLocations3Fields.VERSION:
|
||||
version = Convert.ToInt32(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
fineLocations3.Add(new MMEFineLocations3(sGuid.ToString(), fineLoc3, text1, text2, Convert.ToInt64(version), date, remarks, expired,
|
||||
sortKey, lastChange, lastChangeText, history, pictureShortName, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
return fineLocations3.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// Digital Inputs allow collected data to behave consistently with a digital data source
|
||||
/// the settings are for configuring firmware appropriately and for transforming data for consumption
|
||||
/// </summary>
|
||||
public class DigitalInputSetting : SensorData
|
||||
{
|
||||
/// <summary>
|
||||
/// constructor and copy constructor
|
||||
/// </summary>
|
||||
public DigitalInputSetting() : base()
|
||||
{
|
||||
SetDefaults(this);
|
||||
}
|
||||
public DigitalInputSetting(DigitalInputSetting copy)
|
||||
: base(copy)
|
||||
{
|
||||
SetDefaults(this);
|
||||
}
|
||||
public static void SetDefaults(SensorData sd)
|
||||
{
|
||||
sd.AxisNumber = 0;
|
||||
sd.NumberOfAxes = 1;
|
||||
sd.Capacity = 2400;
|
||||
sd.Bridge = Test.Module.Channel.Sensor.BridgeType.DigitalInput;
|
||||
sd.Capacity = 1;
|
||||
sd.DisplayUnit = "V";
|
||||
sd.BridgeResistance = double.NaN;
|
||||
sd.CheckOffset = false;
|
||||
sd.Manufacturer = "Generic";
|
||||
sd.OffsetToleranceHigh = 2500;
|
||||
sd.OffsetToleranceLow = 2500;
|
||||
sd.Model = "Digital Input Setting";
|
||||
sd.Shunt = ShuntMode.None;
|
||||
sd.MeasureExcitation = false;
|
||||
sd.MeasureNoise = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,541 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public abstract class SensorBase : TagAwareBase
|
||||
{
|
||||
public int CompareTo(SensorModel rhs)
|
||||
{
|
||||
if (null == Model) { Model = ""; }
|
||||
if (null == rhs.Model) { rhs.Model = ""; }
|
||||
return Model.CompareTo(rhs.Model);
|
||||
}
|
||||
|
||||
public virtual bool IsDigitalInput() { return Bridge == Test.Module.Channel.Sensor.BridgeType.DigitalInput; }
|
||||
|
||||
public virtual bool IsDigitalOutput() { return Bridge == Test.Module.Channel.Sensor.BridgeType.TOMDigital; }
|
||||
public virtual bool IsSquib() { return Bridge == Test.Module.Channel.Sensor.BridgeType.SQUIB; }
|
||||
public bool CheckOffset { get; set; } = true;
|
||||
public bool MeasureNoise { get; set; } = true;
|
||||
|
||||
public bool MeasureExcitation { get; set; } = true;
|
||||
|
||||
protected bool _invert = false;
|
||||
public bool Invert
|
||||
{
|
||||
get => _invert;
|
||||
set => _invert = value;
|
||||
}
|
||||
|
||||
public string Model { get; set; } = "";
|
||||
|
||||
public string Manufacturer { get; set; } = "";
|
||||
|
||||
protected string _UserPartNumber = "";
|
||||
public string UserPartNumber
|
||||
{
|
||||
get => _UserPartNumber;
|
||||
set => _UserPartNumber = value;
|
||||
}
|
||||
|
||||
public double Capacity { get; set; } = 2400D;
|
||||
public CouplingModes CouplingMode { get; set; } = CouplingModes.AC;
|
||||
|
||||
protected LowHigh _OffsetTolerance = new LowHigh(-100D, 100D);
|
||||
public double OffsetToleranceLow
|
||||
{
|
||||
get => _OffsetTolerance.Low;
|
||||
set => _OffsetTolerance.Low = value;
|
||||
}
|
||||
public double OffsetToleranceHigh
|
||||
{
|
||||
get => _OffsetTolerance.High;
|
||||
set => _OffsetTolerance.High = value;
|
||||
}
|
||||
|
||||
protected string _DisplayUnit = "";
|
||||
public virtual string DisplayUnit
|
||||
{
|
||||
get => _DisplayUnit;
|
||||
set => SetProperty(ref _DisplayUnit, value, SensorBaseFields.MeasurementUnit.ToString());
|
||||
}
|
||||
protected SensorRange _Range = new SensorRange(10D, 100D, 1000D);
|
||||
public double RangeLow
|
||||
{
|
||||
get => 0 == _Range.Low ? Capacity : _Range.Low;
|
||||
set => _Range.Low = value;
|
||||
}
|
||||
public double RangeMedium
|
||||
{
|
||||
get => 0 == _Range.Medium ? Capacity : _Range.Medium;
|
||||
set => _Range.Medium = value;
|
||||
}
|
||||
public double RangeHigh
|
||||
{
|
||||
get => 0 == _Range.High ? Capacity : _Range.High;
|
||||
set => _Range.High = value;
|
||||
}
|
||||
|
||||
protected List<Test.Module.Channel.Sensor.ExcitationVoltageOption> _supportedExcitation = new List<Test.Module.Channel.Sensor.ExcitationVoltageOption>(
|
||||
new[] { Test.Module.Channel.Sensor.ExcitationVoltageOption.Volt5 });
|
||||
public Test.Module.Channel.Sensor.ExcitationVoltageOption[] SupportedExcitation
|
||||
{
|
||||
get => _supportedExcitation.ToArray();
|
||||
set => _supportedExcitation = new List<Test.Module.Channel.Sensor.ExcitationVoltageOption>(value);
|
||||
}
|
||||
//sensor models shouldn't have a cal date, but this is the min cal date we can use and not cause problems unintentionally somewhere else
|
||||
protected SensorCalibration _calibration = new SensorCalibration();
|
||||
public virtual SensorCalibration Calibration
|
||||
{
|
||||
get => _calibration;
|
||||
set => _calibration = value;
|
||||
}
|
||||
|
||||
public Test.Module.Channel.Sensor.BridgeType Bridge { get; set; } = Test.Module.Channel.Sensor.BridgeType.FullBridge;
|
||||
|
||||
public ShuntMode Shunt { get; set; } = ShuntMode.Emulation;
|
||||
|
||||
public double BridgeResistance { get; set; } = 350D;
|
||||
|
||||
protected FilterClass _Filter = new FilterClass(FilterClass.FilterClassType.CFC1000);
|
||||
public FilterClass Filter
|
||||
{
|
||||
get => _Filter;
|
||||
set => _Filter = value;
|
||||
}
|
||||
public bool UniPolar { get; set; } = false;
|
||||
|
||||
public bool IgnoreRange { get; set; } = false;
|
||||
|
||||
protected string _lastUpdatedBy;
|
||||
public string LastUpdatedBy
|
||||
{
|
||||
get => _lastUpdatedBy;
|
||||
set => SetProperty(ref _lastUpdatedBy, value, "LastUpdatedBy");
|
||||
}
|
||||
|
||||
public int Version { get; set; } = 1;
|
||||
|
||||
protected bool _localOnly = false;
|
||||
public bool LocalOnly => _localOnly;
|
||||
public void SetLocalOnly(bool bLocalOnly) { _localOnly = bLocalOnly; }
|
||||
|
||||
public short AxisNumber { get; set; } = 0;
|
||||
|
||||
public short NumberOfAxes { get; set; } = 1;
|
||||
|
||||
public int CalInterval { get; set; } = 365;
|
||||
public string Polarity
|
||||
{
|
||||
get => _invert ? "-" : "+";
|
||||
set => Invert = value == "-";
|
||||
}
|
||||
|
||||
public DateTime LastModified { get; set; } = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
|
||||
|
||||
protected IsoCode _isoCode = new IsoCode("");
|
||||
public string ISOCode
|
||||
{
|
||||
get => _isoCode.StringRepresentation;
|
||||
set => _isoCode = new IsoCode(value);
|
||||
}
|
||||
|
||||
public string PhysicalDimension
|
||||
{
|
||||
get => _isoCode.PhysicalDimension;
|
||||
set => _isoCode.PhysicalDimension = value;
|
||||
}
|
||||
|
||||
public string Direction
|
||||
{
|
||||
get => _isoCode.Direction;
|
||||
set => _isoCode.Direction = value;
|
||||
}
|
||||
|
||||
|
||||
public bool DoNotUse { get; set; } = false;
|
||||
|
||||
public bool Broken { get; set; } = false;
|
||||
|
||||
|
||||
public enum SensorBaseFields
|
||||
{
|
||||
CheckOffset,
|
||||
Invert,
|
||||
Model,
|
||||
Manufacturer,
|
||||
UserPartNumber,
|
||||
Capacity,
|
||||
CouplingMode,
|
||||
OffsetToleranceLow,
|
||||
OffsetToleranceHigh,
|
||||
MeasurementUnit,
|
||||
RangeLow,
|
||||
RangeMedium,
|
||||
RangeHigh,
|
||||
SupportedExcitation,
|
||||
Calibration,
|
||||
Bridge,
|
||||
Shunt,
|
||||
BridgeResistance,
|
||||
Filter,
|
||||
UniPolar,
|
||||
IgnoreRange,
|
||||
LastUpdatedBy,
|
||||
Version,
|
||||
LocalOnly,
|
||||
AxisNumber,
|
||||
NumberOfAxes,
|
||||
CalInterval,
|
||||
Polarity,
|
||||
LastModified,
|
||||
ISOCode,
|
||||
PhysicalDimension,
|
||||
Direction,
|
||||
Broken,
|
||||
DoNotUse
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// modifies an isocode's Filter Class based on a sensor's Filter if the isocode's Filter Class is "?"
|
||||
/// FB 8037 - sensor's default filter not displayed after SIF import
|
||||
/// </summary>
|
||||
/// <param name="importingIsoCode">the starting ISO code which may or may not already have a filter</param>
|
||||
/// <param name="sensorFilterClass">the sensor's filter class to be used if the channel doesn't already have one</param>
|
||||
/// <returns>a string representation of the ISO code with a non-'?' Filter Class if the sensor's Filter is one of the ISO values</returns>
|
||||
public string BuildIsoCodeFromFilter(string importingIsoCode, FilterClass.FilterClassType sensorFilterClass)
|
||||
{
|
||||
var isoCodeWithFilter = new IsoCode(importingIsoCode);
|
||||
if (isoCodeWithFilter.FilterClass == "?")
|
||||
{
|
||||
isoCodeWithFilter.FilterClass = FClassToIsoFilterCode(sensorFilterClass);
|
||||
};
|
||||
return isoCodeWithFilter.StringRepresentation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns the ISO Code for a Filter Class
|
||||
/// </summary>
|
||||
private string FClassToIsoFilterCode(FilterClass.FilterClassType fClass)
|
||||
{
|
||||
var isoFilterCode = "?";
|
||||
|
||||
switch (fClass)
|
||||
{
|
||||
case FilterClass.FilterClassType.CFC1000:
|
||||
isoFilterCode = "A";
|
||||
break;
|
||||
case FilterClass.FilterClassType.CFC600:
|
||||
isoFilterCode = "B";
|
||||
break;
|
||||
case FilterClass.FilterClassType.CFC180:
|
||||
isoFilterCode = "C";
|
||||
break;
|
||||
case FilterClass.FilterClassType.CFC60:
|
||||
isoFilterCode = "D";
|
||||
break;
|
||||
case FilterClass.FilterClassType.None:
|
||||
isoFilterCode = "P";
|
||||
break;
|
||||
//FB 13120 add AdHoc
|
||||
case FilterClass.FilterClassType.AdHoc:
|
||||
isoFilterCode = "S";
|
||||
break;
|
||||
case FilterClass.FilterClassType.CFC10:
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("fClass", fClass, null);
|
||||
}
|
||||
return isoFilterCode;
|
||||
}
|
||||
|
||||
}
|
||||
public class SensorModel : SensorBase, IComparable<SensorModel>
|
||||
{
|
||||
public override string LookupTable => DbOperations.SensorDB.SensorModelsTable;
|
||||
|
||||
public override ConstraintHelper[] GetConstraints()
|
||||
{
|
||||
return new ConstraintHelper[]
|
||||
{
|
||||
new ConstraintHelper()
|
||||
{
|
||||
ColumnName = DbOperations.SensorDB.SensorModelFields.Model.ToString(),
|
||||
DbType = System.Data.SqlDbType.NVarChar,
|
||||
DbValue = Model
|
||||
},
|
||||
new ConstraintHelper()
|
||||
{
|
||||
ColumnName = DbOperations.SensorDB.SensorModelFields.Manufacturer.ToString(),
|
||||
DbType = System.Data.SqlDbType.NVarChar,
|
||||
DbValue = Manufacturer
|
||||
}
|
||||
};
|
||||
}
|
||||
public Dictionary<string, string> GetValues()
|
||||
{
|
||||
var elementNameValuePairs =
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
[DbOperations.SensorDB.SensorModelFields.Model.ToString()] = Model,
|
||||
[DbOperations.SensorDB.SensorModelFields.Manufacturer.ToString()] = Manufacturer,
|
||||
[DbOperations.SensorDB.SensorModelFields.UserPartNumber.ToString()] = UserPartNumber,
|
||||
[DbOperations.SensorDB.SensorModelFields.Capacity.ToString()] = Capacity.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.OffsetToleranceLow.ToString()] = OffsetToleranceLow.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.OffsetToleranceHigh.ToString()] = OffsetToleranceHigh.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.MeasurementUnit.ToString()] = DisplayUnit,
|
||||
[DbOperations.SensorDB.SensorModelFields.Bridge.ToString()] = Bridge.ToString(),
|
||||
[DbOperations.SensorDB.SensorModelFields.Shunt.ToString()] = Shunt.ToString(),
|
||||
[DbOperations.SensorDB.SensorModelFields.BridgeResistance.ToString()] = BridgeResistance.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.FilterClass.ToString()] = Filter.ToString(),
|
||||
[DbOperations.SensorDB.SensorModelFields.UniPolar.ToString()] = UniPolar.ToString(),
|
||||
[DbOperations.SensorDB.SensorModelFields.IgnoreRange.ToString()] = IgnoreRange.ToString(),
|
||||
[DbOperations.SensorDB.SensorModelFields.CouplingMode.ToString()] = CouplingMode.ToString(),
|
||||
[DbOperations.SensorDB.SensorModelFields.Version.ToString()] = Version.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.RangeLow.ToString()] = RangeLow.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.RangeAve.ToString()] = RangeMedium.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.RangeHigh.ToString()] = RangeHigh.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.LastModified.ToString()] = LastModified.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.ModifiedBy.ToString()] = LastUpdatedBy,
|
||||
[DbOperations.SensorDB.SensorModelFields.LocalOnly.ToString()] = LocalOnly.ToString(),
|
||||
[DbOperations.SensorDB.SensorModelFields.NumberOfAxes.ToString()] = NumberOfAxes.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.CalInterval.ToString()] = CalInterval.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.AxisNumber.ToString()] = AxisNumber.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
[DbOperations.SensorDB.SensorModelFields.Polarity.ToString()] = Polarity,
|
||||
[DbOperations.SensorDB.SensorModelFields.Invert.ToString()] = Invert.ToString(),
|
||||
[DbOperations.SensorDB.SensorModelFields.CheckOffset.ToString()] = CheckOffset.ToString(),
|
||||
[DbOperations.SensorDB.SensorModelFields.CalibrationRecord.ToString()] = Calibration.ToSerializedString(),
|
||||
[DbOperations.SensorDB.SensorModelFields.ISOCode.ToString()] = ISOCode
|
||||
};
|
||||
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorModelFields.SupportedExcitation.ToString()] = string.Join(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, SupportedExcitation.Select(se => se.ToString()).ToArray());
|
||||
|
||||
return elementNameValuePairs;
|
||||
}
|
||||
private Test.Module.Channel.Sensor.BridgeType ConvertToBridge(int bridge)
|
||||
{
|
||||
switch (bridge)
|
||||
{
|
||||
case 0: return Test.Module.Channel.Sensor.BridgeType.IEPE;
|
||||
case 3: return Test.Module.Channel.Sensor.BridgeType.FullBridge;
|
||||
case 2: return Test.Module.Channel.Sensor.BridgeType.HalfBridge;
|
||||
case 1: return Test.Module.Channel.Sensor.BridgeType.QuarterBridge;
|
||||
default: return Test.Module.Channel.Sensor.BridgeType.FullBridge;
|
||||
}
|
||||
}
|
||||
|
||||
internal SensorModel(System.Data.DataRow dr)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.SensorDB.SensorModelFields))
|
||||
.Cast<DbOperations.SensorDB.SensorModelFields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.SensorDB.SensorModelFields.Polarity:
|
||||
Polarity = (string)dr[field.ToString()];
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.AxisNumber:
|
||||
AxisNumber = Convert.ToInt16(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.Bridge:
|
||||
Bridge = ConvertToBridge(Convert.ToInt32(dr[field.ToString()]));
|
||||
//Bridge = (Test.Module.Channel.Sensor.BridgeType)Convert.ToInt32(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.BridgeResistance:
|
||||
BridgeResistance = Convert.ToDouble(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.CalInterval:
|
||||
CalInterval = Convert.ToInt32(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.Capacity:
|
||||
Capacity = Convert.ToDouble(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.CouplingMode:
|
||||
CouplingMode = (CouplingModes)Convert.ToInt32(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.FilterClass:
|
||||
Filter = new FilterClass((string)dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.IgnoreRange:
|
||||
IgnoreRange = Convert.ToBoolean(dr[field.ToString()]);
|
||||
break;
|
||||
/*case Storage.DbOperations.SensorDB.SensorModelFields.InitialEU:
|
||||
InitialEU = Convert.ToDouble(dr[field.ToString()]);
|
||||
break;*/
|
||||
case DbOperations.SensorDB.SensorModelFields.CheckOffset:
|
||||
CheckOffset = Convert.ToBoolean(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.Invert:
|
||||
Invert = Convert.ToBoolean(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.LastModified:
|
||||
LastModified = (DateTime)dr[field.ToString()];
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.LocalOnly:
|
||||
SetLocalOnly(Convert.ToBoolean(dr[field.ToString()]));
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.Manufacturer:
|
||||
Manufacturer = (string)dr[field.ToString()];
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.MeasurementUnit:
|
||||
DisplayUnit = (string)dr[field.ToString()];
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.Model:
|
||||
Model = (string)dr[field.ToString()];
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.ModifiedBy:
|
||||
LastUpdatedBy = (string)dr[field.ToString()];
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.NumberOfAxes:
|
||||
NumberOfAxes = Convert.ToInt16(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.OffsetToleranceHigh:
|
||||
OffsetToleranceHigh = Convert.ToDouble(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.OffsetToleranceLow:
|
||||
OffsetToleranceLow = Convert.ToDouble(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.RangeAve:
|
||||
RangeMedium = Convert.ToDouble(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.RangeHigh:
|
||||
RangeHigh = Convert.ToDouble(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.RangeLow:
|
||||
RangeLow = Convert.ToDouble(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.Shunt:
|
||||
Shunt = (ShuntMode)Convert.ToInt32(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.UniPolar:
|
||||
UniPolar = Convert.ToBoolean(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.UserPartNumber:
|
||||
UserPartNumber = (string)dr[field.ToString()];
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.Version:
|
||||
Version = Convert.ToInt32(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.ISOCode:
|
||||
ISOCode = (string)dr[field.ToString()];
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.CalibrationRecord:
|
||||
Calibration = new SensorCalibration((string)dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorModelFields.SupportedExcitation:
|
||||
{
|
||||
var options = new List<Test.Module.Channel.Sensor.ExcitationVoltageOption>();
|
||||
var tokens = ((string)dr[field.ToString()]).Split(new string[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
if (Enum.TryParse(token, out Test.Module.Channel.Sensor.ExcitationVoltageOption option)) { options.Add(option); }
|
||||
}
|
||||
|
||||
SupportedExcitation = options.ToArray();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("Unknown field: " + field);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to process field: ", field, "exception: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class SensorModelCollection //: INotifyPropertyChanged
|
||||
{
|
||||
private Dictionary<string, Dictionary<string, SensorModel>> _sensorModels = new Dictionary<string, Dictionary<string, SensorModel>>();
|
||||
private static void PopulateCollection()
|
||||
{
|
||||
if (null == _collection)
|
||||
{
|
||||
_collection = new SensorModelCollection();
|
||||
}
|
||||
else
|
||||
{
|
||||
_collection._sensorModels.Clear();
|
||||
}
|
||||
_collection.LoadAllSensorModels();
|
||||
}
|
||||
private static SensorModelCollection _collection = null;
|
||||
public static SensorModelCollection SensorModelList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (null == _collection)
|
||||
{
|
||||
PopulateCollection();
|
||||
}
|
||||
return _collection;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static object _lock = new object();
|
||||
public SensorModel[] SensorModels
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
var l = new List<SensorModel>();
|
||||
var e = _sensorModels.GetEnumerator();
|
||||
while (e.MoveNext())
|
||||
{
|
||||
var e2 = e.Current.Value.GetEnumerator();
|
||||
while (e2.MoveNext())
|
||||
{
|
||||
l.Add(e2.Current.Value);
|
||||
}
|
||||
}
|
||||
return l.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
protected void LoadAllSensorModels()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * FROM [{0}]", DbOperations.SensorDB.SensorModelsTable);
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sm = new SensorModel(dr);
|
||||
if (!_sensorModels.ContainsKey(sm.Manufacturer)) { _sensorModels.Add(sm.Manufacturer, new Dictionary<string, SensorModel>()); }
|
||||
if (!_sensorModels[sm.Manufacturer].ContainsKey(sm.Model))
|
||||
{
|
||||
_sensorModels[sm.Manufacturer].Add(sm.Model, sm);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to process a row in the database: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to retrieve sensor models, ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// list of all non columned test settings
|
||||
/// </summary>
|
||||
public enum TestSettingsEnum
|
||||
{
|
||||
ArmCheckListStep,
|
||||
CheckListInputVoltageCheck,
|
||||
CheckListBatteryVoltageCheck,
|
||||
CheckListSquibResistanceCheck,
|
||||
CheckListSensorIDCheck,
|
||||
CheckListTriggerStartCheck,
|
||||
EW,//ExcitationWarmup
|
||||
CheckListMustPass
|
||||
}
|
||||
public enum RecordingModes
|
||||
{
|
||||
CircularBuffer,
|
||||
Recorder,
|
||||
HybridRecorder
|
||||
}
|
||||
public enum IsoChannelSensorCompatibilityLevels
|
||||
{
|
||||
DontWarn,
|
||||
Warn,
|
||||
DontAllow
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum SupportedExportFormatBitFlags
|
||||
{
|
||||
none = 0x0,
|
||||
csvunfiltered = 0x1,
|
||||
diademadc = 0x2,
|
||||
isounfiltered = 0x4,
|
||||
somatunfiltered = 0x8,
|
||||
tdmsadc = 0x10,
|
||||
toyotaunfiltered = 0x20,
|
||||
tsvunfiltered = 0x40,
|
||||
csvfiltered = 0x80,
|
||||
//diademfiltered = 0x100, //unused & available
|
||||
isofiltered = 0x200,
|
||||
somatfiltered = 0x400,
|
||||
tdasadc = 0x800,
|
||||
toyotafiltered = 0x1000,
|
||||
tsvfiltered = 0x2000,
|
||||
rdfadc = 0x4000,
|
||||
ChryslerDDAS = 0x8000,
|
||||
HDFUnfiltered = 0x10000,
|
||||
HDFFiltered = 0x20000,
|
||||
HDFMV = 0x40000,
|
||||
HDFADC = 0x80000,
|
||||
xlsxfiltered = 0x100000,
|
||||
xlsxunfiltered = 0x200000
|
||||
}
|
||||
|
||||
public enum TestTemplateTags
|
||||
{
|
||||
UploadData,
|
||||
UploadFolder,
|
||||
CommonLine,
|
||||
AllCustomers,
|
||||
AllTestEngineers,
|
||||
AllLabs,
|
||||
Test,
|
||||
AllowMissingSensors,
|
||||
AllowSensorIdToBlankChannel,
|
||||
AutomaticProgression,
|
||||
AutomaticProgressionDelayMS,
|
||||
InvertTriggerCompletion,
|
||||
TriggerCheckStep,
|
||||
PostTestDiagnostics,
|
||||
TriggerCheckRealtime,
|
||||
InvertStartRecordCompletion,
|
||||
ViewDiagnostics,
|
||||
VerifyChannels,
|
||||
AutoVerifyProgress,
|
||||
AutoVerifyDelaySeconds,
|
||||
TestGraphs,
|
||||
GraphCount,
|
||||
Name,
|
||||
TestId,
|
||||
SetupFile,
|
||||
Description,
|
||||
AvailableTestObjects,
|
||||
SamplesPerSecond,
|
||||
SampleRateText,
|
||||
PreTriggerSeconds,
|
||||
PostTriggerSeconds,
|
||||
RecordingMode,
|
||||
RecordingModeText,
|
||||
StrictDiagnostics,
|
||||
TestObjects,
|
||||
AllTestObjects,
|
||||
SysBuiltTestObjects,
|
||||
RequireUserConfirmationOnErrors,
|
||||
DoROIDownload,
|
||||
ROIButtonVisibility,
|
||||
ViewROIDownload,
|
||||
ViewROIDownloadButtonVisibility,
|
||||
DownloadAll,
|
||||
DownloadAllButtonVisibility,
|
||||
ViewRealtime,
|
||||
ViewRealtimeButtonVisibility,
|
||||
ROIStart,
|
||||
ROIEnd,
|
||||
ViewDownloadAll,
|
||||
ViewDownloadAllButtonVisibility,
|
||||
ViewExport,
|
||||
ViewExportButtonVisibility,
|
||||
ExportFormats,
|
||||
DownloadFolder,
|
||||
ExportFolder,
|
||||
SameAsDownloadFolder,
|
||||
TestTime,
|
||||
LabDetails,
|
||||
CustomerDetails,
|
||||
TestEngineerDetails,
|
||||
DefaultNumberRealtimeGraphs,
|
||||
GraphDetailsVisibility,
|
||||
CurrentGraph,
|
||||
UseCustomerDetails,
|
||||
UseTestEngineerDetails,
|
||||
TurnOffExcitation,
|
||||
UseLabratoryDetails,
|
||||
TestDirectory,
|
||||
OriginalTestDirectory,
|
||||
LocalOnly,
|
||||
LastModified,
|
||||
LastMmodifiedBy,
|
||||
ExpressTestSetup,
|
||||
EW,
|
||||
ExcitationWarmupTimeMS,
|
||||
ArmCheckListStep,
|
||||
CheckListBatteryVoltageCheck,
|
||||
CheckListInputVoltageCheck,
|
||||
CheckListSquibResistanceCheck,
|
||||
CheckListSensorIDCheck,
|
||||
CheckListTriggerStartCheck,
|
||||
CheckListMustPass,
|
||||
WarnOnFailedBattery,
|
||||
HardwareOverrides,
|
||||
DoAutoArm,
|
||||
DoStreaming,
|
||||
SysBuiltTestObjectTypes,
|
||||
AddedGroupRemoved,
|
||||
CheckoutMode,
|
||||
QuitTestWithoutWarning,
|
||||
SuppressMissingSensorsWarning,
|
||||
ISFFile,
|
||||
TestObjectsAndAddedGroups,
|
||||
NotAllChannelsRealTime,
|
||||
NotAllChannelsViewer,
|
||||
GroupsStepValid
|
||||
}
|
||||
public enum StrictLevel
|
||||
{
|
||||
Strict,
|
||||
UpdateTable
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class MMEFigures : AbstractOLEDbWrapper
|
||||
{
|
||||
public long ID { get; }
|
||||
|
||||
public string TxtShortName { get; }
|
||||
|
||||
public string TxtDescription { get; }
|
||||
|
||||
public string TxtRemarks { get; }
|
||||
|
||||
public DateTime DatRevision { get; }
|
||||
|
||||
public long IntAuthor { get; }
|
||||
|
||||
public ushort IntPage { get; }
|
||||
|
||||
public ushort IntPages { get; }
|
||||
|
||||
public string TxtImageFile { get; }
|
||||
|
||||
public long IntVersion { get; }
|
||||
|
||||
public bool BolExpired { get; }
|
||||
|
||||
public string TxtSortKey { get; }
|
||||
|
||||
public bool BitStdPath { get; }
|
||||
|
||||
public long IntIDStdPath { get; }
|
||||
|
||||
public string TxtPath { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEFigures(long id, string txtShortName, string txtDescription, string txtRemarks, DateTime datRevision, long intAuthor,
|
||||
ushort intPage, ushort intPages, string txtImageFile, long version, bool bExpired, string txtSortKey,
|
||||
bool bitStdPath, long intIDStdPath, string txtPath, DateTime lastChange, string lastChangeText, string history)
|
||||
{
|
||||
ID = id;
|
||||
TxtShortName = txtShortName;
|
||||
TxtDescription = txtDescription;
|
||||
TxtRemarks = txtRemarks;
|
||||
DatRevision = datRevision;
|
||||
IntAuthor = intAuthor;
|
||||
IntPage = intPage;
|
||||
IntPages = intPages;
|
||||
TxtImageFile = txtImageFile;
|
||||
IntVersion = version;
|
||||
BolExpired = bExpired;
|
||||
TxtSortKey = txtSortKey;
|
||||
BitStdPath = bitStdPath;
|
||||
IntIDStdPath = intIDStdPath;
|
||||
TxtPath = txtPath;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
|
||||
}
|
||||
public static MMEFigures[] GetFigures()
|
||||
{
|
||||
var figures = new List<MMEFigures>();
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMEFIGURES";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
var id = Convert.ToInt64(ISOReader["ID"]);
|
||||
var txtShortName = ISOReader["txtShortName"].ToString();
|
||||
var txtDescription = ISOReader["txtDescription"].ToString();
|
||||
var txtRemarks = ISOReader["txtRemarks"].ToString();
|
||||
var datRevision = DateTime.MinValue;
|
||||
if (!DBNull.Value.Equals(ISOReader["datRevision"]))
|
||||
{
|
||||
datRevision = (DateTime)ISOReader["datRevision"];
|
||||
}
|
||||
var intAuthor = Convert.ToInt64(ISOReader["intAuthor"]);
|
||||
var intPage = Convert.ToUInt16(ISOReader["intPage"]);
|
||||
var intPages = Convert.ToUInt16(ISOReader["intPages"]);
|
||||
var txtImageFile = ISOReader["txtImageFile"].ToString();
|
||||
var version = Convert.ToInt64(ISOReader["intVersion"]);
|
||||
var bExpired = (bool)ISOReader["bolExpired"];
|
||||
var txtSortKey = ISOReader["txtSortKey"].ToString();
|
||||
var bitStdPath = (bool)ISOReader["bitStdPath"];
|
||||
var intIDStdPath = Convert.ToInt64(ISOReader["IntIDStdPath"]);
|
||||
var txtPath = ISOReader["txtPath"].ToString();
|
||||
var lastChange = DateTime.MinValue;
|
||||
if (!DBNull.Value.Equals(ISOReader["LAST_CHANGE"]))
|
||||
{
|
||||
datRevision = (DateTime)ISOReader["LAST_CHANGE"];
|
||||
}
|
||||
var lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
var history = ISOReader["HISTORY"].ToString();
|
||||
figures.Add(new MMEFigures(id, txtShortName, txtDescription, txtRemarks, datRevision, intAuthor, intPage,
|
||||
intPages, txtImageFile, version, bExpired, txtSortKey, bitStdPath, intIDStdPath, txtPath, lastChange,
|
||||
lastChangeText, history));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
ISOReader.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
return figures.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// the scaler is a bit different than an ordinary scaler, so the name here is inaccurate, however the idea is
|
||||
/// that we allow the user to transform collected data, primarly by allowing them to define the 0,1 value of the digital output
|
||||
/// </summary>
|
||||
public class DigitalInputScaleMultiplier
|
||||
{
|
||||
/// <summary>
|
||||
/// these are the different input modes for the data
|
||||
/// </summary>
|
||||
public enum InputModes
|
||||
{
|
||||
TLH = 1 << 1, //Transition Low to High
|
||||
THL = 1 << 2, //Transition High to Low
|
||||
CCNO = 1 << 3, //set to contact closure normally open
|
||||
CCNC = 1 << 4 //set to contact closure normally closed
|
||||
}
|
||||
/// <summary>
|
||||
/// the format the scaler is in
|
||||
/// </summary>
|
||||
public enum Forms { ArbitraryLowAndHigh };
|
||||
|
||||
public Forms Form { get; set; } = Forms.ArbitraryLowAndHigh;
|
||||
|
||||
// /// <summary>
|
||||
// /// for arbirary low/high, this is the low value, the value 0 should be displayed as (OFF)
|
||||
// /// </summary>
|
||||
public double DefaultValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// for arbitrary low/high, this is the high value, the value 1 should be displayed as (ON)
|
||||
/// </summary>
|
||||
public double ActiveValue { get; set; } = 1D;
|
||||
|
||||
// public bool SimpleEquals(DigitalInputScaleMultiplier rhs)
|
||||
// {
|
||||
// return Form == rhs.Form && DefaultValue == rhs.DefaultValue && ActiveValue == rhs.ActiveValue;
|
||||
// }
|
||||
// public override bool Equals(object obj)
|
||||
// {
|
||||
// if (obj is DigitalInputScaleMultiplier)
|
||||
// {
|
||||
// var b = obj as DigitalInputScaleMultiplier;
|
||||
// return b.Form == Form
|
||||
// && b.ActiveValue == ActiveValue
|
||||
// && b.DefaultValue == DefaultValue;
|
||||
// }
|
||||
// else { return false; }
|
||||
// }
|
||||
|
||||
// public override int GetHashCode()
|
||||
// {
|
||||
// //the idea here is to use two primes to avoid collisions, it's not perfect but should work in general and we can predict when it won't
|
||||
// if (ActiveValue == 31 || DefaultValue == 31 || DefaultValue == 79 || ActiveValue == 79)
|
||||
// {
|
||||
// return (int)Form + Convert.ToInt32(ActiveValue * 127) + Convert.ToInt32(DefaultValue * 23);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return (int)Form + Convert.ToInt32(ActiveValue * 31) + Convert.ToInt32(DefaultValue * 79);
|
||||
// }
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// constructor and copy constructor
|
||||
// /// </summary>
|
||||
public DigitalInputScaleMultiplier()
|
||||
{
|
||||
DefaultValue = 0D;
|
||||
}
|
||||
|
||||
public DigitalInputScaleMultiplier(DigitalInputScaleMultiplier copy)
|
||||
{
|
||||
Form = copy.Form;
|
||||
DefaultValue = copy.DefaultValue;
|
||||
ActiveValue = copy.ActiveValue;
|
||||
}
|
||||
/// <summary>
|
||||
/// serializes scaler to a string
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ToSerializeDbString()
|
||||
{
|
||||
switch (Form)
|
||||
{
|
||||
case Forms.ArbitraryLowAndHigh: return ToSerializeDbStringLowAndHigh();
|
||||
default: throw new NotSupportedException("DigitalScaleMultiplier::ToSerializeDbString unsupported form: " + Form.ToString());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// serializes an ArbitraryLowHigh to a string
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string ToSerializeDbStringLowAndHigh() { return string.Format("{1}{0}{2}{0}{3}", System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, Form.ToString(), DefaultValue.ToString(System.Globalization.CultureInfo.InvariantCulture), ActiveValue.ToString(System.Globalization.CultureInfo.InvariantCulture)); }
|
||||
// /// <summary>
|
||||
// /// deserializes an arbitrary low/high from a string
|
||||
// /// </summary>
|
||||
// /// <param name="tokens"></param>
|
||||
// private void FromDbSerializeStringLowAndHigh(string[] tokens)
|
||||
// {
|
||||
// if (tokens.Length < 3) { throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeStringLowAndHigh invalid format for scale multiplier"); }
|
||||
// double d;
|
||||
// if (double.TryParse(tokens[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
||||
// {
|
||||
// DefaultValue = d;
|
||||
// }
|
||||
// else { throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeStringLowAndHigh invalid format for low value: " + tokens[1]); }
|
||||
|
||||
// if (double.TryParse(tokens[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
||||
// {
|
||||
// ActiveValue = d;
|
||||
// }
|
||||
// else { throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeStringLowAndHigh invalid format for high value: " + tokens[2]); }
|
||||
// }
|
||||
/// <summary>
|
||||
/// deserializes a scaler from a string, regardless of format
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
public void FromDbSerializeString(string s)
|
||||
{
|
||||
if (null == s)
|
||||
{
|
||||
//Utilities.Logging.APILogger.Log("Unable to serialize Db. String is null.");
|
||||
|
||||
//FIXME is this the right thing to do?
|
||||
return;
|
||||
//throw new NotSupportedException("DigitalINputScaleMultiplier::FromDbSerializeString nothing to parse");
|
||||
}
|
||||
|
||||
// string[] tokens = s.Split(new[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
// Forms form;
|
||||
// if (Enum.TryParse(tokens[0], out form))
|
||||
// {
|
||||
// Form = form;
|
||||
// switch (form)
|
||||
// {
|
||||
// case Forms.ArbitraryLowAndHigh: FromDbSerializeStringLowAndHigh(tokens); break;
|
||||
// default: throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeString unsupported form " + form.ToString());
|
||||
// }
|
||||
// }
|
||||
// else { throw new NotSupportedException("DigitalINputScaleMultiplier::FromDbSerializeString unsupported format: " + s); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class SquibSetting : SensorData
|
||||
{
|
||||
public string SquibDescription
|
||||
{
|
||||
get => SerialNumber;
|
||||
set { SerialNumber = value; OnPropertyChanged("SquibDescription"); }
|
||||
}
|
||||
|
||||
private bool _bypassCurrentFilter = false;
|
||||
public bool BypassCurrentFilter
|
||||
{
|
||||
get => _bypassCurrentFilter;
|
||||
set => SetProperty(ref _bypassCurrentFilter, value, "BypassCurrentFilter");
|
||||
}
|
||||
|
||||
private bool _bypassVoltageFilter = false;
|
||||
public bool BypassVoltageFilter
|
||||
{
|
||||
get => _bypassVoltageFilter;
|
||||
set => SetProperty(ref _bypassVoltageFilter, value, "BypassVoltageFilter");
|
||||
}
|
||||
|
||||
public string ArticleId
|
||||
{
|
||||
get => Id;
|
||||
set { Id = value; OnPropertyChanged("ArticleId"); }
|
||||
}
|
||||
public static void SetDefaults(SensorData sd)
|
||||
{
|
||||
sd.AxisNumber = 0;
|
||||
sd.Capacity = 5;
|
||||
sd.NumberOfAxes = 1;
|
||||
sd.Manufacturer = "Generic";
|
||||
sd.Model = "Squib Setting";
|
||||
sd.Shunt = ShuntMode.None;
|
||||
sd.CheckOffset = false;
|
||||
sd.BridgeResistance = -1;
|
||||
sd.MeasureNoise = false;
|
||||
sd.MeasureExcitation = false;
|
||||
sd.Bridge = Test.Module.Channel.Sensor.BridgeType.SQUIB;
|
||||
sd.SupportedExcitation = new Test.Module.Channel.Sensor.ExcitationVoltageOption[] { Test.Module.Channel.Sensor.ExcitationVoltageOption.Volt5 };
|
||||
sd.DisplayUnit = "V";
|
||||
sd.Comment = string.IsNullOrWhiteSpace(sd.UserValue1) ? sd.SerialNumber : sd.UserValue1;
|
||||
}
|
||||
|
||||
public SquibSetting(System.Data.DataRow dr)
|
||||
{
|
||||
SetDefaults(this);
|
||||
var fields = Enum.GetValues(typeof(DbOperations.Squib.Fields)).Cast<DbOperations.Squib.Fields>()
|
||||
.ToArray();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var o = dr[field.ToString()];
|
||||
if (DBNull.Value.Equals(o)) { continue; }
|
||||
try
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.Squib.Fields.Version:
|
||||
Version = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.SquibToleranceLow:
|
||||
SquibToleranceLow = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.SquibToleranceHigh:
|
||||
SquibToleranceHigh = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.SquibOutputCurrent:
|
||||
SquibOutputCurrent = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.SquibDescription:
|
||||
SquibDescription = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.MeasurementType:
|
||||
SquibMeasurementType = (OutputSquibChannel.SquibMeasurementType)Convert.ToInt16(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.LocalOnly:
|
||||
_localOnly = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.LimitDuration:
|
||||
LimitSquibFireDuration = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.LastModifiedBy:
|
||||
_lastUpdatedBy = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.LastModified:
|
||||
LastModified = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.ISOCode:
|
||||
ISOCode = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.FireMode:
|
||||
SquibFireMode = (OutputSquibChannel.SquibFireMode)Convert.ToInt16(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.DurationMS:
|
||||
SquibFireDurationMS = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.DelayMS:
|
||||
SquibFireDelayMS = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.BypassVoltageFilter:
|
||||
BypassVoltageFilter = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.BypassCurrentFilter:
|
||||
BypassCurrentFilter = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.ArticleId:
|
||||
ArticleId = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.UserValue1:
|
||||
UserValue1 = Convert.ToString(o);
|
||||
Comment = UserValue1;
|
||||
break;
|
||||
case DbOperations.Squib.Fields.UserValue2:
|
||||
UserValue2 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.UserValue3:
|
||||
UserValue3 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.Squib.Fields.UserTags:
|
||||
TagsBlobBytes = (byte[])o;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("Unknown field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(Comment))
|
||||
{
|
||||
Comment = SerialNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("DatabaseExport")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DatabaseExport")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("0e52df76-b8a7-4c69-981c-cdc27b7ee5a9")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
Test.Module.Channel.Sensor.ExcitationVoltage.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
// *** see Test.cs ***
|
||||
public partial class Test
|
||||
{
|
||||
/// <summary>
|
||||
/// A container for DTS generic module concepts.
|
||||
/// </summary>
|
||||
public sealed partial class Module
|
||||
{
|
||||
// *** see Test.Module.Channel.cs ***
|
||||
public partial class Channel
|
||||
{
|
||||
//*** see Test.Module.Channel.Sensor.cs ***
|
||||
public partial class Sensor
|
||||
{
|
||||
/// <summary>
|
||||
/// All available excitation voltages.
|
||||
/// </summary>
|
||||
public enum ExcitationVoltageOption
|
||||
{
|
||||
/// <summary>
|
||||
/// undefined excitation voltage
|
||||
/// </summary>
|
||||
[VoltageMagnitude(0.0)]
|
||||
[Description("Undefined")]
|
||||
Undefined = 1,
|
||||
/// <summary>
|
||||
/// 2V
|
||||
/// </summary>
|
||||
[VoltageMagnitude(2.0)]
|
||||
[Description("2.0")]
|
||||
Volt2 = 2,
|
||||
/// <summary>
|
||||
/// 2.5V
|
||||
/// </summary>
|
||||
[VoltageMagnitude(2.5)]
|
||||
[Description("2.5")]
|
||||
Volt2_5 = 4,
|
||||
/// <summary>
|
||||
/// 3.0V
|
||||
/// </summary>
|
||||
[VoltageMagnitude(3.0)]
|
||||
[Description("3.0")]
|
||||
Volt3 = 8,
|
||||
/// <summary>
|
||||
/// 5V
|
||||
/// </summary>
|
||||
[VoltageMagnitude(5.0)]
|
||||
[Description("5.0")]
|
||||
Volt5 = 16,
|
||||
/// <summary>
|
||||
/// 10V
|
||||
/// </summary>
|
||||
[VoltageMagnitude(10.0)]
|
||||
[Description("10.0")]
|
||||
Volt10 = 32,
|
||||
/// <summary>
|
||||
/// 1V
|
||||
/// </summary>
|
||||
[VoltageMagnitude(1.0)]
|
||||
[Description("1.0")]
|
||||
Volt1 = 64
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a specified excitation voltage option into its associated numeric value.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="target">
|
||||
/// The <see cref="DTS.DAS.Concepts.Test.Module.Channel.Sensor.ExcitationVoltageOption"/> value
|
||||
/// to be converted.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="double"/> magnitude associated with the specified voltage option.
|
||||
/// </returns>
|
||||
///
|
||||
public static double GetExcitationVoltageMagnitudeFromEnum(ExcitationVoltageOption target)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new VoltageMagnitudeAttributeCoder().DecodeAttributeValue(target);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem attempting to get excitation voltage magnitude from enum", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a specified voltage magnitude to the associated numeric value (if it exists;
|
||||
/// otherwise an exception is thrown).
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="magnitude">
|
||||
/// The <see cref="double"/> magnitude to be converted.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="DTS.DAS.Concepts.Test.Module.Channel.Sensor.ExcitationVoltageOption"/> value
|
||||
/// associated with the specified magnitude (if it exists).
|
||||
/// </returns>
|
||||
///
|
||||
public static ExcitationVoltageOption GetExcitationVoltageEnumFromMagnitude(double magnitude)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new VoltageMagnitudeAttributeCoder().EncodeAttributeValue(magnitude);
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new NotSupportedException("encountered problem attempting to get excitation voltage enum from magnitude", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for specifying the numerical magnitude of the attached field's
|
||||
/// "representation". Intended to be used with enumerations whose members represent
|
||||
/// voltage magnitude options so that the enum item can have a corresponding numerical
|
||||
/// value that can be extracted and used in calculations.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class VoltageMagnitudeAttribute : System.Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// returns voltage magnitude
|
||||
/// </summary>
|
||||
public double Value { get; }
|
||||
|
||||
/// <summary>
|
||||
/// constructs a <see cref="DTS.DAS.Concepts.Test.Module.Channel.Sensor.VoltageMagnitudeAttribute" />
|
||||
/// with a given value
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public VoltageMagnitudeAttribute(double value) { Value = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Object for manipulating voltage option enumeration-attached
|
||||
/// <see cref="double"/> magnitude values.
|
||||
/// </summary>
|
||||
public class VoltageMagnitudeAttributeCoder
|
||||
: AttributeCoder<ExcitationVoltageOption, VoltageMagnitudeAttribute, double>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a <see cref="DTS.DAS.Concepts.Test.Module.Channel.Sensor.VoltageMagnitudeAttributeCoder"/> object.
|
||||
/// </summary>
|
||||
public VoltageMagnitudeAttributeCoder()
|
||||
: base(attribute => attribute.Value, null)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class MMEFilterClasses : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Filter_Class { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
|
||||
public MMEFilterClasses(string textL1)
|
||||
{
|
||||
Filter_Class = textL1;
|
||||
Text_L1 = textL1;
|
||||
}
|
||||
|
||||
public MMEFilterClasses(string sGuid, string filterClass, string textL1, string textL2, long version,
|
||||
DateTime date, string remarks, bool bExpired, string sortKey, DateTime lastChange, string lastChangeText, string history,
|
||||
MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
Filter_Class = filterClass;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = bExpired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
public static MMEFilterClasses[] GetFilterClasses()
|
||||
{
|
||||
var filterClasses = new List<MMEFilterClasses>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandType = CommandType.Text;
|
||||
cmd.CommandText = "SELECT * FROM MMEFilterClasses";
|
||||
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string filterClass = ISOReader["FILTER_CLASS"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = Convert.ToInt64(ISOReader["VERSION"]);
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
filterClasses.Add(new MMEFilterClasses(sGuid, filterClass, textL1, textL2, version, date, remarks, expired,
|
||||
sortkey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * from {0}", DbOperations.MMETables.MMEFilterClassesTable);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.MMETables.MMEFilterClassesFields))
|
||||
.Cast<DbOperations.MMETables.MMEFilterClassesFields>().ToArray();
|
||||
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var version = 0;
|
||||
var text2 = "";
|
||||
var text1 = "";
|
||||
var sortkey = "";
|
||||
var sGuid = "";
|
||||
var remarks = "";
|
||||
var lastChangeText = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var history = "";
|
||||
var filterclass = "??";
|
||||
var expired = false;
|
||||
var date = DateTime.Now;
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.DATE:
|
||||
date = Convert.ToDateTime(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.EXPIRED:
|
||||
expired = Convert.ToBoolean(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.FILTER_CLASS:
|
||||
filterclass = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.HISTORY:
|
||||
history = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.LAST_CHANGE:
|
||||
lastChange = Convert.ToDateTime(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.REMARKS:
|
||||
remarks = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.s_GUID:
|
||||
sGuid = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.SORTKEY:
|
||||
sortkey = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.TEXT_L1:
|
||||
text1 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.TEXT_L2:
|
||||
text2 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEFilterClassesFields.VERSION:
|
||||
version = Convert.ToInt32(dr[field.ToString()]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
filterClasses.Add(new MMEFilterClasses(sGuid.ToString(), filterclass, text1, text2, Convert.ToInt64(version),
|
||||
date, remarks, expired, sortkey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
return filterClasses.ToArray();
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Text_L1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class SensorCalibrationList
|
||||
{
|
||||
protected SensorCalibrationList()
|
||||
{
|
||||
_calibrations = new Dictionary<string, List<SensorCalibration>>();
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * FROM {0}", DbOperations.SensorDB.SensorCalibrationTable);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
foreach (DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
var sc = new SensorCalibration(row);
|
||||
if (!_calibrations.ContainsKey(sc.SerialNumber)) { _calibrations.Add(sc.SerialNumber, new List<SensorCalibration>()); }
|
||||
_calibrations[sc.SerialNumber].Add(sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private Dictionary<string, List<SensorCalibration>> _calibrations = null;
|
||||
private static object _lock = new object();
|
||||
|
||||
private static SensorCalibrationList _calibrationList = null;
|
||||
public static SensorCalibration GetLatestCalibrationBySerialNumberAndExcitation(SensorData sd, Test.Module.Channel.Sensor.ExcitationVoltageOption exc)
|
||||
{
|
||||
if (null == sd) { return null; }
|
||||
if (sd.IsDigitalInput() || sd.IsSquib() || sd.IsDigitalOutput()) { return SensorCalibration.NewDigitalSC(); }
|
||||
lock (_lock)
|
||||
{
|
||||
if (null == _calibrationList)
|
||||
{
|
||||
_calibrationList = new SensorCalibrationList();
|
||||
}
|
||||
if (!_calibrationList._calibrations.ContainsKey(sd.SerialNumber) || _calibrationList._calibrations[sd.SerialNumber].Count <= 0) return null;
|
||||
try
|
||||
{
|
||||
var list = _calibrationList._calibrations[sd.SerialNumber];
|
||||
list.Sort();
|
||||
foreach (var sc in list)
|
||||
{
|
||||
if (!sc.IsProportional) { return new SensorCalibration(sc); }
|
||||
if (Array.Exists(sc.Records.Records, record => record.Excitation == exc))
|
||||
{
|
||||
return new SensorCalibration(sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*Utilities.Logging.APILogger.Log(ex);*/ }
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
public static SensorCalibration[] GetCalibrationsBySerialNumber(SensorData sd)
|
||||
{
|
||||
if (null == sd) { return new SensorCalibration[0]; }
|
||||
if (sd.IsDigitalInput() || sd.IsSquib() || sd.IsDigitalOutput()) { return new SensorCalibration[] { SensorCalibration.NewDigitalSC() }; }
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
if (null == _calibrationList)
|
||||
{
|
||||
_calibrationList = new SensorCalibrationList();
|
||||
}
|
||||
if (!_calibrationList._calibrations.ContainsKey(sd.SerialNumber)) return new SensorCalibration[0];
|
||||
var list = new List<SensorCalibration>(_calibrationList._calibrations[sd.SerialNumber].Count);
|
||||
list.AddRange(_calibrationList._calibrations[sd.SerialNumber].Select(sc => new SensorCalibration(sc)));
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
public class SensorCalibration //: IComparable<SensorCalibration>, INotifyPropertyChanged
|
||||
{
|
||||
public InitialOffset InitialOffset { get; set; } = new InitialOffset();
|
||||
private bool _nonLinear = false;
|
||||
public bool NonLinear
|
||||
{
|
||||
get => _nonLinear;
|
||||
set
|
||||
{
|
||||
_nonLinear = value;
|
||||
if (value)
|
||||
{
|
||||
Records.Records[0].Sensitivity = 1D;
|
||||
IsProportional = false;
|
||||
RemoveOffset = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static SensorCalibration NewDigitalSC()
|
||||
{
|
||||
var sc = new SensorCalibration
|
||||
{
|
||||
RemoveOffset = false,
|
||||
CalibrationDate = DateTime.Now.Date,
|
||||
IsProportional = false,
|
||||
LocalOnly = false,
|
||||
NonLinear = false
|
||||
};
|
||||
sc.Records.Records[0].Sensitivity = 1;
|
||||
sc.Records.Records[0].EngineeringUnits = "V";
|
||||
sc.Records.Records[0].Excitation = Test.Module.Channel.Sensor.ExcitationVoltageOption.Volt5;
|
||||
sc.ZeroMethod = new ZeroMethod(Test.Module.Channel.Sensor.ZeroMethodType.None, 0, 0);
|
||||
return sc;
|
||||
}
|
||||
public static SensorCalibration GetLatestCalibrationBySerialNumberAndExcitation(SensorData sd, Test.Module.Channel.Sensor.ExcitationVoltageOption exc)
|
||||
{
|
||||
return SensorCalibrationList.GetLatestCalibrationBySerialNumberAndExcitation(sd, exc);
|
||||
}
|
||||
public string SerialNumber { get; set; } = "";
|
||||
|
||||
// these two are the keys
|
||||
public DateTime CalibrationDate { get; set; }
|
||||
|
||||
private string _username = "";
|
||||
public string Username
|
||||
{
|
||||
get => _username ?? string.Empty;
|
||||
set => _username = value;
|
||||
}
|
||||
private CalibrationRecords _records = new CalibrationRecords();
|
||||
public CalibrationRecords Records
|
||||
{
|
||||
get => _records;
|
||||
set => _records = value;
|
||||
}
|
||||
|
||||
public DateTime ModifyDate { get; set; }
|
||||
|
||||
private bool _isProportional = true;
|
||||
public bool IsProportional
|
||||
{
|
||||
get => !NonLinear && _isProportional;
|
||||
set => _isProportional = value;
|
||||
}
|
||||
|
||||
private bool _bRemoveOffset = true;
|
||||
public bool RemoveOffset
|
||||
{
|
||||
get => !NonLinear && _bRemoveOffset;
|
||||
set => _bRemoveOffset = value;
|
||||
}
|
||||
|
||||
private List<string> _certificationDocuments = new List<string>();
|
||||
public string[] CertificationDocuments
|
||||
{
|
||||
get => _certificationDocuments.ToArray();
|
||||
set => _certificationDocuments = new List<string>(value);
|
||||
}
|
||||
|
||||
private ZeroMethod _zeroMethod = new ZeroMethod(Test.Module.Channel.Sensor.ZeroMethodType.UsePreEventDiagnosticsZero, -.05, -.02);
|
||||
public ZeroMethod ZeroMethod
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (NonLinear)
|
||||
{
|
||||
switch (Records.Records[0].Poly.Style)
|
||||
{
|
||||
case LinearizationFormula.Styles.IRTraccAverageOverTime: _zeroMethod.Method = Test.Module.Channel.Sensor.ZeroMethodType.AverageOverTime; break;
|
||||
case LinearizationFormula.Styles.IRTraccDiagnosticsZero: _zeroMethod.Method = Test.Module.Channel.Sensor.ZeroMethodType.UsePreEventDiagnosticsZero; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
/*Utilities.Logging.APILogger.Log(ex);*/
|
||||
}
|
||||
return _zeroMethod;
|
||||
}
|
||||
set => _zeroMethod = value;
|
||||
}
|
||||
|
||||
private bool _bLocalOnly = false;
|
||||
public bool LocalOnly
|
||||
{
|
||||
get => _bLocalOnly;
|
||||
set => _bLocalOnly = value;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// protected const int CurrentVersion = 1;
|
||||
|
||||
public SensorCalibration()
|
||||
{
|
||||
if (NonLinear)
|
||||
{
|
||||
Records.Records[0].Sensitivity = 1D;
|
||||
IsProportional = false;
|
||||
RemoveOffset = false;
|
||||
}
|
||||
}
|
||||
public SensorCalibration(string s)
|
||||
{
|
||||
FromSerializedString(s);
|
||||
if (NonLinear)
|
||||
{
|
||||
Records.Records[0].Sensitivity = 1D;
|
||||
IsProportional = false;
|
||||
RemoveOffset = false;
|
||||
}
|
||||
}
|
||||
public SensorCalibration(DataRow dr)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.SensorDB.SensorCalibrationFields)).Cast<DbOperations.SensorDB.SensorCalibrationFields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var o = dr[field.ToString()];
|
||||
if (DBNull.Value.Equals(o)) { continue; }
|
||||
try
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CalibrationDate:
|
||||
CalibrationDate = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.LocalOnly:
|
||||
LocalOnly = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.SerialNumber:
|
||||
SerialNumber = (string)o;
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.Username:
|
||||
Username = (string)o;
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CalibrationRecords:
|
||||
Records = new CalibrationRecords((string)o);
|
||||
break;
|
||||
//case Storage.DbOperations.SensorDB.SensorCalibrationFields.IRTraccCalculationType:
|
||||
//IRTraccCalculationType = (SensorModel.IRTraccFormats)Enum.Parse(typeof(SensorModel.IRTraccFormats), (string)o);
|
||||
// break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.IsProportional:
|
||||
IsProportional = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.ModifyDate:
|
||||
ModifyDate = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.NonLinear:
|
||||
NonLinear = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CertificationDocuments:
|
||||
{
|
||||
CertificationDocuments = ((string)o).Split(new string[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None).ToArray();
|
||||
}
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.RemoveOffset:
|
||||
RemoveOffset = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.ZeroMethod:
|
||||
ZeroMethod = new ZeroMethod((string)o);
|
||||
break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.InitialOffset:
|
||||
InitialOffset = new InitialOffset(); InitialOffset.FromDbSerializeString((string)o);
|
||||
break;
|
||||
default: throw new NotSupportedException("SensorCalibration::SensorCalibration(DataRow) unknown field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//Utilities.Logging.APILogger.Log("Failed to process field: ", field.ToString(), " from db: ", ex);
|
||||
}
|
||||
}
|
||||
//this is downright silly, but because the linearization formula marks itself valid when it deserializes with data in it, we go and correct it here.
|
||||
Records.Records[0].Poly.MarkValid(NonLinear);
|
||||
|
||||
if (NonLinear)
|
||||
{
|
||||
Records.Records[0].Sensitivity = 1D;
|
||||
IsProportional = false;
|
||||
RemoveOffset = false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// serializes to a string
|
||||
/// primarily used by sensor models, which only have one calibration entry
|
||||
/// sensors on the other hand have many and serialize to rows in a db table
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ToSerializedString()
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.SensorDB.SensorCalibrationFields)).Cast<DbOperations.SensorDB.SensorCalibrationFields>().ToArray();
|
||||
|
||||
if (CalibrationDate.Year < 1960) { CalibrationDate = DateTime.Now.Date; }
|
||||
var substrings = new List<string>();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CalibrationDate: substrings.Add(CalibrationDate.Date.ToFileTimeUtc().ToString(System.Globalization.CultureInfo.InvariantCulture)); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CalibrationRecords: substrings.Add(Records.ToSerializedString(this)); break;
|
||||
//case Storage.DbOperations.SensorDB.SensorCalibrationFields.IRTraccCalculationType: substrings.Add(IRTraccCalculationType.ToString()); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.IsProportional: substrings.Add(IsProportional.ToString()); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.LocalOnly: substrings.Add(LocalOnly.ToString()); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.ModifyDate: substrings.Add(DateTime.Now.ToFileTimeUtc().ToString(System.Globalization.CultureInfo.InvariantCulture)); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.NonLinear: substrings.Add(NonLinear.ToString()); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.RemoveOffset: substrings.Add(RemoveOffset.ToString()); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.SerialNumber: substrings.Add(SerialNumber); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.Username: substrings.Add(Username); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.ZeroMethod: substrings.Add(ZeroMethod.ToSerializeString()); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.InitialOffset: substrings.Add(InitialOffset.ToDbSerializeString()); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CertificationDocuments:
|
||||
{
|
||||
var docs = new List<string>();
|
||||
foreach (var d in CertificationDocuments) { docs.Add(d); }
|
||||
substrings.Add(string.Join(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, docs.ToArray()));
|
||||
}
|
||||
break;
|
||||
default: throw new NotSupportedException("SensorCalibration::ToSerializedString unknown field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < substrings.Count; i++)
|
||||
{
|
||||
System.Diagnostics.Trace.Assert(!substrings[i].Contains(SEPARATOR_REPLACEMENT));
|
||||
substrings[i] = substrings[i].Replace(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, SEPARATOR_REPLACEMENT);
|
||||
}
|
||||
return string.Join(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, substrings.ToArray());
|
||||
}
|
||||
public void FromSerializedString(string s)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.SensorDB.SensorCalibrationFields))
|
||||
.Cast<DbOperations.SensorDB.SensorCalibrationFields>().ToArray();
|
||||
var tokens = s.Split(new string[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
|
||||
for (var i = 0; i < tokens.Length && i < fields.Length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
var token = tokens[i].Replace(SEPARATOR_REPLACEMENT, System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator);
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CalibrationDate: CalibrationDate = DateTime.FromFileTimeUtc(Convert.ToInt64(token)); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CalibrationRecords: Records = new CalibrationRecords(token); break;
|
||||
//case Storage.DbOperations.SensorDB.SensorCalibrationFields.IRTraccCalculationType: IRTraccCalculationType = (SensorModel.IRTraccFormats)Enum.Parse(typeof(SensorModel.IRTraccFormats), token);break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.IsProportional: IsProportional = Convert.ToBoolean(token); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.LocalOnly: LocalOnly = Convert.ToBoolean(token); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.ModifyDate: ModifyDate = DateTime.FromFileTimeUtc(Convert.ToInt64(token)); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.NonLinear: NonLinear = Convert.ToBoolean(token); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.RemoveOffset: RemoveOffset = Convert.ToBoolean(token); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.SerialNumber: SerialNumber = token; break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.Username: Username = token; break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.ZeroMethod: ZeroMethod = new ZeroMethod(token); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.InitialOffset: InitialOffset = new InitialOffset(); InitialOffset.FromDbSerializeString(token); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CertificationDocuments:
|
||||
{
|
||||
var subtokens = token.Split(new string[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
var docs = subtokens.ToList();
|
||||
}
|
||||
break;
|
||||
default: throw new NotSupportedException("SensorCalibration::FromSerializedString unknown field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
public const string SEPARATOR_REPLACEMENT = "__SC__";
|
||||
public SensorCalibration(SensorCalibration sc)
|
||||
{
|
||||
SerialNumber = sc.SerialNumber;
|
||||
_username = sc.Username;
|
||||
CalibrationDate = sc.CalibrationDate;
|
||||
ModifyDate = sc.ModifyDate;
|
||||
NonLinear = sc.NonLinear;
|
||||
IsProportional = sc.IsProportional;
|
||||
Records = new CalibrationRecords(sc.Records);
|
||||
RemoveOffset = sc.RemoveOffset;
|
||||
ZeroMethod = new ZeroMethod(sc.ZeroMethod);
|
||||
InitialOffset = new InitialOffset(sc.InitialOffset);
|
||||
CertificationDocuments = sc.CertificationDocuments;
|
||||
}
|
||||
public Dictionary<string, string> GetValues()
|
||||
{
|
||||
var elementNameValuePairs = new Dictionary<string, string>();
|
||||
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.SerialNumber.ToString()] = SerialNumber;
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.CalibrationDate.ToString()] = CalibrationDate.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.Username.ToString()] = Username;
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.LocalOnly.ToString()] = LocalOnly.ToString();
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.NonLinear.ToString()] = NonLinear.ToString();
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.CalibrationRecords.ToString()] = Records.ToSerializedString(this);
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.ModifyDate.ToString()] = ModifyDate.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.IsProportional.ToString()] = IsProportional.ToString();
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.RemoveOffset.ToString()] = RemoveOffset.ToString();
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.ZeroMethod.ToString()] = ZeroMethod.ToDbString();
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.CertificationDocuments.ToString()] = "";
|
||||
elementNameValuePairs[DbOperations.SensorDB.SensorCalibrationFields.InitialOffset.ToString()] = InitialOffset.ToDbSerializeString();
|
||||
|
||||
return elementNameValuePairs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/* Copyright 2017 Diversified Technical Systems
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// this class will probably become an abstract base class in the future but for now since we only have
|
||||
/// summed realtime channels, we can be a little less formal
|
||||
/// </summary>
|
||||
public class CalculatedValueClass
|
||||
{
|
||||
public CalculatedValueClass(System.Data.DataRow dr)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.CalculatedChannels.Fields))
|
||||
.Cast<DbOperations.CalculatedChannels.Fields>().ToArray();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var o = dr[field.ToString()];
|
||||
if (DBNull.Value.Equals(o)) { continue; }
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.CalculatedChannels.Fields.TestSetupName:
|
||||
TestSetupName = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.CalculatedChannels.Fields.Operation:
|
||||
Operation = (Operations)Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.CalculatedChannels.Fields.InputChannelIds:
|
||||
InputChannelIdsBlob = (byte[])o;
|
||||
break;
|
||||
case DbOperations.CalculatedChannels.Fields.Id:
|
||||
Id = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.CalculatedChannels.Fields.CFCForOutput:
|
||||
ChannelFilterClassForOutput = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.CalculatedChannels.Fields.CFCForInputChannels:
|
||||
CFCForInputChannels = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.CalculatedChannels.Fields.CCName:
|
||||
Name = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.CalculatedChannels.Fields.CalculatedChannelValueCode:
|
||||
CalculatedValueCode = Convert.ToString(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Id { get; set; } = -1;
|
||||
|
||||
public enum Operations
|
||||
{
|
||||
SUM = 1,
|
||||
AVERAGE = 2,
|
||||
IRTRACC3D = 3,
|
||||
IRTRACC3D_ABDOMEN = 4,
|
||||
IRTRACC3D_LOWERTHORAX = 5
|
||||
}
|
||||
|
||||
public Operations Operation { get; set; } = Operations.SUM;
|
||||
|
||||
public string CalculatedValueCode { get; set; } = "???????????????X";
|
||||
|
||||
private List<string> _inputChannelIds = new List<string>();
|
||||
public string[] InputChannelIds
|
||||
{
|
||||
get => _inputChannelIds.ToArray();
|
||||
set => _inputChannelIds = new List<string>(value);
|
||||
}
|
||||
public byte[] InputChannelIdsBlob
|
||||
{
|
||||
get
|
||||
{
|
||||
var text = string.Join(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, InputChannelIds);
|
||||
return System.Text.Encoding.UTF8.GetBytes(text);
|
||||
}
|
||||
set
|
||||
{
|
||||
_inputChannelIds.Clear();
|
||||
var text = System.Text.Encoding.UTF8.GetString(value);
|
||||
InputChannelIds = text.Split(new[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
}
|
||||
}
|
||||
|
||||
public string CFCForInputChannels { get; set; } = "";
|
||||
|
||||
public string ChannelFilterClassForOutput { get; set; } = "";
|
||||
|
||||
public string TestSetupName { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for all DAS channels.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DASChannel //: IXmlSerializable // (subset of sensor class)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base class for SQUIB channels.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class OutputTOMDigitalChannel : DigitalOutputDASChannel
|
||||
{
|
||||
public enum DigitalOutputMode
|
||||
{
|
||||
NONE = 0, //digital channel's mode not set
|
||||
FVLH = 1 << 0, //set for 5 volt, low-to-high transition
|
||||
FVHL = 1 << 1, //set for 5 volt, high-to-low transition
|
||||
CCNO = 1 << 2, //set to contact closure normally open
|
||||
CCNC = 1 << 3 //set to contact closure normally closed
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Base class for SQUIB channels.
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public class OutputSquibChannel //: AnalogOutputDASChannel, IComparable
|
||||
{
|
||||
public enum SquibFireMode
|
||||
{
|
||||
NONE = 1 << 0, //squib's fire mode not set
|
||||
CAP = 1 << 1, //use capacitor discharge
|
||||
CONSTANT = 1 << 2, //use constant current discharge
|
||||
AC = 1 << 3 //use AC discharge
|
||||
};
|
||||
public enum SquibMeasurementType
|
||||
{
|
||||
NONE = 0, //the squib's measurement mode has not been set
|
||||
CURRENT = 1 << 0, //the squib's current will be recorded
|
||||
INIT_SIGNAL = 1 << 1, //the squib's initiation indicator will be recorded
|
||||
VOLTAGE = 1 << 2, //the squib's voltage will be recorded
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Base class for output channels.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class OutputDASChannel : DASChannel
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Digital output channel.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DigitalOutputDASChannel : OutputDASChannel
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseExport.ISO
|
||||
{
|
||||
[Serializable()]
|
||||
public class TestEngineerDetails //: ISerializableFile
|
||||
{
|
||||
private enum Fields
|
||||
{
|
||||
Name,
|
||||
TestEngineerName,
|
||||
TestEngineerPhone,
|
||||
TestEngineerFax,
|
||||
TestEngineerEmail,
|
||||
LocalOnly,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
Version
|
||||
}
|
||||
public Dictionary<string, string> GetValues()
|
||||
{
|
||||
var elementNameValuePairs = new Dictionary<string, string>();
|
||||
|
||||
elementNameValuePairs[Fields.Name.ToString()] = Name;
|
||||
elementNameValuePairs[Fields.TestEngineerName.ToString()] = TestEngineerName;
|
||||
elementNameValuePairs[Fields.TestEngineerPhone.ToString()] = TestEngineerPhone;
|
||||
elementNameValuePairs[Fields.TestEngineerFax.ToString()] = TestEngineerFax;
|
||||
elementNameValuePairs[Fields.TestEngineerEmail.ToString()] = TestEngineerEmail;
|
||||
elementNameValuePairs[Fields.LocalOnly.ToString()] = LocalOnly.ToString();
|
||||
elementNameValuePairs[Fields.LastModified.ToString()] = LastModified.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[Fields.LastModifiedBy.ToString()] = LastModifiedBy;
|
||||
elementNameValuePairs[Fields.Version.ToString()] = Version.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
return elementNameValuePairs;
|
||||
}
|
||||
private string _testEngineerName = "NOVALUE";
|
||||
public string TestEngineerName
|
||||
{
|
||||
get => _testEngineerName;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
_testEngineerName = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _testEngineerPhone = "NOVALUE";
|
||||
public string TestEngineerPhone
|
||||
{
|
||||
get => _testEngineerPhone;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
_testEngineerPhone = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _testEngineerFax = "NOVALUE";
|
||||
public string TestEngineerFax
|
||||
{
|
||||
get => _testEngineerFax;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
_testEngineerFax = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _testEngineerEmail = "NOVALUE";
|
||||
public string TestEngineerEmail
|
||||
{
|
||||
get => _testEngineerEmail;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
_testEngineerEmail = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _localOnly = false;
|
||||
public bool LocalOnly
|
||||
{
|
||||
get => _localOnly;
|
||||
set => _localOnly = value;
|
||||
}
|
||||
|
||||
private string _name = "";
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => _name = value;
|
||||
}
|
||||
|
||||
private DateTime _lastModified;
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => _lastModified = value;
|
||||
}
|
||||
|
||||
private string _lastModifiedBy;
|
||||
public string LastModifiedBy
|
||||
{
|
||||
get => _lastModifiedBy;
|
||||
set => _lastModifiedBy = value;
|
||||
}
|
||||
private int _version = 1;
|
||||
public int Version
|
||||
{
|
||||
get => _version;
|
||||
set => _version = value;
|
||||
}
|
||||
|
||||
public TestEngineerDetails()
|
||||
{
|
||||
}
|
||||
|
||||
public TestEngineerDetails(DataRow dr)
|
||||
{
|
||||
_name = (string)dr["Name"];
|
||||
TestEngineerName = (string)dr["TestEngineerName"];
|
||||
TestEngineerPhone = (string)dr["TestEngineerPhone"];
|
||||
TestEngineerFax = (string)dr["TestEngineerFax"];
|
||||
TestEngineerEmail = (string)dr["TestEngineerEmail"];
|
||||
_localOnly = Convert.ToBoolean(dr["LocalOnly"]);
|
||||
_lastModified = Convert.ToDateTime(dr["LastModified"]);
|
||||
_lastModifiedBy = (string)dr["LastModifiedBy"];
|
||||
_version = Convert.ToInt32(dr["Version"]);
|
||||
}
|
||||
public TestEngineerDetails(TestEngineerDetails copy)
|
||||
{
|
||||
_name = copy.Name;
|
||||
TestEngineerName = copy.TestEngineerName;
|
||||
TestEngineerPhone = copy.TestEngineerPhone;
|
||||
TestEngineerFax = copy.TestEngineerFax;
|
||||
TestEngineerEmail = copy.TestEngineerEmail;
|
||||
_localOnly = copy.LocalOnly;
|
||||
_lastModified = copy.LastModified;
|
||||
_lastModifiedBy = copy.LastModifiedBy;
|
||||
_version = copy.Version;
|
||||
}
|
||||
public static TestEngineerDetails[] GetAllTestEngineerDetails()
|
||||
{
|
||||
var list = new List<TestEngineerDetails>();
|
||||
try
|
||||
{
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
sql.CommandText = "SELECT * from [tblTestEngineerDetails]";
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
list.Add(new TestEngineerDetails(dr));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("failed to get test engineer details", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to retrieve test engineer details", ex);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class GlobalSetting : Setting
|
||||
{
|
||||
private const string SYSTEM = "SYSTEM";
|
||||
public GlobalSetting(string id, string defaultPropertyValue)
|
||||
: base(id, PropertyTypes.Global, defaultPropertyValue, SYSTEM)
|
||||
{
|
||||
}
|
||||
protected override void GetPropertyValue(string defaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * FROM {0} WHERE {1}=@{1} AND {2}=@{2}", DbOperations.Settings.Table,
|
||||
DbOperations.Settings.UserFields.PropertyId.ToString(), DbOperations.Settings.UserFields.UserId.ToString());
|
||||
DbOperations.CreateParam(cmd, string.Format("@{0}", DbOperations.Settings.UserFields.PropertyId.ToString()), System.Data.SqlDbType.NVarChar,
|
||||
PropertyId);
|
||||
DbOperations.CreateParam(cmd, string.Format("@{0}", DbOperations.Settings.UserFields.UserId.ToString()), System.Data.SqlDbType.NVarChar,
|
||||
SYSTEM);
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
_propertyValue = Convert.ToString(ds.Tables[0].Rows[0][DbOperations.Settings.UserFields.PropertyValue.ToString()]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_propertyValue = defaultValue;
|
||||
//StoreInDB();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
_propertyValue = defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* DiskUtility.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of handy disk-related methods.
|
||||
/// </summary>
|
||||
public class DiskUtility : Exceptional
|
||||
{
|
||||
/// <summary>
|
||||
/// checks to see if a string contains illegal characters for file and/or path names
|
||||
/// </summary>
|
||||
/// <param name="nameToValidate"></param>
|
||||
/// <returns></returns>
|
||||
public static bool ValidateFileAndPathNameChars(string nameToValidate)
|
||||
{
|
||||
var bValid = true;
|
||||
var name = nameToValidate;
|
||||
if (name.Trim().Length < 1) { bValid = false; }
|
||||
foreach (var invalidChar in Path.GetInvalidFileNameChars())
|
||||
if (name.Contains(invalidChar)) { bValid = false; }
|
||||
foreach (var invalidChar in Path.GetInvalidPathChars())
|
||||
if (name.Contains(invalidChar)) { bValid = false; }
|
||||
if (name.Contains('.')) { bValid = false; }
|
||||
return bValid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseExport.ISO
|
||||
{
|
||||
/// <summary>
|
||||
/// this class is a wrapper for the group template per the db, it's supposed to be a lighter weight version of concept of a test object template, with no
|
||||
/// connection to UI, just serialization and structure
|
||||
/// </summary>
|
||||
public class TestObjectTemplate
|
||||
{
|
||||
// #region Properties
|
||||
/// <summary>
|
||||
/// name of the test object template, this could be a GUID in the case of embedded test object templates
|
||||
/// </summary>
|
||||
public string TemplateName { get; set; }
|
||||
/// <summary>
|
||||
/// a human readable name for the template, for an embedded template this is the original template name, for
|
||||
/// a non embedded template, this is the template name (embedded templates have guids for names)
|
||||
/// </summary>
|
||||
public string TemplateNameOrOriginalTemplateName => Embedded ? OriginalTemplateName : TemplateName;
|
||||
|
||||
/// <summary>
|
||||
/// the icon for the template
|
||||
/// </summary>
|
||||
public string Icon { get; set; }
|
||||
/// <summary>
|
||||
/// description for the template
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
/// whether this template is intended to only be used locally or not
|
||||
/// </summary>
|
||||
public bool LocalOnly { get; set; }
|
||||
/// <summary>
|
||||
/// the version number of this template [not currently used?]
|
||||
/// </summary>
|
||||
public int Version { get; set; }
|
||||
/// <summary>
|
||||
/// last person to modify this template
|
||||
/// </summary>
|
||||
public string LastModifiedBy { get; set; }
|
||||
/// <summary>
|
||||
/// when this template was last modified
|
||||
/// </summary>
|
||||
public DateTime LastModified { get; set; }
|
||||
/// <summary>
|
||||
/// a CRC32 for the template, but not currently used
|
||||
/// original idea was to allow us to not have to check changes in the template, just quickly calculate whether anything has changed
|
||||
/// </summary>
|
||||
public int CRC32 { get; set; }
|
||||
/// <summary>
|
||||
/// test object (iso meta field) for this template
|
||||
/// </summary>
|
||||
public string TestObject { get; set; }
|
||||
/// <summary>
|
||||
/// test object type (iso meta field) for this template, all channels are of this type ...
|
||||
/// </summary>
|
||||
public string TestObjectType { get; set; }
|
||||
/// <summary>
|
||||
/// unsure if this is still used, was originally used to build up templates from sub templates,
|
||||
/// so an ATD could be composed of leg, arm, head, etc
|
||||
/// </summary>
|
||||
public string TemplateParent { get; set; }
|
||||
/// <summary>
|
||||
/// unsure, I think this is whether the group is dynamically added or an existing
|
||||
/// </summary>
|
||||
public bool SysBuilt { get; set; }
|
||||
/// <summary>
|
||||
/// zones where regions on a test object, this is currently hidden, but the idea
|
||||
/// was to associate a picture with a zone, and to allow constructing regions or areas in that zone
|
||||
/// </summary>
|
||||
public TemplateZone[] Zones { get; set; }
|
||||
/// <summary>
|
||||
/// all channels for the template
|
||||
/// </summary>
|
||||
public TestObjectTemplateChannel[] Channels { get; set; }
|
||||
/// <summary>
|
||||
/// the original template name [if we are embedded we got a new name that was a guid, but we store the old name here for readability purposes]
|
||||
/// </summary>
|
||||
public string OriginalTemplateName { get; set; }
|
||||
/// <summary>
|
||||
/// whether this group is embedded in a test setup, or is a user created and living on it's own template
|
||||
/// </summary>
|
||||
public bool Embedded { get; set; }
|
||||
public TestObjectTemplate(DataRow row, ref ISO13499FileDb db, ref List<string> errors)
|
||||
{
|
||||
TemplateName = (string)row["TemplateName"];
|
||||
Icon = (string)row["Icon"];
|
||||
Description = (string)row["Description"];
|
||||
LocalOnly = Convert.ToBoolean(row["LocalOnly"]);
|
||||
Version = Convert.ToInt32(row["Version"]);
|
||||
LastModifiedBy = (string)row["LastModifiedBy"];
|
||||
LastModified = Convert.ToDateTime(row["LastModified"]);
|
||||
CRC32 = Convert.ToInt32(row["CRC32"]);
|
||||
TestObject = (string)row["TestObject"];
|
||||
TestObjectType = (string)row["TestObjectType"];
|
||||
var oTemplate = row["OrigTemplateName"];
|
||||
OriginalTemplateName = DBNull.Value.Equals(oTemplate) ? string.Empty : Convert.ToString(oTemplate);
|
||||
var oEmbedded = row["Embedded"];
|
||||
if (!DBNull.Value.Equals(oEmbedded))
|
||||
{
|
||||
Embedded = Convert.ToBoolean(oEmbedded);
|
||||
}
|
||||
try
|
||||
{
|
||||
TemplateParent = DBNull.Value.Equals(row["ParentTemplate"]) ? "" : (string)row["ParentTemplate"];
|
||||
}
|
||||
catch (Exception) { TemplateParent = null; }
|
||||
SysBuilt = Convert.ToBoolean(row["SysBuilt"]);
|
||||
|
||||
var channels = new List<TestObjectTemplateChannel>();
|
||||
var possibleChannels = db.GetPossibleChannelsForType(TestObjectType);
|
||||
var channelLookup = new Dictionary<int, Dictionary<long, TestObjectTemplateChannel>>();
|
||||
|
||||
foreach (var pc in possibleChannels)
|
||||
{
|
||||
try
|
||||
{
|
||||
var newCh = new TestObjectTemplateChannel(pc);
|
||||
newCh.SetTemplate(this);
|
||||
channels.Add(newCh);
|
||||
if (!channelLookup.ContainsKey(newCh.Channel.MMEChannelType))
|
||||
{
|
||||
channelLookup.Add(newCh.Channel.MMEChannelType, new Dictionary<long, TestObjectTemplateChannel>());
|
||||
}
|
||||
channelLookup[newCh.Channel.MMEChannelType][newCh.Channel.Id] = newCh;
|
||||
}
|
||||
catch (Exception) {/* DTS.Utilities.Logging.APILogger.Log(ex);*/ }
|
||||
}
|
||||
var failedToLoadChannels = 0;
|
||||
try
|
||||
{
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
DbOperations.CreateParam(sql, "@TemplateName", SqlDbType.NVarChar, TemplateName);
|
||||
sql.CommandText = "SELECT * from [tblTemplateChannels] where [TemplateName]=@TemplateName";
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
TestObjectTemplateChannel ch = null;
|
||||
try
|
||||
{
|
||||
ch = new TestObjectTemplateChannel(dr, this, ref db);
|
||||
if (ch.Required)
|
||||
{
|
||||
if (null == ch.Channel)
|
||||
{
|
||||
failedToLoadChannels++;
|
||||
continue;
|
||||
}
|
||||
var old = channelLookup[ch.Channel.MMEChannelType][ch.Channel.Id];
|
||||
channelLookup[ch.Channel.MMEChannelType][ch.Channel.Id] = ch;
|
||||
var index = channels.IndexOf(old);
|
||||
channels.RemoveAt(index);
|
||||
channels.Insert(index, ch);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to retrieve Template channel", ex2);
|
||||
//if (null != ch) { errors.Add("Failed to load " + TemplateName + " - " + ch.Name); }
|
||||
if (null != ch) { errors.Add("Failed to load " + ch.Name + " from template " + TemplateName); }
|
||||
else { errors.Add("Failed to load a channel in " + TemplateName); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errors.Add("Failed to load channels for - " + TemplateName);
|
||||
//DTS.Utilities.Logging.APILogger.Log("failed to retrieve template channels, ", TemplateName, ex);
|
||||
}
|
||||
Channels = channels.ToArray();
|
||||
if (failedToLoadChannels > 0)
|
||||
{
|
||||
errors.Add(string.Format("Failed to load {0} channel(s) from template {1}", failedToLoadChannels.ToString("N0"), TemplateNameOrOriginalTemplateName));
|
||||
}
|
||||
|
||||
var zones = new List<TemplateZone>();
|
||||
try
|
||||
{
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
DbOperations.CreateParam(sql, "@TemplateName", SqlDbType.NVarChar, TemplateName);
|
||||
|
||||
sql.CommandText = "SELECT * from [tblTemplateZones] where [TemplateName]=@TemplateName";
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
zones.Add(new TemplateZone(dr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("failed to retrieve template regions, ", TemplateName, ex);
|
||||
}
|
||||
Zones = zones.ToArray();
|
||||
}
|
||||
public TestObjectTemplate(string templateName, bool bLocalOnly)
|
||||
{
|
||||
Version = 1;
|
||||
TemplateName = templateName;
|
||||
LocalOnly = bLocalOnly;
|
||||
Zones = new TemplateZone[0];
|
||||
Channels = new TestObjectTemplateChannel[0];
|
||||
}
|
||||
public TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)
|
||||
{
|
||||
if (null != copy && null != copy.TemplateName)
|
||||
{
|
||||
TemplateName = copy.TemplateName;
|
||||
}
|
||||
if (copy == null) return;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
Zones = copy.Zones;
|
||||
CRC32 = copy.CRC32;
|
||||
Description = copy.Description;
|
||||
Embedded = copy.Embedded;
|
||||
OriginalTemplateName = copy.OriginalTemplateName;
|
||||
Icon = copy.Icon;
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
SysBuilt = copy.SysBuilt;
|
||||
TemplateParent = copy.TemplateParent;
|
||||
TestObject = copy.TestObject;
|
||||
TestObjectType = copy.TestObjectType;
|
||||
Version = copy.Version;
|
||||
var lookup = new Dictionary<string, bool>();
|
||||
var channels = new List<TestObjectTemplateChannel>();
|
||||
foreach (var c in copy.Channels)
|
||||
{
|
||||
var ch = new TestObjectTemplateChannel(c, this);
|
||||
ch.SetTemplate(this);
|
||||
channels.Add(ch);
|
||||
lookup[string.Format("{0}x{1}", c.Channel.Id, c.Channel.MMEChannelType)] = true;
|
||||
}
|
||||
var possibleChannels = db.GetPossibleChannelsForType(TestObjectType);
|
||||
foreach (var pc in possibleChannels)
|
||||
{
|
||||
var key = string.Format("{0}x{1}", pc.Id, pc.MMEChannelType);
|
||||
if (lookup.ContainsKey(key)) continue;
|
||||
lookup[key] = true;
|
||||
var ch = new TestObjectTemplateChannel(pc);
|
||||
ch.SetTemplate(this);
|
||||
channels.Insert(0, ch);
|
||||
}
|
||||
Channels = channels.ToArray();
|
||||
}
|
||||
public static TestObjectTemplate GetTemplate(ref ISO13499FileDb db, string name)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(name)) return null;
|
||||
|
||||
var errors = new List<string>();
|
||||
var templates = new List<TestObjectTemplate>();
|
||||
try
|
||||
{
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
sql.CommandText = "SELECT * from [tblTestObjectTemplates] where TemplateName=@TemplateName";
|
||||
DbOperations.CreateParam(sql, "@TemplateName", SqlDbType.NVarChar, name);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
//foreach (DataRow row in ds.Tables[0].Rows)
|
||||
if (ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
templates.Add(new TestObjectTemplate(ds.Tables[0].Rows[0], ref db, ref errors));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to retrieve template", ex2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*DTS.Utilities.Logging.APILogger.Log("failed to get all templates", ex);*/ }
|
||||
|
||||
return templates.Count > 0 ? templates[0] : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* SliceRaw.File.PersistentChannel.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public partial class File
|
||||
{
|
||||
/// <summary>
|
||||
/// Representation of a channel. Changes made to this representation
|
||||
/// are immediately manifest in the associated channel file.
|
||||
/// </summary>
|
||||
public partial class PersistentChannel
|
||||
/*: ExceptionalList<short>,
|
||||
ILargeDataAware,
|
||||
IChannelHeader,
|
||||
IDisposable*/
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DatabaseExport.ISO
|
||||
{
|
||||
[Serializable()]
|
||||
public class LabratoryDetails //: ISerializableFile
|
||||
{
|
||||
private string _labratoryName = string.Empty;
|
||||
|
||||
public string LabratoryName
|
||||
{
|
||||
get => _labratoryName;
|
||||
set => _labratoryName = value;
|
||||
}
|
||||
|
||||
private string _labratoryContactName = string.Empty;
|
||||
|
||||
public string LabratoryContactName
|
||||
{
|
||||
get => _labratoryContactName;
|
||||
set => _labratoryContactName = value;
|
||||
}
|
||||
|
||||
private string _labratoryContactPhone = "NOVALUE";
|
||||
|
||||
public string LabratoryContactPhone
|
||||
{
|
||||
get => _labratoryContactPhone;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
_labratoryContactPhone = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _labratoryContactFax = "NOVALUE";
|
||||
|
||||
public string LabratoryContactFax
|
||||
{
|
||||
get => _labratoryContactFax;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
_labratoryContactFax = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _labratoryContactEmail = "NOVALUE";
|
||||
|
||||
public string LabratoryContactEmail
|
||||
{
|
||||
get => _labratoryContactEmail;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
_labratoryContactEmail = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _labratoryTestRefNumber = string.Empty;
|
||||
|
||||
public string LabratoryTestRefNumber
|
||||
{
|
||||
get => _labratoryTestRefNumber;
|
||||
set => _labratoryTestRefNumber = value;
|
||||
}
|
||||
|
||||
private string _labratoryProjectRefNumber = string.Empty;
|
||||
|
||||
public string LabratoryProjectRefNumber
|
||||
{
|
||||
get => _labratoryProjectRefNumber;
|
||||
set => _labratoryProjectRefNumber = value;
|
||||
}
|
||||
|
||||
private string _name = "";
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => _name = value;
|
||||
}
|
||||
|
||||
public static LabratoryDetails[] GetAllLabratoryDetails()
|
||||
{
|
||||
var labs = new List<LabratoryDetails>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT Name" +
|
||||
",LabratoryName" +
|
||||
",LabratoryContactName" +
|
||||
",LabratoryContactPhone" +
|
||||
",LabratoryContactFax" +
|
||||
",LabratoryContactEmail" +
|
||||
",LabratoryTestRefNumber" +
|
||||
",LabratoryProjectRefNumber" +
|
||||
",LastModified" +
|
||||
",LastModifiedBy" +
|
||||
",LocalOnly" +
|
||||
",Version" +
|
||||
",DbTimeStamp" +
|
||||
" from tblLabratoryDetails";
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
labs.Add(new LabratoryDetails(dr));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to read laboratory details", ex2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to retreive laboratory details", ex);
|
||||
}
|
||||
return labs.ToArray();
|
||||
}
|
||||
|
||||
private bool _localOnly = false;
|
||||
|
||||
public bool LocalOnly
|
||||
{
|
||||
get => _localOnly;
|
||||
set => _localOnly = value;
|
||||
}
|
||||
|
||||
private DateTime _lastModified;
|
||||
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => _lastModified = value;
|
||||
}
|
||||
|
||||
private string _lastModifiedBy;
|
||||
|
||||
public string LastModifiedBy
|
||||
{
|
||||
get => _lastModifiedBy;
|
||||
set => _lastModifiedBy = value;
|
||||
}
|
||||
|
||||
public LabratoryDetails()
|
||||
{
|
||||
}
|
||||
|
||||
public LabratoryDetails(System.Data.DataRow dr)
|
||||
{
|
||||
_name = (string)dr["Name"];
|
||||
LabratoryName = (string)dr["LabratoryName"];
|
||||
LabratoryContactName = (string)dr["LabratoryContactName"];
|
||||
LabratoryContactPhone = (string)dr["LabratoryContactPhone"];
|
||||
LabratoryContactFax = (string)dr["LabratoryContactFax"];
|
||||
LabratoryContactEmail = (string)dr["LabratoryContactEmail"];
|
||||
LabratoryTestRefNumber = (string)dr["LabratoryTestRefNumber"];
|
||||
LabratoryProjectRefNumber = (string)dr["LabratoryProjectRefNumber"];
|
||||
_lastModified = Convert.ToDateTime(dr["LastModified"]);
|
||||
_lastModifiedBy = (string)dr["LastModifiedBy"];
|
||||
_localOnly = Convert.ToBoolean(dr["LocalOnly"]);
|
||||
_version = Convert.ToInt32(dr["Version"]);
|
||||
}
|
||||
|
||||
public LabratoryDetails(LabratoryDetails copy)
|
||||
{
|
||||
_name = copy.Name;
|
||||
LabratoryName = copy.LabratoryName;
|
||||
LabratoryContactName = copy.LabratoryContactName;
|
||||
LabratoryContactPhone = copy.LabratoryContactPhone;
|
||||
LabratoryContactFax = copy.LabratoryContactFax;
|
||||
LabratoryContactEmail = copy.LabratoryContactEmail;
|
||||
LabratoryTestRefNumber = copy.LabratoryTestRefNumber;
|
||||
LabratoryProjectRefNumber = copy.LabratoryProjectRefNumber;
|
||||
_lastModified = copy.LastModified;
|
||||
_lastModifiedBy = copy.LastModifiedBy;
|
||||
_localOnly = copy.LocalOnly;
|
||||
_version = copy.Version;
|
||||
}
|
||||
|
||||
private enum fields
|
||||
{
|
||||
Name,
|
||||
LaboratoryName,
|
||||
LaboratoryContactName,
|
||||
LaboratoryContactPhone,
|
||||
LaboratoryContactFax,
|
||||
LaboratoryContactEmail,
|
||||
LaboratoryTestRefNumber,
|
||||
LaboratoryProjectRefNumber,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
LocalOnly,
|
||||
Version
|
||||
};
|
||||
|
||||
public Dictionary<string, string> GetValues()
|
||||
{
|
||||
var elementNameValuePairs = new Dictionary<string, string>();
|
||||
|
||||
elementNameValuePairs[fields.Name.ToString()] = Name;
|
||||
elementNameValuePairs[fields.LaboratoryName.ToString()] = LabratoryName;
|
||||
elementNameValuePairs[fields.LaboratoryContactName.ToString()] = LabratoryContactName;
|
||||
elementNameValuePairs[fields.LaboratoryContactPhone.ToString()] = LabratoryContactPhone;
|
||||
elementNameValuePairs[fields.LaboratoryContactFax.ToString()] = LabratoryContactFax;
|
||||
elementNameValuePairs[fields.LaboratoryContactEmail.ToString()] = LabratoryContactEmail;
|
||||
elementNameValuePairs[fields.LaboratoryTestRefNumber.ToString()] = LabratoryTestRefNumber;
|
||||
elementNameValuePairs[fields.LaboratoryProjectRefNumber.ToString()] = LabratoryProjectRefNumber;
|
||||
elementNameValuePairs[fields.LastModified.ToString()] =
|
||||
LastModified.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
elementNameValuePairs[fields.LastModifiedBy.ToString()] = LastModifiedBy;
|
||||
elementNameValuePairs[fields.LocalOnly.ToString()] = LocalOnly.ToString();
|
||||
elementNameValuePairs[fields.Version.ToString()] =
|
||||
Version.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
return elementNameValuePairs;
|
||||
}
|
||||
|
||||
private int _version = 1;
|
||||
|
||||
public int Version
|
||||
{
|
||||
get => _version;
|
||||
set => _version = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class FilterClass //: INotifyPropertyChanged
|
||||
{
|
||||
public enum FilterClassType
|
||||
{
|
||||
None = 0,
|
||||
AdHoc = -1,
|
||||
CFC10 = 17, // 17 Hz
|
||||
CFC60 = 100, // 100 Hz
|
||||
CFC180 = 300, // 300 Hz
|
||||
CFC600 = 1000, // 1000 Hz
|
||||
CFC1000 = 1650 // 1650 Hz
|
||||
}
|
||||
|
||||
public FilterClassType FClass { get; set; }
|
||||
|
||||
public double Frequency { get; set; }
|
||||
|
||||
public FilterClass(FilterClassType fc)
|
||||
{
|
||||
FClass = fc;
|
||||
switch (fc)
|
||||
{
|
||||
case FilterClassType.None:
|
||||
Frequency = 0;
|
||||
break;
|
||||
case FilterClassType.CFC10:
|
||||
Frequency = (double)FilterClassType.CFC10;
|
||||
break;
|
||||
case FilterClassType.CFC60:
|
||||
Frequency = (double)FilterClassType.CFC60;
|
||||
break;
|
||||
case FilterClassType.CFC180:
|
||||
Frequency = (double)FilterClassType.CFC180;
|
||||
break;
|
||||
case FilterClassType.CFC600:
|
||||
Frequency = (double)FilterClassType.CFC600;
|
||||
break;
|
||||
case FilterClassType.CFC1000:
|
||||
Frequency = (double)FilterClassType.CFC1000;
|
||||
break;
|
||||
default:
|
||||
throw new System.Exception("FilterClass: unknown class");
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
switch (FClass)
|
||||
{
|
||||
case FilterClassType.None:
|
||||
return "None";
|
||||
case FilterClassType.CFC10:
|
||||
return string.Format("{0} (CFC10)", (int)FilterClassType.CFC10);
|
||||
case FilterClassType.CFC60:
|
||||
return string.Format("{0} (CFC60)", (int)FilterClassType.CFC60);
|
||||
case FilterClassType.CFC180:
|
||||
return string.Format("{0} (CFC180)", (int)FilterClassType.CFC180);
|
||||
case FilterClassType.CFC600:
|
||||
return string.Format("{0} (CFC600)", (int)FilterClassType.CFC600);
|
||||
case FilterClassType.CFC1000:
|
||||
return string.Format("{0} (CFC1000)", (int)FilterClassType.CFC1000);
|
||||
case FilterClassType.AdHoc:
|
||||
return ((int)Frequency).ToString();
|
||||
}
|
||||
throw new System.Exception("FilterClass.ToString: Invalid class=" + FClass.ToString());
|
||||
}
|
||||
|
||||
public FilterClass(string fclass)
|
||||
{
|
||||
int fc;
|
||||
if (int.TryParse(fclass, NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out fc))
|
||||
{
|
||||
switch (fc)
|
||||
{
|
||||
case 17:
|
||||
FClass = FilterClassType.CFC10;
|
||||
Frequency = (double)FClass;
|
||||
return;
|
||||
case 100:
|
||||
FClass = FilterClassType.CFC60;
|
||||
Frequency = (double)FClass;
|
||||
return;
|
||||
case 300:
|
||||
FClass = FilterClassType.CFC180;
|
||||
Frequency = (double)FClass;
|
||||
return;
|
||||
case 1000:
|
||||
FClass = FilterClassType.CFC600;
|
||||
Frequency = (double)FClass;
|
||||
return;
|
||||
case 1650:
|
||||
FClass = FilterClassType.CFC1000;
|
||||
Frequency = (double)FClass;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(fclass) || fclass == "None")
|
||||
{
|
||||
FClass = FilterClassType.None;
|
||||
}
|
||||
else if (fclass.Contains("CFC1000"))
|
||||
{
|
||||
FClass = FilterClassType.CFC1000;
|
||||
Frequency = (double)FilterClassType.CFC1000;
|
||||
}
|
||||
else if (fclass.Contains("CFC10"))
|
||||
{
|
||||
FClass = FilterClassType.CFC10;
|
||||
Frequency = (double)FilterClassType.CFC10;
|
||||
}
|
||||
else if (fclass.Contains("CFC600"))
|
||||
{
|
||||
FClass = FilterClassType.CFC600;
|
||||
Frequency = (double)FilterClassType.CFC600;
|
||||
}
|
||||
else if (fclass.Contains("CFC60"))
|
||||
{
|
||||
FClass = FilterClassType.CFC60;
|
||||
Frequency = (double)FilterClassType.CFC60;
|
||||
}
|
||||
else if (fclass.Contains("CFC180"))
|
||||
{
|
||||
FClass = FilterClassType.CFC180;
|
||||
Frequency = (double)FilterClassType.CFC180;
|
||||
}
|
||||
else
|
||||
{
|
||||
FClass = FilterClassType.AdHoc;
|
||||
Frequency = Convert.ToDouble(fclass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// a simple setting in a test
|
||||
/// can have a default value, a value, and an id
|
||||
/// default value is used by TestSettingsDictionary for when
|
||||
/// the setting doesn't currently exist or have a value
|
||||
/// </summary>
|
||||
public class TestSetting
|
||||
{
|
||||
public string Id { get; }
|
||||
|
||||
public string Value { get; set; }
|
||||
|
||||
public string DefaultValue { get; }
|
||||
|
||||
private const string SEPARATOR = "_x_";
|
||||
public TestSetting(TestSetting copy, string value)
|
||||
{
|
||||
Id = copy.Id;
|
||||
DefaultValue = copy.DefaultValue;
|
||||
Value = value;
|
||||
}
|
||||
public TestSetting(TestSetting copy)
|
||||
{
|
||||
Id = copy.Id;
|
||||
DefaultValue = copy.DefaultValue;
|
||||
Value = copy.Value;
|
||||
}
|
||||
public TestSetting(string id, string value, string defaultValue)
|
||||
{
|
||||
Id = id;
|
||||
Value = value;
|
||||
DefaultValue = defaultValue;
|
||||
}
|
||||
public string ToSerializeString()
|
||||
{
|
||||
System.Diagnostics.Trace.Assert(Id.IndexOf(SEPARATOR) < 0);
|
||||
return string.Format("{0}={1}", Id.Replace("=", SEPARATOR), Value.Replace("=", SEPARATOR));
|
||||
}
|
||||
|
||||
public static bool TryParse(string s, out TestSetting ts)
|
||||
{
|
||||
ts = null;
|
||||
|
||||
var tokens = s.Split(new[] { "=" }, StringSplitOptions.None);
|
||||
if (tokens.Length < 2) { return false; }
|
||||
var id = tokens[0].Replace(SEPARATOR, "=");
|
||||
var val = tokens[1].Replace(SEPARATOR, "=");
|
||||
ts = new TestSetting(id, val, val);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// holds all possible settings for a test
|
||||
/// </summary>
|
||||
public class TestSettingDictionary
|
||||
{
|
||||
public TestSettingDictionary()
|
||||
{
|
||||
}
|
||||
public TestSettingDictionary(TestSettingDictionary copy)
|
||||
{
|
||||
var e = copy._lookup.GetEnumerator();
|
||||
while (e.MoveNext())
|
||||
{
|
||||
_lookup[e.Current.Key] = new TestSetting(e.Current.Value);
|
||||
}
|
||||
}
|
||||
private const string _SEPARATOR = "_X_";
|
||||
private Dictionary<string, TestSetting> _lookup = new Dictionary<string, TestSetting>();
|
||||
public string GetValue(string ID, string defaultValue)
|
||||
{
|
||||
if (!_lookup.ContainsKey(ID)) { return defaultValue; }
|
||||
else
|
||||
{
|
||||
if (null == _lookup[ID].Value) { return _lookup[ID].DefaultValue; }
|
||||
else { return _lookup[ID].Value; }
|
||||
}
|
||||
}
|
||||
public void UnLoad()
|
||||
{
|
||||
_lookup.Clear();
|
||||
}
|
||||
/// <summary>
|
||||
/// used to change the value in the dictionary (just the value, leave everything else the same)
|
||||
/// </summary>
|
||||
/// <param name="setting"></param>
|
||||
/// <param name="value"></param>
|
||||
public void SetValue(TestSetting setting, string value)
|
||||
{
|
||||
//we do it this way to avoid Add() and also to avoid accidentally reusing the input setting inappropriately
|
||||
_lookup[setting.Id] = new TestSetting(setting, value);
|
||||
}
|
||||
/// <summary>
|
||||
/// used to initialize a value in the dictionary
|
||||
/// </summary>
|
||||
/// <param name="setting"></param>
|
||||
public void SetValue(TestSetting setting)
|
||||
{
|
||||
_lookup[setting.Id] = setting;
|
||||
}
|
||||
public void SetValue(string id, string value)
|
||||
{
|
||||
if (!_lookup.ContainsKey(id))
|
||||
{
|
||||
_lookup[id] = new TestSetting(id, value, value);
|
||||
}
|
||||
else { _lookup[id].Value = value; }
|
||||
}
|
||||
public string ToSerializeString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var s in _lookup.Values)
|
||||
{
|
||||
var sVal = s.ToSerializeString();
|
||||
System.Diagnostics.Trace.Assert(sVal.IndexOf(_SEPARATOR) < 0);
|
||||
sVal = sVal.Replace(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, _SEPARATOR);
|
||||
if (sb.Length > 0) { sb.Append(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator); }
|
||||
sb.Append(sVal);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
public void LoadSettings(string s)
|
||||
{
|
||||
var tokens = s.Split(new[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
var tok = token.Replace(_SEPARATOR, System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator);
|
||||
TestSetting ts;
|
||||
//we prefer the default settings from the application
|
||||
//if for some reason this key is no longer used, we can still stick it in the storage and use it as is
|
||||
if (TestSetting.TryParse(tok, out ts))
|
||||
{
|
||||
if (!_lookup.ContainsKey(ts.Id))//no longer has a default setting, just use as is
|
||||
{
|
||||
_lookup[ts.Id] = ts;
|
||||
}
|
||||
else { _lookup[ts.Id].Value = ts.Value; }//default setting exists, just set the value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport.ISO
|
||||
{
|
||||
public class TestObject
|
||||
{
|
||||
private List<TestObjectChannel> _allChannels = new List<TestObjectChannel>();
|
||||
public TestObjectChannel[] AllChannels
|
||||
{
|
||||
get => _allChannels.ToArray();
|
||||
set
|
||||
{
|
||||
_allChannels = new List<TestObjectChannel>(value);
|
||||
SortChannels();
|
||||
}
|
||||
}
|
||||
|
||||
public void SortChannels()
|
||||
{
|
||||
_allChannels.Sort();
|
||||
}
|
||||
|
||||
public TestObjectChannel GetChannel(string channelid)
|
||||
{
|
||||
return Array.Find(AllChannels, ch => ch.GetID() == channelid || ch.Name == channelid);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Embedded ? DisplaySerialNumber : SerialNumber;
|
||||
}
|
||||
|
||||
public string DisplaySerialNumber => SysBuilt ? SerialNumberConverted : OriginalSerialNumber;
|
||||
|
||||
public string SerialNumberConverted { get; set; }
|
||||
|
||||
public string SerialNumber { get; set; }
|
||||
|
||||
public string SerialNumberOrOriginalSerialNumber => Embedded ? OriginalSerialNumber : SerialNumber;
|
||||
|
||||
public string TestObjectType { get; set; }
|
||||
|
||||
public string ParentObject { get; set; }
|
||||
|
||||
public bool SysBuilt { get; set; }
|
||||
|
||||
// public string TextL1 { get; set; }
|
||||
|
||||
private List<string> _hardwareIds = new List<string>();
|
||||
public string[] HardwareIds
|
||||
{
|
||||
get => _hardwareIds.ToArray();
|
||||
set { _hardwareIds.Clear(); _hardwareIds.AddRange(value); }
|
||||
}
|
||||
|
||||
public string Template { get; set; }
|
||||
|
||||
public void SetTemplateOnly(string value) { Template = value; }
|
||||
public void SetTemplate(string value, ref ISO13499FileDb db)
|
||||
{
|
||||
Template = value;
|
||||
var template = ISO.TestObjectTemplate.GetTemplate(ref db, Template);
|
||||
SetTemplate(template);
|
||||
}
|
||||
public void SetTemplate(ISO.TestObjectTemplate template)
|
||||
{
|
||||
_allChannels.Clear();
|
||||
if (null == template) return;
|
||||
Template = template.TemplateName;
|
||||
AllChannels = template.Channels.Select(c => new TestObjectChannel(c, this, template)).ToArray();
|
||||
}
|
||||
private bool _localOnly;
|
||||
public bool LocalOnly
|
||||
{
|
||||
get => _localOnly;
|
||||
set => _localOnly = value;
|
||||
}
|
||||
private string _lastModifiedBy;
|
||||
public string LastModifiedBy
|
||||
{
|
||||
get => _lastModifiedBy;
|
||||
set => _lastModifiedBy = value;
|
||||
}
|
||||
private DateTime _lastModified;
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => _lastModified = value;
|
||||
}
|
||||
private TestObject(DataRow dr, ref ISO13499FileDb db)
|
||||
{
|
||||
OriginalTemplate = "";
|
||||
OriginalSerialNumber = "";
|
||||
SerialNumberConverted = string.Empty;
|
||||
TestObjectGuts(dr, ref db);
|
||||
}
|
||||
|
||||
public bool Embedded { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// original serial number of this group (the serial number will be changed once it's embedded in a test setup)
|
||||
/// </summary>
|
||||
public string OriginalSerialNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the original template for this group (the template is also changed once it's embedded in a test setup)
|
||||
/// </summary>
|
||||
public string OriginalTemplate { get; set; }
|
||||
|
||||
private void TestObjectGuts(DataRow dr, ref ISO13499FileDb db)
|
||||
{
|
||||
SerialNumber = (string)dr["SerialNumber"];
|
||||
LocalOnly = Convert.ToBoolean(dr["LocalOnly"]);
|
||||
SetTemplate((string)dr["Template"], ref db);
|
||||
LastModifiedBy = (string)dr["LastModifiedBy"];
|
||||
LastModified = Convert.ToDateTime(dr["LastModified"]);
|
||||
SysBuilt = Convert.ToBoolean(dr["SysBuilt"]);
|
||||
var o = dr["Embedded"];
|
||||
if (!DBNull.Value.Equals(o))
|
||||
{
|
||||
Embedded = Convert.ToBoolean(o);
|
||||
}
|
||||
o = dr["OrigSerialNumber"];
|
||||
if (!DBNull.Value.Equals(o))
|
||||
{
|
||||
OriginalSerialNumber = Convert.ToString(o);
|
||||
}
|
||||
o = dr["OrigTEmplate"];
|
||||
if (!DBNull.Value.Equals(o))
|
||||
{
|
||||
OriginalTemplate = Convert.ToString(o);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (!DBNull.Value.Equals(dr["ParentObject"]))
|
||||
{
|
||||
ParentObject = (string)dr["ParentObject"];
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log(ex);*/ }
|
||||
try
|
||||
{
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
DbOperations.CreateParam(sql, string.Format("@{0}", DbOperations.TestObjectChannelSettings.Fields.TestObjectSerial),
|
||||
SqlDbType.NVarChar, SerialNumber);
|
||||
sql.CommandText = string.Format("SELECT * from [{0}] where [{1}]=@{1}", DbOperations.TestObjectChannelSettings.TableName,
|
||||
DbOperations.TestObjectChannelSettings.Fields.TestObjectSerial);
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (ds.Tables[0].Rows.Count <= 0) return;
|
||||
foreach (DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
var channelId = (string)row[DbOperations.TestObjectChannelSettings.Fields.ChannelId.ToString()];
|
||||
var sensor = (string)row[DbOperations.TestObjectChannelSettings.Fields.SensorSerial.ToString()];
|
||||
var settings = (string)row[DbOperations.TestObjectChannelSettings.Fields.Setting.ToString()];
|
||||
if (string.IsNullOrEmpty(channelId) || string.IsNullOrEmpty(sensor) ||
|
||||
string.IsNullOrEmpty(settings)) continue;
|
||||
var sensorsettings = GetSettingsFromString(settings, sensor, channelId);
|
||||
foreach (var setting in sensorsettings)
|
||||
{
|
||||
SetSensorSetting(channelId, sensor, setting);
|
||||
}
|
||||
}
|
||||
catch (Exception) {/* APILogger.Log(ex);*/ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log(ex); */}
|
||||
}
|
||||
public static SensorSetting[] GetSettingsFromString(string s, string sensor, string channelid)
|
||||
{
|
||||
var tokens = s.Split(',');
|
||||
|
||||
return (from token in tokens select token.Split('=') into subtokens let setting = (SensorSettings)Convert.ToInt32(subtokens[0]) select new SensorSetting(setting, subtokens[1], channelid, sensor)).ToArray();
|
||||
}
|
||||
public TestObject()
|
||||
{
|
||||
OriginalTemplate = "";
|
||||
OriginalSerialNumber = "";
|
||||
SerialNumberConverted = string.Empty;
|
||||
_allChannels = new List<TestObjectChannel>();
|
||||
_hardwareIds = new List<string>();
|
||||
LastModified = DateTime.MinValue;
|
||||
LastModifiedBy = "N/A";
|
||||
LocalOnly = false;
|
||||
SerialNumber = "";
|
||||
Template = "";
|
||||
ParentObject = "";
|
||||
}
|
||||
public enum SensorSettings
|
||||
{
|
||||
Range,
|
||||
CFC,
|
||||
Polarity,
|
||||
Position,
|
||||
LimitDuration,
|
||||
Duration,
|
||||
Delay,
|
||||
OutputMode,
|
||||
SQMode,
|
||||
DIMode,
|
||||
DefaultValue,
|
||||
ActiveValue
|
||||
}
|
||||
public class SensorSetting
|
||||
{
|
||||
public string ChannelId { get; set; }
|
||||
public string SerialNumber { get; set; }
|
||||
public SensorSettings Setting { get; set; }
|
||||
public string Value { get; set; }
|
||||
public SensorSetting(SensorSettings setting, string value, string channelId, string serialNumber)
|
||||
{
|
||||
ChannelId = channelId;
|
||||
Value = value;
|
||||
Setting = setting;
|
||||
SerialNumber = serialNumber;
|
||||
}
|
||||
public SensorSetting(SensorSetting copy)
|
||||
{
|
||||
ChannelId = copy.ChannelId;
|
||||
Value = copy.Value;
|
||||
Setting = copy.Setting;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
}
|
||||
}
|
||||
private Dictionary<string, Dictionary<string, Dictionary<SensorSettings, SensorSetting>>> _sensorSettings = new Dictionary<string, Dictionary<string, Dictionary<SensorSettings, SensorSetting>>>();
|
||||
|
||||
public SensorSetting[] GetSensorSettings(string channelId, string serialNumber)
|
||||
{
|
||||
if (!_sensorSettings.ContainsKey(channelId)) return new SensorSetting[0];
|
||||
return _sensorSettings[channelId].ContainsKey(serialNumber) ? _sensorSettings[channelId][serialNumber].Values.ToArray() : new SensorSetting[0];
|
||||
}
|
||||
public void SetSensorSetting(string channelId, string serialNumber, SensorSetting setting)
|
||||
{
|
||||
if (!_sensorSettings.ContainsKey(channelId)) { _sensorSettings[channelId] = new Dictionary<string, Dictionary<SensorSettings, SensorSetting>>(); }
|
||||
if (!_sensorSettings[channelId].ContainsKey(serialNumber)) { _sensorSettings[channelId][serialNumber] = new Dictionary<SensorSettings, SensorSetting>(); }
|
||||
_sensorSettings[channelId][serialNumber][setting.Setting] = setting;
|
||||
}
|
||||
public TestObject(TestObject copy, ref ISO13499FileDb db)
|
||||
{
|
||||
SerialNumberConverted = string.Empty;
|
||||
OriginalSerialNumber = copy.OriginalSerialNumber;
|
||||
OriginalTemplate = copy.OriginalTemplate;
|
||||
Embedded = copy.Embedded;
|
||||
|
||||
_allChannels = new List<TestObjectChannel>();
|
||||
|
||||
var t = TestObjectTemplate.GetTemplate(ref db, Template);
|
||||
|
||||
copy.SortChannels();
|
||||
foreach (var c in copy.AllChannels) { _allChannels.Add(new TestObjectChannel(c, this, t)); }
|
||||
|
||||
for (var i = 0; i < copy.AllChannels.Length && i < _allChannels.Count; i++)
|
||||
{
|
||||
_allChannels[i].ChannelIDX = i;
|
||||
}
|
||||
|
||||
_hardwareIds = new List<string>(copy.HardwareIds);
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
Template = copy.Template;
|
||||
ParentObject = copy.ParentObject;
|
||||
SysBuilt = copy.SysBuilt;
|
||||
var e = copy._sensorSettings.GetEnumerator();
|
||||
_sensorSettings = new Dictionary<string, Dictionary<string, Dictionary<SensorSettings, SensorSetting>>>();
|
||||
while (e.MoveNext())
|
||||
{
|
||||
if (!_sensorSettings.ContainsKey(e.Current.Key))
|
||||
{
|
||||
_sensorSettings[e.Current.Key] = new Dictionary<string, Dictionary<SensorSettings, SensorSetting>>();
|
||||
}
|
||||
var e2 = copy._sensorSettings[e.Current.Key].GetEnumerator();
|
||||
while (e2.MoveNext())
|
||||
{
|
||||
if (!_sensorSettings[e.Current.Key].ContainsKey(e2.Current.Key))
|
||||
{
|
||||
_sensorSettings[e.Current.Key][e2.Current.Key] = new Dictionary<SensorSettings, SensorSetting>();
|
||||
}
|
||||
var e3 = copy._sensorSettings[e.Current.Key][e2.Current.Key].GetEnumerator();
|
||||
while (e3.MoveNext())
|
||||
{
|
||||
_sensorSettings[e.Current.Key][e2.Current.Key][e3.Current.Key] = new SensorSetting(e3.Current.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private const char CHANNEL_SEPARATOR = 'x';
|
||||
private void GetHardwareAndSensors()
|
||||
{
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
DbOperations.CreateParam(sql, "@TestObject", SqlDbType.NVarChar, SerialNumber);
|
||||
|
||||
sql.CommandText = "SELECT [HardwareId] from [tblTestObjectHardware] WHERE [TestObject]=@TestObject";
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (null != ds && ds.Tables.Count > 0)
|
||||
{
|
||||
var ids = new List<string>();
|
||||
for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
var id = (string)ds.Tables[0].Rows[i]["HardwareId"];
|
||||
var tokens = id.Split('_');
|
||||
if (tokens.Length == 3)
|
||||
{
|
||||
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)); }
|
||||
id = sb.ToString();
|
||||
}
|
||||
if (!ids.Contains(id)) { ids.Add(id); }
|
||||
}
|
||||
_hardwareIds = ids;
|
||||
}
|
||||
}
|
||||
}
|
||||
var channelLookup = AllChannels.ToDictionary(ch => ch.GetID());
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
DbOperations.CreateParam(sql, "@TestObjectId", SqlDbType.NVarChar, SerialNumber);
|
||||
|
||||
sql.CommandText = "SELECT [UIChannelID],[SensorId],[ZoneId],[HardwareId],[ChannelIdx] FROM [tblTestObjectSensors] WHERE [TestObjectId]=@TestObjectId";
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (null != ds && ds.Tables.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var id = Convert.ToString(dr[0]);
|
||||
var sensorId = "";
|
||||
var hardwareId = "";
|
||||
var channelIdx = -1;
|
||||
if (!DBNull.Value.Equals(dr["ChannelIdx"])) { channelIdx = Convert.ToInt32(dr["ChannelIdx"]); }
|
||||
if (!DBNull.Value.Equals(dr[1])) { sensorId = Convert.ToString(dr[1]); }
|
||||
if (!DBNull.Value.Equals(dr[3]))
|
||||
{
|
||||
hardwareId = Convert.ToString(dr[3]);
|
||||
var tokens = hardwareId.Split('_');
|
||||
if (3 == tokens.Length)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendFormat("{0}_{1}", tokens[0], tokens[1]);
|
||||
var index = tokens[2].IndexOf('x');
|
||||
if (index >= 0) { sb.Append(tokens[2].Substring(index)); }
|
||||
hardwareId = sb.ToString();
|
||||
}
|
||||
}
|
||||
if (!channelLookup.ContainsKey(id)) continue;
|
||||
channelLookup[id].SensorSerialNumber = sensorId;
|
||||
channelLookup[id].HardwareId = hardwareId;
|
||||
channelLookup[id].ChannelIDX = channelIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SortChannels();
|
||||
}
|
||||
public string GetSerializedSetting(SensorSetting[] settings)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var bNeedComma = false;
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
if (bNeedComma) { sb.Append(","); }
|
||||
bNeedComma = true;
|
||||
|
||||
sb.AppendFormat("{0}={1}", (int)setting.Setting, setting.Value);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
public static TestObject GetTestObject(string serialNumber, ref ISO13499FileDb db)
|
||||
{
|
||||
try
|
||||
{
|
||||
TestObject testObject = null;
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
DbOperations.CreateParam(sql, "@1", SqlDbType.NVarChar, serialNumber);
|
||||
sql.CommandText = "Select * FROM [tblTestObjects] WHERE [SerialNumber] = @1";
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (null != ds && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
//var testObject = new TestObject(ds.Tables[0].Rows[0], ref db);
|
||||
testObject = new TestObject(ds.Tables[0].Rows[0], ref db);
|
||||
testObject.GetHardwareAndSensors();
|
||||
//return testObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
return testObject;
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve test objects", ex);*/ }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* ExceptionalList.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// A version of <see cref="T:List"/> that provides its own exception type.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="T">
|
||||
/// The type of object contained by this list.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Sample usage:
|
||||
/// public class A : ExceptionalList <int>
|
||||
/// {
|
||||
/// public void ScrewItUp( )
|
||||
/// {
|
||||
/// private bool error = true;
|
||||
/// if ( error ) throw new A.Exception( "Class A-specific screwup." );
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// ...
|
||||
///
|
||||
/// try
|
||||
/// {
|
||||
/// A.ScrewItUp( );
|
||||
/// B.ScrewItUp( );
|
||||
/// C.ScrewItUp( );
|
||||
/// }
|
||||
/// catch ( A.Exception ex )
|
||||
/// {
|
||||
/// // Can pick A's exceptions out of a crowd, or not and just treat it
|
||||
/// // polymorphically as a System.Exception.
|
||||
/// }
|
||||
/// </remarks>
|
||||
///
|
||||
[global::System.Serializable]
|
||||
public class ExceptionalList<T> : List<T>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* DTS.Slice.Control.DAS.Channel.IFilterable.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// Methodical definition of a filterable slice control event module channle.
|
||||
/// </summary>
|
||||
public interface IFilterable
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class MMEPositions : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Position { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
|
||||
public MMEPositions(string sGuid, string position, string textL1, string textL2, long version,
|
||||
DateTime date, string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText,
|
||||
string history, MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
Position = position;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
public static MMEPositions[] GetPositions()
|
||||
{
|
||||
var positions = new List<MMEPositions>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMEPositions";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string position = ISOReader["POSITION"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = GetLong(ISOReader, "VERSION");
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
positions.Add(new MMEPositions(sGuid, position, textL1, textL2, version, date, remarks, expired, sortkey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * FROM {0}", DbOperations.MMETables.MMEPositionsTable);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.MMETables.MMEPositionsFields))
|
||||
.Cast<DbOperations.MMETables.MMEPositionsFields>().ToArray();
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var version = 0;
|
||||
var text2 = "";
|
||||
var text1 = "";
|
||||
var sortKey = "";
|
||||
var sGuid = "";
|
||||
var remarks = "";
|
||||
var position = "?";
|
||||
var lastChangeText = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var history = "";
|
||||
var expired = false;
|
||||
var date = DateTime.Now;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()])) { continue; }
|
||||
|
||||
var o = dr[field.ToString()];
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMEPositionsFields.DATE:
|
||||
date = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPositionsFields.EXPIRED:
|
||||
expired = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPositionsFields.HISTORY:
|
||||
history = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPositionsFields.LAST_CHANGE:
|
||||
lastChange = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPositionsFields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPositionsFields.POSITION:
|
||||
position = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPositionsFields.REMARKS:
|
||||
remarks = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPositionsFields.s_GUID:
|
||||
sGuid = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPositionsFields.SORTKEY:
|
||||
sortKey = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPositionsFields.TEXT_L1:
|
||||
text1 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPositionsFields.TEXT_L2:
|
||||
text2 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPositionsFields.VERSION:
|
||||
version = Convert.ToInt32(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
positions.Add(new MMEPositions(sGuid.ToString(), position, text1, text2, Convert.ToInt64(version), date, remarks, expired,
|
||||
sortKey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
return positions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class SensorsCollection //: INotifyPropertyChanged
|
||||
{
|
||||
private static object _lock = new object();
|
||||
private static SensorsCollection _sensorCollection = null;
|
||||
public static SensorsCollection SensorsList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _sensorCollection ?? (_sensorCollection = new SensorsCollection());
|
||||
}
|
||||
}
|
||||
}
|
||||
private Dictionary<string, SensorData> _sensorDictionary;
|
||||
/// <summary>
|
||||
/// we keep two dictionaries for sensor ids
|
||||
/// 1) we want efficient look up for existing ids
|
||||
/// 2) we need to clean out the lookup. if someone commits an existing sensor that had an id with a different id or no id, we have to clean up
|
||||
/// </summary>
|
||||
private Dictionary<string, List<SensorData>> _sensorIDToSensors;
|
||||
private Dictionary<string, string> _serialNumberToStoredSensorId;
|
||||
public SensorsCollection()
|
||||
{
|
||||
LoadAllSensors();
|
||||
}
|
||||
private void LoadAllSensors()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_sensorDictionary = new Dictionary<string, SensorData>();
|
||||
_serialNumberToStoredSensorId = new Dictionary<string, string>();
|
||||
_sensorIDToSensors = new Dictionary<string, List<SensorData>>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
//sp_GetSensors
|
||||
cmd.CommandText = @"SELECT [SerialNumber],[UserSerialNumber],[Model],[Manufacturer],[Status],[MeasurementUnit],[OffsetToleranceLow],[OffsetToleranceHigh],[Id],[Capacity],[Comment],[BridgeType],[BridgeLegMode],[Shunt],[Invert],[UserValue1],[UserValue2],[UserValue3],[FilterClass],[BridgeResistance],[IsoCode],[CheckOffset],[SupportedExcitation],[InitialEU],[CalInterval],[CalibrationSignal],[InternalShuntResistance],[ExternalShuntResistance],[UniPolar],[RangeLow],[RangeAve],[RangeHigh],[Created],[TimesUsed],[SensorCategory],[BypassFilter],[CouplingMode],[Version],[LastModified],[ModifiedBy],[LocalOnly],[AxisNumber],[NumberOfAxes],[DbTimeStamp],[UserTags],[DoNotUse],[Broken] FROM [tblSensors]";
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sd = new SensorData(dr);
|
||||
if (!_sensorDictionary.ContainsKey(sd.SerialNumber))
|
||||
{
|
||||
_sensorDictionary.Add(sd.SerialNumber, sd);
|
||||
if (string.IsNullOrEmpty(sd.Id)) continue;
|
||||
if (!_sensorIDToSensors.ContainsKey(sd.Id))
|
||||
{
|
||||
_sensorIDToSensors.Add(sd.Id, new List<SensorData>());
|
||||
}
|
||||
_sensorIDToSensors[sd.Id].Add(sd);
|
||||
_serialNumberToStoredSensorId[sd.SerialNumber] = sd.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
//well we are in effect ignoring previous ones here, so lets clean up
|
||||
//the sensor id association information ...
|
||||
if (_serialNumberToStoredSensorId.ContainsKey(sd.SerialNumber))
|
||||
{
|
||||
//its gots it so we've gots to clean up
|
||||
var oldId = _serialNumberToStoredSensorId[sd.SerialNumber];
|
||||
var list = _sensorIDToSensors[oldId];
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (list[i].SerialNumber == sd.SerialNumber)
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
if (list.Count > 0) { _sensorIDToSensors[oldId] = list; }
|
||||
else { _sensorIDToSensors.Remove(oldId); }
|
||||
_serialNumberToStoredSensorId.Remove(sd.SerialNumber);
|
||||
}
|
||||
_sensorDictionary[sd.SerialNumber] = sd;
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*Utilities.Logging.APILogger.Log("Failed to load sensor: ", ex2);*/ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*Utilities.Logging.APILogger.Log("Failed to load Sensors: ", ex); */}
|
||||
try
|
||||
{
|
||||
var settings = new List<DigitalInputSetting>();
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
cmd.CommandText = @"SELECT * FROM tblDigitalInputSetting";
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.DigitalInputSettings.Fields)).Cast<DbOperations.DigitalInputSettings.Fields>().ToArray();
|
||||
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var s = new DigitalInputSetting();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
var o = dr[field.ToString()];
|
||||
if (null == o || DBNull.Value.Equals(o)) { continue; }
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.DigitalInputSettings.Fields.LastModified: s.LastModified = Convert.ToDateTime(o); break;
|
||||
case DbOperations.DigitalInputSettings.Fields.LastModifiedBy: s.LastUpdatedBy = Convert.ToString(o); break;
|
||||
case DbOperations.DigitalInputSettings.Fields.ScaleMultiplier: s.ScaleMultiplier.FromDbSerializeString(Convert.ToString(o)); break;
|
||||
case DbOperations.DigitalInputSettings.Fields.SettingMode: s.InputMode = (DigitalInputScaleMultiplier.InputModes)Convert.ToInt32(o); break;
|
||||
case DbOperations.DigitalInputSettings.Fields.SettingName: s.SettingName = Convert.ToString(o); break;
|
||||
case DbOperations.DigitalInputSettings.Fields.SensorId: s.Id = Convert.ToString(o); break;
|
||||
case DbOperations.DigitalInputSettings.Fields.UserValue1:
|
||||
s.UserValue1 = Convert.ToString(o);
|
||||
s.Comment = s.UserValue1;
|
||||
break;
|
||||
case DbOperations.DigitalInputSettings.Fields.UserValue2:
|
||||
s.UserValue2 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.DigitalInputSettings.Fields.UserValue3:
|
||||
s.UserValue3 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.DigitalInputSettings.Fields.UserTags:
|
||||
s.TagsBlobBytes = (byte[])o;
|
||||
break;
|
||||
default: throw new NotSupportedException("DigitalInputSettingsList::DigitalInputSettingsList unsupported column: " + field.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception) {/* Utilities.Logging.APILogger.Log(ex); */}
|
||||
}
|
||||
settings.Add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var s in settings)
|
||||
{
|
||||
if (_sensorDictionary.ContainsKey(s.SerialNumber))
|
||||
{
|
||||
//don't load it, just ignore the setting
|
||||
}
|
||||
else
|
||||
{
|
||||
_sensorDictionary[s.SerialNumber] = s;
|
||||
if (string.IsNullOrWhiteSpace(s.Id)) continue;
|
||||
if (!_sensorIDToSensors.ContainsKey(s.Id)) { _sensorIDToSensors.Add(s.Id, new List<SensorData>()); }
|
||||
_sensorIDToSensors[s.Id].Add(s);
|
||||
_serialNumberToStoredSensorId[s.SerialNumber] = s.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) {/* Utilities.Logging.APILogger.Log(ex);*/ }
|
||||
try
|
||||
{
|
||||
var settings = new List<SquibSetting>();
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
cmd.CommandText = @"SELECT * FROM tblTOMSquibChannels";
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
try { settings.Add(new SquibSetting(dr)); }
|
||||
catch (Exception) {/* Utilities.Logging.APILogger.Log(ex);*/ }
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var s in settings)
|
||||
{
|
||||
if (_sensorDictionary.ContainsKey(s.SerialNumber))
|
||||
{
|
||||
//serial number already exists as something else, ignore this one!
|
||||
}
|
||||
else
|
||||
{
|
||||
_sensorDictionary[s.SerialNumber] = s;
|
||||
if (!string.IsNullOrWhiteSpace(s.Id))
|
||||
{
|
||||
if (!_sensorIDToSensors.ContainsKey(s.Id))
|
||||
{
|
||||
_sensorIDToSensors.Add(s.Id, new List<SensorData>());
|
||||
}
|
||||
_sensorIDToSensors[s.Id].Add(s);
|
||||
_serialNumberToStoredSensorId[s.SerialNumber] = s.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*Utilities.Logging.APILogger.Log(ex);*/ }
|
||||
try
|
||||
{
|
||||
var lDOS = new List<DigitalOutputSetting>();
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
cmd.CommandText = @"SELECT * FROM tblTOMDigitalChannels";
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
try { lDOS.Add(new DigitalOutputSetting(dr)); }
|
||||
catch (Exception) { /*Utilities.Logging.APILogger.Log(ex);*/ }
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var s in lDOS)
|
||||
{
|
||||
if (!_sensorDictionary.ContainsKey(s.SerialNumber))
|
||||
{
|
||||
_sensorDictionary[s.SerialNumber] = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*Utilities.Logging.APILogger.Log(ex);*/ }
|
||||
}
|
||||
}
|
||||
//TODO: fix broken
|
||||
public SensorData GetSensorBySerialNumber(string serialNumber, bool excludeBroken = true)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (!_sensorDictionary.ContainsKey(serialNumber))
|
||||
{
|
||||
if (!SensorData.IsTestSpecificDigitalOutSN(serialNumber)) return null;
|
||||
var sd = new DigitalOutputSetting { SerialNumber = serialNumber };
|
||||
return sd;
|
||||
}
|
||||
else
|
||||
{
|
||||
var sd = _sensorDictionary[serialNumber];
|
||||
if (excludeBroken) { if (sd.Broken || sd.DoNotUse) { return null; } }
|
||||
if (sd.NumberOfAxes > 1 || sd.AxisNumber > 0) { return null; }
|
||||
//for now eliminate multiple axes sensors
|
||||
//per 6093 Disable 6-axis sensor capability
|
||||
// "Prefiltered > CFC 1000" (Unfiltered)
|
||||
if (sd.FilterClassIso == "?") { sd.FilterClassIso = "P"; }
|
||||
return sd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a list of all sensors, even those marked Broken or Do Not Use
|
||||
/// </summary>
|
||||
public SensorData[] AllSensorsDb
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
var l = new List<SensorData>(_sensorDictionary.Values.ToArray());
|
||||
//for now eliminate multiple axes sensors per 6093 Disable 6-axis sensor capability
|
||||
for (var i = l.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (l[i].NumberOfAxes > 1 || l[i].AxisNumber > 0) { l.RemoveAt(i); }
|
||||
}
|
||||
l.Sort();
|
||||
return l.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public abstract class AbstractOLEDbWrapper
|
||||
{
|
||||
public static long GetLong(IDataReader reader, string field)
|
||||
{
|
||||
if (DBNull.Value == reader[field]) { return long.MinValue; }
|
||||
else { return Convert.ToInt64(reader[field]); }
|
||||
}
|
||||
public static DateTime GetDate(IDataReader reader, string field)
|
||||
{
|
||||
if (DBNull.Value != reader[field]) { return (DateTime)reader[field]; }
|
||||
else { return DateTime.MinValue; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public enum SensorStatus
|
||||
{
|
||||
Available,
|
||||
InUse,
|
||||
OutForService,
|
||||
OutForCalibration,
|
||||
Retired
|
||||
}
|
||||
|
||||
public enum ShuntMode
|
||||
{
|
||||
None,
|
||||
Emulation,
|
||||
Internal,
|
||||
External
|
||||
}
|
||||
|
||||
public enum BridgeLeg
|
||||
{
|
||||
First,
|
||||
Second,
|
||||
Third,
|
||||
Fourth
|
||||
}
|
||||
|
||||
public enum CouplingModes
|
||||
{
|
||||
AC = 0,
|
||||
DC
|
||||
}
|
||||
|
||||
public class LowHigh //: INotifyPropertyChanged
|
||||
{
|
||||
public double Low { get; set; }
|
||||
|
||||
public double High { get; set; }
|
||||
public LowHigh(double _low, double _high)
|
||||
{
|
||||
Low = _low;
|
||||
High = _high;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class MMEPhysicalDimensions : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Physical_Dimension { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public string Default_Unit { get; }
|
||||
|
||||
public long Length_EXP { get; }
|
||||
|
||||
public long Time_EXP { get; }
|
||||
|
||||
public long Mass_EXP { get; }
|
||||
|
||||
public long Electric_Current_EXP { get; }
|
||||
|
||||
public long Temperature_EXP { get; }
|
||||
|
||||
public long Luminous_Intensity_Exp { get; }
|
||||
|
||||
public long Amount_Of_Substance_EXP { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
|
||||
public MMEPhysicalDimensions(string sGUID, string physicalDimension, string textL1, string textL2, string defaultUnit,
|
||||
long lengthExp, long timeExp, long massExp, long currentExp, long temperatureExp, long luminiousExp, long amountExp,
|
||||
long version, DateTime date, string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText,
|
||||
string history, MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGUID;
|
||||
Physical_Dimension = physicalDimension;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Default_Unit = defaultUnit;
|
||||
Length_EXP = lengthExp;
|
||||
Time_EXP = timeExp;
|
||||
Mass_EXP = massExp;
|
||||
Electric_Current_EXP = currentExp;
|
||||
Temperature_EXP = temperatureExp;
|
||||
Luminous_Intensity_Exp = luminiousExp;
|
||||
Amount_Of_Substance_EXP = amountExp;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
public static MMEPhysicalDimensions[] GetPhysicalDimensions()
|
||||
{
|
||||
var physicalDimensions = new List<MMEPhysicalDimensions>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandType = CommandType.Text;
|
||||
cmd.CommandText = "SELECT * FROM MMEPhysicalDimensions";
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string physicalDimension = ISOReader["PHYSICAL_DIMENSION"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
string defaultUnit = ISOReader["DEFAULT_UNIT"].ToString();
|
||||
long lengthExp = GetLong(ISOReader, "LENGTH_EXP");
|
||||
long timeExp = GetLong(ISOReader, "TIME_EXP");
|
||||
long massExp = GetLong(ISOReader, "MASS_EXP");
|
||||
long electricCurrentExp = GetLong(ISOReader, "ELECTRIC_CURRENT_EXP");
|
||||
long temperatureExp = GetLong(ISOReader, "TEMPERATURE_EXP");
|
||||
long luminiousExp = GetLong(ISOReader, "LUMINOUS_INTENSITY_EXP");
|
||||
long amountExp = GetLong(ISOReader, "AMOUNT_OF_SUBSTANCE_EXP");
|
||||
long version = GetLong(ISOReader, "VERSION");
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
|
||||
physicalDimensions.Add(new MMEPhysicalDimensions(sGuid, physicalDimension, textL1, textL2, defaultUnit, lengthExp,
|
||||
timeExp, massExp, electricCurrentExp, temperatureExp, luminiousExp, amountExp,
|
||||
version, date, remarks, expired, sortkey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * FROM {0}", DbOperations.MMETables.MMEPhysicalDimensions);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.MMETables.MMEPhysicalDimensionFields))
|
||||
.Cast<DbOperations.MMETables.MMEPhysicalDimensionFields>().ToArray();
|
||||
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var version = 0;
|
||||
var timeExp = 0;
|
||||
var text2 = "";
|
||||
var text1 = "";
|
||||
var tempExp = 0;
|
||||
var sortKey = "";
|
||||
var sGuid = "";
|
||||
var remarks = "";
|
||||
var physicalDimension = "??";
|
||||
var massExp = 0;
|
||||
var lumIntExp = 0;
|
||||
var lengthExp = 0;
|
||||
var lastChangeText = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var history = "";
|
||||
var expired = false;
|
||||
var electricalExp = 0;
|
||||
var defaultUnit = "";
|
||||
var date = DateTime.Now;
|
||||
var amountOfSubstanceExp = 0;
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()])) { continue; }
|
||||
var o = dr[field.ToString()];
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.AMOUNT_OFSUBSTANCE_EXP:
|
||||
amountOfSubstanceExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.DATE:
|
||||
date = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.DEFAULT_UNIT:
|
||||
defaultUnit = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.ELECTRIC_CURRENT_EXP:
|
||||
electricalExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.EXPIRED:
|
||||
expired = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.HISTORY:
|
||||
history = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE:
|
||||
lastChange = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.LENGTH_EXP:
|
||||
lengthExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.LUMINOUS_INTENSITY_EXP:
|
||||
lumIntExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.MASS_EXP:
|
||||
massExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.PHYSICAL_DIMENSION:
|
||||
physicalDimension = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.REMARKS:
|
||||
remarks = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.s_GUID:
|
||||
sGuid = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.SORTKEY:
|
||||
sortKey = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.TEMPERATURE_EXP:
|
||||
tempExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L1:
|
||||
text1 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L2:
|
||||
text2 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.TIME_EXP:
|
||||
timeExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.VERSION:
|
||||
version = Convert.ToInt32(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
physicalDimensions.Add(new MMEPhysicalDimensions(sGuid.ToString(), physicalDimension, text1, text2, defaultUnit, Convert.ToInt64(lengthExp),
|
||||
Convert.ToInt64(timeExp), Convert.ToInt64(massExp), Convert.ToInt64(electricalExp), Convert.ToInt64(tempExp), Convert.ToInt64(lumIntExp),
|
||||
Convert.ToInt64(amountOfSubstanceExp), Convert.ToInt64(version), date, remarks, expired, sortKey, lastChange, lastChangeText,
|
||||
history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
return physicalDimensions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace DatabaseExport
|
||||
{
|
||||
/// <summary>
|
||||
/// GUI wrapper for template channels ... it contains a testobjecttemplatechannel
|
||||
/// </summary>
|
||||
public class TemplateChannelUI
|
||||
{
|
||||
private TestObjectTemplateChannel _channel;
|
||||
public TemplateChannelUI(TestObjectTemplateChannel channel)
|
||||
{
|
||||
_channel = channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,588 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TestObjectTemplateChannel //: INotifyPropertyChanged
|
||||
{
|
||||
public const string NONISOCHANNELTYPE = "NONISO";
|
||||
private List<string> _channelPropertyNames = new List<string>();
|
||||
private Dictionary<string, ChannelProperty> _channelProperties = new Dictionary<string, ChannelProperty>();
|
||||
protected object GetProperty(string name, object defaultValue)
|
||||
{
|
||||
if (!_channelProperties.ContainsKey(name)) { _channelProperties[name] = new ChannelProperty(name, defaultValue); }
|
||||
return _channelProperties[name].Value;
|
||||
}
|
||||
protected void SetProperty(string name, object value)
|
||||
{
|
||||
if (!_channelProperties.ContainsKey(name)) { _channelProperties[name] = new ChannelProperty(name, value); }
|
||||
else { _channelProperties[name].Value = value; }
|
||||
//OnPropertyChanged("name"); // ? variable name instead of "name"
|
||||
}
|
||||
|
||||
public MMEPossibleChannels Channel { get; }
|
||||
|
||||
public const string SEPARATOR = "_X_";
|
||||
private bool _bRequired = false;
|
||||
|
||||
/// <summary>
|
||||
/// Required channel property raises the OnRequiredChanged event
|
||||
/// </summary>
|
||||
public bool Required
|
||||
{
|
||||
get => _bRequired;
|
||||
set
|
||||
{
|
||||
_bRequired = value;
|
||||
//OnRequiredChanged(new RequiredChangedEventArgs { NewValue = value });
|
||||
_bRequired = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool LocalOnly { get; set; } = false;
|
||||
|
||||
public enum ReferenceChannelTypes { IMPLICIT, EXPLICIT, NOVALUE };
|
||||
|
||||
public enum DataSourceTypes
|
||||
{
|
||||
Transducer,
|
||||
Calculation,
|
||||
Camera,
|
||||
Simulation,
|
||||
Parameter
|
||||
};
|
||||
|
||||
public enum DataStatusTypes
|
||||
{
|
||||
OK,
|
||||
ChannelFailed,
|
||||
MeaninglessData,
|
||||
NoData,
|
||||
QuestionableData,
|
||||
ScalingFactorApplied,
|
||||
SystemFailed,
|
||||
LinearisedData,
|
||||
NOVALUE
|
||||
}
|
||||
|
||||
public enum StandardChannelProperties
|
||||
{
|
||||
/*TestObjectNumber,*/
|
||||
NameOfTheChannel,
|
||||
/*LaboratoryChannelCode,
|
||||
CustomerChannelCode,
|
||||
ChannelCode,
|
||||
Comments1,
|
||||
Location,
|
||||
Dimension,
|
||||
Direction,
|
||||
ChannelFrequencyClass,
|
||||
Unit,
|
||||
ReferenceSystem,
|
||||
TransducerType,
|
||||
TransducerId,
|
||||
PreFilterType,
|
||||
CutOffFrequency,
|
||||
ChannelAmplitudeClass,
|
||||
ReferenceChannel,
|
||||
ReferenceChannelName,
|
||||
DataSource,
|
||||
DataStatus,
|
||||
SamplingInterval,
|
||||
BitResolution,
|
||||
TimeOfFirstSample,
|
||||
NumberOfSamples,
|
||||
OffsetPostTest,
|
||||
TransducerNaturalFrequency,
|
||||
TransducerDampingRatio,
|
||||
Comments2,
|
||||
FirstGlobalMaximumValue,
|
||||
TimeOfMaximumValue,
|
||||
FirstGlobalMinimumValue,
|
||||
TimeOfMinimumValue,
|
||||
StartOffsetInterval,
|
||||
EndOffsetInterval,*/
|
||||
DisplayOrder
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
if (null != Channel) { return string.Format("{0}({1})", Name, Channel.Id); }
|
||||
else { return Name; }
|
||||
}
|
||||
public TestObjectTemplateChannel(DataRow dr, ISO.TestObjectTemplate template, ref ISO13499FileDb db)
|
||||
{
|
||||
_template = template;
|
||||
AddStandardProperties();
|
||||
/*_channelProperties[StandardChannelProperties.TestObjectNumber.ToString()].Value = (string)dr["TestObjectNumber"];*/
|
||||
_channelProperties[StandardChannelProperties.NameOfTheChannel.ToString()].Value = (string)dr["NameOfTheChannel"];
|
||||
/*_channelProperties[StandardChannelProperties.LaboratoryChannelCode.ToString()].Value = (string)dr["LaboratoryChannelCode"];
|
||||
_channelProperties[StandardChannelProperties.CustomerChannelCode.ToString()].Value = (string)dr["CustomerChannelCode"];
|
||||
_channelProperties[StandardChannelProperties.Comments1.ToString()].Value = (string)dr["Comments1"];
|
||||
_channelProperties[StandardChannelProperties.Location.ToString()].Value = (string)dr["Location"];
|
||||
_channelProperties[StandardChannelProperties.Dimension.ToString()].Value = (string)dr["Dimension"];
|
||||
_channelProperties[StandardChannelProperties.Direction.ToString()].Value = (string)dr["Direction"];
|
||||
_channelProperties[StandardChannelProperties.ChannelFrequencyClass.ToString()].Value = (string)dr["ChannelFrequencyClass"];
|
||||
_channelProperties[StandardChannelProperties.Unit.ToString()].Value = (string)dr["Unit"];
|
||||
_channelProperties[StandardChannelProperties.ReferenceSystem.ToString()].Value = (string)dr["ReferenceSystem"];
|
||||
_channelProperties[StandardChannelProperties.TransducerType.ToString()].Value = (string)dr["TransducerType"];
|
||||
_channelProperties[StandardChannelProperties.TransducerId.ToString()].Value = (string)dr["TransducerId"];
|
||||
_channelProperties[StandardChannelProperties.PreFilterType.ToString()].Value = (string)dr["PreFilterType"];
|
||||
_channelProperties[StandardChannelProperties.CutOffFrequency.ToString()].Value = (string)dr["CutOffFrequency"];
|
||||
_channelProperties[StandardChannelProperties.ChannelAmplitudeClass.ToString()].Value = (string)dr["ChannelAmplitudeClass"];
|
||||
_channelProperties[StandardChannelProperties.ReferenceChannel.ToString()].Value = (ReferenceChannelTypes)Enum.Parse(typeof(ReferenceChannelTypes), (string)dr["ReferenceChannel"]);
|
||||
_channelProperties[StandardChannelProperties.ReferenceChannelName.ToString()].Value = (string)dr["ReferenceChannelName"];
|
||||
_channelProperties[StandardChannelProperties.DataSource.ToString()].Value = (DataSourceTypes)Enum.Parse(typeof(DataSourceTypes), (string)dr["DataSource"]);
|
||||
_channelProperties[StandardChannelProperties.DataStatus.ToString()].Value = (DataStatusTypes)Enum.Parse(typeof(DataStatusTypes), (string)dr["DataStatus"]);
|
||||
_channelProperties[StandardChannelProperties.SamplingInterval.ToString()].Value = (string)dr["SamplingInterval"];
|
||||
_channelProperties[StandardChannelProperties.BitResolution.ToString()].Value = (string)dr["BitResolution"];
|
||||
_channelProperties[StandardChannelProperties.TimeOfFirstSample.ToString()].Value = (string)dr["TimeOfFirstSample"];
|
||||
_channelProperties[StandardChannelProperties.NumberOfSamples.ToString()].Value = (string)dr["NumberOfSamples"];
|
||||
_channelProperties[StandardChannelProperties.OffsetPostTest.ToString()].Value = (string)dr["OffsetPostTest"];
|
||||
_channelProperties[StandardChannelProperties.TransducerNaturalFrequency.ToString()].Value = (string)dr["TransducerNaturalFrequency"];
|
||||
_channelProperties[StandardChannelProperties.TransducerDampingRatio.ToString()].Value = (string)dr["TransducerDampingRatio"];
|
||||
_channelProperties[StandardChannelProperties.Comments2.ToString()].Value = (string)dr["Comments"];
|
||||
_channelProperties[StandardChannelProperties.FirstGlobalMaximumValue.ToString()].Value = (string)dr["FirstGlobalMaximumValue"];
|
||||
_channelProperties[StandardChannelProperties.TimeOfMaximumValue.ToString()].Value = (string)dr["TimeOfMaximumValue"];
|
||||
_channelProperties[StandardChannelProperties.FirstGlobalMinimumValue.ToString()].Value = (string)dr["FirstGlobalMinimumValue"];
|
||||
_channelProperties[StandardChannelProperties.TimeOfMinimumValue.ToString()].Value = (string)dr["TimeOfMinimumValue"];
|
||||
_channelProperties[StandardChannelProperties.StartOffsetInterval.ToString()].Value = (string)dr["StartOffsetInterval"];
|
||||
_channelProperties[StandardChannelProperties.EndOffsetInterval.ToString()].Value = (string)dr["EndOffsetInterval"];
|
||||
*/
|
||||
_channelProperties[StandardChannelProperties.DisplayOrder.ToString()].Value = 0;
|
||||
if (!DBNull.Value.Equals(dr["DisplayOrder"]))
|
||||
{
|
||||
_channelProperties[StandardChannelProperties.DisplayOrder.ToString()].Value = Convert.ToInt32(dr["DisplayOrder"]).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
_bRequired = Convert.ToBoolean(dr["Required"]);
|
||||
LocalOnly = Convert.ToBoolean(dr["LocalOnly"]);
|
||||
var channelId = Convert.ToInt64(dr["MMEChannelId"]);
|
||||
var channelType = Convert.ToInt32(dr["MMEChannelType"]);
|
||||
Channel = db.GetPossibleChannel(channelId, channelType);
|
||||
}
|
||||
private void AddStandardProperties()
|
||||
{
|
||||
if (null != _channelProperties) { _channelProperties.Clear(); _channelProperties = null; }
|
||||
_channelProperties = new Dictionary<string, ChannelProperty>();
|
||||
var scp = Enum.GetValues(typeof(StandardChannelProperties)).Cast<StandardChannelProperties>().ToArray();
|
||||
foreach (var p in scp)
|
||||
{
|
||||
ChannelProperty cp = null;
|
||||
switch (p)
|
||||
{
|
||||
/*case StandardChannelProperties.BitResolution:
|
||||
cp = new ChannelProperty("Bit resolution", "16");
|
||||
break;
|
||||
case StandardChannelProperties.ChannelAmplitudeClass:
|
||||
cp = new ChannelProperty("Channel amplitude class", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.ChannelCode:
|
||||
cp = new ChannelProperty("Channel code", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.ChannelFrequencyClass:
|
||||
cp = new ChannelProperty("Channel frequency class", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.Comments1:
|
||||
cp = new ChannelProperty("Comments", "NOVALUE");
|
||||
break;*/
|
||||
case StandardChannelProperties.DisplayOrder:
|
||||
cp = new ChannelProperty(p.ToString(), "0");
|
||||
break;
|
||||
/*case StandardChannelProperties.Comments2:
|
||||
cp = new ChannelProperty("Comments", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.CustomerChannelCode:
|
||||
cp = new ChannelProperty("Customer channel code", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.CutOffFrequency:
|
||||
cp = new ChannelProperty("Cut off frequency", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.DataSource:
|
||||
cp = new ChannelProperty("Data source", DataSourceTypes.Transducer);
|
||||
break;
|
||||
case StandardChannelProperties.DataStatus:
|
||||
cp = new ChannelProperty("Data status", DataStatusTypes.NOVALUE);
|
||||
break;
|
||||
case StandardChannelProperties.Dimension:
|
||||
cp = new ChannelProperty("Dimension", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.Direction:
|
||||
cp = new ChannelProperty("Direction", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.EndOffsetInterval:
|
||||
cp = new ChannelProperty("End Offset Interval", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.FirstGlobalMaximumValue:
|
||||
cp = new ChannelProperty("First global maximum value", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.FirstGlobalMinimumValue:
|
||||
cp = new ChannelProperty("First global minimum value", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.LaboratoryChannelCode:
|
||||
cp = new ChannelProperty("Laboratory channel code", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.Location:
|
||||
cp = new ChannelProperty("Location", "NOVALUE");
|
||||
break;*/
|
||||
case StandardChannelProperties.NameOfTheChannel:
|
||||
cp = new ChannelProperty("Name of the channel", "NOVALUE");
|
||||
break;
|
||||
/*case StandardChannelProperties.NumberOfSamples:
|
||||
cp = new ChannelProperty("Number of samples", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.OffsetPostTest:
|
||||
cp = new ChannelProperty("Offset post test", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.PreFilterType:
|
||||
cp = new ChannelProperty("Pre-filter type", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.ReferenceChannel:
|
||||
cp = new ChannelProperty("Reference channel", ReferenceChannelTypes.NOVALUE);
|
||||
break;
|
||||
case StandardChannelProperties.ReferenceChannelName:
|
||||
cp = new ChannelProperty("Reference channel name", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.ReferenceSystem:
|
||||
cp = new ChannelProperty("Reference system", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.SamplingInterval:
|
||||
cp = new ChannelProperty("Sampling interval", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.StartOffsetInterval:
|
||||
cp = new ChannelProperty("Start offset interval", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.TestObjectNumber:
|
||||
cp = new ChannelProperty("Test object number", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.TimeOfFirstSample:
|
||||
cp = new ChannelProperty("Time of first sample", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.TimeOfMaximumValue:
|
||||
cp = new ChannelProperty("Time of maximum value", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.TimeOfMinimumValue:
|
||||
cp = new ChannelProperty("Time of minimum value", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.TransducerDampingRatio:
|
||||
cp = new ChannelProperty("Transducer damping ratio", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.TransducerId:
|
||||
cp = new ChannelProperty("Transducer id", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.TransducerNaturalFrequency:
|
||||
cp = new ChannelProperty("Transducer natural frequency", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.TransducerType:
|
||||
cp = new ChannelProperty("Transducer type", "NOVALUE");
|
||||
break;
|
||||
case StandardChannelProperties.Unit:
|
||||
cp = new ChannelProperty("Unit", "NOVALUE");
|
||||
break;*/
|
||||
default:
|
||||
cp = new ChannelProperty(p.ToString(), "NOVALUE");
|
||||
break;
|
||||
}
|
||||
_channelProperties.Add(p.ToString(), cp);
|
||||
}
|
||||
}
|
||||
public TestObjectTemplateChannel(TestObjectTemplateChannel copy, ISO.TestObjectTemplate template)
|
||||
{
|
||||
LocalOnly = copy.LocalOnly;
|
||||
_bRequired = copy.Required;
|
||||
Channel = new MMEPossibleChannels(copy.Channel);
|
||||
_channelProperties = new Dictionary<string, ChannelProperty>();
|
||||
var e = copy._channelProperties.GetEnumerator();
|
||||
while (e.MoveNext())
|
||||
{
|
||||
_channelProperties[e.Current.Key] = new ChannelProperty(e.Current.Value);
|
||||
}
|
||||
_channelPropertyNames = new List<string>(copy._channelPropertyNames.ToArray());
|
||||
_template = template;
|
||||
}
|
||||
public TestObjectTemplateChannel(MMEPossibleChannels channel)
|
||||
{
|
||||
Channel = channel;
|
||||
AddStandardProperties();
|
||||
var scp = Enum.GetValues(typeof(StandardChannelProperties)).Cast<StandardChannelProperties>().ToArray();
|
||||
foreach (var p in scp)
|
||||
{
|
||||
switch (p)
|
||||
{
|
||||
case StandardChannelProperties.DisplayOrder:
|
||||
_channelProperties[StandardChannelProperties.DisplayOrder.ToString()].Value = (Convert.ToInt32(Channel.Id)).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case StandardChannelProperties.NameOfTheChannel:
|
||||
break;
|
||||
/*case StandardChannelProperties.BitResolution:
|
||||
case StandardChannelProperties.ChannelAmplitudeClass:
|
||||
case StandardChannelProperties.ChannelCode:
|
||||
case StandardChannelProperties.ChannelFrequencyClass:
|
||||
case StandardChannelProperties.Comments1:
|
||||
case StandardChannelProperties.Comments2:
|
||||
case StandardChannelProperties.CustomerChannelCode:
|
||||
case StandardChannelProperties.CutOffFrequency:
|
||||
case StandardChannelProperties.DataSource:
|
||||
case StandardChannelProperties.DataStatus:
|
||||
break;
|
||||
case StandardChannelProperties.Dimension:
|
||||
_channelProperties[StandardChannelProperties.Dimension.ToString()].Value = _channel.Physical_Dimension;
|
||||
break;
|
||||
case StandardChannelProperties.Direction:
|
||||
_channelProperties[StandardChannelProperties.Direction.ToString()].Value = _channel.Direction;
|
||||
break;
|
||||
case StandardChannelProperties.EndOffsetInterval:
|
||||
case StandardChannelProperties.FirstGlobalMaximumValue:
|
||||
case StandardChannelProperties.FirstGlobalMinimumValue:
|
||||
case StandardChannelProperties.LaboratoryChannelCode:
|
||||
break;
|
||||
case StandardChannelProperties.Location:
|
||||
_channelProperties[StandardChannelProperties.Location.ToString()].Value = _channel.Trans_Main_Loc;
|
||||
break;
|
||||
case StandardChannelProperties.NumberOfSamples:
|
||||
case StandardChannelProperties.OffsetPostTest:
|
||||
case StandardChannelProperties.PreFilterType:
|
||||
case StandardChannelProperties.ReferenceChannel:
|
||||
case StandardChannelProperties.ReferenceChannelName:
|
||||
case StandardChannelProperties.ReferenceSystem:
|
||||
case StandardChannelProperties.SamplingInterval:
|
||||
case StandardChannelProperties.StartOffsetInterval:
|
||||
case StandardChannelProperties.TestObjectNumber:
|
||||
case StandardChannelProperties.TimeOfFirstSample:
|
||||
case StandardChannelProperties.TimeOfMaximumValue:
|
||||
case StandardChannelProperties.TimeOfMinimumValue:
|
||||
case StandardChannelProperties.TransducerDampingRatio:
|
||||
case StandardChannelProperties.TransducerId:
|
||||
case StandardChannelProperties.TransducerNaturalFrequency:
|
||||
case StandardChannelProperties.TransducerType:
|
||||
case StandardChannelProperties.Unit:*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ISO.TestObjectTemplate _template;
|
||||
public void SetTemplate(ISO.TestObjectTemplate template) { _template = template; }
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
var tokens = Channel.Text_L1.Split(new string[] { SEPARATOR }, StringSplitOptions.None);
|
||||
return tokens.Last();
|
||||
}
|
||||
}
|
||||
public const string TEST_SPECIFIC_DOUT = "TSD_";
|
||||
public string NameOfTheChannel
|
||||
{
|
||||
get
|
||||
{
|
||||
var s = _channelProperties[StandardChannelProperties.NameOfTheChannel.ToString()].Value as string;
|
||||
if (string.IsNullOrWhiteSpace(s) || s == DataStatusTypes.NOVALUE.ToString())
|
||||
{
|
||||
if (Name.StartsWith(TEST_SPECIFIC_DOUT))
|
||||
{
|
||||
return "(Digital Output Setting)";
|
||||
}
|
||||
else { return Name; }
|
||||
}
|
||||
return s;
|
||||
}
|
||||
set => _channelProperties[StandardChannelProperties.NameOfTheChannel.ToString()].Value = value;
|
||||
}
|
||||
public string LaboratoryCode
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string CustomerChannelCode
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public int DisplayOrder
|
||||
{
|
||||
get => Convert.ToInt32(_channelProperties[StandardChannelProperties.DisplayOrder.ToString()].Value, System.Globalization.CultureInfo.InvariantCulture);
|
||||
set => _channelProperties[StandardChannelProperties.DisplayOrder.ToString()].Value = value.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
public string Comments1
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string Location
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string Dimension
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string Direction
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string ChannelFrequencyClass
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string Unit
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string ReferenceSystem
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string TestObjectNumber
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string TransducerType
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string TransducerId
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string PreFilterType
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string CutOffFrequency
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string ChannelAmplitudeClass
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public ReferenceChannelTypes ReferenceChannel
|
||||
{
|
||||
get => ReferenceChannelTypes.NOVALUE;
|
||||
set {; }
|
||||
}
|
||||
public string ReferenceChannelName
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public DataSourceTypes DataSource
|
||||
{
|
||||
get => DataSourceTypes.Parameter;
|
||||
set {; }
|
||||
}
|
||||
public DataStatusTypes DataStatus
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE;
|
||||
set {; }
|
||||
}
|
||||
public string SamplingInterval
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string BitResolution
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string TimeOfFirstSample
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string NumberOfSamples
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string OffsetPostTest
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string TransducerNaturalFrequency
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string TransducerDampingRatio
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string Comments2
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string FirstGlobalMaximumValue
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
|
||||
public string TimeOfMaximumValue
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string FirstGlobalMinimumValue
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string TimeOfMinimumValue
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string StartOffsetInterval
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public string EndOffsetInterval
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set {; }
|
||||
}
|
||||
public class ChannelProperty : ISerializable
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public object Value { get; set; } = "NOVALUE";
|
||||
|
||||
public ChannelProperty(ChannelProperty copy)
|
||||
{
|
||||
Name = copy.Name;
|
||||
Value = copy.Value;
|
||||
}
|
||||
public ChannelProperty(string name, object value)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
}
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue("PropertyName", Name);
|
||||
info.AddValue("PropertyValue", Value, Value.GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class Hardware //: INotifyPropertyChanged
|
||||
{
|
||||
public enum HardwareTypes
|
||||
{
|
||||
SLICE_Base = 0,
|
||||
SLICE_Bridge = 1,
|
||||
SLICE_Distributor = 2,
|
||||
TDAS_Pro_Rack = 3,
|
||||
SLICE2_IEPE_Hi = 4,
|
||||
SLICE2_IEPE_Lo = 5,
|
||||
SLICE2_Bridge_Hi = 6,
|
||||
SLICE2_Bridge_Lo = 7,
|
||||
SLICE2_Base = 8,
|
||||
TOM = 9,
|
||||
SIM = 10,
|
||||
DIM = 11,
|
||||
G5VDS = 12,
|
||||
Ribeye = 13,
|
||||
RibeyeLED = 14,
|
||||
SLICE_IEPE = 15,
|
||||
SLICE1_5_Nano_Base = 16,
|
||||
SLICE_Micro_Base = 17,
|
||||
SLICE_NANO_Base = 18,
|
||||
SLICE2_SIM = 19,
|
||||
SLICE2_DIM = 20,
|
||||
SLICE2_TOM = 21,
|
||||
//G5IPORT=22,
|
||||
G5INDUMMY = 23,
|
||||
SLICE_EthernetController = 24,
|
||||
SLICE1_5_Micro_Base = 25,
|
||||
SLICE_LabEthernet = 26,
|
||||
SLICE2_SLS = 27,
|
||||
SLICE1_G5Stack = 28,
|
||||
SLICE2_SLT = 29,
|
||||
SLICE2_SLD = 30,
|
||||
TDAS_LabRack = 31,
|
||||
SLICE6_Base = 32
|
||||
}
|
||||
public static DateTime INVALIDDATE => new DateTime(1970, 1, 1);
|
||||
public string SerialNumber { get; set; } = "";
|
||||
public int CalInterval { get; set; } = 365;
|
||||
|
||||
public int DASType { get; set; } = 0;
|
||||
|
||||
public int MaxModules { get; set; } = 0;
|
||||
|
||||
public long MaxMemory { get; set; } = 0;
|
||||
|
||||
public double MinSampleRate { get; set; } = 0;
|
||||
|
||||
public double MaxSampleRate { get; set; } = 1000000;
|
||||
|
||||
public string FirmwareVersion { get; set; } = "";
|
||||
|
||||
private DateTime _calDate = INVALIDDATE;
|
||||
public DateTime CalDate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_calDate < INVALIDDATE) { return INVALIDDATE; }
|
||||
return _calDate;
|
||||
}
|
||||
set => _calDate = value;
|
||||
}
|
||||
|
||||
public int ProtocolVersion { get; set; } = 0;
|
||||
|
||||
public DateTime LastModified { get; set; } = DateTime.Now;
|
||||
|
||||
public string LastModifiedBy { get; set; } = "";
|
||||
|
||||
public int Version { get; set; } = 1;
|
||||
|
||||
public bool LocalOnly { get; set; } = false;
|
||||
|
||||
public DateTime LastUsed { get; set; } = INVALIDDATE;
|
||||
|
||||
public string LastUsedBy { get; set; } = "";
|
||||
|
||||
public string IPAddress { get; set; } = "";
|
||||
|
||||
public int Channels { get; set; } = 0;
|
||||
|
||||
public string Position { get; set; } = "";
|
||||
|
||||
public bool IsProgrammable { get; set; } = false;
|
||||
|
||||
public bool IsModule { get; set; } = false;
|
||||
|
||||
public bool IsReconfigurable { get; set; } = false;
|
||||
|
||||
private int[] _channelTypes = null;
|
||||
public int[] ChannelTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == _channelTypes) { _channelTypes = new int[0]; }
|
||||
return _channelTypes;
|
||||
}
|
||||
set => _channelTypes = value;
|
||||
}
|
||||
|
||||
public Hardware()
|
||||
{
|
||||
|
||||
}
|
||||
public Hardware(Hardware copy)
|
||||
{
|
||||
Version = copy.Version;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
ProtocolVersion = copy.ProtocolVersion;
|
||||
Position = copy.Position;
|
||||
MinSampleRate = copy.MinSampleRate;
|
||||
MaxSampleRate = copy.MaxSampleRate;
|
||||
MaxModules = copy.MaxModules;
|
||||
MaxMemory = copy.MaxMemory;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
LastUsedBy = copy.LastUsedBy;
|
||||
LastUsed = copy.LastUsed;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
LastModified = copy.LastModified;
|
||||
IsReconfigurable = copy.IsReconfigurable;
|
||||
IsProgrammable = copy.IsProgrammable;
|
||||
var channels = new List<ISOHardwareChannel>();
|
||||
foreach (var c in copy.ISOChannels)
|
||||
{
|
||||
channels.Add(new ISOHardwareChannel(c, this));
|
||||
}
|
||||
ISOChannels = channels.ToArray();
|
||||
IPAddress = copy.IPAddress;
|
||||
FirmwareVersion = copy.FirmwareVersion;
|
||||
DASType = copy.DASType;
|
||||
var channeltypes = new int[copy.ChannelTypes.Length];
|
||||
Array.Copy(copy.ChannelTypes, channeltypes, copy.ChannelTypes.Length);
|
||||
ChannelTypes = channeltypes;
|
||||
Channels = copy.Channels;
|
||||
CalInterval = copy.CalInterval;
|
||||
CalDate = copy.CalDate;
|
||||
IsModule = copy.IsModule;
|
||||
}
|
||||
public Hardware(DataRow dr)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.DAS.Fields)).Cast<DbOperations.DAS.Fields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var o = dr[field.ToString()];
|
||||
if (DBNull.Value.Equals(o)) { continue; }
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.DAS.Fields.CalDate:
|
||||
CalDate = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.Channels:
|
||||
Channels = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.Connection:
|
||||
IPAddress = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.FirmwareVersion:
|
||||
FirmwareVersion = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.LastModified:
|
||||
LastModified = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.LastModifiedBy:
|
||||
LastModifiedBy = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.LastUsed:
|
||||
LastUsed = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.LastUsedBy:
|
||||
LastUsedBy = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.LocalOnly:
|
||||
LocalOnly = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.MaxMemory:
|
||||
MaxMemory = Convert.ToInt64(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.MaxModules:
|
||||
MaxModules = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.MaxSampleRate:
|
||||
MaxSampleRate = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.MinSampleRate:
|
||||
MinSampleRate = Convert.ToDouble(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.Position:
|
||||
Position = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.Reconfigurable:
|
||||
IsReconfigurable = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.IsModule:
|
||||
IsModule = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.Reprogramable:
|
||||
IsProgrammable = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.ProtocolVersion:
|
||||
ProtocolVersion = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.SerialNumber:
|
||||
SerialNumber = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.Type:
|
||||
DASType = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.DAS.Fields.ChannelTypes:
|
||||
{
|
||||
var s = o as string;
|
||||
var tokens = s.Split(new char[] { ',' });
|
||||
var types = new List<int>();
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
if (int.TryParse(token, out var itemp)) { types.Add(itemp); }
|
||||
}
|
||||
ChannelTypes = types.ToArray();
|
||||
}
|
||||
break;
|
||||
case DbOperations.DAS.Fields.Version:
|
||||
Version = Convert.ToInt32(o);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("Unknown field: " + field.ToString());
|
||||
|
||||
}
|
||||
}
|
||||
var channels = new List<ISOHardwareChannel>();
|
||||
var requery = true;
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
sql.CommandText = string.Format("SELECT * FROM [{0}] WHERE [{1}]=@{1}", DbOperations.DAS.TableDASChannels, DbOperations.DAS.DASChannelFields.HardwareId.ToString());
|
||||
DbOperations.CreateParam(sql, string.Format("@{0}", DbOperations.DAS.DASChannelFields.HardwareId.ToString()), SqlDbType.NVarChar, GetId());
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (null != ds.Tables && ds.Tables.Count > 0)
|
||||
{
|
||||
|
||||
foreach (DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
requery = false;
|
||||
channels.Add(new ISOHardwareChannel(row, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (requery)
|
||||
{
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
sql.CommandText = string.Format("SELECT * FROM [{0}] WHERE [{1}]=@{1}", DbOperations.DAS.TableDASChannels, DbOperations.DAS.DASChannelFields.HardwareId.ToString());
|
||||
DbOperations.CreateParam(sql, string.Format("@{0}", DbOperations.DAS.DASChannelFields.HardwareId.ToString()), SqlDbType.NVarChar, GetIdOld());
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (null != ds.Tables && ds.Tables.Count > 0)
|
||||
{
|
||||
foreach (DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
channels.Add(new ISOHardwareChannel(row, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
channels.Sort(ISOHardwareChannel.PhysicalCompare);
|
||||
_isoChannels = channels;
|
||||
}
|
||||
private List<ISOHardwareChannel> _isoChannels = new List<ISOHardwareChannel>();
|
||||
public ISOHardwareChannel[] ISOChannels
|
||||
{
|
||||
get => _isoChannels.ToArray();
|
||||
set => _isoChannels = new List<ISOHardwareChannel>(value);
|
||||
}
|
||||
|
||||
public static Hardware[] GetAllDAS()
|
||||
{
|
||||
var list = new List<Hardware>();
|
||||
try
|
||||
{
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
sql.CommandText = string.Format("SELECT * FROM [{0}]", DbOperations.DAS.Table);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (null != ds.Tables && ds.Tables.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
list.Add(new Hardware(dr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("failed to retrieve all das, ", ex);
|
||||
}
|
||||
list.Sort(new HardwareCompare());
|
||||
return list.ToArray();
|
||||
}
|
||||
public class HardwareCompare : Comparer<Hardware>
|
||||
{
|
||||
public override int Compare(Hardware x, Hardware y)
|
||||
{
|
||||
var ret = x.SerialNumber.CompareTo(y.SerialNumber);
|
||||
if (0 == ret) { ret = x.IPAddress.CompareTo(y.IPAddress); }
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
public string GetId()
|
||||
{
|
||||
return GetId(SerialNumber, DASType.ToString(), IPAddress);
|
||||
}
|
||||
public string GetIdOld()
|
||||
{
|
||||
return string.Format("{0}_{1}_{2}", SerialNumber, DASType.ToString(), IPAddress);
|
||||
}
|
||||
public static string GetId(string sn, string dastype, string ip)
|
||||
{
|
||||
return string.Format("{0}_{1}", sn, dastype);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class CalibrationRecords
|
||||
{
|
||||
public CalibrationRecord[] Records { get; set; } = { new CalibrationRecord() };
|
||||
|
||||
public CalibrationRecords(CalibrationRecords copy)
|
||||
{
|
||||
var records = new CalibrationRecord[copy.Records.Length];
|
||||
for (var i = 0; i < copy.Records.Length; i++)
|
||||
{
|
||||
records[i] = new CalibrationRecord(copy.Records[i]);
|
||||
}
|
||||
Records = records;
|
||||
}
|
||||
|
||||
public CalibrationRecords()
|
||||
{
|
||||
Records = new CalibrationRecord[] { new CalibrationRecord() };
|
||||
}
|
||||
public CalibrationRecords(string records)
|
||||
{
|
||||
FromSerializedString(records);
|
||||
}
|
||||
public void FromSerializedString(string s)
|
||||
{
|
||||
var tokens = s.Split(new string[] { MySeparator }, StringSplitOptions.None);
|
||||
for (var i = 0; i < tokens.Length; i++) { tokens[i] = tokens[i].Replace(MySeparatorBackup, MySeparator); }
|
||||
|
||||
var records = new List<CalibrationRecord>();
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
records.Add(new CalibrationRecord(token));
|
||||
}
|
||||
Records = records.ToArray();
|
||||
}
|
||||
private const string MySeparator = "__x__";
|
||||
private const string MySeparatorBackup = "___xx___";
|
||||
public string ToSerializedString(SensorCalibration sc)
|
||||
{
|
||||
var records = new List<string>();
|
||||
|
||||
foreach (var r in Records) { records.Add(r.ToSerializedString(sc)); }
|
||||
|
||||
for (var i = 0; i < records.Count; i++)
|
||||
{
|
||||
System.Diagnostics.Trace.Assert(!records[i].Contains(MySeparatorBackup));
|
||||
records[i] = records[i].Replace(MySeparator, MySeparatorBackup);
|
||||
}
|
||||
return string.Join(MySeparator, records.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public class CalibrationRecord
|
||||
{
|
||||
public double Sensitivity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ZeroPoint is used to hold the calibration certificate field for 2D/3D IR-TRACC cal certs
|
||||
/// it is used to zero the IR-TRACC and POT data prior to being fed into the 3D equations
|
||||
/// </summary>
|
||||
private double _zeroPoint = 0D;
|
||||
public double ZeroPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
if (false == Equals(Poly.CalibrationFactor, 0.0))
|
||||
{
|
||||
// This field is always calculated. Do not return stored value unless we are unable to calculate
|
||||
return Poly.ZeroPositionIntercept / Poly.CalibrationFactor;
|
||||
}
|
||||
return _zeroPoint;
|
||||
}
|
||||
set => _zeroPoint = value;
|
||||
}
|
||||
|
||||
public LinearizationFormula Poly { get; set; }
|
||||
|
||||
public bool AtCapacity { get; set; } = false;
|
||||
|
||||
//change this, and others, to use the sensor's values?
|
||||
public string EngineeringUnits { get; set; } = "g";
|
||||
|
||||
|
||||
public Test.Module.Channel.Sensor.SensUnits SensitivityUnits { get; set; } = Test.Module.Channel.Sensor.SensUnits.NONE;
|
||||
|
||||
public Test.Module.Channel.Sensor.ExcitationVoltageOption Excitation { get; set; } = Test.Module.Channel.Sensor.ExcitationVoltageOption.Volt5;
|
||||
|
||||
public int CapacityOutputIsBasedOn { get; set; } = 1;
|
||||
private enum Fields
|
||||
{
|
||||
Sensitivity,
|
||||
Poly,
|
||||
AtCapacity,
|
||||
EngineeringUnits,
|
||||
Excitation,
|
||||
CapacityOutputIsBasedOn,
|
||||
SensitivityUnits,
|
||||
ZeroPoint
|
||||
};
|
||||
public string ToSerializedString(SensorCalibration parentCal)
|
||||
{
|
||||
var tokens = new List<string>();
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case Fields.AtCapacity: tokens.Add(AtCapacity.ToString()); break;
|
||||
case Fields.EngineeringUnits: tokens.Add(EngineeringUnits); break;
|
||||
case Fields.Excitation: tokens.Add(Excitation.ToString()); break;
|
||||
case Fields.Poly:
|
||||
if (parentCal.NonLinear) { Poly.MarkValid(true); }
|
||||
else { Poly.MarkValid(false); }
|
||||
tokens.Add(Poly.ToSerializeString());
|
||||
break;
|
||||
case Fields.Sensitivity: tokens.Add(Sensitivity.ToString(System.Globalization.CultureInfo.InvariantCulture)); break;
|
||||
case Fields.CapacityOutputIsBasedOn: tokens.Add(CapacityOutputIsBasedOn.ToString()); break;
|
||||
case Fields.SensitivityUnits: tokens.Add(SensitivityUnits.ToString()); break;
|
||||
case Fields.ZeroPoint:
|
||||
tokens.Add(ZeroPoint.ToString(System.Globalization.CultureInfo.InvariantCulture)); break;
|
||||
default: throw new NotSupportedException("unknown CalibrationRecord field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < tokens.Count; i++)
|
||||
{
|
||||
if (null == tokens[i]) { tokens[i] = ""; }
|
||||
tokens[i] = tokens[i].Replace(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, "x_Separator_x");
|
||||
}
|
||||
return string.Join(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, tokens.ToArray());
|
||||
}
|
||||
public void FromString(string s)
|
||||
{
|
||||
var tokens = s.Split(new string[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
|
||||
for (var i = 0; i < tokens.Length && i < fields.Length; i++)
|
||||
{
|
||||
var token = tokens[i].Replace("x_Separator_x", System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator);
|
||||
switch (fields[i])
|
||||
{
|
||||
case Fields.AtCapacity: AtCapacity = Convert.ToBoolean(token); break;
|
||||
case Fields.EngineeringUnits: EngineeringUnits = token; break;
|
||||
case Fields.Excitation: Excitation = (Test.Module.Channel.Sensor.ExcitationVoltageOption)Enum.Parse(typeof(Test.Module.Channel.Sensor.ExcitationVoltageOption), token); break;
|
||||
case Fields.Poly: Poly = new LinearizationFormula(); Poly.FromSerializeString(token); break;
|
||||
case Fields.Sensitivity: Sensitivity = Convert.ToDouble(token, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case Fields.CapacityOutputIsBasedOn: CapacityOutputIsBasedOn = Convert.ToInt32(token); break;
|
||||
case Fields.SensitivityUnits: SensitivityUnits = (Test.Module.Channel.Sensor.SensUnits)Enum.Parse(typeof(Test.Module.Channel.Sensor.SensUnits), token); break;
|
||||
case Fields.ZeroPoint: ZeroPoint = Convert.ToDouble(token, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
default: throw new NotSupportedException("unknown CalibrationRecord field: " + fields.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public CalibrationRecord(string s)
|
||||
{
|
||||
FromString(s);
|
||||
}
|
||||
public CalibrationRecord(CalibrationRecord copy)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case Fields.AtCapacity: AtCapacity = copy.AtCapacity; break;
|
||||
case Fields.EngineeringUnits: EngineeringUnits = copy.EngineeringUnits; break;
|
||||
case Fields.Excitation: Excitation = copy.Excitation; break;
|
||||
case Fields.Poly: Poly = new LinearizationFormula(copy.Poly); break;
|
||||
case Fields.Sensitivity: Sensitivity = copy.Sensitivity; break;
|
||||
case Fields.CapacityOutputIsBasedOn: CapacityOutputIsBasedOn = copy.CapacityOutputIsBasedOn; break;
|
||||
case Fields.SensitivityUnits: SensitivityUnits = copy.SensitivityUnits; break;
|
||||
case Fields.ZeroPoint: ZeroPoint = copy.ZeroPoint; break;
|
||||
default:
|
||||
throw new NotSupportedException("unknown calibrationrecord field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
public CalibrationRecord()
|
||||
{
|
||||
Poly = new LinearizationFormula();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public interface IUIItems
|
||||
{
|
||||
string GetName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,330 @@
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class IsoCode
|
||||
{
|
||||
private char[] _isoCodeFull = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' };
|
||||
|
||||
private char _TestObject
|
||||
{
|
||||
get => _isoCodeFull[0];
|
||||
set => _isoCodeFull[0] = value;
|
||||
}
|
||||
|
||||
public string TestObject
|
||||
{
|
||||
get => new string(new[] { _TestObject });
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
_TestObject = '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
_TestObject = value[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private char _Position
|
||||
{
|
||||
get => _isoCodeFull[1];
|
||||
set => _isoCodeFull[1] = value;
|
||||
}
|
||||
|
||||
public string Position
|
||||
{
|
||||
get => new string(new[] { _Position });
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
_Position = '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
_Position = value[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private char[] _MainLocation
|
||||
{
|
||||
get => new[] { _isoCodeFull[2], _isoCodeFull[3], _isoCodeFull[4], _isoCodeFull[5] };
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
if (value.Length <= i)
|
||||
{
|
||||
_isoCodeFull[i + 2] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
_isoCodeFull[i + 2] = value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string MainLocation
|
||||
{
|
||||
get => new string(_MainLocation);
|
||||
set
|
||||
{
|
||||
var main = value;
|
||||
if (main.Length < 4)
|
||||
{
|
||||
main = main.PadRight(4, '?');
|
||||
}
|
||||
else if (main.Length > 4)
|
||||
{
|
||||
main = main.Substring(0, 4);
|
||||
}
|
||||
_MainLocation = main.ToCharArray(0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
private char[] _FineLocation1
|
||||
{
|
||||
get => new[] { _isoCodeFull[6], _isoCodeFull[7] };
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
if (value.Length < i)
|
||||
{
|
||||
_isoCodeFull[i + 6] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
_isoCodeFull[i + 6] = value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FineLocation1
|
||||
{
|
||||
get => new string(_FineLocation1);
|
||||
set
|
||||
{
|
||||
var loc = value;
|
||||
if (loc.Length < 2)
|
||||
{
|
||||
loc = loc.PadRight(2, '?');
|
||||
}
|
||||
else if (loc.Length > 2)
|
||||
{
|
||||
loc = loc.Substring(0, 2);
|
||||
}
|
||||
_FineLocation1 = loc.ToCharArray(0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private char[] _FineLocation2
|
||||
{
|
||||
get => new[] { _isoCodeFull[8], _isoCodeFull[9] };
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
if (value.Length < i)
|
||||
{
|
||||
_isoCodeFull[i + 8] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
_isoCodeFull[i + 8] = value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FineLocation2
|
||||
{
|
||||
get => new string(_FineLocation2);
|
||||
set
|
||||
{
|
||||
var loc = value;
|
||||
if (loc.Length < 2)
|
||||
{
|
||||
loc = loc.PadRight(2, '?');
|
||||
}
|
||||
else if (loc.Length > 2)
|
||||
{
|
||||
loc = loc.Substring(0, 2);
|
||||
}
|
||||
_FineLocation2 = loc.ToCharArray(0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private char[] _FineLocations3
|
||||
{
|
||||
get => new[] { _isoCodeFull[10], _isoCodeFull[11] };
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
if (value.Length < i)
|
||||
{
|
||||
_isoCodeFull[i + 10] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
_isoCodeFull[i + 10] = value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FineLocation3
|
||||
{
|
||||
get => new string(_FineLocations3);
|
||||
set
|
||||
{
|
||||
var loc = value;
|
||||
if (loc.Length < 2)
|
||||
{
|
||||
loc = loc.PadRight(2, '?');
|
||||
}
|
||||
else if (loc.Length > 2)
|
||||
{
|
||||
loc = loc.Substring(0, 2);
|
||||
}
|
||||
_FineLocations3 = loc.ToCharArray(0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private char[] _PhysicalDimension
|
||||
{
|
||||
get => new[] { _isoCodeFull[12], _isoCodeFull[13] };
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
if (value.Length < i)
|
||||
{
|
||||
_isoCodeFull[i + 12] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
_isoCodeFull[i + 12] = value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string PhysicalDimension
|
||||
{
|
||||
get => new string(_PhysicalDimension);
|
||||
set
|
||||
{
|
||||
var dim = value;
|
||||
if (dim.Length < 2)
|
||||
{
|
||||
dim = dim.PadRight(2, '?');
|
||||
}
|
||||
else if (dim.Length > 2)
|
||||
{
|
||||
dim = dim.Substring(0, 2);
|
||||
}
|
||||
_PhysicalDimension = dim.ToCharArray(0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private char _Direction
|
||||
{
|
||||
get => _isoCodeFull[14];
|
||||
set => _isoCodeFull[14] = value;
|
||||
}
|
||||
|
||||
public string Direction
|
||||
{
|
||||
get => new string(new[] { _Direction });
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
_Direction = '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
_Direction = value[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private char _FilterClass
|
||||
{
|
||||
get => _isoCodeFull[15];
|
||||
set => _isoCodeFull[15] = value;
|
||||
}
|
||||
|
||||
public string FilterClass
|
||||
{
|
||||
get => new string(new[] { _FilterClass });
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
_FilterClass = '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
_FilterClass = value[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IsoCode(string isoCode)
|
||||
{
|
||||
if (null == isoCode)
|
||||
{
|
||||
isoCode = "";
|
||||
}
|
||||
if (isoCode.Length > 16)
|
||||
{
|
||||
isoCode = isoCode.Substring(0, 16);
|
||||
}
|
||||
if (isoCode.Length < 16)
|
||||
{
|
||||
isoCode = isoCode.PadRight(16, '?');
|
||||
}
|
||||
for (var i = 0; i < 16; i++)
|
||||
{
|
||||
_isoCodeFull[i] = isoCode[i];
|
||||
}
|
||||
}
|
||||
|
||||
public string StringRepresentation
|
||||
{
|
||||
get
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var c in _isoCodeFull)
|
||||
{
|
||||
sb.Append(c);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < 16; i++)
|
||||
{
|
||||
if (i >= value.Length)
|
||||
{
|
||||
_isoCodeFull[i] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
_isoCodeFull[i] = value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TemplateRegion
|
||||
{
|
||||
public string TemplateName { get; }
|
||||
|
||||
public string TemplateZone { get; }
|
||||
|
||||
public int RegionNumber { get; set; }
|
||||
|
||||
public string RegionName { get; set; }
|
||||
|
||||
public string RegionDescription { get; set; }
|
||||
|
||||
public string TestObject { get; set; }
|
||||
|
||||
public string Position { get; set; }
|
||||
|
||||
public string MainLocation { get; set; }
|
||||
|
||||
public string FineLocation1 { get; set; }
|
||||
|
||||
public string FineLocation2 { get; set; }
|
||||
|
||||
public string FineLocation3 { get; set; }
|
||||
|
||||
public string PhysicalDimension { get; set; }
|
||||
|
||||
public string Direction { get; set; }
|
||||
|
||||
public string FilterClass { get; set; }
|
||||
|
||||
public bool LocalOnly { get; } = false;
|
||||
|
||||
private int _upperLeftX = 0;
|
||||
private int _upperLeftY = 0;
|
||||
private int _lowerRightX = 0;
|
||||
private int _lowerRightY = 0;
|
||||
|
||||
public System.Drawing.Point UpperLeft
|
||||
{
|
||||
get => new System.Drawing.Point(_upperLeftX, _upperLeftY);
|
||||
set { _upperLeftX = value.X; _upperLeftY = value.Y; }
|
||||
}
|
||||
|
||||
public System.Drawing.Point LowerRight
|
||||
{
|
||||
get => new System.Drawing.Point(_lowerRightX, _lowerRightY);
|
||||
set { _lowerRightX = value.X; _lowerRightY = value.Y; }
|
||||
}
|
||||
|
||||
public TemplateRegion(string templateName, string zoneName, bool bLocalOnly)
|
||||
{
|
||||
TemplateName = templateName;
|
||||
TemplateZone = zoneName;
|
||||
LocalOnly = bLocalOnly;
|
||||
}
|
||||
|
||||
public TemplateRegion(DataRow dr)
|
||||
{
|
||||
TemplateName = (string)dr["TemplateName"];
|
||||
RegionNumber = Convert.ToInt32(dr["RegionNumber"]);
|
||||
RegionName = (string)dr["RegionName"];
|
||||
RegionDescription = (string)dr["RegionDescription"];
|
||||
TestObject = (string)dr["TestObject"];
|
||||
Position = (string)dr["Position"];
|
||||
MainLocation = (string)dr["MainLocation"];
|
||||
FineLocation1 = (string)dr["FineLocation1"];
|
||||
FineLocation2 = (string)dr["FineLocation2"];
|
||||
FineLocation3 = (string)dr["FineLocation3"];
|
||||
PhysicalDimension = (string)dr["PhysicalDimension"];
|
||||
Direction = (string)dr["Direction"];
|
||||
FilterClass = (string)dr["FilterClass"];
|
||||
LocalOnly = Convert.ToBoolean(dr["LocalOnly"]);
|
||||
_upperLeftX = Convert.ToInt32(dr["UpperLeftX"]);
|
||||
_upperLeftY = Convert.ToInt32(dr["UpperLeftY"]);
|
||||
_lowerRightX = Convert.ToInt32(dr["LowerRightX"]);
|
||||
_lowerRightY = Convert.ToInt32(dr["LowerRightY"]);
|
||||
TemplateZone = (string)dr["ZoneName"];
|
||||
}
|
||||
|
||||
internal static TemplateRegion[] GetAllRegions(string templateName, string zoneName)
|
||||
{
|
||||
var regions = new List<TemplateRegion>();
|
||||
try
|
||||
{
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
DbOperations.CreateParam(sql, "@TemplateName", SqlDbType.NVarChar, templateName);
|
||||
DbOperations.CreateParam(sql, "@ZoneName", SqlDbType.NVarChar, zoneName);
|
||||
|
||||
sql.CommandText = "SELECT * from tblTemplateRegions where [TemplateName]=@TemplateName and [ZoneName]=@ZoneName";
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
regions.Add(new TemplateRegion(dr));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to retrieve a region", templateName, ex2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to retrieve regions", templateName, ex);
|
||||
}
|
||||
return regions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user