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,80 @@
using DTS.Common.Interface.DASFactory.Diagnostics;
using System;
namespace DTS.Common.Classes.DASFactory
{
public class CanDiagnostics : Base.BasePropertyChanged, ICanDiagnosticResult
{
private bool _Active = false;
public bool Active
{
get => _Active;
set => SetProperty(ref _Active, value);
}
private int _ChannelIndex = -1;
public int ChannelIndex
{
get => _ChannelIndex;
set => SetProperty(ref _ChannelIndex, value);
}
private int _Data = 0;
public int Data
{
get => _Data;
set => SetProperty(ref _Data, value);
}
private int _ErrorFrame = 0;
public int ErrorFrame
{
get => _ErrorFrame;
set
{
SetProperty(ref _ErrorFrame, value);
OnPropertyChanged("Errors");
}
}
private double _Load;
public double Load
{
get => _Load;
set => SetProperty(ref _Load, value);
}
private int _Overruns = 0;
public int Overruns
{
get => _Overruns;
set
{
SetProperty(ref _Overruns, value);
OnPropertyChanged("Errors");
}
}
private DateTime _LastUpdate = DateTime.MinValue;
public DateTime LastUpdate
{
get => _LastUpdate;
set => SetProperty(ref _LastUpdate, value);
}
public int Errors
{
get => _ErrorFrame != 0 ? 1 + Overruns : Overruns;
}
private string _ChannelName = string.Empty;
public string ChannelName
{
get => _ChannelName;
set => SetProperty(ref _ChannelName, value);
}
public void Copy(ICanDiagnosticResult source)
{
Active = source.Active;
ChannelIndex = source.ChannelIndex;
Data = source.Data;
ErrorFrame = source.ErrorFrame;
Load = source.Load;
Overruns = source.Overruns;
LastUpdate = source.LastUpdate;
ChannelName = source.ChannelName;
}
}
}

View File

@@ -0,0 +1,22 @@
namespace DTS.Common.Classes.DASFactory
{
/// <summary>
/// currently used to hold CAN BIST rows - we may expand this to other hardware in future
/// </summary>
public class DiagnosticMessageRow
{
public string Field { get; set; }
public string Value { get; set; }
public string Verdict { get; set; }
public DiagnosticMessageRow(string field, string value, string verdict)
{
Field = field;
Value = value;
Verdict = verdict;
}
public override string ToString()
{
return $"Field: {Field}, Value: {Value}, Verdict: {Verdict}";
}
}
}

View File

@@ -0,0 +1,45 @@
using DTS.Common.Interface.DASFactory.Diagnostics;
using DTS.Common.Interface.Sensors.AnalogDiagnostics;
namespace DTS.Common.Classes.DASFactory
{
public class TCDiagnosticResult : Base.BasePropertyChanged, ITCDiagnosticResult
{
private string _channelName = string.Empty;
public string ChannelName
{
get => _channelName;
set => SetProperty(ref _channelName, value);
}
private int _channelIndex;
public int ChannelIndex
{
get => _channelIndex;
set => SetProperty(ref _channelIndex, value);
}
private double? _currentReading = null;
public double? CurrentReading { get => _currentReading; set => SetProperty(ref _currentReading, value); }
private DiagnosticStatus _status = DiagnosticStatus.Untested;
public DiagnosticStatus Status
{
get => _status;
set => SetProperty(ref _status, value);
}
private ConnectionStatuses _connectionStatus = ConnectionStatuses.NotTested;
public ConnectionStatuses ConnectionStatus
{
get => _connectionStatus;
set => SetProperty(ref _connectionStatus, value);
}
public void Copy(ITCDiagnosticResult source)
{
ChannelName = source.ChannelName;
CurrentReading = source.CurrentReading;
Status = source.Status;
ConnectionStatus = source.ConnectionStatus;
}
}
}

View File

