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,36 @@
<UserControl x:Class="DTS.Common.Controls.ChannelNameBuilder"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DTS.Common.Controls"
xmlns:strings="clr-namespace:DTS.Common.Strings"
xmlns:behaviors="clr-namespace:DTS.Common.Behaviors"
mc:Ignorable="d"
x:Name="dtsChannelNameBuilder"
d:DesignHeight="450" d:DesignWidth="800" Loaded="ChannelNameBuilder_OnLoaded"
AutomationProperties.AutomationId="NameChannelBuilderUserControl"
>
<UserControl.Resources>
<!--<local:CodeTypeToCharacterCasingConverter x:Key="CodeTypeToCharacterCasingConverter" />-->
</UserControl.Resources>
<TextBox x:Name="MainEditBox" x:FieldModifier="public" HorizontalAlignment="Stretch" DataContext="{Binding ElementName=dtsChannelNameBuilder}"
LostFocus="MainEditBox_OnLostFocus"
GotKeyboardFocus="MainEditBox_OnGotKeyboardFocus"
MouseDoubleClick="MainEditBox_OnMouseDoubleClick"
PreviewKeyDown="MainEditBox_OnPreviewKeyDown"
AutomationProperties.AutomationId="CNB_MainEditTextBox"
behaviors:TextBoxPasteBehavior.PasteCommand="{Binding PasteCommand}"
Binding.SourceUpdated="TextBoxSourceUpdated"
TextChanged="MainEditBox_OnTextChanged"
Tag="{Binding Tag}">
<TextBox.Text>
<Binding NotifyOnSourceUpdated="True" Path="ChannelName" UpdateSourceTrigger="PropertyChanged" />
</TextBox.Text>
<TextBox.InputBindings>
<KeyBinding Key="Enter"
Command="{local:UpdatePropertySourceWhenEnterPressed}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type TextBox}}}" />
</TextBox.InputBindings>
</TextBox>
</UserControl>

View File

