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,154 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
namespace DTS.Common.Controls
{
//Remove this control after deleting the TTS module and migrating to new test setup wizard
/// <inheritdoc cref="UserControl" />
/// <summary>
/// Interaction logic for TestIdControl.xaml
/// </summary>
public partial class TestIdControl : UserControl, 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
private static readonly TestIdPreFixSuffixHelper TEST_ID_SUFFIX_VALUE_NONE_ITEM =
new TestIdPreFixSuffixHelper(TestIdFixedPrefixSuffixValues.None);
private static readonly TestIdPreFixSuffixHelper TEST_ID_SUFFIX_VALUE_TIME_STAMP_ITEM =
new TestIdPreFixSuffixHelper(TestIdFixedPrefixSuffixValues.TimeStamp);
private static readonly TestIdPreFixSuffixHelper TEST_ID_SUFFIX_VALUE_TEST_SETUP_ITEM =
new TestIdPreFixSuffixHelper(TestIdFixedPrefixSuffixValues.TestSetupName);
public TestIdControl()
{
InitializeComponent();
}
private string _testSetupLabel = string.Empty;
public string TestSetupLabel
{
get => _testSetupLabel;
set
{
_testSetupLabel = value;
OnPropertyChanged("TestSetupLabel");
OnPropertyChanged("TestSetupLabelVisibility");
}
}
public Visibility TestSetupLabelVisibility => string.IsNullOrEmpty(TestSetupLabel)
? Visibility.Collapsed
: Visibility.Visible;
public string TestIdEditableText { get; set; } = string.Empty;
public void PopulateAllTestIdPrefixSuffixValues(string[] serializedValues)
{
_allTestIdPrefixSuffixValues = new List<TestIdPreFixSuffixHelper>
{
TEST_ID_SUFFIX_VALUE_NONE_ITEM,
TEST_ID_SUFFIX_VALUE_TIME_STAMP_ITEM,
TEST_ID_SUFFIX_VALUE_TEST_SETUP_ITEM
};
// Second, populate all values from the db
var dbList = new List<string>();
dbList.AddRange(serializedValues);
foreach (var s in dbList)
{
_allTestIdPrefixSuffixValues.Add(new TestIdPreFixSuffixHelper(s));
}
OnPropertyChanged("AllTestIDPrefixSuffixValues");
}
private List<TestIdPreFixSuffixHelper> _allTestIdPrefixSuffixValues;
public TestIdPreFixSuffixHelper[] AllTestIdPrefixSuffixValues => _allTestIdPrefixSuffixValues?.ToArray() ?? new TestIdPreFixSuffixHelper[0];
public TestIdPreFixSuffixHelper SelectedTestIdPrefixValueItem { get; set; } = TEST_ID_SUFFIX_VALUE_NONE_ITEM;
public TestIdPreFixSuffixHelper SelectedTestIdSuffixValueItem { get; set; } = TEST_ID_SUFFIX_VALUE_TIME_STAMP_ITEM;
public string TestName
{
get; set;
}
public string GetTestId()
{
var testIdList = new List<string>();
var prefix = GetRunTimeTestIdPrefixOrSuffix(SelectedTestIdPrefixValueItem);
if (prefix != string.Empty)
{
testIdList.Add(prefix);
}
if (!string.IsNullOrEmpty(TestSetupLabel))
{
testIdList.Add(TestSetupLabel);
}
if (TestIdEditableText != string.Empty)
{
testIdList.Add(TestIdEditableText);
}
var suffix = GetRunTimeTestIdPrefixOrSuffix(SelectedTestIdSuffixValueItem);
if (suffix != string.Empty)
{
testIdList.Add(suffix);
}
return string.Join("_", testIdList);
/*
CurrentTest.TestId = TestId;
CurrentTest.TestIdNode = CurrentTest.TestId;
_page.HeaderRibbon.tbCurrentTestIdString = TestId;*/
}
private string GetRunTimeTestIdPrefixOrSuffix(TestIdPreFixSuffixHelper prefixOrSuffix)
{
var rv = string.Empty;
if (prefixOrSuffix == null) { return rv; }
switch (prefixOrSuffix.TestIdPreFixSuffix.FixedValue)
{
case TestIdFixedPrefixSuffixValues.TestSetupName:
rv = TestName;
break;
case TestIdFixedPrefixSuffixValues.TimeStamp:
rv = GetTestIdTimestamp();
break;
case TestIdFixedPrefixSuffixValues.NotFixed:
rv = prefixOrSuffix.TestIdPreFixSuffix.ToString();
break;
case TestIdFixedPrefixSuffixValues.None:
default:
// do nothing
break;
}
return rv;
}
public string GetTestIdTimestamp()
{
return $"{DateTime.Now.Year:0000}_{DateTime.Now.Month:00}_{DateTime.Now.Day:00} {DateTime.Now.Hour:00}_{DateTime.Now.Minute:00}";
}
}
}

