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,16 @@
using DTS.Common.Interface.DownloadEvent;
namespace DTS.Common.Interface.DASFactory.Download
{
public interface IDownloadReport
{
/// <summary>
/// An array of all events stored on this DAS.
/// </summary>
IEventInfo[] Events { get; set; }
/// <summary>
/// An array of all UART events stored on this DAS.
/// </summary>
IUARTEventInfo[] UARTEvents { get; set; }
}
}

View File

@@ -0,0 +1,326 @@
using System;
using System.Text;
using System.Net.NetworkInformation;
using System.Data;
using DTS.Common.Utilities.Logging;
using System.Collections.Generic;
namespace DTS.Common.Classes
{
/// <summary>
/// The Utility class.
/// </summary>
///
public sealed class Utility
{
public static byte[] GetBytesFromStringArray(string[] array, string separator)
{
var text = string.Join(separator, array);
return Encoding.UTF8.GetBytes(text);
}
/// <summary>
/// Returns all error messages include inner exceptions' messages.
/// </summary>
/// <param name="ex">The System.Exception object.</param>
/// <returns>Returns all error messages as a string.</returns>
public static string GetAllErrorMessages(Exception ex)
{
if (ex == null)
return string.Empty;
// assign the current exception as first object
// and then loop through its inner exceptions till they are null
var sb = new StringBuilder();
sb.AppendLine("Error Message: " + ex.Message);
var innerEx = ex;
while (innerEx.InnerException != null)
{
innerEx = innerEx.InnerException;
sb.AppendLine("Inner Exception: " + innerEx.Message);
}
return sb.ToString();
}
/// <summary>
/// Check internet connection availability
/// </summary>
/// <param name="hostNameOrAddress">The host name ar address.</param>
/// <returns><c>true</c> if internet connection available; otherwise, <c>false</c>.</returns>
public static bool PingNetwork(string hostNameOrAddress)
{
bool pingStatus;
using (var p = new Ping())
{
var buffer = Encoding.ASCII.GetBytes("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
const int timeout = 4444; // 4s
try
{
var reply = p.Send(hostNameOrAddress, timeout, buffer);
pingStatus = (reply.Status == IPStatus.Success);
}
catch (Exception)
{
pingStatus = false;
}
}
return pingStatus;
}
public static ushort GetUShort(IDataReader reader, string column, ushort defaultValue = 0)
{
if (string.IsNullOrWhiteSpace(column)) { return defaultValue; }
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return defaultValue;
}
try
{
return Convert.ToUInt16(o);
}
catch (Exception ex)
{
APILogger.Log($"Failed to parse string for field {column}", o, ex);
return defaultValue;
}
}
public static uint GetUInt(IDataReader reader, string column, uint defaultValue = 0)
{
if (string.IsNullOrWhiteSpace(column)) { return defaultValue; }
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return defaultValue;
}
try
{
return Convert.ToUInt32(o);
}
catch (Exception ex)
{
APILogger.Log($"Failed to parse string for field {column}", o, ex);
return defaultValue;
}
}
public static string GetString(IDataReader reader, string column, string defaultValue = "")
{
if (string.IsNullOrWhiteSpace(column)) { return defaultValue; }
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return defaultValue;
}
try
{
return Convert.ToString(o);
}
catch (Exception ex)
{
APILogger.Log($"Failed to parse string for field {column}", o, ex);
return defaultValue;
}
}
public static string[] GetStringArray(IDataReader reader,
string column,
string[] defaultValue,
string separator)
{
try
{
var o = reader[column];
if (DBNull.Value.Equals(o)) { return defaultValue; }
var bytes = (byte[])o;
var text = Encoding.UTF8.GetString(bytes);
var values = text.Split(new[] { separator }, StringSplitOptions.None);
return values;
}
catch (Exception ex)
{
APILogger.Log(ex);
return defaultValue;
}
}
public static int GetInt(IDataReader reader, string column, int defaultValue = 0)
{
if (string.IsNullOrWhiteSpace(column))
{
return defaultValue;
}
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return defaultValue;
}
try
{
return Convert.ToInt32(o);
}
catch (Exception ex)
{
APILogger.Log($"Failed to parse int for field {column}", o, ex);
return defaultValue;
}
}
public static double GetDouble(IDataReader reader, string column, double defaultValue = 0D)
{
if (string.IsNullOrWhiteSpace(column))
{
return defaultValue;
}
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return defaultValue;
}
try
{
return Convert.ToDouble(o);
}
catch (Exception ex)
{
APILogger.Log($"Failed to parse double for field {column}", o, ex);
return defaultValue;
}
}
public static short GetShort(IDataReader reader, string column, short defaultValue = 0)
{
if (string.IsNullOrWhiteSpace(column))
{
return defaultValue;
}
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return defaultValue;
}
try
{
return Convert.ToInt16(o);
}
catch (Exception ex)
{
APILogger.Log($"Failed to parse double for field {column}", o, ex);
return defaultValue;
}
}
public static DateTime? GetNullableDateTime(IDataReader reader, string column)
{
if (string.IsNullOrWhiteSpace(column)) { return null; }
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return null;
}
return Convert.ToDateTime(o);
}
public static ulong GetUlong(IDataReader reader, string column, ulong defaultValue = 0)
{
if (string.IsNullOrWhiteSpace(column)) { return defaultValue; }
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return defaultValue;
}
return Convert.ToUInt64(o);
}
public static int? GetNullableInt(IDataReader reader, string column)
{
if (string.IsNullOrWhiteSpace(column)) { return null; }
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return null;
}
return Convert.ToInt32(o);
}
public static byte[] GetByteArray(IDataReader reader, string column)
{
if (string.IsNullOrWhiteSpace(column))
{
return new byte[0];
}
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return new byte[0];
}
return (byte[])reader[column];
}
public static bool GetBool(IDataReader reader, string column, bool defaultValue = false)
{
if (string.IsNullOrWhiteSpace(column))
{
return defaultValue;
}
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return defaultValue;
}
try
{
return Convert.ToBoolean(o);
}
catch (Exception ex)
{
APILogger.Log($"Failed to parse bool for field {column}", o, ex);
return defaultValue;
}
}
public static DateTime GetDateTime(IDataReader reader, string column, DateTime defaultValue)
{
if (string.IsNullOrWhiteSpace(column))
{
return defaultValue;
}
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return defaultValue;
}
try
{
return Convert.ToDateTime(o);
}
catch (Exception ex)
{
APILogger.Log($"Failed to parse DateTime for field {column}", o, ex);
return defaultValue;
}
}
public static long GetLong(IDataReader reader, string column, long defaultValue = 0)
{
if (string.IsNullOrWhiteSpace(column))
{
return defaultValue;
}
var o = reader[column];
if (DBNull.Value.Equals(o))
{
return defaultValue;
}
try
{
return Convert.ToInt64(o);
}
catch (Exception ex)
{
APILogger.Log($"Failed to parse long for field {column}", o, ex);
return defaultValue;
}
}
}
}