@@ -0,0 +1,642 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
namespace DTS.Common.Base.Classes
{
/// <summary>
/// https://stackoverflow.com/questions/16422844/propertygrid-browsable-not-found-for-entity-framework-created-property-how-to-f
/// </summary>
public sealed class DynamicTypeDescriptor : ICustomTypeDescriptor, INotifyPropertyChanged
{
private Type _type;
private AttributeCollection _attributes;
private TypeConverter _typeConverter;
private Dictionary<Type, object> _editors;
private EventDescriptor _defaultEvent;
private PropertyDescriptor _defaultProperty;
private EventDescriptorCollection _events;
public event PropertyChangedEventHandler PropertyChanged;
private DynamicTypeDescriptor()
{
}
public DynamicTypeDescriptor(Type type)
{
if (type == null)
throw new ArgumentNullException("type");
_type = type;
_typeConverter = TypeDescriptor.GetConverter(type);
_defaultEvent = TypeDescriptor.GetDefaultEvent(type);
_defaultProperty = TypeDescriptor.GetDefaultProperty(type);
_events = TypeDescriptor.GetEvents(type);
List<PropertyDescriptor> normalProperties = new List<PropertyDescriptor>();
OriginalProperties = TypeDescriptor.GetProperties(type);
foreach (PropertyDescriptor property in OriginalProperties)
{
if (!property.IsBrowsable)
continue;
normalProperties.Add(property);
}
Properties = new PropertyDescriptorCollection(normalProperties.ToArray());
_attributes = TypeDescriptor.GetAttributes(type);
_editors = new Dictionary<Type, object>();
object editor = TypeDescriptor.GetEditor(type, typeof(UITypeEditor));
if (editor != null)
{
_editors.Add(typeof(UITypeEditor), editor);
}
editor = TypeDescriptor.GetEditor(type, typeof(ComponentEditor));
if (editor != null)
{
_editors.Add(typeof(ComponentEditor), editor);
}
editor = TypeDescriptor.GetEditor(type, typeof(InstanceCreationEditor));
if (editor != null)
{
_editors.Add(typeof(InstanceCreationEditor), editor);
}
}
public T GetPropertyValue<T>(string name, T defaultValue)
{
if (name == null)
throw new ArgumentNullException("name");
foreach (PropertyDescriptor pd in Properties)
{
if (pd.Name == name)
{
try
{
return (T)Convert.ChangeType(pd.GetValue(Component), typeof(T));
}
catch
{
return defaultValue;
}
}
}
return defaultValue;
}
public void SetPropertyValue(string name, object value)
{
if (name == null)
throw new ArgumentNullException("name");
foreach (PropertyDescriptor pd in Properties)
{
if (pd.Name == name)
{
pd.SetValue(Component, value);
break;
}
}
}
internal void OnValueChanged(PropertyDescriptor prop)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(prop.Name));
}
}
internal static T GetAttribute<T>(AttributeCollection attributes) where T : Attribute
{
if (attributes == null)
return null;
foreach (Attribute att in attributes)
{
if (typeof(T).IsAssignableFrom(att.GetType()))
return (T)att;
}
return null;
}
public sealed class DynamicProperty : PropertyDescriptor, INotifyPropertyChanged
{
private readonly Type _type;
private readonly bool _hasDefaultValue;
private readonly object _defaultValue;
private readonly PropertyDescriptor _existing;
private readonly DynamicTypeDescriptor _descriptor;
private Dictionary<Type, object> _editors;
private bool? _readOnly;
private bool? _browsable;
private string _displayName;
private string _description;
private string _category;
private List<Attribute> _attributes = new List<Attribute>();
public event PropertyChangedEventHandler PropertyChanged;
internal DynamicProperty(DynamicTypeDescriptor descriptor, Type type, object value, string name, Attribute[] attrs)
: base(name, attrs)
{
_descriptor = descriptor;
_type = type;
Value = value;
DefaultValueAttribute def = DynamicTypeDescriptor.GetAttribute<DefaultValueAttribute>(Attributes);
if (def == null)
{
_hasDefaultValue = false;
}
else
{
_hasDefaultValue = true;
_defaultValue = def.Value;
}
if (attrs != null)
{
foreach (Attribute att in attrs)
{
_attributes.Add(att);
}
}
}
internal static Attribute[] GetAttributes(PropertyDescriptor existing)
{
List<Attribute> atts = new List<Attribute>();
foreach (Attribute a in existing.Attributes)
{
atts.Add(a);
}
return atts.ToArray();
}
internal DynamicProperty(DynamicTypeDescriptor descriptor, PropertyDescriptor existing, object component)
: this(descriptor, existing.PropertyType, existing.GetValue(component), existing.Name, GetAttributes(existing))
{
_existing = existing;
}
public void RemoveAttributesOfType<T>() where T : Attribute
{
List<Attribute> remove = new List<Attribute>();
foreach (Attribute att in _attributes)
{
if (typeof(T).IsAssignableFrom(att.GetType()))
{
remove.Add(att);
}
}
foreach (Attribute att in remove)
{
_attributes.Remove(att);
}
}
public IList<Attribute> AttributesList
{
get
{
return _attributes;
}
}
public override AttributeCollection Attributes
{
get
{
return new AttributeCollection(_attributes.ToArray());
}
}
public object Value { get; set; }
public override bool CanResetValue(object component)
{
if (_existing != null)
return _existing.CanResetValue(component);
return _hasDefaultValue;
}
public override Type ComponentType
{
get
{
if (_existing != null)
return _existing.ComponentType;
return typeof(object);
}
}
public override object GetValue(object component)
{
if (_existing != null)
return _existing.GetValue(component);
return Value;
}
public override string Category
{
get
{
if (_category != null)
return _category;
return base.Category;
}
}
public void SetCategory(string category)
{
_category = category;
}
public override string Description
{
get
{
if (_description != null)
return _description;
return base.Description;
}
}
public void SetDescription(string description)
{
_description = description;
}
public override string DisplayName
{
get
{
if (_displayName != null)
return _displayName;
if (_existing != null)
return _existing.DisplayName;
return base.DisplayName;
}
}
public void SetDisplayName(string displayName)
{
_displayName = displayName;
}
public override bool IsBrowsable
{
get
{
if (_browsable.HasValue)
return _browsable.Value;
return base.IsBrowsable;
}
}
public void SetBrowsable(bool browsable)
{
_browsable = browsable;
}
public override bool IsReadOnly
{
get
{
if (_readOnly.HasValue)
return _readOnly.Value;
if (_existing != null)
return _existing.IsReadOnly;
ReadOnlyAttribute att = DynamicTypeDescriptor.GetAttribute<ReadOnlyAttribute>(Attributes);
if (att == null)
return false;
return att.IsReadOnly;
}
}
public void SetIsReadOnly(bool readOnly)
{
_readOnly = readOnly;
}
public override Type PropertyType
{
get
{
if (_existing != null)
return _existing.PropertyType;
return _type;
}
}
public override void ResetValue(object component)
{
if (_existing != null)
{
_existing.ResetValue(component);
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(Name));
}
_descriptor.OnValueChanged(this);
return;
}
if (CanResetValue(component))
{
Value = _defaultValue;
_descriptor.OnValueChanged(this);
}
}
public override void SetValue(object component, object value)
{
if (_existing != null)
{
_existing.SetValue(component, value);
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(Name));
}
_descriptor.OnValueChanged(this);
return;
}
Value = value;
_descriptor.OnValueChanged(this);
}
public override bool ShouldSerializeValue(object component)
{
if (_existing != null)
return _existing.ShouldSerializeValue(component);
return false;
}
public override object GetEditor(Type editorBaseType)
{
if (editorBaseType == null)
throw new ArgumentNullException("editorBaseType");
if (_editors != null)
{
object type;
if ((_editors.TryGetValue(editorBaseType, out type)) && (type != null))
return type;
}
return base.GetEditor(editorBaseType);
}
public void SetEditor(Type editorBaseType, object obj)
{
if (editorBaseType == null)
throw new ArgumentNullException("editorBaseType");
if (_editors == null)
{
if (obj == null)
return;
_editors = new Dictionary<Type, object>();
}
if (obj == null)
{
_editors.Remove(editorBaseType);
}
else
{
_editors[editorBaseType] = obj;
}
}
}
public PropertyDescriptor AddProperty(Type type, string name, object value, string displayName, string description, string category, bool hasDefaultValue, object defaultValue, bool readOnly)
{
return AddProperty(type, name, value, displayName, description, category, hasDefaultValue, defaultValue, readOnly, null);
}
public PropertyDescriptor AddProperty(
Type type,
string name,
object value,
string displayName,
string description,
string category,
bool hasDefaultValue,
object defaultValue,
bool readOnly,
Type uiTypeEditor)
{
if (type == null)
throw new ArgumentNullException("type");
if (name == null)
throw new ArgumentNullException("name");
List<Attribute> atts = new List<Attribute>();
if (!string.IsNullOrEmpty(displayName))
{
atts.Add(new DisplayNameAttribute(displayName));
}
if (!string.IsNullOrEmpty(description))
{
atts.Add(new DescriptionAttribute(description));
}
if (!string.IsNullOrEmpty(category))
{
atts.Add(new CategoryAttribute(category));
}
if (hasDefaultValue)
{
atts.Add(new DefaultValueAttribute(defaultValue));
}
if (uiTypeEditor != null)
{
atts.Add(new EditorAttribute(uiTypeEditor, typeof(UITypeEditor)));
}
if (readOnly)
{
atts.Add(new ReadOnlyAttribute(true));
}
DynamicProperty property = new DynamicProperty(this, type, value, name, atts.ToArray());
AddProperty(property);
return property;
}
public void RemoveProperty(string name)
{
if (name == null)
throw new ArgumentNullException("name");
List<PropertyDescriptor> remove = new List<PropertyDescriptor>();
foreach (PropertyDescriptor pd in Properties)
{
if (pd.Name == name)
{
remove.Add(pd);
}
}
foreach (PropertyDescriptor pd in remove)
{
Properties.Remove(pd);
}
}
public void AddProperty(PropertyDescriptor property)
{
if (property == null)
throw new ArgumentNullException("property");
Properties.Add(property);
}
public override string ToString()
{
return base.ToString() + " (" + Component + ")";
}
public PropertyDescriptorCollection OriginalProperties { get; private set; }
public PropertyDescriptorCollection Properties { get; private set; }
public DynamicTypeDescriptor FromComponent(object component)
{
if (component == null)
throw new ArgumentNullException("component");
if (!_type.IsAssignableFrom(component.GetType()))
throw new ArgumentException(null, "component");
DynamicTypeDescriptor desc = new DynamicTypeDescriptor();
desc._type = _type;
desc.Component = component;
// shallow copy on purpose
desc._typeConverter = _typeConverter;
desc._editors = _editors;
desc._defaultEvent = _defaultEvent;
desc._defaultProperty = _defaultProperty;
desc._attributes = _attributes;
desc._events = _events;
desc.OriginalProperties = OriginalProperties;
// track values
List<PropertyDescriptor> properties = new List<PropertyDescriptor>();
foreach (PropertyDescriptor pd in Properties)
{
DynamicProperty ap = new DynamicProperty(desc, pd, component);
properties.Add(ap);
}
desc.Properties = new PropertyDescriptorCollection(properties.ToArray());
return desc;
}
public object Component { get; private set; }
public string ClassName { get; set; }
public string ComponentName { get; set; }
AttributeCollection ICustomTypeDescriptor.GetAttributes()
{
return _attributes;
}
string ICustomTypeDescriptor.GetClassName()
{
if (ClassName != null)
return ClassName;
if (Component != null)
return Component.GetType().Name;
if (_type != null)
return _type.Name;
return null;
}
string ICustomTypeDescriptor.GetComponentName()
{
if (ComponentName != null)
return ComponentName;
return Component != null ? Component.ToString() : null;
}
TypeConverter ICustomTypeDescriptor.GetConverter()
{
return _typeConverter;
}
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent()
{
return _defaultEvent;
}
PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty()
{
return _defaultProperty;
}
object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
{
object editor;
if (_editors.TryGetValue(editorBaseType, out editor))
return editor;
return null;
}
EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
{
return _events;
}
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
{
return _events;
}
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
{
return Properties;
}
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
{
return Properties;
}
object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
{
return Component;
}
}
}

