init
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public const string NON_ISO_TESTOBJECT_CHANNEL_TYPE = "x_NonISOTestObjectType_x";
|
||||
public const string NON_ISO_TESTOBJECT_NAME = "x_NonISOTestObjectName_x";
|
||||
}
|
||||
}
|
||||
127
DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/Enums.cs
Normal file
127
DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/Enums.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
|
||||
public enum RecordingModes
|
||||
{
|
||||
[Description("RecordingModes_CircularBuffer")]
|
||||
CircularBuffer,
|
||||
[Description("RecordingModes_Recorder")]
|
||||
Recorder,
|
||||
[Description("RecordingModes_HybridRecorder")]
|
||||
HybridRecorder
|
||||
}
|
||||
public enum IsoChannelSensorCompatibilityLevels
|
||||
{
|
||||
DontWarn,
|
||||
Warn,
|
||||
DontAllow
|
||||
}
|
||||
public enum TestTemplateTags
|
||||
{
|
||||
UploadData,
|
||||
UploadExportsOnly,
|
||||
UploadFolder,
|
||||
CommonLine,
|
||||
AllCustomers,
|
||||
AllTestEngineers,
|
||||
AllLabs,
|
||||
Test,
|
||||
AllowMissingSensors,
|
||||
AllowSensorIdToBlankChannel,
|
||||
AutomaticProgression,
|
||||
AutomaticProgressionDelayMS,
|
||||
InvertTriggerCompletion,
|
||||
TriggerCheckStep,
|
||||
PostTestDiagnostics,
|
||||
TriggerCheckRealtime,
|
||||
InvertStartRecordCompletion,
|
||||
ViewDiagnostics,
|
||||
VerifyChannels,
|
||||
AutoVerifyProgress,
|
||||
AutoVerifyDelaySeconds,
|
||||
TestGraphs,
|
||||
GraphCount,
|
||||
Name,
|
||||
TestId,
|
||||
SetupFile,
|
||||
Description,
|
||||
AvailableTestObjects,
|
||||
SamplesPerSecond,
|
||||
SampleRateText,
|
||||
PreTriggerSeconds,
|
||||
PostTriggerSeconds,
|
||||
RecordingMode,
|
||||
RecordingModeText,
|
||||
StrictDiagnostics,
|
||||
TestObjects,
|
||||
AllTestObjects,
|
||||
SysBuiltTestObjects,
|
||||
RequireUserConfirmationOnErrors,
|
||||
DoROIDownload,
|
||||
ROIButtonVisibility,
|
||||
ViewROIDownload,
|
||||
ViewROIDownloadButtonVisibility,
|
||||
DownloadAll,
|
||||
DownloadAllButtonVisibility,
|
||||
ViewRealtime,
|
||||
ViewRealtimeButtonVisibility,
|
||||
RegionsOfInterest,
|
||||
ROIStart,
|
||||
ROIEnd,
|
||||
ViewDownloadAll,
|
||||
ViewDownloadAllButtonVisibility,
|
||||
ViewExport,
|
||||
ViewExportButtonVisibility,
|
||||
ExportFormats,
|
||||
DownloadFolder,
|
||||
ExportFolder,
|
||||
SameAsDownloadFolder,
|
||||
TestTime,
|
||||
LabDetails,
|
||||
CustomerDetails,
|
||||
TestEngineerDetails,
|
||||
DefaultNumberRealtimeGraphs,
|
||||
GraphDetailsVisibility,
|
||||
CurrentGraph,
|
||||
UseCustomerDetails,
|
||||
UseTestEngineerDetails,
|
||||
TurnOffExcitation,
|
||||
UseLabratoryDetails,
|
||||
TestDirectory,
|
||||
OriginalTestDirectory,
|
||||
LocalOnly,
|
||||
LastModified,
|
||||
LastMmodifiedBy,
|
||||
ExpressTestSetup,
|
||||
EW,
|
||||
ExcitationWarmupTimeMS,
|
||||
ArmCheckListStep,
|
||||
CheckListBatteryVoltageCheck,
|
||||
CheckListInputVoltageCheck,
|
||||
CheckListSquibResistanceCheck,
|
||||
CheckListSensorIDCheck,
|
||||
CheckListTriggerStartCheck,
|
||||
CheckListMustPass,
|
||||
WarnOnFailedBattery,
|
||||
HardwareOverrides,
|
||||
DoAutoArm,
|
||||
SysBuiltTestObjectTypes,
|
||||
AddedGroupRemoved,
|
||||
CheckoutMode,
|
||||
QuitTestWithoutWarning,
|
||||
SuppressMissingSensorsWarning,
|
||||
ISFFile,
|
||||
TestObjectsAndAddedGroups,
|
||||
NotAllChannelsRealTime,
|
||||
NotAllChannelsViewer,
|
||||
GroupsStepValid
|
||||
}
|
||||
public enum StrictLevel
|
||||
{
|
||||
Strict,
|
||||
UpdateTable
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class DASHardware : DbTimeStampBase, IComparable<DASHardware>, IDASHardware
|
||||
{
|
||||
/// <summary>
|
||||
/// returns whether in the UI this device should be represented as a rack even though it isn't (SLICE6Db, ECM, SLE)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsPseudoRack()
|
||||
{
|
||||
switch (GetHardwareTypeEnum())
|
||||
{
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
case HardwareTypes.SLICE6DB: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public string ParentDAS
|
||||
{
|
||||
get => _hardware.ParentDAS;
|
||||
set => _hardware.ParentDAS = value;
|
||||
}
|
||||
|
||||
public int PositionOnDistributor
|
||||
{
|
||||
get => _hardware.PositionOnDistributor;
|
||||
set => _hardware.PositionOnDistributor = value;
|
||||
}
|
||||
public int CompareTo(DASHardware right)
|
||||
{
|
||||
if (null == right) { return 1; }
|
||||
if (this == right) { return 0; }
|
||||
if (SerialNumber == right.SerialNumber)
|
||||
{
|
||||
return 0;
|
||||
|
||||
}
|
||||
//ensure that children of a das are sorted behind their parents
|
||||
if (!string.IsNullOrWhiteSpace(ParentDAS) && right.SerialNumber == ParentDAS)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(right.ParentDAS) && right.ParentDAS == SerialNumber)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(right.ParentDAS) && right.ParentDAS == ParentDAS)
|
||||
{
|
||||
if (PositionOnDistributor != right.PositionOnDistributor)
|
||||
{
|
||||
return PositionOnDistributor.CompareTo(right.PositionOnDistributor);
|
||||
}
|
||||
}
|
||||
return string.Compare(SerialNumber, right.SerialNumber, StringComparison.Ordinal);
|
||||
}
|
||||
private List<HardwareChannel> _channels = new List<HardwareChannel>();
|
||||
public HardwareChannel[] Channels
|
||||
{
|
||||
get => _channels.ToArray();
|
||||
set
|
||||
{
|
||||
var channels = new List<HardwareChannel>(value);
|
||||
channels.Sort();
|
||||
_channels = channels;
|
||||
//OnPropertyChanged(Tags.ChannelCount.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _hardware.SerialNumber;
|
||||
set => _hardware.SerialNumber = value;
|
||||
}
|
||||
|
||||
public int GetHardwareTypeInt() { return _hardware.DASType; }
|
||||
public HardwareTypes GetHardwareTypeEnum() { return (HardwareTypes)GetHardwareTypeInt(); }
|
||||
public long GetMaxMemoryLong() { return _hardware.MaxMemory; }
|
||||
public DASHardware(DASHardware copy, DASHardware parentDAS)
|
||||
{
|
||||
if (null != copy.Channels)
|
||||
{
|
||||
Channels = copy.Channels.Select(ch => new HardwareChannel(ch)).ToArray();
|
||||
}
|
||||
|
||||
_hardware = new Hardware(copy.GetHardware());
|
||||
DbTimeStamp = copy.DbTimeStamp;
|
||||
}
|
||||
public string[] LinkedDASSerials { get; set; }
|
||||
private Hardware _hardware = new Hardware();
|
||||
public Hardware GetHardware() { return _hardware; }
|
||||
/// <summary>
|
||||
/// note that if you use this constructor, you should set
|
||||
/// TimeStampDb explicitly
|
||||
/// </summary>
|
||||
/// <param name="hardware"></param>
|
||||
public DASHardware(Hardware hardware)
|
||||
{
|
||||
_hardware = new Hardware(hardware);
|
||||
|
||||
Channels = hardware.ISOChannels.Select(channel => new HardwareChannel(channel, this)).ToArray();
|
||||
|
||||
}
|
||||
public bool IsDummy()
|
||||
{
|
||||
return SerialNumber.Contains("Dummy");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class DASHardwareList //: BasePropertyChanged
|
||||
{
|
||||
private static DASHardwareList _list;
|
||||
|
||||
public static DASHardwareList GetList()
|
||||
{
|
||||
if (null != _list) return _list;
|
||||
_list = new DASHardwareList();
|
||||
//_list.PopulateHardware();
|
||||
|
||||
return _list;
|
||||
}
|
||||
|
||||
public void ReloadAll()
|
||||
{
|
||||
//_list = new DASHardwareList();
|
||||
//_list.PopulateHardware();
|
||||
}
|
||||
private ICachedContainer _cachedHardware = null;
|
||||
|
||||
public DASHardware GetHardware(string id, bool bUseCache = true)
|
||||
{
|
||||
return GetHardware(id, true, out var bNotUsed, bUseCache);
|
||||
}
|
||||
|
||||
public DASHardware GetHardware(string id, bool bThrowExceptionIfChanged, out bool changed, bool bUseCache = true)
|
||||
{
|
||||
if (null != _cachedHardware && bUseCache)
|
||||
{
|
||||
var tokens = id.Split('_');
|
||||
var h = _cachedHardware.GetCachedHardware(tokens[0]);
|
||||
if (null != h)
|
||||
{
|
||||
changed = false;
|
||||
return h;
|
||||
}
|
||||
}
|
||||
var hardware = Hardware.GetAllDAS(id, null);
|
||||
changed = false;
|
||||
if (null != hardware && hardware.Any())
|
||||
{
|
||||
return new DASHardware(hardware[0]);
|
||||
}
|
||||
return null;
|
||||
/*if (_hardware.ContainsKey(id))
|
||||
{
|
||||
return _hardware[id];
|
||||
}
|
||||
var matchingSerial = from h in _hardware where h.Value.SerialNumber == id select h.Value;
|
||||
var dasHardwares = matchingSerial as DASHardware[] ?? matchingSerial.ToArray();
|
||||
if (dasHardwares.Any())
|
||||
{
|
||||
return dasHardwares.First();
|
||||
}
|
||||
//check to see if the type changed?
|
||||
var index = id.IndexOf('_');
|
||||
if (index >= 0)
|
||||
{
|
||||
id = id.Substring(0, index);
|
||||
}
|
||||
var match2 = from h in _hardware where h.Value.SerialNumber == id select h.Value;
|
||||
|
||||
if (match2.Any())
|
||||
{
|
||||
if (bThrowExceptionIfChanged)
|
||||
{
|
||||
throw new HardwareTypeChangedException();
|
||||
}
|
||||
changed = true;
|
||||
}return null;*/
|
||||
|
||||
}
|
||||
|
||||
public class HardwareTypeChangedException : Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
//using DTS.Common.Base;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a class for holding das specific settings in a test, for example sample rate or aaf
|
||||
/// it is serialized into tblTestSetupDASSettings
|
||||
/// </summary>
|
||||
public class DASSettings //: BasePropertyChanged
|
||||
{
|
||||
public string DASSerialNumber { get; set; }
|
||||
|
||||
public double SampleRate { get; set; }
|
||||
|
||||
public int ExcitationWarmupTimeMS { get; set; }
|
||||
|
||||
public double HardwareAAF { get; set; }
|
||||
|
||||
public double PreTriggerSeconds { get; set; }
|
||||
|
||||
public double PostTriggerSeconds { get; set; }
|
||||
|
||||
public bool StatusLineCheck { get; set; }
|
||||
|
||||
public bool BatteryCheck { get; set; }
|
||||
|
||||
public double InputVoltageMin { get; set; }
|
||||
|
||||
public double InputVoltageMax { get; set; }
|
||||
|
||||
public double BatteryVoltageMin { get; set; }
|
||||
|
||||
public double BatteryVoltageMax { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class HardwareChannel : /*BasePropertyChanged,*/ IComparable<HardwareChannel>, IHardwareChannel
|
||||
{
|
||||
private readonly ISO.HardwareChannel _isoChannel;
|
||||
public ISO.HardwareChannel GetISOChannel() { return _isoChannel; }
|
||||
|
||||
public int CompareTo(HardwareChannel right)
|
||||
{
|
||||
if (this == right) { return 0; }
|
||||
if (null == right) { return 0; }
|
||||
|
||||
var order = GetISOChannel().DASDisplayOrder.CompareTo(right.GetISOChannel().DASDisplayOrder);
|
||||
return 0 != order ? order : GetISOChannel().ChannelIdx.CompareTo(right.GetISOChannel().ChannelIdx);
|
||||
}
|
||||
public string GetId()
|
||||
{
|
||||
return $"{Hardware.GetHardware().GetId()}x{1 + ChannelNumber}";
|
||||
}
|
||||
|
||||
private TestObjectChannel _testObjectChannel;
|
||||
public HardwareChannel(HardwareChannel copy)
|
||||
{
|
||||
ChannelNumber = copy.ChannelNumber;
|
||||
if (null != copy.Sensor) { Sensor = new SensorData(copy.Sensor); }
|
||||
_testObjectChannel = copy._testObjectChannel;
|
||||
Hardware = copy.Hardware;
|
||||
_isoChannel = copy._isoChannel;
|
||||
}
|
||||
public HardwareChannel(ISO.HardwareChannel channel, DASHardware hardware)
|
||||
{
|
||||
ChannelNumber = channel.ChannelIdx;
|
||||
Hardware = hardware;
|
||||
_isoChannel = channel;
|
||||
}
|
||||
public DASHardware Hardware { get; }
|
||||
public int ChannelNumber { get; } = 0;
|
||||
public SensorData Sensor { get; set; } = null;
|
||||
|
||||
public bool IsSupportedBridgeType(Test.Module.Channel.Sensor.BridgeType bridgeType)
|
||||
{
|
||||
return (GetISOChannel().SupportedBridges & (int)bridgeType) == (int)bridgeType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,683 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class Region //: BasePropertyChanged
|
||||
{
|
||||
private TestObjectTemplate _template;
|
||||
public TestObjectTemplate Template
|
||||
{
|
||||
get => _template;
|
||||
set
|
||||
{
|
||||
//if (null != _template && _template != value) { _template.PropertyChanged -= Template_PropertyChanged; }
|
||||
_template = value;
|
||||
//Template.PropertyChanged += Template_PropertyChanged;
|
||||
DetermineAvailableISOSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void Template_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (Enum.TryParse(e.PropertyName, out TestObjectTemplate.Tags tag))
|
||||
{
|
||||
switch (tag)
|
||||
{
|
||||
case TestObjectTemplate.Tags.TemplateAllChannels:
|
||||
RegionChannels = Template.TemplateAllChannels;
|
||||
RegionUIChannels = Template.TemplateAllUIChannels;
|
||||
DetermineAvailableISOSettings();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case "TestObjectType":
|
||||
RegionChannels = Template.TemplateAllChannels;
|
||||
RegionUIChannels = Template.TemplateAllUIChannels;
|
||||
DetermineAvailableISOSettings();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InvalidateVisual()
|
||||
{
|
||||
_adorner?.InvalidateVisual();
|
||||
}
|
||||
private string _name;
|
||||
public string RegionName
|
||||
{
|
||||
get => _name;
|
||||
set { _name = value; InvalidateVisual(); }
|
||||
}
|
||||
|
||||
private string _regionDescription;
|
||||
public string RegionDescription
|
||||
{
|
||||
get => _regionDescription;
|
||||
set { _regionDescription = value; InvalidateVisual(); }
|
||||
}
|
||||
|
||||
private Point _upperLeft;
|
||||
public Point RegionUpperLeft
|
||||
{
|
||||
get => _upperLeft;
|
||||
set => _upperLeft = value;
|
||||
}
|
||||
|
||||
private Point _bottomRight;
|
||||
public Point RegionBottomRight
|
||||
{
|
||||
get => _bottomRight;
|
||||
set => _bottomRight = value;
|
||||
}
|
||||
|
||||
private MMEDirections _direction;
|
||||
public MMEDirections RegionDirection
|
||||
{
|
||||
get => _direction;
|
||||
set
|
||||
{
|
||||
_direction = value;
|
||||
if (null != value)
|
||||
{
|
||||
_directionIndex = _allDirections.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_directionIndex = -1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMEFilterClasses _filterClass;
|
||||
public MMEFilterClasses RegionFilterClass
|
||||
{
|
||||
get => _filterClass;
|
||||
set
|
||||
{
|
||||
_filterClass = value;
|
||||
if (null != value)
|
||||
{
|
||||
_filterClassIndex = _filterClasses.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_filterClassIndex = -1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
private MMEFineLocations1 _fineLocation1;
|
||||
public MMEFineLocations1 RegionFineLocation1
|
||||
{
|
||||
get => _fineLocation1;
|
||||
set
|
||||
{
|
||||
_fineLocation1 = value;
|
||||
if (null != value)
|
||||
{
|
||||
_fineLocation1Index = _fineLocations1.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fineLocation1Index = -1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMEFineLocations2 _fineLocation2;
|
||||
public MMEFineLocations2 RegionFineLocation2
|
||||
{
|
||||
get => _fineLocation2;
|
||||
set
|
||||
{
|
||||
_fineLocation2 = value;
|
||||
if (null != value)
|
||||
{
|
||||
_fineLocation2Index = _fineLocations2.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fineLocation2Index = -1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMEFineLocations3 _fineLocation3;
|
||||
public MMEFineLocations3 RegionFineLocation3
|
||||
{
|
||||
get => _fineLocation3;
|
||||
set
|
||||
{
|
||||
_fineLocation3 = value;
|
||||
if (null != value)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMETransducerMainLocation _mainLocation;
|
||||
public MMETransducerMainLocation RegionMainLocation
|
||||
{
|
||||
get => _mainLocation;
|
||||
set
|
||||
{
|
||||
if (_mainLocation != value)
|
||||
{
|
||||
_mainLocation = value;
|
||||
if (null != value)
|
||||
{
|
||||
_mainLocationIndex = _mainLocations.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mainLocationIndex = _mainLocations.Count - 1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void FilterRegionChannels()
|
||||
{
|
||||
_regionChannels = new List<TestObjectTemplateChannel>(Template.TemplateAllChannels);
|
||||
_regionUIChannels = new List<TemplateChannelUI>(Template.TemplateAllUIChannels);
|
||||
for (var i = _regionChannels.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var channel = _regionChannels[i];
|
||||
var mmeChannel = channel.Channel;
|
||||
|
||||
if (RegionMainLocation != null && RegionMainLocation.Trans_Main_Loc != mmeChannel.Trans_Main_Loc)
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionDirection != null && RegionDirection.Direction != mmeChannel.Direction && RegionDirection.Direction != "?")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionFilterClass != null && RegionFilterClass.Filter_Class != mmeChannel.Default_Filter_Class && RegionFilterClass.Filter_Class != "?")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionFineLocation1 != null && RegionFineLocation1.Fine_Loc_1 != mmeChannel.Fine_Loc_1 && RegionFineLocation1.Fine_Loc_1 != "??")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionFineLocation2 != null && RegionFineLocation2.FINE_LOC_2 != mmeChannel.Fine_Loc_2 && RegionFineLocation2.FINE_LOC_2 != "??")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionFineLocation3 != null && RegionFineLocation3.FINE_LOC_3 != mmeChannel.Fine_Loc_3 && RegionFineLocation3.FINE_LOC_3 != "??")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionPhysicalDimension != null && RegionPhysicalDimension.Physical_Dimension != mmeChannel.Physical_Dimension && RegionPhysicalDimension.Physical_Dimension != "??")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegionPosition != null && RegionPosition.Position != mmeChannel.Position && RegionPosition.Position != "?")
|
||||
{
|
||||
_regionChannels.RemoveAt(i);
|
||||
_regionUIChannels.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
RegionChannels = _regionChannels.ToArray();
|
||||
RegionUIChannels = _regionUIChannels.ToArray();
|
||||
SetISOCode();
|
||||
}
|
||||
private MMEPhysicalDimensions _physicalDimension;
|
||||
public MMEPhysicalDimensions RegionPhysicalDimension
|
||||
{
|
||||
get => _physicalDimension;
|
||||
set
|
||||
{
|
||||
_physicalDimension = value;
|
||||
if (null != value)
|
||||
{
|
||||
_physicalDimensionIndex = _physicalDimensions.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_physicalDimensionIndex = -1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMEPositions _position;
|
||||
public MMEPositions RegionPosition
|
||||
{
|
||||
get => _position;
|
||||
set
|
||||
{
|
||||
_position = value;
|
||||
if (null != value)
|
||||
{
|
||||
_positionIndex = _positions.IndexOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_positionIndex = -1;
|
||||
}
|
||||
SetISOCode();
|
||||
}
|
||||
}
|
||||
|
||||
private MMETestObjects _testObject;
|
||||
public MMETestObjects RegionTestObject
|
||||
{
|
||||
get => _testObject;
|
||||
set => _testObject = value;
|
||||
}
|
||||
|
||||
|
||||
private RegionAdorner _adorner;
|
||||
|
||||
public Region(RegionAdorner adorner, TestObjectTemplate template)
|
||||
{
|
||||
_adorner = adorner;
|
||||
RegionName = "New region";
|
||||
RegionDescription = "Describe region";
|
||||
Template = template;
|
||||
RegionTestObject = template.TestObject;
|
||||
RegionChannels = template.TemplateAllChannels;
|
||||
RegionUIChannels = template.TemplateAllUIChannels;
|
||||
DetermineAvailableISOSettings();
|
||||
}
|
||||
|
||||
public Region(TestObjectTemplate template, TemplateRegion r)
|
||||
{
|
||||
RegionName = r.RegionName;
|
||||
RegionDescription = r.RegionDescription;
|
||||
Template = template;
|
||||
RegionChannels = template.TemplateAllChannels;
|
||||
RegionUIChannels = template.TemplateAllUIChannels;
|
||||
RegionTestObject = ((App)Application.Current).IsoDb.GetTestObjectByIso(r.TestObject);
|
||||
RegionBottomRight = new Point(r.LowerRight.X, r.LowerRight.Y);
|
||||
RegionUpperLeft = new Point(r.UpperLeft.X, r.UpperLeft.Y);
|
||||
RegionDirection = ((App)Application.Current).IsoDb.GetDirectionByIso(r.Direction);
|
||||
RegionFilterClass = ((App)Application.Current).IsoDb.GetFilterClassByIso(r.FilterClass);
|
||||
RegionFineLocation1 = ((App)Application.Current).IsoDb.GetFineLocation1ByIso(r.FineLocation1);
|
||||
RegionFineLocation2 = ((App)Application.Current).IsoDb.GetFineLocation2ByIso(r.FineLocation2);
|
||||
RegionFineLocation3 = ((App)Application.Current).IsoDb.GetFineLocation3ByIso(r.FineLocation3);
|
||||
RegionMainLocation = ((App)Application.Current).IsoDb.GetMainLocationByIso(r.MainLocation);
|
||||
RegionPhysicalDimension = ((App)Application.Current).IsoDb.GetPhysicalDimensionByIso(r.PhysicalDimension);
|
||||
RegionPosition = ((App)Application.Current).IsoDb.GetPosition(r.Position);
|
||||
FilterRegionChannels();
|
||||
SetISOCode();
|
||||
}
|
||||
|
||||
private Visibility _regionAddVisibility = Visibility.Visible;
|
||||
public Visibility RegionAddVisibility
|
||||
{
|
||||
get => _regionAddVisibility;
|
||||
set => _regionAddVisibility = value;
|
||||
}
|
||||
private Visibility _regionDeleteVisibility = Visibility.Hidden;
|
||||
public Visibility RegionDeleteVisibility
|
||||
{
|
||||
get => _regionDeleteVisibility;
|
||||
set => _regionDeleteVisibility = value;
|
||||
}
|
||||
|
||||
private List<MMEDirections> _allDirections = new List<MMEDirections>();
|
||||
public MMEDirections[] AllDirections
|
||||
{
|
||||
get => _allDirections.ToArray();
|
||||
set
|
||||
{
|
||||
_allDirections = new List<MMEDirections>(value);
|
||||
AllDirectionsStrings = _allDirections.Select(dir => null == dir ? "?" : dir.Text_L1).ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allDirectionsStrings = new List<string>();
|
||||
public string[] AllDirectionsStrings
|
||||
{
|
||||
get => _allDirectionsStrings.ToArray();
|
||||
set => _allDirectionsStrings = new List<string>(value);
|
||||
}
|
||||
private int _directionIndex = -1;
|
||||
|
||||
private List<MMEFilterClasses> _filterClasses = new List<MMEFilterClasses>();
|
||||
public MMEFilterClasses[] AllFilterClasses
|
||||
{
|
||||
get => _filterClasses.ToArray();
|
||||
set
|
||||
{
|
||||
_filterClasses = new List<MMEFilterClasses>(value);
|
||||
var filterclasses = new List<string>();
|
||||
foreach (var fc in _filterClasses) { filterclasses.Add(fc.Text_L1); }
|
||||
AllFilterClassStrings = filterclasses.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allFilterClassStrings = new List<string>();
|
||||
public string[] AllFilterClassStrings
|
||||
{
|
||||
get => _allFilterClassStrings.ToArray();
|
||||
set => _allFilterClassStrings = new List<string>(value);
|
||||
}
|
||||
public int _filterClassIndex = -1;
|
||||
|
||||
private List<MMEFineLocations1> _fineLocations1 = new List<MMEFineLocations1>();
|
||||
public MMEFineLocations1[] AllFineLocations1
|
||||
{
|
||||
get => _fineLocations1.ToArray();
|
||||
set
|
||||
{
|
||||
_fineLocations1 = new List<MMEFineLocations1>(value);
|
||||
var fineLocations1 = new List<string>();
|
||||
foreach (var loc in _fineLocations1)
|
||||
{
|
||||
if (null == loc) { fineLocations1.Add("??"); }
|
||||
else { fineLocations1.Add(loc.Text_L1); }
|
||||
}
|
||||
AllFineLocations1Strings = fineLocations1.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allFineLocations1Strings = new List<string>();
|
||||
public string[] AllFineLocations1Strings
|
||||
{
|
||||
get => _allFineLocations1Strings.ToArray();
|
||||
set => _allFineLocations1Strings = new List<string>(value);
|
||||
}
|
||||
private int _fineLocation1Index = -1;
|
||||
|
||||
private List<MMEFineLocations2> _fineLocations2 = new List<MMEFineLocations2>();
|
||||
public MMEFineLocations2[] AllFineLocations2
|
||||
{
|
||||
get => _fineLocations2.ToArray();
|
||||
set
|
||||
{
|
||||
_fineLocations2 = new List<MMEFineLocations2>(value);
|
||||
var locations = new List<string>();
|
||||
foreach (var loc in _fineLocations2) { locations.Add(loc.Text_L1); }
|
||||
AllFineLocations2Strings = locations.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allFineLocations2Strings = new List<string>();
|
||||
public string[] AllFineLocations2Strings
|
||||
{
|
||||
get => _allFineLocations2Strings.ToArray();
|
||||
set => _allFineLocations2Strings = new List<string>(value);
|
||||
}
|
||||
private int _fineLocation2Index = -1;
|
||||
public int FineLocation2Index
|
||||
{
|
||||
get => _fineLocation2Index;
|
||||
set
|
||||
{
|
||||
if (value == _fineLocation2Index) { return; }
|
||||
if (value < 0) { RegionFineLocation2 = null; }
|
||||
else { RegionFineLocation2 = _fineLocations2[value]; }
|
||||
FilterRegionChannels();
|
||||
}
|
||||
}
|
||||
|
||||
private List<MMEFineLocations3> _fineLocations3 = new List<MMEFineLocations3>();
|
||||
public MMEFineLocations3[] AllFineLocations3
|
||||
{
|
||||
get => _fineLocations3.ToArray();
|
||||
set
|
||||
{
|
||||
_fineLocations3 = new List<MMEFineLocations3>(value);
|
||||
var locations = new List<string>();
|
||||
foreach (var l in _fineLocations3) { locations.Add(l.Text_L1); }
|
||||
AllFineLocations3Strings = locations.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allFineLocations3Strings = new List<string>();
|
||||
public string[] AllFineLocations3Strings
|
||||
{
|
||||
get => _allFineLocations3Strings.ToArray();
|
||||
set => _allFineLocations3Strings = new List<string>(value);
|
||||
}
|
||||
|
||||
private List<MMETransducerMainLocation> _mainLocations = new List<MMETransducerMainLocation>();
|
||||
public MMETransducerMainLocation[] AllMainLocations
|
||||
{
|
||||
get => _mainLocations.ToArray();
|
||||
set
|
||||
{
|
||||
_mainLocations = new List<MMETransducerMainLocation>(value);
|
||||
AllMainLocationsStrings = _mainLocations.Select(loc => null == loc ? "????" : loc.Text_L1).ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allMainLocationsStrings = new List<string>();
|
||||
public string[] AllMainLocationsStrings
|
||||
{
|
||||
get => _allMainLocationsStrings.ToArray();
|
||||
set => _allMainLocationsStrings = new List<string>(value);
|
||||
}
|
||||
private int _mainLocationIndex = -1;
|
||||
private List<MMEPhysicalDimensions> _physicalDimensions = new List<MMEPhysicalDimensions>();
|
||||
public MMEPhysicalDimensions[] AllPhysicalDimensions
|
||||
{
|
||||
get => _physicalDimensions.ToArray();
|
||||
set
|
||||
{
|
||||
_physicalDimensions = new List<MMEPhysicalDimensions>(value);
|
||||
var dimensions = new List<string>();
|
||||
foreach (var dim in _physicalDimensions)
|
||||
{
|
||||
dimensions.Add(null == dim ? "??" : dim.Text_L1);
|
||||
}
|
||||
AllPhysicalDimensionStrings = dimensions.ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allPhysicalDimensionStrings = new List<string>();
|
||||
public string[] AllPhysicalDimensionStrings
|
||||
{
|
||||
get => _allPhysicalDimensionStrings.ToArray();
|
||||
set => _allPhysicalDimensionStrings = new List<string>(value);
|
||||
}
|
||||
private int _physicalDimensionIndex = -1;
|
||||
|
||||
private List<MMEPositions> _positions = new List<MMEPositions>();
|
||||
public MMEPositions[] AllPositions
|
||||
{
|
||||
get => _positions.ToArray();
|
||||
set
|
||||
{
|
||||
_positions = new List<MMEPositions>(value);
|
||||
AllPositionStrings = _positions.Select(pos => pos.Text_L1).ToArray();
|
||||
}
|
||||
}
|
||||
private List<string> _allPositionsStrings = new List<string>();
|
||||
public string[] AllPositionStrings
|
||||
{
|
||||
get => _allPositionsStrings.ToArray();
|
||||
set => _allPositionsStrings = new List<string>(value);
|
||||
}
|
||||
private int _positionIndex = -1;
|
||||
private string _isoCode = "????????????????";
|
||||
public string ISOCode
|
||||
{
|
||||
get => _isoCode;
|
||||
set => _isoCode = value;
|
||||
}
|
||||
private void SetISOCode()
|
||||
{
|
||||
var testObject = "?";
|
||||
if (null != RegionTestObject) { testObject = RegionTestObject.Test_Object; }
|
||||
var position = "?";
|
||||
if (null != RegionPosition) { position = RegionPosition.Position; }
|
||||
var main = "????";
|
||||
if (null != RegionMainLocation) { main = RegionMainLocation.Trans_Main_Loc; }
|
||||
var floc1 = "??";
|
||||
if (null != RegionFineLocation1) { floc1 = RegionFineLocation1.Fine_Loc_1; }
|
||||
var floc2 = "??";
|
||||
if (null != RegionFineLocation2) { floc2 = RegionFineLocation2.FINE_LOC_2; }
|
||||
var floc3 = "??";
|
||||
if (null != RegionFineLocation3) { floc3 = RegionFineLocation3.FINE_LOC_3; }
|
||||
var physdim = "??";
|
||||
if (null != RegionPhysicalDimension) { physdim = RegionPhysicalDimension.Physical_Dimension; }
|
||||
var dir = "?";
|
||||
if (null != RegionDirection) { dir = RegionDirection.Direction; }
|
||||
var fc = "?";
|
||||
if (null != RegionFilterClass) { fc = RegionFilterClass.Filter_Class; }
|
||||
ISOCode = ISO.IsoCode.GetString(testObject, position, main, floc1, floc2, floc3, physdim, dir, fc);
|
||||
}
|
||||
private List<TestObjectTemplateChannel> _regionChannels = new List<TestObjectTemplateChannel>();
|
||||
public TestObjectTemplateChannel[] RegionChannels
|
||||
{
|
||||
get => _regionChannels.ToArray();
|
||||
set
|
||||
{
|
||||
_regionChannels = new List<TestObjectTemplateChannel>(value);
|
||||
DetermineAvailableISOSettings();
|
||||
}
|
||||
}
|
||||
private void DetermineAvailableISOSettings()
|
||||
{
|
||||
var regionChannels = RegionChannels;
|
||||
var templateChannels = Template.TemplateAllChannels;
|
||||
|
||||
var testObjects = (from pc in regionChannels.AsParallel() select pc.Channel.Test_Object).Distinct().ToArray();
|
||||
if (testObjects.Length < 1) { return; }
|
||||
RegionTestObject = ((App)Application.Current).IsoDb.GetTestObjectByIso(testObjects[0]);
|
||||
|
||||
|
||||
var dirs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Direction).Distinct().ToArray());
|
||||
dirs.Sort();
|
||||
var directions = dirs.Select(dir => ((App)Application.Current).IsoDb.GetDirectionByIso(dir)).ToList();
|
||||
var d = ((App)Application.Current).IsoDb.GetDirectionByIso("?");
|
||||
if (!directions.Contains(d)) { directions.Add(d); }
|
||||
AllDirections = directions.ToArray();
|
||||
dirs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Direction).Distinct().ToArray());
|
||||
if (dirs.Count == 1) { RegionDirection = ((App)Application.Current).IsoDb.GetDirectionByIso(dirs[0]); }
|
||||
else if (dirs.Count == 0) { RegionDirection = null; }
|
||||
|
||||
var fcs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Default_Filter_Class).Distinct().ToArray());
|
||||
fcs.Sort();
|
||||
var filterclasses = fcs.Select(fc => ((App)Application.Current).IsoDb.GetFilterClassByIso(fc)).ToList();
|
||||
var fc2 = ((App)Application.Current).IsoDb.GetFilterClassByIso("?");
|
||||
if (!filterclasses.Contains(fc2)) { filterclasses.Add(fc2); }
|
||||
AllFilterClasses = filterclasses.ToArray();
|
||||
fcs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Default_Filter_Class).Distinct().ToArray());
|
||||
if (1 == fcs.Count) { RegionFilterClass = ((App)Application.Current).IsoDb.GetFilterClassByIso(fcs[0]); }
|
||||
else if (0 == fcs.Count) { RegionFilterClass = null; }
|
||||
|
||||
var locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Fine_Loc_1).Distinct().ToArray());
|
||||
locs.Sort();
|
||||
var finelocations1 = new List<MMEFineLocations1>();
|
||||
foreach (var loc in locs) { finelocations1.Add(((App)Application.Current).IsoDb.GetFineLocation1ByIso(loc)); }
|
||||
var f = ((App)Application.Current).IsoDb.GetFineLocation1ByIso("??");
|
||||
if (!finelocations1.Contains(f)) { finelocations1.Add(f); }
|
||||
AllFineLocations1 = finelocations1.ToArray();
|
||||
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Fine_Loc_1).Distinct().ToArray());
|
||||
if (1 == locs.Count) { RegionFineLocation1 = ((App)Application.Current).IsoDb.GetFineLocation1ByIso(locs[0]); }
|
||||
else if (0 == locs.Count) { RegionFineLocation1 = null; }
|
||||
|
||||
locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Fine_Loc_2).Distinct().ToArray());
|
||||
locs.Sort();
|
||||
var finelocations2 = locs.Select(loc => ((App)Application.Current).IsoDb.GetFineLocation2ByIso(loc)).ToList();
|
||||
AllFineLocations2 = finelocations2.ToArray();
|
||||
var f2 = ((App)Application.Current).IsoDb.GetFineLocation2ByIso("??");
|
||||
if (!finelocations2.Contains(f2)) { finelocations2.Add(f2); }
|
||||
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Fine_Loc_2).Distinct().ToArray());
|
||||
if (1 == locs.Count) { RegionFineLocation2 = ((App)Application.Current).IsoDb.GetFineLocation2ByIso(locs[0]); }
|
||||
else if (0 == locs.Count) { RegionFineLocation2 = null; }
|
||||
|
||||
|
||||
locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Fine_Loc_3).Distinct().ToArray());
|
||||
locs.Sort();
|
||||
var finelocations3 = locs.Select(loc => ((App)Application.Current).IsoDb.GetFineLocation3ByIso(loc)).ToList();
|
||||
var f3 = ((App)Application.Current).IsoDb.GetFineLocation3ByIso("??");
|
||||
if (!finelocations3.Contains(f3)) { finelocations3.Add(f3); }
|
||||
AllFineLocations3 = finelocations3.ToArray();
|
||||
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Fine_Loc_3).Distinct().ToArray());
|
||||
if (1 == locs.Count) { RegionFineLocation3 = ((App)Application.Current).IsoDb.GetFineLocation3ByIso(locs[0]); }
|
||||
else if (0 == locs.Count) { RegionFineLocation3 = null; }
|
||||
|
||||
locs = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Trans_Main_Loc).Distinct().ToArray());
|
||||
locs.Sort();
|
||||
var mains = locs.Select(loc => ((App)Application.Current).IsoDb.GetMainLocationByIso(loc)).ToList();
|
||||
var m = ((App)Application.Current).IsoDb.GetMainLocationByIso("????");
|
||||
if (!mains.Contains(m)) { mains.Add(m); }
|
||||
AllMainLocations = mains.ToArray();
|
||||
locs = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Trans_Main_Loc).Distinct().ToArray());
|
||||
if (1 == locs.Count) { RegionMainLocation = ((App)Application.Current).IsoDb.GetMainLocationByIso(locs[0]); }
|
||||
else if (0 == locs.Count) { RegionMainLocation = null; }
|
||||
|
||||
var dims = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Physical_Dimension).Distinct().ToArray());
|
||||
dims.Sort();
|
||||
var dimensions = dims.Select(dim => ((App)Application.Current).IsoDb.GetPhysicalDimensionByIso(dim)).ToList();
|
||||
var pd = ((App)Application.Current).IsoDb.GetPhysicalDimensionByIso("??");
|
||||
if (!dimensions.Contains(pd)) { dimensions.Add(pd); }
|
||||
AllPhysicalDimensions = dimensions.ToArray();
|
||||
dims = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Physical_Dimension).Distinct().ToArray());
|
||||
if (1 == dims.Count) { RegionPhysicalDimension = ((App)Application.Current).IsoDb.GetPhysicalDimensionByIso(dims[0]); }
|
||||
else if (0 == dims.Count) { RegionPhysicalDimension = null; }
|
||||
|
||||
var poss = new List<string>((from pc in templateChannels.AsParallel() select pc.Channel.Position).Distinct().ToArray());
|
||||
poss.Sort();
|
||||
var positions = poss.Select(pos => (Application.Current as App).IsoDb.GetPositionByISO(pos)).ToList();
|
||||
AllPositions = positions.ToArray();
|
||||
poss = new List<string>((from pc in regionChannels.AsParallel() select pc.Channel.Position).Distinct().ToArray());
|
||||
if (1 == poss.Count) { RegionPosition = positions[0]; }
|
||||
else if (0 == poss.Count) { RegionPosition = null; }
|
||||
}
|
||||
|
||||
public TemplateRegion ToISORegion(TestObjectTemplate template, Zone zone, int number)
|
||||
{
|
||||
var region = new TemplateRegion(template.TemplateName, zone.Name, template.IsLocalOnly);
|
||||
region.Direction = null == RegionDirection ? "?" : RegionDirection.Direction;
|
||||
region.FilterClass = null == RegionFilterClass ? "?" : RegionFilterClass.Filter_Class;
|
||||
region.FineLocation1 = null == RegionFineLocation1 ? "??" : RegionFineLocation1.Fine_Loc_1;
|
||||
region.FineLocation2 = null == RegionFineLocation2 ? "??" : RegionFineLocation2.FINE_LOC_2;
|
||||
region.FineLocation3 = null == RegionFineLocation3 ? "??" : RegionFineLocation3.FINE_LOC_3;
|
||||
region.LowerRight = new System.Drawing.Point(Convert.ToInt32(RegionBottomRight.X), Convert.ToInt32(RegionBottomRight.Y));
|
||||
region.MainLocation = null == RegionMainLocation ? "????" : RegionMainLocation.Trans_Main_Loc;
|
||||
region.PhysicalDimension = null == RegionPhysicalDimension ? "??" : RegionPhysicalDimension.Physical_Dimension;
|
||||
region.Position = null == RegionPosition ? "?" : RegionPosition.Position;
|
||||
region.RegionDescription = RegionDescription;
|
||||
region.RegionName = RegionName;
|
||||
region.RegionNumber = number;
|
||||
region.TestObject = null == RegionTestObject ? "?" : RegionTestObject.Test_Object;
|
||||
region.UpperLeft = new System.Drawing.Point(Convert.ToInt32(RegionUpperLeft.X), Convert.ToInt32(RegionUpperLeft.Y));
|
||||
return region;
|
||||
}
|
||||
|
||||
private List<TemplateChannelUI> _regionUIChannels = new List<TemplateChannelUI>();
|
||||
public TemplateChannelUI[] RegionUIChannels
|
||||
{
|
||||
get => _regionUIChannels.ToArray();
|
||||
set => _regionUIChannels = new List<TemplateChannelUI>(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class RegionAdorner : Adorner, INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected bool SetProperty<T>(ref T storage, T value, string propertyName = null)
|
||||
{
|
||||
if (Equals(storage, value)) return false;
|
||||
|
||||
storage = value;
|
||||
OnPropertyChanged(propertyName);
|
||||
return true;
|
||||
}
|
||||
protected void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
public Point GetUpperLeft()
|
||||
{
|
||||
var p = SelectRect.TopLeft;
|
||||
|
||||
var image = AdornedElement as Image;
|
||||
if (null == image) { return p; }
|
||||
|
||||
var s = new Size(image.Source.Width, image.Source.Height);
|
||||
var difX = s.Width - _MeasuredSize.Width;
|
||||
var difY = s.Height - _MeasuredSize.Height;
|
||||
var scaleX = difX / _MeasuredSize.Width;
|
||||
var scaleY = difY / _MeasuredSize.Height;
|
||||
p = new Point(p.X + p.X * scaleX, p.Y + p.Y * scaleY);
|
||||
|
||||
return p;
|
||||
}
|
||||
public Point GetLowerRight()
|
||||
{
|
||||
var p = SelectRect.BottomRight;
|
||||
|
||||
if (!(AdornedElement is Image image)) { return p; }
|
||||
if (null == image.Source) { return new Point(0, 0); }
|
||||
var s = new Size(image.Source.Width, image.Source.Height);
|
||||
var difX = (s.Width - _MeasuredSize.Width);
|
||||
var difY = s.Height - _MeasuredSize.Height;
|
||||
var scaleX = difX / _MeasuredSize.Width;
|
||||
var scaleY = difY / _MeasuredSize.Height;
|
||||
|
||||
p = new Point(p.X + p.X * scaleX, p.Y + p.Y * scaleY);
|
||||
return p;
|
||||
}
|
||||
public delegate void RegionSelectedHandler(RegionAdorner r, MouseButtonEventArgs e);
|
||||
public event RegionSelectedHandler OnRegionSelected;
|
||||
|
||||
private bool _bNew = true;
|
||||
public bool IsNew
|
||||
{
|
||||
get => _bNew;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _bNew, value, "IsNew");
|
||||
if (_bNew)
|
||||
{
|
||||
MyRegion.RegionAddVisibility = Visibility.Visible;
|
||||
MyRegion.RegionDeleteVisibility = Visibility.Hidden;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyRegion.RegionDeleteVisibility = Visibility.Visible;
|
||||
MyRegion.RegionAddVisibility = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Point _anchorPoint;
|
||||
public Point AnchorPoint
|
||||
{
|
||||
get => _anchorPoint;
|
||||
set => SetProperty(ref _anchorPoint, value, "AnchorPoint");
|
||||
}
|
||||
private readonly UIElement _adornedElement;
|
||||
private readonly Path _path;
|
||||
private Rect _selectRect;
|
||||
public Rect SelectRect
|
||||
{
|
||||
get => _selectRect;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _selectRect, value, "SelectRect");
|
||||
MyRegion.RegionUpperLeft = GetUpperLeft();
|
||||
MyRegion.RegionBottomRight = GetLowerRight();
|
||||
}
|
||||
}
|
||||
private readonly RectangleGeometry _geometry;
|
||||
|
||||
private Region _region;
|
||||
public Region MyRegion
|
||||
{
|
||||
get => _region;
|
||||
set => SetProperty(ref _region, value, "MyRegion");
|
||||
}
|
||||
public RegionAdorner(UIElement adornedElement, TestObjectTemplate template, Contexts context)
|
||||
: base(adornedElement)
|
||||
{
|
||||
_region = new Region(this, template);
|
||||
_adornedElement = adornedElement;
|
||||
SelectRect = new Rect();
|
||||
_geometry = new RectangleGeometry();
|
||||
_path = new Path();
|
||||
_path.Data = _geometry;
|
||||
_path.StrokeThickness = 5;
|
||||
_path.Stroke = Brushes.AliceBlue;
|
||||
_path.Opacity = .6;
|
||||
_path.Visibility = Visibility.Hidden;
|
||||
MouseLeftButtonUp += Region_MouseLeftButtonUp;
|
||||
MouseMove += Region_MouseMove;
|
||||
MouseLeftButtonDown += Region_MouseLeftButtonDown;
|
||||
_MeasuredSize = adornedElement.RenderSize;
|
||||
//_region.PropertyChanged += _region_PropertyChanged;
|
||||
Context = context;
|
||||
}
|
||||
private void Region_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
EndSelection(sender, e);
|
||||
}
|
||||
|
||||
public enum Contexts { EditTestObject, EditTestObjectTemplate };
|
||||
private Contexts _context;
|
||||
public Contexts Context
|
||||
{
|
||||
get => _context;
|
||||
set => SetProperty(ref _context, value, "Context");
|
||||
}
|
||||
|
||||
void Region_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
OnRegionSelected?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private Size _MeasuredSize { get; set; }
|
||||
|
||||
private Point p1;
|
||||
|
||||
public void Region_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton != MouseButtonState.Pressed) return;
|
||||
if (IsNew) { DrawSelection(sender, e, _adornedElement); }
|
||||
else { MoveSelection(sender, e, _adornedElement); }
|
||||
|
||||
var layer = AdornerLayer.GetAdornerLayer(_adornedElement);
|
||||
InvalidateVisual();
|
||||
layer.InvalidateVisual();
|
||||
}
|
||||
public void DrawSelection(object sender, MouseEventArgs e, UIElement adornedElement)
|
||||
{
|
||||
if (e.LeftButton != MouseButtonState.Pressed) return;
|
||||
var mousePosition = e.GetPosition(adornedElement);
|
||||
var r = SelectRect;
|
||||
r.X = mousePosition.X < AnchorPoint.X ? mousePosition.X : AnchorPoint.X;
|
||||
r.Y = mousePosition.Y < AnchorPoint.Y ? mousePosition.Y : AnchorPoint.Y;
|
||||
r.Width = Math.Abs(mousePosition.X - AnchorPoint.X);
|
||||
r.Height = Math.Abs(mousePosition.Y - AnchorPoint.Y);
|
||||
SelectRect = r;
|
||||
_geometry.Rect = SelectRect;
|
||||
}
|
||||
public void MoveSelection(object sender, MouseEventArgs e, UIElement adornedElement)
|
||||
{
|
||||
if (e.LeftButton != MouseButtonState.Pressed) return;
|
||||
var mousePosition = e.GetPosition(adornedElement);
|
||||
var r = SelectRect;
|
||||
r.X -= p1.X - mousePosition.X;
|
||||
r.Y -= p1.Y - mousePosition.Y;
|
||||
SelectRect = r;
|
||||
p1 = mousePosition;
|
||||
_geometry.Rect = SelectRect;
|
||||
}
|
||||
public delegate void EndSelectionHandler(RegionAdorner r);
|
||||
public event EndSelectionHandler OnEndSelection;
|
||||
|
||||
public void EndSelection(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ReleaseMouseCapture();
|
||||
OnEndSelection?.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class Zone //: BasePropertyChanged
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public string Image { get; set; }
|
||||
|
||||
private readonly TestObjectTemplate _template;
|
||||
public TemplateZone ISODllZone { get; }
|
||||
|
||||
public Zone(Zone copy, TestObjectTemplate template)
|
||||
{
|
||||
ISODllZone = copy.ISODllZone;
|
||||
_template = template;
|
||||
Description = ISODllZone?.Description ?? "";
|
||||
Image = ISODllZone?.Picture;
|
||||
_fileNames = new List<System.IO.FileInfo>();
|
||||
PopulateFilenamesIfNeeded();
|
||||
PictureIndex = copy.PictureIndex;
|
||||
PictureSource = copy.PictureSource;
|
||||
Name = ISODllZone.ZoneName;
|
||||
_regions = new List<Region>(copy.Regions);
|
||||
}
|
||||
public Zone(TemplateZone z, TestObjectTemplate template)
|
||||
{
|
||||
ISODllZone = z;
|
||||
_template = template;
|
||||
|
||||
Description = z?.Description ?? "";
|
||||
Image = z?.Picture;
|
||||
var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZonePictures");
|
||||
|
||||
if (!string.IsNullOrEmpty(Image))
|
||||
{
|
||||
path = System.IO.Path.Combine(path, Image);
|
||||
if (!System.IO.File.Exists(path)) { PictureIndex = -1; }
|
||||
else
|
||||
{
|
||||
var src = new System.Windows.Media.Imaging.BitmapImage();
|
||||
src.BeginInit();
|
||||
src.UriSource = new Uri(path, UriKind.Absolute);
|
||||
try
|
||||
{
|
||||
src.EndInit();
|
||||
PictureSource = src;
|
||||
_pictureIndex = AllPictures.ToList().IndexOf(Image);
|
||||
}
|
||||
catch
|
||||
{
|
||||
PictureIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (z != null)
|
||||
{
|
||||
Name = z.ZoneName;
|
||||
_regions = new List<Region>();
|
||||
foreach (var r in z.TemplateRegions)
|
||||
{
|
||||
var region = new Region(template, r);
|
||||
_regions.Add(region);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class FileInfoComparer : IComparer<System.IO.FileInfo>
|
||||
{
|
||||
int IComparer<System.IO.FileInfo>.Compare(System.IO.FileInfo left, System.IO.FileInfo right)
|
||||
{
|
||||
if (left == right) { return 0; }
|
||||
if (left == null) { return -1; }
|
||||
return right == null ? 1 : string.Compare(left.FullName, right.FullName, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
private List<System.IO.FileInfo> _fileNames;
|
||||
private static object MyLock = new object();
|
||||
public string[] AllPictures
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
PopulateFilenamesIfNeeded();
|
||||
return _fileNames.Select(fi => fi.Name).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PopulateFilenamesIfNeeded()
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (null == _fileNames || _fileNames.Count == 0)
|
||||
{
|
||||
PopulateFilenames();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void PopulateFilenames()
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
var files = new List<string>();
|
||||
files.AddRange(System.IO.Directory.EnumerateFiles(
|
||||
System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZonePictures")));
|
||||
_fileNames = new List<System.IO.FileInfo>();
|
||||
foreach (var file in files)
|
||||
{
|
||||
_fileNames.Add(new System.IO.FileInfo(file));
|
||||
}
|
||||
_fileNames.Sort(new FileInfoComparer());
|
||||
}
|
||||
}
|
||||
private int _pictureIndex = -1;
|
||||
public int PictureIndex
|
||||
{
|
||||
get => _pictureIndex;
|
||||
set
|
||||
{
|
||||
if (value < 0) { PictureSource = null; }
|
||||
else
|
||||
{
|
||||
var src = new System.Windows.Media.Imaging.BitmapImage();
|
||||
lock (MyLock)
|
||||
{
|
||||
PopulateFilenamesIfNeeded();
|
||||
src.BeginInit();
|
||||
src.UriSource = new Uri(_fileNames[value].FullName, UriKind.Absolute);
|
||||
src.EndInit();
|
||||
}
|
||||
PictureSource = src;
|
||||
}
|
||||
_pictureIndex = value;
|
||||
}
|
||||
}
|
||||
public string GetPictureName()
|
||||
{
|
||||
return _pictureIndex < 0 ? "" : _fileNames[_pictureIndex].Name;
|
||||
}
|
||||
|
||||
public System.Windows.Media.ImageSource PictureSource { get; set; } = null;
|
||||
|
||||
private List<Region> _regions = new List<Region>();
|
||||
public Region[] Regions
|
||||
{
|
||||
get => _regions.ToArray();
|
||||
set => _regions = new List<Region>(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// InitialOffset is the replacement for InitialEU
|
||||
/// it encompasses the old InitialOffset specified in EU with a method of specifying it in mV @EU
|
||||
/// Initial EU is a post data collection adjustment to engineering units recorded
|
||||
/// </summary>
|
||||
public class InitialOffset
|
||||
{
|
||||
/// <summary>
|
||||
/// copy constructor
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public InitialOffset(InitialOffset copy)
|
||||
{
|
||||
if (null == copy) { return; }
|
||||
EU = copy.EU;
|
||||
MV = copy.MV;
|
||||
Form = copy.Form;
|
||||
}
|
||||
/// <summary>
|
||||
/// default constructor
|
||||
/// </summary>
|
||||
public InitialOffset()
|
||||
{
|
||||
Form = Forms.None;
|
||||
EU = 0D;
|
||||
MV = 0D;
|
||||
}
|
||||
/// <summary>
|
||||
/// constructor for the old format Initial EU (a single double represting offset in EU)
|
||||
/// </summary>
|
||||
/// <param name="d"></param>
|
||||
public InitialOffset(double d)
|
||||
{
|
||||
Form = Forms.EU;
|
||||
EU = d;
|
||||
MV = 0D;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// deserializes from a string suitable for db storage
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
public void FromDbSerializeString(string input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
{
|
||||
Form = Forms.None;
|
||||
EU = 0;
|
||||
MV = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
var tokens = input.Split(new string[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
|
||||
Forms form;
|
||||
|
||||
if (Enum.TryParse(tokens[0], out form))
|
||||
{
|
||||
Form = form;
|
||||
if (tokens.Length < 3)
|
||||
{
|
||||
throw new System.IO.InvalidDataException("Invalid InitialOffset number of parameters: " + input);
|
||||
}
|
||||
if (double.TryParse(tokens[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out var d))
|
||||
{
|
||||
EU = d;
|
||||
}
|
||||
else { throw new FormatException("Invalid InitialOffset EU format: " + tokens[1]); }
|
||||
if (double.TryParse(tokens[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
MV = d;
|
||||
}
|
||||
else { throw new FormatException("Invalid InitialOffset MV format: " + tokens[2]); }
|
||||
}
|
||||
else { throw new System.IO.InvalidDataException("Invalid InitialOffset form: " + tokens[0]); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the format Initial Offset is in
|
||||
/// </summary>
|
||||
public enum Forms
|
||||
{
|
||||
None = 0,
|
||||
EU = 1,
|
||||
EUAtMV = 2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the format this intial offset instance is in
|
||||
/// </summary>
|
||||
public Forms Form { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// EU value. In the case of Form == EU, this is the offset in EU
|
||||
/// In. the form of EU@mV, this is the EU@mV value, and offset in EU still needs to be calculated
|
||||
/// GetInitialEUValue calculates the offset in eu
|
||||
/// this value is not used for InitialOffset format None
|
||||
/// </summary>
|
||||
public double EU { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// mV value, only applies for the format EU@mV
|
||||
/// this is the value in mV that The value in EU is observed at by a calibrated instrument
|
||||
/// </summary>
|
||||
public double MV { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class ZeroMethod : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected bool SetProperty<T>(ref T storage, T value, string propertyName = null)
|
||||
{
|
||||
if (Equals(storage, value)) return false;
|
||||
|
||||
storage = value;
|
||||
OnPropertyChanged(propertyName);
|
||||
return true;
|
||||
}
|
||||
protected void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public ZeroMethodType Method { get; set; }
|
||||
|
||||
public double Start { get; set; }
|
||||
|
||||
public double End { get; set; }
|
||||
public ZeroMethod(ZeroMethodType zm, double start, double end)
|
||||
{
|
||||
Method = zm;
|
||||
Start = start;
|
||||
End = end;
|
||||
}
|
||||
public ZeroMethod(string zm)
|
||||
{
|
||||
Initialize(zm, System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
/// <summary>
|
||||
/// do a deep copy
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public ZeroMethod(ZeroMethod copy)
|
||||
{
|
||||
Method = copy.Method;
|
||||
Start = copy.Start;
|
||||
End = copy.End;
|
||||
}
|
||||
private void Initialize(string zm, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = zm.Split(',');
|
||||
if (tokens.Length < 3) { return; }
|
||||
Start = Convert.ToDouble(tokens[1], culture);
|
||||
End = Convert.ToDouble(tokens[2], culture);
|
||||
Method = (ZeroMethodType)Enum.Parse(typeof(ZeroMethodType), tokens[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class CustomerDetails //: BasePropertyChanged
|
||||
{
|
||||
private readonly ISO.CustomerDetails _customerDetails;
|
||||
public string Name
|
||||
{
|
||||
get => _customerDetails.Name;
|
||||
set => _customerDetails.Name = value;
|
||||
}
|
||||
}
|
||||
public class CustomerDetailsList //: BasePropertyChanged
|
||||
{
|
||||
public static void DeleteAll()
|
||||
{
|
||||
ISO.CustomerDetails.DeleteCustomerDetails();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class LabratoryDetails //: BasePropertyChanged
|
||||
{
|
||||
private readonly ISO.LabratoryDetails _lab;
|
||||
public string Name
|
||||
{
|
||||
get => _lab.Name;
|
||||
set => _lab.Name = value;
|
||||
}
|
||||
}
|
||||
public class LabratoryDetailsList
|
||||
{
|
||||
public static void DeleteAll()
|
||||
{
|
||||
ISO.LabratoryDetails.DeleteLabratoryDetails();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TestEngineerDetails //: BasePropertyChanged
|
||||
{
|
||||
private ISO.TestEngineerDetails _testEngineerDetails;
|
||||
public string Name
|
||||
{
|
||||
get => _testEngineerDetails.Name;
|
||||
set => _testEngineerDetails.Name = value;
|
||||
}
|
||||
public TestEngineerDetails()
|
||||
{
|
||||
_testEngineerDetails = new ISO.TestEngineerDetails();
|
||||
_testEngineerDetails.Name = "(none)";
|
||||
}
|
||||
public TestEngineerDetails(ISO.TestEngineerDetails testEngineerDetails)
|
||||
{
|
||||
_testEngineerDetails = new ISO.TestEngineerDetails(testEngineerDetails);
|
||||
}
|
||||
}
|
||||
public class TestEngineerDetailsList //: BasePropertyChanged
|
||||
{
|
||||
private static TestEngineerDetailsList _testEngineerList = new TestEngineerDetailsList();
|
||||
public static TestEngineerDetailsList TestEngineerList => _testEngineerList;
|
||||
private static object _testEngineerLock = new object();
|
||||
private static Dictionary<string, TestEngineerDetails> _testEngineers = null;
|
||||
private void PopulateEngineers()
|
||||
{
|
||||
_testEngineers = new Dictionary<string, TestEngineerDetails>();
|
||||
foreach (var t in _testEngineerList.GetAllTestEngineers())
|
||||
{
|
||||
if (!_testEngineers.ContainsKey(t.Name)) { _testEngineers.Add(t.Name, t); }
|
||||
}
|
||||
}
|
||||
public void ReloadAll()
|
||||
{
|
||||
lock (_testEngineerLock)
|
||||
{
|
||||
PopulateEngineers();
|
||||
}
|
||||
}
|
||||
public static void DeleteAll()
|
||||
{
|
||||
_testEngineers = null;
|
||||
ISO.TestEngineerDetails.DeleteAllTestEngineerDetails();
|
||||
}
|
||||
|
||||
private TestEngineerDetails[] GetAllTestEngineers()
|
||||
{
|
||||
var list = new List<TestEngineerDetails>();
|
||||
list.Add(new TestEngineerDetails()); //This is the "(none)" entry
|
||||
foreach (var ts in ISO.TestEngineerDetails.GetAllTestEngineerDetails())
|
||||
{
|
||||
list.Add(new TestEngineerDetails(ts));
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// GUI wrapper for template channels ... it contains a testobjecttemplatechannel
|
||||
/// </summary>
|
||||
public class TemplateChannelUI //: BasePropertyChanged
|
||||
{
|
||||
private TestObjectTemplateChannel _channel;
|
||||
public TemplateChannelUI(TestObjectTemplateChannel channel)
|
||||
{
|
||||
_channel = channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,626 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TestObject : DbTimeStampBase, IComparable<TestObject>
|
||||
{
|
||||
public void RefreshHardware()
|
||||
{
|
||||
SetHardwareFromISO();
|
||||
}
|
||||
public enum Tags
|
||||
{
|
||||
SerialNumber,
|
||||
SerialNumberConverted,
|
||||
TestObjectType,
|
||||
ParentObject,
|
||||
SysBuilt,
|
||||
Channels,
|
||||
Hardware,
|
||||
LastModifiedBy,
|
||||
LastModifiedText,
|
||||
AllTemplates,
|
||||
Template,
|
||||
TemplateIndex,
|
||||
ChannelsDescription,
|
||||
TemplateDescription,
|
||||
TemplateImage,
|
||||
Zones,
|
||||
SelectedGlobalRangeCACOption,
|
||||
ZoneNames,
|
||||
CurrentZone,
|
||||
CurrentZoneIndex,
|
||||
ChannelVisibility,
|
||||
ChannelTypesIndex
|
||||
}
|
||||
private bool? _isComplete = null;
|
||||
public void MarkIsCompleteUnchecked()
|
||||
{
|
||||
_isComplete = null;
|
||||
}
|
||||
public int CompareTo(TestObject rhs)
|
||||
{
|
||||
if (null == rhs) { return 1; }
|
||||
return rhs == this ? 0 : string.Compare(SerialNumber, rhs.SerialNumber, StringComparison.Ordinal);
|
||||
}
|
||||
/// <summary>
|
||||
/// returns the iso support level of the group
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SerializedSettings.ISOSupportLevels GetObjectISOLevel()
|
||||
{
|
||||
if (TemplateType.Contains(Constants.NON_ISO_TESTOBJECT_CHANNEL_TYPE) || TemplateType.Contains(TestObjectTemplateChannel.NONISOCHANNELTYPE))
|
||||
{
|
||||
return SerializedSettings.ISOSupportLevels.NO_ISO;
|
||||
}
|
||||
return SerializedSettings.ISOSupportLevels.ISO_ONLY;
|
||||
}
|
||||
|
||||
//http://fogbugz/fogbugz/default.asp?11910,
|
||||
//I noticed channel name and channel id were alternatively being used to lookup sensors
|
||||
//rather than trying to force them all to use channel name, I merely allowed it to pass in channel id as well.
|
||||
public SensorData GetSensor(string channelId, string serialNumber, string alternateChannelId = null)
|
||||
{
|
||||
var sd = SensorsCollection.SensorsList.GetSensorBySerialNumber(serialNumber);
|
||||
|
||||
if (null == sd) { return null; }
|
||||
sd = new SensorData(sd);
|
||||
var settings = GetISOTestObject().GetSensorSettings(channelId, sd.SerialNumber);
|
||||
if (null == settings || !settings.Any() && !string.IsNullOrWhiteSpace(alternateChannelId))
|
||||
{
|
||||
settings = GetISOTestObject().GetSensorSettings(alternateChannelId, sd.SerialNumber);
|
||||
}
|
||||
var isoTo = GetISOTestObject();
|
||||
var channel = isoTo.GetChannel(channelId);
|
||||
if (null != channel)
|
||||
{
|
||||
//preset the channel iso fields, these can be filter can be overwritten by to settings below
|
||||
sd.TestObject = channel.Channel.Test_Object;
|
||||
sd.Position = channel.Channel.Position;
|
||||
sd.OriginalPosition = channel.Channel.Position;
|
||||
if (channel.Channel.Default_Filter_Class != "?")
|
||||
{
|
||||
//If ISO says "?", then use the sensor's filter class (but still overwrite with any settings below)
|
||||
sd.FilterClassIso = channel.Channel.Default_Filter_Class;
|
||||
}
|
||||
sd.FineLocation1 = channel.Channel.Fine_Loc_1;
|
||||
sd.FineLocation2 = channel.Channel.Fine_Loc_2;
|
||||
sd.FineLocation3 = channel.Channel.Fine_Loc_3;
|
||||
sd.MainLocation = channel.Channel.Trans_Main_Loc;
|
||||
sd.PhysicalDimension = channel.Channel.Physical_Dimension;
|
||||
sd.Direction = channel.Channel.Direction;
|
||||
}
|
||||
if (null != settings)
|
||||
{
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
switch (setting.Setting)
|
||||
{
|
||||
case ISO.TestObject.SensorSettings.CFC:
|
||||
sd.FilterClassIso = setting.Value;
|
||||
switch (sd.FilterClassIso)
|
||||
{
|
||||
case "A":
|
||||
sd.Filter = new FilterClass(FilterClass.FilterClassType.CFC1000);
|
||||
break;
|
||||
case "B":
|
||||
sd.Filter = new FilterClass(FilterClass.FilterClassType.CFC600);
|
||||
break;
|
||||
case "C":
|
||||
sd.Filter = new FilterClass(FilterClass.FilterClassType.CFC180);
|
||||
break;
|
||||
case "D":
|
||||
sd.Filter = new FilterClass(FilterClass.FilterClassType.CFC60);
|
||||
break;
|
||||
case "P":
|
||||
sd.Filter = new FilterClass(FilterClass.FilterClassType.None);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Position:
|
||||
sd.Position = setting.Value;
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Polarity:
|
||||
sd.Invert = setting.Value == "-";
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Range:
|
||||
sd.Capacity = double.Parse(setting.Value, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.LimitDuration:
|
||||
if (!string.IsNullOrWhiteSpace(setting.Value))
|
||||
{
|
||||
sd.DigitalOutputLimitDuration = bool.Parse(setting.Value);
|
||||
sd.LimitDuration = bool.Parse(setting.Value);
|
||||
sd.LimitSquibFireDuration = bool.Parse(setting.Value);
|
||||
}
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Delay:
|
||||
if (!string.IsNullOrWhiteSpace(setting.Value))
|
||||
{
|
||||
sd.DigitalOutputDelayMS = double.Parse(setting.Value, CultureInfo.InvariantCulture);
|
||||
sd.DelayMS = double.Parse(setting.Value, CultureInfo.InvariantCulture);
|
||||
sd.SquibFireDelayMS = double.Parse(setting.Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Duration:
|
||||
if (!string.IsNullOrWhiteSpace(setting.Value))
|
||||
{
|
||||
sd.DigitalOutputDurationMS = double.Parse(setting.Value, CultureInfo.InvariantCulture);
|
||||
sd.DurationMS = double.Parse(setting.Value, CultureInfo.InvariantCulture);
|
||||
sd.SquibFireDurationMS = double.Parse(setting.Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
break;
|
||||
|
||||
case ISO.TestObject.SensorSettings.OutputMode:
|
||||
if (!string.IsNullOrWhiteSpace(setting.Value))
|
||||
{
|
||||
if (int.TryParse(setting.Value, NumberStyles.Any, CultureInfo.InvariantCulture,
|
||||
out int iValue))
|
||||
{
|
||||
sd.DigitalOutputMode = (DigitalOutputModes)iValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.SQMode:
|
||||
if (!string.IsNullOrWhiteSpace(setting.Value))
|
||||
{
|
||||
if (int.TryParse(setting.Value, NumberStyles.Any, CultureInfo.InvariantCulture,
|
||||
out int iValue))
|
||||
{
|
||||
sd.SquibFireMode = (SquibFireMode)iValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DIMode:
|
||||
if (!string.IsNullOrWhiteSpace(setting.Value))
|
||||
{
|
||||
if (int.TryParse(setting.Value, NumberStyles.Any, CultureInfo.InvariantCulture,
|
||||
out var iValue))
|
||||
{
|
||||
sd.InputMode = (DigitalInputModes)iValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DefaultValue:
|
||||
if (!string.IsNullOrWhiteSpace(setting.Value))
|
||||
{
|
||||
if (double.TryParse(setting.Value, out var defaultValue))
|
||||
{
|
||||
sd.ScaleMultiplier.DefaultValue = defaultValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.ActiveValue:
|
||||
if (!string.IsNullOrWhiteSpace(setting.Value))
|
||||
{
|
||||
if (double.TryParse(setting.Value, out var activeValue))
|
||||
{
|
||||
sd.ScaleMultiplier.ActiveValue = activeValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sd.FilterClassIso == "?")
|
||||
{
|
||||
sd.FilterClassIso = "P"; // "Prefiltered > CFC 1000" (Unfiltered)
|
||||
}
|
||||
return sd;
|
||||
}
|
||||
|
||||
public void SetSensor(string channelName, SensorData sensor)
|
||||
{
|
||||
var settings = new List<ISO.TestObject.SensorSetting>();
|
||||
var fields = Enum.GetValues(typeof(ISO.TestObject.SensorSettings)).Cast<ISO.TestObject.SensorSettings>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var value = "";
|
||||
switch (field)
|
||||
{
|
||||
case ISO.TestObject.SensorSettings.CFC: value = sensor.FilterClassIso; break;
|
||||
case ISO.TestObject.SensorSettings.Position: value = sensor.Position; break;
|
||||
case ISO.TestObject.SensorSettings.Polarity: value = sensor.Invert ? "-" : "+"; break;
|
||||
case ISO.TestObject.SensorSettings.Range: value = sensor.Capacity.ToString(CultureInfo.InvariantCulture); break;
|
||||
case ISO.TestObject.SensorSettings.Duration:
|
||||
value = sensor.DurationMS.ToString(CultureInfo.InvariantCulture);
|
||||
if (sensor.IsSquib())
|
||||
{
|
||||
value = sensor.SquibFireDurationMS.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (sensor.IsDigitalOutput())
|
||||
{
|
||||
value = sensor.DigitalOutputDurationMS.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Delay:
|
||||
value = sensor.DelayMS.ToString(CultureInfo.InvariantCulture);
|
||||
if (sensor.IsSquib())
|
||||
{
|
||||
value = sensor.SquibFireDelayMS.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (sensor.IsDigitalOutput())
|
||||
{
|
||||
value = sensor.DigitalOutputDelayMS.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.LimitDuration:
|
||||
value = sensor.LimitDuration.ToString(CultureInfo.InvariantCulture);
|
||||
if (sensor.IsSquib())
|
||||
{
|
||||
value = sensor.LimitSquibFireDuration.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (sensor.IsDigitalOutput())
|
||||
{
|
||||
value = sensor.DigitalOutputLimitDuration.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.OutputMode: value = ((int)sensor.DigitalOutputMode).ToString(CultureInfo.InvariantCulture); break;
|
||||
case ISO.TestObject.SensorSettings.SQMode: value = ((int)sensor.SquibFireMode).ToString(CultureInfo.InvariantCulture); break;
|
||||
case ISO.TestObject.SensorSettings.DIMode: value = ((int)sensor.InputMode).ToString(CultureInfo.InvariantCulture); break;
|
||||
case ISO.TestObject.SensorSettings.DefaultValue: value = sensor.ScaleMultiplier.DefaultValue.ToString(CultureInfo.InvariantCulture); break;
|
||||
case ISO.TestObject.SensorSettings.ActiveValue: value = sensor.ScaleMultiplier.ActiveValue.ToString(CultureInfo.InvariantCulture); break;
|
||||
default: continue; // If we don't know about a setting we shouldn't overwrite it with blank.
|
||||
}
|
||||
settings.Add(new ISO.TestObject.SensorSetting(field, value, channelName, sensor.SerialNumber));
|
||||
}
|
||||
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
GetISOTestObject().SetSensorSetting(channelName, sensor.SerialNumber, setting);
|
||||
}
|
||||
}
|
||||
|
||||
public TestObject()
|
||||
{
|
||||
//PopulateTemplates();
|
||||
_isoTestObject = new ISO.TestObject();
|
||||
Template = new TestObjectTemplate();
|
||||
ParentObject = "";
|
||||
SysBuilt = false;
|
||||
}
|
||||
|
||||
public DASHardware[] Hardware
|
||||
{
|
||||
get
|
||||
{
|
||||
var hardware = new List<DASHardware>(_hardware.Values.ToArray());
|
||||
hardware.Sort();
|
||||
return hardware.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize(TestObject copy)
|
||||
{
|
||||
//PopulateTemplates();
|
||||
if (!(Application.Current is App app)) return;
|
||||
var db = app.IsoDb;
|
||||
_isoTestObject = new ISO.TestObject(copy.GetISOTestObject(), ref db);
|
||||
SerialNumber = copy.SerialNumber;
|
||||
if (null != copy.Template)
|
||||
{
|
||||
SetTemplateDontResetISOObject(new TestObjectTemplate(copy.Template, ref db));
|
||||
}
|
||||
var copyIsoto = copy.GetISOTestObject();
|
||||
var isoto = GetISOTestObject();
|
||||
|
||||
var hardware = copy.Hardware.Select(das => new DASHardware(das, null)).ToList();
|
||||
foreach (var h in hardware)
|
||||
{
|
||||
_hardware.Add(h.SerialNumber, h);
|
||||
}
|
||||
ParentObject = copy.ParentObject;
|
||||
SysBuilt = copy.SysBuilt;
|
||||
if (SysBuilt)
|
||||
{
|
||||
_isoTestObject.SerialNumberConverted = copy.SerialNumberConverted;
|
||||
}
|
||||
}
|
||||
|
||||
public TestObject(TestObject copy)
|
||||
{
|
||||
Initialize(copy);
|
||||
DbTimeStamp = copy.DbTimeStamp;
|
||||
}
|
||||
private string _serialNumber = string.Empty;
|
||||
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _serialNumber;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _serialNumber, value, Tags.SerialNumber.ToString());
|
||||
GetISOTestObject().SerialNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string SerialNumberOrOriginalSerialNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GetISOTestObject().Embedded)
|
||||
{
|
||||
return GetISOTestObject().OriginalSerialNumber;
|
||||
}
|
||||
return string.IsNullOrWhiteSpace(SerialNumberConverted) ? SerialNumber : SerialNumberConverted;
|
||||
}
|
||||
}
|
||||
|
||||
private string _serialNumberConverted = string.Empty;
|
||||
|
||||
public string SerialNumberConverted
|
||||
{
|
||||
get => _serialNumberConverted;
|
||||
set => SetProperty(ref _serialNumberConverted, value, Tags.SerialNumberConverted.ToString());
|
||||
}
|
||||
|
||||
public string DisplaySerialNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(SerialNumberConverted) && !SysBuilt)
|
||||
{
|
||||
return SerialNumberOrOriginalSerialNumber;
|
||||
}
|
||||
return SerialNumberConverted;
|
||||
}
|
||||
set
|
||||
{
|
||||
//We assume that this is an Added Group being renamed
|
||||
SerialNumber = TestSetupName + "_" + value;
|
||||
SerialNumberConverted = value;
|
||||
GetISOTestObject().OriginalSerialNumber = SerialNumber;
|
||||
Template.OriginalTemplateName = SerialNumber + "_Template";
|
||||
GetISOTestObject().OriginalTemplate = Template.OriginalTemplateName;
|
||||
}
|
||||
}
|
||||
private string _testSetupName = string.Empty;
|
||||
|
||||
public string TestSetupName
|
||||
{
|
||||
get => _testSetupName;
|
||||
set => _testSetupName = value;
|
||||
}
|
||||
|
||||
private string _testObjectType = "?";
|
||||
|
||||
public string TestObjectType
|
||||
{
|
||||
get => _testObjectType;
|
||||
set => SetProperty(ref _testObjectType, value, Tags.TestObjectType.ToString());
|
||||
}
|
||||
|
||||
private string _parentObject = "";
|
||||
|
||||
public string ParentObject
|
||||
{
|
||||
get => _parentObject;
|
||||
set
|
||||
{
|
||||
MarkIsCompleteUnchecked();
|
||||
SetProperty(ref _parentObject, value, Tags.ParentObject.ToString());
|
||||
GetISOTestObject().ParentObject = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _sysBuilt;
|
||||
|
||||
public bool SysBuilt
|
||||
{
|
||||
get => _sysBuilt;
|
||||
set => SetProperty(ref _sysBuilt, value, Tags.SysBuilt.ToString());
|
||||
}
|
||||
private Dictionary<string, DASHardware> _hardware = new Dictionary<string, DASHardware>();
|
||||
|
||||
public bool ContainsHardware(DASHardware h)
|
||||
{
|
||||
return _hardware.ContainsKey(h.SerialNumber);
|
||||
}
|
||||
|
||||
public void SetHardwareFromISO()
|
||||
{
|
||||
_hardware.Clear();
|
||||
var isoTo = GetISOTestObject();
|
||||
foreach (var hid in isoTo.HardwareIds)
|
||||
{
|
||||
var h = DASHardwareList.GetList().GetHardware(hid);
|
||||
if (null == h)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//just making sure we have a copy and not the original hardware record.
|
||||
h = new DASHardware(h.GetHardware());
|
||||
h.SetTimeStampMemory(h.GetTimeStampMemory());
|
||||
if (!_hardware.ContainsKey(h.SerialNumber))
|
||||
{
|
||||
_hardware[h.SerialNumber] = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// this call is intended to be available to test template to update the hardware for the group in memory
|
||||
/// it is not intended to have that hardware stored in the db currently
|
||||
/// </summary>
|
||||
/// <param name="hardware"></param>
|
||||
public void SetHardware(DASHardware[] hardware)
|
||||
{
|
||||
_hardware.Clear();
|
||||
var hids = new List<string>();
|
||||
foreach (var h in hardware)
|
||||
{
|
||||
_hardware[h.SerialNumber] = h;
|
||||
if (!hids.Contains(h.SerialNumber))
|
||||
{
|
||||
hids.Add(h.SerialNumber);
|
||||
}
|
||||
}
|
||||
GetISOTestObject().HardwareIds = hids.ToArray();
|
||||
}
|
||||
|
||||
public void AddHardware(DASHardware hardware)
|
||||
{
|
||||
var stamp = hardware.GetTimeStampMemory();
|
||||
//just making sure we have a copy and not the original hardware record
|
||||
hardware = new DASHardware(hardware.GetHardware());
|
||||
hardware.SetTimeStampMemory(stamp);
|
||||
MarkIsCompleteUnchecked();
|
||||
var toAdd = hardware;
|
||||
if (hardware.IsDummy())
|
||||
{
|
||||
var key = hardware.SerialNumber;
|
||||
if (_hardware.ContainsKey(key))
|
||||
{
|
||||
var current = 1;
|
||||
while (_hardware.ContainsKey(key))
|
||||
{
|
||||
current++;
|
||||
key = $"{hardware.SerialNumber}({current:00})";
|
||||
}
|
||||
toAdd = new DASHardware(hardware.GetHardware());
|
||||
toAdd.SetTimeStampMemory(hardware.GetTimeStampMemory());
|
||||
toAdd.SerialNumber = key;
|
||||
}
|
||||
else
|
||||
{
|
||||
toAdd = new DASHardware(hardware.GetHardware());
|
||||
toAdd.SetTimeStampMemory(hardware.GetTimeStampMemory());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
toAdd = new DASHardware(hardware.GetHardware());
|
||||
toAdd.SetTimeStampMemory(hardware.GetTimeStampMemory());
|
||||
}
|
||||
if (_hardware.ContainsKey(toAdd.SerialNumber))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_hardware.Add(toAdd.SerialNumber, toAdd);
|
||||
OnPropertyChanged(Tags.Hardware.ToString());
|
||||
_isoTestObject.HardwareIds = Hardware.Select(h => h.GetHardware().GetId()).ToArray();
|
||||
}
|
||||
public ISO.TestObject GetISOTestObject()
|
||||
{
|
||||
return _isoTestObject;
|
||||
}
|
||||
private string _lastModifiedBy = "N/A";
|
||||
private DateTime _lastModified = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
|
||||
private TestObjectTemplate _template = null;
|
||||
|
||||
public TestObjectTemplate Template
|
||||
{
|
||||
get => _template;
|
||||
set
|
||||
{
|
||||
if (value == _template)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (null == value)
|
||||
{
|
||||
_template = null;
|
||||
return;
|
||||
}
|
||||
if (GetISOTestObject().Template != value.TemplateName)
|
||||
{
|
||||
var db = ((App)Application.Current).IsoDb;
|
||||
GetISOTestObject().SetTemplate(value.TemplateName, ref db);
|
||||
}
|
||||
SetProperty(ref _template, value, Tags.Template.ToString());
|
||||
OnPropertyChanged(Tags.TemplateIndex.ToString());
|
||||
OnPropertyChanged(Tags.ChannelsDescription.ToString());
|
||||
OnPropertyChanged(Tags.LastModifiedText.ToString());
|
||||
OnPropertyChanged(Tags.TemplateDescription.ToString());
|
||||
OnPropertyChanged(Tags.TemplateImage.ToString());
|
||||
OnPropertyChanged(Tags.Zones.ToString());
|
||||
OnPropertyChanged(Tags.SelectedGlobalRangeCACOption.ToString());
|
||||
ZoneNames = Template.TemplateZones.Select(z => z.Name).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTemplateDontResetISOObject(TestObjectTemplate value)
|
||||
{
|
||||
if (value == _template)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (null == value)
|
||||
{
|
||||
_template = null;
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_isoTestObject?.SetTemplateOnly(value.TemplateName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
|
||||
var db = ((App)Application.Current).IsoDb;
|
||||
SetProperty(ref _template, new TestObjectTemplate(value, ref db), Tags.Template.ToString());
|
||||
OnPropertyChanged(Tags.TemplateIndex.ToString());
|
||||
OnPropertyChanged(Tags.ChannelsDescription.ToString());
|
||||
OnPropertyChanged(Tags.LastModifiedText.ToString());
|
||||
OnPropertyChanged(Tags.TemplateDescription.ToString());
|
||||
OnPropertyChanged(Tags.TemplateImage.ToString());
|
||||
OnPropertyChanged(Tags.Zones.ToString());
|
||||
OnPropertyChanged(Tags.SelectedGlobalRangeCACOption.ToString());
|
||||
ZoneNames = value.TemplateZones.Select(z => z.Name).ToArray();
|
||||
}
|
||||
private List<string> _zoneNames = new List<string>();
|
||||
|
||||
public string[] ZoneNames
|
||||
{
|
||||
get => _zoneNames.ToArray();
|
||||
set => SetProperty(ref _zoneNames, new List<string>(value), Tags.ZoneNames.ToString());
|
||||
}
|
||||
public string TemplateType => null == Template ? "" : Template.TestObjectType;
|
||||
|
||||
private readonly bool _localOnly = false;
|
||||
private ISO.TestObject _isoTestObject = null;
|
||||
public TestObject(ISO.TestObject to, bool sysBuilt)
|
||||
{
|
||||
_isoTestObject = to;
|
||||
SerialNumber = to.SerialNumber;
|
||||
if (sysBuilt)
|
||||
{
|
||||
SerialNumberConverted = to.SerialNumber.Remove(0, SerialNumber.LastIndexOf('_') + 1);
|
||||
Template = to.Template == "SysBuilt_(no channels)" ? TestObjectTemplateCollection.TemplateCollection.SysBuiltTestObjectTemplate : TestObjectTemplateCollection.TemplateCollection.GetTemplate(to.Template);
|
||||
TestObjectType = to.TestObjectType;
|
||||
SysBuilt = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Template = TestObjectTemplateCollection.TemplateCollection.GetTemplate(to.Template);
|
||||
}
|
||||
_localOnly = to.LocalOnly;
|
||||
_lastModifiedBy = to.LastModifiedBy;
|
||||
_lastModified = to.LastModified;
|
||||
foreach (var id in to.HardwareIds)
|
||||
{
|
||||
DASHardware da = null;
|
||||
try
|
||||
{
|
||||
da = DASHardwareList.GetList().GetHardware(id);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log(ex);
|
||||
}
|
||||
if (null != da && !ContainsHardware(da))
|
||||
{
|
||||
AddHardware(da);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// list that holds groups
|
||||
/// </summary>
|
||||
public class TestObjectList //: BasePropertyChanged
|
||||
{
|
||||
private static readonly object MyLock = new object();
|
||||
private static TestObjectList _testObjectList;
|
||||
private static TestObjectList _addedGroupList;
|
||||
public static TestObjectList TestObjectsList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (null == _testObjectList)
|
||||
{
|
||||
_testObjectList = new TestObjectList();
|
||||
}
|
||||
}
|
||||
return _testObjectList;
|
||||
}
|
||||
}
|
||||
|
||||
public static TestObjectList AddedGroupsList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (null == _addedGroupList)
|
||||
{
|
||||
_addedGroupList = new TestObjectList();
|
||||
}
|
||||
}
|
||||
return _addedGroupList;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// reloads all components and subcomponents
|
||||
/// </summary>
|
||||
/// <param name="bLoadSubComponents"></param>
|
||||
public void ReloadAll(bool bLoadSubComponents)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a given test object if it is in the list,
|
||||
/// returns null otherwise
|
||||
/// </summary>
|
||||
/// <param name="serialNumber">serialnumber of group to look for</param>
|
||||
/// <returns></returns>
|
||||
public TestObject GetTestObject(string serialNumber, bool bSysBuilt)
|
||||
{
|
||||
var db = (Application.Current as App).IsoDb;
|
||||
var isoTestObject = ISO.TestObject.GetTestObject(serialNumber, ref db, bSysBuilt);
|
||||
if (null == isoTestObject) { return null; }
|
||||
return new TestObject(isoTestObject, bSysBuilt);
|
||||
}
|
||||
|
||||
public TestObject GetTestObject(string serialNumber)
|
||||
{
|
||||
var a = GetTestObject(serialNumber, false);
|
||||
if (null != a) { return a; }
|
||||
return GetTestObject(serialNumber, true);
|
||||
}
|
||||
public TestObject GetAddedGroup(string serialNumber)
|
||||
{
|
||||
return GetTestObject(serialNumber, true);
|
||||
}
|
||||
/// <summary>
|
||||
/// deletes all test objects
|
||||
/// originally created so TDM imports could clear all tables except DAS
|
||||
/// </summary>
|
||||
public void DeleteAll()
|
||||
{
|
||||
//if (_bUnloaded)
|
||||
//{
|
||||
// Reload();
|
||||
//}
|
||||
try
|
||||
{
|
||||
ISO.TestObject.DeleteAllTestObjects();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to delete all test objects, ", ex);
|
||||
}
|
||||
//Reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TestObjectTemplate //: BasePropertyChanged, IComparable<TestObjectTemplate>
|
||||
{
|
||||
// #region enums and constants
|
||||
public enum Tags
|
||||
{
|
||||
ChannelCountText,
|
||||
PossibleChannelCountText,
|
||||
TemplateName,
|
||||
TemplateDescription,
|
||||
TestObject,
|
||||
TestObjectType,
|
||||
TemplateAllUIChannels,
|
||||
TemplateZones,
|
||||
AvailableTestObjectTypes,
|
||||
TestObjectIndex,
|
||||
TestObjectTypeIndex,
|
||||
CurrentZone,
|
||||
CurrentZoneIndex,
|
||||
AreZoneControlsEnabled,
|
||||
TemplateAllChannels,
|
||||
RequiredChannels
|
||||
}
|
||||
|
||||
public string LastModifiedBy { get; set; } = "N/A";
|
||||
|
||||
public DateTime LastModified { get; set; } = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
|
||||
|
||||
private int _currentZoneIndex = -1;
|
||||
public int CurrentZoneIndex
|
||||
{
|
||||
get => _currentZoneIndex;
|
||||
set
|
||||
{
|
||||
CurrentZone = value >= 0 ? TemplateZones[value] : null;
|
||||
_currentZoneIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Zone _currentZone;
|
||||
public Zone CurrentZone
|
||||
{
|
||||
get => _currentZone;
|
||||
set
|
||||
{
|
||||
//if (null != _currentZone && _currentZone != value) { _currentZone.PropertyChanged -= CurrentZone_PropertyChanged; }
|
||||
_currentZone = value;
|
||||
|
||||
//if (null != _currentZone) { _currentZone.PropertyChanged += CurrentZone_PropertyChanged; }
|
||||
AreZoneControlsEnabled = null != value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool AreZoneControlsEnabled { get; set; }
|
||||
|
||||
private ISO.TestObjectTemplate _template;
|
||||
public List<TestObjectTemplateChannel> RequiredChannels { get; set; } = new List<TestObjectTemplateChannel>();
|
||||
|
||||
public string TemplateParent { get; set; } = "";
|
||||
|
||||
public bool SysBuilt { get; set; }
|
||||
|
||||
private bool _embedded;
|
||||
public bool Embedded
|
||||
{
|
||||
get => _embedded;
|
||||
set
|
||||
{
|
||||
_embedded = value;
|
||||
if (null != _template) { _template.Embedded = value; }
|
||||
}
|
||||
}
|
||||
|
||||
private string _originalTemplateName = "";
|
||||
public string OriginalTemplateName
|
||||
{
|
||||
get => _originalTemplateName;
|
||||
set
|
||||
{
|
||||
_originalTemplateName = value;
|
||||
if (null != _template) { _template.OriginalTemplateName = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public string TemplateName { get; set; }
|
||||
|
||||
public string TemplateDescription { get; set; }
|
||||
|
||||
public bool IsLocalOnly { get; set; }
|
||||
|
||||
private MMETestObjects _testObject;
|
||||
public MMETestObjects TestObject
|
||||
{
|
||||
get => _testObject;
|
||||
set
|
||||
{
|
||||
_testObject = value;
|
||||
if (null == _testObject) return;
|
||||
var app = Application.Current as App;
|
||||
if (app == null) return;
|
||||
AvailableTestObjectTypes = app.IsoDb.GetUniquePossibleChannelTypes(TestObjectTemplateChannel.NONISOCHANNELTYPE);
|
||||
if (AvailableTestObjectTypes.Length > 0) { TestObjectTypeIndex = 0; }
|
||||
else { TestObjectTypeIndex = -1; }
|
||||
}
|
||||
}
|
||||
|
||||
private string _testObjectType;
|
||||
public string TestObjectType
|
||||
{
|
||||
get => _testObjectType;
|
||||
set
|
||||
{
|
||||
_testObjectType = value;
|
||||
_channels = new List<MMEPossibleChannels>(((App)Application.Current).IsoDb.GetPossibleChannelsForType(_testObjectType));
|
||||
TemplateAllChannels = _channels.Select(pc => new TestObjectTemplateChannel(new TestObjectTemplateChannel(pc), /*ref db,*/ _template)).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private List<MMEPossibleChannels> _channels = new List<MMEPossibleChannels>();
|
||||
|
||||
private List<TestObjectTemplateChannel> _allChannels = new List<TestObjectTemplateChannel>();
|
||||
public TestObjectTemplateChannel[] TemplateAllChannels
|
||||
{
|
||||
get { _allChannels.Sort(CompareChannels); return _allChannels.ToArray(); }
|
||||
set
|
||||
{
|
||||
_allChannels = new List<TestObjectTemplateChannel>(value);
|
||||
|
||||
TemplateAllUIChannels = value.Select(c => new TemplateChannelUI(c)).ToArray();
|
||||
}
|
||||
}
|
||||
private List<TemplateChannelUI> _allUIChannels = new List<TemplateChannelUI>();
|
||||
public TemplateChannelUI[] TemplateAllUIChannels
|
||||
{
|
||||
get => _allUIChannels.ToArray();
|
||||
set => _allUIChannels = new List<TemplateChannelUI>(value);
|
||||
}
|
||||
|
||||
private List<Zone> _zones = new List<Zone>();
|
||||
public Zone[] TemplateZones
|
||||
{
|
||||
get => _zones.ToArray();
|
||||
set { _zones = new List<Zone>(value); var j = CurrentZoneIndex; }
|
||||
}
|
||||
private List<string> _availableTestObjectTypes = null;
|
||||
public string[] AvailableTestObjectTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null != _availableTestObjectTypes) return _availableTestObjectTypes.ToArray();
|
||||
if (null == TestObject) { return new string[0]; }
|
||||
_availableTestObjectTypes = new List<string>(((App)Application.Current).IsoDb.GetTestObjectTypeForTestObject(TestObject.Test_Object));
|
||||
return _availableTestObjectTypes.ToArray();
|
||||
}
|
||||
set => _availableTestObjectTypes = new List<string>(value);
|
||||
}
|
||||
private int _testObjectTypeIndex = -1;
|
||||
public int TestObjectTypeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(TestObjectType)) { return -1; }
|
||||
return _availableTestObjectTypes.IndexOf(TestObjectType);
|
||||
}
|
||||
set
|
||||
{
|
||||
TestObjectType = value >= 0 ? _availableTestObjectTypes[value] : null;
|
||||
_testObjectTypeIndex = value;
|
||||
|
||||
TemplateAllChannels = _channels.Select(pc => new TestObjectTemplateChannel(new TestObjectTemplateChannel(pc), /*ref db,*/ _template)).ToArray();
|
||||
}
|
||||
}
|
||||
public static MMETestObjects GetNonISOTestObject()
|
||||
{
|
||||
var existingobjects = ((App)Application.Current).IsoDb.GetTestObjects(false);
|
||||
|
||||
var codes = new List<string>();
|
||||
|
||||
foreach (var existingobject in existingobjects)
|
||||
{
|
||||
if (existingobject.Text_L1 == Constants.NON_ISO_TESTOBJECT_NAME)
|
||||
{
|
||||
return existingobject;
|
||||
}
|
||||
codes.Add(existingobject.Test_Object);
|
||||
}
|
||||
|
||||
//first try to find a suitable alpha character that isn't in use
|
||||
for (var i = (int)'A'; i <= 'Z'; i++)
|
||||
{
|
||||
var s = new string(new[] { (char)i });
|
||||
if (!codes.Contains(s))
|
||||
{
|
||||
var to = new MMETestObjects(Guid.NewGuid().ToString(), s, Constants.NON_ISO_TESTOBJECT_NAME, Constants.NON_ISO_TESTOBJECT_NAME, 1,
|
||||
DateTime.Now, "SYSTEM", false, "", DateTime.Now, "created", "", MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
((App)Application.Current).IsoDb.Commit(to);
|
||||
return to;
|
||||
}
|
||||
}
|
||||
//didn't find one, now try for a suitable numeric character
|
||||
for (var i = (int)'0'; i <= '9'; i++)
|
||||
{
|
||||
var s = new string(new[] { (char)i });
|
||||
if (codes.Contains(s)) continue;
|
||||
var to = new MMETestObjects(Guid.NewGuid().ToString(), s, Constants.NON_ISO_TESTOBJECT_NAME, Constants.NON_ISO_TESTOBJECT_NAME, 1,
|
||||
DateTime.Now, "SYSTEM", false, "", DateTime.Now, "created", "", MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
((App)Application.Current).IsoDb.Commit(to);
|
||||
return to;
|
||||
}
|
||||
throw new NotSupportedException("TestObjectTemplate_CouldNotCreateNONISOTESTOBJECT");
|
||||
}
|
||||
public ISO.TestObjectTemplate ToISOTestObjectTemplate()
|
||||
{
|
||||
var template = new ISO.TestObjectTemplate(TemplateName, IsLocalOnly)
|
||||
{
|
||||
Description = TemplateDescription,
|
||||
OriginalTemplateName = OriginalTemplateName,
|
||||
Embedded = Embedded,
|
||||
Icon = "",
|
||||
LocalOnly = IsLocalOnly,
|
||||
TestObject = TestObject.Test_Object,
|
||||
TestObjectType = TestObjectType
|
||||
};
|
||||
var zones = new List<TemplateZone>();
|
||||
foreach (var zone in TemplateZones)
|
||||
{
|
||||
var isoZone = new TemplateZone(TemplateName, zone.Name, zone.GetPictureName(), zone.Description);
|
||||
|
||||
var i = 0;
|
||||
isoZone.TemplateRegions = zone.Regions.Select(region => region.ToISORegion(this, zone, i++)).ToArray();
|
||||
zones.Add(isoZone);
|
||||
}
|
||||
template.TemplateParent = TemplateParent;
|
||||
template.Channels = TemplateAllChannels;
|
||||
template.Zones = zones.ToArray();
|
||||
template.SysBuilt = SysBuilt;
|
||||
return template;
|
||||
}
|
||||
private int CompareChannels(TestObjectTemplateChannel left, TestObjectTemplateChannel right)
|
||||
{
|
||||
if (left == right) { return 0; }
|
||||
if (null == left) { return -1; }
|
||||
return null == right ? 1 : left.DisplayOrder.CompareTo(right.DisplayOrder);
|
||||
}
|
||||
public TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)
|
||||
{
|
||||
if (null != copy._template) { _template = new ISO.TestObjectTemplate(copy._template, ref db); }
|
||||
TemplateDescription = copy.TemplateDescription;
|
||||
TemplateParent = copy.TemplateParent;
|
||||
TemplateName = copy.TemplateName;
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
TestObject = copy.TestObject;
|
||||
TestObjectType = copy.TestObjectType;
|
||||
foreach (var c in copy.RequiredChannels)
|
||||
{
|
||||
RequiredChannels.Add(new TestObjectTemplateChannel(c, /*ref db,*/ _template));
|
||||
}
|
||||
TemplateAllChannels = copy.TemplateAllChannels.Select(c => new TestObjectTemplateChannel(c, /*ref db,*/ _template)).ToArray();
|
||||
|
||||
TemplateZones = copy.TemplateZones.Select(z => new Zone(z, this)).ToArray();
|
||||
SysBuilt = copy.SysBuilt;
|
||||
Embedded = copy.Embedded;
|
||||
OriginalTemplateName = copy.OriginalTemplateName;
|
||||
}
|
||||
public TestObjectTemplate(ISO.TestObjectTemplate template, ref ISO13499FileDb db)
|
||||
{
|
||||
Initialize(template, ref db, null);
|
||||
}
|
||||
private void Initialize(ISO.TestObjectTemplate template, ref ISO13499FileDb db, List<MMETestObjects> testObjects)
|
||||
{
|
||||
_template = template;
|
||||
TemplateDescription = template.Description;
|
||||
TemplateName = template.TemplateName;
|
||||
LastModified = template.LastModified;
|
||||
LastModifiedBy = template.LastModifiedBy;
|
||||
|
||||
//if a list of test objects is provided, check if the test object we wish is in the list, if so use it
|
||||
var bFoundTestObject = false;
|
||||
if (null != testObjects)
|
||||
{
|
||||
var matches = from to in testObjects where to.Test_Object == template.TestObject select to;
|
||||
var mmeTestObjectses = matches as MMETestObjects[] ?? matches.ToArray();
|
||||
if (mmeTestObjectses.Any())
|
||||
{
|
||||
TestObject = mmeTestObjectses[0];
|
||||
bFoundTestObject = true;
|
||||
}
|
||||
}
|
||||
if (!bFoundTestObject)
|
||||
{
|
||||
TestObject = (Application.Current as App).IsoDb.GetTestObjectByIso(template.TestObject);
|
||||
}
|
||||
TestObjectType = template.TestObjectType;
|
||||
OriginalTemplateName = template.OriginalTemplateName;
|
||||
Embedded = template.Embedded;
|
||||
|
||||
TemplateAllChannels = template.Channels.Select(c => new TestObjectTemplateChannel(c, /*ref db,*/ _template)).ToArray();
|
||||
TemplateZones = template.Zones.Select(z => new Zone(z, this)).ToArray();
|
||||
TemplateParent = template.TemplateParent;
|
||||
SysBuilt = template.SysBuilt;
|
||||
}
|
||||
public TestObjectTemplate()
|
||||
{
|
||||
TemplateName = string.Empty;
|
||||
TemplateDescription = string.Empty;
|
||||
TemplateParent = string.Empty;
|
||||
|
||||
|
||||
switch (SerializedSettings.ISOSupportLevel)
|
||||
{
|
||||
case SerializedSettings.ISOSupportLevels.ISO_ONLY:
|
||||
TestObject = ((App)Application.Current).IsoDb.GetTestObjects(false).FirstOrDefault();
|
||||
break;
|
||||
case SerializedSettings.ISOSupportLevels.NO_ISO:
|
||||
//need to create a template just for this object!
|
||||
InitializeNonISO();
|
||||
break;
|
||||
case SerializedSettings.ISOSupportLevels.TRANSITORY:
|
||||
TestObject = ((App)Application.Current).IsoDb.GetTestObjects(false).FirstOrDefault();
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void InitializeNonISO()
|
||||
{
|
||||
//create template, set template channel type to NONISOTYPE
|
||||
TemplateName = Guid.NewGuid().ToString();
|
||||
|
||||
TestObject = GetNonISOTestObject();
|
||||
TestObjectType = Constants.NON_ISO_TESTOBJECT_CHANNEL_TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TestObjectTemplateCollection //: BasePropertyChanged
|
||||
{
|
||||
private static volatile TestObjectTemplateCollection _testObjectCollection;
|
||||
public static TestObjectTemplateCollection TemplateCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == _testObjectCollection)
|
||||
{
|
||||
_testObjectCollection = new TestObjectTemplateCollection();
|
||||
}
|
||||
return _testObjectCollection;
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadAll(bool loadSubComponents)
|
||||
{
|
||||
//UnloadAll();
|
||||
//if (loadSubComponents)
|
||||
//{
|
||||
// (App.Current as App).IsoDb.RefreshAllData();
|
||||
// DataModel.CustomChannelList.List.ReloadAll();
|
||||
//}
|
||||
//Reload();
|
||||
}
|
||||
private static volatile TestObjectTemplate _sysBuiltTestObjectTemplate;
|
||||
public TestObjectTemplate SysBuiltTestObjectTemplate => _sysBuiltTestObjectTemplate;
|
||||
|
||||
public TestObjectTemplate GetTemplate(string templateId)
|
||||
{
|
||||
var db = ((App)Application.Current).IsoDb;
|
||||
var isoTemplate = ISO.TestObjectTemplate.GetTemplate(ref db, templateId);
|
||||
return null != isoTemplate ? new TestObjectTemplate(isoTemplate, ref db) : null;
|
||||
}
|
||||
/// <summary>
|
||||
/// deletes all test objects
|
||||
/// originally created so TDM imports could clear all tables
|
||||
/// </summary>
|
||||
public static void DeleteAll()
|
||||
{
|
||||
//if (TemplateCollection._bUnloaded) { Reload(); }
|
||||
_testObjectCollection.DeleteAllTemplates();
|
||||
_testObjectCollection = new TestObjectTemplateCollection();
|
||||
TemplateCollection.DeleteAllTemplates();
|
||||
//TemplateCollection._templates.Clear();
|
||||
}
|
||||
private void DeleteAllTemplates()
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (_bUnloaded) { Reload(); }
|
||||
ISO.TestObjectTemplate.DeleteAllTemplates();
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to delete all templates"); */}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a test object that belongs to a test, it's different in that it can have test specific settings ...
|
||||
/// </summary>
|
||||
public class TestTestObject : TestObject
|
||||
{
|
||||
public TestTestObject(TestObject obj)
|
||||
: base(obj)
|
||||
{
|
||||
}
|
||||
private string _position = ChannelDefaultsKey;
|
||||
public MMEPositions Position
|
||||
{
|
||||
get => GetGroupPosition(_position);
|
||||
set
|
||||
{
|
||||
SetProperty(ref _position, value.Position, "Position");
|
||||
if (_position == UserSetKey)
|
||||
{
|
||||
GroupPositionComboBoxVisible = Visibility.Hidden;
|
||||
GroupPositionButtonVisible = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupPositionComboBoxVisible = Visibility.Visible;
|
||||
GroupPositionButtonVisible = Visibility.Hidden;
|
||||
//set the position for every sensor in the test object using this position
|
||||
var isoTestObject = GetISOTestObject();
|
||||
foreach (var ch in isoTestObject.AllChannels)
|
||||
{
|
||||
if (!ch.Required) { continue; }
|
||||
if (string.IsNullOrWhiteSpace(ch.SensorSerialNumber)) { continue; }
|
||||
var sd = GetSensor(ch.Name, ch.SensorSerialNumber, ch.GetId()); // now using ch.Name instead of ch.GetID(); FB 7391 - Group sensor settings not in test when you set the test obj. and position.
|
||||
if (null == sd) { continue; }
|
||||
sd.Position = value.Position;
|
||||
SetSensor(ch.GetId(), sd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public const string ChannelDefaultsKey = "#";
|
||||
public const string UserSetKey = "@";
|
||||
|
||||
private MMEPositions GetGroupPosition(string groupPositionKey)
|
||||
{
|
||||
foreach (var position in AvailableGroupPositions)
|
||||
{
|
||||
if (position.Position == groupPositionKey)
|
||||
{
|
||||
return position;
|
||||
}
|
||||
}
|
||||
return _userSetGUID;
|
||||
}
|
||||
|
||||
private Visibility _groupPositionComboBoxVisible = Visibility.Visible;
|
||||
public Visibility GroupPositionComboBoxVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_groupPositionComboBoxVisible == Visibility.Visible)
|
||||
{
|
||||
return SerializedSettings.ISOSupportLevel == SerializedSettings.ISOSupportLevels.NO_ISO ? Visibility.Collapsed : _groupPositionComboBoxVisible;
|
||||
}
|
||||
return _groupPositionComboBoxVisible;
|
||||
}
|
||||
set => SetProperty(ref _groupPositionComboBoxVisible, value, "GroupPositionComboBoxVisible");
|
||||
}
|
||||
|
||||
private Visibility _groupPositionButtonVisible = Visibility.Hidden;
|
||||
public Visibility GroupPositionButtonVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_groupPositionButtonVisible == Visibility.Visible)
|
||||
{
|
||||
return SerializedSettings.ISOSupportLevel == SerializedSettings.ISOSupportLevels.NO_ISO ? Visibility.Collapsed : _groupPositionButtonVisible;
|
||||
}
|
||||
return _groupPositionButtonVisible;
|
||||
}
|
||||
set => SetProperty(ref _groupPositionButtonVisible, value, "GroupPositionButtonVisible");
|
||||
}
|
||||
|
||||
private string _testObject = "?";
|
||||
public MMETestObjects TestObject
|
||||
{
|
||||
get => ((App)Application.Current).IsoDb.GetTestObjectByIso(_testObject);
|
||||
set
|
||||
{
|
||||
if (value == null) return;
|
||||
SetProperty(ref _testObject, value.Test_Object, "TestObject");
|
||||
//also set the test object for all sensors!
|
||||
|
||||
var isoTestObject = GetISOTestObject();
|
||||
foreach (var ch in isoTestObject.AllChannels)
|
||||
{
|
||||
if (!ch.Required) { continue; }
|
||||
if (string.IsNullOrWhiteSpace(ch.SensorSerialNumber)) { continue; }
|
||||
var sd = GetSensor(ch.GetId(), ch.SensorSerialNumber, ch.GetId());
|
||||
if (null == sd) { continue; }
|
||||
sd.TestObject = value.Test_Object;
|
||||
SetSensor(ch.GetId(), sd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _channelTypesIndex = -1;
|
||||
public int ChannelTypesIndex
|
||||
{
|
||||
get => _channelTypesIndex;
|
||||
set => SetProperty(ref _channelTypesIndex, value, Tags.ChannelTypesIndex.ToString());
|
||||
}
|
||||
|
||||
public void SetTestObject(string s)
|
||||
{
|
||||
_testObject = s;
|
||||
OnPropertyChanged("TestObject");
|
||||
}
|
||||
|
||||
public void SetPosition(string s)
|
||||
{
|
||||
_position = s;
|
||||
OnPropertyChanged("Position");
|
||||
if (s == UserSetKey)
|
||||
{
|
||||
GroupPositionComboBoxVisible = Visibility.Hidden;
|
||||
GroupPositionButtonVisible = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupPositionComboBoxVisible = Visibility.Visible;
|
||||
GroupPositionButtonVisible = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
public MMEPositions[] AvailablePositions => ((App)Application.Current).IsoDb.GetPositions();
|
||||
|
||||
private const string DATAPRO_DEFINED = "DataPRO-defined";
|
||||
public static MMEPositions _channelDefaultsGUID = new MMEPositions(Guid.NewGuid().ToString(), ChannelDefaultsKey, "(channel defaults)", "(channel defaults)", 1, DateTime.Now, DATAPRO_DEFINED, false, "", DateTime.Now,
|
||||
DATAPRO_DEFINED, "", MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
||||
private MMEPositions _userSetGUID = new MMEPositions(Guid.NewGuid().ToString(), UserSetKey, "(multiple)", "(multiple)", 1, DateTime.Now, DATAPRO_DEFINED, false, "", DateTime.Now,
|
||||
DATAPRO_DEFINED, "", MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
||||
public MMEPositions[] AvailableGroupPositions
|
||||
{
|
||||
get
|
||||
{
|
||||
var availableGroupPositions = new List<MMEPositions>();
|
||||
availableGroupPositions.Add(_channelDefaultsGUID);
|
||||
availableGroupPositions.AddRange(AvailablePositions);
|
||||
|
||||
return availableGroupPositions.ToArray();
|
||||
}
|
||||
}
|
||||
public TestTestObject(TestTestObject to)
|
||||
: base(to)
|
||||
{
|
||||
MetaCommonConstructor(to);
|
||||
}
|
||||
/// <summary>
|
||||
/// takes care of the meta data copy constructor items
|
||||
/// </summary>
|
||||
/// <param name="to"></param>
|
||||
private void MetaCommonConstructor(TestTestObject to)
|
||||
{
|
||||
ExcitationWarmupTimeMS = to.ExcitationWarmupTimeMS;
|
||||
TargetSampleRate = to.TargetSampleRate;
|
||||
PreTriggerSeconds = to.PreTriggerSeconds;
|
||||
PostTriggerSeconds = to.PostTriggerSeconds;
|
||||
_position = to._position;
|
||||
Position = to.Position;
|
||||
_testObject = to._testObject;
|
||||
SerialNumberConverted = to.SerialNumberConverted;
|
||||
SysBuilt = to.SysBuilt; //executed?
|
||||
ChannelTypesIndex = to.ChannelTypesIndex;
|
||||
}
|
||||
private int _excitationWarmupTime;
|
||||
public int ExcitationWarmupTimeMS
|
||||
{
|
||||
get => _excitationWarmupTime;
|
||||
set => SetProperty(ref _excitationWarmupTime, value, "ExcitationWarmupTimeMS");
|
||||
}
|
||||
private double _targetSampleRate;
|
||||
public double TargetSampleRate
|
||||
{
|
||||
get => _targetSampleRate;
|
||||
set => SetProperty(ref _targetSampleRate, value, "TargetSampleRate");
|
||||
}
|
||||
|
||||
private double _preTriggerSeconds;
|
||||
public double PreTriggerSeconds
|
||||
{
|
||||
get => _preTriggerSeconds;
|
||||
set => SetProperty(ref _preTriggerSeconds, value, "PreTriggerSeconds");
|
||||
}
|
||||
|
||||
private double _postTriggerSeconds;
|
||||
public double PostTriggerSeconds
|
||||
{
|
||||
get => _postTriggerSeconds;
|
||||
set => SetProperty(ref _postTriggerSeconds, value, "PostTriggerSeconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// we will want to remove or add hardware overriding what hardware would be in the test
|
||||
/// based solely on groups in the test
|
||||
/// this way we can have dasless groups
|
||||
/// </summary>
|
||||
public class HardwareInclusionInstruction
|
||||
{
|
||||
public string HardwareId { get; }
|
||||
|
||||
public enum Actions
|
||||
{
|
||||
Remove, //hardware may be included in test by a group, but ignore it and don't include the hardware...
|
||||
Add //hardware is not included in test by a group, but add it anyhow
|
||||
}
|
||||
|
||||
public Actions Action { get; }
|
||||
|
||||
public HardwareInclusionInstruction(string hardwareId, Actions action)
|
||||
{
|
||||
HardwareId = hardwareId;
|
||||
Action = action;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//using DTS.Common.Interface.Hardware;
|
||||
//using DTS.SensorDB;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public interface ICachedContainer
|
||||
{
|
||||
DASHardware GetCachedHardware(string serialNumber);
|
||||
IISOHardware[] GetAllCachedHardware();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
[Serializable]
|
||||
public class RegionOfInterest : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
public RegionOfInterest()
|
||||
{
|
||||
Suffix = string.Empty;
|
||||
Start = -1D;
|
||||
End = 1D;
|
||||
IsEnabled = true;
|
||||
IsDefault = true;
|
||||
}
|
||||
|
||||
public RegionOfInterest(bool isDefault = false)
|
||||
: this()
|
||||
{
|
||||
IsDefault = isDefault;
|
||||
}
|
||||
public RegionOfInterest(string suffix = "", bool isDefault = false, double start = -1D, double end = 1D)
|
||||
: this(isDefault)
|
||||
{
|
||||
Suffix = suffix;
|
||||
Start = start;
|
||||
End = end;
|
||||
}
|
||||
private string _suffix = string.Empty;
|
||||
public string Suffix
|
||||
{
|
||||
get => _suffix;
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(value) && !(value.StartsWith("_") && string.IsNullOrWhiteSpace(value.Substring(1))))
|
||||
{
|
||||
_suffix = value.StartsWith("_") ? value : "_" + value;
|
||||
}
|
||||
OnPropertyChanged("Suffix");
|
||||
}
|
||||
}
|
||||
|
||||
private double _start = double.MinValue;
|
||||
public double Start
|
||||
{
|
||||
get => _start;
|
||||
set
|
||||
{
|
||||
if (value >= End)
|
||||
{
|
||||
value = End - 0.01;
|
||||
}
|
||||
if (value < PreTrigger)
|
||||
{
|
||||
value = PreTrigger;
|
||||
}
|
||||
_start = value;
|
||||
OnPropertyChanged("Start");
|
||||
}
|
||||
}
|
||||
|
||||
private double _end = double.MaxValue;
|
||||
public double End
|
||||
{
|
||||
get => _end;
|
||||
set
|
||||
{
|
||||
if (value <= Start)
|
||||
{
|
||||
value = Start + 0.01;
|
||||
}
|
||||
if (value > PostTrigger)
|
||||
{
|
||||
value = PostTrigger;
|
||||
}
|
||||
_end = value; OnPropertyChanged("End");
|
||||
}
|
||||
}
|
||||
|
||||
private double _preTrigger = double.MinValue;
|
||||
public double PreTrigger
|
||||
{
|
||||
get => _preTrigger;
|
||||
set
|
||||
{
|
||||
_preTrigger = value;
|
||||
OnPropertyChanged("PreTrigger");
|
||||
if (Start < PreTrigger)
|
||||
{
|
||||
Start = PreTrigger;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private double _postTrigger = double.MaxValue;
|
||||
public double PostTrigger
|
||||
{
|
||||
get => _postTrigger;
|
||||
set
|
||||
{
|
||||
_postTrigger = value;
|
||||
OnPropertyChanged("PostTrigger");
|
||||
if (End > PostTrigger)
|
||||
{
|
||||
End = PostTrigger;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isEnabled = true;
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set { _isEnabled = value; OnPropertyChanged("IsEnabled"); }
|
||||
}
|
||||
|
||||
public bool IsDefault { get; private 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
@@ -0,0 +1,272 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class TestTemplateList //: BasePropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// this property is to hold a template in memory temporarily
|
||||
/// without committing it to the db, but to still act as if it is in the db
|
||||
/// </summary>
|
||||
public TestTemplate TemporaryTemplate { get; set; }
|
||||
public static SensorData GetSensorFromSettings(string settings, string serial, Dictionary<string, SensorData> lookup)
|
||||
{
|
||||
SensorData sd = null;
|
||||
if (null != lookup && lookup.ContainsKey(serial)) { sd = lookup[serial]; }
|
||||
if (null == sd) { sd = SensorsCollection.SensorsList.GetSensorBySerialNumber(serial); }
|
||||
|
||||
if (string.IsNullOrWhiteSpace(serial))
|
||||
{
|
||||
sd = new SensorData { SerialNumber = "" };
|
||||
}
|
||||
if (null == sd) { return null; }
|
||||
sd = new SensorData(sd);
|
||||
var tokens = settings.Split(',');
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
var subtokens = token.Split('=');
|
||||
var setting = (ISO.TestObject.SensorSettings)int.Parse(subtokens[0]);
|
||||
switch (setting)
|
||||
{
|
||||
case ISO.TestObject.SensorSettings.CFC:
|
||||
sd.FilterClassIso = subtokens[1];
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Position:
|
||||
sd.Position = subtokens[1];
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Polarity:
|
||||
sd.Invert = subtokens[1] == "-";
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Range:
|
||||
sd.Capacity = double.Parse(subtokens[1], System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Delay:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.DelayMS = double.Parse(subtokens[1], System.Globalization.CultureInfo.InvariantCulture); sd.DigitalOutputDelayMS = sd.DelayMS; }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Duration:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.DurationMS = double.Parse(subtokens[1], System.Globalization.CultureInfo.InvariantCulture); sd.DigitalOutputDurationMS = sd.DurationMS; }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.OutputMode:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.DigitalOutputMode = (DigitalOutputModes)Convert.ToInt32(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.SQMode:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.SquibFireMode = (SquibFireMode)Convert.ToInt32(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DIMode:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.InputMode = (DigitalInputModes)Convert.ToInt32(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.LimitDuration:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.LimitDuration = bool.Parse(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.ActiveValue:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.ScaleMultiplier.ActiveValue = Convert.ToDouble(subtokens[1]); }
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DefaultValue:
|
||||
if (!string.IsNullOrWhiteSpace(subtokens[1])) { sd.ScaleMultiplier.DefaultValue = Convert.ToDouble(subtokens[1]); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sd;
|
||||
}
|
||||
public static SensorData GetSensorFromSettings(string settings, string serial)
|
||||
{
|
||||
return GetSensorFromSettings(settings, serial, null);
|
||||
}
|
||||
public static string GetSensorSettings(SensorData sd)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var settings = Enum.GetValues(typeof(ISO.TestObject.SensorSettings)).Cast<ISO.TestObject.SensorSettings>().ToArray();
|
||||
var bNeedComma = false;
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
if (bNeedComma) { sb.Append(","); }
|
||||
bNeedComma = true;
|
||||
sb.AppendFormat("{0}=", (int)setting);
|
||||
switch (setting)
|
||||
{
|
||||
case ISO.TestObject.SensorSettings.CFC:
|
||||
sb.Append(sd.FilterClassIso);
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Position:
|
||||
sb.Append(sd.Position);
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Polarity:
|
||||
sb.Append(sd.Invert ? "-" : "+");
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Range:
|
||||
sb.Append(sd.Capacity.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.SQMode:
|
||||
sb.Append(((int)sd.SquibFireMode).ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.LimitDuration:
|
||||
sb.Append(sd.LimitDuration.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Duration:
|
||||
sb.Append(sd.DurationMS.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.OutputMode:
|
||||
sb.Append(((int)sd.DigitalOutputMode).ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.Delay:
|
||||
sb.Append(sd.DelayMS.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DIMode:
|
||||
sb.Append(((int)sd.InputMode).ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.DefaultValue:
|
||||
sb.Append(sd.ScaleMultiplier.DefaultValue.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case ISO.TestObject.SensorSettings.ActiveValue:
|
||||
sb.Append(
|
||||
sd.ScaleMultiplier.ActiveValue.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
private static TestTemplateList _list;
|
||||
private static readonly object OBJECT_LOCK = new object();
|
||||
public static TestTemplateList TestTemplatesList
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (OBJECT_LOCK)
|
||||
{
|
||||
if (null == _list) { _list = new TestTemplateList(); }
|
||||
}
|
||||
return _list;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reload()
|
||||
{
|
||||
lock (OBJECT_LOCK)
|
||||
{
|
||||
if (!(Application.Current is App app)) return;
|
||||
app.IsoDb.RefreshAllData();
|
||||
CustomChannelList.List.ReloadAll();
|
||||
SensorsCollection.SensorsList.Reload();
|
||||
SensorCalibrationList.Reload();
|
||||
DASHardwareList.GetList().ReloadAll();
|
||||
TestEngineerDetailsList.TestEngineerList.ReloadAll();
|
||||
TestObjectTemplateCollection.TemplateCollection.ReloadAll(false);
|
||||
TestObjectList.TestObjectsList.ReloadAll(false);
|
||||
Load();
|
||||
}
|
||||
}
|
||||
public static bool SysBuiltObject(string serialNumber)
|
||||
{
|
||||
var temp = false;
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TestObjectsGet.ToString();
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TestObjectName", SqlDbType.NVarChar, 50) { Value = serialNumber });
|
||||
cmd.Parameters.Add(new SqlParameter("@TemplateName", SqlDbType.NVarChar, 255) { Value = null });
|
||||
cmd.Parameters.Add(new SqlParameter("@SysBuilt", SqlDbType.Bit) { Value = null });
|
||||
|
||||
using (var ds2 = DbOperations.Connection.QueryDataSet(cmd))
|
||||
{
|
||||
if (ds2.Tables.Count <= 0 || ds2.Tables[0].Rows.Count <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach (DataRow row in ds2.Tables[0].Rows)
|
||||
{
|
||||
//really only 1 row
|
||||
temp = Convert.ToBoolean(row["SysBuilt"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
public static void ConvertToDictionary(DataTable dt, ref Dictionary<string, List<Dictionary<string, object>>> lookup, string key)
|
||||
{
|
||||
var count = dt.Columns.Count;
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
var thiskey = Convert.ToString(dr[key]);
|
||||
if (!lookup.ContainsKey(thiskey)) { lookup.Add(thiskey, new List<Dictionary<string, object>>()); }
|
||||
var properties = new Dictionary<string, object>(count);
|
||||
foreach (DataColumn c in dt.Columns)
|
||||
{
|
||||
properties[c.ColumnName] = dr[c.ColumnName];
|
||||
}
|
||||
lookup[thiskey].Add(properties);
|
||||
}
|
||||
}
|
||||
private void Load()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// deletes all test setups originally designed so TDM imports could clear all tables except DAS
|
||||
/// </summary>
|
||||
public void DeleteAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_TestSetupsDeleteAll.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
#region Output
|
||||
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@ErrorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
var errorSeverityParam =
|
||||
new SqlParameter("@ErrorSeverity", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorSeverityParam);
|
||||
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@ErrorState", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
|
||||
#endregion Output
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
if (DBNull.Value != errorNumberParam.Value)
|
||||
{
|
||||
var error = int.Parse(errorNumberParam.Value.ToString());
|
||||
if (error != 0)
|
||||
{
|
||||
var message = int.Parse(errorNumberParam.Value.ToString());
|
||||
var state = int.Parse(errorNumberParam.Value.ToString());
|
||||
//APILogger.Log(
|
||||
// $"Error:{Convert.ToString(error)}, State:{Convert.ToString(state)} Error: {message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { cmd.Connection.Dispose(); }
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to delete all test setups, ", ex);*/ }
|
||||
//Reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a lightweight version of test TestTemplate, holding just the essential information
|
||||
/// [updated]: this concept is already present in testtemplate,
|
||||
/// by default it only loads information in the tblTestSetup, and then uses the IsLoaded flag to
|
||||
/// check whether it's populated information from other tables or not.
|
||||
/// I'll leave the class here for now in case we want to expand on it in the future, also I cleaned up a few things in the process anyhow
|
||||
/// </summary>
|
||||
public class TestTemplateLite : ITestSetup
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
public RecordingModes RecordingMode { get; set; }
|
||||
private double _preTriggerSeconds;
|
||||
public double PreTriggerSeconds
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (RecordingMode)
|
||||
{
|
||||
case RecordingModes.Recorder:
|
||||
case RecordingModes.HybridRecorder:
|
||||
return 0D;
|
||||
case RecordingModes.CircularBuffer:
|
||||
return _preTriggerSeconds;
|
||||
default:
|
||||
return _preTriggerSeconds;
|
||||
}
|
||||
}
|
||||
set => _preTriggerSeconds = value;
|
||||
}
|
||||
|
||||
public string ErrorMessage { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// returns the error messages for a test setup
|
||||
/// calculated at the same time is complete is calculated, however doesn't have a check against
|
||||
/// is dirty, like IsComplete does ...
|
||||
/// </summary>
|
||||
public string CompletionErrorMessage => ErrorMessage.Length > 250 ? ErrorMessage.Substring(0, 250) : ErrorMessage;
|
||||
public double PostTriggerSeconds { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public string LastModifiedBy { get; set; }
|
||||
public bool IsComplete { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user