init
This commit is contained in:
@@ -0,0 +1 @@
|
||||
12
|
||||
@@ -0,0 +1 @@
|
||||
12
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,588 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class DbImporter
|
||||
{
|
||||
public DbImporter()
|
||||
{
|
||||
}
|
||||
public DbImporter(int dbType, string dbName, string server, bool useNTLMAuthentication, string localDbUser, string localDbPassword)
|
||||
{
|
||||
DbOperations.Connection.DBName = dbName;
|
||||
if (1 == dbType)
|
||||
{
|
||||
//Local
|
||||
DbOperations._usingCentralizedDB = false;
|
||||
DbOperations._usingNTLMAuthentication = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Centralized
|
||||
DbOperations._usingCentralizedDB = true;
|
||||
DbOperations._usingNTLMAuthentication = useNTLMAuthentication;
|
||||
DbOperations.Connection.Username = localDbUser;
|
||||
DbOperations.Connection.Password = localDbPassword;
|
||||
}
|
||||
DbOperations.Connection.Server = server;
|
||||
}
|
||||
public enum TopLevelFields
|
||||
{
|
||||
CustomerDetails,
|
||||
TestEngineerDetails,
|
||||
LabDetails,
|
||||
DASList,
|
||||
SensorModels,
|
||||
Sensors,
|
||||
Calibrations,
|
||||
CustomDirections,
|
||||
CustomFilterClasses,
|
||||
CustomTestObjects,
|
||||
CustomFinLoc1s,
|
||||
CustomFinLoc2s,
|
||||
CustomFinLoc3s,
|
||||
CustomMainLocs,
|
||||
CustomPhysicalDimensions,
|
||||
CustomPositions,
|
||||
CustomChannels,
|
||||
GroupTemplates,
|
||||
Groups,
|
||||
TestSetups,
|
||||
Users,
|
||||
GlobalSettings
|
||||
}
|
||||
public delegate void SetStatusDelegate(string status, bool output = false);
|
||||
public void ImportXML(string ImportFile, SetStatusDelegate SetStatus)
|
||||
{
|
||||
// DataPRO database import XML file
|
||||
try
|
||||
{
|
||||
//(System.Windows.Application.Current as App).SetAppBusy();
|
||||
|
||||
////If local, make a backup, just in case.
|
||||
//var sourceDb = Path.Combine("db", "DataPRO.mdf"); ///////////////Fix this to get the actual db file, not necessarily the one in the current directory
|
||||
//if (File.Exists(sourceDb))
|
||||
//{
|
||||
// var destDb = Path.Combine("db", "DataPRO_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".mdf");
|
||||
// try
|
||||
// {
|
||||
// File.Copy(sourceDb, destDb, true);
|
||||
// }
|
||||
// catch(Exception ex)
|
||||
// {
|
||||
// MessageBox.Show(ex.Message);
|
||||
// }
|
||||
//}
|
||||
|
||||
ImportSensorsImportControl.ClearAllTables(true);
|
||||
|
||||
using (var reader = XmlReader.Create(ImportFile))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
var customTestObject = false;
|
||||
if (reader.NodeType != XmlNodeType.Element) continue;
|
||||
var elementName = string.Empty;
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "CustomerDetails":
|
||||
elementName = "CustomerDetail";
|
||||
break;
|
||||
case "TestEngineerDetails":
|
||||
elementName = "TestEngineerDetail";
|
||||
break;
|
||||
case "LabDetails":
|
||||
elementName = "LabDetail";
|
||||
break;
|
||||
case "DASList":
|
||||
elementName = "DASHardware";
|
||||
break;
|
||||
case "SensorModels":
|
||||
elementName = "SensorModel";
|
||||
break;
|
||||
case "Sensors":
|
||||
elementName = "SensorData";
|
||||
break;
|
||||
case "Calibrations":
|
||||
elementName = "SensorCalibration";
|
||||
break;
|
||||
case "CustomDirections":
|
||||
elementName = "CustomDirection";
|
||||
break;
|
||||
case "CustomTestObjects":
|
||||
elementName = "TestObject";
|
||||
customTestObject = true;
|
||||
break;
|
||||
case "CustomFinLoc1s":
|
||||
elementName = "FineLocation1";
|
||||
break;
|
||||
case "CustomFinLoc2s":
|
||||
elementName = "FineLocation2";
|
||||
break;
|
||||
case "CustomFinLoc3s":
|
||||
elementName = "FineLocation3";
|
||||
break;
|
||||
case "CustomMainLocs":
|
||||
elementName = "TransducerMainLocation";
|
||||
break;
|
||||
case "CustomPhysicalDimensions":
|
||||
elementName = "PhysicalDimension";
|
||||
break;
|
||||
case "CustomPositions":
|
||||
elementName = "Position";
|
||||
break;
|
||||
case "CustomChannels":
|
||||
elementName = "CustomChannel";
|
||||
//ImportTestSetup.possibleChannelIdMap.Clear();
|
||||
break;
|
||||
case "GroupTemplates":
|
||||
elementName = "GroupTemplate";
|
||||
break;
|
||||
case "Groups":
|
||||
elementName = "TestObject";
|
||||
break;
|
||||
case "TestSetups":
|
||||
elementName = "TestSetup";
|
||||
break;
|
||||
case "UIItems":
|
||||
elementName = "UIItem";
|
||||
break;
|
||||
case "Users":
|
||||
elementName = "User";
|
||||
break;
|
||||
case "UIItemSettings":
|
||||
elementName = "UIItemSetting";
|
||||
break;
|
||||
case "GlobalSettings":
|
||||
elementName = "Setting";
|
||||
break;
|
||||
case "LastUsedHardware":
|
||||
elementName = "UserHardware";
|
||||
break;
|
||||
case "Tags":
|
||||
elementName = "Tag";
|
||||
break;
|
||||
case "TagAssignments":
|
||||
elementName = "TagAssignment";
|
||||
break;
|
||||
case "TemplateZones":
|
||||
elementName = "TemplateZone";
|
||||
break;
|
||||
case "TemplateRegions":
|
||||
elementName = "TemplateRegion";
|
||||
break;
|
||||
case "DbVersions":
|
||||
elementName = "DbVersion";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
if (string.IsNullOrEmpty(elementName)) continue;
|
||||
var totalItems = reader.GetAttribute("TotalItems");
|
||||
if (string.IsNullOrWhiteSpace(totalItems) || Convert.ToInt32(totalItems) == 0) continue;
|
||||
if (!reader.ReadToFollowing(elementName)) continue;
|
||||
var counter = 0;
|
||||
do
|
||||
{
|
||||
var outerXML = reader.ReadOuterXml();
|
||||
try
|
||||
{
|
||||
ImportTestSetup.ProcessRootNode(customTestObject ? "CustomTestObject" : elementName,
|
||||
outerXML, /*_page,*/ SetStatus);
|
||||
counter++;
|
||||
SetStatus("Importing " + elementName + "..." + counter + "/" + totalItems +
|
||||
" processed");
|
||||
while (string.IsNullOrEmpty(reader.Name))
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SetStatus("Failure " + elementName + " " + counter + ":" + outerXML);
|
||||
throw ex;
|
||||
}
|
||||
} while (reader.Name == elementName);
|
||||
customTestObject = false;
|
||||
} //while
|
||||
} //using
|
||||
|
||||
//Add an entry in the UserProperties table for each user if a
|
||||
//Setting that was imported exists in the DefaultProperties table
|
||||
AssignSettingsToAllUsers();
|
||||
//12431Cannot run test after 1.4 to 1.10 migration with TDAS G5 VDS.
|
||||
//migrate from 1.4 skips the migration steps, migration step 66 fixes the issue with G5 VDS channels
|
||||
//so we need to make use of the data transformation in that step (without changing the db version though)
|
||||
MigrateG5ChannelSupportedBridges();
|
||||
MigrateSPSChannelSupportedBridges();
|
||||
SetStatus("Done with database import");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
//finally
|
||||
//{
|
||||
// SetStatus("Done with database import");
|
||||
// //(System.Windows.Application.Current as App).SetAppAvailable();
|
||||
//}
|
||||
}
|
||||
/// <summary>
|
||||
/// 12431 Cannot run test after 1.4 to 1.10 migration with TDAS G5 VDS.
|
||||
/// this does the migration without updating the version step
|
||||
/// when migrating from 1.4 we start with a clean 1.10 database, which has db version 67
|
||||
/// because of this migrateversion66 is never called.
|
||||
/// to fix the 1.4 vds data that is fixed in migrateversion66, we have to call this directly
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool MigrateG5ChannelSupportedBridges()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.Text;
|
||||
cmd.CommandText =
|
||||
"SELECT DISTINCT(A.[DASId]) FROM [DAS] as A inner join [DASChannels] as B on A.DASId=B.DASId where A.Type=12";
|
||||
|
||||
var dasIds = new List<int>();
|
||||
var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
dasIds.Add(Convert.ToInt32(reader["DASId"]));
|
||||
}
|
||||
reader.Close();
|
||||
if (dasIds.Any())
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
//12431 Cannot run test after 1.4 to 1.10 migration with TDAS G5 VDS.
|
||||
sb.Append(
|
||||
"UPDATE [DASChannels] SET SupportedBridges=140 WHERE SupportedBridges=12 AND DASID in (");
|
||||
var bNeedComma = false;
|
||||
foreach (var id in dasIds)
|
||||
{
|
||||
if (bNeedComma)
|
||||
{
|
||||
sb.Append(", ");
|
||||
}
|
||||
sb.Append(id);
|
||||
bNeedComma = true;
|
||||
}
|
||||
sb.Append(")");
|
||||
cmd.CommandText = sb.ToString();
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool IsServerConnected()
|
||||
{
|
||||
return DbOperations.IsServerConnected();
|
||||
}
|
||||
/// <summary>
|
||||
/// 12850 Channel count mismatch with SPS when migrating from 1.4 to 1.10
|
||||
/// This should set the SupportedBridges value in the DASChannels table to 143 when migrating
|
||||
/// from 1.4 if the <ProtocolVersion> is 154 or greater
|
||||
/// (SLICE2_MinimumProtocols[DFConstantsAndEnums.ProtocolLimitedCommands.HalfBridgeSigPlusSupport] = 154;).
|
||||
/// </summary>
|
||||
public void MigrateSPSChannelSupportedBridges()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.Text;
|
||||
cmd.CommandText =
|
||||
"SELECT DISTINCT(A.[DASId]) FROM [DAS] as A inner join [DASChannels] as B on A.DASId=B.DASId where A.Type=19 AND A.ProtocolVersion >= 154";
|
||||
|
||||
var dasIds = new List<int>();
|
||||
var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
dasIds.Add(Convert.ToInt32(reader["DASId"]));
|
||||
}
|
||||
reader.Close();
|
||||
if (dasIds.Any())
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
//12431 Cannot run test after 1.4 to 1.10 migration with SPS.
|
||||
sb.Append("UPDATE [DASChannels] SET SupportedBridges=143 WHERE SupportedBridges=15 AND DASID in (");
|
||||
var bNeedComma = false;
|
||||
foreach (var id in dasIds)
|
||||
{
|
||||
if (bNeedComma)
|
||||
{
|
||||
sb.Append(", ");
|
||||
}
|
||||
sb.Append(id);
|
||||
bNeedComma = true;
|
||||
}
|
||||
sb.Append(")");
|
||||
cmd.CommandText = sb.ToString();
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
//return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Users can override the system defaults for some settings
|
||||
/// </summary>
|
||||
private void AssignSettingsToAllUsers()
|
||||
{
|
||||
try
|
||||
{
|
||||
var userIdList = GetAllUserIds();
|
||||
foreach (var userId in userIdList)
|
||||
{
|
||||
var defaultPropertyList = GetAllDefaultProperties();
|
||||
foreach (var defaultProperty in defaultPropertyList)
|
||||
{
|
||||
string settingValue = null;
|
||||
switch (defaultProperty.Item2)
|
||||
{
|
||||
case "AllowAdvancedRecordingModes":
|
||||
settingValue = GetSettingValue("AllowAdvancedRecordingModes");
|
||||
if (settingValue != null)
|
||||
{
|
||||
SetUserProperty(userId, defaultProperty.Item1, settingValue);
|
||||
}
|
||||
break;
|
||||
case "AllowTSRAIRRecordingModes":
|
||||
settingValue = GetSettingValue("AllowTSRAIRRecordingModes");
|
||||
if (settingValue != null)
|
||||
{
|
||||
SetUserProperty(userId, defaultProperty.Item1, settingValue);
|
||||
}
|
||||
break;
|
||||
case "DefaultArmCheckListStep":
|
||||
settingValue = GetSettingValue("AutoAdd_ArmChecklist");
|
||||
if (settingValue != null)
|
||||
{
|
||||
SetUserProperty(userId, defaultProperty.Item1, settingValue);
|
||||
}
|
||||
break;
|
||||
case "DefaultAutomaticMode":
|
||||
settingValue = GetSettingValue("TestSetupDefaultAutomaticMode");
|
||||
if (settingValue != null)
|
||||
{
|
||||
SetUserProperty(userId, defaultProperty.Item1, settingValue);
|
||||
}
|
||||
break;
|
||||
case "DefaultCommonStatusLine":
|
||||
settingValue = GetSettingValue("CommonStatusLine");
|
||||
if (settingValue != null)
|
||||
{
|
||||
SetUserProperty(userId, defaultProperty.Item1, settingValue);
|
||||
}
|
||||
break;
|
||||
case "DefaultRealtimeGraphCount":
|
||||
settingValue = GetSettingValue("NumberRealtimeCharts");
|
||||
if (settingValue != null)
|
||||
{
|
||||
SetUserProperty(userId, defaultProperty.Item1, settingValue);
|
||||
}
|
||||
break;
|
||||
case "DefaultRecordingMode":
|
||||
settingValue = GetSettingValue("DefaultRecordingMode");
|
||||
if (settingValue != null)
|
||||
{
|
||||
SetUserProperty(userId, defaultProperty.Item1, settingValue);
|
||||
}
|
||||
break;
|
||||
case "DefaultTestSetupAutomaticProgressDelaySeconds":
|
||||
settingValue = GetSettingValue("AutomaticModeDelayMS");
|
||||
if (settingValue != null)
|
||||
{
|
||||
SetUserProperty(userId, defaultProperty.Item1, settingValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Get all of the ID values from the Users table
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<int> GetAllUserIds()
|
||||
{
|
||||
var userIdList = new List<int>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_UserGetIdsAll.ToString(); //Only used in DataPROPre20.mdf, not DataPRO.mdf
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
userIdList.Add(Convert.ToInt32(dr[DbOperations.Users.UserFields.ID.ToString()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("problem getting user", ex);
|
||||
}
|
||||
return userIdList;
|
||||
}
|
||||
/// <summary>
|
||||
/// Get all of the system default properties
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<Tuple<int, string>> GetAllDefaultProperties()
|
||||
{
|
||||
var properties = new List<Tuple<int, string>>();
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_DefaultPropertiesGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@PropertyId", SqlDbType.Int) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
properties.AddRange(from DataRow row in ds.Tables[0].Rows
|
||||
let id = Convert.ToInt32(row["PropertyId"])
|
||||
let value = Convert.ToString(row["PropertyName"])
|
||||
select new Tuple<int, string>(id, value));
|
||||
}
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
/// <summary>
|
||||
/// Get a value to override the system default for a setting
|
||||
/// </summary>
|
||||
/// <param name="settingId"></param>
|
||||
/// <returns></returns>
|
||||
string GetSettingValue(string settingId)
|
||||
{
|
||||
string settingValue = null;
|
||||
const string SYSTEM = "SYSTEM";
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SettingsGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.NVarChar) { Value = SYSTEM });
|
||||
cmd.Parameters.Add(new SqlParameter("@PropertyId", SqlDbType.NVarChar) { Value = settingId });
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
settingValue = Convert.ToString(ds.Tables[0].Rows[0][DbOperations.Settings.UserFields.PropertyValue.ToString()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) //TODO: handle exception properly
|
||||
{
|
||||
}
|
||||
return settingValue;
|
||||
}
|
||||
/// <summary>
|
||||
/// Add an entry to the UserProperties table
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="propertyId"></param>
|
||||
/// <param name="propertyValue"></param>
|
||||
void SetUserProperty(int userId, int propertyId, string propertyValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_UserPropertiesInsert.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.Int) { Value = userId });
|
||||
cmd.Parameters.Add(new SqlParameter("@PropertyId", SqlDbType.Int) { Value = propertyId });
|
||||
cmd.Parameters.Add(new SqlParameter("@PropertyValue", SqlDbType.NVarChar) { Value = propertyValue });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) {/* APILogger.LogException(ex);*/ }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class Tags
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// represents a single tag, which is composed of an ID and a string of text
|
||||
/// we don't currently let you obsolete, delete, or edit tags, just add
|
||||
/// </summary>
|
||||
public class Tag : ICloneable
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Text { get; set; }
|
||||
public bool IsObsolete { get; set; }
|
||||
public Tag(Tag copy)
|
||||
{
|
||||
ID = copy.ID;
|
||||
Text = copy.Text;
|
||||
IsObsolete = copy.IsObsolete;
|
||||
}
|
||||
|
||||
public Tag(IDataRecord reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
ID = Convert.ToInt32(reader[DbOperations.Tags.TagFields.TagId.ToString()]);
|
||||
IsObsolete = Convert.ToBoolean(reader[DbOperations.Tags.TagFields.Obsolete.ToString()]);
|
||||
Text = Convert.ToString(reader[DbOperations.Tags.TagFields.TagText.ToString()]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
public object Clone()
|
||||
{
|
||||
return new Tag(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <inheritdoc cref="TestObjectTemplateChannel" />
|
||||
/// <summary>
|
||||
/// this class represents a more simpilized version of the group/test object channel
|
||||
/// this is closer tied to what's in the database
|
||||
/// It extends a template channel adds more meta data
|
||||
/// </summary>
|
||||
public class TestObjectChannel : TestObjectTemplateChannel, IComparable<TestObjectChannel>
|
||||
{
|
||||
/// <summary>
|
||||
/// controls whether channel should be used when collecting data or not
|
||||
/// Disabled channels are not used in run test
|
||||
/// </summary>
|
||||
public bool Disabled { get; set; }
|
||||
public int ChannelIdx { get; set; } = CHANNEL_IDX_UNKNOWN;
|
||||
/// <summary>
|
||||
/// the serial number of the sensor associated with this channel (if any)
|
||||
/// </summary>
|
||||
public string SensorSerialNumber
|
||||
{
|
||||
get => GetProperty("SensorSerialNumber", "") as string;
|
||||
set => SetProperty("SensorSerialNumber", value);
|
||||
}
|
||||
/// <summary>
|
||||
/// the physical hardware channel associated with this channel (if any)
|
||||
/// </summary>
|
||||
public string HardwareId
|
||||
{
|
||||
get => GetProperty("HardwareId", "") as string;
|
||||
set
|
||||
{
|
||||
var tokens = value?.Split('_');
|
||||
if (3 == tokens?.Length)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendFormat("{0}_{1}", tokens[0], tokens[1]);
|
||||
var index = tokens[2].IndexOf(CHANNEL_SEPARATOR);
|
||||
if (index >= 0) { sb.Append(tokens[2].Substring(index)); }
|
||||
value = sb.ToString();
|
||||
}
|
||||
SetProperty("HardwareId", value);
|
||||
}
|
||||
}
|
||||
public SquibChannelTypes SquibChannelType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// the test object this channel belongs to
|
||||
/// </summary>
|
||||
public ISO.TestObject TestObject { get; }
|
||||
private const char CHANNEL_SEPARATOR = 'x';
|
||||
public const int CHANNEL_IDX_UNKNOWN = -1;
|
||||
public enum SquibChannelTypes
|
||||
{
|
||||
None, //Non-squib channels
|
||||
Voltage,
|
||||
Current
|
||||
}
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// compares one channel to another, used for sorting
|
||||
/// order is determined by 1) display order, 2) name of the channels, 3) test object serial number (or original serial number)
|
||||
/// </summary>
|
||||
/// <param name="right"></param>
|
||||
/// <returns></returns>
|
||||
public int CompareTo(TestObjectChannel right)
|
||||
{
|
||||
if (null == right) { return 1; }
|
||||
if (this == right) { return 0; }
|
||||
var comp = DisplayOrder.CompareTo(right.DisplayOrder);
|
||||
if (0 != comp) { return comp; }
|
||||
|
||||
comp = string.Compare(Name, right.Name, StringComparison.Ordinal);
|
||||
if (0 != comp) { return comp; }
|
||||
|
||||
if (null == TestObject || null == right.TestObject) return 0;
|
||||
comp = string.Compare(TestObject.SerialNumberOrOriginalSerialNumber, right.TestObject.SerialNumberOrOriginalSerialNumber, StringComparison.Ordinal);
|
||||
return 0 != comp ? comp : 0;
|
||||
}
|
||||
|
||||
public string GetGraphId()
|
||||
{
|
||||
return SquibChannelType == SquibChannelTypes.Current ? GetId() + DTS.Common.Constants.CURRENT_SUFFIX : GetId();
|
||||
}
|
||||
public string GetId()
|
||||
{
|
||||
return GetIdWithSpecificChannelId(Channel.Id);
|
||||
}
|
||||
public string GetIdWithSpecificChannelId(long id)
|
||||
{
|
||||
return $"{TestObject.SerialNumber}_{Channel.MMEChannelType}_{id}";
|
||||
}
|
||||
public TestObjectChannel(TestObjectTemplateChannel copy, ISO.TestObject testObject, ISO.TestObjectTemplate template)
|
||||
: base(copy, template)
|
||||
{
|
||||
TestObject = testObject;
|
||||
if (copy is TestObjectChannel channel)
|
||||
{
|
||||
Disabled = channel.Disabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public const string NON_ISO_TESTOBJECT_CHANNEL_TYPE = "x_NonISOTestObjectType_x";
|
||||
public const string NON_ISO_TESTOBJECT_NAME = "x_NonISOTestObjectName_x";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
[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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TestObjectTemplate //: BasePropertyChanged, IComparable<TestObjectTemplate>
|
||||
{
|
||||
// #region enums and constants
|
||||
public enum Tags
|
||||
{
|
||||
ChannelCountText,
|
||||
PossibleChannelCountText,
|
||||
TemplateName,
|
||||
TemplateDescription,
|
||||
TestObject,
|
||||
TestObjectType,
|
||||
TemplateAllUIChannels,
|
||||
TemplateZones,
|
||||
AvailableTestObjectTypes,
|
||||
TestObjectIndex,
|
||||
TestObjectTypeIndex,
|
||||
CurrentZone,
|
||||
CurrentZoneIndex,
|
||||
AreZoneControlsEnabled,
|
||||
TemplateAllChannels,
|
||||
RequiredChannels
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
CurrentZone = value >= 0 ? TemplateZones[value] : null;
|
||||
_currentZoneIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Zone _currentZone;
|
||||
public Zone CurrentZone
|
||||
{
|
||||
get => _currentZone;
|
||||
set
|
||||
{
|
||||
//if (null != _currentZone && _currentZone != value) { _currentZone.PropertyChanged -= CurrentZone_PropertyChanged; }
|
||||
_currentZone = value;
|
||||
|
||||
//if (null != _currentZone) { _currentZone.PropertyChanged += CurrentZone_PropertyChanged; }
|
||||
AreZoneControlsEnabled = null != value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool AreZoneControlsEnabled { get; set; }
|
||||
|
||||
private ISO.TestObjectTemplate _template;
|
||||
public List<TestObjectTemplateChannel> RequiredChannels { get; set; } = new List<TestObjectTemplateChannel>();
|
||||
|
||||
public string TemplateParent { get; set; } = "";
|
||||
|
||||
public bool SysBuilt { get; set; }
|
||||
|
||||
private bool _embedded;
|
||||
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) return;
|
||||
var app = Application.Current as App;
|
||||
if (app == null) return;
|
||||
AvailableTestObjectTypes = app.IsoDb.GetUniquePossibleChannelTypes(TestObjectTemplateChannel.NONISOCHANNELTYPE);
|
||||
if (AvailableTestObjectTypes.Length > 0) { TestObjectTypeIndex = 0; }
|
||||
else { TestObjectTypeIndex = -1; }
|
||||
}
|
||||
}
|
||||
|
||||
private string _testObjectType;
|
||||
public string TestObjectType
|
||||
{
|
||||
get => _testObjectType;
|
||||
set
|
||||
{
|
||||
_testObjectType = value;
|
||||
_channels = new List<MMEPossibleChannels>(((App)Application.Current).IsoDb.GetPossibleChannelsForType(_testObjectType));
|
||||
TemplateAllChannels = _channels.Select(pc => new TestObjectTemplateChannel(new TestObjectTemplateChannel(pc), /*ref db,*/ _template)).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private List<MMEPossibleChannels> _channels = new List<MMEPossibleChannels>();
|
||||
|
||||
private List<TestObjectTemplateChannel> _allChannels = new List<TestObjectTemplateChannel>();
|
||||
public TestObjectTemplateChannel[] TemplateAllChannels
|
||||
{
|
||||
get { _allChannels.Sort(CompareChannels); return _allChannels.ToArray(); }
|
||||
set
|
||||
{
|
||||
_allChannels = new List<TestObjectTemplateChannel>(value);
|
||||
|
||||
TemplateAllUIChannels = value.Select(c => new TemplateChannelUI(c)).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) return _availableTestObjectTypes.ToArray();
|
||||
if (null == TestObject) { return new string[0]; }
|
||||
_availableTestObjectTypes = new List<string>(((App)Application.Current).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
|
||||
{
|
||||
TestObjectType = value >= 0 ? _availableTestObjectTypes[value] : null;
|
||||
_testObjectTypeIndex = value;
|
||||
|
||||
TemplateAllChannels = _channels.Select(pc => new TestObjectTemplateChannel(new TestObjectTemplateChannel(pc), /*ref db,*/ _template)).ToArray();
|
||||
}
|
||||
}
|
||||
public static MMETestObjects GetNonISOTestObject()
|
||||
{
|
||||
var existingobjects = ((App)Application.Current).IsoDb.GetTestObjects(false);
|
||||
|
||||
var codes = new List<string>();
|
||||
|
||||
foreach (var existingobject in existingobjects)
|
||||
{
|
||||
if (existingobject.Text_L1 == Constants.NON_ISO_TESTOBJECT_NAME)
|
||||
{
|
||||
return existingobject;
|
||||
}
|
||||
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)i });
|
||||
if (!codes.Contains(s))
|
||||
{
|
||||
var to = new MMETestObjects(Guid.NewGuid().ToString(), s, Constants.NON_ISO_TESTOBJECT_NAME, Constants.NON_ISO_TESTOBJECT_NAME, 1,
|
||||
DateTime.Now, "SYSTEM", false, "", DateTime.Now, "created", "", MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
((App)Application.Current).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)i });
|
||||
if (codes.Contains(s)) continue;
|
||||
var to = new MMETestObjects(Guid.NewGuid().ToString(), s, Constants.NON_ISO_TESTOBJECT_NAME, Constants.NON_ISO_TESTOBJECT_NAME, 1,
|
||||
DateTime.Now, "SYSTEM", false, "", DateTime.Now, "created", "", MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
((App)Application.Current).IsoDb.Commit(to);
|
||||
return to;
|
||||
}
|
||||
throw new NotSupportedException("TestObjectTemplate_CouldNotCreateNONISOTESTOBJECT");
|
||||
}
|
||||
public ISO.TestObjectTemplate ToISOTestObjectTemplate()
|
||||
{
|
||||
var template = new ISO.TestObjectTemplate(TemplateName, IsLocalOnly)
|
||||
{
|
||||
Description = TemplateDescription,
|
||||
OriginalTemplateName = OriginalTemplateName,
|
||||
Embedded = Embedded,
|
||||
Icon = "",
|
||||
LocalOnly = IsLocalOnly,
|
||||
TestObject = TestObject.Test_Object,
|
||||
TestObjectType = TestObjectType
|
||||
};
|
||||
var zones = new List<TemplateZone>();
|
||||
foreach (var zone in TemplateZones)
|
||||
{
|
||||
var isoZone = new TemplateZone(TemplateName, zone.Name, zone.GetPictureName(), zone.Description);
|
||||
|
||||
var i = 0;
|
||||
isoZone.TemplateRegions = zone.Regions.Select(region => region.ToISORegion(this, zone, i++)).ToArray();
|
||||
zones.Add(isoZone);
|
||||
}
|
||||
template.TemplateParent = TemplateParent;
|
||||
template.Channels = TemplateAllChannels;
|
||||
template.Zones = zones.ToArray();
|
||||
template.SysBuilt = SysBuilt;
|
||||
return template;
|
||||
}
|
||||
private int CompareChannels(TestObjectTemplateChannel left, TestObjectTemplateChannel right)
|
||||
{
|
||||
if (left == right) { return 0; }
|
||||
if (null == left) { return -1; }
|
||||
return null == right ? 1 : 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;
|
||||
foreach (var c in copy.RequiredChannels)
|
||||
{
|
||||
RequiredChannels.Add(new TestObjectTemplateChannel(c, /*ref db,*/ _template));
|
||||
}
|
||||
TemplateAllChannels = copy.TemplateAllChannels.Select(c => new TestObjectTemplateChannel(c, /*ref db,*/ _template)).ToArray();
|
||||
|
||||
TemplateZones = copy.TemplateZones.Select(z => new Zone(z, this)).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;
|
||||
var mmeTestObjectses = matches as MMETestObjects[] ?? matches.ToArray();
|
||||
if (mmeTestObjectses.Any())
|
||||
{
|
||||
TestObject = mmeTestObjectses[0];
|
||||
bFoundTestObject = true;
|
||||
}
|
||||
}
|
||||
if (!bFoundTestObject)
|
||||
{
|
||||
TestObject = (Application.Current as App).IsoDb.GetTestObjectByIso(template.TestObject);
|
||||
}
|
||||
TestObjectType = template.TestObjectType;
|
||||
OriginalTemplateName = template.OriginalTemplateName;
|
||||
Embedded = template.Embedded;
|
||||
|
||||
TemplateAllChannels = template.Channels.Select(c => new TestObjectTemplateChannel(c, /*ref db,*/ _template)).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 = ((App)Application.Current).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 = ((App)Application.Current).IsoDb.GetTestObjects(false).FirstOrDefault();
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void InitializeNonISO()
|
||||
{
|
||||
//create template, set template channel type to NONISOTYPE
|
||||
TemplateName = Guid.NewGuid().ToString();
|
||||
|
||||
TestObject = GetNonISOTestObject();
|
||||
TestObjectType = Constants.NON_ISO_TESTOBJECT_CHANNEL_TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class CustomerDetails //: BasePropertyChanged
|
||||
{
|
||||
private readonly ISO.CustomerDetails _customerDetails;
|
||||
public string Name
|
||||
{
|
||||
get => _customerDetails.Name;
|
||||
set => _customerDetails.Name = value;
|
||||
}
|
||||
}
|
||||
public class CustomerDetailsList //: BasePropertyChanged
|
||||
{
|
||||
public static void DeleteAll()
|
||||
{
|
||||
ISO.CustomerDetails.DeleteCustomerDetails();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,423 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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 : Exception
|
||||
{
|
||||
public ExpiredISOFieldException(string remark) : base(remark) { }
|
||||
}
|
||||
/// <summary>
|
||||
/// list of directions, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEDirections> _directionsDictionary = new Dictionary<string, MMEDirections>();
|
||||
/// <summary>
|
||||
/// list of filter classes, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEFilterClasses> _filterClassesDictionary = new Dictionary<string, MMEFilterClasses>();
|
||||
/// <summary>
|
||||
/// list of figures, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly List<MMEFigures> _figures = new List<MMEFigures>();
|
||||
/// <summary>
|
||||
/// list of all known fine 1 locations, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEFineLocations1> _fineLoc1Dictionary = new Dictionary<string, MMEFineLocations1>();
|
||||
/// <summary>
|
||||
/// list of all known fine 2 locations, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEFineLocations2> _fineLoc2Dictionary = new Dictionary<string, MMEFineLocations2>();
|
||||
/// <summary>
|
||||
/// list of all known fine 3 locations, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEFineLocations3> _fineLoc3Dictionary = new Dictionary<string, MMEFineLocations3>();
|
||||
/// <summary>
|
||||
/// list of all known physical dimensions, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEPhysicalDimensions> _physicalDimensionsDictionary = new Dictionary<string, MMEPhysicalDimensions>();
|
||||
/// <summary>
|
||||
/// list of all known positions, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEPositions> _positionsDictionary = new Dictionary<string, MMEPositions>();
|
||||
/// <summary>
|
||||
/// list of all known possible channels, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly List<MMEPossibleChannels> _possibleChannels = new List<MMEPossibleChannels>();
|
||||
|
||||
private readonly Dictionary<string, List<MMEPossibleChannels>> _possibleChannelsByType =
|
||||
new Dictionary<string, List<MMEPossibleChannels>>();
|
||||
/// <summary>
|
||||
/// list of possible test objects, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMETestObjects> _testObjectsDictionary = new Dictionary<string, MMETestObjects>();
|
||||
/// <summary>
|
||||
/// list of all possible transducer locations, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMETransducerMainLocation> _transducerMainLoc = new Dictionary<string, MMETransducerMainLocation>();
|
||||
/// <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) return _uniquePossibleChannelTypes.ToArray();
|
||||
_uniquePossibleChannelTypes = new List<string>();
|
||||
var uniquetypes = (from pc in _possibleChannels where !pc.Expired orderby pc.Text_L1 select pc.Type).Distinct().ToArray();
|
||||
if (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();
|
||||
if (!_possibleChannelsByType.ContainsKey(type))
|
||||
{
|
||||
return new MMEPossibleChannels[0];
|
||||
}
|
||||
return _possibleChannelsByType[type].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];
|
||||
}
|
||||
public void DeleteSQL()
|
||||
{
|
||||
try
|
||||
{
|
||||
MMEDirections.DeleteDirections();
|
||||
MMEFigures.DeleteFigures();
|
||||
MMEFilterClasses.DeleteFilterClasses();
|
||||
MMEFineLocations1.DeleteFineLocations1();
|
||||
MMEFineLocations2.DeleteFineLocations2();
|
||||
MMEFineLocations3.DeleteFineLocations3();
|
||||
MMEPhysicalDimensions.DeletePhysicalDimensions();
|
||||
MMEPositions.DeletePositions();
|
||||
MMETestObjects.DeleteTestObjects();
|
||||
MMETransducerMainLocation.DeleteTransducerMainLocations();
|
||||
MMEPossibleChannels.DeletePossibleChannels();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("failure to load ISO tables", ex);
|
||||
}
|
||||
RefreshAllData();
|
||||
}
|
||||
/// <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>
|
||||
/// writes a test object to DATAPro's list of test objects
|
||||
/// </summary>
|
||||
/// <param name="to"></param>
|
||||
public void Commit(MMETestObjects to)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
to.Commit();
|
||||
_testObjectsDictionary[to.Test_Object] = to;
|
||||
}
|
||||
/// <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 (positions.Any()) { return positions.First(); }
|
||||
return null;
|
||||
}
|
||||
/// <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>
|
||||
/// 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 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 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 fine location 3 based on fine location 3 isocode field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEFineLocations3 GetFineLocation3ByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _fineLoc3Dictionary.ContainsKey(key) ? _fineLoc3Dictionary[key] : null;
|
||||
}
|
||||
/// <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;
|
||||
}
|
||||
/// <summary>
|
||||
/// gets all possible positions
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEPositions[] GetPositions()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _positionsDictionary.Values.ToArray();
|
||||
}
|
||||
readonly 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 ExpiredISOFieldException(_expiredMainLocations[key].Remarks); }
|
||||
return null;
|
||||
}
|
||||
private bool _bLoaded = false;
|
||||
private static readonly object RefreshLock = new object();
|
||||
|
||||
private void ProcessPossibleChannels()
|
||||
{
|
||||
foreach (var pc in _possibleChannels)
|
||||
{
|
||||
//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).
|
||||
if (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") { continue; }
|
||||
|
||||
if (!_possibleChannelsByType.ContainsKey(pc.Type))
|
||||
{
|
||||
_possibleChannelsByType[pc.Type] = new List<MMEPossibleChannels>();
|
||||
}
|
||||
_possibleChannelsByType[pc.Type].Add(pc);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// loads all data from iso13499 and datapro databases
|
||||
/// </summary>
|
||||
public void 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();
|
||||
_possibleChannelsByType.Clear();
|
||||
_physicalDimensionsDictionary.Clear();
|
||||
_positionsDictionary.Clear();
|
||||
_possibleChannels.Clear();
|
||||
_testObjectsDictionary.Clear();
|
||||
_transducerMainLoc.Clear();
|
||||
_expiredMainLocations.Clear();
|
||||
|
||||
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());
|
||||
|
||||
ProcessPossibleChannels();
|
||||
|
||||
foreach (var to in MMETestObjects.GetTestObjects()) { if (!_testObjectsDictionary.ContainsKey(to.Test_Object)) { _testObjectsDictionary.Add(to.Test_Object, to); } }
|
||||
|
||||
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)
|
||||
{
|
||||
//APILogger.Log("failure to load ISO tables", ex);
|
||||
}
|
||||
_bLoaded = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_bLoaded = false;
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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 void DeleteFineLocations3()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFineLocations3Delete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) {/* APILogger.Log("failed to delete fine locations3, ", ex); */}
|
||||
}
|
||||
public static MMEFineLocations3[] GetFineLocations3()
|
||||
{
|
||||
var fineLocations3 = new List<MMEFineLocations3>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFineLocations3Get.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
//cmd.ExecuteNonQuery();
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
fineLocations3.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.EXPIRED.ToString()])
|
||||
let fineLoc3 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFineLocations3Fields.FINE_LOC_3.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEFineLocations3Fields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFineLocations3Fields.LAST_CHANGE_TEXT.ToString()])
|
||||
let pictureShortName = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFineLocations3Fields.PICTURE_SHORTNAME
|
||||
.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.s_GUID.ToString()])
|
||||
let sortKey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.TEXT_L2.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.VERSION.ToString()])
|
||||
select new MMEFineLocations3(sGuid, fineLoc3, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortKey, lastChange,
|
||||
lastChangeText, history, pictureShortName,
|
||||
MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process fine locations3: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to load fine locations3, ", ex);*/ }
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFineLocations3GetCustom.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
fineLocations3.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.EXPIRED.ToString()])
|
||||
let fineLoc3 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFineLocations3Fields.FINE_LOC_3.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEFineLocations3Fields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFineLocations3Fields.LAST_CHANGE_TEXT.ToString()])
|
||||
let pictureShortName = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFineLocations3Fields.PICTURE_SHORTNAME
|
||||
.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.s_GUID.ToString()])
|
||||
let sortKey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.TEXT_L2.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMEFineLocations3Fields.VERSION.ToString()])
|
||||
select new MMEFineLocations3(sGuid, fineLoc3, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortKey, lastChange,
|
||||
lastChangeText, history, pictureShortName,
|
||||
MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process custom fine locations3: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) {/* APILogger.Log("failed to load custom fine locations3, ", ex); */}
|
||||
|
||||
return fineLocations3.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// defines the interface tag aware classes must implement
|
||||
/// </summary>
|
||||
public interface ITagAware
|
||||
{
|
||||
}
|
||||
public abstract class TagAwareBase : DbTimeStampBase
|
||||
{
|
||||
public byte[] TagsBlobBytes
|
||||
{
|
||||
get
|
||||
{
|
||||
var result = new byte[TagIDs.Length * sizeof(int)];
|
||||
Buffer.BlockCopy(TagIDs, 0, result, 0, result.Length);
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.Length < sizeof(int)) return;
|
||||
var tagsBlob = new int[value.Length / sizeof(int)];
|
||||
try
|
||||
{
|
||||
Buffer.BlockCopy(value, 0, tagsBlob, 0, value.Length);
|
||||
TagIDs = tagsBlob;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int[] _tagIDs = new int[0];
|
||||
public int[] TagIDs
|
||||
{
|
||||
get => _tagIDs;
|
||||
set => _tagIDs = value ?? new int[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,669 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class SensorData : SensorBase, IComparable<SensorData>, ISensorData
|
||||
{
|
||||
/// <summary>
|
||||
/// 11260 Implement DiagnosticsMode in DataPRO
|
||||
/// DiagnosticsMode means the bridge in analog is short circuited to the outside world and only internal resistors are used
|
||||
/// </summary>
|
||||
public bool DiagnosticsMode { get; set; } = false;
|
||||
public const string TEST_SPECIFIC_DOUT = "TSD_";
|
||||
public static bool IsTestSpecificDigitalOutSN(string sn)
|
||||
{
|
||||
if (!sn.StartsWith(TEST_SPECIFIC_DOUT)) return false;
|
||||
var s = sn.Substring(4);
|
||||
return Guid.TryParse(s, out var notUsed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// At one time all the different DelayMS were using one underlying property for storage, _delayMS.
|
||||
/// Now, the individual SquibFireDelayMS, etc. are defined because we don't want controls that are sharing to limit each other.
|
||||
/// </summary>
|
||||
public double DelayMS
|
||||
{
|
||||
get => _delayMS;
|
||||
set => _delayMS = value;
|
||||
}
|
||||
|
||||
public const double MINIMUM_DIGITALOUTPUT_DELAY_MS = 0D;
|
||||
public const double MAXIMUM_DIGITALOUTPUT_DELAY_MS = 99000D;
|
||||
|
||||
private double _digitalOutputDelayMS;
|
||||
public double DigitalOutputDelayMS
|
||||
{
|
||||
get => _digitalOutputDelayMS;
|
||||
set
|
||||
{
|
||||
var d = value;
|
||||
if (d < MINIMUM_DIGITALOUTPUT_DELAY_MS)
|
||||
{
|
||||
d = MINIMUM_DIGITALOUTPUT_DELAY_MS;
|
||||
}
|
||||
else if (d > MAXIMUM_DIGITALOUTPUT_DELAY_MS)
|
||||
{
|
||||
d = MAXIMUM_DIGITALOUTPUT_DELAY_MS;
|
||||
}
|
||||
SetProperty(ref _digitalOutputDelayMS, d, "DigitalOutputDelayMS");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// At one time all the different DurationMS were using one underlying property for storage, _durationMS.
|
||||
/// Now, the individual SquibFireDurationMS, etc. are defined because we don't want controls that are sharing to limit each other.
|
||||
/// </summary>
|
||||
public double DurationMS
|
||||
{
|
||||
get => _durationMS;
|
||||
set => SetProperty(ref _durationMS, value, "DurationMS");
|
||||
}
|
||||
|
||||
private double _digitalOutputDurationMS = 10D;
|
||||
public double DigitalOutputDurationMS
|
||||
{
|
||||
get => _digitalOutputDurationMS;
|
||||
set => SetProperty(ref _digitalOutputDurationMS, value, "DigitalOutputDurationMS");
|
||||
}
|
||||
private DigitalOutputModes _digitalOutputMode = DigitalOutputModes.FVLH;
|
||||
|
||||
public DigitalOutputModes DigitalOutputMode
|
||||
{
|
||||
get => _digitalOutputMode;
|
||||
set => SetProperty(ref _digitalOutputMode, value, "DigitalOutputMode");
|
||||
}
|
||||
|
||||
public bool DigitalOutputLimitDuration
|
||||
{
|
||||
get => _limitDuration;
|
||||
set => SetProperty(ref _limitDuration, value, "LimitDuration");
|
||||
}
|
||||
|
||||
private double _delayMS;
|
||||
|
||||
public double SquibFireDelayMS
|
||||
{
|
||||
get => _delayMS;
|
||||
set => SetProperty(ref _delayMS, value, "SquibFireDelayMS");
|
||||
}
|
||||
|
||||
private double _durationMS = 10D;
|
||||
public double SquibFireDurationMS
|
||||
{
|
||||
get => _durationMS;
|
||||
set => SetProperty(ref _durationMS, value, "SquibFireDurationMS");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// right now all the Limit Duration mechanisms using the same underlying property for storage (_limitDuration), however
|
||||
/// the public access methods (LimitSquibDuration, etc) exist in case we separate them out in the future
|
||||
/// </summary>
|
||||
public bool LimitDuration
|
||||
{
|
||||
get => _limitDuration;
|
||||
set => SetProperty(ref _limitDuration, value, "LimitDuration");
|
||||
}
|
||||
|
||||
private bool _limitDuration = true;
|
||||
public bool LimitSquibFireDuration
|
||||
{
|
||||
get => _limitDuration;
|
||||
set => SetProperty(ref _limitDuration, value, "LimitSquibFireDuration");
|
||||
}
|
||||
|
||||
private double _squibToleranceLow = 1D;
|
||||
|
||||
public double SquibToleranceLow
|
||||
{
|
||||
get => _squibToleranceLow;
|
||||
set => SetProperty(ref _squibToleranceLow, value, "SquibToleranceLow");
|
||||
}
|
||||
|
||||
private double _squibToleranceHigh = 8D;
|
||||
public double SquibToleranceHigh
|
||||
{
|
||||
get => _squibToleranceHigh;
|
||||
set => SetProperty(ref _squibToleranceHigh, value, "SquibToleranceHigh");
|
||||
}
|
||||
|
||||
private SquibMeasurementType _squibMeasurementType = SquibMeasurementType.VOLTAGE;
|
||||
public SquibMeasurementType SquibMeasurementType
|
||||
{
|
||||
get => _squibMeasurementType;
|
||||
set => SetProperty(ref _squibMeasurementType, value, "SquibMeasurementType");
|
||||
}
|
||||
|
||||
private double _squibOutputCurrent = 1.5D;
|
||||
public double SquibOutputCurrent
|
||||
{
|
||||
get => _squibOutputCurrent;
|
||||
set => SetProperty(ref _squibOutputCurrent, value, "SquibOutputCurrent");
|
||||
}
|
||||
|
||||
public override string DisplayUnit
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsSquib())
|
||||
{
|
||||
switch (SquibMeasurementType)
|
||||
{
|
||||
case SquibMeasurementType.CURRENT:
|
||||
return "A";
|
||||
default:
|
||||
return "V";
|
||||
}
|
||||
}
|
||||
if (null == Calibration || 0 == Calibration.Records.Records.Length) { return ""; }
|
||||
return Calibration.Records.Records[0].EngineeringUnits; //6194 disable display units for the short term
|
||||
}
|
||||
//6194 disable display units for the short term
|
||||
set { }
|
||||
}
|
||||
private SquibFireMode _squibFireMode = SquibFireMode.NONE;
|
||||
public SquibFireMode SquibFireMode
|
||||
{
|
||||
get => _squibFireMode;
|
||||
set => SetProperty(ref _squibFireMode, value, "SquibFireMode");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// the input mode for this setting
|
||||
/// </summary>
|
||||
protected DigitalInputModes _inputMode = DigitalInputModes.CCNO;
|
||||
/// <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>
|
||||
protected DigitalInputScaleMultiplier _digitalInputScaleMultiplier = new DigitalInputScaleMultiplier();
|
||||
|
||||
/// <summary>
|
||||
/// the setting name allows us to refer to different settings and allow it to be more easily included in test setups and channel setups
|
||||
/// </summary>
|
||||
public string SettingName
|
||||
{
|
||||
get => SerialNumber;
|
||||
set
|
||||
{
|
||||
SerialNumber = value;
|
||||
OnPropertyChanged("SettingName");
|
||||
}
|
||||
}
|
||||
|
||||
public DigitalInputModes InputMode
|
||||
{
|
||||
get => _inputMode;
|
||||
set => SetProperty(ref _inputMode, value, "InputMode");
|
||||
}
|
||||
|
||||
public DigitalInputScaleMultiplier ScaleMultiplier
|
||||
{
|
||||
get => _digitalInputScaleMultiplier;
|
||||
set => SetProperty(ref _digitalInputScaleMultiplier, value, "ScaleMultiplier");
|
||||
}
|
||||
|
||||
public SensorData(SensorData copy)
|
||||
{
|
||||
if (null == copy) { copy = new SensorData(); }
|
||||
DbTimeStamp = copy.DbTimeStamp;
|
||||
_digitalOutputMode = copy._digitalOutputMode;
|
||||
_inputMode = copy._inputMode;
|
||||
SquibMeasurementType = copy.SquibMeasurementType;
|
||||
_digitalInputScaleMultiplier = new DigitalInputScaleMultiplier(copy._digitalInputScaleMultiplier);
|
||||
_delayMS = copy._delayMS;
|
||||
_digitalOutputDelayMS = copy._digitalOutputDelayMS;
|
||||
_durationMS = copy._durationMS;
|
||||
_digitalOutputDurationMS = copy._digitalOutputDurationMS;
|
||||
_limitDuration = copy._limitDuration;
|
||||
_squibToleranceHigh = copy._squibToleranceHigh;
|
||||
_squibToleranceLow = copy._squibToleranceLow;
|
||||
_squibFireMode = copy._squibFireMode;
|
||||
_squibOutputCurrent = copy._squibOutputCurrent;
|
||||
TagsBlobBytes = copy.TagsBlobBytes;
|
||||
DoNotUse = copy.DoNotUse;
|
||||
Broken = copy.Broken;
|
||||
DbTimeStamp = copy.DbTimeStamp;
|
||||
if (null != copy.Calibration)
|
||||
{
|
||||
Calibration = new SensorCalibration(copy.Calibration);
|
||||
}
|
||||
try
|
||||
{
|
||||
AxisNumber = copy.AxisNumber;
|
||||
BridgeLegMode = copy.BridgeLegMode;
|
||||
BridgeResistance = copy.BridgeResistance;
|
||||
Bridge = copy.Bridge;
|
||||
ByPassFilter = copy.ByPassFilter;
|
||||
CheckCalibrationSignal = copy.CheckCalibrationSignal;
|
||||
CalInterval = copy.CalInterval;
|
||||
Capacity = copy.Capacity;
|
||||
CheckOffset = copy.CheckOffset;
|
||||
Comment = copy.Comment;
|
||||
CouplingMode = copy.CouplingMode;
|
||||
Created = copy.Created;
|
||||
ExternalShuntResistance = copy.ExternalShuntResistance;
|
||||
Filter = copy.Filter;
|
||||
Id = copy.Id;
|
||||
InternalShuntResistance = copy.InternalShuntResistance;
|
||||
Invert = copy.Invert;
|
||||
ISOCode = copy.ISOCode;
|
||||
LastModified = copy.LastModified;
|
||||
_localOnly = copy.LocalOnly;
|
||||
Manufacturer = copy.Manufacturer;
|
||||
DisplayUnit = copy.DisplayUnit;
|
||||
Model = copy.Model;
|
||||
LastUpdatedBy = copy.LastUpdatedBy;
|
||||
NumberOfAxes = copy.NumberOfAxes;
|
||||
OffsetToleranceHigh = copy.OffsetToleranceHigh;
|
||||
OffsetToleranceLow = copy.OffsetToleranceLow;
|
||||
RangeMedium = copy.RangeMedium;
|
||||
RangeHigh = copy.RangeHigh;
|
||||
RangeLow = copy.RangeLow;
|
||||
SensorCategory = copy.SensorCategory;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
Shunt = copy.Shunt;
|
||||
Status = copy.Status;
|
||||
TimesUsed = copy.TimesUsed;
|
||||
UniPolar = copy.UniPolar;
|
||||
UserSerialNumber = copy.UserSerialNumber;
|
||||
UserValue1 = copy.UserValue1;
|
||||
UserValue2 = copy.UserValue2;
|
||||
UserValue3 = copy.UserValue3;
|
||||
DiagnosticsMode = copy.DiagnosticsMode;
|
||||
Version = copy.Version;
|
||||
SetSupportedExcitationFromString(copy.GetSerializedSupportedExcitation());
|
||||
TagsBlobBytes = copy.TagsBlobBytes;
|
||||
DoNotUse = copy.DoNotUse;
|
||||
Broken = copy.Broken;
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
|
||||
FilterClassIso = copy.FilterClassIso;
|
||||
MeasureExcitation = copy.MeasureExcitation;
|
||||
MeasureNoise = copy.MeasureNoise;
|
||||
}
|
||||
private static Test.Module.Channel.Sensor.BridgeType ConvertToBridge(int bridge)
|
||||
{
|
||||
switch (bridge)
|
||||
{
|
||||
case 0: return Test.Module.Channel.Sensor.BridgeType.IEPE;
|
||||
case 4: return Test.Module.Channel.Sensor.BridgeType.HalfBridge_SigPlus;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//added an option parameter to prevent querying cals one by one by passing in a dictionary
|
||||
//17991 calspan speed ups for opening a test setup
|
||||
public SensorData(IDataRecord reader, IReadOnlyDictionary<string, SensorCalibration> calLookup = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
AxisNumber = Convert.ToInt16(reader[DbOperations.SensorDB.SensorDataFields.AxisNumber.ToString()]);
|
||||
BridgeLegMode = (BridgeLeg)Convert.ToInt32(reader[DbOperations.SensorDB.SensorDataFields.BridgeLegMode.ToString()]);
|
||||
BridgeResistance = Convert.ToDouble(reader[DbOperations.SensorDB.SensorDataFields.BridgeResistance.ToString()]);
|
||||
Bridge = ConvertToBridge(Convert.ToInt32(reader[DbOperations.SensorDB.SensorDataFields.BridgeType.ToString()]));
|
||||
ByPassFilter = Convert.ToBoolean(reader[DbOperations.SensorDB.SensorDataFields.BypassFilter.ToString()]);
|
||||
CheckCalibrationSignal = Convert.ToBoolean(reader[DbOperations.SensorDB.SensorDataFields.CalibrationSignal.ToString()]);
|
||||
CalInterval = Convert.ToInt32(reader[DbOperations.SensorDB.SensorDataFields.CalInterval.ToString()]);
|
||||
Capacity = Convert.ToDouble(reader[DbOperations.SensorDB.SensorDataFields.Capacity.ToString()]);
|
||||
CheckOffset = Convert.ToBoolean(reader[DbOperations.SensorDB.SensorDataFields.CheckOffset.ToString()]);
|
||||
Comment = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.Comment.ToString()]);
|
||||
CouplingMode = (CouplingModes)Convert.ToInt32(reader[DbOperations.SensorDB.SensorDataFields.CouplingMode.ToString()]);
|
||||
Created = (DateTime)reader[DbOperations.SensorDB.SensorDataFields.Created.ToString()];
|
||||
ExternalShuntResistance = Convert.ToDouble(reader[DbOperations.SensorDB.SensorDataFields.ExternalShuntResistance.ToString()]);
|
||||
Filter = new FilterClass(Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.FilterClass.ToString()]));
|
||||
Id = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.eId.ToString()]);
|
||||
InternalShuntResistance = Convert.ToDouble(reader[DbOperations.SensorDB.SensorDataFields.InternalShuntResistance.ToString()]);
|
||||
Invert = Convert.ToBoolean(reader[DbOperations.SensorDB.SensorDataFields.Invert.ToString()]);
|
||||
ISOCode = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.IsoCode.ToString()]);
|
||||
LastModified = (DateTime)reader[DbOperations.SensorDB.SensorDataFields.LastModified.ToString()];
|
||||
_localOnly = Convert.ToBoolean(reader[DbOperations.SensorDB.SensorDataFields.LocalOnly.ToString()]);
|
||||
Manufacturer = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.Manufacturer.ToString()]);
|
||||
DisplayUnit = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.MeasurementUnit.ToString()]);
|
||||
Model = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.Model.ToString()]);
|
||||
LastUpdatedBy = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.ModifiedBy.ToString()]);
|
||||
NumberOfAxes = Convert.ToInt16(reader[DbOperations.SensorDB.SensorDataFields.NumberOfAxes.ToString()]);
|
||||
OffsetToleranceHigh = Convert.ToDouble(reader[DbOperations.SensorDB.SensorDataFields.OffsetToleranceHigh.ToString()]);
|
||||
OffsetToleranceLow = Convert.ToDouble(reader[DbOperations.SensorDB.SensorDataFields.OffsetToleranceLow.ToString()]);
|
||||
RangeMedium = Convert.ToDouble(reader[DbOperations.SensorDB.SensorDataFields.RangeAve.ToString()]);
|
||||
RangeHigh = Convert.ToDouble(reader[DbOperations.SensorDB.SensorDataFields.RangeHigh.ToString()]);
|
||||
RangeLow = Convert.ToDouble(reader[DbOperations.SensorDB.SensorDataFields.RangeLow.ToString()]);
|
||||
SensorCategory = Convert.ToInt32(reader[DbOperations.SensorDB.SensorDataFields.SensorCategory.ToString()]);
|
||||
SerialNumber = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.SerialNumber.ToString()]);
|
||||
Shunt = (ShuntMode)Convert.ToInt32(reader[DbOperations.SensorDB.SensorDataFields.Shunt.ToString()]);
|
||||
var oStatus = reader[DbOperations.SensorDB.SensorDataFields.Status.ToString()];
|
||||
if (oStatus is string s)
|
||||
{
|
||||
if (Enum.TryParse(s, out SensorStatus newStatus))
|
||||
{
|
||||
Status = newStatus;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = (SensorStatus)Convert.ToInt32(oStatus);
|
||||
}
|
||||
TimesUsed = Convert.ToInt32(reader[DbOperations.SensorDB.SensorDataFields.TimesUsed.ToString()]);
|
||||
UniPolar = Convert.ToBoolean(reader[DbOperations.SensorDB.SensorDataFields.UniPolar.ToString()]);
|
||||
UserSerialNumber = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.UserSerialNumber.ToString()]);
|
||||
DiagnosticsMode = Convert.ToBoolean(reader[DbOperations.SensorDB.SensorDataFields.DiagnosticsMode.ToString()]);
|
||||
UserValue1 = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.UserValue1.ToString()]);
|
||||
UserValue2 = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.UserValue2.ToString()]);
|
||||
UserValue3 = Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.UserValue3.ToString()]);
|
||||
Version = Convert.ToInt32(reader[DbOperations.SensorDB.SensorDataFields.Version.ToString()]);
|
||||
SetSupportedExcitationFromString(Convert.ToString(reader[DbOperations.SensorDB.SensorDataFields.SupportedExcitation.ToString()]));
|
||||
TagsBlobBytes = (byte[])reader[DbOperations.SensorDB.SensorDataFields.UserTags.ToString()];
|
||||
DoNotUse = Convert.ToBoolean(reader[DbOperations.SensorDB.SensorDataFields.DoNotUse.ToString()]);
|
||||
Broken = Convert.ToBoolean(reader[DbOperations.SensorDB.SensorDataFields.Broken.ToString()]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process: ", ex);
|
||||
}
|
||||
}
|
||||
private string _serialNumber = "";
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _serialNumber;
|
||||
set => SetProperty(ref _serialNumber, value, "SerialNumber");
|
||||
}
|
||||
private string _userSerialNumber = "";
|
||||
public string UserSerialNumber
|
||||
{
|
||||
get => _userSerialNumber;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
SetProperty(ref _userSerialNumber, value, "UserSerialNumber");
|
||||
}
|
||||
}
|
||||
|
||||
private SensorStatus _status = SensorStatus.Available;
|
||||
public SensorStatus Status
|
||||
{
|
||||
get => _status;
|
||||
set => _status = value;
|
||||
}
|
||||
|
||||
|
||||
private string _id = "";
|
||||
public string Id
|
||||
{
|
||||
get => _id;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
SetProperty(ref _id, value, "Id");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string _comment = "";
|
||||
public string Comment
|
||||
{
|
||||
get => _comment;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) { value = ""; }
|
||||
SetProperty(ref _comment, value, "Comment");
|
||||
}
|
||||
}
|
||||
private double _internalShuntResistance;
|
||||
public double InternalShuntResistance
|
||||
{
|
||||
get => _internalShuntResistance;
|
||||
set => SetProperty(ref _internalShuntResistance, value, "InternalShuntResistance");
|
||||
}
|
||||
|
||||
private double _externalShuntResistance;
|
||||
public double ExternalShuntResistance
|
||||
{
|
||||
get => _externalShuntResistance;
|
||||
set => SetProperty(ref _externalShuntResistance, value, "ExternalShuntResistance");
|
||||
}
|
||||
|
||||
private BridgeLeg _bridgeLegMode = BridgeLeg.First;
|
||||
public BridgeLeg BridgeLegMode
|
||||
{
|
||||
get => _bridgeLegMode;
|
||||
set => SetProperty(ref _bridgeLegMode, value, "BridgeLegMode");
|
||||
}
|
||||
|
||||
|
||||
private string _userValue1 = "";
|
||||
public string UserValue1
|
||||
{
|
||||
get => _userValue1;
|
||||
set { if (value == null) { value = ""; } SetProperty(ref _userValue1, value, "UserValue1"); }
|
||||
}
|
||||
|
||||
private string _userValue2 = "";
|
||||
public string UserValue2
|
||||
{
|
||||
get => _userValue2;
|
||||
set { if (value == null) { value = ""; } SetProperty(ref _userValue2, value, "UserValue2"); }
|
||||
}
|
||||
|
||||
private string _userValue3 = "";
|
||||
public string UserValue3
|
||||
{
|
||||
get => _userValue3;
|
||||
set { if (value == null) { value = ""; } SetProperty(ref _userValue3, value, "UserValue3"); }
|
||||
}
|
||||
|
||||
|
||||
public string GetSerializedSupportedExcitation()
|
||||
{
|
||||
return string.Join(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, SupportedExcitation.Select(sp => sp.ToString()).ToArray());
|
||||
}
|
||||
public void SetSupportedExcitationFromString(string s)
|
||||
{
|
||||
var excitations = new List<ExcitationVoltageOptions.ExcitationVoltageOption>();
|
||||
|
||||
var tokens = s.Split(new[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
if (Enum.TryParse(token, out ExcitationVoltageOptions.ExcitationVoltageOption option)) { excitations.Add(option); }
|
||||
}
|
||||
SupportedExcitation = excitations.ToArray();
|
||||
}
|
||||
|
||||
private DateTime _created = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
|
||||
public DateTime Created
|
||||
{
|
||||
get => _created;
|
||||
set => SetProperty(ref _created, value, "Created");
|
||||
}
|
||||
|
||||
private int _timesUsed;
|
||||
public int TimesUsed
|
||||
{
|
||||
get => _timesUsed;
|
||||
set => SetProperty(ref _timesUsed, value, "TimesUsed");
|
||||
}
|
||||
|
||||
private int _sensorCategory;
|
||||
public int SensorCategory
|
||||
{
|
||||
get => _sensorCategory;
|
||||
set => SetProperty(ref _sensorCategory, value, "SensorCategory");
|
||||
}
|
||||
|
||||
private bool _bypassFilter;
|
||||
public bool ByPassFilter
|
||||
{
|
||||
get => _bypassFilter;
|
||||
set => SetProperty(ref _bypassFilter, value, "BypassFilter");
|
||||
}
|
||||
|
||||
private bool _checkCalibrationSignal;
|
||||
public bool CheckCalibrationSignal
|
||||
{
|
||||
get => _checkCalibrationSignal;
|
||||
set => SetProperty(ref _checkCalibrationSignal, value, "CheckCalibrationSignal");
|
||||
}
|
||||
|
||||
|
||||
public string TestObject
|
||||
{
|
||||
get => new IsoCode(ISOCode).TestObject;
|
||||
set
|
||||
{
|
||||
var ic = new IsoCode(ISOCode) { TestObject = value };
|
||||
ISOCode = ic.StringRepresentation;
|
||||
OnPropertyChanged("TestObject");
|
||||
}
|
||||
}
|
||||
|
||||
public string OriginalPosition { get; set; }
|
||||
|
||||
public string Position
|
||||
{
|
||||
get
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
return ic.Position;
|
||||
}
|
||||
set
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
ic.Position = value;
|
||||
ISOCode = ic.StringRepresentation;
|
||||
OnPropertyChanged("Position");
|
||||
}
|
||||
}
|
||||
public string MainLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
return ic.MainLocation;
|
||||
}
|
||||
set
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
ic.MainLocation = value;
|
||||
ISOCode = ic.StringRepresentation;
|
||||
OnPropertyChanged("MainLocation");
|
||||
}
|
||||
}
|
||||
public string FineLocation1
|
||||
{
|
||||
get
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
return ic.FineLocation1;
|
||||
}
|
||||
set
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
ic.FineLocation1 = value;
|
||||
ISOCode = ic.StringRepresentation;
|
||||
OnPropertyChanged("FineLocation1");
|
||||
}
|
||||
}
|
||||
public string FineLocation2
|
||||
{
|
||||
get
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
return ic.FineLocation2;
|
||||
}
|
||||
set
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
ic.FineLocation2 = value;
|
||||
ISOCode = ic.StringRepresentation;
|
||||
OnPropertyChanged("FineLocation2");
|
||||
}
|
||||
}
|
||||
public string FineLocation3
|
||||
{
|
||||
get
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
return ic.FineLocation3;
|
||||
}
|
||||
set
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
ic.FineLocation3 = value;
|
||||
ISOCode = ic.StringRepresentation;
|
||||
OnPropertyChanged("FineLocation3");
|
||||
}
|
||||
}
|
||||
public string FilterClassIso
|
||||
{
|
||||
get
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
return ic.FilterClass;
|
||||
}
|
||||
set
|
||||
{
|
||||
var ic = new IsoCode(ISOCode);
|
||||
ic.FilterClass = value;
|
||||
ISOCode = ic.StringRepresentation;
|
||||
switch (value)
|
||||
{
|
||||
case "A":
|
||||
Filter = new FilterClass(FilterClass.FilterClassType.CFC1000);
|
||||
break;
|
||||
case "B":
|
||||
Filter = new FilterClass(FilterClass.FilterClassType.CFC600);
|
||||
break;
|
||||
case "C":
|
||||
Filter = new FilterClass(FilterClass.FilterClassType.CFC180);
|
||||
break;
|
||||
case "D":
|
||||
Filter = new FilterClass(FilterClass.FilterClassType.CFC60);
|
||||
break;
|
||||
case "P":
|
||||
Filter = new FilterClass(FilterClass.FilterClassType.None);
|
||||
break;
|
||||
case "S":
|
||||
Filter = new FilterClass(FilterClass.FilterClassType.AdHoc);
|
||||
break;
|
||||
}
|
||||
OnPropertyChanged("FilterClassIso");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public SensorData()
|
||||
{
|
||||
ISOCode = BuildIsoCodeFromFilter(null, Filter.FClass);
|
||||
}
|
||||
|
||||
public int CompareTo(SensorData other)
|
||||
{
|
||||
return string.Compare(SerialNumber, other.SerialNumber, StringComparison.Ordinal);
|
||||
}
|
||||
public bool IncompatibleSensorAssignment(string sensorDimension, string channelDimension)
|
||||
{
|
||||
return sensorDimension != channelDimension &&
|
||||
sensorDimension != "00" &&
|
||||
sensorDimension != "SE" &&
|
||||
!sensorDimension.Contains("?") &&
|
||||
channelDimension != "00" &&
|
||||
channelDimension != "SE" &&
|
||||
!channelDimension.Contains("?");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class DbOperationsEnum
|
||||
{
|
||||
public enum StoredProcedure
|
||||
{
|
||||
sp_UserDelete,
|
||||
sp_UserGet,
|
||||
sp_UserGetIdsAll,
|
||||
sp_CalculatedChannelsGet,
|
||||
sp_CustomerDetailsDelete,
|
||||
sp_CustomerDetailsGet,
|
||||
sp_DASChannelsGet,
|
||||
sp_DASDelete,
|
||||
sp_DASGet,
|
||||
sp_DBImportCustomerDetails,
|
||||
sp_DBImportDASList,
|
||||
sp_DBImportDbVersions,
|
||||
sp_DBImportGroup,
|
||||
sp_DBImportGroupTemplate,
|
||||
sp_DBImportLabDetails,
|
||||
sp_DBImportLastUsedHardware,
|
||||
sp_DBImportMMEDirections,
|
||||
sp_DBImportMMEFineLocations1,
|
||||
sp_DBImportMMEFineLocations2,
|
||||
sp_DBImportMMEFineLocations3,
|
||||
sp_DBImportMMEMainLocations,
|
||||
sp_DBImportMMEPhysicalDimensions,
|
||||
sp_DBImportMMEPositions,
|
||||
sp_DBImportMMEPossibleChannels,
|
||||
sp_DBImportMMETestObjects,
|
||||
sp_DBImportSensorModel,
|
||||
sp_DBImportSensors,
|
||||
sp_DBImportSensorsCalibration,
|
||||
sp_DBImportSettings,
|
||||
sp_DBImportTagAssignments,
|
||||
sp_DBImportTags,
|
||||
sp_DBImportTemplateRegions,
|
||||
sp_DBImportTemplateZones,
|
||||
sp_DBImportTestEngineerDetails,
|
||||
sp_DBImportTestSetups,
|
||||
sp_DBImportUIItems,
|
||||
sp_DBImportUIItemSettings,
|
||||
sp_DBImportUsers,
|
||||
sp_DefaultPropertiesGet,
|
||||
sp_LabratoryDetailsDelete,
|
||||
sp_LabratoryDetailsGet,
|
||||
sp_LevelTriggersGet,
|
||||
sp_MMEDirectionsDelete,
|
||||
sp_MMEDirectionsGet,
|
||||
sp_MMEDirectionsGetCustom,
|
||||
sp_MMEFiguresGet,
|
||||
sp_MMEFiguresGetCustom,
|
||||
sp_MMEFilterClassesDelete,
|
||||
sp_MMEFilterClassesGet,
|
||||
sp_MMEFilterClassesGetCustom,
|
||||
sp_MMEFineLocations1Delete,
|
||||
sp_MMEFineLocations1Get,
|
||||
sp_MMEFineLocations1GetCustom,
|
||||
sp_MMEFineLocations2Delete,
|
||||
sp_MMEFineLocations2Get,
|
||||
sp_MMEFineLocations2GetCustom,
|
||||
sp_MMEFineLocations3Delete,
|
||||
sp_MMEFineLocations3Get,
|
||||
sp_MMEFineLocations3GetCustom,
|
||||
sp_MMEMainLocationsDelete,
|
||||
sp_MMEMainLocationsGet,
|
||||
sp_MMEMainLocationsGetCustom,
|
||||
sp_MMEPhysicalDimensionsDelete,
|
||||
sp_MMEPhysicalDimensionsGet,
|
||||
sp_MMEPhysicalDimensionsGetCustom,
|
||||
sp_MMEPositionsDelete,
|
||||
sp_MMEPositionsGet,
|
||||
sp_MMEPositionsGetCustom,
|
||||
sp_MMEPossibleChannelsDelete,
|
||||
sp_MMEPossibleChannelsGet,
|
||||
sp_MMEPossibleChannelsGetCustom,
|
||||
sp_MMETestObjectsDelete,
|
||||
sp_MMETestObjectsGet,
|
||||
sp_MMETestObjectsGetCustom,
|
||||
sp_MMETestObjectsUpdateInsert,
|
||||
sp_TemplateChannelsGet,
|
||||
sp_TemplateRegionsGet,
|
||||
sp_TemplateZonesGet,
|
||||
sp_TestChannelSettingsGet,
|
||||
sp_TestEngineerDetailsDelete,
|
||||
sp_TestEngineerDetailsGet,
|
||||
sp_TestGraphsGet,
|
||||
sp_TestObjectChannelSettingsGet,
|
||||
sp_TestObjectHardwareIdsGet,
|
||||
sp_TestObjectSensorsGet,
|
||||
sp_TestObjectsDelete,
|
||||
sp_TestObjectsGet,
|
||||
sp_TestObjectTemplatesDelete,
|
||||
sp_TestObjectTemplatesGet,
|
||||
sp_TestSetupDASSettingsGet,
|
||||
sp_TestSetupHardwareGet,
|
||||
sp_TestSetupObjectMetaDataGet,
|
||||
sp_TestSetupObjectsGet,
|
||||
sp_TestSetupsDeleteAll,
|
||||
sp_TestSetupsGet,
|
||||
sp_TestSetupsUpdateInsert,
|
||||
sp_TestSetupsIsCompleteUpdate,
|
||||
sp_SensorCalibrationsDelete,
|
||||
sp_SensorCalibrationsGet,
|
||||
sp_SensorDeleteAll,
|
||||
sp_SensorsDeleteAll,
|
||||
sp_SensorsAnalogGet,
|
||||
sp_SensorsDigitalInGet,
|
||||
sp_SensorsDigitalOutGet,
|
||||
sp_SensorsSquibGet,
|
||||
sp_SensorModelsDelete,
|
||||
sp_SensorModelsGet,
|
||||
sp_SettingsGet,
|
||||
sp_SettingsUpdateInsert,
|
||||
sp_TagsDelete,
|
||||
sp_TagsGet,
|
||||
sp_UIItemsDelete,
|
||||
sp_UIItemsGet,
|
||||
sp_UserPropertiesInsert,
|
||||
sp_DbVersionDelete,
|
||||
sp_DbVersionGet,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// represents hardware in TTS import
|
||||
/// </summary>
|
||||
public interface IDASHardware
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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,
|
||||
SLICE6DB = 33
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public interface IISOHardware
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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
|
||||
{
|
||||
public DigitalInputSetting(IDataRecord reader) : base()
|
||||
{
|
||||
SetDefaults(this);
|
||||
try
|
||||
{
|
||||
LastModified = Convert.ToDateTime(reader[DbOperations.DigitalInputSettings.Fields.LastModified.ToString()]);
|
||||
LastUpdatedBy = Convert.ToString(reader[DbOperations.DigitalInputSettings.Fields.LastModifiedBy.ToString()]);
|
||||
InputMode = (DigitalInputModes)Convert.ToInt32(reader[DbOperations.DigitalInputSettings.Fields.SettingMode.ToString()]);
|
||||
SettingName = Convert.ToString(reader[DbOperations.DigitalInputSettings.Fields.SettingName.ToString()]);
|
||||
Id = Convert.ToString(reader[DbOperations.DigitalInputSettings.Fields.eId.ToString()]);
|
||||
UserValue1 = Convert.ToString(reader[DbOperations.DigitalInputSettings.Fields.UserValue1.ToString()]);
|
||||
UserValue2 = Convert.ToString(reader[DbOperations.DigitalInputSettings.Fields.UserValue2.ToString()]);
|
||||
UserValue3 = Convert.ToString(reader[DbOperations.DigitalInputSettings.Fields.UserValue3.ToString()]);
|
||||
TagsBlobBytes = (byte[])reader[DbOperations.DigitalInputSettings.Fields.UserTags.ToString()];
|
||||
Comment = Convert.ToString(reader[DbOperations.DigitalInputSettings.Fields.UserValue1.ToString()]);
|
||||
ScaleMultiplier.FromDbSerializeString(Convert.ToString(reader[DbOperations.DigitalInputSettings.Fields.ScaleMultiplier.ToString()]));
|
||||
Broken = Convert.ToBoolean(reader[DbOperations.DigitalInputSettings.Fields.Broken.ToString()]);
|
||||
DoNotUse = Convert.ToBoolean(reader[DbOperations.DigitalInputSettings.Fields.DoNotUse.ToString()]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process: ", ex);
|
||||
}
|
||||
}
|
||||
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,23 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
|
||||
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
|
||||
}
|
||||
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
|
||||
public enum SquibFireMode
|
||||
{
|
||||
NONE = 1 << 0, //squib's fire mode not set
|
||||
[DescriptionAttribute("Capacitor discharge")]
|
||||
CAP = 1 << 1, //use capacitor discharge
|
||||
[DescriptionAttribute("Constant current")]
|
||||
CONSTANT = 1 << 2, //use constant current discharge
|
||||
AC = 1 << 3 //use AC discharge
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,238 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport.ISO
|
||||
{
|
||||
[Serializable()]
|
||||
public class LabratoryDetails //: ISerializableFile
|
||||
{
|
||||
private enum Fields
|
||||
{
|
||||
Name,
|
||||
LaboratoryName,
|
||||
LaboratoryContactName,
|
||||
LaboratoryContactPhone,
|
||||
LaboratoryContactFax,
|
||||
LaboratoryContactEmail,
|
||||
LaboratoryTestRefNumber,
|
||||
LaboratoryProjectRefNumber,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
LocalOnly,
|
||||
Version
|
||||
};
|
||||
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;
|
||||
}
|
||||
|
||||
private bool _localOnly;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private int _version = 1;
|
||||
|
||||
public int Version
|
||||
{
|
||||
get => _version;
|
||||
set => _version = value;
|
||||
}
|
||||
public static LabratoryDetails ReadXML(System.Xml.XmlElement root)
|
||||
{
|
||||
var l = new LabratoryDetails();
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
if (node is System.Xml.XmlElement)
|
||||
{
|
||||
ProcessXMLElement(node as System.Xml.XmlElement, ref l);
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
private static void ProcessXMLElement(System.Xml.XmlElement node, ref LabratoryDetails lab)
|
||||
{
|
||||
if (Enum.TryParse(node.Name, out Fields field))
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case Fields.Version:
|
||||
lab.Version = int.Parse(node.InnerText, System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case Fields.Name:
|
||||
lab.Name = node.InnerText;
|
||||
break;
|
||||
case Fields.LocalOnly:
|
||||
lab.LocalOnly = Convert.ToBoolean(node.InnerText);
|
||||
break;
|
||||
case Fields.LastModifiedBy:
|
||||
lab.LastModifiedBy = node.InnerText;
|
||||
break;
|
||||
case Fields.LastModified:
|
||||
lab.LastModified = DateTime.Parse(node.InnerText,
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case Fields.LaboratoryTestRefNumber:
|
||||
lab.LabratoryTestRefNumber = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryProjectRefNumber:
|
||||
lab.LabratoryProjectRefNumber = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryName:
|
||||
lab.LabratoryName = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryContactPhone:
|
||||
lab.LabratoryContactPhone = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryContactName:
|
||||
lab.LabratoryContactName = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryContactFax:
|
||||
lab.LabratoryContactFax = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryContactEmail:
|
||||
lab.LabratoryContactEmail = node.InnerText;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("LabratoryDetails::ProcessXMLElement unsupported field: " +
|
||||
field.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteLabratoryDetails()
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DTS.Common.Storage.DbOperations.LabratoryDetailsDelete(null, out string errorMessage);
|
||||
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
//APILogger.Log("Failed to delete labratory details", errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to delete laboratory details", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public LabratoryDetails()
|
||||
{
|
||||
}
|
||||
public LabratoryDetails(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"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class SensorCalibrationList
|
||||
{
|
||||
private static List<SensorCalibration> _cachedCalibrations = null;
|
||||
protected SensorCalibrationList()
|
||||
{
|
||||
//removed code that appeared it would never work? (wrong parameters to sql sp)
|
||||
}
|
||||
private readonly Dictionary<string, List<SensorCalibration>> _calibrations;
|
||||
private static readonly object LOCK = new object();
|
||||
|
||||
private static SensorCalibrationList _calibrationList;
|
||||
public static void Reload()
|
||||
{
|
||||
lock (LOCK)
|
||||
{
|
||||
_calibrationList = new SensorCalibrationList();
|
||||
}
|
||||
}
|
||||
public static SensorCalibration GetLatestCalibrationBySerialNumberAndExcitation(SensorData sd, ExcitationVoltageOptions.ExcitationVoltageOption exc)
|
||||
{
|
||||
if (null == sd) { return null; }
|
||||
if (sd.IsDigitalInput() || sd.IsSquib() || sd.IsDigitalOutput()) { return SensorCalibration.NewDigitalSC(); }
|
||||
if (null != _cachedCalibrations)
|
||||
{
|
||||
var matches = from sc in _cachedCalibrations where sc.SerialNumber == sd.SerialNumber select sc;
|
||||
var sensorCalibrations = matches as SensorCalibration[] ?? matches.ToArray();
|
||||
if (sensorCalibrations.Any())
|
||||
{
|
||||
SensorCalibration cal = null;
|
||||
|
||||
foreach (var sc in sensorCalibrations)
|
||||
{
|
||||
if (sc.IsProportional)
|
||||
{
|
||||
var bOk = Array.Exists(sc.Records.Records, record => record.Excitation == exc);
|
||||
|
||||
if (!bOk) { continue; }
|
||||
}
|
||||
if (null == cal) { cal = sc; }
|
||||
else if (sc.CalibrationDate > cal.CalibrationDate) { cal = sc; }
|
||||
else if (sc.CalibrationDate == cal.CalibrationDate && sc.ModifyDate > cal.ModifyDate)
|
||||
{
|
||||
cal = sc;
|
||||
}
|
||||
}
|
||||
if (null != cal) { return cal; }
|
||||
}
|
||||
}
|
||||
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) {/* APILogger.Log(ex);*/ }
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
// /// <summary>
|
||||
// /// deletes all calibration data
|
||||
// /// originally created so TDM imports could clear all tables except DAS tables
|
||||
// /// </summary>
|
||||
public static void DeleteAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SensorCalibrationsDelete.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@SensorSerialNumber", SqlDbType.Int) { Value = null });
|
||||
cmd.Parameters.Add(new SqlParameter("@CalibrationDate", SqlDbType.DateTime) { Value = null });
|
||||
cmd.Parameters.Add(new SqlParameter("@ModifiedDate", SqlDbType.DateTime) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
lock (LOCK)
|
||||
{
|
||||
if (null == _calibrationList)
|
||||
{
|
||||
_calibrationList = new SensorCalibrationList();
|
||||
}
|
||||
_calibrationList._calibrations.Clear();
|
||||
}
|
||||
}
|
||||
catch (Exception) {/* APILogger.Log("Failed to delete sensor calibrations ", ex); */}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class SensorsCollection : INotifyPropertyChanged
|
||||
{
|
||||
private readonly SensorData[] _cachedSensors = new SensorData[0];
|
||||
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;
|
||||
}
|
||||
|
||||
private volatile bool _hookedup = true;
|
||||
|
||||
public bool HookedUp
|
||||
{
|
||||
get => _hookedup;
|
||||
set
|
||||
{
|
||||
_hookedup = value;
|
||||
OnPropertyChanged("AllSensors");
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
if (!HookedUp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private static readonly object Lock = new object();
|
||||
|
||||
public void Reload()
|
||||
{
|
||||
}
|
||||
|
||||
private static SensorsCollection _sensorCollection;
|
||||
|
||||
public static SensorsCollection SensorsList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (Lock)
|
||||
{
|
||||
return _sensorCollection ?? (_sensorCollection = new SensorsCollection());
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// deletes all sensors
|
||||
/// originally created so TDM imports could clear all tables except DAS tables.
|
||||
/// </summary>
|
||||
public void DeleteAll()
|
||||
{
|
||||
lock (Lock)
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SensorDeleteAll.ToString(); //Only used in DataPROPre20.mdf, not DataPRO.mdf
|
||||
|
||||
#region params
|
||||
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
//OnSensorsChanged?.Invoke(_sensorCollection.AllSensors.ToArray(), true);
|
||||
|
||||
SensorCalibrationList.DeleteAll();
|
||||
OnPropertyChanged("AllSensors");
|
||||
}
|
||||
}
|
||||
public SensorData GetSensorBySerialNumber(string serialNumber, bool excludeBroken = true, bool bUseCache = true)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(serialNumber))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (bUseCache)
|
||||
{
|
||||
var matches = from s in _cachedSensors where s.SerialNumber == serialNumber select s;
|
||||
if (matches.Any())
|
||||
{
|
||||
return matches.First();
|
||||
}
|
||||
}
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SensorsAnalogGet.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@sensorID", SqlDbType.Int) { Value = null });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@SerialNumber", SqlDbType.NVarChar) { Value = serialNumber });
|
||||
|
||||
#endregion
|
||||
|
||||
var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
var sd = new SensorData(reader);
|
||||
reader.Close();
|
||||
cmd.Connection.Dispose();
|
||||
return sd;
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to load Sensor: ", ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SensorsDigitalInGet.ToString();
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@SerialNumber", SqlDbType.NVarChar, 50) { Value = serialNumber });
|
||||
cmd.Parameters.Add(new SqlParameter("@Id", SqlDbType.NVarChar, 50) { Value = null });
|
||||
var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
var di = new DigitalInputSetting(reader);
|
||||
reader.Close();
|
||||
return di;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SensorsSquibGet.ToString();
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@SerialNumber", SqlDbType.NVarChar, 50) { Value = serialNumber });
|
||||
cmd.Parameters.Add(new SqlParameter("@Id", SqlDbType.NVarChar, 50) { Value = null });
|
||||
var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
var squib = new SquibSetting(reader);
|
||||
reader.Close();
|
||||
return squib;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SensorsDigitalOutGet.ToString();
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@SerialNumber", SqlDbType.NVarChar) { Value = serialNumber });
|
||||
|
||||
var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
var dout = new DigitalOutputSetting(reader);
|
||||
reader.Close();
|
||||
return dout;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
if (SensorData.IsTestSpecificDigitalOutSN(serialNumber))
|
||||
{
|
||||
return new DigitalOutputSetting { SerialNumber = serialNumber };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class CalibrationRecords : ICalibrationRecords
|
||||
{
|
||||
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[] { new CalibrationRecord() };
|
||||
}
|
||||
public CalibrationRecords(string records)
|
||||
{
|
||||
FromSerializedString(records);
|
||||
}
|
||||
public void FromSerializedString(string s)
|
||||
{
|
||||
var tokens = s.Split(new[] { 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 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;
|
||||
|
||||
public string EngineeringUnits { get; set; } = "g";
|
||||
|
||||
|
||||
public Test.Module.Channel.Sensor.SensUnits SensitivityUnits { get; set; } = Test.Module.Channel.Sensor.SensUnits.NONE;
|
||||
|
||||
public ExcitationVoltageOptions.ExcitationVoltageOption Excitation { get; set; } = ExcitationVoltageOptions.ExcitationVoltageOption.Volt5;
|
||||
|
||||
public double CapacityOutputIsBasedOn { get; set; } = 1.000;
|
||||
|
||||
// private InitialOffset.Forms _initialOffsetMethod = InitialOffset.Forms.EU;
|
||||
// public InitialOffset.Forms InitialOffsetMethod { get { return _initialOffsetMethod; } set { _initialOffsetMethod = value; } }
|
||||
|
||||
private enum Fields
|
||||
{
|
||||
Sensitivity,
|
||||
Poly,
|
||||
AtCapacity,
|
||||
EngineeringUnits,
|
||||
Excitation,
|
||||
CapacityOutputIsBasedOn,
|
||||
SensitivityUnits,
|
||||
ZeroPoint
|
||||
};
|
||||
public void FromString(string s)
|
||||
{
|
||||
var tokens = s.Split(new[] { 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 = (ExcitationVoltageOptions.ExcitationVoltageOption)Enum.Parse(typeof(ExcitationVoltageOptions.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.ToDouble(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,12 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public enum NonLinearStyles
|
||||
{
|
||||
IRTraccManual,
|
||||
IRTraccDiagnosticsZero,
|
||||
IRTraccZeroMMmV,
|
||||
IRTraccAverageOverTime,
|
||||
Polynomial,
|
||||
IRTraccCalFactor
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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 void DeleteFineLocations1()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFineLocations1Delete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to delete fine locations1, ", ex); */}
|
||||
}
|
||||
public static MMEFineLocations1[] GetFineLocations1()
|
||||
{
|
||||
var fineLocations1 = new List<MMEFineLocations1>();
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFineLocations1Get.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
fineLocations1.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.EXPIRED.ToString()])
|
||||
let fineLoc1 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFineLocations1Fields.FINE_LOC_1.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEFineLocations1Fields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFineLocations1Fields.LAST_CHANGE_TEXT.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.s_GUID.ToString()])
|
||||
let sortKey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.TEXT_L2.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.VERSION.ToString()])
|
||||
select new MMEFineLocations1(sGuid, fineLoc1, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortKey, lastChange,
|
||||
lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to parse fine locations1:", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve fine locations1, ", ex);*/ }
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFineLocations1GetCustom.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
fineLocations1.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.EXPIRED.ToString()])
|
||||
let fineLoc1 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFineLocations1Fields.FINE_LOC_1.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEFineLocations1Fields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFineLocations1Fields.LAST_CHANGE_TEXT.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.s_GUID.ToString()])
|
||||
let sortKey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.TEXT_L2.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMEFineLocations1Fields.VERSION.ToString()])
|
||||
select new MMEFineLocations1(sGuid, fineLoc1, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortKey, lastChange,
|
||||
lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to parse custom fine locations1:", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve custom fine locations1, ", ex);*/ }
|
||||
|
||||
return fineLocations1.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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 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)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public double Low { get; set; }
|
||||
|
||||
public double High { get; set; }
|
||||
|
||||
public LowHigh(double low, double high)
|
||||
{
|
||||
Low = low;
|
||||
High = high;
|
||||
}
|
||||
public LowHigh(string value)
|
||||
{
|
||||
var values = value.Split(',');
|
||||
if (values.Length < 2) { throw new InvalidDataException("invalid low-high: " + value); }
|
||||
Low = double.Parse(values[0], System.Globalization.CultureInfo.InvariantCulture);
|
||||
High = double.Parse(values[1], System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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>();
|
||||
SqlDataReader reader = null;
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEDirectionsGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
|
||||
reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
var version =
|
||||
Convert.ToInt32(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.VERSION.ToString()]);
|
||||
var text2 = Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.TEXT_L2.ToString()]);
|
||||
var text1 = Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.TEXT_L1.ToString()]);
|
||||
var sortKey =
|
||||
Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.SORTKEY.ToString()]);
|
||||
var sGuid = Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.s_GUID.ToString()]);
|
||||
var remarks =
|
||||
Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.REMARKS.ToString()]);
|
||||
var lastChangeText =
|
||||
Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE_TEXT.ToString()]);
|
||||
var lastChange =
|
||||
Convert.ToDateTime(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE.ToString()]);
|
||||
var history =
|
||||
Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.HISTORY.ToString()]);
|
||||
var expired =
|
||||
Convert.ToBoolean(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.EXPIRED.ToString()]);
|
||||
var direction =
|
||||
Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.DIRECTION.ToString()]);
|
||||
var date = Convert.ToDateTime(
|
||||
reader[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)
|
||||
{
|
||||
//APILogger.Log("failed to load direction", ex);
|
||||
}
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("failed to load sql portion of iso.mmedirections, ", ex);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEDirectionsGetCustom.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
|
||||
reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
var version =
|
||||
Convert.ToInt32(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.VERSION.ToString()]);
|
||||
var text2 = Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.TEXT_L2.ToString()]);
|
||||
var text1 = Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.TEXT_L1.ToString()]);
|
||||
var sortKey =
|
||||
Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.SORTKEY.ToString()]);
|
||||
var sGuid = Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.s_GUID.ToString()]);
|
||||
var remarks =
|
||||
Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.REMARKS.ToString()]);
|
||||
var lastChangeText =
|
||||
Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE_TEXT.ToString()]);
|
||||
var lastChange =
|
||||
Convert.ToDateTime(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE.ToString()]);
|
||||
var history =
|
||||
Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.HISTORY.ToString()]);
|
||||
var expired =
|
||||
Convert.ToBoolean(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.EXPIRED.ToString()]);
|
||||
var direction =
|
||||
Convert.ToString(
|
||||
reader[DbOperations.MMETables.MMEDirectionsFields.DIRECTION.ToString()]);
|
||||
var date = Convert.ToDateTime(
|
||||
reader[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.SQL);
|
||||
directions.Add(mmedirection);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("failed to load custom direction", ex);
|
||||
}
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("failed to load sql portion of custom mmedirections, ", ex);
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
reader?.Close();
|
||||
}
|
||||
return directions.ToArray();
|
||||
}
|
||||
public static void DeleteDirections()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEDirectionsDelete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to delete sql portion of iso.mmedirections, ", ex); */}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
|
||||
public enum RecordingModes
|
||||
{
|
||||
[Description("RecordingModes_CircularBuffer")]
|
||||
CircularBuffer,
|
||||
[Description("RecordingModes_Recorder")]
|
||||
Recorder,
|
||||
[Description("RecordingModes_HybridRecorder")]
|
||||
HybridRecorder
|
||||
}
|
||||
public enum IsoChannelSensorCompatibilityLevels
|
||||
{
|
||||
DontWarn,
|
||||
Warn,
|
||||
DontAllow
|
||||
}
|
||||
public enum TestTemplateTags
|
||||
{
|
||||
UploadData,
|
||||
UploadExportsOnly,
|
||||
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,
|
||||
RegionsOfInterest,
|
||||
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,
|
||||
SysBuiltTestObjectTypes,
|
||||
AddedGroupRemoved,
|
||||
CheckoutMode,
|
||||
QuitTestWithoutWarning,
|
||||
SuppressMissingSensorsWarning,
|
||||
ISFFile,
|
||||
TestObjectsAndAddedGroups,
|
||||
NotAllChannelsRealTime,
|
||||
NotAllChannelsViewer,
|
||||
GroupsStepValid
|
||||
}
|
||||
public enum StrictLevel
|
||||
{
|
||||
Strict,
|
||||
UpdateTable
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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="DatabaseImport.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="DatabaseImport.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<applicationSettings>
|
||||
<DatabaseImport.Properties.Settings>
|
||||
<setting name="DownloadFolder" serializeAs="String">
|
||||
<value>..\Data</value>
|
||||
</setting>
|
||||
<setting name="AllowAutoArm" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DBType" serializeAs="String">
|
||||
<value>1</value>
|
||||
</setting>
|
||||
<setting name="RequireXCrashCompatibilityForISOExports" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
</DatabaseImport.Properties.Settings>
|
||||
</applicationSettings>
|
||||
<userSettings>
|
||||
<DatabaseImport.Properties.Settings>
|
||||
<setting name="CalWarningPeriodDays" serializeAs="String">
|
||||
<value>7</value>
|
||||
</setting>
|
||||
</DatabaseImport.Properties.Settings>
|
||||
</userSettings>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
||||
@@ -0,0 +1,247 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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; set; }
|
||||
public string Type { get; private set; }
|
||||
public string Test_Object { get; private set; }
|
||||
public string Position { get; private set; }
|
||||
public string Trans_Main_Loc { get; private set; }
|
||||
public string Fine_Loc_1 { get; private set; }
|
||||
public string Fine_Loc_2 { get; private set; }
|
||||
public string Fine_Loc_3 { get; private set; }
|
||||
public string Physical_Dimension { get; private set; }
|
||||
public string Direction { get; private set; }
|
||||
public string Default_Filter_Class { get; private set; }
|
||||
public string Text_L1 { get; private set; }
|
||||
public void SetText1(string text1) { Text_L1 = text1; }
|
||||
public string Text_L2 { get; private set; }
|
||||
public long Version { get; }
|
||||
public DateTime Date { get; }
|
||||
public string Remarks { get; private set; }
|
||||
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 void DeletePossibleChannels()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPossibleChannelsDelete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) {/* APILogger.Log("failed to delete possible channels, ", ex);*/ }
|
||||
}
|
||||
public static MMEPossibleChannels[] GetPossibleChannels()
|
||||
{
|
||||
var possibleChannels = new List<MMEPossibleChannels>();
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPossibleChannelsGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@Id", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
possibleChannels.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let id = Convert.ToInt64(dr["ID"])
|
||||
let type = Convert.ToString(dr["TYPE"])
|
||||
let testobject = Convert.ToString(dr["TEST_OBJECT"])
|
||||
let position = Convert.ToString(dr["POSITION"])
|
||||
let mainloc = Convert.ToString(dr["TRANS_MAIN_LOC"])
|
||||
let fineloc1 = Convert.ToString(dr["FINE_LOC_1"])
|
||||
let fineloc2 = Convert.ToString(dr["FINE_LOC_2"])
|
||||
let fineloc3 = Convert.ToString(dr["FINE_LOC_3"])
|
||||
let dimension = Convert.ToString(dr["PHYSICAL_DIMENSION"])
|
||||
let direction = Convert.ToString(dr["DIRECTION"])
|
||||
let filter = Convert.ToString(dr["DEFAULT_FILTER_CLASS"])
|
||||
let textL1 = Convert.ToString(dr["TEXT_L1"])
|
||||
let textL2 = Convert.ToString(dr["TEXT_L2"])
|
||||
let version = Convert.ToInt32(dr["VERSION"])
|
||||
let date = Convert.ToDateTime(dr["DATE"])
|
||||
let remarks = Convert.ToString(dr["REMARKS"])
|
||||
let expired = Convert.ToBoolean(dr["EXPIRED"])
|
||||
let sortkey = Convert.ToString(dr["SORTKEY"])
|
||||
let pictureShortName = Convert.ToString(dr["PICTURE_SHORTNAME"])
|
||||
let lastChange = Convert.ToDateTime(dr["LAST_CHANGE"])
|
||||
let lastChangeText = Convert.ToString(dr["LAST_CHANGE_TEXT"])
|
||||
let history = Convert.ToString(dr["HISTORY"])
|
||||
let isoFlag = Convert.ToString(dr["ISOFlag"])
|
||||
select 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, Convert.ToInt16(isoFlag)));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to get possible channels, ", ex);*/}
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPossibleChannelsGetCustom.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@Id", SqlDbType.NVarChar) { Value = null });
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
possibleChannels.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let id = Convert.ToInt64(dr["ID"])
|
||||
let type = Convert.ToString(dr["TYPE"])
|
||||
let testobject = Convert.ToString(dr["TEST_OBJECT"])
|
||||
let position = Convert.ToString(dr["POSITION"])
|
||||
let mainloc = Convert.ToString(dr["TRANS_MAIN_LOC"])
|
||||
let fineloc1 = Convert.ToString(dr["FINE_LOC_1"])
|
||||
let fineloc2 = Convert.ToString(dr["FINE_LOC_2"])
|
||||
let fineloc3 = Convert.ToString(dr["FINE_LOC_3"])
|
||||
let dimension = Convert.ToString(dr["PHYSICAL_DIMENSION"])
|
||||
let direction = Convert.ToString(dr["DIRECTION"])
|
||||
let filter = Convert.ToString(dr["DEFAULT_FILTER_CLASS"])
|
||||
let textL1 = Convert.ToString(dr["TEXT_L1"])
|
||||
let textL2 = Convert.ToString(dr["TEXT_L2"])
|
||||
let version = Convert.ToInt32(dr["VERSION"])
|
||||
let date = Convert.ToDateTime(dr["DATE"])
|
||||
let remarks = Convert.ToString(dr["REMARKS"])
|
||||
let expired = Convert.ToBoolean(dr["EXPIRED"])
|
||||
let sortkey = Convert.ToString(dr["SORTKEY"])
|
||||
let pictureShortName = Convert.ToString(dr["PICTURE_SHORTNAME"])
|
||||
let lastChange = Convert.ToDateTime(dr["LAST_CHANGE"])
|
||||
let lastChangeText = Convert.ToString(dr["LAST_CHANGE_TEXT"])
|
||||
let history = Convert.ToString(dr["HISTORY"])
|
||||
let isoFlag = MMEChannelTypes.SQL
|
||||
select 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, Convert.ToInt16(isoFlag)));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to get possible custom channels, ", ex); */}
|
||||
return possibleChannels.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,588 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
using System.ComponentModel;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class Hardware : INotifyPropertyChanged, IISOHardware
|
||||
{
|
||||
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)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public enum ChannelType
|
||||
{
|
||||
Analog,
|
||||
IEPE,
|
||||
Squib,
|
||||
DigitalOutput
|
||||
}
|
||||
|
||||
public static DateTime INVALIDDATE => new DateTime(1970, 1, 1);
|
||||
private string _serialNumber = "";
|
||||
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _serialNumber;
|
||||
set => _serialNumber = value;
|
||||
}
|
||||
|
||||
private int _calInterval = 365;
|
||||
|
||||
public int CalInterval
|
||||
{
|
||||
get => _calInterval;
|
||||
set => _calInterval = value;
|
||||
}
|
||||
|
||||
private int _dasType;
|
||||
|
||||
public int DASType
|
||||
{
|
||||
get => _dasType;
|
||||
set => SetProperty(ref _dasType, value, "DASType");
|
||||
}
|
||||
|
||||
private int _maxModules;
|
||||
|
||||
public int MaxModules
|
||||
{
|
||||
get => _maxModules;
|
||||
set => SetProperty(ref _maxModules, value, "MaxModules");
|
||||
}
|
||||
|
||||
private long _maxMemory;
|
||||
|
||||
public long MaxMemory
|
||||
{
|
||||
get => _maxMemory;
|
||||
set => SetProperty(ref _maxMemory, value, "MaxMemory");
|
||||
}
|
||||
|
||||
private double _minSampleRate;
|
||||
|
||||
public double MinSampleRate
|
||||
{
|
||||
get => _minSampleRate;
|
||||
set => SetProperty(ref _minSampleRate, value, "MinSampleRate");
|
||||
}
|
||||
|
||||
private double _maxSampleRate = 1000000;
|
||||
|
||||
public double MaxSampleRate
|
||||
{
|
||||
get => _maxSampleRate;
|
||||
set => SetProperty(ref _maxSampleRate, value, "MaxSampleRate");
|
||||
}
|
||||
|
||||
private double _maxAAFRate = 200000;
|
||||
|
||||
public double MaxAAFRate
|
||||
{
|
||||
get => _maxAAFRate;
|
||||
set => SetProperty(ref _maxAAFRate, value, "MaxAAFRate");
|
||||
}
|
||||
|
||||
private string _firmwareVersion = "";
|
||||
|
||||
public string FirmwareVersion
|
||||
{
|
||||
get => _firmwareVersion;
|
||||
set => SetProperty(ref _firmwareVersion, value, "FirmwareVersion");
|
||||
}
|
||||
|
||||
private DateTime _calDate = INVALIDDATE;
|
||||
|
||||
public DateTime CalDate
|
||||
{
|
||||
get => _calDate < INVALIDDATE ? INVALIDDATE : _calDate;
|
||||
set => SetProperty(ref _calDate, value, "CalDate");
|
||||
}
|
||||
|
||||
private int _protocolVerison;
|
||||
|
||||
public int ProtocolVersion
|
||||
{
|
||||
get => _protocolVerison;
|
||||
set => SetProperty(ref _protocolVerison, value, "ProtocolVersion");
|
||||
}
|
||||
|
||||
private DateTime _lastModified = DateTime.Now;
|
||||
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => SetProperty(ref _lastModified, value, "LastModified");
|
||||
}
|
||||
|
||||
private string _lastModifiedBy = "";
|
||||
|
||||
public string LastModifiedBy
|
||||
{
|
||||
get => _lastModifiedBy;
|
||||
set => SetProperty(ref _lastModifiedBy, value, "LastModifiedBy");
|
||||
}
|
||||
|
||||
private int _version = 1;
|
||||
|
||||
public int Version
|
||||
{
|
||||
get => _version;
|
||||
set => SetProperty(ref _version, value, "Version");
|
||||
}
|
||||
|
||||
private bool _bLocalOnly;
|
||||
|
||||
public bool LocalOnly
|
||||
{
|
||||
get => _bLocalOnly;
|
||||
set => SetProperty(ref _bLocalOnly, value, "LocalOnly");
|
||||
}
|
||||
|
||||
private DateTime _lastUsed = INVALIDDATE;
|
||||
|
||||
public DateTime LastUsed
|
||||
{
|
||||
get => _lastUsed;
|
||||
set => SetProperty(ref _lastUsed, value, "LastUsed");
|
||||
}
|
||||
|
||||
private string _lastUsedBy = "";
|
||||
|
||||
public string LastUsedBy
|
||||
{
|
||||
get => _lastUsedBy;
|
||||
set => SetProperty(ref _lastUsedBy, value, "LastUsedBy");
|
||||
}
|
||||
|
||||
private string _ipAddress = "";
|
||||
|
||||
public string IPAddress
|
||||
{
|
||||
get => _ipAddress;
|
||||
set => SetProperty(ref _ipAddress, value, "IPAddress");
|
||||
}
|
||||
|
||||
private int _channels;
|
||||
|
||||
public int Channels
|
||||
{
|
||||
get => _channels;
|
||||
set => SetProperty(ref _channels, value, "Channels");
|
||||
}
|
||||
|
||||
private string _position = "";
|
||||
|
||||
public string Position
|
||||
{
|
||||
get => _position;
|
||||
set => SetProperty(ref _position, value, "Position");
|
||||
}
|
||||
|
||||
private bool _isProgrammable;
|
||||
|
||||
public bool IsProgrammable
|
||||
{
|
||||
get => _isProgrammable;
|
||||
set => SetProperty(ref _isProgrammable, value, "IsProgrammable");
|
||||
}
|
||||
|
||||
private bool _isModule;
|
||||
|
||||
public bool IsModule
|
||||
{
|
||||
get => _isModule;
|
||||
set => SetProperty(ref _isModule, value, "IsModule");
|
||||
}
|
||||
|
||||
private bool _isReconfigurable;
|
||||
|
||||
public bool IsReconfigurable
|
||||
{
|
||||
get => _isReconfigurable;
|
||||
set => SetProperty(ref _isReconfigurable, value, "IsReconfigurable");
|
||||
}
|
||||
|
||||
private int[] _channelTypes;
|
||||
|
||||
public int[] ChannelTypes
|
||||
{
|
||||
get => _channelTypes ?? (_channelTypes = new int[0]);
|
||||
set => SetProperty(ref _channelTypes, value, "ChannelTypes");
|
||||
}
|
||||
|
||||
public string ParentDAS { get; set; } = "";
|
||||
|
||||
public int Port { get; set; }
|
||||
public int PositionOnChain { get; set; }
|
||||
public int PositionOnDistributor { get; set; }
|
||||
|
||||
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;
|
||||
ISOChannels = copy.ISOChannels.Select(c => new ISO.HardwareChannel(c, this)).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;
|
||||
ParentDAS = copy.ParentDAS;
|
||||
PositionOnChain = copy.PositionOnChain;
|
||||
PositionOnDistributor = copy.PositionOnDistributor;
|
||||
Port = copy.Port;
|
||||
}
|
||||
|
||||
public Hardware(IDataRecord reader)
|
||||
{
|
||||
|
||||
CalDate = Convert.ToDateTime(reader[DbOperations.DAS.Fields.CalDate.ToString()]);
|
||||
Channels = Convert.ToInt32(reader[DbOperations.DAS.Fields.Channels.ToString()]);
|
||||
IPAddress = Convert.ToString(reader[DbOperations.DAS.Fields.Connection.ToString()]);
|
||||
FirmwareVersion = Convert.ToString(reader[DbOperations.DAS.Fields.FirmwareVersion.ToString()]);
|
||||
LastModified = Convert.ToDateTime(reader[DbOperations.DAS.Fields.LastModified.ToString()]);
|
||||
LastModifiedBy = Convert.ToString(reader[DbOperations.DAS.Fields.LastModifiedBy.ToString()]);
|
||||
LastUsed = Convert.ToDateTime(reader[DbOperations.DAS.Fields.LastUsed.ToString()]);
|
||||
LastUsedBy = Convert.ToString(reader[DbOperations.DAS.Fields.LastUsedBy.ToString()]);
|
||||
LocalOnly = Convert.ToBoolean(reader[DbOperations.DAS.Fields.LocalOnly.ToString()]);
|
||||
MaxMemory = Convert.ToInt64(reader[DbOperations.DAS.Fields.MaxMemory.ToString()]);
|
||||
MaxModules = Convert.ToInt32(reader[DbOperations.DAS.Fields.MaxModules.ToString()]);
|
||||
MaxSampleRate = Convert.ToDouble(reader[DbOperations.DAS.Fields.MaxSampleRate.ToString()]);
|
||||
MinSampleRate = Convert.ToDouble(reader[DbOperations.DAS.Fields.MinSampleRate.ToString()]);
|
||||
Position = Convert.ToString(reader[DbOperations.DAS.Fields.Position.ToString()]);
|
||||
IsReconfigurable = Convert.ToBoolean(reader[DbOperations.DAS.Fields.Reconfigurable.ToString()]);
|
||||
IsModule = Convert.ToBoolean(reader[DbOperations.DAS.Fields.IsModule.ToString()]);
|
||||
IsProgrammable = Convert.ToBoolean(reader[DbOperations.DAS.Fields.Reprogramable.ToString()]);
|
||||
ProtocolVersion = Convert.ToInt32(reader[DbOperations.DAS.Fields.ProtocolVersion.ToString()]);
|
||||
SerialNumber = Convert.ToString(reader[DbOperations.DAS.Fields.SerialNumber.ToString()]);
|
||||
DASType = Convert.ToInt32(reader[DbOperations.DAS.Fields.Type.ToString()]);
|
||||
|
||||
if (reader[DbOperations.DAS.Fields.ChannelTypes.ToString()] != null)
|
||||
{
|
||||
var tokens =
|
||||
(reader[DbOperations.DAS.Fields.ChannelTypes.ToString()] as string).Split(',');
|
||||
var itemp = 0;
|
||||
ChannelTypes = (from token in tokens where int.TryParse(token, out itemp) select itemp).ToArray();
|
||||
}
|
||||
Version = Convert.ToInt32(reader[DbOperations.DAS.Fields.Version.ToString()]);
|
||||
ParentDAS = Convert.ToString(reader[DbOperations.DAS.Fields.ParentDAS.ToString()]);
|
||||
|
||||
Port = reader[DbOperations.DAS.Fields.Port.ToString()] is DBNull
|
||||
? 0
|
||||
: Convert.ToInt32(reader[DbOperations.DAS.Fields.Port.ToString()]);
|
||||
|
||||
PositionOnChain = Convert.ToInt32(reader[DbOperations.DAS.Fields.PositionOnChain.ToString()]);
|
||||
PositionOnDistributor = Convert.ToInt32(reader[DbOperations.DAS.Fields.PositionOnDistributor.ToString()]);
|
||||
}
|
||||
|
||||
public static List<ISO.HardwareChannel> GetDASISOChannels(string hardwareId, Hardware das)
|
||||
{
|
||||
var channelList = new List<ISO.HardwareChannel>();
|
||||
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_DASChannelsGet.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@HardwareId", SqlDbType.NVarChar) { Value = hardwareId });
|
||||
|
||||
#endregion params
|
||||
|
||||
using (var readerISOChannels = cmd.ExecuteReader())
|
||||
{
|
||||
while (readerISOChannels.Read())
|
||||
{
|
||||
channelList.Add(new ISO.HardwareChannel(readerISOChannels, das));
|
||||
}
|
||||
readerISOChannels.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
channelList.Sort(ISO.HardwareChannel.PhysicalCompare);
|
||||
return channelList;
|
||||
}
|
||||
|
||||
private static void GetAllDASISOChannels(Dictionary<string, Hardware> serialNumberToHardware)
|
||||
{
|
||||
var channelsByDASKey = new Dictionary<string, List<ISO.HardwareChannel>>();
|
||||
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_DASChannelsGet.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@HardwareId", SqlDbType.NVarChar) { Value = null });
|
||||
|
||||
#endregion params
|
||||
|
||||
using (var readerISOChannels = cmd.ExecuteReader())
|
||||
{
|
||||
while (readerISOChannels.Read())
|
||||
{
|
||||
var serialNumber = Convert.ToString(readerISOChannels["HardwareId"]);
|
||||
if (!serialNumberToHardware.ContainsKey(serialNumber))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var hardware = serialNumberToHardware[serialNumber];
|
||||
var hc = new ISO.HardwareChannel(readerISOChannels, hardware);
|
||||
if (!channelsByDASKey.ContainsKey(serialNumber))
|
||||
{
|
||||
channelsByDASKey[serialNumber] = new List<ISO.HardwareChannel>();
|
||||
}
|
||||
channelsByDASKey[serialNumber].Add(hc);
|
||||
}
|
||||
readerISOChannels.Close();
|
||||
}
|
||||
using (var enumHardware = serialNumberToHardware.GetEnumerator())
|
||||
{
|
||||
while (enumHardware.MoveNext())
|
||||
{
|
||||
var hardware = enumHardware.Current.Value;
|
||||
if (!channelsByDASKey.ContainsKey(enumHardware.Current.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var list = channelsByDASKey[enumHardware.Current.Key];
|
||||
list.Sort(ISO.HardwareChannel.PhysicalCompare);
|
||||
hardware.ISOChannels = list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<ISO.HardwareChannel> _isoChannels = new List<ISO.HardwareChannel>();
|
||||
|
||||
public ISO.HardwareChannel[] ISOChannels
|
||||
{
|
||||
get => _isoChannels.ToArray();
|
||||
set => SetProperty(ref _isoChannels, new List<ISO.HardwareChannel>(value), "ISOChannels");
|
||||
}
|
||||
|
||||
public static Hardware[] GetSingleDAS(string serialNumber, string position)
|
||||
{
|
||||
var list = new List<Hardware>();
|
||||
try
|
||||
{
|
||||
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_DASGet.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@SerialNumber", SqlDbType.NVarChar) { Value = serialNumber });
|
||||
cmd.Parameters.Add(new SqlParameter("@position", SqlDbType.NVarChar)
|
||||
{
|
||||
Value = string.IsNullOrEmpty(position) ? null : position
|
||||
});
|
||||
|
||||
#endregion params
|
||||
|
||||
using (var readerDAS = cmd.ExecuteReader())
|
||||
{
|
||||
while (readerDAS.Read())
|
||||
{
|
||||
list.Add(new Hardware(readerDAS));
|
||||
}
|
||||
readerDAS.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
foreach (var das in list)
|
||||
{
|
||||
var channels = GetDASISOChannels(das.SerialNumber, das);
|
||||
channels.Sort(ISO.HardwareChannel.PhysicalCompare);
|
||||
das.ISOChannels = channels.ToArray();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
/*APILogger.Log("failed to retrieve all das, ", ex); */
|
||||
}
|
||||
list.Sort(new HardwareCompare());
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static Hardware[] GetAllDAS(string serialNumber, string position)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(serialNumber))
|
||||
{
|
||||
return GetSingleDAS(serialNumber, position);
|
||||
}
|
||||
var list = new List<Hardware>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_DASGet.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@SerialNumber", SqlDbType.NVarChar)
|
||||
{
|
||||
Value = string.IsNullOrEmpty(serialNumber) ? null : serialNumber
|
||||
});
|
||||
cmd.Parameters.Add(new SqlParameter("@position", SqlDbType.NVarChar)
|
||||
{
|
||||
Value = string.IsNullOrEmpty(position) ? null : position
|
||||
});
|
||||
|
||||
#endregion params
|
||||
|
||||
using (var readerDAS = cmd.ExecuteReader())
|
||||
{
|
||||
while (readerDAS.Read())
|
||||
{
|
||||
list.Add(new Hardware(readerDAS));
|
||||
}
|
||||
readerDAS.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
var serialNumberToDAS = new Dictionary<string, Hardware>();
|
||||
foreach (var das in list)
|
||||
{
|
||||
serialNumberToDAS[$"{das.SerialNumber}_{das.DASType}"] = das;
|
||||
}
|
||||
GetAllDASISOChannels(serialNumberToDAS);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
/*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 = string.Compare(x.SerialNumber, y.SerialNumber, StringComparison.Ordinal);
|
||||
if (0 == ret)
|
||||
{
|
||||
ret = string.Compare(x.IPAddress, y.IPAddress, StringComparison.Ordinal);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_DASDelete.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@SerialNumber", SqlDbType.NVarChar) { Value = SerialNumber });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetId()
|
||||
{
|
||||
return GetId(SerialNumber, DASType.ToString(), IPAddress);
|
||||
}
|
||||
|
||||
public static string GetId(string sn, string dastype, string ip)
|
||||
{
|
||||
return $"{sn}_{dastype}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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 : ITestSetup
|
||||
{
|
||||
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 string ErrorMessage { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// returns the error messages for a test setup
|
||||
/// calculated at the same time is complete is calculated, however doesn't have a check against
|
||||
/// is dirty, like IsComplete does ...
|
||||
/// </summary>
|
||||
public string CompletionErrorMessage => ErrorMessage.Length > 250 ? ErrorMessage.Substring(0, 250) : ErrorMessage;
|
||||
public double PostTriggerSeconds { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public string LastModifiedBy { get; set; }
|
||||
public bool IsComplete { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class LabratoryDetails //: BasePropertyChanged
|
||||
{
|
||||
private readonly ISO.LabratoryDetails _lab;
|
||||
public string Name
|
||||
{
|
||||
get => _lab.Name;
|
||||
set => _lab.Name = value;
|
||||
}
|
||||
}
|
||||
public class LabratoryDetailsList
|
||||
{
|
||||
public static void DeleteAll()
|
||||
{
|
||||
ISO.LabratoryDetails.DeleteLabratoryDetails();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class LinearizationFormula
|
||||
{
|
||||
private bool _bIsValid;
|
||||
// public bool IsValid() { return _bIsValid; }
|
||||
public void MarkValid(bool bValid)
|
||||
{
|
||||
_bIsValid = bValid;
|
||||
}
|
||||
public NonLinearStyles NonLinearStyle { get; set; } = NonLinearStyles.IRTraccDiagnosticsZero;
|
||||
|
||||
public double PolynomialSensitivity { get; set; } = 1D;
|
||||
|
||||
public double LinearizationExponent { get; set; } = 1D;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// THIS IS MM/V, (UI has already been updated, we need to update the variable name)
|
||||
/// </summary>
|
||||
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;
|
||||
NonLinearStyle = copy.NonLinearStyle;
|
||||
_coefficients = new List<double>(copy._coefficients);
|
||||
_exponents = new List<double>(copy._exponents);
|
||||
PolynomialSensitivity = copy.PolynomialSensitivity;
|
||||
ZeroPositionIntercept = copy.ZeroPositionIntercept;
|
||||
CalibrationFactor = copy.CalibrationFactor;
|
||||
}
|
||||
public bool UsemVOverVForPolys { get; set; } = true;
|
||||
private List<double> _coefficients = new List<double>();
|
||||
private List<double> _exponents = new List<double>();
|
||||
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 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 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 = (NonLinearStyles)Enum.Parse(typeof(NonLinearStyles), tokens[0], true);
|
||||
NonLinearStyle = style;
|
||||
switch (NonLinearStyle)
|
||||
{
|
||||
case NonLinearStyles.IRTraccDiagnosticsZero:
|
||||
FromIRTraccDiagnosticZeroString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case NonLinearStyles.IRTraccManual:
|
||||
FromIRTraccManualString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case NonLinearStyles.IRTraccZeroMMmV:
|
||||
FromIRTraccZeroMMmVString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case NonLinearStyles.Polynomial:
|
||||
FromPolynomialString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case NonLinearStyles.IRTraccAverageOverTime:
|
||||
FromIRTraccAverageOverTimeString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case NonLinearStyles.IRTraccCalFactor:
|
||||
FromIRTraccCalFactorString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("Unknown format: " + NonLinearStyle);
|
||||
}
|
||||
}
|
||||
public void FromSerializeString(string s)
|
||||
{
|
||||
FromSerializeString(s, System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport.ISO
|
||||
{
|
||||
[Serializable]
|
||||
public class CustomerDetails //: ISerializableFile
|
||||
{
|
||||
// #region properties
|
||||
public string CustomerName { get; set; } = string.Empty;
|
||||
public string CustomerTestRefNumber { get; set; } = string.Empty;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool LocalOnly { get; set; } = false;
|
||||
public string Name { get; set; } = "";
|
||||
public DateTime LastModified { get; set; }
|
||||
public string LastModifiedBy { get; set; }
|
||||
public int Version { get; set; } = 1;
|
||||
|
||||
// #endregion properties
|
||||
// #region constructor
|
||||
public CustomerDetails()
|
||||
{
|
||||
}
|
||||
|
||||
// public CustomerDetails(string name, bool localOnly) { Name = name; LocalOnly = localOnly; }
|
||||
|
||||
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;
|
||||
}
|
||||
// #endregion constructor
|
||||
private enum Fields
|
||||
{
|
||||
Name,
|
||||
CustomerName,
|
||||
CustomerTestRefNumber,
|
||||
ProjectRefNumber,
|
||||
CustomerOrderNumber,
|
||||
CustomerCostUnit,
|
||||
LocalOnly,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
Version
|
||||
}
|
||||
public static CustomerDetails ReadXML(System.Xml.XmlElement root)
|
||||
{
|
||||
var c = new CustomerDetails();
|
||||
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
if (node is System.Xml.XmlElement)
|
||||
{
|
||||
ProcessXMLElement(node as System.Xml.XmlElement, ref c);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
private static void ProcessXMLElement(System.Xml.XmlElement node, ref CustomerDetails c)
|
||||
{
|
||||
if (!Enum.TryParse(node.Name, out Fields field)) return;
|
||||
switch (field)
|
||||
{
|
||||
case Fields.CustomerCostUnit: c.CustomerCostUnit = node.InnerText; break;
|
||||
case Fields.CustomerName: c.CustomerName = node.InnerText; break;
|
||||
case Fields.CustomerOrderNumber: c.CustomerOrderNumber = node.InnerText; break;
|
||||
case Fields.CustomerTestRefNumber: c.CustomerTestRefNumber = node.InnerText; break;
|
||||
case Fields.LastModified: c.LastModified = DateTime.Parse(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case Fields.LastModifiedBy: c.LastModifiedBy = node.InnerText; break;
|
||||
case Fields.LocalOnly: c.LocalOnly = bool.Parse(node.InnerText); break;
|
||||
case Fields.Name: c.Name = node.InnerText; break;
|
||||
case Fields.ProjectRefNumber: c.ProjectRefNumber = node.InnerText; break;
|
||||
case Fields.Version: c.Version = int.Parse(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
default: throw new NotSupportedException("ISODll.CustomerDetails::ProcessXMLElement unsupported field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
public void WriteXML(ref System.Xml.XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("CustomerDetail");
|
||||
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
writer.WriteStartElement(field.ToString());
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case Fields.CustomerCostUnit: writer.WriteString(CustomerCostUnit); break;
|
||||
case Fields.CustomerName: writer.WriteString(CustomerName); break;
|
||||
case Fields.CustomerOrderNumber: writer.WriteString(CustomerOrderNumber); break;
|
||||
case Fields.CustomerTestRefNumber: writer.WriteString(CustomerTestRefNumber); break;
|
||||
case Fields.LastModified: writer.WriteString(LastModified.ToString(System.Globalization.CultureInfo.InvariantCulture)); break;
|
||||
case Fields.LastModifiedBy: writer.WriteString(LastModifiedBy); break;
|
||||
case Fields.LocalOnly: writer.WriteString(LocalOnly.ToString()); break;
|
||||
case Fields.Name: writer.WriteString(Name); break;
|
||||
case Fields.ProjectRefNumber: writer.WriteString(ProjectRefNumber); break;
|
||||
case Fields.Version: writer.WriteString(Version.ToString(System.Globalization.CultureInfo.InvariantCulture)); break;
|
||||
default: throw new NotSupportedException("CustomerDetails::WriteXML unsupported field " + field.ToString());
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
public static void DeleteCustomerDetails(string name = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DTS.Common.Storage.DbOperations.CustomerDetailsDelete(name, out string errorMessage);
|
||||
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
//APILogger.Log("Failed to delete customer details", errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to delete customer details", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,759 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class DbOperations
|
||||
{
|
||||
public abstract class Tags
|
||||
{
|
||||
public enum TagFields
|
||||
{
|
||||
TagId,
|
||||
TagText,
|
||||
Obsolete
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class DbVersions
|
||||
{
|
||||
public enum DbVersionFields
|
||||
{
|
||||
Version,
|
||||
Step,
|
||||
Date,
|
||||
Remarks,
|
||||
UserField
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Settings
|
||||
{
|
||||
public enum UserFields
|
||||
{
|
||||
PropertyId,
|
||||
PropertyType,
|
||||
PropertyValue,
|
||||
UserId
|
||||
}
|
||||
}
|
||||
public abstract class Users
|
||||
{
|
||||
public enum UserFields
|
||||
{
|
||||
ID,
|
||||
UserName,
|
||||
DisplayName,
|
||||
Password,
|
||||
Role,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
LocalOnly
|
||||
}
|
||||
public enum UIItemFields
|
||||
{
|
||||
ID,
|
||||
Name
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class SensorDB
|
||||
{
|
||||
public enum SensorDataFields
|
||||
{
|
||||
SerialNumber = 1,
|
||||
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,
|
||||
UserTags,
|
||||
DoNotUse,
|
||||
Broken,
|
||||
eId,
|
||||
DiagnosticsMode
|
||||
}
|
||||
public enum SensorModelFields
|
||||
{
|
||||
Model,
|
||||
Manufacturer,
|
||||
UserPartNumber,
|
||||
Capacity,
|
||||
OffsetToleranceLow,
|
||||
OffsetToleranceHigh,
|
||||
MeasurementUnit,
|
||||
Bridge,
|
||||
Shunt,
|
||||
BridgeResistance,
|
||||
FilterClass,
|
||||
UniPolar,
|
||||
IgnoreRange,
|
||||
CouplingMode,
|
||||
Version,
|
||||
RangeLow,
|
||||
RangeAve,
|
||||
RangeHigh,
|
||||
LastModified,
|
||||
ModifiedBy,
|
||||
LocalOnly,
|
||||
NumberOfAxes,
|
||||
CalInterval,
|
||||
AxisNumber,
|
||||
Polarity,
|
||||
Invert,
|
||||
CheckOffset,
|
||||
CalibrationRecord,
|
||||
ISOCode,
|
||||
SupportedExcitation
|
||||
}
|
||||
public enum SensorCalibrationFields
|
||||
{
|
||||
SerialNumber,
|
||||
CalibrationDate,
|
||||
Username,
|
||||
LocalOnly,
|
||||
NonLinear,
|
||||
CalibrationRecords,
|
||||
ModifyDate,
|
||||
IsProportional,
|
||||
RemoveOffset,
|
||||
ZeroMethod,
|
||||
CertificationDocuments,
|
||||
InitialOffset
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// current db version in this code base
|
||||
/// </summary>
|
||||
public const int CURRENT_DB_VERSION = 61;
|
||||
public class DbTypeAttr : Attribute
|
||||
{
|
||||
public string DbType { get; private set; }
|
||||
internal DbTypeAttr(string attr)
|
||||
{
|
||||
DbType = attr;
|
||||
}
|
||||
public static string GetDbType(object o)
|
||||
{
|
||||
if (o != null)
|
||||
{
|
||||
var mi = o.GetType().GetMember(o.ToString());
|
||||
if (mi != null && mi.Length > 0)
|
||||
{
|
||||
var attr = GetCustomAttribute(mi[0], typeof(DbTypeAttr)) as DbTypeAttr;
|
||||
if (null != attr)
|
||||
{
|
||||
return attr.DbType;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public abstract class CalculatedChannels
|
||||
{
|
||||
public const string Table = "tblCalculatedChannels";
|
||||
public enum Fields
|
||||
{
|
||||
[DbTypeAttr("INTEGER PRIMARY KEY NOT NULL")]
|
||||
Id,
|
||||
[DbTypeAttr("INTEGER")]
|
||||
Operation,
|
||||
[DbTypeAttr("NVARCHAR(255)")]
|
||||
CalculatedChannelValueCode,
|
||||
[DbTypeAttr("BLOB")]
|
||||
InputChannelIds,
|
||||
[DbTypeAttr("NVARCHAR(255)")]
|
||||
CFCForInputChannels,
|
||||
[DbTypeAttr("NVARCHAR(255)")]
|
||||
CFCForOutput,
|
||||
[DbTypeAttr("NVARCHAR(255)")]
|
||||
TestSetupName,
|
||||
[DbTypeAttr("NVARCHAR(255)")]
|
||||
CCName
|
||||
}
|
||||
}
|
||||
public abstract class LevelTriggers
|
||||
{
|
||||
//public const string Table = "tblLevelTriggers";
|
||||
public enum Fields
|
||||
{
|
||||
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
|
||||
TestSetupName,
|
||||
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
|
||||
GroupSerialNumber,
|
||||
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
|
||||
TestObjectChannelId,
|
||||
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
|
||||
HardwareChannelId,
|
||||
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
|
||||
SensorSerialNumber,
|
||||
[DbTypeAttr("BIT NOT NULL")]
|
||||
GreaterThanEnabled,
|
||||
[DbTypeAttr("FLOAT NOT NULL")]
|
||||
GreaterThanEU,
|
||||
[DbTypeAttr("BIT NOT NULL")]
|
||||
LessThanEnabled,
|
||||
[DbTypeAttr("FLOAT NOT NULL")]
|
||||
LessThanEU,
|
||||
[DbTypeAttr("FLOAT NULL")]
|
||||
InsideUpperEU,
|
||||
[DbTypeAttr("FLOAT NULL")]
|
||||
InsideLowerEU,
|
||||
[DbTypeAttr("FLOAT NULL")]
|
||||
OutsideUpperEU,
|
||||
[DbTypeAttr("FLOAT NULL")]
|
||||
OutsideLowerEU,
|
||||
[DbTypeAttr("BIT NULL")]
|
||||
TriggerInside,
|
||||
[DbTypeAttr("BIT NULL")]
|
||||
TriggerOutside,
|
||||
[DbTypeAttr("NVARCHAR(255) NOT NULL")]
|
||||
TestObjectName
|
||||
};
|
||||
}
|
||||
public abstract class TestSetups
|
||||
{
|
||||
public enum HardwareFields
|
||||
{
|
||||
TestSetupName,
|
||||
HardwareId,
|
||||
AddOrRemove //0=remove,1=add
|
||||
}
|
||||
public enum ChannelSettingFields
|
||||
{
|
||||
TestName,
|
||||
TestObjectName,
|
||||
ChannelId,
|
||||
Setting,
|
||||
SensorSerial,
|
||||
Disabled
|
||||
}
|
||||
// public const string TestSetupsTable = "tblTestSetups";
|
||||
public enum Fields
|
||||
{
|
||||
SetupName,
|
||||
SetupDescription,
|
||||
AutomaticTestProgression,
|
||||
AutomaticProgressionDelayMS,
|
||||
InvertTrigger,
|
||||
InvertStart,
|
||||
ViewDiagnostics,
|
||||
VerifyChannels,
|
||||
AutoVerifyChannels,
|
||||
VerifyChannelsDelayMS,
|
||||
RecordingMode,
|
||||
SamplesPerSecond,
|
||||
PreTriggerSeconds,
|
||||
PostTriggerSeconds,
|
||||
StrictDiagnostics,
|
||||
RequireConfirmationOnErrors,
|
||||
ROIDownload,
|
||||
ViewROIDownload,
|
||||
DownloadAll,
|
||||
ViewRealtime,
|
||||
RealtimePlotCount,
|
||||
RegionsOfInterest,
|
||||
ROIStart,
|
||||
ROIEnd,
|
||||
ViewDownloadAll,
|
||||
Export,
|
||||
ExportFormat,
|
||||
LabDetails,
|
||||
UseLabDetails,
|
||||
CustomerDetails,
|
||||
UseCustomerDetails,
|
||||
AllowMissingSensors,
|
||||
AllowSensorIdToBlankChannel,
|
||||
LocalOnly,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
TurnOffExcitation,
|
||||
TriggerCheckRealtime,
|
||||
TriggerCheckStep,
|
||||
PostTestDiagnostics,
|
||||
ExportFolder,
|
||||
DownloadFolder,
|
||||
CommonStatusLine,
|
||||
SameAsDownloadFolder,
|
||||
UploadData,
|
||||
UploadDataFolder,
|
||||
UploadExportsOnly,
|
||||
Settings,
|
||||
WarnOnBatteryFail,
|
||||
Dirty,
|
||||
Complete,
|
||||
ErrorMessage,
|
||||
TestEngineerDetails,
|
||||
UseTestEngineerDetails,
|
||||
UserTags,
|
||||
DoAutoArm,
|
||||
CheckoutMode,
|
||||
QuitTestWithoutWarning,
|
||||
SuppressMissingSensorsWarning,
|
||||
ISFFile,
|
||||
NotAllChannelsRealTime,
|
||||
NotAllChannelsViewer
|
||||
}
|
||||
public enum TestSetupObjectFields
|
||||
{
|
||||
TestObjectSerialNumber,
|
||||
TestObjectName, //TestObjectSerialNumber was changed to TestObjectName in a later version
|
||||
TestSetupName,
|
||||
TargetSampleRate,
|
||||
ExcitationWarmupTimeMS,
|
||||
LocalOnly,
|
||||
TestObjectType,
|
||||
TestObjectPosition
|
||||
}
|
||||
public enum TestObjectMetaDataFields
|
||||
{
|
||||
TestObject,
|
||||
ISOTestObject,
|
||||
SetupName,
|
||||
TestSetupName,
|
||||
PropName,
|
||||
PropValue,
|
||||
Optional,
|
||||
Version,
|
||||
}
|
||||
public enum GraphFields
|
||||
{
|
||||
GraphName,
|
||||
GraphDescription,
|
||||
TemplateName,
|
||||
Channels,
|
||||
UseDomainMin,
|
||||
DomainMin,
|
||||
UseDomainMax,
|
||||
DomainMax,
|
||||
UseRangeMin,
|
||||
RangeMin,
|
||||
UseRangeMax,
|
||||
RangeMax,
|
||||
Thresholds,
|
||||
LocalOnly,
|
||||
TestSetupName
|
||||
}
|
||||
}
|
||||
public abstract class TestObjectChannelSettings
|
||||
{
|
||||
public enum Fields
|
||||
{
|
||||
TestObjectSerial,
|
||||
ChannelId,
|
||||
Setting,
|
||||
SensorSerial,
|
||||
SerialNumber
|
||||
}
|
||||
}
|
||||
public abstract class DigitalOutputSettings
|
||||
{
|
||||
public enum Fields
|
||||
{
|
||||
ChannelDescription,
|
||||
DelayMS,
|
||||
DurationMS,
|
||||
OutputMode,
|
||||
LimitDuration,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
Version,
|
||||
LocalOnly,
|
||||
DurationMSFloat,
|
||||
UserTags,
|
||||
Broken, //new in 2.0
|
||||
DoNotUse //new in 2.0
|
||||
}
|
||||
}
|
||||
public abstract class Squib
|
||||
{
|
||||
public enum Fields
|
||||
{
|
||||
SerialNumber,
|
||||
SquibDescription,
|
||||
BypassCurrentFilter,
|
||||
BypassVoltageFilter,
|
||||
DelayMS,
|
||||
DurationMS,
|
||||
FireMode,
|
||||
ISOCode,
|
||||
MeasurementType,
|
||||
SquibOutputCurrent,
|
||||
SquibToleranceLow,
|
||||
SquibToleranceHigh,
|
||||
LimitDuration,
|
||||
ArticleId,
|
||||
LocalOnly,
|
||||
Version,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
UserValue1,
|
||||
UserValue2,
|
||||
UserValue3,
|
||||
UserTags,
|
||||
Broken, //new in 2.0
|
||||
DoNotUse //new in 2.0
|
||||
}
|
||||
}
|
||||
public class MMETables
|
||||
{
|
||||
public enum MMEDirectionsFields
|
||||
{
|
||||
s_GUID,
|
||||
DIRECTION,
|
||||
TEXT_L1,
|
||||
TEXT_L2,
|
||||
DATE,
|
||||
VERSION,
|
||||
EXPIRED,
|
||||
REMARKS,
|
||||
LAST_CHANGE,
|
||||
LAST_CHANGE_TEXT,
|
||||
HISTORY,
|
||||
SORTKEY
|
||||
}
|
||||
public enum MMEFilterClassesFields
|
||||
{
|
||||
s_GUID,
|
||||
FILTER_CLASS,
|
||||
TEXT_L1,
|
||||
TEXT_L2,
|
||||
VERSION,
|
||||
DATE,
|
||||
REMARKS,
|
||||
EXPIRED,
|
||||
SORTKEY,
|
||||
LAST_CHANGE,
|
||||
LAST_CHANGE_TEXT,
|
||||
HISTORY
|
||||
}
|
||||
public enum MMEFineLocations1Fields
|
||||
{
|
||||
s_GUID,
|
||||
FINE_LOC_1,
|
||||
TEXT_L1,
|
||||
TEXT_L2,
|
||||
VERSION,
|
||||
DATE,
|
||||
REMARKS,
|
||||
EXPIRED,
|
||||
SORTKEY,
|
||||
LAST_CHANGE,
|
||||
LAST_CHANGE_TEXT,
|
||||
HISTORY
|
||||
}
|
||||
public enum MMEFineLocations2Fields
|
||||
{
|
||||
s_GUID,
|
||||
FINE_LOC_2,
|
||||
TEXT_L1,
|
||||
TEXT_L2,
|
||||
VERSION,
|
||||
DATE,
|
||||
REMARKS,
|
||||
EXPIRED,
|
||||
SORTKEY,
|
||||
LAST_CHANGE,
|
||||
LAST_CHANGE_TEXT,
|
||||
HISTORY
|
||||
}
|
||||
public enum MMEFineLocations3Fields
|
||||
{
|
||||
s_GUID,
|
||||
FINE_LOC_3,
|
||||
TEXT_L1,
|
||||
TEXT_L2,
|
||||
VERSION,
|
||||
DATE,
|
||||
REMARKS,
|
||||
EXPIRED,
|
||||
SORTKEY,
|
||||
PICTURE_SHORTNAME,
|
||||
LAST_CHANGE,
|
||||
LAST_CHANGE_TEXT,
|
||||
HISTORY
|
||||
}
|
||||
public enum MMEPhysicalDimensionFields
|
||||
{
|
||||
s_GUID,
|
||||
PHYSICAL_DIMENSION,
|
||||
TEXT_L1,
|
||||
TEXT_L2,
|
||||
DEFAULT_UNIT,
|
||||
LENGTH_EXP,
|
||||
TIME_EXP,
|
||||
MASS_EXP,
|
||||
ELECTRIC_CURRENT_EXP,
|
||||
TEMPERATURE_EXP,
|
||||
LUMINOUS_INTENSITY_EXP,
|
||||
AMOUNT_OFSUBSTANCE_EXP,
|
||||
VERSION,
|
||||
DATE,
|
||||
REMARKS,
|
||||
EXPIRED,
|
||||
SORTKEY,
|
||||
LAST_CHANGE,
|
||||
LAST_CHANGE_TEXT,
|
||||
HISTORY
|
||||
}
|
||||
public enum MMEPositionsFields
|
||||
{
|
||||
s_GUID,
|
||||
POSITION,
|
||||
TEXT_L1,
|
||||
TEXT_L2,
|
||||
VERSION,
|
||||
DATE,
|
||||
REMARKS,
|
||||
EXPIRED,
|
||||
SORTKEY,
|
||||
LAST_CHANGE,
|
||||
LAST_CHANGE_TEXT,
|
||||
HISTORY
|
||||
}
|
||||
public enum MMETestObjectsFields
|
||||
{
|
||||
s_GUID,
|
||||
TEST_OBJECT,
|
||||
TEXT_L1,
|
||||
TEXT_L2,
|
||||
VERSION,
|
||||
DATE,
|
||||
REMARKS,
|
||||
EXPIRED,
|
||||
SORTKEY,
|
||||
LAST_CHANGE,
|
||||
LAST_CHANGE_TEXT,
|
||||
HISTORY
|
||||
}
|
||||
public enum MMEMainLocationsFields
|
||||
{
|
||||
s_GUID,
|
||||
TYPE,
|
||||
TRANS_MAIN_LOC,
|
||||
TEXT_L1,
|
||||
TEXT_L2,
|
||||
VERSION,
|
||||
DATE,
|
||||
REMARKS,
|
||||
EXPIRED,
|
||||
SORTKEY,
|
||||
PICTURE_SHORTNAME,
|
||||
LAST_CHANGE,
|
||||
LAST_CHANGE_TEXT,
|
||||
HISTORY
|
||||
}
|
||||
}
|
||||
public static bool _usingCentralizedDB = true; //True means using a remote, centralized server; False means using a local SqlLocalDb
|
||||
public static bool _usingMSSQL = true;
|
||||
public static bool _usingNTLMAuthentication = false;
|
||||
public static string _previousDir = string.Empty;
|
||||
public class DAS
|
||||
{
|
||||
public enum Fields
|
||||
{
|
||||
SerialNumber,
|
||||
Type,
|
||||
MaxModules,
|
||||
MaxMemory,
|
||||
MaxSampleRate,
|
||||
MinSampleRate,
|
||||
FirmwareVersion,
|
||||
CalDate,
|
||||
ProtocolVersion,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
Version,
|
||||
LocalOnly,
|
||||
LastUsed,
|
||||
LastUsedBy,
|
||||
Connection,
|
||||
Channels,
|
||||
Position,
|
||||
ChannelTypes,
|
||||
Reprogramable,
|
||||
Reconfigurable,
|
||||
IsModule,
|
||||
PositionOnDistributor,
|
||||
PositionOnChain,
|
||||
Port,
|
||||
ParentDAS,
|
||||
MaxAAFRate
|
||||
}
|
||||
public enum DASChannelFields
|
||||
{
|
||||
HardwareId,
|
||||
ChannelIdx,
|
||||
SupportedBridges,
|
||||
SupportedExcitations,
|
||||
DASDisplayOrder,
|
||||
LocalOnly,
|
||||
SupportedDigitalInputModes,
|
||||
SupportedSquibFireModes,
|
||||
SupportedDigitalOutputModes,
|
||||
ModuleSerialNumber,
|
||||
ModuleArrayIndex
|
||||
}
|
||||
}
|
||||
private static System.Data.SqlClient.SqlCommand _cmd = null;
|
||||
public static System.Data.SqlClient.SqlCommand cmd
|
||||
{
|
||||
get => _cmd;
|
||||
set => _cmd = value;
|
||||
}
|
||||
|
||||
public static System.Data.SqlClient.SqlCommand GetSQLCommand()
|
||||
{
|
||||
return GetSQLCommand(false);
|
||||
}
|
||||
|
||||
public static bool IsServerConnected()
|
||||
{
|
||||
|
||||
using (var connection = new SqlConnection(Connection.GetLocalConnectionString()))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
return true;
|
||||
}
|
||||
catch (SqlException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static System.Data.SqlClient.SqlCommand GetSQLCommand(bool newCommand)
|
||||
{
|
||||
if (_cmd == null) { _cmd = new System.Data.SqlClient.SqlCommand(); }
|
||||
var currentCmd = _cmd;
|
||||
if (newCommand) { currentCmd = new System.Data.SqlClient.SqlCommand(); }
|
||||
|
||||
if (currentCmd.Connection == null || currentCmd.Connection.State != ConnectionState.Open)
|
||||
{
|
||||
currentCmd.Connection = new System.Data.SqlClient.SqlConnection(Connection.GetLocalConnectionString());
|
||||
currentCmd.Connection.Open();
|
||||
}
|
||||
|
||||
currentCmd.Parameters.Clear();
|
||||
return currentCmd;
|
||||
}
|
||||
private string _localConnection = null;
|
||||
public string GetLocalConnectionString()
|
||||
{
|
||||
lock (dbLock)
|
||||
{
|
||||
if (null != _localConnection) return _localConnection;
|
||||
if (null == Server /*&& !_bCS3*/) { throw new Exception("db connection not initialized"); }
|
||||
//if (_bCS3)
|
||||
//{
|
||||
// _localConnection = _bCS3UsingNTLMAuthentication ? string.Format("Server={0};Database={1};Trusted_Connection=TRUE;", _csHost, _cs3Name) : string.Format("Server={0};Database={1};User Id={2};Password={3}", _csHost, _cs3Name, _csUser, _cs3Password);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
_localConnection = _usingNTLMAuthentication ?
|
||||
string.Format("Server={0};Database={1};Trusted_Connection=TRUE;", Server, DBName) :
|
||||
string.Format("Server={0};Database={1};User Id={2};Password={3};", Server, DBName, Username, Password);
|
||||
//}
|
||||
}
|
||||
return _localConnection;
|
||||
}
|
||||
public string Server { get; set; } = null;
|
||||
public string Username { get; set; } = null;
|
||||
public string Password { get; set; } = null;
|
||||
public string DBName { get; set; } = null;
|
||||
private static DbOperations _dbOperations = null;
|
||||
private static readonly object dbLock = new object();
|
||||
public static DbOperations Connection
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (dbLock)
|
||||
{
|
||||
if (null == _dbOperations) { _dbOperations = new DbOperations(); }
|
||||
}
|
||||
return _dbOperations;
|
||||
}
|
||||
}
|
||||
public DataSet QueryDataSet(System.Data.SqlClient.SqlCommand icmd)
|
||||
{
|
||||
//try { Log(icmd); }
|
||||
//catch (Exception ex) { APILogger.Log(ex); }
|
||||
|
||||
if (cmd == null) return null;
|
||||
using (var adapter = new System.Data.SqlClient.SqlDataAdapter(icmd))
|
||||
{
|
||||
var ds = new DataSet();
|
||||
try
|
||||
{
|
||||
adapter.Fill(ds);
|
||||
return ds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Log(icmd, true);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
public class DigitalInputSettings
|
||||
{
|
||||
public enum Fields
|
||||
{
|
||||
SettingName,
|
||||
SettingMode,
|
||||
ScaleMultiplier,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
SensorId,
|
||||
UserValue1,
|
||||
UserValue2,
|
||||
UserValue3,
|
||||
UserTags,
|
||||
eId,
|
||||
Broken, //new in 2.0
|
||||
DoNotUse //new in 2.0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public interface ISensorData
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public interface ICalibrationRecords
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public interface ITestSetup
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
|
||||
public enum DigitalOutputModes
|
||||
{
|
||||
[DescriptionAttribute("Off")]
|
||||
NONE = 0, //digital channel's mode not set
|
||||
[DescriptionAttribute("Five volt low to high")]
|
||||
FVLH = 1 << 0, //set for 5 volt, low-to-high transition
|
||||
[DescriptionAttribute("Five volt high to low")]
|
||||
FVHL = 1 << 1, //set for 5 volt, high-to-low transition
|
||||
[DescriptionAttribute("Contact closure normally open")]
|
||||
CCNO = 1 << 2, //set to contact closure normally open
|
||||
[DescriptionAttribute("Contact closure normally closed")]
|
||||
CCNC = 1 << 3 //set to contact closure normally closed
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
protected long DbTimeStamp;
|
||||
public long GetTimeStampMemory()
|
||||
{
|
||||
return DbTimeStamp;
|
||||
}
|
||||
public void SetTimeStampMemory(long value) { DbTimeStamp = value; }
|
||||
public void SetTimeStampMemory(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 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 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* DiskUtility.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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,6 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public interface ISensorCalibration
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class DASHardwareList //: BasePropertyChanged
|
||||
{
|
||||
private static DASHardwareList _list;
|
||||
|
||||
public static DASHardwareList GetList()
|
||||
{
|
||||
if (null != _list) return _list;
|
||||
_list = new DASHardwareList();
|
||||
//_list.PopulateHardware();
|
||||
|
||||
return _list;
|
||||
}
|
||||
|
||||
public void ReloadAll()
|
||||
{
|
||||
//_list = new DASHardwareList();
|
||||
//_list.PopulateHardware();
|
||||
}
|
||||
private ICachedContainer _cachedHardware = null;
|
||||
|
||||
public DASHardware GetHardware(string id, bool bUseCache = true)
|
||||
{
|
||||
return GetHardware(id, true, out var bNotUsed, bUseCache);
|
||||
}
|
||||
|
||||
public DASHardware GetHardware(string id, bool bThrowExceptionIfChanged, out bool changed, bool bUseCache = true)
|
||||
{
|
||||
if (null != _cachedHardware && bUseCache)
|
||||
{
|
||||
var tokens = id.Split('_');
|
||||
var h = _cachedHardware.GetCachedHardware(tokens[0]);
|
||||
if (null != h)
|
||||
{
|
||||
changed = false;
|
||||
return h;
|
||||
}
|
||||
}
|
||||
var hardware = Hardware.GetAllDAS(id, null);
|
||||
changed = false;
|
||||
if (null != hardware && hardware.Any())
|
||||
{
|
||||
return new DASHardware(hardware[0]);
|
||||
}
|
||||
return null;
|
||||
/*if (_hardware.ContainsKey(id))
|
||||
{
|
||||
return _hardware[id];
|
||||
}
|
||||
var matchingSerial = from h in _hardware where h.Value.SerialNumber == id select h.Value;
|
||||
var dasHardwares = matchingSerial as DASHardware[] ?? matchingSerial.ToArray();
|
||||
if (dasHardwares.Any())
|
||||
{
|
||||
return dasHardwares.First();
|
||||
}
|
||||
//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.Any())
|
||||
{
|
||||
if (bThrowExceptionIfChanged)
|
||||
{
|
||||
throw new HardwareTypeChangedException();
|
||||
}
|
||||
changed = true;
|
||||
}return null;*/
|
||||
|
||||
}
|
||||
|
||||
public class HardwareTypeChangedException : Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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 void DeleteFigures()
|
||||
{
|
||||
return;//nothing to do
|
||||
}
|
||||
public static MMEFigures[] GetFigures()
|
||||
{
|
||||
var figures = new List<MMEFigures>();
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFiguresGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@Id", SqlDbType.NVarChar) { Value = null });
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
var id = Convert.ToInt64(reader["ID"]);
|
||||
var txtShortName = reader["txtShortName"].ToString();
|
||||
var txtDescription = reader["txtDescription"].ToString();
|
||||
var txtRemarks = reader["txtRemarks"].ToString();
|
||||
var datRevision = DateTime.MinValue;
|
||||
if (!DBNull.Value.Equals(reader["datRevision"]))
|
||||
{
|
||||
datRevision = (DateTime)reader["datRevision"];
|
||||
}
|
||||
var intAuthor = Convert.ToInt64(reader["intAuthor"]);
|
||||
var intPage = Convert.ToUInt16(reader["intPage"]);
|
||||
var intPages = Convert.ToUInt16(reader["intPages"]);
|
||||
var txtImageFile = reader["txtImageFile"].ToString();
|
||||
var version = Convert.ToInt64(reader["intVersion"]);
|
||||
var bExpired = (bool)reader["bolExpired"];
|
||||
var txtSortKey = reader["txtSortKey"].ToString();
|
||||
var bitStdPath = (bool)reader["bitStdPath"];
|
||||
var intIDStdPath = Convert.ToInt64(reader["IntIDStdPath"]);
|
||||
var txtPath = reader["txtPath"].ToString();
|
||||
var lastChange = DBNull.Value != reader["LAST_CHANGE"]
|
||||
? DateTime.MinValue
|
||||
: (DateTime)reader["LAST_CHANGE"];
|
||||
var lastChangeText = reader["LAST_CHANGE_TEXT"].ToString();
|
||||
var history = reader["HISTORY"].ToString();
|
||||
figures.Add(new MMEFigures(id, txtShortName, txtDescription, txtRemarks,
|
||||
datRevision, intAuthor, intPage,
|
||||
intPages, txtImageFile, version, bExpired, txtSortKey, bitStdPath, intIDStdPath,
|
||||
txtPath, lastChange, lastChangeText, history));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Problem loading figures - ", ex);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFiguresGetCustom.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@Id", SqlDbType.NVarChar) { Value = null });
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
var id = Convert.ToInt64(reader["ID"]);
|
||||
var txtShortName = reader["txtShortName"].ToString();
|
||||
var txtDescription = reader["txtDescription"].ToString();
|
||||
var txtRemarks = reader["txtRemarks"].ToString();
|
||||
var datRevision = DateTime.MinValue;
|
||||
if (!DBNull.Value.Equals(reader["datRevision"]))
|
||||
{
|
||||
datRevision = (DateTime)reader["datRevision"];
|
||||
}
|
||||
var intAuthor = Convert.ToInt64(reader["intAuthor"]);
|
||||
var intPage = Convert.ToUInt16(reader["intPage"]);
|
||||
var intPages = Convert.ToUInt16(reader["intPages"]);
|
||||
var txtImageFile = reader["txtImageFile"].ToString();
|
||||
var version = Convert.ToInt64(reader["intVersion"]);
|
||||
var bExpired = (bool)reader["bolExpired"];
|
||||
var txtSortKey = reader["txtSortKey"].ToString();
|
||||
var bitStdPath = (bool)reader["bitStdPath"];
|
||||
var intIDStdPath = Convert.ToInt64(reader["IntIDStdPath"]);
|
||||
var txtPath = reader["txtPath"].ToString();
|
||||
var lastChange = DBNull.Value != reader["LAST_CHANGE"]
|
||||
? DateTime.MinValue
|
||||
: (DateTime)reader["LAST_CHANGE"];
|
||||
var lastChangeText = reader["LAST_CHANGE_TEXT"].ToString();
|
||||
var history = reader["HISTORY"].ToString();
|
||||
figures.Add(new MMEFigures(id, txtShortName, txtDescription, txtRemarks, datRevision,
|
||||
intAuthor, intPage,
|
||||
intPages, txtImageFile, version, bExpired, txtSortKey, bitStdPath, intIDStdPath,
|
||||
txtPath, lastChange, lastChangeText, history));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Problem loading custom figures - ", ex);
|
||||
}
|
||||
|
||||
return figures.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
Test.Module.Channel.Sensor.Bridge.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
// *** 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 DTS.Common.DAS.Concepts.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,
|
||||
/// <summary>
|
||||
/// digital input setup
|
||||
/// </summary>
|
||||
[Description("DigitalInput")]
|
||||
DigitalInput = 1 << 4,
|
||||
/// <summary>
|
||||
/// squib output setup
|
||||
/// </summary>
|
||||
[Description("SQUIB")]
|
||||
SQUIB = 1 << 5,
|
||||
/// <summary>
|
||||
/// digital output setup
|
||||
/// </summary>
|
||||
[Description("TOMDigital")]
|
||||
TOMDigital = 1 << 6,
|
||||
/// <summary>
|
||||
/// sensor uses a G5 (signal plus) half bridge setup
|
||||
/// </summary>
|
||||
[Description("Bridge-Half SigPlus")]
|
||||
HalfBridge_SigPlus = 1 << 7
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//using DTS.Common.Interface.Hardware;
|
||||
//using DTS.SensorDB;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public interface ICachedContainer
|
||||
{
|
||||
DASHardware GetCachedHardware(string serialNumber);
|
||||
IISOHardware[] GetAllCachedHardware();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TestTemplateList //: BasePropertyChanged
|
||||
{
|
||||
/// <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; }
|
||||
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], System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Delay:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.DelayMS = double.Parse(subtokens[1], System.Globalization.CultureInfo.InvariantCulture); sd.DigitalOutputDelayMS = sd.DelayMS; }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Duration:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.DurationMS = double.Parse(subtokens[1], System.Globalization.CultureInfo.InvariantCulture); sd.DigitalOutputDurationMS = sd.DurationMS; }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.OutputMode:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.DigitalOutputMode = (DigitalOutputModes)Convert.ToInt32(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.SQMode:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.SquibFireMode = (SquibFireMode)Convert.ToInt32(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DIMode:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.InputMode = (DigitalInputModes)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(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.SQMode:
|
||||
sb.Append(((int)sd.SquibFireMode).ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.LimitDuration:
|
||||
sb.Append(sd.LimitDuration.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Duration:
|
||||
sb.Append(sd.DurationMS.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.OutputMode:
|
||||
sb.Append(((int)sd.DigitalOutputMode).ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Delay:
|
||||
sb.Append(sd.DelayMS.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DIMode:
|
||||
sb.Append(((int)sd.InputMode).ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DefaultValue:
|
||||
sb.Append(sd.ScaleMultiplier.DefaultValue.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.ActiveValue:
|
||||
sb.Append(
|
||||
sd.ScaleMultiplier.ActiveValue.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
private static TestTemplateList _list;
|
||||
private static readonly object OBJECT_LOCK = new object();
|
||||
public static TestTemplateList TestTemplatesList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (OBJECT_LOCK)
|
||||
{
|
||||
if (null == _list) { _list = new TestTemplateList(); }
|
||||
}
|
||||
return _list;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reload()
|
||||
{
|
||||
lock (OBJECT_LOCK)
|
||||
{
|
||||
if (!(Application.Current is App app)) return;
|
||||
app.IsoDb.RefreshAllData();
|
||||
CustomChannelList.List.ReloadAll();
|
||||
SensorsCollection.SensorsList.Reload();
|
||||
SensorCalibrationList.Reload();
|
||||
DASHardwareList.GetList().ReloadAll();
|
||||
TestEngineerDetailsList.TestEngineerList.ReloadAll();
|
||||
TestObjectTemplateCollection.TemplateCollection.ReloadAll(false);
|
||||
TestObjectList.TestObjectsList.ReloadAll(false);
|
||||
Load();
|
||||
}
|
||||
}
|
||||
public static bool SysBuiltObject(string serialNumber)
|
||||
{
|
||||
var temp = false;
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TestObjectsGet.ToString();
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TestObjectName", SqlDbType.NVarChar, 50) { Value = serialNumber });
|
||||
cmd.Parameters.Add(new SqlParameter("@TemplateName", SqlDbType.NVarChar, 255) { Value = null });
|
||||
cmd.Parameters.Add(new SqlParameter("@SysBuilt", SqlDbType.Bit) { Value = null });
|
||||
|
||||
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"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
private void Load()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// deletes all test setups originally designed so TDM imports could clear all tables except DAS
|
||||
/// </summary>
|
||||
public void DeleteAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TestSetupsDeleteAll.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
#region Output
|
||||
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@ErrorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
var errorSeverityParam =
|
||||
new SqlParameter("@ErrorSeverity", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorSeverityParam);
|
||||
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@ErrorState", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
|
||||
#endregion Output
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
if (DBNull.Value != errorNumberParam.Value)
|
||||
{
|
||||
var error = int.Parse(errorNumberParam.Value.ToString());
|
||||
if (error != 0)
|
||||
{
|
||||
var message = int.Parse(errorNumberParam.Value.ToString());
|
||||
var state = int.Parse(errorNumberParam.Value.ToString());
|
||||
//APILogger.Log(
|
||||
// $"Error:{Convert.ToString(error)}, State:{Convert.ToString(state)} Error: {message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to delete all test setups, ", ex);*/ }
|
||||
//Reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class MMETransducerMainLocation //: AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Type { get; }
|
||||
|
||||
public string Trans_Main_Loc { 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 MMETransducerMainLocation(string sGuid, string type, string transMainLoc, string textL1, string textL2,
|
||||
long version, DateTime date, string remarks, bool expired, string sortkey, string pictureShortName,
|
||||
DateTime lastChange, string lastChangeText, string history, MMEPossibleChannels.MMEChannelTypes recordType)
|
||||
{
|
||||
RecordType = recordType;
|
||||
S_GUID = sGuid;
|
||||
Type = type;
|
||||
Trans_Main_Loc = transMainLoc;
|
||||
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;
|
||||
}
|
||||
public static void DeleteTransducerMainLocations()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEMainLocationsDelete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to delete main locations, ", ex); */}
|
||||
}
|
||||
public static MMETransducerMainLocation[] GetTransducerMainLocations()
|
||||
{
|
||||
var transducerMainLocations = new List<MMETransducerMainLocation>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEMainLocationsGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
transducerMainLocations.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.EXPIRED.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.LAST_CHANGE_TEXT.ToString()])
|
||||
let pictureShortName = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.PICTURE_SHORTNAME.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.REMARKS.ToString()])
|
||||
let guid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.s_GUID.ToString()])
|
||||
let sortkey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TEXT_L2.ToString()])
|
||||
let mainLoc = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.TRANS_MAIN_LOC.ToString()])
|
||||
let type = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TYPE.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.VERSION.ToString()])
|
||||
select new MMETransducerMainLocation(guid, type, mainLoc, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortkey, pictureShortName,
|
||||
lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process main locations: ", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve main locations, ", ex);*/ }
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEMainLocationsGetCustom.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
transducerMainLocations.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.EXPIRED.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.LAST_CHANGE_TEXT.ToString()])
|
||||
let pictureShortName = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.PICTURE_SHORTNAME.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.REMARKS.ToString()])
|
||||
let guid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.s_GUID.ToString()])
|
||||
let sortkey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TEXT_L2.ToString()])
|
||||
let mainLoc = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.TRANS_MAIN_LOC.ToString()])
|
||||
let type = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TYPE.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.VERSION.ToString()])
|
||||
select new MMETransducerMainLocation(guid, type, mainLoc, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortkey, pictureShortName,
|
||||
lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process custom main locations: ", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve custom main locations, ", ex); */}
|
||||
|
||||
return transducerMainLocations.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseImport.ISO
|
||||
{
|
||||
public class IsoCode
|
||||
{
|
||||
private readonly 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;
|
||||
}
|
||||
private char _position
|
||||
{
|
||||
get => _isoCodeFull[1];
|
||||
set => _isoCodeFull[1] = value;
|
||||
}
|
||||
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++)
|
||||
{
|
||||
_isoCodeFull[i + 6] = value.Length < i ? '0' : 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 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]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <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 $"{testObject}{position}{main}{floc1}{floc2}{floc3}{physdim}{dir}{fc}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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,
|
||||
AllowTSRAIRRecordingModes,
|
||||
IncludeGroupNameInISOExport,
|
||||
WarnIfTestCancelledWithoutExport,
|
||||
DiademChannelName200Option,
|
||||
DiademUserComment201Option,
|
||||
StartingTestSetup,
|
||||
SensitivityDisplayFormat,
|
||||
TriggerSecondsDisplayFormat,
|
||||
NonLinearDisplayFormat,
|
||||
CapacityRangeDisplayFormat,
|
||||
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,
|
||||
SLICE6Db_PowerSetting,
|
||||
UseLegacyTOMCFC,
|
||||
UseLegacyTDCSoftwareFilterAdjustment,
|
||||
AllowModify,
|
||||
ApplyShiftT0ModsTestOnly,
|
||||
POWERPRO_CalPeriod,
|
||||
SLICE6Air_CalPeriod,
|
||||
SLICE6DB_CalPeriod,
|
||||
TSRAir_CalPeriod,
|
||||
LevelTriggerMaxPercentage,
|
||||
LevelTriggerMinPercentage
|
||||
}
|
||||
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 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());
|
||||
ISOSupportLevels level;
|
||||
return !Enum.TryParse(s, out level) ? ISOSupportLevels.ISO_ONLY : level;
|
||||
}
|
||||
set => SettingsDB.SetGlobalValue(Keys.IsoSupportLevel.ToString(), value.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a dictionary of sensor type to iso physical dimension
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, string> GetAllSensorTypeToDimensionMappings()
|
||||
{
|
||||
var d = new Dictionary<string, string>();
|
||||
foreach (var m in AllSensorTypeToDimensions)
|
||||
{
|
||||
if (!d.ContainsKey(m.Code)) { d[m.Code] = m.Dimension; }
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
// key for how many mappings are present
|
||||
private const string NUM_SENSORTYPE_MAPPINGS = "NUM_SENSORTYPE_MAPPINGS";
|
||||
// key for each individual mapping
|
||||
private const string SENSORTYPE_MAPPING_PRE = "SENSORTYPE_";
|
||||
/// <summary>
|
||||
/// returns all Sensor type to ISO physical dimension mappings
|
||||
/// </summary>
|
||||
public static SensorTypeToDimension[] AllSensorTypeToDimensions
|
||||
{
|
||||
get
|
||||
{
|
||||
var sMappings = SettingsDB.GetGlobalValue(NUM_SENSORTYPE_MAPPINGS, "7");
|
||||
var iMappings = 7;
|
||||
int.TryParse(sMappings, out iMappings);
|
||||
var mappings = new List<SensorTypeToDimension>();
|
||||
for (var i = 0; i < iMappings; i++)
|
||||
{
|
||||
var s = GetSensorTypeMapping(i);
|
||||
if (null != s) { mappings.Add(s); }
|
||||
}
|
||||
return mappings.ToArray();
|
||||
}
|
||||
set
|
||||
{
|
||||
for (var i = 0; i < value.Length; i++) { SetSensorTypeMapping(i, value[i]); }
|
||||
SettingsDB.SetGlobalValue(NUM_SENSORTYPE_MAPPINGS, value.Length.ToString());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// stores one sensor type to iso physical dimension
|
||||
/// used by AllSensorTypeToDimensions
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="dim"></param>
|
||||
private static void SetSensorTypeMapping(int index, SensorTypeToDimension dim)
|
||||
{
|
||||
var s = string.Format("{0}{1}{2}{1}{3}", dim.Code, (char)149, dim.Name, dim.Dimension);
|
||||
SettingsDB.SetGlobalValue(string.Format("{0}{1}", SENSORTYPE_MAPPING_PRE, index), s);
|
||||
}
|
||||
private static SensorTypeToDimension GetSensorTypeMapping(int index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: return GetSensorTypeMapping(index, "D", "Acceleration", "AC");
|
||||
case 1: return GetSensorTypeMapping(index, "F", "Force", "FO");
|
||||
case 2: return GetSensorTypeMapping(index, "M", "Momentum", "MO");
|
||||
case 3: return GetSensorTypeMapping(index, "S", "Displacement", "DS");
|
||||
case 4: return GetSensorTypeMapping(index, "W", "Angular Acceleration", "AA");
|
||||
case 5: return GetSensorTypeMapping(index, "A", "Angle", "AN");
|
||||
case 6: return GetSensorTypeMapping(index, "B", "Voltage", "VO");
|
||||
default: return GetSensorTypeMapping(index, "", "", "");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// retrieves an individual sensor type to iso code mapping (or null if there isn't such a mapping)
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="dimension"></param>
|
||||
/// <returns></returns>
|
||||
private static SensorTypeToDimension GetSensorTypeMapping(int index, string code, string name, string dimension)
|
||||
{
|
||||
var s = SettingsDB.GetGlobalValue(string.Format("{0}{1}", SENSORTYPE_MAPPING_PRE, index), string.Format("{0}{1}{2}{1}{3}", code, (char)149, name, dimension));
|
||||
var tokens = s.Split(new char[] { (char)149 });
|
||||
if (tokens.Length < 3) { return null; }
|
||||
var s1 = tokens[0];
|
||||
var s2 = tokens[1];
|
||||
var s3 = tokens[2];
|
||||
if (string.IsNullOrWhiteSpace(s1) || string.IsNullOrWhiteSpace(s2) || string.IsNullOrWhiteSpace(s3)) { return null; }
|
||||
return new SensorTypeToDimension(code, name, dimension);
|
||||
}
|
||||
|
||||
public class SensorTypeToDimension : Tuple<string, string, string>
|
||||
{
|
||||
public SensorTypeToDimension(string sensorType, string name, string dimension) : base(sensorType, name, dimension) { }
|
||||
|
||||
public string Code => Item1;
|
||||
public string Name => Item2;
|
||||
public string Dimension => Item3;
|
||||
}
|
||||
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,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("DatabaseImport")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DatabaseImport")]
|
||||
[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("00b5442e-2279-47ae-8015-6db0ffeb6d88")]
|
||||
|
||||
// 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")]
|
||||
@@ -0,0 +1,293 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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 void DeletePhysicalDimensions()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPhysicalDimensionsDelete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) {/* APILogger.Log("failed to delete physical dimensions", ex);*/ }
|
||||
}
|
||||
public static MMEPhysicalDimensions[] GetPhysicalDimensions()
|
||||
{
|
||||
var physicalDimensions = new List<MMEPhysicalDimensions>();
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPhysicalDimensionsGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
physicalDimensions.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let amountOfSubstanceExp = Convert.ToInt32(
|
||||
dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.AMOUNT_OFSUBSTANCE_EXP
|
||||
.ToString()])
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEPhysicalDimensionFields.DATE.ToString()])
|
||||
let defaultUnit = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.DEFAULT_UNIT.ToString()])
|
||||
let electricalExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.ELECTRIC_CURRENT_EXP
|
||||
.ToString()])
|
||||
let expired = Convert.ToBoolean(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.EXPIRED.ToString()])
|
||||
let history = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE_TEXT
|
||||
.ToString()])
|
||||
let lengthExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LENGTH_EXP.ToString()])
|
||||
let lumIntExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LUMINOUS_INTENSITY_EXP
|
||||
.ToString()])
|
||||
let massExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.MASS_EXP.ToString()])
|
||||
let physicalDimension = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.PHYSICAL_DIMENSION
|
||||
.ToString()])
|
||||
let remarks = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.s_GUID.ToString()])
|
||||
let sortKey = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.SORTKEY.ToString()])
|
||||
let tempExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEMPERATURE_EXP
|
||||
.ToString()])
|
||||
let text1 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L2.ToString()])
|
||||
let timeExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TIME_EXP.ToString()])
|
||||
let version = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.VERSION.ToString()])
|
||||
select new MMEPhysicalDimensions(sGuid, 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.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to parse physical dimensions: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve physical dimensions", ex);*/ }
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPhysicalDimensionsGetCustom.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
physicalDimensions.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let amountOfSubstanceExp = Convert.ToInt32(
|
||||
dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.AMOUNT_OFSUBSTANCE_EXP
|
||||
.ToString()])
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEPhysicalDimensionFields.DATE.ToString()])
|
||||
let defaultUnit = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.DEFAULT_UNIT.ToString()])
|
||||
let electricalExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.ELECTRIC_CURRENT_EXP
|
||||
.ToString()])
|
||||
let expired = Convert.ToBoolean(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.EXPIRED.ToString()])
|
||||
let history = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE_TEXT
|
||||
.ToString()])
|
||||
let lengthExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LENGTH_EXP.ToString()])
|
||||
let lumIntExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LUMINOUS_INTENSITY_EXP
|
||||
.ToString()])
|
||||
let massExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.MASS_EXP.ToString()])
|
||||
let physicalDimension = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.PHYSICAL_DIMENSION
|
||||
.ToString()])
|
||||
let remarks = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.s_GUID.ToString()])
|
||||
let sortKey = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.SORTKEY.ToString()])
|
||||
let tempExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEMPERATURE_EXP
|
||||
.ToString()])
|
||||
let text1 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L2.ToString()])
|
||||
let timeExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TIME_EXP.ToString()])
|
||||
let version = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.VERSION.ToString()])
|
||||
select new MMEPhysicalDimensions(sGuid, 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));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to parse custom physical dimensions: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve custom physical dimensions", ex); */}
|
||||
|
||||
return physicalDimensions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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 void DeletePositions()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPositionsDelete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to delete positions, ", ex);*/ }
|
||||
}
|
||||
public static MMEPositions[] GetPositions()
|
||||
{
|
||||
var positions = new List<MMEPositions>();
|
||||
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPositionsGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) return positions.ToArray();
|
||||
try
|
||||
{
|
||||
positions.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.DATE.ToString()])
|
||||
let expired =
|
||||
Convert.ToBoolean(dr[DbOperations.MMETables.MMEPositionsFields.EXPIRED.ToString()])
|
||||
let history =
|
||||
Convert.ToString(dr[DbOperations.MMETables.MMEPositionsFields.HISTORY.ToString()])
|
||||
let lastChange =
|
||||
Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText =
|
||||
Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.LAST_CHANGE_TEXT.ToString()])
|
||||
let position =
|
||||
Convert.ToString(dr[DbOperations.MMETables.MMEPositionsFields.POSITION.ToString()])
|
||||
let remarks =
|
||||
Convert.ToString(dr[DbOperations.MMETables.MMEPositionsFields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.s_GUID.ToString()])
|
||||
let sortKey =
|
||||
Convert.ToString(dr[DbOperations.MMETables.MMEPositionsFields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.TEXT_L2.ToString()])
|
||||
let version =
|
||||
Convert.ToInt32(dr[DbOperations.MMETables.MMEPositionsFields.VERSION.ToString()])
|
||||
select new MMEPositions(sGuid, position, text1, text2, Convert.ToInt64(version), date,
|
||||
remarks, expired, sortKey, lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to get positions", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPositionsGetCustom.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) return positions.ToArray();
|
||||
try
|
||||
{
|
||||
positions.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.DATE.ToString()])
|
||||
let expired =
|
||||
Convert.ToBoolean(dr[DbOperations.MMETables.MMEPositionsFields.EXPIRED.ToString()])
|
||||
let history =
|
||||
Convert.ToString(dr[DbOperations.MMETables.MMEPositionsFields.HISTORY.ToString()])
|
||||
let lastChange =
|
||||
Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText =
|
||||
Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.LAST_CHANGE_TEXT.ToString()])
|
||||
let position =
|
||||
Convert.ToString(dr[DbOperations.MMETables.MMEPositionsFields.POSITION.ToString()])
|
||||
let remarks =
|
||||
Convert.ToString(dr[DbOperations.MMETables.MMEPositionsFields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.s_GUID.ToString()])
|
||||
let sortKey =
|
||||
Convert.ToString(dr[DbOperations.MMETables.MMEPositionsFields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEPositionsFields.TEXT_L2.ToString()])
|
||||
let version =
|
||||
Convert.ToInt32(dr[DbOperations.MMETables.MMEPositionsFields.VERSION.ToString()])
|
||||
select new MMEPositions(sGuid, position, text1, text2, Convert.ToInt64(version), date,
|
||||
remarks, expired, sortKey, lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to get custom positions", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return positions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// Display enum description instead of enum value
|
||||
/// http://brianlagunas.com/a-better-way-to-data-bind-enums-in-wpf/
|
||||
/// </summary>
|
||||
public class EnumDescriptionTypeConverter : EnumConverter
|
||||
{
|
||||
public EnumDescriptionTypeConverter(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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 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 void DeleteFilterClasses()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFilterClassesDelete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to delete filters, ", ex); */}
|
||||
}
|
||||
|
||||
public static MMEFilterClasses[] GetFilterClasses()
|
||||
{
|
||||
var filterClasses = new List<MMEFilterClasses>();
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFilterClassesGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
//cmd.ExecuteNonQuery();
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
filterClasses.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.EXPIRED.ToString()])
|
||||
let filterclass = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFilterClassesFields.FILTER_CLASS.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEFilterClassesFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFilterClassesFields.LAST_CHANGE_TEXT.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.s_GUID.ToString()])
|
||||
let sortkey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.TEXT_L2.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.VERSION.ToString()])
|
||||
select new MMEFilterClasses(sGuid, filterclass, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortkey, lastChange,
|
||||
lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process filter classes ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("failed to retrieve filters, ", ex);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFilterClassesGetCustom.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
filterClasses.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.EXPIRED.ToString()])
|
||||
let filterclass = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFilterClassesFields.FILTER_CLASS.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEFilterClassesFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEFilterClassesFields.LAST_CHANGE_TEXT.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.s_GUID.ToString()])
|
||||
let sortkey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.TEXT_L2.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMEFilterClassesFields.VERSION.ToString()])
|
||||
select new MMEFilterClasses(sGuid, filterclass, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortkey, lastChange,
|
||||
lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process custom filter classes", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("failed to retrieve custom filters, ", ex);
|
||||
}
|
||||
return filterClasses.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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 void DeleteTestObjects()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMETestObjectsDelete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to delete test objects, ", ex);*/ }
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMETestObjectsUpdateInsert.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = Guid.Parse(S_GUID) });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEST_OBJECT", SqlDbType.NVarChar, 50) { Value = Test_Object });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L1", SqlDbType.NVarChar, 50) { Value = Text_L1 });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L2", SqlDbType.NVarChar, 50) { Value = Text_L2 });
|
||||
cmd.Parameters.Add(new SqlParameter("@VERSION", SqlDbType.Int) { Value = Version });
|
||||
cmd.Parameters.Add(new SqlParameter("@DATE", SqlDbType.DateTime) { Value = Date });
|
||||
cmd.Parameters.Add(new SqlParameter("@REMARKS", SqlDbType.NVarChar, 50) { Value = Remarks });
|
||||
cmd.Parameters.Add(new SqlParameter("@EXPIRED", SqlDbType.Bit) { Value = Expired });
|
||||
cmd.Parameters.Add(new SqlParameter("@SORTKEY", SqlDbType.NVarChar, 50) { Value = SortKey });
|
||||
cmd.Parameters.Add(new SqlParameter("@LAST_CHANGE", SqlDbType.DateTime) { Value = Last_Change });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@LAST_CHANGE_TEXT", SqlDbType.NVarChar, 50) { Value = Last_Change_Text });
|
||||
cmd.Parameters.Add(new SqlParameter("@HISTORY", SqlDbType.NVarChar, 50) { Value = History });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
public static MMETestObjects[] GetTestObjects()
|
||||
{
|
||||
var testObjects = new List<MMETestObjects>();
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMETestObjectsGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
testObjects.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.EXPIRED.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMETestObjectsFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMETestObjectsFields.LAST_CHANGE_TEXT.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.s_GUID.ToString()])
|
||||
let sortKey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.SORTKEY.ToString()])
|
||||
let textObject = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMETestObjectsFields.TEST_OBJECT.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.TEXT_L2.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.VERSION.ToString()])
|
||||
select new MMETestObjects(sGuid, textObject, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortKey, lastChange,
|
||||
lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process test objects: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve test objects, ", ex);*/ }
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMETestObjectsGetCustom.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
testObjects.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.EXPIRED.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMETestObjectsFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMETestObjectsFields.LAST_CHANGE_TEXT.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.s_GUID.ToString()])
|
||||
let sortKey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.SORTKEY.ToString()])
|
||||
let textObject = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMETestObjectsFields.TEST_OBJECT.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.TEXT_L2.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMETestObjectsFields.VERSION.ToString()])
|
||||
select new MMETestObjects(sGuid, textObject, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortKey, lastChange,
|
||||
lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process custom test objects: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve custom test objects, ", ex); */}
|
||||
|
||||
return testObjects.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public interface IHardwareChannel
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
<?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>{00B5442E-2279-47AE-8015-6DB0FFEB6D88}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DatabaseImport</RootNamespace>
|
||||
<AssemblyName>DatabaseImport</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</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.Drawing" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<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="App\WaitCursor.cs" />
|
||||
<Compile Include="App\App.cs" />
|
||||
<Compile Include="Classes\Constants.cs" />
|
||||
<Compile Include="Classes\Enums.cs" />
|
||||
<Compile Include="Classes\Hardware\DASHardware.cs" />
|
||||
<Compile Include="Classes\Hardware\DASHardwareList.cs" />
|
||||
<Compile Include="Classes\Hardware\DASSettings.cs" />
|
||||
<Compile Include="Classes\Hardware\HardwareChannel.cs" />
|
||||
<Compile Include="Classes\RegionsAndZones\Region.cs" />
|
||||
<Compile Include="Classes\RegionsAndZones\RegionAdorner.cs" />
|
||||
<Compile Include="Classes\RegionsAndZones\Zone.cs" />
|
||||
<Compile Include="Classes\Sensors\InitialOffset.cs" />
|
||||
<Compile Include="Classes\Sensors\ZeroMethod.cs" />
|
||||
<Compile Include="Classes\TestMetaData\CustomerDetails.cs" />
|
||||
<Compile Include="Classes\TestMetaData\LabratoryDetails.cs" />
|
||||
<Compile Include="Classes\TestMetaData\TestEngineerDetails.cs" />
|
||||
<Compile Include="Classes\TestObject\TemplateChannelUI.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\TestObject\TestTestObject.cs" />
|
||||
<Compile Include="Classes\TestTemplate\HardwareInclusionInstruction.cs" />
|
||||
<Compile Include="Classes\TestTemplate\ICachedContainer.cs" />
|
||||
<Compile Include="Classes\TestTemplate\RegionOfInterest.cs" />
|
||||
<Compile Include="Classes\TestTemplate\TestTemplate.cs" />
|
||||
<Compile Include="Classes\TestTemplate\TestTemplateList.cs" />
|
||||
<Compile Include="Classes\TestTemplate\TestTemplateLite.cs" />
|
||||
<Compile Include="Controls\SensorsAndModels\ImportSensorsImportControl.cs" />
|
||||
<Compile Include="Controls\TestSetups\ImportTestSetup.cs" />
|
||||
<Compile Include="Converters\EnumDescriptionTypeConverter.cs" />
|
||||
<Compile Include="CustomChannel.cs" />
|
||||
<Compile Include="DASConcepts\Test.Module.Channel.Sensor.Bridge.cs" />
|
||||
<Compile Include="DASConcepts\DigitalInputScaleMultiplier.cs" />
|
||||
<Compile Include="DASConcepts\LinearizationFormula.cs" />
|
||||
<Compile Include="DASConcepts\Test.Module.Channel.Sensor.SensorUnits.cs" />
|
||||
<Compile Include="DbImporter.cs" />
|
||||
<Compile Include="Enums\DigitalInputs.cs" />
|
||||
<Compile Include="Enums\DigitalOutputs.cs" />
|
||||
<Compile Include="Enums\ExcitationVoltageOptions.cs" />
|
||||
<Compile Include="Enums\Hardware\HardwareTypes.cs" />
|
||||
<Compile Include="Enums\Sensors\LinearizationFormula.cs" />
|
||||
<Compile Include="Enums\Sensors\SensorStatus.cs" />
|
||||
<Compile Include="Enums\Sensors\ZeroMethodType.cs" />
|
||||
<Compile Include="Enums\Squibs.cs" />
|
||||
<Compile Include="Enums\SupportedExportFormatBitFlags.cs" />
|
||||
<Compile Include="Interface\DataRecorders\IDASHardware.cs" />
|
||||
<Compile Include="Interface\DataRecorders\IHardwareChannel.cs" />
|
||||
<Compile Include="Interface\Hardware\IISOHardware.cs" />
|
||||
<Compile Include="Interface\Sensors\ICalibrationRecords.cs" />
|
||||
<Compile Include="Interface\Sensors\ISensorCalibration.cs" />
|
||||
<Compile Include="Interface\Sensors\ISensorData.cs" />
|
||||
<Compile Include="Interface\TestSetups\TestSetupsList\ITestSetup.cs" />
|
||||
<Compile Include="ISO\CalculatedValueClass.cs" />
|
||||
<Compile Include="ISO\CustomerDetails.cs" />
|
||||
<Compile Include="ISO\Hardware.cs" />
|
||||
<Compile Include="ISO\HardwareChannel.cs" />
|
||||
<Compile Include="ISO\ISO13499FileDb.cs" />
|
||||
<Compile Include="ISO\IsoCode.cs" />
|
||||
<Compile Include="ISO\LabratoryDetails.cs" />
|
||||
<Compile Include="ISO\LevelTriggerChannel.cs" />
|
||||
<Compile Include="ISO\MMEDirections.cs" />
|
||||
<Compile Include="ISO\MMEFigures.cs" />
|
||||
<Compile Include="ISO\MMEFilterClasses.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\MMEPossibleChannels.cs" />
|
||||
<Compile Include="ISO\MMETestObjects.cs" />
|
||||
<Compile Include="ISO\MMETransducerMainLocation.cs" />
|
||||
<Compile Include="ISO\TemplateRegion.cs" />
|
||||
<Compile Include="ISO\TemplateZone.cs" />
|
||||
<Compile Include="ISO\TestEngineerDetails.cs" />
|
||||
<Compile Include="ISO\TestObject.cs" />
|
||||
<Compile Include="ISO\TestObjectChannel.cs" />
|
||||
<Compile Include="ISO\TestObjectMetaData.cs" />
|
||||
<Compile Include="ISO\TestObjectTemplate.cs" />
|
||||
<Compile Include="ISO\TestObjectTemplateChannel.cs" />
|
||||
<Compile Include="ISO\TestSetting.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SensorDB\CalibrationRecords.cs" />
|
||||
<Compile Include="SensorDB\DigitalInputSetting.cs" />
|
||||
<Compile Include="SensorDB\DigitalOutputSetting.cs" />
|
||||
<Compile Include="SensorDB\FilterClass.cs" />
|
||||
<Compile Include="SensorDB\IsoCode.cs" />
|
||||
<Compile Include="SensorDB\SensorCalibration.cs" />
|
||||
<Compile Include="SensorDB\SensorCalibrationList.cs" />
|
||||
<Compile Include="SensorDB\SensorData.cs" />
|
||||
<Compile Include="SensorDB\SensorDB.cs" />
|
||||
<Compile Include="SensorDB\SensorModel.cs" />
|
||||
<Compile Include="SensorDB\SensorRange.cs" />
|
||||
<Compile Include="SensorDB\SensorsCollection.cs" />
|
||||
<Compile Include="SensorDB\SquibSetting.cs" />
|
||||
<Compile Include="SerializedSettings.cs" />
|
||||
<Compile Include="SettingsDB\GlobalSetting.cs" />
|
||||
<Compile Include="SettingsDB\Setting.cs" />
|
||||
<Compile Include="SettingsDB\SettingsDB.cs" />
|
||||
<Compile Include="Storage\DbOperationsEnum.cs" />
|
||||
<Compile Include="Storage\DbOperations.cs" />
|
||||
<Compile Include="Storage\IDbTimeStampAware.cs" />
|
||||
<Compile Include="TestGraph.cs" />
|
||||
<Compile Include="Users\ITagAware.cs" />
|
||||
<Compile Include="Users\Tags.cs" />
|
||||
<Compile Include="Users\User.cs" />
|
||||
<Compile Include="Utilities\DiskUtility.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\Common\DTS.Common.Storage\DTS.Common.Storage.csproj">
|
||||
<Project>{e3be457c-0ac7-4a9c-bc81-eafeb3217878}</Project>
|
||||
<Name>DTS.Common.Storage</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\Common\DTS.Common\DTS.Common.csproj">
|
||||
<Project>{f7a0804f-61a4-40ae-83d0-f1137622b592}</Project>
|
||||
<Name>DTS.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,207 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Data;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TestObjectTemplateChannel : INotifyPropertyChanged
|
||||
{
|
||||
#region 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)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
#endregion
|
||||
|
||||
public const string NONISOCHANNELTYPE = "NONISO";
|
||||
public const string SEPARATOR = "_X_";
|
||||
public const string TEST_SPECIFIC_DOUT = "TSD_";
|
||||
public enum DataStatusTypes
|
||||
{
|
||||
OK,
|
||||
ChannelFailed,
|
||||
MeaninglessData,
|
||||
NoData,
|
||||
QuestionableData,
|
||||
ScalingFactorApplied,
|
||||
SystemFailed,
|
||||
LinearisedData,
|
||||
NOVALUE
|
||||
}
|
||||
|
||||
public enum StandardChannelProperties
|
||||
{
|
||||
NameOfTheChannel,
|
||||
DisplayOrder
|
||||
}
|
||||
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 int TemplateChannelId { get; set; }
|
||||
public string NameOfTheChannel
|
||||
{
|
||||
get
|
||||
{
|
||||
var s = _channelProperties[StandardChannelProperties.NameOfTheChannel.ToString()].Value as string;
|
||||
if (!string.IsNullOrWhiteSpace(s) && s != DataStatusTypes.NOVALUE.ToString()) return s;
|
||||
if (Name.StartsWith(TEST_SPECIFIC_DOUT))
|
||||
{
|
||||
return $"(Digital Output Setting){Name}";
|
||||
}
|
||||
return Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
_channelProperties[StandardChannelProperties.NameOfTheChannel.ToString()].Value = value;
|
||||
OnPropertyChanged("NameOfTheChannel");
|
||||
}
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
var tokens = Channel.Text_L1.Split(new[] { SEPARATOR }, StringSplitOptions.None);
|
||||
return tokens.Last();
|
||||
}
|
||||
}
|
||||
public ISO.TestObjectTemplate Template { get; private set; }
|
||||
private readonly List<string> _channelPropertyNames = new List<string>();
|
||||
private Dictionary<string, ChannelProperty> _channelProperties = new Dictionary<string, ChannelProperty>();
|
||||
public MMEPossibleChannels Channel { get; private set; }
|
||||
public bool LocalOnly { get; set; }
|
||||
// #endregion
|
||||
|
||||
// #region methods
|
||||
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"
|
||||
}
|
||||
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;
|
||||
switch (p)
|
||||
{
|
||||
case StandardChannelProperties.DisplayOrder: cp = new ChannelProperty(p.ToString(), "0"); break;
|
||||
case StandardChannelProperties.NameOfTheChannel: cp = new ChannelProperty("Name of the channel", "NOVALUE"); break;
|
||||
default: cp = new ChannelProperty(p.ToString(), "NOVALUE"); break;
|
||||
}
|
||||
_channelProperties.Add(p.ToString(), cp);
|
||||
}
|
||||
}
|
||||
public void SetTemplate(ISO.TestObjectTemplate template) { Template = template; }
|
||||
|
||||
private bool _bRequired;
|
||||
|
||||
/// <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 TestObjectTemplateChannel(DataRow dr, ISO.TestObjectTemplate template, ref ISO13499FileDb db)
|
||||
{
|
||||
Template = template;
|
||||
AddStandardProperties();
|
||||
TemplateChannelId = Convert.ToInt32(dr["TemplateChannelId"]);
|
||||
|
||||
_channelProperties[StandardChannelProperties.NameOfTheChannel.ToString()].Value = (string)dr["NameOfTheChannel"];
|
||||
|
||||
_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);
|
||||
}
|
||||
public TestObjectTemplateChannel(TestObjectTemplateChannel copy, ISO.TestObjectTemplate template)
|
||||
{
|
||||
TemplateChannelId = copy.TemplateChannelId;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
_bRequired = copy.Required;
|
||||
Channel = new MMEPossibleChannels(copy.Channel);
|
||||
_channelProperties = new Dictionary<string, ChannelProperty>();
|
||||
using (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO: move to separate class
|
||||
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,14 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// GUI wrapper for template channels ... it contains a testobjecttemplatechannel
|
||||
/// </summary>
|
||||
public class TemplateChannelUI //: BasePropertyChanged
|
||||
{
|
||||
private TestObjectTemplateChannel _channel;
|
||||
public TemplateChannelUI(TestObjectTemplateChannel channel)
|
||||
{
|
||||
_channel = channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TestObjectMetaData
|
||||
{
|
||||
public static double Version { get; set; } = 1.06;
|
||||
public const string NOVALUE = "NOVALUE";
|
||||
|
||||
public void SetProperty(MetaData meta)
|
||||
{
|
||||
_properties[meta.Name] = meta;
|
||||
}
|
||||
public 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 class MetaData
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public bool IsOptional { get; } = false;
|
||||
|
||||
public double Version { get; } = 1.06D;
|
||||
|
||||
public string Value { get; set; } = "NOVALUE";
|
||||
|
||||
public MetaData(string name, bool optional, string value, double version)
|
||||
{
|
||||
Name = name;
|
||||
IsOptional = optional;
|
||||
Value = value;
|
||||
Version = version;
|
||||
}
|
||||
public MetaData(MetaData copy)
|
||||
{
|
||||
Name = copy.Name;
|
||||
IsOptional = copy.IsOptional;
|
||||
Value = copy.Value;
|
||||
Version = copy.Version;
|
||||
}
|
||||
}
|
||||
public class TestSetupMetaData
|
||||
{
|
||||
public double Version { get; set; } = 1.06;
|
||||
public const string NOVALUE = "NOVALUE";
|
||||
public const string MEDIADEFAULT = "1/1";
|
||||
|
||||
public void SetProperty(MetaData meta, bool requireXCrashCompatibilityForISOExports)
|
||||
{
|
||||
switch (meta.Name)
|
||||
{
|
||||
case "LaboratoryName":
|
||||
case "LaboratoryContactName":
|
||||
case "LaboratoryTestReferenceNumber":
|
||||
case "CustomerName":
|
||||
case "CustomerTestReferenceNumber":
|
||||
if ((meta.Value == NOVALUE) && requireXCrashCompatibilityForISOExports)
|
||||
{
|
||||
meta.Value = string.Empty;
|
||||
}
|
||||
break;
|
||||
}
|
||||
_properties[meta.Name] = meta;
|
||||
}
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
private char _testObject = '_';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using DTS.Common.Interface.TestMetaData;
|
||||
|
||||
namespace DatabaseImport.ISO
|
||||
{
|
||||
[Serializable()]
|
||||
public class TestEngineerDetails //: ISerializableFile
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool LocalOnly { get; set; } = false;
|
||||
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public DateTime LastModified { get; set; }
|
||||
|
||||
public string LastModifiedBy { get; set; }
|
||||
public int Version { get; set; } = 1;
|
||||
|
||||
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 TestEngineerDetails(ITestEngineerDetailsDbRecord testEngineerDetailsDbRecord)
|
||||
{
|
||||
Name = testEngineerDetailsDbRecord.Name;
|
||||
TestEngineerName = testEngineerDetailsDbRecord.TestEngineerName;
|
||||
TestEngineerPhone = testEngineerDetailsDbRecord.TestEngineerPhone;
|
||||
TestEngineerFax = testEngineerDetailsDbRecord.TestEngineerFax;
|
||||
TestEngineerEmail = testEngineerDetailsDbRecord.TestEngineerEmail;
|
||||
LocalOnly = testEngineerDetailsDbRecord.LocalOnly;
|
||||
LastModified = testEngineerDetailsDbRecord.LastModified;
|
||||
LastModifiedBy = testEngineerDetailsDbRecord.LastModifiedBy;
|
||||
Version = testEngineerDetailsDbRecord.Version;
|
||||
}
|
||||
public static void DeleteAllTestEngineerDetails()
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DTS.Common.Storage.DbOperations.TestEngineerDetailsDelete(null, out string errorMessage);
|
||||
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
//APILogger.Log("Failed to delete test engineer details", errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("Failed to delete test engineer details", ex);*/ }
|
||||
}
|
||||
public static TestEngineerDetails[] GetAllTestEngineerDetails()
|
||||
{
|
||||
var list = new List<TestEngineerDetails>();
|
||||
try
|
||||
{
|
||||
var errorNumber = DTS.Common.Storage.DbOperations.TestEngineerDetailsGet(null, out ITestEngineerDetailsDbRecord[] testEngineerDetailsDbRecords);
|
||||
|
||||
if (errorNumber == 0)
|
||||
{
|
||||
foreach (var testEngineerDetailsDbRecord in testEngineerDetailsDbRecords)
|
||||
{
|
||||
try
|
||||
{
|
||||
list.Add(new TestEngineerDetails(testEngineerDetailsDbRecord));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//APILogger.Log("failed to get test engineer details", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("Failed to retrieve test engineer details", ex);*/ }
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public enum SensorStatus
|
||||
{
|
||||
Available,
|
||||
InUse,
|
||||
OutForService,
|
||||
OutForCalibration,
|
||||
Retired
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class HardwareChannel : /*BasePropertyChanged,*/ IComparable<HardwareChannel>, IHardwareChannel
|
||||
{
|
||||
private readonly ISO.HardwareChannel _isoChannel;
|
||||
public ISO.HardwareChannel 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);
|
||||
return 0 != order ? order : GetISOChannel().ChannelIdx.CompareTo(right.GetISOChannel().ChannelIdx);
|
||||
}
|
||||
public string GetId()
|
||||
{
|
||||
return $"{Hardware.GetHardware().GetId()}x{1 + ChannelNumber}";
|
||||
}
|
||||
|
||||
private TestObjectChannel _testObjectChannel;
|
||||
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(ISO.HardwareChannel 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,330 @@
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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 cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TemplateRegionsGet.ToString();
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TemplateName", SqlDbType.NVarChar, 255) { Value = templateName });
|
||||
cmd.Parameters.Add(new SqlParameter("@ZoneName", SqlDbType.NVarChar, 50) { Value = zoneName });
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
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)
|
||||
{
|
||||
//APILogger.Log("Failed to retrieve a region", templateName, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) {/* APILogger.Log("Failed to retrieve regions", templateName, ex);*/ }
|
||||
return regions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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
|
||||
{
|
||||
//if (_allGlobalSetting == null)
|
||||
//{
|
||||
// _allGlobalSetting = GetAllGlobalSetting();
|
||||
//}
|
||||
//foreach (var gs in _allGlobalSetting)
|
||||
//{
|
||||
// if (gs.PropertyId != PropertyId) continue;
|
||||
// _propertyValue = gs._propertyValue;
|
||||
// return;
|
||||
//}
|
||||
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SettingsGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.NVarChar) { Value = SYSTEM });
|
||||
cmd.Parameters.Add(new SqlParameter("@PropertyId", SqlDbType.NVarChar) { Value = PropertyId });
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception) //TODO: handle exception properly
|
||||
{
|
||||
_propertyValue = defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,683 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class Region //: BasePropertyChanged
|
||||
{
|
||||
private TestObjectTemplate _template;
|
||||
public TestObjectTemplate Template
|
||||
{
|
||||
get => _template;
|
||||
set
|
||||
{
|
||||
//if (null != _template && _template != value) { _template.PropertyChanged -= Template_PropertyChanged; }
|
||||
_template = value;
|
||||
//Template.PropertyChanged += Template_PropertyChanged;
|
||||
DetermineAvailableISOSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void Template_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (Enum.TryParse(e.PropertyName, out TestObjectTemplate.Tags tag))
|
||||
{
|
||||
switch (tag)
|
||||
{
|
||||
case TestObjectTemplate.Tags.TemplateAllChannels:
|
||||
RegionChannels = Template.TemplateAllChannels;
|
||||
RegionUIChannels = Template.TemplateAllUIChannels;
|
||||
DetermineAvailableISOSettings();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case "TestObjectType":
|
||||
RegionChannels = Template.TemplateAllChannels;
|
||||
RegionUIChannels = Template.TemplateAllUIChannels;
|
||||
DetermineAvailableISOSettings();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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(); }
|
||||
}
|
||||
|
||||
private Point _upperLeft;
|
||||
public Point RegionUpperLeft
|
||||
{
|
||||
get => _upperLeft;
|
||||
set => _upperLeft = value;
|
||||
}
|
||||
|
||||
private Point _bottomRight;
|
||||
public Point RegionBottomRight
|
||||
{
|
||||
get => _bottomRight;
|
||||
set => _bottomRight = value;
|
||||
}
|
||||
|
||||
private MMEDirections _direction;
|
||||
public MMEDirections RegionDirection
|
||||
{
|
||||
get => _direction;
|
||||
set
|
||||
{
|
||||
_direction = value;
|
||||
if (null != value)
|
||||
{
|
||||
_directionIndex = _allDirections.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_directionIndex = -1;
|
||||
}
|
||||
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;
|
||||
if (null != value)
|
||||
{
|
||||
_fineLocation1Index = _fineLocations1.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fineLocation1Index = -1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMEFineLocations2 _fineLocation2;
|
||||
public MMEFineLocations2 RegionFineLocation2
|
||||
{
|
||||
get => _fineLocation2;
|
||||
set
|
||||
{
|
||||
_fineLocation2 = value;
|
||||
if (null != value)
|
||||
{
|
||||
_fineLocation2Index = _fineLocations2.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fineLocation2Index = -1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMEFineLocations3 _fineLocation3;
|
||||
public MMEFineLocations3 RegionFineLocation3
|
||||
{
|
||||
get => _fineLocation3;
|
||||
set
|
||||
{
|
||||
_fineLocation3 = value;
|
||||
if (null != value)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMETransducerMainLocation _mainLocation;
|
||||
public MMETransducerMainLocation RegionMainLocation
|
||||
{
|
||||
get => _mainLocation;
|
||||
set
|
||||
{
|
||||
if (_mainLocation != value)
|
||||
{
|
||||
_mainLocation = value;
|
||||
if (null != value)
|
||||
{
|
||||
_mainLocationIndex = _mainLocations.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mainLocationIndex = _mainLocations.Count - 1;
|
||||
}
|
||||
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;
|
||||
if (null != value)
|
||||
{
|
||||
_physicalDimensionIndex = _physicalDimensions.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_physicalDimensionIndex = -1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMEPositions _position;
|
||||
public MMEPositions RegionPosition
|
||||
{
|
||||
get => _position;
|
||||
set
|
||||
{
|
||||
_position = value;
|
||||
if (null != value)
|
||||
{
|
||||
_positionIndex = _positions.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_positionIndex = -1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMETestObjects _testObject;
|
||||
public MMETestObjects RegionTestObject
|
||||
{
|
||||
get => _testObject;
|
||||
set => _testObject = value;
|
||||
}
|
||||
|
||||
|
||||
private 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 = ((App)Application.Current).IsoDb.GetTestObjectByIso(r.TestObject);
|
||||
RegionBottomRight = new Point(r.LowerRight.X, r.LowerRight.Y);
|
||||
RegionUpperLeft = new Point(r.UpperLeft.X, r.UpperLeft.Y);
|
||||
RegionDirection = ((App)Application.Current).IsoDb.GetDirectionByIso(r.Direction);
|
||||
RegionFilterClass = ((App)Application.Current).IsoDb.GetFilterClassByIso(r.FilterClass);
|
||||
RegionFineLocation1 = ((App)Application.Current).IsoDb.GetFineLocation1ByIso(r.FineLocation1);
|
||||
RegionFineLocation2 = ((App)Application.Current).IsoDb.GetFineLocation2ByIso(r.FineLocation2);
|
||||
RegionFineLocation3 = ((App)Application.Current).IsoDb.GetFineLocation3ByIso(r.FineLocation3);
|
||||
RegionMainLocation = ((App)Application.Current).IsoDb.GetMainLocationByIso(r.MainLocation);
|
||||
RegionPhysicalDimension = ((App)Application.Current).IsoDb.GetPhysicalDimensionByIso(r.PhysicalDimension);
|
||||
RegionPosition = ((App)Application.Current).IsoDb.GetPosition(r.Position);
|
||||
FilterRegionChannels();
|
||||
SetISOCode();
|
||||
}
|
||||
|
||||
private Visibility _regionAddVisibility = Visibility.Visible;
|
||||
public Visibility RegionAddVisibility
|
||||
{
|
||||
get => _regionAddVisibility;
|
||||
set => _regionAddVisibility = value;
|
||||
}
|
||||
private Visibility _regionDeleteVisibility = Visibility.Hidden;
|
||||
public Visibility RegionDeleteVisibility
|
||||
{
|
||||
get => _regionDeleteVisibility;
|
||||
set => _regionDeleteVisibility = value;
|
||||
}
|
||||
|
||||
private List<MMEDirections> _allDirections = new List<MMEDirections>();
|
||||
public MMEDirections[] AllDirections
|
||||
{
|
||||
get => _allDirections.ToArray();
|
||||
set
|
||||
{
|
||||
_allDirections = new List<MMEDirections>(value);
|
||||
AllDirectionsStrings = _allDirections.Select(dir => null == dir ? "?" : dir.Text_L1).ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allDirectionsStrings = new List<string>();
|
||||
public string[] AllDirectionsStrings
|
||||
{
|
||||
get => _allDirectionsStrings.ToArray();
|
||||
set => _allDirectionsStrings = new List<string>(value);
|
||||
}
|
||||
private int _directionIndex = -1;
|
||||
|
||||
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)
|
||||
{
|
||||
if (null == loc) { fineLocations1.Add("??"); }
|
||||
else { fineLocations1.Add(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 int _fineLocation1Index = -1;
|
||||
|
||||
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 int _fineLocation2Index = -1;
|
||||
public int FineLocation2Index
|
||||
{
|
||||
get => _fineLocation2Index;
|
||||
set
|
||||
{
|
||||
if (value == _fineLocation2Index) { return; }
|
||||
if (value < 0) { RegionFineLocation2 = null; }
|
||||
else { RegionFineLocation2 = _fineLocations2[value]; }
|
||||
FilterRegionChannels();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
AllMainLocationsStrings = _mainLocations.Select(loc => null == loc ? "????" : loc.Text_L1).ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allMainLocationsStrings = new List<string>();
|
||||
public string[] AllMainLocationsStrings
|
||||
{
|
||||
get => _allMainLocationsStrings.ToArray();
|
||||
set => _allMainLocationsStrings = new List<string>(value);
|
||||
}
|
||||
private int _mainLocationIndex = -1;
|
||||
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)
|
||||
{
|
||||
dimensions.Add(null == dim ? "??" : 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 int _physicalDimensionIndex = -1;
|
||||
|
||||
private List<MMEPositions> _positions = new List<MMEPositions>();
|
||||
public MMEPositions[] AllPositions
|
||||
{
|
||||
get => _positions.ToArray();
|
||||
set
|
||||
{
|
||||
_positions = new List<MMEPositions>(value);
|
||||
AllPositionStrings = _positions.Select(pos => pos.Text_L1).ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allPositionsStrings = new List<string>();
|
||||
public string[] AllPositionStrings
|
||||
{
|
||||
get => _allPositionsStrings.ToArray();
|
||||
set => _allPositionsStrings = new List<string>(value);
|
||||
}
|
||||
private int _positionIndex = -1;
|
||||
private string _isoCode = "????????????????";
|
||||
public string ISOCode
|
||||
{
|
||||
get => _isoCode;
|
||||
set => _isoCode = value;
|
||||
}
|
||||
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 = ((App)Application.Current).IsoDb.GetTestObjectByIso(testObjects[0]);
|
||||
|
||||
|
||||
var dirs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Direction).Distinct().ToArray());
|
||||
dirs.Sort();
|
||||
var directions = dirs.Select(dir => ((App)Application.Current).IsoDb.GetDirectionByIso(dir)).ToList();
|
||||
var d = ((App)Application.Current).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 (dirs.Count == 1) { RegionDirection = ((App)Application.Current).IsoDb.GetDirectionByIso(dirs[0]); }
|
||||
else if (dirs.Count == 0) { RegionDirection = null; }
|
||||
|
||||
var fcs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Default_Filter_Class).Distinct().ToArray());
|
||||
fcs.Sort();
|
||||
var filterclasses = fcs.Select(fc => ((App)Application.Current).IsoDb.GetFilterClassByIso(fc)).ToList();
|
||||
var fc2 = ((App)Application.Current).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 = ((App)Application.Current).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(((App)Application.Current).IsoDb.GetFineLocation1ByIso(loc)); }
|
||||
var f = ((App)Application.Current).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 = ((App)Application.Current).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 = locs.Select(loc => ((App)Application.Current).IsoDb.GetFineLocation2ByIso(loc)).ToList();
|
||||
AllFineLocations2 = finelocations2.ToArray();
|
||||
var f2 = ((App)Application.Current).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 = ((App)Application.Current).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 = locs.Select(loc => ((App)Application.Current).IsoDb.GetFineLocation3ByIso(loc)).ToList();
|
||||
var f3 = ((App)Application.Current).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 = ((App)Application.Current).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 = locs.Select(loc => ((App)Application.Current).IsoDb.GetMainLocationByIso(loc)).ToList();
|
||||
var m = ((App)Application.Current).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 = ((App)Application.Current).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 = dims.Select(dim => ((App)Application.Current).IsoDb.GetPhysicalDimensionByIso(dim)).ToList();
|
||||
var pd = ((App)Application.Current).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 = ((App)Application.Current).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 = poss.Select(pos => (Application.Current as App).IsoDb.GetPositionByISO(pos)).ToList();
|
||||
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,101 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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;
|
||||
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 => _userId;
|
||||
|
||||
public enum PropertyTypes
|
||||
{
|
||||
User = 1 << 0,
|
||||
Global = 1 << 1
|
||||
}
|
||||
|
||||
protected 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();
|
||||
}
|
||||
|
||||
protected void StoreInDB()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SettingsUpdateInsert.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@PropertyId", SqlDbType.NVarChar, 255) { Value = PropertyId });
|
||||
cmd.Parameters.Add(new SqlParameter("@PropertyType", SqlDbType.Int) { Value = _propertyType });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@PropertyValue", SqlDbType.NVarChar, 255) { Value = PropertyValue });
|
||||
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.NVarChar, 255) { Value = UserId });
|
||||
var newIdParam =
|
||||
new SqlParameter("@new_id", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(newIdParam);
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) {/* APILogger.LogException(ex);*/ }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
//using DTS.Common.Base;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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 //: BasePropertyChanged
|
||||
{
|
||||
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,94 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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;
|
||||
private static readonly object LOCK_OBJECT = new object();
|
||||
|
||||
private static SettingsDB Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (LOCK_OBJECT)
|
||||
{
|
||||
return _instance ?? (_instance = new SettingsDB());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, Setting> _settingsLookup = new Dictionary<string, Setting>();
|
||||
/// <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 (LOCK_OBJECT)
|
||||
{
|
||||
if (!Instance._settingsLookup.ContainsKey(id))
|
||||
{
|
||||
Instance._settingsLookup[id] = new GlobalSetting(id, defaultValue);
|
||||
}
|
||||
return Instance._settingsLookup[id].PropertyValue;
|
||||
}
|
||||
}
|
||||
/// <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)
|
||||
{
|
||||
var sValue = GetGlobalValue(id, defaultValue.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
var b = defaultValue;
|
||||
return !bool.TryParse(sValue, out b) ? b : 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 (LOCK_OBJECT)
|
||||
{
|
||||
if (!Instance._settingsLookup.ContainsKey(id))
|
||||
{
|
||||
Instance._settingsLookup[id] = new GlobalSetting(id, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Instance._settingsLookup[id].SetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <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 (LOCK_OBJECT)
|
||||
{
|
||||
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,57 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class ZeroMethod : 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)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public ZeroMethodType Method { get; set; }
|
||||
|
||||
public double Start { get; set; }
|
||||
|
||||
public double End { get; set; }
|
||||
public ZeroMethod(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 = (ZeroMethodType)Enum.Parse(typeof(ZeroMethodType), tokens[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class ExcitationVoltageOptions
|
||||
{
|
||||
/// <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>
|
||||
/// 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 : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// returns voltage magnitude
|
||||
/// </summary>
|
||||
public double Value { get; }
|
||||
|
||||
/// <summary>
|
||||
/// constructs a <see cref="ExcitationVoltageOptions.VoltageMagnitudeAttribute" />
|
||||
/// with a given value
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public VoltageMagnitudeAttribute(double value) { Value = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class DASHardware : DbTimeStampBase, IComparable<DASHardware>, IDASHardware
|
||||
{
|
||||
/// <summary>
|
||||
/// returns whether in the UI this device should be represented as a rack even though it isn't (SLICE6Db, ECM, SLE)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsPseudoRack()
|
||||
{
|
||||
switch (GetHardwareTypeEnum())
|
||||
{
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
case HardwareTypes.SLICE6DB: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public string ParentDAS
|
||||
{
|
||||
get => _hardware.ParentDAS;
|
||||
set => _hardware.ParentDAS = value;
|
||||
}
|
||||
|
||||
public int PositionOnDistributor
|
||||
{
|
||||
get => _hardware.PositionOnDistributor;
|
||||
set => _hardware.PositionOnDistributor = value;
|
||||
}
|
||||
public int CompareTo(DASHardware right)
|
||||
{
|
||||
if (null == right) { return 1; }
|
||||
if (this == right) { return 0; }
|
||||
if (SerialNumber == right.SerialNumber)
|
||||
{
|
||||
return 0;
|
||||
|
||||
}
|
||||
//ensure that children of a das are sorted behind their parents
|
||||
if (!string.IsNullOrWhiteSpace(ParentDAS) && right.SerialNumber == ParentDAS)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(right.ParentDAS) && right.ParentDAS == SerialNumber)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(right.ParentDAS) && right.ParentDAS == ParentDAS)
|
||||
{
|
||||
if (PositionOnDistributor != right.PositionOnDistributor)
|
||||
{
|
||||
return PositionOnDistributor.CompareTo(right.PositionOnDistributor);
|
||||
}
|
||||
}
|
||||
return string.Compare(SerialNumber, right.SerialNumber, StringComparison.Ordinal);
|
||||
}
|
||||
private List<HardwareChannel> _channels = new List<HardwareChannel>();
|
||||
public HardwareChannel[] Channels
|
||||
{
|
||||
get => _channels.ToArray();
|
||||
set
|
||||
{
|
||||
var channels = new List<HardwareChannel>(value);
|
||||
channels.Sort();
|
||||
_channels = channels;
|
||||
//OnPropertyChanged(Tags.ChannelCount.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _hardware.SerialNumber;
|
||||
set => _hardware.SerialNumber = value;
|
||||
}
|
||||
|
||||
public int GetHardwareTypeInt() { return _hardware.DASType; }
|
||||
public HardwareTypes GetHardwareTypeEnum() { return (HardwareTypes)GetHardwareTypeInt(); }
|
||||
public long GetMaxMemoryLong() { return _hardware.MaxMemory; }
|
||||
public DASHardware(DASHardware copy, DASHardware parentDAS)
|
||||
{
|
||||
if (null != copy.Channels)
|
||||
{
|
||||
Channels = copy.Channels.Select(ch => new HardwareChannel(ch)).ToArray();
|
||||
}
|
||||
|
||||
_hardware = new Hardware(copy.GetHardware());
|
||||
DbTimeStamp = copy.DbTimeStamp;
|
||||
}
|
||||
public string[] LinkedDASSerials { get; set; }
|
||||
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);
|
||||
|
||||
Channels = hardware.ISOChannels.Select(channel => new HardwareChannel(channel, this)).ToArray();
|
||||
|
||||
}
|
||||
public bool IsDummy()
|
||||
{
|
||||
return SerialNumber.Contains("Dummy");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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>
|
||||
/// 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;
|
||||
|
||||
/// <summary>
|
||||
/// constructor and copy constructor
|
||||
/// </summary>
|
||||
public DigitalInputScaleMultiplier()
|
||||
{
|
||||
DefaultValue = 0D;
|
||||
}
|
||||
|
||||
public DigitalInputScaleMultiplier(DigitalInputScaleMultiplier copy)
|
||||
{
|
||||
Form = copy.Form;
|
||||
DefaultValue = copy.DefaultValue;
|
||||
ActiveValue = copy.ActiveValue;
|
||||
}
|
||||
/// <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");
|
||||
}
|
||||
|
||||
var tokens = s.Split(new[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
if (Enum.TryParse(tokens[0], out Forms form))
|
||||
{
|
||||
Form = form;
|
||||
switch (form)
|
||||
{
|
||||
case Forms.ArbitraryLowAndHigh: FromDbSerializeStringLowAndHigh(tokens); break;
|
||||
default: throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeString unsupported form " + form);
|
||||
}
|
||||
}
|
||||
else { throw new NotSupportedException("DigitalINputScaleMultiplier::FromDbSerializeString unsupported format: " + s); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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 : /*BasePropertyChanged,*/ IComparable<CustomChannel>
|
||||
{
|
||||
|
||||
// #region Properties
|
||||
public MMEPossibleChannels Channel { get; private set; }
|
||||
private MMETestObjects _testObject;
|
||||
private MMEPositions _position;
|
||||
private MMETransducerMainLocation _mainLocation;
|
||||
private MMEFineLocations1 _finLoc1;
|
||||
private MMEFineLocations2 _finLoc2;
|
||||
private MMEFineLocations3 _finLoc3;
|
||||
private MMEPhysicalDimensions _physicalDimension;
|
||||
private MMEDirections _direction;
|
||||
private MMEFilterClasses _filterClass;
|
||||
public string Text1
|
||||
{
|
||||
get => Channel.Text_L1;
|
||||
set => Channel.SetText1(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 = ((App)Application.Current).IsoDb.GetDirectionByIso(channel.Direction);
|
||||
_filterClass = ((App)Application.Current).IsoDb.GetFilterClassByIso(channel.Default_Filter_Class);
|
||||
_finLoc1 = ((App)Application.Current).IsoDb.GetFineLocation1ByIso(channel.Fine_Loc_1);
|
||||
_finLoc2 = ((App)Application.Current).IsoDb.GetFineLocation2ByIso(channel.Fine_Loc_2);
|
||||
_finLoc3 = ((App)Application.Current).IsoDb.GetFineLocation3ByIso(channel.Fine_Loc_3);
|
||||
|
||||
try { _mainLocation = ((App)Application.Current).IsoDb.GetMainLocationByIso(channel.Trans_Main_Loc); }
|
||||
catch (ISO13499FileDb.ExpiredISOFieldException ex) { _expiredErrors.Add(ex); }
|
||||
|
||||
_physicalDimension = ((App)Application.Current).IsoDb.GetPhysicalDimensionByIso(channel.Physical_Dimension);
|
||||
_position = ((App)Application.Current).IsoDb.GetPositionByISO(channel.Position);
|
||||
_testObject = ((App)Application.Current).IsoDb.GetTestObjectByIso(channel.Test_Object);
|
||||
}
|
||||
public int CompareTo(CustomChannel other)
|
||||
{
|
||||
return Equals(this, other) ? 0 : string.Compare(Text1, other.Text1, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
public class CustomChannelList //: BasePropertyChanged
|
||||
{
|
||||
private static readonly object LockObject = new object();
|
||||
private static CustomChannelList _list;
|
||||
public static CustomChannelList List
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
if (null == _list)
|
||||
{
|
||||
_list = new CustomChannelList();
|
||||
}
|
||||
}
|
||||
return _list;
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadAll()
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
List._listChannels = null;
|
||||
var app = Application.Current as App;
|
||||
if (app == null) { return; }
|
||||
app.IsoDb.RefreshAllData();
|
||||
List.PopulateChannelsIfNecessary();
|
||||
}
|
||||
}
|
||||
private Dictionary<string, CustomChannel> _dictChannels;
|
||||
private List<CustomChannel> _listChannels;
|
||||
private void PopulateChannelsIfNecessary()
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
if (null != _listChannels) return;
|
||||
_listChannels = new List<CustomChannel>();
|
||||
_dictChannels = new Dictionary<string, CustomChannel>();
|
||||
foreach (var channel in ((App)Application.Current).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();
|
||||
}
|
||||
}
|
||||
private static ISO13499FileDb _isoDb;
|
||||
public ISO13499FileDb IsoDb
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null != _isoDb) return _isoDb;
|
||||
_isoDb = new ISO13499FileDb();
|
||||
_isoDb.RefreshAllData();
|
||||
return _isoDb;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// deletes all customchannels
|
||||
/// originally created so TDM imports could clear all tables except DAS tables
|
||||
/// </summary>
|
||||
public void DeleteAll()
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
_listChannels = null;
|
||||
_dictChannels = null;
|
||||
//((App)Application.Current).IsoDb.DeleteSQL();
|
||||
IsoDb.DeleteSQL();
|
||||
//OnPropertyChanged("AllChannels");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Windows.Controls;
|
||||
using System.Xml;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ImportTestSetup.xaml
|
||||
/// this control handles importing a test setup
|
||||
/// </summary>
|
||||
public partial class ImportTestSetup : UserControl//, IPageContent, INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// sets the status (and reports an error message if necessary)
|
||||
/// thread friendly
|
||||
/// </summary>
|
||||
/// <param name="status"></param>
|
||||
/// <param name="errorMessage"></param>
|
||||
/// <summary>
|
||||
/// these structures hold any custom iso fields until import is pressed
|
||||
/// </summary>
|
||||
public static readonly List<MMEDirections> Directions = new List<MMEDirections>();
|
||||
|
||||
public static readonly List<MMEFilterClasses> FilterClasses = new List<MMEFilterClasses>();
|
||||
public static readonly List<MMEFineLocations1> FineLoc1s = new List<MMEFineLocations1>();
|
||||
public static readonly List<MMEFineLocations2> FineLoc2s = new List<MMEFineLocations2>();
|
||||
public static readonly List<MMEFineLocations3> FineLoc3s = new List<MMEFineLocations3>();
|
||||
public static readonly List<MMETransducerMainLocation> MainLocs = new List<MMETransducerMainLocation>();
|
||||
public static readonly List<MMETestObjects> TestObjects = new List<MMETestObjects>();
|
||||
public static readonly List<MMEPhysicalDimensions> PhysicalDimensions = new List<MMEPhysicalDimensions>();
|
||||
public static readonly List<MMEPositions> Positions = new List<MMEPositions>();
|
||||
private static readonly List<SensorData> _sensorsWithDuplicateIds = new List<SensorData>();
|
||||
|
||||
|
||||
private static double CurrentVersion = 2.0D;
|
||||
private static double _importedVersion;
|
||||
|
||||
private static void Cleanup()
|
||||
{
|
||||
Calibrations.Clear();
|
||||
_customChannels.Clear();
|
||||
CustomerDetails.Clear();
|
||||
LabDetails.Clear();
|
||||
_hardware.Clear();
|
||||
_testChannelOrder.Clear();
|
||||
_sensorModels.Clear();
|
||||
Sensors.Clear();
|
||||
_sensorsWithDuplicateIds.Clear();
|
||||
_groupTemplates.Clear();
|
||||
_groups.Clear();
|
||||
_testSetups.Clear();
|
||||
Directions.Clear();
|
||||
FilterClasses.Clear();
|
||||
FineLoc1s.Clear();
|
||||
FineLoc2s.Clear();
|
||||
FineLoc3s.Clear();
|
||||
MainLocs.Clear();
|
||||
TestObjects.Clear();
|
||||
PhysicalDimensions.Clear();
|
||||
Positions.Clear();
|
||||
_globalSettings.Clear();
|
||||
_users.Clear();
|
||||
}
|
||||
public static void ProcessRootNode(string name, string outerXML, DbImporter.SetStatusDelegate SetStatus)
|
||||
{
|
||||
//if (CancelCheck(SetStatus, page)) { return; }
|
||||
switch (name)
|
||||
{
|
||||
case "CustomerDetail":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportCustomerDetails.ToString(),
|
||||
"@CustomerDetails", "CustomerDetails", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "TestEngineerDetail":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportTestEngineerDetails.ToString(),
|
||||
"@TestEngineerDetails", "TestEngineerDetails", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "LabDetail":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportLabDetails.ToString(),
|
||||
"@LabDetails", "LabDetails", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "DASHardware":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportDASList.ToString(),
|
||||
"@DASList", "DASList", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "SensorModel":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportSensorModel.ToString(),
|
||||
"@SensorModel", "SensorModels", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "SensorData":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportSensors.ToString(),
|
||||
"@Sensors", "Sensors", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "SensorCalibration":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportSensorsCalibration.ToString(),
|
||||
"@SensorsCalibrations", "Calibrations", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "CustomDirection":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportMMEDirections.ToString(),
|
||||
"@MMEDirections", "CustomDirections", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "CustomTestObject":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportMMETestObjects.ToString(),
|
||||
"@MMETestObjects", "CustomTestObjects", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "FineLocation1":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportMMEFineLocations1.ToString(),
|
||||
"@MMEFineLocations1", "CustomFinLoc1s", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "FineLocation2":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportMMEFineLocations2.ToString(),
|
||||
"@MMEFineLocations2", "CustomFinLoc2s", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "FineLocation3":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportMMEFineLocations3.ToString(),
|
||||
"@MMEFineLocations3", "CustomFinLoc3s", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "TransducerMainLocation":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportMMEMainLocations.ToString(),
|
||||
"@MMEMainLocations", "CustomMainLocs", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "PhysicalDimension":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportMMEPhysicalDimensions.ToString(),
|
||||
"@MMEPhysicalDimensions", "CustomPhysicalDimensions", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "Position":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportMMEPositions.ToString(),
|
||||
"@MMEPositions", "CustomPositions", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "CustomChannel":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportMMEPossibleChannels.ToString(),
|
||||
"@MMEPossibleChannels", "CustomChannels", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "GroupTemplate":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportGroupTemplate.ToString(),
|
||||
"@GroupTemplates", "GroupTemplates", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "TestObject":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportGroup.ToString(),
|
||||
"@Groups", "Groups", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "TestSetup":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportTestSetups.ToString(),
|
||||
"@TestSetups", "TestSetups", outerXML);//, SetStatus, page);
|
||||
|
||||
////Store the compressed binary copy of the Test Setup
|
||||
//var testSetupName = GetTestSetupName(outerXML);
|
||||
//var tempTestSetup = TestTemplateList.TestTemplatesList.GetTemplate(testSetupName);
|
||||
//if (tempTestSetup.RegionsOfInterest == null)
|
||||
//{
|
||||
// tempTestSetup.RegionsOfInterest = new BindingList<IRegionOfInterest>() { new RegionOfInterest("", true, tempTestSetup.ROIStart, tempTestSetup.ROIEnd) };
|
||||
//}
|
||||
//AddCompressedTestSetupField(tempTestSetup);
|
||||
break;
|
||||
case "UIItem":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportUIItems.ToString(),
|
||||
"@UIItems", "UIItems", outerXML);
|
||||
break;
|
||||
case "User":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportUsers.ToString(),
|
||||
"@Users", "Users", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "UIItemSetting":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportUIItemSettings.ToString(),
|
||||
"@UIItemSettings", "UIItemSettings", outerXML);
|
||||
break;
|
||||
case "Setting":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportSettings.ToString(),
|
||||
"@GlobalSettings", "GlobalSettings", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "UserHardware":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportLastUsedHardware.ToString(),
|
||||
"@LastUsedHardware", "LastUsedHardware", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "Tag":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportTags.ToString(),
|
||||
"@Tags", "Tags", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "TagAssignment":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportTagAssignments.ToString(),
|
||||
"@TagAssignments", "TagAssignments", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "TemplateZone":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportTemplateZones.ToString(),
|
||||
"@TemplateZones", "TemplateZones", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "TemplateRegion":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportTemplateRegions.ToString(),
|
||||
"@TemplateRegions", "TemplateRegions", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
case "DbVersion":
|
||||
ImportElement(DbOperationsEnum.StoredProcedure.sp_DBImportDbVersions.ToString(),
|
||||
"@DbVersions", "DbVersions", outerXML);//, SetStatus, page);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private static void ImportElement(string storedProcedure, string storedProcedureParameter, string outerElementName, string outerXML)//, SetStatusDelegate setStatus, DataPROPage page)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = storedProcedure;
|
||||
cmd.CommandTimeout = 60; // 1 minute
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter(storedProcedureParameter, SqlDbType.Xml)
|
||||
{
|
||||
Value = "<" + outerElementName + ">" + outerXML + "</" + outerElementName + ">"
|
||||
});
|
||||
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
|
||||
var errorMessageParam = new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
private static string GetTestSetupName(string outerXML)
|
||||
{
|
||||
var doc = new XmlDocument();
|
||||
doc.LoadXml(outerXML);
|
||||
var testSetupName = doc.SelectSingleNode("TestSetup/Fields/SetupName")?.InnerText;
|
||||
|
||||
return testSetupName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the collection of cal histories for sensors in the import file
|
||||
/// </summary>
|
||||
public static readonly List<SensorCalibration> Calibrations = new List<SensorCalibration>();
|
||||
|
||||
private static void ImportCalibrations(XmlElement root, DbImporter.SetStatusDelegate setStatus)//, DataPROPage page)
|
||||
{
|
||||
if (_importedVersion == 2.0D)
|
||||
{
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
//if (CancelCheck(setStatus, page)) { return; }
|
||||
if (node is XmlElement)
|
||||
{
|
||||
var sc = new SensorCalibration();
|
||||
sc.ReadXML(node as XmlElement);
|
||||
Calibrations.Add(sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_importedVersion == 1.0D)
|
||||
{
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
//if (CancelCheck(setStatus, page)) { return; }
|
||||
if (node is XmlElement)
|
||||
{
|
||||
var sc = new SensorCalibration();
|
||||
sc.ReadXML(node as XmlElement);
|
||||
|
||||
sc.Records.Records[0].AtCapacity = false;
|
||||
|
||||
if (sc.NonLinear)
|
||||
{
|
||||
sc.Records.Records[0].SensitivityUnits = Test.Module.Channel.Sensor.SensUnits.NONE;
|
||||
}
|
||||
else if (sc.IsProportional)
|
||||
{
|
||||
sc.Records.Records[0].SensitivityUnits = Test.Module.Channel.Sensor.SensUnits.mVperVperEU;
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.Records.Records[0].SensitivityUnits = Test.Module.Channel.Sensor.SensUnits.mVperEU;
|
||||
}
|
||||
Calibrations.Add(sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly List<ISO.CustomerDetails> CustomerDetails = new List<ISO.CustomerDetails>();
|
||||
private static void ImportCustomerDetails(XmlElement root, DbImporter.SetStatusDelegate setStatus)//, DataPROPage page)
|
||||
{
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
//if (CancelCheck(setStatus, page)) { return; }
|
||||
if (node is XmlElement)
|
||||
{
|
||||
CustomerDetails.Add(ISO.CustomerDetails.ReadXML(node as XmlElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly List<User> _users = new List<User>();
|
||||
public static readonly List<ISO.LabratoryDetails> LabDetails = new List<ISO.LabratoryDetails>();
|
||||
private static void ImportLabDetails(XmlElement root, DbImporter.SetStatusDelegate setStatus)//, DataPROPage page)
|
||||
{
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
//if (CancelCheck(setStatus, page)) { return; }
|
||||
if (node is XmlElement)
|
||||
{
|
||||
LabDetails.Add(ISO.LabratoryDetails.ReadXML(node as XmlElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the global settings that can be imported/exported
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, string> _globalSettings = new Dictionary<string, string>();
|
||||
/// <summary>
|
||||
/// the list of custom channels in the import file
|
||||
/// </summary>
|
||||
private static readonly List<MMEPossibleChannels> _customChannels = new List<MMEPossibleChannels>();
|
||||
/// <summary>
|
||||
/// for imports that define a specific channel order in the test
|
||||
/// 9123 Test Sensor Import File CSV channel order reversed and jumbled
|
||||
/// </summary>
|
||||
private static readonly List<string> _testChannelOrder = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// the list of hardare in the import file
|
||||
/// </summary>
|
||||
private static readonly List<DASHardware> _hardware = new List<DASHardware>();
|
||||
/// <summary>
|
||||
/// the list of groups in the import file
|
||||
/// </summary>
|
||||
private static readonly List<TestObject> _groups = new List<TestObject>();
|
||||
/// <summary>
|
||||
/// the list of group templates in the import file
|
||||
/// </summary>
|
||||
private static readonly List<TestObjectTemplate> _groupTemplates = new List<TestObjectTemplate>();
|
||||
/// <summary>
|
||||
/// the list of sensor models in the import file
|
||||
/// </summary>
|
||||
private static readonly List<SensorModel> _sensorModels = new List<SensorModel>();
|
||||
/// <summary>
|
||||
/// the list of sensors in the import file
|
||||
/// </summary>
|
||||
public static readonly List<SensorData> Sensors = new List<SensorData>();
|
||||
/// <summary>
|
||||
/// the list of test setups in the import file
|
||||
/// </summary>
|
||||
public static List<TestTemplate> _testSetups = new List<TestTemplate>();
|
||||
/// <summary>
|
||||
/// all possible status for UI
|
||||
/// </summary>
|
||||
public enum PossibleStatus
|
||||
{
|
||||
Waiting,
|
||||
Working,
|
||||
Done,
|
||||
Failed
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class WaitCursor : IDisposable
|
||||
{
|
||||
private Cursor _previousCursor;
|
||||
|
||||
public WaitCursor()
|
||||
{
|
||||
_previousCursor = Mouse.OverrideCursor;
|
||||
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
}
|
||||
|
||||
// #region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Mouse.OverrideCursor = _previousCursor;
|
||||
}
|
||||
|
||||
// #endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,544 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseImport.ISO
|
||||
{
|
||||
public class TestObject : IComparable
|
||||
{
|
||||
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 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; }
|
||||
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 = TestObjectTemplate.GetTemplate(ref db, Template);
|
||||
SetTemplate(template);
|
||||
}
|
||||
public void SetTemplate(TestObjectTemplate template)
|
||||
{
|
||||
_allChannels.Clear();
|
||||
if (null == template) return;
|
||||
Template = template.TemplateName;
|
||||
AllChannels = template.Channels.Select(c => new TestObjectChannel(c, this, template)).ToArray();
|
||||
}
|
||||
|
||||
public bool LocalOnly { get; set; }
|
||||
|
||||
public string LastModifiedBy { get; set; }
|
||||
|
||||
public DateTime LastModified { get; set; }
|
||||
private TestObject(DataRow dr, ref ISO13499FileDb db)
|
||||
{
|
||||
OriginalTemplate = "";
|
||||
OriginalSerialNumber = "";
|
||||
SerialNumberConverted = string.Empty;
|
||||
TestObjectData(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 TestObjectData(DataRow dr, ref ISO13499FileDb db)
|
||||
{
|
||||
SerialNumber = (string)dr["TestObjectName"];
|
||||
LocalOnly = Convert.ToBoolean(dr["LocalOnly"]);
|
||||
SetTemplate((string)dr["TemplateName"], 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 cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TestObjectChannelSettingsGet.ToString();
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TestObjectName", SqlDbType.NVarChar, 255) { Value = SerialNumber });
|
||||
cmd.Parameters.Add(new SqlParameter("@ChannelId", SqlDbType.NVarChar, 255) { Value = null });
|
||||
cmd.Parameters.Add(new SqlParameter("@Setting", SqlDbType.NVarChar, 255) { Value = null });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@SensorSerialNumber", SqlDbType.NVarChar, 255) { Value = null });
|
||||
//cmd.ExecuteNonQuery();
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
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.SerialNumber.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
using (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>>();
|
||||
}
|
||||
using (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>();
|
||||
}
|
||||
using (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 cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TestObjectHardwareIdsGet.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TestObjectName", SqlDbType.NVarChar, 255) { Value = SerialNumber });
|
||||
|
||||
#endregion params
|
||||
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
var ids = new List<string>();
|
||||
while (reader.Read())
|
||||
{
|
||||
var id = (string)reader["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;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
var channelLookup = AllChannels.ToDictionary(ch => ch.GetId());
|
||||
var dasIdToSerialNumber = new Dictionary<int, string>();
|
||||
var dasIdToDasType = new Dictionary<int, int>();
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_DASGet.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@SerialNumber", SqlDbType.NVarChar) { Value = null });
|
||||
cmd.Parameters.Add(new SqlParameter("@position", SqlDbType.NVarChar) { Value = null });
|
||||
|
||||
#endregion params
|
||||
|
||||
using (var readerDAS = cmd.ExecuteReader())
|
||||
{
|
||||
while (readerDAS.Read())
|
||||
{
|
||||
var dasId = Convert.ToInt32(readerDAS["DASId"]);
|
||||
var serialNumber = Convert.ToString(readerDAS["SerialNumber"]);
|
||||
var iType = Convert.ToInt32(readerDAS["Type"]);
|
||||
dasIdToDasType[dasId] = iType;
|
||||
dasIdToSerialNumber[dasId] = serialNumber;
|
||||
}
|
||||
readerDAS.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TestObjectSensorsGet.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TestObjectName", SqlDbType.NVarChar, 255) { Value = SerialNumber });
|
||||
|
||||
#endregion params
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (null != ds && ds.Tables.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var id = Convert.ToString(dr[0]);
|
||||
if (!channelLookup.ContainsKey(id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var sensorId = "";
|
||||
var channelIdx = -1;
|
||||
if (!DBNull.Value.Equals(dr["ChannelIdx"]))
|
||||
{
|
||||
channelIdx = Convert.ToInt32(dr["ChannelIdx"]);
|
||||
}
|
||||
if (!DBNull.Value.Equals(dr["SensorId"]))
|
||||
{
|
||||
sensorId = Convert.ToString(dr["SensorId"]);
|
||||
}
|
||||
var hardwareId = "";
|
||||
var dasId = Convert.ToInt32(dr["DasId"]);
|
||||
var dasChannelId = Convert.ToInt32(dr["DasChannelId"]);
|
||||
if (dasIdToSerialNumber.ContainsKey(dasId))
|
||||
{
|
||||
hardwareId = $"{dasIdToSerialNumber[dasId]}_{dasIdToDasType[dasId]}x{dasChannelId}";
|
||||
}
|
||||
channelLookup[id].SensorSerialNumber = sensorId;
|
||||
channelLookup[id].HardwareId = hardwareId;
|
||||
channelLookup[id].ChannelIdx = channelIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
SortChannels();
|
||||
}
|
||||
public static void DeleteAllTestObjects()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TestObjectsDelete.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@TestObjectId", SqlDbType.Int) { Value = 0 });
|
||||
cmd.Parameters.Add(new SqlParameter("@TestObjectName", SqlDbType.NVarChar, 50) { Value = null });
|
||||
|
||||
#region Output
|
||||
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion Output
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
var error = int.Parse(errorNumberParam.Value.ToString());
|
||||
if (error != 0)
|
||||
{
|
||||
var message = int.Parse(errorNumberParam.Value.ToString());
|
||||
var state = int.Parse(errorNumberParam.Value.ToString());
|
||||
//APILogger.Log(
|
||||
// $"Error:{Convert.ToString(error)}, State:{Convert.ToString(state)} Error: {message}");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to delete test objects", ex);*/ }
|
||||
}
|
||||
public static TestObject GetTestObject(string serialNumber, ref ISO13499FileDb db, bool sysBuiltValue)
|
||||
{
|
||||
TestObject testObject = null;
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TestObjectsGet.ToString();
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TestObjectName", SqlDbType.NVarChar, 255) { Value = serialNumber });
|
||||
cmd.Parameters.Add(new SqlParameter("@TemplateName", SqlDbType.NVarChar, 255) { Value = null });
|
||||
cmd.Parameters.Add(new SqlParameter("@SysBuilt", SqlDbType.Bit) { Value = sysBuiltValue });
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
testObject = new TestObject(ds.Tables[0].Rows[0], ref db);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve test objects", ex);*/ }
|
||||
testObject?.GetHardwareAndSensors();
|
||||
return testObject;
|
||||
}
|
||||
private static int CompareTestObject(TestObject left, TestObject right)
|
||||
{
|
||||
if (left == right) { return 0; }
|
||||
if (null == left) { return -1; }
|
||||
return null == right ? 1 : string.Compare(left.SerialNumber, right.SerialNumber, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public int CompareTo(object o)
|
||||
{
|
||||
if (o is TestObject testObject)
|
||||
{
|
||||
return CompareTestObject(this, testObject);
|
||||
}
|
||||
throw new ArgumentException($"object {o} is not the same type as this instance (TestObject)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="DatabaseImport.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="DownloadFolder" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">..\Data</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="RequireXCrashCompatibilityForISOExports" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
private static ISO13499FileDb _isoDb;
|
||||
public ISO13499FileDb IsoDb
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null != _isoDb) return _isoDb;
|
||||
_isoDb = new ISO13499FileDb();
|
||||
_isoDb.RefreshAllData();
|
||||
return _isoDb;
|
||||
}
|
||||
}
|
||||
// Delegate for SetAppBusy and SetAppAvailable
|
||||
private delegate void SetAppBusyAvailableDelegate();
|
||||
|
||||
// WaitCursor for SetAppBusy and SetAppAvailable
|
||||
private WaitCursor _wc;
|
||||
|
||||
private static readonly object WaitCursorLock = new object();
|
||||
// // Apply WaitCursor and disable application
|
||||
// // recommend use before a try statement
|
||||
public void SetAppBusy()
|
||||
{
|
||||
//Can We access
|
||||
if (!Dispatcher.CheckAccess())
|
||||
{
|
||||
Dispatcher.BeginInvoke(new SetAppBusyAvailableDelegate(SetAppBusy));
|
||||
return;
|
||||
}
|
||||
if (null == MainWindow) return;
|
||||
lock (WaitCursorLock)
|
||||
{
|
||||
if (null != _wc) { _wc.Dispose(); }
|
||||
//Init WaitCursor
|
||||
_wc = new WaitCursor();
|
||||
//Enable App
|
||||
MainWindow.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply normal cursor and enable application
|
||||
// recommend use in a finally statement
|
||||
public void SetAppAvailable()
|
||||
{
|
||||
//Can We access
|
||||
if (!Dispatcher.CheckAccess())
|
||||
{
|
||||
Dispatcher.BeginInvoke(new SetAppBusyAvailableDelegate(SetAppAvailable));
|
||||
return;
|
||||
}
|
||||
if (null == MainWindow) return;
|
||||
lock (WaitCursorLock)
|
||||
{
|
||||
//Dispose WaitCursor
|
||||
if (null != _wc) { _wc.Dispose(); _wc = null; }
|
||||
|
||||
//Enable App
|
||||
MainWindow.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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; }
|
||||
|
||||
public bool LessThanEnabled { get; set; }
|
||||
|
||||
public bool TriggerBetweenBounds { get; set; }
|
||||
|
||||
public bool TriggerOutsideBounds { get; set; }
|
||||
|
||||
public double InsideUpperLevelEU { get; set; }
|
||||
|
||||
public double InsideLowerLevelEU { get; set; }
|
||||
|
||||
public double OutsideUpperLevelEU { get; set; }
|
||||
|
||||
public double OutsideLowerLevelEU { get; set; }
|
||||
|
||||
public double LessThanThresholdEU { get; set; }
|
||||
|
||||
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)
|
||||
{
|
||||
try
|
||||
{
|
||||
GreaterThanEnabled = Convert.ToBoolean(dr[DbOperations.LevelTriggers.Fields.GreaterThanEnabled.ToString()]);
|
||||
GreaterThanThresholdEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.GreaterThanEU.ToString()]);
|
||||
GroupSerialNumber = Convert.ToString(dr[DbOperations.LevelTriggers.Fields.TestObjectName.ToString()]);
|
||||
HardwareChannelId = Convert.ToString(dr[DbOperations.LevelTriggers.Fields.HardwareChannelId.ToString()]);
|
||||
LessThanEnabled = Convert.ToBoolean(dr[DbOperations.LevelTriggers.Fields.LessThanEnabled.ToString()]);
|
||||
LessThanThresholdEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.LessThanEU.ToString()]);
|
||||
SensorSerialNumber = Convert.ToString(dr[DbOperations.LevelTriggers.Fields.SensorSerialNumber.ToString()]);
|
||||
TestObjectChannelId = Convert.ToString(dr[DbOperations.LevelTriggers.Fields.TestObjectChannelId.ToString()]);
|
||||
TestSetupName = Convert.ToString(dr[DbOperations.LevelTriggers.Fields.TestSetupName.ToString()]);
|
||||
TriggerBetweenBounds = Convert.ToBoolean(dr[DbOperations.LevelTriggers.Fields.TriggerInside.ToString()]);
|
||||
TriggerOutsideBounds = Convert.ToBoolean(dr[DbOperations.LevelTriggers.Fields.TriggerOutside.ToString()]);
|
||||
OutsideUpperLevelEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.OutsideUpperEU.ToString()]);
|
||||
OutsideLowerLevelEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.OutsideLowerEU.ToString()]);
|
||||
InsideUpperLevelEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.InsideUpperEU.ToString()]);
|
||||
InsideLowerLevelEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.InsideLowerEU.ToString()]);
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log(ex);*/ }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// these are the different input modes for the data
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
|
||||
public enum DigitalInputModes
|
||||
{
|
||||
[DescriptionAttribute("Transition low to high")]
|
||||
TLH = 1 << 1, //Transition Low to High
|
||||
[DescriptionAttribute("Transition high to low")]
|
||||
THL = 1 << 2, //Transition High to Low
|
||||
[DescriptionAttribute("Contact closure normally open")]
|
||||
CCNO = 1 << 3, //set to contact closure normally open
|
||||
[DescriptionAttribute("Contact closure normally closed")]
|
||||
CCNC = 1 << 4 //set to contact closure normally closed
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TestEngineerDetails //: BasePropertyChanged
|
||||
{
|
||||
private ISO.TestEngineerDetails _testEngineerDetails;
|
||||
public string Name
|
||||
{
|
||||
get => _testEngineerDetails.Name;
|
||||
set => _testEngineerDetails.Name = value;
|
||||
}
|
||||
public TestEngineerDetails()
|
||||
{
|
||||
_testEngineerDetails = new ISO.TestEngineerDetails();
|
||||
_testEngineerDetails.Name = "(none)";
|
||||
}
|
||||
public TestEngineerDetails(ISO.TestEngineerDetails testEngineerDetails)
|
||||
{
|
||||
_testEngineerDetails = new ISO.TestEngineerDetails(testEngineerDetails);
|
||||
}
|
||||
}
|
||||
public class TestEngineerDetailsList //: BasePropertyChanged
|
||||
{
|
||||
private static TestEngineerDetailsList _testEngineerList = new TestEngineerDetailsList();
|
||||
public static TestEngineerDetailsList TestEngineerList => _testEngineerList;
|
||||
private static object _testEngineerLock = new object();
|
||||
private static Dictionary<string, TestEngineerDetails> _testEngineers = null;
|
||||
private void PopulateEngineers()
|
||||
{
|
||||
_testEngineers = new Dictionary<string, TestEngineerDetails>();
|
||||
foreach (var t in _testEngineerList.GetAllTestEngineers())
|
||||
{
|
||||
if (!_testEngineers.ContainsKey(t.Name)) { _testEngineers.Add(t.Name, t); }
|
||||
}
|
||||
}
|
||||
public void ReloadAll()
|
||||
{
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
PopulateEngineers();
|
||||
}
|
||||
}
|
||||
public static void DeleteAll()
|
||||
{
|
||||
_testEngineers = null;
|
||||
ISO.TestEngineerDetails.DeleteAllTestEngineerDetails();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class Zone //: BasePropertyChanged
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public string Image { get; set; }
|
||||
|
||||
private readonly TestObjectTemplate _template;
|
||||
public TemplateZone ISODllZone { get; }
|
||||
|
||||
public Zone(Zone copy, TestObjectTemplate template)
|
||||
{
|
||||
ISODllZone = copy.ISODllZone;
|
||||
_template = template;
|
||||
Description = ISODllZone?.Description ?? "";
|
||||
Image = ISODllZone?.Picture;
|
||||
_fileNames = new List<System.IO.FileInfo>();
|
||||
PopulateFilenamesIfNeeded();
|
||||
PictureIndex = copy.PictureIndex;
|
||||
PictureSource = copy.PictureSource;
|
||||
Name = ISODllZone.ZoneName;
|
||||
_regions = new List<Region>(copy.Regions);
|
||||
}
|
||||
public Zone(TemplateZone z, TestObjectTemplate template)
|
||||
{
|
||||
ISODllZone = z;
|
||||
_template = template;
|
||||
|
||||
Description = z?.Description ?? "";
|
||||
Image = z?.Picture;
|
||||
var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZonePictures");
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (z != null)
|
||||
{
|
||||
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; }
|
||||
return right == null ? 1 : string.Compare(left.FullName, right.FullName, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
private List<System.IO.FileInfo> _fileNames;
|
||||
private static object MyLock = new object();
|
||||
public string[] AllPictures
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
PopulateFilenamesIfNeeded();
|
||||
return _fileNames.Select(fi => fi.Name).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PopulateFilenamesIfNeeded()
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (null == _fileNames || _fileNames.Count == 0)
|
||||
{
|
||||
PopulateFilenames();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void PopulateFilenames()
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
private int _pictureIndex = -1;
|
||||
public int PictureIndex
|
||||
{
|
||||
get => _pictureIndex;
|
||||
set
|
||||
{
|
||||
if (value < 0) { PictureSource = null; }
|
||||
else
|
||||
{
|
||||
var src = new System.Windows.Media.Imaging.BitmapImage();
|
||||
lock (MyLock)
|
||||
{
|
||||
PopulateFilenamesIfNeeded();
|
||||
src.BeginInit();
|
||||
src.UriSource = new Uri(_fileNames[value].FullName, UriKind.Absolute);
|
||||
src.EndInit();
|
||||
}
|
||||
PictureSource = src;
|
||||
}
|
||||
_pictureIndex = value;
|
||||
}
|
||||
}
|
||||
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,160 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class FilterClass : 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));
|
||||
}
|
||||
}
|
||||
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 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 Exception("FilterClass.ToString: Invalid class=" + FClass.ToString());
|
||||
}
|
||||
|
||||
public FilterClass(string fclass)
|
||||
{
|
||||
int fc;
|
||||
if (int.TryParse(fclass, NumberStyles.Any, 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,62 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TestObjectTemplateCollection //: BasePropertyChanged
|
||||
{
|
||||
private static volatile TestObjectTemplateCollection _testObjectCollection;
|
||||
public static TestObjectTemplateCollection TemplateCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == _testObjectCollection)
|
||||
{
|
||||
_testObjectCollection = new TestObjectTemplateCollection();
|
||||
}
|
||||
return _testObjectCollection;
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadAll(bool loadSubComponents)
|
||||
{
|
||||
//UnloadAll();
|
||||
//if (loadSubComponents)
|
||||
//{
|
||||
// (App.Current as App).IsoDb.RefreshAllData();
|
||||
// DataModel.CustomChannelList.List.ReloadAll();
|
||||
//}
|
||||
//Reload();
|
||||
}
|
||||
private static volatile TestObjectTemplate _sysBuiltTestObjectTemplate;
|
||||
public TestObjectTemplate SysBuiltTestObjectTemplate => _sysBuiltTestObjectTemplate;
|
||||
|
||||
public TestObjectTemplate GetTemplate(string templateId)
|
||||
{
|
||||
var db = ((App)Application.Current).IsoDb;
|
||||
var isoTemplate = ISO.TestObjectTemplate.GetTemplate(ref db, templateId);
|
||||
return null != isoTemplate ? new TestObjectTemplate(isoTemplate, ref db) : null;
|
||||
}
|
||||
/// <summary>
|
||||
/// deletes all test objects
|
||||
/// originally created so TDM imports could clear all tables
|
||||
/// </summary>
|
||||
public static void DeleteAll()
|
||||
{
|
||||
//if (TemplateCollection._bUnloaded) { Reload(); }
|
||||
_testObjectCollection.DeleteAllTemplates();
|
||||
_testObjectCollection = new TestObjectTemplateCollection();
|
||||
TemplateCollection.DeleteAllTemplates();
|
||||
//TemplateCollection._templates.Clear();
|
||||
}
|
||||
private void DeleteAllTemplates()
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (_bUnloaded) { Reload(); }
|
||||
ISO.TestObjectTemplate.DeleteAllTemplates();
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to delete all templates"); */}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport.ISO
|
||||
{
|
||||
public class HardwareChannel : INotifyPropertyChanged
|
||||
{
|
||||
#region IPropertyNotified
|
||||
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)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
#endregion
|
||||
|
||||
private Hardware _parentHardware;
|
||||
public Hardware ParentDAS
|
||||
{
|
||||
get => _parentHardware;
|
||||
set => SetProperty(ref _parentHardware, value, "ParentDAS");
|
||||
}
|
||||
|
||||
private int _supportedBridges = 12;
|
||||
public int SupportedBridges
|
||||
{
|
||||
get => _supportedBridges;
|
||||
set => SetProperty(ref _supportedBridges, value, "SupportedBridges");
|
||||
}
|
||||
|
||||
private int _supportedSquibFireModes = 16;
|
||||
public int SupportedSquibFireModes
|
||||
{
|
||||
get => _supportedSquibFireModes;
|
||||
set => SetProperty(ref _supportedSquibFireModes, value, "SupportedSquibFireModes");
|
||||
}
|
||||
|
||||
private int _supporedExcitations = 16;
|
||||
public int SupportedExcitations
|
||||
{
|
||||
get => _supporedExcitations;
|
||||
set => SetProperty(ref _supporedExcitations, value, "SupportedExcitations");
|
||||
}
|
||||
|
||||
private int _supportedDigitalInputModes = 16;
|
||||
public int SupportedDigitalInputModes
|
||||
{
|
||||
get => _supportedDigitalInputModes;
|
||||
set => SetProperty(ref _supportedDigitalInputModes, value, "SupportedDigitalInputModes");
|
||||
}
|
||||
|
||||
private int _supportedDigitalOutputModes = 16;
|
||||
public int SupportedDigitalOutputModes
|
||||
{
|
||||
get => _supportedDigitalOutputModes;
|
||||
set => SetProperty(ref _supportedDigitalOutputModes, value, "SupportedDigitalOutputModes");
|
||||
}
|
||||
|
||||
private int _channelIdx;
|
||||
public int ChannelIdx
|
||||
{
|
||||
get => _channelIdx;
|
||||
set => SetProperty(ref _channelIdx, value, "ChannelIdx");
|
||||
}
|
||||
|
||||
private int _dasDisplayOrder;
|
||||
public int DASDisplayOrder
|
||||
{
|
||||
get => _dasDisplayOrder;
|
||||
set => _dasDisplayOrder = value;
|
||||
}
|
||||
|
||||
private string _moduleSerialNumber = "";
|
||||
public string ModuleSerialNumber
|
||||
{
|
||||
get => _moduleSerialNumber;
|
||||
set => SetProperty(ref _moduleSerialNumber, value, "ModuleSerialNumber");
|
||||
}
|
||||
|
||||
private int _moduleArrayIndex;
|
||||
public int ModuleArrayIndex
|
||||
{
|
||||
get => _moduleArrayIndex;
|
||||
set => _moduleArrayIndex = value;
|
||||
}
|
||||
|
||||
// public HardwareChannel() { }
|
||||
public HardwareChannel(HardwareChannel 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 HardwareChannel(IDataRecord reader, Hardware hardware)
|
||||
{
|
||||
ParentDAS = hardware;
|
||||
|
||||
ChannelIdx = Convert.ToInt32(reader[DbOperations.DAS.DASChannelFields.ChannelIdx.ToString()]);
|
||||
SupportedBridges = Convert.ToInt32(reader[DbOperations.DAS.DASChannelFields.SupportedBridges.ToString()]);
|
||||
SupportedExcitations = Convert.ToInt32(reader[DbOperations.DAS.DASChannelFields.SupportedExcitations.ToString()]);
|
||||
SupportedDigitalInputModes = Convert.ToInt32(reader[DbOperations.DAS.DASChannelFields.SupportedDigitalInputModes.ToString()]);
|
||||
SupportedDigitalOutputModes = Convert.ToInt32(reader[DbOperations.DAS.DASChannelFields.SupportedDigitalOutputModes.ToString()]);
|
||||
SupportedSquibFireModes = Convert.ToInt32(reader[DbOperations.DAS.DASChannelFields.SupportedSquibFireModes.ToString()]);
|
||||
DASDisplayOrder = Convert.ToInt32(reader[DbOperations.DAS.DASChannelFields.DASDisplayOrder.ToString()]);
|
||||
ModuleSerialNumber = reader[DbOperations.DAS.DASChannelFields.ModuleSerialNumber.ToString()] as string;
|
||||
LocalOnly = Convert.ToBoolean(reader[DbOperations.DAS.DASChannelFields.LocalOnly.ToString()]);
|
||||
ModuleArrayIndex = Convert.ToInt32(reader[DbOperations.DAS.DASChannelFields.ModuleArrayIndex.ToString()]);
|
||||
|
||||
}
|
||||
private bool _bLocalOnly;
|
||||
public bool LocalOnly
|
||||
{
|
||||
get => _bLocalOnly;
|
||||
set => SetProperty(ref _bLocalOnly, value, "LocalOnly");
|
||||
}
|
||||
|
||||
public static int PhysicalCompare(HardwareChannel left, HardwareChannel right)
|
||||
{
|
||||
if (left == right) { return 0; }
|
||||
if (null == left) { return -1; }
|
||||
return null == right ? 1 : left.ChannelIdx.CompareTo(right.ChannelIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
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;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class RegionAdorner : Adorner, 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)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
public Point GetUpperLeft()
|
||||
{
|
||||
var p = SelectRect.TopLeft;
|
||||
|
||||
var image = AdornedElement as Image;
|
||||
if (null == image) { return p; }
|
||||
|
||||
var s = new Size(image.Source.Width, image.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;
|
||||
|
||||
if (!(AdornedElement is Image image)) { return p; }
|
||||
if (null == image.Source) { return new Point(0, 0); }
|
||||
var s = new Size(image.Source.Width, image.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
|
||||
{
|
||||
SetProperty(ref _bNew, value, "IsNew");
|
||||
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 => SetProperty(ref _anchorPoint, value, "AnchorPoint");
|
||||
}
|
||||
private readonly UIElement _adornedElement;
|
||||
private readonly Path _path;
|
||||
private Rect _selectRect;
|
||||
public Rect SelectRect
|
||||
{
|
||||
get => _selectRect;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _selectRect, value, "SelectRect");
|
||||
MyRegion.RegionUpperLeft = GetUpperLeft();
|
||||
MyRegion.RegionBottomRight = GetLowerRight();
|
||||
}
|
||||
}
|
||||
private readonly RectangleGeometry _geometry;
|
||||
|
||||
private Region _region;
|
||||
public Region MyRegion
|
||||
{
|
||||
get => _region;
|
||||
set => SetProperty(ref _region, value, "MyRegion");
|
||||
}
|
||||
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 += Region_MouseLeftButtonUp;
|
||||
MouseMove += Region_MouseMove;
|
||||
MouseLeftButtonDown += Region_MouseLeftButtonDown;
|
||||
_MeasuredSize = adornedElement.RenderSize;
|
||||
//_region.PropertyChanged += _region_PropertyChanged;
|
||||
Context = context;
|
||||
}
|
||||
private void Region_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
EndSelection(sender, e);
|
||||
}
|
||||
|
||||
public enum Contexts { EditTestObject, EditTestObjectTemplate };
|
||||
private Contexts _context;
|
||||
public Contexts Context
|
||||
{
|
||||
get => _context;
|
||||
set => SetProperty(ref _context, value, "Context");
|
||||
}
|
||||
|
||||
void Region_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
OnRegionSelected?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private Size _MeasuredSize { get; set; }
|
||||
|
||||
private Point p1;
|
||||
|
||||
public void Region_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton != MouseButtonState.Pressed) return;
|
||||
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) return;
|
||||
var mousePosition = e.GetPosition(adornedElement);
|
||||
var r = SelectRect;
|
||||
r.X = mousePosition.X < AnchorPoint.X ? mousePosition.X : AnchorPoint.X;
|
||||
r.Y = mousePosition.Y < AnchorPoint.Y ? mousePosition.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) return;
|
||||
var mousePosition = e.GetPosition(adornedElement);
|
||||
var r = SelectRect;
|
||||
r.X -= p1.X - mousePosition.X;
|
||||
r.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();
|
||||
OnEndSelection?.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <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 DatabaseImport.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.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("..\\Data")]
|
||||
public string DownloadFolder {
|
||||
get {
|
||||
return ((string)(this["DownloadFolder"]));
|
||||
}
|
||||
}
|
||||
|
||||
[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.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool RequireXCrashCompatibilityForISOExports {
|
||||
get {
|
||||
return ((bool)(this["RequireXCrashCompatibilityForISOExports"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport.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
|
||||
{
|
||||
/// <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["TestObjectName"];
|
||||
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) { /*APILogger.Log(ex);*/ }
|
||||
}
|
||||
var failedToLoadChannels = 0;
|
||||
try
|
||||
{
|
||||
|
||||
var channelList = LoadExistingChannels(ref db);
|
||||
foreach (var ch in channelList)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ch.Required) continue;
|
||||
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)
|
||||
{
|
||||
//APILogger.Log("Failed to retrieve Template channel", ex);
|
||||
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);
|
||||
//APILogger.Log("failed to retrieve template channels, ", TemplateName, ex);
|
||||
}
|
||||
Channels = channels.ToArray();
|
||||
if (failedToLoadChannels > 0)
|
||||
{
|
||||
errors.Add($"Failed to load {failedToLoadChannels:N0} channel(s) from template {TemplateNameOrOriginalTemplateName}");
|
||||
}
|
||||
|
||||
var zones = new List<TemplateZone>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TemplateZonesGet.ToString();
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TemplateName", SqlDbType.NVarChar) { Value = TemplateName });
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
zones.Add(new TemplateZone(ds.Tables[0].Rows[0]));
|
||||
//zones.AddRange(from DataRow dr in ds.Tables[0].Rows select new TemplateZone(dr));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*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 (copy?.TemplateName != null)
|
||||
{
|
||||
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[$"{c.Channel.Id}x{c.Channel.MMEChannelType}"] = true;
|
||||
}
|
||||
var possibleChannels = db.GetPossibleChannelsForType(TestObjectType);
|
||||
foreach (var pc in possibleChannels)
|
||||
{
|
||||
var key = $"{pc.Id}x{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();
|
||||
}
|
||||
private List<TestObjectTemplateChannel> LoadExistingChannels(ref ISO13499FileDb db)
|
||||
{
|
||||
var existingChannels = new List<TestObjectTemplateChannel>();
|
||||
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TemplateChannelsGet.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TemplateName", SqlDbType.NVarChar, 50) { Value = TemplateName });
|
||||
|
||||
#endregion params
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) return existingChannels;
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
existingChannels.Add(new TestObjectTemplateChannel(dr, this, ref db));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
return existingChannels;
|
||||
}
|
||||
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 cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TestObjectTemplatesGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@TemplateName", SqlDbType.NVarChar) { Value = name });
|
||||
cmd.Parameters.Add(new SqlParameter("@SysBuilt", SqlDbType.NVarChar) { Value = null });
|
||||
|
||||
//cmd.ExecuteNonQuery();
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
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)
|
||||
{
|
||||
//APILogger.Log("Failed to retrieve template", ex2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to get all templates", ex);*/ }
|
||||
|
||||
return templates.Count > 0 ? templates[0] : null;
|
||||
}
|
||||
public static void DeleteAllTemplates(string templateName = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TestObjectTemplatesDelete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@TemplateName", SqlDbType.NVarChar)
|
||||
{
|
||||
Value = String.IsNullOrEmpty(templateName) ? null : templateName
|
||||
});
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("Failed to delete template:", templateName, ex);*/ throw; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class SensorCalibration : IComparable<SensorCalibration>, INotifyPropertyChanged, ISensorCalibration
|
||||
{
|
||||
public long CalVersion { get; set; } = long.MinValue;
|
||||
|
||||
public InitialOffset InitialOffset { get; set; } = new InitialOffset();
|
||||
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)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
private bool _nonLinear;
|
||||
public bool NonLinear
|
||||
{
|
||||
get => _nonLinear;
|
||||
set
|
||||
{
|
||||
_nonLinear = value;
|
||||
if (!value) return;
|
||||
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 = ExcitationVoltageOptions.ExcitationVoltageOption.Volt5;
|
||||
sc.ZeroMethod = new ZeroMethod(ZeroMethodType.None, 0, 0);
|
||||
return sc;
|
||||
}
|
||||
public static SensorCalibration GetLatestCalibrationBySerialNumberAndExcitation(SensorData sd, ExcitationVoltageOptions.ExcitationVoltageOption exc)
|
||||
{
|
||||
return SensorCalibrationList.GetLatestCalibrationBySerialNumberAndExcitation(sd, exc);
|
||||
}
|
||||
private string _serialNumber = "";
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _serialNumber;
|
||||
set => SetProperty(ref _serialNumber, value, "SerialNumber");
|
||||
}
|
||||
|
||||
private DateTime _calibrationDate; // these two are the keys
|
||||
public DateTime CalibrationDate
|
||||
{
|
||||
get => _calibrationDate;
|
||||
set => SetProperty(ref _calibrationDate, value, "CalibrationDate");
|
||||
}
|
||||
private string _username = "";
|
||||
public string Username
|
||||
{
|
||||
get => _username ?? string.Empty;
|
||||
set => SetProperty(ref _username, value, "Username");
|
||||
}
|
||||
private CalibrationRecords _records = new CalibrationRecords();
|
||||
public CalibrationRecords Records
|
||||
{
|
||||
get => _records;
|
||||
set => _records = value;
|
||||
}
|
||||
|
||||
private DateTime _modifyDate;
|
||||
public DateTime ModifyDate
|
||||
{
|
||||
get => _modifyDate;
|
||||
set => _modifyDate = value;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static int DefaultZeroMethod = 0;
|
||||
|
||||
private ZeroMethod _zeroMethod;
|
||||
public ZeroMethod ZeroMethod
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == _zeroMethod)
|
||||
{
|
||||
_zeroMethod = new ZeroMethod((ZeroMethodType)DefaultZeroMethod, -.05, -.02);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (NonLinear)
|
||||
{
|
||||
switch (Records.Records[0].Poly.NonLinearStyle)
|
||||
{
|
||||
case NonLinearStyles.IRTraccAverageOverTime: _zeroMethod.Method = ZeroMethodType.AverageOverTime; break;
|
||||
case NonLinearStyles.IRTraccDiagnosticsZero: _zeroMethod.Method = ZeroMethodType.UsePreEventDiagnosticsZero; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log(ex);*/ }
|
||||
return _zeroMethod;
|
||||
}
|
||||
set => _zeroMethod = value;
|
||||
}
|
||||
|
||||
public bool LocalOnly { get; set; }
|
||||
public SensorCalibration()
|
||||
{
|
||||
if (!NonLinear) return;
|
||||
Records.Records[0].Sensitivity = 1D;
|
||||
IsProportional = false;
|
||||
RemoveOffset = false;
|
||||
}
|
||||
public SensorCalibration(string s)
|
||||
{
|
||||
FromSerializedString(s);
|
||||
if (!NonLinear) return;
|
||||
Records.Records[0].Sensitivity = 1D;
|
||||
IsProportional = false;
|
||||
RemoveOffset = false;
|
||||
}
|
||||
public SensorCalibration(DataRow dr)
|
||||
{
|
||||
try
|
||||
{
|
||||
CalibrationDate = Convert.ToDateTime(dr[DbOperations.SensorDB.SensorCalibrationFields.CalibrationDate.ToString()]);
|
||||
LocalOnly = Convert.ToBoolean(dr[DbOperations.SensorDB.SensorCalibrationFields.LocalOnly.ToString()]);
|
||||
SerialNumber = (string)dr[DbOperations.SensorDB.SensorCalibrationFields.SerialNumber.ToString()];
|
||||
Username = (string)dr[DbOperations.SensorDB.SensorCalibrationFields.Username.ToString()];
|
||||
Records = new CalibrationRecords((string)dr[DbOperations.SensorDB.SensorCalibrationFields.CalibrationRecords.ToString()]);
|
||||
IsProportional = Convert.ToBoolean(dr[DbOperations.SensorDB.SensorCalibrationFields.IsProportional.ToString()]);
|
||||
ModifyDate = Convert.ToDateTime(dr[DbOperations.SensorDB.SensorCalibrationFields.ModifyDate.ToString()]);
|
||||
NonLinear = Convert.ToBoolean(dr[DbOperations.SensorDB.SensorCalibrationFields.NonLinear.ToString()]);
|
||||
CertificationDocuments = ((string)dr[DbOperations.SensorDB.SensorCalibrationFields.CertificationDocuments.ToString()]).Split(new[] { CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None).ToArray();
|
||||
RemoveOffset = Convert.ToBoolean(dr[DbOperations.SensorDB.SensorCalibrationFields.RemoveOffset.ToString()]);
|
||||
ZeroMethod = new ZeroMethod((string)dr[DbOperations.SensorDB.SensorCalibrationFields.ZeroMethod.ToString()]);
|
||||
InitialOffset = new InitialOffset(); InitialOffset.FromDbSerializeString((string)dr[DbOperations.SensorDB.SensorCalibrationFields.InitialOffset.ToString()]);
|
||||
|
||||
//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) return;
|
||||
Records.Records[0].Sensitivity = 1D;
|
||||
IsProportional = false;
|
||||
RemoveOffset = false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process Sensor Calibration record", ex);
|
||||
}
|
||||
}
|
||||
public void FromSerializedString(string s)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(DbOperations.SensorDB.SensorCalibrationFields)).Cast<DbOperations.SensorDB.SensorCalibrationFields>().ToArray();
|
||||
var tokens = s.Split(new[] { 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, 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 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: CertificationDocuments = token.Split(new[] { CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
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 int CompareTo(SensorCalibration other)
|
||||
{
|
||||
if (null == other) { return 1; }
|
||||
if (Equals(this, other)) { return 0; }
|
||||
if (CalibrationDate.Date != other.CalibrationDate.Date)
|
||||
return other.CalibrationDate.CompareTo(CalibrationDate);
|
||||
var modifyCompare = other.ModifyDate.CompareTo(ModifyDate);
|
||||
return 0 == modifyCompare ? other.CalVersion.CompareTo(CalVersion) : modifyCompare;
|
||||
}
|
||||
public void ReadXML(System.Xml.XmlElement root)
|
||||
{
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
if (node is System.Xml.XmlElement) { ProcessXmlElement(node as System.Xml.XmlElement); }
|
||||
}
|
||||
}
|
||||
private void ProcessXmlElement(System.Xml.XmlElement node)
|
||||
{
|
||||
if (!Enum.TryParse(node.Name, out DbOperations.SensorDB.SensorCalibrationFields field)) return;
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CalibrationDate: CalibrationDate = DateTime.Parse(node.InnerText, CultureInfo.InvariantCulture); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CalibrationRecords: Records = new CalibrationRecords(node.InnerText); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.CertificationDocuments: CertificationDocuments = new string[0]; break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.IsProportional: IsProportional = Convert.ToBoolean(node.InnerText); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.LocalOnly: LocalOnly = Convert.ToBoolean(node.InnerText); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.ModifyDate: ModifyDate = DateTime.Parse(node.InnerText, CultureInfo.InvariantCulture); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.NonLinear: NonLinear = Convert.ToBoolean(node.InnerText); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.RemoveOffset: RemoveOffset = Convert.ToBoolean(node.InnerText); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.SerialNumber: SerialNumber = node.InnerText; break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.Username: Username = node.InnerText; break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.ZeroMethod: ZeroMethod = new ZeroMethod(node.InnerText); break;
|
||||
case DbOperations.SensorDB.SensorCalibrationFields.InitialOffset: InitialOffset = new InitialOffset(); InitialOffset.FromDbSerializeString(node.InnerText); break;
|
||||
default: throw new NotSupportedException("SensorCalibration::ProcessXMLElement unsupported tag: " + field);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,768 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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; }
|
||||
protected bool _checkOffset = true;
|
||||
public bool CheckOffset
|
||||
{
|
||||
get => _checkOffset;
|
||||
set => SetProperty(ref _checkOffset, value, "CheckOffset");
|
||||
}
|
||||
|
||||
|
||||
protected bool _measureNoise = true;
|
||||
public bool MeasureNoise
|
||||
{
|
||||
get => _measureNoise;
|
||||
set => SetProperty(ref _measureNoise, value, "MeasureNoise");
|
||||
}
|
||||
|
||||
protected bool _measureExcitation = true;
|
||||
public bool MeasureExcitation
|
||||
{
|
||||
get => _measureExcitation;
|
||||
set => SetProperty(ref _measureExcitation, value, "MeasureExcitation");
|
||||
}
|
||||
|
||||
protected bool _invert = false;
|
||||
public bool Invert
|
||||
{
|
||||
get => _invert;
|
||||
set => SetProperty(ref _invert, value, "Invert");
|
||||
}
|
||||
|
||||
protected string _Model = "";
|
||||
public string Model
|
||||
{
|
||||
get => _Model;
|
||||
set => SetProperty(ref _Model, value, "Model");
|
||||
}
|
||||
|
||||
protected string _Manufacturer = "";
|
||||
public string Manufacturer
|
||||
{
|
||||
get => _Manufacturer;
|
||||
set => SetProperty(ref _Manufacturer, value, "Manufacturer");
|
||||
}
|
||||
|
||||
protected string _UserPartNumber = "";
|
||||
public string UserPartNumber
|
||||
{
|
||||
get => _UserPartNumber;
|
||||
set => SetProperty(ref _UserPartNumber, value, "UserPartNumber");
|
||||
}
|
||||
|
||||
protected double _Capacity = 2400D;
|
||||
public double Capacity
|
||||
{
|
||||
get => _Capacity;
|
||||
set => SetProperty(ref _Capacity, value, "Capacity");
|
||||
}
|
||||
protected CouplingModes _couplingMode = CouplingModes.AC;
|
||||
public CouplingModes CouplingMode
|
||||
{
|
||||
get => _couplingMode;
|
||||
set => SetProperty(ref _couplingMode, value, "CouplingMode");
|
||||
}
|
||||
|
||||
protected LowHigh _OffsetTolerance = new LowHigh(-100D, 100D);
|
||||
public double OffsetToleranceLow
|
||||
{
|
||||
get => _OffsetTolerance.Low;
|
||||
set { _OffsetTolerance.Low = value; OnPropertyChanged("OffsetToleranceLow"); }
|
||||
}
|
||||
public double OffsetToleranceHigh
|
||||
{
|
||||
get => _OffsetTolerance.High;
|
||||
set { _OffsetTolerance.High = value; OnPropertyChanged("OffsetToleranceHigh"); }
|
||||
}
|
||||
|
||||
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; OnPropertyChanged("RangeLow"); }
|
||||
}
|
||||
public double RangeMedium
|
||||
{
|
||||
get => 0 == _Range.Medium ? Capacity : _Range.Medium;
|
||||
set { _Range.Medium = value; OnPropertyChanged("RangeMedium"); }
|
||||
}
|
||||
public double RangeHigh
|
||||
{
|
||||
get => 0 == _Range.High ? Capacity : _Range.High;
|
||||
set { _Range.High = value; OnPropertyChanged("RangeHigh"); }
|
||||
}
|
||||
|
||||
protected List<ExcitationVoltageOptions.ExcitationVoltageOption> _supportedExcitation = new List<ExcitationVoltageOptions.ExcitationVoltageOption>(
|
||||
new[] { ExcitationVoltageOptions.ExcitationVoltageOption.Volt5 });
|
||||
public ExcitationVoltageOptions.ExcitationVoltageOption[] SupportedExcitation
|
||||
{
|
||||
get => _supportedExcitation.ToArray();
|
||||
set => SetProperty(ref _supportedExcitation, new List<ExcitationVoltageOptions.ExcitationVoltageOption>(value), "SupportedExcitation");
|
||||
}
|
||||
protected SensorCalibration _calibration = new SensorCalibration();
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public virtual SensorCalibration Calibration
|
||||
{
|
||||
get => _calibration;
|
||||
set => SetProperty(ref _calibration, value, "Calibration");
|
||||
}
|
||||
|
||||
protected Test.Module.Channel.Sensor.BridgeType _Bridge = Test.Module.Channel.Sensor.BridgeType.FullBridge;
|
||||
public Test.Module.Channel.Sensor.BridgeType Bridge
|
||||
{
|
||||
get => _Bridge;
|
||||
set => SetProperty(ref _Bridge, value, "Bridge");
|
||||
}
|
||||
|
||||
protected ShuntMode _Shunt = ShuntMode.Emulation;
|
||||
public ShuntMode Shunt
|
||||
{
|
||||
get => _Shunt;
|
||||
set => SetProperty(ref _Shunt, value, "Shunt");
|
||||
}
|
||||
|
||||
protected double _BridgeResistance = 350D;
|
||||
|
||||
public double BridgeResistance
|
||||
{
|
||||
get => _BridgeResistance;
|
||||
set => SetProperty(ref _BridgeResistance, value, "BridgeResistance");
|
||||
}
|
||||
|
||||
protected FilterClass _Filter = new FilterClass(FilterClass.FilterClassType.CFC1000);
|
||||
public FilterClass Filter
|
||||
{
|
||||
get => _Filter;
|
||||
set => SetProperty(ref _Filter, value, "Filter");
|
||||
}
|
||||
protected bool _UniPolar = false;
|
||||
public bool UniPolar
|
||||
{
|
||||
get => _UniPolar;
|
||||
set => SetProperty(ref _UniPolar, value, "UniPolar");
|
||||
}
|
||||
|
||||
protected bool _IgnoreRange = false;
|
||||
public bool IgnoreRange
|
||||
{
|
||||
get => _IgnoreRange;
|
||||
set => SetProperty(ref _IgnoreRange, value, "IgnoreRange");
|
||||
}
|
||||
|
||||
protected string _lastUpdatedBy;
|
||||
public string LastUpdatedBy
|
||||
{
|
||||
get => _lastUpdatedBy;
|
||||
set => SetProperty(ref _lastUpdatedBy, value, "LastUpdatedBy");
|
||||
}
|
||||
|
||||
protected int _version = 1;
|
||||
public int Version
|
||||
{
|
||||
get => _version;
|
||||
set => SetProperty(ref _version, value, "Version");
|
||||
}
|
||||
protected bool _localOnly = false;
|
||||
public bool LocalOnly => _localOnly;
|
||||
public void SetLocalOnly(bool bLocalOnly) { SetProperty(ref _localOnly, bLocalOnly, "LocalOnly"); }
|
||||
|
||||
protected short _axisNumber = 0;
|
||||
public short AxisNumber
|
||||
{
|
||||
get => _axisNumber;
|
||||
set => SetProperty(ref _axisNumber, value, "AxisNumber");
|
||||
}
|
||||
|
||||
protected short _numberOfAxes = 1;
|
||||
public short NumberOfAxes
|
||||
{
|
||||
get => _numberOfAxes;
|
||||
set => SetProperty(ref _numberOfAxes, value, "NumberOfAxes");
|
||||
}
|
||||
protected int _calInterval = 365;
|
||||
public int CalInterval
|
||||
{
|
||||
get => _calInterval;
|
||||
set => SetProperty(ref _calInterval, value, "CalInterval");
|
||||
}
|
||||
public string Polarity
|
||||
{
|
||||
get => _invert ? "-" : "+";
|
||||
set { Invert = value == "-"; OnPropertyChanged("Polarity"); }
|
||||
}
|
||||
|
||||
protected DateTime _lastModified = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
|
||||
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => SetProperty(ref _lastModified, value, "LastModified");
|
||||
}
|
||||
|
||||
protected IsoCode _isoCode = new IsoCode("");
|
||||
|
||||
public string ISOCode
|
||||
{
|
||||
get => _isoCode.StringRepresentation;
|
||||
set => SetProperty(ref _isoCode, new IsoCode(value), "ISOCode");
|
||||
}
|
||||
|
||||
public string PhysicalDimension
|
||||
{
|
||||
get => _isoCode.PhysicalDimension;
|
||||
set => _isoCode.PhysicalDimension = value;
|
||||
}
|
||||
|
||||
public string Direction
|
||||
{
|
||||
get => _isoCode.Direction;
|
||||
set => _isoCode.Direction = value;
|
||||
}
|
||||
|
||||
|
||||
private bool _doNotUse = false;
|
||||
public bool DoNotUse
|
||||
{
|
||||
get => _doNotUse;
|
||||
set => SetProperty(ref _doNotUse, value, "DoNotUse");
|
||||
}
|
||||
|
||||
private bool _broken = false;
|
||||
public bool Broken
|
||||
{
|
||||
get => _broken;
|
||||
set => SetProperty(ref _broken, value, "Broken");
|
||||
}
|
||||
|
||||
|
||||
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 static 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;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("fClass", fClass, null);
|
||||
}
|
||||
return isoFilterCode;
|
||||
}
|
||||
|
||||
}
|
||||
public class SensorModel : SensorBase, IComparable<SensorModel>
|
||||
{
|
||||
public enum IRTraccFormats
|
||||
{
|
||||
Manual,
|
||||
DiagnosticZeroMMmV,
|
||||
ZeroMMmV,
|
||||
AverageOverTime,
|
||||
Polynomial
|
||||
}
|
||||
private enum XMLFields
|
||||
{
|
||||
Model,
|
||||
Manufacturer,
|
||||
UserPartNumber,
|
||||
Capacity,
|
||||
OffsetTolerance,
|
||||
MeasurementUnit,
|
||||
SensorRange,
|
||||
Sensitivity,
|
||||
Excitation,
|
||||
IsProportional,
|
||||
Bridge,
|
||||
Shunt,
|
||||
BridgeResistance,
|
||||
RemoveOffset,
|
||||
FilterClass,
|
||||
ZeroMethod,
|
||||
InitialEU,
|
||||
NonLinear,
|
||||
UniPolar,
|
||||
PolynomialStyle,
|
||||
IRTraccFormat,
|
||||
LinearizationFormula,
|
||||
PhysicalDimension,
|
||||
IgnoreRange,
|
||||
Invert,
|
||||
CouplingMode,
|
||||
CheckOffset
|
||||
}
|
||||
public SensorModel(System.Xml.XmlElement node)
|
||||
{
|
||||
var initialEU = 0D;
|
||||
foreach (var childnode in node.ChildNodes)
|
||||
{
|
||||
if (!(childnode is System.Xml.XmlElement elem)) { continue; }
|
||||
try
|
||||
{
|
||||
var field = (XMLFields)Enum.Parse(typeof(XMLFields), elem.Name);
|
||||
var value = elem.InnerText;
|
||||
switch (field)
|
||||
{
|
||||
case XMLFields.Bridge:
|
||||
Bridge = (Test.Module.Channel.Sensor.BridgeType)Enum.Parse(typeof(Test.Module.Channel.Sensor.BridgeType), value);
|
||||
break;
|
||||
case XMLFields.BridgeResistance:
|
||||
BridgeResistance = double.Parse(value, System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case XMLFields.Capacity:
|
||||
Capacity = double.Parse(value, System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case XMLFields.Excitation:
|
||||
SupportedExcitation = new ExcitationVoltageOptions.ExcitationVoltageOption[] { (ExcitationVoltageOptions.ExcitationVoltageOption)Enum.Parse(typeof(ExcitationVoltageOptions.ExcitationVoltageOption), value) };
|
||||
break;
|
||||
case XMLFields.FilterClass:
|
||||
Filter = new FilterClass(value);
|
||||
break;
|
||||
case XMLFields.IgnoreRange:
|
||||
IgnoreRange = bool.Parse(value);
|
||||
break;
|
||||
case XMLFields.Invert:
|
||||
Invert = bool.Parse(value);
|
||||
break;
|
||||
case XMLFields.InitialEU:
|
||||
initialEU = double.Parse(value, System.Globalization.CultureInfo.InvariantCulture);
|
||||
//InitialEU = double.Parse(value, System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case XMLFields.IsProportional:
|
||||
Calibration.IsProportional = bool.Parse(value);
|
||||
break;
|
||||
case XMLFields.LinearizationFormula:
|
||||
Calibration.Records.Records[0].Poly = new LinearizationFormula();
|
||||
Calibration.Records.Records[0].Poly.FromSerializeString(value);
|
||||
break;
|
||||
case XMLFields.Manufacturer:
|
||||
Manufacturer = value;
|
||||
//System.Diagnostics.Trace.WriteLine(Manufacturer);
|
||||
break;
|
||||
case XMLFields.MeasurementUnit:
|
||||
DisplayUnit = value;
|
||||
break;
|
||||
case XMLFields.Model:
|
||||
Model = value;
|
||||
//System.Diagnostics.Trace.WriteLine(Model);
|
||||
break;
|
||||
case XMLFields.NonLinear:
|
||||
Calibration.NonLinear = bool.Parse(value);
|
||||
break;
|
||||
case XMLFields.OffsetTolerance:
|
||||
{
|
||||
var tol = new LowHigh(value);
|
||||
OffsetToleranceHigh = tol.High;
|
||||
OffsetToleranceLow = tol.Low;
|
||||
}
|
||||
break;
|
||||
case XMLFields.PhysicalDimension:
|
||||
PhysicalDimension = value;
|
||||
break;
|
||||
case XMLFields.PolynomialStyle:
|
||||
//var polystyle = (PolynomialStyles)Enum.Parse(typeof(PolynomialStyles), value);
|
||||
//switch (polystyle)
|
||||
//{
|
||||
// case PolynomialStyles.
|
||||
//}
|
||||
//don't need this anymore?
|
||||
break;
|
||||
case XMLFields.IRTraccFormat:
|
||||
var irFormat = (IRTraccFormats)Enum.Parse(typeof(IRTraccFormats), value);
|
||||
switch (irFormat)
|
||||
{
|
||||
case IRTraccFormats.AverageOverTime: Calibration.Records.Records[0].Poly.NonLinearStyle = NonLinearStyles.IRTraccAverageOverTime; break;
|
||||
case IRTraccFormats.DiagnosticZeroMMmV: Calibration.Records.Records[0].Poly.NonLinearStyle = NonLinearStyles.IRTraccDiagnosticsZero; break;
|
||||
case IRTraccFormats.Manual: Calibration.Records.Records[0].Poly.NonLinearStyle = NonLinearStyles.IRTraccManual; break;
|
||||
case IRTraccFormats.ZeroMMmV: Calibration.Records.Records[0].Poly.NonLinearStyle = NonLinearStyles.IRTraccZeroMMmV; break;
|
||||
case IRTraccFormats.Polynomial: Calibration.Records.Records[0].Poly.NonLinearStyle = NonLinearStyles.Polynomial; break;
|
||||
}
|
||||
break;
|
||||
case XMLFields.RemoveOffset:
|
||||
Calibration.RemoveOffset = bool.Parse(value);
|
||||
break;
|
||||
case XMLFields.Sensitivity:
|
||||
Calibration.Records.Records[0].Sensitivity = double.Parse(value, System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case XMLFields.SensorRange:
|
||||
{
|
||||
var Range = new SensorRange(value);
|
||||
RangeHigh = Range.High;
|
||||
RangeLow = Range.Low;
|
||||
RangeMedium = Range.Medium;
|
||||
}
|
||||
break;
|
||||
case XMLFields.Shunt:
|
||||
Shunt = (ShuntMode)Enum.Parse(typeof(ShuntMode), value);
|
||||
break;
|
||||
case XMLFields.UniPolar:
|
||||
UniPolar = bool.Parse(value);
|
||||
break;
|
||||
case XMLFields.UserPartNumber:
|
||||
UserPartNumber = value;
|
||||
break;
|
||||
case XMLFields.ZeroMethod:
|
||||
{
|
||||
Calibration.ZeroMethod = new ZeroMethod(value);
|
||||
}
|
||||
break;
|
||||
case XMLFields.CouplingMode:
|
||||
CouplingMode = (CouplingModes)Enum.Parse(typeof(CouplingModes), value);
|
||||
break;
|
||||
case XMLFields.CheckOffset:
|
||||
CheckOffset = bool.Parse(value);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("field :" + field);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to parse xml", ex, elem.Name, elem.Value);
|
||||
}
|
||||
Calibration.InitialOffset = new InitialOffset(initialEU);
|
||||
}
|
||||
}
|
||||
private Test.Module.Channel.Sensor.BridgeType ConvertToBridge(int bridge)
|
||||
{
|
||||
switch (bridge)
|
||||
{
|
||||
case 0: return Test.Module.Channel.Sensor.BridgeType.IEPE;
|
||||
case 4: return Test.Module.Channel.Sensor.BridgeType.HalfBridge_SigPlus;
|
||||
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(DataRow dr)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
Polarity = (string)dr[DbOperations.SensorDB.SensorModelFields.Polarity.ToString()];
|
||||
AxisNumber = Convert.ToInt16(dr[DbOperations.SensorDB.SensorModelFields.AxisNumber.ToString()]);
|
||||
Bridge = ConvertToBridge(Convert.ToInt32(dr[DbOperations.SensorDB.SensorModelFields.Bridge.ToString()]));
|
||||
BridgeResistance = Convert.ToDouble(dr[DbOperations.SensorDB.SensorModelFields.BridgeResistance.ToString()]);
|
||||
CalInterval = Convert.ToInt32(dr[DbOperations.SensorDB.SensorModelFields.CalInterval.ToString()]);
|
||||
Capacity = Convert.ToDouble(dr[DbOperations.SensorDB.SensorModelFields.Capacity.ToString()]);
|
||||
CouplingMode = (CouplingModes)Convert.ToInt32(dr[DbOperations.SensorDB.SensorModelFields.CouplingMode.ToString()]);
|
||||
Filter = new FilterClass((string)dr[DbOperations.SensorDB.SensorModelFields.FilterClass.ToString()]);
|
||||
IgnoreRange = Convert.ToBoolean(dr[DbOperations.SensorDB.SensorModelFields.IgnoreRange.ToString()]);
|
||||
CheckOffset = Convert.ToBoolean(dr[DbOperations.SensorDB.SensorModelFields.CheckOffset.ToString()]);
|
||||
Invert = Convert.ToBoolean(dr[DbOperations.SensorDB.SensorModelFields.Invert.ToString()]);
|
||||
LastModified = (DateTime)dr[DbOperations.SensorDB.SensorModelFields.LastModified.ToString()];
|
||||
SetLocalOnly(Convert.ToBoolean(dr[DbOperations.SensorDB.SensorModelFields.LocalOnly.ToString()]));
|
||||
Manufacturer = (string)dr[DbOperations.SensorDB.SensorModelFields.Manufacturer.ToString()];
|
||||
DisplayUnit = (string)dr[DbOperations.SensorDB.SensorModelFields.MeasurementUnit.ToString()];
|
||||
Model = (string)dr[DbOperations.SensorDB.SensorModelFields.Model.ToString()];
|
||||
LastUpdatedBy = (string)dr[DbOperations.SensorDB.SensorModelFields.ModifiedBy.ToString()];
|
||||
NumberOfAxes = Convert.ToInt16(dr[DbOperations.SensorDB.SensorModelFields.NumberOfAxes.ToString()]);
|
||||
OffsetToleranceHigh = Convert.ToDouble(dr[DbOperations.SensorDB.SensorModelFields.OffsetToleranceHigh.ToString()]);
|
||||
OffsetToleranceLow = Convert.ToDouble(dr[DbOperations.SensorDB.SensorModelFields.OffsetToleranceLow.ToString()]);
|
||||
RangeMedium = Convert.ToDouble(dr[DbOperations.SensorDB.SensorModelFields.RangeAve.ToString()]);
|
||||
RangeHigh = Convert.ToDouble(dr[DbOperations.SensorDB.SensorModelFields.RangeHigh.ToString()]);
|
||||
RangeLow = Convert.ToDouble(dr[DbOperations.SensorDB.SensorModelFields.RangeLow.ToString()]);
|
||||
Shunt = (ShuntMode)Convert.ToInt32(dr[DbOperations.SensorDB.SensorModelFields.Shunt.ToString()]);
|
||||
UniPolar = Convert.ToBoolean(dr[DbOperations.SensorDB.SensorModelFields.UniPolar.ToString()]);
|
||||
UserPartNumber = (string)dr[DbOperations.SensorDB.SensorModelFields.UserPartNumber.ToString()];
|
||||
Version = Convert.ToInt32(dr[DbOperations.SensorDB.SensorModelFields.Version.ToString()]);
|
||||
ISOCode = (string)dr[DbOperations.SensorDB.SensorModelFields.ISOCode.ToString()];
|
||||
Calibration = new SensorCalibration((string)dr[DbOperations.SensorDB.SensorModelFields.CalibrationRecord.ToString()]);
|
||||
var options = new List<ExcitationVoltageOptions.ExcitationVoltageOption>();
|
||||
var tokens = ((string)dr[DbOperations.SensorDB.SensorModelFields.SupportedExcitation.ToString()]).Split(new[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
if (Enum.TryParse(token, out ExcitationVoltageOptions.ExcitationVoltageOption option)) { options.Add(option); }
|
||||
}
|
||||
|
||||
SupportedExcitation = options.ToArray();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process fields: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SensorModelCollection : 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)
|
||||
{
|
||||
//if (!HookedUp) { return; }
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
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();
|
||||
}
|
||||
// protected SensorModelCollection() { }
|
||||
private static SensorModelCollection _collection = null;
|
||||
public static SensorModelCollection SensorModelList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (null == _collection)
|
||||
{
|
||||
PopulateCollection();
|
||||
}
|
||||
return _collection;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static readonly object _lock = new object();
|
||||
/// <summary>
|
||||
/// deletes all Sensor Models
|
||||
/// originally created so TDM imports could clear all tables except DAS tables
|
||||
/// </summary>
|
||||
public void DeleteAll()
|
||||
{
|
||||
_sensorModels.Clear();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SensorModelsDelete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@Model", SqlDbType.NVarChar, 50) { Value = null });
|
||||
cmd.Parameters.Add(new SqlParameter("@Manufacturer", SqlDbType.NVarChar, 50) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("Failed to delete sensor models, ", ex); */}
|
||||
LoadAllSensorModels();
|
||||
}
|
||||
private const string FILE_NAME = "Model.SensorDB.xml";
|
||||
protected void LoadAllSensorModels(string path)
|
||||
{
|
||||
var filename = System.IO.Path.Combine(path, FILE_NAME);
|
||||
if (!System.IO.File.Exists(filename))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var doc = new System.Xml.XmlDocument();
|
||||
var xml = System.IO.File.ReadAllText(filename);
|
||||
doc.LoadXml(xml);
|
||||
var nodes = doc.GetElementsByTagName("SensorModels");
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
if (!(node is System.Xml.XmlElement element)) { continue; }
|
||||
foreach (var childNode in element.GetElementsByTagName("SensorModel"))
|
||||
{
|
||||
if (!(childNode is System.Xml.XmlElement elem)) { continue; }
|
||||
LoadSensor(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void LoadAllSensorModels()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_SensorModelsGet.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@Model", SqlDbType.NVarChar, 50) { Value = null });
|
||||
|
||||
#endregion params
|
||||
|
||||
//cmd.ExecuteNonQuery();
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (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)
|
||||
{
|
||||
//APILogger.Log("Failed to process a row in the database: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("Failed to retrieve sensor models, ", ex); */}
|
||||
}
|
||||
|
||||
private void LoadSensor(System.Xml.XmlElement node)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sm = new SensorModel(node);
|
||||
if (!_sensorModels.ContainsKey(sm.Manufacturer))
|
||||
{
|
||||
_sensorModels.Add(sm.Manufacturer, new Dictionary<string, SensorModel>());
|
||||
}
|
||||
_sensorModels[sm.Manufacturer][sm.Model] = sm;
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to get node from sensor model db, ", ex); */}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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 = Visibility.Hidden;
|
||||
GroupPositionButtonVisible = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupPositionComboBoxVisible = Visibility.Visible;
|
||||
GroupPositionButtonVisible = Visibility.Hidden;
|
||||
//set the position for every sensor in the test object using this position
|
||||
var isoTestObject = GetISOTestObject();
|
||||
foreach (var ch in isoTestObject.AllChannels)
|
||||
{
|
||||
if (!ch.Required) { continue; }
|
||||
if (string.IsNullOrWhiteSpace(ch.SensorSerialNumber)) { continue; }
|
||||
var sd = GetSensor(ch.Name, ch.SensorSerialNumber, ch.GetId()); // 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 Visibility _groupPositionComboBoxVisible = Visibility.Visible;
|
||||
public Visibility GroupPositionComboBoxVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_groupPositionComboBoxVisible == Visibility.Visible)
|
||||
{
|
||||
return SerializedSettings.ISOSupportLevel == SerializedSettings.ISOSupportLevels.NO_ISO ? Visibility.Collapsed : _groupPositionComboBoxVisible;
|
||||
}
|
||||
return _groupPositionComboBoxVisible;
|
||||
}
|
||||
set => SetProperty(ref _groupPositionComboBoxVisible, value, "GroupPositionComboBoxVisible");
|
||||
}
|
||||
|
||||
private Visibility _groupPositionButtonVisible = Visibility.Hidden;
|
||||
public Visibility GroupPositionButtonVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_groupPositionButtonVisible == Visibility.Visible)
|
||||
{
|
||||
return SerializedSettings.ISOSupportLevel == SerializedSettings.ISOSupportLevels.NO_ISO ? Visibility.Collapsed : _groupPositionButtonVisible;
|
||||
}
|
||||
return _groupPositionButtonVisible;
|
||||
}
|
||||
set => SetProperty(ref _groupPositionButtonVisible, value, "GroupPositionButtonVisible");
|
||||
}
|
||||
|
||||
private string _testObject = "?";
|
||||
public MMETestObjects TestObject
|
||||
{
|
||||
get => ((App)Application.Current).IsoDb.GetTestObjectByIso(_testObject);
|
||||
set
|
||||
{
|
||||
if (value == null) return;
|
||||
SetProperty(ref _testObject, value.Test_Object, "TestObject");
|
||||
//also set the test object for all sensors!
|
||||
|
||||
var isoTestObject = GetISOTestObject();
|
||||
foreach (var ch in isoTestObject.AllChannels)
|
||||
{
|
||||
if (!ch.Required) { continue; }
|
||||
if (string.IsNullOrWhiteSpace(ch.SensorSerialNumber)) { continue; }
|
||||
var sd = GetSensor(ch.GetId(), ch.SensorSerialNumber, ch.GetId());
|
||||
if (null == sd) { continue; }
|
||||
sd.TestObject = value.Test_Object;
|
||||
SetSensor(ch.GetId(), sd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _channelTypesIndex = -1;
|
||||
public int ChannelTypesIndex
|
||||
{
|
||||
get => _channelTypesIndex;
|
||||
set => SetProperty(ref _channelTypesIndex, value, Tags.ChannelTypesIndex.ToString());
|
||||
}
|
||||
|
||||
public void SetTestObject(string s)
|
||||
{
|
||||
_testObject = s;
|
||||
OnPropertyChanged("TestObject");
|
||||
}
|
||||
|
||||
public void SetPosition(string s)
|
||||
{
|
||||
_position = s;
|
||||
OnPropertyChanged("Position");
|
||||
if (s == UserSetKey)
|
||||
{
|
||||
GroupPositionComboBoxVisible = Visibility.Hidden;
|
||||
GroupPositionButtonVisible = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupPositionComboBoxVisible = Visibility.Visible;
|
||||
GroupPositionButtonVisible = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
public MMEPositions[] AvailablePositions => ((App)Application.Current).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);
|
||||
availableGroupPositions.AddRange(AvailablePositions);
|
||||
|
||||
return availableGroupPositions.ToArray();
|
||||
}
|
||||
}
|
||||
public TestTestObject(TestTestObject to)
|
||||
: base(to)
|
||||
{
|
||||
MetaCommonConstructor(to);
|
||||
}
|
||||
/// <summary>
|
||||
/// takes care of the meta data copy constructor items
|
||||
/// </summary>
|
||||
/// <param name="to"></param>
|
||||
private void MetaCommonConstructor(TestTestObject to)
|
||||
{
|
||||
ExcitationWarmupTimeMS = to.ExcitationWarmupTimeMS;
|
||||
TargetSampleRate = to.TargetSampleRate;
|
||||
PreTriggerSeconds = to.PreTriggerSeconds;
|
||||
PostTriggerSeconds = to.PostTriggerSeconds;
|
||||
_position = to._position;
|
||||
Position = to.Position;
|
||||
_testObject = to._testObject;
|
||||
SerialNumberConverted = to.SerialNumberConverted;
|
||||
SysBuilt = to.SysBuilt; //executed?
|
||||
ChannelTypesIndex = to.ChannelTypesIndex;
|
||||
}
|
||||
private int _excitationWarmupTime;
|
||||
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");
|
||||
}
|
||||
|
||||
private double _preTriggerSeconds;
|
||||
public double PreTriggerSeconds
|
||||
{
|
||||
get => _preTriggerSeconds;
|
||||
set => SetProperty(ref _preTriggerSeconds, value, "PreTriggerSeconds");
|
||||
}
|
||||
|
||||
private double _postTriggerSeconds;
|
||||
public double PostTriggerSeconds
|
||||
{
|
||||
get => _postTriggerSeconds;
|
||||
set => SetProperty(ref _postTriggerSeconds, value, "PostTriggerSeconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Controls;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for EditSensorInfoControl.xaml
|
||||
/// </summary>
|
||||
public partial class ImportSensorsImportControl : UserControl//, IPageContent, INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// TDM export clears all the tables except DAS tables, this function iterates through major tables and clears them
|
||||
/// </summary>
|
||||
public static void ClearAllTables(bool clearForDbImport)
|
||||
{
|
||||
TestTemplateList.TestTemplatesList.DeleteAll();
|
||||
TestObjectList.AddedGroupsList.DeleteAll();
|
||||
TestObjectList.TestObjectsList.DeleteAll();//we have to do this twice because for some reason we keep two copies of the list around!
|
||||
|
||||
//The following call to TestObjectTemplateCollection.DeleteAll() is not needed since TestTemplateList.TestTemplatesList.DeleteAll()
|
||||
//above deletes all TestObjectTemplates already (whether it should or not).
|
||||
//TestObjectTemplateCollection.DeleteAll();
|
||||
CustomChannelList.List.DeleteAll();
|
||||
SensorsCollection.SensorsList.DeleteAll();
|
||||
SensorModelCollection.SensorModelList.DeleteAll();
|
||||
SensorCalibrationList.DeleteAll();
|
||||
CustomerDetailsList.DeleteAll();
|
||||
LabratoryDetailsList.DeleteAll();
|
||||
TestEngineerDetailsList.DeleteAll();
|
||||
|
||||
if (!clearForDbImport) return;
|
||||
DTS.Common.Storage.DbOperations.ClearNonPrototypeDas();
|
||||
ClearAllLockedItems(); //Needed before ClearAllUsers runs
|
||||
ClearAllUsers(); //Also clears all UIItemSettings
|
||||
ClearAllTags();
|
||||
ClearAllUIItems();
|
||||
ClearAllExceptCurrentDbVersion();
|
||||
}
|
||||
|
||||
private static void ClearAllLockedItems()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = "DELETE FROM LockedItems";
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void ClearAllUsers()
|
||||
{
|
||||
var users = GetAllUsers();
|
||||
foreach (var user in users)
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_UserDelete.ToString(); //Only used in DataPROPre20.mdf, not DataPRO.mdf
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@UserName", SqlDbType.NVarChar, 50) { Value = user[1] });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static List<string[]> GetAllUsers()
|
||||
{
|
||||
var resultList = new List<string[]>();
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_UserGet.ToString(); //Only used in DataPROPre20.mdf, not DataPRO.mdf
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
|
||||
#region params
|
||||
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.Int) { Value = null });
|
||||
#endregion params
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
foreach (DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
var id = Convert.ToString(row[DbOperations.Users.UserFields.ID.ToString()]);
|
||||
var userName = Convert.ToString(row[DbOperations.Users.UserFields.UserName.ToString()]);
|
||||
var displayName = Convert.ToString(row[DbOperations.Users.UserFields.DisplayName.ToString()]);
|
||||
var password = Convert.ToString(row[DbOperations.Users.UserFields.Password.ToString()]);
|
||||
var role = Convert.ToString(row[DbOperations.Users.UserFields.Role.ToString()]);
|
||||
var lastModified = Convert.ToString(row[DbOperations.Users.UserFields.LastModified.ToString()]);
|
||||
var lastModifiedBy = Convert.ToString(row[DbOperations.Users.UserFields.LastModifiedBy.ToString()]);
|
||||
var localOnly = Convert.ToString(row[DbOperations.Users.UserFields.LocalOnly.ToString()]);
|
||||
var results = new[] { id, userName, displayName, password, role, lastModified, lastModifiedBy, localOnly };
|
||||
resultList.Add(results);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
private static void ClearAllUIItems()
|
||||
{
|
||||
//We're assuming that all of the UIItemSettings and Users are already deleted via ClearAllUsers!!!
|
||||
var uiItemIds = GetAllUIItemIds();
|
||||
foreach (var uiItemId in uiItemIds)
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_UIItemsDelete.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@ID", SqlDbType.Int) { Value = uiItemId });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<long> GetAllUIItemIds()
|
||||
{
|
||||
var idList = new List<long>();
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_UIItemsGet.ToString();
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
foreach (DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
idList.Add(Convert.ToInt64(row[DbOperations.Users.UIItemFields.ID.ToString()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
return idList;
|
||||
}
|
||||
private static void ClearAllTags()
|
||||
{
|
||||
//We're assuming that all of the TagAssignments are already deleted via ClearAllUsers!!!
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TagsGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@TagId", SqlDbType.Int) { Value = null });
|
||||
|
||||
var reader = cmd.ExecuteReader();
|
||||
var tagsList = new List<int>();
|
||||
while (reader.Read())
|
||||
{
|
||||
var t = new Tags.Tag(reader);
|
||||
if (t.ID == 0) continue;
|
||||
tagsList.Add(t.ID);
|
||||
}
|
||||
reader.Close();
|
||||
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TagsDelete.ToString();
|
||||
foreach (var tagId in tagsList)
|
||||
{
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Parameters.Add(new SqlParameter("@TagId", SqlDbType.Int) { Value = tagId });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void ClearAllExceptCurrentDbVersion()
|
||||
{
|
||||
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_DbVersionGet.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@Version", SqlDbType.Int) { Value = null });
|
||||
var reader = cmd.ExecuteReader();
|
||||
var dbVersionsList = new List<int>();
|
||||
while (reader.Read())
|
||||
{
|
||||
var version =
|
||||
Convert.ToInt32(reader[DbOperations.DbVersions.DbVersionFields.Version.ToString()]);
|
||||
if (version >= DbOperations.CURRENT_DB_VERSION) continue;
|
||||
dbVersionsList.Add(version);
|
||||
}
|
||||
reader.Close();
|
||||
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_DbVersionDelete.ToString();
|
||||
foreach (var version in dbVersionsList)
|
||||
{
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Parameters.Add(new SqlParameter("@Version", SqlDbType.Int) { Value = version });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TemplateZone
|
||||
{
|
||||
public string TemplateName { get; }
|
||||
|
||||
public string ZoneName { get; } = "";
|
||||
|
||||
public string Picture { get; set; }
|
||||
|
||||
public string Description { get; } = "";
|
||||
|
||||
public TemplateZone(string template, string name, string picture, string description)
|
||||
{
|
||||
ZoneName = name;
|
||||
TemplateName = template;
|
||||
Picture = picture;
|
||||
Description = description;
|
||||
}
|
||||
|
||||
public TemplateZone(DataRow dr)
|
||||
{
|
||||
TemplateName = (string)dr["TemplateName"];
|
||||
if (DBNull.Value == dr["ZoneName"]) { ZoneName = "Default zone"; }
|
||||
else { ZoneName = (string)dr["ZoneName"]; }
|
||||
if (DBNull.Value == dr["ZoneDescription"]) { Description = ""; }
|
||||
else { Description = (string)dr["ZoneDescription"]; }
|
||||
Picture = (string)dr["Picture"];
|
||||
TemplateRegions = TemplateRegion.GetAllRegions(TemplateName, ZoneName);
|
||||
}
|
||||
private readonly List<TemplateRegion> _regions = new List<TemplateRegion>();
|
||||
public TemplateRegion[] TemplateRegions
|
||||
{
|
||||
get => _regions.ToArray();
|
||||
set { _regions.Clear(); _regions.AddRange(value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user