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,77 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace DTS.Common.Utils
{
public class StopWatchQueue
{
private readonly Stopwatch _stopWatch;
private readonly Queue<long> _watchQueue;
private readonly string _name;
public StopWatchQueue(string name)
{
_stopWatch = new Stopwatch();
_watchQueue = new Queue<long>(5000);
_name = name;
}
private static double CalculateStdDev(IEnumerable<double> values)
{
double ret = 0;
var valuesArray = values as double[] ?? values.ToArray();
if (valuesArray.Length <= 1) return ret;
//Compute the Average
var avg = valuesArray.Average();
//Perform the Sum of (value-avg)^2
var sum = valuesArray.Sum(d => Math.Pow(d - avg, 2));
//Put it all together
ret = Math.Sqrt(sum / (valuesArray.Length - 1));
return ret;
}
~StopWatchQueue()
{
DumpData();
}
public void DumpData()
{
if (_watchQueue.Count == 0)
return;
var qArray = new double[_watchQueue.Count];
for (var idx = 0; idx < qArray.Length; idx++)
qArray[idx] = Convert.ToDouble(_watchQueue.Dequeue()) / Stopwatch.Frequency * 1000D;
var qMax = qArray.Max();
var qMin = qArray.Min();
var qAvg = qArray.Average();
var qStd = CalculateStdDev(qArray);
var fName = _name + DateTime.Now.ToFileTime() + ".csv";
using (var sw = new StreamWriter(fName, false))
{
sw.WriteLine("The StopWatchQueue contains {0} entries", qArray.Length);
sw.WriteLine("Max={0} Min={1} Average={2} StdDev={3}", qMax, qMin, qAvg, qStd);
sw.WriteLine("All values in milli seconds");
for (var idx = 0; idx < qArray.Length; idx++)
sw.WriteLine("{0},{1}", idx, qArray[idx]);
}
}
public void Start()
{
_stopWatch.Start();
}
public void Stop()
{
_watchQueue.Enqueue(_stopWatch.ElapsedTicks);
_stopWatch.Reset();
}
}
}

View File

@@ -0,0 +1,80 @@
using System.ComponentModel.DataAnnotations;
namespace DTS.Common.Interface.Graphs
{
/// <summary>
/// describes a record in the db for a graph
/// </summary>
public interface IGraphRecord
{
/// <summary>
/// database key for graph
/// </summary>
int GraphId { get; set; }
/// <summary>
/// test setup key for graph
/// </summary>
int TestSetupId { get; set; }
/// <summary>
/// name of graph
/// </summary>
[MaxLength(50)]
string GraphName { get; set; }
/// <summary>
/// description of graph
/// </summary>
[MaxLength(50)]
string GraphDescription { get; set; }
/// <summary>
/// all the channels in the graph
/// </summary>
[MaxLength(2048)]
string ChannelsString { get; set; }
/// <summary>
/// whether to restrict domain axis to a min value
/// </summary>
bool UseDomainMin { get; set; }
/// <summary>
/// the minimum value to show on domain axis
/// (only valid when UseDomainMin is true)
/// </summary>
double DomainMin { get; set; }
/// <summary>
/// whether to restrict domain axis to a max value
/// </summary>
bool UseDomainMax { get; set; }
/// <summary>
/// maximum value to show on domain axis
/// (only valid when UseDomainMax is true)
/// </summary>
double DomainMax { get; set; }
/// <summary>
/// whether to restrict range axis to a min value
/// </summary>
bool UseRangeMin { get; set; }
/// <summary>
/// minimum value to show on range axis
/// (only valid when UseRangeMin is true)
/// </summary>
double RangeMin { get; set; }
/// <summary>
/// whether to restrict range axis to a max value
/// </summary>
bool UseRangeMax { get; set; }
/// <summary>
/// the maximum value to show on the range axis
/// (only valid when UseRangeMax is true)
/// </summary>
double RangeMax { get; set; }
/// <summary>
/// any thresholds/lines to show on the graph
/// </summary>
[MaxLength(2048)]
string ThresholdsString { get; set; }
/// <summary>
/// whether to synchronize record with central db
/// [deprecated]
/// </summary>
bool LocalOnly { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System;
namespace DTS.Common.Interface.Groups
{
/// <summary>
/// Interface describing a GroupHardware record in the Db
/// </summary>
public interface IGroupHardwareDbRecord
{
[Key]
[Column("Id")]
/// <summary>
/// The id/key of the GroupHardware record in the db
/// </summary>
int Id { get; set; }
[Column("GroupId")]
int GroupId { get; set; }
[Column("DASId")]
int DASId { get; set; }
[Column("SerialNumber")]
string SerialNumber { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Windows.Data;
using System.Windows.Media;
namespace DTS.Common.Converters
{
public class TriggerTextConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is bool b)
{
if (b) { return Strings.Strings.Triggered; }
else { return Strings.Strings.TriggerClear; }
}
return Strings.Strings.TriggerClear;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTS.Common.XMLUtils
{
public class HardwareXMLClass
{
public string Hardware { get; set; }
}
}