init
This commit is contained in:
133
DataPRO/SensorDB/SquibSetting.cs
Normal file
133
DataPRO/SensorDB/SquibSetting.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using DTS.Common.Classes.Sensors;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Interface.Sensors;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.SensorDB
|
||||
{
|
||||
public class SquibSetting : SensorData
|
||||
{
|
||||
public string SquibDescription
|
||||
{
|
||||
get => SerialNumber;
|
||||
set
|
||||
{
|
||||
SerialNumber = value;
|
||||
OnPropertyChanged("SquibDescription");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _bypassCurrentFilter;
|
||||
|
||||
public new bool BypassCurrentFilter
|
||||
{
|
||||
get => _bypassCurrentFilter;
|
||||
set => SetProperty(ref _bypassCurrentFilter, value, "BypassCurrentFilter");
|
||||
}
|
||||
|
||||
private bool _bypassVoltageFilter;
|
||||
|
||||
public new bool BypassVoltageFilter
|
||||
{
|
||||
get => _bypassVoltageFilter;
|
||||
set => SetProperty(ref _bypassVoltageFilter, value, "BypassVoltageFilter");
|
||||
}
|
||||
|
||||
public string ArticleId
|
||||
{
|
||||
get => EID;
|
||||
set
|
||||
{
|
||||
EID = value;
|
||||
OnPropertyChanged("ArticleId");
|
||||
}
|
||||
}
|
||||
|
||||
public SquibSetting()
|
||||
{
|
||||
SetDefaults(this);
|
||||
}
|
||||
|
||||
public SquibSetting(SquibSetting copy)
|
||||
: base(copy)
|
||||
{
|
||||
SetDefaults(this);
|
||||
}
|
||||
|
||||
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 = SensorConstants.BridgeType.SQUIB;
|
||||
sd.SupportedExcitation = new[]
|
||||
{ExcitationVoltageOptions.ExcitationVoltageOption.Volt5};
|
||||
sd.DisplayUnit = "V";
|
||||
sd.Comment = string.IsNullOrWhiteSpace(sd.UserValue1) ? sd.SerialNumber : sd.UserValue1;
|
||||
}
|
||||
|
||||
public SquibSetting(ISquibDbRecord record)
|
||||
{
|
||||
try
|
||||
{
|
||||
SetDefaults(this);
|
||||
DatabaseId = record.Id;
|
||||
ISOChannelName = record.IsoChannelName;
|
||||
UserCode = record.UserCode;
|
||||
UserChannelName = record.UserChannelName;
|
||||
Broken = record.Broken;
|
||||
DoNotUse = record.DoNotUse;
|
||||
Version = record.Version;
|
||||
SquibToleranceLow = record.SquibToleranceLow;
|
||||
SquibToleranceHigh = record.SquibToleranceHigh;
|
||||
SquibOutputCurrent = record.SquibOutputCurrent;
|
||||
SquibDescription = record.SerialNumber;
|
||||
SquibMeasurementType = record.MeasurementType;
|
||||
LimitSquibFireDuration = record.LimitDuration;
|
||||
DefineDelayInTest = record.DefineDelayInTest;
|
||||
ModifiedBy = record.LastModifiedBy;
|
||||
LastModified = record.LastModified;
|
||||
ISOCode = record.IsoCode;
|
||||
SquibFireMode = record.FireMode;
|
||||
SquibFireDurationMS = record.DurationMs;
|
||||
SquibFireDelayMS = record.DelayMs;
|
||||
BypassVoltageFilter = record.BypassVoltageFilter;
|
||||
BypassCurrentFilter = record.BypassCurrentFilter;
|
||||
ArticleId = record.ArticleId;
|
||||
UserValue1 = record.UserValue1;
|
||||
Comment = UserValue1;
|
||||
UserValue2 = record.UserValue2;
|
||||
UserValue3 = record.UserValue3;
|
||||
TagsBlobBytes = record.UserTags;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process: ", ex);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Comment))
|
||||
{
|
||||
Comment = SerialNumber;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Commit(SensorData setting)
|
||||
{
|
||||
SetDefaults(setting);
|
||||
|
||||
var record = new SquibDbRecord(setting, setting.DefineDelayInTest, setting.TagsBlobBytes);
|
||||
var hr = DbOperations.SensorsSquibUpdateInsert(record);
|
||||
if (0 == hr) { setting.DatabaseId = record.Id; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user