View File

@@ -0,0 +1,73 @@
using System.Xml;
using System.Xml.Schema;
namespace DTS.Common.Interface.DASFactory.Config
{
public interface IConfigurationData
{
/// <summary>
/// Array of Module objects in the DAS.
/// </summary>
IDASModule[] Modules { get; set; }
/// <summary>
/// EID's for the whole DAS.
/// </summary>
IEID[] IDs { get; set; }
/// <summary>
/// The ID of the current test/event.
/// </summary>
string TestID { get; set; }
string TestSetupUniqueId { get; set; }
/// <summary>
/// The ID of an instance of a test run, for the purpose
/// of identifying where to download data.
/// </summary>
string InstanceID { get; set; }
/// <summary>
/// A description of the current test/event.
/// </summary>
string Description { get; set; }
bool ClearSetup { get; set; }
/// <summary>
/// Counts how many channels are configured. If a channel's
/// 'IsConfigured' property is 'true' it is configured.
/// </summary>
/// <returns>Number of configured channels</returns>
int NumberOfConfiguredChannels();
/// <summary>
/// Count how many channels we have (regardless if they are configured or not).
/// </summary>
/// <returns>Total number of channels</returns>
int NumberOfChannels();
/// <summary>
/// Count how many downloadable channels (i.e. not UART or StreamOut) we have (regardless if they are configured or not).
/// </summary>
/// <returns>Total number of downloadable channels</returns>
int NumberOfDownloadChannels();
int[] DisplayOrder { get; set; }
int DasDisplayOrder { get; set; }
int GetDisplayOrder(uint channelIdx);
#region Serialization functions
void WriteXml(XmlWriter writer);
void ReadXml(XmlReader reader);
XmlSchema GetSchema();
/// <summary>
/// the Address the DAS receives UDP information from
/// used to control the OBR-DDR
/// </summary>
string UDPReceiveAddress { get; set; }
#endregion
}
}

View File

@@ -0,0 +1,16 @@
using System.Windows;
using System.Windows.Media;
using DTS.Common.Base;
namespace DTS.Common.Classes
{
public class StatusAndProgressBarEventArgs
{
public Color StatusColor { get; set; }
public string StatusText { get; set; }
public double ProgressValue { get; set; }
public Visibility ProgressBarVisibility { get; set; }
public IBaseViewModel Requester { get; set; }
public string ErrorText { get; set; }
}
}

View File