View File

@@ -0,0 +1,36 @@
namespace DTS.Common.Classes.Locking
{
public class LockError
{
public int ErrorCode { get; private set; }
public string Message { get; private set; }
public string LockingUser { get; private set; }
public string LockingMachine { get; private set; }
public bool LockStolen => ErrorCode == LOCKSTOLEN_ERROR;
public bool LockLost => ErrorCode == LOCKDOESNTEXIST_ERROR;
public override string ToString()
{
return $"{ErrorCode} - {Message}";
}
public LockError(int error, string message, string user = null, string machine = null)
{
ErrorCode = error;
Message = message;
LockingUser = user ?? string.Empty;
LockingMachine = machine ?? string.Empty;
}
//14782 Improve lost remote db connection modal dialogs
//this can apparently be returned by sqlclient on failed lock maintenance issues
public const int BAD_NETPATH_ERROR = 994;
//14782 Improve lost remote db connection modal dialogs
//system error of semaphore timeout, returned by sqlclient on failed to connect issues
public const int SEM_TIMEOUT_ERROR = 995;
public const int ITEM_NOT_FOUND = 996;
public const int LOCKDOESNTEXIST_ERROR = 997;
public const int LOCKSTOLEN_ERROR = 998;
public const int UNKNOWN_ERROR = 999;
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections;
using System.Windows;
using System.Windows.Data;
namespace DTS.Common.Converters
{
/// <summary>
/// simple converter that converts array or lists so visible or hidden
/// </summary>
public class ArrayVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (null == value) { return Visibility.Hidden; }
if (value is IList list) { return list.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
if (value is Array array)
{
return array.Length > 0 ? Visibility.Visible : Visibility.Collapsed;
}
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,36 @@
using DTS.Common.SharedResource.Strings;
using System.Globalization;
using System.Windows.Controls;
using DTS.Common.Constant;
namespace DTS.Common.Validators
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S101:Types should be named in PascalCase", Justification = "acronyms")]
public class CANArbBaseBitrateValidator : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
if (value is string s)
{
if (!long.TryParse(s, out var temp))
{
return new ValidationResult(false, StringResources.InvalidFormat);
}
else
{
//Since the Arb/Base Bitrate min/max is different for FD vs. non-FD CANs, use the widest range.
if (temp > EmbeddedSensors.CANFD_ARB_BASE_BITRATE_MAX)
{
return new ValidationResult(false, $"{StringResources.MaxValueIs}{EmbeddedSensors.CANFD_ARB_BASE_BITRATE_MAX}");
}
if (temp < EmbeddedSensors.NON_CANFD_ARB_BASE_BITRATE_MIN)
{
return new ValidationResult(false, $"{StringResources.MinValueIs}{EmbeddedSensors.NON_CANFD_ARB_BASE_BITRATE_MIN}");
}
return new ValidationResult(true, null);
}
}
return new ValidationResult(false, StringResources.InvalidFormat);
}
}
}

View File

@@ -0,0 +1,6 @@
using DTS.Common.Base;
namespace DTS.Common.Interface
{
public interface IRealtimeSettingsViewModel : IBaseViewModel { }
}