1709 lines
75 KiB
Plaintext
1709 lines
75 KiB
Plaintext
|
|
using DTS.Common.Converters;
|
||
|
|
using DTS.Common.Enums;
|
||
|
|
using DTS.Common.Enums.DASFactory;
|
||
|
|
using DTS.Common.Enums.Hardware;
|
||
|
|
using DTS.Common.Enums.Sensors;
|
||
|
|
using DTS.Common.Interface.DASFactory.Diagnostics;
|
||
|
|
using DTS.Common.Interface.DataRecorders;
|
||
|
|
using DTS.Common.Interface.Hardware.AddEditHardware;
|
||
|
|
using DTS.Common.Storage;
|
||
|
|
using DTS.Common.Utilities.Logging;
|
||
|
|
using HardwareList.Model;
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Collections.ObjectModel;
|
||
|
|
using System.Data;
|
||
|
|
using System.Data.SqlClient;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Windows.Media;
|
||
|
|
using System.Windows.Media.Imaging;
|
||
|
|
using AddEditHardware.Resources;
|
||
|
|
|
||
|
|
namespace AddEditHardware.Model
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// represents an object being operated on by the viewmodel
|
||
|
|
/// </summary>
|
||
|
|
public class Hardware : DTS.Common.Base.BasePropertyChanged, IAddEditHardwareHardware
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// returns the max sample rate for a SLICE1.5 given the number of attached modules
|
||
|
|
/// 17824 Manually creating a SLICE1.5 does not appear to have proper max sample rate
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="h"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
private static double GetSLICE15MaxSampleRate(int modules)
|
||
|
|
{
|
||
|
|
switch (modules)
|
||
|
|
{
|
||
|
|
case 0:
|
||
|
|
case 1:
|
||
|
|
return 500000;
|
||
|
|
case 2:
|
||
|
|
return 400000;
|
||
|
|
case 3:
|
||
|
|
return 300000;
|
||
|
|
default:
|
||
|
|
return 200000;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// returns the max sample rate for a SLICE1 given the number of attached
|
||
|
|
/// modules
|
||
|
|
/// 17824 Manually creating a SLICE1.5 does not appear to have proper max sample rate
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="h"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
private static double GetSLICE1MaxSampleRate(int modules)
|
||
|
|
{
|
||
|
|
return modules > 0 ? Convert.ToUInt32(120000 / modules) : 120000;
|
||
|
|
}
|
||
|
|
private bool _isAdd = true;
|
||
|
|
/// <summary>
|
||
|
|
/// indicates whether this record exists in the db or is a new entry
|
||
|
|
/// </summary>
|
||
|
|
public bool IsAdd
|
||
|
|
{
|
||
|
|
get => _isAdd;
|
||
|
|
set => SetProperty(ref _isAdd, value, "IsAdd");
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// the original dashardware if "Edit" was used
|
||
|
|
/// </summary>
|
||
|
|
public IDASHardware DASHardware { get; set; } = null;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// the original iso hardware if "Edit" was used
|
||
|
|
/// </summary>
|
||
|
|
public IISOHardware ISOHardware { get; set; } = null;
|
||
|
|
|
||
|
|
public bool RackFull => Modules.Count >= 8;
|
||
|
|
public bool Disabled { get; set; } = false;
|
||
|
|
public bool IsTSRAIR
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
switch (HardwareType)
|
||
|
|
{
|
||
|
|
case HardwareTypes.DIM:
|
||
|
|
case HardwareTypes.DKR:
|
||
|
|
case HardwareTypes.TSR_AIR:
|
||
|
|
case HardwareTypes.TSR_AIR_RevB:
|
||
|
|
return true;
|
||
|
|
default:
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public bool IsModule { get; set; } = false;
|
||
|
|
public ObservableCollection<IAddEditHardwareDASModule> Modules { get; set; } = new ObservableCollection<IAddEditHardwareDASModule>();
|
||
|
|
private RackSizes _rackSize = RackSizes.FOUR;
|
||
|
|
/// <summary>
|
||
|
|
/// the rack size of the das (if supported)
|
||
|
|
/// </summary>
|
||
|
|
public RackSizes RackSize
|
||
|
|
{
|
||
|
|
get => _rackSize;
|
||
|
|
set
|
||
|
|
{
|
||
|
|
if (value == RackSizes.FOUR && _rackSize == RackSizes.EIGHT)
|
||
|
|
{
|
||
|
|
while (Modules.Count > 4)
|
||
|
|
{
|
||
|
|
Modules.RemoveAt(4);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (value == RackSizes.EIGHT && _rackSize == RackSizes.FOUR)
|
||
|
|
{
|
||
|
|
while (Modules.Count < 8)
|
||
|
|
{
|
||
|
|
Modules.Add(new DASModule() { OwningHardware = this, ModuleType = HardwareTypes.UNDEFINED });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
SetProperty(ref _rackSize, value, "RackSize");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public bool SupportsConfiguration
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
return SupportsSLICEPROSIMConfiguration || SupportsSLICETCConfiguration;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// whether the das supports configuration or not
|
||
|
|
/// </summary>
|
||
|
|
public bool SupportsSLICEPROSIMConfiguration
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
switch (HardwareType)
|
||
|
|
{
|
||
|
|
case HardwareTypes.SLICE2_SIM:
|
||
|
|
return true;
|
||
|
|
default: return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// whether the das supports configuration or not
|
||
|
|
/// </summary>
|
||
|
|
public bool SupportsSLICETCConfiguration
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
switch (HardwareType)
|
||
|
|
{
|
||
|
|
case HardwareTypes.SLICE6_AIR_TC:
|
||
|
|
return true;
|
||
|
|
default: return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// whether the das supports using an ipaddress or not
|
||
|
|
/// </summary>
|
||
|
|
public bool SupportsIPAddress
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (StandIn)
|
||
|
|
{
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
switch (HardwareType)
|
||
|
|
{
|
||
|
|
case HardwareTypes.SLICE_Distributor:
|
||
|
|
case HardwareTypes.TDAS_Pro_Rack:
|
||
|
|
case HardwareTypes.G5VDS:
|
||
|
|
case HardwareTypes.G5INDUMMY:
|
||
|
|
case HardwareTypes.SLICE_EthernetController:
|
||
|
|
case HardwareTypes.SLICE_Mini_Distributor:
|
||
|
|
case HardwareTypes.SLICE_LabEthernet:
|
||
|
|
case HardwareTypes.TDAS_LabRack:
|
||
|
|
case HardwareTypes.SLICE6_Base:
|
||
|
|
case HardwareTypes.SLICE6DB:
|
||
|
|
case HardwareTypes.SLICE6DB3:
|
||
|
|
case HardwareTypes.SLICE_Pro_Distributor:
|
||
|
|
case HardwareTypes.SLICE6DB_InDummy:
|
||
|
|
// case HardwareTypes.SLICE6DB_AIR:
|
||
|
|
case HardwareTypes.SLICE6_AIR:
|
||
|
|
case HardwareTypes.SLICE6_AIR_BR:
|
||
|
|
case HardwareTypes.S6A_EthernetRecorder:
|
||
|
|
case HardwareTypes.PowerPro:
|
||
|
|
case HardwareTypes.TSR_AIR:
|
||
|
|
case HardwareTypes.TSR_AIR_RevB:
|
||
|
|
case HardwareTypes.SLICE6_AIR_TC:
|
||
|
|
return true;
|
||
|
|
default:
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private HardwareTypes _hardwareType = HardwareTypes.SLICE2_SIM;
|
||
|
|
/// <summary>
|
||
|
|
/// the type of das
|
||
|
|
/// </summary>
|
||
|
|
public HardwareTypes HardwareType
|
||
|
|
{
|
||
|
|
get => _hardwareType;
|
||
|
|
set
|
||
|
|
{
|
||
|
|
SetProperty(ref _hardwareType, value, "HardwareType");
|
||
|
|
OnPropertyChanged("SupportsRackSize");
|
||
|
|
OnPropertyChanged("SupportsSLICEPROSIMConfiguration");
|
||
|
|
OnPropertyChanged("SupportsSLICETCConfiguration");
|
||
|
|
OnPropertyChanged("SupportsConfiguration");
|
||
|
|
OnPropertyChanged("SupportsIPAddress");
|
||
|
|
HardwareTypeChanged();
|
||
|
|
SetImage();
|
||
|
|
DetermineShowTreeView();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void HardwareTypeChanged()
|
||
|
|
{
|
||
|
|
switch (HardwareType)
|
||
|
|
{
|
||
|
|
case HardwareTypes.SLICE1_5_Micro_Base:
|
||
|
|
case HardwareTypes.SLICE1_5_Nano_Base:
|
||
|
|
case HardwareTypes.SLICE_Micro_Base:
|
||
|
|
case HardwareTypes.SLICE_NANO_Base:
|
||
|
|
Modules.Clear();
|
||
|
|
for (var i = 0; i < 8; i++)
|
||
|
|
{
|
||
|
|
Modules.Add(new DASModule()
|
||
|
|
{
|
||
|
|
ModuleType = HardwareTypes.SLICE_Bridge,
|
||
|
|
SLICEBridgeType = SLICEBridgeTypes.Bridge,
|
||
|
|
OwningHardware = this
|
||
|
|
});
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case HardwareTypes.TDAS_LabRack:
|
||
|
|
Modules.Clear();
|
||
|
|
for (var i = 0; i < 6; i++)
|
||
|
|
{
|
||
|
|
Modules.Add(new DASModule() { ModuleType = HardwareTypes.UNDEFINED, OwningHardware = this });
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case HardwareTypes.TDAS_Pro_Rack:
|
||
|
|
Modules.Clear();
|
||
|
|
var numModules = 4;
|
||
|
|
if (RackSize == RackSizes.EIGHT)
|
||
|
|
{
|
||
|
|
numModules = 8;
|
||
|
|
}
|
||
|
|
|
||
|
|
for (var i = 0; i < numModules; i++)
|
||
|
|
{
|
||
|
|
Modules.Add(new DASModule() { ModuleType = HardwareTypes.UNDEFINED, OwningHardware = this });
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
OnPropertyChanged("RackFull");
|
||
|
|
}
|
||
|
|
private string _serialNumber;
|
||
|
|
/// <summary>
|
||
|
|
/// the serial number of the das
|
||
|
|
/// </summary>
|
||
|
|
public string SerialNumber
|
||
|
|
{
|
||
|
|
get => _serialNumber;
|
||
|
|
set => SetProperty(ref _serialNumber, value, "SerialNumber");
|
||
|
|
}
|
||
|
|
|
||
|
|
private string _firmwareVersion;
|
||
|
|
/// <summary>
|
||
|
|
/// the firmware version of the das (if supported)
|
||
|
|
/// </summary>
|
||
|
|
public string FirmwareVersion
|
||
|
|
{
|
||
|
|
get => _firmwareVersion;
|
||
|
|
set => SetProperty(ref _firmwareVersion, value, "FirmwareVersion");
|
||
|
|
}
|
||
|
|
|
||
|
|
private string _ipAddress = "";
|
||
|
|
/// <summary>
|
||
|
|
/// the ipaddress of the das (if supported)
|
||
|
|
/// </summary>
|
||
|
|
public string IPAddress
|
||
|
|
{
|
||
|
|
get => _ipAddress;
|
||
|
|
set => SetProperty(ref _ipAddress, value, "IPAddress");
|
||
|
|
}
|
||
|
|
|
||
|
|
private bool _standIn = true;
|
||
|
|
/// <summary>
|
||
|
|
/// whether the unit is an actual physical piece of hardware, or a stand-in/dummy piece of hardware
|
||
|
|
/// </summary>
|
||
|
|
public bool StandIn
|
||
|
|
{
|
||
|
|
get => _standIn;
|
||
|
|
set
|
||
|
|
{
|
||
|
|
SetProperty(ref _standIn, value, "StandIn");
|
||
|
|
OnPropertyChanged("SupportsIPAddress");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// whether the das supports rack sizes
|
||
|
|
/// </summary>
|
||
|
|
public bool SupportsRackSize
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
switch (HardwareType)
|
||
|
|
{
|
||
|
|
case HardwareTypes.TDAS_Pro_Rack:
|
||
|
|
return true;
|
||
|
|
default:
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private SLICEPROSIMConfigurations _slicePROSIMConfiguration = SLICEPROSIMConfigurations.SIX_HUNDRED;
|
||
|
|
/// <summary>
|
||
|
|
/// the configuration of the das (if supported)
|
||
|
|
/// </summary>
|
||
|
|
public SLICEPROSIMConfigurations SLICEPROSIMConfiguration
|
||
|
|
{
|
||
|
|
get => _slicePROSIMConfiguration;
|
||
|
|
set { SetProperty(ref _slicePROSIMConfiguration, value, "SLICEPROSIMConfiguration"); }
|
||
|
|
}
|
||
|
|
|
||
|
|
private SLICETCConfigurations _sliceTCConfiguration = SLICETCConfigurations.TWENTYFOUR;
|
||
|
|
/// <summary>
|
||
|
|
/// the configuration of the das (if supported)
|
||
|
|
/// </summary>
|
||
|
|
public SLICETCConfigurations SLICETCConfiguration
|
||
|
|
{
|
||
|
|
get => _sliceTCConfiguration;
|
||
|
|
set { SetProperty(ref _sliceTCConfiguration, value, "SLICETCConfiguration"); }
|
||
|
|
}
|
||
|
|
|
||
|
|
private ImageSource _image = null;
|
||
|
|
/// <summary>
|
||
|
|
/// the image of the das
|
||
|
|
/// </summary>
|
||
|
|
public ImageSource DASImage
|
||
|
|
{
|
||
|
|
get => _image;
|
||
|
|
set => SetProperty(ref _image, value, "DASImage");
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// uri for finding images using the application resources
|
||
|
|
/// </summary>
|
||
|
|
private static readonly Uri _baseUri = new Uri("pack://application:,,,/ResourceFile.xaml");
|
||
|
|
|
||
|
|
private const string SLICE6DB3ImagePath = "Assets/Hardware/SLICE6Db3.png";
|
||
|
|
/// <summary>
|
||
|
|
/// returns an image resource path given a type of hardware
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="hw"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
private static string GetImage(HardwareTypes hw)
|
||
|
|
{
|
||
|
|
var image = "";
|
||
|
|
switch (hw)
|
||
|
|
{
|
||
|
|
case HardwareTypes.TOM: image = "Assets/Hardware/TDAS_TOM_Front.jpg"; break;
|
||
|
|
case HardwareTypes.SIM: image = "Assets/Hardware/TDAS_SIM_Front.jpg"; break;
|
||
|
|
case HardwareTypes.SLICE1_G5Stack: image = "Assets/Hardware/SLICE_G5_Angle.jpg"; break;
|
||
|
|
case HardwareTypes.G5INDUMMY: image = "Assets/Hardware/TDAS_G5_Angle.jpg"; break;
|
||
|
|
case HardwareTypes.G5VDS: image = "Assets/Hardware/G5 Docking Station - retouched.jpg"; break;
|
||
|
|
case HardwareTypes.DIM: image = "Assets/Hardware/TDAS_DIM_Front.jpg"; break;
|
||
|
|
case HardwareTypes.TDAS_Pro_Rack: image = "Assets/Hardware/TDAS_Rack_4M8M_Angle.jpg"; break;
|
||
|
|
case HardwareTypes.RibeyeLED: image = "Assets/LightGray.png"; break;
|
||
|
|
case HardwareTypes.Ribeye: image = "Assets/LightGray.png"; break;
|
||
|
|
case HardwareTypes.SLICE2_IEPE_Lo: image = "Assets/Hardware/SLICE_PRO_Angle.jpg"; break;
|
||
|
|
case HardwareTypes.SLICE2_IEPE_Hi: image = "Assets/Hardware/SLICE_PRO_Angle.jpg"; break;
|
||
|
|
case HardwareTypes.SLICE2_Bridge_Lo: image = "Assets/Hardware/SLICE_PRO_Angle.jpg"; break;
|
||
|
|
case HardwareTypes.SLICE2_Bridge_Hi: image = "Assets/Hardware/SLICE_PRO_Angle.jpg"; break;
|
||
|
|
|
||
|
|
case HardwareTypes.TDAS_LabRack:
|
||
|
|
image = "Assets/Hardware/LAB Rack - retouched.jpg";
|
||
|
|
break;
|
||
|
|
|
||
|
|
case HardwareTypes.SLICE2_DIM:
|
||
|
|
image = "Assets/Hardware/SLICE PRO DIM_removed.png";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE2_SLD:
|
||
|
|
image = "Assets/Hardware/SLICE_LAB_DIM.jpg";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE2_SLS:
|
||
|
|
image = "Assets/Hardware/SLICE_PRO_SLS_Angle.jpg";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE2_SIM:
|
||
|
|
image = "Assets/Hardware/SLICE_PRO_Angle.jpg";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE2_TOM:
|
||
|
|
image = "Assets/Hardware/SLICE PRO TOM_removed.png";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE2_SLT:
|
||
|
|
image = "Assets/Hardware/SLICE_LAB_TOM.jpg";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE1_5_Nano_Base:
|
||
|
|
image = "Assets/Hardware/SLICE_1_5_NANO_Angle.jpg";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE1_5_Micro_Base:
|
||
|
|
image = "Assets/Hardware/SLICE_1_5_MICRO_Angle.jpg";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE_IEPE: image = "Assets/Hardware/SLICE_1_NANO_BRIDGE_Connctor_Angle.jpg"; break;
|
||
|
|
case HardwareTypes.SLICE_Distributor: image = "Assets/Hardware/SLICE_1_DB_Angle.jpg"; break;
|
||
|
|
case HardwareTypes.SLICE_Bridge: image = "Assets/Hardware/SLICE_1_NANO_BRIDGE_Connctor_Angle.jpg"; break;
|
||
|
|
|
||
|
|
case HardwareTypes.SLICE_Base:
|
||
|
|
case HardwareTypes.SLICE_NANO_Base:
|
||
|
|
image = "Assets/Hardware/SLICE_Base_NANO_Angle.jpg";
|
||
|
|
break;
|
||
|
|
|
||
|
|
case HardwareTypes.SLICE_LabEthernet:
|
||
|
|
image = "Assets/Hardware/SLICE PRO Lab ECM.png";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE_Micro_Base: image = "Assets/Hardware/SLICE_Base_MICRO_Angle.jpg"; break;
|
||
|
|
case HardwareTypes.SLICE_EthernetController:
|
||
|
|
image = "Assets/Hardware/SLICE PRO ECM_removed.png";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE_Mini_Distributor:
|
||
|
|
image = "Assets/Hardware/SLICE_Mini_DB_Angle.jpg";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6DB:
|
||
|
|
image = "Assets/Hardware/SLICE6Db.png";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE_Pro_Distributor:
|
||
|
|
image = "Assets/Hardware/SLICEPRODb.png";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6DB3:
|
||
|
|
image = SLICE6DB3ImagePath;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6DB_InDummy:
|
||
|
|
image = "Assets/Hardware/SLICE6Db.png";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6_Base:
|
||
|
|
image = "Assets/Hardware/SLICE6 Base.png";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6_AIR:
|
||
|
|
case HardwareTypes.S6A_EthernetRecorder:
|
||
|
|
image = "Assets/Hardware/SLICE6 AIR.png";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6_AIR_BR:
|
||
|
|
image = "Assets/Hardware/SLICE6_AIR_BR.png";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.PowerPro:
|
||
|
|
image = "Assets/Hardware/PowerPro.jpg";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.TSR_AIR:
|
||
|
|
case HardwareTypes.TSR_AIR_RevB:
|
||
|
|
image = "Assets/Hardware/TSRAIR.png";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.DKR:
|
||
|
|
image = "Assets/Hardware/DKR-ISO.jpg";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.DIR:
|
||
|
|
image = "Assets/Hardware/DIR-ISO.jpg";
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6_AIR_TC:
|
||
|
|
image = "Assets/Hardware/SLICETC_CAD_Small.png"; ////////////////////////temp
|
||
|
|
break;
|
||
|
|
default: break;
|
||
|
|
}
|
||
|
|
return image;
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// sets the image property for the das
|
||
|
|
/// </summary>
|
||
|
|
private void SetImage()
|
||
|
|
{
|
||
|
|
var filename = GetImage(HardwareType);
|
||
|
|
try
|
||
|
|
{
|
||
|
|
var image = new BitmapImage(new Uri(_baseUri, filename));
|
||
|
|
image.Freeze();
|
||
|
|
DASImage = image;
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
APILogger.Log(
|
||
|
|
$"Failed to get image: {filename} for type: {HardwareType.ToString()} exception: {ex.Message.ToString()}");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public Hardware()
|
||
|
|
{
|
||
|
|
SetImage();
|
||
|
|
IsAdd = true;
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// determines whether the SLICE6TreeView should be shown or not
|
||
|
|
/// </summary>
|
||
|
|
private void DetermineShowTreeView()
|
||
|
|
{
|
||
|
|
if (IsAdd)
|
||
|
|
{
|
||
|
|
ShowTreeView = false;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
switch (HardwareType)
|
||
|
|
{
|
||
|
|
case HardwareTypes.SLICE6DB:
|
||
|
|
case HardwareTypes.SLICE6DB_InDummy:
|
||
|
|
case HardwareTypes.SLICE6DB3:
|
||
|
|
ShowTreeView = true;
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
ShowTreeView = false;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private bool _showTreeView;
|
||
|
|
/// <summary>
|
||
|
|
/// controls whether to show the treeview or not
|
||
|
|
/// </summary>
|
||
|
|
public bool ShowTreeView
|
||
|
|
{
|
||
|
|
get => _showTreeView;
|
||
|
|
set => SetProperty(ref _showTreeView, value, "ShowTreeView");
|
||
|
|
}
|
||
|
|
public Hardware(IDASHardware hw, IISOHardware isoHW)
|
||
|
|
{
|
||
|
|
HardwareType = isoHW.DASTypeEnum;
|
||
|
|
SerialNumber = isoHW.SerialNumber;
|
||
|
|
StandIn = isoHW.StandIn;
|
||
|
|
FirmwareVersion = isoHW.FirmwareVersion;
|
||
|
|
IPAddress = isoHW.IPAddress;
|
||
|
|
SetModulesFromChannels(hw, isoHW);
|
||
|
|
ISOHardware = isoHW;
|
||
|
|
if (hw.IsTDASRack())
|
||
|
|
{
|
||
|
|
if (isoHW.DASTypeEnum != HardwareTypes.TDAS_LabRack)
|
||
|
|
{
|
||
|
|
switch (isoHW.MaxModules)
|
||
|
|
{
|
||
|
|
case 8:
|
||
|
|
RackSize = RackSizes.EIGHT;
|
||
|
|
break;
|
||
|
|
case 4:
|
||
|
|
default:
|
||
|
|
RackSize = RackSizes.FOUR;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
SetImage();
|
||
|
|
IsAdd = false;
|
||
|
|
DetermineShowTreeView();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void SetSLICEConfiguration(IDASHardware hw)
|
||
|
|
{
|
||
|
|
var channels = hw.GetIHardwareChannels();
|
||
|
|
|
||
|
|
if (channels.Length >= 18)
|
||
|
|
{
|
||
|
|
SLICEPROSIMConfiguration = SLICEPROSIMConfigurations.SIX_HUNDRED;
|
||
|
|
}
|
||
|
|
else if (channels.Length >= 15)
|
||
|
|
{
|
||
|
|
SLICEPROSIMConfiguration = SLICEPROSIMConfigurations.SEVEN_HUNDRED;
|
||
|
|
}
|
||
|
|
else if (channels.Length >= 12)
|
||
|
|
{
|
||
|
|
SLICEPROSIMConfiguration = SLICEPROSIMConfigurations.EIGHT_HUNDRED;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
SLICEPROSIMConfiguration = SLICEPROSIMConfigurations.MEGA;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private void SetSLICETCConfiguration(IDASHardware hw)
|
||
|
|
{
|
||
|
|
var channels = hw.GetIHardwareChannels();
|
||
|
|
|
||
|
|
if (channels.Length >= 24)
|
||
|
|
{
|
||
|
|
SLICETCConfiguration = SLICETCConfigurations.TWENTYFOUR;
|
||
|
|
}
|
||
|
|
else if (channels.Length >= 16)
|
||
|
|
{
|
||
|
|
SLICETCConfiguration = SLICETCConfigurations.SIXTEEN;
|
||
|
|
}
|
||
|
|
else if (channels.Length >= 8)
|
||
|
|
{
|
||
|
|
SLICETCConfiguration = SLICETCConfigurations.EIGHT;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private void SetModulesFromChannels(IDASHardware hw, IISOHardware isoHW)
|
||
|
|
{
|
||
|
|
var hwtype = isoHW.DASTypeEnum;
|
||
|
|
switch (hwtype)
|
||
|
|
{
|
||
|
|
case HardwareTypes.SLICE2_SIM:
|
||
|
|
SetSLICEConfiguration(hw);
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6_AIR_TC:
|
||
|
|
SetSLICETCConfiguration(hw);
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE1_5_Micro_Base:
|
||
|
|
case HardwareTypes.SLICE1_5_Nano_Base:
|
||
|
|
case HardwareTypes.SLICE_NANO_Base:
|
||
|
|
case HardwareTypes.SLICE_Micro_Base:
|
||
|
|
SetSLICEModulesFromChannels(hw);
|
||
|
|
break;
|
||
|
|
case HardwareTypes.TDAS_LabRack:
|
||
|
|
case HardwareTypes.TDAS_Pro_Rack:
|
||
|
|
SetTDASModulesFromChannels(hw, isoHW);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
private void SetTDASModulesFromChannels(IDASHardware hw, IISOHardware isoHW)
|
||
|
|
{
|
||
|
|
var currentChannel = 0;
|
||
|
|
|
||
|
|
var channels = hw.GetIHardwareChannels();
|
||
|
|
Modules.Clear();
|
||
|
|
while (currentChannel < channels.Length)
|
||
|
|
{
|
||
|
|
//try to guess the module based on the channel type
|
||
|
|
//if Squib, then it's a TOM, if it's a digital input, it's a DIM,
|
||
|
|
//if it's a anlog, it's a sim - note that g5s are handled separately, this is only racks ...
|
||
|
|
var channel = channels[currentChannel];
|
||
|
|
var module = new DASModule() { OwningHardware = this, SerialNumber = channel.ModuleSerialNumber };
|
||
|
|
|
||
|
|
if (channel.IsSupportedBridgeType(SensorConstants.BridgeType.SQUIB))
|
||
|
|
{//TOM
|
||
|
|
currentChannel += 16;
|
||
|
|
module.ModuleType = HardwareTypes.TOM;
|
||
|
|
}
|
||
|
|
else if (channel.IsSupportedBridgeType(SensorConstants.BridgeType.DigitalInput))
|
||
|
|
{//DIM
|
||
|
|
currentChannel += 16;
|
||
|
|
module.ModuleType = HardwareTypes.DIM;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{//SIM
|
||
|
|
currentChannel += 8;
|
||
|
|
module.ModuleType = HardwareTypes.SIM;
|
||
|
|
}
|
||
|
|
|
||
|
|
Modules.Add(module);
|
||
|
|
}
|
||
|
|
|
||
|
|
for (var i = Modules.Count; i < isoHW.MaxModules; i++)
|
||
|
|
{
|
||
|
|
Modules.Add(new DASModule() { OwningHardware = this, ModuleType = HardwareTypes.UNDEFINED });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private void SetSLICEModulesFromChannels(IDASHardware hw)
|
||
|
|
{
|
||
|
|
var channels = hw.GetIHardwareChannels();
|
||
|
|
Modules.Clear();
|
||
|
|
for (var i = 0; i < channels.Length; i += 3)
|
||
|
|
{
|
||
|
|
var ch = channels[i];
|
||
|
|
var module = new DASModule() { OwningHardware = this, ModuleType = HardwareTypes.SLICE_Bridge };
|
||
|
|
module.SerialNumber = ch.ModuleSerialNumber;
|
||
|
|
if (ch.IsSupportedBridgeType(SensorConstants.BridgeType.IEPE))
|
||
|
|
{
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.IEPE;
|
||
|
|
}
|
||
|
|
else if (ch.IsSupportedBridgeType(SensorConstants.BridgeType.RTC))
|
||
|
|
{
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.RTC;
|
||
|
|
}
|
||
|
|
else if (ch.IsSupportedBridgeType(SensorConstants.BridgeType.UART))
|
||
|
|
{
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.UART;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
if (ch.ModuleSerialNumber.StartsWith("BR")) { module.SLICEBridgeType = SLICEBridgeTypes.Bridge; }
|
||
|
|
else if (ch.ModuleSerialNumber.StartsWith("AC")) { module.SLICEBridgeType = SLICEBridgeTypes.ACC; }
|
||
|
|
else if (ch.ModuleSerialNumber.StartsWith("AR")) { module.SLICEBridgeType = SLICEBridgeTypes.ARS; }
|
||
|
|
else
|
||
|
|
{
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.Bridge;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
Modules.Add(module);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public void RemoveModule(IAddEditHardwareDASModule module)
|
||
|
|
{
|
||
|
|
Modules.Remove(module);
|
||
|
|
OnPropertyChanged("RackFull");
|
||
|
|
}
|
||
|
|
|
||
|
|
public void AddModule()
|
||
|
|
{
|
||
|
|
Modules.Insert(0, new DASModule()
|
||
|
|
{
|
||
|
|
OwningHardware = this,
|
||
|
|
SLICEBridgeType = SLICEBridgeTypes.Bridge,
|
||
|
|
ModuleType = HardwareTypes.SLICE_Bridge
|
||
|
|
});
|
||
|
|
OnPropertyChanged("RackFull");
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// creates an IISOHardware object representing this hardware
|
||
|
|
/// </summary>
|
||
|
|
/// <returns></returns>
|
||
|
|
public IISOHardware ToISOHardware()
|
||
|
|
{
|
||
|
|
if (null == ISOHardware)
|
||
|
|
{
|
||
|
|
return GetISOHardware(null);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (ISOHardware.SerialNumber == SerialNumber)
|
||
|
|
{
|
||
|
|
return GetUpdatedISOHardware(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
return GetISOHardware(ISOHardware);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// updates the iso hardware object associated with fields from hardware object
|
||
|
|
/// including channels
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="hardware"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
private DTS.Common.ISO.Hardware GetUpdatedISOHardware(Hardware source)
|
||
|
|
{
|
||
|
|
var hardware = GetISOHardware(source.ISOHardware);
|
||
|
|
hardware.DASId = source.ISOHardware.DASId;
|
||
|
|
System.Diagnostics.Trace.WriteLine($"DASId is {hardware.DASId}");
|
||
|
|
return hardware;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// creates and returns a new ISO hardware object from hardware object
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="source">optional hardware object to take defaults from</param>
|
||
|
|
/// <returns></returns>
|
||
|
|
private DTS.Common.ISO.Hardware GetISOHardware(IISOHardware source = null)
|
||
|
|
{
|
||
|
|
//get default configuration from the prototype
|
||
|
|
var hardware = ReconfigureFromPrototype();
|
||
|
|
if (hardware != null)
|
||
|
|
{
|
||
|
|
hardware.Position = string.Empty;
|
||
|
|
if (hardware.DASTypeEnum == HardwareTypes.SLICE2_Base)
|
||
|
|
{
|
||
|
|
hardware.DASTypeEnum = HardwareTypes.SLICE2_SIM;
|
||
|
|
}
|
||
|
|
//wipe out the das id, it currently points to prototype
|
||
|
|
hardware.DASId = -1;
|
||
|
|
//reassign modules/channels as needed for racks/configurable devices
|
||
|
|
hardware.SerialNumber = SerialNumber;
|
||
|
|
ReconfigureISOHardware(hardware);
|
||
|
|
//finally if we have a source, copy the caldate/firmware/other data from the source
|
||
|
|
if (null != source)
|
||
|
|
{
|
||
|
|
hardware.CalDate = source.CalDate;
|
||
|
|
hardware.FirmwareVersion = source.FirmwareVersion;
|
||
|
|
hardware.FirstUseDate = source.FirstUseDate;
|
||
|
|
hardware.IsFirstUseValid = source.IsFirstUseValid;
|
||
|
|
}
|
||
|
|
hardware.IPAddress = IPAddress;
|
||
|
|
hardware.StandIn = StandIn;
|
||
|
|
if (hardware.IsTSRAIRModule())
|
||
|
|
{
|
||
|
|
hardware.IsModule = true;
|
||
|
|
}
|
||
|
|
if (!StandIn && null != FirmwareVersion)
|
||
|
|
{
|
||
|
|
hardware.FirmwareVersion = FirmwareVersion;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return hardware;
|
||
|
|
}
|
||
|
|
|
||
|
|
private DTS.Common.ISO.Hardware ReconfigureFromPrototype()
|
||
|
|
{
|
||
|
|
var key = string.Empty;
|
||
|
|
try
|
||
|
|
{
|
||
|
|
switch (HardwareType)
|
||
|
|
{
|
||
|
|
case HardwareTypes.SLICE_Distributor: key = DbOperations.DAS.SDB_PROTOTYPE; break;
|
||
|
|
case HardwareTypes.TDAS_Pro_Rack:
|
||
|
|
if (RackSize == RackSizes.EIGHT) { key = DbOperations.DAS.TDASPRO_8MRack; }
|
||
|
|
else { key = DbOperations.DAS.TDASPRO_4MRack; }
|
||
|
|
break;
|
||
|
|
case HardwareTypes.G5VDS:
|
||
|
|
key = DbOperations.DAS.G5_VDSPROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE1_5_Nano_Base:
|
||
|
|
key = DbOperations.DAS.SLICE1_5PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE_Micro_Base:
|
||
|
|
key = DbOperations.DAS.Slice_MicroPROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE_NANO_Base:
|
||
|
|
key = DbOperations.DAS.Slice_NanoPROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE2_SIM:
|
||
|
|
key = DbOperations.DAS.SLICEPROSIM_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE2_DIM:
|
||
|
|
key = DbOperations.DAS.SLICEPRODIM_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE2_TOM:
|
||
|
|
key = DbOperations.DAS.SLICEPROTOM_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.G5INDUMMY:
|
||
|
|
key = DbOperations.DAS.G5_INDUMMYPROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE_EthernetController:
|
||
|
|
key = DbOperations.DAS.ECM_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
//FB 16148 Simiulate ECM
|
||
|
|
case HardwareTypes.SLICE_Mini_Distributor:
|
||
|
|
key = DbOperations.DAS.SPM_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE1_5_Micro_Base:
|
||
|
|
key = DbOperations.DAS.SLICE1_5_MicroPROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE_LabEthernet:
|
||
|
|
key = DbOperations.DAS.SLE_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE2_SLS:
|
||
|
|
key = DbOperations.DAS.SLICEPROSLS_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE1_G5Stack:
|
||
|
|
key = DbOperations.DAS.SG5_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE2_SLT:
|
||
|
|
key = DbOperations.DAS.SLICEPROSLT_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE2_SLD:
|
||
|
|
key = DbOperations.DAS.SLICEPROSLD_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.TDAS_LabRack:
|
||
|
|
key = DbOperations.DAS.TDASPRO_LabRack;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6_Base:
|
||
|
|
key = DbOperations.DAS.SLICE6_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE_Pro_Distributor:
|
||
|
|
key = DbOperations.DAS.SLICEPRO_DB_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6DB:
|
||
|
|
key = DbOperations.DAS.SLICE6DB_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6DB3:
|
||
|
|
key = DbOperations.DAS.SLICE6DB3_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6DB_InDummy:
|
||
|
|
key = DbOperations.DAS.SLICE6DB_INDUMMY_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
//case HardwareTypes.SLICE6DB_AIR:
|
||
|
|
// key = DbOperations.DAS.SLICE6DB_AIR_PROTOTYPE;
|
||
|
|
// break;
|
||
|
|
case HardwareTypes.SLICE6_AIR:
|
||
|
|
key = DbOperations.DAS.SLICE6_AIR_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.S6A_EthernetRecorder:
|
||
|
|
key = DbOperations.DAS.SLICE6_AIR_ER_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6_AIR_BR:
|
||
|
|
key = DbOperations.DAS.SLICE6_AIR_BR_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.PowerPro:
|
||
|
|
key = DbOperations.DAS.POWERPRO_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.TSR_AIR:
|
||
|
|
key = DbOperations.DAS.TSR_AIR_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.TSR_AIR_RevB:
|
||
|
|
key = DbOperations.DAS.TSR_AIR_REVB_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.DKR:
|
||
|
|
key = DbOperations.DAS.DKR_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.DIR:
|
||
|
|
key = DbOperations.DAS.DIR_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.EMB_LIN_ACC_LO:
|
||
|
|
key = DbOperations.DAS.EMB_LIN_ACC_LO_MODULE_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.EMB_LIN_ACC_HI:
|
||
|
|
key = DbOperations.DAS.EMB_LIN_ACC_HI_MODULE_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.EMB_ANG_ARS:
|
||
|
|
key = DbOperations.DAS.EMB_ARS_MODULE_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.EMB_ATM:
|
||
|
|
key = DbOperations.DAS.EMB_ATM_MODULE_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6_AIR_TC:
|
||
|
|
key = DbOperations.DAS.SLICE_TC_PROTOTYPE;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!string.IsNullOrEmpty(key))
|
||
|
|
{
|
||
|
|
key = $"{key}_{(int)HardwareType}";
|
||
|
|
|
||
|
|
var matches = DTS.Common.ISO.Hardware.GetAllDAS(key, DbOperations.DAS.PROTOTYPE_POSITION);
|
||
|
|
if (matches.Any())
|
||
|
|
{
|
||
|
|
return matches[0];
|
||
|
|
}
|
||
|
|
//Any databases migrated from 3.3 have "Falcon Prototype" instead of "SLICE6 Falcon Prototype"
|
||
|
|
//in the DAS table, so try the former if the latter has failed.
|
||
|
|
else if (key.StartsWith(DbOperations.DAS.SLICE6_AIR_BR_PROTOTYPE))
|
||
|
|
{
|
||
|
|
key = key.Remove(0, "SLICE6 ".Length);
|
||
|
|
matches = DTS.Common.ISO.Hardware.GetAllDAS(key, DbOperations.DAS.PROTOTYPE_POSITION);
|
||
|
|
if (matches.Any())
|
||
|
|
{
|
||
|
|
return matches[0];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
APILogger.Log(ex);
|
||
|
|
throw new NotSupportedException(
|
||
|
|
$"Unsupported hardware prototype: {HardwareType.ToString()} - {ex.Message}");
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// takes the current configuration as determined by the UI, and creates the appropriate channels in the _hardware (ISODll.Hardware) object
|
||
|
|
/// </summary>
|
||
|
|
private void ReconfigureISOHardware(DTS.Common.ISO.Hardware hardware)
|
||
|
|
{
|
||
|
|
switch (HardwareType)
|
||
|
|
{
|
||
|
|
case HardwareTypes.G5VDS:
|
||
|
|
case HardwareTypes.G5INDUMMY:
|
||
|
|
case HardwareTypes.SLICE2_Base:
|
||
|
|
case HardwareTypes.SLICE2_SLS:
|
||
|
|
case HardwareTypes.SLICE2_DIM:
|
||
|
|
case HardwareTypes.SLICE2_TOM:
|
||
|
|
case HardwareTypes.SLICE2_SLT:
|
||
|
|
case HardwareTypes.SLICE2_SLD:
|
||
|
|
case HardwareTypes.SLICE_Distributor:
|
||
|
|
case HardwareTypes.SLICE_EthernetController:
|
||
|
|
case HardwareTypes.SLICE_Mini_Distributor:
|
||
|
|
case HardwareTypes.SLICE6DB:
|
||
|
|
case HardwareTypes.SLICE_Pro_Distributor:
|
||
|
|
case HardwareTypes.SLICE6DB3:
|
||
|
|
case HardwareTypes.SLICE6DB_InDummy:
|
||
|
|
case HardwareTypes.SLICE_LabEthernet:
|
||
|
|
case HardwareTypes.SLICE1_G5Stack:
|
||
|
|
case HardwareTypes.SLICE6_Base:
|
||
|
|
case HardwareTypes.SLICE6_AIR:
|
||
|
|
case HardwareTypes.SLICE6_AIR_BR:
|
||
|
|
return;//nothing to do
|
||
|
|
case HardwareTypes.SLICE1_5_Nano_Base:
|
||
|
|
case HardwareTypes.SLICE_Base:
|
||
|
|
case HardwareTypes.SLICE_Micro_Base:
|
||
|
|
case HardwareTypes.SLICE_NANO_Base:
|
||
|
|
case HardwareTypes.SLICE1_5_Micro_Base:
|
||
|
|
ReconfigureISOHardwareSlice(hardware);
|
||
|
|
return;
|
||
|
|
case HardwareTypes.TDAS_Pro_Rack:
|
||
|
|
case HardwareTypes.TDAS_LabRack:
|
||
|
|
ReconfigureISOHardwareTDAS(hardware);
|
||
|
|
return;
|
||
|
|
case HardwareTypes.SLICE2_SIM:
|
||
|
|
//here we may need to adjust the number of channels based on slice configuration
|
||
|
|
ReconfigureISOHardwareSPS(hardware);
|
||
|
|
return;
|
||
|
|
case HardwareTypes.DIR:
|
||
|
|
case HardwareTypes.DKR:
|
||
|
|
case HardwareTypes.TSR_AIR:
|
||
|
|
case HardwareTypes.TSR_AIR_RevB:
|
||
|
|
ReconfigureISOHardwareTSR(hardware);
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SLICE6_AIR_TC:
|
||
|
|
ReconfigureISOHardwareSliceTC(hardware);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public static void Save(Hardware h, int? testId, bool isAdd)
|
||
|
|
{
|
||
|
|
var hw = h.ToISOHardware();
|
||
|
|
hw.TestId = testId;
|
||
|
|
if (hw.StandIn || isAdd)
|
||
|
|
{
|
||
|
|
hw.IsFirstUseValid = true;
|
||
|
|
hw.FirstUseDate = null;
|
||
|
|
hw.CalDate = DateTime.Today;
|
||
|
|
}
|
||
|
|
AdjustMaxSampleRateIfNeeded(hw, h.Modules.Count);
|
||
|
|
AdjustConnectionIfNeeded(hw);
|
||
|
|
if (hw.DASId > 0)
|
||
|
|
{
|
||
|
|
hw.Update();
|
||
|
|
h.ISOHardware = hw;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
hw.Insert();
|
||
|
|
h.ISOHardware = hw;
|
||
|
|
}
|
||
|
|
h.IsAdd = false;
|
||
|
|
h.DetermineShowTreeView();
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// adjusts the max sample rate if needed if modules were added or removed
|
||
|
|
/// for some hardware
|
||
|
|
/// 17824 Manually creating a SLICE1.5 does not appear to have proper max sample rate
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="hardware"></param>
|
||
|
|
private static void AdjustMaxSampleRateIfNeeded(IISOHardware hardware, int modules)
|
||
|
|
{
|
||
|
|
switch (hardware.DASTypeEnum)
|
||
|
|
{
|
||
|
|
case DTS.Common.Enums.Hardware.HardwareTypes.SLICE1_5_Micro_Base:
|
||
|
|
case DTS.Common.Enums.Hardware.HardwareTypes.SLICE1_5_Nano_Base:
|
||
|
|
hardware.MaxSampleRate = Model.Hardware.GetSLICE15MaxSampleRate(modules);
|
||
|
|
break;
|
||
|
|
case DTS.Common.Enums.Hardware.HardwareTypes.SLICE_Base:
|
||
|
|
case DTS.Common.Enums.Hardware.HardwareTypes.SLICE_Micro_Base:
|
||
|
|
case DTS.Common.Enums.Hardware.HardwareTypes.SLICE_NANO_Base:
|
||
|
|
hardware.MaxSampleRate = Model.Hardware.GetSLICE1MaxSampleRate(modules);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private static void AdjustConnectionIfNeeded(IISOHardware hardware)
|
||
|
|
{
|
||
|
|
switch (hardware.DASTypeEnum)
|
||
|
|
{
|
||
|
|
case HardwareTypes.SLICE_Base:
|
||
|
|
case HardwareTypes.SLICE2_Base:
|
||
|
|
case HardwareTypes.SLICE1_5_Nano_Base:
|
||
|
|
case HardwareTypes.SLICE_Micro_Base:
|
||
|
|
case HardwareTypes.SLICE_NANO_Base:
|
||
|
|
case HardwareTypes.SLICE2_SIM:
|
||
|
|
case HardwareTypes.SLICE2_DIM:
|
||
|
|
case HardwareTypes.SLICE2_TOM:
|
||
|
|
case HardwareTypes.SLICE1_5_Micro_Base:
|
||
|
|
case HardwareTypes.SLICE2_SLS:
|
||
|
|
case HardwareTypes.SLICE2_SLT:
|
||
|
|
case HardwareTypes.SLICE2_SLD:
|
||
|
|
if (string.IsNullOrWhiteSpace(hardware.IPAddress))
|
||
|
|
{
|
||
|
|
hardware.IPAddress = "USB";
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private void ReconfigureISOHardwareSPS(DTS.Common.ISO.Hardware h)
|
||
|
|
{
|
||
|
|
var numberWeWant = h.ISOChannels.Length;
|
||
|
|
switch (SLICEPROSIMConfiguration)
|
||
|
|
{
|
||
|
|
case SLICEPROSIMConfigurations.MEGA://9ch
|
||
|
|
//remove any channels after 9
|
||
|
|
numberWeWant = 9;
|
||
|
|
h.MaxSampleRate = 1000000;
|
||
|
|
break;
|
||
|
|
case SLICEPROSIMConfigurations.EIGHT_HUNDRED://12ch
|
||
|
|
numberWeWant = 12;
|
||
|
|
h.MaxSampleRate = 800000;
|
||
|
|
break;
|
||
|
|
case SLICEPROSIMConfigurations.SEVEN_HUNDRED://15ch
|
||
|
|
numberWeWant = 15;
|
||
|
|
h.MaxSampleRate = 700000;
|
||
|
|
break;
|
||
|
|
case SLICEPROSIMConfigurations.SIX_HUNDRED://18ch
|
||
|
|
numberWeWant = 18;
|
||
|
|
h.MaxSampleRate = 600000;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
var existing = h.ISOChannels.ToList();
|
||
|
|
if (existing.Count > numberWeWant)
|
||
|
|
{
|
||
|
|
existing.RemoveRange(numberWeWant, existing.Count - numberWeWant);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (existing.Count < numberWeWant)
|
||
|
|
{
|
||
|
|
for (var i = existing.Count; i < numberWeWant; i++)
|
||
|
|
{
|
||
|
|
var copiedChannel = new DTS.Common.ISO.HardwareChannel(existing[0], h);
|
||
|
|
copiedChannel.ChannelIdx = i;
|
||
|
|
copiedChannel.ModuleArrayIndex = Convert.ToInt32(Math.Truncate(i / 3D));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
h.ISOChannels = existing.ToArray();
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// reconfigures all the channels and channel types of the object using what is configured in the UI
|
||
|
|
/// (slice only)
|
||
|
|
/// </summary>
|
||
|
|
private void ReconfigureISOHardwareSlice(DTS.Common.ISO.Hardware h)
|
||
|
|
{
|
||
|
|
var channelTypes = new List<int>();
|
||
|
|
var isoChannels = new List<DTS.Common.ISO.HardwareChannel>();
|
||
|
|
|
||
|
|
for (var i = 0; i < 8; i++)
|
||
|
|
{
|
||
|
|
GetSliceChannels(i, ref isoChannels, ref channelTypes, h);
|
||
|
|
}
|
||
|
|
h.Channels = channelTypes.Count;
|
||
|
|
h.ChannelTypes = channelTypes.ToArray();
|
||
|
|
h.ISOChannels = isoChannels.ToArray();
|
||
|
|
h.LastModified = DateTime.Now;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// sets the channels and channel types given selections in UI
|
||
|
|
/// (TDAS only)
|
||
|
|
/// </summary>
|
||
|
|
private void ReconfigureISOHardwareTDAS(DTS.Common.ISO.Hardware h)
|
||
|
|
{
|
||
|
|
h.MaxMemory = 0;
|
||
|
|
var channelTypes = new List<int>();
|
||
|
|
var isoChannels = new List<DTS.Common.ISO.HardwareChannel>();
|
||
|
|
|
||
|
|
var rackSize = (h.DASTypeEnum == HardwareTypes.TDAS_LabRack) ? 6 : Modules.Count;
|
||
|
|
|
||
|
|
for (var i = 0; i < rackSize; i++)
|
||
|
|
{
|
||
|
|
GetTDASChannels(i, ref isoChannels, ref channelTypes, h);
|
||
|
|
}
|
||
|
|
h.Channels = channelTypes.Count;
|
||
|
|
h.ChannelTypes = channelTypes.ToArray();
|
||
|
|
h.ISOChannels = isoChannels.ToArray();
|
||
|
|
h.LastModified = DateTime.Now;
|
||
|
|
}
|
||
|
|
private const int TSR_AIR_MODULES_COUNT = 8;
|
||
|
|
private void ReconfigureISOHardwareTSR(DTS.Common.ISO.Hardware h)
|
||
|
|
{
|
||
|
|
Modules.Clear();
|
||
|
|
//stand in will use a guid as a default serial, to avoid this lets use the hardware type
|
||
|
|
var serialNumber = SerialNumber;
|
||
|
|
if (StandIn)
|
||
|
|
{
|
||
|
|
serialNumber = EnumDescriptionTypeConverter.GetEnumDescription(HardwareType);
|
||
|
|
}
|
||
|
|
for (var i = 0; i < TSR_AIR_MODULES_COUNT; i++) //8 modules: ARS, HiG, LowG, Atm, RTC-S, RTC-NS, UART, and StreamOut
|
||
|
|
{
|
||
|
|
var module = new DASModule() { OwningHardware = this, ModuleType = HardwareTypes.TSR_AIR };
|
||
|
|
switch (i)
|
||
|
|
{
|
||
|
|
case (0):
|
||
|
|
module.SerialNumber = $"{serialNumber}{DFConstantsAndEnums.SERIAL_SEPARATOR}{DFConstantsAndEnums.ARS_SERIAL_APPEND}";
|
||
|
|
module.ModuleType = HardwareTypes.EMB_ANG_ARS;
|
||
|
|
break;
|
||
|
|
case (1):
|
||
|
|
module.SerialNumber = $"{serialNumber}{DFConstantsAndEnums.SERIAL_SEPARATOR}{DFConstantsAndEnums.HIGHG_SERIAL_APPEND}";
|
||
|
|
module.ModuleType = HardwareTypes.EMB_LIN_ACC_HI;
|
||
|
|
break;
|
||
|
|
case (2):
|
||
|
|
module.SerialNumber = $"{serialNumber}{DFConstantsAndEnums.SERIAL_SEPARATOR}{DFConstantsAndEnums.LOWG_SERIAL_APPEND}";
|
||
|
|
module.ModuleType = HardwareTypes.EMB_LIN_ACC_LO;
|
||
|
|
break;
|
||
|
|
case (3):
|
||
|
|
module.SerialNumber = $"{serialNumber}{DFConstantsAndEnums.SERIAL_SEPARATOR}{DFConstantsAndEnums.ATMOSPHERIC_SERIAL_APPEND}";
|
||
|
|
module.ModuleType = HardwareTypes.EMB_ATM;
|
||
|
|
break;
|
||
|
|
case (4):
|
||
|
|
module.SerialNumber = $"{serialNumber}{DFConstantsAndEnums.SERIAL_SEPARATOR}{DFConstantsAndEnums.RTCSECONDANDMARKER_SERIAL_APPEND}";
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.RTC;
|
||
|
|
module.ModuleType = HardwareTypes.EMB_RTC_S_MARK;
|
||
|
|
break;
|
||
|
|
case (5):
|
||
|
|
module.SerialNumber = $"{serialNumber}{DFConstantsAndEnums.SERIAL_SEPARATOR}{DFConstantsAndEnums.RTCCLOCKNANOPAD_SERIAL_APPEND}";
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.RTC;
|
||
|
|
module.ModuleType = HardwareTypes.EMB_RTC_NS_PAD;
|
||
|
|
break;
|
||
|
|
case (6):
|
||
|
|
module.SerialNumber = $"{serialNumber}{DFConstantsAndEnums.SERIAL_SEPARATOR}{DFConstantsAndEnums.UART_SERIAL_APPEND}";
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.UART;
|
||
|
|
module.ModuleType = HardwareTypes.UNDEFINED;
|
||
|
|
break;
|
||
|
|
case (7):
|
||
|
|
module.SerialNumber = $"{serialNumber}{DFConstantsAndEnums.SERIAL_SEPARATOR}{DFConstantsAndEnums.STREAMOUT_SERIAL_APPEND}";
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.StreamOut;
|
||
|
|
module.ModuleType = HardwareTypes.UNDEFINED;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
Modules.Add(module);
|
||
|
|
}
|
||
|
|
|
||
|
|
var isoChannels = new List<DTS.Common.ISO.HardwareChannel>();
|
||
|
|
var channelTypes = new List<int>();
|
||
|
|
for (var i = 0; i < TSR_AIR_MODULES_COUNT; i++)
|
||
|
|
{
|
||
|
|
GetTSRChannels(i, ref isoChannels, ref channelTypes, h);
|
||
|
|
}
|
||
|
|
h.Channels = channelTypes.Count;
|
||
|
|
h.ChannelTypes = channelTypes.ToArray();
|
||
|
|
h.ISOChannels = isoChannels.ToArray();
|
||
|
|
h.LastModified = DateTime.Now;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void ReconfigureISOHardwareSliceTC(DTS.Common.ISO.Hardware h)
|
||
|
|
{
|
||
|
|
Modules.Clear();
|
||
|
|
//stand in will use a guid as a default serial, to avoid this lets use the hardware type
|
||
|
|
var serialNumber = SerialNumber;
|
||
|
|
if (StandIn)
|
||
|
|
{
|
||
|
|
serialNumber = EnumDescriptionTypeConverter.GetEnumDescription(HardwareType);
|
||
|
|
}
|
||
|
|
|
||
|
|
var slicetcModulesCount = 0;
|
||
|
|
switch (SLICETCConfiguration)
|
||
|
|
{
|
||
|
|
case SLICETCConfigurations.EIGHT:
|
||
|
|
slicetcModulesCount = 1;
|
||
|
|
break;
|
||
|
|
case SLICETCConfigurations.SIXTEEN:
|
||
|
|
slicetcModulesCount = 2;
|
||
|
|
break;
|
||
|
|
case SLICETCConfigurations.TWENTYFOUR:
|
||
|
|
slicetcModulesCount = 3;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
var isoChannels = new List<DTS.Common.ISO.HardwareChannel>();
|
||
|
|
var channelTypes = new List<int>();
|
||
|
|
DASModule module;
|
||
|
|
|
||
|
|
for (var i = 0; i < slicetcModulesCount; i++) //Up to 3 modules (4 counting Stream Out)
|
||
|
|
{
|
||
|
|
module = new DASModule() { OwningHardware = this, ModuleType = HardwareTypes.UNDEFINED };
|
||
|
|
|
||
|
|
switch (i)
|
||
|
|
{
|
||
|
|
case (0):
|
||
|
|
module.SerialNumber = StringResources.XModule1;
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.Thermocoupler;
|
||
|
|
module.ModuleType = HardwareTypes.UNDEFINED;
|
||
|
|
break;
|
||
|
|
case (1):
|
||
|
|
module.SerialNumber = StringResources.XModule2;
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.Thermocoupler;
|
||
|
|
module.ModuleType = HardwareTypes.UNDEFINED;
|
||
|
|
break;
|
||
|
|
case (2):
|
||
|
|
module.SerialNumber = StringResources.XModule3;
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.Thermocoupler;
|
||
|
|
module.ModuleType = HardwareTypes.UNDEFINED;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
Modules.Add(module);
|
||
|
|
}
|
||
|
|
|
||
|
|
//Now add the Stream output module
|
||
|
|
module = new DASModule() { OwningHardware = this, ModuleType = HardwareTypes.UNDEFINED };
|
||
|
|
module.SerialNumber = $"{DFConstantsAndEnums.STREAMOUT_SERIAL_APPEND}";
|
||
|
|
module.SLICEBridgeType = SLICEBridgeTypes.StreamOut;
|
||
|
|
module.ModuleType = HardwareTypes.UNDEFINED;
|
||
|
|
Modules.Add(module);
|
||
|
|
slicetcModulesCount++;
|
||
|
|
|
||
|
|
for (var i = 0; i < slicetcModulesCount; i++)
|
||
|
|
{
|
||
|
|
GetTCChannels(i, ref isoChannels, ref channelTypes, h);
|
||
|
|
}
|
||
|
|
h.Channels = channelTypes.Count;
|
||
|
|
h.ChannelTypes = channelTypes.ToArray();
|
||
|
|
h.ISOChannels = isoChannels.ToArray();
|
||
|
|
h.LastModified = DateTime.Now;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// gets and populates the channel types and channels using information in the UI given a particular module
|
||
|
|
/// (slice only)
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="index"></param>
|
||
|
|
/// <param name="channels"></param>
|
||
|
|
/// <param name="channelTypes"></param>
|
||
|
|
/// <param name="h"></param>
|
||
|
|
private void GetSliceChannels(int index, ref List<DTS.Common.ISO.HardwareChannel> channels, ref List<int> channelTypes, DTS.Common.ISO.Hardware h)
|
||
|
|
{
|
||
|
|
var digitalInputModes = (int)DigitalInputModes.CCNC | (int)DigitalInputModes.CCNO |
|
||
|
|
(int)DigitalInputModes.THL | (int)DigitalInputModes.TLH;
|
||
|
|
if (index >= Modules.Count) { return; }
|
||
|
|
var module = Modules[index];
|
||
|
|
var moduleSN = $"{module.GetSerialNumberPrefix()}{(1 + index):000}";
|
||
|
|
|
||
|
|
var supportedExcitations = (int)ExcitationVoltageOptions.ExcitationVoltageOption.Volt5;
|
||
|
|
switch (module.SLICEBridgeType)
|
||
|
|
{
|
||
|
|
case SLICEBridgeTypes.IEPE:
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.IEPE);
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.IEPE);
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.IEPE);
|
||
|
|
for (var i = 0; i < 3; i++)
|
||
|
|
{
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
ParentDAS = h,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
SupportedBridges = (int)SensorConstants.BridgeType.IEPE,
|
||
|
|
SupportedDigitalInputModes = digitalInputModes,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedExcitations = supportedExcitations,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case SLICEBridgeTypes.Bridge:
|
||
|
|
case SLICEBridgeTypes.ARS:
|
||
|
|
case SLICEBridgeTypes.ACC:
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.IEPE);
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.IEPE);
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.IEPE);
|
||
|
|
var bridgeType = (int)SensorConstants.BridgeType.FullBridge | (int)SensorConstants.BridgeType.HalfBridge;
|
||
|
|
for (var i = 0; i < 3; i++)
|
||
|
|
{
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
ParentDAS = h,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
SupportedBridges = bridgeType,
|
||
|
|
SupportedDigitalInputModes = digitalInputModes,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedExcitations = supportedExcitations,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case SLICEBridgeTypes.RTC:
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.RTC);
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.RTC);
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.RTC);
|
||
|
|
var bridgeType = (int)SensorConstants.BridgeType.RTC;
|
||
|
|
for (var i = 0; i < 3; i++)
|
||
|
|
{
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
ParentDAS = h,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
SupportedBridges = bridgeType,
|
||
|
|
SupportedDigitalInputModes = 0,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedExcitations = (int)ExcitationVoltageOptions.ExcitationVoltageOption.Undefined,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case SLICEBridgeTypes.UART:
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.UART);
|
||
|
|
var bridgeType = (int)SensorConstants.BridgeType.UART;
|
||
|
|
for (var i = 0; i < 1; i++)
|
||
|
|
{
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
ParentDAS = h,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
SupportedBridges = bridgeType,
|
||
|
|
SupportedDigitalInputModes = 0,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedExcitations = (int)ExcitationVoltageOptions.ExcitationVoltageOption.Undefined,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
default: return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private void GetTCChannels(int index, ref List<DTS.Common.ISO.HardwareChannel> channels, ref List<int> channelTypes, DTS.Common.ISO.Hardware h)
|
||
|
|
{
|
||
|
|
if (index >= Modules.Count) { return; }
|
||
|
|
var module = Modules[index];
|
||
|
|
var moduleSN = module.SerialNumber;
|
||
|
|
|
||
|
|
if (module.SLICEBridgeType == SLICEBridgeTypes.StreamOut)
|
||
|
|
{
|
||
|
|
var bridgeType = (int)SensorConstants.BridgeType.StreamOut;
|
||
|
|
for (var i = 0; i < 1; i++)
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.StreamOutput);
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
ParentDAS = h,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
SupportedBridges = bridgeType,
|
||
|
|
SupportedDigitalInputModes = 0,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedExcitations = (int)ExcitationVoltageOptions.ExcitationVoltageOption.Undefined,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (module.SLICEBridgeType == SLICEBridgeTypes.Thermocoupler)
|
||
|
|
{
|
||
|
|
var bridgeType = (int)SensorConstants.BridgeType.Thermocoupler;
|
||
|
|
for (var i = 0; i < 8; i++)
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.Thermocoupler);
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
ParentDAS = h,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
SupportedBridges = bridgeType,
|
||
|
|
SupportedDigitalInputModes = 0,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedExcitations = (int)ExcitationVoltageOptions.ExcitationVoltageOption.Undefined,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private void GetTSRChannels(int index, ref List<DTS.Common.ISO.HardwareChannel> channels, ref List<int> channelTypes, DTS.Common.ISO.Hardware h)
|
||
|
|
{
|
||
|
|
var digitalInputModes = (int)DigitalInputModes.CCNC | (int)DigitalInputModes.CCNO |
|
||
|
|
(int)DigitalInputModes.THL | (int)DigitalInputModes.TLH;
|
||
|
|
if (index >= Modules.Count) { return; }
|
||
|
|
var module = Modules[index];
|
||
|
|
var moduleSN = module.SerialNumber;
|
||
|
|
|
||
|
|
var supportedExcitations = (int)ExcitationVoltageOptions.ExcitationVoltageOption.Volt5;
|
||
|
|
switch (module.SLICEBridgeType)
|
||
|
|
{
|
||
|
|
case SLICEBridgeTypes.Bridge:
|
||
|
|
{
|
||
|
|
var bridgeType = (int)SensorConstants.BridgeType.FullBridge | (int)SensorConstants.BridgeType.HalfBridge;
|
||
|
|
for (var i = 0; i < 3; i++)
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.Analog);
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
ParentDAS = h,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
SupportedBridges = bridgeType,
|
||
|
|
SupportedDigitalInputModes = digitalInputModes,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedExcitations = supportedExcitations,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case SLICEBridgeTypes.RTC:
|
||
|
|
{
|
||
|
|
var bridgeType = (int)SensorConstants.BridgeType.RTC;
|
||
|
|
for (var i = 0; i < 3; i++)
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.RTC);
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
ParentDAS = h,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
SupportedBridges = bridgeType,
|
||
|
|
SupportedDigitalInputModes = 0,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedExcitations = (int)ExcitationVoltageOptions.ExcitationVoltageOption.Undefined,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case SLICEBridgeTypes.StreamOut:
|
||
|
|
{
|
||
|
|
var bridgeType = (int)SensorConstants.BridgeType.StreamOut;
|
||
|
|
for (var i = 0; i < 1; i++)
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.StreamOutput);
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
ParentDAS = h,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
SupportedBridges = bridgeType,
|
||
|
|
SupportedDigitalInputModes = 0,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedExcitations = (int)ExcitationVoltageOptions.ExcitationVoltageOption.Undefined,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case SLICEBridgeTypes.UART:
|
||
|
|
{
|
||
|
|
var bridgeType = (int)SensorConstants.BridgeType.UART;
|
||
|
|
for (var i = 0; i < 1; i++)
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.UART);
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
ParentDAS = h,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
SupportedBridges = bridgeType,
|
||
|
|
SupportedDigitalInputModes = 0,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedExcitations = (int)ExcitationVoltageOptions.ExcitationVoltageOption.Undefined,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
default: return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// gets and populates channels and channel types using information in the UI, given a module index
|
||
|
|
/// (TDAS only)
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="index"></param>
|
||
|
|
/// <param name="channels"></param>
|
||
|
|
/// <param name="channelTypes"></param>
|
||
|
|
/// <param name="h"></param>
|
||
|
|
private void GetTDASChannels(int index, ref List<DTS.Common.ISO.HardwareChannel> channels, ref List<int> channelTypes, DTS.Common.ISO.Hardware h)
|
||
|
|
{
|
||
|
|
var memoryBefore = h.MaxMemory;
|
||
|
|
long memoryAdded = 0;
|
||
|
|
var module = Modules[index];
|
||
|
|
var moduleSN = $"{module.GetSerialNumberPrefix()}{(1 + index):000}";
|
||
|
|
var supportedExcitation = (int)ExcitationVoltageOptions.ExcitationVoltageOption.Volt5 | (int)ExcitationVoltageOptions.ExcitationVoltageOption.Volt10;
|
||
|
|
var digitalInputModes = (int)DigitalInputModes.CCNC | (int)DigitalInputModes.CCNO | (int)DigitalInputModes.THL | (int)DigitalInputModes.TLH;
|
||
|
|
switch (module.ModuleType)
|
||
|
|
{
|
||
|
|
case HardwareTypes.UNDEFINED: return;
|
||
|
|
case HardwareTypes.DIM:
|
||
|
|
{
|
||
|
|
memoryAdded = HardwareConstants.DEFAULTMEMORYSIZE_DIM;
|
||
|
|
for (var i = 0; i < 16; i++)
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.Analog);
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
ParentDAS = h,
|
||
|
|
SupportedBridges = (int)SensorConstants.BridgeType.DigitalInput,
|
||
|
|
SupportedDigitalInputModes = digitalInputModes,
|
||
|
|
SupportedExcitations = supportedExcitation,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case HardwareTypes.SIM:
|
||
|
|
{ //8 analog channels, 5V only, adjust memory up for one sim
|
||
|
|
memoryAdded = HardwareConstants.DEFAULTMEMORYSIZE_PRO;
|
||
|
|
for (var i = 0; i < 8; i++)
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.Analog);
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
ParentDAS = h,
|
||
|
|
SupportedBridges = (int)SensorConstants.BridgeType.FullBridge | (int)SensorConstants.BridgeType.HalfBridge,
|
||
|
|
SupportedDigitalInputModes = digitalInputModes,
|
||
|
|
SupportedExcitations = supportedExcitation,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break; ;
|
||
|
|
case HardwareTypes.TOM:
|
||
|
|
{
|
||
|
|
memoryAdded = HardwareConstants.DEFAULTMEMORYSIZE_TOM;
|
||
|
|
for (var i = 0; i < 8; i++) //8 squib channels
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.Squib);
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
ParentDAS = h,
|
||
|
|
SupportedBridges = (int)SensorConstants.BridgeType.SQUIB,
|
||
|
|
SupportedDigitalInputModes = digitalInputModes,
|
||
|
|
SupportedExcitations = supportedExcitation,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.AC |
|
||
|
|
(int)SquibFireMode.CAP | (int)SquibFireMode.CONSTANT | (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
for (var i = 8; i < 16; i++)//8 digital output channels?
|
||
|
|
{
|
||
|
|
channelTypes.Add((int)DTS.Common.ISO.Hardware.ChannelType.DigitalOutput);
|
||
|
|
channels.Add(new DTS.Common.ISO.HardwareChannel
|
||
|
|
{
|
||
|
|
ChannelIdx = channels.Count,
|
||
|
|
DASDisplayOrder = -1,
|
||
|
|
LocalOnly = false,
|
||
|
|
ParentDAS = h,
|
||
|
|
SupportedBridges = (int)SensorConstants.BridgeType.TOMDigital,
|
||
|
|
SupportedDigitalInputModes = digitalInputModes,
|
||
|
|
SupportedExcitations = supportedExcitation,
|
||
|
|
SupportedDigitalOutputModes = (int)DigitalOutputModes.NONE |
|
||
|
|
(int)DigitalOutputModes.CCNC |
|
||
|
|
(int)DigitalOutputModes.CCNO |
|
||
|
|
(int)DigitalOutputModes.FVHL |
|
||
|
|
(int)DigitalOutputModes.FVLH,
|
||
|
|
SupportedSquibFireModes = (int)SquibFireMode.NONE,
|
||
|
|
ModuleSerialNumber = moduleSN,
|
||
|
|
ModuleArrayIndex = index
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
break; ;
|
||
|
|
}
|
||
|
|
h.MaxMemory = memoryBefore + memoryAdded;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// returns true if serial number does not match any in db, false otherwise
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="sn"></param>
|
||
|
|
/// <returns>true if serial number is unique</returns>
|
||
|
|
public static bool CheckUniqueSN(string sn)
|
||
|
|
{
|
||
|
|
if (string.IsNullOrWhiteSpace(sn))
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
var hResult = DbOperations.DASGet(sn, null, out var das);
|
||
|
|
|
||
|
|
if (0 == hResult && null != das && das.Any())
|
||
|
|
{
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|