@@ -0,0 +1,72 @@
using System;
using System.Windows;
using System.Runtime.InteropServices;
using System.Windows.Interop;
namespace DTS.Common.Dialogs
{
/// <summary>
/// Interaction logic for NotificationWindow.xaml
/// </summary>
public partial class NotificationWindow : Window
{
public static readonly DependencyProperty NotificationTemplateProperty = DependencyProperty.Register("NotificationTemplate", typeof(DataTemplate), typeof(NotificationWindow), new PropertyMetadata(null));
public static readonly DependencyProperty ImageUriProperty = DependencyProperty.Register("ImageUri", typeof(Uri), typeof(NotificationWindow), new PropertyMetadata(new Uri("pack://application:,,,/" + System.Reflection.Assembly.GetExecutingAssembly() + ";component/RibbonControl/Images/warning_48.png", UriKind.RelativeOrAbsolute)));
/// <summary>
/// Creates a new instance of <see cref="NotificationWindow"/>
/// </summary>
public NotificationWindow()
{
// Hook the SourceInitialized event and then using the SetWindowLong function to strip off the WS_SYSMENU bit.
SourceInitialized += NotificationWindow_SourceInitialized;
InitializeComponent();
}
/// <summary>
/// The <see cref="DataTemplate"/> to apply when displaying <see cref="DTS.Common.Interactivity.InteractionRequest.Confirmation"/> data.
/// </summary>
public DataTemplate NotificationTemplate
{
get => (DataTemplate)GetValue(NotificationTemplateProperty);
set => SetValue(NotificationTemplateProperty, value);
}
/// <summary>
/// Gets or sets the <see cref="Uri"/> for the notification image.
/// </summary>
public Uri ImageUri
{
get => (Uri)GetValue(ImageUriProperty);
set => SetValue(ImageUriProperty, value);
}
void NotificationWindow_SourceInitialized(object sender, EventArgs e)
{
// Removing the Close Button on a WPF window.
// The key here is hooking the SourceInitialized event and then using the SetWindowLong function to strip off the WS_SYSMENU bit.
var wih = new WindowInteropHelper(this);
var style = GetWindowLong(wih.Handle, GWL_STYLE);
SetWindowLong(wih.Handle, GWL_STYLE, style & ~WS_SYSMENU);
}
private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x00080000;
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hwnd, int index, int value);
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hwnd, int index);
public void Connect(int connectionId, object target)
{
}
private void CoppyToClibord_Click(object sender, RoutedEventArgs e)
{
Clipboard.SetText("Hello, clipboard");
}
}
}

View File

@@ -0,0 +1,52 @@
using System.Windows.Controls;
using System.Windows.Media;
namespace DTS.Common.Utils
{
public class ImageButton : Button
{
private readonly Image _image;
private readonly TextBlock _textBlock;
public ImageButton()
{
var panel = new StackPanel
{
Orientation = Orientation.Vertical,
Margin = new System.Windows.Thickness(10)
};
_image = new Image { Margin = new System.Windows.Thickness(0, 0, 0, 0), Stretch = Stretch.Fill };
panel.Children.Add(_image);
_textBlock = new TextBlock();
panel.Children.Add(_textBlock);
Content = panel;
}
private ImageSource _source;
public ImageSource Source
{
get => _source;
set
{
_source = value;
_image.Source = _source;
}
}
private string _imageText;
public string ImageText
{
get => _imageText;
set
{
_imageText = value;
_textBlock.Text = _imageText;
}
}
}
}

View File

@@ -0,0 +1,39 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Threading;
using DTS.Common.Base;
// ReSharper disable CheckNamespace
namespace DTS.Common.Interface
{
public interface IExportGraphMainViewModel : IBaseViewModel
{
/// <summary>
/// Gets the Graph Main View.
/// </summary>
IExportGraphMainView View { get; set; }
IBaseViewModel Parent { get; set; }
List<ITestChannel> LockedChannelList { get; set; }
List<ITestChannel> SelectedChannelList { get; set; }
List<ITestEvent> SelectedEventList { get; set; }
string LockedGroupName { get; set; }
void PublishSelectedChannels();
void AddSelectedChannel(ITestChannel channel);
void AddSelectedGroupChannels(string groupName, List<ITestChannel> channels);
void AddToSelectedEvents(string groupName, List<ITestEvent> events);
void RemoveFromSelectedEvents(string groupName, List<ITestEvent> events);
void SetItemsBetween(int startTreeIndex, int endTreeIndex);
void ResetAllItems();
void AddLockedChannel(ITestChannel channel, bool isLocked);
void AddLockedEvents(string testName, string groupName, List<ITestEvent> events, bool isLocked);
void AddLockedGroupChannels(string testName, string groupName, List<ITestChannel> channels, bool isLocked);
void GraphList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e);
bool SettingChildNodesToTrue { get; set; }
bool SettingOrResettingChildNodes { get; set; }
bool SettingPeerNodeToTrue { get; set; }
bool SettingItemsBetween { get; set; }
bool ResettingAllItems { get; set; }
int LastIndexChecked { get; }
void SetLastIndexChecked(int index);
}
}