View File

@@ -0,0 +1,43 @@
namespace DTS.Common.Interface.DASFactory.Download
{
public interface IUARTEventInfo
{
/// <summary>
/// From which event do we want to download data?
/// </summary>
ushort EventNumber { get; set; }
/// <summary>
/// Is data present?
/// </summary>
bool DataPresent { get; set; }
/// <summary>
/// Has data already been downloaded?
/// </summary>
bool DataDownloaded { get; set; }
/// <summary>
/// How much data is there?
/// </summary>
ulong TotalByteCount { get; set; }
/// <summary>
/// Where in the data did the trigger occur?
/// </summary>
ulong TriggerByteCount { get; set; }
/// <summary>
/// Where are the faults?
/// </summary>
ulong FaultByteCount { get; set; }
/// <summary>
/// When did the UART stream start?
/// </summary>
ulong StartTimestamp { get; set; }
/// <summary>
/// When did the UART stream end?
/// </summary>
ulong EndTimestamp { get; set; }
/// <summary>
/// What was the baud rate during UART recording?
/// </summary>
uint BaudRate { get; set; }
}
}

View File

@@ -0,0 +1,44 @@
using System;
namespace DTS.Common.Attributes
{
public class ProgrammableTriggersAttribute : Attribute
{
public bool PreTrigger { get; set; }
public bool PostTrigger { get; set; }
public ProgrammableTriggersAttribute(bool preTrigger, bool postTrigger)
{
PreTrigger = preTrigger;
PostTrigger = postTrigger;
}
public static bool IsPreTriggerProgrammable(Enum value)
{
var fi = value.GetType().GetField(value.ToString());
var attributes = fi.GetCustomAttributes(typeof(ProgrammableTriggersAttribute), false);
if (attributes.Length > 0)
{
if (attributes[0] is ProgrammableTriggersAttribute attr)
{
return attr.PreTrigger;
}
}
return true;
}
public static bool IsPostTriggerProgrammable(Enum value)
{
var fi = value.GetType().GetField(value.ToString());
var attributes = fi.GetCustomAttributes(typeof(ProgrammableTriggersAttribute), false);
if (attributes.Length > 0)
{
if (attributes[0] is ProgrammableTriggersAttribute attr)
{
return attr.PostTrigger;
}
}
return true;
}
}
}