@@ -0,0 +1,242 @@
using DTS.Common.Enums;
using System;
using System.Linq;
using System.Text;
namespace DTS.Common.Classes.DASFactory
{
/// <summary>
/// this class encapsulates/replaces a uint array that was already in use in FWTU and DP
/// it adds some named fields and some to and from just to make things a little easier
/// </summary>
public class TMNSConfig
{
/// <summary>
/// the TMNS config implementation in firmware is just an array of uint32, so here's the same thing internally
/// </summary>
private uint[] _values;
/// <summary>
/// the TMNS PCM sub frame id
/// </summary>
public uint TMNS_PCMSubFrameId
{
get => GetValue(Fields.TMNS_PCMSubFrameID);
set => SetValue(Fields.TMNS_PCMSubFrameID, value);
}
/// <summary>
/// the TMNS message id
/// </summary>
public uint TMNS_MsgId
{
get => GetValue(Fields.TMNS_MsgId);
set => SetValue(Fields.TMNS_MsgId, value);
}
/// <summary>
/// the TMNS PCM minor per major setting
/// </summary>
public uint TMNS_PCMMinorPerMajor
{
get => GetValue(Fields.TMNS_PCMMinorPerMajor);
set => SetValue(Fields.TMNS_PCMMinorPerMajor, value);
}
/// <summary>
/// the TMNS TMATs port number setting
/// </summary>
public uint TMNS_TMATSPortNumber
{
get => GetValue(Fields.TMNS_TMATSPortNumber);
set => SetValue(Fields.TMNS_TMATSPortNumber, value);
}
/// <summary>
/// the IENA UDP source port number
/// </summary>
public uint IENAUDP_PortNumber
{
get => GetValue(Fields.IENAUDP_PortNumber);
set => SetValue(Fields.IENAUDP_PortNumber, value);
}
/// <summary>
/// reserved field 5
/// </summary>
public uint TMNS5
{
get => GetValue(Fields.TMNS5);
set => SetValue(Fields.TMNS5, value);
}
/// <summary>
/// reserved field 6
/// </summary>
public uint TMNS6
{
get => GetValue(Fields.TMNS6);
set => SetValue(Fields.TMNS6, value);
}
/// <summary>
/// reserved field 7
/// </summary>
public uint TMNS7
{
get => GetValue(Fields.TMNS7);
set => SetValue(Fields.TMNS7, value);
}
/// <summary>
/// all fields in the TMNS config unit array and their order
/// </summary>
public enum Fields
{
TMNS_PCMSubFrameID,
TMNS_MsgId,
TMNS_PCMMinorPerMajor,
TMNS_TMATSPortNumber,
IENAUDP_PortNumber,
TMNS5,
TMNS6,
TMNS7
}
/// <summary>
/// handles common init from all constructors
/// </summary>
private void CommonInit()
{
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
_values = new uint[fields.Length];
}
/// <summary>
/// constructor that takes an array of uints in the same order as the TMNS config
/// </summary>
/// <param name="parameters"></param>
public TMNSConfig(uint[] parameters)
{
CommonInit();
if (null == parameters) { return; }
for (var i = 0; i < parameters.Length && i < _values.Length; i++)
{
_values[i] = parameters[i];
}
}
/// <summary>
/// constructor that takes an array of uints comma separated (and allows for enclosing () around whole string)
/// </summary>
/// <param name="parameters"></param>
public TMNSConfig(string parameters)
{
CommonInit();
parameters = parameters.Replace("(", "").Replace(")", "");
var tokens = parameters.Split(new[] { ',' });
for (var i = 0; i < tokens.Length && i < _values.Length; i++)
{
if (uint.TryParse(tokens[i], out var temp))
{
_values[i] = temp;
}
}
}
public TMNSConfig()
{
CommonInit();
}
/// <summary>
/// sets indicated field to indicated value
/// </summary>
/// <param name="field"></param>
/// <param name="value"></param>
public void SetValue(Fields field, uint value)
{
_values[(int)field] = value;
}
/// <summary>
/// gets the value from the indicated field
/// </summary>
/// <param name="field"></param>
/// <returns></returns>
public uint GetValue(Fields field) => _values[(int)field];
public uint[] ToUintArray()
{
var copy = new uint[_values.Length];
_values.CopyTo(copy, 0);
return copy;
}
/// <summary>
/// returns a string suitable for storage (x,...n) of the TMNS config
/// </summary>
/// <returns></returns>
public string ToCSVString()
{
var sb = new StringBuilder();
sb.Append("(");
for (var i = 0; i < _values.Length; i++)
{
if (i > 0) { sb.Append(","); }
sb.Append(_values[i]);
}
sb.Append(")");
return sb.ToString();
}
/// <summary>
/// returns true if the profile is a ch10 streaming profile
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
public static bool IsCh10(UDPStreamProfile profile)
{
switch (profile)
{
case UDPStreamProfile.CH10_MANUAL_CONFIG:
case UDPStreamProfile.CH10_PCM128_MM:
case UDPStreamProfile.CH10_ANALOG:
case UDPStreamProfile.CH10_PCM_STANDARD:
case UDPStreamProfile.CH10_PCM_SUPERCOM:
case UDPStreamProfile.CH10_PCM_128BIT_2HDR:
case UDPStreamProfile.CH10_ANALOG_2HDR:
case UDPStreamProfile.CH10_PCM_STANDARD_2HDR:
case UDPStreamProfile.CH10_PCM_SUPERCOM_2HDR:
return true;
default:
return false;
}
}
/// <summary>
/// returns true if the streaming profile is an IENA profile
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
public static bool IsIENA(UDPStreamProfile profile)
{
switch (profile)
{
case UDPStreamProfile.IENA_PTYPE_STREAM: return true;
default: return false;
}
}
/// <summary>
/// returns true if the streaming profile is a TMNS profile
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
public static bool IsTMNS(UDPStreamProfile profile)
{
switch (profile)
{
case UDPStreamProfile.TMNS_PCM_STANDARD:
case UDPStreamProfile.TMNS_PCM_SUPERCOM:
return true;
default: return false;
}
}
/// <summary>
/// returns true if the streaming profile is a UART profile
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
public static bool IsUART(UDPStreamProfile profile)
{
switch (profile)
{
case UDPStreamProfile.UART_STREAM: return true;
default: return false;
}
}
}
}

