init
This commit is contained in:
1
Common/DTS.Common.DataModel/.svn/entries
Normal file
1
Common/DTS.Common.DataModel/.svn/entries
Normal file
@@ -0,0 +1 @@
|
||||
12
|
||||
1
Common/DTS.Common.DataModel/.svn/format
Normal file
1
Common/DTS.Common.DataModel/.svn/format
Normal file
@@ -0,0 +1 @@
|
||||
12
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,43 @@
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.ISO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a container for all of the Dynamic Groups of a given type (Vehicle 1, Vehicle 2, Sled, etc.)
|
||||
/// </summary>
|
||||
public class SysBuiltObjectType
|
||||
{
|
||||
public SysBuiltObjectType(string testObjectType)
|
||||
{
|
||||
_testObject = testObjectType;
|
||||
}
|
||||
|
||||
private string _testObject = "?";
|
||||
public MMETestObjects TestObject
|
||||
{
|
||||
get { return ApplicationProperties.IsoDb.GetTestObjectByIso(_testObject); }
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
_testObject = value.Test_Object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ISOTestObjectType
|
||||
{
|
||||
get { return TestObject.Text_L1; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return TestObject.Text_L1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,605 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.DASLib.Service;
|
||||
using System.Threading;
|
||||
using System.Linq;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using DTS.Common.DataModel.Common;
|
||||
using DTS.Common.Enums.TSRAIRGo;
|
||||
using DTS.Common.Constant.DASSpecific;
|
||||
using DTS.Common.DataModel.Classes.TSRAIRGo;
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes
|
||||
{
|
||||
public class Arming
|
||||
{
|
||||
readonly Configuration configuration = new Configuration();
|
||||
public Arming()
|
||||
{
|
||||
}
|
||||
|
||||
public bool SetConfigAndFlashClear(DataModel.TestTemplate currentTest,
|
||||
List<IDASCommunication> dasList,
|
||||
Dictionary<string, int> dasSampleRateList,
|
||||
double duration,
|
||||
StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
return SetConfigAndStartFlashClear(currentTest, dasList, dasSampleRateList, duration, false, setProgressFunction, onError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private bool SetConfigAndStartFlashClear(DataModel.TestTemplate currentTest,
|
||||
List<IDASCommunication> dasList,
|
||||
Dictionary<string, int> dasSampleRateList,
|
||||
double duration,
|
||||
bool diagnosticsVoltage,
|
||||
StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
foreach (var mod in das.ConfigData.Modules)
|
||||
{
|
||||
mod.PostTriggerSeconds = duration;
|
||||
mod.PreTriggerSeconds = (double)TSRAIR.TSRAIR_MAX_PRE_TRIGGER_SAMPLES / Convert.ToInt32(dasSampleRateList[das.SerialNumber]);
|
||||
//FB 26980 mod.NumberOfEvents has already a correct value but override it to make sure the value is there
|
||||
mod.NumberOfEvents = currentTest.NumberOfEvents;
|
||||
mod.WakeUpMotionTimeout = currentTest.WakeUpMotionTimeout; //10?
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
setProgressFunction(das, 0D, TSRAIRGoStatus.StatusTypes.PREPARING_FOR_ARMING);
|
||||
}
|
||||
|
||||
configuration.SetConfig(currentTest, dasList, diagnosticsVoltage, setProgressFunction);
|
||||
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
setProgressFunction(das, 0D, TSRAIRGoStatus.StatusTypes.PREPARING_DATA_MEMORY);
|
||||
}
|
||||
return StartFlashClear(dasList, setProgressFunction, currentTest, onError);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
onError?.Invoke(this, $"{StringResources.FailedToArm}: {ex.Message}", ex);
|
||||
APILogger.Log(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
protected bool StartFlashClear(List<IDASCommunication> dasList, StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
DataModel.TestTemplate currentTest, ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
return FlashErase(dasList, setProgressFunction, currentTest, onError);
|
||||
}
|
||||
protected bool FlashErase(List<IDASCommunication> dasList, StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
DataModel.TestTemplate currentTest, ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
var cancelEvent = new ManualResetEvent(false);
|
||||
var resetEvent = new ManualResetEvent(false);
|
||||
var bFailed = false;
|
||||
var flashDevices = new List<IDASCommunication>(dasList);
|
||||
var failureToClearFlashDevices = new List<IDASCommunication>();
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
if (flashDevices.Any())
|
||||
{
|
||||
using (var armingService = new ArmingService())
|
||||
{
|
||||
armingService.AggregateProgress = false;
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
armingService.BeginFlashErase(flashDevices, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
bFailed = true;
|
||||
|
||||
//39345 Don't hang if Flash Erase fails
|
||||
cbd.Target.DASArmStatus.FaultMessage = StringResources.ArmSystem_FailedToClearFlash;
|
||||
cbd.Target.SetDASArmStatus();
|
||||
onError?.Invoke(this, string.Format(StringResources.ArmSystem_FailedToClearFlash, cbd.Target.SerialNumber), null);
|
||||
failureToClearFlashDevices.Add(cbd.Target);
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
break;
|
||||
}
|
||||
}, flashDevices, false);
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//39345 Don't hang if Flash Erase fails
|
||||
if (bFailed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flashDevices.Any())
|
||||
{
|
||||
using (var armingService = new ArmingService())
|
||||
{
|
||||
armingService.AggregateProgress = false;
|
||||
var bDone = false;
|
||||
var flashStatus = new Dictionary<IDASCommunication, bool>();
|
||||
|
||||
foreach (var das in flashDevices)
|
||||
{
|
||||
flashStatus[das] = false;
|
||||
}
|
||||
while (!bDone)
|
||||
{
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
armingService.GetFlashEraseStatus(flashDevices, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
bFailed = true;
|
||||
flashStatus[cbd.Target] = true;
|
||||
failureToClearFlashDevices.Add(cbd.Target);
|
||||
onError?.Invoke(this, string.Format(StringResources.ArmSystem_FailedToClearFlash, cbd.Target.SerialNumber), cbd.ErrorException);
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
flashStatus[cbd.Target] = true;
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
{
|
||||
using (var enumeratorFlashStatus = flashStatus.GetEnumerator())
|
||||
{
|
||||
var b = true;
|
||||
while (enumeratorFlashStatus.MoveNext())
|
||||
{
|
||||
if (!enumeratorFlashStatus.Current.Value)
|
||||
{
|
||||
b = false;
|
||||
}
|
||||
}
|
||||
bDone = b;
|
||||
}
|
||||
}
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
StatusHelpers.SetStatus2(cbd.Target, cbd.ProgressValue, TSRAIRGoStatus.StatusTypes.PREPARING_DATA_MEMORY, setProgressFunction);
|
||||
if (100 <= cbd.ProgressValue)
|
||||
{
|
||||
flashStatus[cbd.Target] = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}, flashDevices);
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
if (cancelEvent.WaitOne(0, false))
|
||||
{
|
||||
bDone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//39345 Don't hang if Flash Erase fails
|
||||
if (bFailed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!cancelEvent.WaitOne(0, false) && !bFailed)
|
||||
{
|
||||
return PrepareArmFunc(dasList, setProgressFunction, currentTest, onError);
|
||||
}
|
||||
else if (bFailed)
|
||||
{
|
||||
resetEvent.Set();
|
||||
cancelEvent.Set();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected bool PrepareArmFunc(List<IDASCommunication> dasList, StatusHelpers.SetProgressValueDelegate setProgressFunction, DataModel.TestTemplate currentTest,
|
||||
ServiceBase.ServiceCallbackErrorEventHandler onError
|
||||
)
|
||||
{
|
||||
const int ARM_NOW_TIMEOUT = 30000;
|
||||
var cancelEvent = new ManualResetEvent(false);
|
||||
var g = Guid.NewGuid();
|
||||
|
||||
var bFailedPrepareArm = false;
|
||||
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
if (currentTest.LevelTriggerChannels.Count > 0)
|
||||
{
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
var mre = new ManualResetEvent(false);
|
||||
armService.CheckAlreadyLevelTriggered(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
onError(this, $"{StringResources.ArmSystem_FailedArm} {cbd.ErrorMessage} - {cbd.Target.SerialNumber}", cbd.ErrorException);
|
||||
bFailedPrepareArm = true;
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
mre.Set();
|
||||
break;
|
||||
}
|
||||
}, dasList);
|
||||
mre.WaitOne();
|
||||
var alreadyLevelTriggeredChannels = (from das in dasList where null != das.ConfigData from m in das.ConfigData.Modules from ch in m.Channels where ch is AnalogInputDASChannel let aCh = ch as AnalogInputDASChannel where aCh.AlreadyLevelTriggered select $"{das.SerialNumber} {1 + aCh.Number}").ToList();
|
||||
if (alreadyLevelTriggeredChannels.Count > 0)
|
||||
{
|
||||
bFailedPrepareArm = true;
|
||||
var errors = new List<string>();
|
||||
errors.Add(StringResources.AlreadyLevelTriggeredChannels);
|
||||
errors.AddRange(alreadyLevelTriggeredChannels.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bFailedPrepareArm)
|
||||
{
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
armService.ReadyForArm(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
StatusHelpers.SetStatus2(cbd.Target, cbd.ProgressValue, TSRAIRGoStatus.StatusTypes.PREPARING_FOR_ARMING, setProgressFunction);
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
bFailedPrepareArm = true;
|
||||
onError(this, $"{StringResources.ArmSystem_FailedArm} {cbd.ErrorMessage} - {cbd.Target.SerialNumber}", cbd.ErrorException);
|
||||
break;
|
||||
}
|
||||
}, dasList, 600000, false, currentTest.NumberOfEvents, 0, g, false, dasList.Count > 1);
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFailedPrepareArm)
|
||||
{
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
armService.PrepareForArmNow(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
onError(this, $"{StringResources.ArmSystem_FailedArm} {cbd.ErrorMessage} - {cbd.Target.SerialNumber}", cbd.ErrorException);
|
||||
bFailedPrepareArm = true;
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
StatusHelpers.SetStatus2(cbd.Target, cbd.ProgressValue, TSRAIRGoStatus.StatusTypes.PREPARING_FOR_ARMING, setProgressFunction);
|
||||
break;
|
||||
}
|
||||
}, dasList, ARM_NOW_TIMEOUT, false, currentTest.NumberOfEvents, g, dasList.Count > 1/* && CurrentTest.CommonLine*/);
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
|
||||
if (!cancelEvent.WaitOne(0, false))
|
||||
{
|
||||
done.Reset();
|
||||
}
|
||||
}
|
||||
if (bFailedPrepareArm)
|
||||
{
|
||||
cancelEvent.Set();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cancelEvent.Set();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return ArmNowFunc(dasList, setProgressFunction, currentTest, onError);
|
||||
}
|
||||
protected bool ArmNowFunc(List<IDASCommunication> dasList, StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
DataModel.TestTemplate currentTest, ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
var cancelEvent = new ManualResetEvent(false);
|
||||
|
||||
if (Common.SerializedSettings.StoreTestHistoryInDb)
|
||||
{
|
||||
//add code here?
|
||||
}
|
||||
var g = Guid.NewGuid();
|
||||
|
||||
var bFailedArm = false;
|
||||
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
var bSomeoneArmed = false;
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
|
||||
done.Reset();
|
||||
var disarmList = new List<IDASCommunication>();
|
||||
PreparedArmNowFunc(dasList, g, ref bSomeoneArmed, ref bFailedArm, ref timeWaited, ref disarmList, setProgressFunction, currentTest,
|
||||
onError);
|
||||
|
||||
//for safety reasons, make a disarm call to _everybody_ that "failed to arm", incase a module armed but the rack didn't
|
||||
//http://fogbugz/fogbugz/default.asp?4527
|
||||
if (done.WaitOne(0, false) && disarmList.Count > 0)
|
||||
{
|
||||
done.Reset();
|
||||
bSomeoneArmed = false;
|
||||
using (var aService = new ArmingService())
|
||||
{
|
||||
aService.Disarm(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
}
|
||||
}
|
||||
, dasList);
|
||||
}
|
||||
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
if (bSomeoneArmed)
|
||||
{
|
||||
if (!cancelEvent.WaitOne(0, false))
|
||||
{
|
||||
var das = new List<IDASCommunication>(dasList);
|
||||
for (var i = das.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (null == das[i].DASArmStatus || das[i].DASArmStatus.IsArmed == false)
|
||||
{
|
||||
das.RemoveAt(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (null != das[i].ConfigData && das[i].ConfigData.NumberOfConfiguredChannels() == 0 /*&& CareAboutNumberOfConfiguredChannels(das[i])*/)
|
||||
{
|
||||
das.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
var bFailedEnableFaultChecking = false;
|
||||
var faultCheckingErrors = new List<string>();
|
||||
//keeps track of whether we need to restore semaphores
|
||||
//15630 limit EnableFaultChecking to single unit at a time for TDAS when there's a rack involved
|
||||
if (das.Count > 1)
|
||||
{
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
armService.EnableFaultChecking(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
bFailedEnableFaultChecking = true;
|
||||
faultCheckingErrors.Add($"{cbd.Target.SerialNumber} {StringResources.FailedEnableFaultChecking}");
|
||||
onError(this, $"{StringResources.ArmSystem_FailedArm} {cbd.ErrorMessage} - {cbd.Target.SerialNumber}", cbd.ErrorException);
|
||||
break;
|
||||
}
|
||||
}, das);
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//15267 Stop on ERR response from TDAS ARM RF
|
||||
if (bFailedEnableFaultChecking)
|
||||
{
|
||||
DisarmAll(dasList);
|
||||
cancelEvent.Set();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bFailedArm)
|
||||
{
|
||||
cancelEvent.Set();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private void DisarmAll(List<IDASCommunication> das)
|
||||
{
|
||||
var mre = new ManualResetEvent(false);
|
||||
using (var aService = new ArmingService())
|
||||
{
|
||||
aService.Disarm(das, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
mre.Set();
|
||||
break;
|
||||
}
|
||||
}
|
||||
, das);
|
||||
}
|
||||
|
||||
mre.WaitOne();
|
||||
}
|
||||
private void PreparedArmNowFunc(List<IDASCommunication> dasList,
|
||||
Guid g,
|
||||
ref bool bSomeoneArmed,
|
||||
ref bool bFailedArm,
|
||||
ref int timeWaited,
|
||||
ref List<IDASCommunication> lDisarmList,
|
||||
StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
DataModel.TestTemplate currentTest,
|
||||
ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
var someoneArmed = false;
|
||||
var failedArm = false;
|
||||
var disarmList = new List<IDASCommunication>();
|
||||
var doneEvent = new ManualResetEvent(false);
|
||||
var cancelEvent = new ManualResetEvent(false);
|
||||
var done = doneEvent;
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
armService.PreparedArmNow(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
onError(this, $"{StringResources.ArmSystem_FailedArm} {cbd.ErrorMessage} - {cbd.Target.SerialNumber}", cbd.ErrorException);
|
||||
disarmList.Add(cbd.Target);
|
||||
failedArm = true;
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
if (!cbd.Target.IsEthernetDistributor())
|
||||
{
|
||||
someoneArmed = true;
|
||||
try
|
||||
{
|
||||
if (null == cbd.Target.DASArmStatus) { cbd.Target.DASArmStatus = new ArmStatus(); }
|
||||
cbd.Target.DASArmStatus.IsArmed = true;
|
||||
cbd.Target.SetDASArmStatus();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex.Message);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
StatusHelpers.SetStatus2(cbd.Target, cbd.ProgressValue, TSRAIRGoStatus.StatusTypes.PREPARING_FOR_ARMING, setProgressFunction);
|
||||
break;
|
||||
}
|
||||
}, dasList, 30000, false, currentTest.NumberOfEvents, g, dasList.Count > 1); ///////////fix the 30000 and 1 (at least)
|
||||
}
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
bSomeoneArmed = bSomeoneArmed || someoneArmed;
|
||||
bFailedArm = bFailedArm || failedArm;
|
||||
lDisarmList.AddRange(disarmList);
|
||||
doneEvent = done;
|
||||
}
|
||||
public void SoftwareTrigger(List<IDASCommunication> dasList)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var armingService = new ArmingService())
|
||||
{
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
var mre = new ManualResetEvent(false);
|
||||
armingService.Trigger(dasList, delegate (ServiceBase.CallbackData data)
|
||||
{
|
||||
switch (data.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished: mre.Set(); break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure: APILogger.Log(data.ErrorMessage); break;
|
||||
}
|
||||
}, dasList);
|
||||
while (!mre.WaitOne(10, false)) { }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failure in Software Trigger");
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
public void DisarmAsync(List<IDASCommunication> dasList)
|
||||
{
|
||||
Disarm(dasList);
|
||||
}
|
||||
private void Disarm(List<IDASCommunication> dasList)
|
||||
{
|
||||
DisarmSync(dasList);
|
||||
}
|
||||
private void DisarmSync(List<IDASCommunication> dasList)
|
||||
{
|
||||
var mre = new ManualResetEvent(false);
|
||||
using (var armingService = new ArmingService())
|
||||
{
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
armingService.Disarm(
|
||||
dasList,
|
||||
delegate (ServiceBase.CallbackData data)
|
||||
{
|
||||
switch (data.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
mre.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Canceled:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
break;
|
||||
}
|
||||
},
|
||||
dasList);
|
||||
while (!mre.WaitOne(10, false)) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,456 @@
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DataPROWin7.DataModel.BatteryAndInputVoltageDefaults
|
||||
{
|
||||
public class DasBatteryInputSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// all possible battery settings
|
||||
/// note that the order is important since serialization assumes this order,
|
||||
/// so don't change order without addressing that.
|
||||
/// </summary>
|
||||
public enum Settings
|
||||
{
|
||||
BatteryLowDiagnosticsThreshold,
|
||||
BatteryHighDiagnosticsThreshold,
|
||||
BatteryLowArmedThreshold,
|
||||
BatteryHighArmedThreshold,
|
||||
InputLowDiagnosticsThreshold,
|
||||
InputHighDiagnosticsThreshold,
|
||||
InputLowArmedThreshold,
|
||||
InputHighArmedThreshold,
|
||||
MinimumValidBatteryThreshold,
|
||||
MinimumValidInputThreshold,
|
||||
MaximumValidBatteryThreshold,
|
||||
MaximumValidInputThreshold,
|
||||
BatteryMediumDiagnosticsThreshold,
|
||||
BatteryMediumArmedThreshold,
|
||||
InputMediumDiagnosticsThreshold,
|
||||
InputMediumArmedThreshold,
|
||||
}
|
||||
|
||||
public double BatteryLowDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryLowDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryLowDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryHighDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryHighDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryHighDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryLowArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryLowArmedThreshold);
|
||||
set => SetValue(Settings.BatteryLowArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryHighArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryHighArmedThreshold);
|
||||
set => SetValue(Settings.BatteryHighArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputLowDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputLowDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputLowDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputHighDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputHighDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputHighDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputLowArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputLowArmedThreshold);
|
||||
set => SetValue(Settings.InputLowArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputHighArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputHighArmedThreshold);
|
||||
set => SetValue(Settings.InputHighArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double MinimumValidBatteryThreshold
|
||||
{
|
||||
get => GetValue(Settings.MinimumValidBatteryThreshold);
|
||||
set => SetValue(Settings.MinimumValidBatteryThreshold, value);
|
||||
}
|
||||
|
||||
public double MinimumValidInputThreshold
|
||||
{
|
||||
get => GetValue(Settings.MinimumValidInputThreshold);
|
||||
set => SetValue(Settings.MinimumValidInputThreshold, value);
|
||||
}
|
||||
|
||||
public double MaximumValidBatteryThreshold
|
||||
{
|
||||
get => GetValue(Settings.MaximumValidBatteryThreshold);
|
||||
set => SetValue(Settings.MaximumValidBatteryThreshold, value);
|
||||
}
|
||||
|
||||
public double MaximumValidInputThreshold
|
||||
{
|
||||
get => GetValue(Settings.MaximumValidInputThreshold);
|
||||
set => SetValue(Settings.MaximumValidInputThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryMediumDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryMediumDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryMediumDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryMediumArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryMediumArmedThreshold);
|
||||
set => SetValue(Settings.BatteryMediumArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputMediumDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputMediumDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputMediumDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputMediumArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputMediumArmedThreshold);
|
||||
set => SetValue(Settings.InputMediumArmedThreshold, value);
|
||||
}
|
||||
public Dictionary<Settings, double> SettingsProperty { get; } = new Dictionary<Settings, double>();
|
||||
|
||||
public DasBatteryInputSettings(string s)
|
||||
{
|
||||
var tokens = s.Split(new char[] { ',' });
|
||||
for (int i = 0; i < tokens.Length; i++)
|
||||
{
|
||||
var setting = (Settings)i;
|
||||
if (double.TryParse(tokens[i], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out double d))
|
||||
{
|
||||
SettingsProperty[setting] = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
public DasBatteryInputSettings(DasBatteryInputSettings copy)
|
||||
{
|
||||
using (var e = copy.SettingsProperty.GetEnumerator())
|
||||
{
|
||||
while (e.MoveNext())
|
||||
{
|
||||
SettingsProperty[e.Current.Key] = e.Current.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public DasBatteryInputSettings()
|
||||
{
|
||||
var settings = Enum.GetValues(typeof(Settings)).Cast<Settings>().ToArray();
|
||||
foreach (var s in settings)
|
||||
{
|
||||
double d = double.NaN;
|
||||
switch (s)
|
||||
{
|
||||
case Settings.BatteryHighArmedThreshold: d = 9D; break;
|
||||
case Settings.BatteryHighDiagnosticsThreshold: d = 9D; break;
|
||||
case Settings.BatteryLowArmedThreshold: d = 6.8D; break;
|
||||
case Settings.BatteryLowDiagnosticsThreshold: d = 7.8D; break;
|
||||
case Settings.InputHighArmedThreshold: d = 15.3; break;
|
||||
case Settings.InputHighDiagnosticsThreshold: d = 15.3; break;
|
||||
case Settings.InputLowArmedThreshold: d = 6.5D; break;
|
||||
case Settings.InputLowDiagnosticsThreshold: d = 10D; break;
|
||||
case Settings.MinimumValidBatteryThreshold: d = 4D; break;
|
||||
case Settings.MinimumValidInputThreshold: d = 4D; break;
|
||||
case Settings.MaximumValidBatteryThreshold: d = 9D; break;
|
||||
case Settings.MaximumValidInputThreshold: d = 19D; break;
|
||||
|
||||
case Settings.BatteryMediumArmedThreshold: d = 7.9D; break; //7.9 is halfway between low and high
|
||||
case Settings.BatteryMediumDiagnosticsThreshold: d = 8.4D; break; //8.4 is halfway between low and high
|
||||
case Settings.InputMediumArmedThreshold: d = 10.9D; break; //10.9 is halfway between low and high
|
||||
case Settings.InputMediumDiagnosticsThreshold: d = 12.7D; break; //12.7 is halfway between low and high
|
||||
|
||||
default: throw new NotSupportedException("Unknown Battery setting: " + s.ToString());
|
||||
}
|
||||
SettingsProperty[s] = d;
|
||||
}
|
||||
}
|
||||
public string ToSerializedString()
|
||||
{
|
||||
var settings = Enum.GetValues(typeof(Settings)).Cast<Settings>().ToArray();
|
||||
var sb = new string[settings.Length];
|
||||
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
sb[(int)setting] = GetValue(setting).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
return string.Join(",", sb);
|
||||
}
|
||||
public double GetValue(Settings setting)
|
||||
{
|
||||
if (SettingsProperty.ContainsKey(setting)) { return SettingsProperty[setting]; }
|
||||
else { throw new NotSupportedException("unknown setting: " + setting.ToString()); }
|
||||
}
|
||||
|
||||
public void SetValue(Settings setting, double d)
|
||||
{
|
||||
SettingsProperty[setting] = d;
|
||||
}
|
||||
}
|
||||
public static class InputAndBatterySettings
|
||||
{
|
||||
/// <summary>
|
||||
/// holds the battery/input settings in a cache so they don't have to be requeried from db
|
||||
/// 17615 BatteryAndInputVoltageDefaults improvements 3.2
|
||||
/// </summary>
|
||||
public static Dictionary<HardwareTypes, DasBatteryInputSettings> _cache =
|
||||
new Dictionary<HardwareTypes, DasBatteryInputSettings>();
|
||||
|
||||
/// <summary>
|
||||
/// clears the cache. This serves the purpose of ensuring
|
||||
/// that the values will be re-queried between runs, so if the settings are changed
|
||||
/// between runs the new values will be used
|
||||
/// </summary>
|
||||
public static void ClearCache()
|
||||
{
|
||||
_cache.Clear();
|
||||
}
|
||||
public static double GetValue(string DasType, DasBatteryInputSettings.Settings setting)
|
||||
{
|
||||
if (Enum.TryParse(DasType, out HardwareTypes type))
|
||||
{
|
||||
return GetValue(type, setting);
|
||||
}
|
||||
else { return double.NaN; }
|
||||
}
|
||||
|
||||
public static DasBatteryInputSettings GetDefaultSettingForHWType(HardwareTypes type)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
if (_cache.ContainsKey(type))
|
||||
{
|
||||
return _cache[type];
|
||||
}
|
||||
}
|
||||
DasBatteryInputSettings setting = null;
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY: setting = Common.SerializedSettings.G5INDUMMY_PowerSetting_Default; break;
|
||||
case HardwareTypes.G5VDS: setting = Common.SerializedSettings.G5VDS_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE_Distributor: setting = Common.SerializedSettings.SLICE_Distributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor: setting = Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_EthernetController: setting = Common.SerializedSettings.SLICE_EthernetController_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_LabEthernet: setting = Common.SerializedSettings.SLICE_LabEthernet_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE_Micro_Base: setting = Common.SerializedSettings.SLICE_Micro_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_NANO_Base: setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: setting = Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: setting = Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE1_G5Stack: setting = Common.SerializedSettings.SLICE1_G5Stack_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE2_DIM: setting = Common.SerializedSettings.SLICE2_DIM_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
setting = Common.SerializedSettings.SLICE2_SIM_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_TOM: setting = Common.SerializedSettings.SLICE2_TOM_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE2_SLD: setting = Common.SerializedSettings.SLICE2_SLD_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SLS: setting = Common.SerializedSettings.SLICE2_SLS_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SLT: setting = Common.SerializedSettings.SLICE2_SLT_PowerSetting_Default; break;
|
||||
|
||||
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
setting = Common.SerializedSettings.SLICE6_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB: setting = Common.SerializedSettings.SLICE6Db_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB3: setting = Common.SerializedSettings.SLICE6Db3_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: setting = Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting_Default; break;
|
||||
case HardwareTypes.PowerPro: setting = Common.SerializedSettings.PowerPRO_PowerSetting_Default; break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
setting = Common.SerializedSettings.TSRAIR_PowerSetting_Default; break;
|
||||
//case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting_Default; break;
|
||||
//case HardwareTypes.Falcon: setting = Common.SerializedSettings.Falcon_PowerSetting_Default; break;
|
||||
}
|
||||
|
||||
if (null != setting)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
_cache[type] = setting;
|
||||
}
|
||||
return setting;
|
||||
}
|
||||
|
||||
throw new NotSupportedException($"unknown type: {type.ToString()}");
|
||||
}
|
||||
public static void SetSettingForHWType(HardwareTypes type,
|
||||
DasBatteryInputSettings setting)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
Common.SerializedSettings.G5INDUMMY_PowerSetting = setting; break;
|
||||
case HardwareTypes.G5VDS:
|
||||
Common.SerializedSettings.G5VDS_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Distributor:
|
||||
Common.SerializedSettings.SLICE_Distributor_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB: Common.SerializedSettings.SLICE6Db_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB3: Common.SerializedSettings.SLICE6Db3_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: Common.SerializedSettings.SLICEPRODistributor_PowerSetting = setting; break;
|
||||
//case HardwareTypes.SLICE6DB_AIR: Common.SerializedSettings.SLICE6Db_AIR_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor:
|
||||
Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
Common.SerializedSettings.SLICE_EthernetController_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
Common.SerializedSettings.SLICE_LabEthernet_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Micro_Base:
|
||||
Common.SerializedSettings.SLICE_Micro_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_NANO_Base:
|
||||
Common.SerializedSettings.SLICE_NANO_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_5_Micro_Base:
|
||||
Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base:
|
||||
Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_G5Stack:
|
||||
Common.SerializedSettings.SLICE1_G5Stack_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
Common.SerializedSettings.SLICE2_DIM_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
Common.SerializedSettings.SLICE2_SIM_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
Common.SerializedSettings.SLICE2_SLD_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
Common.SerializedSettings.SLICE2_SLS_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
Common.SerializedSettings.SLICE2_SLT_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
Common.SerializedSettings.SLICE2_TOM_PowerSetting = setting; break;
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
Common.SerializedSettings.SLICE6_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
Common.SerializedSettings.SLICE6_AIR_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.PowerPro:
|
||||
Common.SerializedSettings.PowerPRO_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
Common.SerializedSettings.TSRAIR_PowerSetting = setting;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static DasBatteryInputSettings GetSettingForHWType(HardwareTypes type)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
if (_cache.ContainsKey(type))
|
||||
{
|
||||
return _cache[type];
|
||||
}
|
||||
}
|
||||
|
||||
DasBatteryInputSettings setting = null;
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY: setting = Common.SerializedSettings.G5INDUMMY_PowerSetting; break;
|
||||
case HardwareTypes.G5VDS: setting = Common.SerializedSettings.G5VDS_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE_Distributor: setting = Common.SerializedSettings.SLICE_Distributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor: setting = Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB: setting = Common.SerializedSettings.SLICE6Db_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB3: setting = Common.SerializedSettings.SLICE6Db3_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: setting = Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_EthernetController: setting = Common.SerializedSettings.SLICE_EthernetController_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_LabEthernet: setting = Common.SerializedSettings.SLICE_LabEthernet_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE_Micro_Base: setting = Common.SerializedSettings.SLICE_Micro_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_NANO_Base: setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: setting = Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: setting = Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_G5Stack: setting = Common.SerializedSettings.SLICE1_G5Stack_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_DIM: setting = Common.SerializedSettings.SLICE2_DIM_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
setting = Common.SerializedSettings.SLICE2_SIM_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLD: setting = Common.SerializedSettings.SLICE2_SLD_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLS: setting = Common.SerializedSettings.SLICE2_SLS_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLT: setting = Common.SerializedSettings.SLICE2_SLT_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_TOM: setting = Common.SerializedSettings.SLICE2_TOM_PowerSetting; break;
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting; break;
|
||||
case HardwareTypes.DIM:
|
||||
case HardwareTypes.SIM:
|
||||
case HardwareTypes.TOM:
|
||||
//we are not expected to get here but if we do, just use the tdas default
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting; break;
|
||||
case HardwareTypes.Ribeye:
|
||||
case HardwareTypes.RibeyeLED:
|
||||
case HardwareTypes.SLICE_Base:
|
||||
case HardwareTypes.SLICE_Bridge:
|
||||
case HardwareTypes.SLICE_IEPE:
|
||||
case HardwareTypes.SLICE2_IEPE_Hi:
|
||||
case HardwareTypes.SLICE2_IEPE_Lo:
|
||||
//these are all never expected to get here, but are all slice types
|
||||
setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_Base: setting = Common.SerializedSettings.SLICE6_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
case HardwareTypes.S6A_EthernetRecorder:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting; break;
|
||||
case HardwareTypes.PowerPro: setting = Common.SerializedSettings.PowerPRO_PowerSetting; break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
setting = Common.SerializedSettings.TSRAIR_PowerSetting;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("unknown das type: " + type.ToString());
|
||||
}
|
||||
if (null != setting)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
_cache[type] = setting;
|
||||
}
|
||||
}
|
||||
return setting;
|
||||
}
|
||||
public static double GetValue(HardwareTypes type, DasBatteryInputSettings.Settings setting)
|
||||
{
|
||||
return GetSettingForHWType(type).GetValue(setting);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using DTS.Slice.Users.UserSettings;
|
||||
|
||||
namespace DTS.Common.DataModel.Classes.TestTemplate
|
||||
{
|
||||
public class TSRAIRGoTestSetup : DataPROWin7.DataModel.TestTemplate
|
||||
{
|
||||
private static object MY_LOCK = new object();
|
||||
private static TSRAIRGoTestSetup _setup = null;
|
||||
|
||||
public const string TEST_NAME = "TSRAIR_GO_TEST";
|
||||
public override string Name
|
||||
{
|
||||
get => TEST_NAME;
|
||||
set {; }
|
||||
}
|
||||
protected TSRAIRGoTestSetup(DataPROWin7.DataModel.TestTemplate test) : base(test)
|
||||
{
|
||||
}
|
||||
protected TSRAIRGoTestSetup(TestSetupDefaults defaults) : base(defaults)
|
||||
{
|
||||
}
|
||||
public static TSRAIRGoTestSetup GetInstance(int userId, bool useCache = true)
|
||||
{
|
||||
lock (MY_LOCK)
|
||||
{
|
||||
if (null != _setup && useCache) { return _setup; }
|
||||
var template = DataPROWin7.DataModel.TestTemplateList.TestTemplatesList.GetTemplate(TEST_NAME, false);
|
||||
if (null != template)
|
||||
{
|
||||
_setup = new TSRAIRGoTestSetup(template);
|
||||
_setup.Load(true);
|
||||
return _setup;
|
||||
}
|
||||
var defaults = TestSetupDefaults.GetUserSettings(userId);
|
||||
_setup = new TSRAIRGoTestSetup(defaults);
|
||||
return _setup;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
|
||||
namespace DataPROWin7.DataModel.BatteryAndInputVoltageDefaults
|
||||
{
|
||||
public class DasBatteryInputSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// all possible battery settings
|
||||
/// note that the order is important since serialization assumes this order,
|
||||
/// so don't change order without addressing that.
|
||||
/// </summary>
|
||||
public enum Settings
|
||||
{
|
||||
BatteryLowDiagnosticsThreshold,
|
||||
BatteryHighDiagnosticsThreshold,
|
||||
BatteryLowArmedThreshold,
|
||||
BatteryHighArmedThreshold,
|
||||
InputLowDiagnosticsThreshold,
|
||||
InputHighDiagnosticsThreshold,
|
||||
InputLowArmedThreshold,
|
||||
InputHighArmedThreshold,
|
||||
MinimumValidBatteryThreshold,
|
||||
MinimumValidInputThreshold,
|
||||
MaximumValidBatteryThreshold,
|
||||
MaximumValidInputThreshold,
|
||||
BatteryMediumDiagnosticsThreshold,
|
||||
BatteryMediumArmedThreshold,
|
||||
InputMediumDiagnosticsThreshold,
|
||||
InputMediumArmedThreshold,
|
||||
}
|
||||
|
||||
public double BatteryLowDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryLowDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryLowDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryHighDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryHighDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryHighDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryLowArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryLowArmedThreshold);
|
||||
set => SetValue(Settings.BatteryLowArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryHighArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryHighArmedThreshold);
|
||||
set => SetValue(Settings.BatteryHighArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputLowDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputLowDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputLowDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputHighDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputHighDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputHighDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputLowArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputLowArmedThreshold);
|
||||
set => SetValue(Settings.InputLowArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputHighArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputHighArmedThreshold);
|
||||
set => SetValue(Settings.InputHighArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double MinimumValidBatteryThreshold
|
||||
{
|
||||
get => GetValue(Settings.MinimumValidBatteryThreshold);
|
||||
set => SetValue(Settings.MinimumValidBatteryThreshold, value);
|
||||
}
|
||||
|
||||
public double MinimumValidInputThreshold
|
||||
{
|
||||
get => GetValue(Settings.MinimumValidInputThreshold);
|
||||
set => SetValue(Settings.MinimumValidInputThreshold, value);
|
||||
}
|
||||
|
||||
public double MaximumValidBatteryThreshold
|
||||
{
|
||||
get => GetValue(Settings.MaximumValidBatteryThreshold);
|
||||
set => SetValue(Settings.MaximumValidBatteryThreshold, value);
|
||||
}
|
||||
|
||||
public double MaximumValidInputThreshold
|
||||
{
|
||||
get => GetValue(Settings.MaximumValidInputThreshold);
|
||||
set => SetValue(Settings.MaximumValidInputThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryMediumDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryMediumDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryMediumDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryMediumArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryMediumArmedThreshold);
|
||||
set => SetValue(Settings.BatteryMediumArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputMediumDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputMediumDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputMediumDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputMediumArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputMediumArmedThreshold);
|
||||
set => SetValue(Settings.InputMediumArmedThreshold, value);
|
||||
}
|
||||
public Dictionary<Settings, double> SettingsProperty { get; } = new Dictionary<Settings, double>();
|
||||
|
||||
public DasBatteryInputSettings(string s)
|
||||
{
|
||||
var tokens = s.Split(new char[] { ',' });
|
||||
for (int i = 0; i < tokens.Length; i++)
|
||||
{
|
||||
var setting = (Settings)i;
|
||||
if (double.TryParse(tokens[i], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out double d))
|
||||
{
|
||||
SettingsProperty[setting] = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
public DasBatteryInputSettings(DasBatteryInputSettings copy)
|
||||
{
|
||||
using (var e = copy.SettingsProperty.GetEnumerator())
|
||||
{
|
||||
while (e.MoveNext())
|
||||
{
|
||||
SettingsProperty[e.Current.Key] = e.Current.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public DasBatteryInputSettings()
|
||||
{
|
||||
var settings = Enum.GetValues(typeof(Settings)).Cast<Settings>().ToArray();
|
||||
foreach (var s in settings)
|
||||
{
|
||||
double d = double.NaN;
|
||||
switch (s)
|
||||
{
|
||||
case Settings.BatteryHighArmedThreshold: d = 9D; break;
|
||||
case Settings.BatteryHighDiagnosticsThreshold: d = 9D; break;
|
||||
case Settings.BatteryLowArmedThreshold: d = 6.8D; break;
|
||||
case Settings.BatteryLowDiagnosticsThreshold: d = 7.8D; break;
|
||||
case Settings.InputHighArmedThreshold: d = 15.3; break;
|
||||
case Settings.InputHighDiagnosticsThreshold: d = 15.3; break;
|
||||
case Settings.InputLowArmedThreshold: d = 6.5D; break;
|
||||
case Settings.InputLowDiagnosticsThreshold: d = 10D; break;
|
||||
case Settings.MinimumValidBatteryThreshold: d = 4D; break;
|
||||
case Settings.MinimumValidInputThreshold: d = 4D; break;
|
||||
case Settings.MaximumValidBatteryThreshold: d = 9D; break;
|
||||
case Settings.MaximumValidInputThreshold: d = 19D; break;
|
||||
|
||||
case Settings.BatteryMediumArmedThreshold: d = 7.9D; break; //7.9 is halfway between low and high
|
||||
case Settings.BatteryMediumDiagnosticsThreshold: d = 8.4D; break; //8.4 is halfway between low and high
|
||||
case Settings.InputMediumArmedThreshold: d = 10.9D; break; //10.9 is halfway between low and high
|
||||
case Settings.InputMediumDiagnosticsThreshold: d = 12.7D; break; //12.7 is halfway between low and high
|
||||
|
||||
default: throw new NotSupportedException("Unknown Battery setting: " + s.ToString());
|
||||
}
|
||||
SettingsProperty[s] = d;
|
||||
}
|
||||
}
|
||||
public string ToSerializedString()
|
||||
{
|
||||
var settings = Enum.GetValues(typeof(Settings)).Cast<Settings>().ToArray();
|
||||
var sb = new string[settings.Length];
|
||||
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
sb[(int)setting] = GetValue(setting).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
return string.Join(",", sb);
|
||||
}
|
||||
public double GetValue(Settings setting)
|
||||
{
|
||||
if (SettingsProperty.ContainsKey(setting)) { return SettingsProperty[setting]; }
|
||||
else { throw new NotSupportedException("unknown setting: " + setting.ToString()); }
|
||||
}
|
||||
|
||||
public void SetValue(Settings setting, double d)
|
||||
{
|
||||
SettingsProperty[setting] = d;
|
||||
}
|
||||
}
|
||||
public static class InputAndBatterySettings
|
||||
{
|
||||
/// <summary>
|
||||
/// holds the battery/input settings in a cache so they don't have to be requeried from db
|
||||
/// 17615 BatteryAndInputVoltageDefaults improvements 3.2
|
||||
/// </summary>
|
||||
public static Dictionary<HardwareTypes, DasBatteryInputSettings> _cache =
|
||||
new Dictionary<HardwareTypes, DasBatteryInputSettings>();
|
||||
|
||||
/// <summary>
|
||||
/// clears the cache. This serves the purpose of ensuring
|
||||
/// that the values will be re-queried between runs, so if the settings are changed
|
||||
/// between runs the new values will be used
|
||||
/// </summary>
|
||||
public static void ClearCache()
|
||||
{
|
||||
_cache.Clear();
|
||||
}
|
||||
public static double GetValue(string DasType, DasBatteryInputSettings.Settings setting)
|
||||
{
|
||||
if (Enum.TryParse(DasType, out HardwareTypes type))
|
||||
{
|
||||
return GetValue(type, setting);
|
||||
}
|
||||
else { return double.NaN; }
|
||||
}
|
||||
|
||||
public static DasBatteryInputSettings GetDefaultSettingForHWType(HardwareTypes type)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
if (_cache.ContainsKey(type))
|
||||
{
|
||||
return _cache[type];
|
||||
}
|
||||
}
|
||||
DasBatteryInputSettings setting = null;
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY: setting = Common.SerializedSettings.G5INDUMMY_PowerSetting_Default; break;
|
||||
case HardwareTypes.G5VDS: setting = Common.SerializedSettings.G5VDS_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE_Distributor: setting = Common.SerializedSettings.SLICE_Distributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor: setting = Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_EthernetController: setting = Common.SerializedSettings.SLICE_EthernetController_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_LabEthernet: setting = Common.SerializedSettings.SLICE_LabEthernet_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE_Micro_Base: setting = Common.SerializedSettings.SLICE_Micro_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_NANO_Base: setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: setting = Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: setting = Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE1_G5Stack: setting = Common.SerializedSettings.SLICE1_G5Stack_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE2_DIM: setting = Common.SerializedSettings.SLICE2_DIM_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
setting = Common.SerializedSettings.SLICE2_SIM_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_TOM: setting = Common.SerializedSettings.SLICE2_TOM_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE2_SLD: setting = Common.SerializedSettings.SLICE2_SLD_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SLS: setting = Common.SerializedSettings.SLICE2_SLS_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SLT: setting = Common.SerializedSettings.SLICE2_SLT_PowerSetting_Default; break;
|
||||
|
||||
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
setting = Common.SerializedSettings.SLICE6_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB: setting = Common.SerializedSettings.SLICE6Db_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB3: setting = Common.SerializedSettings.SLICE6Db3_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: setting = Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting_Default; break;
|
||||
case HardwareTypes.PowerPro: setting = Common.SerializedSettings.PowerPRO_PowerSetting_Default; break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
setting = Common.SerializedSettings.TSRAIR_PowerSetting_Default; break;
|
||||
//case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting_Default; break;
|
||||
//case HardwareTypes.Falcon: setting = Common.SerializedSettings.Falcon_PowerSetting_Default; break;
|
||||
}
|
||||
|
||||
if (null != setting)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
_cache[type] = setting;
|
||||
}
|
||||
return setting;
|
||||
}
|
||||
|
||||
throw new NotSupportedException($"unknown type: {type.ToString()}");
|
||||
}
|
||||
public static void SetSettingForHWType(HardwareTypes type,
|
||||
DasBatteryInputSettings setting)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
Common.SerializedSettings.G5INDUMMY_PowerSetting = setting; break;
|
||||
case HardwareTypes.G5VDS:
|
||||
Common.SerializedSettings.G5VDS_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Distributor:
|
||||
Common.SerializedSettings.SLICE_Distributor_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB: Common.SerializedSettings.SLICE6Db_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB3: Common.SerializedSettings.SLICE6Db3_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: Common.SerializedSettings.SLICEPRODistributor_PowerSetting = setting; break;
|
||||
//case HardwareTypes.SLICE6DB_AIR: Common.SerializedSettings.SLICE6Db_AIR_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor:
|
||||
Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
Common.SerializedSettings.SLICE_EthernetController_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
Common.SerializedSettings.SLICE_LabEthernet_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Micro_Base:
|
||||
Common.SerializedSettings.SLICE_Micro_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_NANO_Base:
|
||||
Common.SerializedSettings.SLICE_NANO_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_5_Micro_Base:
|
||||
Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base:
|
||||
Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_G5Stack:
|
||||
Common.SerializedSettings.SLICE1_G5Stack_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
Common.SerializedSettings.SLICE2_DIM_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
Common.SerializedSettings.SLICE2_SIM_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
Common.SerializedSettings.SLICE2_SLD_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
Common.SerializedSettings.SLICE2_SLS_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
Common.SerializedSettings.SLICE2_SLT_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
Common.SerializedSettings.SLICE2_TOM_PowerSetting = setting; break;
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
Common.SerializedSettings.SLICE6_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
Common.SerializedSettings.SLICE6_AIR_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.PowerPro:
|
||||
Common.SerializedSettings.PowerPRO_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
Common.SerializedSettings.TSRAIR_PowerSetting = setting;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static DasBatteryInputSettings GetSettingForHWType(HardwareTypes type)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
if (_cache.ContainsKey(type))
|
||||
{
|
||||
return _cache[type];
|
||||
}
|
||||
}
|
||||
|
||||
DasBatteryInputSettings setting = null;
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY: setting = Common.SerializedSettings.G5INDUMMY_PowerSetting; break;
|
||||
case HardwareTypes.G5VDS: setting = Common.SerializedSettings.G5VDS_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE_Distributor: setting = Common.SerializedSettings.SLICE_Distributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor: setting = Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB: setting = Common.SerializedSettings.SLICE6Db_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB3: setting = Common.SerializedSettings.SLICE6Db3_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: setting = Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_EthernetController: setting = Common.SerializedSettings.SLICE_EthernetController_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_LabEthernet: setting = Common.SerializedSettings.SLICE_LabEthernet_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE_Micro_Base: setting = Common.SerializedSettings.SLICE_Micro_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_NANO_Base: setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: setting = Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: setting = Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_G5Stack: setting = Common.SerializedSettings.SLICE1_G5Stack_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_DIM: setting = Common.SerializedSettings.SLICE2_DIM_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
setting = Common.SerializedSettings.SLICE2_SIM_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLD: setting = Common.SerializedSettings.SLICE2_SLD_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLS: setting = Common.SerializedSettings.SLICE2_SLS_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLT: setting = Common.SerializedSettings.SLICE2_SLT_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_TOM: setting = Common.SerializedSettings.SLICE2_TOM_PowerSetting; break;
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting; break;
|
||||
case HardwareTypes.DIM:
|
||||
case HardwareTypes.SIM:
|
||||
case HardwareTypes.TOM:
|
||||
//we are not expected to get here but if we do, just use the tdas default
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting; break;
|
||||
case HardwareTypes.Ribeye:
|
||||
case HardwareTypes.RibeyeLED:
|
||||
case HardwareTypes.SLICE_Base:
|
||||
case HardwareTypes.SLICE_Bridge:
|
||||
case HardwareTypes.SLICE_IEPE:
|
||||
case HardwareTypes.SLICE2_IEPE_Hi:
|
||||
case HardwareTypes.SLICE2_IEPE_Lo:
|
||||
//these are all never expected to get here, but are all slice types
|
||||
setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_Base: setting = Common.SerializedSettings.SLICE6_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
case HardwareTypes.S6A_EthernetRecorder:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting; break;
|
||||
case HardwareTypes.PowerPro: setting = Common.SerializedSettings.PowerPRO_PowerSetting; break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
setting = Common.SerializedSettings.TSRAIR_PowerSetting;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_TC:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_TC_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_PRO_CAN_FD:
|
||||
setting = Common.SerializedSettings.SPFD_PowerSetting; break;
|
||||
default:
|
||||
throw new NotSupportedException("unknown das type: " + type.ToString());
|
||||
}
|
||||
if (null != setting)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
_cache[type] = setting;
|
||||
}
|
||||
}
|
||||
return setting;
|
||||
}
|
||||
public static double GetValue(HardwareTypes type, DasBatteryInputSettings.Settings setting)
|
||||
{
|
||||
return GetSettingForHWType(type).GetValue(setting);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,342 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using DataPROWin7.DataModel.Classes.Hardware;
|
||||
using DTS.Common.Converters;
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using DTS.Common.Constant.DASSpecific;
|
||||
|
||||
namespace DataPROWin7
|
||||
{
|
||||
public class ChannelRepresentation
|
||||
{
|
||||
public enum ChannelTypeEnum
|
||||
{
|
||||
SQUIB,
|
||||
TOMDigital,
|
||||
DigitalInput,
|
||||
Other
|
||||
}
|
||||
|
||||
private readonly ChannelTypeEnum _channelType = ChannelTypeEnum.Other;
|
||||
|
||||
public ChannelRepresentation(DataModel.DASHardware h, DTS.DASLib.Service.DASChannel c,
|
||||
int startingChannelNumber)
|
||||
{
|
||||
//adjust the starting channel number (which appears to be a DAS channel number) to a module channel number
|
||||
if (h.CareAboutModules)
|
||||
{
|
||||
startingChannelNumber = 1 + c.ModuleChannelNumber;
|
||||
}
|
||||
if (c is DTS.DASLib.Service.OutputSquibChannel)
|
||||
{
|
||||
startingChannelNumber = DoSquibConversion(startingChannelNumber);
|
||||
_channelType = ChannelTypeEnum.SQUIB;
|
||||
}
|
||||
else if (c is DTS.DASLib.Service.OutputTOMDigitalChannel)
|
||||
{
|
||||
_channelType = ChannelTypeEnum.TOMDigital;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((c as DTS.DASLib.Service.AnalogInputDASChannel).SupportedBridges.Length == 1) &&
|
||||
((c as DTS.DASLib.Service.AnalogInputDASChannel).SupportedBridges[0] ==
|
||||
SensorConstants.BridgeType.DigitalInput))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.DigitalInput;
|
||||
}
|
||||
}
|
||||
|
||||
ConvertChannelNumbers(h.DASTypeEnum, startingChannelNumber, h.SerialNumber, c.OwningModule.SerialNumber(),
|
||||
_channelType);
|
||||
}
|
||||
|
||||
|
||||
private int GetModuleChannelNumber(DataModel.HardwareChannel c)
|
||||
{
|
||||
if (null == c.Hardware)
|
||||
{
|
||||
return 1 + c.ChannelNumber;
|
||||
}
|
||||
var moduleChannelNumber = 0;
|
||||
var moduleArrayIndex = -1;
|
||||
|
||||
foreach (var ch in c.Hardware.Channels)
|
||||
{
|
||||
if (ch.ModuleArrayIndex != moduleArrayIndex)
|
||||
{
|
||||
moduleChannelNumber = 0;
|
||||
moduleArrayIndex = ch.ModuleArrayIndex;
|
||||
}
|
||||
moduleChannelNumber++;
|
||||
if (ch.ChannelNumber == c.ChannelNumber)
|
||||
{
|
||||
return moduleChannelNumber;
|
||||
}
|
||||
}
|
||||
return 1 + c.ChannelNumber;
|
||||
}
|
||||
|
||||
public ChannelRepresentation(DataModel.HardwareChannel c, int startingChannelNumber, IDASHardware[] hardwares = null)
|
||||
{
|
||||
if (null != c.Hardware && c.Hardware.CareAboutModules)
|
||||
{
|
||||
startingChannelNumber = GetModuleChannelNumber(c);
|
||||
}
|
||||
if (c.IsSupportedBridgeType(SensorConstants.BridgeType.SQUIB))
|
||||
{
|
||||
startingChannelNumber = DoSquibConversion(startingChannelNumber);
|
||||
_channelType = ChannelTypeEnum.SQUIB;
|
||||
}
|
||||
else if (c.IsSupportedBridgeType(SensorConstants.BridgeType.TOMDigital))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.TOMDigital;
|
||||
}
|
||||
else if (c.IsSupportedBridgeType(SensorConstants.BridgeType.DigitalInput))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.DigitalInput;
|
||||
}
|
||||
|
||||
var moduleSerialNumber = c.ModuleSerialNumber;
|
||||
var dasSerialNumber = c.Hardware.SerialNumber;
|
||||
|
||||
var h = c.Hardware.GetHardware();
|
||||
if (h.StandIn)
|
||||
{
|
||||
dasSerialNumber = EnumDescriptionTypeConverter.GetEnumDescription(h.DASTypeEnum);
|
||||
switch (c.Hardware.DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
break;
|
||||
default:
|
||||
moduleSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (c.Hardware.IsPseudoRackModule() && c.Hardware.IsModule())
|
||||
{
|
||||
moduleSerialNumber = c.Hardware.SerialNumber;
|
||||
dasSerialNumber = c.Hardware.ParentDAS;
|
||||
}
|
||||
else if (c.Hardware.IsTSRAIRModule() && c.Hardware.IsModule())
|
||||
{
|
||||
moduleSerialNumber = c.Hardware.SerialNumber;
|
||||
dasSerialNumber = string.IsNullOrWhiteSpace(c.Hardware.ParentDAS) ?
|
||||
c.Hardware.Connection.Split(new[] { "xEMB" }, StringSplitOptions.RemoveEmptyEntries)[0] :
|
||||
c.Hardware.ParentDAS;
|
||||
}
|
||||
|
||||
ConvertChannelNumbers(c.Hardware.DASTypeEnum, startingChannelNumber, dasSerialNumber, moduleSerialNumber,
|
||||
_channelType, hardwares);
|
||||
if (!c.Hardware.IsTSRAIR())
|
||||
{
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
}
|
||||
}
|
||||
|
||||
public string DASSerialNumber { get; set; } = string.Empty;
|
||||
|
||||
public string SerialNumber //Module
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = string.Empty;
|
||||
|
||||
public string ChannelNumberString { get; set; } = string.Empty;
|
||||
|
||||
public int ChannelNumber { get; set; } = 0;
|
||||
|
||||
private int DoSquibConversion(int squibChannelNumber)
|
||||
{
|
||||
Math.DivRem(squibChannelNumber, 8, out var remainder);
|
||||
switch (remainder)
|
||||
{
|
||||
case 1:
|
||||
return 1;
|
||||
case 3:
|
||||
return 2;
|
||||
case 5:
|
||||
return 3;
|
||||
case 7:
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConvertChannelNumbers(HardwareTypes dasType, int startingChannelNumber, string dasSerialNumber,
|
||||
string moduleSerialNumber,
|
||||
ChannelTypeEnum channelType, IDASHardware[] hardwares = null)
|
||||
{
|
||||
var displayChannelNumber = 0;
|
||||
switch (dasType)
|
||||
{
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
if (moduleSerialNumber.StartsWith("DIM"))
|
||||
{
|
||||
Math.DivRem(startingChannelNumber - 1, 16, out displayChannelNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
}
|
||||
}
|
||||
displayChannelNumber++;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
// Start counting the Digital Output channels from 1
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.G5VDS: // Start counting the Digital Input channels from 1
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
Math.DivRem(startingChannelNumber - 1, 32, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.SLICE1_G5Stack:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.SLICE_Base: //Is this the micro base?
|
||||
case HardwareTypes.SLICE_Micro_Base: //Is this the micro base?
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: //This is for nano
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: //This is for micro
|
||||
case HardwareTypes.SLICE_NANO_Base: //This is for nano
|
||||
Math.DivRem(startingChannelNumber - 1, 3, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
case HardwareTypes.SLICE_PRO_CAN_FD:
|
||||
|
||||
bool isPseudoDAS = false;
|
||||
IDASHardware[] list = null;
|
||||
if (null != hardwares)
|
||||
{
|
||||
list = hardwares;
|
||||
}
|
||||
else { list = DASHardwareList.GetAllHardware(); }
|
||||
if (list.Any())
|
||||
{
|
||||
//13096 Unhandled exception clicking save in hardware disco (test setup)
|
||||
var matches = from das in list where das.SerialNumber == dasSerialNumber select das;
|
||||
if (matches.Any())
|
||||
{
|
||||
isPseudoDAS = matches.First().IsPseudoRack();
|
||||
}
|
||||
}
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = isPseudoDAS ? moduleSerialNumber : dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.EMB_ANG_ARS:
|
||||
case HardwareTypes.EMB_ATM:
|
||||
case HardwareTypes.EMB_LIN_ACC_HI:
|
||||
case HardwareTypes.EMB_LIN_ACC_LO:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = moduleSerialNumber; //dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber; //.Substring(0, dasSerialNumber.IndexOf('-'));
|
||||
break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
case HardwareTypes.DIR:
|
||||
case HardwareTypes.DKR:
|
||||
Math.DivRem(startingChannelNumber - 1, 3, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_TC:
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
var displayModuleNumber = Math.DivRem(startingChannelNumber - 1, SLICE6AIRTC.ThermocouplersPerModule, out displayChannelNumber);
|
||||
SerialNumber = string.Format(StringResources.ModuleNumber, displayModuleNumber.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
if (moduleSerialNumber.StartsWith(StringResources.StreamOut))
|
||||
{
|
||||
//Stream out
|
||||
displayChannelNumber = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Thermocoupler
|
||||
Math.DivRem(startingChannelNumber - 1, SLICE6AIRTC.ThermocouplersPerModule, out displayChannelNumber);
|
||||
}
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
displayChannelNumber++;
|
||||
break;
|
||||
default:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
}
|
||||
if (channelType == ChannelTypeEnum.SQUIB)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_Squib + displayChannelNumber.ToString("00");
|
||||
}
|
||||
else if (channelType == ChannelTypeEnum.TOMDigital)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_DigitalOut +
|
||||
displayChannelNumber.ToString("00");
|
||||
}
|
||||
else if (channelType == ChannelTypeEnum.DigitalInput)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_DigitalIn +
|
||||
displayChannelNumber.ToString("00");
|
||||
}
|
||||
else
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_Other + displayChannelNumber.ToString("00");
|
||||
}
|
||||
ChannelNumber = displayChannelNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
<?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>{2A2F03A9-BF85-4360-A06A-CF3016D2633B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DTS.Common.DataModel</RootNamespace>
|
||||
<AssemblyName>DTS.Common.DataModel</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</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>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\DataPRO\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="PresentationFramework.Aero" />
|
||||
<Reference Include="Prism">
|
||||
<HintPath>..\DTS.Common\lib\PrismLibrary\Prism.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism.Unity.Wpf">
|
||||
<HintPath>..\DTS.Common\lib\PrismLibrary\Prism.Unity.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism.Wpf">
|
||||
<HintPath>..\DTS.Common\lib\PrismLibrary\Prism.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Stateless">
|
||||
<HintPath>..\DTS.Common\lib\Stateless.4.2.1\lib\net45\Stateless.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<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="Unity.Abstractions">
|
||||
<HintPath>..\DTS.Common\lib\PrismLibrary\Unity.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Container">
|
||||
<HintPath>..\DTS.Common\lib\PrismLibrary\Unity.Container.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ApplicationProperties.cs" />
|
||||
<Compile Include="ChannelRepresentation.cs" />
|
||||
<Compile Include="Classes\Arming\Arming.cs" />
|
||||
<Compile Include="Classes\Configuration\Configuration.cs" />
|
||||
<Compile Include="Classes\Diagnostics\Diagnostics.cs" />
|
||||
<Compile Include="Classes\Enums.cs" />
|
||||
<Compile Include="Classes\Export\ExportHeader.cs" />
|
||||
<Compile Include="Classes\Export\ExportTestSetup.cs" />
|
||||
<Compile Include="Classes\Hardware\BatteryAndInputVoltageDefaults.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\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\BuildTestSetup.cs" />
|
||||
<Compile Include="Classes\TestTemplate\DownloadEvent.cs" />
|
||||
<Compile Include="Classes\TestTemplate\HardwareInclusionInstruction.cs" />
|
||||
<Compile Include="Classes\TestTemplate\ICachedContainer.cs" />
|
||||
<Compile Include="Classes\TestTemplate\TestTemplate.cs" />
|
||||
<Compile Include="Classes\TestTemplate\TestTemplateList.cs" />
|
||||
<Compile Include="Classes\TestTemplate\TSRAIRGoTestSetup.cs" />
|
||||
<Compile Include="Classes\TSRAIRGo\TSRAIRGoStatus.cs" />
|
||||
<Compile Include="CollectDataProcess.cs" />
|
||||
<Compile Include="Common\ChannelHelper.cs" />
|
||||
<Compile Include="Common\DbWrappers\DASGet.cs" />
|
||||
<Compile Include="Common\DbWrappers\TestSetupHardwareGet.cs" />
|
||||
<Compile Include="Common\SerializedSettings.cs" />
|
||||
<Compile Include="Common\StatusHelpers.cs" />
|
||||
<Compile Include="Common\TestObjectHelper.cs" />
|
||||
<Compile Include="Common\TestSetupCollection.cs" />
|
||||
<Compile Include="CustomChannel.cs" />
|
||||
<Compile Include="DASFactory.cs" />
|
||||
<Compile Include="DataFiles.cs" />
|
||||
<Compile Include="Group.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="DataModelSettings.cs" />
|
||||
<Compile Include="SensorDatabaseExport.cs" />
|
||||
<Compile Include="StateMachines\OverallArmStatusStateMachine.cs" />
|
||||
<Compile Include="SysBuiltObjectType.cs" />
|
||||
<Compile Include="TestGraph.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\DataPRO\DASFactory\DASFactory.csproj">
|
||||
<Project>{02eeba8c-7b22-4bc3-bf3a-8de23eaf2e61}</Project>
|
||||
<Name>DASFactory</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\DataPRO\EquipmentExchange\EquipmentExchange.csproj">
|
||||
<Project>{2513797d-ec82-48d5-969e-6b3b5e6002e3}</Project>
|
||||
<Name>EquipmentExchange</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\DataPRO\ICommand\ICommand.csproj">
|
||||
<Project>{58e70872-8acc-4957-bb8e-d3746bcc536d}</Project>
|
||||
<Name>ICommand</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\DataPRO\IService\IService.csproj">
|
||||
<Project>{c9c45b72-05a3-4962-bc13-a78b1f4b1925}</Project>
|
||||
<Name>IService</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\DataPRO\SensorDB\SensorDB.csproj">
|
||||
<Project>{444ef10c-046e-47ad-a9a5-17318d488723}</Project>
|
||||
<Name>SensorDB</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\DataPRO\TDASCommands\TDASCommands.csproj">
|
||||
<Project>{14b4a79f-a4b5-4c4c-a041-0105eed82782}</Project>
|
||||
<Name>TDASCommands</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\DataPRO\Users\Users.csproj">
|
||||
<Project>{be8d217d-6da9-4bca-b62a-a82325b33979}</Project>
|
||||
<Name>Users</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common.DAS.Concepts\DTS.Common.DAS.Concepts.csproj">
|
||||
<Project>{ae3987f7-c4c6-40fb-a353-1a2dadef7a9a}</Project>
|
||||
<Name>DTS.Common.DAS.Concepts</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common.ISO\DTS.Common.ISO.csproj">
|
||||
<Project>{27d0c63b-9095-42da-95fd-f64444c80558}</Project>
|
||||
<Name>DTS.Common.ISO</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common.Licensing\DTS.Common.Licensing.csproj">
|
||||
<Project>{8b169b1c-37cb-4b7c-8071-385036b96faa}</Project>
|
||||
<Name>DTS.Common.Licensing</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common.SerializationPlus\DTS.Common.SerializationPlus.csproj">
|
||||
<Project>{b9d1ac5b-7a6f-4b14-9ff8-3a1fc03519e2}</Project>
|
||||
<Name>DTS.Common.SerializationPlus</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common.Serialization\DTS.Common.Serialization.csproj">
|
||||
<Project>{0679d014-59c2-4327-b288-0e3bd1374710}</Project>
|
||||
<Name>DTS.Common.Serialization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common.SettingsDB\DTS.Common.Settings.csproj">
|
||||
<Project>{61017104-d8ee-41d1-b9ca-dad863ff78b2}</Project>
|
||||
<Name>DTS.Common.Settings</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common.SharedResource\DTS.Common.SharedResource.csproj">
|
||||
<Project>{c01e723f-86e2-403a-864c-9f56bdb60b8d}</Project>
|
||||
<Name>DTS.Common.SharedResource</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common.Storage\DTS.Common.Storage.csproj">
|
||||
<Project>{e3be457c-0ac7-4a9c-bc81-eafeb3217878}</Project>
|
||||
<Name>DTS.Common.Storage</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common.Utilities\DTS.Common.Utilities.csproj">
|
||||
<Project>{d6da1b74-c711-43c2-91b1-1908a8d04dbf}</Project>
|
||||
<Name>DTS.Common.Utilities</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common\DTS.Common.csproj">
|
||||
<Project>{f7a0804f-61a4-40ae-83d0-f1137622b592}</Project>
|
||||
<Name>DTS.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,461 @@
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
|
||||
namespace DataPROWin7.DataModel.BatteryAndInputVoltageDefaults
|
||||
{
|
||||
public class DasBatteryInputSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// all possible battery settings
|
||||
/// note that the order is important since serialization assumes this order,
|
||||
/// so don't change order without addressing that.
|
||||
/// </summary>
|
||||
public enum Settings
|
||||
{
|
||||
BatteryLowDiagnosticsThreshold,
|
||||
BatteryHighDiagnosticsThreshold,
|
||||
BatteryLowArmedThreshold,
|
||||
BatteryHighArmedThreshold,
|
||||
InputLowDiagnosticsThreshold,
|
||||
InputHighDiagnosticsThreshold,
|
||||
InputLowArmedThreshold,
|
||||
InputHighArmedThreshold,
|
||||
MinimumValidBatteryThreshold,
|
||||
MinimumValidInputThreshold,
|
||||
MaximumValidBatteryThreshold,
|
||||
MaximumValidInputThreshold,
|
||||
BatteryMediumDiagnosticsThreshold,
|
||||
BatteryMediumArmedThreshold,
|
||||
InputMediumDiagnosticsThreshold,
|
||||
InputMediumArmedThreshold,
|
||||
}
|
||||
|
||||
public double BatteryLowDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryLowDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryLowDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryHighDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryHighDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryHighDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryLowArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryLowArmedThreshold);
|
||||
set => SetValue(Settings.BatteryLowArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryHighArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryHighArmedThreshold);
|
||||
set => SetValue(Settings.BatteryHighArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputLowDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputLowDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputLowDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputHighDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputHighDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputHighDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputLowArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputLowArmedThreshold);
|
||||
set => SetValue(Settings.InputLowArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputHighArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputHighArmedThreshold);
|
||||
set => SetValue(Settings.InputHighArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double MinimumValidBatteryThreshold
|
||||
{
|
||||
get => GetValue(Settings.MinimumValidBatteryThreshold);
|
||||
set => SetValue(Settings.MinimumValidBatteryThreshold, value);
|
||||
}
|
||||
|
||||
public double MinimumValidInputThreshold
|
||||
{
|
||||
get => GetValue(Settings.MinimumValidInputThreshold);
|
||||
set => SetValue(Settings.MinimumValidInputThreshold, value);
|
||||
}
|
||||
|
||||
public double MaximumValidBatteryThreshold
|
||||
{
|
||||
get => GetValue(Settings.MaximumValidBatteryThreshold);
|
||||
set => SetValue(Settings.MaximumValidBatteryThreshold, value);
|
||||
}
|
||||
|
||||
public double MaximumValidInputThreshold
|
||||
{
|
||||
get => GetValue(Settings.MaximumValidInputThreshold);
|
||||
set => SetValue(Settings.MaximumValidInputThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryMediumDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryMediumDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryMediumDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryMediumArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryMediumArmedThreshold);
|
||||
set => SetValue(Settings.BatteryMediumArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputMediumDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputMediumDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputMediumDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputMediumArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputMediumArmedThreshold);
|
||||
set => SetValue(Settings.InputMediumArmedThreshold, value);
|
||||
}
|
||||
public Dictionary<Settings, double> SettingsProperty { get; } = new Dictionary<Settings, double>();
|
||||
|
||||
public DasBatteryInputSettings(string s)
|
||||
{
|
||||
var tokens = s.Split(new char[] { ',' });
|
||||
for (int i = 0; i < tokens.Length; i++)
|
||||
{
|
||||
var setting = (Settings)i;
|
||||
if (double.TryParse(tokens[i], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out double d))
|
||||
{
|
||||
SettingsProperty[setting] = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
public DasBatteryInputSettings(DasBatteryInputSettings copy)
|
||||
{
|
||||
using (var e = copy.SettingsProperty.GetEnumerator())
|
||||
{
|
||||
while (e.MoveNext())
|
||||
{
|
||||
SettingsProperty[e.Current.Key] = e.Current.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public DasBatteryInputSettings()
|
||||
{
|
||||
var settings = Enum.GetValues(typeof(Settings)).Cast<Settings>().ToArray();
|
||||
foreach (var s in settings)
|
||||
{
|
||||
double d = double.NaN;
|
||||
switch (s)
|
||||
{
|
||||
case Settings.BatteryHighArmedThreshold: d = 9D; break;
|
||||
case Settings.BatteryHighDiagnosticsThreshold: d = 9D; break;
|
||||
case Settings.BatteryLowArmedThreshold: d = 6.8D; break;
|
||||
case Settings.BatteryLowDiagnosticsThreshold: d = 7.8D; break;
|
||||
case Settings.InputHighArmedThreshold: d = 15.3; break;
|
||||
case Settings.InputHighDiagnosticsThreshold: d = 15.3; break;
|
||||
case Settings.InputLowArmedThreshold: d = 6.5D; break;
|
||||
case Settings.InputLowDiagnosticsThreshold: d = 10D; break;
|
||||
case Settings.MinimumValidBatteryThreshold: d = 4D; break;
|
||||
case Settings.MinimumValidInputThreshold: d = 4D; break;
|
||||
case Settings.MaximumValidBatteryThreshold: d = 9D; break;
|
||||
case Settings.MaximumValidInputThreshold: d = 19D; break;
|
||||
|
||||
case Settings.BatteryMediumArmedThreshold: d = 7.9D; break; //7.9 is halfway between low and high
|
||||
case Settings.BatteryMediumDiagnosticsThreshold: d = 8.4D; break; //8.4 is halfway between low and high
|
||||
case Settings.InputMediumArmedThreshold: d = 10.9D; break; //10.9 is halfway between low and high
|
||||
case Settings.InputMediumDiagnosticsThreshold: d = 12.7D; break; //12.7 is halfway between low and high
|
||||
|
||||
default: throw new NotSupportedException("Unknown Battery setting: " + s.ToString());
|
||||
}
|
||||
SettingsProperty[s] = d;
|
||||
}
|
||||
}
|
||||
public string ToSerializedString()
|
||||
{
|
||||
var settings = Enum.GetValues(typeof(Settings)).Cast<Settings>().ToArray();
|
||||
var sb = new string[settings.Length];
|
||||
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
sb[(int)setting] = GetValue(setting).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
return string.Join(",", sb);
|
||||
}
|
||||
public double GetValue(Settings setting)
|
||||
{
|
||||
if (SettingsProperty.ContainsKey(setting)) { return SettingsProperty[setting]; }
|
||||
else { throw new NotSupportedException("unknown setting: " + setting.ToString()); }
|
||||
}
|
||||
|
||||
public void SetValue(Settings setting, double d)
|
||||
{
|
||||
SettingsProperty[setting] = d;
|
||||
}
|
||||
}
|
||||
public static class InputAndBatterySettings
|
||||
{
|
||||
/// <summary>
|
||||
/// holds the battery/input settings in a cache so they don't have to be requeried from db
|
||||
/// 17615 BatteryAndInputVoltageDefaults improvements 3.2
|
||||
/// </summary>
|
||||
public static Dictionary<HardwareTypes, DasBatteryInputSettings> _cache =
|
||||
new Dictionary<HardwareTypes, DasBatteryInputSettings>();
|
||||
|
||||
/// <summary>
|
||||
/// clears the cache. This serves the purpose of ensuring
|
||||
/// that the values will be re-queried between runs, so if the settings are changed
|
||||
/// between runs the new values will be used
|
||||
/// </summary>
|
||||
public static void ClearCache()
|
||||
{
|
||||
_cache.Clear();
|
||||
}
|
||||
public static double GetValue(string DasType, DasBatteryInputSettings.Settings setting)
|
||||
{
|
||||
if (Enum.TryParse(DasType, out HardwareTypes type))
|
||||
{
|
||||
return GetValue(type, setting);
|
||||
}
|
||||
else { return double.NaN; }
|
||||
}
|
||||
|
||||
public static DasBatteryInputSettings GetDefaultSettingForHWType(HardwareTypes type)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
if (_cache.ContainsKey(type))
|
||||
{
|
||||
return _cache[type];
|
||||
}
|
||||
}
|
||||
DasBatteryInputSettings setting = null;
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY: setting = Common.SerializedSettings.G5INDUMMY_PowerSetting_Default; break;
|
||||
case HardwareTypes.G5VDS: setting = Common.SerializedSettings.G5VDS_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE_Distributor: setting = Common.SerializedSettings.SLICE_Distributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor: setting = Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_EthernetController: setting = Common.SerializedSettings.SLICE_EthernetController_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_LabEthernet: setting = Common.SerializedSettings.SLICE_LabEthernet_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE_Micro_Base: setting = Common.SerializedSettings.SLICE_Micro_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_NANO_Base: setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: setting = Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: setting = Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE1_G5Stack: setting = Common.SerializedSettings.SLICE1_G5Stack_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE2_DIM: setting = Common.SerializedSettings.SLICE2_DIM_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
setting = Common.SerializedSettings.SLICE2_SIM_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_TOM: setting = Common.SerializedSettings.SLICE2_TOM_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE2_SLD: setting = Common.SerializedSettings.SLICE2_SLD_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SLS: setting = Common.SerializedSettings.SLICE2_SLS_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SLT: setting = Common.SerializedSettings.SLICE2_SLT_PowerSetting_Default; break;
|
||||
|
||||
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
setting = Common.SerializedSettings.SLICE6_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB: setting = Common.SerializedSettings.SLICE6Db_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB3: setting = Common.SerializedSettings.SLICE6Db3_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: setting = Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting_Default; break;
|
||||
case HardwareTypes.PowerPro: setting = Common.SerializedSettings.PowerPRO_PowerSetting_Default; break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
setting = Common.SerializedSettings.TSRAIR_PowerSetting_Default; break;
|
||||
//case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting_Default; break;
|
||||
//case HardwareTypes.Falcon: setting = Common.SerializedSettings.Falcon_PowerSetting_Default; break;
|
||||
}
|
||||
|
||||
if (null != setting)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
_cache[type] = setting;
|
||||
}
|
||||
return setting;
|
||||
}
|
||||
|
||||
throw new NotSupportedException($"unknown type: {type.ToString()}");
|
||||
}
|
||||
public static void SetSettingForHWType(HardwareTypes type,
|
||||
DasBatteryInputSettings setting)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
Common.SerializedSettings.G5INDUMMY_PowerSetting = setting; break;
|
||||
case HardwareTypes.G5VDS:
|
||||
Common.SerializedSettings.G5VDS_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Distributor:
|
||||
Common.SerializedSettings.SLICE_Distributor_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB: Common.SerializedSettings.SLICE6Db_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB3: Common.SerializedSettings.SLICE6Db3_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: Common.SerializedSettings.SLICEPRODistributor_PowerSetting = setting; break;
|
||||
//case HardwareTypes.SLICE6DB_AIR: Common.SerializedSettings.SLICE6Db_AIR_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor:
|
||||
Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
Common.SerializedSettings.SLICE_EthernetController_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
Common.SerializedSettings.SLICE_LabEthernet_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Micro_Base:
|
||||
Common.SerializedSettings.SLICE_Micro_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_NANO_Base:
|
||||
Common.SerializedSettings.SLICE_NANO_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_5_Micro_Base:
|
||||
Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base:
|
||||
Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_G5Stack:
|
||||
Common.SerializedSettings.SLICE1_G5Stack_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
Common.SerializedSettings.SLICE2_DIM_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
Common.SerializedSettings.SLICE2_SIM_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
Common.SerializedSettings.SLICE2_SLD_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
Common.SerializedSettings.SLICE2_SLS_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
Common.SerializedSettings.SLICE2_SLT_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
Common.SerializedSettings.SLICE2_TOM_PowerSetting = setting; break;
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
Common.SerializedSettings.SLICE6_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
Common.SerializedSettings.SLICE6_AIR_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.PowerPro:
|
||||
Common.SerializedSettings.PowerPRO_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
Common.SerializedSettings.TSRAIR_PowerSetting = setting;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static DasBatteryInputSettings GetSettingForHWType(HardwareTypes type)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
if (_cache.ContainsKey(type))
|
||||
{
|
||||
return _cache[type];
|
||||
}
|
||||
}
|
||||
|
||||
DasBatteryInputSettings setting = null;
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY: setting = Common.SerializedSettings.G5INDUMMY_PowerSetting; break;
|
||||
case HardwareTypes.G5VDS: setting = Common.SerializedSettings.G5VDS_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE_Distributor: setting = Common.SerializedSettings.SLICE_Distributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor: setting = Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB: setting = Common.SerializedSettings.SLICE6Db_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB3: setting = Common.SerializedSettings.SLICE6Db3_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: setting = Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_EthernetController: setting = Common.SerializedSettings.SLICE_EthernetController_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_LabEthernet: setting = Common.SerializedSettings.SLICE_LabEthernet_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE_Micro_Base: setting = Common.SerializedSettings.SLICE_Micro_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_NANO_Base: setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: setting = Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: setting = Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_G5Stack: setting = Common.SerializedSettings.SLICE1_G5Stack_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_DIM: setting = Common.SerializedSettings.SLICE2_DIM_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
setting = Common.SerializedSettings.SLICE2_SIM_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLD: setting = Common.SerializedSettings.SLICE2_SLD_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLS: setting = Common.SerializedSettings.SLICE2_SLS_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLT: setting = Common.SerializedSettings.SLICE2_SLT_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_TOM: setting = Common.SerializedSettings.SLICE2_TOM_PowerSetting; break;
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting; break;
|
||||
case HardwareTypes.DIM:
|
||||
case HardwareTypes.SIM:
|
||||
case HardwareTypes.TOM:
|
||||
//we are not expected to get here but if we do, just use the tdas default
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting; break;
|
||||
case HardwareTypes.Ribeye:
|
||||
case HardwareTypes.RibeyeLED:
|
||||
case HardwareTypes.SLICE_Base:
|
||||
case HardwareTypes.SLICE_Bridge:
|
||||
case HardwareTypes.SLICE_IEPE:
|
||||
case HardwareTypes.SLICE2_IEPE_Hi:
|
||||
case HardwareTypes.SLICE2_IEPE_Lo:
|
||||
//these are all never expected to get here, but are all slice types
|
||||
setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_Base: setting = Common.SerializedSettings.SLICE6_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
case HardwareTypes.S6A_EthernetRecorder:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting; break;
|
||||
case HardwareTypes.PowerPro: setting = Common.SerializedSettings.PowerPRO_PowerSetting; break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
setting = Common.SerializedSettings.TSRAIR_PowerSetting;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_TC:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_TC_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_PRO_CAN_FD:
|
||||
setting = Common.SerializedSettings.SLICE_Micro_Base_PowerSetting; break;
|
||||
default:
|
||||
throw new NotSupportedException("unknown das type: " + type.ToString());
|
||||
}
|
||||
if (null != setting)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
_cache[type] = setting;
|
||||
}
|
||||
}
|
||||
return setting;
|
||||
}
|
||||
public static double GetValue(HardwareTypes type, DasBatteryInputSettings.Settings setting)
|
||||
{
|
||||
return GetSettingForHWType(type).GetValue(setting);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using DataPROWin7.DataModel.Classes.Hardware;
|
||||
using DTS.Common.Converters;
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using DTS.Common.Constant.DASSpecific;
|
||||
|
||||
namespace DataPROWin7
|
||||
{
|
||||
public class ChannelRepresentation
|
||||
{
|
||||
public enum ChannelTypeEnum
|
||||
{
|
||||
SQUIB,
|
||||
TOMDigital,
|
||||
DigitalInput,
|
||||
Other
|
||||
}
|
||||
|
||||
private readonly ChannelTypeEnum _channelType = ChannelTypeEnum.Other;
|
||||
|
||||
public ChannelRepresentation(DataModel.DASHardware h, DTS.DASLib.Service.DASChannel c,
|
||||
int startingChannelNumber)
|
||||
{
|
||||
//adjust the starting channel number (which appears to be a DAS channel number) to a module channel number
|
||||
if (h.CareAboutModules)
|
||||
{
|
||||
startingChannelNumber = 1 + c.ModuleChannelNumber;
|
||||
}
|
||||
if (c is DTS.DASLib.Service.OutputSquibChannel)
|
||||
{
|
||||
startingChannelNumber = DoSquibConversion(startingChannelNumber);
|
||||
_channelType = ChannelTypeEnum.SQUIB;
|
||||
}
|
||||
else if (c is DTS.DASLib.Service.OutputTOMDigitalChannel)
|
||||
{
|
||||
_channelType = ChannelTypeEnum.TOMDigital;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((c as DTS.DASLib.Service.AnalogInputDASChannel).SupportedBridges.Length == 1) &&
|
||||
((c as DTS.DASLib.Service.AnalogInputDASChannel).SupportedBridges[0] ==
|
||||
SensorConstants.BridgeType.DigitalInput))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.DigitalInput;
|
||||
}
|
||||
}
|
||||
|
||||
ConvertChannelNumbers(h.DASTypeEnum, startingChannelNumber, h.SerialNumber, c.OwningModule.SerialNumber(),
|
||||
_channelType);
|
||||
}
|
||||
|
||||
|
||||
private int GetModuleChannelNumber(DataModel.HardwareChannel c)
|
||||
{
|
||||
if (null == c.Hardware)
|
||||
{
|
||||
return 1 + c.ChannelNumber;
|
||||
}
|
||||
var moduleChannelNumber = 0;
|
||||
var moduleArrayIndex = -1;
|
||||
|
||||
foreach (var ch in c.Hardware.Channels)
|
||||
{
|
||||
if (ch.ModuleArrayIndex != moduleArrayIndex)
|
||||
{
|
||||
moduleChannelNumber = 0;
|
||||
moduleArrayIndex = ch.ModuleArrayIndex;
|
||||
}
|
||||
moduleChannelNumber++;
|
||||
if (ch.ChannelNumber == c.ChannelNumber)
|
||||
{
|
||||
return moduleChannelNumber;
|
||||
}
|
||||
}
|
||||
return 1 + c.ChannelNumber;
|
||||
}
|
||||
|
||||
public ChannelRepresentation(DataModel.HardwareChannel c, int startingChannelNumber, IDASHardware[] hardwares = null)
|
||||
{
|
||||
if (null != c.Hardware && c.Hardware.CareAboutModules)
|
||||
{
|
||||
startingChannelNumber = GetModuleChannelNumber(c);
|
||||
}
|
||||
if (c.IsSupportedBridgeType(SensorConstants.BridgeType.SQUIB))
|
||||
{
|
||||
startingChannelNumber = DoSquibConversion(startingChannelNumber);
|
||||
_channelType = ChannelTypeEnum.SQUIB;
|
||||
}
|
||||
else if (c.IsSupportedBridgeType(SensorConstants.BridgeType.TOMDigital))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.TOMDigital;
|
||||
}
|
||||
else if (c.IsSupportedBridgeType(SensorConstants.BridgeType.DigitalInput))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.DigitalInput;
|
||||
}
|
||||
|
||||
var moduleSerialNumber = c.ModuleSerialNumber;
|
||||
var dasSerialNumber = c.Hardware.SerialNumber;
|
||||
|
||||
var h = c.Hardware.GetHardware();
|
||||
if (h.StandIn)
|
||||
{
|
||||
dasSerialNumber = EnumDescriptionTypeConverter.GetEnumDescription(h.DASTypeEnum);
|
||||
switch (c.Hardware.DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
break;
|
||||
default:
|
||||
moduleSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (c.Hardware.IsPseudoRackModule() && c.Hardware.IsModule())
|
||||
{
|
||||
moduleSerialNumber = c.Hardware.SerialNumber;
|
||||
dasSerialNumber = c.Hardware.ParentDAS;
|
||||
}
|
||||
else if (c.Hardware.IsTSRAIRModule() && c.Hardware.IsModule())
|
||||
{
|
||||
moduleSerialNumber = c.Hardware.SerialNumber;
|
||||
dasSerialNumber = string.IsNullOrWhiteSpace(c.Hardware.ParentDAS) ?
|
||||
c.Hardware.Connection.Split(new[] { "xEMB" }, StringSplitOptions.RemoveEmptyEntries)[0] :
|
||||
c.Hardware.ParentDAS;
|
||||
}
|
||||
|
||||
ConvertChannelNumbers(c.Hardware.DASTypeEnum, startingChannelNumber, dasSerialNumber, moduleSerialNumber,
|
||||
_channelType, hardwares);
|
||||
if (!c.Hardware.IsTSRAIR())
|
||||
{
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
}
|
||||
}
|
||||
|
||||
public string DASSerialNumber { get; set; } = string.Empty;
|
||||
|
||||
public string SerialNumber //Module
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = string.Empty;
|
||||
|
||||
public string ChannelNumberString { get; set; } = string.Empty;
|
||||
|
||||
public int ChannelNumber { get; set; } = 0;
|
||||
|
||||
private int DoSquibConversion(int squibChannelNumber)
|
||||
{
|
||||
Math.DivRem(squibChannelNumber, 8, out var remainder);
|
||||
switch (remainder)
|
||||
{
|
||||
case 1:
|
||||
return 1;
|
||||
case 3:
|
||||
return 2;
|
||||
case 5:
|
||||
return 3;
|
||||
case 7:
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConvertChannelNumbers(HardwareTypes dasType, int startingChannelNumber, string dasSerialNumber,
|
||||
string moduleSerialNumber,
|
||||
ChannelTypeEnum channelType, IDASHardware[] hardwares = null)
|
||||
{
|
||||
var displayChannelNumber = 0;
|
||||
switch (dasType)
|
||||
{
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
if (moduleSerialNumber.StartsWith("DIM"))
|
||||
{
|
||||
Math.DivRem(startingChannelNumber - 1, 16, out displayChannelNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
}
|
||||
}
|
||||
displayChannelNumber++;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
// Start counting the Digital Output channels from 1
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.G5VDS: // Start counting the Digital Input channels from 1
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
Math.DivRem(startingChannelNumber - 1, 32, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.SLICE1_G5Stack:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.SLICE_Base: //Is this the micro base?
|
||||
case HardwareTypes.SLICE_Micro_Base: //Is this the micro base?
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: //This is for nano
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: //This is for micro
|
||||
case HardwareTypes.SLICE_NANO_Base: //This is for nano
|
||||
Math.DivRem(startingChannelNumber - 1, 3, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
case HardwareTypes.SLICE_PRO_CAN_FD:
|
||||
|
||||
bool isPseudoDAS = false;
|
||||
IDASHardware[] list = null;
|
||||
if (null != hardwares)
|
||||
{
|
||||
list = hardwares;
|
||||
}
|
||||
else { list = DASHardwareList.GetAllHardware(); }
|
||||
if (list.Any())
|
||||
{
|
||||
//13096 Unhandled exception clicking save in hardware disco (test setup)
|
||||
var matches = from das in list where das.SerialNumber == dasSerialNumber select das;
|
||||
if (matches.Any())
|
||||
{
|
||||
isPseudoDAS = matches.First().IsPseudoRack();
|
||||
}
|
||||
}
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = isPseudoDAS ? moduleSerialNumber : dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.EMB_ANG_ARS:
|
||||
case HardwareTypes.EMB_ATM:
|
||||
case HardwareTypes.EMB_LIN_ACC_HI:
|
||||
case HardwareTypes.EMB_LIN_ACC_LO:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = moduleSerialNumber; //dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber; //.Substring(0, dasSerialNumber.IndexOf('-'));
|
||||
break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
case HardwareTypes.DIR:
|
||||
case HardwareTypes.DKR:
|
||||
Math.DivRem(startingChannelNumber - 1, 3, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_TC:
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
var displayModuleNumber = Math.DivRem(startingChannelNumber - 1, SLICE6AIRTC.ThermocouplersPerModule, out displayChannelNumber);
|
||||
SerialNumber = string.Format(StringResources.ModuleNumber, displayModuleNumber.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
if (moduleSerialNumber.StartsWith(StringResources.StreamOut))
|
||||
{
|
||||
//Stream out
|
||||
displayChannelNumber = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Thermocoupler
|
||||
SerialNumber = dasSerialNumber;
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
}
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
default:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
}
|
||||
if (channelType == ChannelTypeEnum.SQUIB)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_Squib + displayChannelNumber.ToString("00");
|
||||
}
|
||||
else if (channelType == ChannelTypeEnum.TOMDigital)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_DigitalOut +
|
||||
displayChannelNumber.ToString("00");
|
||||
}
|
||||
else if (channelType == ChannelTypeEnum.DigitalInput)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_DigitalIn +
|
||||
displayChannelNumber.ToString("00");
|
||||
}
|
||||
else
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_Other + displayChannelNumber.ToString("00");
|
||||
}
|
||||
ChannelNumber = displayChannelNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Classes.Hardware;
|
||||
|
||||
|
||||
namespace DTS.Common.DataModel.Common.DbWrappers
|
||||
{
|
||||
public class DASGet : DASDBRecord
|
||||
{
|
||||
public DASGet() { }
|
||||
public DASGet(IDASDBRecord record) : base(record)
|
||||
{
|
||||
if (double.IsNaN(MaxAAFRate))
|
||||
{
|
||||
MaxAAFRate = MaxSampleRate / 5;
|
||||
}
|
||||
}
|
||||
public int Type { get => DASType; set => DASType = value; }
|
||||
public bool Reprogramable { get => IsProgrammable; set => IsProgrammable = value; }
|
||||
public bool Reconfigurable { get => IsReconfigurable; set => IsReconfigurable = value; }
|
||||
|
||||
/// <summary>
|
||||
/// This ensures that any bad data in the database can be repaired in one place.
|
||||
/// FB 17777
|
||||
/// </summary>
|
||||
/// <param name="serialNumber"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public List<DASGet> DASGet_Wrapper(string serialNumber = null, string position = null)
|
||||
{
|
||||
var dasGetList = new List<DASGet>();
|
||||
|
||||
var hResult = DbOperations.DASGet(serialNumber, position, out var dbDAS);
|
||||
if (0 == hResult && null != dbDAS)
|
||||
{
|
||||
foreach (var das in dbDAS)
|
||||
{
|
||||
dasGetList.Add(new DASGet(das));
|
||||
}
|
||||
}
|
||||
|
||||
return dasGetList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
using DTS.Common.DataModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <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, IComparable<TestTestObject>
|
||||
{
|
||||
public TestTestObject(TestObject obj)
|
||||
: base(obj)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// added a new constructor for
|
||||
/// 9570 Test object and position defaulted (traditional groups) when you rename or copy a test setup
|
||||
/// as old constructor missed the meta data copy
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="convertToEmbedded"></param>
|
||||
public TestTestObject(TestTestObject obj, bool convertToEmbedded)
|
||||
{
|
||||
CommonCustructorItems(obj, convertToEmbedded);
|
||||
MetaCommonConstructor(obj);
|
||||
}
|
||||
public TestTestObject(TestObject obj, bool convertToEmbedded)
|
||||
{
|
||||
CommonCustructorItems(obj, convertToEmbedded);
|
||||
}
|
||||
/// <summary>
|
||||
/// takes care of all the non meta constructor information
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="convertToEmbedded"></param>
|
||||
private void CommonCustructorItems(TestObject obj, bool convertToEmbedded)
|
||||
{
|
||||
var bAlreadyConverted = obj.GetISOTestObject().Embedded;
|
||||
if (convertToEmbedded)
|
||||
{
|
||||
var guid = Guid.NewGuid();
|
||||
//first grab a copy of the template and convert it
|
||||
var isoTemplate = obj.Template.ToISOTestObjectTemplate();
|
||||
isoTemplate.Embedded = true;
|
||||
|
||||
isoTemplate.OriginalTemplateName = bAlreadyConverted ? isoTemplate.OriginalTemplateName : isoTemplate.TemplateName;
|
||||
|
||||
isoTemplate.TemplateName = guid.ToString();
|
||||
var db = ApplicationProperties.IsoDb;
|
||||
var template = new TestObjectTemplate(isoTemplate, ref db);
|
||||
|
||||
var isoTestObject = new DTS.Common.ISO.TestObject(obj.GetISOTestObject(), isoTemplate, db);
|
||||
isoTestObject.OriginalSerialNumber = obj.SerialNumber;
|
||||
if (bAlreadyConverted) { isoTestObject.OriginalSerialNumber = obj.SerialNumberOrOriginalSerialNumber; }
|
||||
isoTestObject.SerialNumber = guid.ToString();
|
||||
isoTestObject.Embedded = true;
|
||||
isoTestObject.OriginalTemplate = obj.Template.TemplateName;
|
||||
if (bAlreadyConverted) { isoTestObject.OriginalTemplate = obj.Template.OriginalTemplateName; }
|
||||
isoTestObject.SetTemplateOnly(guid.ToString());
|
||||
var includedHardware = new Dictionary<string, DASHardware>();
|
||||
foreach (var h in obj.Hardware)
|
||||
{
|
||||
includedHardware[h.GetHardware().GetId()] = h;
|
||||
}
|
||||
var to = new TestObject(isoTestObject, false, template, includedHardware);
|
||||
Initialize(to);
|
||||
//UGH, something resets the template properties.
|
||||
//just change them back for now to the right values :/
|
||||
Template.Embedded = true;
|
||||
Template.OriginalTemplateName = template.OriginalTemplateName;
|
||||
Template.TemplateName = template.TemplateName;
|
||||
}
|
||||
else
|
||||
{
|
||||
Initialize(obj);
|
||||
}
|
||||
}
|
||||
private string _position = ChannelDefaultsKey;
|
||||
public DTS.Common.ISO.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 DTS.Common.ISO.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
|
||||
{
|
||||
//TODO Remove Non-ISO Mode code
|
||||
if (_groupPositionComboBoxVisible == Visibility.Visible)
|
||||
{
|
||||
return /*Common.SerializedSettings.ISOSupportLevel == Common.SerializedSettings.ISOSupportLevels.NO_ISO ? Visibility.Collapsed :*/ _groupPositionComboBoxVisible;
|
||||
}
|
||||
return _groupPositionComboBoxVisible;
|
||||
}
|
||||
set => SetProperty(ref _groupPositionComboBoxVisible, value, "GroupPositionComboBoxVisible");
|
||||
}
|
||||
|
||||
private Visibility _groupPositionButtonVisible = Visibility.Hidden;
|
||||
public Visibility GroupPositionButtonVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
//TODO Remove Non-ISO Mode code
|
||||
if (_groupPositionButtonVisible == Visibility.Visible)
|
||||
{
|
||||
return /*Common.SerializedSettings.ISOSupportLevel == Common.SerializedSettings.ISOSupportLevels.NO_ISO ? Visibility.Collapsed :*/ _groupPositionButtonVisible;
|
||||
}
|
||||
return _groupPositionButtonVisible;
|
||||
}
|
||||
set => SetProperty(ref _groupPositionButtonVisible, value, "GroupPositionButtonVisible");
|
||||
}
|
||||
|
||||
private string _testObject = "?";
|
||||
public DTS.Common.ISO.MMETestObjects TestObject
|
||||
{
|
||||
get => ApplicationProperties.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 DTS.Common.ISO.MMEPositions[] AvailablePositions => ApplicationProperties.IsoDb.GetPositions();
|
||||
|
||||
private const string DATAPRO_DEFINED = "DataPRO-defined";
|
||||
public static DTS.Common.ISO.MMEPositions _channelDefaultsGUID = new DTS.Common.ISO.MMEPositions(Guid.NewGuid().ToString(), ChannelDefaultsKey, "(channel defaults)", "(channel defaults)", 1, DateTime.Now, DATAPRO_DEFINED, false, "", DateTime.Now,
|
||||
DATAPRO_DEFINED, "", DTS.Common.ISO.MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
||||
private DTS.Common.ISO.MMEPositions _userSetGUID = new DTS.Common.ISO.MMEPositions(Guid.NewGuid().ToString(), UserSetKey, "(multiple)", "(multiple)", 1, DateTime.Now, DATAPRO_DEFINED, false, "", DateTime.Now,
|
||||
DATAPRO_DEFINED, "", DTS.Common.ISO.MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
||||
public DTS.Common.ISO.MMEPositions[] AvailableGroupPositions
|
||||
{
|
||||
get
|
||||
{
|
||||
var availableGroupPositions = new List<DTS.Common.ISO.MMEPositions>();
|
||||
availableGroupPositions.Add(_channelDefaultsGUID);
|
||||
availableGroupPositions.AddRange(AvailablePositions);
|
||||
|
||||
return availableGroupPositions.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private List<TestObject> _addedGroups = new List<TestObject>();
|
||||
public TestObject[] AddedGroups
|
||||
{
|
||||
get => _addedGroups.ToArray();
|
||||
set
|
||||
{
|
||||
SetProperty(ref _addedGroups, new List<TestObject>(value), "AddedSysBuiltTestObjects");
|
||||
OnPropertyChanged("AddedSysBuiltTestObjectsMME");
|
||||
}
|
||||
}
|
||||
|
||||
public string[] ChannelTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
var typeList = new List<string>();
|
||||
typeList.Add("(no channels)"); //temp
|
||||
typeList.AddRange(ApplicationProperties.IsoDb.GetUniquePossibleChannelTypes(DTS.Common.ISO.TestObjectTemplateChannel.NONISOCHANNELTYPE));
|
||||
return typeList.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?
|
||||
IsAdd = to.IsAdd;
|
||||
DisplayOrder = to.DisplayOrder;
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
public void Rename(string oldName, string newName)
|
||||
{
|
||||
SerialNumber = SerialNumber.Replace(oldName, newName);
|
||||
GetISOTestObject().OriginalSerialNumber = GetISOTestObject().OriginalSerialNumber.Replace(oldName, newName);
|
||||
GetISOTestObject().OriginalTemplate = GetISOTestObject().OriginalTemplate.Replace(oldName, newName);
|
||||
TestSetupName = newName;
|
||||
var templateGUIDString = Guid.NewGuid().ToString();
|
||||
Template.TemplateName = templateGUIDString;
|
||||
Template.OriginalTemplateName = templateGUIDString;
|
||||
}
|
||||
|
||||
public int DisplayOrder { get; set; } = -1;
|
||||
|
||||
public bool IsAdd { get; set; }
|
||||
public int CompareTo(TestTestObject other)
|
||||
{
|
||||
var ret = DisplayOrder.CompareTo(other.DisplayOrder);
|
||||
if (0 == ret)
|
||||
{
|
||||
ret = base.CompareTo(other);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DataPROWin7.Common;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Serialization;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using File = System.IO.File;
|
||||
using System.Xml.Linq;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.Utils;
|
||||
using DTS.Common.DataModel.Classes.TestTemplate;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class DataFiles : BasePropertyChanged
|
||||
{
|
||||
public DataFiles(string expandCollapse,
|
||||
string testName,
|
||||
string id,
|
||||
string allOrROI,
|
||||
string lab,
|
||||
string customer,
|
||||
DateTime dateCreated,
|
||||
string description,
|
||||
string numberOfChannels,
|
||||
string testEngineer,
|
||||
bool isTSRAIR,
|
||||
string roiSuffix = "")
|
||||
{
|
||||
ExpandCollapse = expandCollapse;
|
||||
TestName = testName;
|
||||
TestId = id;
|
||||
AllOrROI = allOrROI;
|
||||
Lab = lab;
|
||||
Customer = customer;
|
||||
DateCreated = dateCreated;
|
||||
Description = description;
|
||||
NumberOfChannels = numberOfChannels;
|
||||
TestEngineer = testEngineer;
|
||||
ROISuffix = roiSuffix;
|
||||
IsTSRAIR = isTSRAIR;
|
||||
}
|
||||
|
||||
public string LongString { get; set; }
|
||||
|
||||
public bool TestSelected { get; set; }
|
||||
|
||||
public string ExpandCollapse { get; set; }
|
||||
|
||||
public string TestId { get; set; }
|
||||
|
||||
public string TestName { get; set; }
|
||||
|
||||
public string AllOrROI { get; set; }
|
||||
|
||||
public string Lab { get; set; }
|
||||
|
||||
public string Customer { get; set; }
|
||||
|
||||
public DateTime DateCreated { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public string NumberOfChannels { get; set; }
|
||||
|
||||
public string TestEngineer { get; set; }
|
||||
|
||||
public string ROISuffix { get; set; }
|
||||
/// <summary>
|
||||
/// location of DTS file if known (populated in export tab)
|
||||
/// 18525 The data set is in Data folder but not listed on Export Data tab
|
||||
/// </summary>
|
||||
public string DTSFile { get; set; }
|
||||
public bool IsTSRAIR { get; set; } = false;
|
||||
}
|
||||
|
||||
|
||||
public class DataFilesList : BasePropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// returns all folders that have a dts and .chn files, recursively travels down subfolders
|
||||
/// </summary>
|
||||
private string[] GetFoldersWithData(string folder)
|
||||
{
|
||||
var folders = new List<string>();
|
||||
var subFolders = Directory.GetDirectories(folder);
|
||||
foreach (var subFolder in subFolders) { folders.AddRange(GetFoldersWithData(subFolder)); }
|
||||
|
||||
var files = Directory.GetFiles(folder);
|
||||
|
||||
if (Array.Exists(files, f => f.ToLower().Contains(".dts")) && Array.Exists(files, f => f.ToLower().Contains(".chn")))
|
||||
{
|
||||
folders.Add(folder);
|
||||
}
|
||||
return folders.ToArray();
|
||||
}
|
||||
|
||||
public string DownloadFolder = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// parses out the test information out of a DTS file without loading the entire file into memory with DOM xml
|
||||
/// we could use a SAX parser instead
|
||||
/// 23342 Export and View Tiles very slow [APG-ATEC]
|
||||
/// </summary>
|
||||
/// <param name="dtsFilePath"></param>
|
||||
/// <param name="lab"></param>
|
||||
/// <param name="customer"></param>
|
||||
/// <param name="description"></param>
|
||||
/// <param name="testEngineer"></param>
|
||||
/// <param name="dt"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
private bool GetTestInfo(string dtsFilePath, out string lab, out string customer, out string description,
|
||||
out string testEngineer, out DateTime dt, out string name)
|
||||
{
|
||||
//initialize all returns, then fill them in if the info is in the file
|
||||
lab = string.Empty;
|
||||
customer = string.Empty;
|
||||
description = string.Empty;
|
||||
testEngineer = string.Empty;
|
||||
dt = DateTime.MinValue;
|
||||
name = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
var sFile = DTS.Serialization.SliceRaw.File.Reader.ReadTestStringsFromFile(dtsFilePath);
|
||||
var testInfoLine = Array.Find(sFile, f => f.Contains("<Test Id"));
|
||||
if (null == testInfoLine) { return false; }
|
||||
//the <Test> tag is incomplete, so add an end tag just so xml doesn't complain
|
||||
testInfoLine = $"{testInfoLine}</Test>";
|
||||
var testXml = XElement.Parse(testInfoLine);
|
||||
description = testXml.Attribute("Description").Value;
|
||||
name = testXml.Attribute("Id").Value;
|
||||
|
||||
var teLine = Array.Find(sFile, f => f.Contains("<TEName>"));
|
||||
if (null != teLine)
|
||||
{
|
||||
var teXml = XElement.Parse(teLine);
|
||||
testEngineer = teXml.Value;
|
||||
}
|
||||
|
||||
var labLine = Array.Find(sFile, f => f.Contains("<LabName>"));
|
||||
if (null != labLine)
|
||||
{
|
||||
var labXml = XElement.Parse(labLine);
|
||||
lab = labXml.Value;
|
||||
}
|
||||
|
||||
var custLine = Array.Find(sFile, f => f.Contains("<CustName>"));
|
||||
if (null != custLine)
|
||||
{
|
||||
var custXml = XElement.Parse(custLine);
|
||||
customer = custXml.Value;
|
||||
}
|
||||
|
||||
var timeStampLine = Array.Find(sFile, f => f.Contains("<Timestamp>"));
|
||||
if (null != timeStampLine)
|
||||
{
|
||||
var timeStampXml = XElement.Parse(timeStampLine);
|
||||
dt = DateTime.Parse(timeStampXml.Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public DataFiles[] GetAllFiles(string testName)
|
||||
{
|
||||
//FB 32926 No need to check for instance since always would have a value
|
||||
//var current = (App) Application.Current;
|
||||
//if (current == null) { return new DataFiles[0]; }
|
||||
|
||||
var dataFiles = new List<DataFiles>();
|
||||
try
|
||||
{
|
||||
var testNameFolder = Path.GetFullPath(DataModelSettings.DownloadFolder);
|
||||
DownloadFolder = testNameFolder;
|
||||
testNameFolder = Path.Combine(testNameFolder, testName);
|
||||
if (Directory.Exists(testNameFolder))
|
||||
{
|
||||
var foldersWithData = GetFoldersWithData(testNameFolder);
|
||||
foreach (string folder in foldersWithData)
|
||||
{
|
||||
var dtsFiles = Directory.GetFiles(folder, "*.dts");
|
||||
if (1 != dtsFiles.Length) { continue; }
|
||||
var dtsFile = dtsFiles[0];
|
||||
|
||||
if (!GetTestInfo(dtsFiles[0], out var lab, out var customer, out var description,
|
||||
out var testEngineer, out var dt, out var name)) { continue; }
|
||||
|
||||
var isTSRAIR = dtsFiles[0].Contains(TSRAIRGoTestSetup.TEST_NAME);
|
||||
var numberOfChannels = string.Empty;
|
||||
|
||||
var directoryInfo = new FileInfo(dtsFile).Directory;
|
||||
if (directoryInfo != null)
|
||||
{
|
||||
var channels = Directory.GetFiles(directoryInfo.FullName, "*.chn");
|
||||
numberOfChannels = channels.Length.ToString();
|
||||
}
|
||||
|
||||
var subFolders = folder.Split(Path.DirectorySeparatorChar).ToList();
|
||||
var binaryFolderIndex = subFolders.IndexOf("Binary");
|
||||
var allOrROI = StringResources.Table_NA;
|
||||
//as long as we found the binary folder, use the next folder to determine All or ROI
|
||||
if (binaryFolderIndex > 0)
|
||||
{
|
||||
allOrROI = subFolders[binaryFolderIndex + 1];
|
||||
}
|
||||
var roiSuffix = TestUtils.ParseROISuffix(folder);
|
||||
var dtsFileInfo = new FileInfo(dtsFile);
|
||||
var testId = dtsFileInfo.Name.Replace(dtsFileInfo.Extension, "");
|
||||
var df = new DataFiles(string.Empty, name,
|
||||
testId, allOrROI, lab, customer, dt, description, numberOfChannels, testEngineer, isTSRAIR,
|
||||
roiSuffix)
|
||||
{ DTSFile = dtsFile };
|
||||
dataFiles.Add(df);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to retrieve Data Files", ex);
|
||||
}
|
||||
|
||||
return dataFiles.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public DataFiles[] Contract(DataFiles df)
|
||||
{
|
||||
_dataFiles.RemoveAll(item => (item.TestName == df.TestName) && (item.ExpandCollapse != "-"));
|
||||
_dataFiles.Find(item => item.TestName == df.TestName).ExpandCollapse = "+";
|
||||
return _dataFiles.ToArray();
|
||||
}
|
||||
|
||||
public DataFiles[] GetAllDataFiles()
|
||||
{
|
||||
var dataFiles = new List<DataFiles>();
|
||||
try
|
||||
{
|
||||
var dataFolder = Path.GetFullPath(DataModelSettings.DownloadFolder);
|
||||
if (Directory.Exists(dataFolder))
|
||||
{
|
||||
var testFolders = Directory.GetDirectories(dataFolder);
|
||||
foreach (var testFolder in testFolders)
|
||||
{
|
||||
var testName = new DirectoryInfo(testFolder).Name;
|
||||
var testIdFolders = Directory.GetDirectories(testFolder);
|
||||
var fileCount = 0;
|
||||
foreach (var testIdFolder in testIdFolders)
|
||||
{
|
||||
if (!Directory.Exists(Path.Combine(testIdFolder, "Binary"))) continue;
|
||||
var binaryFolder = Path.Combine(testIdFolder, "Binary");
|
||||
var testId = new DirectoryInfo(testIdFolder).Name;
|
||||
fileCount += GetFileCount(binaryFolder, testId);
|
||||
}
|
||||
|
||||
if (fileCount <= 0) continue;
|
||||
var isTSRAIR = testFolder.Contains(TSRAIRGoTestSetup.TEST_NAME);
|
||||
var df = new DataFiles("+", testName, string.Empty, string.Empty, string.Empty, string.Empty, new DateTime(), string.Empty, string.Empty, string.Empty, isTSRAIR);
|
||||
dataFiles.Add(df);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to retrieve Data Files", ex);
|
||||
}
|
||||
return dataFiles.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// gets the count of tests data sets in the given binary folder
|
||||
/// this means it will traverse down the given folder looking for dts and chn files
|
||||
/// matching a pattern
|
||||
/// </summary>
|
||||
private int GetFileCount(string binaryFolder, string testId)
|
||||
{
|
||||
var count = 0;
|
||||
var subFolders = Directory.GetDirectories(binaryFolder);
|
||||
foreach (var subfolder in subFolders)
|
||||
{
|
||||
count += GetFileCount(subfolder, testId);
|
||||
}
|
||||
//different tests seem to name the dts file differently
|
||||
//lets not care about the name as long as there's only one dts file
|
||||
//and there's chn files which follow the dts file name
|
||||
var dtsFiles = Directory.GetFiles(binaryFolder, "*.dts");
|
||||
if (1 == dtsFiles.Length)
|
||||
{
|
||||
var fi = new FileInfo(dtsFiles[0]);
|
||||
var testName = fi.Name.Replace(fi.Extension, "");
|
||||
//make sure there's at least one file
|
||||
if (Directory.GetFiles(binaryFolder, $"{testName}*.*.chn").Any())
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
private List<DataFiles> _dataFiles;
|
||||
public DataFiles[] DataFiles
|
||||
{
|
||||
get
|
||||
{
|
||||
_dataFiles = new List<DataFiles>();
|
||||
_dataFiles.AddRange(GetAllDataFiles());
|
||||
return _dataFiles.ToArray();
|
||||
}
|
||||
set => SetProperty(ref _dataFiles, new List<DataFiles>(value), "DataFiles");
|
||||
}
|
||||
|
||||
private static DataFilesList _dataFileList;
|
||||
public static DataFilesList DataFileList => _dataFileList ?? (_dataFileList = new DataFilesList());
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
||||
using DataPROWin7.Common;
|
||||
using DTS.Common.Interface.Channels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DTS.Common.DataModel.Common
|
||||
{
|
||||
public static class ChannelHelper
|
||||
{
|
||||
public static string GetWarningChannelName(IGroupChannel groupChannel)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (groupChannel.TestSetupOrder >= 0)
|
||||
{
|
||||
sb.Append($"{groupChannel.TestSetupOrder}, ");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append($"{groupChannel.GroupChannelOrder}, ");
|
||||
}
|
||||
|
||||
var name = groupChannel.GetChannelName(SerializedSettings.ISOViewMode);
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
sb.Append("'', ");
|
||||
if (groupChannel.SensorValid)
|
||||
{
|
||||
sb.Append($"({groupChannel.Sensor}) ");
|
||||
}
|
||||
|
||||
if (groupChannel.HardwareValid)
|
||||
{
|
||||
sb.Append($"{groupChannel.Hardware}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append($"'{name}'");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class TestEngineerDetails : BasePropertyChanged
|
||||
{
|
||||
|
||||
private bool _blank = true;
|
||||
public bool IsBlank() { return _blank; }
|
||||
|
||||
private DTS.Common.ISO.TestEngineerDetails _testEngineerDetails;
|
||||
public enum Fields
|
||||
{
|
||||
Name,
|
||||
TestEngineerName,
|
||||
TestEngineerPhone,
|
||||
TestEngineerFax,
|
||||
TestEngineerEmail
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _testEngineerDetails.Name;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.Name = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.Name.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerName
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerName;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerName = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerName.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerPhone
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerPhone;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerPhone = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerPhone.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerFax
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerFax;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerFax = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerFax.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerEmail
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerEmail;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerEmail = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerEmail.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public bool LocalOnly => _testEngineerDetails.LocalOnly;
|
||||
|
||||
public DateTime LastModified => _testEngineerDetails.LastModified;
|
||||
|
||||
public string LastModifiedBy => _testEngineerDetails.LastModifiedBy;
|
||||
|
||||
public int Version => _testEngineerDetails.Version;
|
||||
|
||||
public TestEngineerDetails()
|
||||
{
|
||||
_testEngineerDetails = new DTS.Common.ISO.TestEngineerDetails();
|
||||
_testEngineerDetails.Name = StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
|
||||
public bool HasBlankName()
|
||||
{
|
||||
return _testEngineerDetails.Name == StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public TestEngineerDetails(DTS.Common.ISO.TestEngineerDetails testEngineerDetails)
|
||||
{
|
||||
_blank = false;
|
||||
_testEngineerDetails = new DTS.Common.ISO.TestEngineerDetails(testEngineerDetails);
|
||||
}
|
||||
public DTS.Common.ISO.TestEngineerDetails GetISOTestEngineer()
|
||||
{
|
||||
return _testEngineerDetails;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class TestEngineerDetailsList : BasePropertyChanged
|
||||
{
|
||||
public enum Tags
|
||||
{
|
||||
TestEngineers
|
||||
|
||||
}
|
||||
protected TestEngineerDetailsList()
|
||||
{
|
||||
}
|
||||
|
||||
private static TestEngineerDetailsList _testEngineerList = new TestEngineerDetailsList();
|
||||
public static TestEngineerDetailsList TestEngineerList => _testEngineerList;
|
||||
public void Delete(TestEngineerDetails testEngineer)
|
||||
{
|
||||
testEngineer.GetISOTestEngineer().Delete(ApplicationProperties.CurrentUser.UserName);
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
_testEngineers.Remove(testEngineer.Name);
|
||||
}
|
||||
OnPropertyChanged(Tags.TestEngineers.ToString());
|
||||
}
|
||||
public void Delete(TestEngineerDetails[] testEngineers)
|
||||
{
|
||||
foreach (var testEngineer in testEngineers)
|
||||
{
|
||||
Delete(testEngineer);
|
||||
}
|
||||
}
|
||||
private static readonly object _testEngineerLock = new object();
|
||||
private Dictionary<string, TestEngineerDetails> _testEngineers = null;
|
||||
public TestEngineerDetails[] TestEngineers
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
if (null == _testEngineers || _testEngineers.Count == 0)
|
||||
{
|
||||
PopulateEngineers();
|
||||
}
|
||||
}
|
||||
List<TestEngineerDetails> testEngineers = new List<TestEngineerDetails>(_testEngineers.Values);
|
||||
testEngineers.Sort(new Comparison<TestEngineerDetails>(CompareTestEngineers));
|
||||
return testEngineers.ToArray();
|
||||
}
|
||||
}
|
||||
private void PopulateEngineers()
|
||||
{
|
||||
_testEngineers = new Dictionary<string, TestEngineerDetails>();
|
||||
foreach (var t in GetAllTestEngineers())
|
||||
{
|
||||
if (!_testEngineers.ContainsKey(t.Name)) { _testEngineers.Add(t.Name, t); }
|
||||
}
|
||||
}
|
||||
public void ReloadAll()
|
||||
{
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
PopulateEngineers();
|
||||
}
|
||||
}
|
||||
public void DeleteAll()
|
||||
{
|
||||
_testEngineers = null;
|
||||
DTS.Common.ISO.TestEngineerDetails.DeleteAllTestEngineerDetails();
|
||||
}
|
||||
private int CompareTestEngineers(TestEngineerDetails a, TestEngineerDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
if (null == b) { return 1; }
|
||||
return a.Name.CompareTo(b.Name);
|
||||
}
|
||||
|
||||
public static TestEngineerDetails[] GetAllTestEngineers()
|
||||
{
|
||||
var list = new List<TestEngineerDetails>();
|
||||
if (RunTestVariables.InRunTest &&
|
||||
TestTemplateList.TestTemplatesList.CachedTestEngineerDetails != null &&
|
||||
TestTemplateList.TestTemplatesList.CachedTestEngineerDetails.Count > 0)
|
||||
{
|
||||
DbOperations.LogDBCaching("****** Using cached Laboratory Details in GetAllTestEngineers");
|
||||
var isoTestEngineersList = new List<DTS.Common.ISO.TestEngineerDetails>();
|
||||
foreach (var te in TestTemplateList.TestTemplatesList.CachedTestEngineerDetails)
|
||||
{
|
||||
var isoTestEngineerDetails = new DTS.Common.ISO.TestEngineerDetails()
|
||||
{
|
||||
Name = te.Value.Name,
|
||||
TestEngineerName = te.Value.TestEngineerName,
|
||||
TestEngineerPhone = te.Value.TestEngineerPhone,
|
||||
TestEngineerEmail = te.Value.TestEngineerEmail,
|
||||
TestEngineerFax = te.Value.TestEngineerFax
|
||||
};
|
||||
|
||||
isoTestEngineersList.Add(isoTestEngineerDetails);
|
||||
}
|
||||
list = isoTestEngineersList.Select(isote => new TestEngineerDetails(isote)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var ts in DTS.Common.ISO.TestEngineerDetails.GetAllTestEngineerDetails())
|
||||
{
|
||||
list.Add(new TestEngineerDetails(ts));
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public TestEngineerDetails GetTestEngineerDetail(string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) { return null; }
|
||||
var testEngineers = from t in TestEngineers.AsParallel() where t.Name == name select t;
|
||||
if (null != testEngineers && testEngineers.Any()) { return testEngineers.First(); }
|
||||
else { return null; }
|
||||
}
|
||||
|
||||
public void AddTestEngineer(TestEngineerDetails testEngineer)
|
||||
{
|
||||
testEngineer.GetISOTestEngineer().Commit(ApplicationProperties.CurrentUser.UserName);
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
//force _testEngineers to not be null...
|
||||
var length = TestEngineers.Length;
|
||||
if (!_testEngineers.ContainsKey(testEngineer.Name)) { _testEngineers.Add(testEngineer.Name, testEngineer); }
|
||||
else { _testEngineers[testEngineer.Name] = testEngineer; }
|
||||
}
|
||||
OnPropertyChanged(Tags.TestEngineers.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DataPROWin7.DataModel.Classes.TestTemplate;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.Interface.DASFactory.Diagnostics;
|
||||
using DTS.Common.Interface.DASFactory.Diagnostics.HardwareList;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using DTS.Common.Storage;
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes.Hardware
|
||||
{
|
||||
public class DASHardwareList : BasePropertyChanged
|
||||
{
|
||||
private static DASHardwareList _list;
|
||||
|
||||
private static bool _cache = false;
|
||||
/// <summary>
|
||||
/// turns off queries to the db and starts using cached data instead
|
||||
/// this is done when a large number of test setups are validating, since each test setup
|
||||
/// will get a complete list of hardware from the db, which adds time when you have a lot of hardware and test setups
|
||||
/// </summary>
|
||||
public static bool Cache
|
||||
{
|
||||
get => _cache;
|
||||
set
|
||||
{
|
||||
_cache = value;
|
||||
if (!value)
|
||||
{
|
||||
_cachedDASHardware = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 void SetCache(ICachedContainer container)
|
||||
{
|
||||
_cachedHardware = container;
|
||||
}
|
||||
|
||||
public void ClearCache()
|
||||
{
|
||||
_cachedHardware = null;
|
||||
}
|
||||
public string GetDASSerialNumberFromId(int id)
|
||||
{
|
||||
//this could probably be improved, but rather than getting ALL HARDWARE and ALL channels
|
||||
//just to get a serial number for a database id
|
||||
//just get the hardware without the channels
|
||||
var hr = DbOperations.DASGet(null, null, out var records);
|
||||
if (0 == hr && null != records && records.Any())
|
||||
{
|
||||
var match = Array.Find(records, das => das.DASId == id);
|
||||
if (null != match) { return match.SerialNumber; }
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
public DASHardware GetHardware(int id)
|
||||
{
|
||||
var sn = GetDASSerialNumberFromId(id);
|
||||
return GetHardware(sn);
|
||||
}
|
||||
public DASHardware GetHardware(string id, bool bUseCache = true)
|
||||
{
|
||||
return GetHardware(id, true, out var bNotUsed, bUseCache);
|
||||
}
|
||||
|
||||
public DASHardware[] GetHardware(string[] ids, bool bUseCache = true)
|
||||
{
|
||||
List<DASHardware> dasHW = new List<DASHardware>();
|
||||
foreach (string id in ids)
|
||||
{
|
||||
var hw = GetHardware(id, bUseCache);
|
||||
if (null != hw)
|
||||
{
|
||||
dasHW.Add(hw);
|
||||
}
|
||||
}
|
||||
return dasHW.ToArray();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
if (null != _cachedDASHardware)
|
||||
{
|
||||
h = Array.Find(_cachedDASHardware, das => das.SerialNumber == id);
|
||||
if (null != h)
|
||||
{
|
||||
changed = false;
|
||||
return h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var hardware = DTS.Common.ISO.Hardware.GetAllDAS(id, null);
|
||||
changed = false;
|
||||
if (null != hardware && hardware.Any())
|
||||
{
|
||||
return new DASHardware(hardware[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public class HardwareTypeChangedException : Exception
|
||||
{
|
||||
}
|
||||
|
||||
public DASHardware GetHardware(string serialNumber, string ipaddress)
|
||||
{
|
||||
return GetHardware(serialNumber);
|
||||
}
|
||||
|
||||
public void UpdateMaxMemory(DASHardware h, long newMaxMemory)
|
||||
{
|
||||
h.GetHardware().MaxMemory = newMaxMemory;
|
||||
h.GetHardware().Update();
|
||||
}
|
||||
|
||||
public DASHardware GetPrototypeHardware(string serial, int type)
|
||||
{
|
||||
//return new DASHardware();
|
||||
var key = $"{serial}_{type}";
|
||||
var das = DTS.Common.ISO.Hardware.GetAllDAS(key, DbOperations.DAS.PROTOTYPE_POSITION);
|
||||
if (null != das && das.Any())
|
||||
{
|
||||
return new DASHardware(das[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// holds a cache of all hardware this is done for speed reasons when there are a large number
|
||||
/// of test setups to validate, each one of them grabs all the hardware, which takes time
|
||||
/// </summary>
|
||||
private static DASHardware[] _cachedDASHardware = null;
|
||||
public static DASHardware[] GetAllHardware()
|
||||
{
|
||||
if (Cache && null != _cachedDASHardware) { return _cachedDASHardware; }
|
||||
var allHardware = DTS.Common.ISO.Hardware.GetAllDAS();
|
||||
var ret = allHardware.Select(h => new DASHardware(h)).ToArray();
|
||||
if (Cache) { _cachedDASHardware = ret; }
|
||||
return ret;
|
||||
}
|
||||
public static List<int> GetEmbeddedModules(IDASHardware[] hardware, int id)
|
||||
{
|
||||
var modules = new List<int>();
|
||||
|
||||
foreach (var hw in hardware)
|
||||
{
|
||||
if (hw.Connection.StartsWith(hardware.First(h => h.DASId == id).SerialNumber))
|
||||
{
|
||||
modules.Add(hw.DASId);
|
||||
}
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
public static Dictionary<string, double> GetEmbeddedModuleInfo(DASHardware[] hardware, int id)
|
||||
{
|
||||
var info = new Dictionary<string, double>();
|
||||
|
||||
foreach (var hw in hardware)
|
||||
{
|
||||
if (hw.Connection.StartsWith(hardware.First(h => h.DASId == id).SerialNumber))
|
||||
{
|
||||
info[hw.SerialNumber] = hw.GetMaxSampleRateDouble();
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public enum Tags
|
||||
{
|
||||
Hardware
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unassociate is used to indicate whether children das should be unassociated before commiting or not
|
||||
/// </summary>
|
||||
public void Commit(DASHardware hardware, bool bExisting = false, bool bCheckExisting = true, bool Unassociate = true)
|
||||
{
|
||||
//note when you are commiting a group of hardware that contains a SLICE6Db, you should
|
||||
//sort the hardware so that this call happens BEFORE we commit any child slice6
|
||||
if (hardware.IsPseudoRack() && Unassociate)
|
||||
{
|
||||
UnassociateParentDAS(hardware.SerialNumber);
|
||||
}
|
||||
|
||||
var iso = hardware.GetHardware();
|
||||
var h = new DTS.Common.ISO.Hardware
|
||||
{
|
||||
SerialNumber = hardware.SerialNumber,
|
||||
LocalOnly = hardware.LocalOnly,
|
||||
IsModule = hardware.IsModule(),
|
||||
CalDate = hardware.CalDate,
|
||||
DASType = hardware.GetHardwareTypeInt(),
|
||||
FirmwareVersion = hardware.Firmware,
|
||||
IPAddress = hardware.Connection,
|
||||
MaxMemory = hardware.GetMaxMemoryLong(),
|
||||
MaxModules = hardware.MaxModules,
|
||||
MaxSampleRate = hardware.GetMaxSampleRateDouble(),
|
||||
MinSampleRate = hardware.GetMinSampleRateDouble(),
|
||||
ProtocolVersion = hardware.ProtocolVersion,
|
||||
Channels = hardware.Channels.Length,
|
||||
LastModified = DateTime.Now,
|
||||
LastModifiedBy = ApplicationProperties.CurrentUser.UserName,
|
||||
IsReconfigurable = hardware.Reconfigurable,
|
||||
IsProgrammable = hardware.Reprogrammable,
|
||||
ChannelTypes = hardware.ChannelTypes,
|
||||
ParentDAS = hardware.ParentDAS,
|
||||
Port = hardware.PortOnDistributor,
|
||||
PositionOnChain = hardware.PositionOnChain,
|
||||
PositionOnDistributor = hardware.PositionOnDistributor,
|
||||
IsFirstUseValid = hardware.IsFirstUseValid,
|
||||
FirstUseDate = hardware.FirstUseDate,
|
||||
StandIn = iso.StandIn,
|
||||
MaxAAFRate = hardware.GetMaxAAFRateDouble(),
|
||||
TestId = iso.TestId,
|
||||
GroupId = iso.GroupId,
|
||||
LastUsed = iso.LastUsed,
|
||||
LastUsedBy = iso.LastUsedBy
|
||||
};
|
||||
|
||||
h.ISOChannels = hardware.Channels.Select(channel => new DTS.Common.ISO.HardwareChannel(channel.GetISOChannel(), h))
|
||||
.ToArray();
|
||||
hardware.SetHardware(h);
|
||||
|
||||
//if (null == _hardware)
|
||||
//{
|
||||
// PopulateHardware();
|
||||
//}
|
||||
|
||||
//10037 TDAS G5 module is detected as a TDAS G5 in a VDS, so if the existing serial number and ip address
|
||||
//already exists in the database
|
||||
if (bCheckExisting)
|
||||
{
|
||||
//22320 Unnecessary hardware retrieval
|
||||
bExisting = DASHardware.GetDataBaseID(hardware.SerialNumber) > 0;
|
||||
}
|
||||
if (!bExisting)
|
||||
{
|
||||
h.Insert();
|
||||
}
|
||||
else
|
||||
{
|
||||
h.Version = h.Version + 1;
|
||||
//10037 TDAS G5 module is detected as a TDAS G5 in a VDS
|
||||
//the id could change, so if we are doing an update, we should make sure to remove the old instance in the list
|
||||
//_hardware.Remove(existingHardware.GetHardware().GetId());
|
||||
//_hardware[hardware.GetHardware().GetId()] = hardware;
|
||||
h.Update();
|
||||
}
|
||||
OnPropertyChanged(Tags.Hardware.ToString());
|
||||
|
||||
//no longer need to mark groups incomplete
|
||||
}
|
||||
/// <summary>
|
||||
/// deletes the selected IHardware
|
||||
/// </summary>
|
||||
public void Delete(IHardware hardware)
|
||||
{
|
||||
if (hardware.Hardware is IISOHardware isoHW)
|
||||
{
|
||||
isoHW.Delete();
|
||||
}
|
||||
}
|
||||
public void Delete(DASHardware hardware)
|
||||
{
|
||||
var h = hardware?.GetHardware();
|
||||
if (h == null) { return; }
|
||||
h.Delete();
|
||||
|
||||
if (hardware.IsPseudoRack())
|
||||
{
|
||||
UnassociateParentDAS(hardware.SerialNumber);
|
||||
}
|
||||
OnPropertyChanged(Tags.Hardware.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
/// iteratively deletes the given hardware
|
||||
/// </summary>
|
||||
public void Delete(IHardware[] hardware)
|
||||
{
|
||||
foreach (var h in hardware)
|
||||
{
|
||||
Delete(h);
|
||||
}
|
||||
}
|
||||
public void Delete(DASHardware[] hardware)
|
||||
{
|
||||
foreach (DASHardware hw in hardware)
|
||||
{
|
||||
Delete(hw);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnassociateParentDAS(string distributorSerialNumber)
|
||||
{
|
||||
using (var sql = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
sql.CommandType = System.Data.CommandType.StoredProcedure;
|
||||
sql.CommandText = DbOperationsEnum.StoredProcedure.sp_DASChildrenUnAssociate.ToString();
|
||||
DbOperations.CreateParam(sql, "@ParentSerialNumber", System.Data.SqlDbType.NVarChar,
|
||||
distributorSerialNumber);
|
||||
sql.ExecuteNonQuery();
|
||||
}
|
||||
finally { sql.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,751 @@
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Interface.Groups.GroupList;
|
||||
using DTS.SensorDB;
|
||||
using DTS.Common.Interface.Sensors;
|
||||
using DTS.Common.Interface.Channels;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Threading;
|
||||
using System;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using DTS.Common.Storage;
|
||||
using Prism.Ioc;
|
||||
using DTS.Common.ISO;
|
||||
using DTS.Common.Utils;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using System.Text;
|
||||
using Unity;
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes
|
||||
{
|
||||
public static class ExportTestSetup
|
||||
{
|
||||
public static void PrepareForExport(DataModel.TestTemplate t,
|
||||
Dictionary<string, DataModel.TestTemplate> includedTests,
|
||||
Dictionary<string, IGroup> includedGroups,
|
||||
Dictionary<string, DataModel.DASHardware> includedDAS,
|
||||
Dictionary<string, SensorData> includedSensors,
|
||||
HashSet<int> sensorsAlreadyAdded,
|
||||
Dictionary<string, SensorModel> includedSensorModels,
|
||||
Dictionary<string, SensorCalibration[]> includedCalibration,
|
||||
Dictionary<string, DTS.Common.ISO.CustomerDetails> includedCustomerDetails,
|
||||
Dictionary<string, DTS.Common.ISO.TestEngineerDetails> includedTestEngineerDetails,
|
||||
Dictionary<string, DTS.Common.ISO.LabratoryDetails> includedLabDetails,
|
||||
bool savingRunningTest,
|
||||
// ReSharper disable once InconsistentNaming
|
||||
bool savingTTSImport
|
||||
)
|
||||
{
|
||||
if (!includedTests.ContainsKey(t.Name)) { includedTests[t.Name] = t; }
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(t.CustomerDetails?.Name))
|
||||
{
|
||||
includedCustomerDetails[t.CustomerDetails.Name] = t.CustomerDetails.GetISOCustomer();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(t.TestEngineerDetails?.Name))
|
||||
{
|
||||
includedTestEngineerDetails[t.TestEngineerDetails.Name] = t.TestEngineerDetails.GetISOTestEngineer();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(t.LabDetails?.Name))
|
||||
{
|
||||
includedLabDetails[t.LabDetails.Name] = t.LabDetails.GetIsoLab();
|
||||
}
|
||||
|
||||
var groups = new List<IGroup>(t.Groups);
|
||||
|
||||
var sensorLookup = new Dictionary<int, ISensorData>();
|
||||
var sensors = SensorsCollection.SensorsList.GetAllSensors(false);
|
||||
foreach (var s in sensors)
|
||||
{
|
||||
sensorLookup[s.DatabaseId] = s;
|
||||
}
|
||||
var hardwareList = GetHardware();
|
||||
var dasList = DTS.Common.ISO.Hardware.GetAllDAS();
|
||||
foreach (var embeddedGroup in groups)
|
||||
{
|
||||
//Find the channels in this embedded Group so the Sensors will be included
|
||||
var groupChannelList = new List<IGroupChannel>();
|
||||
foreach (var groupChannelsList in t.ChannelsForGroup) //make this a linq statement?
|
||||
{
|
||||
if (groupChannelsList.Key == embeddedGroup)
|
||||
{
|
||||
groupChannelList = groupChannelsList.Value.ToList();
|
||||
}
|
||||
}
|
||||
foreach (var groupChannel in groupChannelList)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(groupChannel.Sensor))
|
||||
{
|
||||
var sd = SensorsCollection.SensorsList.GetOriginalSensorBySensorDatabaseId(
|
||||
groupChannel.SensorId);
|
||||
var scs = SensorCalibration.GetCalibrationsBySerialNumber(sd);
|
||||
if (null != sd && null != scs && scs.Length > 0)
|
||||
{
|
||||
if (!sensorsAlreadyAdded.Contains(sd.DatabaseId))
|
||||
{
|
||||
if (!sd.IsTestSpecificDigitalOutput && !sd.IsTestSpecificSquib && !sd.IsTestSpecificDigitalIn)
|
||||
{
|
||||
includedCalibration.Add(sd.SerialNumber, scs);
|
||||
}
|
||||
|
||||
includedSensors.Add(sd.SerialNumber, sd);
|
||||
sensorsAlreadyAdded.Add(sd.DatabaseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var dasId in embeddedGroup.IncludedHardware)
|
||||
{
|
||||
var h = GetDAS(hardwareList, dasId, dasList);
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, new DataModel.DASHardware(h));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If there's a non-imbedded (static) Group in the db, process it too.
|
||||
IGroup nonEmbeddedGroup = null;
|
||||
if (embeddedGroup.StaticGroupId != null)
|
||||
{
|
||||
if (System.Windows.Application.Current.Dispatcher.CheckAccess())
|
||||
{
|
||||
nonEmbeddedGroup = GetNonEmbeddedGroup(embeddedGroup.StaticGroupId);
|
||||
}
|
||||
else
|
||||
{
|
||||
ManualResetEvent manualResetEvent = new ManualResetEvent(false);
|
||||
|
||||
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
nonEmbeddedGroup = GetNonEmbeddedGroup(embeddedGroup.StaticGroupId);
|
||||
manualResetEvent.Set();
|
||||
}));
|
||||
|
||||
|
||||
manualResetEvent.WaitOne();
|
||||
}
|
||||
}
|
||||
|
||||
if (nonEmbeddedGroup == null || nonEmbeddedGroup.Id != embeddedGroup.StaticGroupId)
|
||||
{
|
||||
//We can get here if the static Group was created from a static Group which was later deleted,
|
||||
//but the embedded Group didn't have its StaticGroupId set to null (also fixed in this patch,
|
||||
//but pre-existing embedded Groups in the database could be pointing to a non-existent record)
|
||||
embeddedGroup.StaticGroupId = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
var hardwareLookup = new Dictionary<int, IDASHardware>();
|
||||
using (var enumHardware = includedDAS.GetEnumerator())
|
||||
{
|
||||
while (enumHardware.MoveNext()) { hardwareLookup[enumHardware.Current.Value.DASId] = enumHardware.Current.Value; }
|
||||
}
|
||||
|
||||
var channelDefaults = DbOperations.GetChannelSettingDefaults();
|
||||
|
||||
var groupChannelArray = nonEmbeddedGroup.GetAllChannels(false, sensorLookup, hardwareLookup, channelDefaults);
|
||||
foreach (var groupChannel in groupChannelArray)
|
||||
{
|
||||
nonEmbeddedGroup.GroupChannelList.Add(groupChannel);
|
||||
nonEmbeddedGroup.ChannelCount++;
|
||||
}
|
||||
|
||||
var channels = t.ChannelsForGroup[embeddedGroup];
|
||||
|
||||
foreach (var groupChannel in channels)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(groupChannel.Sensor))
|
||||
{
|
||||
var sd = SensorsCollection.SensorsList.GetOriginalSensorBySensorDatabaseId(groupChannel.SensorId);
|
||||
var scs = SensorCalibration.GetCalibrationsBySerialNumber(sd);
|
||||
if (null != sd && null != scs && scs.Length > 0)
|
||||
{
|
||||
if (!sensorsAlreadyAdded.Contains(sd.DatabaseId))
|
||||
{
|
||||
if (!sd.IsTestSpecificSquib && !sd.IsTestSpecificDigitalOutput && !sd.IsTestSpecificDigitalIn)
|
||||
{
|
||||
includedCalibration.Add(sd.SerialNumber, scs);
|
||||
}
|
||||
|
||||
includedSensors.Add(sd.SerialNumber, sd);
|
||||
sensorsAlreadyAdded.Add(sd.DatabaseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var dasId in nonEmbeddedGroup.IncludedHardware)
|
||||
{
|
||||
var h = GetDAS(hardwareList, dasId, dasList);
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, new DataModel.DASHardware(h));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Only add static Groups to includedGroups
|
||||
if (!includedGroups.ContainsKey(nonEmbeddedGroup.Name))
|
||||
{
|
||||
includedGroups.Add(nonEmbeddedGroup.Name, nonEmbeddedGroup);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var group in t.Groups)
|
||||
{
|
||||
var channels = t.ChannelsForGroup[group];
|
||||
foreach (var ch in channels)
|
||||
{
|
||||
if (ch.IsBlank())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch.SensorId > 0)
|
||||
{
|
||||
var sd = SensorsCollection.SensorsList.GetOriginalSensorBySensorDatabaseId(ch.SensorId);
|
||||
if (!includedSensors.ContainsKey(sd.SerialNumber))
|
||||
{
|
||||
if (!sensorsAlreadyAdded.Contains(sd.DatabaseId))
|
||||
{
|
||||
includedSensors.Add(sd.SerialNumber, sd);
|
||||
if (!sd.IsTestSpecificDigitalOutput && !sd.IsTestSpecificSquib && !sd.IsTestSpecificDigitalIn)
|
||||
{
|
||||
var scs = SensorCalibration.GetCalibrationsBySerialNumber(sd);
|
||||
includedCalibration.Add(sd.SerialNumber, scs);
|
||||
var sm = SensorModelCollection.SensorModelList.GetSensorModel(sd.Manufacturer,
|
||||
sd.Model);
|
||||
if (null == sm)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var key = $"{sm.Manufacturer}x_x{sm.Model}";
|
||||
if (!includedSensorModels.ContainsKey(key))
|
||||
{
|
||||
includedSensorModels.Add(key, sm);
|
||||
}
|
||||
}
|
||||
|
||||
sensorsAlreadyAdded.Add(sd.DatabaseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var hardware = t.GetHardware();
|
||||
foreach (var h in hardware)
|
||||
{
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, h);
|
||||
}
|
||||
}
|
||||
|
||||
if (!savingTTSImport) return;
|
||||
var allSensors = SensorsCollection.SensorsList.GetAllSensors(true);
|
||||
foreach (var sd in allSensors)
|
||||
{
|
||||
if (includedSensors.ContainsKey(sd.SerialNumber)) continue;
|
||||
var scs = SensorCalibration.GetCalibrationsBySerialNumber(sd);
|
||||
if (null != scs && scs.Length > 0)
|
||||
{
|
||||
includedCalibration.Add(sd.SerialNumber, scs);
|
||||
includedSensors.Add(sd.SerialNumber, sd);
|
||||
var sm = SensorModelCollection.SensorModelList.GetSensorModel(sd.Manufacturer,
|
||||
sd.Model);
|
||||
if (null == sm) continue;
|
||||
var key = $"{sm.Manufacturer}x_x{sm.Model}";
|
||||
if (!includedSensorModels.ContainsKey(key))
|
||||
{
|
||||
includedSensorModels.Add(key, sm);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine("calibration record is null");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static string ExportToFile(Dictionary<string, DataModel.TestTemplate> includedTests,
|
||||
Dictionary<string, IGroup> includedGroups,
|
||||
Dictionary<string, DataModel.DASHardware> includedDAS,
|
||||
Dictionary<string, SensorData> includedSensors,
|
||||
Dictionary<string, SensorModel> includedSensorModels,
|
||||
Dictionary<string, SensorCalibration[]> includedCalibration,
|
||||
Dictionary<string, DTS.Common.ISO.CustomerDetails> includedCustomerDetails,
|
||||
Dictionary<string, DTS.Common.ISO.TestEngineerDetails> includedTestEngineerDetails,
|
||||
Dictionary<string, DTS.Common.ISO.LabratoryDetails> includedLabDetails,
|
||||
Dictionary<string, DTS.Slice.Users.User> includedUsers,
|
||||
Dictionary<string, string> includedGlobalSettings,
|
||||
string exportFile,
|
||||
string originalImportFile,
|
||||
bool bUseFirstUseDate = true)
|
||||
{
|
||||
double totalStepsToComplete = includedCalibration.Count + includedDAS.Count +
|
||||
includedGroups.Count +
|
||||
+includedSensorModels.Count + includedSensors.Count + includedTests.Count +
|
||||
includedLabDetails.Count
|
||||
+ includedCustomerDetails.Count + includedTestEngineerDetails.Count +
|
||||
includedUsers.Count + includedGlobalSettings.Count;
|
||||
|
||||
double done = 0;
|
||||
var writer = FileUtils.GetExportWriter(Convert.ToInt32(totalStepsToComplete), FileUtils.CurrentXmlVersion,
|
||||
System.Reflection.Assembly.GetEntryAssembly().GetName().Name,
|
||||
System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(4), APILogger.Log, out var sb);
|
||||
|
||||
try
|
||||
{
|
||||
writer.WriteAttributeString("OriginalImportFile", originalImportFile);
|
||||
|
||||
var fields = Enum.GetValues(typeof(TopLevelFields)).Cast<TopLevelFields>().ToArray();
|
||||
|
||||
foreach (var f in fields)
|
||||
{
|
||||
switch (f)
|
||||
{
|
||||
case TopLevelFields.Calibrations:
|
||||
if (includedCalibration.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var c in includedCalibration)
|
||||
{
|
||||
foreach (var sc in c.Value) { writer.Flush(); sc.WriteXML(ref writer); writer.Flush(); }
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.CustomChannels:
|
||||
break;
|
||||
case TopLevelFields.DASList:
|
||||
if (includedDAS.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var h in includedDAS)
|
||||
{
|
||||
writer.Flush(); h.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.Groups:
|
||||
if (includedGroups.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var g in includedGroups)
|
||||
{
|
||||
writer.Flush(); g.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.GroupTemplates:
|
||||
break;
|
||||
case TopLevelFields.SensorModels:
|
||||
if (includedSensorModels.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var sm in includedSensorModels)
|
||||
{
|
||||
writer.Flush(); sm.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.Sensors:
|
||||
if (includedSensors.Count > 0)
|
||||
{
|
||||
writer.Flush();
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var sd in includedSensors)
|
||||
{
|
||||
writer.Flush(); sd.Value.WriteXML(ref writer, bUseFirstUseDate); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.TestSetups:
|
||||
if (includedTests.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var t in includedTests)
|
||||
{
|
||||
writer.Flush(); t.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.CustomerDetails:
|
||||
if (includedCustomerDetails.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var c in includedCustomerDetails)
|
||||
{
|
||||
writer.Flush(); c.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.Users:
|
||||
if (includedUsers.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
|
||||
foreach (var user in includedUsers)
|
||||
{
|
||||
writer.Flush();
|
||||
user.Value.WriteXML(ref writer);
|
||||
writer.Flush();
|
||||
done++;
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.TestEngineerDetails:
|
||||
if (includedTestEngineerDetails.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var c in includedTestEngineerDetails)
|
||||
{
|
||||
writer.Flush(); c.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.LabDetails:
|
||||
if (includedLabDetails.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
|
||||
foreach (var ld in includedLabDetails)
|
||||
{
|
||||
writer.Flush(); ld.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.CustomDirections:
|
||||
case TopLevelFields.CustomFilterClasses:
|
||||
case TopLevelFields.CustomFinLoc1s:
|
||||
case TopLevelFields.CustomFinLoc2s:
|
||||
case TopLevelFields.CustomFinLoc3s:
|
||||
case TopLevelFields.CustomMainLocs:
|
||||
case TopLevelFields.CustomTestObjects:
|
||||
case TopLevelFields.CustomPhysicalDimensions:
|
||||
case TopLevelFields.CustomPositions:
|
||||
break;
|
||||
case TopLevelFields.GlobalSettings:
|
||||
{
|
||||
if (includedGlobalSettings.Any())
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
|
||||
foreach (var setting in includedGlobalSettings)
|
||||
{
|
||||
writer.Flush();
|
||||
WriteGlobalSetting(setting.Key, setting.Value, ref writer);
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.SensorChangeHistory: break;
|
||||
default:
|
||||
throw new NotSupportedException("ExportTestSetup::ExportFunc unknown element: " + f);
|
||||
}
|
||||
}
|
||||
writer.WriteEndElement();//exportdocument
|
||||
writer.WriteEndDocument();
|
||||
|
||||
writer.Flush();
|
||||
writer.Close();
|
||||
if (null != exportFile)
|
||||
{
|
||||
System.IO.File.WriteAllText(exportFile, sb.ToString(), Encoding.Unicode);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
private static IGroup GetNonEmbeddedGroup(int? embeddedGroupStaticGroupId)
|
||||
{
|
||||
var unityContainer = ContainerLocator.Container.Resolve<IUnityContainer>();
|
||||
var vm = unityContainer.Resolve<IGroupListViewModel>();
|
||||
var g = vm.GetGroup(embeddedGroupStaticGroupId);
|
||||
return g;
|
||||
}
|
||||
private static List<DTS.Common.ISO.Hardware> GetHardware()
|
||||
{
|
||||
var hardwareList = new List<DTS.Common.ISO.Hardware>();
|
||||
var hResult = DbOperations.DASGet(null, null, out var dbDAS);
|
||||
if (0 == hResult)
|
||||
{
|
||||
foreach (var das in dbDAS)
|
||||
{
|
||||
hardwareList.Add(new DTS.Common.ISO.Hardware(das));
|
||||
}
|
||||
}
|
||||
return hardwareList;
|
||||
}
|
||||
private static DTS.Common.ISO.Hardware GetDAS(List<DTS.Common.ISO.Hardware> hardwareList, int hardwareId, DTS.Common.ISO.Hardware[] dasList)
|
||||
{
|
||||
var dasSerialNumber = GetHardwareSerialNumber(hardwareList, hardwareId);
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
if (das.SerialNumber == dasSerialNumber)
|
||||
{
|
||||
return das;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static string GetHardwareSerialNumber(List<DTS.Common.ISO.Hardware> hardwareList, int hId)
|
||||
{
|
||||
foreach (var hardware in hardwareList)
|
||||
{
|
||||
if (hardware.DASId == hId)
|
||||
{
|
||||
return hardware.SerialNumber;
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
private static void WriteGlobalSetting(string key, string value, ref System.Xml.XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("Setting");
|
||||
writer.WriteStartElement("SettingName");
|
||||
writer.WriteString(key);
|
||||
writer.WriteEndElement();
|
||||
writer.WriteStartElement("SettingValue");
|
||||
writer.WriteString(value);
|
||||
writer.WriteEndElement();
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
public static void PrepareForExportFields(DataModel.TestTemplate t,
|
||||
Dictionary<string, DataModel.TestTemplate> includedTests,
|
||||
Dictionary<string, DataModel.DASHardware> includedDAS
|
||||
)
|
||||
{
|
||||
if (!includedTests.ContainsKey(t.Name)) { includedTests[t.Name] = t; }
|
||||
|
||||
var groups = new List<IGroup>(t.Groups);
|
||||
|
||||
var sensorLookup = new Dictionary<int, ISensorData>();
|
||||
var sensors = SensorsCollection.SensorsList.GetAllSensors(false);
|
||||
foreach (var s in sensors)
|
||||
{
|
||||
sensorLookup[s.DatabaseId] = s;
|
||||
}
|
||||
var hardwareList = GetHardware();
|
||||
var dasList = DTS.Common.ISO.Hardware.GetAllDAS();
|
||||
foreach (var embeddedGroup in groups)
|
||||
{
|
||||
//Find the channels in this embedded Group so the Sensors will be included
|
||||
var groupChannelList = new List<IGroupChannel>();
|
||||
foreach (var groupChannelsList in t.ChannelsForGroup) //make this a linq statement?
|
||||
{
|
||||
if (groupChannelsList.Key == embeddedGroup)
|
||||
{
|
||||
groupChannelList = groupChannelsList.Value.ToList();
|
||||
}
|
||||
}
|
||||
foreach (var groupChannel in groupChannelList)
|
||||
{
|
||||
foreach (var dasId in embeddedGroup.IncludedHardware)
|
||||
{
|
||||
var h = GetDAS(hardwareList, dasId, dasList);
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, new DataModel.DASHardware(h));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If there's a non-imbedded (static) Group in the db, process it too.
|
||||
IGroup nonEmbeddedGroup = null;
|
||||
if (embeddedGroup.StaticGroupId != null)
|
||||
{
|
||||
if (Application.Current.Dispatcher.CheckAccess())
|
||||
{
|
||||
nonEmbeddedGroup = GetNonEmbeddedGroup(embeddedGroup.StaticGroupId);
|
||||
}
|
||||
else
|
||||
{
|
||||
ManualResetEvent manualResetEvent = new ManualResetEvent(false);
|
||||
|
||||
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
nonEmbeddedGroup = GetNonEmbeddedGroup(embeddedGroup.StaticGroupId);
|
||||
manualResetEvent.Set();
|
||||
}));
|
||||
|
||||
|
||||
manualResetEvent.WaitOne();
|
||||
}
|
||||
}
|
||||
|
||||
if (nonEmbeddedGroup == null || nonEmbeddedGroup.Id != embeddedGroup.StaticGroupId)
|
||||
{
|
||||
//We can get here if the static Group was created from a static Group which was later deleted,
|
||||
//but the embedded Group didn't have its StaticGroupId set to null (also fixed in this patch,
|
||||
//but pre-existing embedded Groups in the database could be pointing to a non-existent record)
|
||||
embeddedGroup.StaticGroupId = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
var hardwareLookup = new Dictionary<int, IDASHardware>();
|
||||
using (var enumHardware = includedDAS.GetEnumerator())
|
||||
{
|
||||
while (enumHardware.MoveNext()) { hardwareLookup[enumHardware.Current.Value.DASId] = enumHardware.Current.Value; }
|
||||
}
|
||||
|
||||
var channelDefaults = DbOperations.GetChannelSettingDefaults();
|
||||
|
||||
var groupChannelArray = nonEmbeddedGroup.GetAllChannels(false, sensorLookup, hardwareLookup, channelDefaults);
|
||||
foreach (var groupChannel in groupChannelArray)
|
||||
{
|
||||
nonEmbeddedGroup.GroupChannelList.Add(groupChannel);
|
||||
nonEmbeddedGroup.ChannelCount++;
|
||||
}
|
||||
|
||||
var channels = t.ChannelsForGroup[embeddedGroup];
|
||||
|
||||
foreach (var groupChannel in channels)
|
||||
{
|
||||
foreach (var dasId in nonEmbeddedGroup.IncludedHardware)
|
||||
{
|
||||
var h = GetDAS(hardwareList, dasId, dasList);
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, new DataModel.DASHardware(h));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var hardware = t.GetHardware();
|
||||
foreach (var h in hardware)
|
||||
{
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, h);
|
||||
}
|
||||
}
|
||||
foreach (var h in hardwareList)
|
||||
{
|
||||
if (includedDAS.ContainsKey(h.SerialNumber)) continue;
|
||||
|
||||
if (t.DASSampleRateList.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
t.DASSampleRateList.Remove(h.SerialNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static string ExportToFileFields(Dictionary<string, DataModel.TestTemplate> includedTests,
|
||||
Dictionary<string, DataModel.DASHardware> includedDAS,
|
||||
string originalImportFile)
|
||||
{
|
||||
double totalStepsToComplete = includedDAS.Count +
|
||||
includedTests.Count;
|
||||
|
||||
double done = 0;
|
||||
var writer = FileUtils.GetExportWriter(Convert.ToInt32(totalStepsToComplete), FileUtils.CurrentXmlVersion,
|
||||
System.Reflection.Assembly.GetEntryAssembly().GetName().Name,
|
||||
System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(4), APILogger.Log, out var sb);
|
||||
|
||||
try
|
||||
{
|
||||
writer.WriteAttributeString("OriginalImportFile", originalImportFile);
|
||||
|
||||
var fields = Enum.GetValues(typeof(TopLevelFields)).Cast<TopLevelFields>().ToArray();
|
||||
|
||||
foreach (var f in fields)
|
||||
{
|
||||
switch (f)
|
||||
{
|
||||
case TopLevelFields.DASList:
|
||||
if (includedDAS.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var h in includedDAS)
|
||||
{
|
||||
writer.Flush(); h.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.TestSetups:
|
||||
if (includedTests.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var t in includedTests)
|
||||
{
|
||||
writer.Flush(); t.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.CustomerDetails:
|
||||
case TopLevelFields.Users:
|
||||
case TopLevelFields.Calibrations:
|
||||
case TopLevelFields.CustomChannels:
|
||||
case TopLevelFields.Groups:
|
||||
case TopLevelFields.GroupTemplates:
|
||||
case TopLevelFields.SensorModels:
|
||||
case TopLevelFields.Sensors:
|
||||
case TopLevelFields.TestEngineerDetails:
|
||||
case TopLevelFields.LabDetails:
|
||||
case TopLevelFields.CustomDirections:
|
||||
case TopLevelFields.CustomFilterClasses:
|
||||
case TopLevelFields.CustomFinLoc1s:
|
||||
case TopLevelFields.CustomFinLoc2s:
|
||||
case TopLevelFields.CustomFinLoc3s:
|
||||
case TopLevelFields.CustomMainLocs:
|
||||
case TopLevelFields.CustomTestObjects:
|
||||
case TopLevelFields.CustomPhysicalDimensions:
|
||||
case TopLevelFields.CustomPositions:
|
||||
case TopLevelFields.GlobalSettings:
|
||||
case TopLevelFields.SensorChangeHistory:
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("ExportTestSetup::ExportFunc unknown element: " + f);
|
||||
}
|
||||
}
|
||||
writer.WriteEndElement();//exportdocument
|
||||
writer.WriteEndDocument();
|
||||
|
||||
writer.Flush();
|
||||
writer.Close();
|
||||
return sb.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.DataModel.Common
|
||||
{
|
||||
public class TestObjectHelper
|
||||
{
|
||||
#region constants and enums
|
||||
/// <summary>
|
||||
/// 8747 - this is the break point for TDC for software filters for TOM channels
|
||||
/// greater than 8000 sps it will use CFC 1000, 8k and below it uses 1/5 of SPS
|
||||
/// in datapro for now we only handle >8k and don't worry about <=8k
|
||||
/// </summary>
|
||||
public const double TDC_LEGACY_TOM_CUTOFF_SPS = 8000;
|
||||
/// <summary>
|
||||
/// this is the default filter in TDC for TOM channels recorded at > 8k SPS
|
||||
/// this is CFC1000
|
||||
/// </summary>
|
||||
public const double TDC_LEGACY_TOM_HIGH_FILTER = 1650D;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Windows.Media;
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class CollectDataProcess : BasePropertyChanged
|
||||
{
|
||||
private string _name;
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => SetProperty(ref _name, value, "Name");
|
||||
}
|
||||
|
||||
private Color _color;
|
||||
public Color BackgroundColor
|
||||
{
|
||||
get => _color;
|
||||
set => SetProperty(ref _color, value, "BackgroundColor");
|
||||
}
|
||||
|
||||
public CollectDataProcess(string name, Color color)
|
||||
{
|
||||
_name = name;
|
||||
_color = color;
|
||||
}
|
||||
private bool _isEnabled;
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set => SetProperty(ref _isEnabled, value, "IsEnabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class LabratoryDetails : BasePropertyChanged
|
||||
{
|
||||
private readonly DTS.Common.ISO.LabratoryDetails _lab;
|
||||
|
||||
public enum Tags
|
||||
{
|
||||
LabratoryName,
|
||||
LabratoryContactName,
|
||||
LabratoryContactPhone,
|
||||
LabratoryContactFax,
|
||||
LabratoryContactEmail,
|
||||
LabratoryTestRefNumber,
|
||||
LabratoryProjectRefNumber,
|
||||
Name
|
||||
}
|
||||
public string LabratoryName
|
||||
{
|
||||
get => _lab.LabratoryName;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryName = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryName.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryContactName
|
||||
{
|
||||
get => _lab.LabratoryContactName;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryContactName = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryContactName.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryContactPhone
|
||||
{
|
||||
get => _lab.LabratoryContactPhone;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryContactPhone = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryContactPhone.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryContactFax
|
||||
{
|
||||
get => _lab.LabratoryContactFax;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryContactFax = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryContactFax.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryContactEmail
|
||||
{
|
||||
get => _lab.LabratoryContactEmail;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryContactEmail = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryContactEmail.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryTestRefNumber
|
||||
{
|
||||
get => _lab.LabratoryTestRefNumber;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryTestRefNumber = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryTestRefNumber.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryProjectRefNumber
|
||||
{
|
||||
get => _lab.LabratoryProjectRefNumber;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryProjectRefNumber = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryProjectRefNumber.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _lab.Name;
|
||||
set
|
||||
{
|
||||
_lab.Name = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.Name.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public bool LocalOnly => _lab.LocalOnly;
|
||||
|
||||
public DateTime LastModified => _lab.LastModified;
|
||||
|
||||
public string LastModifiedBy => _lab.LastModifiedBy;
|
||||
|
||||
public int Version => _lab.Version;
|
||||
|
||||
public LabratoryDetails()
|
||||
{
|
||||
_lab = new DTS.Common.ISO.LabratoryDetails();
|
||||
_lab.Name = StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public bool HasBlankName()
|
||||
{
|
||||
return _lab.Name == StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public LabratoryDetails(DTS.Common.ISO.LabratoryDetails lab)
|
||||
{
|
||||
_lab = new DTS.Common.ISO.LabratoryDetails(lab);
|
||||
_isBlank = false;
|
||||
}
|
||||
public DTS.Common.ISO.LabratoryDetails GetIsoLab() { return _lab; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public bool IsBlank()
|
||||
{
|
||||
return _isBlank;
|
||||
}
|
||||
private bool _isBlank = true;
|
||||
}
|
||||
public class LabratoryDetailsList
|
||||
{
|
||||
protected LabratoryDetailsList()
|
||||
{
|
||||
}
|
||||
|
||||
public static LabratoryDetails[] GetAllLabs()
|
||||
{
|
||||
var isoLabs = DTS.Common.ISO.LabratoryDetails.GetAllLabratoryDetails();
|
||||
var labs = isoLabs.Select(isolab => new LabratoryDetails(isolab)).ToList();
|
||||
labs.Sort(CompareLabs);
|
||||
return labs.ToArray();
|
||||
}
|
||||
|
||||
public enum Tags
|
||||
{
|
||||
Labs
|
||||
}
|
||||
|
||||
public static void DeleteAll()
|
||||
{
|
||||
DTS.Common.ISO.LabratoryDetails.DeleteLabratoryDetails();
|
||||
}
|
||||
|
||||
private static int CompareLabs(LabratoryDetails a, LabratoryDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
return null == b ? 1 : string.Compare(a.Name, b.Name, StringComparison.Ordinal);
|
||||
}
|
||||
public static void Delete(LabratoryDetails lab)
|
||||
{
|
||||
lab?.GetIsoLab().Delete(ApplicationProperties.CurrentUser.UserName);
|
||||
}
|
||||
|
||||
public static void Delete(LabratoryDetails[] labs)
|
||||
{
|
||||
foreach (var lab in labs)
|
||||
{
|
||||
Delete(lab);
|
||||
}
|
||||
}
|
||||
public static LabratoryDetails GetLab(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name)) { return null; }
|
||||
var iso = DTS.Common.ISO.LabratoryDetails.GetLabratoryDetails(name);
|
||||
return null == iso ? null : new LabratoryDetails(iso);
|
||||
}
|
||||
|
||||
public static void AddLab(LabratoryDetails lab)
|
||||
{
|
||||
lab.GetIsoLab().Commit(ApplicationProperties.CurrentUser.UserName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <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 DASSettings()
|
||||
{
|
||||
}
|
||||
public DASSettings(DASSettings setting)
|
||||
{
|
||||
_DASSerialNumber = setting.DASSerialNumber;
|
||||
_sampleRate = setting.SampleRate;
|
||||
_excitationWarmupTimeMS = setting.ExcitationWarmupTimeMS;
|
||||
_aaf = setting.HardwareAAF;
|
||||
_preTriggerSeconds = setting.PreTriggerSeconds;
|
||||
_postTriggerSeconds = setting.PostTriggerSeconds;
|
||||
_statusLineCheck = setting.StatusLineCheck;
|
||||
_batteryCheck = setting.BatteryCheck;
|
||||
_inputVoltageMin = setting.InputVoltageMin;
|
||||
_inputVoltageMax = setting.InputVoltageMax;
|
||||
_batteryVoltageMin = setting.BatteryVoltageMin;
|
||||
_batteryVoltageMax = setting.BatteryVoltageMax;
|
||||
}
|
||||
private string _DASSerialNumber;
|
||||
public string DASSerialNumber { get => _DASSerialNumber; set => SetProperty(ref _DASSerialNumber, value, "DASSerialNumber"); }
|
||||
|
||||
private double _sampleRate;
|
||||
public double SampleRate { get => _sampleRate; set => SetProperty(ref _sampleRate, value, "SampleRate"); }
|
||||
|
||||
private int _excitationWarmupTimeMS;
|
||||
public int ExcitationWarmupTimeMS { get => _excitationWarmupTimeMS; set => SetProperty(ref _excitationWarmupTimeMS, value, "ExcitationWarmupTimeMS"); }
|
||||
|
||||
private double _aaf;
|
||||
public double HardwareAAF { get => _aaf; set => SetProperty(ref _aaf, value, "HardwareAAF"); }
|
||||
|
||||
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"); }
|
||||
|
||||
private bool _statusLineCheck;
|
||||
public bool StatusLineCheck { get => _statusLineCheck; set => SetProperty(ref _statusLineCheck, value, "StatusLineCheck"); }
|
||||
|
||||
private bool _batteryCheck;
|
||||
public bool BatteryCheck { get => _batteryCheck; set => SetProperty(ref _batteryCheck, value, "BatteryCheck"); }
|
||||
|
||||
private double _inputVoltageMin;
|
||||
public double InputVoltageMin { get => _inputVoltageMin; set => SetProperty(ref _inputVoltageMin, value, "InputVoltageMin"); }
|
||||
|
||||
private double _inputVoltageMax;
|
||||
public double InputVoltageMax { get => _inputVoltageMax; set => SetProperty(ref _inputVoltageMax, value, "InputVoltageMax"); }
|
||||
|
||||
private double _batteryVoltageMin;
|
||||
public double BatteryVoltageMin { get => _batteryVoltageMin; set => SetProperty(ref _batteryVoltageMin, value, "BatteryVoltageMin"); }
|
||||
|
||||
private double _batteryVoltageMax;
|
||||
public double BatteryVoltageMax { get => _batteryVoltageMax; set => SetProperty(ref _batteryVoltageMax, value, "BatteryVoltageMax"); }
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
using DTS.Common.Interface.DASFactory.Diagnostics;
|
||||
using DTS.SensorDB;
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes.TestTemplate
|
||||
{
|
||||
public interface ICachedContainer
|
||||
{
|
||||
DASHardware GetCachedHardware(string serialNumber);
|
||||
SensorData GetCachedSensor(string serialNumber);
|
||||
SensorCalibration[] GetCalibrations(string serialNumber);
|
||||
IISOHardware[] GetAllCachedHardware();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class CustomerDetails : BasePropertyChanged
|
||||
{
|
||||
private readonly DTS.Common.ISO.CustomerDetails _customerDetails;
|
||||
private bool _blank = true;
|
||||
public bool IsBlank() { return _blank; }
|
||||
public enum Fields
|
||||
{
|
||||
Name,
|
||||
CustomerName,
|
||||
CustomerTestRefNumber,
|
||||
ProjectRefNumber,
|
||||
CustomerOrderNumber,
|
||||
CustomerCostUnit
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _customerDetails.Name;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.Name = value; OnPropertyChanged(Fields.Name.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomerName
|
||||
{
|
||||
get => _customerDetails.CustomerName;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.CustomerName = value; OnPropertyChanged(Fields.CustomerName.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomerTestRefNumber
|
||||
{
|
||||
get => _customerDetails.CustomerTestRefNumber;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.CustomerTestRefNumber = value; OnPropertyChanged(Fields.CustomerTestRefNumber.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string ProjectRefNumber
|
||||
{
|
||||
get => _customerDetails.ProjectRefNumber;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.ProjectRefNumber = value; OnPropertyChanged(Fields.ProjectRefNumber.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomerOrderNumber
|
||||
{
|
||||
get => _customerDetails.CustomerOrderNumber;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.CustomerOrderNumber = value; OnPropertyChanged(Fields.CustomerOrderNumber.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomerCostUnit
|
||||
{
|
||||
get => _customerDetails.CustomerCostUnit;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.CustomerCostUnit = value; OnPropertyChanged(Fields.CustomerCostUnit.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public bool LocalOnly => _customerDetails.LocalOnly;
|
||||
|
||||
public DateTime LastModified => _customerDetails.LastModified;
|
||||
|
||||
public string LastModifiedBy => _customerDetails.LastModifiedBy;
|
||||
|
||||
public int Version => _customerDetails.Version;
|
||||
|
||||
public CustomerDetails()
|
||||
{
|
||||
_customerDetails = new DTS.Common.ISO.CustomerDetails();
|
||||
_customerDetails.Name = StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public bool HasBlankName()
|
||||
{
|
||||
return _customerDetails.Name == StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public CustomerDetails(DTS.Common.ISO.CustomerDetails customerDetails)
|
||||
{
|
||||
_customerDetails = new DTS.Common.ISO.CustomerDetails(customerDetails);
|
||||
_blank = false;
|
||||
}
|
||||
public DTS.Common.ISO.CustomerDetails GetISOCustomer()
|
||||
{
|
||||
return _customerDetails;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class CustomerDetailsList : BasePropertyChanged
|
||||
{
|
||||
protected CustomerDetailsList()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Delete(CustomerDetails customer)
|
||||
{
|
||||
customer.GetISOCustomer().Delete(ApplicationProperties.CurrentUser.UserName);
|
||||
}
|
||||
|
||||
public static void Delete(CustomerDetails[] customers)
|
||||
{
|
||||
foreach (var customer in customers)
|
||||
{
|
||||
Delete(customer);
|
||||
}
|
||||
}
|
||||
public static CustomerDetails[] GetAllCustomers()
|
||||
{
|
||||
var customers = DTS.Common.ISO.CustomerDetails.GetAllCustomerDetails();
|
||||
var allCustomers = new List<DataModel.CustomerDetails>();
|
||||
foreach (var customer in customers)
|
||||
{
|
||||
allCustomers.Add(new CustomerDetails(customer));
|
||||
}
|
||||
allCustomers.Sort(CompareCustomers);
|
||||
return allCustomers.ToArray();
|
||||
}
|
||||
public static void DeleteAll()
|
||||
{
|
||||
DTS.Common.ISO.CustomerDetails.DeleteCustomerDetails();
|
||||
}
|
||||
|
||||
private static int CompareCustomers(CustomerDetails a, CustomerDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
return null == b ? 1 : string.Compare(a.Name, b.Name, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static CustomerDetails GetCustomerDetail(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name)) { return null; }
|
||||
var iso = DTS.Common.ISO.CustomerDetails.GetCustomerDetails(name);
|
||||
return null == iso ? null : new CustomerDetails(iso);
|
||||
}
|
||||
|
||||
public static void AddCustomer(CustomerDetails customer)
|
||||
{
|
||||
customer.GetISOCustomer().Commit(ApplicationProperties.CurrentUser.UserName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using DTS.Common.Interface.ExportData;
|
||||
using System.ComponentModel;
|
||||
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes.Export
|
||||
{
|
||||
public class ExportHeader : IExportHeader
|
||||
{
|
||||
public ExportHeader()
|
||||
{
|
||||
}
|
||||
public ExportHeader(string headerName)
|
||||
{
|
||||
HeaderName = headerName;
|
||||
}
|
||||
public ExportHeader(string headerName, bool isSelected) : this(headerName)
|
||||
{
|
||||
IsSelected = isSelected;
|
||||
}
|
||||
private string _headerName;
|
||||
public string HeaderName
|
||||
{
|
||||
get { return _headerName; }
|
||||
set
|
||||
{
|
||||
_headerName = value;
|
||||
OnPropertyChanged("HeaderName");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isSelected = false;
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return _isSelected; }
|
||||
set
|
||||
{
|
||||
_isSelected = value;
|
||||
OnPropertyChanged("IsSelected");
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,429 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.DASLib.DASFactory;
|
||||
using DTS.DASLib.Service;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using DTS.Common.Enums.DASFactory;
|
||||
using DTS.Common.DataModel;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class DASFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// starts the auto discovery process if it's not running yet
|
||||
/// </summary>
|
||||
public void StartMulticastAutoDiscovery()
|
||||
{
|
||||
_dasFactory.StartMulticastAutoDiscovery();
|
||||
}
|
||||
/// <summary>
|
||||
/// stops the auto discovery process if it is running
|
||||
/// </summary>
|
||||
public void StopMulticastAutoDiscovery()
|
||||
{
|
||||
_dasFactory.StopMulticastAutoDiscovery();
|
||||
}
|
||||
/// <summary>
|
||||
/// returns any discovered devices
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IDiscoveredDevice [] GetDiscoveredDevices()
|
||||
{
|
||||
return _dasFactory.GetDiscoveredDevices();
|
||||
}
|
||||
private DTS.DASLib.DASFactory.DASFactory _dasFactory;
|
||||
public IDASFactory GetDASFactory() { return _dasFactory; }
|
||||
public DASFactory()
|
||||
{
|
||||
//10285 Unhandled exception during diagnostics.
|
||||
//this initializes the interval value used in CheckUnitsAvailable to make the sleep time configurable.
|
||||
DTS.DASLib.Service.ServiceBase.InitializeCheckUnitsInterval(DataModelSettings.CheckUnitsIntervalMillisecond);
|
||||
//10843 TDAS communication needs to be throttled
|
||||
//this initializes the throttling of TDAS devices
|
||||
DTS.DASLib.Command.TDAS.CommandBase.InitializeSemaphore(
|
||||
DataModelSettings.SemaphoreDelay,
|
||||
DataModelSettings.SemaphoreSpots);
|
||||
//initialize SLICESemaphore before any communication starts
|
||||
//10852 Add semaphore to SLICE communication to improve SLICE 6 multiple IP performance
|
||||
DTS.DASLib.Command.SliceCommandBase.Initialize(DataModelSettings.SLICEConcurrentSpots,
|
||||
DataModelSettings.SLICEConcurrentDelayMs);
|
||||
_dasFactory = new DTS.DASLib.DASFactory.DASFactory(false, false);
|
||||
_dasFactory.DetachAllDevices();
|
||||
var mre = new ManualResetEvent(false);
|
||||
_dasFactory.Refresh(delegate { mre.Set(); });
|
||||
mre.WaitOne();
|
||||
_dasFactory.MultiCastAutoDiscoveryDefaultTimeoutMS = DataModelSettings.MulticastAutoDiscoveryReceiveTimeoutMS;
|
||||
|
||||
//16053 Implement KeepAliveSeconds and KeepAliveRetrySeconds in the .config file
|
||||
DFConstantsAndEnums.LocalKeepAliveRetryIntervalMS = DataModelSettings.LocalKeepAliveRetryIntervalMS;
|
||||
DFConstantsAndEnums.LocalKeepAliveTimeOutMS = DataModelSettings.LocalKeepAliveTimeOutMS;
|
||||
DFConstantsAndEnums.RemoteKeepAliveRetryIntervalSeconds = DataModelSettings.RemoteKeepAliveRetryIntervalSeconds;
|
||||
DFConstantsAndEnums.RemoteKeepAliveSeconds = DataModelSettings.RemoteKeepAliveSeconds;
|
||||
|
||||
DFConstantsAndEnums.ReceiveBufferSizeBytes = DataModelSettings.ReceiveBufferSizeBytes;
|
||||
DFConstantsAndEnums.SendBufferSizeBytes = DataModelSettings.SendBufferSizeBytes;
|
||||
|
||||
DFConstantsAndEnums.HeartbeatAsyncConnectTimeoutMS = DataModelSettings.HeartbeatAsyncConnectTimeoutMS;
|
||||
|
||||
_dasFactory.DeviceArrived += _dasFactory_DeviceArrived;
|
||||
_dasFactory.DeviceFailed += _dasFactory_DeviceFailed;
|
||||
_dasFactory.DeviceRemoved += _dasFactory_DeviceRemoved;
|
||||
}
|
||||
|
||||
public event DASFactoryEventHandler OnDeviceArrived;
|
||||
public event DASFactoryEventHandler OnFactoryChanged;
|
||||
|
||||
public void TakeOwnership()
|
||||
{
|
||||
try
|
||||
{
|
||||
_dasFactory.TakeOwnership();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void _dasFactory_DeviceRemoved(object sender, DASFactoryEventArgs e)
|
||||
{
|
||||
OnFactoryChanged?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
|
||||
private void _dasFactory_DeviceFailed(object sender, DASFactoryEventArgs e)
|
||||
{
|
||||
OnFactoryChanged?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
private void _dasFactory_DeviceArrived(object sender, DASFactoryEventArgs e)
|
||||
{
|
||||
OnDeviceArrived?.Invoke(sender, e);
|
||||
OnFactoryChanged?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
public void DetachAllDevices(bool detachUSB = false)
|
||||
{
|
||||
// FB14290: make USB detaching conditional
|
||||
_dasFactory.DetachAllDevices(detachUSB);
|
||||
}
|
||||
|
||||
public void DisposeFactory()
|
||||
{
|
||||
_dasFactory.Dispose();
|
||||
_dasFactory = null;
|
||||
}
|
||||
//#define LOG_DEBUG_REFRESH
|
||||
public string[] TDASHostNames
|
||||
{
|
||||
get { return _dasFactory.TDASHostNames; }
|
||||
set
|
||||
{
|
||||
if (_bInRefresh)
|
||||
{
|
||||
#if LOG_DEBUG_REFRESH
|
||||
var st = new StackTrace(true);
|
||||
APILogger.Log("TDASHostNames SET WHILE WE ARE IN REFRESH\n", st.ToString());
|
||||
#endif
|
||||
}
|
||||
if (null == value || null == _dasFactory.TDASHostNames)
|
||||
{
|
||||
_dasFactory.TDASHostNames = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this has side effects, so only change if needed
|
||||
var equals = _dasFactory.TDASHostNames.OrderBy(a => a).SequenceEqual(value.OrderBy(a => a));
|
||||
if (false == equals)
|
||||
{
|
||||
_dasFactory.TDASHostNames = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// http://fogbugz/fogbugz/default.asp?2903
|
||||
/// could also be called SliceDbHostNames
|
||||
/// </summary>
|
||||
public string[] SDBHostNames
|
||||
{
|
||||
get { return _dasFactory.SliceDBHostNames; }
|
||||
set
|
||||
{
|
||||
if (_bInRefresh)
|
||||
{
|
||||
#if LOG_DEBUG_REFRESH
|
||||
var st = new StackTrace(true);
|
||||
APILogger.Log("SDBHostNames SET WHILE WE ARE IN REFRESH\n", st.ToString());
|
||||
#endif
|
||||
}
|
||||
if (null == value || null == _dasFactory.SliceDBHostNames)
|
||||
{
|
||||
_dasFactory.SliceDBHostNames = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this has side effects, so only change if needed
|
||||
var equals = _dasFactory.SliceDBHostNames.OrderBy(a => a).SequenceEqual(value.OrderBy(a => a));
|
||||
if (false == equals)
|
||||
{
|
||||
_dasFactory.SliceDBHostNames = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public SortableBindingList<IDiscoveredDevice> AutoDiscoverMulticast()
|
||||
{
|
||||
CancellationToken ct = new CancellationToken();
|
||||
return _dasFactory.AutoDiscoverMulticast(ct);
|
||||
}
|
||||
public delegate void DiscoveredDASEventHandler(object sender, IEnumerable<IDiscoveredDevice> newDevices);
|
||||
public event DiscoveredDASEventHandler DiscoveredDAS;
|
||||
public void DiscoveryThread(DFConstantsAndEnums.MultiCastDeviceClasses[] deviceFilter, CancellationToken ct, bool discoverParents = true)
|
||||
{
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
var discoveries = _dasFactory.AutoDiscoverMulticast(ct, discoverParents).ToList();
|
||||
var filteredDiscoveries = deviceFilter?.Count() > 0 ? discoveries.Where(idd => deviceFilter.Contains(idd.DevClass)).ToList() : discoveries;
|
||||
|
||||
DiscoveredDAS.Invoke(this, filteredDiscoveries);
|
||||
|
||||
ct.WaitHandle.WaitOne(1000);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// starts qats listening
|
||||
/// </summary>
|
||||
public void StartQATSListening()
|
||||
{
|
||||
_dasFactory.StartQATSListening();
|
||||
}
|
||||
/// <summary>
|
||||
/// stops any QATS listening
|
||||
/// </summary>
|
||||
public void StopQATSListening()
|
||||
{
|
||||
_dasFactory.StopQATSListening();
|
||||
}
|
||||
/// <summary>
|
||||
/// sends the request to send UDP QATS messages
|
||||
/// </summary>
|
||||
public void SendQATSRequest()
|
||||
{
|
||||
_dasFactory.SendQATSRequest();
|
||||
}
|
||||
/// <summary>
|
||||
/// returns any QueryArmTriggerStatus that are waiting and clears the list of waiting QATS
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IUDPQATSEntry[] GetQATS()
|
||||
{
|
||||
return _dasFactory.GetQATS();
|
||||
}
|
||||
/// <summary>
|
||||
/// configures the default timeout for multicast autodiscovery receive timeout
|
||||
/// in ms
|
||||
/// </summary>
|
||||
public int MulticastAutoDiscoveryReceiveTimeoutMS
|
||||
{
|
||||
get => _dasFactory.MultiCastAutoDiscoveryDefaultTimeoutMS;
|
||||
set => _dasFactory.MultiCastAutoDiscoveryDefaultTimeoutMS = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// configures the trasmit address for multicast autodiscovery
|
||||
/// in ms
|
||||
/// </summary>
|
||||
public string MulticastAutoDiscoveryAddress
|
||||
{
|
||||
get => _dasFactory.MulticastAutoDiscoveryAddress;
|
||||
set => _dasFactory.MulticastAutoDiscoveryAddress = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// configures the trasmit port for multicast autodiscovery
|
||||
/// in ms
|
||||
/// </summary>
|
||||
public int MulticastAutoDiscoveryPort
|
||||
{
|
||||
get => _dasFactory.MulticastAutoDiscoveryPort;
|
||||
set => _dasFactory.MulticastAutoDiscoveryPort = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// configures the receive port for multicast autodiscovery
|
||||
/// in ms
|
||||
/// </summary>
|
||||
public int MulticastAutoDiscoveryResponsePort
|
||||
{
|
||||
get => _dasFactory.MulticastAutoDiscoveryResponsePort;
|
||||
set => _dasFactory.MulticastAutoDiscoveryResponsePort = value;
|
||||
}
|
||||
|
||||
public double S6ConnectNewTimeout
|
||||
{
|
||||
get => _dasFactory.S6ConnectNewTimeout;
|
||||
set => _dasFactory.S6ConnectNewTimeout = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// I noticed in some logs - only one refresh at a time
|
||||
/// refresh is getting called multiple times for some reason.
|
||||
/// This gets a bit sticky, there's no reason for Refresh to be called more than once while refresh is still running,
|
||||
/// however one of the options for refresh is to not wait for it to finish, which means you could get into this situation.
|
||||
/// I haven't been able to duplicate this problem myself, so I'm going to add some logging to help find out how we got there if we
|
||||
/// get there again, and also some code to address when we do find ourselves there
|
||||
///
|
||||
/// </summary>
|
||||
private volatile bool _bInRefresh;
|
||||
|
||||
public void Refresh(bool wait)
|
||||
{
|
||||
|
||||
APILogger.Log(APILogger.GetCurrentMethod());
|
||||
if (_bInRefresh)
|
||||
{
|
||||
#if LOG_DEBUG_REFRESH
|
||||
var st = new StackTrace(true);
|
||||
APILogger.Log(string.Format("Warning - OVERLAPPING REFRESH CALL!\nStackTrace:\n{0}", st));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
var mre = new ManualResetEvent(false);
|
||||
try
|
||||
{
|
||||
_bInRefresh = true;
|
||||
_dasFactory.Refresh(delegate
|
||||
{
|
||||
mre.Set();
|
||||
_bInRefresh = false;
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Exception refreshing ", ex.Message);
|
||||
return;
|
||||
}
|
||||
if (wait)
|
||||
{
|
||||
mre.WaitOne();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<IDASCommunication> GetActiveDevices()
|
||||
{
|
||||
return _dasFactory.GetDASList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 14157 Refresh/Stability Issue in Data Acquisition Tile
|
||||
/// returns the list of all devices known connectable via ECM/SDB/S6DB
|
||||
/// these distributors have a HELLO SLICEBASE x.x.x.x:yyyy format, so
|
||||
/// we keep track of what the db told us
|
||||
/// this returns all the reported connections
|
||||
/// </summary>
|
||||
public string[] GetReportedConnections()
|
||||
{
|
||||
return _dasFactory.GetConnectedDevices();
|
||||
}
|
||||
/// <summary>
|
||||
/// runs auto discovery if needed, populating the downstream mac addresses for all attached SLICE6/SLICE6Db devices
|
||||
/// completes immediately if there are no attached SLICE6/SLICE6Db devices
|
||||
/// </summary>
|
||||
public void AutoDiscoverIfNecessary()
|
||||
{
|
||||
var foundDas = ApplicationProperties.DASFactory.GetActiveDevices();
|
||||
var bNeedToRun = foundDas.OfType<EthernetSlice6DB>().Any();
|
||||
if (!bNeedToRun) return;
|
||||
var ipAddressToIdas = new Dictionary<string, IDASCommunication>();
|
||||
foreach (var das in foundDas)
|
||||
{
|
||||
var h = new DASHardware(das);
|
||||
var connection = h.ConnectionUSBAware.ToLower();
|
||||
if (connection.Contains("usb"))
|
||||
{
|
||||
connection = h.SerialNumber;
|
||||
}
|
||||
ipAddressToIdas[connection] = das;
|
||||
}
|
||||
try
|
||||
{
|
||||
var units = ApplicationProperties.DASFactory.AutoDiscoverMulticast();
|
||||
var macAddresToDevice = new Dictionary<string, IDiscoveredDevice>();
|
||||
foreach (var unit in units)
|
||||
{
|
||||
var mac = unit.Mac.Replace('-', ':').ToUpper();
|
||||
macAddresToDevice[mac] = unit;
|
||||
}
|
||||
foreach (var unit in units)
|
||||
{
|
||||
if (!ipAddressToIdas.ContainsKey(unit.Ip))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ipAddressToIdas[unit.Ip].MACAddress = unit.Mac;
|
||||
ipAddressToIdas[unit.Ip].DownstreamMACAddresses = (from c in unit.Connections
|
||||
select c.MACAddress.Replace('-', ':').ToUpper()
|
||||
into childMac
|
||||
where macAddresToDevice.ContainsKey(childMac)
|
||||
select macAddresToDevice[childMac]
|
||||
into childDevice
|
||||
select childDevice.Mac).ToArray();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// returns true if the DAS is streaming
|
||||
/// </summary>
|
||||
/// <param name="das"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsStreaming(IDASCommunication das)
|
||||
{
|
||||
if (!(das is EthernetSlice6Air)) { return false; }
|
||||
|
||||
if (null == das.DASArmStatus)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//15932 Error when performing test when S6A is streaming
|
||||
//don't currently know of a better way to determine if the unit is streaming or not
|
||||
//when attaching to a stream device some attributes can't be read and because of timing
|
||||
//some status may not be populated, but if we aren't armed or in realtime and we are a S6A and
|
||||
//we responded with Invalid mode during setup, we are _probably_ streaming
|
||||
return !das.DASArmStatus.IsArmed && !das.DASArmStatus.IsInRealtime &&
|
||||
das.DASArmStatus.ReceivedInvalidModeDuringSetup;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns true if the unit is in realtime
|
||||
/// uses DASArmStatus, but this isn't always populated on time, so if the unit is streaming it will also
|
||||
/// return true, which seems to be consistent with what was intended in the old code
|
||||
/// 15932 Error when performing test when S6A is streaming
|
||||
/// </summary>
|
||||
/// <param name="das"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsInRealtime(IDASCommunication das)
|
||||
{
|
||||
if (null == das.DASArmStatus) { return false; }
|
||||
return das.DASArmStatus.IsInRealtime || IsStreaming(das);
|
||||
}
|
||||
/// <summary>
|
||||
/// returns true if any of the units in the input parameters are in realtime or are streaming
|
||||
/// </summary>
|
||||
/// <param name="das"></param>
|
||||
/// <returns></returns>
|
||||
public static bool AnyInRealtime(List<IDASCommunication> das)
|
||||
{
|
||||
return das.Exists(unit => IsInRealtime(unit));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.ISO;
|
||||
using DTS.Common.DataModel;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class TestObjectTemplateCollection : BasePropertyChanged
|
||||
{
|
||||
private static volatile TestObjectTemplateCollection _testObjectCollection;
|
||||
public static TestObjectTemplateCollection TemplateCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == _testObjectCollection)
|
||||
{
|
||||
_testObjectCollection = new TestObjectTemplateCollection();
|
||||
}
|
||||
return _testObjectCollection;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly TestObjectTemplate _sysBuiltTestObjectTemplate;
|
||||
public TestObjectTemplate SysBuiltTestObjectTemplate => _sysBuiltTestObjectTemplate;
|
||||
public TestObjectTemplate GetTemplate(string templateId)
|
||||
{
|
||||
var db = ApplicationProperties.IsoDb;
|
||||
var isoTemplate = DTS.Common.ISO.TestObjectTemplate.GetTemplate(ref db, templateId);
|
||||
if (null != isoTemplate)
|
||||
{
|
||||
return new TestObjectTemplate(isoTemplate, ref db);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TestObjectTemplateCollection()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,544 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.ISO;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
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
|
||||
}
|
||||
private enum GroupTemplateChannelFields
|
||||
{
|
||||
TestObjectNumber,
|
||||
NameOfTheChannel,
|
||||
LaboratoryChannelCode,
|
||||
CustomerChannelCode,
|
||||
Comments1,
|
||||
Location,
|
||||
Dimension,
|
||||
Direction,
|
||||
ChannelFrequencyClass,
|
||||
Unit,
|
||||
ReferenceSystem,
|
||||
TransducerType,
|
||||
TransducerId,
|
||||
PreFilterType,
|
||||
CutOffFrequency,
|
||||
ChannelAmplitudeClass,
|
||||
ReferenceChannel,
|
||||
ReferenceChannelName,
|
||||
DataSource,
|
||||
DataStatus,
|
||||
SamplingInterval,
|
||||
BitResolution,
|
||||
TimeOfFirstSample,
|
||||
NumberOfSamples,
|
||||
OffsetPostTest,
|
||||
TransducerNaturalFrequency,
|
||||
TransducerDampingRatio,
|
||||
Comments,
|
||||
FirstGlobalMaximumValue,
|
||||
TimeOfMaximumValue,
|
||||
FirstGlobalMinimumValue,
|
||||
TimeOfMinimumValue,
|
||||
StartOffsetInterval,
|
||||
EndOffsetInterval,
|
||||
MMEChannelId,
|
||||
MMEChannelType,
|
||||
Required,
|
||||
DisplayOrder,
|
||||
LocalOnly
|
||||
}
|
||||
private enum GroupTemplateFields
|
||||
{
|
||||
TemplateName,
|
||||
Icon,
|
||||
Description,
|
||||
LocalOnly,
|
||||
Version,
|
||||
LastModifiedBy,
|
||||
LastModified,
|
||||
CRC32,
|
||||
TestObjectType,
|
||||
TestObject,
|
||||
ParentTemplate,
|
||||
SysBuilt,
|
||||
OriginalTemplateName,
|
||||
Embedded
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region properties
|
||||
|
||||
private string _lastModifiedBy = "N/A";
|
||||
public string LastModifiedBy
|
||||
{
|
||||
get => _lastModifiedBy;
|
||||
set => SetProperty(ref _lastModifiedBy, value, "LastModifiedBy");
|
||||
}
|
||||
|
||||
private DateTime _lastModified = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => SetProperty(ref _lastModified, value, "LastModified");
|
||||
}
|
||||
|
||||
private DTS.Common.ISO.TestObjectTemplate _template;
|
||||
|
||||
private List<TestObjectTemplateChannel> _requiredChannels = new List<TestObjectTemplateChannel>();
|
||||
public List<TestObjectTemplateChannel> RequiredChannels
|
||||
{
|
||||
get => _requiredChannels;
|
||||
set { _requiredChannels = value; OnPropertyChanged("RequiredChannels"); }
|
||||
}
|
||||
|
||||
private string _templateParent = "";
|
||||
public string TemplateParent
|
||||
{
|
||||
get => _templateParent;
|
||||
set => SetProperty(ref _templateParent, value, "TemplateParent");
|
||||
}
|
||||
|
||||
private bool _sysBuilt;
|
||||
public bool SysBuilt
|
||||
{
|
||||
get => _sysBuilt;
|
||||
set => SetProperty(ref _sysBuilt, value, "SysBuilt");
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
private string _name;
|
||||
public string TemplateName
|
||||
{
|
||||
get => _name;
|
||||
set => SetProperty(ref _name, value, Tags.TemplateName.ToString());
|
||||
}
|
||||
|
||||
private string _desc;
|
||||
public string TemplateDescription
|
||||
{
|
||||
get => _desc;
|
||||
set => SetProperty(ref _desc, value, Tags.TemplateDescription.ToString());
|
||||
}
|
||||
|
||||
private bool _bLocalOnly;
|
||||
|
||||
public bool IsLocalOnly
|
||||
{
|
||||
get => _bLocalOnly;
|
||||
set => SetProperty(ref _bLocalOnly, value, "IsLocalOnly");
|
||||
}
|
||||
|
||||
private MMETestObjects _testObject;
|
||||
public MMETestObjects TestObject
|
||||
{
|
||||
get => _testObject;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _testObject, value, Tags.TestObject.ToString());
|
||||
if (null == _testObject) return;
|
||||
AvailableTestObjectTypes = ApplicationProperties.IsoDb.GetUniquePossibleChannelTypes(TestObjectTemplateChannel.NONISOCHANNELTYPE);
|
||||
if (AvailableTestObjectTypes.Length > 0) { TestObjectTypeIndex = 0; }
|
||||
else { TestObjectTypeIndex = -1; }
|
||||
}
|
||||
}
|
||||
|
||||
private string _testObjectType;
|
||||
public string TestObjectType
|
||||
{
|
||||
get => _testObjectType;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _testObjectType, value, Tags.TestObjectType.ToString());
|
||||
_channels = new List<MMEPossibleChannels>(ApplicationProperties.IsoDb.GetPossibleChannelsForType(_testObjectType));
|
||||
TemplateAllChannels = _channels.Select(pc => new TestObjectTemplateChannel(new TestObjectTemplateChannel(pc), /*ref db,*/ _template)).ToArray();
|
||||
AssignOrders();
|
||||
OnPropertyChanged(Tags.PossibleChannelCountText.ToString());
|
||||
OnPropertyChanged(Tags.ChannelCountText.ToString());
|
||||
OnPropertyChanged(Tags.TestObjectTypeIndex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void AssignOrders()
|
||||
{
|
||||
var allChannels = TemplateAllChannels.ToList();
|
||||
if (!allChannels.Any()) { return; }
|
||||
allChannels.Sort();
|
||||
var maxDisplayOrder = (from ch in allChannels select ch.DisplayOrder).Max();
|
||||
foreach (var ch in allChannels)
|
||||
{
|
||||
if (-1 == ch.DisplayOrder)
|
||||
{
|
||||
ch.DisplayOrder = ++maxDisplayOrder;
|
||||
}
|
||||
}
|
||||
}
|
||||
private List<MMEPossibleChannels> _channels = new List<MMEPossibleChannels>();
|
||||
|
||||
//11287 Out of memory exception when importing large CSV Test Setup files
|
||||
//reduced one collection of channels to refer to channel super class members
|
||||
public TestObjectTemplateChannel[] TemplateAllChannels
|
||||
{
|
||||
get
|
||||
{
|
||||
var channels = (from ch in _allUIChannels select ch.Channel).ToArray();
|
||||
return channels;
|
||||
}
|
||||
set
|
||||
{
|
||||
TemplateAllUIChannels = value.Select(c => new TemplateChannelUI(c)).ToArray();
|
||||
}
|
||||
}
|
||||
private List<TemplateChannelUI> _allUIChannels = new List<TemplateChannelUI>();
|
||||
public TemplateChannelUI[] TemplateAllUIChannels
|
||||
{
|
||||
get => _allUIChannels.ToArray();
|
||||
set => SetProperty(ref _allUIChannels, new List<TemplateChannelUI>(value), Tags.TemplateAllUIChannels.ToString());
|
||||
}
|
||||
|
||||
|
||||
private List<MMETestObjects> _testObjects = new List<MMETestObjects>();
|
||||
|
||||
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>(ApplicationProperties.IsoDb.GetTestObjectTypeForTestObject(TestObject.Test_Object));
|
||||
return _availableTestObjectTypes.ToArray();
|
||||
}
|
||||
set => SetProperty(ref _availableTestObjectTypes, new List<string>(value), Tags.AvailableTestObjectTypes.ToString());
|
||||
}
|
||||
|
||||
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;
|
||||
SetProperty(ref _testObjectTypeIndex, value, Tags.TestObjectTypeIndex.ToString());
|
||||
|
||||
TemplateAllChannels = _channels.Select(pc => new TestObjectTemplateChannel(new TestObjectTemplateChannel(pc), /*ref db,*/ _template)).ToArray();
|
||||
AssignOrders();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region methods
|
||||
public void MarkChanged(string tag)
|
||||
{
|
||||
OnPropertyChanged(tag);
|
||||
}
|
||||
|
||||
public int CompareTo(TestObjectTemplate rhs)
|
||||
{
|
||||
if (null == rhs) { return 1; }
|
||||
return this == rhs ? 0 : string.Compare(TemplateName, rhs.TemplateName, StringComparison.Ordinal);
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Embedded ? OriginalTemplateName : TemplateName;
|
||||
}
|
||||
|
||||
public DTS.Common.ISO.TestObjectTemplate ToISOTestObjectTemplate()
|
||||
{
|
||||
var template = new DTS.Common.ISO.TestObjectTemplate(TemplateName, IsLocalOnly)
|
||||
{
|
||||
Description = TemplateDescription,
|
||||
OriginalTemplateName = OriginalTemplateName,
|
||||
Embedded = Embedded,
|
||||
Icon = "",
|
||||
LocalOnly = IsLocalOnly,
|
||||
TestObject = TestObject.Test_Object,
|
||||
TestObjectType = TestObjectType
|
||||
};
|
||||
|
||||
template.TemplateParent = TemplateParent;
|
||||
template.Channels = TemplateAllChannels;
|
||||
template.SysBuilt = SysBuilt;
|
||||
return template;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region constructors and initialization
|
||||
public TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)
|
||||
{
|
||||
if (null != copy._template) { _template = new DTS.Common.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();
|
||||
|
||||
SysBuilt = copy.SysBuilt;
|
||||
Embedded = copy.Embedded;
|
||||
OriginalTemplateName = copy.OriginalTemplateName;
|
||||
}
|
||||
public TestObjectTemplate(DTS.Common.ISO.TestObjectTemplate template, ref ISO13499FileDb db)
|
||||
{
|
||||
Initialize(template, ref db, null);
|
||||
}
|
||||
public TestObjectTemplate(DTS.Common.ISO.TestObjectTemplate template, ref ISO13499FileDb db, List<MMETestObjects> testObjects)
|
||||
{
|
||||
Initialize(template, ref db, testObjects);
|
||||
}
|
||||
private void Initialize(DTS.Common.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 = ApplicationProperties.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();
|
||||
TemplateParent = template.TemplateParent;
|
||||
SysBuilt = template.SysBuilt;
|
||||
}
|
||||
public TestObjectTemplate()
|
||||
{
|
||||
TemplateName = string.Empty;
|
||||
TemplateDescription = string.Empty;
|
||||
TemplateParent = string.Empty;
|
||||
TestObject = ApplicationProperties.IsoDb.GetTestObjects(false).FirstOrDefault();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region XML Serialization
|
||||
public static DTS.Common.ISO.TestObjectTemplate ReadXML(System.Xml.XmlElement root, Dictionary<long, MMEPossibleChannels> importChannels)
|
||||
{
|
||||
var template = new DTS.Common.ISO.TestObjectTemplate("", false);
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
if (node is System.Xml.XmlElement) { ProcessXMLElement(node as System.Xml.XmlElement, ref template, importChannels); }
|
||||
}
|
||||
return template;
|
||||
}
|
||||
private static void ProcessXMLElement(System.Xml.XmlElement node, ref DTS.Common.ISO.TestObjectTemplate template, Dictionary<long, MMEPossibleChannels> importChannels)
|
||||
{
|
||||
if (Enum.TryParse(node.Name, out GroupTemplateFields field))
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case GroupTemplateFields.CRC32: template.CRC32 = Convert.ToInt32(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case GroupTemplateFields.Description: template.Description = node.InnerText; break;
|
||||
case GroupTemplateFields.Icon: template.Icon = node.InnerText; break;
|
||||
case GroupTemplateFields.LastModified: template.LastModified = DateTime.Parse(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case GroupTemplateFields.LastModifiedBy: template.LastModifiedBy = node.InnerText; break;
|
||||
case GroupTemplateFields.LocalOnly: template.LocalOnly = Convert.ToBoolean(node.InnerText); break;
|
||||
case GroupTemplateFields.ParentTemplate: template.TemplateParent = node.InnerText; break;
|
||||
case GroupTemplateFields.SysBuilt: template.SysBuilt = Convert.ToBoolean(node.InnerText); break;
|
||||
case GroupTemplateFields.TemplateName: template.TemplateName = node.InnerText.Trim(); break;
|
||||
case GroupTemplateFields.TestObject: template.TestObject = node.InnerText; break;
|
||||
case GroupTemplateFields.TestObjectType: template.TestObjectType = node.InnerText; break;
|
||||
case GroupTemplateFields.Version: template.Version = Convert.ToInt32(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case GroupTemplateFields.OriginalTemplateName: template.OriginalTemplateName = node.InnerText; break;
|
||||
case GroupTemplateFields.Embedded: template.Embedded = Convert.ToBoolean(node.InnerText); break;
|
||||
default: throw new NotSupportedException("TestObjectTemplate::ProcessXMLElement unknown field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
else if (node.Name == "TemplateChannels")
|
||||
{
|
||||
foreach (var child in node.ChildNodes)
|
||||
{
|
||||
ProcessChannelXMLNode(child as System.Xml.XmlElement, ref template, importChannels);
|
||||
}
|
||||
var channels = new List<TestObjectTemplateChannel>(template.Channels);
|
||||
channels.Sort();
|
||||
template.Channels = channels.ToArray();
|
||||
}
|
||||
}
|
||||
private static void ProcessChannelXMLNode(System.Xml.XmlElement root, ref DTS.Common.ISO.TestObjectTemplate template, Dictionary<long, MMEPossibleChannels> importChannels)
|
||||
{
|
||||
var existingChannels = new List<TestObjectTemplateChannel>(template.Channels);
|
||||
|
||||
var values = new Dictionary<GroupTemplateChannelFields, string>();
|
||||
foreach (var child in root.ChildNodes)
|
||||
{
|
||||
var node = child as System.Xml.XmlElement;
|
||||
if (null == node) { continue; }
|
||||
|
||||
if (Enum.TryParse(node.Name, out GroupTemplateChannelFields field)) { values[field] = node.InnerText; }
|
||||
}
|
||||
|
||||
if (!values.ContainsKey(GroupTemplateChannelFields.MMEChannelId) || !values.ContainsKey(GroupTemplateChannelFields.MMEChannelType)) { return; }
|
||||
|
||||
|
||||
if (!long.TryParse(values[GroupTemplateChannelFields.MMEChannelId], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out long id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!int.TryParse(values[GroupTemplateChannelFields.MMEChannelType], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out int cType))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MMEPossibleChannels mChannel;
|
||||
|
||||
if (cType == (int)MMEPossibleChannels.MMEChannelTypes.SQL && importChannels.ContainsKey(id))
|
||||
{
|
||||
mChannel = importChannels[id];
|
||||
}
|
||||
else { mChannel = ApplicationProperties.IsoDb.GetPossibleChannel(id, cType); }
|
||||
|
||||
if (null == mChannel) { return; }
|
||||
|
||||
var channel = new TestObjectTemplateChannel(mChannel);
|
||||
|
||||
using (var enumeratorGroupChannelFieldSettings = values.GetEnumerator())
|
||||
{
|
||||
while (enumeratorGroupChannelFieldSettings.MoveNext())
|
||||
{
|
||||
switch (enumeratorGroupChannelFieldSettings.Current.Key)
|
||||
{
|
||||
case GroupTemplateChannelFields.BitResolution: break;
|
||||
case GroupTemplateChannelFields.ChannelAmplitudeClass: break;
|
||||
case GroupTemplateChannelFields.ChannelFrequencyClass: break;
|
||||
case GroupTemplateChannelFields.Comments: break;
|
||||
case GroupTemplateChannelFields.Comments1: break;
|
||||
case GroupTemplateChannelFields.CustomerChannelCode: break;
|
||||
case GroupTemplateChannelFields.CutOffFrequency: break;
|
||||
case GroupTemplateChannelFields.DataSource: break;
|
||||
case GroupTemplateChannelFields.DataStatus: break;
|
||||
case GroupTemplateChannelFields.Dimension: break;
|
||||
case GroupTemplateChannelFields.Direction: break;
|
||||
case GroupTemplateChannelFields.DisplayOrder:
|
||||
channel.DisplayOrder = Convert.ToInt32(enumeratorGroupChannelFieldSettings.Current.Value,
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case GroupTemplateChannelFields.EndOffsetInterval: break;
|
||||
case GroupTemplateChannelFields.FirstGlobalMaximumValue: break;
|
||||
case GroupTemplateChannelFields.FirstGlobalMinimumValue: break;
|
||||
case GroupTemplateChannelFields.LaboratoryChannelCode: break;
|
||||
case GroupTemplateChannelFields.LocalOnly:
|
||||
channel.LocalOnly = Convert.ToBoolean(enumeratorGroupChannelFieldSettings.Current.Value);
|
||||
break;
|
||||
case GroupTemplateChannelFields.Location: break;
|
||||
case GroupTemplateChannelFields.MMEChannelId: break;
|
||||
case GroupTemplateChannelFields.MMEChannelType: break;
|
||||
case GroupTemplateChannelFields.NameOfTheChannel:
|
||||
channel.NameOfTheChannel = enumeratorGroupChannelFieldSettings.Current.Value;
|
||||
break;
|
||||
case GroupTemplateChannelFields.NumberOfSamples: break;
|
||||
case GroupTemplateChannelFields.OffsetPostTest: break;
|
||||
case GroupTemplateChannelFields.PreFilterType: break;
|
||||
case GroupTemplateChannelFields.ReferenceChannel: break;
|
||||
case GroupTemplateChannelFields.ReferenceChannelName: break;
|
||||
case GroupTemplateChannelFields.ReferenceSystem: break;
|
||||
case GroupTemplateChannelFields.Required:
|
||||
channel.Required = Convert.ToBoolean(enumeratorGroupChannelFieldSettings.Current.Value);
|
||||
break;
|
||||
case GroupTemplateChannelFields.SamplingInterval: break;
|
||||
case GroupTemplateChannelFields.StartOffsetInterval: break;
|
||||
case GroupTemplateChannelFields.TestObjectNumber: break;
|
||||
case GroupTemplateChannelFields.TimeOfFirstSample: break;
|
||||
case GroupTemplateChannelFields.TimeOfMaximumValue: break;
|
||||
case GroupTemplateChannelFields.TimeOfMinimumValue: break;
|
||||
case GroupTemplateChannelFields.TransducerDampingRatio: break;
|
||||
case GroupTemplateChannelFields.TransducerId: break;
|
||||
case GroupTemplateChannelFields.TransducerNaturalFrequency: break;
|
||||
case GroupTemplateChannelFields.TransducerType: break;
|
||||
case GroupTemplateChannelFields.Unit: break;
|
||||
default:
|
||||
throw new NotSupportedException(
|
||||
"TestObjectTemplate::ProcessChannelXMLNode unsupported field: " + enumeratorGroupChannelFieldSettings.Current.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
existingChannels.Add(channel);
|
||||
var maxDisplayOrder = (from ch in existingChannels select ch.DisplayOrder).Max();
|
||||
|
||||
foreach (var ch in existingChannels)
|
||||
{
|
||||
if (-1 == ch.DisplayOrder)
|
||||
{
|
||||
ch.DisplayOrder = ++maxDisplayOrder;
|
||||
}
|
||||
}
|
||||
template.Channels = existingChannels.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
using Stateless;
|
||||
using Prism.Ioc;
|
||||
using DTS.Common.Enums.TSRAIRGo;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using System;
|
||||
using Prism.Events;
|
||||
|
||||
namespace DTS.Common.DataModel.StateMachines
|
||||
{
|
||||
public class OverallArmStatusStateMachine
|
||||
{
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers> overallArmStatusStateMachine = null;
|
||||
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> NoDataToDownloadTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> DataNeverDownloadedTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> DASNotFoundTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> FlashClearTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> WaitingForTriggerTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> WaitingForScheduleTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> WaitingForIntervalTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> RecordingTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> DoneRecordingTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> ErrorTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> CheckingForDataTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> GettingEventInfoTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> ReadyForDownloadTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> DownloadTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> DownloadCleaningUpTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> DownloadFinishedTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> IDLETrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> StreamingTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> DisarmTrigger;
|
||||
private StateMachine<ArmStateMachineStates.States, Triggers>.TriggerWithParameters<ArmStateMachineStates.States> RearmingTrigger;
|
||||
|
||||
ArmStateMachineStates.States CurrentOverallStatusState = ArmStateMachineStates.States.CheckingForDAS;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the Event Aggregator and the Overall Arm Status state machine.
|
||||
/// </summary>
|
||||
public OverallArmStatusStateMachine()
|
||||
{
|
||||
_eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public enum Triggers
|
||||
{
|
||||
bFillingBuffer,
|
||||
CheckingForData,
|
||||
ConfigurationIsSet,
|
||||
DASNotFound,
|
||||
DataNeverDownloaded,
|
||||
Disarm,
|
||||
DoneRecording,
|
||||
Downloading,
|
||||
DownloadCleaningUp,
|
||||
DownloadFinished,
|
||||
Error,
|
||||
Faulted,
|
||||
FlashClear,
|
||||
GettingEventInfo,
|
||||
IDLE,
|
||||
IntervalRecording,
|
||||
NoDataToDownload,
|
||||
NonIntervalRecording,
|
||||
PostTestProcessing,
|
||||
ReadyForDownload,
|
||||
Rearming,
|
||||
Recording,
|
||||
RunButton,
|
||||
Streaming,
|
||||
WaitingForTrigger,
|
||||
WaitingForSchedule,
|
||||
WaitingForInterval,
|
||||
a,
|
||||
c,
|
||||
d,
|
||||
e,
|
||||
h,
|
||||
n,
|
||||
rr,
|
||||
tt,
|
||||
uu,
|
||||
yy
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
overallArmStatusStateMachine = new StateMachine<ArmStateMachineStates.States, Triggers>(ArmStateMachineStates.States.CheckingForDAS);
|
||||
|
||||
NoDataToDownloadTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.NoDataToDownload);
|
||||
DataNeverDownloadedTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.DataNeverDownloaded);
|
||||
DASNotFoundTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.DASNotFound);
|
||||
FlashClearTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.FlashClear);
|
||||
RecordingTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.Recording);
|
||||
DoneRecordingTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.DoneRecording);
|
||||
WaitingForTriggerTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.WaitingForTrigger);
|
||||
WaitingForScheduleTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.WaitingForSchedule);
|
||||
WaitingForIntervalTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.WaitingForInterval);
|
||||
CheckingForDataTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.CheckingForData);
|
||||
ErrorTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.Error);
|
||||
GettingEventInfoTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.GettingEventInfo);
|
||||
ReadyForDownloadTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.ReadyForDownload);
|
||||
DownloadTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.Downloading);
|
||||
DownloadCleaningUpTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.DownloadCleaningUp);
|
||||
DownloadFinishedTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.DownloadFinished);
|
||||
IDLETrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.IDLE);
|
||||
StreamingTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.Streaming);
|
||||
DisarmTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.Disarm);
|
||||
RearmingTrigger = overallArmStatusStateMachine.SetTriggerParameters<ArmStateMachineStates.States>(Triggers.Rearming);
|
||||
|
||||
//--------------------CheckingForDAS--------------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.CheckingForDAS)
|
||||
.OnEntryFrom(DASNotFoundTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(FlashClearTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(ReadyForDownloadTrigger, o => SetOverallStatus(o))
|
||||
.PermitReentry(Triggers.DASNotFound)
|
||||
.Permit(Triggers.Recording, ArmStateMachineStates.States.Recording)
|
||||
.Permit(Triggers.ReadyForDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.NoDataToDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.DataNeverDownloaded, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.DoneRecording, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.Streaming, ArmStateMachineStates.States.Streaming)
|
||||
.Permit(Triggers.FlashClear, ArmStateMachineStates.States.ClearingFlash)
|
||||
.Permit(Triggers.WaitingForTrigger, ArmStateMachineStates.States.WaitingForTrigger)
|
||||
.Permit(Triggers.WaitingForSchedule, ArmStateMachineStates.States.WaitingForSchedule)
|
||||
.Permit(Triggers.WaitingForInterval, ArmStateMachineStates.States.WaitingForInterval);
|
||||
|
||||
//--------------------IDLE--------------------------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.IDLE)
|
||||
.OnEntryFrom(ReadyForDownloadTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(NoDataToDownloadTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(DataNeverDownloadedTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(DoneRecordingTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(FlashClearTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(WaitingForTriggerTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(StreamingTrigger, o => SetOverallStatus(o))
|
||||
.Permit(Triggers.DASNotFound, ArmStateMachineStates.States.CheckingForDAS)
|
||||
.Permit(Triggers.FlashClear, ArmStateMachineStates.States.ClearingFlash)
|
||||
.Permit(Triggers.WaitingForTrigger, ArmStateMachineStates.States.WaitingForTrigger)
|
||||
.Permit(Triggers.WaitingForSchedule, ArmStateMachineStates.States.WaitingForSchedule)
|
||||
.Permit(Triggers.WaitingForInterval, ArmStateMachineStates.States.WaitingForInterval)
|
||||
.PermitReentry(Triggers.ReadyForDownload)
|
||||
.PermitReentry(Triggers.NoDataToDownload)
|
||||
.PermitReentry(Triggers.DataNeverDownloaded)
|
||||
.PermitReentry(Triggers.DoneRecording);
|
||||
|
||||
//--------------------Streaming--------------------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.Streaming)
|
||||
.OnEntryFrom(StreamingTrigger, o => SetOverallStatus(o))
|
||||
.Permit(Triggers.DASNotFound, ArmStateMachineStates.States.CheckingForDAS)
|
||||
.Permit(Triggers.DoneRecording, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.NoDataToDownload, ArmStateMachineStates.States.IDLE)
|
||||
.PermitReentry(Triggers.Streaming);
|
||||
|
||||
//--------------------ClearingFlash-----------------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.ClearingFlash)
|
||||
.OnEntryFrom(FlashClearTrigger, o => SetOverallStatus(o))
|
||||
.Ignore(Triggers.ReadyForDownload)
|
||||
.Ignore(Triggers.NoDataToDownload)
|
||||
.Ignore(Triggers.DataNeverDownloaded)
|
||||
.Permit(Triggers.WaitingForTrigger, ArmStateMachineStates.States.WaitingForTrigger)
|
||||
.Permit(Triggers.WaitingForSchedule, ArmStateMachineStates.States.WaitingForSchedule)
|
||||
.Permit(Triggers.WaitingForInterval, ArmStateMachineStates.States.WaitingForInterval)
|
||||
.Permit(Triggers.Disarm, ArmStateMachineStates.States.Disarmed)
|
||||
.Permit(Triggers.Streaming, ArmStateMachineStates.States.Streaming)
|
||||
.Permit(Triggers.DASNotFound, ArmStateMachineStates.States.CheckingForDAS)
|
||||
.PermitReentry(Triggers.FlashClear);
|
||||
|
||||
//--------------------WaitingForTrigger------------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.WaitingForTrigger)
|
||||
.OnEntryFrom(WaitingForTriggerTrigger, o => SetOverallStatus(o))
|
||||
.Ignore(Triggers.DataNeverDownloaded)
|
||||
.Permit(Triggers.DASNotFound, ArmStateMachineStates.States.CheckingForDAS)
|
||||
.Permit(Triggers.Recording, ArmStateMachineStates.States.Recording)
|
||||
.Permit(Triggers.DoneRecording, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.ReadyForDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.NoDataToDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.Disarm, ArmStateMachineStates.States.Disarmed)
|
||||
.Permit(Triggers.Rearming, ArmStateMachineStates.States.Rearming)
|
||||
.PermitReentry(Triggers.WaitingForTrigger)
|
||||
.PermitReentry(Triggers.WaitingForSchedule)
|
||||
.PermitReentry(Triggers.WaitingForInterval);
|
||||
|
||||
//--------------------WaitingForSchedule------------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.WaitingForSchedule)
|
||||
.OnEntryFrom(WaitingForScheduleTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(DisarmTrigger, o => SetOverallStatus(o))
|
||||
.Ignore(Triggers.DataNeverDownloaded)
|
||||
.Permit(Triggers.DASNotFound, ArmStateMachineStates.States.CheckingForDAS)
|
||||
.Permit(Triggers.Recording, ArmStateMachineStates.States.Recording)
|
||||
.Permit(Triggers.DoneRecording, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.WaitingForInterval, ArmStateMachineStates.States.WaitingForInterval)
|
||||
.Permit(Triggers.ReadyForDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.NoDataToDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.Disarm, ArmStateMachineStates.States.Disarmed)
|
||||
.PermitReentry(Triggers.WaitingForSchedule);
|
||||
|
||||
//--------------------WaitingForInterval------------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.WaitingForInterval)
|
||||
.OnEntryFrom(WaitingForIntervalTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(DisarmTrigger, o => SetOverallStatus(o))
|
||||
.Ignore(Triggers.DataNeverDownloaded)
|
||||
.Permit(Triggers.DASNotFound, ArmStateMachineStates.States.CheckingForDAS)
|
||||
.Permit(Triggers.Recording, ArmStateMachineStates.States.Recording)
|
||||
.Permit(Triggers.DoneRecording, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.ReadyForDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.NoDataToDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.Disarm, ArmStateMachineStates.States.Disarmed)
|
||||
.PermitReentry(Triggers.WaitingForInterval);
|
||||
|
||||
//--------------------Recording--------------------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.Recording)
|
||||
.OnEntryFrom(RecordingTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(DoneRecordingTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(WaitingForIntervalTrigger, o => SetOverallStatus(o))
|
||||
.Permit(Triggers.DASNotFound, ArmStateMachineStates.States.CheckingForDAS)
|
||||
.Permit(Triggers.DoneRecording, ArmStateMachineStates.States.PostTestProcessing)
|
||||
.Permit(Triggers.WaitingForTrigger, ArmStateMachineStates.States.WaitingForTrigger)
|
||||
.Permit(Triggers.WaitingForInterval, ArmStateMachineStates.States.WaitingForInterval)
|
||||
.Permit(Triggers.Rearming, ArmStateMachineStates.States.Rearming)
|
||||
.Permit(Triggers.ReadyForDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.NoDataToDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.DataNeverDownloaded, ArmStateMachineStates.States.ReadyForDownload)
|
||||
.Permit(Triggers.Disarm, ArmStateMachineStates.States.Disarmed)
|
||||
.PermitReentry(Triggers.Recording);
|
||||
|
||||
//--------------------Rearming-----------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.Rearming)
|
||||
.OnEntryFrom(RecordingTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(WaitingForTriggerTrigger, o => SetOverallStatus(o))
|
||||
.Permit(Triggers.WaitingForTrigger, ArmStateMachineStates.States.WaitingForTrigger)
|
||||
.Permit(Triggers.WaitingForInterval, ArmStateMachineStates.States.WaitingForInterval)
|
||||
.Permit(Triggers.Recording, ArmStateMachineStates.States.Recording)
|
||||
.PermitReentry(Triggers.Rearming);
|
||||
|
||||
//--------------------Disarmed-----------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.Disarmed)
|
||||
.OnEntryFrom(DisarmTrigger, o => SetOverallStatus(o))
|
||||
.Permit(Triggers.DASNotFound, ArmStateMachineStates.States.CheckingForDAS)
|
||||
.Permit(Triggers.NoDataToDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.ReadyForDownload, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.DataNeverDownloaded, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.FlashClear, ArmStateMachineStates.States.ClearingFlash);
|
||||
|
||||
//--------------------PostTestProcessing-----------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.PostTestProcessing)
|
||||
.OnEntryFrom(DoneRecordingTrigger, o => SetOverallStatus(o))
|
||||
.Permit(Triggers.GettingEventInfo, ArmStateMachineStates.States.GettingEventInfo)
|
||||
.PermitReentry(Triggers.PostTestProcessing);
|
||||
|
||||
//--------------------CheckingForData-----------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.CheckingForData)
|
||||
.OnEntryFrom(DoneRecordingTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(CheckingForDataTrigger, o => SetOverallStatus(o))
|
||||
.Permit(Triggers.GettingEventInfo, ArmStateMachineStates.States.GettingEventInfo)
|
||||
.PermitReentry(Triggers.DoneRecording)
|
||||
.PermitReentry(Triggers.CheckingForData);
|
||||
|
||||
//--------------------GettingEventInfo-----------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.GettingEventInfo)
|
||||
.OnEntryFrom(GettingEventInfoTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(DataNeverDownloadedTrigger, o => SetOverallStatus(o))
|
||||
.Permit(Triggers.DataNeverDownloaded, ArmStateMachineStates.States.ReadyForDownload);
|
||||
|
||||
//--------------------ReadyForDownload-----------------
|
||||
overallArmStatusStateMachine.Configure(ArmStateMachineStates.States.ReadyForDownload)
|
||||
.OnEntryFrom(DataNeverDownloadedTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(ReadyForDownloadTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(FlashClearTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(WaitingForTriggerTrigger, o => SetOverallStatus(o)) //In case Flash Clear finishes very quickly
|
||||
.OnEntryFrom(WaitingForScheduleTrigger, o => SetOverallStatus(o))
|
||||
.OnEntryFrom(WaitingForIntervalTrigger, o => SetOverallStatus(o))
|
||||
.Permit(Triggers.DASNotFound, ArmStateMachineStates.States.IDLE)
|
||||
.Permit(Triggers.Downloading, ArmStateMachineStates.States.Downloading)
|
||||
.Permit(Triggers.FlashClear, ArmStateMachineStates.States.ClearingFlash)
|
||||
.Permit(Triggers.WaitingForTrigger, ArmStateMachineStates.States.WaitingForTrigger)
|
||||
.Permit(Triggers.WaitingForSchedule, ArmStateMachineStates.States.WaitingForSchedule)
|
||||
.Permit(Triggers.WaitingForInterval, ArmStateMachineStates.States.WaitingForInterval)
|
||||
.Ignore(Triggers.DataNeverDownloaded)
|
||||
.PermitReentry(Triggers.ReadyForDownload);
|
||||
|
||||
string graph = Stateless.Graph.UmlDotGraph.Format(overallArmStatusStateMachine.GetInfo());
|
||||
graph = graph.Replace("DTS.DASLib.Service.StateMachine.", "");
|
||||
|
||||
}
|
||||
public delegate void OverallStatusStateChangeDelegate(ArmStateMachineStates.States previousState, ArmStateMachineStates.States nextState);
|
||||
|
||||
/// <summary>
|
||||
/// Handler for consumers to be notified when overall state transitions
|
||||
/// </summary>
|
||||
public event OverallStatusStateChangeDelegate OverallStatusStateChange;
|
||||
/// <summary>
|
||||
/// Display a message in the Global Status field.
|
||||
/// </summary>
|
||||
/// <param name="newState"></param>
|
||||
private void SetOverallStatus(ArmStateMachineStates.States newState)
|
||||
{
|
||||
if (newState != CurrentOverallStatusState)
|
||||
{
|
||||
APILogger.Log($"Transitioning from {CurrentOverallStatusState} to {newState}");
|
||||
OverallStatusStateChange?.Invoke(CurrentOverallStatusState, newState);
|
||||
CurrentOverallStatusState = newState;
|
||||
}
|
||||
}
|
||||
|
||||
public ArmStateMachineStates.States GetDASStatus()
|
||||
{
|
||||
return CurrentOverallStatusState;
|
||||
}
|
||||
|
||||
public void FireTrigger(Triggers trigger, ArmStateMachineStates.States state)
|
||||
{
|
||||
try
|
||||
{
|
||||
//why specify state here? shouldn't that be done based on current state/trigger?
|
||||
switch (trigger)
|
||||
{
|
||||
case Triggers.DASNotFound:
|
||||
overallArmStatusStateMachine.Fire(DASNotFoundTrigger, state);
|
||||
break;
|
||||
case Triggers.NoDataToDownload:
|
||||
overallArmStatusStateMachine.Fire(NoDataToDownloadTrigger, state);
|
||||
break;
|
||||
case Triggers.DataNeverDownloaded:
|
||||
overallArmStatusStateMachine.Fire(DataNeverDownloadedTrigger, state);
|
||||
break;
|
||||
case Triggers.DoneRecording:
|
||||
overallArmStatusStateMachine.Fire(DoneRecordingTrigger, state);
|
||||
break;
|
||||
case Triggers.FlashClear:
|
||||
overallArmStatusStateMachine.Fire(FlashClearTrigger, state);
|
||||
break;
|
||||
case Triggers.WaitingForTrigger:
|
||||
overallArmStatusStateMachine.Fire(WaitingForTriggerTrigger, state);
|
||||
break;
|
||||
case Triggers.WaitingForSchedule:
|
||||
overallArmStatusStateMachine.Fire(WaitingForScheduleTrigger, state);
|
||||
break;
|
||||
case Triggers.WaitingForInterval:
|
||||
overallArmStatusStateMachine.Fire(WaitingForIntervalTrigger, state);
|
||||
break;
|
||||
case Triggers.Recording:
|
||||
overallArmStatusStateMachine.Fire(RecordingTrigger, state);
|
||||
break;
|
||||
case Triggers.PostTestProcessing:
|
||||
overallArmStatusStateMachine.Fire(DoneRecordingTrigger, state);
|
||||
break;
|
||||
case Triggers.CheckingForData:
|
||||
overallArmStatusStateMachine.Fire(CheckingForDataTrigger, state);
|
||||
break;
|
||||
case Triggers.GettingEventInfo:
|
||||
overallArmStatusStateMachine.Fire(GettingEventInfoTrigger, state);
|
||||
break;
|
||||
case Triggers.ReadyForDownload:
|
||||
overallArmStatusStateMachine.Fire(ReadyForDownloadTrigger, state);
|
||||
break;
|
||||
case Triggers.Error:
|
||||
overallArmStatusStateMachine.Fire(ErrorTrigger, state);
|
||||
break;
|
||||
case Triggers.Streaming:
|
||||
overallArmStatusStateMachine.Fire(StreamingTrigger, state);
|
||||
break;
|
||||
case Triggers.Disarm:
|
||||
overallArmStatusStateMachine.Fire(DisarmTrigger, state);
|
||||
break;
|
||||
case Triggers.Rearming:
|
||||
overallArmStatusStateMachine.Fire(RearmingTrigger, state);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,476 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.ISO;
|
||||
using DTS.Common.DataModel;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <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>
|
||||
{
|
||||
private const string defaultDefaultFilterClass = "P";
|
||||
|
||||
#region Properties
|
||||
public MMEPossibleChannels Channel { get; private set; }
|
||||
|
||||
public string TypeString
|
||||
{
|
||||
get => Channel.Type;
|
||||
set { Channel.SetType(value); OnPropertyChanged("TypeString"); }
|
||||
}
|
||||
|
||||
private MMETestObjects _testObject;
|
||||
public MMETestObjects TestObject
|
||||
{
|
||||
get => _testObject;
|
||||
set { SetProperty(ref _testObject, value, "TestObject"); if (null != Channel && null != value) { Channel.Set_Test_Object(value.Test_Object); } }
|
||||
}
|
||||
|
||||
private MMEPositions _position;
|
||||
public MMEPositions Position
|
||||
{
|
||||
get => _position;
|
||||
set { SetProperty(ref _position, value, "Position"); if (null != Channel && null != value) { Channel.Set_Position(value.Position); } }
|
||||
}
|
||||
|
||||
private MMETransducerMainLocation _mainLocation;
|
||||
public MMETransducerMainLocation MainLocation
|
||||
{
|
||||
get => _mainLocation;
|
||||
set { SetProperty(ref _mainLocation, value, "MainLocation"); if (null != Channel && null != value) { Channel.Set_Main_Loc(value.Trans_Main_Loc); } }
|
||||
}
|
||||
|
||||
private MMEFineLocations1 _finLoc1;
|
||||
|
||||
public MMEFineLocations1 FinLoc1
|
||||
{
|
||||
get => _finLoc1;
|
||||
set { SetProperty(ref _finLoc1, value, "FinLoc1"); if (null != Channel && null != value) { Channel.Set_Fine_Loc_1(value.Fine_Loc_1); } }
|
||||
}
|
||||
|
||||
private MMEFineLocations2 _finLoc2;
|
||||
public MMEFineLocations2 FinLoc2
|
||||
{
|
||||
get => _finLoc2;
|
||||
set { SetProperty(ref _finLoc2, value, "FinLoc2"); if (null != Channel && null != value) { Channel.Set_Fine_Loc_2(value.FINE_LOC_2); } }
|
||||
}
|
||||
|
||||
private MMEFineLocations3 _finLoc3;
|
||||
public MMEFineLocations3 FinLoc3
|
||||
{
|
||||
get => _finLoc3;
|
||||
set { SetProperty(ref _finLoc3, value, "FinLoc3"); if (null != Channel && null != value) { Channel.Set_Fine_Loc_3(value.FINE_LOC_3); } }
|
||||
}
|
||||
|
||||
private MMEPhysicalDimensions _physicalDimension;
|
||||
public MMEPhysicalDimensions PhysicalDimension
|
||||
{
|
||||
get => _physicalDimension;
|
||||
set { SetProperty(ref _physicalDimension, value, "PhysicalDimension"); if (null != Channel && null != value) { Channel.Set_Physical_Dimension(value.Physical_Dimension); } }
|
||||
}
|
||||
|
||||
private MMEDirections _direction;
|
||||
public MMEDirections Direction
|
||||
{
|
||||
get => _direction;
|
||||
set { SetProperty(ref _direction, value, "Direction"); if (null != Channel && null != value) { Channel.Set_Direction(value.Direction); } }
|
||||
}
|
||||
|
||||
private MMEFilterClasses _filterClass;
|
||||
public MMEFilterClasses FilterClass
|
||||
{
|
||||
get => _filterClass;
|
||||
set { SetProperty(ref _filterClass, value, "FilterClass"); if (null != Channel && null != value) { Channel.Set_Default_Filter_Class(value.Filter_Class); } }
|
||||
}
|
||||
#endregion Properties
|
||||
|
||||
public string Text1
|
||||
{
|
||||
get => Channel.Text_L1;
|
||||
set
|
||||
{
|
||||
var name = value;
|
||||
System.Diagnostics.Trace.Assert(name?.Length < 250, "Channel text is too long");
|
||||
Channel.SetText1(name);
|
||||
OnPropertyChanged("Text1");
|
||||
}
|
||||
}
|
||||
|
||||
public string Remarks
|
||||
{
|
||||
get => Channel.Remarks;
|
||||
set
|
||||
{
|
||||
Channel.SetRemarks(value);
|
||||
OnPropertyChanged("Remarks");
|
||||
}
|
||||
}
|
||||
|
||||
public CustomChannel()
|
||||
{
|
||||
Channel = new MMEPossibleChannels(-1, "", "", "", "", "", "", "", "", "", "", "", "", 0, DateTime.Now, "", false, "", "", DateTime.MinValue, "", "", (int)MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
_filterClass = ApplicationProperties.IsoDb.GetFilterClassByIso("A");
|
||||
}
|
||||
|
||||
private readonly List<ISO13499FileDb.ExpiredISOFieldException> _expiredErrors = new List<ISO13499FileDb.ExpiredISOFieldException>();
|
||||
/// <summary>
|
||||
/// these are any errors detected during loading of the custom channel
|
||||
/// as custom channels are reliant on the ISO13499 mdb, it is possible for it to have been updated and for things to have been removed or expired
|
||||
/// </summary>
|
||||
public ISO13499FileDb.ExpiredISOFieldException[] ExpiredErrors => _expiredErrors.ToArray();
|
||||
|
||||
|
||||
public CustomChannel(MMEPossibleChannels channel, bool newChannel = true)
|
||||
{
|
||||
Channel = newChannel ? new MMEPossibleChannels(channel) : channel;
|
||||
|
||||
_direction = ApplicationProperties.IsoDb.GetDirectionByIso(channel.Direction);
|
||||
_filterClass = ApplicationProperties.IsoDb.GetFilterClassByIso(channel.Default_Filter_Class) ??
|
||||
ApplicationProperties.IsoDb.GetFilterClassByIso(defaultDefaultFilterClass);
|
||||
_finLoc1 = ApplicationProperties.IsoDb.GetFineLocation1ByIso(channel.Fine_Loc_1);
|
||||
_finLoc2 = ApplicationProperties.IsoDb.GetFineLocation2ByIso(channel.Fine_Loc_2);
|
||||
_finLoc3 = ApplicationProperties.IsoDb.GetFineLocation3ByIso(channel.Fine_Loc_3);
|
||||
|
||||
try { _mainLocation = ApplicationProperties.IsoDb.GetMainLocationByIso(channel.Trans_Main_Loc); }
|
||||
catch (ISO13499FileDb.ExpiredISOFieldException ex) { _expiredErrors.Add(ex); }
|
||||
|
||||
_physicalDimension = ApplicationProperties.IsoDb.GetPhysicalDimensionByIso(channel.Physical_Dimension);
|
||||
_position = ApplicationProperties.IsoDb.GetPositionByISO(channel.Position);
|
||||
_testObject = ApplicationProperties.IsoDb.GetTestObjectByIso(channel.Test_Object);
|
||||
}
|
||||
public void Commit(bool bNotify)
|
||||
{
|
||||
if (null == Channel)
|
||||
{
|
||||
Channel = new MMEPossibleChannels(-1, TypeString, TestObject.Test_Object, Position.Position, MainLocation?.Trans_Main_Loc, FinLoc1.Fine_Loc_1,
|
||||
FinLoc2.FINE_LOC_2, FinLoc3.FINE_LOC_3, PhysicalDimension.Physical_Dimension, Direction?.Direction, FilterClass?.Filter_Class,
|
||||
Text1, Text1, 1, DateTime.Now, Remarks, false, "", "", DateTime.Now, string.Format("created in DataPRO by {0}", ApplicationProperties.CurrentUser.UserName),
|
||||
"", (int)MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
else
|
||||
{
|
||||
Channel = new MMEPossibleChannels(Channel.Id, TypeString, TestObject.Test_Object, Position.Position, MainLocation?.Trans_Main_Loc, FinLoc1.Fine_Loc_1,
|
||||
FinLoc2.FINE_LOC_2, FinLoc3.FINE_LOC_3, PhysicalDimension.Physical_Dimension, Direction?.Direction, FilterClass?.Filter_Class,
|
||||
Text1, Text1, 1, DateTime.Now, Remarks, false, "", "", DateTime.Now, string.Format("updated in DataPRO by {0}", ApplicationProperties.CurrentUser.UserName),
|
||||
"", (int)MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
|
||||
ApplicationProperties.IsoDb.Commit(Channel, bNotify);
|
||||
|
||||
}
|
||||
public MMEPossibleChannels GetISOChannelForCommit()
|
||||
{
|
||||
if (null == Channel)
|
||||
{
|
||||
Channel = new MMEPossibleChannels(-1, TypeString, TestObject.Test_Object, Position.Position, MainLocation.Trans_Main_Loc, FinLoc1.Fine_Loc_1,
|
||||
FinLoc2.FINE_LOC_2, FinLoc3.FINE_LOC_3, PhysicalDimension.Physical_Dimension, Direction.Direction, FilterClass.Filter_Class,
|
||||
Text1, Text1, 1, DateTime.Now, Remarks, false, "", "", DateTime.Now, string.Format("created in DataPRO by {0}", ApplicationProperties.CurrentUser.UserName),
|
||||
"", (int)MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
else
|
||||
{
|
||||
Channel = new MMEPossibleChannels(Channel.Id, TypeString, TestObject.Test_Object, Position.Position, MainLocation.Trans_Main_Loc, FinLoc1.Fine_Loc_1,
|
||||
FinLoc2.FINE_LOC_2, FinLoc3.FINE_LOC_3, PhysicalDimension.Physical_Dimension, Direction.Direction, FilterClass.Filter_Class,
|
||||
Text1, Text1, 1, DateTime.Now, Remarks, false, "", "", DateTime.Now, string.Format("updated in DataPRO by {0}", ApplicationProperties.CurrentUser.UserName),
|
||||
"", (int)MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
return Channel;
|
||||
}
|
||||
public int CompareTo(CustomChannel other)
|
||||
{
|
||||
return Equals(this, other) ? 0 : string.Compare(Text1, other.Text1, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public string ISOCode => TestObject.Test_Object + Position.Position + MainLocation.Trans_Main_Loc + FinLoc1.Fine_Loc_1 + FinLoc2.FINE_LOC_2 +
|
||||
FinLoc3.FINE_LOC_3 + PhysicalDimension.Physical_Dimension + Direction.Direction + FilterClass.Filter_Class;
|
||||
|
||||
}
|
||||
public class CustomChannelList : BasePropertyChanged
|
||||
{
|
||||
public enum Tags
|
||||
{
|
||||
AllChannels
|
||||
}
|
||||
|
||||
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; }
|
||||
ApplicationProperties.IsoDb?.RefreshAllData();
|
||||
List.PopulateChannelsIfNecessary(false);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// returns true if found, for a given isocode and/or channel id
|
||||
/// returns false otherwise
|
||||
/// </summary>
|
||||
/// <param name="isocode"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsChannelExists(string isocode)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
PopulateChannelsIfNecessary(false);
|
||||
return ApplicationProperties.IsoDb.ContainsPossibleChannelWithISOCode(isocode);
|
||||
}
|
||||
}
|
||||
public bool IsChannelExists(string isocode, long id)
|
||||
{
|
||||
if (id == -1) { return IsChannelExists(isocode); }
|
||||
lock (LockObject)
|
||||
{
|
||||
PopulateChannelsIfNecessary(false);
|
||||
if (_dictChannels.ContainsKey(isocode)) { return _dictChannels[isocode].Channel.Id != id; }
|
||||
//still need to check isocode isn't in regular iso channels.
|
||||
return ApplicationProperties.IsoDb.ContainsPossibleChannelWithISOCode(isocode);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a custom channel if found, for a given isocode
|
||||
/// returns null otherwise
|
||||
/// </summary>
|
||||
/// <param name="isocode"></param>
|
||||
/// <returns></returns>
|
||||
public CustomChannel GetChannelByISOCode(string isocode, bool careAboutTestTimeFields)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
PopulateChannelsIfNecessary(careAboutTestTimeFields);
|
||||
return _dictChannels.ContainsKey(isocode) ? _dictChannels[isocode] : null;
|
||||
}
|
||||
}
|
||||
public CustomChannel GetChannelByFullISOCode(string isocode)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
PopulateChannelsIfNecessary(false);
|
||||
if (_dictChannels.ContainsKey(isocode))
|
||||
{
|
||||
return _dictChannels[isocode];
|
||||
}
|
||||
var isocodeWithQuestionMarks = isocode.Substring(0, 15) + "?";
|
||||
return DictChannelsContainsChannel(isocode, isocodeWithQuestionMarks) ? _dictChannels[isocodeWithQuestionMarks] : null;
|
||||
}
|
||||
}
|
||||
private bool DictChannelsContainsChannel(string isocode, string isocodeWithQuestionMarks)
|
||||
{
|
||||
if (!_dictChannels.ContainsKey(isocodeWithQuestionMarks)) return false;
|
||||
var temp = _dictChannels[isocodeWithQuestionMarks];
|
||||
return temp.FilterClass.Filter_Class == isocode.Substring(15, 1);
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a channel given a name, this should _ONLY_ be used in
|
||||
/// NON-ISO mode, as in other modes the name may not unique
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public CustomChannel GetChannelByName(string name)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
var ch = from c in AllChannels.AsParallel() where c.Channel.Text_L1 == name select c;
|
||||
return ch.Any() ? ch.First() : null;
|
||||
}
|
||||
}
|
||||
public CustomChannel GetChannel(long id)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
PopulateChannelsIfNecessary(false);
|
||||
var ch = from c in AllChannels where c.Channel.Id == id select c;
|
||||
|
||||
var customChannels = ch as CustomChannel[] ?? ch.ToArray();
|
||||
return customChannels.Any() ? customChannels[0] : null;
|
||||
}
|
||||
}
|
||||
private CustomChannelList()
|
||||
{
|
||||
}
|
||||
|
||||
private Dictionary<string, CustomChannel> _dictChannels;
|
||||
private List<CustomChannel> _listChannels;
|
||||
public CustomChannel[] AllChannels
|
||||
{
|
||||
get
|
||||
{
|
||||
PopulateChannelsIfNecessary(false);
|
||||
return _listChannels.ToArray();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// loads all calculated channels, if necessary
|
||||
/// </summary>
|
||||
private void PopulateChannelsIfNecessary(bool careAboutTestTimeFields)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
if (null != _listChannels) return;
|
||||
_listChannels = new List<CustomChannel>();
|
||||
_dictChannels = new Dictionary<string, CustomChannel>();
|
||||
foreach (var channel in ApplicationProperties.IsoDb.GetSQLPossibleChannels())
|
||||
{
|
||||
var ch = new CustomChannel(channel);
|
||||
var iso = IsoCodeStatics.GetString(ch.Channel, careAboutTestTimeFields);
|
||||
if (_dictChannels.ContainsKey(iso)) continue;
|
||||
_listChannels.Add(ch);
|
||||
_dictChannels[iso] = ch;
|
||||
}
|
||||
_listChannels.Sort();
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(CustomChannel[] channels)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
var idx = 0;
|
||||
IDbCommand iCmd = null;
|
||||
try
|
||||
{
|
||||
foreach (var channel in channels)
|
||||
{
|
||||
for (var i = _listChannels.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (_listChannels[i].Channel.Id == channel.Channel.Id)
|
||||
{
|
||||
_listChannels.RemoveAt(i);
|
||||
if (null == iCmd)
|
||||
{
|
||||
iCmd = DbOperations.GetSQLCommand(true);
|
||||
iCmd.CommandText = DbOperations.BEGIN_STATEMENT;
|
||||
}
|
||||
|
||||
iCmd.CommandText += $"DELETE FROM [{DbOperations.MMETables.MMEPossibleChannelsTable}] WHERE [{DbOperations.MMETables.MMEPossibleChannelsFields.ID}]=@{idx}_1;";
|
||||
DbOperations.CreateParam(iCmd,
|
||||
$"@{idx}_1",
|
||||
SqlDbType.NVarChar,
|
||||
channel.Channel.Id);
|
||||
idx++;
|
||||
if (0 == idx % 2000)
|
||||
{
|
||||
iCmd.CommandText += DbOperations.COMMIT_STATEMENT;
|
||||
DbOperations.Connection.ExecuteCommand(iCmd);
|
||||
iCmd.Connection.Dispose();
|
||||
iCmd.Dispose();
|
||||
iCmd = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_dictChannels.ContainsKey(channel.Text1))
|
||||
{
|
||||
_dictChannels.Remove(channel.ISOCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (null != iCmd)
|
||||
{
|
||||
iCmd.CommandText += DbOperations.COMMIT_STATEMENT;
|
||||
DbOperations.Connection.ExecuteCommand(iCmd);
|
||||
iCmd.Connection.Dispose();
|
||||
iCmd.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAll()
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
_listChannels = null;
|
||||
_dictChannels = null;
|
||||
ApplicationProperties.IsoDb.RefreshAllData();
|
||||
}
|
||||
OnPropertyChanged("AllChannels");
|
||||
}
|
||||
/// <summary>
|
||||
/// this is a custom bulk insert of channels
|
||||
/// it doesn't do the validation (make sure channels don't already exist)
|
||||
/// and the clean the ordinary commit does (get the new id #)
|
||||
/// so ... it's good for bulk, but make sure to call updateall so the ids are updated
|
||||
/// </summary>
|
||||
/// <param name="channels"></param>
|
||||
public void Commit(CustomChannel[] channels)
|
||||
{
|
||||
MMEPossibleChannels.Commit(channels.Select(ch => ch.GetISOChannelForCommit()).ToArray());
|
||||
}
|
||||
public void Commit(CustomChannel channel) { Commit(channel, true, true); }
|
||||
public void Commit(CustomChannel channel, bool bDoLookForExistingNameCheck, bool bNotify)
|
||||
{
|
||||
PopulateChannelsIfNecessary(false);
|
||||
var bFound = false;
|
||||
//don't consider the test fields when getting isocode (filter, position, test object)
|
||||
var key = IsoCodeStatics.GetString(channel.Channel, false);
|
||||
if (bDoLookForExistingNameCheck)
|
||||
{
|
||||
if (_dictChannels.ContainsKey(key))
|
||||
{
|
||||
bFound = true;
|
||||
channel.Channel.SetId(_dictChannels[key].Channel.Id);
|
||||
}
|
||||
}
|
||||
if (bFound && !bNotify)
|
||||
{
|
||||
//bypass the ordinary commit as it will attempt to do an insert
|
||||
//and we just want to do an update.
|
||||
//I'm abusing the bNotify flag above to limit the scope of my changes as I know it's
|
||||
//false in batch updates where we aren't updating the list with every commit which is where the problem exists.
|
||||
//see http://fogbugz/fogbugz/default.asp?6713 2016-03-14
|
||||
channel.Channel.Commit();
|
||||
}
|
||||
else { channel.Commit(bNotify); }
|
||||
|
||||
if (bNotify)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
_listChannels = null;
|
||||
_dictChannels = null;
|
||||
}
|
||||
OnPropertyChanged("AllChannels");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bFound)
|
||||
{
|
||||
lock (LockObject)
|
||||
{
|
||||
_listChannels.Add(channel);
|
||||
_dictChannels[key] = channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
using DataPROWin7.DataModel;
|
||||
using DTS.Common.Events;
|
||||
using Prism.Ioc;
|
||||
using Prism.Events;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Threading;
|
||||
using System.Windows;
|
||||
using System.Threading;
|
||||
|
||||
namespace DTS.Common.DataModel.Common
|
||||
{
|
||||
public class TestSetupCollection
|
||||
{
|
||||
|
||||
public static List<string> TestSetupIds
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
return _testSetupList;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static object TestSetupListLock { get; private set; } = new object();
|
||||
private static DateTime _lastUpdateTime = DateTime.MinValue;
|
||||
private static List<TestTemplate> _actualTestTemplates = new List<TestTemplate>();
|
||||
|
||||
private const int MIN_TESTS_UPDATEINTERVAL_MINUTES = 30;
|
||||
private static uint _crc = 0xFFFF;
|
||||
private static List<string> _testSetupList = null;
|
||||
|
||||
public static TestTemplate[] TestSetups
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
return _actualTestTemplates.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// will update the test setup list if it's more than MIN_TESTS_UPDATEINTERVAL_MINUTES OLD,
|
||||
/// OR the CRC has changed for the
|
||||
/// otherwise uses it's existing copy
|
||||
/// </summary>
|
||||
public static void UpdateTestSetupListIfStale()
|
||||
{
|
||||
if (DateTime.Now.Subtract(_lastUpdateTime).TotalMinutes > MIN_TESTS_UPDATEINTERVAL_MINUTES)
|
||||
{
|
||||
UpdateTestSetupList();
|
||||
}
|
||||
else if (GetCRC() != _crc)
|
||||
{
|
||||
UpdateTestSetupList();
|
||||
}
|
||||
}
|
||||
public static void UpdateTestSetupList(TestTemplate test)
|
||||
{
|
||||
|
||||
//fixes an error when cmdline import and servicelocator is null
|
||||
IEventAggregator eventAggregator = null;
|
||||
try
|
||||
{
|
||||
eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (test.IsDirty)
|
||||
{
|
||||
if (!test.IsComplete)
|
||||
{
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
if (TestSetupList.Contains(test.Name))
|
||||
{
|
||||
_testSetupList.Remove(test.Name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!test.IsComplete) { return; }
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
if (!TestSetupList.Contains(test.Name))
|
||||
{
|
||||
_testSetupList.Add(test.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateTestSetupList(Action onCompleteAction = null)
|
||||
{
|
||||
var allTemplates = TestTemplateList.TestTemplatesList.AllTemplates;
|
||||
var testSetupList = new List<string>();
|
||||
var count = allTemplates.Length;
|
||||
var currentItem = 0;
|
||||
|
||||
//fixes an error when cmdline import and servicelocator is null
|
||||
IEventAggregator eventAggregator = null;
|
||||
try
|
||||
{
|
||||
if (Application.Current.Dispatcher.CheckAccess())
|
||||
{
|
||||
eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
eventAggregator?.GetEvent<ProgressBarEvent>().Publish(new ProgressBarEventArg()
|
||||
{ ProgressBarPercentage = 0D, SetPercentage = true });
|
||||
bool bCache = false;
|
||||
foreach (var t in allTemplates)
|
||||
{
|
||||
eventAggregator?.GetEvent<ProgressBarEvent>().Publish(new ProgressBarEventArg()
|
||||
{ SetPercentage = true, ProgressBarPercentage = 100D * currentItem / count });
|
||||
currentItem++;
|
||||
|
||||
//calculating iscomplete is expensive on a large test setup list with lots of sensors
|
||||
//for now just calculate on demand and put all tests in the list
|
||||
testSetupList.Add(t.Name);
|
||||
}
|
||||
eventAggregator?.GetEvent<ProgressBarEvent>().Publish(new ProgressBarEventArg()
|
||||
{ SetPercentage = true, ProgressBarPercentage = 100D });
|
||||
|
||||
var crc = GetCRC();
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
_lastUpdateTime = DateTime.Now;
|
||||
_testSetupList = testSetupList;
|
||||
_actualTestTemplates = new List<TestTemplate>(1000);
|
||||
_actualTestTemplates.AddRange(allTemplates);
|
||||
_crc = crc;
|
||||
}
|
||||
onCompleteAction?.Invoke();
|
||||
}
|
||||
public static string[] TestSetupList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
if (null != _testSetupList && _testSetupList.Any())
|
||||
{
|
||||
return _testSetupList.ToArray();
|
||||
}
|
||||
}
|
||||
var allTemplates = TestTemplateList.TestTemplatesList.AllTemplates;
|
||||
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
_lastUpdateTime = DateTime.Now;
|
||||
_testSetupList = new List<string>();
|
||||
_actualTestTemplates = new List<TestTemplate>();
|
||||
_actualTestTemplates.AddRange(allTemplates);
|
||||
var total = allTemplates.Length;
|
||||
int currentDone = 0;
|
||||
|
||||
var eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
||||
|
||||
foreach (var t in allTemplates)
|
||||
{
|
||||
eventAggregator.GetEvent<ProgressBarEvent>().Publish(new ProgressBarEventArg()
|
||||
{ SetPercentage = true, ProgressBarPercentage = 100D * currentDone / total });
|
||||
currentDone++;
|
||||
if (!t.IsComplete) { continue; }
|
||||
_testSetupList.Add(t.Name);
|
||||
}
|
||||
eventAggregator.GetEvent<ProgressBarEvent>().Publish(new ProgressBarEventArg()
|
||||
{ SetPercentage = true, ProgressBarPercentage = 100D });
|
||||
_crc = GetCRC();
|
||||
return _testSetupList.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static uint GetCRC()
|
||||
{
|
||||
var list = new List<byte>();
|
||||
|
||||
using (var cmd = Storage.DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = System.Data.CommandType.Text;
|
||||
cmd.CommandText = "SELECT [TestSetupName], [Dirty], [Complete], [LastModified] FROM [TestSetups]";
|
||||
var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
var name = (string)reader["TestSetupName"];
|
||||
list.AddRange(System.Text.Encoding.ASCII.GetBytes(name));
|
||||
var isDirty = (bool)reader["Dirty"];
|
||||
list.AddRange(BitConverter.GetBytes(isDirty));
|
||||
var complete = (bool)reader["Complete"];
|
||||
list.AddRange(BitConverter.GetBytes(complete));
|
||||
var lastModified = (DateTime)reader["LastModified"];
|
||||
list.AddRange(BitConverter.GetBytes(lastModified.ToBinary()));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
var crc = new DTS.Utilities.Crc32();
|
||||
return crc.Get(list);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,540 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using DTS.Common.Interface.BuildTestSetup;
|
||||
using DTS.Common.XMLUtils;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
[Serializable]
|
||||
public class BuildTestSetup : IBuildTestSetup
|
||||
{
|
||||
|
||||
public BuildTestSetup(string dasSerialNumber, string testSetupName, ExportFileXMLClass exportFileXML)
|
||||
{
|
||||
var testSetupXML = exportFileXML.TestSetupsOuter[0].TestSetups[0];
|
||||
var testSetupXMLFields = testSetupXML.Fields;
|
||||
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
SetupName = testSetupXMLFields.SetupName;
|
||||
|
||||
SetupDescription = testSetupXMLFields.SetupDescription;
|
||||
AutomaticMode = testSetupXMLFields.AutomaticTestProgression;
|
||||
AutomaticModeDelay = testSetupXMLFields.AutomaticProgressionDelayMS;
|
||||
//testSetupXMLFields.InvertTrigger;
|
||||
//testSetupXMLFields.InvertStart;
|
||||
//ViewDiagnostics = testSetupXMLFields.ViewDiagnostics;
|
||||
//VerifyChannels = testSetupXMLFields.VerifyChannels;
|
||||
//AutoVerifyChannels
|
||||
//VerifyChannelsDelayMS
|
||||
RecordingMode = testSetupXMLFields.RecordingMode;
|
||||
SamplesPerSecond = testSetupXMLFields.SamplesPerSecond;
|
||||
PreTriggerSeconds = testSetupXMLFields.PreTriggerSeconds;
|
||||
PostTriggerSeconds = testSetupXMLFields.PostTriggerSeconds;
|
||||
NumberOfEvents = testSetupXMLFields.NumberOfEvents;
|
||||
WakeUpMotionTimeout = testSetupXMLFields.WakeUpMotionTimeout;
|
||||
ScheduledStartDateTime = testSetupXMLFields.ScheduledStartDateTime;
|
||||
IntervalBetweenEventStartsMinutes = testSetupXMLFields.IntervalBetweenEventStartsMinutes;
|
||||
StartWithEvent = testSetupXMLFields.StartWithEvent;
|
||||
WakeUpWithMotion = testSetupXMLFields.WakeUpWithMotion;
|
||||
StrictDiagnostics = testSetupXMLFields.StrictDiagnostics;
|
||||
RequireConfirmationOnErrors = testSetupXMLFields.RequireConfirmationOnErrors;
|
||||
ROIDownload = testSetupXMLFields.ROIDownload;
|
||||
ViewROIDownload = testSetupXMLFields.ViewROIDownload;
|
||||
DownloadAll = testSetupXMLFields.DownloadAll;
|
||||
ViewRealtime = testSetupXMLFields.ViewRealtime;
|
||||
RealtimeCharts = testSetupXMLFields.RealtimePlotCount;
|
||||
ROIStart = testSetupXMLFields.ROIStart;
|
||||
ROIEnd = testSetupXMLFields.ROIEnd;
|
||||
ViewDownloadAll = testSetupXMLFields.ViewDownloadAll;
|
||||
Export = testSetupXMLFields.Export;
|
||||
//ExportFormat = testSetupXMLFields.ExportFormat;
|
||||
DecodeExportFormats(testSetupXMLFields.ExportFormat);
|
||||
//LabDetails = testSetupXMLFields.LabDetails;
|
||||
UseLabDetails = testSetupXMLFields.UseLabDetails;
|
||||
//CustomerDetails
|
||||
UseCustomerDetails = testSetupXMLFields.UseCustomerDetails;
|
||||
AllowMissingSensors = testSetupXMLFields.AllowMissingSensors;
|
||||
AllowSensorIdToBlankChannel = testSetupXMLFields.AllowSensorIdToBlankChannel;
|
||||
ParseSettings(testSetupXMLFields.Settings);
|
||||
//LocalOnly
|
||||
LastModified = testSetupXMLFields.LastModified;
|
||||
LastModifiedBy = testSetupXMLFields.LastModifiedBy;
|
||||
//TurnOffExcitation
|
||||
//TriggerCheckRealtime
|
||||
TriggerCheckStep = testSetupXMLFields.TriggerCheckStep;
|
||||
PostTestDiagnostics = testSetupXMLFields.PostTestDiagnostics;
|
||||
ExportFolder = testSetupXMLFields.ExportFolder;
|
||||
//DownloadFolder
|
||||
CommonStatusLine = testSetupXMLFields.CommonStatusLine;
|
||||
//SameAsDownloadFolder
|
||||
UploadData = testSetupXMLFields.UploadData;
|
||||
UploadDataFolder = testSetupXMLFields.UploadDataFolder;
|
||||
//UploadExportsOnly
|
||||
//Settings
|
||||
WarnOnBatteryFail = testSetupXMLFields.WarnOnBatteryFail;
|
||||
//Dirty
|
||||
//Complete
|
||||
//ErrorMessage
|
||||
//TestEngineerDetails
|
||||
UseTestEngineerDetails = testSetupXMLFields.UseTestEngineerDetails;
|
||||
UserTags = testSetupXMLFields.UserTags;
|
||||
AutoArm = testSetupXMLFields.DoAutoArm;
|
||||
Streaming = testSetupXMLFields.DoStreaming;
|
||||
//CheckoutMode
|
||||
QuitTestWithoutWarning = testSetupXMLFields.QuitTestWithoutWarning;
|
||||
SuppressMissingSensorsWarning = testSetupXMLFields.SuppressMissingSensorsWarning;
|
||||
//ISFFile
|
||||
NotAllChannelsRealTime = testSetupXMLFields.NotAllChannelsRealTime;
|
||||
NotAllChannelsViewer = testSetupXMLFields.NotAllChannelsViewer;
|
||||
CalibrationBehavior = testSetupXMLFields.CalibrationBehavior;
|
||||
//ClockSyncProfileMaster
|
||||
//ClockSyncProfileSlave
|
||||
//ExtraProperties
|
||||
MeasureSquibResistances = testSetupXMLFields.MeasureSquibResistancesStep;
|
||||
|
||||
Groups = new List<GroupXMLClass>();
|
||||
foreach (var group in testSetupXML.Groups[0].Group)
|
||||
{
|
||||
Groups.Add(group);
|
||||
}
|
||||
|
||||
LevelTriggers = new List<LevelTriggerXMLClass>();
|
||||
if (testSetupXML.LevelTriggers != null && testSetupXML.LevelTriggers.LevelTriggers != null)
|
||||
{
|
||||
foreach (var levelTrigger in testSetupXML.LevelTriggers.LevelTriggers)
|
||||
{
|
||||
LevelTriggers.Add(levelTrigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ParseSettings(string allSettings)
|
||||
{
|
||||
const string PerformArmChecklistNumber = "0=";
|
||||
const string CheckInputVoltageNumber = "1=";
|
||||
const string CheckBatteryVoltageNumber = "2=";
|
||||
const string CheckSquibResistanceNumber = "3=";
|
||||
const string CheckSensorIdsNumber = "4=";
|
||||
const string CheckStartEventLinesNumber = "5=";
|
||||
const string CheckTiltSensorNumber = "6=";
|
||||
const string CheckTemperatureNumber = "7=";
|
||||
|
||||
const string ExcitationWarmupMSNumber = "9=";
|
||||
const string CheckRequireAllUnitsPassArmChecklistNumber = "10=";
|
||||
|
||||
var settings = allSettings.Split(',');
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
var startIndex = setting.IndexOf('=') + 1;
|
||||
var len = setting.Length - startIndex;
|
||||
if (setting.StartsWith(PerformArmChecklistNumber))
|
||||
{
|
||||
PerformArmChecklist = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckInputVoltageNumber))
|
||||
{
|
||||
CheckInputVoltage = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckBatteryVoltageNumber))
|
||||
{
|
||||
CheckBatteryVoltage = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckSquibResistanceNumber))
|
||||
{
|
||||
CheckSquibResistance = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckSensorIdsNumber))
|
||||
{
|
||||
CheckSensorIds = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckStartEventLinesNumber))
|
||||
{
|
||||
CheckStartEventLines = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckTiltSensorNumber))
|
||||
{
|
||||
CheckTiltSensor = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckTemperatureNumber))
|
||||
{
|
||||
CheckTemperature = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(ExcitationWarmupMSNumber))
|
||||
{
|
||||
ExcitationWarmupTimeMS = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckRequireAllUnitsPassArmChecklistNumber))
|
||||
{
|
||||
RequireAllUnitsPassArmCheckList = setting.Substring(startIndex, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DecodeExportFormats(string exportFormat)
|
||||
{
|
||||
var exportFormatInt = Int32.Parse(exportFormat);
|
||||
ExportCh10FilteredEUDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.Ch10FilteredEU) == SupportedExportFormatBitFlags.Ch10FilteredEU).ToString();
|
||||
//ExportCh10UnfilteredEUDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.Ch10UnfilteredEU) == SupportedExportFormatBitFlags.Ch10UnfilteredEU).ToString();
|
||||
ExportChryslerDDASDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.ChryslerDDAS) == SupportedExportFormatBitFlags.ChryslerDDAS).ToString();
|
||||
ExportCSVADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.CSVADC) == SupportedExportFormatBitFlags.CSVADC).ToString();
|
||||
ExportCSVFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.csvfiltered) == SupportedExportFormatBitFlags.csvfiltered).ToString();
|
||||
ExportCSVMVDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.CSVMV) == SupportedExportFormatBitFlags.CSVMV).ToString();
|
||||
ExportCSVUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.csvunfiltered) == SupportedExportFormatBitFlags.csvunfiltered).ToString();
|
||||
ExportDiademADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.diademadc) == SupportedExportFormatBitFlags.diademadc).ToString();
|
||||
ExportASCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.FIATASC) == SupportedExportFormatBitFlags.FIATASC).ToString();
|
||||
ExportHDFADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.HDFADC) == SupportedExportFormatBitFlags.HDFADC).ToString();
|
||||
//ExportHDFFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.HDFFiltered) == SupportedExportFormatBitFlags.HDFFiltered).ToString();
|
||||
ExportHDFMVDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.HDFMV) == SupportedExportFormatBitFlags.HDFMV).ToString();
|
||||
ExportHDFUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.HDFUnfiltered) == SupportedExportFormatBitFlags.HDFUnfiltered).ToString();
|
||||
ExportISOFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.isofiltered) == SupportedExportFormatBitFlags.isofiltered).ToString();
|
||||
ExportISOUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.isounfiltered) == SupportedExportFormatBitFlags.isounfiltered).ToString();
|
||||
ExportRDFADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.rdfadc) == SupportedExportFormatBitFlags.rdfadc).ToString();
|
||||
//ExportSomatFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.somatfiltered) == SupportedExportFormatBitFlags.somatfiltered).ToString();
|
||||
//ExportSomatUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.somatunfiltered) == SupportedExportFormatBitFlags.somatunfiltered).ToString();
|
||||
ExportTDASADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.tdasadc) == SupportedExportFormatBitFlags.tdasadc).ToString();
|
||||
ExportTDMSADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.tdmsadc) == SupportedExportFormatBitFlags.tdmsadc).ToString();
|
||||
//ExportToyotaFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.toyotafiltered) == SupportedExportFormatBitFlags.toyotafiltered).ToString();
|
||||
ExportToyotaUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.toyotaunfiltered) == SupportedExportFormatBitFlags.toyotaunfiltered).ToString();
|
||||
ExportTSVFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.tsvfiltered) == SupportedExportFormatBitFlags.tsvfiltered).ToString();
|
||||
ExportTSVUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.tsvunfiltered) == SupportedExportFormatBitFlags.tsvunfiltered).ToString();
|
||||
ExportXLSXFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.xlsxfiltered) == SupportedExportFormatBitFlags.xlsxfiltered).ToString();
|
||||
ExportXLSXUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.xlsxunfiltered) == SupportedExportFormatBitFlags.xlsxunfiltered).ToString();
|
||||
}
|
||||
public BuildTestSetup(string dasSerialNumber, string testSetupName, TestTemplate testTemplate)
|
||||
{
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
SetupName = string.IsNullOrWhiteSpace(testSetupName) ? StringResources.DefaultTestSetupName : testSetupName;
|
||||
|
||||
SetupDescription = testTemplate.Description;
|
||||
AutomaticMode = testTemplate.AutomaticProgression.ToString();
|
||||
AutomaticModeDelay = testTemplate.AutomaticProgressionDelayMS.ToString();
|
||||
//testSetupXMLFields.InvertTrigger;
|
||||
//testSetupXMLFields.InvertStart;
|
||||
//ViewDiagnostics = testTemplate.ViewDiagnostics.ToString();
|
||||
//VerifyChannels = testTemplate.VerifyChannels;
|
||||
//AutoVerifyChannels
|
||||
//VerifyChannelsDelayMS
|
||||
RecordingMode = testTemplate.RecordingMode.ToString();
|
||||
SamplesPerSecond = testTemplate.SamplesPerSecondAggregate.ToString();
|
||||
PreTriggerSeconds = testTemplate.PreTriggerSeconds.ToString();
|
||||
PostTriggerSeconds = testTemplate.PostTriggerSeconds.ToString();
|
||||
NumberOfEvents = testTemplate.NumberOfEvents.ToString();
|
||||
WakeUpMotionTimeout = testTemplate.WakeUpMotionTimeout.ToString();
|
||||
StrictDiagnostics = testTemplate.StrictDiagnostics.ToString();
|
||||
RequireConfirmationOnErrors = testTemplate.RequireUserConfirmationOnErrors.ToString();
|
||||
ROIDownload = testTemplate.DoROIDownload.ToString();
|
||||
ViewROIDownload = testTemplate.ViewROIDownload.ToString();
|
||||
DownloadAll = testTemplate.DownloadAll.ToString();
|
||||
ViewRealtime = testTemplate.ViewRealtime.ToString();
|
||||
RealtimeCharts = testTemplate.DefaultNumberRealtimeGraphs.ToString();
|
||||
ROIStart = testTemplate.ROIStart.ToString();
|
||||
ROIEnd = testTemplate.ROIEnd.ToString();
|
||||
ViewDownloadAll = testTemplate.ViewDownloadAll.ToString();
|
||||
Export = testTemplate.ViewExport.ToString();
|
||||
ExportFolder = testTemplate.ExportFolder;
|
||||
//ExportFormat = testTemplate.ExportFormats.ToString();
|
||||
GetExports(testTemplate.ExportFormats.ToString());
|
||||
//LabDetails = testSetupXMLFields.LabDetails;
|
||||
UseLabDetails = testTemplate.UseLabratoryDetails.ToString();
|
||||
//CustomerDetails
|
||||
UseCustomerDetails = testTemplate.UseCustomerDetails.ToString();
|
||||
AllowMissingSensors = testTemplate.AllowMissingSensors.ToString();
|
||||
AllowSensorIdToBlankChannel = testTemplate.AllowSensorIdToBlankChannel.ToString();
|
||||
ExcitationWarmupTimeMS = testTemplate.ExcitationWarmupTimeMS.ToString();
|
||||
//LocalOnly
|
||||
LastModified = testTemplate.LastModified.ToString();
|
||||
LastModifiedBy = testTemplate.LastModifiedBy;
|
||||
//TurnOffExcitation
|
||||
//TriggerCheckRealtime
|
||||
TriggerCheckStep = testTemplate.TriggerCheckStep.ToString();
|
||||
PostTestDiagnostics = testTemplate.PostTestDiagnosticsLevel.ToString();
|
||||
//ExportFolder
|
||||
//DownloadFolder
|
||||
CommonStatusLine = testTemplate.CommonLine.ToString();
|
||||
//SameAsDownloadFolder
|
||||
UploadData = testTemplate.UploadData.ToString();
|
||||
UploadDataFolder = testTemplate.UploadFolder;
|
||||
//UploadExportsOnly
|
||||
//Settings
|
||||
WarnOnBatteryFail = testTemplate.WarnOnFailedBattery.ToString();
|
||||
//Dirty
|
||||
//Complete
|
||||
//ErrorMessage
|
||||
//TestEngineerDetails
|
||||
UseTestEngineerDetails = testTemplate.UseTestEngineerDetails.ToString();
|
||||
UserTags = string.Empty;
|
||||
AutoArm = testTemplate.DoAutoArm.ToString();
|
||||
Streaming = testTemplate.DoStreaming.ToString();
|
||||
//CheckoutMode
|
||||
QuitTestWithoutWarning = testTemplate.QuitTestWithoutWarning.ToString();
|
||||
SuppressMissingSensorsWarning = testTemplate.SuppressMissingSensorsWarning.ToString();
|
||||
//ISFFile
|
||||
NotAllChannelsRealTime = testTemplate.NotAllChannelsRealTime.ToString();
|
||||
NotAllChannelsViewer = testTemplate.NotAllChannelsViewer.ToString();
|
||||
CalibrationBehavior = testTemplate.CalibrationBehavior.ToString();
|
||||
//ClockSyncProfileMaster
|
||||
//ClockSyncProfileSlave
|
||||
//ExtraProperties
|
||||
MeasureSquibResistances = testTemplate.MeasureSquibResistancesStep.ToString();
|
||||
PerformArmChecklist = testTemplate.ArmCheckListStep.ToString();
|
||||
CheckInputVoltage = testTemplate.CheckListInputVoltageCheck.ToString();
|
||||
CheckBatteryVoltage = testTemplate.CheckListBatteryVoltageCheck.ToString();
|
||||
CheckSquibResistance = testTemplate.CheckListSquibResistanceCheck.ToString();
|
||||
CheckSensorIds = testTemplate.CheckListSensorIdCheck.ToString();
|
||||
CheckStartEventLines = testTemplate.CheckListTriggerStartCheck.ToString();
|
||||
CheckTiltSensor = testTemplate.CheckListTiltSensorCheck.ToString();
|
||||
CheckTemperature = testTemplate.CheckListTemperatureCheck.ToString();
|
||||
|
||||
RequireAllUnitsPassArmCheckList = testTemplate.CheckListRequirePass.ToString();
|
||||
|
||||
Groups = new List<GroupXMLClass>();
|
||||
foreach (var group in testTemplate.Groups)
|
||||
{
|
||||
var xmlGroup = new GroupXMLClass();
|
||||
xmlGroup.Name = group.Name;
|
||||
xmlGroup.DisplayName = group.DisplayName;
|
||||
xmlGroup.Description = group.Description;
|
||||
xmlGroup.DisplayOrder = group.DisplayOrder.ToString();
|
||||
xmlGroup.HardwareList = new HardwareListXMLClass(); //Add hardware serial numbers to this (from channels? from includedHardwareList?)
|
||||
|
||||
foreach (var channel in group.GroupChannelList)
|
||||
{
|
||||
var xmlChannel = new ChannelXMLClass();
|
||||
xmlChannel.ISOChannelName = channel.IsoChannelName;
|
||||
xmlChannel.ISOCode = channel.IsoCode;
|
||||
xmlChannel.UserChannelName = channel.UserChannelName;
|
||||
xmlChannel.UserCode = channel.UserCode;
|
||||
xmlChannel.TestSetupOrder = channel.TestSetupOrder.ToString();
|
||||
xmlChannel.GroupOrder = channel.GroupChannelOrder.ToString();
|
||||
|
||||
xmlChannel.Settings.FilterClass = $"{channel.FilterClass.FClass.ToString()},{channel.FilterClass.Frequency.ToString()}";
|
||||
xmlChannel.Settings.Polarity = channel.Polarity;
|
||||
xmlChannel.Settings.Range = channel.Range.ToString();
|
||||
xmlChannel.Settings.ZeroMethod = channel.ZeroMethod.ToString();
|
||||
xmlChannel.Settings.ZeroMethodStart = channel.ZeroMethodStart.ToString();
|
||||
xmlChannel.Settings.ZeroMethodEnd = channel.ZeroMethodEnd.ToString();
|
||||
xmlChannel.Settings.InitialOffset = $"{channel.InitialOffset.Form},{channel.InitialOffset.EU},{channel.InitialOffset.MV}";
|
||||
xmlChannel.Settings.UserValue1 = channel.SensorData.UserValue1;
|
||||
xmlChannel.Settings.UserValue2 = channel.SensorData.UserValue2;
|
||||
xmlChannel.Settings.UserValue3 = channel.SensorData.UserValue3;
|
||||
|
||||
xmlGroup.Channel.Add(xmlChannel);
|
||||
}
|
||||
|
||||
Groups.Add(xmlGroup);
|
||||
}
|
||||
|
||||
LevelTriggers = new List<LevelTriggerXMLClass>();
|
||||
if (testTemplate.LevelTriggerChannels != null)
|
||||
{
|
||||
foreach (var levelTrigger in testTemplate.LevelTriggerChannels)
|
||||
{
|
||||
var xmlLevelTrigger = new LevelTriggerXMLClass();
|
||||
xmlLevelTrigger.GreaterThanEnabled = levelTrigger.Value.GreaterThanEnabled.ToString();
|
||||
xmlLevelTrigger.GreaterThanValue = levelTrigger.Value.GreaterThanThresholdEU.ToString();
|
||||
xmlLevelTrigger.GroupChannelId = levelTrigger.Value.GroupChannelId;
|
||||
xmlLevelTrigger.HardwareChannelId = levelTrigger.Value.HardwareChannelId;
|
||||
xmlLevelTrigger.InsideLowerEU = levelTrigger.Value.InsideLowerLevelEU.ToString();
|
||||
xmlLevelTrigger.InsideUpperEU = levelTrigger.Value.InsideUpperLevelEU.ToString();
|
||||
xmlLevelTrigger.LessThanEnabled = levelTrigger.Value.LessThanEnabled.ToString();
|
||||
xmlLevelTrigger.LessThanValue = levelTrigger.Value.LessThanThresholdEU.ToString();
|
||||
xmlLevelTrigger.OutsideLowerEU = levelTrigger.Value.OutsideLowerLevelEU.ToString();
|
||||
xmlLevelTrigger.OutsideUpperEU = levelTrigger.Value.OutsideUpperLevelEU.ToString();
|
||||
xmlLevelTrigger.SensorSerialNumber = levelTrigger.Value.SensorSerialNumber;
|
||||
xmlLevelTrigger.TriggerInside = levelTrigger.Value.TriggerBetweenBounds.ToString();
|
||||
xmlLevelTrigger.TriggerOutside = levelTrigger.Value.TriggerOutsideBounds.ToString();
|
||||
LevelTriggers.Add(xmlLevelTrigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void GetExports(string exportFormats)
|
||||
{
|
||||
//Initialize all to false
|
||||
ExportCSVUnfilteredDesired = false.ToString();
|
||||
ExportDiademADCDesired = false.ToString();
|
||||
ExportISOFilteredDesired = false.ToString();
|
||||
ExportISOUnfilteredDesired = false.ToString();
|
||||
ExportToyotaUnfilteredDesired = false.ToString();
|
||||
ExportTSVUnfilteredDesired = false.ToString();
|
||||
ExportCSVFilteredDesired = false.ToString();
|
||||
ExportTDASADCDesired = false.ToString();
|
||||
ExportTSVFilteredDesired = false.ToString();
|
||||
ExportRDFADCDesired = false.ToString();
|
||||
ExportChryslerDDASDesired = false.ToString();
|
||||
ExportHDFUnfilteredDesired = false.ToString();
|
||||
ExportHDFMVDesired = false.ToString();
|
||||
ExportHDFADCDesired = false.ToString();
|
||||
ExportXLSXFilteredDesired = false.ToString();
|
||||
ExportXLSXUnfilteredDesired = false.ToString();
|
||||
ExportCSVADCDesired = false.ToString();
|
||||
ExportCSVMVDesired = false.ToString();
|
||||
ExportCh10FilteredEUDesired = false.ToString();
|
||||
ExportTDMSADCDesired = false.ToString();
|
||||
ExportASCDesired = false.ToString();
|
||||
var exportFormatArray = exportFormats.Split(',');
|
||||
foreach (var exportFormat in exportFormatArray)
|
||||
{
|
||||
switch (exportFormat.Trim())
|
||||
{
|
||||
case "csvunfiltered":
|
||||
ExportCSVUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "diademadc":
|
||||
ExportDiademADCDesired = true.ToString();
|
||||
break;
|
||||
case "isofiltered":
|
||||
ExportISOFilteredDesired = true.ToString();
|
||||
break;
|
||||
case "isounfiltered":
|
||||
ExportISOUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "toyotaunfiltered":
|
||||
ExportToyotaUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "tsvunfiltered":
|
||||
ExportTSVUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "csvfiltered":
|
||||
ExportCSVFilteredDesired = true.ToString();
|
||||
break;
|
||||
case "tdasadc":
|
||||
ExportTDASADCDesired = true.ToString();
|
||||
break;
|
||||
case "tdmsadc":
|
||||
ExportTDMSADCDesired = true.ToString();
|
||||
break;
|
||||
case "tsvfiltered":
|
||||
ExportTSVFilteredDesired = true.ToString();
|
||||
break;
|
||||
case "rdfadc":
|
||||
ExportRDFADCDesired = true.ToString();
|
||||
break;
|
||||
case "ChryslerDDAS":
|
||||
ExportChryslerDDASDesired = true.ToString();
|
||||
break;
|
||||
case "HDFUnfiltered":
|
||||
ExportHDFUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "HDFMV":
|
||||
ExportHDFMVDesired = true.ToString();
|
||||
break;
|
||||
case "HDFADC":
|
||||
ExportHDFADCDesired = true.ToString();
|
||||
break;
|
||||
case "xlsxfiltered":
|
||||
ExportXLSXFilteredDesired = true.ToString();
|
||||
break;
|
||||
case "xlsxunfiltered":
|
||||
ExportXLSXUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "CSVADC":
|
||||
ExportCSVADCDesired = true.ToString();
|
||||
break;
|
||||
case "CSVMV":
|
||||
ExportCSVMVDesired = true.ToString();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string DASSerialNumber { get; set; }
|
||||
public string SetupName { get; set; }
|
||||
public string SetupDescription { get; set; }
|
||||
public string AutomaticMode { get; set; }
|
||||
public string AutomaticModeDelay { get; set; }
|
||||
public string WarnOnBatteryFail { get; set; }
|
||||
public string ViewRealtime { get; set; }
|
||||
public string RecordingMode { get; set; }
|
||||
public string SamplesPerSecond { get; set; }
|
||||
public string PreTriggerSeconds { get; set; }
|
||||
public string PostTriggerSeconds { get; set; }
|
||||
public string NumberOfEvents { get; set; }
|
||||
public string WakeUpMotionTimeout { get; set; }
|
||||
public string ScheduledStartDateTime { get; set; }
|
||||
public string IntervalBetweenEventStartsMinutes { get; set; }
|
||||
public string StartWithEvent { get; set; }
|
||||
public string WakeUpWithMotion { get; set; }
|
||||
public string StrictDiagnostics { get; set; }
|
||||
public string RequireConfirmationOnErrors { get; set; }
|
||||
public string AllowSensorIdToBlankChannel { get; set; }
|
||||
public string PerformArmChecklist { get; set; }
|
||||
public string CheckInputVoltage { get; set; }
|
||||
public string CheckBatteryVoltage { get; set; }
|
||||
public string CheckSquibResistance { get; set; }
|
||||
public string CheckSensorIds { get; set; }
|
||||
public string CheckStartEventLines { get; set; }
|
||||
public string CheckTiltSensor { get; set; }
|
||||
public string CheckTemperature { get; set; }
|
||||
public string ExcitationWarmupTimeMS { get; set; }
|
||||
public string RequireAllUnitsPassArmCheckList { get; set; }
|
||||
public string ROIDownload { get; set; }
|
||||
public string ViewROIDownload { get; set; }
|
||||
public string DownloadAll { get; set; }
|
||||
public string RealtimeCharts { get; set; }
|
||||
public string ROIStart { get; set; }
|
||||
public string ROIEnd { get; set; }
|
||||
public string ViewDownloadAll { get; set; }
|
||||
public string Export { get; set; }
|
||||
//public string ExportFormat { get; set; }
|
||||
public string ExportCh10FilteredEUDesired { get; set; }
|
||||
//public string ExportCh10UnfilteredEUDesired { get; set; }
|
||||
public string ExportChryslerDDASDesired { get; set; }
|
||||
public string ExportCSVADCDesired { get; set; }
|
||||
public string ExportCSVFilteredDesired { get; set; }
|
||||
public string ExportCSVMVDesired { get; set; }
|
||||
public string ExportCSVUnfilteredDesired { get; set; }
|
||||
public string ExportDiademADCDesired { get; set; }
|
||||
public string ExportASCDesired { get; set; }
|
||||
public string ExportHDFADCDesired { get; set; }
|
||||
//public string ExportHDFFilteredDesired { get; set; }
|
||||
public string ExportHDFMVDesired { get; set; }
|
||||
public string ExportHDFUnfilteredDesired { get; set; }
|
||||
public string ExportISOFilteredDesired { get; set; }
|
||||
public string ExportISOUnfilteredDesired { get; set; }
|
||||
public string ExportRDFADCDesired { get; set; }
|
||||
//public string ExportSomatFilteredDesired { get; set; }
|
||||
//public string ExportSomatUnfilteredDesired { get; set; }
|
||||
public string ExportTDASADCDesired { get; set; }
|
||||
public string ExportTDMSADCDesired { get; set; }
|
||||
//public string ExportToyotaFilteredDesired { get; set; }
|
||||
public string ExportToyotaUnfilteredDesired { get; set; }
|
||||
public string ExportTSVFilteredDesired { get; set; }
|
||||
public string ExportTSVUnfilteredDesired { get; set; }
|
||||
public string ExportXLSXFilteredDesired { get; set; }
|
||||
public string ExportXLSXUnfilteredDesired { get; set; }
|
||||
public string UseLabDetails { get; set; }
|
||||
public string UseCustomerDetails { get; set; }
|
||||
public string AllowMissingSensors { get; set; }
|
||||
public string LastModified { get; set; }
|
||||
public string LastModifiedBy { get; set; }
|
||||
public string PostTestDiagnostics { get; set; }
|
||||
public string UserTags { get; set; }
|
||||
public string CalibrationBehavior { get; set; }
|
||||
public string SuppressMissingSensorsWarning { get; set; }
|
||||
public string NotAllChannelsRealTime { get; set; }
|
||||
public string NotAllChannelsViewer { get; set; }
|
||||
public string TriggerCheckStep { get; set; }
|
||||
public string QuitTestWithoutWarning { get; set; }
|
||||
public string ExportFolder { get; set; }
|
||||
public string DownloadFolder { get; set; }
|
||||
public string CommonStatusLine { get; set; }
|
||||
public string UploadData { get; set; }
|
||||
public string UploadDataFolder { get; set; }
|
||||
public string UseTestEngineerDetails { get; set; }
|
||||
public string AutoArm { get; set; }
|
||||
public string Streaming { get; set; }
|
||||
public string MeasureSquibResistances { get; set; }
|
||||
public List<GroupXMLClass> Groups { get; set; }
|
||||
public List<LevelTriggerXMLClass> LevelTriggers { get; set; }
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,109 @@
|
||||
using DTS.Common.Converters;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DTS.Common.DataModel.Classes.TSRAIRGo
|
||||
{
|
||||
public class TSRAIRGoStatus
|
||||
{
|
||||
[TypeConverter(typeof(EnumDescriptionTypeConverterShared))]
|
||||
public enum StatusTypes
|
||||
{
|
||||
[Description("Table_NA")]
|
||||
UNKNOWN,
|
||||
[Description("HardwareDiscoveryControl_PingFailed")]
|
||||
PING_FAILED,
|
||||
[Description("AutoDetectDASControl_Pinging")]
|
||||
PINGING,
|
||||
[Description("AutoDetectDASControl_Ping_Good")]
|
||||
PING_SUCCESS,
|
||||
[Description("HardwareDiscoveryControl_FailedToConnect")]
|
||||
CONNECT_FAILED,
|
||||
[Description("AutoDetectDASControl_Connecting")]
|
||||
CONNECTING,
|
||||
[Description("AutoDetectDASControl_QueryFailed")]
|
||||
QUERY_FAILED,
|
||||
[Description("HardwareDiscoveryControl_QueryTimedOut")]
|
||||
QUERY_TIMEDOUT,
|
||||
[Description("AutoDetectDASControl_Done")]
|
||||
DONE,
|
||||
[Description("AutoDetectDASControl_Querying")]
|
||||
QUERYING,
|
||||
[Description("AutoDetectDASControl_Updated")]
|
||||
UPDATED,
|
||||
[Description("AutoDetectDASControl_Added")]
|
||||
ADDED,
|
||||
[Description("HardwareDiscoveryControl_Online")]
|
||||
ONLINE,
|
||||
[Description("HardwareDiscoveryControl_Connected")]
|
||||
CONNECTED,
|
||||
[Description("CheckHardware_UnexpectedMaxMemory")]
|
||||
UNEXPECTED_MAX_MEMORY,
|
||||
[Description("CheckHardware_FirmwareMismatch")]
|
||||
UNEXPECTED_FIRMWARE_VERSION,
|
||||
[Description("CheckHardwareStatus_Passed")]
|
||||
PASSED,
|
||||
[Description("CheckHardware_CalDateOverdue")]
|
||||
EXPIRED_CAL_DATE,
|
||||
[Description("CheckHardware_ChannelCountMismatch")]
|
||||
CHANNEL_COUNT_MISMATCH,
|
||||
[Description("Table_NA")]
|
||||
MISSING_MODULES,
|
||||
CANCELED,
|
||||
[Description("CheckHardware_NoMemory")]
|
||||
NO_MEMORY,
|
||||
[Description("ArmSystem_Armed")]
|
||||
ARMED,
|
||||
[Description("AutoArmed")]
|
||||
AUTOARMED,
|
||||
[Description("Admin_SystemSettings_Page_Realtime")]
|
||||
REALTIME,
|
||||
[Description("ReadyToStream")]
|
||||
READYTOSTREAM,
|
||||
[Description("ArmSystem_CurrentlyStreaming")]
|
||||
STREAMING,
|
||||
[Description("LostDock")]
|
||||
LOST_DOCK,
|
||||
[Description("Status_Rebooting")]
|
||||
REBOOTING,
|
||||
[Description("CheckHardwareStatus_SettingClockSources")]
|
||||
SETTING_CLOCK,
|
||||
[Description("CheckHardware_UnexpectedFirstUseDate")]
|
||||
UNEXPECTED_FIRSTUSE_DATE,
|
||||
[Description("InvalidRecordingMode")]
|
||||
INVALID_RECORDING_MODE,
|
||||
[Description("InvalidStreamMode")]
|
||||
INVALID_STREAMING_MODE,
|
||||
[Description("StreamingNotAvailable")]
|
||||
STREAMING_NOT_AVAILABLE,
|
||||
ARMING,
|
||||
DISARMING,
|
||||
[Description("ArmSystem_Disarmed")]
|
||||
DISARMED,
|
||||
[Description("ArmSystem_ArmFailed")]
|
||||
ARM_FAILED,
|
||||
[Description("ArmSystem_SettingConfiguration")]
|
||||
UPDATING_DAS_CONFIG,
|
||||
[Description("ArmSystem_ClearingFlash")]
|
||||
PREPARING_DATA_MEMORY,
|
||||
[Description("ArmSystem_Rearming")]
|
||||
REARMING,
|
||||
[Description("ArmSystem_PreparingForArming")]
|
||||
PREPARING_FOR_ARMING,
|
||||
[Description("ArmSystem_WaitingForInterval")]
|
||||
WAITING_FOR_INTERVAL,
|
||||
[Description("ArmSystem_WaitingForTrigger")]
|
||||
WAITING_FOR_TRIGGER,
|
||||
[Description("ArmSystem_WaitingForScheduleStartTime")]
|
||||
WAITING_FOR_SCHEDULE,
|
||||
[Description("ArmSystem_Recording")]
|
||||
RECORDING,
|
||||
[Description("Offline")]
|
||||
OFFLINE,
|
||||
[Description("Downloading")]
|
||||
DOWNLOADING,
|
||||
[Description("Download_StatusTypes_GettingEventData")]
|
||||
GETTINGEVENTDATA
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <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;
|
||||
}
|
||||
public HardwareInclusionInstruction(HardwareInclusionInstruction copy)
|
||||
{
|
||||
HardwareId = copy.HardwareId;
|
||||
Action = copy.Action;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.DASLib.Service;
|
||||
using System.Threading;
|
||||
using DTS.Common.DataModel.Common;
|
||||
using DTS.Common;
|
||||
using DTS.Common.Enums.TSRAIRGo;
|
||||
using System.Windows.Forms;
|
||||
using DTS.Common.DataModel.Classes.TSRAIRGo;
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes
|
||||
{
|
||||
public class Configuration
|
||||
{
|
||||
public Configuration()
|
||||
{
|
||||
}
|
||||
public void SetConfig(DataModel.TestTemplate currentTest,
|
||||
List<IDASCommunication> dasList,
|
||||
bool calledDuringDiagnostics,
|
||||
StatusHelpers.SetProgressValueDelegate setProgressFunction)
|
||||
{
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
|
||||
var type = das.GetHardwareType();
|
||||
das.MinimumValidInputVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.MinimumValidInputThreshold));
|
||||
das.MaximumValidInputVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.MaximumValidInputThreshold));
|
||||
das.MinimumValidBatteryVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.MinimumValidBatteryThreshold));
|
||||
das.MaximumValidBatteryVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.MaximumValidBatteryThreshold));
|
||||
|
||||
StatusHelpers.SetStatus2(das, 0, TSRAIRGoStatus.StatusTypes.UPDATING_DAS_CONFIG, setProgressFunction);
|
||||
|
||||
if (calledDuringDiagnostics)
|
||||
{
|
||||
das.BatteryHighVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryHighDiagnosticsThreshold));
|
||||
das.BatteryMediumVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryMediumDiagnosticsThreshold));
|
||||
das.BatteryLowVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryLowDiagnosticsThreshold));
|
||||
das.InputHighVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputHighDiagnosticsThreshold));
|
||||
das.InputMediumVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputMediumDiagnosticsThreshold));
|
||||
das.InputLowVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputLowDiagnosticsThreshold));
|
||||
}
|
||||
else
|
||||
{
|
||||
das.BatteryHighVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryHighArmedThreshold));
|
||||
das.BatteryMediumVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryMediumArmedThreshold));
|
||||
das.BatteryLowVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryLowArmedThreshold));
|
||||
das.InputHighVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputHighArmedThreshold));
|
||||
das.InputMediumVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputMediumArmedThreshold));
|
||||
das.InputLowVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputLowArmedThreshold));
|
||||
}
|
||||
}
|
||||
|
||||
//setting the configuration checks the hardware lines
|
||||
//so make sure we reset them prior to setting configuration
|
||||
using (var configService = new ConfigurationService())
|
||||
{
|
||||
var mreLocal = new ManualResetEvent(false);
|
||||
configService.ResetHardwareLines(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished: mreLocal.Set(); break;
|
||||
}
|
||||
}, dasList);
|
||||
mreLocal.WaitOne();
|
||||
}
|
||||
|
||||
using (var config = new ConfigurationService())
|
||||
{
|
||||
config.AggregateProgress = false;
|
||||
var done = new ManualResetEvent(false);
|
||||
var elapsed = 0;
|
||||
try
|
||||
{
|
||||
config.SetConfiguration(dasList, true, true,
|
||||
delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
StatusHelpers.SetStatus2(cbd.Target, cbd.ProgressValue, TSRAIRGoStatus.StatusTypes.UPDATING_DAS_CONFIG, setProgressFunction);
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
}
|
||||
},
|
||||
dasList,
|
||||
ErrorCallback,
|
||||
calledDuringDiagnostics,
|
||||
new double[] { Common.SerializedSettings.MaxAAFRate_TDAS, Common.SerializedSettings.MaxAAFRate_G5 },
|
||||
true,
|
||||
true,
|
||||
Common.SerializedSettings.GetDefaultDSP(),
|
||||
true
|
||||
);
|
||||
while (!done.WaitOne(50, false))
|
||||
{
|
||||
elapsed += 50;
|
||||
}
|
||||
CopyGlobalConfigsToLocalFolder(currentTest, dasList);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static DialogResult ErrorCallback(string errorString, string units)
|
||||
{
|
||||
APILogger.Log("error setting configuration", errorString);
|
||||
return DialogResult.OK; //Fix this
|
||||
}
|
||||
private void CopyGlobalConfigsToLocalFolder(DataModel.TestTemplate currentTest, List<IDASCommunication> dasList)
|
||||
{
|
||||
var sourcePath = System.IO.Path.Combine(Environment.CurrentDirectory, Constants.DAS_CONFIGS);
|
||||
var destPath = System.IO.Path.Combine(currentTest.TestDirectory.Trim(), Constants.DAS_CONFIGS);
|
||||
try
|
||||
{
|
||||
if (!System.IO.Directory.Exists(destPath))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(destPath);
|
||||
}
|
||||
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
//Copy the entire das config
|
||||
var sourceFileName = System.IO.Path.Combine(sourcePath, $"{((InfoResult)das.DASInfo).OwningDAS}.xml");
|
||||
var destFileName = System.IO.Path.Combine(destPath, $"{((InfoResult)das.DASInfo).OwningDAS}.xml");
|
||||
if (System.IO.File.Exists(sourceFileName))
|
||||
{
|
||||
System.IO.File.Copy(sourceFileName, destFileName, true);
|
||||
}
|
||||
|
||||
foreach (var module in das.DASInfo.Modules)
|
||||
{
|
||||
//Copy each module config
|
||||
sourceFileName = System.IO.Path.Combine(sourcePath, $"{module.SerialNumber}.xml");
|
||||
if (!System.IO.File.Exists(sourceFileName)) continue;
|
||||
destFileName = System.IO.Path.Combine(destPath, $"{module.SerialNumber}.xml");
|
||||
System.IO.File.Copy(sourceFileName, destFileName, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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("DTS.Common.DataModel")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DTS.Common.DataModel")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[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("2a2f03a9-bf85-4360-a06a-cf3016d2633b")]
|
||||
|
||||
// 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,339 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using DataPROWin7.DataModel.Classes.Hardware;
|
||||
using DTS.Common.Converters;
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using DTS.Common.Constant.DASSpecific;
|
||||
|
||||
namespace DataPROWin7
|
||||
{
|
||||
public class ChannelRepresentation
|
||||
{
|
||||
public enum ChannelTypeEnum
|
||||
{
|
||||
SQUIB,
|
||||
TOMDigital,
|
||||
DigitalInput,
|
||||
Other
|
||||
}
|
||||
|
||||
private readonly ChannelTypeEnum _channelType = ChannelTypeEnum.Other;
|
||||
|
||||
public ChannelRepresentation(DataModel.DASHardware h, DTS.DASLib.Service.DASChannel c,
|
||||
int startingChannelNumber)
|
||||
{
|
||||
//adjust the starting channel number (which appears to be a DAS channel number) to a module channel number
|
||||
if (h.CareAboutModules)
|
||||
{
|
||||
startingChannelNumber = 1 + c.ModuleChannelNumber;
|
||||
}
|
||||
if (c is DTS.DASLib.Service.OutputSquibChannel)
|
||||
{
|
||||
startingChannelNumber = DoSquibConversion(startingChannelNumber);
|
||||
_channelType = ChannelTypeEnum.SQUIB;
|
||||
}
|
||||
else if (c is DTS.DASLib.Service.OutputTOMDigitalChannel)
|
||||
{
|
||||
_channelType = ChannelTypeEnum.TOMDigital;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((c as DTS.DASLib.Service.AnalogInputDASChannel).SupportedBridges.Length == 1) &&
|
||||
((c as DTS.DASLib.Service.AnalogInputDASChannel).SupportedBridges[0] ==
|
||||
SensorConstants.BridgeType.DigitalInput))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.DigitalInput;
|
||||
}
|
||||
}
|
||||
|
||||
ConvertChannelNumbers(h.DASTypeEnum, startingChannelNumber, h.SerialNumber, c.OwningModule.SerialNumber(),
|
||||
_channelType);
|
||||
}
|
||||
|
||||
|
||||
private int GetModuleChannelNumber(DataModel.HardwareChannel c)
|
||||
{
|
||||
if (null == c.Hardware)
|
||||
{
|
||||
return 1 + c.ChannelNumber;
|
||||
}
|
||||
var moduleChannelNumber = 0;
|
||||
var moduleArrayIndex = -1;
|
||||
|
||||
foreach (var ch in c.Hardware.Channels)
|
||||
{
|
||||
if (ch.ModuleArrayIndex != moduleArrayIndex)
|
||||
{
|
||||
moduleChannelNumber = 0;
|
||||
moduleArrayIndex = ch.ModuleArrayIndex;
|
||||
}
|
||||
moduleChannelNumber++;
|
||||
if (ch.ChannelNumber == c.ChannelNumber)
|
||||
{
|
||||
return moduleChannelNumber;
|
||||
}
|
||||
}
|
||||
return 1 + c.ChannelNumber;
|
||||
}
|
||||
|
||||
public ChannelRepresentation(DataModel.HardwareChannel c, int startingChannelNumber, IDASHardware[] hardwares = null)
|
||||
{
|
||||
if (null != c.Hardware && c.Hardware.CareAboutModules)
|
||||
{
|
||||
startingChannelNumber = GetModuleChannelNumber(c);
|
||||
}
|
||||
if (c.IsSupportedBridgeType(SensorConstants.BridgeType.SQUIB))
|
||||
{
|
||||
startingChannelNumber = DoSquibConversion(startingChannelNumber);
|
||||
_channelType = ChannelTypeEnum.SQUIB;
|
||||
}
|
||||
else if (c.IsSupportedBridgeType(SensorConstants.BridgeType.TOMDigital))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.TOMDigital;
|
||||
}
|
||||
else if (c.IsSupportedBridgeType(SensorConstants.BridgeType.DigitalInput))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.DigitalInput;
|
||||
}
|
||||
|
||||
var moduleSerialNumber = c.ModuleSerialNumber;
|
||||
var dasSerialNumber = c.Hardware.SerialNumber;
|
||||
|
||||
var h = c.Hardware.GetHardware();
|
||||
if (h.StandIn)
|
||||
{
|
||||
dasSerialNumber = EnumDescriptionTypeConverter.GetEnumDescription(h.DASTypeEnum);
|
||||
switch (c.Hardware.DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
break;
|
||||
default:
|
||||
moduleSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (c.Hardware.IsPseudoRackModule() && c.Hardware.IsModule())
|
||||
{
|
||||
moduleSerialNumber = c.Hardware.SerialNumber;
|
||||
dasSerialNumber = c.Hardware.ParentDAS;
|
||||
}
|
||||
else if (c.Hardware.IsTSRAIRModule() && c.Hardware.IsModule())
|
||||
{
|
||||
moduleSerialNumber = c.Hardware.SerialNumber;
|
||||
dasSerialNumber = string.IsNullOrWhiteSpace(c.Hardware.ParentDAS) ?
|
||||
c.Hardware.Connection.Split(new[] { "xEMB" }, StringSplitOptions.RemoveEmptyEntries)[0] :
|
||||
c.Hardware.ParentDAS;
|
||||
}
|
||||
|
||||
ConvertChannelNumbers(c.Hardware.DASTypeEnum, startingChannelNumber, dasSerialNumber, moduleSerialNumber,
|
||||
_channelType, hardwares);
|
||||
if (!c.Hardware.IsTSRAIR())
|
||||
{
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
}
|
||||
}
|
||||
|
||||
public string DASSerialNumber { get; set; } = string.Empty;
|
||||
|
||||
public string SerialNumber //Module
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = string.Empty;
|
||||
|
||||
public string ChannelNumberString { get; set; } = string.Empty;
|
||||
|
||||
public int ChannelNumber { get; set; } = 0;
|
||||
|
||||
private int DoSquibConversion(int squibChannelNumber)
|
||||
{
|
||||
Math.DivRem(squibChannelNumber, 8, out var remainder);
|
||||
switch (remainder)
|
||||
{
|
||||
case 1:
|
||||
return 1;
|
||||
case 3:
|
||||
return 2;
|
||||
case 5:
|
||||
return 3;
|
||||
case 7:
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConvertChannelNumbers(HardwareTypes dasType, int startingChannelNumber, string dasSerialNumber,
|
||||
string moduleSerialNumber,
|
||||
ChannelTypeEnum channelType, IDASHardware[] hardwares = null)
|
||||
{
|
||||
var displayChannelNumber = 0;
|
||||
switch (dasType)
|
||||
{
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
if (moduleSerialNumber.StartsWith("DIM"))
|
||||
{
|
||||
Math.DivRem(startingChannelNumber - 1, 16, out displayChannelNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
}
|
||||
}
|
||||
displayChannelNumber++;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
// Start counting the Digital Output channels from 1
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.G5VDS: // Start counting the Digital Input channels from 1
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
Math.DivRem(startingChannelNumber - 1, 32, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.SLICE1_G5Stack:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.SLICE_Base: //Is this the micro base?
|
||||
case HardwareTypes.SLICE_Micro_Base: //Is this the micro base?
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: //This is for nano
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: //This is for micro
|
||||
case HardwareTypes.SLICE_NANO_Base: //This is for nano
|
||||
Math.DivRem(startingChannelNumber - 1, 3, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
|
||||
bool isPseudoDAS = false;
|
||||
IDASHardware[] list = null;
|
||||
if (null != hardwares)
|
||||
{
|
||||
list = hardwares;
|
||||
}
|
||||
else { list = DASHardwareList.GetAllHardware(); }
|
||||
if (list.Any())
|
||||
{
|
||||
//13096 Unhandled exception clicking save in hardware disco (test setup)
|
||||
var matches = from das in list where das.SerialNumber == dasSerialNumber select das;
|
||||
if (matches.Any())
|
||||
{
|
||||
isPseudoDAS = matches.First().IsPseudoRack();
|
||||
}
|
||||
}
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = isPseudoDAS ? moduleSerialNumber : dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.EMB_ANG_ARS:
|
||||
case HardwareTypes.EMB_ATM:
|
||||
case HardwareTypes.EMB_LIN_ACC_HI:
|
||||
case HardwareTypes.EMB_LIN_ACC_LO:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = moduleSerialNumber; //dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber; //.Substring(0, dasSerialNumber.IndexOf('-'));
|
||||
break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
case HardwareTypes.DIR:
|
||||
case HardwareTypes.DKR:
|
||||
Math.DivRem(startingChannelNumber - 1, 3, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_TC:
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
var displayModuleNumber = Math.DivRem(startingChannelNumber - 1, SLICE6AIRTC.ThermocouplersPerModule, out displayChannelNumber);
|
||||
SerialNumber = string.Format(StringResources.ModuleNumber, displayModuleNumber.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
if (moduleSerialNumber.Contains(StringResources.ModuleNumber))
|
||||
{
|
||||
Math.DivRem(startingChannelNumber - 1, SLICE6AIRTC.ThermocouplersPerModule, out displayChannelNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
displayChannelNumber = 0; //Stream out
|
||||
}
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
displayChannelNumber++;
|
||||
break;
|
||||
default:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
}
|
||||
if (channelType == ChannelTypeEnum.SQUIB)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_Squib + displayChannelNumber.ToString("00");
|
||||
}
|
||||
else if (channelType == ChannelTypeEnum.TOMDigital)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_DigitalOut +
|
||||
displayChannelNumber.ToString("00");
|
||||
}
|
||||
else if (channelType == ChannelTypeEnum.DigitalInput)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_DigitalIn +
|
||||
displayChannelNumber.ToString("00");
|
||||
}
|
||||
else
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_Other + displayChannelNumber.ToString("00");
|
||||
}
|
||||
ChannelNumber = displayChannelNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public enum IsoChannelSensorCompatibilityLevels
|
||||
{
|
||||
DontWarn,
|
||||
Warn,
|
||||
DontAllow
|
||||
}
|
||||
public enum SupportedExportFormats
|
||||
{
|
||||
[Description("CSV")]
|
||||
csv,
|
||||
[Description("Diadem")]
|
||||
diadem,
|
||||
[Description("ISO")]
|
||||
iso,
|
||||
[Description("SOMAT")]
|
||||
somat,
|
||||
[Description("TDAS")]
|
||||
tdas,
|
||||
[Description("TSV")]
|
||||
tsv,
|
||||
[Description("TTS")]
|
||||
tts,
|
||||
[Description("RDF")]
|
||||
rdf,
|
||||
[Description("TDMS")]
|
||||
tdms,
|
||||
[Description("DDAS")]
|
||||
ddas,
|
||||
[Description("HDF5")]
|
||||
hdf,
|
||||
[Description("XLSX")]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
xlsx,
|
||||
//DataPRO 3.3, IRIG 106 Chapter 10 export
|
||||
[Description("Chapter10")]
|
||||
chapter10,
|
||||
[Description("ASC")]
|
||||
asc,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public enum StrictLevel
|
||||
{
|
||||
Strict,
|
||||
UpdateTable,
|
||||
CheckoutOnly,
|
||||
QuickCheckout
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
using DataPROWin7.DataModel;
|
||||
using DTS.Common.Events;
|
||||
using Prism.Ioc;
|
||||
using Prism.Events;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Threading;
|
||||
using System.Windows;
|
||||
using System.Threading;
|
||||
|
||||
namespace DTS.Common.DataModel.Common
|
||||
{
|
||||
public class TestSetupCollection
|
||||
{
|
||||
|
||||
public static List<string> TestSetupIds
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
return _testSetupList;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static object TestSetupListLock { get; private set; } = new object();
|
||||
private static DateTime _lastUpdateTime = DateTime.MinValue;
|
||||
private static List<TestTemplate> _actualTestTemplates = new List<TestTemplate>();
|
||||
|
||||
private const int MIN_TESTS_UPDATEINTERVAL_MINUTES = 30;
|
||||
private static uint _crc = 0xFFFF;
|
||||
private static List<string> _testSetupList = null;
|
||||
|
||||
public static TestTemplate[] TestSetups
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
return _actualTestTemplates.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// will update the test setup list if it's more than MIN_TESTS_UPDATEINTERVAL_MINUTES OLD,
|
||||
/// OR the CRC has changed for the
|
||||
/// otherwise uses it's existing copy
|
||||
/// </summary>
|
||||
public static void UpdateTestSetupListIfStale()
|
||||
{
|
||||
if (DateTime.Now.Subtract(_lastUpdateTime).TotalMinutes > MIN_TESTS_UPDATEINTERVAL_MINUTES)
|
||||
{
|
||||
UpdateTestSetupList();
|
||||
}
|
||||
else if (GetCRC() != _crc)
|
||||
{
|
||||
UpdateTestSetupList();
|
||||
}
|
||||
}
|
||||
public static void UpdateTestSetupList(TestTemplate test)
|
||||
{
|
||||
|
||||
//fixes an error when cmdline import and servicelocator is null
|
||||
IEventAggregator eventAggregator = null;
|
||||
try
|
||||
{
|
||||
eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (test.IsDirty)
|
||||
{
|
||||
if (!test.IsComplete)
|
||||
{
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
if (TestSetupList.Contains(test.Name))
|
||||
{
|
||||
_testSetupList.Remove(test.Name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!test.IsComplete) { return; }
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
if (!TestSetupList.Contains(test.Name))
|
||||
{
|
||||
_testSetupList.Add(test.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateTestSetupList(Action onCompleteAction = null)
|
||||
{
|
||||
var allTemplates = TestTemplateList.TestTemplatesList.AllTemplates;
|
||||
var testSetupList = new List<string>();
|
||||
var count = allTemplates.Length;
|
||||
var currentItem = 0;
|
||||
|
||||
//fixes an error when cmdline import and servicelocator is null
|
||||
IEventAggregator eventAggregator = null;
|
||||
try
|
||||
{
|
||||
if (Application.Current.Dispatcher.CheckAccess())
|
||||
{
|
||||
eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
eventAggregator?.GetEvent<ProgressBarEvent>().Publish(new ProgressBarEventArg()
|
||||
{ ProgressBarPercentage = 0D, SetPercentage = true });
|
||||
bool bCache = false;
|
||||
foreach (var t in allTemplates)
|
||||
{
|
||||
eventAggregator?.GetEvent<ProgressBarEvent>().Publish(new ProgressBarEventArg()
|
||||
{ SetPercentage = true, ProgressBarPercentage = 100D * currentItem / count });
|
||||
currentItem++;
|
||||
|
||||
//calculating iscomplete is expensive on a large test setup list with lots of sensors
|
||||
//for now just calculate on demand and put all tests in the list
|
||||
testSetupList.Add(t.Name);
|
||||
}
|
||||
eventAggregator?.GetEvent<ProgressBarEvent>().Publish(new ProgressBarEventArg()
|
||||
{ SetPercentage = true, ProgressBarPercentage = 100D });
|
||||
|
||||
var crc = GetCRC();
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
_lastUpdateTime = DateTime.Now;
|
||||
_testSetupList = testSetupList;
|
||||
_actualTestTemplates = new List<TestTemplate>(1000);
|
||||
_actualTestTemplates.AddRange(allTemplates);
|
||||
_crc = crc;
|
||||
}
|
||||
onCompleteAction?.Invoke();
|
||||
}
|
||||
public static string[] TestSetupList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
if (null != _testSetupList && _testSetupList.Any())
|
||||
{
|
||||
return _testSetupList.ToArray();
|
||||
}
|
||||
}
|
||||
var allTemplates = TestTemplateList.TestTemplatesList.AllTemplates;
|
||||
|
||||
lock (TestSetupListLock)
|
||||
{
|
||||
_lastUpdateTime = DateTime.Now;
|
||||
_testSetupList = new List<string>();
|
||||
_actualTestTemplates = new List<TestTemplate>();
|
||||
_actualTestTemplates.AddRange(allTemplates);
|
||||
var total = allTemplates.Length;
|
||||
int currentDone = 0;
|
||||
|
||||
var eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
||||
|
||||
foreach (var t in allTemplates)
|
||||
{
|
||||
eventAggregator.GetEvent<ProgressBarEvent>().Publish(new ProgressBarEventArg()
|
||||
{ SetPercentage = true, ProgressBarPercentage = 100D * currentDone / total });
|
||||
currentDone++;
|
||||
if (!t.IsComplete) { continue; }
|
||||
_testSetupList.Add(t.Name);
|
||||
}
|
||||
eventAggregator.GetEvent<ProgressBarEvent>().Publish(new ProgressBarEventArg()
|
||||
{ SetPercentage = true, ProgressBarPercentage = 100D });
|
||||
_crc = GetCRC();
|
||||
return _testSetupList.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static uint GetCRC()
|
||||
{
|
||||
var list = new List<byte>();
|
||||
|
||||
using (var cmd = Storage.DbOperations.GetSQLCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = System.Data.CommandType.Text;
|
||||
cmd.CommandText = "SELECT [TestSetupName], [Dirty], [Complete], [LastModified] FROM [TestSetups]";
|
||||
var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
var name = (string)reader["TestSetupName"];
|
||||
list.AddRange(System.Text.Encoding.ASCII.GetBytes(name));
|
||||
var isDirty = (bool)reader["Dirty"];
|
||||
list.AddRange(BitConverter.GetBytes(isDirty));
|
||||
var complete = (bool)reader["Complete"];
|
||||
list.AddRange(BitConverter.GetBytes(complete));
|
||||
var lastModified = (DateTime)reader["LastModified"];
|
||||
list.AddRange(BitConverter.GetBytes(lastModified.ToBinary()));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
var crc = new DTS.Utilities.Crc32();
|
||||
return crc.Get(list);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using DTS.Common.Enums.TSRAIRGo;
|
||||
using DTS.Common.DataModel.Classes.TSRAIRGo;
|
||||
|
||||
namespace DTS.Common.DataModel.Common
|
||||
{
|
||||
public class StatusHelpers
|
||||
{
|
||||
public delegate void SetProgressValueDelegate(IDASCommunication idas, double progressValue, TSRAIRGoStatus.StatusTypes? status);
|
||||
public static void SetStatus2(IDASCommunication das, int progressValue, TSRAIRGoStatus.StatusTypes? status, SetProgressValueDelegate setProgressValue)
|
||||
{
|
||||
setProgressValue(das, progressValue, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,452 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.DASLib.DASFactory;
|
||||
using DTS.DASLib.Service;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using DTS.Common.Enums.DASFactory;
|
||||
using DTS.Common.DataModel;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class DASFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// starts the auto discovery process if it's not running yet
|
||||
/// </summary>
|
||||
public void StartMulticastAutoDiscovery()
|
||||
{
|
||||
_dasFactory.StartMulticastAutoDiscovery();
|
||||
}
|
||||
/// <summary>
|
||||
/// stops the auto discovery process if it is running
|
||||
/// </summary>
|
||||
public void StopMulticastAutoDiscovery()
|
||||
{
|
||||
_dasFactory.StopMulticastAutoDiscovery();
|
||||
}
|
||||
/// <summary>
|
||||
/// returns any discovered devices
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IDiscoveredDevice [] GetDiscoveredDevices()
|
||||
{
|
||||
return _dasFactory.GetDiscoveredDevices();
|
||||
}
|
||||
private DTS.DASLib.DASFactory.DASFactory _dasFactory;
|
||||
public IDASFactory GetDASFactory() { return _dasFactory; }
|
||||
public DASFactory()
|
||||
{
|
||||
//10285 Unhandled exception during diagnostics.
|
||||
//this initializes the interval value used in CheckUnitsAvailable to make the sleep time configurable.
|
||||
DTS.DASLib.Service.ServiceBase.InitializeCheckUnitsInterval(DataModelSettings.CheckUnitsIntervalMillisecond);
|
||||
//10843 TDAS communication needs to be throttled
|
||||
//this initializes the throttling of TDAS devices
|
||||
DTS.DASLib.Command.TDAS.CommandBase.InitializeSemaphore(
|
||||
DataModelSettings.SemaphoreDelay,
|
||||
DataModelSettings.SemaphoreSpots);
|
||||
//initialize SLICESemaphore before any communication starts
|
||||
//10852 Add semaphore to SLICE communication to improve SLICE 6 multiple IP performance
|
||||
DTS.DASLib.Command.SliceCommandBase.Initialize(DataModelSettings.SLICEConcurrentSpots,
|
||||
DataModelSettings.SLICEConcurrentDelayMs);
|
||||
_dasFactory = new DTS.DASLib.DASFactory.DASFactory(false, false);
|
||||
_dasFactory.DetachAllDevices();
|
||||
var mre = new ManualResetEvent(false);
|
||||
_dasFactory.Refresh(delegate { mre.Set(); });
|
||||
mre.WaitOne();
|
||||
_dasFactory.MultiCastAutoDiscoveryDefaultTimeoutMS = DataModelSettings.MulticastAutoDiscoveryReceiveTimeoutMS;
|
||||
|
||||
//16053 Implement KeepAliveSeconds and KeepAliveRetrySeconds in the .config file
|
||||
DFConstantsAndEnums.LocalKeepAliveRetryIntervalMS = DataModelSettings.LocalKeepAliveRetryIntervalMS;
|
||||
DFConstantsAndEnums.LocalKeepAliveTimeOutMS = DataModelSettings.LocalKeepAliveTimeOutMS;
|
||||
DFConstantsAndEnums.RemoteKeepAliveRetryIntervalSeconds = DataModelSettings.RemoteKeepAliveRetryIntervalSeconds;
|
||||
DFConstantsAndEnums.RemoteKeepAliveSeconds = DataModelSettings.RemoteKeepAliveSeconds;
|
||||
|
||||
DFConstantsAndEnums.ReceiveBufferSizeBytes = DataModelSettings.ReceiveBufferSizeBytes;
|
||||
DFConstantsAndEnums.SendBufferSizeBytes = DataModelSettings.SendBufferSizeBytes;
|
||||
|
||||
DFConstantsAndEnums.HeartbeatAsyncConnectTimeoutMS = DataModelSettings.HeartbeatAsyncConnectTimeoutMS;
|
||||
|
||||
_dasFactory.DeviceArrived += _dasFactory_DeviceArrived;
|
||||
_dasFactory.DeviceFailed += _dasFactory_DeviceFailed;
|
||||
_dasFactory.DeviceRemoved += _dasFactory_DeviceRemoved;
|
||||
}
|
||||
|
||||
public event DASFactoryEventHandler OnDeviceArrived;
|
||||
public event DASFactoryEventHandler OnFactoryChanged;
|
||||
|
||||
public void TakeOwnership()
|
||||
{
|
||||
try
|
||||
{
|
||||
_dasFactory.TakeOwnership();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void _dasFactory_DeviceRemoved(object sender, DASFactoryEventArgs e)
|
||||
{
|
||||
OnFactoryChanged?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
|
||||
private void _dasFactory_DeviceFailed(object sender, DASFactoryEventArgs e)
|
||||
{
|
||||
OnFactoryChanged?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
private void _dasFactory_DeviceArrived(object sender, DASFactoryEventArgs e)
|
||||
{
|
||||
OnDeviceArrived?.Invoke(sender, e);
|
||||
OnFactoryChanged?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
public void DetachAllDevices(bool detachUSB = false)
|
||||
{
|
||||
// FB14290: make USB detaching conditional
|
||||
_dasFactory.DetachAllDevices(detachUSB);
|
||||
}
|
||||
|
||||
public void DisposeFactory()
|
||||
{
|
||||
_dasFactory.Dispose();
|
||||
_dasFactory = null;
|
||||
}
|
||||
//#define LOG_DEBUG_REFRESH
|
||||
public string[] TDASHostNames
|
||||
{
|
||||
get { return _dasFactory.TDASHostNames; }
|
||||
set
|
||||
{
|
||||
if (_bInRefresh)
|
||||
{
|
||||
#if LOG_DEBUG_REFRESH
|
||||
var st = new StackTrace(true);
|
||||
APILogger.Log("TDASHostNames SET WHILE WE ARE IN REFRESH\n", st.ToString());
|
||||
#endif
|
||||
}
|
||||
if (null == value || null == _dasFactory.TDASHostNames)
|
||||
{
|
||||
_dasFactory.TDASHostNames = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
var val = value.Distinct().OrderBy(a => a);
|
||||
// this has side effects, so only change if needed
|
||||
var isEqual = _dasFactory.TDASHostNames.OrderBy(a => a).SequenceEqual(val);
|
||||
if (!isEqual)
|
||||
{
|
||||
_dasFactory.TDASHostNames = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string[] SPFDHostNames
|
||||
{
|
||||
get => _dasFactory.SPFDHostNames;
|
||||
set
|
||||
{
|
||||
if (null == value || null == _dasFactory.SPFDHostNames)
|
||||
{
|
||||
_dasFactory.SPFDHostNames = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
var val = value.Distinct().OrderBy(a => a);
|
||||
// this has side effects, so only change if needed
|
||||
var isEqual = _dasFactory.SPFDHostNames.OrderBy(a => a).SequenceEqual(val);
|
||||
if (!isEqual)
|
||||
{
|
||||
_dasFactory.SPFDHostNames = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// http://fogbugz/fogbugz/default.asp?2903
|
||||
/// could also be called SliceDbHostNames
|
||||
/// </summary>
|
||||
public string[] SDBHostNames
|
||||
{
|
||||
get { return _dasFactory.SliceDBHostNames; }
|
||||
set
|
||||
{
|
||||
if (_bInRefresh)
|
||||
{
|
||||
#if LOG_DEBUG_REFRESH
|
||||
var st = new StackTrace(true);
|
||||
APILogger.Log("SDBHostNames SET WHILE WE ARE IN REFRESH\n", st.ToString());
|
||||
#endif
|
||||
}
|
||||
if (null == value || null == _dasFactory.SliceDBHostNames)
|
||||
{
|
||||
_dasFactory.SliceDBHostNames = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this has side effects, so only change if needed
|
||||
var equals = _dasFactory.SliceDBHostNames.OrderBy(a => a).SequenceEqual(value.OrderBy(a => a));
|
||||
if (false == equals)
|
||||
{
|
||||
_dasFactory.SliceDBHostNames = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public SortableBindingList<IDiscoveredDevice> AutoDiscoverMulticast()
|
||||
{
|
||||
CancellationToken ct = new CancellationToken();
|
||||
return _dasFactory.AutoDiscoverMulticast(ct);
|
||||
}
|
||||
public delegate void DiscoveredDASEventHandler(object sender, IEnumerable<IDiscoveredDevice> newDevices);
|
||||
public event DiscoveredDASEventHandler DiscoveredDAS;
|
||||
public void DiscoveryThread(DFConstantsAndEnums.MultiCastDeviceClasses[] deviceFilter, CancellationToken ct, bool discoverParents = true)
|
||||
{
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
var discoveries = _dasFactory.AutoDiscoverMulticast(ct, discoverParents).ToList();
|
||||
var filteredDiscoveries = deviceFilter?.Count() > 0 ? discoveries.Where(idd => deviceFilter.Contains(idd.DevClass)).ToList() : discoveries;
|
||||
|
||||
DiscoveredDAS.Invoke(this, filteredDiscoveries);
|
||||
|
||||
ct.WaitHandle.WaitOne(1000);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// starts qats listening
|
||||
/// </summary>
|
||||
public void StartQATSListening()
|
||||
{
|
||||
_dasFactory.StartQATSListening();
|
||||
}
|
||||
/// <summary>
|
||||
/// stops any QATS listening
|
||||
/// </summary>
|
||||
public void StopQATSListening()
|
||||
{
|
||||
_dasFactory.StopQATSListening();
|
||||
}
|
||||
/// <summary>
|
||||
/// sends the request to send UDP QATS messages
|
||||
/// </summary>
|
||||
public void SendQATSRequest()
|
||||
{
|
||||
_dasFactory.SendQATSRequest();
|
||||
}
|
||||
/// <summary>
|
||||
/// returns any QueryArmTriggerStatus that are waiting and clears the list of waiting QATS
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IUDPQATSEntry[] GetQATS()
|
||||
{
|
||||
return _dasFactory.GetQATS();
|
||||
}
|
||||
/// <summary>
|
||||
/// configures the default timeout for multicast autodiscovery receive timeout
|
||||
/// in ms
|
||||
/// </summary>
|
||||
public int MulticastAutoDiscoveryReceiveTimeoutMS
|
||||
{
|
||||
get => _dasFactory.MultiCastAutoDiscoveryDefaultTimeoutMS;
|
||||
set => _dasFactory.MultiCastAutoDiscoveryDefaultTimeoutMS = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// configures the trasmit address for multicast autodiscovery
|
||||
/// in ms
|
||||
/// </summary>
|
||||
public string MulticastAutoDiscoveryAddress
|
||||
{
|
||||
get => _dasFactory.MulticastAutoDiscoveryAddress;
|
||||
set => _dasFactory.MulticastAutoDiscoveryAddress = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// configures the trasmit port for multicast autodiscovery
|
||||
/// in ms
|
||||
/// </summary>
|
||||
public int MulticastAutoDiscoveryPort
|
||||
{
|
||||
get => _dasFactory.MulticastAutoDiscoveryPort;
|
||||
set => _dasFactory.MulticastAutoDiscoveryPort = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// configures the receive port for multicast autodiscovery
|
||||
/// in ms
|
||||
/// </summary>
|
||||
public int MulticastAutoDiscoveryResponsePort
|
||||
{
|
||||
get => _dasFactory.MulticastAutoDiscoveryResponsePort;
|
||||
set => _dasFactory.MulticastAutoDiscoveryResponsePort = value;
|
||||
}
|
||||
|
||||
public double S6ConnectNewTimeout
|
||||
{
|
||||
get => _dasFactory.S6ConnectNewTimeout;
|
||||
set => _dasFactory.S6ConnectNewTimeout = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// I noticed in some logs - only one refresh at a time
|
||||
/// refresh is getting called multiple times for some reason.
|
||||
/// This gets a bit sticky, there's no reason for Refresh to be called more than once while refresh is still running,
|
||||
/// however one of the options for refresh is to not wait for it to finish, which means you could get into this situation.
|
||||
/// I haven't been able to duplicate this problem myself, so I'm going to add some logging to help find out how we got there if we
|
||||
/// get there again, and also some code to address when we do find ourselves there
|
||||
///
|
||||
/// </summary>
|
||||
private volatile bool _bInRefresh;
|
||||
|
||||
public void Refresh(bool wait)
|
||||
{
|
||||
|
||||
APILogger.Log(APILogger.GetCurrentMethod());
|
||||
if (_bInRefresh)
|
||||
{
|
||||
#if LOG_DEBUG_REFRESH
|
||||
var st = new StackTrace(true);
|
||||
APILogger.Log(string.Format("Warning - OVERLAPPING REFRESH CALL!\nStackTrace:\n{0}", st));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
var mre = new ManualResetEvent(false);
|
||||
try
|
||||
{
|
||||
_bInRefresh = true;
|
||||
_dasFactory.Refresh(delegate
|
||||
{
|
||||
mre.Set();
|
||||
_bInRefresh = false;
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Exception refreshing ", ex.Message);
|
||||
return;
|
||||
}
|
||||
if (wait)
|
||||
{
|
||||
mre.WaitOne();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<IDASCommunication> GetActiveDevices()
|
||||
{
|
||||
return _dasFactory.GetDASList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 14157 Refresh/Stability Issue in Data Acquisition Tile
|
||||
/// returns the list of all devices known connectable via ECM/SDB/S6DB
|
||||
/// these distributors have a HELLO SLICEBASE x.x.x.x:yyyy format, so
|
||||
/// we keep track of what the db told us
|
||||
/// this returns all the reported connections
|
||||
/// </summary>
|
||||
public string[] GetReportedConnections()
|
||||
{
|
||||
return _dasFactory.GetConnectedDevices();
|
||||
}
|
||||
/// <summary>
|
||||
/// runs auto discovery if needed, populating the downstream mac addresses for all attached SLICE6/SLICE6Db devices
|
||||
/// completes immediately if there are no attached SLICE6/SLICE6Db devices
|
||||
/// </summary>
|
||||
public void AutoDiscoverIfNecessary()
|
||||
{
|
||||
var foundDas = ApplicationProperties.DASFactory.GetActiveDevices();
|
||||
var bNeedToRun = foundDas.OfType<EthernetSlice6DB>().Any();
|
||||
if (!bNeedToRun) return;
|
||||
var ipAddressToIdas = new Dictionary<string, IDASCommunication>();
|
||||
foreach (var das in foundDas)
|
||||
{
|
||||
var h = new DASHardware(das);
|
||||
var connection = h.ConnectionUSBAware.ToLower();
|
||||
if (connection.Contains("usb"))
|
||||
{
|
||||
connection = h.SerialNumber;
|
||||
}
|
||||
ipAddressToIdas[connection] = das;
|
||||
}
|
||||
try
|
||||
{
|
||||
var units = ApplicationProperties.DASFactory.AutoDiscoverMulticast();
|
||||
var macAddresToDevice = new Dictionary<string, IDiscoveredDevice>();
|
||||
foreach (var unit in units)
|
||||
{
|
||||
var mac = unit.Mac.Replace('-', ':').ToUpper();
|
||||
macAddresToDevice[mac] = unit;
|
||||
}
|
||||
foreach (var unit in units)
|
||||
{
|
||||
if (!ipAddressToIdas.ContainsKey(unit.Ip))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ipAddressToIdas[unit.Ip].MACAddress = unit.Mac;
|
||||
ipAddressToIdas[unit.Ip].DownstreamMACAddresses = (from c in unit.Connections
|
||||
select c.MACAddress.Replace('-', ':').ToUpper()
|
||||
into childMac
|
||||
where macAddresToDevice.ContainsKey(childMac)
|
||||
select macAddresToDevice[childMac]
|
||||
into childDevice
|
||||
select childDevice.Mac).ToArray();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// returns true if the DAS is streaming
|
||||
/// </summary>
|
||||
/// <param name="das"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsStreaming(IDASCommunication das)
|
||||
{
|
||||
if (!(das is EthernetSlice6Air)) { return false; }
|
||||
|
||||
if (null == das.DASArmStatus)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//15932 Error when performing test when S6A is streaming
|
||||
//don't currently know of a better way to determine if the unit is streaming or not
|
||||
//when attaching to a stream device some attributes can't be read and because of timing
|
||||
//some status may not be populated, but if we aren't armed or in realtime and we are a S6A and
|
||||
//we responded with Invalid mode during setup, we are _probably_ streaming
|
||||
return !das.DASArmStatus.IsArmed && !das.DASArmStatus.IsInRealtime &&
|
||||
das.DASArmStatus.ReceivedInvalidModeDuringSetup;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns true if the unit is in realtime
|
||||
/// uses DASArmStatus, but this isn't always populated on time, so if the unit is streaming it will also
|
||||
/// return true, which seems to be consistent with what was intended in the old code
|
||||
/// 15932 Error when performing test when S6A is streaming
|
||||
/// </summary>
|
||||
/// <param name="das"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsInRealtime(IDASCommunication das)
|
||||
{
|
||||
if (null == das.DASArmStatus) { return false; }
|
||||
return das.DASArmStatus.IsInRealtime || IsStreaming(das);
|
||||
}
|
||||
/// <summary>
|
||||
/// returns true if any of the units in the input parameters are in realtime or are streaming
|
||||
/// </summary>
|
||||
/// <param name="das"></param>
|
||||
/// <returns></returns>
|
||||
public static bool AnyInRealtime(List<IDASCommunication> das)
|
||||
{
|
||||
return das.Exists(unit => IsInRealtime(unit));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <summary>
|
||||
/// GUI wrapper for template channels ... it contains a testobjecttemplatechannel
|
||||
/// </summary>
|
||||
public class TemplateChannelUI : BasePropertyChanged
|
||||
{
|
||||
private DTS.Common.ISO.TestObjectTemplateChannel _channel;
|
||||
public DTS.Common.ISO.TestObjectTemplateChannel Channel
|
||||
{
|
||||
get => _channel;
|
||||
set => SetProperty(ref _channel, value, "Channel");
|
||||
}
|
||||
|
||||
public TemplateChannelUI(DTS.Common.ISO.TestObjectTemplateChannel channel)
|
||||
{
|
||||
_channel = channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using DTS.Common.Classes.Hardware;
|
||||
using DTS.Common.Classes.TestSetups;
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
using DataPROWin7.Common;
|
||||
|
||||
namespace DTS.Common.DataModel.Common.DbWrappers
|
||||
{
|
||||
public class TestSetupHardwareGet : TestSetupHardwareRecord
|
||||
{
|
||||
public TestSetupHardwareGet() { }
|
||||
public TestSetupHardwareGet(ITestSetupHardwareRecord copy) : base(copy) { }
|
||||
public bool AddOrRemove
|
||||
{
|
||||
get => AddDAS;
|
||||
set
|
||||
{
|
||||
AddDAS = value;
|
||||
OnPropertyChanged("AddOrRemove");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This ensures that any bad data in the database can be repaired in one place.
|
||||
/// FB 17777
|
||||
/// </summary>
|
||||
/// <param name="testSetupId"></param>
|
||||
/// <param name="hardwareLookup"></param>
|
||||
/// <returns></returns>
|
||||
public List<TestSetupHardwareGet> TestSetupHardwareGet_Wrapper(int? testSetupId, Dictionary<int, IDASHardware> hardwareLookup)
|
||||
{
|
||||
var testSetupHardwareGetList = new List<TestSetupHardwareGet>();
|
||||
|
||||
var hr = DbOperations.TestSetupHardwareGet(testSetupId, out var records);
|
||||
if (0 == hr && null != records && records.Any())
|
||||
{
|
||||
foreach (var record in records)
|
||||
{
|
||||
var testSetupHardwareGet = new TestSetupHardwareGet(record);
|
||||
if (record.AntiAliasFilterRate == 0 && null != hardwareLookup)
|
||||
{
|
||||
var dasTypeEnum = hardwareLookup[record.DASId].DASTypeEnum;
|
||||
testSetupHardwareGet.AntiAliasFilterRate = RepairAntiAliasFilterRate(dasTypeEnum, record.SamplesPerSecond);
|
||||
}
|
||||
testSetupHardwareGetList.Add(testSetupHardwareGet);
|
||||
}
|
||||
}
|
||||
|
||||
//Now make sure we don't return any 0s in AntiAliasFilterRate (hardwareLookup may have been passed in as null)
|
||||
foreach (var testSetupHardwareGet in testSetupHardwareGetList)
|
||||
{
|
||||
if (testSetupHardwareGet.AntiAliasFilterRate == 0)
|
||||
{
|
||||
var dasTypeEnum = GetDASTypeEnumFromId(testSetupHardwareGet.DASId);
|
||||
testSetupHardwareGet.AntiAliasFilterRate = RepairAntiAliasFilterRate(dasTypeEnum, testSetupHardwareGet.SamplesPerSecond);
|
||||
}
|
||||
}
|
||||
|
||||
return testSetupHardwareGetList;
|
||||
}
|
||||
private HardwareTypes GetDASTypeEnumFromId(int dasId)
|
||||
{
|
||||
var dasGet = new DASGet();
|
||||
var dasGetList = dasGet.DASGet_Wrapper();
|
||||
foreach (var das in dasGetList)
|
||||
{
|
||||
if (das.DASId == dasId)
|
||||
{
|
||||
var dasTemp = new DTS.Common.ISO.Hardware();
|
||||
//Get of DASTypeEnum returns the enum: (HardwareTypes)DASType
|
||||
dasTemp.DASType = das.Type;
|
||||
return dasTemp.DASTypeEnum;
|
||||
}
|
||||
}
|
||||
return HardwareTypes.UNDEFINED;
|
||||
}
|
||||
private int RepairAntiAliasFilterRate(HardwareTypes dasTypeEnum, int samplesPerSecond)
|
||||
{
|
||||
int antiAliasFilterRate = 0;
|
||||
|
||||
switch (dasTypeEnum)
|
||||
{
|
||||
case HardwareTypes.DIM:
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
case HardwareTypes.G5VDS:
|
||||
case HardwareTypes.SIM:
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
case HardwareTypes.TOM:
|
||||
//TDAS allows 0, so don't do the repair
|
||||
//antiAliasFilterRate = Convert.ToInt32(SerializedSettings.GetAAFException(SerializableAAF.DAS_TYPE.TDAS, samplesPerSecond));
|
||||
break;
|
||||
default:
|
||||
antiAliasFilterRate = Convert.ToInt32(SerializedSettings.GetAAFException(SerializableAAF.DAS_TYPE.SLICE, samplesPerSecond));
|
||||
break;
|
||||
}
|
||||
|
||||
return antiAliasFilterRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class TestEngineerDetails : BasePropertyChanged
|
||||
{
|
||||
|
||||
private bool _blank = true;
|
||||
public bool IsBlank() { return _blank; }
|
||||
|
||||
private DTS.Common.ISO.TestEngineerDetails _testEngineerDetails;
|
||||
public enum Fields
|
||||
{
|
||||
Name,
|
||||
TestEngineerName,
|
||||
TestEngineerPhone,
|
||||
TestEngineerFax,
|
||||
TestEngineerEmail
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _testEngineerDetails.Name;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.Name = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.Name.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerName
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerName;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerName = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerName.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerPhone
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerPhone;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerPhone = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerPhone.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerFax
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerFax;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerFax = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerFax.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerEmail
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerEmail;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerEmail = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerEmail.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public bool LocalOnly => _testEngineerDetails.LocalOnly;
|
||||
|
||||
public DateTime LastModified => _testEngineerDetails.LastModified;
|
||||
|
||||
public string LastModifiedBy => _testEngineerDetails.LastModifiedBy;
|
||||
|
||||
public int Version => _testEngineerDetails.Version;
|
||||
|
||||
public TestEngineerDetails()
|
||||
{
|
||||
_testEngineerDetails = new DTS.Common.ISO.TestEngineerDetails();
|
||||
_testEngineerDetails.Name = StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
|
||||
public bool HasBlankName()
|
||||
{
|
||||
return _testEngineerDetails.Name == StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public TestEngineerDetails(DTS.Common.ISO.TestEngineerDetails testEngineerDetails)
|
||||
{
|
||||
_blank = false;
|
||||
_testEngineerDetails = new DTS.Common.ISO.TestEngineerDetails(testEngineerDetails);
|
||||
}
|
||||
public DTS.Common.ISO.TestEngineerDetails GetISOTestEngineer()
|
||||
{
|
||||
return _testEngineerDetails;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class TestEngineerDetailsList : BasePropertyChanged
|
||||
{
|
||||
public enum Tags
|
||||
{
|
||||
TestEngineers
|
||||
|
||||
}
|
||||
protected TestEngineerDetailsList()
|
||||
{
|
||||
}
|
||||
|
||||
private static TestEngineerDetailsList _testEngineerList = new TestEngineerDetailsList();
|
||||
public static TestEngineerDetailsList TestEngineerList => _testEngineerList;
|
||||
public void Delete(TestEngineerDetails testEngineer)
|
||||
{
|
||||
testEngineer.GetISOTestEngineer().Delete(ApplicationProperties.CurrentUser.UserName);
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
_testEngineers.Remove(testEngineer.Name);
|
||||
}
|
||||
OnPropertyChanged(Tags.TestEngineers.ToString());
|
||||
}
|
||||
public void Delete(TestEngineerDetails[] testEngineers)
|
||||
{
|
||||
foreach (var testEngineer in testEngineers)
|
||||
{
|
||||
Delete(testEngineer);
|
||||
}
|
||||
}
|
||||
private static readonly object _testEngineerLock = new object();
|
||||
private Dictionary<string, TestEngineerDetails> _testEngineers = null;
|
||||
public TestEngineerDetails[] TestEngineers
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
if (null == _testEngineers || _testEngineers.Count == 0)
|
||||
{
|
||||
PopulateEngineers();
|
||||
}
|
||||
}
|
||||
List<TestEngineerDetails> testEngineers = new List<TestEngineerDetails>(_testEngineers.Values);
|
||||
testEngineers.Sort(new Comparison<TestEngineerDetails>(CompareTestEngineers));
|
||||
return testEngineers.ToArray();
|
||||
}
|
||||
}
|
||||
private void PopulateEngineers()
|
||||
{
|
||||
_testEngineers = new Dictionary<string, TestEngineerDetails>();
|
||||
foreach (var t in GetAllTestEngineers())
|
||||
{
|
||||
if (!_testEngineers.ContainsKey(t.Name)) { _testEngineers.Add(t.Name, t); }
|
||||
}
|
||||
}
|
||||
public void ReloadAll()
|
||||
{
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
PopulateEngineers();
|
||||
}
|
||||
}
|
||||
public void DeleteAll()
|
||||
{
|
||||
_testEngineers = null;
|
||||
DTS.Common.ISO.TestEngineerDetails.DeleteAllTestEngineerDetails();
|
||||
}
|
||||
private int CompareTestEngineers(TestEngineerDetails a, TestEngineerDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
if (null == b) { return 1; }
|
||||
return a.Name.CompareTo(b.Name);
|
||||
}
|
||||
|
||||
public static TestEngineerDetails[] GetAllTestEngineers()
|
||||
{
|
||||
var list = new List<TestEngineerDetails>();
|
||||
if (RunTestVariables.InRunTest &&
|
||||
TestTemplateList.TestTemplatesList.CachedTestEngineerDetails != null &&
|
||||
TestTemplateList.TestTemplatesList.CachedTestEngineerDetails.Count > 0)
|
||||
{
|
||||
DbOperations.LogDBCaching("****** Using cached Laboratory Details in GetAllTestEngineers");
|
||||
var isoTestEngineersList = new List<DTS.Common.ISO.TestEngineerDetails>();
|
||||
foreach (var te in TestTemplateList.TestTemplatesList.CachedTestEngineerDetails)
|
||||
{
|
||||
var isoTestEngineerDetails = new DTS.Common.ISO.TestEngineerDetails()
|
||||
{
|
||||
Name = te.Value.Name,
|
||||
TestEngineerName = te.Value.TestEngineerName,
|
||||
TestEngineerPhone = te.Value.TestEngineerPhone,
|
||||
TestEngineerEmail = te.Value.TestEngineerEmail,
|
||||
TestEngineerFax = te.Value.TestEngineerFax
|
||||
};
|
||||
|
||||
isoTestEngineersList.Add(isoTestEngineerDetails);
|
||||
}
|
||||
list = isoTestEngineersList.Select(isote => new TestEngineerDetails(isote)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var ts in DTS.Common.ISO.TestEngineerDetails.GetAllTestEngineerDetails())
|
||||
{
|
||||
list.Add(new TestEngineerDetails(ts));
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public TestEngineerDetails GetTestEngineerDetail(string name)
|
||||
{
|
||||
var testEngineers = from t in TestEngineers.AsParallel() where t.Name == name select t;
|
||||
if (null != testEngineers && testEngineers.Any()) { return testEngineers.First(); }
|
||||
else { return null; }
|
||||
}
|
||||
|
||||
public void AddTestEngineer(TestEngineerDetails testEngineer)
|
||||
{
|
||||
testEngineer.GetISOTestEngineer().Commit(ApplicationProperties.CurrentUser.UserName);
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
//force _testEngineers to not be null...
|
||||
var length = TestEngineers.Length;
|
||||
if (!_testEngineers.ContainsKey(testEngineer.Name)) { _testEngineers.Add(testEngineer.Name, testEngineer); }
|
||||
else { _testEngineers[testEngineer.Name] = testEngineer; }
|
||||
}
|
||||
OnPropertyChanged(Tags.TestEngineers.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DataPROWin7.Common;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.ISO;
|
||||
using DTS.Common.DataModel;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <summary>
|
||||
/// list that holds groups
|
||||
/// </summary>
|
||||
public class TestObjectList : BasePropertyChanged
|
||||
{
|
||||
#region Tags and Constants
|
||||
public enum Tags
|
||||
{
|
||||
TestObjects
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
private static readonly object MyLock = new object();
|
||||
private static TestObjectList _testObjectList;
|
||||
|
||||
public static TestObjectList TestObjectsList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (null == _testObjectList)
|
||||
{
|
||||
_testObjectList = new TestObjectList();
|
||||
}
|
||||
}
|
||||
return _testObjectList;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// adds a group
|
||||
/// will notify listeners if bNotify is true
|
||||
/// you would not want to notify listeners if you are in a bulk
|
||||
/// operation and intend to refresh everyone when done
|
||||
/// </summary>
|
||||
/// <param name="to"></param>
|
||||
/// <param name="bNotify"></param>
|
||||
public void Add(TestObject to, bool bNotify)
|
||||
{
|
||||
to.LastModifiedBy = ApplicationProperties.CurrentUser.UserName;
|
||||
to.SetLastModified(DateTime.Now);
|
||||
to.Commit();
|
||||
if (bNotify)
|
||||
{
|
||||
OnPropertyChanged("TestObjects");
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAll()
|
||||
{
|
||||
OnPropertyChanged("TestObjects");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected TestObjectList()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DTS.Common.DataModel
|
||||
{
|
||||
public static class DataModelSettings
|
||||
{
|
||||
public static bool UseISOCodeForDiadem200 { get; set; } = false;
|
||||
public static byte SampleRateAAFilterRatio { get; set; } = 5;
|
||||
public static string SupportedSquibFireModes { get; set; } = "CAP,CONSTANT";
|
||||
public static bool ShowCompactHardware { get; set; } = true;
|
||||
public static double AllowedVoltageInsertionErrorPercent { get; set; } = 1;
|
||||
public static double AllowedExcitationErrorPercent { get; set; } = 2;
|
||||
public static double AllowedShuntErrorPercent { get; set; } = 5;
|
||||
public static double ShuntToleranceHighOhmPercent { get; set; } = 10;
|
||||
public static double AllowedGainErrorPercent { get; set; } = 2;
|
||||
public static double AllowedGainErrorPercent_SLICE6andSLICE6A { get; set; } = 5;
|
||||
public static double AutoZeroPercentDeviationAllowed { get; set; } = 5;
|
||||
public static double ShuntToleranceHighOhmResistance { get; set; } = 4000;
|
||||
public static string DownloadFolder { get; set; } = "..\\..\\Data";
|
||||
public static bool RequireXCrashCompatibilityForISOExports { get; set; } = true;
|
||||
public static bool DisplayDuplicateUDPStreamOutWarning { get; set; } = true;
|
||||
public static bool SLICETurnOffAAFRealtime { get; set; } = true;
|
||||
public static bool UseTestChannelOrder { get; set; } = false;
|
||||
public static byte RealtimeSampleRateAAFilterRatio { get; set; } = 1;
|
||||
public static bool ArmChecklistRequiredIfTOM { get; set; } = true;
|
||||
public static bool TestsRequireLevelTriggers { get; set; } = false;
|
||||
public static int CheckUnitsIntervalMillisecond { get; set; } = 50;
|
||||
public static double SemaphoreDelay { get; set; } = 10;
|
||||
public static int SemaphoreSpots { get; set; } = 3;
|
||||
public static int SLICEConcurrentSpots { get; set; } = 999;
|
||||
public static int SLICEConcurrentDelayMs { get; set; } = 0;
|
||||
public static int MulticastAutoDiscoveryReceiveTimeoutMS { get; set; } = 1500;
|
||||
public static uint LocalKeepAliveRetryIntervalMS { get; set; } = 1000;
|
||||
public static uint LocalKeepAliveTimeOutMS { get; set; } = 5000;
|
||||
public static uint RemoteKeepAliveRetryIntervalSeconds { get; set; } = 5;
|
||||
public static uint RemoteKeepAliveSeconds { get; set; } = 60;
|
||||
public static int ReceiveBufferSizeBytes { get; set; } = 65536;
|
||||
public static int SendBufferSizeBytes { get; set; } = 65536;
|
||||
public static int HeartbeatAsyncConnectTimeoutMS { get; set; } = 10000;
|
||||
public static string DefaultTDCSensorDatabaseFolder { get; set; } = "..\\SensorDatabase";
|
||||
public static string DefaultTDCSensorDatabaseFile { get; set; } = "SensorDatabase.CSV";
|
||||
public static bool TDCSensorDatabaseExportUseCurrentLocale { get; set; } = false;
|
||||
public static string TDCSensorDatabaseImportEncoding { get; set; } = "Shift-JIS";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,565 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Media;
|
||||
using DataPROWin7.Common;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using DTS.Common.Interface.Channels;
|
||||
using DTS.SensorDB;
|
||||
using DTS.Common.ISO;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Classes.TestSetups;
|
||||
using DTS.Common.Interface.Graphs;
|
||||
using DTS.Common;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class TestGraph : GraphRecord, IGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// updates the ChannelsString and ThresholdsString
|
||||
/// using GroupChannels and Thresholds properties
|
||||
/// </summary>
|
||||
public void UpdateChannelAndThresholdStrings()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
int index = 0;
|
||||
foreach (var ch in GroupChannels)
|
||||
{
|
||||
if (0 != index++)
|
||||
{
|
||||
sb.Append(",");
|
||||
}
|
||||
sb.Append(ch.Id);
|
||||
}
|
||||
ChannelsString = sb.ToString();
|
||||
index = 0;
|
||||
sb.Clear();
|
||||
foreach (var d in Thresholds)
|
||||
{
|
||||
if (0 != index++)
|
||||
{
|
||||
sb.Append(",");
|
||||
}
|
||||
sb.Append(d.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
ThresholdsString = sb.ToString();
|
||||
}
|
||||
public void AddChannel(IGroupChannel groupChannel)
|
||||
{
|
||||
_groupChannels.Add(groupChannel);
|
||||
OnPropertyChanged("GroupChannels");
|
||||
}
|
||||
|
||||
public void RemoveChannel(IGroupChannel groupChannel)
|
||||
{
|
||||
_groupChannels.Remove(groupChannel);
|
||||
OnPropertyChanged("GroupChannels");
|
||||
}
|
||||
|
||||
private readonly List<IGroupChannel> _groupChannels = new List<IGroupChannel>();
|
||||
public IGroupChannel[] GroupChannels => _groupChannels.ToArray();
|
||||
|
||||
private const string SEPARATOR = "§";
|
||||
|
||||
public string GetThresholdsSQL()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("{");
|
||||
|
||||
int count = 0;
|
||||
foreach (var t in Thresholds)
|
||||
{
|
||||
if (count > 0) { sb.Append(SEPARATOR); }
|
||||
//for now thresholds are only doubles, we'll probably want more complicated ones in the future
|
||||
sb.Append("(");
|
||||
sb.Append(t.ToString(CultureInfo.InvariantCulture));
|
||||
sb.Append(")");
|
||||
count++;
|
||||
}
|
||||
sb.Append("}");
|
||||
return sb.ToString();
|
||||
}
|
||||
public void SetThresholdsFromSQL(string sThresholds)
|
||||
{
|
||||
//for now we take an easy parse
|
||||
sThresholds = sThresholds.Replace("{", "").Replace("}", "");
|
||||
var sTokens = sThresholds.Split(new[] { SEPARATOR }, StringSplitOptions.None);
|
||||
foreach (var token in sTokens)
|
||||
{
|
||||
if (double.TryParse(token, out var d))
|
||||
{
|
||||
_thresholds.Add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetChannelsFromSQL(string sChannels)
|
||||
{
|
||||
var lookup = new Dictionary<string, TestObjectChannel>();
|
||||
if (null == AvailableChannels)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var channel in AvailableChannels)
|
||||
{
|
||||
lookup[channel.GetGraphId()] = channel;
|
||||
}
|
||||
sChannels = sChannels.Replace("{", "").Replace("}", "");
|
||||
var tokens = sChannels.Split(new[] { SEPARATOR }, StringSplitOptions.None);
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
var sChannelId = token.Replace("(", "").Replace(")", "");
|
||||
if (lookup.ContainsKey(sChannelId)) { AddChannel(lookup[sChannelId]); }
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Generate a key like <groupName>_<channelName>_<channelType> and if the channel is squib "current", "_CU"
|
||||
/// </summary>
|
||||
/// <param name="ch"></param>
|
||||
/// <returns></returns>
|
||||
private string GetTestGraphKey(TestObjectChannel ch)
|
||||
{
|
||||
var key = string.Format("{0}_{1}_{2}", ch.TestObject.SerialNumber, ch.Name, ch.Channel.MMEChannelType);
|
||||
|
||||
var sd = SensorsCollection.SensorsList.GetSensorBySerialNumber(ch.SensorSerialNumber);
|
||||
if (null == sd || !sd.IsDigitalOutput())
|
||||
{
|
||||
if ((sd != null) && (sd.Bridge == SensorConstants.BridgeType.SQUIB))
|
||||
{
|
||||
if (ch.SquibChannelType == TestObjectChannel.SquibChannelTypes.Current)
|
||||
{
|
||||
key += Constants.CURRENT_SUFFIX;
|
||||
}
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
public string GetChannelsForSQL()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("{");
|
||||
var bNeedSep = false;
|
||||
|
||||
//we must "refresh" the channels we have as they are a snapshot from when the graph was created and the channels may have new ids
|
||||
//6991 Clicking save removes sensors from graph in test setup.
|
||||
var channelLookup = new Dictionary<string, TestObjectChannel>();
|
||||
foreach (var ch in _channels)
|
||||
{
|
||||
channelLookup[GetTestGraphKey(ch)] = ch;
|
||||
}
|
||||
foreach (var ch in AvailableChannels)
|
||||
{
|
||||
channelLookup[GetTestGraphKey(ch)] = ch;
|
||||
}
|
||||
var channelsAfterResolve = new List<TestObjectChannel>();
|
||||
|
||||
foreach (var ch in _channels)
|
||||
{
|
||||
if (channelLookup.ContainsKey(GetTestGraphKey(ch)))
|
||||
{
|
||||
channelsAfterResolve.Add(ch);
|
||||
}
|
||||
}
|
||||
|
||||
_channels = channelsAfterResolve;
|
||||
foreach (var ch in Channels)
|
||||
{
|
||||
if (bNeedSep) { sb.Append(SEPARATOR); }
|
||||
else { bNeedSep = true; }
|
||||
sb.AppendFormat("({0})", ch.GetGraphId());
|
||||
}
|
||||
sb.Append("}");
|
||||
return sb.ToString();
|
||||
}
|
||||
public static SolidColorBrush[] Brushes = {
|
||||
System.Windows.Media.Brushes.Blue,
|
||||
System.Windows.Media.Brushes.Red,
|
||||
System.Windows.Media.Brushes.Green,
|
||||
System.Windows.Media.Brushes.Orange,
|
||||
System.Windows.Media.Brushes.Brown,
|
||||
System.Windows.Media.Brushes.Purple,
|
||||
System.Windows.Media.Brushes.Pink,
|
||||
System.Windows.Media.Brushes.Lime,
|
||||
System.Windows.Media.Brushes.Magenta
|
||||
};
|
||||
|
||||
private List<TestObjectChannel> _channels = new List<TestObjectChannel>();
|
||||
private readonly Dictionary<string, TestObjectChannel> _lookup = new Dictionary<string, TestObjectChannel>();
|
||||
|
||||
public TestObjectChannel[] Channels
|
||||
{
|
||||
get
|
||||
{
|
||||
var toBeRemoved = new List<TestObjectChannel>();
|
||||
|
||||
foreach (var ch in _channels)
|
||||
{
|
||||
var found = false;
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
if (group.SerialNumber == ch.TestObject.SerialNumber)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
foreach (var addedGroup in AddedGroups)
|
||||
{
|
||||
if (addedGroup.SerialNumber == ch.TestObject.SerialNumber)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
toBeRemoved.Add(ch);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var ch in toBeRemoved)
|
||||
{
|
||||
_channels.Remove(ch);
|
||||
}
|
||||
|
||||
return _channels.ToArray();
|
||||
}
|
||||
}
|
||||
private void AddGroup(TestTestObject group)
|
||||
{
|
||||
Groups.Add(group);
|
||||
}
|
||||
private void AddAddedGroup(TestTestObject addedGroup)
|
||||
{
|
||||
AddedGroups.Add(addedGroup);
|
||||
}
|
||||
private void AddChannel(TestObjectChannel channel)
|
||||
{
|
||||
_channels.Add(channel);
|
||||
_lookup[channel.GetGraphId()] = channel;
|
||||
OnPropertyChanged("Channels");
|
||||
OnPropertyChanged("AvailableChannels");
|
||||
}
|
||||
private bool ContainsChannel(TestObjectChannel channel)
|
||||
{
|
||||
return _lookup.ContainsKey(channel.GetGraphId());
|
||||
}
|
||||
private bool ContainsCurrentChannel(TestObjectChannel channel)
|
||||
{
|
||||
if (channel.SquibChannelType == TestObjectChannel.SquibChannelTypes.Current)
|
||||
{
|
||||
return ContainsChannel(channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
return _lookup.ContainsKey(channel.GetGraphId() + Constants.CURRENT_SUFFIX);
|
||||
}
|
||||
}
|
||||
private bool ContainsVoltageChannel(TestObjectChannel channel)
|
||||
{
|
||||
return ContainsChannel(channel);
|
||||
}
|
||||
|
||||
private const int MAX_CHANNELS_PER_GRAPH = 8;
|
||||
public TestObjectChannel[] AvailableChannels
|
||||
{
|
||||
get
|
||||
{
|
||||
_lookup.Clear();
|
||||
var channels = new List<TestObjectChannel>();
|
||||
if (_channels.Count >= MAX_CHANNELS_PER_GRAPH) return channels.ToArray();
|
||||
foreach (var setChannel in _channels)
|
||||
{
|
||||
_lookup[setChannel.GetGraphId()] = setChannel;
|
||||
}
|
||||
if (Groups.Exists(to => !AddChannels(to, channels)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (AddedGroups.Where(to => to.Hardware.Any()).Any(to => !AddChannels(to, channels)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
channels.Sort();
|
||||
return channels.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private bool AddChannels(TestTestObject to, List<TestObjectChannel> channels)
|
||||
{
|
||||
var isoTestObject = to.GetISOTestObject();
|
||||
if (null == isoTestObject)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach (var channel in isoTestObject.AllChannels)
|
||||
{
|
||||
if (!channel.Required || channel.Disabled) { continue; }
|
||||
if (string.IsNullOrWhiteSpace(channel.SensorSerialNumber)) { continue; }
|
||||
var sd = SensorsCollection.SensorsList.GetSensorBySerialNumber(channel.SensorSerialNumber);
|
||||
if (null == sd || !sd.IsDigitalOutput())
|
||||
{
|
||||
if ((sd != null) && (sd.Bridge == SensorConstants.BridgeType.SQUIB))
|
||||
{
|
||||
//Put squib channels (Current and/or Voltage) in the
|
||||
//Available list if and only if they are not in the graph
|
||||
if (!ContainsCurrentChannel(channel))
|
||||
{
|
||||
var currentChannel = new TestObjectChannel(channel, isoTestObject, new TestObjectTemplate().ToISOTestObjectTemplate())
|
||||
{
|
||||
SquibChannelType = TestObjectChannel.SquibChannelTypes.Current,
|
||||
NameOfTheChannel = channel.Name + " " + StringResources.Graph_SquibCurrent
|
||||
};
|
||||
channels.Add(currentChannel);
|
||||
}
|
||||
|
||||
if (!ContainsVoltageChannel(channel))
|
||||
{
|
||||
channel.SquibChannelType = TestObjectChannel.SquibChannelTypes.Voltage;
|
||||
channel.NameOfTheChannel = channel.Name + " " + StringResources.Graph_SquibVoltage;
|
||||
channels.Add(channel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ContainsChannel(channel)) { continue; }
|
||||
channels.Add(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<double> _thresholds = new List<double>();
|
||||
public double[] Thresholds
|
||||
{
|
||||
get => _thresholds.ToArray();
|
||||
set => SetProperty(ref _thresholds, new List<double>(value), "Thresholds");
|
||||
}
|
||||
|
||||
private bool _bSelected;
|
||||
public bool Selected
|
||||
{
|
||||
get => _bSelected;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _bSelected, value, "Selected");
|
||||
OnPropertyChanged("BackgroundColor");
|
||||
OnPropertyChanged("ForegroundColor");
|
||||
OnPropertyChanged("Channels");
|
||||
OnPropertyChanged("AvailableChannels");
|
||||
}
|
||||
}
|
||||
|
||||
public Color BackgroundColor => Selected ? DTS.Common.BrushesAndColors.Color_ActionBackground : DTS.Common.BrushesAndColors.Color_ItemBackground;
|
||||
|
||||
private readonly Color _foregroundColor = DTS.Common.BrushesAndColors.Color_ItemForeground;
|
||||
public Color ForegroundColor => Selected ? DTS.Common.BrushesAndColors.Color_ActionForeground : _foregroundColor;
|
||||
|
||||
|
||||
private readonly TestTemplate _template;
|
||||
public List<TestTestObject> Groups { get; set; } = new List<TestTestObject>();
|
||||
public List<TestTestObject> AddedGroups { get; set; } = new List<TestTestObject>();
|
||||
|
||||
public TestGraph()
|
||||
{
|
||||
|
||||
}
|
||||
private void CommonInit(IReadOnlyDictionary<long, IGroupChannel> lookup)
|
||||
{
|
||||
var s = ChannelsString;
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
var tokens = s.Split(',');
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
if (long.TryParse(token, NumberStyles.Any,
|
||||
CultureInfo.InvariantCulture, out var l))
|
||||
{
|
||||
if (lookup.ContainsKey(l))
|
||||
{
|
||||
AddChannel(lookup[l]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
s = ThresholdsString;
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
var list = new List<double>();
|
||||
var tokens = s.Split(',');
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
if (double.TryParse(token, NumberStyles.Any,
|
||||
CultureInfo.InvariantCulture, out var d))
|
||||
{
|
||||
list.Add(d);
|
||||
}
|
||||
}
|
||||
|
||||
Thresholds = list.ToArray();
|
||||
}
|
||||
}
|
||||
public TestGraph(IGraphRecord record, IReadOnlyDictionary<long, IGroupChannel> lookup)
|
||||
: base(record)
|
||||
{
|
||||
CommonInit(lookup);
|
||||
}
|
||||
public TestGraph(IDataReader reader, IReadOnlyDictionary<long, IGroupChannel> lookup)
|
||||
: base(reader)
|
||||
{
|
||||
CommonInit(lookup);
|
||||
}
|
||||
public void ReadXML(System.Xml.XmlElement root, IReadOnlyDictionary<long, IGroupChannel> channelLookup)
|
||||
{
|
||||
var s = root.GetAttribute("DomainMax");
|
||||
if (double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out var d))
|
||||
{
|
||||
DomainMax = d;
|
||||
}
|
||||
|
||||
s = root.GetAttribute("DomainMin");
|
||||
if (double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
DomainMin = d;
|
||||
}
|
||||
|
||||
GraphDescription = root.GetAttribute("GraphDescription");
|
||||
s = root.GetAttribute("GraphId");
|
||||
if (int.TryParse(s, out var i))
|
||||
{
|
||||
GraphId = i;
|
||||
}
|
||||
|
||||
GraphName = root.GetAttribute("GraphName");
|
||||
|
||||
s = root.GetAttribute("RangeMax");
|
||||
if (double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
RangeMax = d;
|
||||
}
|
||||
|
||||
s = root.GetAttribute("RangeMin");
|
||||
if (double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
RangeMin = d;
|
||||
}
|
||||
|
||||
s = root.GetAttribute("Thresholds");
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
var tokens = s.Split(',');
|
||||
var list = new List<double>();
|
||||
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
if (double.TryParse(token, NumberStyles.Any, CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
list.Add(d);
|
||||
}
|
||||
}
|
||||
|
||||
Thresholds = list.ToArray();
|
||||
}
|
||||
|
||||
s = root.GetAttribute("UseDomainMax");
|
||||
if (bool.TryParse(s, out var b)) { UseDomainMax = b; }
|
||||
|
||||
s = root.GetAttribute("UseDomainMin");
|
||||
if (bool.TryParse(s, out b)) { UseDomainMin = b; }
|
||||
|
||||
s = root.GetAttribute("UseRangeMax");
|
||||
if (bool.TryParse(s, out b)) { UseRangeMax = b; }
|
||||
|
||||
s = root.GetAttribute("UseRangeMin");
|
||||
if (bool.TryParse(s, out b)) { UseRangeMin = b; }
|
||||
|
||||
s = root.GetAttribute("Channels");
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
var tokens = s.Split(',');
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
if (long.TryParse(token, out var l))
|
||||
{
|
||||
if (channelLookup.ContainsKey(l))
|
||||
{
|
||||
AddChannel(channelLookup[l]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void WriteXML(ref System.Xml.XmlWriter writer)
|
||||
{
|
||||
writer.WriteAttributeString("DomainMax", DomainMax.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
writer.WriteAttributeString("DomainMin", DomainMin.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
writer.WriteAttributeString("GraphDescription", GraphDescription ?? "");
|
||||
|
||||
writer.WriteAttributeString("GraphId", GraphId.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
writer.WriteAttributeString("GraphName", GraphName);
|
||||
|
||||
writer.WriteAttributeString("RangeMax", RangeMax.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
writer.WriteAttributeString("RangeMin", RangeMin.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
var sb = new StringBuilder();
|
||||
var index = 0;
|
||||
foreach (var d in Thresholds)
|
||||
{
|
||||
if (0 != index++)
|
||||
{
|
||||
sb.Append(",");
|
||||
}
|
||||
sb.Append(d.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
writer.WriteAttributeString("Thresholds", sb.ToString());
|
||||
|
||||
writer.WriteAttributeString("UseDomainMax", UseDomainMax.ToString());
|
||||
|
||||
writer.WriteAttributeString("UseDomainMin", UseDomainMin.ToString());
|
||||
|
||||
writer.WriteAttributeString("UseRangeMax", UseRangeMax.ToString());
|
||||
writer.WriteAttributeString("UseRangeMin", UseRangeMin.ToString());
|
||||
|
||||
sb.Clear();
|
||||
index = 0;
|
||||
foreach (var ch in GroupChannels)
|
||||
{
|
||||
if (0 != index++)
|
||||
{
|
||||
sb.Append(",");
|
||||
}
|
||||
|
||||
sb.Append(ch.Id.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
writer.WriteAttributeString("Channels", sb.ToString());
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
|
||||
public TestGraph(TestTemplate template)
|
||||
{
|
||||
_template = template;
|
||||
foreach (var group in _template.TestObjectsWithChannels)
|
||||
{
|
||||
AddGroup(new TestTestObject(group));
|
||||
}
|
||||
foreach (var addedGroup in _template.AddedGroups)
|
||||
{
|
||||
AddAddedGroup(new TestTestObject(addedGroup));
|
||||
}
|
||||
}
|
||||
public TestGraph(TestGraph copy) : base(copy)
|
||||
{
|
||||
_thresholds = new List<double>(copy.Thresholds);
|
||||
_groupChannels = new List<IGroupChannel>(copy.GroupChannels);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,17 @@
|
||||
using DTS.Slice.Users;
|
||||
using DataPROWin7.DataModel;
|
||||
using DTS.Common.ISO;
|
||||
using DTS.Common.Licensing.Messages;
|
||||
|
||||
namespace DTS.Common.DataModel
|
||||
{
|
||||
public static class ApplicationProperties
|
||||
{
|
||||
public static User CurrentUser { get; set; }
|
||||
public static DASFactory DASFactory { get; set; }
|
||||
public static User CurrentView { get; set; }
|
||||
public static ISO13499FileDb IsoDb { get; set; }
|
||||
public static ValidationResult LicenseValidationResult { get; set; }
|
||||
public static bool CanCurrentUserCommitChannelCodes { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DataPROWin7.DataModel.Classes.TestTemplate;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.Interface.DASFactory.Diagnostics;
|
||||
using DTS.Common.Interface.DASFactory.Diagnostics.HardwareList;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using DTS.Common.Storage;
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes.Hardware
|
||||
{
|
||||
public class DASHardwareList : BasePropertyChanged
|
||||
{
|
||||
private static DASHardwareList _list;
|
||||
|
||||
private static bool _cache = false;
|
||||
/// <summary>
|
||||
/// turns off queries to the db and starts using cached data instead
|
||||
/// this is done when a large number of test setups are validating, since each test setup
|
||||
/// will get a complete list of hardware from the db, which adds time when you have a lot of hardware and test setups
|
||||
/// </summary>
|
||||
public static bool Cache
|
||||
{
|
||||
get => _cache;
|
||||
set
|
||||
{
|
||||
_cache = value;
|
||||
if (!value)
|
||||
{
|
||||
_cachedDASHardware = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 void SetCache(ICachedContainer container)
|
||||
{
|
||||
_cachedHardware = container;
|
||||
}
|
||||
|
||||
public void ClearCache()
|
||||
{
|
||||
_cachedHardware = null;
|
||||
}
|
||||
public string GetDASSerialNumberFromId(int id)
|
||||
{
|
||||
//this could probably be improved, but rather than getting ALL HARDWARE and ALL channels
|
||||
//just to get a serial number for a database id
|
||||
//just get the hardware without the channels
|
||||
var hr = DbOperations.DASGet(null, null, out var records);
|
||||
if (0 == hr && null != records && records.Any())
|
||||
{
|
||||
var match = Array.Find(records, das => das.DASId == id);
|
||||
if (null != match) { return match.SerialNumber; }
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
public DASHardware GetHardware(int id)
|
||||
{
|
||||
var sn = GetDASSerialNumberFromId(id);
|
||||
return GetHardware(sn);
|
||||
}
|
||||
public DASHardware GetHardware(string id, bool bUseCache = true)
|
||||
{
|
||||
return GetHardware(id, true, out var bNotUsed, bUseCache);
|
||||
}
|
||||
|
||||
public DASHardware[] GetHardware(string[] ids, bool bUseCache = true)
|
||||
{
|
||||
List<DASHardware> dasHW = new List<DASHardware>();
|
||||
foreach (string id in ids)
|
||||
{
|
||||
var hw = GetHardware(id, bUseCache);
|
||||
if (null != hw)
|
||||
{
|
||||
dasHW.Add(hw);
|
||||
}
|
||||
}
|
||||
return dasHW.ToArray();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
if (null != _cachedDASHardware)
|
||||
{
|
||||
h = Array.Find(_cachedDASHardware, das => das.SerialNumber == id);
|
||||
if (null != h)
|
||||
{
|
||||
changed = false;
|
||||
return h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var hardware = DTS.Common.ISO.Hardware.GetAllDAS(id, null);
|
||||
changed = false;
|
||||
if (null != hardware && hardware.Any())
|
||||
{
|
||||
return new DASHardware(hardware[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public class HardwareTypeChangedException : Exception
|
||||
{
|
||||
}
|
||||
|
||||
public DASHardware GetHardware(string serialNumber, string ipaddress)
|
||||
{
|
||||
return GetHardware(serialNumber);
|
||||
}
|
||||
|
||||
public void UpdateMaxMemory(DASHardware h, long newMaxMemory)
|
||||
{
|
||||
h.GetHardware().MaxMemory = newMaxMemory;
|
||||
h.GetHardware().Update();
|
||||
}
|
||||
|
||||
public DASHardware GetPrototypeHardware(string serial, int type)
|
||||
{
|
||||
//return new DASHardware();
|
||||
var key = $"{serial}_{type}";
|
||||
var das = DTS.Common.ISO.Hardware.GetAllDAS(key, DbOperations.DAS.PROTOTYPE_POSITION);
|
||||
if (null != das && das.Any())
|
||||
{
|
||||
das[0].CalDate = DateTime.MinValue;//if something is using the prototype, use a blank caldate
|
||||
return new DASHardware(das[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// holds a cache of all hardware this is done for speed reasons when there are a large number
|
||||
/// of test setups to validate, each one of them grabs all the hardware, which takes time
|
||||
/// </summary>
|
||||
private static DASHardware[] _cachedDASHardware = null;
|
||||
public static DASHardware[] GetAllHardware()
|
||||
{
|
||||
if (Cache && null != _cachedDASHardware) { return _cachedDASHardware; }
|
||||
var allHardware = DTS.Common.ISO.Hardware.GetAllDAS();
|
||||
var ret = allHardware.Select(h => new DASHardware(h)).ToArray();
|
||||
if (Cache) { _cachedDASHardware = ret; }
|
||||
return ret;
|
||||
}
|
||||
public static List<int> GetEmbeddedModules(IDASHardware[] hardware, int id)
|
||||
{
|
||||
var modules = new List<int>();
|
||||
|
||||
foreach (var hw in hardware)
|
||||
{
|
||||
if (hw.Connection.StartsWith(hardware.First(h => h.DASId == id).SerialNumber))
|
||||
{
|
||||
modules.Add(hw.DASId);
|
||||
}
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
public static Dictionary<string, double> GetEmbeddedModuleInfo(DASHardware[] hardware, int id)
|
||||
{
|
||||
var info = new Dictionary<string, double>();
|
||||
|
||||
foreach (var hw in hardware)
|
||||
{
|
||||
if (hw.Connection.StartsWith(hardware.First(h => h.DASId == id).SerialNumber))
|
||||
{
|
||||
info[hw.SerialNumber] = hw.GetMaxSampleRateDouble();
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public enum Tags
|
||||
{
|
||||
Hardware
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unassociate is used to indicate whether children das should be unassociated before commiting or not
|
||||
/// </summary>
|
||||
public void Commit(DASHardware hardware, bool bExisting = false, bool bCheckExisting = true, bool Unassociate = true)
|
||||
{
|
||||
//note when you are commiting a group of hardware that contains a SLICE6Db, you should
|
||||
//sort the hardware so that this call happens BEFORE we commit any child slice6
|
||||
if (hardware.IsPseudoRack() && Unassociate)
|
||||
{
|
||||
UnassociateParentDAS(hardware.SerialNumber);
|
||||
}
|
||||
|
||||
var iso = hardware.GetHardware();
|
||||
var h = new DTS.Common.ISO.Hardware
|
||||
{
|
||||
SerialNumber = hardware.SerialNumber,
|
||||
LocalOnly = hardware.LocalOnly,
|
||||
IsModule = hardware.IsModule(),
|
||||
CalDate = hardware.CalDate,
|
||||
DASType = hardware.GetHardwareTypeInt(),
|
||||
FirmwareVersion = hardware.Firmware,
|
||||
IPAddress = hardware.Connection,
|
||||
MaxMemory = hardware.GetMaxMemoryLong(),
|
||||
MaxModules = hardware.MaxModules,
|
||||
MaxSampleRate = hardware.GetMaxSampleRateDouble(),
|
||||
MinSampleRate = hardware.GetMinSampleRateDouble(),
|
||||
ProtocolVersion = hardware.ProtocolVersion,
|
||||
Channels = hardware.Channels.Length,
|
||||
LastModified = DateTime.Now,
|
||||
LastModifiedBy = ApplicationProperties.CurrentUser.UserName,
|
||||
IsReconfigurable = hardware.Reconfigurable,
|
||||
IsProgrammable = hardware.Reprogrammable,
|
||||
ChannelTypes = hardware.ChannelTypes,
|
||||
ParentDAS = hardware.ParentDAS,
|
||||
Port = hardware.PortOnDistributor,
|
||||
PositionOnChain = hardware.PositionOnChain,
|
||||
PositionOnDistributor = hardware.PositionOnDistributor,
|
||||
IsFirstUseValid = hardware.IsFirstUseValid,
|
||||
FirstUseDate = hardware.FirstUseDate,
|
||||
StandIn = iso.StandIn,
|
||||
MaxAAFRate = hardware.GetMaxAAFRateDouble(),
|
||||
TestId = iso.TestId,
|
||||
GroupId = iso.GroupId,
|
||||
LastUsed = iso.LastUsed,
|
||||
LastUsedBy = iso.LastUsedBy
|
||||
};
|
||||
|
||||
h.ISOChannels = hardware.Channels.Select(channel => new DTS.Common.ISO.HardwareChannel(channel.GetISOChannel(), h))
|
||||
.ToArray();
|
||||
hardware.SetHardware(h);
|
||||
|
||||
//if (null == _hardware)
|
||||
//{
|
||||
// PopulateHardware();
|
||||
//}
|
||||
|
||||
//10037 TDAS G5 module is detected as a TDAS G5 in a VDS, so if the existing serial number and ip address
|
||||
//already exists in the database
|
||||
if (bCheckExisting)
|
||||
{
|
||||
//22320 Unnecessary hardware retrieval
|
||||
bExisting = DASHardware.GetDataBaseID(hardware.SerialNumber) > 0;
|
||||
}
|
||||
if (!bExisting)
|
||||
{
|
||||
h.Insert();
|
||||
}
|
||||
else
|
||||
{
|
||||
h.Version = h.Version + 1;
|
||||
//10037 TDAS G5 module is detected as a TDAS G5 in a VDS
|
||||
//the id could change, so if we are doing an update, we should make sure to remove the old instance in the list
|
||||
//_hardware.Remove(existingHardware.GetHardware().GetId());
|
||||
//_hardware[hardware.GetHardware().GetId()] = hardware;
|
||||
h.Update();
|
||||
}
|
||||
OnPropertyChanged(Tags.Hardware.ToString());
|
||||
|
||||
//no longer need to mark groups incomplete
|
||||
}
|
||||
/// <summary>
|
||||
/// deletes the selected IHardware
|
||||
/// </summary>
|
||||
public void Delete(IHardware hardware)
|
||||
{
|
||||
if (hardware.Hardware is IISOHardware isoHW)
|
||||
{
|
||||
isoHW.Delete();
|
||||
}
|
||||
}
|
||||
public void Delete(DASHardware hardware)
|
||||
{
|
||||
var h = hardware?.GetHardware();
|
||||
if (h == null) { return; }
|
||||
h.Delete();
|
||||
|
||||
if (hardware.IsPseudoRack())
|
||||
{
|
||||
UnassociateParentDAS(hardware.SerialNumber);
|
||||
}
|
||||
OnPropertyChanged(Tags.Hardware.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
/// iteratively deletes the given hardware
|
||||
/// </summary>
|
||||
public void Delete(IHardware[] hardware)
|
||||
{
|
||||
foreach (var h in hardware)
|
||||
{
|
||||
Delete(h);
|
||||
}
|
||||
}
|
||||
public void Delete(DASHardware[] hardware)
|
||||
{
|
||||
foreach (DASHardware hw in hardware)
|
||||
{
|
||||
Delete(hw);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnassociateParentDAS(string distributorSerialNumber)
|
||||
{
|
||||
using (var sql = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
sql.CommandType = System.Data.CommandType.StoredProcedure;
|
||||
sql.CommandText = DbOperationsEnum.StoredProcedure.sp_DASChildrenUnAssociate.ToString();
|
||||
DbOperations.CreateParam(sql, "@ParentSerialNumber", System.Data.SqlDbType.NVarChar,
|
||||
distributorSerialNumber);
|
||||
sql.ExecuteNonQuery();
|
||||
}
|
||||
finally { sql.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using DTS.Common.Interface.DownloadEvent;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
[Serializable]
|
||||
public class DownloadEvent : IDownloadEvent
|
||||
{
|
||||
|
||||
public DownloadEvent()
|
||||
{
|
||||
EventNumber = 0;
|
||||
IsEnabled = true;
|
||||
IsDefault = true;
|
||||
IsReadonly = true;
|
||||
}
|
||||
|
||||
public DownloadEvent(bool isDefault = false)
|
||||
: this()
|
||||
{
|
||||
IsDefault = isDefault;
|
||||
}
|
||||
public DownloadEvent(int eventNumber = 0, bool isDefault = false)
|
||||
: this(isDefault)
|
||||
{
|
||||
EventNumber = eventNumber;
|
||||
}
|
||||
|
||||
private int _eventNumber = 0;
|
||||
public int EventNumber
|
||||
{
|
||||
get => _eventNumber;
|
||||
set
|
||||
{
|
||||
_eventNumber = value;
|
||||
OnPropertyChanged("EventNumber");
|
||||
EventNumberDisplay = $"{DTS.Common.Constants.EventNumber} {_eventNumber:00}";
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isEnabled = true;
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set { _isEnabled = value; OnPropertyChanged("IsEnabled"); }
|
||||
}
|
||||
|
||||
public bool IsDefault { get; }
|
||||
|
||||
private string _eventNumberDisplay = string.Empty;
|
||||
public string EventNumberDisplay
|
||||
{
|
||||
get => _eventNumberDisplay;
|
||||
set
|
||||
{
|
||||
_eventNumberDisplay = value;
|
||||
OnPropertyChanged("EventNumberDisplay");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 43387 Export multiple events: Used to store the <TestSetup>:<TestId>:("<All or ROI>") on a per event basis, for later use by export code
|
||||
/// </summary>
|
||||
private string _testItem = string.Empty;
|
||||
public string TestItem
|
||||
{
|
||||
get => _testItem;
|
||||
set
|
||||
{
|
||||
_testItem = value;
|
||||
OnPropertyChanged("TestItem");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 43387 Export multiple events: Used to store the .DTS file on a per event basis, for later use by export code
|
||||
/// </summary>
|
||||
private string _dtsFile = string.Empty;
|
||||
public string DTSFile
|
||||
{
|
||||
get => _dtsFile;
|
||||
set
|
||||
{
|
||||
_dtsFile = value;
|
||||
OnPropertyChanged("DTSFile");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isReadonly = true;
|
||||
public bool IsReadonly
|
||||
{
|
||||
get => _isReadonly;
|
||||
set { _isReadonly = value; OnPropertyChanged("IsReadonly"); }
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private TimeSpan _eventLength = new TimeSpan(0);
|
||||
/// <summary>
|
||||
/// total time available for download event
|
||||
/// </summary>
|
||||
public TimeSpan EventLength
|
||||
{
|
||||
get => _eventLength;
|
||||
set
|
||||
{
|
||||
_eventLength = value; OnPropertyChanged("EventLength");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _ShouldDisplayLength = false;
|
||||
/// <summary>
|
||||
/// whether EventLength should be displayed or not
|
||||
/// </summary>
|
||||
public bool ShouldDisplayLength
|
||||
{
|
||||
get => _ShouldDisplayLength;
|
||||
set
|
||||
{
|
||||
_ShouldDisplayLength = value;
|
||||
OnPropertyChanged("ShouldDisplayLength");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
BIN
Common/DTS.Common.DataModel/.svn/wc.db
Normal file
BIN
Common/DTS.Common.DataModel/.svn/wc.db
Normal file
Binary file not shown.
0
Common/DTS.Common.DataModel/.svn/wc.db-journal
Normal file
0
Common/DTS.Common.DataModel/.svn/wc.db-journal
Normal file
17
Common/DTS.Common.DataModel/ApplicationProperties.cs
Normal file
17
Common/DTS.Common.DataModel/ApplicationProperties.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using DTS.Slice.Users;
|
||||
using DataPROWin7.DataModel;
|
||||
using DTS.Common.ISO;
|
||||
using DTS.Common.Licensing.Messages;
|
||||
|
||||
namespace DTS.Common.DataModel
|
||||
{
|
||||
public static class ApplicationProperties
|
||||
{
|
||||
public static User CurrentUser { get; set; }
|
||||
public static DASFactory DASFactory { get; set; }
|
||||
public static User CurrentView { get; set; }
|
||||
public static ISO13499FileDb IsoDb { get; set; }
|
||||
public static ValidationResult LicenseValidationResult { get; set; }
|
||||
public static bool CanCurrentUserCommitChannelCodes { get; set; }
|
||||
}
|
||||
}
|
||||
342
Common/DTS.Common.DataModel/ChannelRepresentation.cs
Normal file
342
Common/DTS.Common.DataModel/ChannelRepresentation.cs
Normal file
@@ -0,0 +1,342 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using DataPROWin7.DataModel.Classes.Hardware;
|
||||
using DTS.Common.Converters;
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using DTS.Common.Constant.DASSpecific;
|
||||
|
||||
namespace DataPROWin7
|
||||
{
|
||||
public class ChannelRepresentation
|
||||
{
|
||||
public enum ChannelTypeEnum
|
||||
{
|
||||
SQUIB,
|
||||
TOMDigital,
|
||||
DigitalInput,
|
||||
Other
|
||||
}
|
||||
|
||||
private readonly ChannelTypeEnum _channelType = ChannelTypeEnum.Other;
|
||||
|
||||
public ChannelRepresentation(DataModel.DASHardware h, DTS.DASLib.Service.DASChannel c,
|
||||
int startingChannelNumber)
|
||||
{
|
||||
//adjust the starting channel number (which appears to be a DAS channel number) to a module channel number
|
||||
if (h.CareAboutModules)
|
||||
{
|
||||
startingChannelNumber = 1 + c.ModuleChannelNumber;
|
||||
}
|
||||
if (c is DTS.DASLib.Service.OutputSquibChannel)
|
||||
{
|
||||
startingChannelNumber = DoSquibConversion(startingChannelNumber);
|
||||
_channelType = ChannelTypeEnum.SQUIB;
|
||||
}
|
||||
else if (c is DTS.DASLib.Service.OutputTOMDigitalChannel)
|
||||
{
|
||||
_channelType = ChannelTypeEnum.TOMDigital;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((c as DTS.DASLib.Service.AnalogInputDASChannel).SupportedBridges.Length == 1) &&
|
||||
((c as DTS.DASLib.Service.AnalogInputDASChannel).SupportedBridges[0] ==
|
||||
SensorConstants.BridgeType.DigitalInput))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.DigitalInput;
|
||||
}
|
||||
}
|
||||
|
||||
ConvertChannelNumbers(h.DASTypeEnum, startingChannelNumber, h.SerialNumber, c.OwningModule.SerialNumber(),
|
||||
_channelType);
|
||||
}
|
||||
|
||||
|
||||
private int GetModuleChannelNumber(DataModel.HardwareChannel c)
|
||||
{
|
||||
if (null == c.Hardware)
|
||||
{
|
||||
return 1 + c.ChannelNumber;
|
||||
}
|
||||
var moduleChannelNumber = 0;
|
||||
var moduleArrayIndex = -1;
|
||||
|
||||
foreach (var ch in c.Hardware.Channels)
|
||||
{
|
||||
if (ch.ModuleArrayIndex != moduleArrayIndex)
|
||||
{
|
||||
moduleChannelNumber = 0;
|
||||
moduleArrayIndex = ch.ModuleArrayIndex;
|
||||
}
|
||||
moduleChannelNumber++;
|
||||
if (ch.ChannelNumber == c.ChannelNumber)
|
||||
{
|
||||
return moduleChannelNumber;
|
||||
}
|
||||
}
|
||||
return 1 + c.ChannelNumber;
|
||||
}
|
||||
|
||||
public ChannelRepresentation(DataModel.HardwareChannel c, int startingChannelNumber, IDASHardware[] hardwares = null)
|
||||
{
|
||||
if (null != c.Hardware && c.Hardware.CareAboutModules)
|
||||
{
|
||||
startingChannelNumber = GetModuleChannelNumber(c);
|
||||
}
|
||||
if (c.IsSupportedBridgeType(SensorConstants.BridgeType.SQUIB))
|
||||
{
|
||||
startingChannelNumber = DoSquibConversion(startingChannelNumber);
|
||||
_channelType = ChannelTypeEnum.SQUIB;
|
||||
}
|
||||
else if (c.IsSupportedBridgeType(SensorConstants.BridgeType.TOMDigital))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.TOMDigital;
|
||||
}
|
||||
else if (c.IsSupportedBridgeType(SensorConstants.BridgeType.DigitalInput))
|
||||
{
|
||||
_channelType = ChannelTypeEnum.DigitalInput;
|
||||
}
|
||||
|
||||
var moduleSerialNumber = c.ModuleSerialNumber;
|
||||
var dasSerialNumber = c.Hardware.SerialNumber;
|
||||
|
||||
var h = c.Hardware.GetHardware();
|
||||
if (h.StandIn)
|
||||
{
|
||||
dasSerialNumber = EnumDescriptionTypeConverter.GetEnumDescription(h.DASTypeEnum);
|
||||
switch (c.Hardware.DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
break;
|
||||
default:
|
||||
moduleSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (c.Hardware.IsPseudoRackModule() && c.Hardware.IsModule())
|
||||
{
|
||||
moduleSerialNumber = c.Hardware.SerialNumber;
|
||||
dasSerialNumber = c.Hardware.ParentDAS;
|
||||
}
|
||||
else if (c.Hardware.IsTSRAIRModule() && c.Hardware.IsModule())
|
||||
{
|
||||
moduleSerialNumber = c.Hardware.SerialNumber;
|
||||
dasSerialNumber = string.IsNullOrWhiteSpace(c.Hardware.ParentDAS) ?
|
||||
c.Hardware.Connection.Split(new[] { "xEMB" }, StringSplitOptions.RemoveEmptyEntries)[0] :
|
||||
c.Hardware.ParentDAS;
|
||||
}
|
||||
|
||||
ConvertChannelNumbers(c.Hardware.DASTypeEnum, startingChannelNumber, dasSerialNumber, moduleSerialNumber,
|
||||
_channelType, hardwares);
|
||||
if (!c.Hardware.IsTSRAIR())
|
||||
{
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
}
|
||||
}
|
||||
|
||||
public string DASSerialNumber { get; set; } = string.Empty;
|
||||
|
||||
public string SerialNumber //Module
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = string.Empty;
|
||||
|
||||
public string ChannelNumberString { get; set; } = string.Empty;
|
||||
|
||||
public int ChannelNumber { get; set; } = 0;
|
||||
|
||||
private int DoSquibConversion(int squibChannelNumber)
|
||||
{
|
||||
Math.DivRem(squibChannelNumber, 8, out var remainder);
|
||||
switch (remainder)
|
||||
{
|
||||
case 1:
|
||||
return 1;
|
||||
case 3:
|
||||
return 2;
|
||||
case 5:
|
||||
return 3;
|
||||
case 7:
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConvertChannelNumbers(HardwareTypes dasType, int startingChannelNumber, string dasSerialNumber,
|
||||
string moduleSerialNumber,
|
||||
ChannelTypeEnum channelType, IDASHardware[] hardwares = null)
|
||||
{
|
||||
var displayChannelNumber = 0;
|
||||
switch (dasType)
|
||||
{
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
if (moduleSerialNumber.StartsWith("DIM"))
|
||||
{
|
||||
Math.DivRem(startingChannelNumber - 1, 16, out displayChannelNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
}
|
||||
}
|
||||
displayChannelNumber++;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
// Start counting the Digital Output channels from 1
|
||||
Math.DivRem(startingChannelNumber - 1, 8, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.G5VDS: // Start counting the Digital Input channels from 1
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
Math.DivRem(startingChannelNumber - 1, 32, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.SLICE1_G5Stack:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = StringResources.ChannelDASNA;
|
||||
break;
|
||||
case HardwareTypes.SLICE_Base: //Is this the micro base?
|
||||
case HardwareTypes.SLICE_Micro_Base: //Is this the micro base?
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: //This is for nano
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: //This is for micro
|
||||
case HardwareTypes.SLICE_NANO_Base: //This is for nano
|
||||
Math.DivRem(startingChannelNumber - 1, 3, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
case HardwareTypes.SLICE_PRO_CAN_FD:
|
||||
|
||||
bool isPseudoDAS = false;
|
||||
IDASHardware[] list = null;
|
||||
if (null != hardwares)
|
||||
{
|
||||
list = hardwares;
|
||||
}
|
||||
else { list = DASHardwareList.GetAllHardware(); }
|
||||
if (list.Any())
|
||||
{
|
||||
//13096 Unhandled exception clicking save in hardware disco (test setup)
|
||||
var matches = from das in list where das.SerialNumber == dasSerialNumber select das;
|
||||
if (matches.Any())
|
||||
{
|
||||
isPseudoDAS = matches.First().IsPseudoRack();
|
||||
}
|
||||
}
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = isPseudoDAS ? moduleSerialNumber : dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.EMB_ANG_ARS:
|
||||
case HardwareTypes.EMB_ATM:
|
||||
case HardwareTypes.EMB_LIN_ACC_HI:
|
||||
case HardwareTypes.EMB_LIN_ACC_LO:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = moduleSerialNumber; //dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber; //.Substring(0, dasSerialNumber.IndexOf('-'));
|
||||
break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
case HardwareTypes.DIR:
|
||||
case HardwareTypes.DKR:
|
||||
Math.DivRem(startingChannelNumber - 1, 3, out displayChannelNumber);
|
||||
displayChannelNumber++;
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
SerialNumber = StringResources.UnknownModule;
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_TC:
|
||||
if (string.IsNullOrWhiteSpace(moduleSerialNumber))
|
||||
{
|
||||
var displayModuleNumber = Math.DivRem(startingChannelNumber - 1, SLICE6AIRTC.ThermocouplersPerModule, out displayChannelNumber);
|
||||
SerialNumber = string.Format(StringResources.ModuleNumber, displayModuleNumber.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
SerialNumber = moduleSerialNumber;
|
||||
if (moduleSerialNumber.StartsWith(StringResources.StreamOut))
|
||||
{
|
||||
//Stream out
|
||||
displayChannelNumber = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Thermocoupler
|
||||
SerialNumber = dasSerialNumber;
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
}
|
||||
}
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
default:
|
||||
displayChannelNumber = startingChannelNumber;
|
||||
SerialNumber = dasSerialNumber;
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
break;
|
||||
}
|
||||
if (channelType == ChannelTypeEnum.SQUIB)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_Squib + displayChannelNumber.ToString("00");
|
||||
}
|
||||
else if (channelType == ChannelTypeEnum.TOMDigital)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_DigitalOut +
|
||||
displayChannelNumber.ToString("00");
|
||||
}
|
||||
else if (channelType == ChannelTypeEnum.DigitalInput)
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_DigitalIn +
|
||||
displayChannelNumber.ToString("00");
|
||||
}
|
||||
else
|
||||
{
|
||||
ChannelNumberString = StringResources.ChannelPrefix_Other + displayChannelNumber.ToString("00");
|
||||
}
|
||||
ChannelNumber = displayChannelNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
605
Common/DTS.Common.DataModel/Classes/Arming/Arming.cs
Normal file
605
Common/DTS.Common.DataModel/Classes/Arming/Arming.cs
Normal file
@@ -0,0 +1,605 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.DASLib.Service;
|
||||
using System.Threading;
|
||||
using System.Linq;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using DTS.Common.DataModel.Common;
|
||||
using DTS.Common.Enums.TSRAIRGo;
|
||||
using DTS.Common.Constant.DASSpecific;
|
||||
using DTS.Common.DataModel.Classes.TSRAIRGo;
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes
|
||||
{
|
||||
public class Arming
|
||||
{
|
||||
readonly Configuration configuration = new Configuration();
|
||||
public Arming()
|
||||
{
|
||||
}
|
||||
|
||||
public bool SetConfigAndFlashClear(DataModel.TestTemplate currentTest,
|
||||
List<IDASCommunication> dasList,
|
||||
Dictionary<string, int> dasSampleRateList,
|
||||
double duration,
|
||||
StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
return SetConfigAndStartFlashClear(currentTest, dasList, dasSampleRateList, duration, false, setProgressFunction, onError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private bool SetConfigAndStartFlashClear(DataModel.TestTemplate currentTest,
|
||||
List<IDASCommunication> dasList,
|
||||
Dictionary<string, int> dasSampleRateList,
|
||||
double duration,
|
||||
bool diagnosticsVoltage,
|
||||
StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
foreach (var mod in das.ConfigData.Modules)
|
||||
{
|
||||
mod.PostTriggerSeconds = duration;
|
||||
mod.PreTriggerSeconds = (double)TSRAIR.TSRAIR_MAX_PRE_TRIGGER_SAMPLES / Convert.ToInt32(dasSampleRateList[das.SerialNumber]);
|
||||
//FB 26980 mod.NumberOfEvents has already a correct value but override it to make sure the value is there
|
||||
mod.NumberOfEvents = currentTest.NumberOfEvents;
|
||||
mod.WakeUpMotionTimeout = currentTest.WakeUpMotionTimeout; //10?
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
setProgressFunction(das, 0D, TSRAIRGoStatus.StatusTypes.PREPARING_FOR_ARMING);
|
||||
}
|
||||
|
||||
configuration.SetConfig(currentTest, dasList, diagnosticsVoltage, setProgressFunction);
|
||||
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
setProgressFunction(das, 0D, TSRAIRGoStatus.StatusTypes.PREPARING_DATA_MEMORY);
|
||||
}
|
||||
return StartFlashClear(dasList, setProgressFunction, currentTest, onError);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
onError?.Invoke(this, $"{StringResources.FailedToArm}: {ex.Message}", ex);
|
||||
APILogger.Log(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
protected bool StartFlashClear(List<IDASCommunication> dasList, StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
DataModel.TestTemplate currentTest, ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
return FlashErase(dasList, setProgressFunction, currentTest, onError);
|
||||
}
|
||||
protected bool FlashErase(List<IDASCommunication> dasList, StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
DataModel.TestTemplate currentTest, ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
var cancelEvent = new ManualResetEvent(false);
|
||||
var resetEvent = new ManualResetEvent(false);
|
||||
var bFailed = false;
|
||||
var flashDevices = new List<IDASCommunication>(dasList);
|
||||
var failureToClearFlashDevices = new List<IDASCommunication>();
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
if (flashDevices.Any())
|
||||
{
|
||||
using (var armingService = new ArmingService())
|
||||
{
|
||||
armingService.AggregateProgress = false;
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
armingService.BeginFlashErase(flashDevices, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
bFailed = true;
|
||||
|
||||
//39345 Don't hang if Flash Erase fails
|
||||
cbd.Target.DASArmStatus.FaultMessage = StringResources.ArmSystem_FailedToClearFlash;
|
||||
cbd.Target.SetDASArmStatus();
|
||||
onError?.Invoke(this, string.Format(StringResources.ArmSystem_FailedToClearFlash, cbd.Target.SerialNumber), null);
|
||||
failureToClearFlashDevices.Add(cbd.Target);
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
break;
|
||||
}
|
||||
}, flashDevices, false);
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//39345 Don't hang if Flash Erase fails
|
||||
if (bFailed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flashDevices.Any())
|
||||
{
|
||||
using (var armingService = new ArmingService())
|
||||
{
|
||||
armingService.AggregateProgress = false;
|
||||
var bDone = false;
|
||||
var flashStatus = new Dictionary<IDASCommunication, bool>();
|
||||
|
||||
foreach (var das in flashDevices)
|
||||
{
|
||||
flashStatus[das] = false;
|
||||
}
|
||||
while (!bDone)
|
||||
{
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
armingService.GetFlashEraseStatus(flashDevices, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
bFailed = true;
|
||||
flashStatus[cbd.Target] = true;
|
||||
failureToClearFlashDevices.Add(cbd.Target);
|
||||
onError?.Invoke(this, string.Format(StringResources.ArmSystem_FailedToClearFlash, cbd.Target.SerialNumber), cbd.ErrorException);
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
flashStatus[cbd.Target] = true;
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
{
|
||||
using (var enumeratorFlashStatus = flashStatus.GetEnumerator())
|
||||
{
|
||||
var b = true;
|
||||
while (enumeratorFlashStatus.MoveNext())
|
||||
{
|
||||
if (!enumeratorFlashStatus.Current.Value)
|
||||
{
|
||||
b = false;
|
||||
}
|
||||
}
|
||||
bDone = b;
|
||||
}
|
||||
}
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
StatusHelpers.SetStatus2(cbd.Target, cbd.ProgressValue, TSRAIRGoStatus.StatusTypes.PREPARING_DATA_MEMORY, setProgressFunction);
|
||||
if (100 <= cbd.ProgressValue)
|
||||
{
|
||||
flashStatus[cbd.Target] = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}, flashDevices);
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
if (cancelEvent.WaitOne(0, false))
|
||||
{
|
||||
bDone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//39345 Don't hang if Flash Erase fails
|
||||
if (bFailed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!cancelEvent.WaitOne(0, false) && !bFailed)
|
||||
{
|
||||
return PrepareArmFunc(dasList, setProgressFunction, currentTest, onError);
|
||||
}
|
||||
else if (bFailed)
|
||||
{
|
||||
resetEvent.Set();
|
||||
cancelEvent.Set();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected bool PrepareArmFunc(List<IDASCommunication> dasList, StatusHelpers.SetProgressValueDelegate setProgressFunction, DataModel.TestTemplate currentTest,
|
||||
ServiceBase.ServiceCallbackErrorEventHandler onError
|
||||
)
|
||||
{
|
||||
const int ARM_NOW_TIMEOUT = 30000;
|
||||
var cancelEvent = new ManualResetEvent(false);
|
||||
var g = Guid.NewGuid();
|
||||
|
||||
var bFailedPrepareArm = false;
|
||||
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
if (currentTest.LevelTriggerChannels.Count > 0)
|
||||
{
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
var mre = new ManualResetEvent(false);
|
||||
armService.CheckAlreadyLevelTriggered(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
onError(this, $"{StringResources.ArmSystem_FailedArm} {cbd.ErrorMessage} - {cbd.Target.SerialNumber}", cbd.ErrorException);
|
||||
bFailedPrepareArm = true;
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
mre.Set();
|
||||
break;
|
||||
}
|
||||
}, dasList);
|
||||
mre.WaitOne();
|
||||
var alreadyLevelTriggeredChannels = (from das in dasList where null != das.ConfigData from m in das.ConfigData.Modules from ch in m.Channels where ch is AnalogInputDASChannel let aCh = ch as AnalogInputDASChannel where aCh.AlreadyLevelTriggered select $"{das.SerialNumber} {1 + aCh.Number}").ToList();
|
||||
if (alreadyLevelTriggeredChannels.Count > 0)
|
||||
{
|
||||
bFailedPrepareArm = true;
|
||||
var errors = new List<string>();
|
||||
errors.Add(StringResources.AlreadyLevelTriggeredChannels);
|
||||
errors.AddRange(alreadyLevelTriggeredChannels.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bFailedPrepareArm)
|
||||
{
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
armService.ReadyForArm(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
StatusHelpers.SetStatus2(cbd.Target, cbd.ProgressValue, TSRAIRGoStatus.StatusTypes.PREPARING_FOR_ARMING, setProgressFunction);
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
bFailedPrepareArm = true;
|
||||
onError(this, $"{StringResources.ArmSystem_FailedArm} {cbd.ErrorMessage} - {cbd.Target.SerialNumber}", cbd.ErrorException);
|
||||
break;
|
||||
}
|
||||
}, dasList, 600000, false, currentTest.NumberOfEvents, 0, g, false, dasList.Count > 1);
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFailedPrepareArm)
|
||||
{
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
armService.PrepareForArmNow(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
onError(this, $"{StringResources.ArmSystem_FailedArm} {cbd.ErrorMessage} - {cbd.Target.SerialNumber}", cbd.ErrorException);
|
||||
bFailedPrepareArm = true;
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
StatusHelpers.SetStatus2(cbd.Target, cbd.ProgressValue, TSRAIRGoStatus.StatusTypes.PREPARING_FOR_ARMING, setProgressFunction);
|
||||
break;
|
||||
}
|
||||
}, dasList, ARM_NOW_TIMEOUT, false, currentTest.NumberOfEvents, g, dasList.Count > 1/* && CurrentTest.CommonLine*/);
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
|
||||
if (!cancelEvent.WaitOne(0, false))
|
||||
{
|
||||
done.Reset();
|
||||
}
|
||||
}
|
||||
if (bFailedPrepareArm)
|
||||
{
|
||||
cancelEvent.Set();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cancelEvent.Set();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return ArmNowFunc(dasList, setProgressFunction, currentTest, onError);
|
||||
}
|
||||
protected bool ArmNowFunc(List<IDASCommunication> dasList, StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
DataModel.TestTemplate currentTest, ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
var cancelEvent = new ManualResetEvent(false);
|
||||
|
||||
if (Common.SerializedSettings.StoreTestHistoryInDb)
|
||||
{
|
||||
//add code here?
|
||||
}
|
||||
var g = Guid.NewGuid();
|
||||
|
||||
var bFailedArm = false;
|
||||
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
var bSomeoneArmed = false;
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
|
||||
done.Reset();
|
||||
var disarmList = new List<IDASCommunication>();
|
||||
PreparedArmNowFunc(dasList, g, ref bSomeoneArmed, ref bFailedArm, ref timeWaited, ref disarmList, setProgressFunction, currentTest,
|
||||
onError);
|
||||
|
||||
//for safety reasons, make a disarm call to _everybody_ that "failed to arm", incase a module armed but the rack didn't
|
||||
//http://fogbugz/fogbugz/default.asp?4527
|
||||
if (done.WaitOne(0, false) && disarmList.Count > 0)
|
||||
{
|
||||
done.Reset();
|
||||
bSomeoneArmed = false;
|
||||
using (var aService = new ArmingService())
|
||||
{
|
||||
aService.Disarm(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
}
|
||||
}
|
||||
, dasList);
|
||||
}
|
||||
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
if (bSomeoneArmed)
|
||||
{
|
||||
if (!cancelEvent.WaitOne(0, false))
|
||||
{
|
||||
var das = new List<IDASCommunication>(dasList);
|
||||
for (var i = das.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (null == das[i].DASArmStatus || das[i].DASArmStatus.IsArmed == false)
|
||||
{
|
||||
das.RemoveAt(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (null != das[i].ConfigData && das[i].ConfigData.NumberOfConfiguredChannels() == 0 /*&& CareAboutNumberOfConfiguredChannels(das[i])*/)
|
||||
{
|
||||
das.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
var bFailedEnableFaultChecking = false;
|
||||
var faultCheckingErrors = new List<string>();
|
||||
//keeps track of whether we need to restore semaphores
|
||||
//15630 limit EnableFaultChecking to single unit at a time for TDAS when there's a rack involved
|
||||
if (das.Count > 1)
|
||||
{
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
var done = new ManualResetEvent(false);
|
||||
var timeWaited = 0;
|
||||
armService.EnableFaultChecking(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
bFailedEnableFaultChecking = true;
|
||||
faultCheckingErrors.Add($"{cbd.Target.SerialNumber} {StringResources.FailedEnableFaultChecking}");
|
||||
onError(this, $"{StringResources.ArmSystem_FailedArm} {cbd.ErrorMessage} - {cbd.Target.SerialNumber}", cbd.ErrorException);
|
||||
break;
|
||||
}
|
||||
}, das);
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//15267 Stop on ERR response from TDAS ARM RF
|
||||
if (bFailedEnableFaultChecking)
|
||||
{
|
||||
DisarmAll(dasList);
|
||||
cancelEvent.Set();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bFailedArm)
|
||||
{
|
||||
cancelEvent.Set();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private void DisarmAll(List<IDASCommunication> das)
|
||||
{
|
||||
var mre = new ManualResetEvent(false);
|
||||
using (var aService = new ArmingService())
|
||||
{
|
||||
aService.Disarm(das, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
mre.Set();
|
||||
break;
|
||||
}
|
||||
}
|
||||
, das);
|
||||
}
|
||||
|
||||
mre.WaitOne();
|
||||
}
|
||||
private void PreparedArmNowFunc(List<IDASCommunication> dasList,
|
||||
Guid g,
|
||||
ref bool bSomeoneArmed,
|
||||
ref bool bFailedArm,
|
||||
ref int timeWaited,
|
||||
ref List<IDASCommunication> lDisarmList,
|
||||
StatusHelpers.SetProgressValueDelegate setProgressFunction,
|
||||
DataModel.TestTemplate currentTest,
|
||||
ServiceBase.ServiceCallbackErrorEventHandler onError)
|
||||
{
|
||||
var someoneArmed = false;
|
||||
var failedArm = false;
|
||||
var disarmList = new List<IDASCommunication>();
|
||||
var doneEvent = new ManualResetEvent(false);
|
||||
var cancelEvent = new ManualResetEvent(false);
|
||||
var done = doneEvent;
|
||||
using (var armService = new ArmingService())
|
||||
{
|
||||
armService.PreparedArmNow(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
onError(this, $"{StringResources.ArmSystem_FailedArm} {cbd.ErrorMessage} - {cbd.Target.SerialNumber}", cbd.ErrorException);
|
||||
disarmList.Add(cbd.Target);
|
||||
failedArm = true;
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
if (!cbd.Target.IsEthernetDistributor())
|
||||
{
|
||||
someoneArmed = true;
|
||||
try
|
||||
{
|
||||
if (null == cbd.Target.DASArmStatus) { cbd.Target.DASArmStatus = new ArmStatus(); }
|
||||
cbd.Target.DASArmStatus.IsArmed = true;
|
||||
cbd.Target.SetDASArmStatus();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex.Message);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
StatusHelpers.SetStatus2(cbd.Target, cbd.ProgressValue, TSRAIRGoStatus.StatusTypes.PREPARING_FOR_ARMING, setProgressFunction);
|
||||
break;
|
||||
}
|
||||
}, dasList, 30000, false, currentTest.NumberOfEvents, g, dasList.Count > 1); ///////////fix the 30000 and 1 (at least)
|
||||
}
|
||||
while (!cancelEvent.WaitOne(0, false) && !done.WaitOne(50, false))
|
||||
{
|
||||
timeWaited += 50;
|
||||
}
|
||||
bSomeoneArmed = bSomeoneArmed || someoneArmed;
|
||||
bFailedArm = bFailedArm || failedArm;
|
||||
lDisarmList.AddRange(disarmList);
|
||||
doneEvent = done;
|
||||
}
|
||||
public void SoftwareTrigger(List<IDASCommunication> dasList)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var armingService = new ArmingService())
|
||||
{
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
var mre = new ManualResetEvent(false);
|
||||
armingService.Trigger(dasList, delegate (ServiceBase.CallbackData data)
|
||||
{
|
||||
switch (data.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished: mre.Set(); break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure: APILogger.Log(data.ErrorMessage); break;
|
||||
}
|
||||
}, dasList);
|
||||
while (!mre.WaitOne(10, false)) { }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failure in Software Trigger");
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
public void DisarmAsync(List<IDASCommunication> dasList)
|
||||
{
|
||||
Disarm(dasList);
|
||||
}
|
||||
private void Disarm(List<IDASCommunication> dasList)
|
||||
{
|
||||
DisarmSync(dasList);
|
||||
}
|
||||
private void DisarmSync(List<IDASCommunication> dasList)
|
||||
{
|
||||
var mre = new ManualResetEvent(false);
|
||||
using (var armingService = new ArmingService())
|
||||
{
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
armingService.Disarm(
|
||||
dasList,
|
||||
delegate (ServiceBase.CallbackData data)
|
||||
{
|
||||
switch (data.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
mre.Set();
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Canceled:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
break;
|
||||
}
|
||||
},
|
||||
dasList);
|
||||
while (!mre.WaitOne(10, false)) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.DASLib.Service;
|
||||
using System.Threading;
|
||||
using DTS.Common.DataModel.Common;
|
||||
using DTS.Common;
|
||||
using DTS.Common.Enums.TSRAIRGo;
|
||||
using System.Windows.Forms;
|
||||
using DTS.Common.DataModel.Classes.TSRAIRGo;
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes
|
||||
{
|
||||
public class Configuration
|
||||
{
|
||||
public Configuration()
|
||||
{
|
||||
}
|
||||
public void SetConfig(DataModel.TestTemplate currentTest,
|
||||
List<IDASCommunication> dasList,
|
||||
bool calledDuringDiagnostics,
|
||||
StatusHelpers.SetProgressValueDelegate setProgressFunction)
|
||||
{
|
||||
lock (DASHardware.GetArmStatusLock)
|
||||
{
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
|
||||
var type = das.GetHardwareType();
|
||||
das.MinimumValidInputVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.MinimumValidInputThreshold));
|
||||
das.MaximumValidInputVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.MaximumValidInputThreshold));
|
||||
das.MinimumValidBatteryVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.MinimumValidBatteryThreshold));
|
||||
das.MaximumValidBatteryVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.MaximumValidBatteryThreshold));
|
||||
|
||||
StatusHelpers.SetStatus2(das, 0, TSRAIRGoStatus.StatusTypes.UPDATING_DAS_CONFIG, setProgressFunction);
|
||||
|
||||
if (calledDuringDiagnostics)
|
||||
{
|
||||
das.BatteryHighVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryHighDiagnosticsThreshold));
|
||||
das.BatteryMediumVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryMediumDiagnosticsThreshold));
|
||||
das.BatteryLowVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryLowDiagnosticsThreshold));
|
||||
das.InputHighVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputHighDiagnosticsThreshold));
|
||||
das.InputMediumVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputMediumDiagnosticsThreshold));
|
||||
das.InputLowVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputLowDiagnosticsThreshold));
|
||||
}
|
||||
else
|
||||
{
|
||||
das.BatteryHighVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryHighArmedThreshold));
|
||||
das.BatteryMediumVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryMediumArmedThreshold));
|
||||
das.BatteryLowVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.BatteryLowArmedThreshold));
|
||||
das.InputHighVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputHighArmedThreshold));
|
||||
das.InputMediumVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputMediumArmedThreshold));
|
||||
das.InputLowVoltage = Convert.ToSingle(DataModel.BatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), DataModel.BatteryAndInputVoltageDefaults.DasBatteryInputSettings.Settings.InputLowArmedThreshold));
|
||||
}
|
||||
}
|
||||
|
||||
//setting the configuration checks the hardware lines
|
||||
//so make sure we reset them prior to setting configuration
|
||||
using (var configService = new ConfigurationService())
|
||||
{
|
||||
var mreLocal = new ManualResetEvent(false);
|
||||
configService.ResetHardwareLines(dasList, delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished: mreLocal.Set(); break;
|
||||
}
|
||||
}, dasList);
|
||||
mreLocal.WaitOne();
|
||||
}
|
||||
|
||||
using (var config = new ConfigurationService())
|
||||
{
|
||||
config.AggregateProgress = false;
|
||||
var done = new ManualResetEvent(false);
|
||||
var elapsed = 0;
|
||||
try
|
||||
{
|
||||
config.SetConfiguration(dasList, true, true,
|
||||
delegate (ServiceBase.CallbackData cbd)
|
||||
{
|
||||
switch (cbd.Status)
|
||||
{
|
||||
case ServiceBase.CallbackData.CallbackStatus.Progress:
|
||||
StatusHelpers.SetStatus2(cbd.Target, cbd.ProgressValue, TSRAIRGoStatus.StatusTypes.UPDATING_DAS_CONFIG, setProgressFunction);
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.Success:
|
||||
case ServiceBase.CallbackData.CallbackStatus.Failure:
|
||||
break;
|
||||
case ServiceBase.CallbackData.CallbackStatus.AllFinished:
|
||||
done.Set();
|
||||
break;
|
||||
}
|
||||
},
|
||||
dasList,
|
||||
ErrorCallback,
|
||||
calledDuringDiagnostics,
|
||||
new double[] { Common.SerializedSettings.MaxAAFRate_TDAS, Common.SerializedSettings.MaxAAFRate_G5 },
|
||||
true,
|
||||
true,
|
||||
Common.SerializedSettings.GetDefaultDSP(),
|
||||
true
|
||||
);
|
||||
while (!done.WaitOne(50, false))
|
||||
{
|
||||
elapsed += 50;
|
||||
}
|
||||
CopyGlobalConfigsToLocalFolder(currentTest, dasList);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static DialogResult ErrorCallback(string errorString, string units)
|
||||
{
|
||||
APILogger.Log("error setting configuration", errorString);
|
||||
return DialogResult.OK; //Fix this
|
||||
}
|
||||
private void CopyGlobalConfigsToLocalFolder(DataModel.TestTemplate currentTest, List<IDASCommunication> dasList)
|
||||
{
|
||||
var sourcePath = System.IO.Path.Combine(Environment.CurrentDirectory, Constants.DAS_CONFIGS);
|
||||
var destPath = System.IO.Path.Combine(currentTest.TestDirectory.Trim(), Constants.DAS_CONFIGS);
|
||||
try
|
||||
{
|
||||
if (!System.IO.Directory.Exists(destPath))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(destPath);
|
||||
}
|
||||
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
//Copy the entire das config
|
||||
var sourceFileName = System.IO.Path.Combine(sourcePath, $"{((InfoResult)das.DASInfo).OwningDAS}.xml");
|
||||
var destFileName = System.IO.Path.Combine(destPath, $"{((InfoResult)das.DASInfo).OwningDAS}.xml");
|
||||
if (System.IO.File.Exists(sourceFileName))
|
||||
{
|
||||
System.IO.File.Copy(sourceFileName, destFileName, true);
|
||||
}
|
||||
|
||||
foreach (var module in das.DASInfo.Modules)
|
||||
{
|
||||
//Copy each module config
|
||||
sourceFileName = System.IO.Path.Combine(sourcePath, $"{module.SerialNumber}.xml");
|
||||
if (!System.IO.File.Exists(sourceFileName)) continue;
|
||||
destFileName = System.IO.Path.Combine(destPath, $"{module.SerialNumber}.xml");
|
||||
System.IO.File.Copy(sourceFileName, destFileName, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1757
Common/DTS.Common.DataModel/Classes/Diagnostics/Diagnostics.cs
Normal file
1757
Common/DTS.Common.DataModel/Classes/Diagnostics/Diagnostics.cs
Normal file
File diff suppressed because it is too large
Load Diff
56
Common/DTS.Common.DataModel/Classes/Enums.cs
Normal file
56
Common/DTS.Common.DataModel/Classes/Enums.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public enum IsoChannelSensorCompatibilityLevels
|
||||
{
|
||||
DontWarn,
|
||||
Warn,
|
||||
DontAllow
|
||||
}
|
||||
public enum SupportedExportFormats
|
||||
{
|
||||
[Description("CSV")]
|
||||
csv,
|
||||
[Description("Diadem")]
|
||||
diadem,
|
||||
[Description("ISO")]
|
||||
iso,
|
||||
[Description("SOMAT")]
|
||||
somat,
|
||||
[Description("TDAS")]
|
||||
tdas,
|
||||
[Description("TSV")]
|
||||
tsv,
|
||||
[Description("TTS")]
|
||||
tts,
|
||||
[Description("RDF")]
|
||||
rdf,
|
||||
[Description("TDMS")]
|
||||
tdms,
|
||||
[Description("DDAS")]
|
||||
ddas,
|
||||
[Description("HDF5")]
|
||||
hdf,
|
||||
[Description("XLSX")]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
xlsx,
|
||||
//DataPRO 3.3, IRIG 106 Chapter 10 export
|
||||
[Description("Chapter10")]
|
||||
chapter10,
|
||||
[Description("ASC")]
|
||||
asc,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public enum StrictLevel
|
||||
{
|
||||
Strict,
|
||||
UpdateTable,
|
||||
CheckoutOnly,
|
||||
QuickCheckout
|
||||
}
|
||||
}
|
||||
48
Common/DTS.Common.DataModel/Classes/Export/ExportHeader.cs
Normal file
48
Common/DTS.Common.DataModel/Classes/Export/ExportHeader.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using DTS.Common.Interface.ExportData;
|
||||
using System.ComponentModel;
|
||||
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes.Export
|
||||
{
|
||||
public class ExportHeader : IExportHeader
|
||||
{
|
||||
public ExportHeader()
|
||||
{
|
||||
}
|
||||
public ExportHeader(string headerName)
|
||||
{
|
||||
HeaderName = headerName;
|
||||
}
|
||||
public ExportHeader(string headerName, bool isSelected) : this(headerName)
|
||||
{
|
||||
IsSelected = isSelected;
|
||||
}
|
||||
private string _headerName;
|
||||
public string HeaderName
|
||||
{
|
||||
get { return _headerName; }
|
||||
set
|
||||
{
|
||||
_headerName = value;
|
||||
OnPropertyChanged("HeaderName");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isSelected = false;
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return _isSelected; }
|
||||
set
|
||||
{
|
||||
_isSelected = value;
|
||||
OnPropertyChanged("IsSelected");
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
751
Common/DTS.Common.DataModel/Classes/Export/ExportTestSetup.cs
Normal file
751
Common/DTS.Common.DataModel/Classes/Export/ExportTestSetup.cs
Normal file
@@ -0,0 +1,751 @@
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Interface.Groups.GroupList;
|
||||
using DTS.SensorDB;
|
||||
using DTS.Common.Interface.Sensors;
|
||||
using DTS.Common.Interface.Channels;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Threading;
|
||||
using System;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using DTS.Common.Storage;
|
||||
using Prism.Ioc;
|
||||
using DTS.Common.ISO;
|
||||
using DTS.Common.Utils;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using System.Text;
|
||||
using Unity;
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes
|
||||
{
|
||||
public static class ExportTestSetup
|
||||
{
|
||||
public static void PrepareForExport(DataModel.TestTemplate t,
|
||||
Dictionary<string, DataModel.TestTemplate> includedTests,
|
||||
Dictionary<string, IGroup> includedGroups,
|
||||
Dictionary<string, DataModel.DASHardware> includedDAS,
|
||||
Dictionary<string, SensorData> includedSensors,
|
||||
HashSet<int> sensorsAlreadyAdded,
|
||||
Dictionary<string, SensorModel> includedSensorModels,
|
||||
Dictionary<string, SensorCalibration[]> includedCalibration,
|
||||
Dictionary<string, DTS.Common.ISO.CustomerDetails> includedCustomerDetails,
|
||||
Dictionary<string, DTS.Common.ISO.TestEngineerDetails> includedTestEngineerDetails,
|
||||
Dictionary<string, DTS.Common.ISO.LabratoryDetails> includedLabDetails,
|
||||
bool savingRunningTest,
|
||||
// ReSharper disable once InconsistentNaming
|
||||
bool savingTTSImport
|
||||
)
|
||||
{
|
||||
if (!includedTests.ContainsKey(t.Name)) { includedTests[t.Name] = t; }
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(t.CustomerDetails?.Name))
|
||||
{
|
||||
includedCustomerDetails[t.CustomerDetails.Name] = t.CustomerDetails.GetISOCustomer();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(t.TestEngineerDetails?.Name))
|
||||
{
|
||||
includedTestEngineerDetails[t.TestEngineerDetails.Name] = t.TestEngineerDetails.GetISOTestEngineer();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(t.LabDetails?.Name))
|
||||
{
|
||||
includedLabDetails[t.LabDetails.Name] = t.LabDetails.GetIsoLab();
|
||||
}
|
||||
|
||||
var groups = new List<IGroup>(t.Groups);
|
||||
|
||||
var sensorLookup = new Dictionary<int, ISensorData>();
|
||||
var sensors = SensorsCollection.SensorsList.GetAllSensors(false);
|
||||
foreach (var s in sensors)
|
||||
{
|
||||
sensorLookup[s.DatabaseId] = s;
|
||||
}
|
||||
var hardwareList = GetHardware();
|
||||
var dasList = DTS.Common.ISO.Hardware.GetAllDAS();
|
||||
foreach (var embeddedGroup in groups)
|
||||
{
|
||||
//Find the channels in this embedded Group so the Sensors will be included
|
||||
var groupChannelList = new List<IGroupChannel>();
|
||||
foreach (var groupChannelsList in t.ChannelsForGroup) //make this a linq statement?
|
||||
{
|
||||
if (groupChannelsList.Key == embeddedGroup)
|
||||
{
|
||||
groupChannelList = groupChannelsList.Value.ToList();
|
||||
}
|
||||
}
|
||||
foreach (var groupChannel in groupChannelList)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(groupChannel.Sensor))
|
||||
{
|
||||
var sd = SensorsCollection.SensorsList.GetOriginalSensorBySensorDatabaseId(
|
||||
groupChannel.SensorId);
|
||||
var scs = SensorCalibration.GetCalibrationsBySerialNumber(sd);
|
||||
if (null != sd && null != scs && scs.Length > 0)
|
||||
{
|
||||
if (!sensorsAlreadyAdded.Contains(sd.DatabaseId))
|
||||
{
|
||||
if (!sd.IsTestSpecificDigitalOutput && !sd.IsTestSpecificSquib && !sd.IsTestSpecificDigitalIn)
|
||||
{
|
||||
includedCalibration.Add(sd.SerialNumber, scs);
|
||||
}
|
||||
|
||||
includedSensors.Add(sd.SerialNumber, sd);
|
||||
sensorsAlreadyAdded.Add(sd.DatabaseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var dasId in embeddedGroup.IncludedHardware)
|
||||
{
|
||||
var h = GetDAS(hardwareList, dasId, dasList);
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, new DataModel.DASHardware(h));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If there's a non-imbedded (static) Group in the db, process it too.
|
||||
IGroup nonEmbeddedGroup = null;
|
||||
if (embeddedGroup.StaticGroupId != null)
|
||||
{
|
||||
if (System.Windows.Application.Current.Dispatcher.CheckAccess())
|
||||
{
|
||||
nonEmbeddedGroup = GetNonEmbeddedGroup(embeddedGroup.StaticGroupId);
|
||||
}
|
||||
else
|
||||
{
|
||||
ManualResetEvent manualResetEvent = new ManualResetEvent(false);
|
||||
|
||||
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
nonEmbeddedGroup = GetNonEmbeddedGroup(embeddedGroup.StaticGroupId);
|
||||
manualResetEvent.Set();
|
||||
}));
|
||||
|
||||
|
||||
manualResetEvent.WaitOne();
|
||||
}
|
||||
}
|
||||
|
||||
if (nonEmbeddedGroup == null || nonEmbeddedGroup.Id != embeddedGroup.StaticGroupId)
|
||||
{
|
||||
//We can get here if the static Group was created from a static Group which was later deleted,
|
||||
//but the embedded Group didn't have its StaticGroupId set to null (also fixed in this patch,
|
||||
//but pre-existing embedded Groups in the database could be pointing to a non-existent record)
|
||||
embeddedGroup.StaticGroupId = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
var hardwareLookup = new Dictionary<int, IDASHardware>();
|
||||
using (var enumHardware = includedDAS.GetEnumerator())
|
||||
{
|
||||
while (enumHardware.MoveNext()) { hardwareLookup[enumHardware.Current.Value.DASId] = enumHardware.Current.Value; }
|
||||
}
|
||||
|
||||
var channelDefaults = DbOperations.GetChannelSettingDefaults();
|
||||
|
||||
var groupChannelArray = nonEmbeddedGroup.GetAllChannels(false, sensorLookup, hardwareLookup, channelDefaults);
|
||||
foreach (var groupChannel in groupChannelArray)
|
||||
{
|
||||
nonEmbeddedGroup.GroupChannelList.Add(groupChannel);
|
||||
nonEmbeddedGroup.ChannelCount++;
|
||||
}
|
||||
|
||||
var channels = t.ChannelsForGroup[embeddedGroup];
|
||||
|
||||
foreach (var groupChannel in channels)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(groupChannel.Sensor))
|
||||
{
|
||||
var sd = SensorsCollection.SensorsList.GetOriginalSensorBySensorDatabaseId(groupChannel.SensorId);
|
||||
var scs = SensorCalibration.GetCalibrationsBySerialNumber(sd);
|
||||
if (null != sd && null != scs && scs.Length > 0)
|
||||
{
|
||||
if (!sensorsAlreadyAdded.Contains(sd.DatabaseId))
|
||||
{
|
||||
if (!sd.IsTestSpecificSquib && !sd.IsTestSpecificDigitalOutput && !sd.IsTestSpecificDigitalIn)
|
||||
{
|
||||
includedCalibration.Add(sd.SerialNumber, scs);
|
||||
}
|
||||
|
||||
includedSensors.Add(sd.SerialNumber, sd);
|
||||
sensorsAlreadyAdded.Add(sd.DatabaseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var dasId in nonEmbeddedGroup.IncludedHardware)
|
||||
{
|
||||
var h = GetDAS(hardwareList, dasId, dasList);
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, new DataModel.DASHardware(h));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Only add static Groups to includedGroups
|
||||
if (!includedGroups.ContainsKey(nonEmbeddedGroup.Name))
|
||||
{
|
||||
includedGroups.Add(nonEmbeddedGroup.Name, nonEmbeddedGroup);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var group in t.Groups)
|
||||
{
|
||||
var channels = t.ChannelsForGroup[group];
|
||||
foreach (var ch in channels)
|
||||
{
|
||||
if (ch.IsBlank())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch.SensorId > 0)
|
||||
{
|
||||
var sd = SensorsCollection.SensorsList.GetOriginalSensorBySensorDatabaseId(ch.SensorId);
|
||||
if (!includedSensors.ContainsKey(sd.SerialNumber))
|
||||
{
|
||||
if (!sensorsAlreadyAdded.Contains(sd.DatabaseId))
|
||||
{
|
||||
includedSensors.Add(sd.SerialNumber, sd);
|
||||
if (!sd.IsTestSpecificDigitalOutput && !sd.IsTestSpecificSquib && !sd.IsTestSpecificDigitalIn)
|
||||
{
|
||||
var scs = SensorCalibration.GetCalibrationsBySerialNumber(sd);
|
||||
includedCalibration.Add(sd.SerialNumber, scs);
|
||||
var sm = SensorModelCollection.SensorModelList.GetSensorModel(sd.Manufacturer,
|
||||
sd.Model);
|
||||
if (null == sm)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var key = $"{sm.Manufacturer}x_x{sm.Model}";
|
||||
if (!includedSensorModels.ContainsKey(key))
|
||||
{
|
||||
includedSensorModels.Add(key, sm);
|
||||
}
|
||||
}
|
||||
|
||||
sensorsAlreadyAdded.Add(sd.DatabaseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var hardware = t.GetHardware();
|
||||
foreach (var h in hardware)
|
||||
{
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, h);
|
||||
}
|
||||
}
|
||||
|
||||
if (!savingTTSImport) return;
|
||||
var allSensors = SensorsCollection.SensorsList.GetAllSensors(true);
|
||||
foreach (var sd in allSensors)
|
||||
{
|
||||
if (includedSensors.ContainsKey(sd.SerialNumber)) continue;
|
||||
var scs = SensorCalibration.GetCalibrationsBySerialNumber(sd);
|
||||
if (null != scs && scs.Length > 0)
|
||||
{
|
||||
includedCalibration.Add(sd.SerialNumber, scs);
|
||||
includedSensors.Add(sd.SerialNumber, sd);
|
||||
var sm = SensorModelCollection.SensorModelList.GetSensorModel(sd.Manufacturer,
|
||||
sd.Model);
|
||||
if (null == sm) continue;
|
||||
var key = $"{sm.Manufacturer}x_x{sm.Model}";
|
||||
if (!includedSensorModels.ContainsKey(key))
|
||||
{
|
||||
includedSensorModels.Add(key, sm);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine("calibration record is null");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static string ExportToFile(Dictionary<string, DataModel.TestTemplate> includedTests,
|
||||
Dictionary<string, IGroup> includedGroups,
|
||||
Dictionary<string, DataModel.DASHardware> includedDAS,
|
||||
Dictionary<string, SensorData> includedSensors,
|
||||
Dictionary<string, SensorModel> includedSensorModels,
|
||||
Dictionary<string, SensorCalibration[]> includedCalibration,
|
||||
Dictionary<string, DTS.Common.ISO.CustomerDetails> includedCustomerDetails,
|
||||
Dictionary<string, DTS.Common.ISO.TestEngineerDetails> includedTestEngineerDetails,
|
||||
Dictionary<string, DTS.Common.ISO.LabratoryDetails> includedLabDetails,
|
||||
Dictionary<string, DTS.Slice.Users.User> includedUsers,
|
||||
Dictionary<string, string> includedGlobalSettings,
|
||||
string exportFile,
|
||||
string originalImportFile,
|
||||
bool bUseFirstUseDate = true)
|
||||
{
|
||||
double totalStepsToComplete = includedCalibration.Count + includedDAS.Count +
|
||||
includedGroups.Count +
|
||||
+includedSensorModels.Count + includedSensors.Count + includedTests.Count +
|
||||
includedLabDetails.Count
|
||||
+ includedCustomerDetails.Count + includedTestEngineerDetails.Count +
|
||||
includedUsers.Count + includedGlobalSettings.Count;
|
||||
|
||||
double done = 0;
|
||||
var writer = FileUtils.GetExportWriter(Convert.ToInt32(totalStepsToComplete), FileUtils.CurrentXmlVersion,
|
||||
System.Reflection.Assembly.GetEntryAssembly().GetName().Name,
|
||||
System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(4), APILogger.Log, out var sb);
|
||||
|
||||
try
|
||||
{
|
||||
writer.WriteAttributeString("OriginalImportFile", originalImportFile);
|
||||
|
||||
var fields = Enum.GetValues(typeof(TopLevelFields)).Cast<TopLevelFields>().ToArray();
|
||||
|
||||
foreach (var f in fields)
|
||||
{
|
||||
switch (f)
|
||||
{
|
||||
case TopLevelFields.Calibrations:
|
||||
if (includedCalibration.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var c in includedCalibration)
|
||||
{
|
||||
foreach (var sc in c.Value) { writer.Flush(); sc.WriteXML(ref writer); writer.Flush(); }
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.CustomChannels:
|
||||
break;
|
||||
case TopLevelFields.DASList:
|
||||
if (includedDAS.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var h in includedDAS)
|
||||
{
|
||||
writer.Flush(); h.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.Groups:
|
||||
if (includedGroups.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var g in includedGroups)
|
||||
{
|
||||
writer.Flush(); g.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.GroupTemplates:
|
||||
break;
|
||||
case TopLevelFields.SensorModels:
|
||||
if (includedSensorModels.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var sm in includedSensorModels)
|
||||
{
|
||||
writer.Flush(); sm.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.Sensors:
|
||||
if (includedSensors.Count > 0)
|
||||
{
|
||||
writer.Flush();
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var sd in includedSensors)
|
||||
{
|
||||
writer.Flush(); sd.Value.WriteXML(ref writer, bUseFirstUseDate); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.TestSetups:
|
||||
if (includedTests.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var t in includedTests)
|
||||
{
|
||||
writer.Flush(); t.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.CustomerDetails:
|
||||
if (includedCustomerDetails.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var c in includedCustomerDetails)
|
||||
{
|
||||
writer.Flush(); c.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.Users:
|
||||
if (includedUsers.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
|
||||
foreach (var user in includedUsers)
|
||||
{
|
||||
writer.Flush();
|
||||
user.Value.WriteXML(ref writer);
|
||||
writer.Flush();
|
||||
done++;
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.TestEngineerDetails:
|
||||
if (includedTestEngineerDetails.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var c in includedTestEngineerDetails)
|
||||
{
|
||||
writer.Flush(); c.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.LabDetails:
|
||||
if (includedLabDetails.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
|
||||
foreach (var ld in includedLabDetails)
|
||||
{
|
||||
writer.Flush(); ld.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.CustomDirections:
|
||||
case TopLevelFields.CustomFilterClasses:
|
||||
case TopLevelFields.CustomFinLoc1s:
|
||||
case TopLevelFields.CustomFinLoc2s:
|
||||
case TopLevelFields.CustomFinLoc3s:
|
||||
case TopLevelFields.CustomMainLocs:
|
||||
case TopLevelFields.CustomTestObjects:
|
||||
case TopLevelFields.CustomPhysicalDimensions:
|
||||
case TopLevelFields.CustomPositions:
|
||||
break;
|
||||
case TopLevelFields.GlobalSettings:
|
||||
{
|
||||
if (includedGlobalSettings.Any())
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
|
||||
foreach (var setting in includedGlobalSettings)
|
||||
{
|
||||
writer.Flush();
|
||||
WriteGlobalSetting(setting.Key, setting.Value, ref writer);
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.SensorChangeHistory: break;
|
||||
default:
|
||||
throw new NotSupportedException("ExportTestSetup::ExportFunc unknown element: " + f);
|
||||
}
|
||||
}
|
||||
writer.WriteEndElement();//exportdocument
|
||||
writer.WriteEndDocument();
|
||||
|
||||
writer.Flush();
|
||||
writer.Close();
|
||||
if (null != exportFile)
|
||||
{
|
||||
System.IO.File.WriteAllText(exportFile, sb.ToString(), Encoding.Unicode);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
private static IGroup GetNonEmbeddedGroup(int? embeddedGroupStaticGroupId)
|
||||
{
|
||||
var unityContainer = ContainerLocator.Container.Resolve<IUnityContainer>();
|
||||
var vm = unityContainer.Resolve<IGroupListViewModel>();
|
||||
var g = vm.GetGroup(embeddedGroupStaticGroupId);
|
||||
return g;
|
||||
}
|
||||
private static List<DTS.Common.ISO.Hardware> GetHardware()
|
||||
{
|
||||
var hardwareList = new List<DTS.Common.ISO.Hardware>();
|
||||
var hResult = DbOperations.DASGet(null, null, out var dbDAS);
|
||||
if (0 == hResult)
|
||||
{
|
||||
foreach (var das in dbDAS)
|
||||
{
|
||||
hardwareList.Add(new DTS.Common.ISO.Hardware(das));
|
||||
}
|
||||
}
|
||||
return hardwareList;
|
||||
}
|
||||
private static DTS.Common.ISO.Hardware GetDAS(List<DTS.Common.ISO.Hardware> hardwareList, int hardwareId, DTS.Common.ISO.Hardware[] dasList)
|
||||
{
|
||||
var dasSerialNumber = GetHardwareSerialNumber(hardwareList, hardwareId);
|
||||
foreach (var das in dasList)
|
||||
{
|
||||
if (das.SerialNumber == dasSerialNumber)
|
||||
{
|
||||
return das;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static string GetHardwareSerialNumber(List<DTS.Common.ISO.Hardware> hardwareList, int hId)
|
||||
{
|
||||
foreach (var hardware in hardwareList)
|
||||
{
|
||||
if (hardware.DASId == hId)
|
||||
{
|
||||
return hardware.SerialNumber;
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
private static void WriteGlobalSetting(string key, string value, ref System.Xml.XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("Setting");
|
||||
writer.WriteStartElement("SettingName");
|
||||
writer.WriteString(key);
|
||||
writer.WriteEndElement();
|
||||
writer.WriteStartElement("SettingValue");
|
||||
writer.WriteString(value);
|
||||
writer.WriteEndElement();
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
public static void PrepareForExportFields(DataModel.TestTemplate t,
|
||||
Dictionary<string, DataModel.TestTemplate> includedTests,
|
||||
Dictionary<string, DataModel.DASHardware> includedDAS
|
||||
)
|
||||
{
|
||||
if (!includedTests.ContainsKey(t.Name)) { includedTests[t.Name] = t; }
|
||||
|
||||
var groups = new List<IGroup>(t.Groups);
|
||||
|
||||
var sensorLookup = new Dictionary<int, ISensorData>();
|
||||
var sensors = SensorsCollection.SensorsList.GetAllSensors(false);
|
||||
foreach (var s in sensors)
|
||||
{
|
||||
sensorLookup[s.DatabaseId] = s;
|
||||
}
|
||||
var hardwareList = GetHardware();
|
||||
var dasList = DTS.Common.ISO.Hardware.GetAllDAS();
|
||||
foreach (var embeddedGroup in groups)
|
||||
{
|
||||
//Find the channels in this embedded Group so the Sensors will be included
|
||||
var groupChannelList = new List<IGroupChannel>();
|
||||
foreach (var groupChannelsList in t.ChannelsForGroup) //make this a linq statement?
|
||||
{
|
||||
if (groupChannelsList.Key == embeddedGroup)
|
||||
{
|
||||
groupChannelList = groupChannelsList.Value.ToList();
|
||||
}
|
||||
}
|
||||
foreach (var groupChannel in groupChannelList)
|
||||
{
|
||||
foreach (var dasId in embeddedGroup.IncludedHardware)
|
||||
{
|
||||
var h = GetDAS(hardwareList, dasId, dasList);
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, new DataModel.DASHardware(h));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If there's a non-imbedded (static) Group in the db, process it too.
|
||||
IGroup nonEmbeddedGroup = null;
|
||||
if (embeddedGroup.StaticGroupId != null)
|
||||
{
|
||||
if (Application.Current.Dispatcher.CheckAccess())
|
||||
{
|
||||
nonEmbeddedGroup = GetNonEmbeddedGroup(embeddedGroup.StaticGroupId);
|
||||
}
|
||||
else
|
||||
{
|
||||
ManualResetEvent manualResetEvent = new ManualResetEvent(false);
|
||||
|
||||
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
nonEmbeddedGroup = GetNonEmbeddedGroup(embeddedGroup.StaticGroupId);
|
||||
manualResetEvent.Set();
|
||||
}));
|
||||
|
||||
|
||||
manualResetEvent.WaitOne();
|
||||
}
|
||||
}
|
||||
|
||||
if (nonEmbeddedGroup == null || nonEmbeddedGroup.Id != embeddedGroup.StaticGroupId)
|
||||
{
|
||||
//We can get here if the static Group was created from a static Group which was later deleted,
|
||||
//but the embedded Group didn't have its StaticGroupId set to null (also fixed in this patch,
|
||||
//but pre-existing embedded Groups in the database could be pointing to a non-existent record)
|
||||
embeddedGroup.StaticGroupId = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
var hardwareLookup = new Dictionary<int, IDASHardware>();
|
||||
using (var enumHardware = includedDAS.GetEnumerator())
|
||||
{
|
||||
while (enumHardware.MoveNext()) { hardwareLookup[enumHardware.Current.Value.DASId] = enumHardware.Current.Value; }
|
||||
}
|
||||
|
||||
var channelDefaults = DbOperations.GetChannelSettingDefaults();
|
||||
|
||||
var groupChannelArray = nonEmbeddedGroup.GetAllChannels(false, sensorLookup, hardwareLookup, channelDefaults);
|
||||
foreach (var groupChannel in groupChannelArray)
|
||||
{
|
||||
nonEmbeddedGroup.GroupChannelList.Add(groupChannel);
|
||||
nonEmbeddedGroup.ChannelCount++;
|
||||
}
|
||||
|
||||
var channels = t.ChannelsForGroup[embeddedGroup];
|
||||
|
||||
foreach (var groupChannel in channels)
|
||||
{
|
||||
foreach (var dasId in nonEmbeddedGroup.IncludedHardware)
|
||||
{
|
||||
var h = GetDAS(hardwareList, dasId, dasList);
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, new DataModel.DASHardware(h));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var hardware = t.GetHardware();
|
||||
foreach (var h in hardware)
|
||||
{
|
||||
if (!includedDAS.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
includedDAS.Add(h.SerialNumber, h);
|
||||
}
|
||||
}
|
||||
foreach (var h in hardwareList)
|
||||
{
|
||||
if (includedDAS.ContainsKey(h.SerialNumber)) continue;
|
||||
|
||||
if (t.DASSampleRateList.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
t.DASSampleRateList.Remove(h.SerialNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static string ExportToFileFields(Dictionary<string, DataModel.TestTemplate> includedTests,
|
||||
Dictionary<string, DataModel.DASHardware> includedDAS,
|
||||
string originalImportFile)
|
||||
{
|
||||
double totalStepsToComplete = includedDAS.Count +
|
||||
includedTests.Count;
|
||||
|
||||
double done = 0;
|
||||
var writer = FileUtils.GetExportWriter(Convert.ToInt32(totalStepsToComplete), FileUtils.CurrentXmlVersion,
|
||||
System.Reflection.Assembly.GetEntryAssembly().GetName().Name,
|
||||
System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(4), APILogger.Log, out var sb);
|
||||
|
||||
try
|
||||
{
|
||||
writer.WriteAttributeString("OriginalImportFile", originalImportFile);
|
||||
|
||||
var fields = Enum.GetValues(typeof(TopLevelFields)).Cast<TopLevelFields>().ToArray();
|
||||
|
||||
foreach (var f in fields)
|
||||
{
|
||||
switch (f)
|
||||
{
|
||||
case TopLevelFields.DASList:
|
||||
if (includedDAS.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var h in includedDAS)
|
||||
{
|
||||
writer.Flush(); h.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.TestSetups:
|
||||
if (includedTests.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(f.ToString());
|
||||
foreach (var t in includedTests)
|
||||
{
|
||||
writer.Flush(); t.Value.WriteXML(ref writer); writer.Flush();
|
||||
done++;
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
break;
|
||||
case TopLevelFields.CustomerDetails:
|
||||
case TopLevelFields.Users:
|
||||
case TopLevelFields.Calibrations:
|
||||
case TopLevelFields.CustomChannels:
|
||||
case TopLevelFields.Groups:
|
||||
case TopLevelFields.GroupTemplates:
|
||||
case TopLevelFields.SensorModels:
|
||||
case TopLevelFields.Sensors:
|
||||
case TopLevelFields.TestEngineerDetails:
|
||||
case TopLevelFields.LabDetails:
|
||||
case TopLevelFields.CustomDirections:
|
||||
case TopLevelFields.CustomFilterClasses:
|
||||
case TopLevelFields.CustomFinLoc1s:
|
||||
case TopLevelFields.CustomFinLoc2s:
|
||||
case TopLevelFields.CustomFinLoc3s:
|
||||
case TopLevelFields.CustomMainLocs:
|
||||
case TopLevelFields.CustomTestObjects:
|
||||
case TopLevelFields.CustomPhysicalDimensions:
|
||||
case TopLevelFields.CustomPositions:
|
||||
case TopLevelFields.GlobalSettings:
|
||||
case TopLevelFields.SensorChangeHistory:
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("ExportTestSetup::ExportFunc unknown element: " + f);
|
||||
}
|
||||
}
|
||||
writer.WriteEndElement();//exportdocument
|
||||
writer.WriteEndDocument();
|
||||
|
||||
writer.Flush();
|
||||
writer.Close();
|
||||
return sb.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
|
||||
namespace DataPROWin7.DataModel.BatteryAndInputVoltageDefaults
|
||||
{
|
||||
public class DasBatteryInputSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// all possible battery settings
|
||||
/// note that the order is important since serialization assumes this order,
|
||||
/// so don't change order without addressing that.
|
||||
/// </summary>
|
||||
public enum Settings
|
||||
{
|
||||
BatteryLowDiagnosticsThreshold,
|
||||
BatteryHighDiagnosticsThreshold,
|
||||
BatteryLowArmedThreshold,
|
||||
BatteryHighArmedThreshold,
|
||||
InputLowDiagnosticsThreshold,
|
||||
InputHighDiagnosticsThreshold,
|
||||
InputLowArmedThreshold,
|
||||
InputHighArmedThreshold,
|
||||
MinimumValidBatteryThreshold,
|
||||
MinimumValidInputThreshold,
|
||||
MaximumValidBatteryThreshold,
|
||||
MaximumValidInputThreshold,
|
||||
BatteryMediumDiagnosticsThreshold,
|
||||
BatteryMediumArmedThreshold,
|
||||
InputMediumDiagnosticsThreshold,
|
||||
InputMediumArmedThreshold,
|
||||
}
|
||||
|
||||
public double BatteryLowDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryLowDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryLowDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryHighDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryHighDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryHighDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryLowArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryLowArmedThreshold);
|
||||
set => SetValue(Settings.BatteryLowArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryHighArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryHighArmedThreshold);
|
||||
set => SetValue(Settings.BatteryHighArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputLowDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputLowDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputLowDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputHighDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputHighDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputHighDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputLowArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputLowArmedThreshold);
|
||||
set => SetValue(Settings.InputLowArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputHighArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputHighArmedThreshold);
|
||||
set => SetValue(Settings.InputHighArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double MinimumValidBatteryThreshold
|
||||
{
|
||||
get => GetValue(Settings.MinimumValidBatteryThreshold);
|
||||
set => SetValue(Settings.MinimumValidBatteryThreshold, value);
|
||||
}
|
||||
|
||||
public double MinimumValidInputThreshold
|
||||
{
|
||||
get => GetValue(Settings.MinimumValidInputThreshold);
|
||||
set => SetValue(Settings.MinimumValidInputThreshold, value);
|
||||
}
|
||||
|
||||
public double MaximumValidBatteryThreshold
|
||||
{
|
||||
get => GetValue(Settings.MaximumValidBatteryThreshold);
|
||||
set => SetValue(Settings.MaximumValidBatteryThreshold, value);
|
||||
}
|
||||
|
||||
public double MaximumValidInputThreshold
|
||||
{
|
||||
get => GetValue(Settings.MaximumValidInputThreshold);
|
||||
set => SetValue(Settings.MaximumValidInputThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryMediumDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryMediumDiagnosticsThreshold);
|
||||
set => SetValue(Settings.BatteryMediumDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double BatteryMediumArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.BatteryMediumArmedThreshold);
|
||||
set => SetValue(Settings.BatteryMediumArmedThreshold, value);
|
||||
}
|
||||
|
||||
public double InputMediumDiagnosticsThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputMediumDiagnosticsThreshold);
|
||||
set => SetValue(Settings.InputMediumDiagnosticsThreshold, value);
|
||||
}
|
||||
|
||||
public double InputMediumArmedThreshold
|
||||
{
|
||||
get => GetValue(Settings.InputMediumArmedThreshold);
|
||||
set => SetValue(Settings.InputMediumArmedThreshold, value);
|
||||
}
|
||||
public Dictionary<Settings, double> SettingsProperty { get; } = new Dictionary<Settings, double>();
|
||||
|
||||
public DasBatteryInputSettings(string s)
|
||||
{
|
||||
var tokens = s.Split(new char[] { ',' });
|
||||
for (int i = 0; i < tokens.Length; i++)
|
||||
{
|
||||
var setting = (Settings)i;
|
||||
if (double.TryParse(tokens[i], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out double d))
|
||||
{
|
||||
SettingsProperty[setting] = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
public DasBatteryInputSettings(DasBatteryInputSettings copy)
|
||||
{
|
||||
using (var e = copy.SettingsProperty.GetEnumerator())
|
||||
{
|
||||
while (e.MoveNext())
|
||||
{
|
||||
SettingsProperty[e.Current.Key] = e.Current.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public DasBatteryInputSettings()
|
||||
{
|
||||
var settings = Enum.GetValues(typeof(Settings)).Cast<Settings>().ToArray();
|
||||
foreach (var s in settings)
|
||||
{
|
||||
double d = double.NaN;
|
||||
switch (s)
|
||||
{
|
||||
case Settings.BatteryHighArmedThreshold: d = 9D; break;
|
||||
case Settings.BatteryHighDiagnosticsThreshold: d = 9D; break;
|
||||
case Settings.BatteryLowArmedThreshold: d = 6.8D; break;
|
||||
case Settings.BatteryLowDiagnosticsThreshold: d = 7.8D; break;
|
||||
case Settings.InputHighArmedThreshold: d = 15.3; break;
|
||||
case Settings.InputHighDiagnosticsThreshold: d = 15.3; break;
|
||||
case Settings.InputLowArmedThreshold: d = 6.5D; break;
|
||||
case Settings.InputLowDiagnosticsThreshold: d = 10D; break;
|
||||
case Settings.MinimumValidBatteryThreshold: d = 4D; break;
|
||||
case Settings.MinimumValidInputThreshold: d = 4D; break;
|
||||
case Settings.MaximumValidBatteryThreshold: d = 9D; break;
|
||||
case Settings.MaximumValidInputThreshold: d = 19D; break;
|
||||
|
||||
case Settings.BatteryMediumArmedThreshold: d = 7.9D; break; //7.9 is halfway between low and high
|
||||
case Settings.BatteryMediumDiagnosticsThreshold: d = 8.4D; break; //8.4 is halfway between low and high
|
||||
case Settings.InputMediumArmedThreshold: d = 10.9D; break; //10.9 is halfway between low and high
|
||||
case Settings.InputMediumDiagnosticsThreshold: d = 12.7D; break; //12.7 is halfway between low and high
|
||||
|
||||
default: throw new NotSupportedException("Unknown Battery setting: " + s.ToString());
|
||||
}
|
||||
SettingsProperty[s] = d;
|
||||
}
|
||||
}
|
||||
public string ToSerializedString()
|
||||
{
|
||||
var settings = Enum.GetValues(typeof(Settings)).Cast<Settings>().ToArray();
|
||||
var sb = new string[settings.Length];
|
||||
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
sb[(int)setting] = GetValue(setting).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
return string.Join(",", sb);
|
||||
}
|
||||
public double GetValue(Settings setting)
|
||||
{
|
||||
if (SettingsProperty.ContainsKey(setting)) { return SettingsProperty[setting]; }
|
||||
else { throw new NotSupportedException("unknown setting: " + setting.ToString()); }
|
||||
}
|
||||
|
||||
public void SetValue(Settings setting, double d)
|
||||
{
|
||||
SettingsProperty[setting] = d;
|
||||
}
|
||||
}
|
||||
public static class InputAndBatterySettings
|
||||
{
|
||||
/// <summary>
|
||||
/// holds the battery/input settings in a cache so they don't have to be requeried from db
|
||||
/// 17615 BatteryAndInputVoltageDefaults improvements 3.2
|
||||
/// </summary>
|
||||
public static Dictionary<HardwareTypes, DasBatteryInputSettings> _cache =
|
||||
new Dictionary<HardwareTypes, DasBatteryInputSettings>();
|
||||
|
||||
/// <summary>
|
||||
/// clears the cache. This serves the purpose of ensuring
|
||||
/// that the values will be re-queried between runs, so if the settings are changed
|
||||
/// between runs the new values will be used
|
||||
/// </summary>
|
||||
public static void ClearCache()
|
||||
{
|
||||
_cache.Clear();
|
||||
}
|
||||
public static double GetValue(string DasType, DasBatteryInputSettings.Settings setting)
|
||||
{
|
||||
if (Enum.TryParse(DasType, out HardwareTypes type))
|
||||
{
|
||||
return GetValue(type, setting);
|
||||
}
|
||||
else { return double.NaN; }
|
||||
}
|
||||
|
||||
public static DasBatteryInputSettings GetDefaultSettingForHWType(HardwareTypes type)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
if (_cache.ContainsKey(type))
|
||||
{
|
||||
return _cache[type];
|
||||
}
|
||||
}
|
||||
DasBatteryInputSettings setting = null;
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY: setting = Common.SerializedSettings.G5INDUMMY_PowerSetting_Default; break;
|
||||
case HardwareTypes.G5VDS: setting = Common.SerializedSettings.G5VDS_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE_Distributor: setting = Common.SerializedSettings.SLICE_Distributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor: setting = Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_EthernetController: setting = Common.SerializedSettings.SLICE_EthernetController_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_LabEthernet: setting = Common.SerializedSettings.SLICE_LabEthernet_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE_Micro_Base: setting = Common.SerializedSettings.SLICE_Micro_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_NANO_Base: setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: setting = Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: setting = Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE1_G5Stack: setting = Common.SerializedSettings.SLICE1_G5Stack_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE2_DIM: setting = Common.SerializedSettings.SLICE2_DIM_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
setting = Common.SerializedSettings.SLICE2_SIM_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_TOM: setting = Common.SerializedSettings.SLICE2_TOM_PowerSetting_Default; break;
|
||||
|
||||
case HardwareTypes.SLICE2_SLD: setting = Common.SerializedSettings.SLICE2_SLD_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SLS: setting = Common.SerializedSettings.SLICE2_SLS_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE2_SLT: setting = Common.SerializedSettings.SLICE2_SLT_PowerSetting_Default; break;
|
||||
|
||||
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
setting = Common.SerializedSettings.SLICE6_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB: setting = Common.SerializedSettings.SLICE6Db_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB3: setting = Common.SerializedSettings.SLICE6Db3_PowerSetting_Default; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: setting = Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting_Default; break;
|
||||
case HardwareTypes.PowerPro: setting = Common.SerializedSettings.PowerPRO_PowerSetting_Default; break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
setting = Common.SerializedSettings.TSRAIR_PowerSetting_Default; break;
|
||||
//case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting_Default; break;
|
||||
//case HardwareTypes.Falcon: setting = Common.SerializedSettings.Falcon_PowerSetting_Default; break;
|
||||
}
|
||||
|
||||
if (null != setting)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
_cache[type] = setting;
|
||||
}
|
||||
return setting;
|
||||
}
|
||||
|
||||
throw new NotSupportedException($"unknown type: {type.ToString()}");
|
||||
}
|
||||
public static void SetSettingForHWType(HardwareTypes type,
|
||||
DasBatteryInputSettings setting)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
Common.SerializedSettings.G5INDUMMY_PowerSetting = setting; break;
|
||||
case HardwareTypes.G5VDS:
|
||||
Common.SerializedSettings.G5VDS_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Distributor:
|
||||
Common.SerializedSettings.SLICE_Distributor_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB: Common.SerializedSettings.SLICE6Db_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB3: Common.SerializedSettings.SLICE6Db3_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: Common.SerializedSettings.SLICEPRODistributor_PowerSetting = setting; break;
|
||||
//case HardwareTypes.SLICE6DB_AIR: Common.SerializedSettings.SLICE6Db_AIR_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor:
|
||||
Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
Common.SerializedSettings.SLICE_EthernetController_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
Common.SerializedSettings.SLICE_LabEthernet_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_Micro_Base:
|
||||
Common.SerializedSettings.SLICE_Micro_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE_NANO_Base:
|
||||
Common.SerializedSettings.SLICE_NANO_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_5_Micro_Base:
|
||||
Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base:
|
||||
Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE1_G5Stack:
|
||||
Common.SerializedSettings.SLICE1_G5Stack_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
Common.SerializedSettings.SLICE2_DIM_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
Common.SerializedSettings.SLICE2_SIM_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
Common.SerializedSettings.SLICE2_SLD_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
Common.SerializedSettings.SLICE2_SLS_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
Common.SerializedSettings.SLICE2_SLT_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
Common.SerializedSettings.SLICE2_TOM_PowerSetting = setting; break;
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting = setting; break;
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
Common.SerializedSettings.SLICE6_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
Common.SerializedSettings.SLICE6_AIR_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.PowerPro:
|
||||
Common.SerializedSettings.PowerPRO_PowerSetting = setting;
|
||||
break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
Common.SerializedSettings.TSRAIR_PowerSetting = setting;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static DasBatteryInputSettings GetSettingForHWType(HardwareTypes type)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
if (_cache.ContainsKey(type))
|
||||
{
|
||||
return _cache[type];
|
||||
}
|
||||
}
|
||||
|
||||
DasBatteryInputSettings setting = null;
|
||||
switch (type)
|
||||
{
|
||||
case HardwareTypes.G5INDUMMY: setting = Common.SerializedSettings.G5INDUMMY_PowerSetting; break;
|
||||
case HardwareTypes.G5VDS: setting = Common.SerializedSettings.G5VDS_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE_Distributor: setting = Common.SerializedSettings.SLICE_Distributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor: setting = Common.SerializedSettings.SLICE_Mini_Distributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor: setting = Common.SerializedSettings.SLICEPRODistributor_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB: setting = Common.SerializedSettings.SLICE6Db_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB3: setting = Common.SerializedSettings.SLICE6Db3_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6DB_InDummy: setting = Common.SerializedSettings.SLICE6Db_InDummy_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_EthernetController: setting = Common.SerializedSettings.SLICE_EthernetController_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_LabEthernet: setting = Common.SerializedSettings.SLICE_LabEthernet_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE_Micro_Base: setting = Common.SerializedSettings.SLICE_Micro_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_NANO_Base: setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_5_Micro_Base: setting = Common.SerializedSettings.SLICE1_5_Micro_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base: setting = Common.SerializedSettings.SLICE1_5_Nano_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE1_G5Stack: setting = Common.SerializedSettings.SLICE1_G5Stack_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_DIM: setting = Common.SerializedSettings.SLICE2_DIM_PowerSetting; break;
|
||||
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
setting = Common.SerializedSettings.SLICE2_SIM_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLD: setting = Common.SerializedSettings.SLICE2_SLD_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLS: setting = Common.SerializedSettings.SLICE2_SLS_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_SLT: setting = Common.SerializedSettings.SLICE2_SLT_PowerSetting; break;
|
||||
case HardwareTypes.SLICE2_TOM: setting = Common.SerializedSettings.SLICE2_TOM_PowerSetting; break;
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting; break;
|
||||
case HardwareTypes.DIM:
|
||||
case HardwareTypes.SIM:
|
||||
case HardwareTypes.TOM:
|
||||
//we are not expected to get here but if we do, just use the tdas default
|
||||
setting = Common.SerializedSettings.TDAS_Pro_Rack_PowerSetting; break;
|
||||
case HardwareTypes.Ribeye:
|
||||
case HardwareTypes.RibeyeLED:
|
||||
case HardwareTypes.SLICE_Base:
|
||||
case HardwareTypes.SLICE_Bridge:
|
||||
case HardwareTypes.SLICE_IEPE:
|
||||
case HardwareTypes.SLICE2_IEPE_Hi:
|
||||
case HardwareTypes.SLICE2_IEPE_Lo:
|
||||
//these are all never expected to get here, but are all slice types
|
||||
setting = Common.SerializedSettings.SLICE_NANO_Base_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_Base: setting = Common.SerializedSettings.SLICE6_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
case HardwareTypes.S6A_EthernetRecorder:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_PowerSetting; break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_BR_PowerSetting; break;
|
||||
case HardwareTypes.PowerPro: setting = Common.SerializedSettings.PowerPRO_PowerSetting; break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
setting = Common.SerializedSettings.TSRAIR_PowerSetting;
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_TC:
|
||||
setting = Common.SerializedSettings.SLICE6_AIR_TC_PowerSetting; break;
|
||||
case HardwareTypes.SLICE_PRO_CAN_FD:
|
||||
setting = Common.SerializedSettings.SPFD_PowerSetting; break;
|
||||
default:
|
||||
throw new NotSupportedException("unknown das type: " + type.ToString());
|
||||
}
|
||||
if (null != setting)
|
||||
{
|
||||
if (RunTestVariables.InRunTest && RunTestVariables.CacheVoltageSettingsInRunTest)
|
||||
{
|
||||
_cache[type] = setting;
|
||||
}
|
||||
}
|
||||
return setting;
|
||||
}
|
||||
public static double GetValue(HardwareTypes type, DasBatteryInputSettings.Settings setting)
|
||||
{
|
||||
return GetSettingForHWType(type).GetValue(setting);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
3983
Common/DTS.Common.DataModel/Classes/Hardware/DASHardware.cs
Normal file
3983
Common/DTS.Common.DataModel/Classes/Hardware/DASHardware.cs
Normal file
File diff suppressed because it is too large
Load Diff
341
Common/DTS.Common.DataModel/Classes/Hardware/DASHardwareList.cs
Normal file
341
Common/DTS.Common.DataModel/Classes/Hardware/DASHardwareList.cs
Normal file
@@ -0,0 +1,341 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DataPROWin7.DataModel.Classes.TestTemplate;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.Interface.DASFactory.Diagnostics;
|
||||
using DTS.Common.Interface.DASFactory.Diagnostics.HardwareList;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
using DTS.Common.Storage;
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes.Hardware
|
||||
{
|
||||
public class DASHardwareList : BasePropertyChanged
|
||||
{
|
||||
private static DASHardwareList _list;
|
||||
|
||||
private static bool _cache = false;
|
||||
/// <summary>
|
||||
/// turns off queries to the db and starts using cached data instead
|
||||
/// this is done when a large number of test setups are validating, since each test setup
|
||||
/// will get a complete list of hardware from the db, which adds time when you have a lot of hardware and test setups
|
||||
/// </summary>
|
||||
public static bool Cache
|
||||
{
|
||||
get => _cache;
|
||||
set
|
||||
{
|
||||
_cache = value;
|
||||
if (!value)
|
||||
{
|
||||
_cachedDASHardware = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 void SetCache(ICachedContainer container)
|
||||
{
|
||||
_cachedHardware = container;
|
||||
}
|
||||
|
||||
public void ClearCache()
|
||||
{
|
||||
_cachedHardware = null;
|
||||
}
|
||||
public string GetDASSerialNumberFromId(int id)
|
||||
{
|
||||
//this could probably be improved, but rather than getting ALL HARDWARE and ALL channels
|
||||
//just to get a serial number for a database id
|
||||
//just get the hardware without the channels
|
||||
var hr = DbOperations.DASGet(null, null, out var records);
|
||||
if (0 == hr && null != records && records.Any())
|
||||
{
|
||||
var match = Array.Find(records, das => das.DASId == id);
|
||||
if (null != match) { return match.SerialNumber; }
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
public DASHardware GetHardware(int id)
|
||||
{
|
||||
var sn = GetDASSerialNumberFromId(id);
|
||||
return GetHardware(sn);
|
||||
}
|
||||
public DASHardware GetHardware(string id, bool bUseCache = true)
|
||||
{
|
||||
return GetHardware(id, true, out var bNotUsed, bUseCache);
|
||||
}
|
||||
|
||||
public DASHardware[] GetHardware(string[] ids, bool bUseCache = true)
|
||||
{
|
||||
List<DASHardware> dasHW = new List<DASHardware>();
|
||||
foreach (string id in ids)
|
||||
{
|
||||
var hw = GetHardware(id, bUseCache);
|
||||
if (null != hw)
|
||||
{
|
||||
dasHW.Add(hw);
|
||||
}
|
||||
}
|
||||
return dasHW.ToArray();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
if (null != _cachedDASHardware)
|
||||
{
|
||||
h = Array.Find(_cachedDASHardware, das => das.SerialNumber == id);
|
||||
if (null != h)
|
||||
{
|
||||
changed = false;
|
||||
return h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var hardware = DTS.Common.ISO.Hardware.GetAllDAS(id, null);
|
||||
changed = false;
|
||||
if (null != hardware && hardware.Any())
|
||||
{
|
||||
return new DASHardware(hardware[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public class HardwareTypeChangedException : Exception
|
||||
{
|
||||
}
|
||||
|
||||
public DASHardware GetHardware(string serialNumber, string ipaddress)
|
||||
{
|
||||
return GetHardware(serialNumber);
|
||||
}
|
||||
|
||||
public void UpdateMaxMemory(DASHardware h, long newMaxMemory)
|
||||
{
|
||||
h.GetHardware().MaxMemory = newMaxMemory;
|
||||
h.GetHardware().Update();
|
||||
}
|
||||
|
||||
public DASHardware GetPrototypeHardware(string serial, int type)
|
||||
{
|
||||
//return new DASHardware();
|
||||
var key = $"{serial}_{type}";
|
||||
var das = DTS.Common.ISO.Hardware.GetAllDAS(key, DbOperations.DAS.PROTOTYPE_POSITION);
|
||||
if (null != das && das.Any())
|
||||
{
|
||||
das[0].CalDate = DateTime.MinValue;//if something is using the prototype, use a blank caldate
|
||||
return new DASHardware(das[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// holds a cache of all hardware this is done for speed reasons when there are a large number
|
||||
/// of test setups to validate, each one of them grabs all the hardware, which takes time
|
||||
/// </summary>
|
||||
private static DASHardware[] _cachedDASHardware = null;
|
||||
public static DASHardware[] GetAllHardware()
|
||||
{
|
||||
if (Cache && null != _cachedDASHardware) { return _cachedDASHardware; }
|
||||
var allHardware = DTS.Common.ISO.Hardware.GetAllDAS();
|
||||
var ret = allHardware.Select(h => new DASHardware(h)).ToArray();
|
||||
if (Cache) { _cachedDASHardware = ret; }
|
||||
return ret;
|
||||
}
|
||||
public static List<int> GetEmbeddedModules(IDASHardware[] hardware, int id)
|
||||
{
|
||||
var modules = new List<int>();
|
||||
|
||||
foreach (var hw in hardware)
|
||||
{
|
||||
if (hw.Connection.StartsWith(hardware.First(h => h.DASId == id).SerialNumber))
|
||||
{
|
||||
modules.Add(hw.DASId);
|
||||
}
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
public static Dictionary<string, double> GetEmbeddedModuleInfo(DASHardware[] hardware, int id)
|
||||
{
|
||||
var info = new Dictionary<string, double>();
|
||||
|
||||
foreach (var hw in hardware)
|
||||
{
|
||||
if (hw.Connection.StartsWith(hardware.First(h => h.DASId == id).SerialNumber))
|
||||
{
|
||||
info[hw.SerialNumber] = hw.GetMaxSampleRateDouble();
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public enum Tags
|
||||
{
|
||||
Hardware
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unassociate is used to indicate whether children das should be unassociated before commiting or not
|
||||
/// </summary>
|
||||
public void Commit(DASHardware hardware, bool bExisting = false, bool bCheckExisting = true, bool Unassociate = true)
|
||||
{
|
||||
//note when you are commiting a group of hardware that contains a SLICE6Db, you should
|
||||
//sort the hardware so that this call happens BEFORE we commit any child slice6
|
||||
if (hardware.IsPseudoRack() && Unassociate)
|
||||
{
|
||||
UnassociateParentDAS(hardware.SerialNumber);
|
||||
}
|
||||
|
||||
var iso = hardware.GetHardware();
|
||||
var h = new DTS.Common.ISO.Hardware
|
||||
{
|
||||
SerialNumber = hardware.SerialNumber,
|
||||
LocalOnly = hardware.LocalOnly,
|
||||
IsModule = hardware.IsModule(),
|
||||
CalDate = hardware.CalDate,
|
||||
DASType = hardware.GetHardwareTypeInt(),
|
||||
FirmwareVersion = hardware.Firmware,
|
||||
IPAddress = hardware.Connection,
|
||||
MaxMemory = hardware.GetMaxMemoryLong(),
|
||||
MaxModules = hardware.MaxModules,
|
||||
MaxSampleRate = hardware.GetMaxSampleRateDouble(),
|
||||
MinSampleRate = hardware.GetMinSampleRateDouble(),
|
||||
ProtocolVersion = hardware.ProtocolVersion,
|
||||
Channels = hardware.Channels.Length,
|
||||
LastModified = DateTime.Now,
|
||||
LastModifiedBy = ApplicationProperties.CurrentUser.UserName,
|
||||
IsReconfigurable = hardware.Reconfigurable,
|
||||
IsProgrammable = hardware.Reprogrammable,
|
||||
ChannelTypes = hardware.ChannelTypes,
|
||||
ParentDAS = hardware.ParentDAS,
|
||||
Port = hardware.PortOnDistributor,
|
||||
PositionOnChain = hardware.PositionOnChain,
|
||||
PositionOnDistributor = hardware.PositionOnDistributor,
|
||||
IsFirstUseValid = hardware.IsFirstUseValid,
|
||||
FirstUseDate = hardware.FirstUseDate,
|
||||
StandIn = iso.StandIn,
|
||||
MaxAAFRate = hardware.GetMaxAAFRateDouble(),
|
||||
TestId = iso.TestId,
|
||||
GroupId = iso.GroupId,
|
||||
LastUsed = iso.LastUsed,
|
||||
LastUsedBy = iso.LastUsedBy
|
||||
};
|
||||
|
||||
h.ISOChannels = hardware.Channels.Select(channel => new DTS.Common.ISO.HardwareChannel(channel.GetISOChannel(), h))
|
||||
.ToArray();
|
||||
hardware.SetHardware(h);
|
||||
|
||||
//if (null == _hardware)
|
||||
//{
|
||||
// PopulateHardware();
|
||||
//}
|
||||
|
||||
//10037 TDAS G5 module is detected as a TDAS G5 in a VDS, so if the existing serial number and ip address
|
||||
//already exists in the database
|
||||
if (bCheckExisting)
|
||||
{
|
||||
//22320 Unnecessary hardware retrieval
|
||||
bExisting = DASHardware.GetDataBaseID(hardware.SerialNumber) > 0;
|
||||
}
|
||||
if (!bExisting)
|
||||
{
|
||||
h.Insert();
|
||||
}
|
||||
else
|
||||
{
|
||||
h.Version = h.Version + 1;
|
||||
//10037 TDAS G5 module is detected as a TDAS G5 in a VDS
|
||||
//the id could change, so if we are doing an update, we should make sure to remove the old instance in the list
|
||||
//_hardware.Remove(existingHardware.GetHardware().GetId());
|
||||
//_hardware[hardware.GetHardware().GetId()] = hardware;
|
||||
h.Update();
|
||||
}
|
||||
OnPropertyChanged(Tags.Hardware.ToString());
|
||||
|
||||
//no longer need to mark groups incomplete
|
||||
}
|
||||
/// <summary>
|
||||
/// deletes the selected IHardware
|
||||
/// </summary>
|
||||
public void Delete(IHardware hardware)
|
||||
{
|
||||
if (hardware.Hardware is IISOHardware isoHW)
|
||||
{
|
||||
isoHW.Delete();
|
||||
}
|
||||
}
|
||||
public void Delete(DASHardware hardware)
|
||||
{
|
||||
var h = hardware?.GetHardware();
|
||||
if (h == null) { return; }
|
||||
h.Delete();
|
||||
|
||||
if (hardware.IsPseudoRack())
|
||||
{
|
||||
UnassociateParentDAS(hardware.SerialNumber);
|
||||
}
|
||||
OnPropertyChanged(Tags.Hardware.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
/// iteratively deletes the given hardware
|
||||
/// </summary>
|
||||
public void Delete(IHardware[] hardware)
|
||||
{
|
||||
foreach (var h in hardware)
|
||||
{
|
||||
Delete(h);
|
||||
}
|
||||
}
|
||||
public void Delete(DASHardware[] hardware)
|
||||
{
|
||||
foreach (DASHardware hw in hardware)
|
||||
{
|
||||
Delete(hw);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnassociateParentDAS(string distributorSerialNumber)
|
||||
{
|
||||
using (var sql = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
sql.CommandType = System.Data.CommandType.StoredProcedure;
|
||||
sql.CommandText = DbOperationsEnum.StoredProcedure.sp_DASChildrenUnAssociate.ToString();
|
||||
DbOperations.CreateParam(sql, "@ParentSerialNumber", System.Data.SqlDbType.NVarChar,
|
||||
distributorSerialNumber);
|
||||
sql.ExecuteNonQuery();
|
||||
}
|
||||
finally { sql.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
69
Common/DTS.Common.DataModel/Classes/Hardware/DASSettings.cs
Normal file
69
Common/DTS.Common.DataModel/Classes/Hardware/DASSettings.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <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 DASSettings()
|
||||
{
|
||||
}
|
||||
public DASSettings(DASSettings setting)
|
||||
{
|
||||
_DASSerialNumber = setting.DASSerialNumber;
|
||||
_sampleRate = setting.SampleRate;
|
||||
_excitationWarmupTimeMS = setting.ExcitationWarmupTimeMS;
|
||||
_aaf = setting.HardwareAAF;
|
||||
_preTriggerSeconds = setting.PreTriggerSeconds;
|
||||
_postTriggerSeconds = setting.PostTriggerSeconds;
|
||||
_statusLineCheck = setting.StatusLineCheck;
|
||||
_batteryCheck = setting.BatteryCheck;
|
||||
_inputVoltageMin = setting.InputVoltageMin;
|
||||
_inputVoltageMax = setting.InputVoltageMax;
|
||||
_batteryVoltageMin = setting.BatteryVoltageMin;
|
||||
_batteryVoltageMax = setting.BatteryVoltageMax;
|
||||
}
|
||||
private string _DASSerialNumber;
|
||||
public string DASSerialNumber { get => _DASSerialNumber; set => SetProperty(ref _DASSerialNumber, value, "DASSerialNumber"); }
|
||||
|
||||
private double _sampleRate;
|
||||
public double SampleRate { get => _sampleRate; set => SetProperty(ref _sampleRate, value, "SampleRate"); }
|
||||
|
||||
private int _excitationWarmupTimeMS;
|
||||
public int ExcitationWarmupTimeMS { get => _excitationWarmupTimeMS; set => SetProperty(ref _excitationWarmupTimeMS, value, "ExcitationWarmupTimeMS"); }
|
||||
|
||||
private double _aaf;
|
||||
public double HardwareAAF { get => _aaf; set => SetProperty(ref _aaf, value, "HardwareAAF"); }
|
||||
|
||||
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"); }
|
||||
|
||||
private bool _statusLineCheck;
|
||||
public bool StatusLineCheck { get => _statusLineCheck; set => SetProperty(ref _statusLineCheck, value, "StatusLineCheck"); }
|
||||
|
||||
private bool _batteryCheck;
|
||||
public bool BatteryCheck { get => _batteryCheck; set => SetProperty(ref _batteryCheck, value, "BatteryCheck"); }
|
||||
|
||||
private double _inputVoltageMin;
|
||||
public double InputVoltageMin { get => _inputVoltageMin; set => SetProperty(ref _inputVoltageMin, value, "InputVoltageMin"); }
|
||||
|
||||
private double _inputVoltageMax;
|
||||
public double InputVoltageMax { get => _inputVoltageMax; set => SetProperty(ref _inputVoltageMax, value, "InputVoltageMax"); }
|
||||
|
||||
private double _batteryVoltageMin;
|
||||
public double BatteryVoltageMin { get => _batteryVoltageMin; set => SetProperty(ref _batteryVoltageMin, value, "BatteryVoltageMin"); }
|
||||
|
||||
private double _batteryVoltageMax;
|
||||
public double BatteryVoltageMax { get => _batteryVoltageMax; set => SetProperty(ref _batteryVoltageMax, value, "BatteryVoltageMax"); }
|
||||
}
|
||||
}
|
||||
1508
Common/DTS.Common.DataModel/Classes/Hardware/HardwareChannel.cs
Normal file
1508
Common/DTS.Common.DataModel/Classes/Hardware/HardwareChannel.cs
Normal file
File diff suppressed because it is too large
Load Diff
109
Common/DTS.Common.DataModel/Classes/TSRAIRGo/TSRAIRGoStatus.cs
Normal file
109
Common/DTS.Common.DataModel/Classes/TSRAIRGo/TSRAIRGoStatus.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using DTS.Common.Converters;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DTS.Common.DataModel.Classes.TSRAIRGo
|
||||
{
|
||||
public class TSRAIRGoStatus
|
||||
{
|
||||
[TypeConverter(typeof(EnumDescriptionTypeConverterShared))]
|
||||
public enum StatusTypes
|
||||
{
|
||||
[Description("Table_NA")]
|
||||
UNKNOWN,
|
||||
[Description("HardwareDiscoveryControl_PingFailed")]
|
||||
PING_FAILED,
|
||||
[Description("AutoDetectDASControl_Pinging")]
|
||||
PINGING,
|
||||
[Description("AutoDetectDASControl_Ping_Good")]
|
||||
PING_SUCCESS,
|
||||
[Description("HardwareDiscoveryControl_FailedToConnect")]
|
||||
CONNECT_FAILED,
|
||||
[Description("AutoDetectDASControl_Connecting")]
|
||||
CONNECTING,
|
||||
[Description("AutoDetectDASControl_QueryFailed")]
|
||||
QUERY_FAILED,
|
||||
[Description("HardwareDiscoveryControl_QueryTimedOut")]
|
||||
QUERY_TIMEDOUT,
|
||||
[Description("AutoDetectDASControl_Done")]
|
||||
DONE,
|
||||
[Description("AutoDetectDASControl_Querying")]
|
||||
QUERYING,
|
||||
[Description("AutoDetectDASControl_Updated")]
|
||||
UPDATED,
|
||||
[Description("AutoDetectDASControl_Added")]
|
||||
ADDED,
|
||||
[Description("HardwareDiscoveryControl_Online")]
|
||||
ONLINE,
|
||||
[Description("HardwareDiscoveryControl_Connected")]
|
||||
CONNECTED,
|
||||
[Description("CheckHardware_UnexpectedMaxMemory")]
|
||||
UNEXPECTED_MAX_MEMORY,
|
||||
[Description("CheckHardware_FirmwareMismatch")]
|
||||
UNEXPECTED_FIRMWARE_VERSION,
|
||||
[Description("CheckHardwareStatus_Passed")]
|
||||
PASSED,
|
||||
[Description("CheckHardware_CalDateOverdue")]
|
||||
EXPIRED_CAL_DATE,
|
||||
[Description("CheckHardware_ChannelCountMismatch")]
|
||||
CHANNEL_COUNT_MISMATCH,
|
||||
[Description("Table_NA")]
|
||||
MISSING_MODULES,
|
||||
CANCELED,
|
||||
[Description("CheckHardware_NoMemory")]
|
||||
NO_MEMORY,
|
||||
[Description("ArmSystem_Armed")]
|
||||
ARMED,
|
||||
[Description("AutoArmed")]
|
||||
AUTOARMED,
|
||||
[Description("Admin_SystemSettings_Page_Realtime")]
|
||||
REALTIME,
|
||||
[Description("ReadyToStream")]
|
||||
READYTOSTREAM,
|
||||
[Description("ArmSystem_CurrentlyStreaming")]
|
||||
STREAMING,
|
||||
[Description("LostDock")]
|
||||
LOST_DOCK,
|
||||
[Description("Status_Rebooting")]
|
||||
REBOOTING,
|
||||
[Description("CheckHardwareStatus_SettingClockSources")]
|
||||
SETTING_CLOCK,
|
||||
[Description("CheckHardware_UnexpectedFirstUseDate")]
|
||||
UNEXPECTED_FIRSTUSE_DATE,
|
||||
[Description("InvalidRecordingMode")]
|
||||
INVALID_RECORDING_MODE,
|
||||
[Description("InvalidStreamMode")]
|
||||
INVALID_STREAMING_MODE,
|
||||
[Description("StreamingNotAvailable")]
|
||||
STREAMING_NOT_AVAILABLE,
|
||||
ARMING,
|
||||
DISARMING,
|
||||
[Description("ArmSystem_Disarmed")]
|
||||
DISARMED,
|
||||
[Description("ArmSystem_ArmFailed")]
|
||||
ARM_FAILED,
|
||||
[Description("ArmSystem_SettingConfiguration")]
|
||||
UPDATING_DAS_CONFIG,
|
||||
[Description("ArmSystem_ClearingFlash")]
|
||||
PREPARING_DATA_MEMORY,
|
||||
[Description("ArmSystem_Rearming")]
|
||||
REARMING,
|
||||
[Description("ArmSystem_PreparingForArming")]
|
||||
PREPARING_FOR_ARMING,
|
||||
[Description("ArmSystem_WaitingForInterval")]
|
||||
WAITING_FOR_INTERVAL,
|
||||
[Description("ArmSystem_WaitingForTrigger")]
|
||||
WAITING_FOR_TRIGGER,
|
||||
[Description("ArmSystem_WaitingForScheduleStartTime")]
|
||||
WAITING_FOR_SCHEDULE,
|
||||
[Description("ArmSystem_Recording")]
|
||||
RECORDING,
|
||||
[Description("Offline")]
|
||||
OFFLINE,
|
||||
[Description("Downloading")]
|
||||
DOWNLOADING,
|
||||
[Description("Download_StatusTypes_GettingEventData")]
|
||||
GETTINGEVENTDATA
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class CustomerDetails : BasePropertyChanged
|
||||
{
|
||||
private readonly DTS.Common.ISO.CustomerDetails _customerDetails;
|
||||
private bool _blank = true;
|
||||
public bool IsBlank() { return _blank; }
|
||||
public enum Fields
|
||||
{
|
||||
Name,
|
||||
CustomerName,
|
||||
CustomerTestRefNumber,
|
||||
ProjectRefNumber,
|
||||
CustomerOrderNumber,
|
||||
CustomerCostUnit
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _customerDetails.Name;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.Name = value; OnPropertyChanged(Fields.Name.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomerName
|
||||
{
|
||||
get => _customerDetails.CustomerName;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.CustomerName = value; OnPropertyChanged(Fields.CustomerName.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomerTestRefNumber
|
||||
{
|
||||
get => _customerDetails.CustomerTestRefNumber;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.CustomerTestRefNumber = value; OnPropertyChanged(Fields.CustomerTestRefNumber.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string ProjectRefNumber
|
||||
{
|
||||
get => _customerDetails.ProjectRefNumber;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.ProjectRefNumber = value; OnPropertyChanged(Fields.ProjectRefNumber.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomerOrderNumber
|
||||
{
|
||||
get => _customerDetails.CustomerOrderNumber;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.CustomerOrderNumber = value; OnPropertyChanged(Fields.CustomerOrderNumber.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomerCostUnit
|
||||
{
|
||||
get => _customerDetails.CustomerCostUnit;
|
||||
set
|
||||
{
|
||||
_blank = false;
|
||||
_customerDetails.CustomerCostUnit = value; OnPropertyChanged(Fields.CustomerCostUnit.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public bool LocalOnly => _customerDetails.LocalOnly;
|
||||
|
||||
public DateTime LastModified => _customerDetails.LastModified;
|
||||
|
||||
public string LastModifiedBy => _customerDetails.LastModifiedBy;
|
||||
|
||||
public int Version => _customerDetails.Version;
|
||||
|
||||
public CustomerDetails()
|
||||
{
|
||||
_customerDetails = new DTS.Common.ISO.CustomerDetails();
|
||||
_customerDetails.Name = StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public bool HasBlankName()
|
||||
{
|
||||
return _customerDetails.Name == StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public CustomerDetails(DTS.Common.ISO.CustomerDetails customerDetails)
|
||||
{
|
||||
_customerDetails = new DTS.Common.ISO.CustomerDetails(customerDetails);
|
||||
_blank = false;
|
||||
}
|
||||
public DTS.Common.ISO.CustomerDetails GetISOCustomer()
|
||||
{
|
||||
return _customerDetails;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class CustomerDetailsList : BasePropertyChanged
|
||||
{
|
||||
protected CustomerDetailsList()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Delete(CustomerDetails customer)
|
||||
{
|
||||
customer.GetISOCustomer().Delete(ApplicationProperties.CurrentUser.UserName);
|
||||
}
|
||||
|
||||
public static void Delete(CustomerDetails[] customers)
|
||||
{
|
||||
foreach (var customer in customers)
|
||||
{
|
||||
Delete(customer);
|
||||
}
|
||||
}
|
||||
public static CustomerDetails[] GetAllCustomers()
|
||||
{
|
||||
var customers = DTS.Common.ISO.CustomerDetails.GetAllCustomerDetails();
|
||||
var allCustomers = new List<DataModel.CustomerDetails>();
|
||||
foreach (var customer in customers)
|
||||
{
|
||||
allCustomers.Add(new CustomerDetails(customer));
|
||||
}
|
||||
allCustomers.Sort(CompareCustomers);
|
||||
return allCustomers.ToArray();
|
||||
}
|
||||
public static void DeleteAll()
|
||||
{
|
||||
DTS.Common.ISO.CustomerDetails.DeleteCustomerDetails();
|
||||
}
|
||||
|
||||
private static int CompareCustomers(CustomerDetails a, CustomerDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
return null == b ? 1 : string.Compare(a.Name, b.Name, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static CustomerDetails GetCustomerDetail(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name)) { return null; }
|
||||
var iso = DTS.Common.ISO.CustomerDetails.GetCustomerDetails(name);
|
||||
return null == iso ? null : new CustomerDetails(iso);
|
||||
}
|
||||
|
||||
public static void AddCustomer(CustomerDetails customer)
|
||||
{
|
||||
customer.GetISOCustomer().Commit(ApplicationProperties.CurrentUser.UserName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class LabratoryDetails : BasePropertyChanged
|
||||
{
|
||||
private readonly DTS.Common.ISO.LabratoryDetails _lab;
|
||||
|
||||
public enum Tags
|
||||
{
|
||||
LabratoryName,
|
||||
LabratoryContactName,
|
||||
LabratoryContactPhone,
|
||||
LabratoryContactFax,
|
||||
LabratoryContactEmail,
|
||||
LabratoryTestRefNumber,
|
||||
LabratoryProjectRefNumber,
|
||||
Name
|
||||
}
|
||||
public string LabratoryName
|
||||
{
|
||||
get => _lab.LabratoryName;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryName = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryName.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryContactName
|
||||
{
|
||||
get => _lab.LabratoryContactName;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryContactName = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryContactName.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryContactPhone
|
||||
{
|
||||
get => _lab.LabratoryContactPhone;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryContactPhone = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryContactPhone.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryContactFax
|
||||
{
|
||||
get => _lab.LabratoryContactFax;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryContactFax = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryContactFax.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryContactEmail
|
||||
{
|
||||
get => _lab.LabratoryContactEmail;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryContactEmail = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryContactEmail.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryTestRefNumber
|
||||
{
|
||||
get => _lab.LabratoryTestRefNumber;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryTestRefNumber = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryTestRefNumber.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string LabratoryProjectRefNumber
|
||||
{
|
||||
get => _lab.LabratoryProjectRefNumber;
|
||||
set
|
||||
{
|
||||
_lab.LabratoryProjectRefNumber = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.LabratoryProjectRefNumber.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _lab.Name;
|
||||
set
|
||||
{
|
||||
_lab.Name = value;
|
||||
_isBlank = false;
|
||||
OnPropertyChanged(Tags.Name.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public bool LocalOnly => _lab.LocalOnly;
|
||||
|
||||
public DateTime LastModified => _lab.LastModified;
|
||||
|
||||
public string LastModifiedBy => _lab.LastModifiedBy;
|
||||
|
||||
public int Version => _lab.Version;
|
||||
|
||||
public LabratoryDetails()
|
||||
{
|
||||
_lab = new DTS.Common.ISO.LabratoryDetails();
|
||||
_lab.Name = StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public bool HasBlankName()
|
||||
{
|
||||
return _lab.Name == StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public LabratoryDetails(DTS.Common.ISO.LabratoryDetails lab)
|
||||
{
|
||||
_lab = new DTS.Common.ISO.LabratoryDetails(lab);
|
||||
_isBlank = false;
|
||||
}
|
||||
public DTS.Common.ISO.LabratoryDetails GetIsoLab() { return _lab; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public bool IsBlank()
|
||||
{
|
||||
return _isBlank;
|
||||
}
|
||||
private bool _isBlank = true;
|
||||
}
|
||||
public class LabratoryDetailsList
|
||||
{
|
||||
protected LabratoryDetailsList()
|
||||
{
|
||||
}
|
||||
|
||||
public static LabratoryDetails[] GetAllLabs()
|
||||
{
|
||||
var isoLabs = DTS.Common.ISO.LabratoryDetails.GetAllLabratoryDetails();
|
||||
var labs = isoLabs.Select(isolab => new LabratoryDetails(isolab)).ToList();
|
||||
labs.Sort(CompareLabs);
|
||||
return labs.ToArray();
|
||||
}
|
||||
|
||||
public enum Tags
|
||||
{
|
||||
Labs
|
||||
}
|
||||
|
||||
public static void DeleteAll()
|
||||
{
|
||||
DTS.Common.ISO.LabratoryDetails.DeleteLabratoryDetails();
|
||||
}
|
||||
|
||||
private static int CompareLabs(LabratoryDetails a, LabratoryDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
return null == b ? 1 : string.Compare(a.Name, b.Name, StringComparison.Ordinal);
|
||||
}
|
||||
public static void Delete(LabratoryDetails lab)
|
||||
{
|
||||
lab?.GetIsoLab().Delete(ApplicationProperties.CurrentUser.UserName);
|
||||
}
|
||||
|
||||
public static void Delete(LabratoryDetails[] labs)
|
||||
{
|
||||
foreach (var lab in labs)
|
||||
{
|
||||
Delete(lab);
|
||||
}
|
||||
}
|
||||
public static LabratoryDetails GetLab(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name)) { return null; }
|
||||
var iso = DTS.Common.ISO.LabratoryDetails.GetLabratoryDetails(name);
|
||||
return null == iso ? null : new LabratoryDetails(iso);
|
||||
}
|
||||
|
||||
public static void AddLab(LabratoryDetails lab)
|
||||
{
|
||||
lab.GetIsoLab().Commit(ApplicationProperties.CurrentUser.UserName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class TestEngineerDetails : BasePropertyChanged
|
||||
{
|
||||
|
||||
private bool _blank = true;
|
||||
public bool IsBlank() { return _blank; }
|
||||
|
||||
private DTS.Common.ISO.TestEngineerDetails _testEngineerDetails;
|
||||
public enum Fields
|
||||
{
|
||||
Name,
|
||||
TestEngineerName,
|
||||
TestEngineerPhone,
|
||||
TestEngineerFax,
|
||||
TestEngineerEmail
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _testEngineerDetails.Name;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.Name = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.Name.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerName
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerName;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerName = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerName.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerPhone
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerPhone;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerPhone = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerPhone.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerFax
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerFax;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerFax = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerFax.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string TestEngineerEmail
|
||||
{
|
||||
get => _testEngineerDetails.TestEngineerEmail;
|
||||
set
|
||||
{
|
||||
_testEngineerDetails.TestEngineerEmail = value;
|
||||
_blank = false;
|
||||
OnPropertyChanged(Fields.TestEngineerEmail.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public bool LocalOnly => _testEngineerDetails.LocalOnly;
|
||||
|
||||
public DateTime LastModified => _testEngineerDetails.LastModified;
|
||||
|
||||
public string LastModifiedBy => _testEngineerDetails.LastModifiedBy;
|
||||
|
||||
public int Version => _testEngineerDetails.Version;
|
||||
|
||||
public TestEngineerDetails()
|
||||
{
|
||||
_testEngineerDetails = new DTS.Common.ISO.TestEngineerDetails();
|
||||
_testEngineerDetails.Name = StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
|
||||
public bool HasBlankName()
|
||||
{
|
||||
return _testEngineerDetails.Name == StringResources.TestTemplate_EmptyListName;
|
||||
}
|
||||
public TestEngineerDetails(DTS.Common.ISO.TestEngineerDetails testEngineerDetails)
|
||||
{
|
||||
_blank = false;
|
||||
_testEngineerDetails = new DTS.Common.ISO.TestEngineerDetails(testEngineerDetails);
|
||||
}
|
||||
public DTS.Common.ISO.TestEngineerDetails GetISOTestEngineer()
|
||||
{
|
||||
return _testEngineerDetails;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
public class TestEngineerDetailsList : BasePropertyChanged
|
||||
{
|
||||
public enum Tags
|
||||
{
|
||||
TestEngineers
|
||||
|
||||
}
|
||||
protected TestEngineerDetailsList()
|
||||
{
|
||||
}
|
||||
|
||||
private static TestEngineerDetailsList _testEngineerList = new TestEngineerDetailsList();
|
||||
public static TestEngineerDetailsList TestEngineerList => _testEngineerList;
|
||||
public void Delete(TestEngineerDetails testEngineer)
|
||||
{
|
||||
testEngineer.GetISOTestEngineer().Delete(ApplicationProperties.CurrentUser.UserName);
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
_testEngineers.Remove(testEngineer.Name);
|
||||
}
|
||||
OnPropertyChanged(Tags.TestEngineers.ToString());
|
||||
}
|
||||
public void Delete(TestEngineerDetails[] testEngineers)
|
||||
{
|
||||
foreach (var testEngineer in testEngineers)
|
||||
{
|
||||
Delete(testEngineer);
|
||||
}
|
||||
}
|
||||
private static readonly object _testEngineerLock = new object();
|
||||
private Dictionary<string, TestEngineerDetails> _testEngineers = null;
|
||||
public TestEngineerDetails[] TestEngineers
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
if (null == _testEngineers || _testEngineers.Count == 0)
|
||||
{
|
||||
PopulateEngineers();
|
||||
}
|
||||
}
|
||||
List<TestEngineerDetails> testEngineers = new List<TestEngineerDetails>(_testEngineers.Values);
|
||||
testEngineers.Sort(new Comparison<TestEngineerDetails>(CompareTestEngineers));
|
||||
return testEngineers.ToArray();
|
||||
}
|
||||
}
|
||||
private void PopulateEngineers()
|
||||
{
|
||||
_testEngineers = new Dictionary<string, TestEngineerDetails>();
|
||||
foreach (var t in GetAllTestEngineers())
|
||||
{
|
||||
if (!_testEngineers.ContainsKey(t.Name)) { _testEngineers.Add(t.Name, t); }
|
||||
}
|
||||
}
|
||||
public void ReloadAll()
|
||||
{
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
PopulateEngineers();
|
||||
}
|
||||
}
|
||||
public void DeleteAll()
|
||||
{
|
||||
_testEngineers = null;
|
||||
DTS.Common.ISO.TestEngineerDetails.DeleteAllTestEngineerDetails();
|
||||
}
|
||||
private int CompareTestEngineers(TestEngineerDetails a, TestEngineerDetails b)
|
||||
{
|
||||
if (a == b) { return 0; }
|
||||
if (null == a) { return -1; }
|
||||
if (null == b) { return 1; }
|
||||
return a.Name.CompareTo(b.Name);
|
||||
}
|
||||
|
||||
public static TestEngineerDetails[] GetAllTestEngineers()
|
||||
{
|
||||
var list = new List<TestEngineerDetails>();
|
||||
if (RunTestVariables.InRunTest &&
|
||||
TestTemplateList.TestTemplatesList.CachedTestEngineerDetails != null &&
|
||||
TestTemplateList.TestTemplatesList.CachedTestEngineerDetails.Count > 0)
|
||||
{
|
||||
DbOperations.LogDBCaching("****** Using cached Laboratory Details in GetAllTestEngineers");
|
||||
var isoTestEngineersList = new List<DTS.Common.ISO.TestEngineerDetails>();
|
||||
foreach (var te in TestTemplateList.TestTemplatesList.CachedTestEngineerDetails)
|
||||
{
|
||||
var isoTestEngineerDetails = new DTS.Common.ISO.TestEngineerDetails()
|
||||
{
|
||||
Name = te.Value.Name,
|
||||
TestEngineerName = te.Value.TestEngineerName,
|
||||
TestEngineerPhone = te.Value.TestEngineerPhone,
|
||||
TestEngineerEmail = te.Value.TestEngineerEmail,
|
||||
TestEngineerFax = te.Value.TestEngineerFax
|
||||
};
|
||||
|
||||
isoTestEngineersList.Add(isoTestEngineerDetails);
|
||||
}
|
||||
list = isoTestEngineersList.Select(isote => new TestEngineerDetails(isote)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var ts in DTS.Common.ISO.TestEngineerDetails.GetAllTestEngineerDetails())
|
||||
{
|
||||
list.Add(new TestEngineerDetails(ts));
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public TestEngineerDetails GetTestEngineerDetail(string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) { return null; }
|
||||
var testEngineers = from t in TestEngineers.AsParallel() where t.Name == name select t;
|
||||
if (null != testEngineers && testEngineers.Any()) { return testEngineers.First(); }
|
||||
else { return null; }
|
||||
}
|
||||
|
||||
public void AddTestEngineer(TestEngineerDetails testEngineer)
|
||||
{
|
||||
testEngineer.GetISOTestEngineer().Commit(ApplicationProperties.CurrentUser.UserName);
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
//force _testEngineers to not be null...
|
||||
var length = TestEngineers.Length;
|
||||
if (!_testEngineers.ContainsKey(testEngineer.Name)) { _testEngineers.Add(testEngineer.Name, testEngineer); }
|
||||
else { _testEngineers[testEngineer.Name] = testEngineer; }
|
||||
}
|
||||
OnPropertyChanged(Tags.TestEngineers.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <summary>
|
||||
/// GUI wrapper for template channels ... it contains a testobjecttemplatechannel
|
||||
/// </summary>
|
||||
public class TemplateChannelUI : BasePropertyChanged
|
||||
{
|
||||
private DTS.Common.ISO.TestObjectTemplateChannel _channel;
|
||||
public DTS.Common.ISO.TestObjectTemplateChannel Channel
|
||||
{
|
||||
get => _channel;
|
||||
set => SetProperty(ref _channel, value, "Channel");
|
||||
}
|
||||
|
||||
public TemplateChannelUI(DTS.Common.ISO.TestObjectTemplateChannel channel)
|
||||
{
|
||||
_channel = channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
1097
Common/DTS.Common.DataModel/Classes/TestObject/TestObject.cs
Normal file
1097
Common/DTS.Common.DataModel/Classes/TestObject/TestObject.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DataPROWin7.Common;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.ISO;
|
||||
using DTS.Common.DataModel;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <summary>
|
||||
/// list that holds groups
|
||||
/// </summary>
|
||||
public class TestObjectList : BasePropertyChanged
|
||||
{
|
||||
#region Tags and Constants
|
||||
public enum Tags
|
||||
{
|
||||
TestObjects
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
private static readonly object MyLock = new object();
|
||||
private static TestObjectList _testObjectList;
|
||||
|
||||
public static TestObjectList TestObjectsList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (null == _testObjectList)
|
||||
{
|
||||
_testObjectList = new TestObjectList();
|
||||
}
|
||||
}
|
||||
return _testObjectList;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// adds a group
|
||||
/// will notify listeners if bNotify is true
|
||||
/// you would not want to notify listeners if you are in a bulk
|
||||
/// operation and intend to refresh everyone when done
|
||||
/// </summary>
|
||||
/// <param name="to"></param>
|
||||
/// <param name="bNotify"></param>
|
||||
public void Add(TestObject to, bool bNotify)
|
||||
{
|
||||
to.LastModifiedBy = ApplicationProperties.CurrentUser.UserName;
|
||||
to.SetLastModified(DateTime.Now);
|
||||
to.Commit();
|
||||
if (bNotify)
|
||||
{
|
||||
OnPropertyChanged("TestObjects");
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAll()
|
||||
{
|
||||
OnPropertyChanged("TestObjects");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected TestObjectList()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,544 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.DataModel;
|
||||
using DTS.Common.ISO;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
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
|
||||
}
|
||||
private enum GroupTemplateChannelFields
|
||||
{
|
||||
TestObjectNumber,
|
||||
NameOfTheChannel,
|
||||
LaboratoryChannelCode,
|
||||
CustomerChannelCode,
|
||||
Comments1,
|
||||
Location,
|
||||
Dimension,
|
||||
Direction,
|
||||
ChannelFrequencyClass,
|
||||
Unit,
|
||||
ReferenceSystem,
|
||||
TransducerType,
|
||||
TransducerId,
|
||||
PreFilterType,
|
||||
CutOffFrequency,
|
||||
ChannelAmplitudeClass,
|
||||
ReferenceChannel,
|
||||
ReferenceChannelName,
|
||||
DataSource,
|
||||
DataStatus,
|
||||
SamplingInterval,
|
||||
BitResolution,
|
||||
TimeOfFirstSample,
|
||||
NumberOfSamples,
|
||||
OffsetPostTest,
|
||||
TransducerNaturalFrequency,
|
||||
TransducerDampingRatio,
|
||||
Comments,
|
||||
FirstGlobalMaximumValue,
|
||||
TimeOfMaximumValue,
|
||||
FirstGlobalMinimumValue,
|
||||
TimeOfMinimumValue,
|
||||
StartOffsetInterval,
|
||||
EndOffsetInterval,
|
||||
MMEChannelId,
|
||||
MMEChannelType,
|
||||
Required,
|
||||
DisplayOrder,
|
||||
LocalOnly
|
||||
}
|
||||
private enum GroupTemplateFields
|
||||
{
|
||||
TemplateName,
|
||||
Icon,
|
||||
Description,
|
||||
LocalOnly,
|
||||
Version,
|
||||
LastModifiedBy,
|
||||
LastModified,
|
||||
CRC32,
|
||||
TestObjectType,
|
||||
TestObject,
|
||||
ParentTemplate,
|
||||
SysBuilt,
|
||||
OriginalTemplateName,
|
||||
Embedded
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region properties
|
||||
|
||||
private string _lastModifiedBy = "N/A";
|
||||
public string LastModifiedBy
|
||||
{
|
||||
get => _lastModifiedBy;
|
||||
set => SetProperty(ref _lastModifiedBy, value, "LastModifiedBy");
|
||||
}
|
||||
|
||||
private DateTime _lastModified = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => SetProperty(ref _lastModified, value, "LastModified");
|
||||
}
|
||||
|
||||
private DTS.Common.ISO.TestObjectTemplate _template;
|
||||
|
||||
private List<TestObjectTemplateChannel> _requiredChannels = new List<TestObjectTemplateChannel>();
|
||||
public List<TestObjectTemplateChannel> RequiredChannels
|
||||
{
|
||||
get => _requiredChannels;
|
||||
set { _requiredChannels = value; OnPropertyChanged("RequiredChannels"); }
|
||||
}
|
||||
|
||||
private string _templateParent = "";
|
||||
public string TemplateParent
|
||||
{
|
||||
get => _templateParent;
|
||||
set => SetProperty(ref _templateParent, value, "TemplateParent");
|
||||
}
|
||||
|
||||
private bool _sysBuilt;
|
||||
public bool SysBuilt
|
||||
{
|
||||
get => _sysBuilt;
|
||||
set => SetProperty(ref _sysBuilt, value, "SysBuilt");
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
private string _name;
|
||||
public string TemplateName
|
||||
{
|
||||
get => _name;
|
||||
set => SetProperty(ref _name, value, Tags.TemplateName.ToString());
|
||||
}
|
||||
|
||||
private string _desc;
|
||||
public string TemplateDescription
|
||||
{
|
||||
get => _desc;
|
||||
set => SetProperty(ref _desc, value, Tags.TemplateDescription.ToString());
|
||||
}
|
||||
|
||||
private bool _bLocalOnly;
|
||||
|
||||
public bool IsLocalOnly
|
||||
{
|
||||
get => _bLocalOnly;
|
||||
set => SetProperty(ref _bLocalOnly, value, "IsLocalOnly");
|
||||
}
|
||||
|
||||
private MMETestObjects _testObject;
|
||||
public MMETestObjects TestObject
|
||||
{
|
||||
get => _testObject;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _testObject, value, Tags.TestObject.ToString());
|
||||
if (null == _testObject) return;
|
||||
AvailableTestObjectTypes = ApplicationProperties.IsoDb.GetUniquePossibleChannelTypes(TestObjectTemplateChannel.NONISOCHANNELTYPE);
|
||||
if (AvailableTestObjectTypes.Length > 0) { TestObjectTypeIndex = 0; }
|
||||
else { TestObjectTypeIndex = -1; }
|
||||
}
|
||||
}
|
||||
|
||||
private string _testObjectType;
|
||||
public string TestObjectType
|
||||
{
|
||||
get => _testObjectType;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _testObjectType, value, Tags.TestObjectType.ToString());
|
||||
_channels = new List<MMEPossibleChannels>(ApplicationProperties.IsoDb.GetPossibleChannelsForType(_testObjectType));
|
||||
TemplateAllChannels = _channels.Select(pc => new TestObjectTemplateChannel(new TestObjectTemplateChannel(pc), /*ref db,*/ _template)).ToArray();
|
||||
AssignOrders();
|
||||
OnPropertyChanged(Tags.PossibleChannelCountText.ToString());
|
||||
OnPropertyChanged(Tags.ChannelCountText.ToString());
|
||||
OnPropertyChanged(Tags.TestObjectTypeIndex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void AssignOrders()
|
||||
{
|
||||
var allChannels = TemplateAllChannels.ToList();
|
||||
if (!allChannels.Any()) { return; }
|
||||
allChannels.Sort();
|
||||
var maxDisplayOrder = (from ch in allChannels select ch.DisplayOrder).Max();
|
||||
foreach (var ch in allChannels)
|
||||
{
|
||||
if (-1 == ch.DisplayOrder)
|
||||
{
|
||||
ch.DisplayOrder = ++maxDisplayOrder;
|
||||
}
|
||||
}
|
||||
}
|
||||
private List<MMEPossibleChannels> _channels = new List<MMEPossibleChannels>();
|
||||
|
||||
//11287 Out of memory exception when importing large CSV Test Setup files
|
||||
//reduced one collection of channels to refer to channel super class members
|
||||
public TestObjectTemplateChannel[] TemplateAllChannels
|
||||
{
|
||||
get
|
||||
{
|
||||
var channels = (from ch in _allUIChannels select ch.Channel).ToArray();
|
||||
return channels;
|
||||
}
|
||||
set
|
||||
{
|
||||
TemplateAllUIChannels = value.Select(c => new TemplateChannelUI(c)).ToArray();
|
||||
}
|
||||
}
|
||||
private List<TemplateChannelUI> _allUIChannels = new List<TemplateChannelUI>();
|
||||
public TemplateChannelUI[] TemplateAllUIChannels
|
||||
{
|
||||
get => _allUIChannels.ToArray();
|
||||
set => SetProperty(ref _allUIChannels, new List<TemplateChannelUI>(value), Tags.TemplateAllUIChannels.ToString());
|
||||
}
|
||||
|
||||
|
||||
private List<MMETestObjects> _testObjects = new List<MMETestObjects>();
|
||||
|
||||
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>(ApplicationProperties.IsoDb.GetTestObjectTypeForTestObject(TestObject.Test_Object));
|
||||
return _availableTestObjectTypes.ToArray();
|
||||
}
|
||||
set => SetProperty(ref _availableTestObjectTypes, new List<string>(value), Tags.AvailableTestObjectTypes.ToString());
|
||||
}
|
||||
|
||||
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;
|
||||
SetProperty(ref _testObjectTypeIndex, value, Tags.TestObjectTypeIndex.ToString());
|
||||
|
||||
TemplateAllChannels = _channels.Select(pc => new TestObjectTemplateChannel(new TestObjectTemplateChannel(pc), /*ref db,*/ _template)).ToArray();
|
||||
AssignOrders();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region methods
|
||||
public void MarkChanged(string tag)
|
||||
{
|
||||
OnPropertyChanged(tag);
|
||||
}
|
||||
|
||||
public int CompareTo(TestObjectTemplate rhs)
|
||||
{
|
||||
if (null == rhs) { return 1; }
|
||||
return this == rhs ? 0 : string.Compare(TemplateName, rhs.TemplateName, StringComparison.Ordinal);
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Embedded ? OriginalTemplateName : TemplateName;
|
||||
}
|
||||
|
||||
public DTS.Common.ISO.TestObjectTemplate ToISOTestObjectTemplate()
|
||||
{
|
||||
var template = new DTS.Common.ISO.TestObjectTemplate(TemplateName, IsLocalOnly)
|
||||
{
|
||||
Description = TemplateDescription,
|
||||
OriginalTemplateName = OriginalTemplateName,
|
||||
Embedded = Embedded,
|
||||
Icon = "",
|
||||
LocalOnly = IsLocalOnly,
|
||||
TestObject = TestObject.Test_Object,
|
||||
TestObjectType = TestObjectType
|
||||
};
|
||||
|
||||
template.TemplateParent = TemplateParent;
|
||||
template.Channels = TemplateAllChannels;
|
||||
template.SysBuilt = SysBuilt;
|
||||
return template;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region constructors and initialization
|
||||
public TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)
|
||||
{
|
||||
if (null != copy._template) { _template = new DTS.Common.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();
|
||||
|
||||
SysBuilt = copy.SysBuilt;
|
||||
Embedded = copy.Embedded;
|
||||
OriginalTemplateName = copy.OriginalTemplateName;
|
||||
}
|
||||
public TestObjectTemplate(DTS.Common.ISO.TestObjectTemplate template, ref ISO13499FileDb db)
|
||||
{
|
||||
Initialize(template, ref db, null);
|
||||
}
|
||||
public TestObjectTemplate(DTS.Common.ISO.TestObjectTemplate template, ref ISO13499FileDb db, List<MMETestObjects> testObjects)
|
||||
{
|
||||
Initialize(template, ref db, testObjects);
|
||||
}
|
||||
private void Initialize(DTS.Common.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 = ApplicationProperties.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();
|
||||
TemplateParent = template.TemplateParent;
|
||||
SysBuilt = template.SysBuilt;
|
||||
}
|
||||
public TestObjectTemplate()
|
||||
{
|
||||
TemplateName = string.Empty;
|
||||
TemplateDescription = string.Empty;
|
||||
TemplateParent = string.Empty;
|
||||
TestObject = ApplicationProperties.IsoDb.GetTestObjects(false).FirstOrDefault();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region XML Serialization
|
||||
public static DTS.Common.ISO.TestObjectTemplate ReadXML(System.Xml.XmlElement root, Dictionary<long, MMEPossibleChannels> importChannels)
|
||||
{
|
||||
var template = new DTS.Common.ISO.TestObjectTemplate("", false);
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
if (node is System.Xml.XmlElement) { ProcessXMLElement(node as System.Xml.XmlElement, ref template, importChannels); }
|
||||
}
|
||||
return template;
|
||||
}
|
||||
private static void ProcessXMLElement(System.Xml.XmlElement node, ref DTS.Common.ISO.TestObjectTemplate template, Dictionary<long, MMEPossibleChannels> importChannels)
|
||||
{
|
||||
if (Enum.TryParse(node.Name, out GroupTemplateFields field))
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case GroupTemplateFields.CRC32: template.CRC32 = Convert.ToInt32(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case GroupTemplateFields.Description: template.Description = node.InnerText; break;
|
||||
case GroupTemplateFields.Icon: template.Icon = node.InnerText; break;
|
||||
case GroupTemplateFields.LastModified: template.LastModified = DateTime.Parse(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case GroupTemplateFields.LastModifiedBy: template.LastModifiedBy = node.InnerText; break;
|
||||
case GroupTemplateFields.LocalOnly: template.LocalOnly = Convert.ToBoolean(node.InnerText); break;
|
||||
case GroupTemplateFields.ParentTemplate: template.TemplateParent = node.InnerText; break;
|
||||
case GroupTemplateFields.SysBuilt: template.SysBuilt = Convert.ToBoolean(node.InnerText); break;
|
||||
case GroupTemplateFields.TemplateName: template.TemplateName = node.InnerText.Trim(); break;
|
||||
case GroupTemplateFields.TestObject: template.TestObject = node.InnerText; break;
|
||||
case GroupTemplateFields.TestObjectType: template.TestObjectType = node.InnerText; break;
|
||||
case GroupTemplateFields.Version: template.Version = Convert.ToInt32(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case GroupTemplateFields.OriginalTemplateName: template.OriginalTemplateName = node.InnerText; break;
|
||||
case GroupTemplateFields.Embedded: template.Embedded = Convert.ToBoolean(node.InnerText); break;
|
||||
default: throw new NotSupportedException("TestObjectTemplate::ProcessXMLElement unknown field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
else if (node.Name == "TemplateChannels")
|
||||
{
|
||||
foreach (var child in node.ChildNodes)
|
||||
{
|
||||
ProcessChannelXMLNode(child as System.Xml.XmlElement, ref template, importChannels);
|
||||
}
|
||||
var channels = new List<TestObjectTemplateChannel>(template.Channels);
|
||||
channels.Sort();
|
||||
template.Channels = channels.ToArray();
|
||||
}
|
||||
}
|
||||
private static void ProcessChannelXMLNode(System.Xml.XmlElement root, ref DTS.Common.ISO.TestObjectTemplate template, Dictionary<long, MMEPossibleChannels> importChannels)
|
||||
{
|
||||
var existingChannels = new List<TestObjectTemplateChannel>(template.Channels);
|
||||
|
||||
var values = new Dictionary<GroupTemplateChannelFields, string>();
|
||||
foreach (var child in root.ChildNodes)
|
||||
{
|
||||
var node = child as System.Xml.XmlElement;
|
||||
if (null == node) { continue; }
|
||||
|
||||
if (Enum.TryParse(node.Name, out GroupTemplateChannelFields field)) { values[field] = node.InnerText; }
|
||||
}
|
||||
|
||||
if (!values.ContainsKey(GroupTemplateChannelFields.MMEChannelId) || !values.ContainsKey(GroupTemplateChannelFields.MMEChannelType)) { return; }
|
||||
|
||||
|
||||
if (!long.TryParse(values[GroupTemplateChannelFields.MMEChannelId], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out long id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!int.TryParse(values[GroupTemplateChannelFields.MMEChannelType], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out int cType))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MMEPossibleChannels mChannel;
|
||||
|
||||
if (cType == (int)MMEPossibleChannels.MMEChannelTypes.SQL && importChannels.ContainsKey(id))
|
||||
{
|
||||
mChannel = importChannels[id];
|
||||
}
|
||||
else { mChannel = ApplicationProperties.IsoDb.GetPossibleChannel(id, cType); }
|
||||
|
||||
if (null == mChannel) { return; }
|
||||
|
||||
var channel = new TestObjectTemplateChannel(mChannel);
|
||||
|
||||
using (var enumeratorGroupChannelFieldSettings = values.GetEnumerator())
|
||||
{
|
||||
while (enumeratorGroupChannelFieldSettings.MoveNext())
|
||||
{
|
||||
switch (enumeratorGroupChannelFieldSettings.Current.Key)
|
||||
{
|
||||
case GroupTemplateChannelFields.BitResolution: break;
|
||||
case GroupTemplateChannelFields.ChannelAmplitudeClass: break;
|
||||
case GroupTemplateChannelFields.ChannelFrequencyClass: break;
|
||||
case GroupTemplateChannelFields.Comments: break;
|
||||
case GroupTemplateChannelFields.Comments1: break;
|
||||
case GroupTemplateChannelFields.CustomerChannelCode: break;
|
||||
case GroupTemplateChannelFields.CutOffFrequency: break;
|
||||
case GroupTemplateChannelFields.DataSource: break;
|
||||
case GroupTemplateChannelFields.DataStatus: break;
|
||||
case GroupTemplateChannelFields.Dimension: break;
|
||||
case GroupTemplateChannelFields.Direction: break;
|
||||
case GroupTemplateChannelFields.DisplayOrder:
|
||||
channel.DisplayOrder = Convert.ToInt32(enumeratorGroupChannelFieldSettings.Current.Value,
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case GroupTemplateChannelFields.EndOffsetInterval: break;
|
||||
case GroupTemplateChannelFields.FirstGlobalMaximumValue: break;
|
||||
case GroupTemplateChannelFields.FirstGlobalMinimumValue: break;
|
||||
case GroupTemplateChannelFields.LaboratoryChannelCode: break;
|
||||
case GroupTemplateChannelFields.LocalOnly:
|
||||
channel.LocalOnly = Convert.ToBoolean(enumeratorGroupChannelFieldSettings.Current.Value);
|
||||
break;
|
||||
case GroupTemplateChannelFields.Location: break;
|
||||
case GroupTemplateChannelFields.MMEChannelId: break;
|
||||
case GroupTemplateChannelFields.MMEChannelType: break;
|
||||
case GroupTemplateChannelFields.NameOfTheChannel:
|
||||
channel.NameOfTheChannel = enumeratorGroupChannelFieldSettings.Current.Value;
|
||||
break;
|
||||
case GroupTemplateChannelFields.NumberOfSamples: break;
|
||||
case GroupTemplateChannelFields.OffsetPostTest: break;
|
||||
case GroupTemplateChannelFields.PreFilterType: break;
|
||||
case GroupTemplateChannelFields.ReferenceChannel: break;
|
||||
case GroupTemplateChannelFields.ReferenceChannelName: break;
|
||||
case GroupTemplateChannelFields.ReferenceSystem: break;
|
||||
case GroupTemplateChannelFields.Required:
|
||||
channel.Required = Convert.ToBoolean(enumeratorGroupChannelFieldSettings.Current.Value);
|
||||
break;
|
||||
case GroupTemplateChannelFields.SamplingInterval: break;
|
||||
case GroupTemplateChannelFields.StartOffsetInterval: break;
|
||||
case GroupTemplateChannelFields.TestObjectNumber: break;
|
||||
case GroupTemplateChannelFields.TimeOfFirstSample: break;
|
||||
case GroupTemplateChannelFields.TimeOfMaximumValue: break;
|
||||
case GroupTemplateChannelFields.TimeOfMinimumValue: break;
|
||||
case GroupTemplateChannelFields.TransducerDampingRatio: break;
|
||||
case GroupTemplateChannelFields.TransducerId: break;
|
||||
case GroupTemplateChannelFields.TransducerNaturalFrequency: break;
|
||||
case GroupTemplateChannelFields.TransducerType: break;
|
||||
case GroupTemplateChannelFields.Unit: break;
|
||||
default:
|
||||
throw new NotSupportedException(
|
||||
"TestObjectTemplate::ProcessChannelXMLNode unsupported field: " + enumeratorGroupChannelFieldSettings.Current.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
existingChannels.Add(channel);
|
||||
var maxDisplayOrder = (from ch in existingChannels select ch.DisplayOrder).Max();
|
||||
|
||||
foreach (var ch in existingChannels)
|
||||
{
|
||||
if (-1 == ch.DisplayOrder)
|
||||
{
|
||||
ch.DisplayOrder = ++maxDisplayOrder;
|
||||
}
|
||||
}
|
||||
template.Channels = existingChannels.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.ISO;
|
||||
using DTS.Common.DataModel;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
public class TestObjectTemplateCollection : BasePropertyChanged
|
||||
{
|
||||
private static volatile TestObjectTemplateCollection _testObjectCollection;
|
||||
public static TestObjectTemplateCollection TemplateCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == _testObjectCollection)
|
||||
{
|
||||
_testObjectCollection = new TestObjectTemplateCollection();
|
||||
}
|
||||
return _testObjectCollection;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly TestObjectTemplate _sysBuiltTestObjectTemplate;
|
||||
public TestObjectTemplate SysBuiltTestObjectTemplate => _sysBuiltTestObjectTemplate;
|
||||
public TestObjectTemplate GetTemplate(string templateId)
|
||||
{
|
||||
var db = ApplicationProperties.IsoDb;
|
||||
var isoTemplate = DTS.Common.ISO.TestObjectTemplate.GetTemplate(ref db, templateId);
|
||||
if (null != isoTemplate)
|
||||
{
|
||||
return new TestObjectTemplate(isoTemplate, ref db);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TestObjectTemplateCollection()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
315
Common/DTS.Common.DataModel/Classes/TestObject/TestTestObject.cs
Normal file
315
Common/DTS.Common.DataModel/Classes/TestObject/TestTestObject.cs
Normal file
@@ -0,0 +1,315 @@
|
||||
using DTS.Common.DataModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <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, IComparable<TestTestObject>
|
||||
{
|
||||
public TestTestObject(TestObject obj)
|
||||
: base(obj)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// added a new constructor for
|
||||
/// 9570 Test object and position defaulted (traditional groups) when you rename or copy a test setup
|
||||
/// as old constructor missed the meta data copy
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="convertToEmbedded"></param>
|
||||
public TestTestObject(TestTestObject obj, bool convertToEmbedded)
|
||||
{
|
||||
CommonCustructorItems(obj, convertToEmbedded);
|
||||
MetaCommonConstructor(obj);
|
||||
}
|
||||
public TestTestObject(TestObject obj, bool convertToEmbedded)
|
||||
{
|
||||
CommonCustructorItems(obj, convertToEmbedded);
|
||||
}
|
||||
/// <summary>
|
||||
/// takes care of all the non meta constructor information
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="convertToEmbedded"></param>
|
||||
private void CommonCustructorItems(TestObject obj, bool convertToEmbedded)
|
||||
{
|
||||
var bAlreadyConverted = obj.GetISOTestObject().Embedded;
|
||||
if (convertToEmbedded)
|
||||
{
|
||||
var guid = Guid.NewGuid();
|
||||
//first grab a copy of the template and convert it
|
||||
var isoTemplate = obj.Template.ToISOTestObjectTemplate();
|
||||
isoTemplate.Embedded = true;
|
||||
|
||||
isoTemplate.OriginalTemplateName = bAlreadyConverted ? isoTemplate.OriginalTemplateName : isoTemplate.TemplateName;
|
||||
|
||||
isoTemplate.TemplateName = guid.ToString();
|
||||
var db = ApplicationProperties.IsoDb;
|
||||
var template = new TestObjectTemplate(isoTemplate, ref db);
|
||||
|
||||
var isoTestObject = new DTS.Common.ISO.TestObject(obj.GetISOTestObject(), isoTemplate, db);
|
||||
isoTestObject.OriginalSerialNumber = obj.SerialNumber;
|
||||
if (bAlreadyConverted) { isoTestObject.OriginalSerialNumber = obj.SerialNumberOrOriginalSerialNumber; }
|
||||
isoTestObject.SerialNumber = guid.ToString();
|
||||
isoTestObject.Embedded = true;
|
||||
isoTestObject.OriginalTemplate = obj.Template.TemplateName;
|
||||
if (bAlreadyConverted) { isoTestObject.OriginalTemplate = obj.Template.OriginalTemplateName; }
|
||||
isoTestObject.SetTemplateOnly(guid.ToString());
|
||||
var includedHardware = new Dictionary<string, DASHardware>();
|
||||
foreach (var h in obj.Hardware)
|
||||
{
|
||||
includedHardware[h.GetHardware().GetId()] = h;
|
||||
}
|
||||
var to = new TestObject(isoTestObject, false, template, includedHardware);
|
||||
Initialize(to);
|
||||
//UGH, something resets the template properties.
|
||||
//just change them back for now to the right values :/
|
||||
Template.Embedded = true;
|
||||
Template.OriginalTemplateName = template.OriginalTemplateName;
|
||||
Template.TemplateName = template.TemplateName;
|
||||
}
|
||||
else
|
||||
{
|
||||
Initialize(obj);
|
||||
}
|
||||
}
|
||||
private string _position = ChannelDefaultsKey;
|
||||
public DTS.Common.ISO.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 DTS.Common.ISO.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
|
||||
{
|
||||
//TODO Remove Non-ISO Mode code
|
||||
if (_groupPositionComboBoxVisible == Visibility.Visible)
|
||||
{
|
||||
return /*Common.SerializedSettings.ISOSupportLevel == Common.SerializedSettings.ISOSupportLevels.NO_ISO ? Visibility.Collapsed :*/ _groupPositionComboBoxVisible;
|
||||
}
|
||||
return _groupPositionComboBoxVisible;
|
||||
}
|
||||
set => SetProperty(ref _groupPositionComboBoxVisible, value, "GroupPositionComboBoxVisible");
|
||||
}
|
||||
|
||||
private Visibility _groupPositionButtonVisible = Visibility.Hidden;
|
||||
public Visibility GroupPositionButtonVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
//TODO Remove Non-ISO Mode code
|
||||
if (_groupPositionButtonVisible == Visibility.Visible)
|
||||
{
|
||||
return /*Common.SerializedSettings.ISOSupportLevel == Common.SerializedSettings.ISOSupportLevels.NO_ISO ? Visibility.Collapsed :*/ _groupPositionButtonVisible;
|
||||
}
|
||||
return _groupPositionButtonVisible;
|
||||
}
|
||||
set => SetProperty(ref _groupPositionButtonVisible, value, "GroupPositionButtonVisible");
|
||||
}
|
||||
|
||||
private string _testObject = "?";
|
||||
public DTS.Common.ISO.MMETestObjects TestObject
|
||||
{
|
||||
get => ApplicationProperties.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 DTS.Common.ISO.MMEPositions[] AvailablePositions => ApplicationProperties.IsoDb.GetPositions();
|
||||
|
||||
private const string DATAPRO_DEFINED = "DataPRO-defined";
|
||||
public static DTS.Common.ISO.MMEPositions _channelDefaultsGUID = new DTS.Common.ISO.MMEPositions(Guid.NewGuid().ToString(), ChannelDefaultsKey, "(channel defaults)", "(channel defaults)", 1, DateTime.Now, DATAPRO_DEFINED, false, "", DateTime.Now,
|
||||
DATAPRO_DEFINED, "", DTS.Common.ISO.MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
||||
private DTS.Common.ISO.MMEPositions _userSetGUID = new DTS.Common.ISO.MMEPositions(Guid.NewGuid().ToString(), UserSetKey, "(multiple)", "(multiple)", 1, DateTime.Now, DATAPRO_DEFINED, false, "", DateTime.Now,
|
||||
DATAPRO_DEFINED, "", DTS.Common.ISO.MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
||||
public DTS.Common.ISO.MMEPositions[] AvailableGroupPositions
|
||||
{
|
||||
get
|
||||
{
|
||||
var availableGroupPositions = new List<DTS.Common.ISO.MMEPositions>();
|
||||
availableGroupPositions.Add(_channelDefaultsGUID);
|
||||
availableGroupPositions.AddRange(AvailablePositions);
|
||||
|
||||
return availableGroupPositions.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private List<TestObject> _addedGroups = new List<TestObject>();
|
||||
public TestObject[] AddedGroups
|
||||
{
|
||||
get => _addedGroups.ToArray();
|
||||
set
|
||||
{
|
||||
SetProperty(ref _addedGroups, new List<TestObject>(value), "AddedSysBuiltTestObjects");
|
||||
OnPropertyChanged("AddedSysBuiltTestObjectsMME");
|
||||
}
|
||||
}
|
||||
|
||||
public string[] ChannelTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
var typeList = new List<string>();
|
||||
typeList.Add("(no channels)"); //temp
|
||||
typeList.AddRange(ApplicationProperties.IsoDb.GetUniquePossibleChannelTypes(DTS.Common.ISO.TestObjectTemplateChannel.NONISOCHANNELTYPE));
|
||||
return typeList.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?
|
||||
IsAdd = to.IsAdd;
|
||||
DisplayOrder = to.DisplayOrder;
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
public void Rename(string oldName, string newName)
|
||||
{
|
||||
SerialNumber = SerialNumber.Replace(oldName, newName);
|
||||
GetISOTestObject().OriginalSerialNumber = GetISOTestObject().OriginalSerialNumber.Replace(oldName, newName);
|
||||
GetISOTestObject().OriginalTemplate = GetISOTestObject().OriginalTemplate.Replace(oldName, newName);
|
||||
TestSetupName = newName;
|
||||
var templateGUIDString = Guid.NewGuid().ToString();
|
||||
Template.TemplateName = templateGUIDString;
|
||||
Template.OriginalTemplateName = templateGUIDString;
|
||||
}
|
||||
|
||||
public int DisplayOrder { get; set; } = -1;
|
||||
|
||||
public bool IsAdd { get; set; }
|
||||
public int CompareTo(TestTestObject other)
|
||||
{
|
||||
var ret = DisplayOrder.CompareTo(other.DisplayOrder);
|
||||
if (0 == ret)
|
||||
{
|
||||
ret = base.CompareTo(other);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,540 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using DTS.Common.Interface.BuildTestSetup;
|
||||
using DTS.Common.XMLUtils;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
[Serializable]
|
||||
public class BuildTestSetup : IBuildTestSetup
|
||||
{
|
||||
|
||||
public BuildTestSetup(string dasSerialNumber, string testSetupName, ExportFileXMLClass exportFileXML)
|
||||
{
|
||||
var testSetupXML = exportFileXML.TestSetupsOuter[0].TestSetups[0];
|
||||
var testSetupXMLFields = testSetupXML.Fields;
|
||||
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
SetupName = testSetupXMLFields.SetupName;
|
||||
|
||||
SetupDescription = testSetupXMLFields.SetupDescription;
|
||||
AutomaticMode = testSetupXMLFields.AutomaticTestProgression;
|
||||
AutomaticModeDelay = testSetupXMLFields.AutomaticProgressionDelayMS;
|
||||
//testSetupXMLFields.InvertTrigger;
|
||||
//testSetupXMLFields.InvertStart;
|
||||
//ViewDiagnostics = testSetupXMLFields.ViewDiagnostics;
|
||||
//VerifyChannels = testSetupXMLFields.VerifyChannels;
|
||||
//AutoVerifyChannels
|
||||
//VerifyChannelsDelayMS
|
||||
RecordingMode = testSetupXMLFields.RecordingMode;
|
||||
SamplesPerSecond = testSetupXMLFields.SamplesPerSecond;
|
||||
PreTriggerSeconds = testSetupXMLFields.PreTriggerSeconds;
|
||||
PostTriggerSeconds = testSetupXMLFields.PostTriggerSeconds;
|
||||
NumberOfEvents = testSetupXMLFields.NumberOfEvents;
|
||||
WakeUpMotionTimeout = testSetupXMLFields.WakeUpMotionTimeout;
|
||||
ScheduledStartDateTime = testSetupXMLFields.ScheduledStartDateTime;
|
||||
IntervalBetweenEventStartsMinutes = testSetupXMLFields.IntervalBetweenEventStartsMinutes;
|
||||
StartWithEvent = testSetupXMLFields.StartWithEvent;
|
||||
WakeUpWithMotion = testSetupXMLFields.WakeUpWithMotion;
|
||||
StrictDiagnostics = testSetupXMLFields.StrictDiagnostics;
|
||||
RequireConfirmationOnErrors = testSetupXMLFields.RequireConfirmationOnErrors;
|
||||
ROIDownload = testSetupXMLFields.ROIDownload;
|
||||
ViewROIDownload = testSetupXMLFields.ViewROIDownload;
|
||||
DownloadAll = testSetupXMLFields.DownloadAll;
|
||||
ViewRealtime = testSetupXMLFields.ViewRealtime;
|
||||
RealtimeCharts = testSetupXMLFields.RealtimePlotCount;
|
||||
ROIStart = testSetupXMLFields.ROIStart;
|
||||
ROIEnd = testSetupXMLFields.ROIEnd;
|
||||
ViewDownloadAll = testSetupXMLFields.ViewDownloadAll;
|
||||
Export = testSetupXMLFields.Export;
|
||||
//ExportFormat = testSetupXMLFields.ExportFormat;
|
||||
DecodeExportFormats(testSetupXMLFields.ExportFormat);
|
||||
//LabDetails = testSetupXMLFields.LabDetails;
|
||||
UseLabDetails = testSetupXMLFields.UseLabDetails;
|
||||
//CustomerDetails
|
||||
UseCustomerDetails = testSetupXMLFields.UseCustomerDetails;
|
||||
AllowMissingSensors = testSetupXMLFields.AllowMissingSensors;
|
||||
AllowSensorIdToBlankChannel = testSetupXMLFields.AllowSensorIdToBlankChannel;
|
||||
ParseSettings(testSetupXMLFields.Settings);
|
||||
//LocalOnly
|
||||
LastModified = testSetupXMLFields.LastModified;
|
||||
LastModifiedBy = testSetupXMLFields.LastModifiedBy;
|
||||
//TurnOffExcitation
|
||||
//TriggerCheckRealtime
|
||||
TriggerCheckStep = testSetupXMLFields.TriggerCheckStep;
|
||||
PostTestDiagnostics = testSetupXMLFields.PostTestDiagnostics;
|
||||
ExportFolder = testSetupXMLFields.ExportFolder;
|
||||
//DownloadFolder
|
||||
CommonStatusLine = testSetupXMLFields.CommonStatusLine;
|
||||
//SameAsDownloadFolder
|
||||
UploadData = testSetupXMLFields.UploadData;
|
||||
UploadDataFolder = testSetupXMLFields.UploadDataFolder;
|
||||
//UploadExportsOnly
|
||||
//Settings
|
||||
WarnOnBatteryFail = testSetupXMLFields.WarnOnBatteryFail;
|
||||
//Dirty
|
||||
//Complete
|
||||
//ErrorMessage
|
||||
//TestEngineerDetails
|
||||
UseTestEngineerDetails = testSetupXMLFields.UseTestEngineerDetails;
|
||||
UserTags = testSetupXMLFields.UserTags;
|
||||
AutoArm = testSetupXMLFields.DoAutoArm;
|
||||
Streaming = testSetupXMLFields.DoStreaming;
|
||||
//CheckoutMode
|
||||
QuitTestWithoutWarning = testSetupXMLFields.QuitTestWithoutWarning;
|
||||
SuppressMissingSensorsWarning = testSetupXMLFields.SuppressMissingSensorsWarning;
|
||||
//ISFFile
|
||||
NotAllChannelsRealTime = testSetupXMLFields.NotAllChannelsRealTime;
|
||||
NotAllChannelsViewer = testSetupXMLFields.NotAllChannelsViewer;
|
||||
CalibrationBehavior = testSetupXMLFields.CalibrationBehavior;
|
||||
//ClockSyncProfileMaster
|
||||
//ClockSyncProfileSlave
|
||||
//ExtraProperties
|
||||
MeasureSquibResistances = testSetupXMLFields.MeasureSquibResistancesStep;
|
||||
|
||||
Groups = new List<GroupXMLClass>();
|
||||
foreach (var group in testSetupXML.Groups[0].Group)
|
||||
{
|
||||
Groups.Add(group);
|
||||
}
|
||||
|
||||
LevelTriggers = new List<LevelTriggerXMLClass>();
|
||||
if (testSetupXML.LevelTriggers != null && testSetupXML.LevelTriggers.LevelTriggers != null)
|
||||
{
|
||||
foreach (var levelTrigger in testSetupXML.LevelTriggers.LevelTriggers)
|
||||
{
|
||||
LevelTriggers.Add(levelTrigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ParseSettings(string allSettings)
|
||||
{
|
||||
const string PerformArmChecklistNumber = "0=";
|
||||
const string CheckInputVoltageNumber = "1=";
|
||||
const string CheckBatteryVoltageNumber = "2=";
|
||||
const string CheckSquibResistanceNumber = "3=";
|
||||
const string CheckSensorIdsNumber = "4=";
|
||||
const string CheckStartEventLinesNumber = "5=";
|
||||
const string CheckTiltSensorNumber = "6=";
|
||||
const string CheckTemperatureNumber = "7=";
|
||||
|
||||
const string ExcitationWarmupMSNumber = "9=";
|
||||
const string CheckRequireAllUnitsPassArmChecklistNumber = "10=";
|
||||
|
||||
var settings = allSettings.Split(',');
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
var startIndex = setting.IndexOf('=') + 1;
|
||||
var len = setting.Length - startIndex;
|
||||
if (setting.StartsWith(PerformArmChecklistNumber))
|
||||
{
|
||||
PerformArmChecklist = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckInputVoltageNumber))
|
||||
{
|
||||
CheckInputVoltage = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckBatteryVoltageNumber))
|
||||
{
|
||||
CheckBatteryVoltage = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckSquibResistanceNumber))
|
||||
{
|
||||
CheckSquibResistance = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckSensorIdsNumber))
|
||||
{
|
||||
CheckSensorIds = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckStartEventLinesNumber))
|
||||
{
|
||||
CheckStartEventLines = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckTiltSensorNumber))
|
||||
{
|
||||
CheckTiltSensor = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckTemperatureNumber))
|
||||
{
|
||||
CheckTemperature = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(ExcitationWarmupMSNumber))
|
||||
{
|
||||
ExcitationWarmupTimeMS = setting.Substring(startIndex, len);
|
||||
}
|
||||
else if (setting.StartsWith(CheckRequireAllUnitsPassArmChecklistNumber))
|
||||
{
|
||||
RequireAllUnitsPassArmCheckList = setting.Substring(startIndex, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DecodeExportFormats(string exportFormat)
|
||||
{
|
||||
var exportFormatInt = Int32.Parse(exportFormat);
|
||||
ExportCh10FilteredEUDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.Ch10FilteredEU) == SupportedExportFormatBitFlags.Ch10FilteredEU).ToString();
|
||||
//ExportCh10UnfilteredEUDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.Ch10UnfilteredEU) == SupportedExportFormatBitFlags.Ch10UnfilteredEU).ToString();
|
||||
ExportChryslerDDASDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.ChryslerDDAS) == SupportedExportFormatBitFlags.ChryslerDDAS).ToString();
|
||||
ExportCSVADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.CSVADC) == SupportedExportFormatBitFlags.CSVADC).ToString();
|
||||
ExportCSVFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.csvfiltered) == SupportedExportFormatBitFlags.csvfiltered).ToString();
|
||||
ExportCSVMVDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.CSVMV) == SupportedExportFormatBitFlags.CSVMV).ToString();
|
||||
ExportCSVUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.csvunfiltered) == SupportedExportFormatBitFlags.csvunfiltered).ToString();
|
||||
ExportDiademADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.diademadc) == SupportedExportFormatBitFlags.diademadc).ToString();
|
||||
ExportASCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.FIATASC) == SupportedExportFormatBitFlags.FIATASC).ToString();
|
||||
ExportHDFADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.HDFADC) == SupportedExportFormatBitFlags.HDFADC).ToString();
|
||||
//ExportHDFFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.HDFFiltered) == SupportedExportFormatBitFlags.HDFFiltered).ToString();
|
||||
ExportHDFMVDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.HDFMV) == SupportedExportFormatBitFlags.HDFMV).ToString();
|
||||
ExportHDFUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.HDFUnfiltered) == SupportedExportFormatBitFlags.HDFUnfiltered).ToString();
|
||||
ExportISOFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.isofiltered) == SupportedExportFormatBitFlags.isofiltered).ToString();
|
||||
ExportISOUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.isounfiltered) == SupportedExportFormatBitFlags.isounfiltered).ToString();
|
||||
ExportRDFADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.rdfadc) == SupportedExportFormatBitFlags.rdfadc).ToString();
|
||||
//ExportSomatFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.somatfiltered) == SupportedExportFormatBitFlags.somatfiltered).ToString();
|
||||
//ExportSomatUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.somatunfiltered) == SupportedExportFormatBitFlags.somatunfiltered).ToString();
|
||||
ExportTDASADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.tdasadc) == SupportedExportFormatBitFlags.tdasadc).ToString();
|
||||
ExportTDMSADCDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.tdmsadc) == SupportedExportFormatBitFlags.tdmsadc).ToString();
|
||||
//ExportToyotaFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.toyotafiltered) == SupportedExportFormatBitFlags.toyotafiltered).ToString();
|
||||
ExportToyotaUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.toyotaunfiltered) == SupportedExportFormatBitFlags.toyotaunfiltered).ToString();
|
||||
ExportTSVFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.tsvfiltered) == SupportedExportFormatBitFlags.tsvfiltered).ToString();
|
||||
ExportTSVUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.tsvunfiltered) == SupportedExportFormatBitFlags.tsvunfiltered).ToString();
|
||||
ExportXLSXFilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.xlsxfiltered) == SupportedExportFormatBitFlags.xlsxfiltered).ToString();
|
||||
ExportXLSXUnfilteredDesired = (((SupportedExportFormatBitFlags)exportFormatInt & SupportedExportFormatBitFlags.xlsxunfiltered) == SupportedExportFormatBitFlags.xlsxunfiltered).ToString();
|
||||
}
|
||||
public BuildTestSetup(string dasSerialNumber, string testSetupName, TestTemplate testTemplate)
|
||||
{
|
||||
DASSerialNumber = dasSerialNumber;
|
||||
SetupName = string.IsNullOrWhiteSpace(testSetupName) ? StringResources.DefaultTestSetupName : testSetupName;
|
||||
|
||||
SetupDescription = testTemplate.Description;
|
||||
AutomaticMode = testTemplate.AutomaticProgression.ToString();
|
||||
AutomaticModeDelay = testTemplate.AutomaticProgressionDelayMS.ToString();
|
||||
//testSetupXMLFields.InvertTrigger;
|
||||
//testSetupXMLFields.InvertStart;
|
||||
//ViewDiagnostics = testTemplate.ViewDiagnostics.ToString();
|
||||
//VerifyChannels = testTemplate.VerifyChannels;
|
||||
//AutoVerifyChannels
|
||||
//VerifyChannelsDelayMS
|
||||
RecordingMode = testTemplate.RecordingMode.ToString();
|
||||
SamplesPerSecond = testTemplate.SamplesPerSecondAggregate.ToString();
|
||||
PreTriggerSeconds = testTemplate.PreTriggerSeconds.ToString();
|
||||
PostTriggerSeconds = testTemplate.PostTriggerSeconds.ToString();
|
||||
NumberOfEvents = testTemplate.NumberOfEvents.ToString();
|
||||
WakeUpMotionTimeout = testTemplate.WakeUpMotionTimeout.ToString();
|
||||
StrictDiagnostics = testTemplate.StrictDiagnostics.ToString();
|
||||
RequireConfirmationOnErrors = testTemplate.RequireUserConfirmationOnErrors.ToString();
|
||||
ROIDownload = testTemplate.DoROIDownload.ToString();
|
||||
ViewROIDownload = testTemplate.ViewROIDownload.ToString();
|
||||
DownloadAll = testTemplate.DownloadAll.ToString();
|
||||
ViewRealtime = testTemplate.ViewRealtime.ToString();
|
||||
RealtimeCharts = testTemplate.DefaultNumberRealtimeGraphs.ToString();
|
||||
ROIStart = testTemplate.ROIStart.ToString();
|
||||
ROIEnd = testTemplate.ROIEnd.ToString();
|
||||
ViewDownloadAll = testTemplate.ViewDownloadAll.ToString();
|
||||
Export = testTemplate.ViewExport.ToString();
|
||||
ExportFolder = testTemplate.ExportFolder;
|
||||
//ExportFormat = testTemplate.ExportFormats.ToString();
|
||||
GetExports(testTemplate.ExportFormats.ToString());
|
||||
//LabDetails = testSetupXMLFields.LabDetails;
|
||||
UseLabDetails = testTemplate.UseLabratoryDetails.ToString();
|
||||
//CustomerDetails
|
||||
UseCustomerDetails = testTemplate.UseCustomerDetails.ToString();
|
||||
AllowMissingSensors = testTemplate.AllowMissingSensors.ToString();
|
||||
AllowSensorIdToBlankChannel = testTemplate.AllowSensorIdToBlankChannel.ToString();
|
||||
ExcitationWarmupTimeMS = testTemplate.ExcitationWarmupTimeMS.ToString();
|
||||
//LocalOnly
|
||||
LastModified = testTemplate.LastModified.ToString();
|
||||
LastModifiedBy = testTemplate.LastModifiedBy;
|
||||
//TurnOffExcitation
|
||||
//TriggerCheckRealtime
|
||||
TriggerCheckStep = testTemplate.TriggerCheckStep.ToString();
|
||||
PostTestDiagnostics = testTemplate.PostTestDiagnosticsLevel.ToString();
|
||||
//ExportFolder
|
||||
//DownloadFolder
|
||||
CommonStatusLine = testTemplate.CommonLine.ToString();
|
||||
//SameAsDownloadFolder
|
||||
UploadData = testTemplate.UploadData.ToString();
|
||||
UploadDataFolder = testTemplate.UploadFolder;
|
||||
//UploadExportsOnly
|
||||
//Settings
|
||||
WarnOnBatteryFail = testTemplate.WarnOnFailedBattery.ToString();
|
||||
//Dirty
|
||||
//Complete
|
||||
//ErrorMessage
|
||||
//TestEngineerDetails
|
||||
UseTestEngineerDetails = testTemplate.UseTestEngineerDetails.ToString();
|
||||
UserTags = string.Empty;
|
||||
AutoArm = testTemplate.DoAutoArm.ToString();
|
||||
Streaming = testTemplate.DoStreaming.ToString();
|
||||
//CheckoutMode
|
||||
QuitTestWithoutWarning = testTemplate.QuitTestWithoutWarning.ToString();
|
||||
SuppressMissingSensorsWarning = testTemplate.SuppressMissingSensorsWarning.ToString();
|
||||
//ISFFile
|
||||
NotAllChannelsRealTime = testTemplate.NotAllChannelsRealTime.ToString();
|
||||
NotAllChannelsViewer = testTemplate.NotAllChannelsViewer.ToString();
|
||||
CalibrationBehavior = testTemplate.CalibrationBehavior.ToString();
|
||||
//ClockSyncProfileMaster
|
||||
//ClockSyncProfileSlave
|
||||
//ExtraProperties
|
||||
MeasureSquibResistances = testTemplate.MeasureSquibResistancesStep.ToString();
|
||||
PerformArmChecklist = testTemplate.ArmCheckListStep.ToString();
|
||||
CheckInputVoltage = testTemplate.CheckListInputVoltageCheck.ToString();
|
||||
CheckBatteryVoltage = testTemplate.CheckListBatteryVoltageCheck.ToString();
|
||||
CheckSquibResistance = testTemplate.CheckListSquibResistanceCheck.ToString();
|
||||
CheckSensorIds = testTemplate.CheckListSensorIdCheck.ToString();
|
||||
CheckStartEventLines = testTemplate.CheckListTriggerStartCheck.ToString();
|
||||
CheckTiltSensor = testTemplate.CheckListTiltSensorCheck.ToString();
|
||||
CheckTemperature = testTemplate.CheckListTemperatureCheck.ToString();
|
||||
|
||||
RequireAllUnitsPassArmCheckList = testTemplate.CheckListRequirePass.ToString();
|
||||
|
||||
Groups = new List<GroupXMLClass>();
|
||||
foreach (var group in testTemplate.Groups)
|
||||
{
|
||||
var xmlGroup = new GroupXMLClass();
|
||||
xmlGroup.Name = group.Name;
|
||||
xmlGroup.DisplayName = group.DisplayName;
|
||||
xmlGroup.Description = group.Description;
|
||||
xmlGroup.DisplayOrder = group.DisplayOrder.ToString();
|
||||
xmlGroup.HardwareList = new HardwareListXMLClass(); //Add hardware serial numbers to this (from channels? from includedHardwareList?)
|
||||
|
||||
foreach (var channel in group.GroupChannelList)
|
||||
{
|
||||
var xmlChannel = new ChannelXMLClass();
|
||||
xmlChannel.ISOChannelName = channel.IsoChannelName;
|
||||
xmlChannel.ISOCode = channel.IsoCode;
|
||||
xmlChannel.UserChannelName = channel.UserChannelName;
|
||||
xmlChannel.UserCode = channel.UserCode;
|
||||
xmlChannel.TestSetupOrder = channel.TestSetupOrder.ToString();
|
||||
xmlChannel.GroupOrder = channel.GroupChannelOrder.ToString();
|
||||
|
||||
xmlChannel.Settings.FilterClass = $"{channel.FilterClass.FClass.ToString()},{channel.FilterClass.Frequency.ToString()}";
|
||||
xmlChannel.Settings.Polarity = channel.Polarity;
|
||||
xmlChannel.Settings.Range = channel.Range.ToString();
|
||||
xmlChannel.Settings.ZeroMethod = channel.ZeroMethod.ToString();
|
||||
xmlChannel.Settings.ZeroMethodStart = channel.ZeroMethodStart.ToString();
|
||||
xmlChannel.Settings.ZeroMethodEnd = channel.ZeroMethodEnd.ToString();
|
||||
xmlChannel.Settings.InitialOffset = $"{channel.InitialOffset.Form},{channel.InitialOffset.EU},{channel.InitialOffset.MV}";
|
||||
xmlChannel.Settings.UserValue1 = channel.SensorData.UserValue1;
|
||||
xmlChannel.Settings.UserValue2 = channel.SensorData.UserValue2;
|
||||
xmlChannel.Settings.UserValue3 = channel.SensorData.UserValue3;
|
||||
|
||||
xmlGroup.Channel.Add(xmlChannel);
|
||||
}
|
||||
|
||||
Groups.Add(xmlGroup);
|
||||
}
|
||||
|
||||
LevelTriggers = new List<LevelTriggerXMLClass>();
|
||||
if (testTemplate.LevelTriggerChannels != null)
|
||||
{
|
||||
foreach (var levelTrigger in testTemplate.LevelTriggerChannels)
|
||||
{
|
||||
var xmlLevelTrigger = new LevelTriggerXMLClass();
|
||||
xmlLevelTrigger.GreaterThanEnabled = levelTrigger.Value.GreaterThanEnabled.ToString();
|
||||
xmlLevelTrigger.GreaterThanValue = levelTrigger.Value.GreaterThanThresholdEU.ToString();
|
||||
xmlLevelTrigger.GroupChannelId = levelTrigger.Value.GroupChannelId;
|
||||
xmlLevelTrigger.HardwareChannelId = levelTrigger.Value.HardwareChannelId;
|
||||
xmlLevelTrigger.InsideLowerEU = levelTrigger.Value.InsideLowerLevelEU.ToString();
|
||||
xmlLevelTrigger.InsideUpperEU = levelTrigger.Value.InsideUpperLevelEU.ToString();
|
||||
xmlLevelTrigger.LessThanEnabled = levelTrigger.Value.LessThanEnabled.ToString();
|
||||
xmlLevelTrigger.LessThanValue = levelTrigger.Value.LessThanThresholdEU.ToString();
|
||||
xmlLevelTrigger.OutsideLowerEU = levelTrigger.Value.OutsideLowerLevelEU.ToString();
|
||||
xmlLevelTrigger.OutsideUpperEU = levelTrigger.Value.OutsideUpperLevelEU.ToString();
|
||||
xmlLevelTrigger.SensorSerialNumber = levelTrigger.Value.SensorSerialNumber;
|
||||
xmlLevelTrigger.TriggerInside = levelTrigger.Value.TriggerBetweenBounds.ToString();
|
||||
xmlLevelTrigger.TriggerOutside = levelTrigger.Value.TriggerOutsideBounds.ToString();
|
||||
LevelTriggers.Add(xmlLevelTrigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void GetExports(string exportFormats)
|
||||
{
|
||||
//Initialize all to false
|
||||
ExportCSVUnfilteredDesired = false.ToString();
|
||||
ExportDiademADCDesired = false.ToString();
|
||||
ExportISOFilteredDesired = false.ToString();
|
||||
ExportISOUnfilteredDesired = false.ToString();
|
||||
ExportToyotaUnfilteredDesired = false.ToString();
|
||||
ExportTSVUnfilteredDesired = false.ToString();
|
||||
ExportCSVFilteredDesired = false.ToString();
|
||||
ExportTDASADCDesired = false.ToString();
|
||||
ExportTSVFilteredDesired = false.ToString();
|
||||
ExportRDFADCDesired = false.ToString();
|
||||
ExportChryslerDDASDesired = false.ToString();
|
||||
ExportHDFUnfilteredDesired = false.ToString();
|
||||
ExportHDFMVDesired = false.ToString();
|
||||
ExportHDFADCDesired = false.ToString();
|
||||
ExportXLSXFilteredDesired = false.ToString();
|
||||
ExportXLSXUnfilteredDesired = false.ToString();
|
||||
ExportCSVADCDesired = false.ToString();
|
||||
ExportCSVMVDesired = false.ToString();
|
||||
ExportCh10FilteredEUDesired = false.ToString();
|
||||
ExportTDMSADCDesired = false.ToString();
|
||||
ExportASCDesired = false.ToString();
|
||||
var exportFormatArray = exportFormats.Split(',');
|
||||
foreach (var exportFormat in exportFormatArray)
|
||||
{
|
||||
switch (exportFormat.Trim())
|
||||
{
|
||||
case "csvunfiltered":
|
||||
ExportCSVUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "diademadc":
|
||||
ExportDiademADCDesired = true.ToString();
|
||||
break;
|
||||
case "isofiltered":
|
||||
ExportISOFilteredDesired = true.ToString();
|
||||
break;
|
||||
case "isounfiltered":
|
||||
ExportISOUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "toyotaunfiltered":
|
||||
ExportToyotaUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "tsvunfiltered":
|
||||
ExportTSVUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "csvfiltered":
|
||||
ExportCSVFilteredDesired = true.ToString();
|
||||
break;
|
||||
case "tdasadc":
|
||||
ExportTDASADCDesired = true.ToString();
|
||||
break;
|
||||
case "tdmsadc":
|
||||
ExportTDMSADCDesired = true.ToString();
|
||||
break;
|
||||
case "tsvfiltered":
|
||||
ExportTSVFilteredDesired = true.ToString();
|
||||
break;
|
||||
case "rdfadc":
|
||||
ExportRDFADCDesired = true.ToString();
|
||||
break;
|
||||
case "ChryslerDDAS":
|
||||
ExportChryslerDDASDesired = true.ToString();
|
||||
break;
|
||||
case "HDFUnfiltered":
|
||||
ExportHDFUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "HDFMV":
|
||||
ExportHDFMVDesired = true.ToString();
|
||||
break;
|
||||
case "HDFADC":
|
||||
ExportHDFADCDesired = true.ToString();
|
||||
break;
|
||||
case "xlsxfiltered":
|
||||
ExportXLSXFilteredDesired = true.ToString();
|
||||
break;
|
||||
case "xlsxunfiltered":
|
||||
ExportXLSXUnfilteredDesired = true.ToString();
|
||||
break;
|
||||
case "CSVADC":
|
||||
ExportCSVADCDesired = true.ToString();
|
||||
break;
|
||||
case "CSVMV":
|
||||
ExportCSVMVDesired = true.ToString();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string DASSerialNumber { get; set; }
|
||||
public string SetupName { get; set; }
|
||||
public string SetupDescription { get; set; }
|
||||
public string AutomaticMode { get; set; }
|
||||
public string AutomaticModeDelay { get; set; }
|
||||
public string WarnOnBatteryFail { get; set; }
|
||||
public string ViewRealtime { get; set; }
|
||||
public string RecordingMode { get; set; }
|
||||
public string SamplesPerSecond { get; set; }
|
||||
public string PreTriggerSeconds { get; set; }
|
||||
public string PostTriggerSeconds { get; set; }
|
||||
public string NumberOfEvents { get; set; }
|
||||
public string WakeUpMotionTimeout { get; set; }
|
||||
public string ScheduledStartDateTime { get; set; }
|
||||
public string IntervalBetweenEventStartsMinutes { get; set; }
|
||||
public string StartWithEvent { get; set; }
|
||||
public string WakeUpWithMotion { get; set; }
|
||||
public string StrictDiagnostics { get; set; }
|
||||
public string RequireConfirmationOnErrors { get; set; }
|
||||
public string AllowSensorIdToBlankChannel { get; set; }
|
||||
public string PerformArmChecklist { get; set; }
|
||||
public string CheckInputVoltage { get; set; }
|
||||
public string CheckBatteryVoltage { get; set; }
|
||||
public string CheckSquibResistance { get; set; }
|
||||
public string CheckSensorIds { get; set; }
|
||||
public string CheckStartEventLines { get; set; }
|
||||
public string CheckTiltSensor { get; set; }
|
||||
public string CheckTemperature { get; set; }
|
||||
public string ExcitationWarmupTimeMS { get; set; }
|
||||
public string RequireAllUnitsPassArmCheckList { get; set; }
|
||||
public string ROIDownload { get; set; }
|
||||
public string ViewROIDownload { get; set; }
|
||||
public string DownloadAll { get; set; }
|
||||
public string RealtimeCharts { get; set; }
|
||||
public string ROIStart { get; set; }
|
||||
public string ROIEnd { get; set; }
|
||||
public string ViewDownloadAll { get; set; }
|
||||
public string Export { get; set; }
|
||||
//public string ExportFormat { get; set; }
|
||||
public string ExportCh10FilteredEUDesired { get; set; }
|
||||
//public string ExportCh10UnfilteredEUDesired { get; set; }
|
||||
public string ExportChryslerDDASDesired { get; set; }
|
||||
public string ExportCSVADCDesired { get; set; }
|
||||
public string ExportCSVFilteredDesired { get; set; }
|
||||
public string ExportCSVMVDesired { get; set; }
|
||||
public string ExportCSVUnfilteredDesired { get; set; }
|
||||
public string ExportDiademADCDesired { get; set; }
|
||||
public string ExportASCDesired { get; set; }
|
||||
public string ExportHDFADCDesired { get; set; }
|
||||
//public string ExportHDFFilteredDesired { get; set; }
|
||||
public string ExportHDFMVDesired { get; set; }
|
||||
public string ExportHDFUnfilteredDesired { get; set; }
|
||||
public string ExportISOFilteredDesired { get; set; }
|
||||
public string ExportISOUnfilteredDesired { get; set; }
|
||||
public string ExportRDFADCDesired { get; set; }
|
||||
//public string ExportSomatFilteredDesired { get; set; }
|
||||
//public string ExportSomatUnfilteredDesired { get; set; }
|
||||
public string ExportTDASADCDesired { get; set; }
|
||||
public string ExportTDMSADCDesired { get; set; }
|
||||
//public string ExportToyotaFilteredDesired { get; set; }
|
||||
public string ExportToyotaUnfilteredDesired { get; set; }
|
||||
public string ExportTSVFilteredDesired { get; set; }
|
||||
public string ExportTSVUnfilteredDesired { get; set; }
|
||||
public string ExportXLSXFilteredDesired { get; set; }
|
||||
public string ExportXLSXUnfilteredDesired { get; set; }
|
||||
public string UseLabDetails { get; set; }
|
||||
public string UseCustomerDetails { get; set; }
|
||||
public string AllowMissingSensors { get; set; }
|
||||
public string LastModified { get; set; }
|
||||
public string LastModifiedBy { get; set; }
|
||||
public string PostTestDiagnostics { get; set; }
|
||||
public string UserTags { get; set; }
|
||||
public string CalibrationBehavior { get; set; }
|
||||
public string SuppressMissingSensorsWarning { get; set; }
|
||||
public string NotAllChannelsRealTime { get; set; }
|
||||
public string NotAllChannelsViewer { get; set; }
|
||||
public string TriggerCheckStep { get; set; }
|
||||
public string QuitTestWithoutWarning { get; set; }
|
||||
public string ExportFolder { get; set; }
|
||||
public string DownloadFolder { get; set; }
|
||||
public string CommonStatusLine { get; set; }
|
||||
public string UploadData { get; set; }
|
||||
public string UploadDataFolder { get; set; }
|
||||
public string UseTestEngineerDetails { get; set; }
|
||||
public string AutoArm { get; set; }
|
||||
public string Streaming { get; set; }
|
||||
public string MeasureSquibResistances { get; set; }
|
||||
public List<GroupXMLClass> Groups { get; set; }
|
||||
public List<LevelTriggerXMLClass> LevelTriggers { get; set; }
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using DTS.Common.Interface.DownloadEvent;
|
||||
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
[Serializable]
|
||||
public class DownloadEvent : IDownloadEvent
|
||||
{
|
||||
|
||||
public DownloadEvent()
|
||||
{
|
||||
EventNumber = 0;
|
||||
IsEnabled = true;
|
||||
IsDefault = true;
|
||||
IsReadonly = true;
|
||||
}
|
||||
|
||||
public DownloadEvent(bool isDefault = false)
|
||||
: this()
|
||||
{
|
||||
IsDefault = isDefault;
|
||||
}
|
||||
public DownloadEvent(int eventNumber = 0, bool isDefault = false)
|
||||
: this(isDefault)
|
||||
{
|
||||
EventNumber = eventNumber;
|
||||
}
|
||||
|
||||
private int _eventNumber = 0;
|
||||
public int EventNumber
|
||||
{
|
||||
get => _eventNumber;
|
||||
set
|
||||
{
|
||||
_eventNumber = value;
|
||||
OnPropertyChanged("EventNumber");
|
||||
EventNumberDisplay = $"{DTS.Common.Constants.EventNumber} {_eventNumber:00}";
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isEnabled = true;
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set { _isEnabled = value; OnPropertyChanged("IsEnabled"); }
|
||||
}
|
||||
|
||||
public bool IsDefault { get; }
|
||||
|
||||
private string _eventNumberDisplay = string.Empty;
|
||||
public string EventNumberDisplay
|
||||
{
|
||||
get => _eventNumberDisplay;
|
||||
set
|
||||
{
|
||||
_eventNumberDisplay = value;
|
||||
OnPropertyChanged("EventNumberDisplay");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 43387 Export multiple events: Used to store the <TestSetup>:<TestId>:("<All or ROI>") on a per event basis, for later use by export code
|
||||
/// </summary>
|
||||
private string _testItem = string.Empty;
|
||||
public string TestItem
|
||||
{
|
||||
get => _testItem;
|
||||
set
|
||||
{
|
||||
_testItem = value;
|
||||
OnPropertyChanged("TestItem");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 43387 Export multiple events: Used to store the .DTS file on a per event basis, for later use by export code
|
||||
/// </summary>
|
||||
private string _dtsFile = string.Empty;
|
||||
public string DTSFile
|
||||
{
|
||||
get => _dtsFile;
|
||||
set
|
||||
{
|
||||
_dtsFile = value;
|
||||
OnPropertyChanged("DTSFile");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isReadonly = true;
|
||||
public bool IsReadonly
|
||||
{
|
||||
get => _isReadonly;
|
||||
set { _isReadonly = value; OnPropertyChanged("IsReadonly"); }
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private TimeSpan _eventLength = new TimeSpan(0);
|
||||
/// <summary>
|
||||
/// total time available for download event
|
||||
/// </summary>
|
||||
public TimeSpan EventLength
|
||||
{
|
||||
get => _eventLength;
|
||||
set
|
||||
{
|
||||
_eventLength = value; OnPropertyChanged("EventLength");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _ShouldDisplayLength = false;
|
||||
/// <summary>
|
||||
/// whether EventLength should be displayed or not
|
||||
/// </summary>
|
||||
public bool ShouldDisplayLength
|
||||
{
|
||||
get => _ShouldDisplayLength;
|
||||
set
|
||||
{
|
||||
_ShouldDisplayLength = value;
|
||||
OnPropertyChanged("ShouldDisplayLength");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace DataPROWin7.DataModel
|
||||
{
|
||||
/// <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;
|
||||
}
|
||||
public HardwareInclusionInstruction(HardwareInclusionInstruction copy)
|
||||
{
|
||||
HardwareId = copy.HardwareId;
|
||||
Action = copy.Action;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using DTS.Common.Interface.DASFactory.Diagnostics;
|
||||
using DTS.SensorDB;
|
||||
|
||||
namespace DataPROWin7.DataModel.Classes.TestTemplate
|
||||
{
|
||||
public interface ICachedContainer
|
||||
{
|
||||
DASHardware GetCachedHardware(string serialNumber);
|
||||
SensorData GetCachedSensor(string serialNumber);
|
||||
SensorCalibration[] GetCalibrations(string serialNumber);
|
||||
IISOHardware[] GetAllCachedHardware();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using DTS.Slice.Users.UserSettings;
|
||||
|
||||
namespace DTS.Common.DataModel.Classes.TestTemplate
|
||||
{
|
||||
public class TSRAIRGoTestSetup : DataPROWin7.DataModel.TestTemplate
|
||||
{
|
||||
private static object MY_LOCK = new object();
|
||||
private static TSRAIRGoTestSetup _setup = null;
|
||||
|
||||
public const string TEST_NAME = "TSRAIR_GO_TEST";
|
||||
public override string Name
|
||||
{
|
||||
get => TEST_NAME;
|
||||
set {; }
|
||||
}
|
||||
protected TSRAIRGoTestSetup(DataPROWin7.DataModel.TestTemplate test) : base(test)
|
||||
{
|
||||
}
|
||||
protected TSRAIRGoTestSetup(TestSetupDefaults defaults) : base(defaults)
|
||||
{
|
||||
}
|
||||
public static TSRAIRGoTestSetup GetInstance(int userId, bool useCache = true)
|
||||
{
|
||||
lock (MY_LOCK)
|
||||
{
|
||||
if (null != _setup && useCache) { return _setup; }
|
||||
var template = DataPROWin7.DataModel.TestTemplateList.TestTemplatesList.GetTemplate(TEST_NAME, false);
|
||||
if (null != template)
|
||||
{
|
||||
_setup = new TSRAIRGoTestSetup(template);
|
||||
_setup.Load(true);
|
||||
return _setup;
|
||||
}
|
||||
var defaults = TestSetupDefaults.GetUserSettings(userId);
|
||||
_setup = new TSRAIRGoTestSetup(defaults);
|
||||
return _setup;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user