View File

@@ -0,0 +1,359 @@
using DTS.Common.Enums;
using DTS.Common.Enums.DASFactory;
using DTS.Common.Interface.DASFactory;
using DTS.Common.Interface.Hardware;
using DTS.Common.Utilities.Logging;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
namespace DTS.Common.Classes.Hardware
{
public class DASMonitorInfo : IDASMonitorInfo
{
public string SerialNumber { get; private set; }
public double[] TiltSensorCals { get; private set; } = new double[18];
public short[] TiltSensorDataPre { get; private set; } = new short[3];
public DFConstantsAndEnums.TiltAxes TiltAxes { get; private set; } = DFConstantsAndEnums.TiltAxes.IXIYIZ;
public int AxisIgnored { get; private set; }
public double MountOffsetAxisOne { get; private set; } = double.NaN;
public double MountOffsetAxisTwo { get; private set; } = double.NaN;
private string[] _channelNames = new string[0];
public string GetChannelName(int index)
{
if (index >= _channelNames.Length) { return $"{Strings.Strings.Ch}#{1 + index:00}"; }
return _channelNames[index];
}
private double[] _offsetTolerancesHigh = new double[6];
public double GetOffsetTolerancemVHigh(int index)
{
if (index >= _offsetTolerancesHigh.Length) { return 0D; }
return _offsetTolerancesHigh[index];
}
private double[] _offsetTolerancesLow = new double[6];
public double GetOffsetTolerancemVLow(int index)
{
if (index >= _offsetTolerancesLow.Length) { return 0D; }
return _offsetTolerancesLow[index];
}
public void ReadFromFile(string path)
{
if (!File.Exists(path)) { return; }
try
{
var lines = File.ReadAllLines(path);
var keys = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
for (var i = 0; i < lines.Length && i < keys.Length; i++)
{
var line = lines[i];
var key = keys[i];
switch (key)
{
case Fields.SerialNumber:
SerialNumber = line;
break;
case Fields.TiltSensorCals:
TiltSensorCals = ToDoubleArray(line);
break;
case Fields.TiltSensorDataPre:
TiltSensorDataPre = ToShortArray(line);
break;
case Fields.TiltAxes:
TiltAxes = (DFConstantsAndEnums.TiltAxes)Enum.Parse(typeof(DFConstantsAndEnums.TiltAxes), line);
break;
case Fields.AxesIgnored:
AxisIgnored = int.Parse(line, CultureInfo.InvariantCulture);
break;
case Fields.MountOffsetAxisOne:
MountOffsetAxisOne = double.Parse(line, CultureInfo.InvariantCulture);
break;
case Fields.MountOffsetAxisTwo:
MountOffsetAxisTwo = double.Parse(line, CultureInfo.InvariantCulture);
break;
case Fields.ChannelNames:
_channelNames = ToStringArray(line);
break;
case Fields.OffsetTolerancesLow:
_offsetTolerancesLow = ToDoubleArray(line);
break;
case Fields.OffsetTolerancesHigh:
_offsetTolerancesHigh = ToDoubleArray(line);
break;
}
}
}
catch (Exception ex)
{
APILogger.Log(ex);
}
}
private short[] ToShortArray(string line)
{
var shorts = new List<short>();
var tokens = line.Split(new[] { SEPARATOR }, StringSplitOptions.None);
foreach (var token in tokens)
{
if (short.TryParse(line, NumberStyles.Any, CultureInfo.InvariantCulture, out var s))
{
shorts.Add(s);
}
}
return shorts.ToArray();
}
private string[] ToStringArray(string line)
{
return line.Split(new[] { SEPARATOR }, StringSplitOptions.None);
}
private double[] ToDoubleArray(string line)
{
var doubles = new List<double>();
var tokens = line.Split(new[] { SEPARATOR }, StringSplitOptions.None);
foreach (var token in tokens)
{
if (double.TryParse(token, NumberStyles.Any, CultureInfo.InvariantCulture, out double d))
{
doubles.Add(d);
}
}
return doubles.ToArray();
}
private const string SEPARATOR = ",";
public void WriteToFile(string path)
{
try
{
var lines = new List<string>();
var keys = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
foreach (var key in keys)
{
switch (key)
{
case Fields.SerialNumber:
lines.Add(SerialNumber);
break;
case Fields.TiltSensorCals:
lines.Add(ToString(TiltSensorCals));
break;
case Fields.TiltSensorDataPre:
lines.Add(ToString(TiltSensorDataPre));
break;
case Fields.TiltAxes:
lines.Add(TiltAxes.ToString());
break;
case Fields.AxesIgnored:
lines.Add(AxisIgnored.ToString());
break;
case Fields.MountOffsetAxisOne:
lines.Add(MountOffsetAxisOne.ToString(CultureInfo.InvariantCulture));
break;
case Fields.MountOffsetAxisTwo:
lines.Add(MountOffsetAxisTwo.ToString(CultureInfo.InvariantCulture));
break;
case Fields.ChannelNames:
lines.Add(ToString(_channelNames));
break;
case Fields.OffsetTolerancesLow:
lines.Add(ToString(_offsetTolerancesLow));
break;
case Fields.OffsetTolerancesHigh:
lines.Add(ToString(_offsetTolerancesHigh));
break;
}
}
File.WriteAllLines(path, lines.ToArray());
}
catch (Exception ex)
{
APILogger.Log(ex);
}
}
private string ToString(string[] values)
{
return string.Join(SEPARATOR, values);
}
private string ToString(double[] values)
{
var l = new List<string>();
foreach (var val in values)
{
l.Add(val.ToString(CultureInfo.InvariantCulture));
}
return ToString(l.ToArray());
}
private string ToString(short[] values)
{
var l = new List<string>();
foreach (var val in values)
{
l.Add(val.ToString(CultureInfo.InvariantCulture));
}
return ToString(l.ToArray());
}
private enum Fields
{
SerialNumber,
TiltSensorCals,
TiltSensorDataPre,
TiltAxes,
AxesIgnored,
MountOffsetAxisOne,
MountOffsetAxisTwo,
ChannelNames,
OffsetTolerancesLow,
OffsetTolerancesHigh
}
private double[] GetTiltSensorCals(IDASCommunication das)
{
return das is ITiltSensorCalAware iTiltAware ? iTiltAware.TiltSensorCals : (new double[0]);
}
private short[] GetTiltSensorData(IDASCommunication das)
{
return new short[] { 0, 0, 0 };
}
public DASMonitorInfo(IDASCommunication das, IsoViewMode mode)
{
var keys = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
foreach (var key in keys)
{
switch (key)
{
case Fields.SerialNumber:
SerialNumber = das.SerialNumber;
break;
case Fields.TiltSensorCals:
TiltSensorCals = GetTiltSensorCals(das);
break;
case Fields.TiltSensorDataPre:
TiltSensorDataPre = GetTiltSensorData(das);
break;
case Fields.TiltAxes:
TiltAxes = GetTiltAxes(das);
break;
case Fields.AxesIgnored:
AxisIgnored = GetAxisIgnored(das);
break;
case Fields.MountOffsetAxisOne:
MountOffsetAxisOne = GetMountOffsetAxisOne(das);
break;
case Fields.MountOffsetAxisTwo:
MountOffsetAxisTwo = GetMountOffsetAxisTwo(das);
break;
case Fields.ChannelNames:
_channelNames = GetChannelNames(das, mode);
break;
case Fields.OffsetTolerancesLow:
_offsetTolerancesLow = GetOffsetTolerancemVLow(das);
break;
case Fields.OffsetTolerancesHigh:
_offsetTolerancesHigh = GetOffsetTolerancemVHigh(das);
break;
}
}
}
private double[] GetOffsetTolerancemVHigh(IDASCommunication das)
{
if (NoModules(das)) { return new double[0]; }
var list = new List<double>();
foreach (var module in das.ConfigData.Modules)
{
foreach (var ch in module.Channels)
{
if (ch is IAnalogInputDASChannel aic)
{
list.Add(aic.OffsetToleranceHighMilliVolts);
}
else { list.Add(0); }
}
}
return list.ToArray();
}
private double[] GetOffsetTolerancemVLow(IDASCommunication das)
{
if (NoModules(das)) { return new double[0]; }
var list = new List<double>();
foreach (var module in das.ConfigData.Modules)
{
foreach (var ch in module.Channels)
{
if (ch is IAnalogInputDASChannel aic)
{
list.Add(aic.OffsetToleranceLowMilliVolts);
}
else { list.Add(0); }
}
}
return list.ToArray();
}
private bool NoModules(IDASCommunication das)
{
return null == das.ConfigData || null == das.ConfigData.Modules || 0 == das.ConfigData.Modules.Length;
}
private double GetMountOffsetAxisTwo(IDASCommunication das)
{
return NoModules(das) ? float.NaN : das.ConfigData.Modules[0].MountOffsetAxisTwo;
}
private double GetMountOffsetAxisOne(IDASCommunication das)
{
return NoModules(das) ? float.NaN : das.ConfigData.Modules[0].MountOffsetAxisOne;
}
private int GetAxisIgnored(IDASCommunication das)
{
return NoModules(das) ? 0 : das.ConfigData.Modules[0].AxisIgnored;
}
private DFConstantsAndEnums.TiltAxes GetTiltAxes(IDASCommunication das)
{
return NoModules(das) ? DFConstantsAndEnums.TiltAxes.IXIYIZ : das.ConfigData.Modules[0].TiltAxes;
}
private string[] GetChannelNames(IDASCommunication das, IsoViewMode viewMode)
{
if (NoModules(das)) { return new string[0]; }
var list = new List<string>();
foreach (var mod in das.ConfigData.Modules)
{
foreach (var ch in mod.Channels)
{
switch (viewMode)
{
case IsoViewMode.ISOOnly:
list.Add(ch.IsoChannelName);
break;
case IsoViewMode.ISOAndUserCode:
list.Add($"{ ch.IsoChannelName}\\{ch.UserChannelName}");
break;
case IsoViewMode.UserCodeOnly:
list.Add(ch.UserCode);
break;
case IsoViewMode.ChannelNameOnly:
list.Add(ch.UserChannelName);
break;
}
}
}
return list.ToArray();
}
public DASMonitorInfo(string path)
{
try
{
ReadFromFile(path);
}
catch (Exception ex)
{
APILogger.Log(ex);
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,271 @@
using DTS.Common.Classes.Sensors;
using DTS.Common.Enums;
using DTS.Common.Enums.Sensors;
using DTS.Common.Interface.Sensors.SoftwareFilters;
using System;
using System.IO.Ports;
namespace DTS.Common.Interface.Sensors
{
public interface ISensorData
{
string DIUnits { get; set; }
/// <summary>
/// gets the calibration due date for the sensor given a sensor calibration
/// 13065 Sensor "First Use" Date
/// </summary>
DateTime GetDueDate(ISensorCalibration sc);
/// <summary>
/// initial offset information is stored in a sensor calibration at least in terms of possible settings for the sensor
/// HOWEVER, the offset to use is stored here for convenience, this is the result of group or test parameters
///
/// </summary>
InitialOffset InitialOffset { get; set; }
SensorConstants.BridgeType Bridge { get; set; }
ISensorCalibration GetLatestCalibration();
ISensorCalibration NewEmbeddedSC(string units);
int DatabaseId { get; set; }
/// <summary>
/// 11260 Implement DiagnosticsMode in DataPRO
/// DiagnosticsMode means the bridge in analog is short circuited to the outside world and only internal resistors are used
/// </summary>
bool DiagnosticsMode { get; set; }
bool IsTestSpecificDigitalOutput { get; set; }
bool IsTestSpecificSquib { get; set; }
/// <summary>
/// returns true if the sensor is a test specific digital input
/// a digital input only created inside a test
/// </summary>
bool IsTestSpecificDigitalIn { get; set; }
bool IsTestSpecificEmbedded { get; set; }
bool IsTestSpecificEmbeddedClock { get; set; }
bool IsTestSpecificStreamInput { get; set; }
bool IsTestSpecificStreamOutput { get; set; }
bool IsTestSpecificUart { get; set; }
/// <summary>
/// At one time all the different DelayMS were using one underlying property for storage, _delayMS.
/// Now, the individual SquibFireDelayMS, etc. are defined because we don't want controls that are sharing to limit each other.
/// </summary>
double DelayMS { get; set; }
double DigitalOutputDelayMS { get; set; }
/// <summary>
/// At one time all the different DurationMS were using one underlying property for storage, _durationMS.
/// Now, the individual SquibFireDurationMS, etc. are defined because we don't want controls that are sharing to limit each other.
/// </summary>
double DurationMS { get; set; }
double DigitalOutputDurationMS { get; set; }
DigitalOutputModes DigitalOutputMode { get; set; }
bool DigitalOutputLimitDuration { get; set; }
double SquibFireDelayMS { get; set; }
double SquibFireDurationMS { get; set; }
/// <summary>
/// right now all the Limit Duration mechanisms using the same underlying property for storage (_limitDuration), however
/// the public access methods (LimitSquibDuration, etc) exist in case we separate them out in the future
/// </summary>
bool LimitDuration { get; set; }
bool LimitSquibFireDuration { get; set; }
double SquibToleranceLow { get; set; }
double SquibToleranceHigh { get; set; }
SquibMeasurementType SquibMeasurementType { get; set; }
double SquibOutputCurrent { get; set; }
string DisplayUnit { get; }
bool BypassCurrentFilter { get; }
bool BypassVoltageFilter { get; }
SquibFireMode SquibFireMode { get; set; }
/// <summary>
/// the setting name allows us to refer to different settings and allow it to be more easily included in test setups and channel setups
/// </summary>
string SettingName { get; set; }
DigitalInputModes InputMode { get; set; }
/// <summary>
/// Returns comment string. Returns serial number with axis if comment is not present.
/// </summary>
/// <returns></returns>
string ToDisplayString();
void ReadXML(System.Xml.XmlElement root);
void WriteXML(ref System.Xml.XmlWriter writer, bool exportFirstUseDate = true);
string UUID { get; set; }
string SerialNumber { get; set; }
string GetSerialNumberWithAxis(string format);
string UserSerialNumber { get; set; }
SensorStatus Status { get; set; }
string EID { get; set; }
string Comment { get; set; }
bool PerformShuntEmulation { get; }
bool CalSignal { get; set; }
double InternalShuntResistance { get; set; }
double ExternalShuntResistance { get; set; }
string UserValue1 { get; set; }
string UserValue2 { get; set; }
string UserValue3 { get; set; }
string GetSerializedSupportedExcitation();
void SetSupportedExcitationFromString(string s);
DateTime Created { get; set; }
int TimesUsed { get; set; }
int SensorCategory { get; set; }
bool ByPassFilter { get; set; }
bool CheckCalibrationSignal { get; set; }
string TestObject { get; set; }
string OriginalPosition { get; set; }
string Position { get; set; }
string MainLocation { get; set; }
string FineLocation1 { get; set; }
string FineLocation2 { get; set; }
string FineLocation3 { get; set; }
string FilterClassIso { get; set; }
bool IncompatibleSensorAssignment(string sensorDimension, string channelDimension);
bool IsDigitalInput();
bool IsDigitalOutput();
bool IsSquib();
bool IsUart();
/// <summary>
/// uart baud rate
/// </summary>
uint UartBaudRate { get; set; }
/// <summary>
/// uart data bits
/// </summary>
uint UartDataBits { get; set; }
/// <summary>
/// uart stop bits
/// </summary>
StopBits UartStopBits { get; set; }
/// <summary>
/// uart parity
/// </summary>
Parity UartParity { get; set; }
/// <summary>
/// uart flow control FB 30486 Hardcode FlowControl to NONE for UART sensor type.
/// </summary>
Handshake UartFlowControl { get; }
/// <summary>
/// the data format of incoming data
/// </summary>
UartDataFormat UartDataFormat { get; set; }
bool IsStreamInput();
///<summary>
/// udp address setting value
///</summary>
string StreamInUDPAddress { get; set; }
bool IsStreamOutput();
bool IsThermocoupler();
///<summary>
/// udp profile setting value
///</summary>
UDPStreamProfile StreamOutUDPProfile { get; set; }
///<summary>
/// udp address setting value
///</summary>
string StreamOutUDPAddress { get; set; }
///<summary>
/// time channel id setting value
///</summary>
ushort StreamOutUDPTimeChannelId { get; set; }
///<summary>
/// data channel id setting value
///</summary>
ushort StreamOutUDPDataChannelId { get; set; }
///<summary>
/// tmns config setting value
///</summary>
string StreamOutUDPTmNSConfig { get; set; }
///<summary>
/// irig data packet interval setting value
///</summary>
ushort StreamOutIRIGTimeDataPacketIntervalMs { get; set; }
/// <summary>
/// interval in ms between sending out TMATs information
/// http://manuscript.dts.local/f/cases/29987/Add-CG-DP-TMATS-interval-UI-support
/// </summary>
ushort StreamOutTMATSIntervalMs { get; set; }
bool CheckOffset { get; set; }
bool MeasureNoise { get; set; }
bool MeasureExcitation { get; set; }
bool Invert { get; set; }
string Model { get; set; }
string Manufacturer { get; set; }
string UserPartNumber { get; set; }
double Capacity { get; set; }
//FB 13120 Added FilterClass property
IFilterClass FilterClass { get; set; }
double FullScaleCapacity { get; }
double OffsetToleranceLow { get; set; }
double OffsetToleranceHigh { get; set; }
void SetDisplayUnitNoNotify(string unit);
double RangeLow { get; set; }
double RangeMedium { get; set; }
double RangeHigh { get; set; }
ExcitationVoltageOptions.ExcitationVoltageOption[] SupportedExcitation { get; set; }
void SetExcitationsNoNotify(ExcitationVoltageOptions.ExcitationVoltageOption[] excitations);
ISensorCalibration Calibration { get; set; }
double BridgeResistance { get; set; }
bool UniPolar { get; set; }
bool IgnoreRange { get; set; }
string LastUpdatedBy { get; set; }
int Version { get; set; }
void SetLocalOnly(bool bLocalOnly);
short AxisNumber { get; set; }
short NumberOfAxes { get; set; }
int CalInterval { get; set; }
string Polarity { get; set; }
DateTime LastModified { get; set; }
string ISOCode { get; set; }
string ISOChannelName { get; set; }
string UserCode { get; set; }
string UserChannelName { get; set; }
string PhysicalDimension { get; set; }
string Direction { get; set; }
bool DoNotUse { get; set; }
//FB 43046
double SensitivityTolerancePercent { get; set; }
bool Broken { get; set; }
double InputActiveValue { get; set; }
double InputDefaultValue { get; set; }
FilterClassType FilterType { get; }
int SensorCalWarningPeriodDays { get; set; }
/// <summary>
/// Date of first use, null indicates value not set
/// value is only valid when using the latest calibration (as indicated by LatestCalibrationId)
/// 13065 Sensor "First Use" Date
/// </summary>
DateTime? FirstUseDate { get; set; }
/// <summary>
/// Latest calibration for sensor, null indicates value not set
/// 13065 Sensor "First Use" Date
/// </summary>
int? LatestCalibrationId { get; set; }
int UsageCount { get; set; }
int MaximumUsage { get; set; }
string AssemblyName { get; set; }
}
}

View File

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

View File

@@ -0,0 +1,8 @@
using DTS.Common.Base;
namespace DTS.Common.Interface
{
public interface IStatusAndProgressFooterView : IBaseView
{
}
}

View File

@@ -0,0 +1,55 @@
using System;
using System.Windows.Input;
using Prism.Commands;
namespace DTS.Common.RibbonControl
{
public static class ViewModelData
{
internal const int TabCount = 4;
internal const int ContextualTabGroupCount = 2;
internal const int GroupCount = 3;
internal const int ControlCount = 5;
internal const int ButtonCount = 1;
internal const int ToggleButtonCount = 1;
internal const int RadioButtonCount = 1;
internal const int CheckBoxCount = 1;
internal const int TextBoxCount = 1;
internal const int MenuButtonCount = 1;
internal const int MenuItemCount = 2;
internal const int SplitButtonCount = 1;
internal const int SplitMenuItemCount = 2;
internal const int GalleryCount = 1;
internal const int GalleryCategoryCount = 3;
internal const int GalleryItemCount = 10;
internal const int MenuItemNestingCount = 2;
internal const int ComboBoxCount = 1;
public static RibbonData RibbonData
{
get
{
if (_data == null)
{
_data = new RibbonData();
}
return _data;
}
}
public static ICommand DefaultCommand => _defaultCommand ?? (_defaultCommand = new DelegateCommand(DefaultExecuted, DefaultCanExecute));
private static void DefaultExecuted()
{
}
private static bool DefaultCanExecute()
{
return true;
}
[ThreadStatic]
private static RibbonData _data;
private static ICommand _defaultCommand;
}
}