145 lines
6.3 KiB
C#
145 lines
6.3 KiB
C#
|
|
using System;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace DatabaseExport
|
|||
|
|
{
|
|||
|
|
public class SquibSetting : SensorData
|
|||
|
|
{
|
|||
|
|
public string SquibDescription
|
|||
|
|
{
|
|||
|
|
get => SerialNumber;
|
|||
|
|
set { SerialNumber = value; OnPropertyChanged("SquibDescription"); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool _bypassCurrentFilter = false;
|
|||
|
|
public bool BypassCurrentFilter
|
|||
|
|
{
|
|||
|
|
get => _bypassCurrentFilter;
|
|||
|
|
set => SetProperty(ref _bypassCurrentFilter, value, "BypassCurrentFilter");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool _bypassVoltageFilter = false;
|
|||
|
|
public bool BypassVoltageFilter
|
|||
|
|
{
|
|||
|
|
get => _bypassVoltageFilter;
|
|||
|
|
set => SetProperty(ref _bypassVoltageFilter, value, "BypassVoltageFilter");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string ArticleId
|
|||
|
|
{
|
|||
|
|
get => Id;
|
|||
|
|
set { Id = value; OnPropertyChanged("ArticleId"); }
|
|||
|
|
}
|
|||
|
|
public static void SetDefaults(SensorData sd)
|
|||
|
|
{
|
|||
|
|
sd.AxisNumber = 0;
|
|||
|
|
sd.Capacity = 5;
|
|||
|
|
sd.NumberOfAxes = 1;
|
|||
|
|
sd.Manufacturer = "Generic";
|
|||
|
|
sd.Model = "Squib Setting";
|
|||
|
|
sd.Shunt = ShuntMode.None;
|
|||
|
|
sd.CheckOffset = false;
|
|||
|
|
sd.BridgeResistance = -1;
|
|||
|
|
sd.MeasureNoise = false;
|
|||
|
|
sd.MeasureExcitation = false;
|
|||
|
|
sd.Bridge = Test.Module.Channel.Sensor.BridgeType.SQUIB;
|
|||
|
|
sd.SupportedExcitation = new Test.Module.Channel.Sensor.ExcitationVoltageOption[] { Test.Module.Channel.Sensor.ExcitationVoltageOption.Volt5 };
|
|||
|
|
sd.DisplayUnit = "V";
|
|||
|
|
sd.Comment = string.IsNullOrWhiteSpace(sd.UserValue1) ? sd.SerialNumber : sd.UserValue1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public SquibSetting(System.Data.DataRow dr)
|
|||
|
|
{
|
|||
|
|
SetDefaults(this);
|
|||
|
|
var fields = Enum.GetValues(typeof(DbOperations.Squib.Fields)).Cast<DbOperations.Squib.Fields>()
|
|||
|
|
.ToArray();
|
|||
|
|
|
|||
|
|
foreach (var field in fields)
|
|||
|
|
{
|
|||
|
|
var o = dr[field.ToString()];
|
|||
|
|
if (DBNull.Value.Equals(o)) { continue; }
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
switch (field)
|
|||
|
|
{
|
|||
|
|
case DbOperations.Squib.Fields.Version:
|
|||
|
|
Version = Convert.ToInt32(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.SquibToleranceLow:
|
|||
|
|
SquibToleranceLow = Convert.ToDouble(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.SquibToleranceHigh:
|
|||
|
|
SquibToleranceHigh = Convert.ToDouble(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.SquibOutputCurrent:
|
|||
|
|
SquibOutputCurrent = Convert.ToDouble(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.SquibDescription:
|
|||
|
|
SquibDescription = Convert.ToString(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.MeasurementType:
|
|||
|
|
SquibMeasurementType = (OutputSquibChannel.SquibMeasurementType)Convert.ToInt16(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.LocalOnly:
|
|||
|
|
_localOnly = Convert.ToBoolean(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.LimitDuration:
|
|||
|
|
LimitSquibFireDuration = Convert.ToBoolean(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.LastModifiedBy:
|
|||
|
|
_lastUpdatedBy = Convert.ToString(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.LastModified:
|
|||
|
|
LastModified = Convert.ToDateTime(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.ISOCode:
|
|||
|
|
ISOCode = Convert.ToString(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.FireMode:
|
|||
|
|
SquibFireMode = (OutputSquibChannel.SquibFireMode)Convert.ToInt16(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.DurationMS:
|
|||
|
|
SquibFireDurationMS = Convert.ToDouble(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.DelayMS:
|
|||
|
|
SquibFireDelayMS = Convert.ToDouble(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.BypassVoltageFilter:
|
|||
|
|
BypassVoltageFilter = Convert.ToBoolean(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.BypassCurrentFilter:
|
|||
|
|
BypassCurrentFilter = Convert.ToBoolean(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.ArticleId:
|
|||
|
|
ArticleId = Convert.ToString(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.UserValue1:
|
|||
|
|
UserValue1 = Convert.ToString(o);
|
|||
|
|
Comment = UserValue1;
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.UserValue2:
|
|||
|
|
UserValue2 = Convert.ToString(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.UserValue3:
|
|||
|
|
UserValue3 = Convert.ToString(o);
|
|||
|
|
break;
|
|||
|
|
case DbOperations.Squib.Fields.UserTags:
|
|||
|
|
TagsBlobBytes = (byte[])o;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
throw new NotSupportedException("Unknown field: " + field.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
//ignore
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrWhiteSpace(Comment))
|
|||
|
|
{
|
|||
|
|
Comment = SerialNumber;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|