View File

@@ -0,0 +1,116 @@
using DTS.Common.Enums.DASFactory;
using System;
using System.Collections;
using System.Collections.Generic;
using static DTS.Common.Enums.DASFactory.DFConstantsAndEnums;
namespace DTS.Common.Classes.DASFactory
{
public class TemperatureConfig
{
public ushort LogEnable { get; set; }
public ushort LogIntervalSec { get; set; }
private BitArray _channels = new BitArray(new[] { 0x00, 0x00 });
public ushort Channels
{
get
{
var bytes = new byte[2];
_channels.CopyTo(bytes, 0);
return BitConverter.ToUInt16(bytes, 0);
}
set
{
var bytes = BitConverter.GetBytes(value);
_channels = new BitArray(bytes);
}
}
public const ushort Reserved = 0;
public bool MCUTemp
{
get => _channels.Get((int)TempLogChannelBits.OnBoardTemp);
set => _channels.Set((int)TempLogChannelBits.OnBoardTemp, value);
}
public bool OnBoardHumidity
{
get => _channels.Get((int)TempLogChannelBits.OnBoardHumidity);
set => _channels.Set((int)TempLogChannelBits.OnBoardHumidity, value);
}
public bool EnvironmentalCh1
{
get => _channels.Get((int)TempLogChannelBits.EnvironmentalCh1);
set => _channels.Set((int)TempLogChannelBits.EnvironmentalCh1, value);
}
public bool EnvironmentalCh2
{
get => _channels.Get((int)TempLogChannelBits.EnvironmentalCh2);
set => _channels.Set((int)TempLogChannelBits.EnvironmentalCh2, value);
}
public bool EnvironmentalCh3
{
get => _channels.Get((int)TempLogChannelBits.EnvironmentalCh3);
set => _channels.Set((int)TempLogChannelBits.EnvironmentalCh3, value);
}
public bool EnvironmentalCh4
{
get => _channels.Get((int)TempLogChannelBits.EnvironmentalCh4);
set => _channels.Set((int)TempLogChannelBits.EnvironmentalCh4, value);
}
public ushort[] ToUShortArray()
{
return new[] { LogEnable, LogIntervalSec, Channels, Reserved };
}
public TemperatureConfig() { }
public TemperatureConfig(ushort[] ushortArray)
{
if (null == ushortArray) { return; }
LogEnable = GetUShort(ushortArray, 0);
LogIntervalSec = GetUShort(ushortArray, 1);
Channels = GetUShort(ushortArray, 2);
}
private ushort GetUShort(ushort[] ushortArray, int position)
{
if (ushortArray.Length > position) { return ushortArray[position]; }
return 0;
}
public int[] GetChannelsArray()
{
var list = new List<int>();
for (var i = 0; i < _channels.Length; i++)
{
if (_channels.Get(i))
{
list.Add(i);
}
}
return list.ToArray();
}
public S6DBDiagnosticChannelList[] GetMeasurementChannels()
{
var list = new List<S6DBDiagnosticChannelList>();
if (MCUTemp) { list.Add(S6DBDiagnosticChannelList.DiagMcuTemperature); }
if (OnBoardHumidity) { list.Add(S6DBDiagnosticChannelList.DiagEnv_1_Humidity); }
if (EnvironmentalCh1) { list.Add(S6DBDiagnosticChannelList.DiagEnv_1_Temperature); }
if (EnvironmentalCh2) { list.Add(S6DBDiagnosticChannelList.DiagEnv_2_Temperature); }
if (EnvironmentalCh3) { list.Add(S6DBDiagnosticChannelList.DiagEnv_3_Temperature); }
if (EnvironmentalCh4) { list.Add(S6DBDiagnosticChannelList.DiagEnv_4_Temperature); }
return list.ToArray();
}
private readonly Dictionary<S6DBDiagnosticChannelList, TempLogChannelBits> _diagChannelToTempLogBit = new Dictionary<S6DBDiagnosticChannelList, TempLogChannelBits>()
{
{S6DBDiagnosticChannelList.DiagMcuTemperature, TempLogChannelBits.OnBoardTemp },
{S6DBDiagnosticChannelList.DiagEnv_1_Humidity, TempLogChannelBits.OnBoardHumidity },
{S6DBDiagnosticChannelList.DiagEnv_1_Temperature, TempLogChannelBits.EnvironmentalCh1 },
{S6DBDiagnosticChannelList.DiagEnv_2_Temperature, TempLogChannelBits.EnvironmentalCh2 },
{S6DBDiagnosticChannelList.DiagEnv_3_Temperature, TempLogChannelBits.EnvironmentalCh3 },
{S6DBDiagnosticChannelList.DiagEnv_4_Temperature, TempLogChannelBits.EnvironmentalCh4 }
};
public TempLogChannelBits GetChannelBitForDiagChannel(S6DBDiagnosticChannelList ch)
{
if (_diagChannelToTempLogBit.ContainsKey(ch)) { return _diagChannelToTempLogBit[ch]; }
throw new NullReferenceException($"Not found: {ch}");
}
}
}