This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
using System;
using System.Windows.Data;
namespace DTS.Common.Converters
{
/// <summary>
/// Date converter that will display Table_NA when date is null, otherwise datetime [xaml responsible for formatting]
/// </summary>
public class NullableFloatConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value is float ft ? ft : (object)string.Empty;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value is float ft ? ft : (object)string.Empty;
}
}
}

View File

@@ -0,0 +1,91 @@
using DTS.Common.Base;
using DTS.Common.Interface.TestSetups;
using System.Data;
namespace DTS.Common.Classes.TestSetups
{
/// <summary>
/// Describes a record in the TestSetupROIs table
/// </summary>
public class TestSetupROIsRecord : BasePropertyChanged, ITestSetupROIRecord
{
/// <summary>
/// The field that matches the same field in the ROIPeriodChannels table
/// </summary>
private int _testSetupROIId;
public int TestSetupROIId
{
get => _testSetupROIId;
set => SetProperty(ref _testSetupROIId, value, "TestSetupROIId");
}
/// <summary>
/// The field that matches the same field in the TestSetups table
/// </summary>
private int _testSetupId;
public int TestSetupId
{
get => _testSetupId;
set => SetProperty(ref _testSetupId, value, "TestSetupId");
}
/// <summary>
/// e.g. "_ROI Period 1", "_ROI Period 2", etc.
/// </summary>
private string _suffix = "";
public string Suffix
{
get => _suffix;
set => SetProperty(ref _suffix, value, "Suffix");
}
/// <summary>
/// The starting time of the ROI period.
/// </summary>
private double _roiStart = -1.0D;
public double ROIStart
{
get => _roiStart;
set => SetProperty(ref _roiStart, value, "ROIStart");
}
/// <summary>
/// The ending time of the ROI period.
/// </summary>
private double _roiEnd = 1.0D;
public double ROIEnd
{
get => _roiEnd;
set => SetProperty(ref _roiEnd, value, "ROIEnd");
}
/// <summary>
/// Whether or not the period is enabled.
/// </summary>
private bool _isEnabled = true;
public bool IsEnabled
{
get => _isEnabled;
set => SetProperty(ref _isEnabled, value, "IsEnabled");
}
/// <summary>
/// Whether or not the period is the default
/// </summary>
private bool _isDefault = true;
public bool IsDefault
{
get => _isDefault;
set => SetProperty(ref _isDefault, value, "IsDefault");
}
/// <summary>
/// Builds a TestSetupROIs record after a call to sp_TestSetupROIsGet
/// </summary>
/// <param name="reader"></param>
public TestSetupROIsRecord(IDataReader reader)
{
TestSetupROIId = Utility.GetInt(reader, "TestSetupROIId");
TestSetupId = Utility.GetInt(reader, "TestSetupROIId");
Suffix = Utility.GetString(reader, "Suffix");
ROIStart = Utility.GetDouble(reader, "ROIStart", -1);
ROIEnd = Utility.GetDouble(reader, "ROIEnd", 1);
IsEnabled = Utility.GetBool(reader, "IsEnabled");
IsDefault = Utility.GetBool(reader, "IsDefault");
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
namespace DTS.Common.Interface.Tags
{
/// <summary>
/// describes a database record for a tag
/// </summary>
public interface ITag : ICloneable
{
/// <summary>
/// Database id for tag
/// </summary>
int ID { get; set; }
/// <summary>
/// text associated with tag
/// </summary>
string Text { get; set; }
/// <summary>
/// whether tag is obsolete or not
/// </summary>
bool IsObsolete { get; set; }
}
}

View File

@@ -0,0 +1,177 @@
using DTS.Common.Base;
using DTS.Common.Enums.Sensors;
using DTS.Common.Interface.Sensors;
using DTS.Common.Utilities.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
using System.Globalization;
using System.Linq;
namespace DTS.Common.Classes.Sensors
{
public class SensorCalDbRecord : BasePropertyChanged, ISensorCalDbRecord
{
public bool LinearAdded
{
get => NonLinear && Records.Records[0].Poly.NonLinearStyle == NonLinearStyles.Polynomial &&
Records.Records.Length > 1 && ZeroMethods.Methods.Length > 1;
}
private int? _calibrationId = null;
/// <summary>
/// database id, if known, for calibration, null indicates not known
/// 13065 Sensor "First Use" Date
/// </summary>
[Key]
public int? CalibrationId
{
get => _calibrationId;
set => SetProperty(ref _calibrationId, value, "CalibrationId");
}
protected string _serialNumber;
public string SerialNumber
{
get => _serialNumber;
set => SetProperty(ref _serialNumber, value, "SerialNumber");
}
protected DateTime _calibrationDate;
[Column(TypeName = "datetime")]
public DateTime CalibrationDate
{
get => _calibrationDate;
set => SetProperty(ref _calibrationDate, value, "CalibrationDate");
}
protected string _userName = "";
[Required]
[StringLength(50)]
public string Username
{
get => _userName;
set => SetProperty(ref _userName, value, "Username");
}
private bool _localOnly;
public bool LocalOnly
{
get => _localOnly;
set => SetProperty(ref _localOnly, value, "LocalOnly");
}
private bool _nonLinear;
public bool NonLinear
{
get => _nonLinear;
set
{
SetProperty(ref _nonLinear, value, "NonLinear");
if (!value) return;
Records.Records.First().Sensitivity = 1D;
//FB 29728 don't make IsProportinal false
//IsProportional = false;
RemoveOffset = false;
}
}
private ICalibrationRecords _records = new CalibrationRecords();
[Required]
[StringLength(255)]
public ICalibrationRecords Records
{
get => _records;
set => SetProperty(ref _records, value, "Records");
}
private DateTime _modifyDate;
[Column(TypeName = "datetime")]
public DateTime ModifyDate
{
get => _modifyDate;
set => SetProperty(ref _modifyDate, value, "ModifyDate");
}
private bool _isProportional;
public bool IsProportional
{
get => _isProportional;
set => SetProperty(ref _isProportional, value, "IsProportional");
}
private bool _removeOffset;
public bool RemoveOffset
{
get => _removeOffset;
set => SetProperty(ref _removeOffset, value, "RemoveOffset");
}
private ZeroMethods _zeroMethods = new ZeroMethods();
[Required]
[StringLength(255)]
public ZeroMethods ZeroMethods
{
get => _zeroMethods;
set => SetProperty(ref _zeroMethods, value, "ZeroMethods");
}
private string[] _certificationDocuments = new string[0];
[Required]
[StringLength(2048)]
public string[] CertificationDocuments
{
get => _certificationDocuments;
set => SetProperty(ref _certificationDocuments, value, "CertificationDocuments");
}
//FB18158 It's None the default now not EU
private InitialOffsets _initialOffsets = new InitialOffsets(new InitialOffset());
public InitialOffsets InitialOffsets
{
get => _initialOffsets;
set => SetProperty(ref _initialOffsets, value, "InitialOffsets");
}
public SensorCalDbRecord() { }
public SensorCalDbRecord(ISensorCalDbRecord copy)
{
CalibrationDate = copy.CalibrationDate;
LocalOnly = copy.LocalOnly;
SerialNumber = copy.SerialNumber;
Username = copy.Username;
Records = new CalibrationRecords(copy.Records);
NonLinear = copy.NonLinear;
IsProportional = copy.IsProportional;
ModifyDate = copy.ModifyDate;
var list = new List<string>(copy.CertificationDocuments);
CertificationDocuments = list.ToArray();
RemoveOffset = copy.RemoveOffset;
ZeroMethods = new ZeroMethods(copy.ZeroMethods);
InitialOffsets = new InitialOffsets(copy.InitialOffsets);
CalibrationId = copy.CalibrationId;
//this is downright silly, but because the linearization formula marks itself valid when it deserializes with data in it, we go and correct it here.
Records.Records[0].Poly.MarkValid(NonLinear);
}
public SensorCalDbRecord(IDataReader reader)
{
try
{
CalibrationDate = Utility.GetDateTime(reader, "CalibrationDate", DateTime.MinValue);
LocalOnly = Utility.GetBool(reader, "LocalOnly", false);
SerialNumber = Utility.GetString(reader, "SerialNumber");
Username = Utility.GetString(reader, "Username");
Records = new CalibrationRecords(Utility.GetString(reader, "CalibrationRecords"));
NonLinear = Utility.GetBool(reader, "NonLinear");
IsProportional = Utility.GetBool(reader, "IsProportional");
ModifyDate = Utility.GetDateTime(reader, "ModifyDate", DateTime.MinValue);
CertificationDocuments = Utility.GetString(reader, "CertificationDocuments").Split(new[] { CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None).ToArray();
RemoveOffset = Utility.GetBool(reader, "RemoveOffset");
ZeroMethods = new ZeroMethods(Utility.GetString(reader, "ZeroMethod"));
InitialOffsets = new InitialOffsets(Utility.GetString(reader, "InitialOffset"));
CalibrationId = Utility.GetNullableInt(reader, "SensorCalibrationId");
//this is downright silly, but because the linearization formula marks itself valid when it deserializes with data in it, we go and correct it here.
Records.Records[0].Poly.MarkValid(NonLinear);
}
catch (Exception ex)
{
APILogger.Log("Failed to process Sensor Calibration record", ex);
}
}
}
}

View File

@@ -0,0 +1,102 @@
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
namespace DTS.Common.Controls
{
public class DynamicGrid : Grid, INotifyPropertyChanged
{
#region 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));
}
#endregion
public DynamicGrid()
: base()
{
Refresh();
}
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
{
base.OnVisualChildrenChanged(visualAdded, visualRemoved);
Refresh();
}
public void Refresh()
{
ColumnDefinitions.Clear();
for (byte i = 0; i < GridColumns; i++)
{
ColumnDefinitions.Add(new ColumnDefinition());
if (i + 1 != GridColumns)
{
ColumnDefinitions[i].Width = new GridLength(1, GridUnitType.Auto);
}
else
{
ColumnDefinitions[i].Width = new GridLength(1, GridUnitType.Star);
}
}
var curRow = 0;
var curCol = 0;
RowDefinitions.Clear();
if (Children != null)
{
foreach (UIElement curChild in Children)
{
if(0 == curCol)
{
// We're on the first column, we need a new row for the child
RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
}
// Set the child to its row and column
SetRow(curChild, curRow);
SetColumn(curChild, curCol);
// Iderate
if (curCol < GridColumns-1)
{
// We're moving to the next column
curCol++;
}
else
{
// We're at the end, go back to clumn 0
curCol = 0;
curRow++;
}
}
}
RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
}
private byte _columns = 2;
public byte GridColumns
{
get => _columns;
set { _columns = value; Refresh(); }
}
}
}