init
This commit is contained in:
1
Common/DTS.Common.Utilities/.svn/entries
Normal file
1
Common/DTS.Common.Utilities/.svn/entries
Normal file
@@ -0,0 +1 @@
|
||||
12
|
||||
1
Common/DTS.Common.Utilities/.svn/format
Normal file
1
Common/DTS.Common.Utilities/.svn/format
Normal file
@@ -0,0 +1 @@
|
||||
12
|
||||
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
public class PersistWindowState : System.ComponentModel.Component
|
||||
{
|
||||
// event info that allows form to persist extra window state data
|
||||
public delegate void WindowStateDelegate(object sender, RegistryKey key);
|
||||
public event WindowStateDelegate LoadStateEvent;
|
||||
public event WindowStateDelegate SaveStateEvent;
|
||||
|
||||
private Form m_parent;
|
||||
private string m_regPath;
|
||||
private int m_normalLeft;
|
||||
private int m_normalTop;
|
||||
private int m_normalWidth;
|
||||
private int m_normalHeight;
|
||||
private FormWindowState m_windowState;
|
||||
private bool m_allowSaveMinimized = false;
|
||||
private bool m_startMaximized = false;
|
||||
|
||||
public PersistWindowState()
|
||||
{
|
||||
}
|
||||
|
||||
public Form Parent
|
||||
{
|
||||
set
|
||||
{
|
||||
m_parent = value;
|
||||
|
||||
// subscribe to parent form's events
|
||||
m_parent.Closing += new System.ComponentModel.CancelEventHandler(OnClosing);
|
||||
m_parent.Resize += new System.EventHandler(OnResize);
|
||||
m_parent.Move += new System.EventHandler(OnMove);
|
||||
m_parent.Load += new System.EventHandler(OnLoad);
|
||||
|
||||
// get initial width and height in case form is never resized
|
||||
m_normalWidth = m_parent.Width;
|
||||
m_normalHeight = m_parent.Height;
|
||||
}
|
||||
get => m_parent;
|
||||
}
|
||||
|
||||
// registry key should be set in parent form's constructor
|
||||
public string RegistryPath
|
||||
{
|
||||
set => m_regPath = value;
|
||||
get => m_regPath;
|
||||
}
|
||||
|
||||
public bool AllowSaveMinimized
|
||||
{
|
||||
set => m_allowSaveMinimized = value;
|
||||
}
|
||||
|
||||
public bool StartMaximized
|
||||
{
|
||||
set => m_startMaximized = value;
|
||||
}
|
||||
|
||||
private void OnResize(object sender, System.EventArgs e)
|
||||
{
|
||||
// save width and height
|
||||
if (m_parent.WindowState == FormWindowState.Normal)
|
||||
{
|
||||
m_normalWidth = m_parent.Width;
|
||||
m_normalHeight = m_parent.Height;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMove(object sender, System.EventArgs e)
|
||||
{
|
||||
// save position
|
||||
if (m_parent.WindowState == FormWindowState.Normal)
|
||||
{
|
||||
m_normalLeft = m_parent.Left;
|
||||
m_normalTop = m_parent.Top;
|
||||
}
|
||||
// save state
|
||||
m_windowState = m_parent.WindowState;
|
||||
}
|
||||
|
||||
private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
// save position, size and state
|
||||
var key = Registry.CurrentUser.CreateSubKey(m_regPath);
|
||||
key.SetValue("Left", m_normalLeft);
|
||||
key.SetValue("Top", m_normalTop);
|
||||
key.SetValue("Width", m_normalWidth);
|
||||
key.SetValue("Height", m_normalHeight);
|
||||
|
||||
// check if we are allowed to save the state as minimized (not normally)
|
||||
if (!m_allowSaveMinimized)
|
||||
{
|
||||
if (m_windowState == FormWindowState.Minimized)
|
||||
m_windowState = FormWindowState.Normal;
|
||||
}
|
||||
|
||||
key.SetValue("WindowState", (int)m_windowState);
|
||||
|
||||
// fire SaveState event
|
||||
if (SaveStateEvent != null)
|
||||
SaveStateEvent(this, key);
|
||||
}
|
||||
|
||||
private void OnLoad(object sender, System.EventArgs e)
|
||||
{
|
||||
// attempt to read state from registry
|
||||
var key = Registry.CurrentUser.OpenSubKey(m_regPath);
|
||||
if (key != null)
|
||||
{
|
||||
var left = (int)key.GetValue("Left", m_parent.Left);
|
||||
var top = (int)key.GetValue("Top", m_parent.Top);
|
||||
var width = (int)key.GetValue("Width", m_parent.Width);
|
||||
var height = (int)key.GetValue("Height", m_parent.Height);
|
||||
var windowState = new FormWindowState();
|
||||
if (m_startMaximized == true)
|
||||
{
|
||||
windowState = FormWindowState.Maximized;
|
||||
}
|
||||
else
|
||||
{
|
||||
windowState = (FormWindowState)key.GetValue("WindowState", (int)m_parent.WindowState);
|
||||
}
|
||||
if (Screen.AllScreens.Length == 1)
|
||||
{
|
||||
//There is only 1 monitor, so disregard what was in the registry
|
||||
//to ensure that the window is not displayed on a non-existent monitor
|
||||
m_parent.Location = new Point(100, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_parent.Location = new Point(left, top);
|
||||
}
|
||||
m_parent.Size = new Size(width, height);
|
||||
m_parent.WindowState = windowState;
|
||||
|
||||
// fire LoadState event
|
||||
if (LoadStateEvent != null)
|
||||
LoadStateEvent(this, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
public class SortableBindingList<T> : BindingList<T>
|
||||
{
|
||||
private readonly Dictionary<Type, PropertyComparer<T>> _comparers;
|
||||
private bool _isSorted;
|
||||
private ListSortDirection _listSortDirection;
|
||||
private PropertyDescriptor _propertyDescriptor;
|
||||
|
||||
public SortableBindingList()
|
||||
: base(new List<T>())
|
||||
{
|
||||
_comparers = new Dictionary<Type, PropertyComparer<T>>();
|
||||
}
|
||||
|
||||
public SortableBindingList(IEnumerable<T> enumeration)
|
||||
: base(new List<T>(enumeration))
|
||||
{
|
||||
_comparers = new Dictionary<Type, PropertyComparer<T>>();
|
||||
}
|
||||
|
||||
protected override bool SupportsSortingCore => true;
|
||||
|
||||
protected override bool IsSortedCore => _isSorted;
|
||||
|
||||
protected override PropertyDescriptor SortPropertyCore => _propertyDescriptor;
|
||||
|
||||
protected override ListSortDirection SortDirectionCore => _listSortDirection;
|
||||
|
||||
protected override bool SupportsSearchingCore => true;
|
||||
|
||||
protected override void ApplySortCore(PropertyDescriptor property, ListSortDirection direction)
|
||||
{
|
||||
var itemsList = (List<T>)Items;
|
||||
|
||||
var propertyType = property.PropertyType;
|
||||
PropertyComparer<T> comparer;
|
||||
if (!_comparers.TryGetValue(propertyType, out comparer))
|
||||
{
|
||||
comparer = new PropertyComparer<T>(property, direction);
|
||||
_comparers.Add(propertyType, comparer);
|
||||
}
|
||||
|
||||
comparer.SetPropertyAndDirection(property, direction);
|
||||
itemsList.Sort(comparer);
|
||||
|
||||
_propertyDescriptor = property;
|
||||
_listSortDirection = direction;
|
||||
_isSorted = true;
|
||||
|
||||
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
|
||||
}
|
||||
|
||||
protected override void RemoveSortCore()
|
||||
{
|
||||
_isSorted = false;
|
||||
_propertyDescriptor = base.SortPropertyCore;
|
||||
_listSortDirection = base.SortDirectionCore;
|
||||
|
||||
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
|
||||
}
|
||||
|
||||
protected override int FindCore(PropertyDescriptor property, object key)
|
||||
{
|
||||
var count = Count;
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
var element = this[i];
|
||||
var value = property.GetValue(element);
|
||||
if (value != null && value.Equals(key))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
Exceptional.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
using DTS.Common.Utilities.Properties;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// "Ultimate" base class for all DTS classes that expect to throw exceptions.
|
||||
/// Deriving classes from this class allows exceptions to be trapped based on
|
||||
/// the class type that threw them.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Sample usage:
|
||||
/// public class A : Exceptional
|
||||
/// {
|
||||
/// public void ScrewItUp( )
|
||||
/// {
|
||||
/// private bool error = true;
|
||||
/// if ( error ) throw new A.Exception( "Class A-specific screwup." );
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// ...
|
||||
///
|
||||
/// try
|
||||
/// {
|
||||
/// A.ScrewItUp( );
|
||||
/// B.ScrewItUp( );
|
||||
/// C.ScrewItUp( );
|
||||
/// }
|
||||
/// catch ( A.Exception ex )
|
||||
/// {
|
||||
/// // Can pick A's exceptions out of a crowd, or not and just treat it
|
||||
/// // polymorphically as a System.Exception.
|
||||
/// }
|
||||
/// </remarks>
|
||||
///
|
||||
[Serializable]
|
||||
public abstract class Exceptional
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the DerivedClass.Exception class.
|
||||
/// </summary>
|
||||
public class Exception : ApplicationException
|
||||
{
|
||||
/// <summary>
|
||||
/// create a <see cref="Exceptional.Exception" /> object
|
||||
/// </summary>
|
||||
public Exception() { }
|
||||
/// <summary>
|
||||
/// create a <see cref="Exceptional.Exception" /> object
|
||||
/// </summary>
|
||||
/// <param name="msg">a message that describes the error</param>
|
||||
public Exception(string msg) : base(msg) { }
|
||||
/// <summary>
|
||||
/// create a <see cref="Exceptional.Exception" /> object
|
||||
/// </summary>
|
||||
/// <param name="msg">a message that describes the error</param>
|
||||
/// <param name="innerEx">The exception that is the cause of the current exception.</param>
|
||||
public Exception(string msg, System.Exception innerEx) : base(msg, innerEx) { }
|
||||
protected Exception(
|
||||
SerializationInfo info,
|
||||
StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the DerivedClass.UserException class.
|
||||
/// </summary>
|
||||
public class UserException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// create a user Exception with a description of the event
|
||||
/// </summary>
|
||||
/// <param name="msg">description of error</param>
|
||||
public UserException(string msg) : base(msg) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Walk the nested exception tree and generate a single string from their messages.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="ex">
|
||||
/// The parent <see cref="System.Exception"/>.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="string"/> concatenation of the exception tree's messages.
|
||||
/// </returns>
|
||||
///
|
||||
public static string GenerateLogMessageFromExceptionTree(System.Exception ex)
|
||||
{
|
||||
return GenerateMessageFromExceptionTree(ex, true, true, true);
|
||||
}
|
||||
public static string GenerateUIMessageFromExceptionTree(System.Exception ex)
|
||||
{
|
||||
return GenerateMessageFromExceptionTree(ex, true, true, false);
|
||||
}
|
||||
/// <summary>
|
||||
/// Walk the nested exception tree and generate a single string from their messages.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="ex">
|
||||
/// The parent <see cref="System.Exception"/>.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="addNewlines">
|
||||
/// <see cref="Boolean"/> true to insert a newline between each exception's message,
|
||||
/// false to insert a delimiter between each instead.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="string"/> concatenation of the exception tree's messages.
|
||||
/// </returns>
|
||||
///
|
||||
public static string GenerateLogMessageFromExceptionTree(System.Exception ex, bool addNewlines)
|
||||
{
|
||||
return GenerateMessageFromExceptionTree(ex, addNewlines, true, true);
|
||||
}
|
||||
public static string GenerateUIMessageFromExceptionTree(System.Exception ex, bool addNewLines)
|
||||
{
|
||||
return GenerateMessageFromExceptionTree(ex, addNewLines, true, false);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Legacy wrapper for walking the nested exception tree and generating a single string from their messages
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="ex">
|
||||
/// The parent <see cref="System.Exception"/>.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="string"/> concatenation of the exception tree's messages.
|
||||
/// </returns>
|
||||
|
||||
public static string GenerateMessageFromExceptionTree(System.Exception ex)
|
||||
{
|
||||
return GenerateMessageFromExceptionTree(ex, true, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Walk the nested exception tree and generate a single string from their messages.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="ex">
|
||||
/// The parent <see cref="System.Exception"/>.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="addNewlines">
|
||||
/// <see cref="Boolean"/> true to insert a newline between each exception's message,
|
||||
/// false to insert a delimiter between each instead.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="makeSentence">
|
||||
/// <see cref="Boolean"/> true to append "because" after each exception message in
|
||||
/// string and end deepest message with a period, false to leave messages raw.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="bLogMessage"></param>
|
||||
/// <returns>
|
||||
/// The <see cref="string"/> concatenation of the exception tree's messages.
|
||||
/// </returns>
|
||||
///
|
||||
public static string GenerateMessageFromExceptionTree(System.Exception ex, bool addNewlines, bool makeSentence, bool bLogMessage)
|
||||
{
|
||||
var message = "";
|
||||
var stackTrace = "";
|
||||
var currentEx = ex;
|
||||
while (null != currentEx)
|
||||
{
|
||||
if (bLogMessage)
|
||||
{
|
||||
message += string.Format(Resources.Exceptional_GenerateMessageFromExceptionTree_MessageFormatString,
|
||||
currentEx.Message,
|
||||
makeSentence && null != currentEx.InnerException
|
||||
? Resources.Exceptional_GenerateMessageFromExceptionTree_BecauseString
|
||||
: Resources.Exceptional_GenerateMessageFromExceptionTree_ErrorTextTerminatorString,
|
||||
null != currentEx.InnerException ? (addNewlines ? "\n" : " : ") : "");
|
||||
}
|
||||
else { message = currentEx.Message; }
|
||||
|
||||
stackTrace += currentEx.StackTrace;
|
||||
currentEx = currentEx.InnerException;
|
||||
}
|
||||
|
||||
#if ( DEBUG )
|
||||
if (bLogMessage) { message += "\n\n*** Debug Mode Stack Trace ***\n" + stackTrace; }
|
||||
#endif
|
||||
|
||||
return message.EndsWith(
|
||||
string.Format(Resources.Exceptional_GenerateMessageFromExceptionTree_EndsWithFormatString,
|
||||
Resources.Exceptional_GenerateMessageFromExceptionTree_ErrorTextTerminatorString,
|
||||
Resources.Exceptional_GenerateMessageFromExceptionTree_ErrorTextTerminatorString))
|
||||
? message.Remove(message.LastIndexOf(Resources.Exceptional_GenerateMessageFromExceptionTree_ErrorTextTerminatorString, StringComparison.Ordinal))
|
||||
: message;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract the first exception of the specified class type from the specified
|
||||
/// exception's exception tree.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="TExceptionType">
|
||||
/// The type of System.Exception-derived class to be extracted.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <param name="ex">
|
||||
/// The <see cref="System.Exception"/>-derived class to have its exception tree
|
||||
/// searched.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The first nested innner exception of type ExceptionType; null otherwise.
|
||||
/// </returns>
|
||||
///
|
||||
public static TExceptionType
|
||||
ExtractFirstExceptionOfTypeFromExceptionTree<TExceptionType>(System.Exception ex)
|
||||
where TExceptionType : System.Exception
|
||||
{
|
||||
var currentEx = ex;
|
||||
while (null != currentEx)
|
||||
{
|
||||
if (currentEx is TExceptionType exceptionType)
|
||||
return exceptionType;
|
||||
currentEx = currentEx.InnerException;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine whether or not the specified exception's exception tree contains
|
||||
/// a UserException-derived exception.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="ex">
|
||||
/// The <see cref="System.Exception"/>-derived class to have its exception tree
|
||||
/// searched.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// <see cref="bool"/> true if the specified exception tree contains a
|
||||
/// UserException-type exception; false otherwise.
|
||||
/// </returns>
|
||||
///
|
||||
public static bool ExceptionTreeContainsUserException(System.Exception ex)
|
||||
{
|
||||
return null != ExtractFirstExceptionOfTypeFromExceptionTree<UserException>(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,418 @@
|
||||
/*
|
||||
* Xml.PropertyAttributeDecoder.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities.Xml
|
||||
{
|
||||
/// <summary>
|
||||
/// A tool for decoding XmlSerializationTag
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="T">
|
||||
/// The type of the property container, class-constrained.
|
||||
/// </typeparam>
|
||||
///
|
||||
public class PropertyAttributeDecoder<T>
|
||||
: Exceptional where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Xml.PropertyAttributeDecoder class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="propertyContainer">
|
||||
/// The <see cref="Object"/> containing the properties to be decoded.
|
||||
/// </param>
|
||||
///
|
||||
public PropertyAttributeDecoder(T propertyContainer)
|
||||
{
|
||||
try
|
||||
{
|
||||
PropertyContainer = propertyContainer;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the object containing the properties to be decoded by this class instance.
|
||||
/// </summary>
|
||||
public T PropertyContainer
|
||||
{
|
||||
get => _PropertyContainer.Value;
|
||||
private set => _PropertyContainer.Value = value;
|
||||
}
|
||||
private Property<T> _PropertyContainer
|
||||
= new Property<T>(
|
||||
typeof(PropertyAttributeDecoder<T>).Namespace + ".PropertyAttributeDecoder.PropertyContainer",
|
||||
null,
|
||||
false
|
||||
);
|
||||
|
||||
public bool ExtractBoolProperty(string propertyName, XmlReader reader, bool defaultValue)
|
||||
{
|
||||
try
|
||||
{ //
|
||||
// Get the specified integer property.
|
||||
//
|
||||
if (string.IsNullOrEmpty(propertyName))
|
||||
throw new ArgumentNullException("cannot extract value from null/empty attribute name");
|
||||
else if (null == reader)
|
||||
throw new ArgumentNullException("cannot extract value from null/empty reader");
|
||||
else
|
||||
{
|
||||
var attributeExtractor = new AttributeExtractor<XmlSerializationTagAttribute>();
|
||||
|
||||
string attributeName;
|
||||
try { attributeName = attributeExtractor.ExtractAttachedAttributeFromProperty(PropertyContainer, propertyName).Value; }
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem extracting attribute name for \"" + propertyName + "\"", ex); }
|
||||
|
||||
string attributeValueString;
|
||||
try { attributeValueString = reader.GetAttribute(attributeName); }
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem extracting value string from XML attribute \"" + attributeName + "\"", ex); }
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(attributeValueString)) { return defaultValue; }
|
||||
return bool.Parse(attributeValueString);
|
||||
}
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem parsing integer value out of value text \"" + attributeValueString + "\"", ex); }
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem parsing " + (propertyName ?? "<<NULL>>") + " property", ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Extract the specified boolean attribute property value from the decoder's
|
||||
/// bound object.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="propertyName">
|
||||
/// The <see cref="string"/> name of the property to be extracted.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="reader">
|
||||
/// The <see cref="System.Xml.XmlReader"/> the property value is to be decoded from.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The specified <see cref="bool"/> value.
|
||||
/// </returns>
|
||||
///
|
||||
public bool ExtractBoolProperty(string propertyName, XmlReader reader)
|
||||
{
|
||||
try
|
||||
{ //
|
||||
// Get the specified integer property.
|
||||
//
|
||||
if (string.IsNullOrEmpty(propertyName))
|
||||
throw new ArgumentNullException("cannot extract value from null/empty attribute name");
|
||||
else if (null == reader)
|
||||
throw new ArgumentNullException("cannot extract value from null/empty reader");
|
||||
else
|
||||
{
|
||||
var attributeExtractor = new AttributeExtractor<XmlSerializationTagAttribute>();
|
||||
|
||||
string attributeName;
|
||||
try { attributeName = attributeExtractor.ExtractAttachedAttributeFromProperty(PropertyContainer, propertyName).Value; }
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem extracting attribute name for \"" + propertyName + "\"", ex); }
|
||||
|
||||
string attributeValueString;
|
||||
try { attributeValueString = reader.GetAttribute(attributeName); }
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem extracting value string from XML attribute \"" + attributeName + "\"", ex); }
|
||||
|
||||
try
|
||||
{
|
||||
return bool.Parse(attributeValueString);
|
||||
}
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem parsing integer value out of value text \"" + attributeValueString + "\"", ex); }
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem parsing " + (propertyName ?? "<<NULL>>") + " property", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract the specified int attribute property value from the decoder's
|
||||
/// bound object.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="propertyName">
|
||||
/// The <see cref="string"/> name of the property to be extracted.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="reader">
|
||||
/// The <see cref="System.Xml.XmlReader"/> the property value is to be decoded from.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The specified <see cref="int"/> value.
|
||||
/// </returns>
|
||||
public int ExtractIntProperty(string propertyName, XmlReader reader)
|
||||
{
|
||||
try
|
||||
{ //
|
||||
// Get the specified integer property.
|
||||
//
|
||||
if (string.IsNullOrEmpty(propertyName))
|
||||
throw new ArgumentNullException("cannot extract value from null/empty attribute name");
|
||||
else if (null == reader)
|
||||
throw new ArgumentNullException("cannot extract value from null/empty reader");
|
||||
else
|
||||
{
|
||||
var attributeExtractor = new AttributeExtractor<XmlSerializationTagAttribute>();
|
||||
|
||||
string attributeName;
|
||||
try { attributeName = attributeExtractor.ExtractAttachedAttributeFromProperty(PropertyContainer, propertyName).Value; }
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem extracting attribute name for \"" + propertyName + "\"", ex); }
|
||||
|
||||
string attributeValueString;
|
||||
try { attributeValueString = reader.GetAttribute(attributeName); }
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem extracting value string from XML attribute \"" + attributeName + "\"", ex); }
|
||||
|
||||
try
|
||||
{
|
||||
var cult = new System.Globalization.CultureInfo("");
|
||||
return int.Parse(attributeValueString, cult);
|
||||
}
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem parsing integer value out of value text \"" + attributeValueString + "\"", ex); }
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem parsing " + (propertyName ?? "<<NULL>>") + " property", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract the specified double attribute property value from the decoder's
|
||||
/// bound object.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="propertyName">
|
||||
/// The <see cref="string"/> name of the property to be extracted.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="reader">
|
||||
/// The <see cref="System.Xml.XmlReader"/> the property value is to be decoded from.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The specified <see cref="double"/> value.
|
||||
/// </returns>
|
||||
///
|
||||
public double ExtractDoubleProperty(string propertyName, XmlReader reader)
|
||||
{
|
||||
try
|
||||
{ //
|
||||
// Get the specified double property.
|
||||
//
|
||||
if (string.IsNullOrEmpty(propertyName))
|
||||
throw new ArgumentNullException("cannot extract value from null/empty attribute name");
|
||||
else if (null == reader)
|
||||
throw new ArgumentNullException("cannot extract value from null/empty reader");
|
||||
else
|
||||
{
|
||||
var attributeExtractor = new AttributeExtractor<XmlSerializationTagAttribute>();
|
||||
|
||||
string attributeName;
|
||||
try { attributeName = attributeExtractor.ExtractAttachedAttributeFromProperty(PropertyContainer, propertyName).Value; }
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem extracting attribute name for \"" + propertyName + "\"", ex); }
|
||||
|
||||
string attributeValueString;
|
||||
try { attributeValueString = reader.GetAttribute(attributeName); }
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem extracting value string from XML attribute \"" + attributeName + "\"", ex); }
|
||||
|
||||
try
|
||||
{
|
||||
var cult = new System.Globalization.CultureInfo("");
|
||||
return double.Parse(attributeValueString, cult);
|
||||
}
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem parsing double value out of value text \"" + attributeValueString + "\"", ex); }
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem parsing " + (propertyName ?? "<<NULL>>") + " property", ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Extract the specified double attribute property value from the decoder's
|
||||
/// bound object.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="propertyName">
|
||||
/// The <see cref="string"/> name of the property to be extracted.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="reader">
|
||||
/// The <see cref="System.Xml.XmlReader"/> the property value is to be decoded from.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="dValue"></param>
|
||||
/// <returns>
|
||||
/// The specified <see cref="double"/> value.
|
||||
/// </returns>
|
||||
///
|
||||
public bool ExtractDoubleProperty(string propertyName, XmlReader reader, out double dValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
dValue = 0D;
|
||||
//
|
||||
// Get the specified double property.
|
||||
//
|
||||
if (string.IsNullOrEmpty(propertyName)) { return false; }
|
||||
else if (null == reader) { return false; }
|
||||
else
|
||||
{
|
||||
var attributeExtractor = new AttributeExtractor<XmlSerializationTagAttribute>();
|
||||
|
||||
string attributeName;
|
||||
try { attributeName = attributeExtractor.ExtractAttachedAttributeFromProperty(PropertyContainer, propertyName).Value; }
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem extracting attribute name for \"" + propertyName + "\"", ex); }
|
||||
|
||||
string attributeValueString;
|
||||
try
|
||||
{
|
||||
attributeValueString = reader.GetAttribute(attributeName);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
"encountered problem extracting value string from XML attribute \"" + attributeName + "\"",
|
||||
ex);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(attributeValueString))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (double.TryParse(attributeValueString, System.Globalization.NumberStyles.Any,
|
||||
new System.Globalization.CultureInfo(""), out dValue))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem parsing double value out of value text \"" + attributeValueString + "\"", ex); }
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem parsing " + (propertyName ?? "<<NULL>>") + " property", ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Extract the specified string attribute property value from the decoder's
|
||||
/// bound object.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="propertyName">
|
||||
/// The <see cref="string"/> name of the property to be extracted.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="reader">
|
||||
/// The <see cref="System.Xml.XmlReader"/> the property value is to be decoded from.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The specified <see cref="string"/> value.
|
||||
/// </returns>
|
||||
///
|
||||
public string ExtractStringProperty(string propertyName, XmlReader reader)
|
||||
{
|
||||
try
|
||||
{ //
|
||||
// Get the specified double property.
|
||||
//
|
||||
if (string.IsNullOrEmpty(propertyName))
|
||||
throw new ArgumentNullException("cannot extract value from null/empty attribute name");
|
||||
else if (null == reader)
|
||||
throw new ArgumentNullException("cannot extract value from null/empty reader");
|
||||
else
|
||||
{
|
||||
var attributeExtractor = new AttributeExtractor<XmlSerializationTagAttribute>();
|
||||
|
||||
string attributeName;
|
||||
try { attributeName = attributeExtractor.ExtractAttachedAttributeFromProperty(PropertyContainer, propertyName).Value; }
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem extracting attribute name for \"" + propertyName + "\"", ex); }
|
||||
|
||||
try
|
||||
{
|
||||
var cult = new System.Globalization.CultureInfo("");
|
||||
return reader.GetAttribute(attributeName);
|
||||
}
|
||||
catch (System.Exception ex) { throw new Exception("encountered problem extracting value string from XML attribute \"" + attributeName + "\"", ex); }
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem parsing " + (propertyName ?? "<<NULL>>") + " property", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract the specified enum attribute property value from the decoder's
|
||||
/// bound object.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="propertyName">
|
||||
/// The <see cref="string"/> name of the property to be extracted.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="reader">
|
||||
/// The <see cref="System.Xml.XmlReader"/> the property value is to be decoded from.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="enumType">the Enumeration that the enum value belongs to</param>
|
||||
/// <returns>
|
||||
/// The specified enum value.
|
||||
/// </returns>
|
||||
public object ExtractEnumProperty(string propertyName, Type enumType, XmlReader reader)
|
||||
{
|
||||
try
|
||||
{ //
|
||||
// Get the specified enum property.
|
||||
//
|
||||
if (string.IsNullOrEmpty(propertyName))
|
||||
throw new ArgumentNullException("cannot extract value from null/empty attribute name");
|
||||
else if (null == enumType)
|
||||
throw new ArgumentNullException("cannot extract value with no specified enumeration type");
|
||||
else if (null == reader)
|
||||
throw new ArgumentNullException("cannot extract value from null/empty reader");
|
||||
else
|
||||
{
|
||||
var cult = new System.Globalization.CultureInfo("");
|
||||
var attributeExtractor = new AttributeExtractor<XmlSerializationTagAttribute>();
|
||||
return Enum.Parse(
|
||||
enumType,
|
||||
reader.GetAttribute(attributeExtractor.ExtractAttachedAttributeFromProperty(PropertyContainer, propertyName).Value));
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem parsing " + (propertyName ?? "<<NULL>>") + " property", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
using System.Text;
|
||||
using System;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// encapsulates converting array or IEnumerables to a string
|
||||
/// </summary>
|
||||
public static class ArrayToString
|
||||
{
|
||||
/// <summary>
|
||||
/// separator between elements
|
||||
/// </summary>
|
||||
/// <remarks>This will change the separator for all callers</remarks>
|
||||
public static string Separater { get; set; } = ", ";
|
||||
|
||||
/// <summary>
|
||||
/// separator between elements with no space
|
||||
/// </summary>
|
||||
/// <remarks>This will change the separator for all callers</remarks>
|
||||
public static string SeparaterNoSpace { get; set; } = ",";
|
||||
|
||||
/// <summary>
|
||||
/// symbol for the start of a group
|
||||
/// </summary>
|
||||
/// <remarks>this will change the symbol for all callers</remarks>
|
||||
public static string LeftGroup { get; set; } = "(";
|
||||
|
||||
/// <summary>
|
||||
/// symbol for the end of a group
|
||||
/// </summary>
|
||||
/// <remarks>this will change the symbol for all callers</remarks>
|
||||
public static string RightGroup { get; set; } = ")";
|
||||
|
||||
/// <summary>
|
||||
/// separator character between elements
|
||||
/// </summary>
|
||||
public static char[] SeparaterChar { get; set; } = new char[1] { ',' };
|
||||
/// <summary>
|
||||
/// symbol for the opening paren
|
||||
/// </summary>
|
||||
public static char[] LeftGroupChar { get; set; } = new char[1] { '(' };
|
||||
|
||||
/// <summary>
|
||||
/// symbol for the closing paren
|
||||
/// </summary>
|
||||
public static char[] RightGroupChar { get; set; } = new char[1] { ')' };
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// constructs a string out of an array.
|
||||
/// IEnumerable classes are returned using .ToString()
|
||||
/// if object is null, a string with null in angle brackets is returned
|
||||
/// </summary>
|
||||
/// <param name="arr">array to serialize to string</param>
|
||||
/// <param name="leftStr">symbol to put at the start of the string</param>
|
||||
/// <param name="sepStr">symbol to use between elements</param>
|
||||
/// <param name="rightStr">symbol to use at the end of the string</param>
|
||||
/// <returns>string representation of array</returns>
|
||||
public static string ArrayObjectToString(object arr, string leftStr, string sepStr, string rightStr)
|
||||
{
|
||||
if (arr == null)
|
||||
return "<null>";
|
||||
var enumerable = arr as System.Collections.IEnumerable;
|
||||
if (enumerable == null)
|
||||
{
|
||||
// not an array
|
||||
return arr.ToString();
|
||||
}
|
||||
|
||||
if (arr is string sArr) { return sArr; }
|
||||
|
||||
var str = new StringBuilder(leftStr);
|
||||
var addsep = false;
|
||||
foreach (var obj in enumerable)
|
||||
{
|
||||
if (addsep)
|
||||
str.Append(sepStr);
|
||||
str.Append(obj);
|
||||
addsep = true;
|
||||
}
|
||||
str.Append(rightStr);
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns a string representation of an array
|
||||
/// </summary>
|
||||
/// <param name="arr">array to serialize to string</param>
|
||||
/// <returns>string representation of array</returns>
|
||||
public static string ArrayObjectToString(object arr)
|
||||
{
|
||||
return ArrayObjectToString(arr, LeftGroup, Separater, RightGroup);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructs an array of unsigned ints out of a string
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <param name="leftGroup">symbol to remove at the start</param>
|
||||
/// <param name="separater">symbol used to separate elements</param>
|
||||
/// <param name="rightGroup">symbol to remove at the end</param>
|
||||
/// <returns></returns>
|
||||
public static uint[] StringToUIntArray(string s, char[] leftGroup, char[] separater, char[] rightGroup)
|
||||
{
|
||||
var noParens = s.TrimStart(leftGroup); //First paren
|
||||
noParens = noParens.TrimEnd(rightGroup); //Last paren
|
||||
var elements = noParens.Split(separater); //Comma
|
||||
uint[] a = new uint[elements.Length];
|
||||
var index = 0;
|
||||
foreach (var element in elements)
|
||||
{
|
||||
a[index] = Convert.ToUInt32(element);
|
||||
index++;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns an array of unsigned ints
|
||||
/// </summary>
|
||||
/// <param name="s">string to convert to an array of unsigned ints</param>
|
||||
/// <returns>an array of unsigned ints</returns>
|
||||
public static uint[] StringToUIntArray(string s)
|
||||
{
|
||||
return StringToUIntArray(s, LeftGroupChar, SeparaterChar, RightGroupChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,428 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using DTS.Common.Utilities.Properties;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Common.Utilities.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// this class encapsulating writing to the log
|
||||
///
|
||||
/// </summary>
|
||||
public static class APILogger
|
||||
{
|
||||
private static readonly object ProcessLock = new object();
|
||||
private static readonly Dictionary<string, Stack<Stopwatch>> _processes = new Dictionary<string, Stack<Stopwatch>>();
|
||||
public static int LogLevel { get; set; } = 3;
|
||||
public static void StartProcess(string name)
|
||||
{
|
||||
lock (ProcessLock)
|
||||
{
|
||||
if (!_processes.ContainsKey(name)) { _processes[name] = new Stack<Stopwatch>(); }
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
_processes[name].Push(sw);
|
||||
Log($"Starting process: [{name}] ({_processes[name].Count})");
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopProcess(string name)
|
||||
{
|
||||
lock (ProcessLock)
|
||||
{
|
||||
if (!_processes.ContainsKey(name) || 0 == _processes[name].Count)
|
||||
{
|
||||
Log($"Stopping process: [{name}] (0)");
|
||||
return;
|
||||
}
|
||||
var sw = _processes[name].Pop();
|
||||
sw.Stop();
|
||||
var ts = new TimeSpan(sw.ElapsedTicks);
|
||||
Log($"Stopping process: [{name}], {TimespanToHumanReadable(ts)}");
|
||||
}
|
||||
}
|
||||
private static string TimespanToHumanReadable(TimeSpan ts)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (ts.TotalDays > 1)
|
||||
{
|
||||
sb.Append($"{System.Math.Floor(ts.TotalDays):0} days, ");
|
||||
}
|
||||
sb.Append($"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds}.{ts.Milliseconds:000}");
|
||||
return sb.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// describes an event that should be raised when there's an error that needs to be handled by an application
|
||||
/// </summary>
|
||||
public delegate void ErrorRaisedEventDelegate(string msg);
|
||||
|
||||
private static ErrorRaisedEventDelegate _OnErrorRaised;
|
||||
/// <summary>
|
||||
/// Error handler called when errors are raised
|
||||
/// </summary>
|
||||
public static ErrorRaisedEventDelegate OnErrorRaised
|
||||
{
|
||||
get => _OnErrorRaised;
|
||||
set => _OnErrorRaised = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// raises an error, if an error handler is set, calls error handler
|
||||
/// </summary>
|
||||
public static void RaiseError(string error)
|
||||
{
|
||||
OnErrorRaised?.Invoke(error);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static string GetCurrentMethod()
|
||||
{
|
||||
var st = new StackTrace();
|
||||
var sf = st.GetFrame(1);
|
||||
|
||||
return sf.GetMethod().Name;
|
||||
}
|
||||
|
||||
private static bool _bDoPerformanceLog;
|
||||
public static void SetDoPerformanceLog(bool bDoLog)
|
||||
{
|
||||
_bDoPerformanceLog = bDoLog;
|
||||
}
|
||||
private static readonly object MyLock = new object();
|
||||
public static void DoPerformanceLog(string msg)
|
||||
{
|
||||
if (!_bDoPerformanceLog) { return; }
|
||||
var dt = DateTime.Now;
|
||||
var s = string.Format("{0:0000}-{1:00}-{2:00} {3:00}:{4:00}:{5:00}.{6:0000} ***{7}\r\n", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Millisecond, msg);
|
||||
lock (MyLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.AppendAllText("PERFLOG.LOG", s);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored - performance logging is only for statistics, we fail then we fail, just keep going
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// a function capable of logging a message
|
||||
/// </summary>
|
||||
/// <param name="msg">message to log</param>
|
||||
public delegate void Sink(string msg);
|
||||
|
||||
/// <summary>
|
||||
/// a consumer of log messages
|
||||
/// </summary>
|
||||
public static Sink Writer;
|
||||
|
||||
public static Sink ConfigurationLogWriter;
|
||||
public static Sink ConfigReadErrorLogWriter;
|
||||
|
||||
public static Sink StateWriter;
|
||||
|
||||
private static string LogException(Exception ex, bool bPrepend, bool bNewLine)
|
||||
{
|
||||
if (Writer == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
try
|
||||
{
|
||||
if (ex == null)
|
||||
{
|
||||
Writer("LogException: called with null exception");
|
||||
}
|
||||
else
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (bPrepend) { sb.Append(string.Concat(DateTime.Now.ToString(Resources.APILogging_DateTime_Format), " ")); }
|
||||
ExceptionFormater(ref sb, ex, 0);
|
||||
sb = sb.Replace(Environment.NewLine, " ");
|
||||
if (bNewLine) { sb.AppendLine(); }
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ownEx)
|
||||
{
|
||||
// and to be really paranoid...
|
||||
string orgMsg;
|
||||
if (ex == null)
|
||||
{
|
||||
orgMsg = "null exception";
|
||||
}
|
||||
else if (string.IsNullOrEmpty(ex.Message))
|
||||
{
|
||||
orgMsg = "blank exception message";
|
||||
}
|
||||
else
|
||||
{
|
||||
orgMsg = ex.Message;
|
||||
}
|
||||
try
|
||||
{
|
||||
Writer("APILogger: LogException threw an expection: " + ownEx.Message + " when handling: " + orgMsg);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
/// <summary>
|
||||
/// log an exception
|
||||
/// </summary>
|
||||
/// <param name="ex">exception to be logged</param>
|
||||
public static void LogException(Exception ex)
|
||||
{
|
||||
Writer(LogException(ex, true, true));
|
||||
}
|
||||
public const string EXCEPTIONSTART_STRING = "!! ";
|
||||
private static void ExceptionFormater(ref StringBuilder sb, Exception ex, int level)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (ex == null)
|
||||
return;
|
||||
var front = new string(' ', level);
|
||||
sb.Append(EXCEPTIONSTART_STRING);
|
||||
sb.AppendFormat(Resources.APILogging_ExceptionFormatter_ExceptionOfTypeOccurredString, front, level > 0 ? Resources.APILogging_ExceptionFormatter_InnerIndicationString : Resources.APILogging_ExceptionFormatter_NonInnerIndicationString, ex.GetType());
|
||||
if (null != ex.TargetSite)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_ModuleNameDisplayString, front, NullGuard(ex.TargetSite.Module.Name), NullGuard(ex.TargetSite.Name));
|
||||
}
|
||||
sb.AppendFormat(Resources.APILogging_ExceptionMessageDisplayString, front, NullGuard(ex.Message));
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
{
|
||||
// RW: It appears .NET 4.5 has a subtle difference in stack formatting. I don't see it, but it's breaking the Regex.
|
||||
// I'm not sure why it's using regex in the first place. This should work for both, but has not been tested with .NET 2.0
|
||||
string[] delimeters = { Environment.NewLine };
|
||||
var lines = ex.StackTrace.Split(delimeters, 2, StringSplitOptions.None);
|
||||
if (lines.Length > 0)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_StackTraceDisplayString, front, NullGuard(lines[0]));
|
||||
if (lines.Length > 1)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_StackTraceDisplayString, front, NullGuard(lines[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
// now call ourself with inner
|
||||
ex = ex.InnerException;
|
||||
level = level + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static string NullGuard(string s)
|
||||
{
|
||||
return s ?? Resources.Generic_NullIndicatorString;
|
||||
}
|
||||
|
||||
private static readonly string DATE_FORMAT = Resources.APILogging_DateTime_Format;
|
||||
private static string LogString(string str, bool bPrepend, bool bNewLine, bool bReplaceNewLines = true)
|
||||
{
|
||||
if (Writer == null)
|
||||
throw new Exception(Resources.APILogging_NullWriterDelegateString);
|
||||
var sb = new StringBuilder();
|
||||
if (bPrepend) { sb.Append($"{DateTime.Now.ToString(DATE_FORMAT)} "); }
|
||||
|
||||
if (bReplaceNewLines)
|
||||
{
|
||||
sb.Append(str.Replace(Environment.NewLine, " "));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(str);
|
||||
}
|
||||
|
||||
if (bNewLine) { sb.AppendLine(); }
|
||||
return sb.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// logs a string
|
||||
/// </summary>
|
||||
/// <param name="str">string to be logged</param>
|
||||
public static void LogString(string str)
|
||||
{
|
||||
Writer?.Invoke(LogString(str, true, true));
|
||||
}
|
||||
private static readonly object PhaseShiftLogLock = new object();
|
||||
/// <summary>
|
||||
/// logs a phase shift into a table
|
||||
/// </summary>
|
||||
/// <param name="serial"></param>
|
||||
/// <param name="msPhaseShift">MICROSECONDS of shift</param>
|
||||
/// <param name="originalT0"></param>
|
||||
/// <param name="modifiedTo"></param>
|
||||
/// <param name="samples"></param>
|
||||
/// <param name="rule"></param>
|
||||
public static void LogPhaseShift(string serial, double msPhaseShift, ulong originalT0, ulong modifiedTo, ulong samples, string rule)
|
||||
{
|
||||
try
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var s = string.Format("{0:0000}-{1:00}-{2:00} {3:00}:{4:00}:{5:00}.{6:0000}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\r\n",
|
||||
now.Year,
|
||||
now.Month,
|
||||
now.Day,
|
||||
now.Hour,
|
||||
now.Minute,
|
||||
now.Second,
|
||||
now.Millisecond,
|
||||
serial,
|
||||
samples,
|
||||
msPhaseShift,
|
||||
originalT0,
|
||||
modifiedTo,
|
||||
rule
|
||||
);
|
||||
lock (PhaseShiftLogLock)
|
||||
{
|
||||
|
||||
File.WriteAllLines("PHASE_SHIFT_LOG.txt", new[] { s });
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { Log(ex); }
|
||||
}
|
||||
|
||||
public static void StateLog(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
if (i > 0) { sb.Append(" "); }
|
||||
var s = paramlist[i] as string;
|
||||
if (paramlist[i] is DialogResult) { s = string.Format(" User selected {0}", ((DialogResult)paramlist[i])); }
|
||||
var ex = paramlist[i] as Exception;
|
||||
|
||||
if (null == s && null == ex && null != paramlist[i]) { s = paramlist[i].ToString(); }
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex) { sb.Append(LogException(ex, bPrepend, bNewLine)); }
|
||||
else if (null != s) { sb.Append(LogString(s, bPrepend, bNewLine, false)); }
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
StateWriter(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//if we fail to log there's not much more we can do ...
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
private const int LOG_LEVEL_DEBUG = 2;
|
||||
private static void LogEx(int logLevel, params object[] paramList)
|
||||
{
|
||||
if (logLevel >= LogLevel)
|
||||
{
|
||||
var newparams = new object[paramList.Length + 1];
|
||||
Array.Copy(new[] { $"LOG_LEVEL_{logLevel}" }, 0, newparams, 0, 1);
|
||||
Array.Copy(paramList, 0, newparams, 1, paramList.Length);
|
||||
Log(newparams);
|
||||
}
|
||||
}
|
||||
public static void DebugLog(params object[] paramList)
|
||||
{
|
||||
LogEx(LOG_LEVEL_DEBUG, paramList);
|
||||
}
|
||||
/// <summary>
|
||||
/// logs multiple parameters
|
||||
/// </summary>
|
||||
/// <param name="paramlist">
|
||||
/// collection of parameters, can be exceptions, strings, or an object with tostring
|
||||
/// </param>
|
||||
public static void Log(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
var obj = paramlist[i];
|
||||
if (i > 0) { sb.Append(" "); }
|
||||
var s = obj as string;
|
||||
if (obj is DialogResult) { s = $" User selected {(DialogResult)obj}"; }
|
||||
|
||||
if (obj is byte[])
|
||||
{
|
||||
s = BitConverter.ToString((byte[])obj).Replace("-", "");
|
||||
}
|
||||
|
||||
var ex = obj as Exception;
|
||||
if (null == s && null == ex && null != obj) { s = obj.ToString(); }
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex) { sb.Append(LogException(ex, bPrepend, bNewLine)); }
|
||||
else if (null != s) { sb.Append(LogString(s, bPrepend, bNewLine)); }
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
//KeywordAlert.Instance.ProcessMsg(msg);
|
||||
Writer(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//if we fail to log there's not much more we can do ...
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// logs multiple parameters
|
||||
/// </summary>
|
||||
/// <param name="paramlist">
|
||||
/// collection of parameters, can be exceptions, strings, or an object with tostring
|
||||
/// </param>
|
||||
public static void ConfLog(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
sb.Append(" ");
|
||||
}
|
||||
var s = paramlist[i] as string;
|
||||
if (paramlist[i] is DialogResult)
|
||||
{
|
||||
s = $" User selected {(DialogResult)paramlist[i]}";
|
||||
}
|
||||
var ex = paramlist[i] as Exception;
|
||||
|
||||
if (null == s && null == ex && null != paramlist[i])
|
||||
{
|
||||
s = paramlist[i].ToString();
|
||||
}
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex)
|
||||
{
|
||||
sb.Append(LogException(ex, bPrepend, bNewLine));
|
||||
}
|
||||
else if (null != s)
|
||||
{
|
||||
sb.Append(LogString(s, bPrepend, bNewLine));
|
||||
}
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
ConfigurationLogWriter(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//as with the other log function, if we fail we don't have much backing we can do
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
ChannelFilter.cs
|
||||
|
||||
$Log: ChannelFilter.cs,v $
|
||||
Revision 1.2 2007/04/20 17:46:32 Paul Hrissikopoulos
|
||||
Added integration and differentiation to standard filter set.
|
||||
|
||||
Revision 1.1 2006/10/26 22:06:47 Paul Hrissikopoulos
|
||||
Added channel data filtering.
|
||||
|
||||
Copyright © 2006
|
||||
Diversified Technical Systems, Inc.
|
||||
All Righst Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumeration of all possible filters that may be applied to channel
|
||||
/// data. These can be used as software filters in data review.
|
||||
///
|
||||
/// </summary>
|
||||
public enum ChannelFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// no filter is applied
|
||||
/// </summary>
|
||||
[Description("UnfilteredZero")]
|
||||
[CFCValue(0)]
|
||||
[IsoDescription("0")]
|
||||
[Enumerability(true)]
|
||||
UnfilteredZero = -2,
|
||||
|
||||
/// <summary>
|
||||
/// no filter is applied
|
||||
/// </summary>
|
||||
[Description("Unfiltered")]
|
||||
[CFCValue(0)]
|
||||
[IsoDescription("0")]
|
||||
[Enumerability(true)]
|
||||
Unfiltered = 0,
|
||||
|
||||
/// <summary>
|
||||
/// filter at 17Hz (Channel Frequency Class)
|
||||
/// </summary>
|
||||
[Description("CFC 10")]
|
||||
[CFCValue(10)]
|
||||
[IsoDescription("Q")]
|
||||
[Enumerability(true)]
|
||||
Class10 = 17,
|
||||
|
||||
/// <summary>
|
||||
/// filter at 100Hz (Channel Frequency Class)
|
||||
/// 3 dB limit Frequncy
|
||||
/// stop damping -30 dB
|
||||
/// sample frequency > 600Hz
|
||||
/// </summary>
|
||||
[Description("CFC 60")]
|
||||
[CFCValue(60)]
|
||||
[IsoDescription("D")]
|
||||
[Enumerability(true)]
|
||||
Class60 = 100,
|
||||
|
||||
/// <summary>
|
||||
/// filter at 300Hz (Channel Frequency Class)
|
||||
/// 3 dB limit frequency
|
||||
/// stop damping -30Db
|
||||
/// sampling frequency > 1800Hz
|
||||
/// </summary>
|
||||
[Description("CFC 180")]
|
||||
[CFCValue(180)]
|
||||
[IsoDescription("C")]
|
||||
[Enumerability(true)]
|
||||
Class180 = 300,
|
||||
|
||||
/// <summary>
|
||||
/// 3Db limit frequency 1000Hz (channel frequency class)
|
||||
/// stop damping -40Db
|
||||
/// sampling frequency > 6 khz
|
||||
/// </summary>
|
||||
[Description("CFC 600")]
|
||||
[CFCValue(600)]
|
||||
[IsoDescription("B")]
|
||||
[Enumerability(true)]
|
||||
Class600 = 1000,
|
||||
|
||||
/// <summary>
|
||||
/// 3dB limit frequency 1650Hz
|
||||
/// stop damping -40dB
|
||||
/// sampling frequency > 10khz
|
||||
/// </summary>
|
||||
[Description("CFC 1000")]
|
||||
[CFCValue(1000)]
|
||||
[IsoDescription("A")]
|
||||
[Enumerability(true)]
|
||||
Class1000 = 1650,
|
||||
|
||||
[Description("Custom")]
|
||||
[CFCValue(-1)]
|
||||
//FB 13120 AdHoc ISO code is S
|
||||
[IsoDescription("S")]
|
||||
[Enumerability(false)]
|
||||
AdHoc = -1
|
||||
|
||||
//[Description( "1st Integration")]
|
||||
//[IsoDescription( "?" )]
|
||||
//Integral = 2000,
|
||||
|
||||
//[Description( "1st Derivative")]
|
||||
//[IsoDescription( "?" )]
|
||||
//Derivative = 2001,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for specifying the ISO code fragment description of the attached
|
||||
/// field's representation. Intended to be applied to enumerations that
|
||||
/// represent ISO-codeable elements.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class IsoDescriptionAttribute : Attribute
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get the <see cref="string"/> that ISO-describes whatever this attribute
|
||||
/// is attached to.
|
||||
/// </summary>
|
||||
public string IsoDescription { get; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes an instance of the IsoDescriptionAttribute class.
|
||||
/// </summary>
|
||||
/// <param name="isoDescription">
|
||||
/// The <see cref="T:System.String" /> that ISO-describes whatever this attribute
|
||||
/// is attached to.
|
||||
/// </param>
|
||||
public IsoDescriptionAttribute(string isoDescription)
|
||||
{
|
||||
IsoDescription = isoDescription;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tool for manipulating <see cref="ChannelFilter"/>-attached <see cref="IsoDescriptionAttribute"/>s.
|
||||
/// </summary>
|
||||
public class IsoDescriptionAttributeCoder
|
||||
: AttributeCoder<ChannelFilter, IsoDescriptionAttribute, string>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes an instance of the IsoDescriptionAttributeCoder class.
|
||||
/// </summary>
|
||||
public IsoDescriptionAttributeCoder()
|
||||
: base(attribute => attribute.IsoDescription, null)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for specifying the "enumerability" of the attached
|
||||
/// field's representation. Intended to be applied to enumerations that
|
||||
/// contain valid, but special case elements that should never be automatically
|
||||
/// enumerated.
|
||||
/// </summary>
|
||||
///
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class EnumerabilityAttribute : Attribute
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get the <see cref="bool"/> that describes enumerability.
|
||||
/// </summary>
|
||||
public bool IsEnumerable { get; private set; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an instance of the EnumerablilityAttribute class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="isEnumerable">
|
||||
/// The <see cref="bool"/> that describes the attached object's enumerability.
|
||||
/// </param>
|
||||
///
|
||||
public EnumerabilityAttribute(bool isEnumerable)
|
||||
{
|
||||
IsEnumerable = isEnumerable;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tool for manipulating <see cref="ChannelFilter"/>-attached <see cref="EnumerabilityAttribute"/>s.
|
||||
/// </summary>
|
||||
public class EnumerabilityAttributeCoder
|
||||
: AttributeCoder<ChannelFilter, EnumerabilityAttribute, bool>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes an instance of the EnumerabilityAttributeCoder class.
|
||||
/// </summary>
|
||||
public EnumerabilityAttributeCoder()
|
||||
: base(attribute => attribute.IsEnumerable, null)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute for specifying the numeric value of the filter CFC.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class CFCValueAttribute : Attribute
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get the <see cref="double"/> value of the CFC this attribute is attached to.
|
||||
/// </summary>
|
||||
public double CFCValue => _cfcValue;
|
||||
|
||||
private readonly double _cfcValue;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an instance of the CFCValueAttribute class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="cfcValue">
|
||||
/// The <see cref="double"/> value of the CFC this attribute is attached to.
|
||||
/// </param>
|
||||
///
|
||||
public CFCValueAttribute(double cfcValue)
|
||||
{
|
||||
_cfcValue = cfcValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tool for manipulating <see cref="ChannelFilter"/>-attached <see cref="CFCValueAttribute"/>s.
|
||||
/// </summary>
|
||||
public class CfcValueAttributeCoder
|
||||
: AttributeCoder<ChannelFilter, CFCValueAttribute, double>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes an instance of the CfcValueAttributeCoder class.
|
||||
/// </summary>
|
||||
public CfcValueAttributeCoder()
|
||||
: base(attribute => attribute.CFCValue, null)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* ExceptionalList.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// A version of <see cref="T:List"/> that provides its own exception type.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="T">
|
||||
/// The type of object contained by this list.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Sample usage:
|
||||
/// public class A : ExceptionalList <int>
|
||||
/// {
|
||||
/// public void ScrewItUp( )
|
||||
/// {
|
||||
/// private bool error = true;
|
||||
/// if ( error ) throw new A.Exception( "Class A-specific screwup." );
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// ...
|
||||
///
|
||||
/// try
|
||||
/// {
|
||||
/// A.ScrewItUp( );
|
||||
/// B.ScrewItUp( );
|
||||
/// C.ScrewItUp( );
|
||||
/// }
|
||||
/// catch ( A.Exception ex )
|
||||
/// {
|
||||
/// // Can pick A's exceptions out of a crowd, or not and just treat it
|
||||
/// // polymorphically as a System.Exception.
|
||||
/// }
|
||||
/// </remarks>
|
||||
///
|
||||
[global::System.Serializable]
|
||||
public class ExceptionalList<T> : List<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the ExceptionalList class.
|
||||
/// </summary>
|
||||
public ExceptionalList()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the ExceptionalList class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="capacity">
|
||||
/// The number of elements that the list can initially store.
|
||||
/// </param>
|
||||
///
|
||||
public ExceptionalList(int capacity)
|
||||
: base(capacity)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the ExceptionalList class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="collection">
|
||||
/// The collection whose elements are copied to the new list.
|
||||
/// </param>
|
||||
///
|
||||
public ExceptionalList(IEnumerable<T> collection)
|
||||
: base(collection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A representation of the DerivedClass.Exception class.
|
||||
/// </summary>
|
||||
public class Exception : ApplicationException
|
||||
{
|
||||
public Exception() { }
|
||||
public Exception(string msg) : base(msg) { }
|
||||
public Exception(string msg, System.Exception innerEx) : base(msg, innerEx) { }
|
||||
protected Exception(
|
||||
System.Runtime.Serialization.SerializationInfo info,
|
||||
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Utilities
|
||||
{ //
|
||||
// Nothing in here.
|
||||
} //
|
||||
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
public class PowerManagement
|
||||
{
|
||||
[DllImport("powrprof.dll")]
|
||||
static extern uint PowerGetActiveScheme(
|
||||
IntPtr UserRootPowerKey,
|
||||
ref IntPtr ActivePolicyGuid);
|
||||
|
||||
[DllImport("powrprof.dll")]
|
||||
static extern uint PowerReadACValue(
|
||||
IntPtr RootPowerKey,
|
||||
IntPtr SchemeGuid,
|
||||
IntPtr SubGroupOfPowerSettingGuid,
|
||||
ref Guid PowerSettingGuid,
|
||||
ref int Type,
|
||||
ref IntPtr Buffer,
|
||||
ref uint BufferSize
|
||||
);
|
||||
|
||||
[DllImport("powrprof.dll", CharSet = CharSet.Unicode)]
|
||||
static extern uint PowerReadFriendlyName(
|
||||
IntPtr RootPowerKey,
|
||||
IntPtr SchemeGuid,
|
||||
IntPtr SubGroupOfPowerSettingGuid,
|
||||
IntPtr PowerSettingGuid,
|
||||
StringBuilder Buffer,
|
||||
ref uint BufferSize
|
||||
);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern IntPtr LocalFree(
|
||||
IntPtr hMem
|
||||
);
|
||||
[DllImport("powrprof.dll")]
|
||||
static extern uint PowerEnumerate(
|
||||
IntPtr RootPowerKey,
|
||||
IntPtr SchemeGuid,
|
||||
ref Guid SubGroupOfPowerSetting,
|
||||
uint AccessFlags,
|
||||
uint Index,
|
||||
ref Guid Buffer,
|
||||
ref uint BufferSize);
|
||||
|
||||
private const uint ERROR_MORE_DATA = 234;
|
||||
private static Guid HIGH_PERFORMANCE_GUID = new Guid("8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c");
|
||||
private static Guid MAX_PERFORMANCE_GUID = new Guid("01360e7e-525f-4625-ab94-f283dcfbd515");
|
||||
//private static Guid GUID_PROCESSOR_SETTINGS_SUBGROUP = new Guid("GUID_PROCESSOR_SETTINGS_SUBGROUP");
|
||||
//private static Guid GUID_POWERSCHEME_PERSONALITY = new Guid(0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7);
|
||||
private static Guid GUID_PROCESSOR_SETTINGS_SUBGROUP = new Guid("54533251-82be-4824-96c1-47b60b740d00");
|
||||
private const uint ACCESS_INDIVIDUAL_SETTING = 18;
|
||||
public static bool IsInHighPowerMode()
|
||||
{
|
||||
var activeGuidPtr = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
uint res = 0;
|
||||
|
||||
//8663 don't do power warning if performance/max performance power modes don't exist
|
||||
//enumerate all the schemes and look for either the high power guid or name, or max
|
||||
//we could use this to determine the active one scheme, but for now we just want to log and
|
||||
//not continue on if we don't find high performance/max performance.
|
||||
var bContainsMaxOrHighPerformance = false;
|
||||
|
||||
var p = new System.Diagnostics.Process
|
||||
{
|
||||
StartInfo =
|
||||
{
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true,
|
||||
WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized,
|
||||
FileName = "powercfg",
|
||||
Arguments = "/list"
|
||||
}
|
||||
};
|
||||
|
||||
p.Start();
|
||||
var output = p.StandardOutput.ReadToEnd();
|
||||
//APILogger.Log("Active Power Schemes", output);
|
||||
p.WaitForExit();
|
||||
|
||||
if (output.Contains(HIGH_PERFORMANCE_GUID.ToString()) || (output.Contains(MAX_PERFORMANCE_GUID.ToString()))
|
||||
|| output.Contains("High performance") || output.Contains("Max performance")
|
||||
)
|
||||
{
|
||||
bContainsMaxOrHighPerformance = true;
|
||||
}
|
||||
|
||||
|
||||
//8663 don't do power warning if performance/max performance power modes don't exist
|
||||
if (!bContainsMaxOrHighPerformance)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
res = PowerGetActiveScheme(IntPtr.Zero, ref activeGuidPtr);
|
||||
if (res != 0)
|
||||
throw new Win32Exception();
|
||||
|
||||
var g = (Guid)System.Runtime.InteropServices.Marshal.PtrToStructure(activeGuidPtr, typeof(Guid));
|
||||
if (g == HIGH_PERFORMANCE_GUID || g == MAX_PERFORMANCE_GUID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Get Friendly Name
|
||||
uint buffSize = 0;
|
||||
var buffer = new StringBuilder();
|
||||
var subGroupGuid = Guid.Empty;
|
||||
var powerSettingGuid = Guid.Empty;
|
||||
res = PowerReadFriendlyName(IntPtr.Zero, activeGuidPtr,
|
||||
IntPtr.Zero, IntPtr.Zero, buffer, ref buffSize);
|
||||
|
||||
if (res == ERROR_MORE_DATA)
|
||||
{
|
||||
buffer.Capacity = (int)buffSize;
|
||||
res = PowerReadFriendlyName(IntPtr.Zero, activeGuidPtr,
|
||||
IntPtr.Zero, IntPtr.Zero, buffer, ref buffSize);
|
||||
}
|
||||
|
||||
var name = buffer.ToString();
|
||||
name = name.ToLower();
|
||||
if (name.Contains("maximum performance") || name.Contains("high performance"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
APILogger.Log(string.Format("{0}\nProfile name:", APILogger.GetCurrentMethod()), name, "GUID:", g.ToString());
|
||||
APILogger.Log("Active Power Schemes", output);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (activeGuidPtr != IntPtr.Zero)
|
||||
{
|
||||
var res = LocalFree(activeGuidPtr);
|
||||
if (res != IntPtr.Zero)
|
||||
throw new Win32Exception();
|
||||
}
|
||||
}
|
||||
//default to okay, so if there's an error, or if we can't read, just continue on
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
* DataWindowAverager.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Time averaging data over a specific window
|
||||
/// there can be pretrigger time and begin time can be used to compute the start
|
||||
/// of the averaging window
|
||||
/// </summary>
|
||||
public partial class DataWindowAverager : Exceptional
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Initialize an instance of this data window averager class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="beginTimeSec">
|
||||
/// Get the <see cref="double"/> time value (sec) of the start of the averaging window.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="endTimeSec">
|
||||
/// Get the <see cref="double"/> time value (sec) of the end of the averaging window.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="preTriggerTimeSec">
|
||||
/// Get the <see cref="double"/> pre-trigger time (sec).
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="sampleRateHz">
|
||||
/// Get the <see cref="double"/> sample rate (Hz).
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="defaultValue">
|
||||
/// Get the default <see cref="short"/> ADC value to be returned if the specified window
|
||||
/// is invalid.
|
||||
/// </param>
|
||||
///
|
||||
public DataWindowAverager(
|
||||
double beginTimeSec,
|
||||
double endTimeSec,
|
||||
double preTriggerTimeSec,
|
||||
double sampleRateHz,
|
||||
short defaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
BeginTimeSec = beginTimeSec;
|
||||
EndTimeSec = endTimeSec;
|
||||
PreTriggerTimeSec = preTriggerTimeSec;
|
||||
SampleRateHz = sampleRateHz;
|
||||
DefaultValue = defaultValue;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="double"/> time value (sec) of the start of the averaging window.
|
||||
/// </summary>
|
||||
public double BeginTimeSec
|
||||
{
|
||||
get => _beginTimeSec.Value;
|
||||
private set => _beginTimeSec.Value = value;
|
||||
}
|
||||
private readonly Property<double> _beginTimeSec
|
||||
= new Property<double>(
|
||||
typeof(DataWindowAverager).FullName + ".BeginTimeSec",
|
||||
0.0,
|
||||
false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="double"/> time value (sec) of the end of the averaging window.
|
||||
/// </summary>
|
||||
public double EndTimeSec
|
||||
{
|
||||
get => _endTimeSec.Value;
|
||||
private set => _endTimeSec.Value = value;
|
||||
}
|
||||
private readonly Property<double> _endTimeSec
|
||||
= new Property<double>(
|
||||
typeof(DataWindowAverager).FullName + ".EndTimeSec",
|
||||
0.0,
|
||||
false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="double"/> pre-trigger time (sec).
|
||||
/// </summary>
|
||||
public double PreTriggerTimeSec
|
||||
{
|
||||
get => _preTriggerTimeSec.Value;
|
||||
private set => _preTriggerTimeSec.Value = value;
|
||||
}
|
||||
private readonly Property<double> _preTriggerTimeSec
|
||||
= new Property<double>(
|
||||
typeof(DataWindowAverager).FullName + ".PreTriggerTimeSec",
|
||||
0.0,
|
||||
false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="double"/> sample rate (Hz).
|
||||
/// </summary>
|
||||
public double SampleRateHz
|
||||
{
|
||||
get => _sampleRateHz.Value;
|
||||
private set => _sampleRateHz.Value = value;
|
||||
}
|
||||
private readonly Property<double> _sampleRateHz
|
||||
= new Property<double>(
|
||||
typeof(DataWindowAverager).FullName + ".SampleRateHz",
|
||||
0.0,
|
||||
false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get the default <see cref="short"/> ADC value to be returned if the specified window
|
||||
/// is invalid.
|
||||
/// </summary>
|
||||
public short DefaultValue
|
||||
{
|
||||
get => _defaultValue.Value;
|
||||
private set => _defaultValue.Value = value;
|
||||
}
|
||||
private readonly Property<short> _defaultValue
|
||||
= new Property<short>(
|
||||
typeof(DataWindowAverager).FullName + ".DefaultValue",
|
||||
0,
|
||||
false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Compute the <see cref="short"/> average of the window represented by the current state
|
||||
/// of this object over the specified window values.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="windowValues">
|
||||
/// An array of <see cref="short"/> values to be window-averaged.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The average of the specified value falling within this object's window.
|
||||
/// </returns>
|
||||
///
|
||||
public short DetermineWindowAverage(short[] windowValues)
|
||||
{
|
||||
try
|
||||
{
|
||||
var numSamples = (ulong)((EndTimeSec - BeginTimeSec) * SampleRateHz) + 1;
|
||||
var windowSamples = new double[numSamples];
|
||||
var startingIndex = ((long)((PreTriggerTimeSec + BeginTimeSec) * SampleRateHz));
|
||||
|
||||
if (0 > startingIndex)
|
||||
throw new WindowDoesNotExistException(
|
||||
"the specified averaging window (" + BeginTimeSec + "s to " + EndTimeSec + "s) does not exist in the specified data set"
|
||||
);
|
||||
try
|
||||
{
|
||||
for (ulong i = 0; i < numSamples; i++)
|
||||
windowSamples[i] = windowValues[i + (ulong)startingIndex];
|
||||
return ((short)windowSamples.Average());
|
||||
}
|
||||
|
||||
catch (IndexOutOfRangeException)
|
||||
{
|
||||
throw new WindowDoesNotExistException("the specified averaging window lies outside of the supplied data");
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem determining window average", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compute the <see cref="short"/> average of the window represented by the current state
|
||||
/// of this object over the specified window values.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="windowValues">
|
||||
/// An array of <see cref="double"/> values to be window-averaged.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The average of the specified value falling within this object's window.
|
||||
/// </returns>
|
||||
///
|
||||
public short DetermineWindowAverage(double[] windowValues)
|
||||
{
|
||||
try
|
||||
{
|
||||
var numSamples = (ulong)((EndTimeSec - BeginTimeSec) * SampleRateHz) + 1;
|
||||
var windowSamples = new double[numSamples];
|
||||
var startingIndex = ((long)((PreTriggerTimeSec + BeginTimeSec) * SampleRateHz));
|
||||
|
||||
if (0 > startingIndex)
|
||||
throw new WindowDoesNotExistException(
|
||||
"the specified averaging window (" + BeginTimeSec + "s to " + EndTimeSec + "s) does not exist in the given data set"
|
||||
);
|
||||
try
|
||||
{
|
||||
for (ulong i = 0; i < numSamples; i++)
|
||||
windowSamples[i] = windowValues[i + (ulong)startingIndex];
|
||||
var ave = (short)windowSamples.Average();
|
||||
|
||||
return (ave);
|
||||
}
|
||||
|
||||
catch (IndexOutOfRangeException)
|
||||
{
|
||||
throw new WindowDoesNotExistException("the specified averaging window lies outside of the supplied data");
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem determining window average", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,494 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||
<Class Name="DTS.Common.Utilities.ActiveUpdateList<T>" Collapsed="true">
|
||||
<Position X="0.5" Y="5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>ACMAAAAAAAAAAAAAIAAABAAAAAAAAAAAKAAAAIBEAAA=</HashCode>
|
||||
<FileName>ActiveUpdateList.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.ArrayToString" Collapsed="true">
|
||||
<Position X="44.75" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAQAAAEAAAAAQAAAAAAAAAAEAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>ArrayToString.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.AttributeCoder<TargetType, AttributeType, AttributeValueType>" Collapsed="true">
|
||||
<Position X="11.25" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAIQAAAAAAAAAAAAAAAAAAEAAAAAIAAAAAgAAAA=</HashCode>
|
||||
<FileName>AttributeCoder.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.AttributeExtractor<TAttributeType>" Collapsed="true">
|
||||
<Position X="20.25" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAE=</HashCode>
|
||||
<FileName>AttributeExtractor.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.AverageQueue" Collapsed="true">
|
||||
<Position X="46.5" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>ABABAAAAAAAABAAAAAACAAAAQAAAAAAAgAAAQBAACAA=</HashCode>
|
||||
<FileName>AverageQueue.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.AverageShortValueOverTime" Collapsed="true">
|
||||
<Position X="36" Y="3.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACA=</HashCode>
|
||||
<FileName>AverageShortValueOverTime.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.AverageValueOverTime<T>" Collapsed="true">
|
||||
<Position X="36" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BAAAAAAAQAIAAAAAAAAAAACAAAAgAAAAAAAAAAAAACA=</HashCode>
|
||||
<FileName>AverageValueOverTime.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.IsoDescriptionAttribute" Collapsed="true">
|
||||
<Position X="53.5" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAA=</HashCode>
|
||||
<FileName>ChannelFilter.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.IsoDescriptionAttributeCoder" Collapsed="true">
|
||||
<Position X="6.75" Y="3.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>ChannelFilter.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.EnumerabilityAttribute" Collapsed="true">
|
||||
<Position X="46.5" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>ChannelFilter.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.EnumerabilityAttributeCoder" Collapsed="true">
|
||||
<Position X="11.25" Y="3.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>ChannelFilter.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.CFCValueAttribute" Collapsed="true">
|
||||
<Position X="48.25" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAEAAAAAAA=</HashCode>
|
||||
<FileName>ChannelFilter.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.CfcValueAttributeCoder" Collapsed="true">
|
||||
<Position X="15.75" Y="3.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>ChannelFilter.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.CheckComboBoxItem" Collapsed="true">
|
||||
<Position X="51.75" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAgAAAEAAAAAAAAAAAAAAAAAAIACAAAAAA=</HashCode>
|
||||
<FileName>CheckComboBox.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.CheckComboBox" Collapsed="true">
|
||||
<Position X="50" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAQAAEgAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>CheckComboBox.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.FlagAttribute" Collapsed="true">
|
||||
<Position X="50" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>DataFlag.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.DataFlagAttributeCoder" Collapsed="true">
|
||||
<Position X="9" Y="3.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>DataFlag.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.DataWindowAverager" Collapsed="true">
|
||||
<Position X="4.5" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAkAAAAAAAAIAAAAAAAAgAAAgBAAAAAABYBAAAAEAA=</HashCode>
|
||||
<FileName>DataWindowAverager.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.DegreesFromADC" Collapsed="true">
|
||||
<Position X="53.5" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAA=</HashCode>
|
||||
<FileName>DegreesFromADC.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.DescriptionAttributeCoder<TTargetType>" Collapsed="true">
|
||||
<Position X="13.5" Y="3.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>DescriptionAttributeCoder.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.DiskUtility" Collapsed="true">
|
||||
<Position X="22.5" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAI=</HashCode>
|
||||
<FileName>DiskUtility.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.EnumDropDown<T>" Collapsed="true">
|
||||
<Position X="44.75" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAQAEABQAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>EnumDropDown.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Exceptional" Collapsed="true">
|
||||
<Position X="21.5" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAgAAAAEAAAAAAAgAEAAAAAACAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Exceptional.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.ExceptionalDictionary<TKey, TValue>" Collapsed="true">
|
||||
<Position X="48.25" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>ExceptionalDictionary.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.ExceptionalForm" Collapsed="true">
|
||||
<Position X="50" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>ExceptionalForm.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.ExceptionalList<T>" Collapsed="true">
|
||||
<Position X="0.5" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>ExceptionalList.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.ExceptionalUserControl" Collapsed="true">
|
||||
<Position X="51.75" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>ExceptionalUserControl.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.ExportINIFile" Collapsed="true">
|
||||
<Position X="53.5" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>CAAACAASQgAAAAAAAQKwAACABEQAAAACgICAQAAAAAA=</HashCode>
|
||||
<FileName>ExportINIFile.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.FileIOApiDeclarations" Collapsed="true">
|
||||
<Position X="43" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAQDgAgAAQBAQEAAgAQAgCgAAAAAQAAAAIABCCAgAAQ=</HashCode>
|
||||
<FileName>FileIODeclarations.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.FirmwareVersionToLong" Collapsed="true">
|
||||
<Position X="48.25" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>FirmwareVersionToLong.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.HexEncoding" Collapsed="true">
|
||||
<Position X="51.75" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AACAAAAQAAAAAAAEAAAAggAgAAAAAAAAAAABAAAAAAA=</HashCode>
|
||||
<FileName>HexEncoding.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.KeywordAlert" Collapsed="true">
|
||||
<Position X="43" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAQAAAAAAAAIIAAAAAAAAAAAQAAAAgAAAAA=</HashCode>
|
||||
<FileName>KeywordAlert.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.NaturalStringComparer" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="48.25" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAA=</HashCode>
|
||||
<FileName>NaturalStringCompare.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.NHTSASubSample<T>" Collapsed="true">
|
||||
<Position X="40.5" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAQAAAAAAAACEAAABAAAAAAAAAAAAAAQAAAEAAA=</HashCode>
|
||||
<FileName>NHTSASubSample.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.PersistWindowState" Collapsed="true">
|
||||
<Position X="50" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>CASAAAJEAAIAIAAAQAAA4gQCCAAAIAAAAAAAAQAAAAA=</HashCode>
|
||||
<FileName>PersistWindowState.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.PowerManagement" Collapsed="true">
|
||||
<Position X="51.75" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AIAAAAAAgAAEAAEAAAAAAgAKEAAAAAAAAAwAQAAAAAA=</HashCode>
|
||||
<FileName>PowerManagement.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.PropertyComparer<T>" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="43" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAQAAAAAAAIAAAAAAABAAAAAAIAQAEABAAAAAAAA=</HashCode>
|
||||
<FileName>PropertyComparer.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.ScrollingMessageBox" Collapsed="true">
|
||||
<Position X="50" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAIEAAEGAAAAAAALCkgQECAAAhAAAEAIAAkQABACA=</HashCode>
|
||||
<FileName>ScrollingMessageBox.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.SortableBindingList<T>" Collapsed="true">
|
||||
<Position X="53.5" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAgAIAAABAEAAAAAAACBAAAEIAAgIEAAAAAAAEAA=</HashCode>
|
||||
<FileName>SortableBindingList.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Time" Collapsed="true">
|
||||
<Position X="44.75" Y="5.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAACAAAAAAAgAIIAAAAEQAAA=</HashCode>
|
||||
<FileName>Time.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.UpdateNotifyingList<T>" Collapsed="true">
|
||||
<Position X="38.25" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAABAACAAAAAAAAAAAAAAAAAAAAAAAAAEAAAA=</HashCode>
|
||||
<FileName>UpdateNotifyingList.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.WaitWithCondition" Collapsed="true">
|
||||
<Position X="46.5" Y="5.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAA=</HashCode>
|
||||
<FileName>WaitWithCondition.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Logging.APILogger" Collapsed="true">
|
||||
<Position X="43" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAEgAAAQAAABMAAAAEgCAAAAQAABAAGAAAI=</HashCode>
|
||||
<FileName>APILogging.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Logging.TextLogger" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="43" Y="5.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>MAAAAQIAgCAAAIAIiBAAQAAAAAAQgAIAAAAAAAACEEA=</HashCode>
|
||||
<FileName>TextLogger.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.IO.MemoryMap.DoubleLargeArray" Collapsed="true">
|
||||
<Position X="43" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAgAgCAAAAACAAAAAAAAQAAAAAAAAABA=</HashCode>
|
||||
<FileName>DoubleLargeArray.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.IO.MemoryMap.FileMapIOException" Collapsed="true">
|
||||
<Position X="44.75" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAIAAAAAA=</HashCode>
|
||||
<FileName>FileMapIOException.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.IO.MemoryMap.FileMapViewArray" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="46.5" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAQAAAAAACAAAAQECAABAAAAAACAABAEACBAAAAAEAA=</HashCode>
|
||||
<FileName>FileMapViewArray.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.IO.MemoryMap.LargeArray<T>" Collapsed="true">
|
||||
<Position X="24.75" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>JEIAYEAAACCAkngwyAAAnASgARABZAAQCCAEAABQMHI=</HashCode>
|
||||
<FileName>LargeArray.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.IO.MemoryMap.MapViewStream" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="44.75" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IAAAAAAAACAAQAAgGAAAAABgAIABAAAABAAIggGIACA=</HashCode>
|
||||
<FileName>MapViewStream.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.IO.MemoryMap.MemoryMappedFile" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="46.5" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IAAAAAAAQCAAIAAAgAIAAAgAAAAAAEAAABAAQACAAAQ=</HashCode>
|
||||
<FileName>MemoryMappedFile.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.IO.MemoryMap.ShortLargeArray" Collapsed="true">
|
||||
<Position X="51.75" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAgAgCAAAAACAAAAAAAAQAAAAAAAAABA=</HashCode>
|
||||
<FileName>ShortLargeArray.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.IO.MemoryMap.Win32MapApis" Collapsed="true">
|
||||
<Position X="48.25" Y="5.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAEAgCAAAAAAAAAAAAQAQCAEAAACAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Win32APIs.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.SaeJ211.FilterUtility" Collapsed="true">
|
||||
<Position X="18" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BCAAAAAMAAgAAEAQAAACQQgCUQAAAABAgQIEAAAAAAA=</HashCode>
|
||||
<FileName>FilterUtility.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Math.DoubleListOperation" Collapsed="true">
|
||||
<Position X="29.25" Y="3.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Math.DoubleListOperation.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Math.Operation<DomainType, RangeType>" Collapsed="true">
|
||||
<Position X="29.25" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAACAAAAAACAAAAAgAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Math.Operation.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Math.Iso.Differentiation" Collapsed="true">
|
||||
<Position X="27" Y="4.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BAAAAAAAAAgACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Math.Iso.Differentiation.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Math.Nhtsa.Differentiation" Collapsed="true">
|
||||
<Position X="29.25" Y="4.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BAAAAAAAAAgACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Math.Nhtsa.Differentiation.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Math.Nhtsa.Integration" Collapsed="true">
|
||||
<Position X="31.5" Y="4.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BAAAAAAAAAgACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Math.Nhtsa.Integration.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.DotNetProgrammingConstructs.PowerOfTwoIntProperty" Collapsed="true">
|
||||
<Position X="53.5" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAgAAAAAAAAAAAAAAAAAAABAAAAAAAAAQAAAA=</HashCode>
|
||||
<FileName>PowerOfTwoIntProperty.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.DotNetProgrammingConstructs.Property<Type>" Collapsed="true">
|
||||
<Position X="2.25" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Property.ConstructionException.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.DotNetProgrammingConstructs.RangeRestrictedDoubleProperty" Collapsed="true">
|
||||
<Position X="44.75" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAIEAAAAAAQAAABAgAAAAAAAQAAAA=</HashCode>
|
||||
<FileName>RangeRestrictedDoubleProperty.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.DotNetProgrammingConstructs.RangeRestrictedIntProperty" Collapsed="true">
|
||||
<Position X="46.5" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAIEAAAAAAQAAABAgAAAAAAAQAAAA=</HashCode>
|
||||
<FileName>RangeRestrictedIntProperty.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Properties.Resources" Collapsed="true">
|
||||
<Position X="48.25" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BCASqICmIARAgGGAAESBmJgGKcgwoIMAAALPQgcCiNg=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Xml.PropertyAttributeDecoder<T>" Collapsed="true">
|
||||
<Position X="33.75" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAABEAIAAAQAAAAAAAAAQQAAAAAAAAAAAQA=</HashCode>
|
||||
<FileName>Xml.PropertyAttributeDecoder.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.Utilities.Xml.XmlSerializationTagAttribute" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="50" Y="5.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAEAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAgAAAAAAA=</HashCode>
|
||||
<FileName>XmlSerializationTagAttribute.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Enum Name="DTS.Common.Utilities.ChannelFilter" Collapsed="true">
|
||||
<Position X="43" Y="6.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAIAAAEAAAgIAAAAAAAAACAAAAAAAAAAAAAI=</HashCode>
|
||||
<FileName>ChannelFilter.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Enum>
|
||||
<Enum Name="DTS.Common.Utilities.DataFlag" Collapsed="true">
|
||||
<Position X="44.75" Y="6.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BBAAAAAAAAAgAEAAAAAAAAAAAAAIAAAAAAAAAAEAAAA=</HashCode>
|
||||
<FileName>DataFlag.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Enum>
|
||||
<Enum Name="DTS.Common.Utilities.IO.MemoryMap.MapProtection" Collapsed="true">
|
||||
<Position X="48.25" Y="6.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAgAAACAAAABAAAACAAAAEAAAAAAAAAAAgAAAAAgAE=</HashCode>
|
||||
<FileName>MapViewStream.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Enum>
|
||||
<Enum Name="DTS.Common.Utilities.IO.MemoryMap.MapAccess" Collapsed="true">
|
||||
<Position X="46.5" Y="6.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAgAAAAAAQAAgQAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>MemoryMappedFile.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Enum>
|
||||
<Font Name="Segoe UI" Size="9" />
|
||||
</ClassDiagram>
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Utilities
|
||||
{
|
||||
public class StandardDev
|
||||
{
|
||||
public static double StandardDeviation(IEnumerable<double> values)
|
||||
{
|
||||
double standardDeviation = 0;
|
||||
|
||||
if (!values.Any()) return standardDeviation;
|
||||
// Compute the average.
|
||||
double avg = values.Average();
|
||||
|
||||
// Perform the Sum of (value-avg)_2_2.
|
||||
double sum = values.Sum(d => System.Math.Pow(d - avg, 2));
|
||||
|
||||
// Put it all together.
|
||||
standardDeviation = System.Math.Sqrt((sum) / (values.Count() - 1));
|
||||
|
||||
return standardDeviation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
//disables xml comments missing warning - this file is just a wrapper for win32
|
||||
//imports, documentation can be found in win32 api or headers.
|
||||
#pragma warning disable 1591
|
||||
|
||||
/// <summary>
|
||||
/// win32 I/O declarations
|
||||
/// </summary>
|
||||
public class FileIOApiDeclarations
|
||||
{
|
||||
|
||||
// API declarations relating to file I/O.
|
||||
|
||||
// ******************************************************************************
|
||||
// API constants
|
||||
// ******************************************************************************
|
||||
|
||||
public const uint GENERIC_READ = 0x80000000;
|
||||
public const uint GENERIC_WRITE = 0x40000000;
|
||||
public const uint FILE_SHARE_READ = 0x00000001;
|
||||
public const uint FILE_SHARE_WRITE = 0x00000002;
|
||||
public const uint FILE_FLAG_OVERLAPPED = 0x40000000;
|
||||
public const int INVALID_HANDLE_VALUE = -1;
|
||||
public const short OPEN_EXISTING = 3;
|
||||
public const int WAIT_TIMEOUT = 0x102;
|
||||
public const uint WAIT_OBJECT_0 = 0;
|
||||
public const uint WAIT_FAILED = 0xFFFFFFFF;
|
||||
public const uint WAIT_ABANDONED = 0x00000080;
|
||||
public const int FSCTL_SET_COMPRESSION = 0x9C040;
|
||||
|
||||
// ******************************************************************************
|
||||
// Structures and classes for API calls, listed alphabetically
|
||||
// ******************************************************************************
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct OVERLAPPED
|
||||
{
|
||||
public int Internal;
|
||||
public int InternalHigh;
|
||||
public int Offset;
|
||||
public int OffsetHigh;
|
||||
public int hEvent;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SECURITY_ATTRIBUTES
|
||||
{
|
||||
public int nLength;
|
||||
public int lpSecurityDescriptor;
|
||||
public int bInheritHandle;
|
||||
}
|
||||
|
||||
// ******************************************************************************
|
||||
// API functions, listed alphabetically
|
||||
// ******************************************************************************
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern int CancelIo(int hFile);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern int CloseHandle(int hObject);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern int CreateEvent(ref SECURITY_ATTRIBUTES SecurityAttributes, int bManualReset, int bInitialState, string lpName);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern int CreateFile(string lpFileName,
|
||||
uint dwDesiredAccess,
|
||||
uint dwShareMode,
|
||||
ref SECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
int dwCreationDisposition,
|
||||
uint dwFlagsAndAttributes,
|
||||
int hTemplateFile);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern int GetLastError();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
// static public extern int ReadFile(int hFile, ref byte lpBuffer, int nNumberOfBytesToRead, ref int lpNumberOfBytesRead, ref OVERLAPPED lpOverlapped);
|
||||
public static extern int ReadFile(int hFile, ref byte lpBuffer, int nNumberOfBytesToRead, ref int lpNumberOfBytesRead, int lpOverlapped);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern uint WaitForSingleObject(int hHandle, int dwMilliseconds);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern int WriteFile(int hFile, ref byte lpBuffer, int nNumberOfBytesToWrite, ref int lpNumberOfBytesWritten, int lpOverlapped);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
|
||||
public static extern int DeviceIoControl(IntPtr hDevice,
|
||||
int dwIoControlCode,
|
||||
ref short lpInBuffer,
|
||||
int nInBufferSize,
|
||||
IntPtr lpOutBuffer,
|
||||
int nOutBufferSize,
|
||||
ref int lpBytesReturned,
|
||||
IntPtr lpOverlapped);
|
||||
|
||||
/*public static extern bool DeviceIoControl(int hDevice,
|
||||
int dwIoControlCode,
|
||||
ref int lpInBuffer,
|
||||
uint nInBufferSize,
|
||||
ref int lpOutBuffer,
|
||||
uint nOutBufferSize,
|
||||
out int lpBytesReturned,
|
||||
uint lpOverlapped);*/
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
Math.Iso.Differentiation.cs
|
||||
|
||||
24 November 2009 - Adapted from old Dave codebase to generic DTS utility, with
|
||||
appropriate name change.
|
||||
|
||||
$Log: Math.Iso.ChannelDifferentiation.cs,v $
|
||||
Revision 1.3 2007/04/20 17:40:42 Paul Hrissikopoulos
|
||||
Fixed bad range checking in sample rate property set accessor.
|
||||
|
||||
Revision 1.2 2007/02/05 17:17:08 Paul Hrissikopoulos
|
||||
Finished installing generic channel math framework + basic calculus operations.
|
||||
|
||||
Revision 1.1 2007/02/02 22:34:09 Paul Hrissikopoulos
|
||||
Added framework for DAVE channel math operators.
|
||||
|
||||
Copyright © 2007
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities.Math.Iso
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Representation of the ISO-based differentiation
|
||||
/// System.Collections.Generic.IList of <see cref="double"/>
|
||||
/// -based operation.
|
||||
/// </summary>
|
||||
public class Differentiation : DoubleListOperation
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get/set the <see cref="double"/> time resolution of this differentiation.
|
||||
/// Should probably be the length of one "sample" of digital data seeing as
|
||||
/// we're trying to approximate a continuous domain.
|
||||
/// </summary>
|
||||
public double SampleRate
|
||||
{
|
||||
get => _SampleRate.Value;
|
||||
set => _SampleRate.Value = value;
|
||||
}
|
||||
private Property<double> _SampleRate
|
||||
= new Property<double>(
|
||||
typeof(Differentiation).FullName + ".SampleRate",
|
||||
0.0,
|
||||
false
|
||||
);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Differentiation class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="domain">
|
||||
/// The System.Collection.Generic.IList of <see cref="double"/>s
|
||||
/// domain for this operation.
|
||||
/// </param>
|
||||
///
|
||||
public Differentiation(IList<double> domain)
|
||||
: base(domain)
|
||||
{
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Iso.ChannelDifferentiation class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="domain">
|
||||
/// The System.Collections.Generic.IList of <see cref="double"/>s
|
||||
/// domain for this operation.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="sampleRate">
|
||||
/// The <see cref="double"/> sample rate of the data to be differentiated.
|
||||
/// </param>
|
||||
///
|
||||
public Differentiation(IList<double> domain, double sampleRate)
|
||||
: this(domain)
|
||||
{
|
||||
try { SampleRate = sampleRate; }
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get the result of the operation on the
|
||||
/// System.Collections.Generic.IList of <see cref="double"/>s
|
||||
/// domain representation.
|
||||
/// </summary>
|
||||
public override IList<double> Range
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null == Domain)
|
||||
throw new ArgumentNullException("attempted to differentiate null domain reference");
|
||||
|
||||
else if (0 >= SampleRate)
|
||||
throw new ArgumentOutOfRangeException("attempted to differentiate with sample rate <= zero");
|
||||
|
||||
else if (!(Domain is ICloneable))
|
||||
throw new InvalidCastException("the domain type for " + typeof(Differentiation).FullName + " must be ICloneable");
|
||||
|
||||
else
|
||||
{
|
||||
var IndexOfLastDomainValue = Domain.Count - 1;
|
||||
var range = ((ICloneable)Domain).Clone() as double[];
|
||||
var deltaT = SampleRate / 12.0;
|
||||
|
||||
for (var t = 2; t <= IndexOfLastDomainValue - 2; t++)
|
||||
range[t] = ((Domain[t + 1] - Domain[t - 1]) * 8
|
||||
- Domain[t + 2] + Domain[t - 2]) * deltaT;
|
||||
Domain[IndexOfLastDomainValue - 1] = 0;
|
||||
Domain[IndexOfLastDomainValue] = 0;
|
||||
Domain[0] = 0;
|
||||
Domain[1] = 0;
|
||||
|
||||
return range;
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem doing " + GetType().FullName + " operation", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumeration of all possible Data Flags
|
||||
///
|
||||
/// </summary>
|
||||
public enum DataFlag
|
||||
{
|
||||
[Description("None")]
|
||||
[Flag(0)]
|
||||
None,
|
||||
|
||||
[Description("Normal")]
|
||||
[Flag(1)]
|
||||
Normal,
|
||||
|
||||
[Description("Saturated")]
|
||||
[Flag(2)]
|
||||
Saturated,
|
||||
|
||||
[Description("Zero Crossing Error")]
|
||||
[Flag(3)]
|
||||
ZeroCrossing,
|
||||
|
||||
[Description("Broken Wire")]
|
||||
[Flag(4)]
|
||||
BrokenWire,
|
||||
|
||||
[Description("Other")]
|
||||
[Flag(-1)]
|
||||
Other
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class FlagAttribute : Attribute
|
||||
{
|
||||
public int Flag { get; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public FlagAttribute(int flag)
|
||||
{
|
||||
Flag = flag;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Tool for manipulating <see cref="T:DTS.Common.Utilities.ChannelFilter" />-attached <see cref="T:DTS.Common.Utilities.IsoDescriptionAttribute" />s.
|
||||
/// </summary>
|
||||
public class DataFlagAttributeCoder
|
||||
: AttributeCoder<DataFlag, FlagAttribute, int>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes an instance of the IsoDescriptionAttributeCoder class.
|
||||
/// </summary>
|
||||
public DataFlagAttributeCoder()
|
||||
: base(attribute => attribute.Flag, null)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* LargeArray.MissingScratchFileException.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
// *** see LargeArray.cs ***
|
||||
public partial class LargeArray<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Representation of erroneous missing <see cref="T:LargeArray"/>
|
||||
/// scratch file condition.
|
||||
/// </summary>
|
||||
private class MissingScratchFileException : ApplicationException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="T:LargeArray.MissingScratchFileException"/> class.
|
||||
/// </summary>
|
||||
public MissingScratchFileException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="T:LargeArray.MissingScratchFileException"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public MissingScratchFileException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="T:LargeArray.MissingScratchFileException"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The inner <see cref="System.Exception"/> behind this enclosing
|
||||
/// exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public MissingScratchFileException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* LargeArray.ScratchFileAlreadyExistsException.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
// *** see LargeArray.cs ***
|
||||
public partial class LargeArray<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Representation of erroneous pre-existing <see cref="T:LargeArray"/>
|
||||
/// scratch file condition.
|
||||
/// </summary>
|
||||
private class ScratchFileAlreadyExistsException : ApplicationException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="T:LargeArray.ScratchFileAlreadyExistsException"/> class.
|
||||
/// </summary>
|
||||
public ScratchFileAlreadyExistsException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="T:LargeArray.ScratchFileAlreadyExistsException"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public ScratchFileAlreadyExistsException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="T:LargeArray.ScratchFileAlreadyExistsException"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The inner <see cref="System.Exception"/> behind this enclosing
|
||||
/// exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public ScratchFileAlreadyExistsException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
public class NHTSASubSample<T> : Exceptional
|
||||
{
|
||||
public UInt64 preTriggerSamples;
|
||||
public T[] data;
|
||||
public UInt16 subSampleInterval;
|
||||
public double sampleRate;
|
||||
public int iNpre;
|
||||
|
||||
public void SubSample()
|
||||
{
|
||||
/*----------------------------------------------------------------------------
|
||||
|
||||
* This is translated from Tim's C code translation. Variable names are retained for tracability.
|
||||
*
|
||||
This function is translated from the original NHTSA FORTRAN code by
|
||||
Tim Kippen of Diversified Technical Systems, Inc.
|
||||
|
||||
The original comments appear below:
|
||||
|
||||
SUBROUTINE SUBSMP (AOLD, DTOLD,DTNEW, NFP,NLP)
|
||||
C**************************************************************************
|
||||
C.
|
||||
C. This routine takes a signal contained in array AOLD,
|
||||
C. which was sampled with a time step of DTOLD seconds, and
|
||||
C. converts it to a signal sampled at DTNEW seconds. The revised
|
||||
C. signal is returned in AOLD. The routine uses an interpolation
|
||||
C. algorithm which will set the sampling rate to exactly that
|
||||
C. specified by DTNEW, regardless of whether or not DTNEW
|
||||
C. is an integer multiple of DTOLD.
|
||||
C.
|
||||
C. This routine does not worry about aliasing, so the input
|
||||
C. signal should have been appropiately filtered prior to
|
||||
C. invoking SUBSMP.
|
||||
C.
|
||||
C. Implemented on the NHTSA's Office of Crashworthiness
|
||||
C. VAX 11/780. The DO WHILE are not standard FORTRAN 77
|
||||
C. an may have to be simulated with IF statements and GO TO's
|
||||
C. on other machines
|
||||
C.
|
||||
C. Start by setting the values at time 0 equal to each other
|
||||
C. Then create the data with the new sampling rate before time 0
|
||||
C. Will not create more than 50 data points before time 0.
|
||||
C.
|
||||
C Revision Record
|
||||
C ---------------
|
||||
C. Original - Jeff Marcus (NHTSA)
|
||||
C. July, 1987 Jeff Marcus (NHTSA)
|
||||
C. Revised to guarantee no shift of time 0
|
||||
C Sept. 1987 - Clay Gabler
|
||||
C Revised to handle case of NFP=0
|
||||
C.
|
||||
C**************************************************************************
|
||||
*/
|
||||
var pdOld = data;
|
||||
var dDeltaOld = 1.0 / sampleRate;
|
||||
var dtNew = 1.0 / sampleRate * subSampleInterval;
|
||||
iNpre = (int)preTriggerSamples;
|
||||
var iNpts = data.Length;
|
||||
|
||||
|
||||
double dTimeOld, dTimeNew, dTimeNext;
|
||||
int iNew, iOld;
|
||||
|
||||
// start at t=0 (index is iPre)
|
||||
var iTZero = iNpre;
|
||||
var iNewPts = iNpts;
|
||||
|
||||
// allocate array for new data points
|
||||
var pdNew = new T[1 + iNpts];
|
||||
|
||||
var dtOld = dDeltaOld;
|
||||
|
||||
// Anchor Signal at Time Zero
|
||||
pdNew[iTZero] = pdOld[iTZero];
|
||||
|
||||
// Subsample Portion of Signal Prior to Time Zero
|
||||
if (iNpre > 0)
|
||||
{
|
||||
|
||||
// start with first pre-trigger point index and calculate the time
|
||||
iNew = iTZero - 1;
|
||||
dTimeNew = (iNew - iTZero) * dtNew;
|
||||
|
||||
// for every old point
|
||||
for (iOld = iTZero; iOld > 0; iOld--)
|
||||
{
|
||||
// calculate the time for the old point and the next old point
|
||||
dTimeOld = (iOld - iTZero) * dtOld;
|
||||
|
||||
if (iNew <= 0)
|
||||
break;
|
||||
|
||||
dTimeNext = (iOld - iTZero - 1) * dtOld;
|
||||
|
||||
if (dTimeNew <= dTimeNext || iNew <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Templates can't be used with math operators. .NET 4.0 dynamic is a work around.
|
||||
dynamic dOld = pdOld[iOld];
|
||||
dynamic dOldMinusOne = pdOld[iOld - 1];
|
||||
|
||||
// calculate the new value
|
||||
pdNew[iNew] = (T)(pdOld[iOld] - // current old value
|
||||
((dTimeNew - dTimeOld) / dtOld * // delta Time
|
||||
(dOldMinusOne - dOld))); // delta value for old data
|
||||
|
||||
// setup next new point and calculate the new deltaT
|
||||
iNew--;
|
||||
dTimeNew = (iNew - iTZero) * dtNew;
|
||||
}
|
||||
|
||||
// calculate the new first point
|
||||
iNpre = iTZero - (iNew + 1);
|
||||
}
|
||||
|
||||
if (iNpts > iNpre)
|
||||
{
|
||||
// start with first pre-trigger point index and calculate the time
|
||||
iNew = iTZero + 1;
|
||||
dTimeNew = (iNew - iTZero) * dtNew;
|
||||
|
||||
// for every old point
|
||||
for (iOld = iTZero; iOld < iNpts; iOld++)
|
||||
{
|
||||
// calculate the time for the old point and the next old point
|
||||
dTimeOld = (iOld - iTZero) * dtOld;
|
||||
|
||||
if (iNew >= iNpts)
|
||||
break;
|
||||
|
||||
dTimeNext = (iOld - iTZero + 1) * dtOld;
|
||||
|
||||
if (dTimeNew >= dTimeNext || iNew >= iNpts)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Templates can't be used with math operators. .NET 4.0 dynamic is a work around.
|
||||
dynamic dOld = pdOld[iOld];
|
||||
dynamic dOldMinusOne = pdOld[iOld - 1];
|
||||
|
||||
// calculate the new value
|
||||
pdNew[iNew] = (T)(pdOld[iOld] - // current old value
|
||||
((dTimeNew - dTimeOld) / dtOld * // delta Time
|
||||
(dOldMinusOne - dOld))); // delta value for old data
|
||||
|
||||
// setup next new point and calculate the new deltaT
|
||||
iNew++;
|
||||
dTimeNew = (iNew - iTZero) * dtNew;
|
||||
}
|
||||
|
||||
// calculate the new number of points
|
||||
iNewPts = iNpre + (iNew - iTZero - 1);
|
||||
}
|
||||
|
||||
// zero old array
|
||||
//memset( pdOld , 0, *iNpts*sizeof(double));
|
||||
|
||||
// copy values for return to calling function
|
||||
iNpts = iNewPts;
|
||||
//*dDeltaOld = dtNew;
|
||||
|
||||
data = new T[iNpts];
|
||||
for (var i = 0; i < iNpts; i++)
|
||||
{
|
||||
data[i] = pdNew[System.Math.Max(0, iTZero - (iNpre + 1) + i)];
|
||||
}
|
||||
|
||||
sampleRate = 1.0 / dtNew;
|
||||
//free (pdNew);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This class wraps the list items in the combo box
|
||||
/// </summary>
|
||||
public class CheckComboBoxItem
|
||||
{
|
||||
/// <summary>
|
||||
/// C'tor - creates a CheckComboBoxItem
|
||||
/// </summary>
|
||||
/// <param name="text">Label of the check box in the drop down list</param>
|
||||
/// <param name="initialCheckState">Initial value for the check box (true=checked)</param>
|
||||
public CheckComboBoxItem(string text, bool initialCheckState)
|
||||
{
|
||||
CheckState = initialCheckState;
|
||||
Text = text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get or set the check value (true=checked)
|
||||
/// </summary>
|
||||
public bool CheckState { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the label of the check box
|
||||
/// </summary>
|
||||
public string Text { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// User defined data
|
||||
/// </summary>
|
||||
public object Tag { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// This is used to keep the edit control portion of the combo box consistent
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "Select Options";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inherits from ComboBox and handles DrawItem and SelectedIndexChanged events to create an
|
||||
/// owner drawn combo box drop-down. The contents of the dropdown are rendered using the
|
||||
/// CheckBoxRenderer class.
|
||||
/// </summary>
|
||||
public partial class CheckComboBox : ComboBox
|
||||
{
|
||||
/// <summary>
|
||||
/// C'tor
|
||||
/// </summary>
|
||||
public CheckComboBox()
|
||||
{
|
||||
DrawMode = DrawMode.OwnerDrawFixed;
|
||||
DrawItem += CheckComboBox_DrawItem;
|
||||
SelectedIndexChanged += CheckComboBox_SelectedIndexChanged;
|
||||
SelectedText = "Select Options";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the selected index is changed on the dropdown. This sets the check state
|
||||
/// of the CheckComboBoxItem and fires the public event CheckStateChanged using the
|
||||
/// CheckComboBoxItem as the event sender.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void CheckComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var item = (CheckComboBoxItem)SelectedItem;
|
||||
if (item == null)
|
||||
return;
|
||||
item.CheckState = !item.CheckState;
|
||||
if (CheckStateChanged != null)
|
||||
CheckStateChanged(item, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the ComboBox has to render the drop-down items.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void CheckComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
// make sure the index is valid (sanity check)
|
||||
if (e.Index == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// test the item to see if its a CheckComboBoxItem
|
||||
if (!(Items[e.Index] is CheckComboBoxItem))
|
||||
{
|
||||
// it's not, so just render it as a default string
|
||||
e.Graphics.DrawString(
|
||||
Items[e.Index].ToString(),
|
||||
Font,
|
||||
Brushes.Black,
|
||||
new Point(e.Bounds.X, e.Bounds.Y));
|
||||
return;
|
||||
}
|
||||
|
||||
// get the CheckComboBoxItem from the collection
|
||||
var box = (CheckComboBoxItem)Items[e.Index];
|
||||
|
||||
// render it
|
||||
CheckBoxRenderer.RenderMatchingApplicationState = true;
|
||||
CheckBoxRenderer.DrawCheckBox(
|
||||
e.Graphics,
|
||||
new Point(e.Bounds.X, e.Bounds.Y),
|
||||
e.Bounds,
|
||||
box.Text,
|
||||
Font,
|
||||
(e.State & DrawItemState.Focus) == 0,
|
||||
box.CheckState ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the user clicks a check box item in the drop-down list
|
||||
/// </summary>
|
||||
public event EventHandler CheckStateChanged;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D6DA1B74-C711-43C2-91B1-1908A8D04DBF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DTS.Utilities</RootNamespace>
|
||||
<AssemblyName>DTS.Utilities</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkProfile />
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DocumentationFile>bin\Debug\DTS.Utilities.XML</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>SharpZipLib\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ActiveUpdateList.cs" />
|
||||
<Compile Include="APILogging.cs" />
|
||||
<Compile Include="ArrayToString.cs" />
|
||||
<Compile Include="AttributeCoder.cs" />
|
||||
<Compile Include="AttributeExtractor.cs" />
|
||||
<Compile Include="AverageShortValueOverTime.cs" />
|
||||
<Compile Include="AverageValueOverTime.cs" />
|
||||
<Compile Include="CRC32.cs" />
|
||||
<Compile Include="DataConditioning.cs" />
|
||||
<Compile Include="DegreesFromADC.cs" />
|
||||
<Compile Include="DataFlag.cs" />
|
||||
<Compile Include="ChannelFilter.cs" />
|
||||
<Compile Include="CheckComboBox.cs" />
|
||||
<Compile Include="AverageQueue.cs" />
|
||||
<Compile Include="DTSChecksum.cs" />
|
||||
<Compile Include="ExportINIFile.cs" />
|
||||
<Compile Include="KeywordAlert.cs" />
|
||||
<Compile Include="LevelTriggerLogging.cs" />
|
||||
<Compile Include="NHTSASubSample.cs" />
|
||||
<Compile Include="PowerManagement.cs" />
|
||||
<Compile Include="PropertyComparer.cs" />
|
||||
<Compile Include="PTP1588Timestamps.cs" />
|
||||
<Compile Include="SignalToNoiseRatio.cs" />
|
||||
<Compile Include="SortableBindingList.cs" />
|
||||
<Compile Include="StandardDev.cs" />
|
||||
<Compile Include="TestRenamer.cs" />
|
||||
<Compile Include="Time.cs" />
|
||||
<Compile Include="DataWindowAverager.cs" />
|
||||
<Compile Include="DataWindowAverager.WindowDoesNotExistException.cs" />
|
||||
<Compile Include="DescriptionAttributeCoder.cs" />
|
||||
<Compile Include="DiskUtility.cs" />
|
||||
<Compile Include="DoubleLargeArray.cs" />
|
||||
<Compile Include="EnumDropDown.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Exceptional.cs" />
|
||||
<Compile Include="ExceptionalDictionary.cs" />
|
||||
<Compile Include="ExceptionalForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ExceptionalList.cs" />
|
||||
<Compile Include="ExceptionalUserControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FileIODeclarations.cs" />
|
||||
<Compile Include="FileMapIOException.cs" />
|
||||
<Compile Include="FileMapViewArray.cs" />
|
||||
<Compile Include="FilterUtility.cs" />
|
||||
<Compile Include="FirmwareVersionToLong.cs" />
|
||||
<Compile Include="HexEncoding.cs" />
|
||||
<Compile Include="Math.DoubleListOperation.cs" />
|
||||
<Compile Include="Math.Iso.Differentiation.cs" />
|
||||
<Compile Include="Math.Nhtsa.Differentiation.cs" />
|
||||
<Compile Include="Math.Nhtsa.Integration.cs" />
|
||||
<Compile Include="Math.Operation.cs" />
|
||||
<Compile Include="NaturalStringCompare.cs" />
|
||||
<Compile Include="PersistWindowState.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="LargeArray.cs" />
|
||||
<Compile Include="LargeArray.Enumerator.cs" />
|
||||
<Compile Include="LargeArray.LargeOverflowException.cs" />
|
||||
<Compile Include="LargeArray.MissingScratchFileException.cs" />
|
||||
<Compile Include="LargeArray.NameGeneratorLock.cs" />
|
||||
<Compile Include="LargeArray.ScratchFileAlreadyExistsException.cs" />
|
||||
<Compile Include="MapViewStream.cs" />
|
||||
<Compile Include="MemoryMappedFile.cs" />
|
||||
<Compile Include="PowerOfTwoIntProperty.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Property.ConstructionException.cs" />
|
||||
<Compile Include="Property.cs" />
|
||||
<Compile Include="Property.InvalidValueException.cs" />
|
||||
<Compile Include="Property.NotInitializedException.cs" />
|
||||
<Compile Include="RangeRestrictedDoubleProperty.cs" />
|
||||
<Compile Include="RangeRestrictedDoubleProperty.InvalidRangeException.cs" />
|
||||
<Compile Include="RangeRestrictedIntProperty.cs" />
|
||||
<Compile Include="RangeRestrictedIntProperty.InvalidRangeException.cs" />
|
||||
<Compile Include="ScrollingMessageBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ScrollingMessageBox.Designer.cs">
|
||||
<DependentUpon>ScrollingMessageBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ShortLargeArray.cs" />
|
||||
<Compile Include="TextLogger.cs" />
|
||||
<Compile Include="TextLogger.LogPathnameNotInitializedException.cs" />
|
||||
<Compile Include="TextLogger.WriteCycleHandle.cs" />
|
||||
<Compile Include="UpdateNotifyingList.cs" />
|
||||
<Compile Include="WaitWithCondition.cs" />
|
||||
<Compile Include="Win32APIs.cs" />
|
||||
<Compile Include="Xml.PropertyAttributeDecoder.cs" />
|
||||
<Compile Include="XmlSerializationTagAttribute.cs" />
|
||||
<Compile Include="XmlToObject.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
<CustomToolNamespace>DTS.Common.Utilities.Properties</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ScrollingMessageBox.resx">
|
||||
<DependentUpon>ScrollingMessageBox.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Design\DTS.Common.UtilitiesClassDiagram.cd" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>rem del $(TargetFileName)
|
||||
rem "C:\Program Files\Microsoft\ILMerge\ILMerge" /wildcards /log:ILMerge.log /t:library /out:$(TargetFileName) *.dll
|
||||
</PostBuildEvent>
|
||||
<PreBuildEvent>rem %25comspec%25 /k "C:\Program Files\Microsoft Visual Studio .NET\Common7\Tools\vsvars32.bat"</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Public utilty class for manipulating Unix timestamps
|
||||
/// Primarily exposed for the SDK
|
||||
/// </summary>
|
||||
public class PTP1588Timestamps
|
||||
{
|
||||
private const int MIN_VALID_TIMESTAMP_YEAR = 1990;
|
||||
/// <summary>
|
||||
/// tests time in seconds since 1,1,1970 to (unix time) to see whether the time should be valid or not
|
||||
/// this is used by TestMetaDataList to control whether to show unix time or not for a dataset in a viewer
|
||||
/// now it's also used by the CSV export to eliminate timestamps that occur before 1990
|
||||
/// this was done because of a dataset in http://manuscript.dts.local/f/cases/33199/
|
||||
/// which contained an invalid timestamp
|
||||
/// </summary>
|
||||
/// <param name="unixTimeStampSeconds">time in seconds since 1970-1-1</param>
|
||||
/// <returns>true if the value is valid or not</returns>
|
||||
public static bool IsValidTimeStamp(double unixTimeStampSeconds)
|
||||
{
|
||||
return UnixTimeStampToDateTimeLocal(unixTimeStampSeconds).Year > MIN_VALID_TIMESTAMP_YEAR;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns DateTime object from Unix timestamp in seconds
|
||||
/// </summary>
|
||||
/// <param name="unixTimeStampSec"></param>
|
||||
/// <returns></returns>
|
||||
public static DateTime UnixTimeStampToDateTimeLocal(double unixTimeStampSec)
|
||||
{
|
||||
return UnixTimeStampToDateTimeLocal((decimal)unixTimeStampSec);
|
||||
}
|
||||
public static DateTime UnixTimeStampToDateTimeLocal(decimal unixTimeStampSec)
|
||||
{
|
||||
return UnitTimeStampToDateTimeLocal(unixTimeStampSec, (decimal)0);
|
||||
}
|
||||
public static DateTime UnitTimeStampToDateTimeLocal(double unixTimeStampSec, double ns)
|
||||
{
|
||||
var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
dtDateTime = dtDateTime.AddSeconds(unixTimeStampSec).AddTicks(Convert.ToInt64(ns / 100));
|
||||
return dtDateTime.ToLocalTime();
|
||||
}
|
||||
public static DateTime UnitTimeStampToDateTimeLocal(decimal unixTimeStampSec, decimal ns)
|
||||
{
|
||||
var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
dtDateTime = dtDateTime.AddSeconds(Convert.ToDouble(unixTimeStampSec)).AddTicks(Convert.ToInt64(ns / 100));
|
||||
return dtDateTime.ToLocalTime();
|
||||
}
|
||||
/// <summary>
|
||||
/// String representation in Unix timestamp is seconds past epoch
|
||||
/// </summary>
|
||||
public static string ToDateTimeString(double unixTimeStampSec, double ns) =>
|
||||
ToDateTimeString((decimal)unixTimeStampSec, (decimal)ns);
|
||||
|
||||
public static string ToDateTimeString(decimal unixTimeStampSec, decimal ns) =>
|
||||
$"{UnixTimeStampToDateTimeLocal(unixTimeStampSec).ToUniversalTime():yyyy/MM/dd HH:mm:ss}:{ns,9:000000000}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
RangeRestrictedDoubleProperty.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
|
||||
namespace DTS.Common.Utilities.DotNetProgrammingConstructs
|
||||
{
|
||||
/// <summary>
|
||||
/// A class to implement self-checking, on-error-auto-syntax-building
|
||||
/// range-restricted int properties.
|
||||
/// </summary>
|
||||
public partial class RangeRestrictedDoubleProperty : Property<double>
|
||||
{
|
||||
/// <summary>
|
||||
/// Determine whether or not the specified value is valid for this property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value">
|
||||
/// The <see cref="double"/> value to be validity checked.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// <see cref="bool"/> true if the value is valid; false otherwise.
|
||||
/// </returns>
|
||||
///
|
||||
public override bool IsValidValue(double value)
|
||||
{
|
||||
try
|
||||
{
|
||||
return value >= MinimumValue && value <= MaximumValue;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format(Properties.Resources.RangeRestrictedDoubleProperty_IsValidValue_UnableToDetermineValidityString, value.ToString()),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a user-readable explanation as to why the specified value is
|
||||
/// not valid for this property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value">
|
||||
/// The <see cref="int"/> value to be described.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// A <see cref="string"/> description explaining why the specified value
|
||||
/// is not valid for this property.
|
||||
/// </returns>
|
||||
///
|
||||
public string GetInvalidValueDescription(int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (value < MinimumValue)
|
||||
return string.Format(Properties.Resources.RangeRestrictedDoubleProperty_GetInvalidValueDescription_MinimumDescriptionString, value.ToString(), MinimumValue.ToString());
|
||||
else if (value > MaximumValue)
|
||||
return string.Format(Properties.Resources.RangeRestrictedDoubleProperty_GetInvalidValueDescription_MaximumDescriptionString, value.ToString(), MaximumValue.ToString());
|
||||
else
|
||||
return string.Format(Properties.Resources.RangeRestrictedDoubleProperty_GetInvalidValueDescription_ValidValueDescriptionString, value.ToString());
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format(Properties.Resources.RangeRestrictedDoubleProperty_GetInvalidValueDescription_GetDescriptionFailedString, value.ToString()),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The minimum <see cref="double"/> value permitted in this property.
|
||||
/// </summary>
|
||||
public double MinimumValue
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return _MinimumValue.Value;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Properties.Resources.RangeRestrictedDoubleProperty_MinimumValue_GetValueFailedString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
try { _MinimumValue.Value = value; }
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Properties.Resources.RangeRestrictedDoubleProperty_MinimumValue_SetValueFailedString, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private readonly Property<double> _MinimumValue = new Property<double>(0, false);
|
||||
|
||||
/// <summary>
|
||||
/// The maximum <see cref="double"/> value permitted in this property.
|
||||
/// </summary>
|
||||
public double MaximumValue
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return _MaximumValue.Value;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Properties.Resources.RangeRestrictedDoubleProperty_MaximumValue_GetValueFailedString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
try { _MaximumValue.Value = value; }
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Properties.Resources.RangeRestrictedDoubleProperty_MaximumValue_SetValueFailedString, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private readonly Property<double> _MaximumValue = new Property<double>(0, false);
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of a range-restricted integer property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="minimumValue">
|
||||
/// The minimum <see cref="int"/> value permitted in this property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="maximumValue">
|
||||
/// The maximum <see cref="int"/> value permitted in this property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="initialValue">
|
||||
/// The initial <see cref="int"/> value of this property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="isInitialized">
|
||||
/// <see cref="bool"/> true if this property is to be considered
|
||||
/// initialized after construction, false otherwise.
|
||||
/// </param>
|
||||
///
|
||||
public RangeRestrictedDoubleProperty(double minimumValue,
|
||||
double maximumValue,
|
||||
double initialValue,
|
||||
bool isInitialized)
|
||||
: base(initialValue, isInitialized)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (minimumValue > maximumValue)
|
||||
throw new InvalidRangeException(
|
||||
string.Format(
|
||||
Properties.Resources.RangeRestrictedDoubleProperty_MinMustBeLessThanMaxString, minimumValue.ToString(), maximumValue.ToString()));
|
||||
else
|
||||
{
|
||||
MinimumValue = minimumValue;
|
||||
MaximumValue = maximumValue;
|
||||
if (!IsValidValue(initialValue))
|
||||
throw new InvalidValueException(GetInvalidValueDescription(initialValue));
|
||||
else return;
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new ConstructionException(
|
||||
string.Format(Properties.Resources.Generic_EncounteredProblemConstructingClassString, GetType().FullName),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of a range-restricted integer property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="minimumValue">
|
||||
/// The minimum <see cref="double"/> value permitted in this property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="maximumValue">
|
||||
/// The maximum <see cref="double"/> value permitted in this property.
|
||||
/// </param>
|
||||
///
|
||||
public RangeRestrictedDoubleProperty(double minimumValue, double maximumValue)
|
||||
: base(0, false)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (minimumValue > maximumValue)
|
||||
throw new InvalidRangeException(
|
||||
string.Format(
|
||||
Properties.Resources.RangeRestrictedDoubleProperty_MinMustBeLessThanMaxString, minimumValue.ToString(), maximumValue.ToString()));
|
||||
else
|
||||
{
|
||||
MinimumValue = minimumValue;
|
||||
MaximumValue = maximumValue;
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new ConstructionException(
|
||||
string.Format(
|
||||
Properties.Resources.Generic_EncounteredProblemConstructingClassString, GetType().FullName),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
RangeRestrictedDoubleProperty.InvalidRangeException.cs
|
||||
|
||||
$Log: RangeRestrictedDoubleProperty.InvalidRangeException.cs,v $
|
||||
Revision 1.1 2007/12/13 23:57:33 Paul Hrissikopoulos
|
||||
Added ISO raw format.
|
||||
|
||||
Copyright © 2007
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities.DotNetProgrammingConstructs
|
||||
{
|
||||
// See "RangeRestrictedDoubleProperty.cs"
|
||||
public partial class RangeRestrictedDoubleProperty
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representation for range-restricted integer property
|
||||
/// range exceptions.
|
||||
/// </summary>
|
||||
public class InvalidRangeException
|
||||
: System.Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// RangeRestrictedDoubleProperty.InvalidRangeException class.
|
||||
/// </summary>
|
||||
public InvalidRangeException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// RangeRestrictedDoubleProperty.InvalidRangeException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public InvalidRangeException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// RangeRestrictedDoubleProperty.InvalidRangeException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The inner <see cref="System.Exception"/> behind this enclosing
|
||||
/// exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public InvalidRangeException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* ExceptionalDictionary.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of keys and values, with its own exception type.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="TKey">
|
||||
/// The type of the keys in the dictionary.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <typeparam name="TValue">
|
||||
/// The type of the values in the dictionary.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Sample usage:
|
||||
/// public class A : ExceptionalDictionary <int, int>
|
||||
/// {
|
||||
/// public void ScrewItUp( )
|
||||
/// {
|
||||
/// private bool error = true;
|
||||
/// if ( error ) throw new A.Exception( "Class A-specific screwup." );
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// ...
|
||||
///
|
||||
/// try
|
||||
/// {
|
||||
/// A.ScrewItUp( );
|
||||
/// B.ScrewItUp( );
|
||||
/// C.ScrewItUp( );
|
||||
/// }
|
||||
/// catch ( A.Exception ex )
|
||||
/// {
|
||||
/// // Can pick A's exceptions out of a crowd, or not and just treat it
|
||||
/// // polymorphically as a System.Exception.
|
||||
/// }
|
||||
/// </remarks>
|
||||
///
|
||||
[global::System.Serializable]
|
||||
public class ExceptionalDictionary<TKey, TValue> : Dictionary<TKey, TValue>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ExceptionalDictionary
|
||||
/// class that is empty, has the default initial capacity, and uses the default quality
|
||||
/// comparer for the key type.
|
||||
/// </summary>
|
||||
public ExceptionalDictionary()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ExceptionalDictionary
|
||||
/// class that is empty, has the specified initial capacity, and uses the default quality
|
||||
/// comparer for the key type.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="capacity">
|
||||
/// The initial number of elements that the ExceptionalDictionary
|
||||
/// can contain.
|
||||
/// </param>
|
||||
///
|
||||
public ExceptionalDictionary(int capacity)
|
||||
: base(capacity)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ExceptionalDictionary
|
||||
/// class that is empty, has the default initial capacity, and uses the specified quality
|
||||
/// comparer for the key type.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="comparer">
|
||||
/// The T:System.Collections.Generic.IEqualityComparer implementation to use when comparaing
|
||||
/// keys, or null to use the default T:System.Collections.Generic.IEqualityComparer for the
|
||||
/// type of the key.
|
||||
/// </param>
|
||||
///
|
||||
public ExceptionalDictionary(IEqualityComparer<TKey> comparer)
|
||||
: base(comparer)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ExceptionalDictionary
|
||||
/// class initialized to the settings and contents of the specified
|
||||
/// System.Collections.Generic.IDictionary-sporting object.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="dictionary">
|
||||
/// The System.Collections.Generic.IDictionary whose elements are copied
|
||||
/// to the new ExceptionalDictionary.
|
||||
/// </param>
|
||||
///
|
||||
public ExceptionalDictionary(IDictionary<TKey, TValue> dictionary)
|
||||
: base(dictionary)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ExceptionalDictionary
|
||||
/// class that is empty, has the specified initial capacity, and uses the specified quality
|
||||
/// comparer for the key type.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="capacity">
|
||||
/// The initial number of elements that the ExceptionalDictionary
|
||||
/// can contain.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="comparer">
|
||||
/// The T:System.Collections.Generic.IEqualityComparer implementation to use when comparing
|
||||
/// keys, or null to use the default T:System.Collections.Generic.IEqualityComparer for the
|
||||
/// type of the key.
|
||||
/// </param>
|
||||
///
|
||||
public ExceptionalDictionary(int capacity, IEqualityComparer<TKey> comparer)
|
||||
: base(capacity, comparer)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ExceptionalDictionary
|
||||
/// class with the specified serialization information and context.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="info">
|
||||
/// A System.Runtime.Serialization.SerializationInfo object containing the information
|
||||
/// required to serialize the ExceptionalDictionary.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="context">
|
||||
/// A System.Runtime.Serialization.StreamingContext structure containing the source and
|
||||
/// destination of the serialized stream associated with the
|
||||
/// DTS.UtilitiesExceptionalDictionary.
|
||||
/// </param>
|
||||
///
|
||||
public ExceptionalDictionary(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ExceptionalDictionary
|
||||
/// class with the specified dictionary key/value pairs and the specified comparer implementation.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="dictionary">
|
||||
/// The System.Collections.Generic.IDictionary whose elements are copied to the new
|
||||
/// ExceptionalDictionary.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="comparer">
|
||||
/// The T:System.Collections.Generic.IEqualityComparer implementation to use when comparing keys, or null to use the default
|
||||
/// T:System.Collections.Generic.IEqualityComparer for the type of the key.
|
||||
/// </param>
|
||||
///
|
||||
public ExceptionalDictionary(IDictionary<TKey, TValue> dictionary, IEqualityComparer<TKey> comparer)
|
||||
: base(dictionary, comparer)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A representation of the DerivedClass.Exception class.
|
||||
/// </summary>
|
||||
public class Exception : ApplicationException
|
||||
{
|
||||
public Exception() { }
|
||||
public Exception(string msg) : base(msg) { }
|
||||
public Exception(string msg, System.Exception innerEx) : base(msg, innerEx) { }
|
||||
protected Exception(
|
||||
System.Runtime.Serialization.SerializationInfo info,
|
||||
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
PowerOfTwoIntProperty.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
|
||||
namespace DTS.Common.Utilities.DotNetProgrammingConstructs
|
||||
{
|
||||
/// <summary>
|
||||
/// A class to implement self-checking, on-error-auto-syntax-building
|
||||
/// power of 2 int properties.
|
||||
/// </summary>
|
||||
public class PowerOfTwoIntProperty : Property<int>
|
||||
{
|
||||
/// <summary>
|
||||
/// Determine whether or not the specified value is valid for this property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value">
|
||||
/// The <see cref="int"/> value to be validity checked.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// <see cref="bool"/> true if the value is valid; false otherwise.
|
||||
/// </returns>
|
||||
///
|
||||
public override bool IsValidValue(int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
return IsPowerOf2(value);
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format(Properties.Resources.PowerOfTwoProperty_IsValidValue_UnableToDetermineValidityString, value.ToString()),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine whether or not the specified value is a power of two.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value">
|
||||
/// The <see cref="int"/> value to be power of 2-checked.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// <see cref="bool"/> true if the value is a power of 2, false otherwise.
|
||||
/// </returns>
|
||||
///
|
||||
private bool IsPowerOf2(int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (var r = value; r > 0; r >>= 1)
|
||||
if (2 == r) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format(Properties.Resources.PowerOfTwoProperty_IsPowerOf2_UnableToDeterminePowerOf2nessString, value.ToString()),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a user-readable explanation as to why the specified value is
|
||||
/// not valid for this property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value">
|
||||
/// The <see cref="int"/> value to be described.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// A <see cref="string"/> description explaining why the specified value
|
||||
/// is not valid for this property.
|
||||
/// </returns>
|
||||
///
|
||||
public override string GetInvalidValueDescription(int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
return string.Format(Properties.Resources.PowerOfTwoProperty_GetInvalidValueDescription_ProposedValueIsNotPowerOf2String, value.ToString());
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Properties.Resources.PowerOfTwoProperty_GetInvalidValueDescription_UnableToGetDescriptionString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of a power of two int property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="initialValue">
|
||||
/// The initialize <see cref="int"/> value of the int property.
|
||||
/// </param>
|
||||
///
|
||||
public PowerOfTwoIntProperty(int initialValue)
|
||||
: base(initialValue, true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsValidValue(initialValue))
|
||||
throw new InvalidValueException(GetInvalidValueDescription(initialValue));
|
||||
else return;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new ConstructionException(
|
||||
string.Format(Properties.Resources.Generic_EncounteredProblemConstructingClassString, GetType().FullName)
|
||||
, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of a power of two int property.
|
||||
/// </summary>
|
||||
public PowerOfTwoIntProperty()
|
||||
: base(0, false)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* LargeArray.NameGeneratorLock.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
// *** see LargeArray.cs ***
|
||||
public partial class LargeArray<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// A class intended to serve as a locking object for all MegArrays, so they don't
|
||||
/// try to use the same seed number for generating their respective scratch files.
|
||||
/// </summary>
|
||||
protected class NameGeneratorLock
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a class for doing natural string compares like in explorer (using the explorer function)
|
||||
/// http://msdn.microsoft.com/en-us/library/bb759947%28VS.85%29.aspx
|
||||
/// </summary>
|
||||
/// <remarks>requires XP or greater</remarks>
|
||||
public class NaturalStringComparer : IComparer<string>
|
||||
{
|
||||
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
|
||||
static extern int StrCmpLogicalW(String x, String y);
|
||||
|
||||
/// <summary>
|
||||
/// do a natural string compare between two strings
|
||||
/// </summary>
|
||||
/// <param name="x">left string to compare</param>
|
||||
/// <param name="y">right string to compare</param>
|
||||
/// <returns>-1 if natural order of x is less than y, +1 if x is after y, 0 if they are equal</returns>
|
||||
public int Compare(string x, string y)
|
||||
{
|
||||
if (null == x) { return -1; }
|
||||
if (null == y) { return 1; }
|
||||
return StrCmpLogicalW(x, y);
|
||||
}
|
||||
|
||||
public static int StaticCompare(string x, string y)
|
||||
{
|
||||
if (null == x) { return -1; }
|
||||
if (null == y) { return 1; }
|
||||
return StrCmpLogicalW(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
XmlSerializationTagAttribute.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities.Xml
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute for specifying the XML serialization tag for the attached
|
||||
/// object member entity.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
|
||||
public class XmlSerializationTagAttribute : Attribute, IComparable<XmlSerializationTagAttribute>
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the <see cref="string"/> value of this tag attribute.
|
||||
/// </summary>
|
||||
public string Value { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="int"/> order of the tag attribute. This will be used in sorting
|
||||
/// the like-tag attributes attached to the same object.
|
||||
/// </summary>
|
||||
public int Order { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the XmlSerializationTagAttribute class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value">
|
||||
/// The <see cref="string"/> value of this attribute.
|
||||
/// </param>
|
||||
///
|
||||
public XmlSerializationTagAttribute(string value) : this(value, 0)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the XmlSerializationTagAttribute class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value">
|
||||
/// The <see cref="string"/> value of this attribute.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="order">
|
||||
/// The <see cref="int"/> order of this attribute. This will be used in sorting
|
||||
/// the like-tag attributes attached to the same object.
|
||||
/// </param>
|
||||
///
|
||||
public XmlSerializationTagAttribute(string value, int order)
|
||||
{
|
||||
try
|
||||
{
|
||||
Value = value;
|
||||
Order = order;
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format(
|
||||
Properties.Resources.Generic_EncounteredProblemConstructingClassString, GetType().FullName),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare this object to the one specified.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="that">The <see cref="Xml.XmlSerializationTagAttribute"/>
|
||||
/// tag to compare to</param>
|
||||
/// <returns></returns>
|
||||
///
|
||||
public int CompareTo(XmlSerializationTagAttribute that)
|
||||
{
|
||||
return Order.CompareTo(that.Order);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
public static class TestRenamer
|
||||
{
|
||||
private static IEnumerable<string> GetAllDirectories(string dir)
|
||||
{
|
||||
return Directory.GetDirectories(dir, "*", SearchOption.AllDirectories);
|
||||
}
|
||||
|
||||
//FB 29992 imported from rename tool , changed to have bothh rename ID and test setup name
|
||||
//in one method
|
||||
public static bool RenameTest(string origTestFolder, string newTestName, string oldTestName, string dtsFileFolder, string newTestId, string oldTestId, Action<int> progressFunc)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (newTestName == oldTestName && newTestId == oldTestId)
|
||||
{
|
||||
//No need to rename since it's same
|
||||
return true;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(origTestFolder)
|
||||
|| string.IsNullOrEmpty(newTestName)) { return false; }
|
||||
|
||||
var eventPath = Directory.GetParent(dtsFileFolder);
|
||||
var eventNumber = eventPath.FullName.Split('\\').LastOrDefault();
|
||||
|
||||
var path = Directory.GetParent(Directory.GetParent(origTestFolder).FullName).FullName;
|
||||
string newTestFolder = Path.Combine(path, newTestName, newTestId);
|
||||
|
||||
if (Directory.Exists(newTestFolder))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Create directories
|
||||
foreach (var d in GetAllDirectories(origTestFolder))
|
||||
{
|
||||
if (d.Contains("_Event Number") && !d.Contains(eventNumber))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Directory.CreateDirectory(d.Replace(origTestFolder, newTestFolder));
|
||||
}
|
||||
|
||||
//Copy files
|
||||
|
||||
var allFiles = Directory.GetFiles(origTestFolder, "*.*", SearchOption.AllDirectories);
|
||||
var currentFile = 0;
|
||||
|
||||
foreach (var f in allFiles)
|
||||
{
|
||||
currentFile++;
|
||||
|
||||
if (f.Contains("_Event Number") && !f.Contains(eventNumber))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var fullPath = f.Replace(origTestFolder, newTestFolder);
|
||||
var originalFile = Path.GetFileName(fullPath);
|
||||
var updatedFile = originalFile.Replace(oldTestId, newTestId);
|
||||
fullPath = Path.Combine(fullPath.Remove(fullPath.LastIndexOf('\\')), updatedFile);
|
||||
|
||||
File.Copy(f, fullPath, true);
|
||||
|
||||
if (fullPath.EndsWith(".dts"))
|
||||
{
|
||||
FindandReplace(fullPath, string.Concat("<Test Id=\"", oldTestName, "\""), string.Concat("<Test Id=\"", newTestName, "\""));
|
||||
}
|
||||
|
||||
var testIdNoEvent = oldTestId.Replace(eventNumber, "");
|
||||
|
||||
if (fullPath.EndsWith(string.Concat(oldTestId, ".xml"))
|
||||
|| fullPath.EndsWith(string.Concat(newTestId, ".xml"))
|
||||
|| fullPath.EndsWith(string.Concat(testIdNoEvent, ".xml")))
|
||||
{
|
||||
FindandReplace(fullPath, string.Concat("<SetupName>", oldTestName), string.Concat("<SetupName>", newTestName));
|
||||
var xmlFile = string.Concat(newTestId, ".xml");
|
||||
if (originalFile != xmlFile)
|
||||
{
|
||||
var newFullPath = Path.Combine(fullPath.Remove(fullPath.LastIndexOf('\\')), xmlFile);
|
||||
File.Move(fullPath, newFullPath);
|
||||
}
|
||||
}
|
||||
|
||||
var progress = currentFile * 100 / allFiles.Count();
|
||||
if (progress < 0) { progress = 0; }
|
||||
else if (progress > 100) { progress = 100; }
|
||||
progressFunc?.Invoke(progress);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void FindandReplace(string path, string oldText, string newText)
|
||||
{
|
||||
string text = File.ReadAllText(path);
|
||||
text = text.Replace(oldText, newText);
|
||||
File.WriteAllText(path, text);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
|
||||
//
|
||||
// MemoryMappedFile.cs
|
||||
//
|
||||
// Implementation of a library to use Win32 Memory Mapped
|
||||
// Files from within .NET applications
|
||||
//
|
||||
// COPYRIGHT (C) 2001, Tomas Restrepo (tomasr@mvps.org)
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Specifies access for the mapped file.
|
||||
/// These correspond to the FILE_MAP_XXX
|
||||
/// constants used by MapViewOfFile[Ex]()
|
||||
/// </summary>
|
||||
public enum MapAccess
|
||||
{
|
||||
FileMapCopy = 0x0001,
|
||||
FileMapWrite = 0x0002,
|
||||
FileMapRead = 0x0004,
|
||||
FileMapAllAccess = 0x001f,
|
||||
}
|
||||
|
||||
/// <summary>Wrapper class around the Win32 MMF APIs</summary>
|
||||
/// <remarks>
|
||||
/// Allows you to easily use memory mapped files on
|
||||
/// .NET applications.
|
||||
/// Currently, not all functionality provided by
|
||||
/// the Win32 system is avaliable. Things that are not
|
||||
/// supported include:
|
||||
/// <list>
|
||||
/// <item>You can't specify security descriptors</item>
|
||||
/// <item>You can't build the memory mapped file
|
||||
/// on top of a System.IO.File already opened</item>
|
||||
/// </list>
|
||||
/// The class is currently MarshalByRefObject, but I would
|
||||
/// be careful about possible interactions!
|
||||
/// </remarks>
|
||||
public class MemoryMappedFile : MarshalByRefObject, IDisposable
|
||||
{
|
||||
//! handle to MemoryMappedFile object
|
||||
private IntPtr _hMap = IntPtr.Zero;
|
||||
|
||||
#region Constants
|
||||
|
||||
private const int GENERIC_READ = unchecked((int)0x80000000);
|
||||
private const int GENERIC_WRITE = unchecked(0x40000000);
|
||||
private const int OPEN_ALWAYS = 4;
|
||||
private static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);
|
||||
private static readonly IntPtr NULL_HANDLE = IntPtr.Zero;
|
||||
|
||||
#endregion // Constants
|
||||
|
||||
public bool IsOpen => (_hMap != NULL_HANDLE);
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
private MemoryMappedFile()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Finalizer
|
||||
/// </summary>
|
||||
~MemoryMappedFile()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
|
||||
#region Create Overloads
|
||||
|
||||
/// <summary>
|
||||
/// Create an unnamed map object with no file backing
|
||||
/// </summary>
|
||||
/// <param name="protection">desired access to the
|
||||
/// mapping object</param>
|
||||
/// <param name="maxSize">maximum size of filemap object</param>
|
||||
/// <param name="name">name of file mapping object</param>
|
||||
/// <returns>The memory mapped file instance</returns>
|
||||
public static MemoryMappedFile
|
||||
Create(MapProtection protection, long maxSize, string name)
|
||||
{
|
||||
return Create(null, protection, maxSize, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an named map object with no file backing
|
||||
/// </summary>
|
||||
/// <param name="protection">desired access to the
|
||||
/// mapping object</param>
|
||||
/// <param name="maxSize">maximum size of filemap object</param>
|
||||
/// <returns>The memory mapped file instance</returns>
|
||||
public static MemoryMappedFile
|
||||
Create(MapProtection protection, long maxSize)
|
||||
{
|
||||
return Create(null, protection, maxSize, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an unnamed map object with a maximum size
|
||||
/// equal to that of the file
|
||||
/// </summary>
|
||||
/// <param name="fileName">name of backing file</param>
|
||||
/// <param name="protection">desired access to the
|
||||
/// mapping object</param>
|
||||
/// <returns>The memory mapped file instance</returns>
|
||||
public static MemoryMappedFile
|
||||
Create(string fileName, MapProtection protection)
|
||||
{
|
||||
return Create(fileName, protection, -1, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an unnamed map object
|
||||
/// </summary>
|
||||
/// <param name="fileName">name of backing file</param>
|
||||
/// <param name="protection">desired access to the
|
||||
/// mapping object</param>
|
||||
/// <param name="maxSize">maximum size of filemap
|
||||
/// object, or -1 for size of file</param>
|
||||
/// <returns>The memory mapped file instance</returns>
|
||||
public static MemoryMappedFile
|
||||
Create(string fileName, MapProtection protection,
|
||||
long maxSize)
|
||||
{
|
||||
return Create(fileName, protection, maxSize, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a named map object
|
||||
/// </summary>
|
||||
/// <param name="fileName">name of backing file, or null
|
||||
/// for a pagefile-backed map</param>
|
||||
/// <param name="protection">desired access to the mapping
|
||||
/// object</param>
|
||||
/// <param name="maxSize">maximum size of filemap object, or 0
|
||||
/// for size of file</param>
|
||||
/// <param name="name">name of file mapping object</param>
|
||||
/// <returns>The memory mapped file instance</returns>
|
||||
public static MemoryMappedFile
|
||||
Create(string fileName, MapProtection protection,
|
||||
long maxSize, String name)
|
||||
{
|
||||
var map = new MemoryMappedFile();
|
||||
|
||||
// open file first
|
||||
var hFile = INVALID_HANDLE_VALUE;
|
||||
|
||||
if (fileName != null)
|
||||
{
|
||||
// determine file access needed
|
||||
// we'll always need generic read access
|
||||
var desiredAccess = GENERIC_READ;
|
||||
if ((protection == MapProtection.PageReadWrite) ||
|
||||
(protection == MapProtection.PageWriteCopy))
|
||||
{
|
||||
desiredAccess |= GENERIC_WRITE;
|
||||
}
|
||||
|
||||
// open or create the file
|
||||
// if it doesn't exist, it gets created
|
||||
hFile = Win32MapApis.CreateFile(
|
||||
fileName, desiredAccess, 0,
|
||||
IntPtr.Zero, OPEN_ALWAYS, 0, IntPtr.Zero
|
||||
);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
throw new FileMapIOException(Marshal.GetHRForLastWin32Error());
|
||||
|
||||
// FIX: Is support needed for zero-length files!?!
|
||||
}
|
||||
|
||||
map._hMap = Win32MapApis.CreateFileMapping(
|
||||
hFile, IntPtr.Zero, (int)protection,
|
||||
(int)((maxSize >> 32) & 0xFFFFFFFF),
|
||||
(int)(maxSize & 0xFFFFFFFF), name
|
||||
);
|
||||
|
||||
// close file handle, we don't need it
|
||||
if (hFile != INVALID_HANDLE_VALUE) Win32MapApis.CloseHandle(hFile);
|
||||
if (map._hMap == NULL_HANDLE)
|
||||
{
|
||||
try
|
||||
{
|
||||
var w32 = new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error());
|
||||
APILogger.Log("Create(", fileName, ") failed, null handle, ", w32.Message);
|
||||
}
|
||||
catch { }
|
||||
var ex = Win32MapApis.GetLastError();
|
||||
throw new FileMapIOException(Marshal.GetHRForLastWin32Error());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
#endregion // Create Overloads
|
||||
|
||||
/// <summary>
|
||||
/// Open an existing named File Mapping object
|
||||
/// </summary>
|
||||
/// <param name="access">desired access to the map</param>
|
||||
/// <param name="name">name of object</param>
|
||||
/// <returns>The memory mapped file instance</returns>
|
||||
public static MemoryMappedFile Open(MapAccess access, String name)
|
||||
{
|
||||
var map = new MemoryMappedFile();
|
||||
|
||||
map._hMap = Win32MapApis.OpenFileMapping((int)access, false, name);
|
||||
if (map._hMap == NULL_HANDLE)
|
||||
throw new FileMapIOException(Marshal.GetHRForLastWin32Error());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Close this File Mapping object
|
||||
/// From here on, You can't do anything with it
|
||||
/// but the open views remain valid.
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Map a view of the file mapping object
|
||||
/// This returns a stream, giving you easy access to the memory,
|
||||
/// as you can use StreamReaders and StreamWriters on top of it
|
||||
/// </summary>
|
||||
/// <param name="access">desired access to the view</param>
|
||||
/// <param name="offset">offset of the file mapping object to
|
||||
/// start view at</param>
|
||||
/// <param name="size">size of the view</param>
|
||||
public Stream MapView(MapAccess access, long offset, int size)
|
||||
{
|
||||
if (!IsOpen)
|
||||
throw new ObjectDisposedException("MMF already closed");
|
||||
|
||||
var baseAddress = IntPtr.Zero;
|
||||
baseAddress = Win32MapApis.MapViewOfFile(
|
||||
_hMap, (int)access,
|
||||
(int)((offset >> 32) & 0xFFFFFFFF),
|
||||
(int)(offset & 0xFFFFFFFF), size
|
||||
);
|
||||
|
||||
if (baseAddress == IntPtr.Zero)
|
||||
{
|
||||
try
|
||||
{
|
||||
var w32 = new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error());
|
||||
APILogger.Log("MapView - error, base address= 0, ", w32.Message);
|
||||
}
|
||||
catch { }
|
||||
var ex = Win32MapApis.GetLastError();
|
||||
throw new FileMapIOException(Marshal.GetHRForLastWin32Error());
|
||||
}
|
||||
// Find out what MapProtection to use
|
||||
// based on the MapAccess flags...
|
||||
MapProtection protection;
|
||||
if (access == MapAccess.FileMapRead)
|
||||
protection = MapProtection.PageReadOnly;
|
||||
else
|
||||
protection = MapProtection.PageReadWrite;
|
||||
|
||||
return new MapViewStream(baseAddress, size, protection);
|
||||
}
|
||||
|
||||
|
||||
#region IDisposable implementation
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (IsOpen)
|
||||
Win32MapApis.CloseHandle(_hMap);
|
||||
_hMap = NULL_HANDLE;
|
||||
|
||||
if (disposing)
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion // IDisposable implementation
|
||||
|
||||
} // class MemoryMappedFile
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Property.NotInitializedException.cs
|
||||
|
||||
$Log: Property.NotInitializedException.cs,v $
|
||||
Revision 1.1 2007/12/13 23:57:33 Paul Hrissikopoulos
|
||||
Added ISO raw format.
|
||||
|
||||
Copyright © 2007
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities.DotNetProgrammingConstructs
|
||||
{
|
||||
// See "Property.cs".
|
||||
public partial class Property<Type>
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representation for property value not initialized exceptions.
|
||||
/// </summary>
|
||||
public class NotInitializedException
|
||||
: System.Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Property.NotInitializedException class.
|
||||
/// </summary>
|
||||
public NotInitializedException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Property.NotInitializedException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public NotInitializedException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Property.NotInitializedException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The inner <see cref="System.Exception"/> behind this enclosing
|
||||
/// exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public NotInitializedException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* LargeArray.Enumerator.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
// *** see LargeArray.cs ***
|
||||
public partial class LargeArray<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// An enumerator class for <see cref="T:LargeArray"/>.
|
||||
/// </summary>
|
||||
public class Enumerator : Exceptional, IEnumerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the <see cref="T:LargeArray.Enumerator"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="enumeratee">
|
||||
/// The <see cref="T:LargeArray"/> object to be operated upon by this instance.
|
||||
/// </param>
|
||||
///
|
||||
public Enumerator(LargeArray<T> enumeratee)
|
||||
{
|
||||
try
|
||||
{
|
||||
Enumeratee = enumeratee;
|
||||
CurrentIndex = (Enumeratee.LargeCount > 0 ? (ulong?)0 : null);
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem ", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="T:LargeArray"/> that his enumerator object is
|
||||
/// acting upon.
|
||||
/// </summary>
|
||||
protected LargeArray<T> Enumeratee
|
||||
{
|
||||
get => _Enumeratee.Value;
|
||||
private set => _Enumeratee.Value = value;
|
||||
}
|
||||
private Property<LargeArray<T>> _Enumeratee
|
||||
= new Property<LargeArray<T>>(
|
||||
typeof(Enumerator).FullName + ".Enumeratee",
|
||||
null,
|
||||
false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ulong"/> index of the current item.
|
||||
/// </summary>
|
||||
private ulong? CurrentIndex
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#region IEnumerator interface
|
||||
// *********************************************************************
|
||||
// ******************** BEGIN IEnumerator Interface ********************
|
||||
// *********************************************************************
|
||||
|
||||
/// <summary>
|
||||
/// Get the current element in the collection.
|
||||
/// </summary>
|
||||
///
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// The enumerator is positioned before the first element of the collection or after the last element OR...
|
||||
/// The collection was modified after the enumerator was created.
|
||||
/// </exception>
|
||||
///
|
||||
public object Current
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null == CurrentIndex)
|
||||
throw new InvalidOperationException("the current position is outside of the collection");
|
||||
|
||||
else if ( /*EnumerateeHasBeenModified*/ true)
|
||||
throw new InvalidOperationException("the collection has been modified since this enumerator was created");
|
||||
|
||||
//else return Enumeratee[ (ulong) CurrentIndex ]; - inaccessible code - 6/9/2010 - dtm
|
||||
}
|
||||
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem getting current element in the collection", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next element of the collection.
|
||||
/// </summary>
|
||||
///
|
||||
/// <returns>
|
||||
/// <see cref="bool"/> true if the enumerator was successfully advanced to the next
|
||||
/// element; false if the enumerator has passed the end of the collection.
|
||||
/// </returns>
|
||||
///
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// The collection was modified after the enumerator was created.
|
||||
/// </exception>
|
||||
///
|
||||
public bool MoveNext()
|
||||
{
|
||||
//try
|
||||
//{
|
||||
throw new NotSupportedException("MemoryMapArray MoveNext not supported");
|
||||
//}
|
||||
//catch (InvalidOperationException ex) { throw ex; }
|
||||
//catch (System.Exception ex)
|
||||
//{
|
||||
// throw new Exception("encountered problem advancing to the next element of the collection", ex);
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element
|
||||
/// in the collection.
|
||||
/// </summary>
|
||||
///
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// The collection was modified after the enumerator was created.
|
||||
/// </exception>
|
||||
///
|
||||
public void Reset()
|
||||
{
|
||||
//try
|
||||
//{
|
||||
// // TODO: implement
|
||||
throw new NotSupportedException("MemoryMap.LargeArray Reset not supported");
|
||||
//}
|
||||
//catch (InvalidOperationException) { throw; }
|
||||
//catch (System.Exception ex)
|
||||
//{
|
||||
// throw new Exception("encountered problem setting the enumerator to its initial position", ex);
|
||||
//}
|
||||
}
|
||||
|
||||
// *******************************************************************
|
||||
// ******************** END IEnumerator Interface ********************
|
||||
// *******************************************************************
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
AttributeCoder.cs
|
||||
|
||||
* 12/18/2008 Relo'd from Dave to SVN-controlled utilities project.
|
||||
|
||||
$Log: AttributeCoder.cs,v $
|
||||
Revision 1.1 2006/09/14 18:41:54 Paul Hrissikopoulos
|
||||
Moved AttributeCoder files from Dave solution.
|
||||
|
||||
Revision 1.3 2006/09/07 20:43:08 Paul Hrissikopoulos
|
||||
Expanded commentary.
|
||||
|
||||
Revision 1.2 2006/08/17 23:44:46 Paul Hrissikopoulos
|
||||
Removed freeloading DCX XML prototype code.
|
||||
|
||||
Revision 1.1 2006/08/17 23:05:11 Paul Hrissikopoulos
|
||||
Added generically-derived SelectionCriterion.ComparisonType enumeration attributes.
|
||||
|
||||
Copyright © 2006
|
||||
Diversified Technical Systems
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
using DTS.Common.Utilities.Properties;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Object for manipulating object-attached attributes and attribute values.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="TargetType">
|
||||
/// The type of <see cref="object"/> the attributes we are concerned with are
|
||||
/// are attached to.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <typeparam name="AttributeType">
|
||||
/// The type of attribute to be manipulated.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <typeparam name="AttributeValueType">
|
||||
/// The type of value contained by the attribute to be manipulated.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <remarks>
|
||||
/// This class was created to make it easier to "match" attributes and the data
|
||||
/// types they're attached to in a somewhat generic manner. It is intended that
|
||||
/// attribute coder classes that deal with specific attribute types be derived
|
||||
/// from this one.
|
||||
/// </remarks>
|
||||
///
|
||||
public class AttributeCoder<TargetType, AttributeType, AttributeValueType> : Exceptional
|
||||
{
|
||||
/// <summary>
|
||||
/// Method that specifies how to access the value of a given "AttributeType".
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="attribute">
|
||||
/// The "AttributeType" attribute to have its value extracted.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The "AttributeValueType" value of the specified attribute.
|
||||
/// </returns>
|
||||
///
|
||||
public delegate AttributeValueType AttributeValueExtractionMethod(AttributeType attribute);
|
||||
|
||||
/// <summary>
|
||||
/// Method for determining the equality of two "AttributeValueType" values.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value1">
|
||||
/// A "AttributeValueType" to be equality-compared.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="value2">
|
||||
/// A "AttributeValueType" to be equality-compared.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// True if the two values are equal; false otherwise.
|
||||
/// </returns>
|
||||
///
|
||||
public delegate bool AttributeValueEqualityComparisonMethod(AttributeValueType value1, AttributeValueType value2);
|
||||
|
||||
private readonly AttributeValueExtractionMethod _extractAttributeValue;
|
||||
private readonly AttributeValueEqualityComparisonMethod _areAttributeValuesEqual;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an instance of the AttributeCoder class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="attributeValueExtractionMethod">
|
||||
/// A <see cref="AttributeValueExtractionMethod"/> that defines how "AttributeValueType"
|
||||
/// values are to be extracted from "AttributeType" attributes.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="attributeValueEqualityComparisonMethod">
|
||||
/// Optional parameter for specifying a custom comparison method to override default
|
||||
/// "AttributeValueType" equality determination. Pass null to use default
|
||||
/// comparison.
|
||||
/// </param>
|
||||
///
|
||||
public AttributeCoder(AttributeValueExtractionMethod attributeValueExtractionMethod,
|
||||
AttributeValueEqualityComparisonMethod attributeValueEqualityComparisonMethod)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null == attributeValueExtractionMethod)
|
||||
throw new Exception(Resources.AttributeCoder_AttributeCoder_NullAttributeValueExtractionMethodReferenceString);
|
||||
_extractAttributeValue = attributeValueExtractionMethod;
|
||||
if (null != attributeValueEqualityComparisonMethod)
|
||||
_areAttributeValuesEqual = attributeValueEqualityComparisonMethod;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format(Resources.Generic_EncounteredProblemConstructingClassString, GetType().FullName),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the "AttributeValueType" of the "AttributeType" attribute
|
||||
/// attached to the specified "TargetType".
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="target">
|
||||
/// The "TargetType" object whose "AttributeType" attribute is to be
|
||||
/// evaluated.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The "AttributeValueType" of the "AttributeType" attribute attached
|
||||
/// to the specified "TargetType".
|
||||
/// </returns>
|
||||
///
|
||||
public AttributeValueType DecodeAttributeValue(TargetType target)
|
||||
{
|
||||
try
|
||||
{
|
||||
var attributes = DecodeAttributeValues(target);
|
||||
|
||||
if (attributes.Count > 0) return attributes[0];
|
||||
throw new Exception(Resources.AttributeCoder_NoTypeAttributesFoundOnTargetString);
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Resources.AttributeCoder_DecodeAttributeExceptionString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the <see cref="T:List"/> of "AttributeValueType"s of the
|
||||
/// "AttributeType" attached to the specified "TargetType".
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="target">
|
||||
/// The "TargetType" object whose "AttributeType" attribute is to be
|
||||
/// evaluated.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The "AttributeValueType" of the "AttributeType" attribute attached
|
||||
/// to the specified "TargetType".
|
||||
/// </returns>
|
||||
///
|
||||
public List<AttributeValueType> DecodeAttributeValues(TargetType target)
|
||||
{
|
||||
try
|
||||
{
|
||||
var info = target.GetType().GetField(target.ToString());
|
||||
var attributes = (info.GetCustomAttributes(typeof(AttributeType), false) as AttributeType[]);
|
||||
var attributeList = new List<AttributeValueType>();
|
||||
if (attributes != null)
|
||||
{
|
||||
attributeList.AddRange(attributes.Select(t => _extractAttributeValue(t)));
|
||||
}
|
||||
return attributeList;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Resources.AttributeCoder_DecodeAttributesExceptionString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the "TargetType" value that has the "AttributeType"
|
||||
/// attribute with the specified "AttributeValueType" value attached
|
||||
/// to it.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="attributeValue">
|
||||
/// The value of the "AttributeType" attribute attached to the
|
||||
/// "TargetType" target object we're looking for.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The "TargetType" target object that has the "AttributeType"
|
||||
/// attribute attached to it that has a "AttributeValueType" value of
|
||||
/// attributeValue.
|
||||
/// </returns>
|
||||
///
|
||||
public TargetType EncodeAttributeValue(AttributeValueType attributeValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var targets = DehashAttributeValue(attributeValue);
|
||||
|
||||
if (1 != targets.Count) throw new Exception(Resources.AttributeCoder_UnableToFindTargetTypeMappingString);
|
||||
return targets[0];
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Resources.AttributeCoder_EncodeAttributeExceptionString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a list of "TargetType" values that have the
|
||||
/// "AttributeType" attribute with the specified
|
||||
/// "AttributeValueType" value attached to them.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="attributeValue">
|
||||
/// The value of the "AttributeType" attribute attached to the
|
||||
/// "TargetType" target object we're looking for.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="T:List"/> of "TargetType" target objects that has
|
||||
/// the "AttributeType" attribute attached to it that has a
|
||||
/// "AttributeValueType" value of attributeValue.
|
||||
/// </returns>
|
||||
///
|
||||
public List<TargetType> DehashAttributeValue(AttributeValueType attributeValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var targets = Enum.GetValues(typeof(TargetType)).Cast<TargetType>()
|
||||
.Where(target => (null != _areAttributeValuesEqual) ?
|
||||
_areAttributeValuesEqual(DecodeAttributeValue(target), attributeValue) : DecodeAttributeValue(target).Equals(attributeValue)).ToList();
|
||||
if (targets.Count <= 0) throw new Exception(Resources.AttributeCoder_DehashAttributeValue_UnableToMatchAttributeValueWithTargetString);
|
||||
return targets;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Resources.AttributeCoder_DehashAttributeValue_DehashAttributeValueExceptionString, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* TextLogger.WriteCycleHandle.cs
|
||||
*
|
||||
* Copyright © 2010
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace DTS.Common.Utilities.Logging
|
||||
{ // *** see TextLogger.cs ***
|
||||
public partial class TextLogger
|
||||
{
|
||||
/// <summary>
|
||||
/// "Handle" containing the state information for a log message write session.
|
||||
/// </summary>
|
||||
protected class WriteCycleHandle
|
||||
{
|
||||
/// <summary>
|
||||
/// The filename of the log file receiving the messages being supplied to this
|
||||
/// write session.
|
||||
/// </summary>
|
||||
public string FullLogFileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="System.Threading.AutoResetEvent"/> whose "set" kicks off
|
||||
/// a write cycle.
|
||||
/// </summary>
|
||||
public AutoResetEvent CycleTrigger { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="System.Threading.AutoResetEvent"/> that is signaled when
|
||||
/// a write cycle completes.
|
||||
/// </summary>
|
||||
public AutoResetEvent CycleCompletionTrigger { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Logging.TextLogger.WriteCycleExceptionHandler"/> to be
|
||||
/// invoked when the write cycle encounters an exception.
|
||||
/// </summary>
|
||||
public WriteCycleExceptionHandler OnWriteCycleException { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="bool"/> flag that controls whether or not the write cycle should
|
||||
/// auto-terminate whenever it encounters an exception.
|
||||
/// </summary>
|
||||
public bool TerminateCycleOnException { get; set; }
|
||||
|
||||
private static readonly object MyLock = new object();
|
||||
/// <summary>
|
||||
/// Get/set the <see cref="bool"/> flag that will terminate the associated write cycle when set to 'true'.
|
||||
/// </summary>
|
||||
public bool TerminateWriteCycle
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (!_IsTerminateWriteCycleInitialized)
|
||||
throw new ApplicationException("TerminateWriteCycle value has not been initialized");
|
||||
else return _TerminateWriteCycle;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem getting value for property " + GetType().FullName + ".TerminateWriteCycle", ex);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (MyLock)
|
||||
{ //
|
||||
// Set the termination flag and then kick off a cycle so it goes into
|
||||
// effect asap.
|
||||
//
|
||||
_IsTerminateWriteCycleInitialized = true;
|
||||
_TerminateWriteCycle = value;
|
||||
if (_TerminateWriteCycle)
|
||||
CycleTrigger.Set();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem setting value for property " + GetType().FullName + ".TerminateWriteCycle", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool _TerminateWriteCycle;
|
||||
private bool _IsTerminateWriteCycleInitialized = false;
|
||||
|
||||
/// <summary>
|
||||
/// The actually queue of log message <see cref="string"/>s to be written to the active log file.
|
||||
/// </summary>
|
||||
public Queue<string> WriteQueue
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_IsWriteQueueInitialized)
|
||||
throw new ApplicationException("WriteQueue has not been initialized");
|
||||
else return _WriteQueue;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem getting value for property " + GetType().FullName + ".WriteQueue", ex);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
_IsWriteQueueInitialized = true;
|
||||
_WriteQueue = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem setting value for property " + GetType().FullName + ".WriteQueue", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private Queue<string> _WriteQueue = null;
|
||||
private bool _IsWriteQueueInitialized = false;
|
||||
|
||||
/// <summary>
|
||||
/// Callback to be invoked when the write cycle has closed it's associated log file's
|
||||
/// write handle for the last time.
|
||||
/// </summary>
|
||||
public WriteCycleCallback OnWriteCycleTermination
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
return _OnWriteCycleTermination;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem getting value for property " + GetType().FullName + ".OnWriteCycleTermination", ex);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (MyLock)
|
||||
{ //
|
||||
// Set the cycle termination callback. If we're undergoing termination and there's
|
||||
// nothing left in the write queue, then go ahead and immediately call the termination
|
||||
// callback. Null the reference after the call so we don't accidentally somehow end up
|
||||
// calling it twice.
|
||||
//
|
||||
_OnWriteCycleTermination = value;
|
||||
if (_IsTerminateWriteCycleInitialized && _TerminateWriteCycle &&
|
||||
_IsWriteQueueInitialized && _WriteQueue.Count <= 0)
|
||||
{
|
||||
_OnWriteCycleTermination(_WriteQueue);
|
||||
_OnWriteCycleTermination = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem setting value for property " + GetType().FullName + ".OnWriteCycleTermination", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private WriteCycleCallback _OnWriteCycleTermination = null;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the <see cref="Logging.TextLogger.WriteCycleHandle"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="fullLogFileName">
|
||||
/// The filename of the log file receiving the messages being supplied to this
|
||||
/// write session.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="writeQueue">
|
||||
/// The actually queue of log message <see cref="string"/>s to be written to the active log file.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="onWriteCycleTermination">
|
||||
/// Callback to be invoked when the write cycle has closed it's associated log file's
|
||||
/// write handle for the last time.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="onWriteCycleException">
|
||||
/// Callback to be invoked when the write cycle has closed it's associated log file's
|
||||
/// write handle for the last time.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="terminateCycleOnException">
|
||||
/// <see cref="bool"/> flag that controls whether or not the write cycle should
|
||||
/// auto-terminate whenever it encounters an exception.
|
||||
/// </param>
|
||||
///
|
||||
public WriteCycleHandle(string fullLogFileName,
|
||||
Queue<string> writeQueue,
|
||||
WriteCycleCallback onWriteCycleTermination,
|
||||
WriteCycleExceptionHandler onWriteCycleException,
|
||||
bool terminateCycleOnException)
|
||||
{
|
||||
TerminateWriteCycle = false;
|
||||
FullLogFileName = fullLogFileName;
|
||||
WriteQueue = writeQueue;
|
||||
CycleTrigger = new AutoResetEvent(false);
|
||||
CycleCompletionTrigger = new AutoResetEvent(false);
|
||||
OnWriteCycleTermination = onWriteCycleTermination;
|
||||
OnWriteCycleException = onWriteCycleException;
|
||||
TerminateCycleOnException = terminateCycleOnException;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace DTS.Common.Utilities.Xml
|
||||
{
|
||||
public class XmlToObject<T>
|
||||
{
|
||||
public static T FromXml(string xml)
|
||||
{
|
||||
T xmlClass = default(T);
|
||||
|
||||
try
|
||||
{
|
||||
using (TextReader reader = new StringReader(xml))
|
||||
{
|
||||
try
|
||||
{
|
||||
xmlClass =
|
||||
(T)new XmlSerializer(typeof(T)).Deserialize(reader);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
return xmlClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a class to simplify waiting for a resource
|
||||
/// it can wait for a specified period and also check another signal or condition
|
||||
/// </summary>
|
||||
public class WaitWithCondition
|
||||
{
|
||||
/// <summary>
|
||||
/// the max time to wait in any spin cycle
|
||||
/// </summary>
|
||||
/// <remarks>this should probably be private and never modified as it will affect all
|
||||
/// waitwithcondition instances.
|
||||
/// if a wait condition is created with a 1000 millisecond wait period, and the EachWaitMilliSec
|
||||
/// was 20, we would wait for 50 cycles of 20ms before our final timeout
|
||||
/// </remarks>
|
||||
public static int EachWaitMilliSec = 20; // we wait 0.02 second each time
|
||||
|
||||
/// <summary>
|
||||
/// optional function to check while waiting for handle to return.
|
||||
/// </summary>
|
||||
/// <returns>bool if condition has been met, false otherwise</returns>
|
||||
public delegate bool Condition();
|
||||
|
||||
/// <summary>
|
||||
/// this exception is used to indicate a condition was met to the calling code
|
||||
/// </summary>
|
||||
public class ConditionMetException : ApplicationException
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// waits either for work to be finished (signaled by workevent),
|
||||
/// timeout, or the work to be canceled
|
||||
/// returns false if timed out, returns true if work completed
|
||||
/// throws an exception if canceled?
|
||||
/// (note this should be the same behavior as Wait(handle, int, condition)
|
||||
/// 17600 Communication class improvements from 3.2
|
||||
/// </summary>
|
||||
public static bool Wait(WaitHandle workEvent, int toMS, WaitHandle cancelEvent)
|
||||
{
|
||||
var res = WaitHandle.WaitAny(new[] { workEvent, cancelEvent }, toMS);
|
||||
//nothing signalled
|
||||
if (WaitHandle.WaitTimeout == res) { return false; }
|
||||
|
||||
if (0 == res) { return true; }
|
||||
throw new ConditionMetException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// wait for a resource to be available
|
||||
/// </summary>
|
||||
/// <param name="handle"><see cref="System.Threading.WaitHandle" /> object to wait on</param>
|
||||
/// <param name="toMilliSec">max amount of time in milliseconds to wait
|
||||
/// use <see cref="System.Threading.Timeout.Infinite" /> to wait for the max amount of time
|
||||
/// allowed.
|
||||
/// </param>
|
||||
/// <param name="condition">an additional condition to check. Can be null.
|
||||
/// if condition is met before resource is available a <see cref="WaitWithCondition.ConditionMetException" />
|
||||
/// is thrown.
|
||||
/// </param>
|
||||
/// <returns>true indicates the <see cref="System.Threading.WaitHandle" /> object has returned within
|
||||
/// the requested time period, false otherwise
|
||||
/// </returns>
|
||||
public static bool Wait(WaitHandle handle, int toMilliSec, Condition condition)
|
||||
{
|
||||
var NumberOfWaits = 1;
|
||||
|
||||
// check for infinity
|
||||
if (toMilliSec < 0)
|
||||
{
|
||||
if (toMilliSec != System.Threading.Timeout.Infinite)
|
||||
{
|
||||
throw new ArgumentException("WaitWithCondition.Wait: invalid timeout value");
|
||||
}
|
||||
// they want to wait forever, a billion seconds is pretty long
|
||||
NumberOfWaits = 1000000000;
|
||||
}
|
||||
else if (toMilliSec == 0)
|
||||
{
|
||||
// 0 means no wait just check
|
||||
EachWaitMilliSec = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// they want to wait X milli seconds,
|
||||
// first make sure that isn't shorter than our eachWaitMilliSec
|
||||
if (toMilliSec < EachWaitMilliSec)
|
||||
{
|
||||
// yes it is, adjust our wait
|
||||
EachWaitMilliSec = toMilliSec;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no, how many times do we have to try?
|
||||
NumberOfWaits = toMilliSec / EachWaitMilliSec;
|
||||
}
|
||||
}
|
||||
for (var idx = 0; idx < NumberOfWaits; idx++)
|
||||
{
|
||||
if (handle.WaitOne(EachWaitMilliSec, false))
|
||||
{
|
||||
// no timeout, we have data but check cancel first
|
||||
if ((null != condition))
|
||||
{
|
||||
if (condition())
|
||||
{
|
||||
throw new ConditionMetException();
|
||||
}
|
||||
}
|
||||
// no, give it to them
|
||||
return true;
|
||||
}
|
||||
|
||||
// timeout. check for cancel before looping
|
||||
if ((null != condition))
|
||||
{
|
||||
if (condition())
|
||||
{
|
||||
throw new ConditionMetException();
|
||||
}
|
||||
}
|
||||
}
|
||||
// we didn't get anything, return timeout
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
|
||||
//
|
||||
// FileMapIOException.cs
|
||||
//
|
||||
// Implementation of a library to use Win32 Memory Mapped
|
||||
// Files from within .NET applications
|
||||
//
|
||||
// COPYRIGHT (C) 2001, Tomas Restrepo (tomasr@mvps.org)
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
|
||||
/// <summary>Exception class thrown by the library</summary>
|
||||
/// <remarks>
|
||||
/// Represents an exception occured as a result of an
|
||||
/// invalid IO operation on any of the File mapping classes
|
||||
/// It wraps the error message and the underlying Win32 error
|
||||
/// code that caused the error.
|
||||
/// </remarks>
|
||||
// TODO: Make Serializable!
|
||||
public class FileMapIOException : IOException
|
||||
{
|
||||
//
|
||||
// properties
|
||||
//
|
||||
private int m_win32Error = 0;
|
||||
/// <summary>
|
||||
/// the Win32 Error code describing the error.
|
||||
/// http://msdn.microsoft.com/en-us/library/ms681381%28VS.85%29.aspx
|
||||
/// </summary>
|
||||
public int Win32ErrorCode => m_win32Error;
|
||||
|
||||
/// <summary>
|
||||
/// A description of the error.
|
||||
/// </summary>
|
||||
public override string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Win32ErrorCode != 0)
|
||||
return base.Message + " (" + Win32ErrorCode + ")";
|
||||
else
|
||||
return base.Message;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="IO.MemoryMap.FileMapIOException"/>
|
||||
/// </summary>
|
||||
/// <param name="error">win32 error code describing error</param>
|
||||
public FileMapIOException(int error)
|
||||
: base()
|
||||
{
|
||||
m_win32Error = error;
|
||||
}
|
||||
/// <summary>
|
||||
/// Construct a <see cref="IO.MemoryMap.FileMapIOException" />
|
||||
/// </summary>
|
||||
/// <param name="message">description of error</param>
|
||||
public FileMapIOException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Construct a <see cref="IO.MemoryMap.FileMapIOException" />
|
||||
/// </summary>
|
||||
/// <param name="message">description of error</param>
|
||||
/// <param name="innerException">exception causing the error</param>
|
||||
public FileMapIOException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
} // class FileMapIOException
|
||||
|
||||
|
||||
} // namespace Winterdom.IO.FileMap
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* AverageOverTime.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// A class to represent the average value of a dynamically specified set over time. This
|
||||
/// class is intended to be used to keep a running average of sets of piecemeal-collected
|
||||
/// data, and it is assumed that a subclass will implement the type-specific features of
|
||||
/// this task.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="T">
|
||||
/// The type we're talking the average value over time of.
|
||||
/// </typeparam>
|
||||
///
|
||||
public abstract class AverageValueOverTime<T> : Exceptional
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the AverageValueOverTime class, assuming that no
|
||||
/// averaging has been done yet.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="initialTime">
|
||||
/// The <see cref="double"/> begin time of the average (using the time units specified
|
||||
/// by the "TimeUnitSymbol" property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="sampleRate">
|
||||
/// The <see cref="double"/> sample rate of the items being averaged (using the time units
|
||||
/// specifed by the "TimeUnitSymbol" property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="initialAverage">
|
||||
/// The "zero" value of our generic data type.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="timeUnitSymbol">
|
||||
/// The <see cref="string"/> time unit description for begin/end times and the sample rate.
|
||||
/// </param>
|
||||
///
|
||||
protected AverageValueOverTime(double initialTime,
|
||||
double sampleRate,
|
||||
T initialAverage,
|
||||
string timeUnitSymbol)
|
||||
: this(initialTime,
|
||||
initialTime,
|
||||
sampleRate,
|
||||
initialAverage,
|
||||
timeUnitSymbol)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the AverageValueOverTime class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="beginTime">
|
||||
/// The <see cref="double"/> begin time of the average (using the time units specified
|
||||
/// by the "TimeUnitSymbol" property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="endTime">
|
||||
/// The <see cref="double"/> end time of the average (using the time units specified
|
||||
/// by the "TimeUnitSymbol" property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="sampleRate">
|
||||
/// The <see cref="double"/> sample rate of the items being averaged (using the time units
|
||||
/// specifed by the "TimeUnitSymbol" property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="initialAverage">
|
||||
/// The initial average value to be appended to.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="timeUnitSymbol">
|
||||
/// The <see cref="string"/> time unit description for begin/end times and the sample rate.
|
||||
/// </param>
|
||||
///
|
||||
protected AverageValueOverTime(double beginTime,
|
||||
double endTime,
|
||||
double sampleRate,
|
||||
T initialAverage,
|
||||
string timeUnitSymbol)
|
||||
{
|
||||
try
|
||||
{ //
|
||||
// Initialize the known knowns.
|
||||
//
|
||||
BeginTime = beginTime;
|
||||
EndTime = endTime;
|
||||
SampleRate = sampleRate;
|
||||
TimeUnitSymbol = timeUnitSymbol;
|
||||
CurrentAverage = initialAverage;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// These properties should be useful no matter what we're taking
|
||||
// the running average of.
|
||||
//
|
||||
/// <summary>
|
||||
/// Beginning Time
|
||||
/// </summary>
|
||||
public double BeginTime { get; protected set; }
|
||||
/// <summary>
|
||||
/// Ending Time
|
||||
/// </summary>
|
||||
public double EndTime { get; protected set; }
|
||||
/// <summary>
|
||||
/// The sampling rate
|
||||
/// </summary>
|
||||
public double SampleRate { get; protected set; }
|
||||
/// <summary>
|
||||
/// the time unit symbol
|
||||
/// </summary>
|
||||
public string TimeUnitSymbol { get; protected set; }
|
||||
/// <summary>
|
||||
/// the current average
|
||||
/// </summary>
|
||||
public T CurrentAverage { get; protected set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// appends a list of values
|
||||
/// </summary>
|
||||
/// <param name="values">list of values</param>
|
||||
/// <remarks>inheriting clases should know more about the nature of the data type
|
||||
/// and averaging them over time.
|
||||
/// </remarks>
|
||||
public abstract void AppendValues(List<T> values);
|
||||
/// <summary>
|
||||
/// appends an array of values
|
||||
/// </summary>
|
||||
/// <param name="values">array of values</param>
|
||||
/// <remarks>inheriting clases should know more about the nature of the data type
|
||||
/// and averaging them over time.
|
||||
/// </remarks>
|
||||
public abstract void AppendValues(T[] values);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// produces a long value given a firmware version in string representation
|
||||
/// </summary>
|
||||
public class FirmwareVersionToLong
|
||||
{
|
||||
/// <summary>
|
||||
/// Produces a long value given a firmware version represented as a string
|
||||
/// </summary>
|
||||
/// <param name="version">firmware version</param>
|
||||
/// <returns>firmware version as a long</returns>
|
||||
public static long Query(string version)
|
||||
{
|
||||
var result = 0L;
|
||||
var chars = version.Length > 4 ? 4 : version.Length;
|
||||
var shift = 48;
|
||||
|
||||
for (var i = 0; i < chars; i++)
|
||||
{
|
||||
result += version[i] << shift;
|
||||
shift -= 16;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
|
||||
//
|
||||
// MapViewStream.cs
|
||||
//
|
||||
// Implementation of a library to use Win32 Memory Mapped
|
||||
// Files from within .NET applications
|
||||
//
|
||||
// COPYRIGHT (C) 2001, Tomas Restrepo (tomasr@mvps.org)
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Specifies page protection for the mapped file
|
||||
/// These correspond to the PAGE_XXX set of flags
|
||||
/// passed to CreateFileMapping()
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum MapProtection
|
||||
{
|
||||
#pragma warning disable 1591 //disable xml comment warnings - these are from the Win32 API (I think)
|
||||
PageNone = 0x00000000,
|
||||
// protection
|
||||
PageReadOnly = 0x00000002,
|
||||
PageReadWrite = 0x00000004,
|
||||
PageWriteCopy = 0x00000008,
|
||||
// attributes
|
||||
SecImage = 0x01000000,
|
||||
SecReserve = 0x04000000,
|
||||
SecCommit = 0x08000000,
|
||||
SecNoCache = 0x10000000,
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to read/write from/to
|
||||
/// a view of a memory mapped file.
|
||||
/// </summary>
|
||||
public class MapViewStream : Stream, IDisposable
|
||||
{
|
||||
|
||||
#region variables
|
||||
|
||||
//! What's our access?
|
||||
private readonly MapProtection _protection = MapProtection.PageNone;
|
||||
|
||||
//! base address of our buffer
|
||||
private IntPtr _base = IntPtr.Zero;
|
||||
|
||||
//! our current buffer length
|
||||
private readonly long _length = 0;
|
||||
|
||||
//! our current position in the stream buffer
|
||||
private long _position = 0;
|
||||
|
||||
#endregion // variables
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor used internally by MemoryMappedFile.
|
||||
/// </summary>
|
||||
/// <param name="baseAddress">base address where the view starts</param>
|
||||
/// <param name="length">Length of view, in bytes</param>
|
||||
/// <param name="protection"></param>
|
||||
internal MapViewStream(IntPtr baseAddress, long length,
|
||||
MapProtection protection)
|
||||
{
|
||||
_base = baseAddress;
|
||||
_length = length;
|
||||
_protection = protection;
|
||||
_position = 0;
|
||||
IsOpen = (baseAddress != IntPtr.Zero);
|
||||
}
|
||||
/// <summary>
|
||||
/// finalizer for MapViewStream.
|
||||
/// </summary>
|
||||
~MapViewStream()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
|
||||
#region Properties
|
||||
|
||||
public override bool CanRead => true;
|
||||
|
||||
public override bool CanSeek => true;
|
||||
|
||||
public override bool CanWrite => (((int)_protection) & 0x000000C) != 0;
|
||||
public override long Length => _length;
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get => _position;
|
||||
set => Seek(value, SeekOrigin.Begin);
|
||||
}
|
||||
private bool IsOpen { get; set; } = false;
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
|
||||
#region Stream Methods
|
||||
|
||||
/// <summary>
|
||||
/// causes any buffered data to be written to the stream and clears the buffer
|
||||
/// </summary>
|
||||
public override void Flush()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsOpen)
|
||||
throw new ObjectDisposedException("Stream is closed");
|
||||
// flush the view but leave the buffer intact
|
||||
// FIX: get rid of cast
|
||||
Win32MapApis.FlushViewOfFile(_base, (int)_length);
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
/// <summary>
|
||||
/// reads a sequence of bytes from the current stream and advances the position in the stream by the number
|
||||
/// of bytes read
|
||||
/// </summary>
|
||||
/// <param name="buffer">array of bytes, will contain the bytes read from the stream offset by
|
||||
/// "offset"</param>
|
||||
/// <param name="offset">the offset from the start of buffer to store read data</param>
|
||||
/// <param name="count">the maximum number of bytes to read</param>
|
||||
/// <returns>the number of bytes read into the buffer
|
||||
/// Arguement Exception if count is greater than buffer after offset is removed
|
||||
/// ObjectDisposedException if stream is not open
|
||||
/// </returns>
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (!IsOpen)
|
||||
throw new ObjectDisposedException("Stream is closed");
|
||||
|
||||
if (buffer.Length - offset < count)
|
||||
throw new ArgumentException("Invalid Offset");
|
||||
|
||||
var bytesToRead = (int)System.Math.Min(Length - _position, count);
|
||||
Marshal.Copy((IntPtr)(_base.ToInt64() + _position), buffer, offset, bytesToRead);
|
||||
|
||||
_position += bytesToRead;
|
||||
return bytesToRead;
|
||||
}
|
||||
//Added by Tadd 2009.07.01:
|
||||
public int ReadShort(short[] buffer, int offset, int count)
|
||||
{
|
||||
if (!IsOpen)
|
||||
throw new ObjectDisposedException("Stream is closed");
|
||||
|
||||
if (buffer.Length - offset < count)
|
||||
throw new ArgumentException("Invalid Offset");
|
||||
|
||||
// If the above exceptions are thrown and handled the method goes on to return
|
||||
// as many of the requested objects as it can.
|
||||
var shortsToRead = (int)System.Math.Min(Length - _position, count);
|
||||
Marshal.Copy((IntPtr)(_base.ToInt64() + _position), buffer, offset, shortsToRead);
|
||||
|
||||
_position += shortsToRead;
|
||||
return shortsToRead;
|
||||
}
|
||||
/// <summary>
|
||||
/// writes specified number of bytes to the stream starting at an offset
|
||||
/// </summary>
|
||||
/// <param name="buffer">array containing the bytes to be written</param>
|
||||
/// <param name="offset">the offset from the start of buffer to start reading from</param>
|
||||
/// <param name="count">maximum number of bytes to write</param>
|
||||
/// <remarks>
|
||||
/// throws ObjectDisposedException if the stream is no longer open
|
||||
/// throws FileMapIOException if the stream cannot be written to
|
||||
/// throws ArgumentException if count is greater than buffer length after removing offset
|
||||
/// </remarks>
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (!IsOpen)
|
||||
throw new ObjectDisposedException("Stream is closed");
|
||||
if (!CanWrite)
|
||||
throw new FileMapIOException("Stream cannot be written to");
|
||||
|
||||
if (buffer.Length - offset < count)
|
||||
throw new ArgumentException("Invalid Offset");
|
||||
|
||||
var bytesToWrite = (int)System.Math.Min(Length - _position, count);
|
||||
if (bytesToWrite == 0)
|
||||
return;
|
||||
|
||||
Marshal.Copy(buffer, offset, (IntPtr)(_base.ToInt64() + _position), bytesToWrite);
|
||||
|
||||
_position += bytesToWrite;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// move to a specified position in the stream
|
||||
/// </summary>
|
||||
/// <param name="offset">a byte offset relative to the origin parameter</param>
|
||||
/// <param name="origin"><see cref="System.IO.SeekOrigin" /> position to seek relative to
|
||||
/// (current, beginning, end)
|
||||
/// </param>
|
||||
/// <returns>new position in the stream</returns>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
if (!IsOpen)
|
||||
throw new ObjectDisposedException("Stream is closed");
|
||||
|
||||
long newpos = 0;
|
||||
switch (origin)
|
||||
{
|
||||
case SeekOrigin.Begin: newpos = offset; break;
|
||||
case SeekOrigin.Current: newpos = Position + offset; break;
|
||||
case SeekOrigin.End: newpos = Length + offset; break;
|
||||
}
|
||||
// sanity check
|
||||
if (newpos < 0 || newpos >= Length)
|
||||
throw new FileMapIOException("Invalid Seek Offset");
|
||||
_position = newpos;
|
||||
|
||||
return newpos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// not supported
|
||||
/// sets the length of the current stream
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
// not supported!
|
||||
throw new NotSupportedException("Can't change View Size");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close the current stream and release any resources
|
||||
/// </summary>
|
||||
/// <remarks>generally close isn't overriden?</remarks>
|
||||
public override void Close()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
#endregion // Stream methods
|
||||
|
||||
|
||||
#region IDisposable Implementation
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// release unmanaged resources
|
||||
/// </summary>
|
||||
/// <param name="disposing"></param>
|
||||
/// <remarks>virtual void Dispose functions can be dangerous
|
||||
/// as overriding it in an inherited class might mean you miss
|
||||
/// the base class Dispose
|
||||
/// </remarks>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (IsOpen)
|
||||
{
|
||||
Flush();
|
||||
// FIX: eliminate cast
|
||||
Win32MapApis.UnmapViewOfFile(_base);
|
||||
IsOpen = false;
|
||||
}
|
||||
|
||||
if (disposing)
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion // IDisposable Implementation
|
||||
|
||||
} // class MapViewStream
|
||||
|
||||
} // namespace Winterdom.IO.FileMap
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
RangeRestrictedIntProperty.InvalidRangeException.cs
|
||||
|
||||
$Log: RangeRestrictedIntProperty.InvalidRangeException.cs,v $
|
||||
Revision 1.1 2007/12/13 23:57:33 Paul Hrissikopoulos
|
||||
Added ISO raw format.
|
||||
|
||||
Copyright © 2007
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities.DotNetProgrammingConstructs
|
||||
{
|
||||
// See "RangeRestrictedIntProperty.cs"
|
||||
public partial class RangeRestrictedIntProperty
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representation for range-restricted integer property
|
||||
/// range exceptions.
|
||||
/// </summary>
|
||||
public class InvalidRangeException
|
||||
: System.Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// RangeRestrictedIntProperty.InvalidRangeException class.
|
||||
/// </summary>
|
||||
public InvalidRangeException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// RangeRestrictedIntProperty.InvalidRangeException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public InvalidRangeException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// RangeRestrictedIntProperty.InvalidRangeException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The inner <see cref="System.Exception"/> behind this enclosing
|
||||
/// exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public InvalidRangeException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
Math.Nhtsa.ChannelIntegration.cs
|
||||
|
||||
$Log: Math.Nhtsa.ChannelIntegration.cs,v $
|
||||
Revision 1.4 2007/10/04 04:57:45 Paul Hrissikopoulos
|
||||
Added new integration object.
|
||||
|
||||
Revision 1.3 2007/08/24 23:31:08 Paul Hrissikopoulos
|
||||
Fixed comment typos.
|
||||
|
||||
Revision 1.2 2007/03/28 15:58:02 Paul Hrissikopoulos
|
||||
Fixed error in integration calculation; fixed erroenous error check in SampleRate accessor.
|
||||
|
||||
Revision 1.1 2007/02/05 17:17:08 Paul Hrissikopoulos
|
||||
Finished installing generic channel math framework + basic calculus operations.
|
||||
|
||||
Copyright © 2007
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities.Math.Nhtsa
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Representation of NHTSA-based integration channel operation.
|
||||
/// </summary>
|
||||
public class Integration : DoubleListOperation
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get/set the <see cref="double"/> sample rate for this data to be integrated.
|
||||
/// </summary>
|
||||
public double SampleRate
|
||||
{
|
||||
get => _SampleRate.Value;
|
||||
set => _SampleRate.Value = value;
|
||||
}
|
||||
private Property<double> _SampleRate
|
||||
= new Property<double>(
|
||||
typeof(Integration).FullName + ".SampleRate",
|
||||
0.0,
|
||||
false
|
||||
);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Integration class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="domain">
|
||||
/// The System.Collections.Generic.IList of <see cref="double"/>s
|
||||
/// domain for this operation.
|
||||
/// </param>
|
||||
///
|
||||
public Integration(IList<double> domain)
|
||||
: base(domain)
|
||||
{ //
|
||||
// I'd prefer to do this statically, but I don't know of any C# way to place a constraint
|
||||
// on a generic type that's already been determined by some ancestor we're inheriting from,
|
||||
// so for now we'll have to dynamically check it on object instantiation.
|
||||
//
|
||||
if (!(domain is ICloneable))
|
||||
throw new InvalidCastException("the domain type for " + typeof(Integration).FullName + " must be ICloneable");
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Iso.ChannelIntegration class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="domain">
|
||||
/// The System.Collections.Generic.IList of <see cref="double"/>s
|
||||
/// domain for this operation.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="sampleRate">
|
||||
/// The <see cref="int"/> sample rate of the channel to be integrated.
|
||||
/// </param>
|
||||
///
|
||||
public Integration(IList<double> domain, int sampleRate)
|
||||
: this(domain)
|
||||
{
|
||||
try { SampleRate = sampleRate; }
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get the System.Collections.Generic.IList of <see cref="double"/>s result of
|
||||
/// the operation on the channel.
|
||||
/// </summary>
|
||||
public override IList<double> Range
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null == Domain)
|
||||
throw new ArgumentNullException("attempted to integrate null channel reference");
|
||||
|
||||
else if (0.0 >= SampleRate)
|
||||
throw new ArgumentOutOfRangeException("SampleRate must be greater than zero");
|
||||
|
||||
else if (!(Domain is ICloneable))
|
||||
throw new InvalidCastException("the domain type for " + typeof(Integration).FullName + " must be ICloneable");
|
||||
|
||||
else
|
||||
{
|
||||
var IndexOfLastSample = Domain.Count - 1;
|
||||
var de = 1 / (SampleRate * 2.0);
|
||||
var range = ((ICloneable)Domain).Clone() as IList<double>;
|
||||
|
||||
range[0] = Domain[0] * de;
|
||||
for (var t = 1; t < IndexOfLastSample; t++)
|
||||
range[t] = range[t - 1] + 2 * Domain[t] * de;
|
||||
range[IndexOfLastSample] = range[IndexOfLastSample - 1] + Domain[IndexOfLastSample] * de;
|
||||
|
||||
return range;
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem doing " + GetType().FullName + " operation", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
public class EnumDropDown<T> : System.Windows.Forms.ComboBox where T : struct, IComparable
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the class which actually holds the entrys in the list
|
||||
/// </summary>
|
||||
public class EnumListEntry : IComparable<EnumListEntry>
|
||||
{
|
||||
public T Value { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var decoder = new DescriptionAttributeCoder<T>();
|
||||
return decoder.DecodeAttributeValue(Value);
|
||||
}
|
||||
|
||||
public EnumListEntry(T val)
|
||||
{
|
||||
Value = val;
|
||||
}
|
||||
|
||||
public int CompareTo(EnumListEntry other)
|
||||
{
|
||||
return Value.CompareTo(other.Value);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
return false;
|
||||
var ele = (EnumListEntry)obj;
|
||||
return Value.Equals(ele.Value);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Value.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public delegate bool Filter(T enumEntry);
|
||||
|
||||
protected Filter _EnumFilter;
|
||||
public Filter EnumFilter
|
||||
{
|
||||
set
|
||||
{
|
||||
_EnumFilter = value;
|
||||
PopulateList();
|
||||
}
|
||||
}
|
||||
|
||||
public EnumDropDown(Filter defaultFilter)
|
||||
: base()
|
||||
{
|
||||
_EnumFilter = defaultFilter;
|
||||
PopulateList();
|
||||
}
|
||||
|
||||
public void PopulateList()
|
||||
{
|
||||
var values = Enum.GetValues(typeof(T));
|
||||
var entryList = new List<EnumListEntry>();
|
||||
foreach (T i in values)
|
||||
{
|
||||
if (_EnumFilter == null || _EnumFilter(i))
|
||||
{
|
||||
entryList.Add(new EnumListEntry(i));
|
||||
}
|
||||
}
|
||||
Items.Clear();
|
||||
Items.AddRange(entryList.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get or Set the selection as an EnumListEntry (can be null).
|
||||
/// </summary>
|
||||
public EnumListEntry SelectedEntry
|
||||
{
|
||||
get => (EnumListEntry)SelectedItem;
|
||||
|
||||
set => SelectedItem = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get or Set the selection as the enum itself (can NOT be null)!
|
||||
/// </summary>
|
||||
public T? SelectedEnum
|
||||
{
|
||||
get => SelectedEntry?.Value;
|
||||
|
||||
set => SelectedEntry = value == null ? null : new EnumListEntry((T)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D6DA1B74-C711-43C2-91B1-1908A8D04DBF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DTS.Utilities</RootNamespace>
|
||||
<AssemblyName>DTS.Utilities</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkProfile />
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DocumentationFile>bin\Debug\DTS.Utilities.XML</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>SharpZipLib\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ActiveUpdateList.cs" />
|
||||
<Compile Include="APILogging.cs" />
|
||||
<Compile Include="ArrayToString.cs" />
|
||||
<Compile Include="AttributeCoder.cs" />
|
||||
<Compile Include="AttributeExtractor.cs" />
|
||||
<Compile Include="AverageShortValueOverTime.cs" />
|
||||
<Compile Include="AverageValueOverTime.cs" />
|
||||
<Compile Include="ConfigInitializationHelper.cs" />
|
||||
<Compile Include="CRC32.cs" />
|
||||
<Compile Include="DataConditioning.cs" />
|
||||
<Compile Include="DegreesFromADC.cs" />
|
||||
<Compile Include="DataFlag.cs" />
|
||||
<Compile Include="ChannelFilter.cs" />
|
||||
<Compile Include="CheckComboBox.cs" />
|
||||
<Compile Include="AverageQueue.cs" />
|
||||
<Compile Include="DTSChecksum.cs" />
|
||||
<Compile Include="ExportINIFile.cs" />
|
||||
<Compile Include="KeywordAlert.cs" />
|
||||
<Compile Include="LevelTriggerLogging.cs" />
|
||||
<Compile Include="NHTSASubSample.cs" />
|
||||
<Compile Include="PowerManagement.cs" />
|
||||
<Compile Include="PropertyComparer.cs" />
|
||||
<Compile Include="PTP1588Timestamps.cs" />
|
||||
<Compile Include="SignalToNoiseRatio.cs" />
|
||||
<Compile Include="SortableBindingList.cs" />
|
||||
<Compile Include="StandardDev.cs" />
|
||||
<Compile Include="TaskbarHelper.cs" />
|
||||
<Compile Include="TestRenamer.cs" />
|
||||
<Compile Include="Time.cs" />
|
||||
<Compile Include="DataWindowAverager.cs" />
|
||||
<Compile Include="DataWindowAverager.WindowDoesNotExistException.cs" />
|
||||
<Compile Include="DescriptionAttributeCoder.cs" />
|
||||
<Compile Include="DiskUtility.cs" />
|
||||
<Compile Include="DoubleLargeArray.cs" />
|
||||
<Compile Include="EnumDropDown.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Exceptional.cs" />
|
||||
<Compile Include="ExceptionalDictionary.cs" />
|
||||
<Compile Include="ExceptionalForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ExceptionalList.cs" />
|
||||
<Compile Include="ExceptionalUserControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FileIODeclarations.cs" />
|
||||
<Compile Include="FileMapIOException.cs" />
|
||||
<Compile Include="FileMapViewArray.cs" />
|
||||
<Compile Include="FilterUtility.cs" />
|
||||
<Compile Include="FirmwareVersionToLong.cs" />
|
||||
<Compile Include="HexEncoding.cs" />
|
||||
<Compile Include="Math.DoubleListOperation.cs" />
|
||||
<Compile Include="Math.Iso.Differentiation.cs" />
|
||||
<Compile Include="Math.Nhtsa.Differentiation.cs" />
|
||||
<Compile Include="Math.Nhtsa.Integration.cs" />
|
||||
<Compile Include="Math.Operation.cs" />
|
||||
<Compile Include="NaturalStringCompare.cs" />
|
||||
<Compile Include="PersistWindowState.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="LargeArray.cs" />
|
||||
<Compile Include="LargeArray.Enumerator.cs" />
|
||||
<Compile Include="LargeArray.LargeOverflowException.cs" />
|
||||
<Compile Include="LargeArray.MissingScratchFileException.cs" />
|
||||
<Compile Include="LargeArray.NameGeneratorLock.cs" />
|
||||
<Compile Include="LargeArray.ScratchFileAlreadyExistsException.cs" />
|
||||
<Compile Include="MapViewStream.cs" />
|
||||
<Compile Include="MemoryMappedFile.cs" />
|
||||
<Compile Include="PowerOfTwoIntProperty.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Property.ConstructionException.cs" />
|
||||
<Compile Include="Property.cs" />
|
||||
<Compile Include="Property.InvalidValueException.cs" />
|
||||
<Compile Include="Property.NotInitializedException.cs" />
|
||||
<Compile Include="RangeRestrictedDoubleProperty.cs" />
|
||||
<Compile Include="RangeRestrictedDoubleProperty.InvalidRangeException.cs" />
|
||||
<Compile Include="RangeRestrictedIntProperty.cs" />
|
||||
<Compile Include="RangeRestrictedIntProperty.InvalidRangeException.cs" />
|
||||
<Compile Include="ScrollingMessageBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ScrollingMessageBox.Designer.cs">
|
||||
<DependentUpon>ScrollingMessageBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ShortLargeArray.cs" />
|
||||
<Compile Include="TextLogger.cs" />
|
||||
<Compile Include="TextLogger.LogPathnameNotInitializedException.cs" />
|
||||
<Compile Include="TextLogger.WriteCycleHandle.cs" />
|
||||
<Compile Include="UpdateNotifyingList.cs" />
|
||||
<Compile Include="WaitWithCondition.cs" />
|
||||
<Compile Include="Win32APIs.cs" />
|
||||
<Compile Include="Xml.PropertyAttributeDecoder.cs" />
|
||||
<Compile Include="XmlSerializationTagAttribute.cs" />
|
||||
<Compile Include="XmlToObject.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
<CustomToolNamespace>DTS.Common.Utilities.Properties</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ScrollingMessageBox.resx">
|
||||
<DependentUpon>ScrollingMessageBox.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Design\DTS.Common.UtilitiesClassDiagram.cd" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>rem del $(TargetFileName)
|
||||
rem "C:\Program Files\Microsoft\ILMerge\ILMerge" /wildcards /log:ILMerge.log /t:library /out:$(TargetFileName) *.dll
|
||||
</PostBuildEvent>
|
||||
<PreBuildEvent>rem %25comspec%25 /k "C:\Program Files\Microsoft Visual Studio .NET\Common7\Tools\vsvars32.bat"</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
* ScrollingMessageBox.cs
|
||||
*
|
||||
* Copyright © 2010
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Crude form for displaying modal yes/no dialog queries.
|
||||
/// </summary>
|
||||
public partial class ScrollingMessageBox : Form
|
||||
{
|
||||
public int TimeWait { get; set; } = 0;
|
||||
|
||||
public ScrollBars ScrollBarStyle
|
||||
{
|
||||
get => messageTextBox.ScrollBars;
|
||||
set => messageTextBox.ScrollBars = value;
|
||||
}
|
||||
public void SetButtonFocus(DialogResult res)
|
||||
{
|
||||
var maxIndex = System.Math.Max(YesButton.TabIndex, NoButton.TabIndex);
|
||||
var minIndex = System.Math.Min(YesButton.TabIndex, NoButton.TabIndex);
|
||||
|
||||
switch (res)
|
||||
{
|
||||
case DialogResult.No:
|
||||
AcceptButton = NoButton;
|
||||
NoButton.TabIndex = minIndex;
|
||||
YesButton.TabIndex = maxIndex;
|
||||
break;
|
||||
case DialogResult.Yes:
|
||||
default:
|
||||
AcceptButton = YesButton;
|
||||
YesButton.TabIndex = minIndex;
|
||||
NoButton.TabIndex = maxIndex;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
public bool ShowYesNo
|
||||
{
|
||||
get => YesButton.Visible && NoButton.Visible;
|
||||
set
|
||||
{
|
||||
YesButton.Visible = value;
|
||||
NoButton.Visible = value;
|
||||
}
|
||||
}
|
||||
public Size FormSize
|
||||
{
|
||||
get => Size;
|
||||
set
|
||||
{
|
||||
if (value == Size) { return; }
|
||||
//Size oldSize = Size;
|
||||
Size = value;
|
||||
//FormResize(oldSize, Size);
|
||||
}
|
||||
}
|
||||
public bool ShowClose
|
||||
{
|
||||
get => btnClose.Visible;
|
||||
set => btnClose.Visible = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initialize an instance of the <see cref="ScrollingMessageBox"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="message">
|
||||
/// The message <see cref="string"/> to be displayed in the dialog's scroll-enabled
|
||||
/// text field. Note that it does not recognize "\n" as newline; rather use
|
||||
/// Environmenet.Newline.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="caption">
|
||||
/// The caption <see cref="string"/> for the dialog.
|
||||
/// </param>
|
||||
///
|
||||
public ScrollingMessageBox(string message, string caption)
|
||||
{
|
||||
try
|
||||
{
|
||||
SuspendLayout();
|
||||
InitializeComponent();
|
||||
ResumeLayout();
|
||||
|
||||
Text = caption;
|
||||
messageTextBox.Text = message;
|
||||
messageTextBox.Select(0, 0);
|
||||
//this.YesButton.Focus( );
|
||||
KeyPreview = true;
|
||||
KeyDown += new KeyEventHandler(ScrollingMessageBox_KeyDown);
|
||||
|
||||
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem constructing " + GetType().FullName, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the <see cref="ScrollingMessageBox"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="message">
|
||||
/// The message <see cref="string"/> to be displayed in the dialog's scroll-enabled
|
||||
/// text field. Note that it does not recognize "\n" as newline; rather use
|
||||
/// Environmenet.Newline.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="caption">
|
||||
/// The caption <see cref="string"/> for the dialog.
|
||||
/// </param>
|
||||
/// <param name="ico">icon</param> for the dialog
|
||||
///
|
||||
public ScrollingMessageBox(string message, string caption, Icon ico)
|
||||
{
|
||||
try
|
||||
{
|
||||
SuspendLayout();
|
||||
InitializeComponent();
|
||||
ResumeLayout();
|
||||
|
||||
Text = caption;
|
||||
messageTextBox.Text = message;
|
||||
messageTextBox.Select(0, 0);
|
||||
//this.YesButton.Focus();
|
||||
KeyPreview = true;
|
||||
KeyDown += new KeyEventHandler(ScrollingMessageBox_KeyDown);
|
||||
Icon = ico;
|
||||
//this.ResizeBegin += new EventHandler(ScrollingMessageBox_ResizeBegin);
|
||||
//this.ResizeEnd += new EventHandler(ScrollingMessageBox_ResizeEnd);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem constructing " + GetType().FullName, ex);
|
||||
}
|
||||
}
|
||||
/*
|
||||
private Size beforeSize = Size.Empty;
|
||||
void ScrollingMessageBox_ResizeBegin(object sender, EventArgs e)
|
||||
{
|
||||
beforeSize = Size;
|
||||
}
|
||||
|
||||
void ScrollingMessageBox_ResizeEnd(object sender, EventArgs e)
|
||||
{
|
||||
Size afterSize = Size;
|
||||
FormResize(beforeSize, afterSize);
|
||||
}
|
||||
private void FormResize(Size before, Size after)
|
||||
{
|
||||
int xChange = after.Width - before.Width;
|
||||
int yChange = after.Height - before.Height;
|
||||
Size newSize = messageTextBox.Size;
|
||||
newSize.Height += yChange;
|
||||
newSize.Width += xChange;
|
||||
messageTextBox.Size = newSize;
|
||||
//if (btnClose.Visible)
|
||||
//{
|
||||
Point loc = btnClose.Location;
|
||||
loc.Y += yChange;
|
||||
loc.X = ((after.Width - btnClose.Width) / 2);
|
||||
btnClose.Location = loc;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
loc = YesButton.Location;
|
||||
loc.X += xChange / 2;
|
||||
loc.Y += yChange;
|
||||
YesButton.Location = loc;
|
||||
loc = NoButton.Location;
|
||||
loc.X += xChange / 2;
|
||||
loc.Y += yChange;
|
||||
NoButton.Location = loc;
|
||||
//}
|
||||
NoButton.Focus();
|
||||
}*/
|
||||
/// <summary>
|
||||
/// handle the key down for yes and no
|
||||
/// note - this isn't i18N'd, so the keycodes might need to change whenever we do change this
|
||||
/// from just "yes", "no"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ScrollingMessageBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Y)
|
||||
{
|
||||
YesButtonClick();
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
else if (e.KeyCode == Keys.N)
|
||||
{
|
||||
NoButtonClick();
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
e.Handled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for YesButton click events.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="sender">
|
||||
/// The <see cref="object"/> responsible for generating this event.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="e">
|
||||
/// The <see cref="EventArgs"/> for this event.
|
||||
/// </param>
|
||||
///
|
||||
private void YesButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
YesButtonClick();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for NoButton click events.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="sender">
|
||||
/// The <see cref="object"/> responsible for generating this event.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="e">
|
||||
/// The <see cref="EventArgs"/> for this event.
|
||||
/// </param>
|
||||
///
|
||||
private void NoButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
NoButtonClick();
|
||||
}
|
||||
/// <summary>
|
||||
/// do yes
|
||||
/// </summary>
|
||||
private void YesButtonClick()
|
||||
{
|
||||
DialogResult = DialogResult.Yes;
|
||||
Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// do no
|
||||
/// </summary>
|
||||
private void NoButtonClick()
|
||||
{
|
||||
DialogResult = DialogResult.No;
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
private void TimerTick(object sender, EventArgs e)
|
||||
{
|
||||
BeginInvoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
btnClose.Enabled = true;
|
||||
YesButton.Enabled = true;
|
||||
NoButton.Enabled = true;
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
public new DialogResult ShowDialog()
|
||||
{
|
||||
CheckTimer();
|
||||
return base.ShowDialog();
|
||||
}
|
||||
public new DialogResult ShowDialog(IWin32Window owner)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
return (DialogResult)Invoke(new Func<IWin32Window, DialogResult>((DialogResult) => ShowDialog(owner)));
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckTimer();
|
||||
return base.ShowDialog(owner);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckTimer()
|
||||
{
|
||||
if (TimeWait > 0)
|
||||
{
|
||||
_TimeDelay.Interval = TimeWait;
|
||||
_TimeDelay.Start();
|
||||
btnClose.Enabled = false;
|
||||
YesButton.Enabled = false;
|
||||
NoButton.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* ExceptionalForm.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// A Windows-style Form with it's own exception type.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Sample usage:
|
||||
/// public class A : ExceptionalForm
|
||||
/// {
|
||||
/// public void ScrewItUp( )
|
||||
/// {
|
||||
/// private bool error = true;
|
||||
/// if ( error ) throw new A.Exception( "Class A-specific screwup." );
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// ...
|
||||
///
|
||||
/// try
|
||||
/// {
|
||||
/// A.ScrewItUp( );
|
||||
/// B.ScrewItUp( );
|
||||
/// C.ScrewItUp( );
|
||||
/// }
|
||||
/// catch ( A.Exception ex )
|
||||
/// {
|
||||
/// // Can pick A's exceptions out of a crowd, or not and just treat it
|
||||
/// // polymorphically as a System.Exception.
|
||||
/// }
|
||||
/// </remarks>
|
||||
///
|
||||
[global::System.Serializable]
|
||||
public class ExceptionalForm : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the ExceptionForm class.
|
||||
/// </summary>
|
||||
public ExceptionalForm()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A representation of the DerivedClass.Exception class.
|
||||
/// </summary>
|
||||
public class Exception : ApplicationException
|
||||
{
|
||||
/// <summary>
|
||||
/// create a <see cref="ExceptionalForm.Exception" />
|
||||
/// </summary>
|
||||
public Exception() { }
|
||||
/// <summary>
|
||||
/// create a <see cref="ExceptionalForm.Exception" /> with
|
||||
/// a description
|
||||
/// </summary>
|
||||
/// <param name="msg">Description of error</param>
|
||||
public Exception(string msg) : base(msg) { }
|
||||
/// <summary>
|
||||
/// create a <see cref="ExceptionalForm.Exception" /> with
|
||||
/// a description and a reference to the exception causing the error
|
||||
/// </summary>
|
||||
/// <param name="msg">Description of error</param>
|
||||
/// <param name="innerEx">exception causing the error</param>
|
||||
public Exception(string msg, System.Exception innerEx) : base(msg, innerEx) { }
|
||||
protected Exception(
|
||||
System.Runtime.Serialization.SerializationInfo info,
|
||||
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
namespace DTS.Utilities
|
||||
{
|
||||
public static class DTSChecksum
|
||||
{
|
||||
#region PrivateVariables
|
||||
private static readonly short[] _oddparity = {0, 1, 1, 0, 1, 0, 0, 1,
|
||||
1, 0, 0, 1, 0, 1, 1, 0 };
|
||||
|
||||
private static readonly ushort[] _crc_table =
|
||||
{
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5,
|
||||
0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b,
|
||||
0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210,
|
||||
0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
||||
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c,
|
||||
0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401,
|
||||
0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b,
|
||||
0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
|
||||
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6,
|
||||
0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738,
|
||||
0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5,
|
||||
0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
|
||||
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969,
|
||||
0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96,
|
||||
0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc,
|
||||
0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
|
||||
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03,
|
||||
0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd,
|
||||
0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6,
|
||||
0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
|
||||
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a,
|
||||
0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb,
|
||||
0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1,
|
||||
0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
|
||||
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c,
|
||||
0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2,
|
||||
0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb,
|
||||
0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
|
||||
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447,
|
||||
0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8,
|
||||
0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2,
|
||||
0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
|
||||
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9,
|
||||
0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827,
|
||||
0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c,
|
||||
0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
|
||||
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0,
|
||||
0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d,
|
||||
0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07,
|
||||
0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
|
||||
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba,
|
||||
0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74,
|
||||
0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
||||
};
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Computes the 16-bit CRC of the n passed in data bytes. N should be
|
||||
/// even(if it is not, the last byte will not get included in the
|
||||
/// computation). The initial_crc is the value to seed the computation
|
||||
/// from - normally it will be set to 0.
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="data">the unsigned character buffer of which to compute the CRC16 </param>
|
||||
/// <param name="initial_crc">the CRC16 value to seed the computation with</param>
|
||||
/// <returns>the updated CRC16 starting with initial_crc and computed over n data bytes</returns>
|
||||
public static ushort GetCRC16(byte[] data, ushort initial_crc = 0xFFFF)
|
||||
{
|
||||
|
||||
ushort crc = 0;//initial_crc98765430.
|
||||
int i;
|
||||
|
||||
for (i = 0; i < data.Length; i += 2)
|
||||
{
|
||||
crc = Math_DoCRC16Step((ushort)((data[i + 1] << 8) | data[i]), crc);
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
#region PrivateFunctions
|
||||
/**
|
||||
* Computes the 16-bit CRC of the n passed in data bytes. CCITT implementation
|
||||
* N should be
|
||||
* even (if it is not, the last byte will not get included in the
|
||||
* computation). The initial_crc is the value to seed the computation
|
||||
* from - normally it will be set to 0.
|
||||
*
|
||||
* @param data the unsigned character buffer of which to compute the CRC16
|
||||
* @param n the number of bytes in data (must be even!)
|
||||
* @param initial_crc the CRC16 value to seed the computation with
|
||||
*
|
||||
* @return the updated CRC16 starting with initial_crc and computed over
|
||||
* n data bytes
|
||||
*/
|
||||
/* Slightly changed to handle array of bytes */
|
||||
private static ushort CalculateCRCCCITT(byte[] data, ushort initial_crc)
|
||||
{
|
||||
|
||||
ushort crc = initial_crc;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < data.Length; i += 2)
|
||||
{
|
||||
crc = Math_DoCRCCCITTStep((ushort)((data[i + 1] << 8) | data[i]), crc);
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
private static ushort Math_DoCRC16Step(ushort cdata, ushort current_crc)
|
||||
{
|
||||
cdata = (ushort)((cdata ^ (current_crc & 0xff)) & 0xff);
|
||||
current_crc >>= 8;
|
||||
|
||||
if (0 != (_oddparity[cdata & 0xf] ^ _oddparity[cdata >> 4]))
|
||||
current_crc ^= 0xc001;
|
||||
|
||||
cdata <<= 6;
|
||||
current_crc ^= cdata;
|
||||
cdata <<= 1;
|
||||
current_crc ^= cdata;
|
||||
|
||||
return current_crc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static ushort Math_DoCRCCCITTStep(ushort cdata, ushort current_crc)
|
||||
{
|
||||
return (ushort)((ushort)(current_crc << 8) ^ _crc_table[(ushort)(((ushort)(current_crc >> 8) ^ cdata) & 0xFF)]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MD5 hash of a byte array
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] GetMD5(byte[] data)
|
||||
{
|
||||
System.Security.Cryptography.MD5 md5Hash = System.Security.Cryptography.MD5.Create();
|
||||
return md5Hash.ComputeHash(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert a DateTime to Unix Time. No attempt is made to correct for time zone/localities.
|
||||
/// </summary>
|
||||
public class Time
|
||||
{
|
||||
public static UInt32 DateTimeToUnixTimestamp(DateTime dateTime)
|
||||
{
|
||||
var start = new DateTime(1970, 1, 1);
|
||||
var span = dateTime - start;
|
||||
|
||||
return (UInt32)span.TotalSeconds;
|
||||
}
|
||||
|
||||
public static UInt32 CurrentUtcUnixTimestamp()
|
||||
{
|
||||
var span = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
|
||||
|
||||
return (UInt32)span.TotalSeconds;
|
||||
}
|
||||
|
||||
public static UInt32 CurrentLocalUnixTimestamp()
|
||||
{
|
||||
var span = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Local));
|
||||
|
||||
return (UInt32)span.TotalSeconds;
|
||||
}
|
||||
|
||||
public static DateTime ToDateTime(UInt32 seconds)
|
||||
{
|
||||
return new DateTime(1970, 1, 1).AddSeconds(seconds);
|
||||
}
|
||||
|
||||
public static UInt32 ToUnixTime(DateTime dateTime)
|
||||
{
|
||||
var start = new DateTime(1970, 1, 1);
|
||||
var span = dateTime - start;
|
||||
|
||||
return (UInt32)span.TotalSeconds;
|
||||
}
|
||||
|
||||
public static bool IsBeginningOfTime(DateTime dateTime)
|
||||
{
|
||||
var start = new DateTime(1970, 1, 1);
|
||||
var span = dateTime - start;
|
||||
|
||||
return (0 == span.TotalSeconds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,725 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DTS.Common.Utilities.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DTS.Utilities.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to yyyy-MM-dd HH:mm:ss.fff.
|
||||
/// </summary>
|
||||
internal static string APILogging_DateTime_Format {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_DateTime_Format", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}An {1}exception of type: {2} occurred.
|
||||
/// </summary>
|
||||
internal static string APILogging_ExceptionFormatter_ExceptionOfTypeOccurredString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_ExceptionFormatter_ExceptionOfTypeOccurredString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to inner .
|
||||
/// </summary>
|
||||
internal static string APILogging_ExceptionFormatter_InnerIndicationString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_ExceptionFormatter_InnerIndicationString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to .
|
||||
/// </summary>
|
||||
internal static string APILogging_ExceptionFormatter_NonInnerIndicationString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_ExceptionFormatter_NonInnerIndicationString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}Message: {1}.
|
||||
/// </summary>
|
||||
internal static string APILogging_ExceptionMessageDisplayString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_ExceptionMessageDisplayString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to === .
|
||||
/// </summary>
|
||||
internal static string APILogging_LevelSeperatorString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_LevelSeperatorString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ========================================.
|
||||
/// </summary>
|
||||
internal static string APILogging_LogEntrySeperatorString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_LogEntrySeperatorString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to APILogger.LogException: Writer delegate is null.
|
||||
/// </summary>
|
||||
internal static string APILogging_LogException_NullWriterDelegateString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_LogException_NullWriterDelegateString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}Module: {1}, Name: {2}.
|
||||
/// </summary>
|
||||
internal static string APILogging_ModuleNameDisplayString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_ModuleNameDisplayString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to APILogger.LogString: Writer delegate is null.
|
||||
/// </summary>
|
||||
internal static string APILogging_NullWriterDelegateString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_NullWriterDelegateString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}StackTrace: {1}.
|
||||
/// </summary>
|
||||
internal static string APILogging_StackTraceDisplayString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_StackTraceDisplayString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to applicationSettings.
|
||||
/// </summary>
|
||||
internal static string ApplicationSettings {
|
||||
get {
|
||||
return ResourceManager.GetString("ApplicationSettings", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to cannot use null attribute value extraction method reference.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_AttributeCoder_NullAttributeValueExtractionMethodReferenceString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_AttributeCoder_NullAttributeValueExtractionMethodReferenceString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem decoding attribute value.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_DecodeAttributeExceptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_DecodeAttributeExceptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem decoding attribute values.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_DecodeAttributesExceptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_DecodeAttributesExceptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem dehashing attribute value.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_DehashAttributeValue_DehashAttributeValueExceptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_DehashAttributeValue_DehashAttributeValueExceptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to unable to match attribute value with an actual target type.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_DehashAttributeValue_UnableToMatchAttributeValueWithTargetString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_DehashAttributeValue_UnableToMatchAttributeValueWithTargetString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem encoding attribute value.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_EncodeAttributeExceptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_EncodeAttributeExceptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to no attributes of specified type found on designated target.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_NoTypeAttributesFoundOnTargetString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_NoTypeAttributesFoundOnTargetString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to unable to find unique target type mapping for the specified attribute value.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_UnableToFindTargetTypeMappingString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_UnableToFindTargetTypeMappingString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to because.
|
||||
/// </summary>
|
||||
internal static string Exceptional_GenerateMessageFromExceptionTree_BecauseString {
|
||||
get {
|
||||
return ResourceManager.GetString("Exceptional_GenerateMessageFromExceptionTree_BecauseString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}{1}.
|
||||
/// </summary>
|
||||
internal static string Exceptional_GenerateMessageFromExceptionTree_EndsWithFormatString {
|
||||
get {
|
||||
return ResourceManager.GetString("Exceptional_GenerateMessageFromExceptionTree_EndsWithFormatString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ..
|
||||
/// </summary>
|
||||
internal static string Exceptional_GenerateMessageFromExceptionTree_ErrorTextTerminatorString {
|
||||
get {
|
||||
return ResourceManager.GetString("Exceptional_GenerateMessageFromExceptionTree_ErrorTextTerminatorString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}{1}{2}.
|
||||
/// </summary>
|
||||
internal static string Exceptional_GenerateMessageFromExceptionTree_MessageFormatString {
|
||||
get {
|
||||
return ResourceManager.GetString("Exceptional_GenerateMessageFromExceptionTree_MessageFormatString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem constructing {0}.
|
||||
/// </summary>
|
||||
internal static string Generic_EncounteredProblemConstructingClassString {
|
||||
get {
|
||||
return ResourceManager.GetString("Generic_EncounteredProblemConstructingClassString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <null>.
|
||||
/// </summary>
|
||||
internal static string Generic_NullIndicatorString {
|
||||
get {
|
||||
return ResourceManager.GetString("Generic_NullIndicatorString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Warning: DataPRO.exe.config was not updated because config settings from new version of DataPRO could not be found: {0}; {1}.
|
||||
/// </summary>
|
||||
internal static string NewSettingsCouldNotBeFound {
|
||||
get {
|
||||
return ResourceManager.GetString("NewSettingsCouldNotBeFound", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Warning: DataPRO.exe.config was not updated because config settings from new version of DataPRO could not be processed..
|
||||
/// </summary>
|
||||
internal static string NewSettingsCouldNotBeProcessed {
|
||||
get {
|
||||
return ResourceManager.GetString("NewSettingsCouldNotBeProcessed", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to proposed value "{0}" is not a power of two.
|
||||
/// </summary>
|
||||
internal static string PowerOfTwoProperty_GetInvalidValueDescription_ProposedValueIsNotPowerOf2String {
|
||||
get {
|
||||
return ResourceManager.GetString("PowerOfTwoProperty_GetInvalidValueDescription_ProposedValueIsNotPowerOf2String", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting invalid value description.
|
||||
/// </summary>
|
||||
internal static string PowerOfTwoProperty_GetInvalidValueDescription_UnableToGetDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("PowerOfTwoProperty_GetInvalidValueDescription_UnableToGetDescriptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem determining whether or not "{0}" is a power of two.
|
||||
/// </summary>
|
||||
internal static string PowerOfTwoProperty_IsPowerOf2_UnableToDeterminePowerOf2nessString {
|
||||
get {
|
||||
return ResourceManager.GetString("PowerOfTwoProperty_IsPowerOf2_UnableToDeterminePowerOf2nessString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem determing power of two-validity of "{0} ".
|
||||
/// </summary>
|
||||
internal static string PowerOfTwoProperty_IsValidValue_UnableToDetermineValidityString {
|
||||
get {
|
||||
return ResourceManager.GetString("PowerOfTwoProperty_IsValidValue_UnableToDetermineValidityString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to property {0}cannot be set to {1}.
|
||||
/// </summary>
|
||||
internal static string Property_GetInvalidValueDescription_CouldNotSetToValueString {
|
||||
get {
|
||||
return ResourceManager.GetString("Property_GetInvalidValueDescription_CouldNotSetToValueString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem generating invalid valid description.
|
||||
/// </summary>
|
||||
internal static string Property_GetInvalidValueDescription_GetDescriptionFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("Property_GetInvalidValueDescription_GetDescriptionFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting property {0}value.
|
||||
/// </summary>
|
||||
internal static string Property_Value_CouldNotGetValueString {
|
||||
get {
|
||||
return ResourceManager.GetString("Property_Value_CouldNotGetValueString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem setting property {0}value.
|
||||
/// </summary>
|
||||
internal static string Property_Value_CouldNotSetValueString {
|
||||
get {
|
||||
return ResourceManager.GetString("Property_Value_CouldNotSetValueString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to property has not been initialized.
|
||||
/// </summary>
|
||||
internal static string Property_Value_NotInitializedString {
|
||||
get {
|
||||
return ResourceManager.GetString("Property_Value_NotInitializedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem generating invalid value description for value "{0}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_GetInvalidValueDescription_GetDescriptionFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_GetInvalidValueDescription_GetDescriptionFailedStri" +
|
||||
"ng", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is greater than the maximum allowable value of "{1}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_GetInvalidValueDescription_MaximumDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_GetInvalidValueDescription_MaximumDescriptionString" +
|
||||
"", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is less than the minimum allowable value of "{1}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_GetInvalidValueDescription_MinimumDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_GetInvalidValueDescription_MinimumDescriptionString" +
|
||||
"", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is valid.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_GetInvalidValueDescription_ValidValueDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_GetInvalidValueDescription_ValidValueDescriptionStr" +
|
||||
"ing", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem determing range-restricted validity of "{0}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_IsValidValue_UnableToDetermineValidityString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_IsValidValue_UnableToDetermineValidityString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting maximum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_MaximumValue_GetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_MaximumValue_GetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem setting maximum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_MaximumValue_SetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_MaximumValue_SetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting minimum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_MinimumValue_GetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_MinimumValue_GetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem setting minimum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_MinimumValue_SetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_MinimumValue_SetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to minimum value ({0}) must be less than or equal to maximum value ({1}).
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_MinMustBeLessThanMaxString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_MinMustBeLessThanMaxString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem generating invalid value description for value "{0}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_GetInvalidValueDescription_GetDescriptionFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_GetInvalidValueDescription_GetDescriptionFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is greater than the maximum allowable value of "{1}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_GetInvalidValueDescription_MaximumDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_GetInvalidValueDescription_MaximumDescriptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is less than the minimum allowable value of "{1}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_GetInvalidValueDescription_MinimumDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_GetInvalidValueDescription_MinimumDescriptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is valid.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_GetInvalidValueDescription_ValidValueDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_GetInvalidValueDescription_ValidValueDescriptionString" +
|
||||
"", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem determing range-restricted validity of "{0}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_IsValidValue_UnableToDetermineValidityString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_IsValidValue_UnableToDetermineValidityString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting maximum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_MaximumValue_GetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_MaximumValue_GetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem setting maximum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_MaximumValue_SetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_MaximumValue_SetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting minimum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_MinimumValue_GetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_MinimumValue_GetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem setting minimum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_MinimumValue_SetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_MinimumValue_SetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to minimum value ({0}) must be less than or equal to maximum value ({1}).
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_MinMustBeLessThanMaxString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_MinMustBeLessThanMaxString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to DataPRO.exe.
|
||||
/// </summary>
|
||||
internal static string RegistryDataPROExe {
|
||||
get {
|
||||
return ResourceManager.GetString("RegistryDataPROExe", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.AddMessage: Logger is not running, call Start first.
|
||||
/// </summary>
|
||||
internal static string TextLogger_AddMessage_LoggerNotRunningString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_AddMessage_LoggerNotRunningString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.dtor: Writing thread didn't go to Exited state, it's in {0}.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Dispose_WriteThreadExitFailureString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Dispose_WriteThreadExitFailureString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.dtor: Writing thread didn't respond in time.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Dispose_WriteThreadResponseTimeoutString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Dispose_WriteThreadResponseTimeoutString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.AddMessage: Logger is already running, call Stop first.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Start_LoggerAlreadyRunningString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Start_LoggerAlreadyRunningString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Start: filename can't be null or blank.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Start_NullEmptyFilenameString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Start_NullEmptyFilenameString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Start: folder can't be null or blank.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Start_NullEmptyFolderString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Start_NullEmptyFolderString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Start: Writing thread didn't respond in time.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Start_WriteThreadResponseTimeoutString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Start_WriteThreadResponseTimeoutString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Start: Writing thread didn't go to Started state, it's in {0}.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Start_WriteThreadStartFailureString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Start_WriteThreadStartFailureString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Stop: Logger is not running, call Start first.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Stop_LoggerNotRunningString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Stop_LoggerNotRunningString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Stop: Writing thread didn't respond in time.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Stop_WriteThreadResponseTimeoutString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Stop_WriteThreadResponseTimeoutString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Stop: Writing thread didn't go to Stopped state, it's in {0}.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Stop_WriteThreadStopFailureString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Stop_WriteThreadStopFailureString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger: Can't enqueue Writer.
|
||||
/// </summary>
|
||||
internal static string TextLogger_TextLogger_EnqueueWriterFailureString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_TextLogger_EnqueueWriterFailureString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger: Callback can't be null.
|
||||
/// </summary>
|
||||
internal static string TextLogger_TextLogger_NullCallbackString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_TextLogger_NullCallbackString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.ctor: Writing thread didn't start in time.
|
||||
/// </summary>
|
||||
internal static string TextLogger_TextLogger_WriteThreadStartTimeoutString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_TextLogger_WriteThreadStartTimeoutString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Writer: invalid command {0}.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Writer_InvalidCommandString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Writer_InvalidCommandString", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* ExceptionalUserControl.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// A version of <see cref="System.Windows.Forms.UserControl"/> that provides its own exception type.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Sample usage:
|
||||
/// public class A : ExceptionalUserControl
|
||||
/// {
|
||||
/// public void ScrewItUp( )
|
||||
/// {
|
||||
/// private bool error = true;
|
||||
/// if ( error ) throw new A.Exception( "Class A-specific screwup." );
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// ...
|
||||
///
|
||||
/// try
|
||||
/// {
|
||||
/// A.ScrewItUp( );
|
||||
/// B.ScrewItUp( );
|
||||
/// C.ScrewItUp( );
|
||||
/// }
|
||||
/// catch ( A.Exception ex )
|
||||
/// {
|
||||
/// // Can pick A's exceptions out of a crowd, or not and just treat it
|
||||
/// // polymorphically as a System.Exception.
|
||||
/// }
|
||||
/// </remarks>
|
||||
///
|
||||
public class ExceptionalUserControl : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the ExceptionalUserControl class.
|
||||
/// </summary>
|
||||
public ExceptionalUserControl()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A representation of the DerivedClass.Exception class.
|
||||
/// </summary>
|
||||
[global::System.Serializable]
|
||||
public class Exception : ApplicationException
|
||||
{
|
||||
/// <summary>
|
||||
/// create a <see cref="ExceptionalUserControl.Exception" />
|
||||
/// </summary>
|
||||
public Exception() { }
|
||||
/// <summary>
|
||||
/// create a <see cref="ExceptionalUserControl.Exception" /> with a description
|
||||
/// </summary>
|
||||
/// <param name="msg">Description of error</param>
|
||||
public Exception(string msg) : base(msg) { }
|
||||
/// <summary>
|
||||
/// create a <see cref="ExceptionalUserControl.Exception" /> with a description
|
||||
/// and a reference to the exception causing the error
|
||||
/// </summary>
|
||||
/// <param name="msg">Description of error</param>
|
||||
/// <param name="innerEx">exception causing error</param>
|
||||
public Exception(string msg, System.Exception innerEx) : base(msg, innerEx) { }
|
||||
protected Exception(
|
||||
System.Runtime.Serialization.SerializationInfo info,
|
||||
System.Runtime.Serialization.StreamingContext context)
|
||||
: base(info, context) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,689 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DTS.Common.Utilities.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DTS.Utilities.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to yyyy-MM-dd HH:mm:ss.fff.
|
||||
/// </summary>
|
||||
internal static string APILogging_DateTime_Format {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_DateTime_Format", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}An {1}exception of type: {2} occurred.
|
||||
/// </summary>
|
||||
internal static string APILogging_ExceptionFormatter_ExceptionOfTypeOccurredString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_ExceptionFormatter_ExceptionOfTypeOccurredString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to inner .
|
||||
/// </summary>
|
||||
internal static string APILogging_ExceptionFormatter_InnerIndicationString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_ExceptionFormatter_InnerIndicationString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to .
|
||||
/// </summary>
|
||||
internal static string APILogging_ExceptionFormatter_NonInnerIndicationString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_ExceptionFormatter_NonInnerIndicationString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}Message: {1}.
|
||||
/// </summary>
|
||||
internal static string APILogging_ExceptionMessageDisplayString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_ExceptionMessageDisplayString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to === .
|
||||
/// </summary>
|
||||
internal static string APILogging_LevelSeperatorString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_LevelSeperatorString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ========================================.
|
||||
/// </summary>
|
||||
internal static string APILogging_LogEntrySeperatorString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_LogEntrySeperatorString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to APILogger.LogException: Writer delegate is null.
|
||||
/// </summary>
|
||||
internal static string APILogging_LogException_NullWriterDelegateString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_LogException_NullWriterDelegateString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}Module: {1}, Name: {2}.
|
||||
/// </summary>
|
||||
internal static string APILogging_ModuleNameDisplayString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_ModuleNameDisplayString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to APILogger.LogString: Writer delegate is null.
|
||||
/// </summary>
|
||||
internal static string APILogging_NullWriterDelegateString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_NullWriterDelegateString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}StackTrace: {1}.
|
||||
/// </summary>
|
||||
internal static string APILogging_StackTraceDisplayString {
|
||||
get {
|
||||
return ResourceManager.GetString("APILogging_StackTraceDisplayString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to cannot use null attribute value extraction method reference.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_AttributeCoder_NullAttributeValueExtractionMethodReferenceString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_AttributeCoder_NullAttributeValueExtractionMethodReferenceString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem decoding attribute value.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_DecodeAttributeExceptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_DecodeAttributeExceptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem decoding attribute values.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_DecodeAttributesExceptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_DecodeAttributesExceptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem dehashing attribute value.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_DehashAttributeValue_DehashAttributeValueExceptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_DehashAttributeValue_DehashAttributeValueExceptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to unable to match attribute value with an actual target type.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_DehashAttributeValue_UnableToMatchAttributeValueWithTargetString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_DehashAttributeValue_UnableToMatchAttributeValueWithTargetString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem encoding attribute value.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_EncodeAttributeExceptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_EncodeAttributeExceptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to no attributes of specified type found on designated target.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_NoTypeAttributesFoundOnTargetString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_NoTypeAttributesFoundOnTargetString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to unable to find unique target type mapping for the specified attribute value.
|
||||
/// </summary>
|
||||
internal static string AttributeCoder_UnableToFindTargetTypeMappingString {
|
||||
get {
|
||||
return ResourceManager.GetString("AttributeCoder_UnableToFindTargetTypeMappingString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to because.
|
||||
/// </summary>
|
||||
internal static string Exceptional_GenerateMessageFromExceptionTree_BecauseString {
|
||||
get {
|
||||
return ResourceManager.GetString("Exceptional_GenerateMessageFromExceptionTree_BecauseString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}{1}.
|
||||
/// </summary>
|
||||
internal static string Exceptional_GenerateMessageFromExceptionTree_EndsWithFormatString {
|
||||
get {
|
||||
return ResourceManager.GetString("Exceptional_GenerateMessageFromExceptionTree_EndsWithFormatString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ..
|
||||
/// </summary>
|
||||
internal static string Exceptional_GenerateMessageFromExceptionTree_ErrorTextTerminatorString {
|
||||
get {
|
||||
return ResourceManager.GetString("Exceptional_GenerateMessageFromExceptionTree_ErrorTextTerminatorString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0}{1}{2}.
|
||||
/// </summary>
|
||||
internal static string Exceptional_GenerateMessageFromExceptionTree_MessageFormatString {
|
||||
get {
|
||||
return ResourceManager.GetString("Exceptional_GenerateMessageFromExceptionTree_MessageFormatString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem constructing {0}.
|
||||
/// </summary>
|
||||
internal static string Generic_EncounteredProblemConstructingClassString {
|
||||
get {
|
||||
return ResourceManager.GetString("Generic_EncounteredProblemConstructingClassString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <null>.
|
||||
/// </summary>
|
||||
internal static string Generic_NullIndicatorString {
|
||||
get {
|
||||
return ResourceManager.GetString("Generic_NullIndicatorString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to proposed value "{0}" is not a power of two.
|
||||
/// </summary>
|
||||
internal static string PowerOfTwoProperty_GetInvalidValueDescription_ProposedValueIsNotPowerOf2String {
|
||||
get {
|
||||
return ResourceManager.GetString("PowerOfTwoProperty_GetInvalidValueDescription_ProposedValueIsNotPowerOf2String", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting invalid value description.
|
||||
/// </summary>
|
||||
internal static string PowerOfTwoProperty_GetInvalidValueDescription_UnableToGetDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("PowerOfTwoProperty_GetInvalidValueDescription_UnableToGetDescriptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem determining whether or not "{0}" is a power of two.
|
||||
/// </summary>
|
||||
internal static string PowerOfTwoProperty_IsPowerOf2_UnableToDeterminePowerOf2nessString {
|
||||
get {
|
||||
return ResourceManager.GetString("PowerOfTwoProperty_IsPowerOf2_UnableToDeterminePowerOf2nessString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem determing power of two-validity of "{0} ".
|
||||
/// </summary>
|
||||
internal static string PowerOfTwoProperty_IsValidValue_UnableToDetermineValidityString {
|
||||
get {
|
||||
return ResourceManager.GetString("PowerOfTwoProperty_IsValidValue_UnableToDetermineValidityString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to property {0}cannot be set to {1}.
|
||||
/// </summary>
|
||||
internal static string Property_GetInvalidValueDescription_CouldNotSetToValueString {
|
||||
get {
|
||||
return ResourceManager.GetString("Property_GetInvalidValueDescription_CouldNotSetToValueString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem generating invalid valid description.
|
||||
/// </summary>
|
||||
internal static string Property_GetInvalidValueDescription_GetDescriptionFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("Property_GetInvalidValueDescription_GetDescriptionFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting property {0}value.
|
||||
/// </summary>
|
||||
internal static string Property_Value_CouldNotGetValueString {
|
||||
get {
|
||||
return ResourceManager.GetString("Property_Value_CouldNotGetValueString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem setting property {0}value.
|
||||
/// </summary>
|
||||
internal static string Property_Value_CouldNotSetValueString {
|
||||
get {
|
||||
return ResourceManager.GetString("Property_Value_CouldNotSetValueString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to property has not been initialized.
|
||||
/// </summary>
|
||||
internal static string Property_Value_NotInitializedString {
|
||||
get {
|
||||
return ResourceManager.GetString("Property_Value_NotInitializedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem generating invalid value description for value "{0}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_GetInvalidValueDescription_GetDescriptionFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_GetInvalidValueDescription_GetDescriptionFailedStri" +
|
||||
"ng", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is greater than the maximum allowable value of "{1}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_GetInvalidValueDescription_MaximumDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_GetInvalidValueDescription_MaximumDescriptionString" +
|
||||
"", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is less than the minimum allowable value of "{1}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_GetInvalidValueDescription_MinimumDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_GetInvalidValueDescription_MinimumDescriptionString" +
|
||||
"", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is valid.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_GetInvalidValueDescription_ValidValueDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_GetInvalidValueDescription_ValidValueDescriptionStr" +
|
||||
"ing", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem determing range-restricted validity of "{0}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_IsValidValue_UnableToDetermineValidityString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_IsValidValue_UnableToDetermineValidityString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting maximum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_MaximumValue_GetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_MaximumValue_GetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem setting maximum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_MaximumValue_SetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_MaximumValue_SetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting minimum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_MinimumValue_GetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_MinimumValue_GetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem setting minimum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_MinimumValue_SetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_MinimumValue_SetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to minimum value ({0}) must be less than or equal to maximum value ({1}).
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedDoubleProperty_MinMustBeLessThanMaxString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedDoubleProperty_MinMustBeLessThanMaxString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem generating invalid value description for value "{0}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_GetInvalidValueDescription_GetDescriptionFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_GetInvalidValueDescription_GetDescriptionFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is greater than the maximum allowable value of "{1}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_GetInvalidValueDescription_MaximumDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_GetInvalidValueDescription_MaximumDescriptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is less than the minimum allowable value of "{1}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_GetInvalidValueDescription_MinimumDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_GetInvalidValueDescription_MinimumDescriptionString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to the specified value "{0}" is valid.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_GetInvalidValueDescription_ValidValueDescriptionString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_GetInvalidValueDescription_ValidValueDescriptionString" +
|
||||
"", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem determing range-restricted validity of "{0}".
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_IsValidValue_UnableToDetermineValidityString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_IsValidValue_UnableToDetermineValidityString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting maximum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_MaximumValue_GetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_MaximumValue_GetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem setting maximum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_MaximumValue_SetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_MaximumValue_SetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem getting minimum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_MinimumValue_GetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_MinimumValue_GetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to encountered problem setting minimum range value.
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_MinimumValue_SetValueFailedString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_MinimumValue_SetValueFailedString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to minimum value ({0}) must be less than or equal to maximum value ({1}).
|
||||
/// </summary>
|
||||
internal static string RangeRestrictedIntProperty_MinMustBeLessThanMaxString {
|
||||
get {
|
||||
return ResourceManager.GetString("RangeRestrictedIntProperty_MinMustBeLessThanMaxString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.AddMessage: Logger is not running, call Start first.
|
||||
/// </summary>
|
||||
internal static string TextLogger_AddMessage_LoggerNotRunningString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_AddMessage_LoggerNotRunningString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.dtor: Writing thread didn't go to Exited state, it's in {0}.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Dispose_WriteThreadExitFailureString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Dispose_WriteThreadExitFailureString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.dtor: Writing thread didn't respond in time.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Dispose_WriteThreadResponseTimeoutString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Dispose_WriteThreadResponseTimeoutString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.AddMessage: Logger is already running, call Stop first.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Start_LoggerAlreadyRunningString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Start_LoggerAlreadyRunningString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Start: filename can't be null or blank.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Start_NullEmptyFilenameString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Start_NullEmptyFilenameString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Start: folder can't be null or blank.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Start_NullEmptyFolderString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Start_NullEmptyFolderString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Start: Writing thread didn't respond in time.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Start_WriteThreadResponseTimeoutString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Start_WriteThreadResponseTimeoutString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Start: Writing thread didn't go to Started state, it's in {0}.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Start_WriteThreadStartFailureString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Start_WriteThreadStartFailureString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Stop: Logger is not running, call Start first.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Stop_LoggerNotRunningString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Stop_LoggerNotRunningString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Stop: Writing thread didn't respond in time.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Stop_WriteThreadResponseTimeoutString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Stop_WriteThreadResponseTimeoutString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Stop: Writing thread didn't go to Stopped state, it's in {0}.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Stop_WriteThreadStopFailureString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Stop_WriteThreadStopFailureString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger: Can't enqueue Writer.
|
||||
/// </summary>
|
||||
internal static string TextLogger_TextLogger_EnqueueWriterFailureString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_TextLogger_EnqueueWriterFailureString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger: Callback can't be null.
|
||||
/// </summary>
|
||||
internal static string TextLogger_TextLogger_NullCallbackString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_TextLogger_NullCallbackString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.ctor: Writing thread didn't start in time.
|
||||
/// </summary>
|
||||
internal static string TextLogger_TextLogger_WriteThreadStartTimeoutString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_TextLogger_WriteThreadStartTimeoutString", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TextLogger.Writer: invalid command {0}.
|
||||
/// </summary>
|
||||
internal static string TextLogger_Writer_InvalidCommandString {
|
||||
get {
|
||||
return ResourceManager.GetString("TextLogger_Writer_InvalidCommandString", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* DiskUtility.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of handy disk-related methods.
|
||||
/// </summary>
|
||||
public class DiskUtility : Exceptional
|
||||
{
|
||||
/// <summary>
|
||||
/// substitutes doubles from a file into the list of doubles starting at 0 and going until either the list is out of numbers
|
||||
/// or the file is
|
||||
/// originally created for 29654 dp 4.0 476 3D IRTRACC DATA does not match expected data when injecting dc input per test steps
|
||||
/// </summary>
|
||||
/// <param name="list">list to substitute values into, this as a ref to make it obvious it will be modified</param>
|
||||
/// <param name="fileName">file to read values from</param>
|
||||
public static void ReplaceDataIfNeeded(ref List<double> list, string fileName)
|
||||
{
|
||||
if (!File.Exists(fileName)) { return; }
|
||||
var lines = File.ReadAllLines(fileName);
|
||||
|
||||
for (var i = 0; i < list.Count && i < lines.Length; i++)
|
||||
{
|
||||
if (double.TryParse(lines[i], out var dTemp))
|
||||
{
|
||||
list[i] = dTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// just a helper function to translates bytes to a more readable string
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetHumanReadableBytes(ulong bytes)
|
||||
{
|
||||
var bytesReadable = string.Format("{0} bytes", bytes);
|
||||
if (bytes > 1073741824)
|
||||
{
|
||||
bytesReadable = string.Format("{0:##.##} GB", bytes / 1073741824.0);
|
||||
}
|
||||
else if (bytes > 1048576)
|
||||
{
|
||||
bytesReadable = string.Format("{0:##.##} MB", bytes / 1048576.0);
|
||||
}
|
||||
else if (bytes > 1024)
|
||||
{
|
||||
bytesReadable = string.Format("{0:##.##} KB", (double)bytes / 1024);
|
||||
}
|
||||
return bytesReadable;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// checks to see if a string contains illegal characters for file and/or path names
|
||||
/// </summary>
|
||||
/// <param name="nameToValidate"></param>
|
||||
/// <returns></returns>
|
||||
public static bool ValidateFileAndPathNameChars(string nameToValidate)
|
||||
{
|
||||
var bValid = true;
|
||||
var name = nameToValidate;
|
||||
if (name.Trim().Length < 1) { bValid = false; }
|
||||
foreach (var invalidChar in Path.GetInvalidFileNameChars())
|
||||
if (name.Contains(invalidChar)) { bValid = false; }
|
||||
foreach (var invalidChar in Path.GetInvalidPathChars())
|
||||
if (name.Contains(invalidChar)) { bValid = false; }
|
||||
if (name.Contains('.')) { bValid = false; }
|
||||
return bValid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// checks to see if a path contains a proper length. Full string is no greater than 260char and path is no greater than 248char
|
||||
/// </summary>
|
||||
/// <param name="nameToValidate"></param>
|
||||
/// <returns></returns>
|
||||
public static bool ValidateFileAndPathNameLength(string nameToValidate)
|
||||
{
|
||||
try
|
||||
{
|
||||
var fullPath = Path.GetFullPath(nameToValidate);
|
||||
}
|
||||
catch (PathTooLongException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// All This function cares about is length. Ignore this exception. Dont need to log.
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
///
|
||||
/// <summary>
|
||||
/// Get useful disk usage statistics.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="directoryName">
|
||||
/// The <see cref="string"/> directory name to be queried for usage numbers.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="freeBytesAvailable">
|
||||
/// The <see cref="ulong"/> number of free bytes available on the specified volume.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="totalNumberOfBytes">
|
||||
/// The <see cref="ulong"/> total number of bytes available on the specified volume.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="totalNumberOfFreeBytes">
|
||||
/// The <see cref="ulong"/> total number of free bytes available on the specified volume.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// <see cref="int"/> status code, determined by windows.
|
||||
/// </returns>
|
||||
///
|
||||
[DllImport("kernel32", CharSet = CharSet.Auto)]
|
||||
public static extern int GetDiskFreeSpaceEx(
|
||||
string directoryName,
|
||||
out ulong freeBytesAvailable,
|
||||
out ulong totalNumberOfBytes,
|
||||
out ulong totalNumberOfFreeBytes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
|
||||
//
|
||||
// Win32APIs.cs
|
||||
//
|
||||
// Implementation of a library to use Win32 Memory Mapped
|
||||
// Files from within .NET applications
|
||||
//
|
||||
// COPYRIGHT (C) 2001, Tomas Restrepo (tomasr@mvps.org)
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
|
||||
/// <summary>Win32 APIs used by the library</summary>
|
||||
/// <remarks>
|
||||
/// Defines the PInvoke functions we use
|
||||
/// to access the FileMapping Win32 APIs
|
||||
/// </remarks>
|
||||
internal class Win32MapApis
|
||||
{
|
||||
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr CreateFile(
|
||||
String lpFileName, int dwDesiredAccess, int dwShareMode,
|
||||
IntPtr lpSecurityAttributes, int dwCreationDisposition,
|
||||
int dwFlagsAndAttributes, IntPtr hTemplateFile);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr CreateFileMapping(
|
||||
IntPtr hFile, IntPtr lpAttributes, int flProtect,
|
||||
int dwMaximumSizeLow, int dwMaximumSizeHigh,
|
||||
String lpName);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true)]
|
||||
public static extern bool FlushViewOfFile(
|
||||
IntPtr lpBaseAddress, int dwNumBytesToFlush);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true)]
|
||||
public static extern IntPtr MapViewOfFile(
|
||||
IntPtr hFileMappingObject, int dwDesiredAccess, int dwFileOffsetHigh,
|
||||
int dwFileOffsetLow, int dwNumBytesToMap);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr OpenFileMapping(
|
||||
int dwDesiredAccess, bool bInheritHandle, String lpName);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true)]
|
||||
public static extern bool UnmapViewOfFile(IntPtr lpBaseAddress);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true)]
|
||||
public static extern bool CloseHandle(IntPtr handle);
|
||||
|
||||
[DllImport("kernel32", SetLastError = false)]
|
||||
public static extern int GetLastError();
|
||||
|
||||
} // class Win32MapApis
|
||||
|
||||
}
|
||||
@@ -0,0 +1,413 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using DTS.Common.Utilities.Properties;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Common.Utilities.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// this class encapsulating writing to the log
|
||||
///
|
||||
/// </summary>
|
||||
public static class APILogger
|
||||
{
|
||||
private static readonly object ProcessLock = new object();
|
||||
private static readonly Dictionary<string, Stack<Stopwatch>> _processes = new Dictionary<string, Stack<Stopwatch>>();
|
||||
|
||||
public static void StartProcess(string name)
|
||||
{
|
||||
lock (ProcessLock)
|
||||
{
|
||||
if (!_processes.ContainsKey(name)) { _processes[name] = new Stack<Stopwatch>(); }
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
_processes[name].Push(sw);
|
||||
Log($"Starting process: [{name}] ({_processes[name].Count})");
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopProcess(string name)
|
||||
{
|
||||
lock (ProcessLock)
|
||||
{
|
||||
if (!_processes.ContainsKey(name) || 0 == _processes[name].Count)
|
||||
{
|
||||
Log($"Stopping process: [{name}] (0)");
|
||||
return;
|
||||
}
|
||||
var sw = _processes[name].Pop();
|
||||
sw.Stop();
|
||||
var ts = new TimeSpan(sw.ElapsedTicks);
|
||||
Log($"Stopping process: [{name}], {TimespanToHumanReadable(ts)}");
|
||||
}
|
||||
}
|
||||
private static string TimespanToHumanReadable(TimeSpan ts)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (ts.TotalDays > 1)
|
||||
{
|
||||
sb.Append($"{System.Math.Floor(ts.TotalDays):0} days, ");
|
||||
}
|
||||
sb.Append($"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds}.{ts.Milliseconds:000}");
|
||||
return sb.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// describes an event that should be raised when there's an error that needs to be handled by an application
|
||||
/// </summary>
|
||||
public delegate void ErrorRaisedEventDelegate(string msg);
|
||||
|
||||
private static ErrorRaisedEventDelegate _OnErrorRaised;
|
||||
/// <summary>
|
||||
/// Error handler called when errors are raised
|
||||
/// </summary>
|
||||
public static ErrorRaisedEventDelegate OnErrorRaised
|
||||
{
|
||||
get => _OnErrorRaised;
|
||||
set => _OnErrorRaised = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// raises an error, if an error handler is set, calls error handler
|
||||
/// </summary>
|
||||
public static void RaiseError(string error)
|
||||
{
|
||||
OnErrorRaised?.Invoke(error);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static string GetCurrentMethod()
|
||||
{
|
||||
var st = new StackTrace();
|
||||
var sf = st.GetFrame(1);
|
||||
|
||||
return sf.GetMethod().Name;
|
||||
}
|
||||
|
||||
private static bool _bDoPerformanceLog;
|
||||
public static void SetDoPerformanceLog(bool bDoLog)
|
||||
{
|
||||
_bDoPerformanceLog = bDoLog;
|
||||
}
|
||||
private static readonly object MyLock = new object();
|
||||
public static void DoPerformanceLog(string msg)
|
||||
{
|
||||
if (!_bDoPerformanceLog) { return; }
|
||||
var dt = DateTime.Now;
|
||||
var s = string.Format("{0:0000}-{1:00}-{2:00} {3:00}:{4:00}:{5:00}.{6:0000} ***{7}\r\n", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Millisecond, msg);
|
||||
lock (MyLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.AppendAllText("PERFLOG.LOG", s);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored - performance logging is only for statistics, we fail then we fail, just keep going
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// a function capable of logging a message
|
||||
/// </summary>
|
||||
/// <param name="msg">message to log</param>
|
||||
public delegate void Sink(string msg);
|
||||
|
||||
/// <summary>
|
||||
/// a consumer of log messages
|
||||
/// </summary>
|
||||
public static Sink Writer;
|
||||
|
||||
public static Sink ConfigurationLogWriter;
|
||||
public static Sink ConfigReadErrorLogWriter;
|
||||
|
||||
public static Sink StateWriter;
|
||||
|
||||
private static string LogException(Exception ex, bool bPrepend, bool bNewLine)
|
||||
{
|
||||
if (Writer == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
try
|
||||
{
|
||||
if (ex == null)
|
||||
{
|
||||
Writer("LogException: called with null exception");
|
||||
}
|
||||
else
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (bPrepend) { sb.Append(string.Concat(DateTime.Now.ToString(Resources.APILogging_DateTime_Format), " ")); }
|
||||
ExceptionFormater(ref sb, ex, 0);
|
||||
sb = sb.Replace(Environment.NewLine, " ");
|
||||
if (bNewLine) { sb.AppendLine(); }
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ownEx)
|
||||
{
|
||||
// and to be really paranoid...
|
||||
string orgMsg;
|
||||
if (ex == null)
|
||||
{
|
||||
orgMsg = "null exception";
|
||||
}
|
||||
else if (string.IsNullOrEmpty(ex.Message))
|
||||
{
|
||||
orgMsg = "blank exception message";
|
||||
}
|
||||
else
|
||||
{
|
||||
orgMsg = ex.Message;
|
||||
}
|
||||
try
|
||||
{
|
||||
Writer("APILogger: LogException threw an expection: " + ownEx.Message + " when handling: " + orgMsg);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
/// <summary>
|
||||
/// log an exception
|
||||
/// </summary>
|
||||
/// <param name="ex">exception to be logged</param>
|
||||
public static void LogException(Exception ex)
|
||||
{
|
||||
Writer(LogException(ex, true, true));
|
||||
}
|
||||
public const string EXCEPTIONSTART_STRING = "!! ";
|
||||
private static void ExceptionFormater(ref StringBuilder sb, Exception ex, int level)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (ex == null)
|
||||
return;
|
||||
var front = new string(' ', level);
|
||||
sb.Append(EXCEPTIONSTART_STRING);
|
||||
sb.AppendFormat(Resources.APILogging_ExceptionFormatter_ExceptionOfTypeOccurredString, front, level > 0 ? Resources.APILogging_ExceptionFormatter_InnerIndicationString : Resources.APILogging_ExceptionFormatter_NonInnerIndicationString, ex.GetType());
|
||||
if (null != ex.TargetSite)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_ModuleNameDisplayString, front, NullGuard(ex.TargetSite.Module.Name), NullGuard(ex.TargetSite.Name));
|
||||
}
|
||||
sb.AppendFormat(Resources.APILogging_ExceptionMessageDisplayString, front, NullGuard(ex.Message));
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
{
|
||||
// RW: It appears .NET 4.5 has a subtle difference in stack formatting. I don't see it, but it's breaking the Regex.
|
||||
// I'm not sure why it's using regex in the first place. This should work for both, but has not been tested with .NET 2.0
|
||||
string[] delimeters = { Environment.NewLine };
|
||||
var lines = ex.StackTrace.Split(delimeters, 2, StringSplitOptions.None);
|
||||
if (lines.Length > 0)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_StackTraceDisplayString, front, NullGuard(lines[0]));
|
||||
if (lines.Length > 1)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_StackTraceDisplayString, front, NullGuard(lines[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
// now call ourself with inner
|
||||
ex = ex.InnerException;
|
||||
level = level + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static string NullGuard(string s)
|
||||
{
|
||||
return s ?? Resources.Generic_NullIndicatorString;
|
||||
}
|
||||
|
||||
private static readonly string DATE_FORMAT = Resources.APILogging_DateTime_Format;
|
||||
private static string LogString(string str, bool bPrepend, bool bNewLine, bool bReplaceNewLines = true)
|
||||
{
|
||||
if (Writer == null)
|
||||
throw new Exception(Resources.APILogging_NullWriterDelegateString);
|
||||
var sb = new StringBuilder();
|
||||
if (bPrepend) { sb.Append($"{DateTime.Now.ToString(DATE_FORMAT)} "); }
|
||||
|
||||
if (bReplaceNewLines)
|
||||
{
|
||||
sb.Append(str.Replace(Environment.NewLine, " "));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(str);
|
||||
}
|
||||
|
||||
if (bNewLine) { sb.AppendLine(); }
|
||||
return sb.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// logs a string
|
||||
/// </summary>
|
||||
/// <param name="str">string to be logged</param>
|
||||
public static void LogString(string str)
|
||||
{
|
||||
Writer?.Invoke(LogString(str, true, true));
|
||||
}
|
||||
private static readonly object PhaseShiftLogLock = new object();
|
||||
/// <summary>
|
||||
/// logs a phase shift into a table
|
||||
/// </summary>
|
||||
/// <param name="serial"></param>
|
||||
/// <param name="msPhaseShift">MICROSECONDS of shift</param>
|
||||
/// <param name="originalT0"></param>
|
||||
/// <param name="modifiedTo"></param>
|
||||
/// <param name="samples"></param>
|
||||
/// <param name="rule"></param>
|
||||
public static void LogPhaseShift(string serial, double msPhaseShift, ulong originalT0, ulong modifiedTo, ulong samples, string rule)
|
||||
{
|
||||
try
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var s = string.Format("{0:0000}-{1:00}-{2:00} {3:00}:{4:00}:{5:00}.{6:0000}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\r\n",
|
||||
now.Year,
|
||||
now.Month,
|
||||
now.Day,
|
||||
now.Hour,
|
||||
now.Minute,
|
||||
now.Second,
|
||||
now.Millisecond,
|
||||
serial,
|
||||
samples,
|
||||
msPhaseShift,
|
||||
originalT0,
|
||||
modifiedTo,
|
||||
rule
|
||||
);
|
||||
lock (PhaseShiftLogLock)
|
||||
{
|
||||
|
||||
File.WriteAllLines("PHASE_SHIFT_LOG.txt", new[] { s });
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { Log(ex); }
|
||||
}
|
||||
|
||||
public static void StateLog(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
if (i > 0) { sb.Append(" "); }
|
||||
var s = paramlist[i] as string;
|
||||
if (paramlist[i] is DialogResult) { s = string.Format(" User selected {0}", ((DialogResult)paramlist[i])); }
|
||||
var ex = paramlist[i] as Exception;
|
||||
|
||||
if (null == s && null == ex && null != paramlist[i]) { s = paramlist[i].ToString(); }
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex) { sb.Append(LogException(ex, bPrepend, bNewLine)); }
|
||||
else if (null != s) { sb.Append(LogString(s, bPrepend, bNewLine, false)); }
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
StateWriter(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//if we fail to log there's not much more we can do ...
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// logs multiple parameters
|
||||
/// </summary>
|
||||
/// <param name="paramlist">
|
||||
/// collection of parameters, can be exceptions, strings, or an object with tostring
|
||||
/// </param>
|
||||
public static void Log(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
var obj = paramlist[i];
|
||||
if (i > 0) { sb.Append(" "); }
|
||||
var s = obj as string;
|
||||
if (obj is DialogResult) { s = $" User selected {(DialogResult)obj}"; }
|
||||
|
||||
if (obj is byte[])
|
||||
{
|
||||
s = BitConverter.ToString((byte[])obj).Replace("-", "");
|
||||
}
|
||||
|
||||
var ex = obj as Exception;
|
||||
if (null == s && null == ex && null != obj) { s = obj.ToString(); }
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex) { sb.Append(LogException(ex, bPrepend, bNewLine)); }
|
||||
else if (null != s) { sb.Append(LogString(s, bPrepend, bNewLine)); }
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
//KeywordAlert.Instance.ProcessMsg(msg);
|
||||
Writer(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//if we fail to log there's not much more we can do ...
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// logs multiple parameters
|
||||
/// </summary>
|
||||
/// <param name="paramlist">
|
||||
/// collection of parameters, can be exceptions, strings, or an object with tostring
|
||||
/// </param>
|
||||
public static void ConfLog(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
sb.Append(" ");
|
||||
}
|
||||
var s = paramlist[i] as string;
|
||||
if (paramlist[i] is DialogResult)
|
||||
{
|
||||
s = $" User selected {(DialogResult)paramlist[i]}";
|
||||
}
|
||||
var ex = paramlist[i] as Exception;
|
||||
|
||||
if (null == s && null == ex && null != paramlist[i])
|
||||
{
|
||||
s = paramlist[i].ToString();
|
||||
}
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex)
|
||||
{
|
||||
sb.Append(LogException(ex, bPrepend, bNewLine));
|
||||
}
|
||||
else if (null != s)
|
||||
{
|
||||
sb.Append(LogString(s, bPrepend, bNewLine));
|
||||
}
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
ConfigurationLogWriter(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//as with the other log function, if we fail we don't have much backing we can do
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// handles averaging over a queue of values (like in realtime mode)
|
||||
/// </summary>
|
||||
/// <remarks>thread safe</remarks>
|
||||
public class AverageQueue
|
||||
{
|
||||
private Queue<double> Queue { get; set; }
|
||||
private readonly object _queueLock;
|
||||
private int QueueLength { get; set; }
|
||||
private double _queueSum;
|
||||
/// <summary>
|
||||
/// constructs a queue that will maintain track of the average of the contents
|
||||
/// </summary>
|
||||
/// <param name="length">the length of the queue, when contents exceed size,
|
||||
/// the first item is dequeued
|
||||
/// </param>
|
||||
public AverageQueue(int length)
|
||||
{
|
||||
Queue = new Queue<double>(length);
|
||||
QueueLength = length;
|
||||
_queueLock = new object();
|
||||
}
|
||||
/// <summary>
|
||||
/// pushes a new value into the queue
|
||||
/// </summary>
|
||||
/// <param name="newValue">value to be pushed onto queue</param>
|
||||
/// <returns>current average</returns>
|
||||
public double Push(double newValue)
|
||||
{
|
||||
lock (_queueLock)
|
||||
{
|
||||
// enqueue the new value
|
||||
Queue.Enqueue(newValue);
|
||||
// add it to the sum
|
||||
_queueSum += newValue;
|
||||
if (Queue.Count > QueueLength)
|
||||
{
|
||||
// we have a full queue, remove the oldest
|
||||
var discard = Queue.Dequeue();
|
||||
// subtract it from sum
|
||||
_queueSum -= discard;
|
||||
}
|
||||
// return the average of the queue
|
||||
return _queueSum / Queue.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns current average
|
||||
/// </summary>
|
||||
/// <returns>current average</returns>
|
||||
public double GetAverage()
|
||||
{
|
||||
lock (_queueLock)
|
||||
{
|
||||
return _queueSum / Queue.Count;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// removes all entries in the queue.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
lock (_queueLock)
|
||||
{
|
||||
Queue.Clear();
|
||||
_queueSum = 0;
|
||||
}
|
||||
}
|
||||
public double GetMin()
|
||||
{
|
||||
lock (_queueLock) { return Queue.Min(); }
|
||||
}
|
||||
public double GetMax()
|
||||
{
|
||||
lock (_queueLock) { return Queue.Max(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
public static class DegreesFromADC
|
||||
{
|
||||
public static double GetDegrees(double Sxyz, double SG)
|
||||
{
|
||||
return (180.0 / System.Math.PI) * System.Math.Asin(Sxyz / SG);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Property.InvalidValueException.cs
|
||||
|
||||
$Log: Property.InvalidValueException.cs,v $
|
||||
Revision 1.1 2007/12/13 23:57:33 Paul Hrissikopoulos
|
||||
Added ISO raw format.
|
||||
|
||||
Copyright © 2007
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities.DotNetProgrammingConstructs
|
||||
{
|
||||
// See "Property.cs".
|
||||
public partial class Property<Type>
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representation for invalid property value exceptions.
|
||||
/// </summary>
|
||||
public class InvalidValueException
|
||||
: System.Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Property.InvalidValueException class.
|
||||
/// </summary>
|
||||
public InvalidValueException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Property.InvalidValueException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public InvalidValueException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Property.InvalidValueException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The inner <see cref="System.Exception"/> behind this enclosing
|
||||
/// exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public InvalidValueException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
partial class ScrollingMessageBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if ( disposing && ( components != null ) )
|
||||
{
|
||||
components.Dispose( );
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent( )
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.messageTextBox = new System.Windows.Forms.TextBox();
|
||||
this.YesButton = new System.Windows.Forms.Button();
|
||||
this.NoButton = new System.Windows.Forms.Button();
|
||||
this.btnClose = new System.Windows.Forms.Button();
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this._TimeDelay = new System.Windows.Forms.Timer(this.components);
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// messageTextBox
|
||||
//
|
||||
this.messageTextBox.BackColor = System.Drawing.Color.WhiteSmoke;
|
||||
this.messageTextBox.CausesValidation = false;
|
||||
this.messageTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.messageTextBox.Location = new System.Drawing.Point(3, 3);
|
||||
this.messageTextBox.Multiline = true;
|
||||
this.messageTextBox.Name = "messageTextBox";
|
||||
this.messageTextBox.ReadOnly = true;
|
||||
this.messageTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.messageTextBox.Size = new System.Drawing.Size(332, 218);
|
||||
this.messageTextBox.TabIndex = 2;
|
||||
//
|
||||
// YesButton
|
||||
//
|
||||
this.YesButton.BackColor = System.Drawing.Color.WhiteSmoke;
|
||||
this.YesButton.Location = new System.Drawing.Point(88, 0);
|
||||
this.YesButton.Name = "YesButton";
|
||||
this.YesButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.YesButton.TabIndex = 0;
|
||||
this.YesButton.Text = "Yes";
|
||||
this.YesButton.UseVisualStyleBackColor = false;
|
||||
this.YesButton.Click += new System.EventHandler(this.YesButton_Click);
|
||||
//
|
||||
// NoButton
|
||||
//
|
||||
this.NoButton.BackColor = System.Drawing.Color.WhiteSmoke;
|
||||
this.NoButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.NoButton.Location = new System.Drawing.Point(169, 0);
|
||||
this.NoButton.Name = "NoButton";
|
||||
this.NoButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.NoButton.TabIndex = 1;
|
||||
this.NoButton.Text = "No";
|
||||
this.NoButton.UseVisualStyleBackColor = false;
|
||||
this.NoButton.Click += new System.EventHandler(this.NoButton_Click);
|
||||
//
|
||||
// btnClose
|
||||
//
|
||||
this.btnClose.BackColor = System.Drawing.Color.WhiteSmoke;
|
||||
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnClose.Location = new System.Drawing.Point(129, 0);
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnClose.TabIndex = 3;
|
||||
this.btnClose.Text = "Close";
|
||||
this.btnClose.UseVisualStyleBackColor = false;
|
||||
this.btnClose.Visible = false;
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 1;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.messageTextBox, 0, 0);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 2;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 39F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(338, 263);
|
||||
this.tableLayoutPanel1.TabIndex = 4;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.btnClose);
|
||||
this.panel1.Controls.Add(this.YesButton);
|
||||
this.panel1.Controls.Add(this.NoButton);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel1.Location = new System.Drawing.Point(3, 227);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(332, 33);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// _TimeDelay
|
||||
//
|
||||
this._TimeDelay.Tick += new System.EventHandler(this.TimerTick);
|
||||
//
|
||||
// ScrollingMessageBox
|
||||
//
|
||||
this.AcceptButton = this.YesButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoSize = true;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(246)))), ((int)(((byte)(253)))));
|
||||
this.CancelButton = this.NoButton;
|
||||
this.ClientSize = new System.Drawing.Size(338, 263);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ScrollingMessageBox";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "ScrollingMessageBox";
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox messageTextBox;
|
||||
private System.Windows.Forms.Button YesButton;
|
||||
private System.Windows.Forms.Button NoButton;
|
||||
private System.Windows.Forms.Button btnClose;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Timer _TimeDelay;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="APILogging_ExceptionFormatter_ExceptionOfTypeOccurredString" xml:space="preserve">
|
||||
<value>{0}An {1}exception of type: {2} occurred</value>
|
||||
<comment>{0} = level or ' ', {1} = "inner" marker or ' ', {2} = string representation of exception type.</comment>
|
||||
</data>
|
||||
<data name="APILogging_ExceptionFormatter_InnerIndicationString" xml:space="preserve">
|
||||
<value>inner </value>
|
||||
</data>
|
||||
<data name="APILogging_ExceptionFormatter_NonInnerIndicationString" xml:space="preserve">
|
||||
<value />
|
||||
<comment>comment</comment>
|
||||
</data>
|
||||
<data name="APILogging_ExceptionMessageDisplayString" xml:space="preserve">
|
||||
<value>{0}Message: {1}</value>
|
||||
<comment>{0} = level or ' ', {1} = exception message string</comment>
|
||||
</data>
|
||||
<data name="APILogging_LevelSeperatorString" xml:space="preserve">
|
||||
<value>=== </value>
|
||||
</data>
|
||||
<data name="APILogging_LogEntrySeperatorString" xml:space="preserve">
|
||||
<value> ========================================</value>
|
||||
</data>
|
||||
<data name="APILogging_LogException_NullWriterDelegateString" xml:space="preserve">
|
||||
<value>APILogger.LogException: Writer delegate is null</value>
|
||||
</data>
|
||||
<data name="APILogging_ModuleNameDisplayString" xml:space="preserve">
|
||||
<value> {0}Module: {1}, Name: {2}</value>
|
||||
<comment> {0} = level or ' ', {1} = target site module name, {2} = target site name</comment>
|
||||
</data>
|
||||
<data name="APILogging_NullWriterDelegateString" xml:space="preserve">
|
||||
<value>APILogger.LogString: Writer delegate is null</value>
|
||||
</data>
|
||||
<data name="APILogging_StackTraceDisplayString" xml:space="preserve">
|
||||
<value> {0}StackTrace: {1}</value>
|
||||
<comment> {0} = level or ' ', {1} = stack trace lines</comment>
|
||||
</data>
|
||||
<data name="AttributeCoder_AttributeCoder_NullAttributeValueExtractionMethodReferenceString" xml:space="preserve">
|
||||
<value>cannot use null attribute value extraction method reference</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_DecodeAttributeExceptionString" xml:space="preserve">
|
||||
<value>encountered problem decoding attribute value</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_DecodeAttributesExceptionString" xml:space="preserve">
|
||||
<value>encountered problem decoding attribute values</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_DehashAttributeValue_DehashAttributeValueExceptionString" xml:space="preserve">
|
||||
<value>encountered problem dehashing attribute value</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_DehashAttributeValue_UnableToMatchAttributeValueWithTargetString" xml:space="preserve">
|
||||
<value>unable to match attribute value with an actual target type</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_EncodeAttributeExceptionString" xml:space="preserve">
|
||||
<value>encountered problem encoding attribute value</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_NoTypeAttributesFoundOnTargetString" xml:space="preserve">
|
||||
<value>no attributes of specified type found on designated target</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_UnableToFindTargetTypeMappingString" xml:space="preserve">
|
||||
<value>unable to find unique target type mapping for the specified attribute value</value>
|
||||
</data>
|
||||
<data name="Exceptional_GenerateMessageFromExceptionTree_BecauseString" xml:space="preserve">
|
||||
<value> because</value>
|
||||
<comment>The "because" text used to string together multiple nested exception messages when the Exceptional textifier assembles user-readable output.</comment>
|
||||
</data>
|
||||
<data name="Exceptional_GenerateMessageFromExceptionTree_EndsWithFormatString" xml:space="preserve">
|
||||
<value>{0}{1}</value>
|
||||
</data>
|
||||
<data name="Exceptional_GenerateMessageFromExceptionTree_ErrorTextTerminatorString" xml:space="preserve">
|
||||
<value>.</value>
|
||||
<comment>The sentence terminator used after strung-together nested exception messages have been textified into user-readable output.</comment>
|
||||
</data>
|
||||
<data name="Exceptional_GenerateMessageFromExceptionTree_MessageFormatString" xml:space="preserve">
|
||||
<value>{0}{1}{2}</value>
|
||||
</data>
|
||||
<data name="Generic_EncounteredProblemConstructingClassString" xml:space="preserve">
|
||||
<value>encountered problem constructing {0}</value>
|
||||
<comment>{0} = type name string of class</comment>
|
||||
</data>
|
||||
<data name="Generic_NullIndicatorString" xml:space="preserve">
|
||||
<value><null></value>
|
||||
</data>
|
||||
<data name="PowerOfTwoProperty_GetInvalidValueDescription_ProposedValueIsNotPowerOf2String" xml:space="preserve">
|
||||
<value>proposed value "{0}" is not a power of two</value>
|
||||
<comment>{0} = proposed value</comment>
|
||||
</data>
|
||||
<data name="PowerOfTwoProperty_GetInvalidValueDescription_UnableToGetDescriptionString" xml:space="preserve">
|
||||
<value>encountered problem getting invalid value description</value>
|
||||
</data>
|
||||
<data name="PowerOfTwoProperty_IsPowerOf2_UnableToDeterminePowerOf2nessString" xml:space="preserve">
|
||||
<value>encountered problem determining whether or not "{0}" is a power of two</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="PowerOfTwoProperty_IsValidValue_UnableToDetermineValidityString" xml:space="preserve">
|
||||
<value>encountered problem determing power of two-validity of "{0} "</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="Property_GetInvalidValueDescription_CouldNotSetToValueString" xml:space="preserve">
|
||||
<value>property {0}cannot be set to {1}</value>
|
||||
<comment>{0} = quoted name of property value, or empty string if none has been provided to the constructor, {1} = proposed new value, null indication string if it's null</comment>
|
||||
</data>
|
||||
<data name="Property_GetInvalidValueDescription_GetDescriptionFailedString" xml:space="preserve">
|
||||
<value>encountered problem generating invalid valid description</value>
|
||||
</data>
|
||||
<data name="Property_Value_CouldNotGetValueString" xml:space="preserve">
|
||||
<value>encountered problem getting property {0}value</value>
|
||||
<comment>{0} = quoted name of property value, or empty string if none has been provided to the constructor</comment>
|
||||
</data>
|
||||
<data name="Property_Value_CouldNotSetValueString" xml:space="preserve">
|
||||
<value>encountered problem setting property {0}value</value>
|
||||
<comment>{0} = quoted name of property value, or empty string if none has been provided to the constructor</comment>
|
||||
</data>
|
||||
<data name="Property_Value_NotInitializedString" xml:space="preserve">
|
||||
<value>property has not been initialized</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_GetInvalidValueDescription_GetDescriptionFailedString" xml:space="preserve">
|
||||
<value>encountered problem generating invalid value description for value "{0}"</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_GetInvalidValueDescription_MaximumDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is greater than the maximum allowable value of "{1}"</value>
|
||||
<comment>{0} = target value, {1} = maximum value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_GetInvalidValueDescription_MinimumDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is less than the minimum allowable value of "{1}"</value>
|
||||
<comment>{0} = target value, {1} = minimum value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_GetInvalidValueDescription_ValidValueDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is valid</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_IsValidValue_UnableToDetermineValidityString" xml:space="preserve">
|
||||
<value>encountered problem determing range-restricted validity of "{0}"</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_MaximumValue_GetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem getting maximum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_MaximumValue_SetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem setting maximum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_MinimumValue_GetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem getting minimum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_MinimumValue_SetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem setting minimum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_MinMustBeLessThanMaxString" xml:space="preserve">
|
||||
<value>minimum value ({0}) must be less than or equal to maximum value ({1})</value>
|
||||
<comment>{0} = target minimum value, {1} = target maximum value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_GetInvalidValueDescription_GetDescriptionFailedString" xml:space="preserve">
|
||||
<value>encountered problem generating invalid value description for value "{0}"</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_GetInvalidValueDescription_MaximumDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is greater than the maximum allowable value of "{1}"</value>
|
||||
<comment>{0} = target value, {1} = maximum value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_GetInvalidValueDescription_MinimumDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is less than the minimum allowable value of "{1}"</value>
|
||||
<comment>{0} = target value, {1} = minimum value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_GetInvalidValueDescription_ValidValueDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is valid</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_IsValidValue_UnableToDetermineValidityString" xml:space="preserve">
|
||||
<value>encountered problem determing range-restricted validity of "{0}"</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_MaximumValue_GetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem getting maximum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_MaximumValue_SetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem setting maximum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_MinimumValue_GetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem getting minimum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_MinimumValue_SetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem setting minimum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_MinMustBeLessThanMaxString" xml:space="preserve">
|
||||
<value>minimum value ({0}) must be less than or equal to maximum value ({1})</value>
|
||||
<comment>{0} = target minimum value, {1} = target maximum value</comment>
|
||||
</data>
|
||||
<data name="TextLogger_AddMessage_LoggerNotRunningString" xml:space="preserve">
|
||||
<value>TextLogger.AddMessage: Logger is not running, call Start first</value>
|
||||
</data>
|
||||
<data name="TextLogger_Dispose_WriteThreadExitFailureString" xml:space="preserve">
|
||||
<value>TextLogger.dtor: Writing thread didn't go to Exited state, it's in {0}</value>
|
||||
<comment>{0} = target thread control string</comment>
|
||||
</data>
|
||||
<data name="TextLogger_Dispose_WriteThreadResponseTimeoutString" xml:space="preserve">
|
||||
<value>TextLogger.dtor: Writing thread didn't respond in time</value>
|
||||
</data>
|
||||
<data name="TextLogger_Start_LoggerAlreadyRunningString" xml:space="preserve">
|
||||
<value>TextLogger.AddMessage: Logger is already running, call Stop first</value>
|
||||
</data>
|
||||
<data name="TextLogger_Start_NullEmptyFilenameString" xml:space="preserve">
|
||||
<value>TextLogger.Start: filename can't be null or blank</value>
|
||||
</data>
|
||||
<data name="TextLogger_Start_NullEmptyFolderString" xml:space="preserve">
|
||||
<value>TextLogger.Start: folder can't be null or blank</value>
|
||||
</data>
|
||||
<data name="TextLogger_Start_WriteThreadResponseTimeoutString" xml:space="preserve">
|
||||
<value>TextLogger.Start: Writing thread didn't respond in time</value>
|
||||
</data>
|
||||
<data name="TextLogger_Start_WriteThreadStartFailureString" xml:space="preserve">
|
||||
<value>TextLogger.Start: Writing thread didn't go to Started state, it's in {0}</value>
|
||||
<comment>{0} = target thread control string</comment>
|
||||
</data>
|
||||
<data name="TextLogger_Stop_LoggerNotRunningString" xml:space="preserve">
|
||||
<value>TextLogger.Stop: Logger is not running, call Start first</value>
|
||||
</data>
|
||||
<data name="TextLogger_Stop_WriteThreadResponseTimeoutString" xml:space="preserve">
|
||||
<value>TextLogger.Stop: Writing thread didn't respond in time</value>
|
||||
</data>
|
||||
<data name="TextLogger_Stop_WriteThreadStopFailureString" xml:space="preserve">
|
||||
<value>TextLogger.Stop: Writing thread didn't go to Stopped state, it's in {0}</value>
|
||||
<comment>{0} = target thread control string</comment>
|
||||
</data>
|
||||
<data name="TextLogger_TextLogger_EnqueueWriterFailureString" xml:space="preserve">
|
||||
<value>TextLogger: Can't enqueue Writer</value>
|
||||
</data>
|
||||
<data name="TextLogger_TextLogger_NullCallbackString" xml:space="preserve">
|
||||
<value>TextLogger: Callback can't be null</value>
|
||||
</data>
|
||||
<data name="TextLogger_TextLogger_WriteThreadStartTimeoutString" xml:space="preserve">
|
||||
<value>TextLogger.ctor: Writing thread didn't start in time</value>
|
||||
</data>
|
||||
<data name="TextLogger_Writer_InvalidCommandString" xml:space="preserve">
|
||||
<value>TextLogger.Writer: invalid command {0}</value>
|
||||
<comment>{0} = invalid command string</comment>
|
||||
</data>
|
||||
<data name="APILogging_DateTime_Format" xml:space="preserve">
|
||||
<value>yyyy-MM-dd HH:mm:ss.fff</value>
|
||||
</data>
|
||||
<data name="ApplicationSettings" xml:space="preserve">
|
||||
<value>applicationSettings</value>
|
||||
</data>
|
||||
<data name="NewSettingsCouldNotBeFound" xml:space="preserve">
|
||||
<value>Warning: DataPRO.exe.config was not updated because config settings from new version of DataPRO could not be found: {0}; {1}</value>
|
||||
</data>
|
||||
<data name="NewSettingsCouldNotBeProcessed" xml:space="preserve">
|
||||
<value>Warning: DataPRO.exe.config was not updated because config settings from new version of DataPRO could not be processed.</value>
|
||||
</data>
|
||||
<data name="RegistryDataPROExe" xml:space="preserve">
|
||||
<value>DataPRO.exe</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* AverageShortValueOverTime.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// A class to represent the average value of a set of shorts over time.
|
||||
/// </summary>
|
||||
public class AverageShortValueOverTime
|
||||
: AverageValueOverTime<short>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the AverageShortValueOverTime class, assuming that no
|
||||
/// averaging has been done yet.
|
||||
/// </summary>
|
||||
/// <param name="initialTime">
|
||||
/// The <see cref="double"/> begin time of the average (using the time units specified
|
||||
/// by the "TimeUnitSymbol" property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="sampleRate">
|
||||
/// The <see cref="double"/> sample rate of the items being averaged (using the time units
|
||||
/// specifed by the "TimeUnitSymbol" property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="timeUnitSymbol">
|
||||
/// The <see cref="string"/> time unit description for begin/end times and the sample rate.
|
||||
/// </param>
|
||||
///
|
||||
public AverageShortValueOverTime(double initialTime,
|
||||
double sampleRate,
|
||||
string timeUnitSymbol)
|
||||
: base(initialTime,
|
||||
sampleRate,
|
||||
0,
|
||||
timeUnitSymbol)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the AverageShortValueOverTime class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="beginTime">
|
||||
/// The <see cref="double"/> begin time of the average (using the time units specified
|
||||
/// by the "TimeUnitSymbol" property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="endTime">
|
||||
/// The <see cref="double"/> end time of the average (using the time units specified
|
||||
/// by the "TimeUnitSymbol" property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="sampleRate">
|
||||
/// The <see cref="double"/> sample rate of the items being averaged (using the time units
|
||||
/// specifed by the "TimeUnitSymbol" property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="initialAverage">
|
||||
/// The <see cref="short"/> pre-existing average to be appended to.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="timeUnitSymbol">
|
||||
/// The <see cref="string"/> time unit description for begin/end times and the sample rate.
|
||||
/// </param>
|
||||
///
|
||||
public AverageShortValueOverTime(double beginTime,
|
||||
double endTime,
|
||||
double sampleRate,
|
||||
short initialAverage,
|
||||
string timeUnitSymbol)
|
||||
: base(beginTime,
|
||||
endTime,
|
||||
sampleRate,
|
||||
initialAverage,
|
||||
timeUnitSymbol)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append the specified <see cref="T:List"/> of values to the running average.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="values">
|
||||
/// The <see cref="T:List"/> of <see cref="short"/>s to be appended to the running average.
|
||||
/// </param>
|
||||
///
|
||||
public override void AppendValues(List<short> values)
|
||||
{
|
||||
AppendValues(values.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append the specified array of values to the running average.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="values">
|
||||
/// The array of <see cref="short"/>s to be appended to the running average.
|
||||
/// </param>
|
||||
///
|
||||
public override void AppendValues(short[] values)
|
||||
{
|
||||
if (0 == values.Length)
|
||||
{
|
||||
APILogger.Log($"AverageShortValueOverTime.AppendValues - no values to append");
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Get the average of the appended values by themselves.
|
||||
//
|
||||
var numAppendixSamples = values.Length;
|
||||
var appendixSamples = new double[numAppendixSamples];
|
||||
for (var i = 0; i < numAppendixSamples; i++)
|
||||
appendixSamples[i] = values[i];
|
||||
var appendixAverage = appendixSamples.Average();
|
||||
|
||||
//
|
||||
// Get the previous average and number of samples.
|
||||
//
|
||||
var numPreviousSamples = (ulong)((EndTime - BeginTime) * SampleRate);
|
||||
double previousAverage = CurrentAverage;
|
||||
|
||||
//
|
||||
// Now combine them with the previous average values (with the
|
||||
// appropriate weighting) to get a new combined average.
|
||||
//
|
||||
var numTotalSamples = numPreviousSamples + (ulong)numAppendixSamples;
|
||||
var combinedAverage = ((previousAverage * numPreviousSamples) + (appendixAverage * numAppendixSamples)) / numTotalSamples;
|
||||
|
||||
// Save our new average.
|
||||
CurrentAverage = (short)combinedAverage;
|
||||
|
||||
// Update the end time to take into account the appended data.
|
||||
EndTime += (numAppendixSamples / SampleRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="APILogging_ExceptionFormatter_ExceptionOfTypeOccurredString" xml:space="preserve">
|
||||
<value>{0}An {1}exception of type: {2} occurred</value>
|
||||
<comment>{0} = level or ' ', {1} = "inner" marker or ' ', {2} = string representation of exception type.</comment>
|
||||
</data>
|
||||
<data name="APILogging_ExceptionFormatter_InnerIndicationString" xml:space="preserve">
|
||||
<value>inner </value>
|
||||
</data>
|
||||
<data name="APILogging_ExceptionFormatter_NonInnerIndicationString" xml:space="preserve">
|
||||
<value />
|
||||
<comment>comment</comment>
|
||||
</data>
|
||||
<data name="APILogging_ExceptionMessageDisplayString" xml:space="preserve">
|
||||
<value>{0}Message: {1}</value>
|
||||
<comment>{0} = level or ' ', {1} = exception message string</comment>
|
||||
</data>
|
||||
<data name="APILogging_LevelSeperatorString" xml:space="preserve">
|
||||
<value>=== </value>
|
||||
</data>
|
||||
<data name="APILogging_LogEntrySeperatorString" xml:space="preserve">
|
||||
<value> ========================================</value>
|
||||
</data>
|
||||
<data name="APILogging_LogException_NullWriterDelegateString" xml:space="preserve">
|
||||
<value>APILogger.LogException: Writer delegate is null</value>
|
||||
</data>
|
||||
<data name="APILogging_ModuleNameDisplayString" xml:space="preserve">
|
||||
<value> {0}Module: {1}, Name: {2}</value>
|
||||
<comment> {0} = level or ' ', {1} = target site module name, {2} = target site name</comment>
|
||||
</data>
|
||||
<data name="APILogging_NullWriterDelegateString" xml:space="preserve">
|
||||
<value>APILogger.LogString: Writer delegate is null</value>
|
||||
</data>
|
||||
<data name="APILogging_StackTraceDisplayString" xml:space="preserve">
|
||||
<value> {0}StackTrace: {1}</value>
|
||||
<comment> {0} = level or ' ', {1} = stack trace lines</comment>
|
||||
</data>
|
||||
<data name="AttributeCoder_AttributeCoder_NullAttributeValueExtractionMethodReferenceString" xml:space="preserve">
|
||||
<value>cannot use null attribute value extraction method reference</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_DecodeAttributeExceptionString" xml:space="preserve">
|
||||
<value>encountered problem decoding attribute value</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_DecodeAttributesExceptionString" xml:space="preserve">
|
||||
<value>encountered problem decoding attribute values</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_DehashAttributeValue_DehashAttributeValueExceptionString" xml:space="preserve">
|
||||
<value>encountered problem dehashing attribute value</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_DehashAttributeValue_UnableToMatchAttributeValueWithTargetString" xml:space="preserve">
|
||||
<value>unable to match attribute value with an actual target type</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_EncodeAttributeExceptionString" xml:space="preserve">
|
||||
<value>encountered problem encoding attribute value</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_NoTypeAttributesFoundOnTargetString" xml:space="preserve">
|
||||
<value>no attributes of specified type found on designated target</value>
|
||||
</data>
|
||||
<data name="AttributeCoder_UnableToFindTargetTypeMappingString" xml:space="preserve">
|
||||
<value>unable to find unique target type mapping for the specified attribute value</value>
|
||||
</data>
|
||||
<data name="Exceptional_GenerateMessageFromExceptionTree_BecauseString" xml:space="preserve">
|
||||
<value> because</value>
|
||||
<comment>The "because" text used to string together multiple nested exception messages when the Exceptional textifier assembles user-readable output.</comment>
|
||||
</data>
|
||||
<data name="Exceptional_GenerateMessageFromExceptionTree_EndsWithFormatString" xml:space="preserve">
|
||||
<value>{0}{1}</value>
|
||||
</data>
|
||||
<data name="Exceptional_GenerateMessageFromExceptionTree_ErrorTextTerminatorString" xml:space="preserve">
|
||||
<value>.</value>
|
||||
<comment>The sentence terminator used after strung-together nested exception messages have been textified into user-readable output.</comment>
|
||||
</data>
|
||||
<data name="Exceptional_GenerateMessageFromExceptionTree_MessageFormatString" xml:space="preserve">
|
||||
<value>{0}{1}{2}</value>
|
||||
</data>
|
||||
<data name="Generic_EncounteredProblemConstructingClassString" xml:space="preserve">
|
||||
<value>encountered problem constructing {0}</value>
|
||||
<comment>{0} = type name string of class</comment>
|
||||
</data>
|
||||
<data name="Generic_NullIndicatorString" xml:space="preserve">
|
||||
<value><null></value>
|
||||
</data>
|
||||
<data name="PowerOfTwoProperty_GetInvalidValueDescription_ProposedValueIsNotPowerOf2String" xml:space="preserve">
|
||||
<value>proposed value "{0}" is not a power of two</value>
|
||||
<comment>{0} = proposed value</comment>
|
||||
</data>
|
||||
<data name="PowerOfTwoProperty_GetInvalidValueDescription_UnableToGetDescriptionString" xml:space="preserve">
|
||||
<value>encountered problem getting invalid value description</value>
|
||||
</data>
|
||||
<data name="PowerOfTwoProperty_IsPowerOf2_UnableToDeterminePowerOf2nessString" xml:space="preserve">
|
||||
<value>encountered problem determining whether or not "{0}" is a power of two</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="PowerOfTwoProperty_IsValidValue_UnableToDetermineValidityString" xml:space="preserve">
|
||||
<value>encountered problem determing power of two-validity of "{0} "</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="Property_GetInvalidValueDescription_CouldNotSetToValueString" xml:space="preserve">
|
||||
<value>property {0}cannot be set to {1}</value>
|
||||
<comment>{0} = quoted name of property value, or empty string if none has been provided to the constructor, {1} = proposed new value, null indication string if it's null</comment>
|
||||
</data>
|
||||
<data name="Property_GetInvalidValueDescription_GetDescriptionFailedString" xml:space="preserve">
|
||||
<value>encountered problem generating invalid valid description</value>
|
||||
</data>
|
||||
<data name="Property_Value_CouldNotGetValueString" xml:space="preserve">
|
||||
<value>encountered problem getting property {0}value</value>
|
||||
<comment>{0} = quoted name of property value, or empty string if none has been provided to the constructor</comment>
|
||||
</data>
|
||||
<data name="Property_Value_CouldNotSetValueString" xml:space="preserve">
|
||||
<value>encountered problem setting property {0}value</value>
|
||||
<comment>{0} = quoted name of property value, or empty string if none has been provided to the constructor</comment>
|
||||
</data>
|
||||
<data name="Property_Value_NotInitializedString" xml:space="preserve">
|
||||
<value>property has not been initialized</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_GetInvalidValueDescription_GetDescriptionFailedString" xml:space="preserve">
|
||||
<value>encountered problem generating invalid value description for value "{0}"</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_GetInvalidValueDescription_MaximumDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is greater than the maximum allowable value of "{1}"</value>
|
||||
<comment>{0} = target value, {1} = maximum value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_GetInvalidValueDescription_MinimumDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is less than the minimum allowable value of "{1}"</value>
|
||||
<comment>{0} = target value, {1} = minimum value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_GetInvalidValueDescription_ValidValueDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is valid</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_IsValidValue_UnableToDetermineValidityString" xml:space="preserve">
|
||||
<value>encountered problem determing range-restricted validity of "{0}"</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_MaximumValue_GetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem getting maximum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_MaximumValue_SetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem setting maximum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_MinimumValue_GetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem getting minimum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_MinimumValue_SetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem setting minimum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedDoubleProperty_MinMustBeLessThanMaxString" xml:space="preserve">
|
||||
<value>minimum value ({0}) must be less than or equal to maximum value ({1})</value>
|
||||
<comment>{0} = target minimum value, {1} = target maximum value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_GetInvalidValueDescription_GetDescriptionFailedString" xml:space="preserve">
|
||||
<value>encountered problem generating invalid value description for value "{0}"</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_GetInvalidValueDescription_MaximumDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is greater than the maximum allowable value of "{1}"</value>
|
||||
<comment>{0} = target value, {1} = maximum value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_GetInvalidValueDescription_MinimumDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is less than the minimum allowable value of "{1}"</value>
|
||||
<comment>{0} = target value, {1} = minimum value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_GetInvalidValueDescription_ValidValueDescriptionString" xml:space="preserve">
|
||||
<value>the specified value "{0}" is valid</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_IsValidValue_UnableToDetermineValidityString" xml:space="preserve">
|
||||
<value>encountered problem determing range-restricted validity of "{0}"</value>
|
||||
<comment>{0} = target value</comment>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_MaximumValue_GetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem getting maximum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_MaximumValue_SetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem setting maximum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_MinimumValue_GetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem getting minimum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_MinimumValue_SetValueFailedString" xml:space="preserve">
|
||||
<value>encountered problem setting minimum range value</value>
|
||||
</data>
|
||||
<data name="RangeRestrictedIntProperty_MinMustBeLessThanMaxString" xml:space="preserve">
|
||||
<value>minimum value ({0}) must be less than or equal to maximum value ({1})</value>
|
||||
<comment>{0} = target minimum value, {1} = target maximum value</comment>
|
||||
</data>
|
||||
<data name="TextLogger_AddMessage_LoggerNotRunningString" xml:space="preserve">
|
||||
<value>TextLogger.AddMessage: Logger is not running, call Start first</value>
|
||||
</data>
|
||||
<data name="TextLogger_Dispose_WriteThreadExitFailureString" xml:space="preserve">
|
||||
<value>TextLogger.dtor: Writing thread didn't go to Exited state, it's in {0}</value>
|
||||
<comment>{0} = target thread control string</comment>
|
||||
</data>
|
||||
<data name="TextLogger_Dispose_WriteThreadResponseTimeoutString" xml:space="preserve">
|
||||
<value>TextLogger.dtor: Writing thread didn't respond in time</value>
|
||||
</data>
|
||||
<data name="TextLogger_Start_LoggerAlreadyRunningString" xml:space="preserve">
|
||||
<value>TextLogger.AddMessage: Logger is already running, call Stop first</value>
|
||||
</data>
|
||||
<data name="TextLogger_Start_NullEmptyFilenameString" xml:space="preserve">
|
||||
<value>TextLogger.Start: filename can't be null or blank</value>
|
||||
</data>
|
||||
<data name="TextLogger_Start_NullEmptyFolderString" xml:space="preserve">
|
||||
<value>TextLogger.Start: folder can't be null or blank</value>
|
||||
</data>
|
||||
<data name="TextLogger_Start_WriteThreadResponseTimeoutString" xml:space="preserve">
|
||||
<value>TextLogger.Start: Writing thread didn't respond in time</value>
|
||||
</data>
|
||||
<data name="TextLogger_Start_WriteThreadStartFailureString" xml:space="preserve">
|
||||
<value>TextLogger.Start: Writing thread didn't go to Started state, it's in {0}</value>
|
||||
<comment>{0} = target thread control string</comment>
|
||||
</data>
|
||||
<data name="TextLogger_Stop_LoggerNotRunningString" xml:space="preserve">
|
||||
<value>TextLogger.Stop: Logger is not running, call Start first</value>
|
||||
</data>
|
||||
<data name="TextLogger_Stop_WriteThreadResponseTimeoutString" xml:space="preserve">
|
||||
<value>TextLogger.Stop: Writing thread didn't respond in time</value>
|
||||
</data>
|
||||
<data name="TextLogger_Stop_WriteThreadStopFailureString" xml:space="preserve">
|
||||
<value>TextLogger.Stop: Writing thread didn't go to Stopped state, it's in {0}</value>
|
||||
<comment>{0} = target thread control string</comment>
|
||||
</data>
|
||||
<data name="TextLogger_TextLogger_EnqueueWriterFailureString" xml:space="preserve">
|
||||
<value>TextLogger: Can't enqueue Writer</value>
|
||||
</data>
|
||||
<data name="TextLogger_TextLogger_NullCallbackString" xml:space="preserve">
|
||||
<value>TextLogger: Callback can't be null</value>
|
||||
</data>
|
||||
<data name="TextLogger_TextLogger_WriteThreadStartTimeoutString" xml:space="preserve">
|
||||
<value>TextLogger.ctor: Writing thread didn't start in time</value>
|
||||
</data>
|
||||
<data name="TextLogger_Writer_InvalidCommandString" xml:space="preserve">
|
||||
<value>TextLogger.Writer: invalid command {0}</value>
|
||||
<comment>{0} = invalid command string</comment>
|
||||
</data>
|
||||
<data name="APILogging_DateTime_Format" xml:space="preserve">
|
||||
<value>yyyy-MM-dd HH:mm:ss.fff</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Math.DoubleArrayOperation.cs
|
||||
|
||||
24 November 2009 - Adapted from old Dave codebase to generic DTS utility, with
|
||||
appropriate name change.
|
||||
|
||||
$Log: Math.ChannelOperation.cs,v $
|
||||
Revision 1.2 2007/02/05 17:17:08 Paul Hrissikopoulos
|
||||
Finished installing generic channel math framework + basic calculus operations.
|
||||
|
||||
Revision 1.1 2007/02/02 22:34:09 Paul Hrissikopoulos
|
||||
Added framework for DAVE channel math operators.
|
||||
|
||||
Copyright © 2007
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities.Math
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Representation of a mathematical operation to be performed
|
||||
/// on <see cref="double"/> System.Collections.Generic.IList data.
|
||||
/// </summary>
|
||||
public abstract class DoubleListOperation : Operation<IList<double>, IList<double>>
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Initialize an instance of the ChannelOperation class. As a matter of
|
||||
/// style, a domain is required for object creation.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="domain">
|
||||
/// A System.Collections.Generic.IList of <see cref="double"/>s to be
|
||||
/// integrated.
|
||||
/// </param>
|
||||
///
|
||||
public DoubleListOperation(IList<double> domain)
|
||||
: base(domain)
|
||||
{
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="_TimeDelay.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Performs 32-bit reversed cyclic redundancy checks.
|
||||
/// </summary>
|
||||
public class Crc32
|
||||
{
|
||||
#region Constants
|
||||
/// <summary>
|
||||
/// Generator polynomial (modulo 2) for the reversed CRC32 algorithm.
|
||||
/// </summary>
|
||||
private const uint s_generator = 0xEDB88320;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Creates a new instance of the Crc32 class.
|
||||
/// </summary>
|
||||
public Crc32()
|
||||
{
|
||||
// Constructs the checksum lookup table. Used to optimize the checksum.
|
||||
m_checksumTable = Enumerable.Range(0, 256).Select(i =>
|
||||
{
|
||||
var tableEntry = (uint)i;
|
||||
for (var j = 0; j < 8; ++j)
|
||||
{
|
||||
tableEntry = ((tableEntry & 1) != 0)
|
||||
? (s_generator ^ (tableEntry >> 1))
|
||||
: (tableEntry >> 1);
|
||||
}
|
||||
return tableEntry;
|
||||
}).ToArray();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Calculates the checksum of the byte stream.
|
||||
/// </summary>
|
||||
/// <param name="byteStream">The byte stream to calculate the checksum for.</param>
|
||||
/// <returns>A 32-bit reversed checksum.</returns>
|
||||
public uint Get<T>(IEnumerable<T> byteStream)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Initialize checksumRegister to 0xFFFFFFFF and calculate the checksum.
|
||||
return ~byteStream.Aggregate(0xFFFFFFFF, (checksumRegister, currentByte) =>
|
||||
(m_checksumTable[(checksumRegister & 0xFF) ^ Convert.ToByte(currentByte)] ^ (checksumRegister >> 8)));
|
||||
}
|
||||
catch (FormatException e)
|
||||
{
|
||||
throw new FormatException("Could not read the stream out as bytes.", e);
|
||||
}
|
||||
catch (InvalidCastException e)
|
||||
{
|
||||
throw new InvalidCastException("Could not read the stream out as bytes.", e);
|
||||
}
|
||||
catch (OverflowException e)
|
||||
{
|
||||
throw new OverflowException("Could not read the stream out as bytes.", e);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Contains a cache of calculated checksum chunks.
|
||||
/// </summary>
|
||||
private readonly uint[] m_checksumTable;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* LargeArray.LargeOverflowException.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
// *** see LargeArray.cs ***
|
||||
public partial class LargeArray<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Representation of a failed attempt to convert a "Large" interface data type to one of
|
||||
/// the smaller data types in the "standard" interface.
|
||||
/// </summary>
|
||||
private class LargeOverflowException : ApplicationException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="T:LargeArray.LargeOverflowException"/> class.
|
||||
/// </summary>
|
||||
public LargeOverflowException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="T:LargeArray.LargeOverflowException"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public LargeOverflowException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="T:LargeArray.LargeOverflowException"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The inner <see cref="System.Exception"/> behind this enclosing
|
||||
/// exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public LargeOverflowException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Configuration;
|
||||
using DTS.Common.Utilities.Properties;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
public static class ConfigInitializationHelper
|
||||
{
|
||||
public static void UpdateTSRAIRAppSettings(string targetDir, bool launchTSRAIRGoValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
APILogger.Log($"Calling GetNewSettings with targetDir={targetDir}");
|
||||
if (!GetNewSettings(Resources.ApplicationSettings, targetDir, out var result, out var settings, out var config))
|
||||
{
|
||||
APILogger.Log($"failed to updatetsrairappsetting {result}");
|
||||
}
|
||||
|
||||
APILogger.Log($"Calling settings.Get");
|
||||
var setting = settings.Get("LaunchTSRAIRGo");
|
||||
settings.Remove(setting);
|
||||
setting.Value.ValueXml.InnerXml = launchTSRAIRGoValue ? "True" : "False";
|
||||
settings.Add(setting);
|
||||
config.Save(ConfigurationSaveMode.Full);
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log($"Failed to update tsr air app settings {ex.Message}");
|
||||
//nothing to do right now
|
||||
}
|
||||
}
|
||||
public static bool GetNewSettings(string settingsType, string targetDir,
|
||||
out string result, out SettingElementCollection newSettings, out Configuration newConfig)
|
||||
{
|
||||
result = string.Empty;
|
||||
newSettings = null;
|
||||
newConfig = null;
|
||||
|
||||
var newPath = string.Empty;
|
||||
try
|
||||
{
|
||||
//Open the new config file just installed
|
||||
newPath = Path.Combine(targetDir, Resources.RegistryDataPROExe);
|
||||
newConfig = ConfigurationManager.OpenExeConfiguration(@newPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log($"In catch: {ex.Message}");
|
||||
result = string.Format(Resources.NewSettingsCouldNotBeFound, ex.Message, newPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
APILogger.Log($"newPath & newConfig found; calling GetConfigSettings with {settingsType}");
|
||||
newSettings = GetConfigSettings(settingsType, newConfig);
|
||||
APILogger.Log($"back from GetConfigSettings; newSettings = {newSettings}");
|
||||
if (newSettings != null) return true;
|
||||
|
||||
result = Resources.NewSettingsCouldNotBeProcessed;
|
||||
return false;
|
||||
}
|
||||
private static SettingElementCollection GetConfigSettings(string settingsType, Configuration config)
|
||||
{
|
||||
var clientSettingsSection = new ClientSettingsSection();
|
||||
var configurationSectionGroup = config.SectionGroups[settingsType];
|
||||
if ((configurationSectionGroup != null) && (configurationSectionGroup.Sections[0] != null))
|
||||
{
|
||||
clientSettingsSection = configurationSectionGroup.Sections[0] as ClientSettingsSection;
|
||||
}
|
||||
return clientSettingsSection?.Settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,469 @@
|
||||
/*
|
||||
SaeJ211FilterUtility.cs
|
||||
|
||||
$Log: FilterUtility.cs,v $
|
||||
Revision 1.3 2008/11/11 21:56:41 DTS\paul.hrissikopoulos
|
||||
Added Brian's suggested filtering changes.
|
||||
|
||||
Revision 1.2 2007/01/26 21:53:50 Paul Hrissikopoulos
|
||||
Added bulk of October 2003 SAE J211-compliant filter utility implementation.
|
||||
|
||||
Revision 1.1 2007/01/13 00:42:00 Paul Hrissikopoulos
|
||||
Added initial support for October 2003-compliant filtering.
|
||||
|
||||
Revision 1.3 2006/10/26 22:06:47 Paul Hrissikopoulos
|
||||
Added channel data filtering.
|
||||
|
||||
Revision 1.2 2006/10/23 16:07:16 Paul Hrissikopoulos
|
||||
Added data filtering phase and related support.
|
||||
|
||||
Revision 1.1 2006/10/18 23:44:11 Paul Hrissikopoulos
|
||||
Added SaeJ211FilterUtility class.
|
||||
|
||||
Copyright © 2006
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Utilities.SaeJ211
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility for filtering data according to the NHTSA implementation of the
|
||||
/// SAE J211 standard.
|
||||
/// </summary>
|
||||
public class FilterUtility : Exceptional
|
||||
{
|
||||
/// <summary>
|
||||
/// Get/set the calibration scaling factor to be applied to data, post-filtering.
|
||||
/// Useful for "last minute" scaling or inversion. Defaults to "1.0".
|
||||
/// </summary>
|
||||
public double CalibrationFactor
|
||||
{
|
||||
get => _CalibrationFactor.Value;
|
||||
set => _CalibrationFactor.Value = value;
|
||||
}
|
||||
private readonly RangeRestrictedDoubleProperty _CalibrationFactor
|
||||
= new RangeRestrictedDoubleProperty(-1.0, 1.0, 1.0, true);
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the sampling rate (samples/sec) of the data to be filtered. This
|
||||
/// property must be set by user before the data can be filtered.
|
||||
/// </summary>
|
||||
public double SampleRate
|
||||
{
|
||||
get => _SampleRate.Value;
|
||||
set => _SampleRate.Value = value;
|
||||
}
|
||||
private readonly RangeRestrictedDoubleProperty _SampleRate
|
||||
= new RangeRestrictedDoubleProperty(0.0, 1000000000.0, 0, false);
|
||||
|
||||
/// <summary>
|
||||
/// Get/set SAE Channel Filter Class to be applied to data. This property must
|
||||
/// be set by user before the data can be filtered.
|
||||
/// </summary>
|
||||
public ChannelFilter Cfc
|
||||
{
|
||||
get => _ChannelFilter.Value;
|
||||
set => _cfc = new CfcValueAttributeCoder().DecodeAttributeValue(_ChannelFilter.Value = value);
|
||||
}
|
||||
private readonly Property<ChannelFilter> _ChannelFilter
|
||||
= new Property<ChannelFilter>(
|
||||
typeof(FilterUtility).Namespace + ".FilterUtility.ChannelFilter",
|
||||
ChannelFilter.Unfiltered,
|
||||
false
|
||||
);
|
||||
double _cfc;
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the <see cref="double"/> ad hoc frequency of this filter.
|
||||
/// </summary>
|
||||
public double AdHocFrequency
|
||||
{
|
||||
get => _AdHocFrequency.Value;
|
||||
set => _AdHocFrequency.Value = value;
|
||||
}
|
||||
private readonly Property<double> _AdHocFrequency
|
||||
= new Property<double>(
|
||||
typeof(FilterUtility).Namespace + ".FilterUtility",
|
||||
-1,
|
||||
false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the zero baseline flag. Defaults to "false".
|
||||
/// </summary>
|
||||
public bool ZeroBaseline
|
||||
{
|
||||
get => _ZeroBaseline.Value;
|
||||
set => _ZeroBaseline.Value = value;
|
||||
}
|
||||
private readonly Property<bool> _ZeroBaseline
|
||||
= new Property<bool>(
|
||||
typeof(FilterUtility).Namespace + ".FilterUtility.ZeroBaseline",
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the size (in sec) of the padding added to the beginning and ending of
|
||||
/// the data before filtering to "squelch out" startup spikes. A negative value
|
||||
/// will cause pad to default to 5% of data size.
|
||||
/// </summary>
|
||||
public double PadSize
|
||||
{
|
||||
get => _PadSize.Value;
|
||||
set => _PadSize.Value = value;
|
||||
}
|
||||
private readonly Property<double> _PadSize
|
||||
= new Property<double>(
|
||||
typeof(FilterUtility).Namespace + ".FilterUtility.PadSize",
|
||||
-1.0,
|
||||
true
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Types of pre/post-padding data population available.
|
||||
/// </summary>
|
||||
public enum DataPaddingType
|
||||
{
|
||||
/// <summary>
|
||||
/// Create data padding by repeatedly copying value of first and last samples.
|
||||
/// </summary>
|
||||
FirstAndLast,
|
||||
|
||||
/// <summary>
|
||||
/// Create data padding by mirroring data at beginning and end of data vector.
|
||||
/// </summary>
|
||||
Mirror,
|
||||
|
||||
/// <summary>
|
||||
/// Pad the data with zeros
|
||||
/// </summary>
|
||||
Zero
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the type of data padding appended/prepended to the data prior to
|
||||
/// being subjected to the filtering algorithm.
|
||||
/// </summary>
|
||||
public DataPaddingType DataPadding
|
||||
{
|
||||
get => _DataPadding.Value;
|
||||
set => _DataPadding.Value = value;
|
||||
}
|
||||
private readonly Property<DataPaddingType> _DataPadding
|
||||
= new Property<DataPaddingType>(
|
||||
typeof(FilterUtility).Namespace + ".FilterUtility.DataPaddingType",
|
||||
DataPaddingType.Mirror,
|
||||
true
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get the string that describes the type of filtering performed by this object.
|
||||
/// </summary>
|
||||
public string Type => "Butterworth, 4-pole";
|
||||
|
||||
public uint NumberOfPreDataPointsToInclude
|
||||
{
|
||||
get => _NumberOfPreDataPointsToInclude.Value;
|
||||
set => _NumberOfPreDataPointsToInclude.Value = value;
|
||||
}
|
||||
|
||||
private readonly Property<uint> _NumberOfPreDataPointsToInclude
|
||||
= new Property<uint>(typeof(FilterUtility).Namespace + ".FilterUtility.NumberOfPreDataPointsToInclude",
|
||||
0, true);
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the SaeJ211FilterUtility class.
|
||||
/// </summary>
|
||||
public FilterUtility()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert the specified frequency to an equivalent CFC value. Note that the
|
||||
/// "Big 4" CFC values get slightly special treatment.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="frequency">
|
||||
/// The <see cref="double"/> frequency to be converted.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="double"/> CFC equivalent of the specified frequency.
|
||||
/// </returns>
|
||||
///
|
||||
private double FrequencyToCfc(double frequency)
|
||||
{
|
||||
try
|
||||
{
|
||||
double cfc = -1;
|
||||
foreach (ChannelFilter filter in Enum.GetValues(typeof(ChannelFilter)))
|
||||
{
|
||||
if (frequency == (int)filter)
|
||||
{
|
||||
cfc = new CfcValueAttributeCoder().DecodeAttributeValue(filter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cfc >= 0 ? cfc : frequency * 0.6;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new FilterUtility.Exception("encountered problem converting frequency to CFC value", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void InvalidDataDelegate();
|
||||
public delegate void SetProgressDelegate(double value = -1D);
|
||||
/// <summary>
|
||||
/// Apply the SAE J211 filter algorithm (4-pole, phaseless, lo-pass) to the specified
|
||||
/// data using to the current FilterTool properties.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="data">
|
||||
/// An array of <see cref="double"/>s containing the raw data to be filtered.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="bUseLegacyTDCFilterAdjustment"></param>
|
||||
/// <param name="invalidDataFunc"></param>
|
||||
/// <returns>
|
||||
/// An array of <see cref="double"/>s containing the filtered data.
|
||||
/// </returns>
|
||||
///
|
||||
public virtual double[] ApplyFilter(double[] data, InvalidDataDelegate invalidDataFunc = null, bool bUseLegacyTDCFilterAdjustment = false,
|
||||
SetProgressDelegate setProgress = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null != invalidDataFunc)
|
||||
{
|
||||
var invalids = from d in data where double.IsNaN(d) select d;
|
||||
if (invalids.Any())
|
||||
{
|
||||
invalidDataFunc();
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPLEMENTATION NOTE:
|
||||
//
|
||||
// Pads the data with 5% of the original buffer size fore and aft to "squelch" out
|
||||
// filter start-up spikes. Optionally zeros baseline by subtracting the average
|
||||
// of the first 5% of the original data points (skips data which is padded by this
|
||||
// method). Optionally scales the data after filtering.
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (null == data)
|
||||
throw new ArgumentNullException("attempted to apply filter to null data buffer reference");
|
||||
|
||||
else
|
||||
{
|
||||
if (Cfc == ChannelFilter.Unfiltered) return data;
|
||||
if (Cfc == ChannelFilter.UnfilteredZero) { return data; }
|
||||
double t, pi, wd, wa, d0, d1, d2, e1, e2;
|
||||
double f1, f2, f3, f4, f5;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Formula setup
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
t = 1.0 / SampleRate;
|
||||
pi = 4.0 * System.Math.Atan(1.0);
|
||||
wd = 2.0 * pi * (Cfc == ChannelFilter.AdHoc ? FrequencyToCfc(AdHocFrequency) : _cfc) * 2.0775;
|
||||
wa = (System.Math.Sin(wd * (t / 2.0))) / (System.Math.Cos(wd * (t / 2.0))); // The original formula
|
||||
d0 = (wa * wa) / (1 + System.Math.Sqrt(2.0) * wa + (wa * wa));
|
||||
d1 = 2.0 * d0;
|
||||
d2 = d0;
|
||||
e1 = -2.0 * ((wa * wa) - 1) / (1 + System.Math.Sqrt(2.0) * wa + (wa * wa));
|
||||
e2 = (-1 + System.Math.Sqrt(2.0) * wa - (wa * wa)) / (1 + System.Math.Sqrt(2.0) * wa + (wa * wa));
|
||||
|
||||
var DataEnd = data.Length - 1;
|
||||
int Pad;
|
||||
|
||||
if (PadSize >= 0.0)
|
||||
{
|
||||
Pad = (int)(PadSize * SampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate padding as either 5% of all data, or the time required
|
||||
// for theoretical filter stabilization.
|
||||
Pad = (int)System.Math.Max(0.05 * DataEnd, 4 / AdHocFrequency * SampleRate);
|
||||
}
|
||||
|
||||
var Z = new double[2 * Pad + data.Length];
|
||||
var A = new double[2 * Pad + data.Length];
|
||||
var paddedData = new double[2 * Pad + data.Length];
|
||||
|
||||
var FirstIndexOfBeginPad = 0;
|
||||
var LastIndexOfBeginPad = Pad - 1;
|
||||
if ((DataPadding == DataPaddingType.Mirror) && (Pad - FirstIndexOfBeginPad >= data.Length))
|
||||
{ // Avoid fault in Mirror mode
|
||||
DataPadding = DataPaddingType.FirstAndLast;
|
||||
}
|
||||
switch (DataPadding)
|
||||
{ //
|
||||
// Populate the start-side pad according to this instance's current
|
||||
// DataPadding setting.
|
||||
//
|
||||
case DataPaddingType.FirstAndLast:
|
||||
for (var i = FirstIndexOfBeginPad; i <= LastIndexOfBeginPad; i++)
|
||||
paddedData[i] = data[0]; // 1st point of data
|
||||
break;
|
||||
|
||||
case DataPaddingType.Mirror:
|
||||
for (var i = FirstIndexOfBeginPad; i <= LastIndexOfBeginPad; i++)
|
||||
paddedData[i] = data[Pad - i]; // Mirror of data
|
||||
break;
|
||||
|
||||
case DataPaddingType.Zero:
|
||||
for (var i = FirstIndexOfBeginPad; i <= LastIndexOfBeginPad; i++)
|
||||
paddedData[i] = 0;
|
||||
break;
|
||||
default:
|
||||
|
||||
throw new FilterUtility.Exception("implementor attempted to use an undefined data padding type");
|
||||
}
|
||||
|
||||
// Copy raw data into newData after initial pad.
|
||||
var FirstIndexOfData = LastIndexOfBeginPad + 1;
|
||||
var LastIndexOfData = FirstIndexOfData + DataEnd;
|
||||
for (var i = FirstIndexOfData; i <= LastIndexOfData; i++)
|
||||
paddedData[i] = data[i - Pad];
|
||||
|
||||
var FirstIndexOfEndPad = LastIndexOfData + 1;
|
||||
var LastIndexOfEndPad = LastIndexOfData + Pad;
|
||||
switch (DataPadding)
|
||||
{ //
|
||||
// Populate the end-side pad according to this instance's current
|
||||
// DataPadding setting.
|
||||
//
|
||||
case DataPaddingType.FirstAndLast:
|
||||
for (var i = FirstIndexOfEndPad; i <= LastIndexOfEndPad; i++)
|
||||
paddedData[i] = data[DataEnd]; // Last point of data
|
||||
break;
|
||||
|
||||
case DataPaddingType.Mirror:
|
||||
for (var i = FirstIndexOfEndPad; i <= LastIndexOfEndPad; i++)
|
||||
paddedData[i] = paddedData[2 * LastIndexOfData - i]; // Mirror of data
|
||||
break;
|
||||
|
||||
case DataPaddingType.Zero:
|
||||
for (var i = FirstIndexOfEndPad; i <= LastIndexOfEndPad; i++)
|
||||
paddedData[i] = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw new FilterUtility.Exception("implementor attempted to use an undefined data padding type");
|
||||
}
|
||||
|
||||
var PaddedDataEnd = LastIndexOfEndPad; // DataEnd + 2 * Pad;
|
||||
|
||||
|
||||
// You need to set initial values before the calculation
|
||||
for (var i = 0; i <= 9; i++)
|
||||
Z[PaddedDataEnd] += 0.1 * paddedData[i];
|
||||
Z[PaddedDataEnd - 1] = Z[PaddedDataEnd];
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Data passed through filter backward
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
long travel = (PaddedDataEnd - 2);
|
||||
var progress = 0D;
|
||||
for (var j = travel; j >= 0; j--)
|
||||
{
|
||||
f1 = (d0 * paddedData[j]); // Breaking
|
||||
f2 = (d1 * paddedData[j + 1]); // down
|
||||
f3 = (d2 * paddedData[j + 2]); // a big
|
||||
f4 = (e1 * Z[j + 1]); // formula
|
||||
f5 = (e2 * Z[j + 2]); // into smaller "groups".
|
||||
Z[j] = f1 + f2 + f3 + f4 + f5; // Putting the "groups" back together
|
||||
var percent = System.Math.Floor(33D * ((travel - j) / (double)travel));
|
||||
if (percent > progress) { setProgress?.Invoke(percent); progress = percent; }
|
||||
}
|
||||
setProgress?.Invoke(33);
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Data passed through filter forward
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// You need to set initial values before the calculation
|
||||
for (var i = 0; i <= 9; i++)
|
||||
A[0] += 0.1 * Z[i];
|
||||
A[1] = A[0];
|
||||
|
||||
for (var k = 3; k <= PaddedDataEnd; k++)
|
||||
{
|
||||
f1 = (d0 * Z[k]); // Breaking
|
||||
f2 = (d1 * Z[k - 1]); // down
|
||||
f3 = (d2 * Z[k - 2]); // a big
|
||||
f4 = (e1 * A[k - 1]); // formula
|
||||
f5 = (e2 * A[k - 2]); // into smaller "groups".
|
||||
A[k] = f1 + f2 + f3 + f4 + f5; // Putting the "groups" back together
|
||||
var percent = System.Math.Floor(33 + 33D * ((PaddedDataEnd - k) / (double)PaddedDataEnd));
|
||||
if (percent > progress) { setProgress?.Invoke(percent); progress = percent; }
|
||||
}
|
||||
setProgress?.Invoke(66);
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Prepare baseline calculation, if required
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
var baselineSum = 0.0;
|
||||
|
||||
// Compute baseline if it's going to be applied.
|
||||
if (ZeroBaseline)
|
||||
for (var n = Pad; n <= (2 * Pad); n++)
|
||||
baselineSum += A[n];
|
||||
|
||||
// Baseline adjustment.
|
||||
var adjust = baselineSum / Pad;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Apply baseline and/or calibration factor, then finalize filtered data
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
var filteredIndex = 0;
|
||||
var filteredData = new double[data.Length];
|
||||
//8747 - TDC data shifts one point when filtered
|
||||
//this allows us to preserve that shift on demand
|
||||
var numOfPreDataPointsToInclude = NumberOfPreDataPointsToInclude;
|
||||
if (bUseLegacyTDCFilterAdjustment)
|
||||
{
|
||||
numOfPreDataPointsToInclude++;
|
||||
}
|
||||
travel = (PaddedDataEnd - (Pad + numOfPreDataPointsToInclude)) - (Pad - numOfPreDataPointsToInclude);
|
||||
for (var k = (int)(Pad - numOfPreDataPointsToInclude); k <= (PaddedDataEnd - (Pad + numOfPreDataPointsToInclude)); k++)
|
||||
{
|
||||
// Zero baseline, if requested.
|
||||
if (ZeroBaseline)
|
||||
A[k] = A[k] - adjust;
|
||||
|
||||
// Multiplying by the calibration factor unless factor is 1.0
|
||||
// AFTER the filtering has been finished.
|
||||
if (1.0 != CalibrationFactor)
|
||||
A[k] = A[k] * CalibrationFactor;
|
||||
|
||||
// Copy finished product into return buffer.
|
||||
filteredData[filteredIndex++] = A[k];
|
||||
var percent = System.Math.Floor(66D + 33D * (filteredIndex / (double)travel));
|
||||
if (percent > progress) { setProgress?.Invoke(percent); progress = percent; }
|
||||
}
|
||||
setProgress?.Invoke(100);
|
||||
// The deed is done. Share the pain.
|
||||
return filteredData;
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new FilterUtility.Exception("encountered problem SAE J211-filtering data", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
DescriptionAttributeCoder.cs
|
||||
|
||||
* 12/18/2008 Relo'd from Dave to SVN-controlled utilities project.
|
||||
|
||||
$Log: DescriptionAttributeCoder.cs,v $
|
||||
Revision 1.1 2006/09/14 18:41:54 Paul Hrissikopoulos
|
||||
Moved AttributeCoder files from Dave solution.
|
||||
|
||||
Revision 1.2 2006/09/07 20:43:08 Paul Hrissikopoulos
|
||||
Expanded commentary.
|
||||
|
||||
Revision 1.1 2006/08/17 23:05:11 Paul Hrissikopoulos
|
||||
Added generically-derived SelectionCriterion.ComparisonType enumeration attributes.
|
||||
|
||||
Copyright © 2006
|
||||
Diversified Technical Services
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for "matching" <see cref="DescriptionAttribute"/>s and the "TargetType" data
|
||||
/// type data type they're attached to.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="TTargetType">
|
||||
/// The data type the attribute being encoded to/decoded from is attached to.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Generally useful with enumeration target types in which each enumeration value
|
||||
/// has a specific "DescriptionAttribute" assigned to it. This class essentially
|
||||
/// allows one to "encode" the a specific description value into the enumeration
|
||||
/// value it's attached to, as well as "decode" an enumeration into the description
|
||||
/// that's attached to it. For example, if we create an enumeration type whose
|
||||
/// values at some point need to be converted to string values (and back again),
|
||||
/// we can simply attach DescriptionAttributes containing the string conversion
|
||||
/// to each value in the enumeration definition and use the DescriptionAttributeCoder
|
||||
/// to convert directly from one to the other without the need for any kind of
|
||||
/// seperate lookup table.
|
||||
///</remarks>
|
||||
///
|
||||
public class DescriptionAttributeCoder<TTargetType>
|
||||
: AttributeCoder<TTargetType, DescriptionAttribute, string>
|
||||
{
|
||||
/// <summary>
|
||||
/// constructs a <see cref="T:DescriptionAttributeCoder" /> object
|
||||
/// </summary>
|
||||
public DescriptionAttributeCoder()
|
||||
: base(delegate (DescriptionAttribute attribute) { return attribute.Description; },
|
||||
delegate (string s1, string s2) { return s1.Equals(s2, StringComparison.OrdinalIgnoreCase); })
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
/*
|
||||
* ActiveUpdateList.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// An extension of the standard <see cref="T:List"/> class that provides active notification to
|
||||
/// registered callbacks whenever items are added to or removed from the list.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="T">
|
||||
/// The type of object contained in this list.
|
||||
/// </typeparam>
|
||||
///
|
||||
public class ActiveUpdateList<T> : ExceptionalList<T>
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Initialize an instance of this class.
|
||||
/// </summary>
|
||||
///
|
||||
public ActiveUpdateList()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of this class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="capacity">
|
||||
/// The number of elements that the list can initially store.
|
||||
/// </param>
|
||||
///
|
||||
public ActiveUpdateList(int capacity)
|
||||
: base(capacity)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of this class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="collection">
|
||||
/// The collection whose elements are copied to the new list.
|
||||
/// </param>
|
||||
///
|
||||
public ActiveUpdateList(IEnumerable<T> collection)
|
||||
: base(collection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The argument type passed to "on items added" and "on items removed" callbacks. It contains
|
||||
/// a list of the items that have been added/removed.
|
||||
/// </summary>
|
||||
public class EventArgs : System.EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// construct an empty collection of items
|
||||
/// </summary>
|
||||
public EventArgs() { }
|
||||
/// <summary>
|
||||
/// construct a collection of items
|
||||
/// </summary>
|
||||
/// <param name="items">arguments to add</param>
|
||||
public EventArgs(IEnumerable<T> items) { Items = items; }
|
||||
public IEnumerable<T> Items { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The type of the callbacks issued by this class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="sender">
|
||||
/// The <see cref="object"/> responsible for generating this event.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="args">
|
||||
/// The <see cref="T:ActiveUpdateList.EventArgs"/> for this event.
|
||||
/// </param>
|
||||
///
|
||||
public delegate void EventHandler(object sender, EventArgs args);
|
||||
|
||||
/// <summary>
|
||||
/// The event generated whenever items are added to this object's list.
|
||||
/// </summary>
|
||||
public event EventHandler OnItemsAdded;
|
||||
|
||||
/// <summary>
|
||||
/// The event generated whenever items are removed from this list.
|
||||
/// </summary>
|
||||
public event EventHandler OnItemsRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// Adds an object to the end of the <see cref="T:ActiveUpdateList"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="item">
|
||||
/// The item to be added to this list.
|
||||
/// </param>
|
||||
///
|
||||
/// <exception cref="T:ActiveUpdateList.Exception">
|
||||
/// All exceptions generated by this method will be nested in one of these.
|
||||
/// </exception>
|
||||
///
|
||||
public new void Add(T item)
|
||||
{
|
||||
try
|
||||
{
|
||||
base.Add(item);
|
||||
var addList = new List<T>();
|
||||
addList.Add(item);
|
||||
|
||||
OnItemsAdded?.Invoke(this, new EventArgs(addList));
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem adding item to active update list", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the elements of the specified collection to the end of the <see cref="T:ActiveUpdateList"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="collection">
|
||||
/// The collection to the added to this list.
|
||||
/// </param>
|
||||
///
|
||||
/// <exception cref="T:ActiveUpdateList.Exception">
|
||||
/// All exceptions generated by this method will be nested in one of these.
|
||||
/// </exception>
|
||||
///
|
||||
public new void AddRange(IEnumerable<T> collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
var enumerable = collection as T[] ?? collection.ToArray();
|
||||
base.AddRange(enumerable);
|
||||
|
||||
OnItemsAdded?.Invoke(this, new EventArgs(enumerable));
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem adding range to active update list", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all elements from the <see cref="T:ActiveUpdateList"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <exception cref="T:ActiveUpdateList.Exception">
|
||||
/// All exceptions generated by this method will be nested in one of these.
|
||||
/// </exception>
|
||||
///
|
||||
public new void Clear()
|
||||
{
|
||||
try
|
||||
{
|
||||
var removedItems = new List<T>();
|
||||
foreach (var item in this)
|
||||
removedItems.Add(item);
|
||||
base.Clear();
|
||||
|
||||
OnItemsRemoved?.Invoke(this, new EventArgs(removedItems));
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem clearing active update list", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts the elements of a collection into the <see cref="T:ActiveUpdateList"/> at the
|
||||
/// specified index.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="index">
|
||||
/// The zero-based index at which the new elements should be inserted.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="collection">
|
||||
/// The collection whose elements should be inserted into the T:ActiveUpdateList.
|
||||
/// The collection itself cannot be null, but it can contain elements that are
|
||||
/// null, if type T is a reference type.
|
||||
/// </param>
|
||||
///
|
||||
/// <exception cref="T:ActiveUpdateList.Exception">
|
||||
/// All exceptions generated by this method will be nested in one of these.
|
||||
/// </exception>
|
||||
///
|
||||
public new void InsertRange(int index, IEnumerable<T> collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
var enumerable = collection as T[] ?? collection.ToArray();
|
||||
base.InsertRange(index, enumerable);
|
||||
|
||||
OnItemsAdded?.Invoke(this, new EventArgs(enumerable));
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem inserting range in active update list", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific object from the <see cref="T:ActiveUpdateList"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="item">
|
||||
/// The object to remove from the <see cref="T:System.Collections.Generic.List" />. The value
|
||||
/// can be null for reference types.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// <see cref="bool"/> true if item is successfully removed; otherwise, false. This method also
|
||||
/// returns false if item was not found in the <see cref="T:ActiveUpdateList"/>.
|
||||
/// </returns>
|
||||
///
|
||||
/// <exception cref="T:ActiveUpdateList.Exception">
|
||||
/// All exceptions generated by this method will be nested in one of these.
|
||||
/// </exception>
|
||||
///
|
||||
public new bool Remove(T item)
|
||||
{
|
||||
try
|
||||
{
|
||||
var success = base.Remove(item);
|
||||
var removeList = new List<T>();
|
||||
removeList.Add(item);
|
||||
|
||||
OnItemsRemoved?.Invoke(this, new EventArgs(removeList));
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem removing item from active update list", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the all the elements that match the conditions defined by the specified
|
||||
/// predicate.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="match">
|
||||
/// The <see cref="T:System.Predicate"/> delegate that defines the conditions of the elements
|
||||
/// to remove.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The number of elements removed from the <see cref="T:ActiveUpdateList"/>
|
||||
/// </returns>
|
||||
///
|
||||
/// <exception cref="T:ActiveUpdateList.Exception">
|
||||
/// All exceptions generated by this method will be nested in one of these.
|
||||
/// </exception>
|
||||
///
|
||||
public new int RemoveAll(Predicate<T> match)
|
||||
{
|
||||
try
|
||||
{
|
||||
var removeList = FindAll(match);
|
||||
var numberOfItemsRemoved = base.RemoveAll(match);
|
||||
OnItemsRemoved?.Invoke(this, new EventArgs(removeList));
|
||||
|
||||
return numberOfItemsRemoved;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem removing all matching items from active update list", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the element at the specified index of the <see cref="T:ActiveUpdateList"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="index">
|
||||
/// The zero-based index of the element to remove.
|
||||
/// </param>
|
||||
///
|
||||
/// <exception cref="T:ActiveUpdateList.Exception">
|
||||
/// All exceptions generated by this method will be nested in one of these.
|
||||
/// </exception>
|
||||
///
|
||||
public new void RemoveAt(int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
var removeList = new List<T>();
|
||||
removeList.Add(base[index]);
|
||||
base.RemoveAt(index);
|
||||
|
||||
OnItemsRemoved?.Invoke(this, new EventArgs(removeList));
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem removing item at specified index from active update list", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a range of elements from the <see cref="T:ActiveUpdateList"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="index">
|
||||
/// The zero-based starting index of the range of elements to remove.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="count">
|
||||
/// The number of elements to remove.
|
||||
/// </param>
|
||||
///
|
||||
/// <exception cref="T:ActiveUpdateList.Exception">
|
||||
/// All exceptions generated by this method will be nested in one of these.
|
||||
/// </exception>
|
||||
///
|
||||
public new void RemoveRange(int index, int count)
|
||||
{
|
||||
try
|
||||
{
|
||||
var removeList = GetRange(index, count);
|
||||
base.RemoveRange(index, count);
|
||||
|
||||
OnItemsRemoved?.Invoke(this, new EventArgs(removeList));
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem removing range from active update list", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// helper class for reading and processing GM Milford INI files, hopefully in the future this can be expanded into a general Export.ini file
|
||||
/// </summary>
|
||||
public class ExportINIFile
|
||||
{
|
||||
public string Location { get; }
|
||||
public string RemoteSaveArchiveData { get; }
|
||||
public string LocalSaveArchiveData { get; }
|
||||
public string ISFPathLocation { get; }
|
||||
public string JCLDir { get; }
|
||||
public string RemoteSaveROIData { get; }
|
||||
public string LocalSaveROIData { get; }
|
||||
public string RemoteSaveISF { get; }
|
||||
public string LocalSaveISF { get; }
|
||||
public string RemoteBinaryAllData { get; }
|
||||
public string LocalBinaryAllData { get; }
|
||||
public string RemoteBinaryROIData { get; }
|
||||
public string LocalBinaryROIData { get; }
|
||||
public string LocalXMLSetup { get; }
|
||||
public string RemoteXMLSetup { get; }
|
||||
public string LocalExportData { get; }
|
||||
public string RemoteExportData { get; }
|
||||
public string LocalLogsData { get; }
|
||||
public string RemoteLogsData { get; }
|
||||
public string LocalReportsData { get; }
|
||||
public string RemoteReportsData { get; }
|
||||
|
||||
public enum Rows
|
||||
{
|
||||
[FileLineAttr("---- Default Directories to Save GM Data (remote is default if available) ----")]
|
||||
DefaultDirectoriesComment,
|
||||
[FileLineAttr("remote_save_archive_data=")]
|
||||
RemoteSaveArchiveData,
|
||||
[FileLineAttr("local_save_archive_data=")]
|
||||
LocalSaveArchiveData,
|
||||
[FileLineAttr("---- Default Directory to Read GM ISF ----")]
|
||||
DefaultDirectoryToReadGMISFComment,
|
||||
[FileLineAttr("ISF_path_location=")]
|
||||
ISFPathLocation,
|
||||
[FileLineAttr("---- ROI & JCL file location ----")]
|
||||
ROIAndJCLFileLocationComment,
|
||||
[FileLineAttr("JCL_Dir=")]
|
||||
JCLDir,
|
||||
[FileLineAttr("remote_save_roi_data=")]
|
||||
RemoteSaveROIData,
|
||||
[FileLineAttr("local_save_roi_data=")]
|
||||
LocalSaveROIData,
|
||||
[FileLineAttr("remote_save_isf=")]
|
||||
RemoteSaveISF,
|
||||
[FileLineAttr("local_save_isf=")]
|
||||
LocalSaveISF,
|
||||
[FileLineAttr("---- End INI File ----")]
|
||||
EOFComment,
|
||||
[FileLineAttr("---- Default Directories to Save Data (remote is default if available) ----")]
|
||||
GenericSaveDataComment,
|
||||
[FileLineAttr("---- Binary ALL Upload Folders ----")]
|
||||
GenericAllUploadFolders,
|
||||
[FileLineAttr("remote_binary_all_data=")]
|
||||
RemoteBinaryAllData,
|
||||
[FileLineAttr("local_binary_all_data=")]
|
||||
LocalBinaryAllData,
|
||||
[FileLineAttr("---- Binary ROI Upload Folders ----")]
|
||||
GenericROIUploadFolders,
|
||||
[FileLineAttr("remote_binary_roi_data=")]
|
||||
RemoteBinaryROIData,
|
||||
[FileLineAttr("local_binary_roi_data=")]
|
||||
LocalBinaryROIData,
|
||||
[FileLineAttr("---- XML Setup Upload Folders ----")]
|
||||
XMLSetupUploadFolders,
|
||||
[FileLineAttr("local_xml_setup=")]
|
||||
LocalXMLSetup,
|
||||
[FileLineAttr("remote_xml_setup=")]
|
||||
RemoteXMLSetup,
|
||||
[FileLineAttr("---- Export Upload Folders ----")]
|
||||
ExportUploadFolders,
|
||||
[FileLineAttr("local_export_data=")]
|
||||
LocalExportData,
|
||||
[FileLineAttr("remote_export_data=")]
|
||||
RemoteExportData,
|
||||
[FileLineAttr("---- Logs Upload Folders ----")]
|
||||
LogsUploadFolders,
|
||||
[FileLineAttr("local_logs_data=")]
|
||||
LocalLogsData,
|
||||
[FileLineAttr("remote_logs_data=")]
|
||||
RemoteLogsData,
|
||||
[FileLineAttr("---- Reports Upload Folders ----")]
|
||||
ReportsUploadFolder,
|
||||
[FileLineAttr("local_reports_data=")]
|
||||
LocalReportsData,
|
||||
[FileLineAttr("remote_reports_data=")]
|
||||
RemoteReportsData
|
||||
}
|
||||
|
||||
public enum Errors
|
||||
{
|
||||
FILE_NOT_FOUND,
|
||||
FILE_NOT_READ,
|
||||
FILE_INCOMPLETE,
|
||||
FILE_INVALID_DATA
|
||||
}
|
||||
public class FileLineAttr : Attribute
|
||||
{
|
||||
public string LineString { get; }
|
||||
internal FileLineAttr(string attr)
|
||||
{
|
||||
LineString = attr;
|
||||
}
|
||||
public static string GetFileLine(object o)
|
||||
{
|
||||
if (o != null)
|
||||
{
|
||||
var mi = o.GetType().GetMember(o.ToString());
|
||||
if (mi != null && mi.Length > 0)
|
||||
{
|
||||
var attr = GetCustomAttribute(mi[0], typeof(FileLineAttr)) as FileLineAttr;
|
||||
if (null != attr)
|
||||
{
|
||||
return attr.LineString;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class ExportINIFileException : Exception
|
||||
{
|
||||
public Errors Error { get; }
|
||||
public ExportINIFileException(Errors error, string message)
|
||||
: base(string.Format("{0} - {1}", error.ToString(), message))
|
||||
{
|
||||
Error = error;
|
||||
}
|
||||
}
|
||||
|
||||
public ExportINIFile(string path)
|
||||
{
|
||||
if (!System.IO.File.Exists(path))
|
||||
{
|
||||
throw new ExportINIFileException(Errors.FILE_NOT_FOUND, path);
|
||||
}
|
||||
string[] lines;
|
||||
try
|
||||
{
|
||||
lines = System.IO.File.ReadAllLines(path);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new ExportINIFileException(Errors.FILE_NOT_READ, ex.Message);
|
||||
}
|
||||
if (null == lines || lines.Length < 2)
|
||||
{
|
||||
throw new ExportINIFileException(Errors.FILE_INCOMPLETE, path);
|
||||
}
|
||||
Location = lines[0];
|
||||
var rows = Enum.GetValues(typeof(Rows)).Cast<Rows>().ToArray();
|
||||
var bValid = false;
|
||||
for (var i = 1; i < lines.Length; i++)
|
||||
{
|
||||
var line = lines[i].Trim();
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var key = FileLineAttr.GetFileLine(row);
|
||||
if (line.StartsWith(key))
|
||||
{
|
||||
switch (row)
|
||||
{
|
||||
case Rows.DefaultDirectoriesComment: break; //just a comment line, nothing to store
|
||||
|
||||
case Rows.RemoteSaveArchiveData:
|
||||
RemoteSaveArchiveData = line.Substring(key.Length);
|
||||
break;
|
||||
case Rows.LocalSaveArchiveData:
|
||||
LocalSaveArchiveData = line.Substring(key.Length);
|
||||
break;
|
||||
|
||||
case Rows.DefaultDirectoryToReadGMISFComment: break; //just a comment line, nothing to store
|
||||
case Rows.ISFPathLocation:
|
||||
ISFPathLocation = line.Substring(key.Length);
|
||||
break;
|
||||
|
||||
case Rows.ROIAndJCLFileLocationComment: break; //just a comment line, nothing to store
|
||||
case Rows.JCLDir:
|
||||
JCLDir = line.Substring(key.Length);
|
||||
break;
|
||||
|
||||
case Rows.RemoteSaveROIData:
|
||||
RemoteSaveROIData = line.Substring(key.Length);
|
||||
break;
|
||||
case Rows.LocalSaveROIData:
|
||||
LocalSaveROIData = line.Substring(key.Length);
|
||||
break;
|
||||
|
||||
case Rows.RemoteSaveISF:
|
||||
RemoteSaveISF = line.Substring(key.Length);
|
||||
break;
|
||||
case Rows.LocalSaveISF:
|
||||
LocalSaveISF = line.Substring(key.Length);
|
||||
break;
|
||||
|
||||
case Rows.GenericSaveDataComment: break; //empty line
|
||||
case Rows.GenericAllUploadFolders: break; //empty line
|
||||
case Rows.GenericROIUploadFolders: break; //empty line
|
||||
case Rows.XMLSetupUploadFolders: break; //empty line
|
||||
case Rows.ExportUploadFolders: break; //empty line
|
||||
case Rows.LogsUploadFolders: break; //empty line
|
||||
case Rows.ReportsUploadFolder: break; //empty line
|
||||
|
||||
case Rows.RemoteBinaryAllData: RemoteBinaryAllData = line.Substring(key.Length); break;
|
||||
case Rows.LocalBinaryAllData: LocalBinaryAllData = line.Substring(key.Length); break;
|
||||
case Rows.RemoteBinaryROIData: RemoteBinaryROIData = line.Substring(key.Length); break;
|
||||
case Rows.LocalBinaryROIData: LocalBinaryROIData = line.Substring(key.Length); break;
|
||||
case Rows.LocalXMLSetup: LocalXMLSetup = line.Substring(key.Length); break;
|
||||
case Rows.RemoteXMLSetup: RemoteXMLSetup = line.Substring(key.Length); break;
|
||||
case Rows.LocalExportData: LocalExportData = line.Substring(key.Length); break;
|
||||
case Rows.RemoteExportData: RemoteExportData = line.Substring(key.Length); break;
|
||||
case Rows.LocalLogsData: LocalLogsData = line.Substring(key.Length); break;
|
||||
case Rows.RemoteLogsData: RemoteLogsData = line.Substring(key.Length); break;
|
||||
case Rows.LocalReportsData: LocalReportsData = line.Substring(key.Length); break;
|
||||
case Rows.RemoteReportsData: RemoteReportsData = line.Substring(key.Length); break;
|
||||
|
||||
case Rows.EOFComment:
|
||||
bValid = true; //for now the only thing we require is the end of file comment line ...
|
||||
break;
|
||||
default:
|
||||
//silently eat and log for now
|
||||
APILogger.Log("Export INI File parsing error, unknown field: " + row.ToString());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bValid)
|
||||
{
|
||||
throw new ExportINIFileException(Errors.FILE_INCOMPLETE, "EOF line not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DTS.Utilities
|
||||
{
|
||||
public static class SignalToNoiseRatio
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculates Noise given a full scale peak-to-peak
|
||||
/// </summary>
|
||||
/// <param name="values">Data set</param>
|
||||
/// <param name="fullScalePP">The full scale peak-to-peak of the data set; 65536.0 by default for ADC data</param>
|
||||
/// <returns></returns>
|
||||
public static double CalculateSNR(IEnumerable<double> values, double fullScalePP = 65536.0)
|
||||
{
|
||||
var stdDev = StandardDev.StandardDeviation(values);
|
||||
return -20 * System.Math.Log10(3.0 * stdDev / fullScalePP);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
Math.Operation.cs
|
||||
|
||||
24 November 2009 - Adapted from old Dave codebase to generic DTS utility.
|
||||
|
||||
$Log: Math.Operation.cs,v $
|
||||
Revision 1.3 2007/03/28 15:58:55 Paul Hrissikopoulos
|
||||
Fixed erroneous error-checking in Domain accessor.
|
||||
|
||||
Revision 1.2 2007/02/05 17:17:08 Paul Hrissikopoulos
|
||||
Finished installing generic channel math framework + basic calculus operations.
|
||||
|
||||
Revision 1.1 2007/02/02 22:34:09 Paul Hrissikopoulos
|
||||
Added framework for DAVE channel math operators.
|
||||
|
||||
Copyright © 2007
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
|
||||
namespace DTS.Common.Utilities.Math
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Representation of a generic operation that maps a domain to a range.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="DomainType">
|
||||
/// The input data type.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <typeparam name="RangeType">
|
||||
/// The output data type.
|
||||
/// </typeparam>
|
||||
///
|
||||
public abstract class Operation<DomainType, RangeType>
|
||||
: Exceptional
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get/set the domain of the differentiation.
|
||||
/// </summary>
|
||||
public DomainType Domain
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null == domain)
|
||||
throw new NullReferenceException("value has not been set");
|
||||
else return domain;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem getting Domain property", ex);
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null == value)
|
||||
throw new ArgumentNullException("attempted to set value to null reference");
|
||||
else domain = value;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem setting Domain property", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private DomainType domain;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get the result of the operation.
|
||||
/// </summary>
|
||||
public abstract RangeType Range { get; }
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Math.Operation class. As a matter of style,
|
||||
/// a domain is required for object creation.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="domain">
|
||||
/// The "DomainType" domain of this mathematical operation.
|
||||
/// </param>
|
||||
///
|
||||
public Operation(DomainType domain)
|
||||
{
|
||||
try { Domain = domain; }
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem constructing Math.Operation", ex);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,89 @@
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.SaeJ211;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Utilities
|
||||
{
|
||||
public static class DataConditioning
|
||||
{
|
||||
/// <summary>
|
||||
/// returns an integer part of a string that might contain a decimal
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
/// <returns></returns>
|
||||
public static int GetIntegerIfPossible(object o)
|
||||
{
|
||||
if (null == o) { throw new System.Exception("expected non null input parameter"); }
|
||||
var s = o.ToString();
|
||||
var index = s.IndexOf(".");
|
||||
if (index == 0) { return 0; }
|
||||
if (index > 0) { s = s.Substring(0, index); }
|
||||
return int.Parse(s);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets Zered EU data given a time window to average
|
||||
/// </summary>
|
||||
/// <param name="euData"></param>
|
||||
/// <param name="sampleRate"></param>
|
||||
/// <param name="triggerSample"></param>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <returns></returns>
|
||||
public static double[] GetAverageOverTimeEuData(
|
||||
double[] euData,
|
||||
double sampleRate,
|
||||
double triggerSample,
|
||||
double startTime,
|
||||
double endTime)
|
||||
{
|
||||
double[] zeroedEuData;
|
||||
var duration = endTime - startTime; //.3 - .2 = .1
|
||||
var startSample = (int)(triggerSample + (startTime * sampleRate));
|
||||
var endSample = (int)(startSample + (duration * sampleRate));
|
||||
var numSamples = endSample - startSample;
|
||||
if (numSamples <= 0) return euData;
|
||||
if (numSamples > euData.Length) return euData;
|
||||
var averagingSamples = new double[numSamples];
|
||||
var i = 0;
|
||||
for (var sampleNum = startSample; sampleNum < endSample; sampleNum++)
|
||||
{
|
||||
averagingSamples[i] = euData[sampleNum];
|
||||
i++;
|
||||
}
|
||||
var average = averagingSamples.Average();
|
||||
|
||||
var zeroedDataIndex = 0;
|
||||
zeroedEuData = new double[euData.Length];
|
||||
foreach (var sample in euData)
|
||||
{
|
||||
zeroedEuData[zeroedDataIndex] = sample - average; //If average is a negative number, the sample will be increased
|
||||
zeroedDataIndex++;
|
||||
}
|
||||
return zeroedEuData;
|
||||
}
|
||||
|
||||
public static double[] GetFilteredZeroedEUData(
|
||||
double[] euData,
|
||||
int filterRate,
|
||||
double sampleRate,
|
||||
double triggerSample,
|
||||
double startTime,
|
||||
double endTime)
|
||||
{
|
||||
return GetFilteredEUData(GetAverageOverTimeEuData(euData, sampleRate, triggerSample, startTime, endTime), filterRate, sampleRate);
|
||||
}
|
||||
|
||||
public static double[] GetFilteredEUData(double[] euData, int filterRate, double sampleRate)
|
||||
{
|
||||
if (filterRate <= 0) return euData;
|
||||
var filterUtility = new FilterUtility
|
||||
{
|
||||
Cfc = ChannelFilter.AdHoc,
|
||||
AdHocFrequency = filterRate,
|
||||
SampleRate = sampleRate
|
||||
};
|
||||
var filteredData = filterUtility.ApplyFilter(euData);
|
||||
return filteredData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DTS.Utilities
|
||||
{
|
||||
//FB 45077
|
||||
public static class TaskbarHelper
|
||||
{
|
||||
[DllImport("shell32.dll", SetLastError = true)]
|
||||
public static extern int SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DTS.Common.Utilities.LTLogging
|
||||
{
|
||||
public class LevelTriggerLogging
|
||||
{
|
||||
private static readonly object ltLock = new object();
|
||||
|
||||
private const string LEVEL_TRIGGER_LOG = @"Logs\LevelTriggerSettings.txt";
|
||||
public static void LevelTriggerLog(string msg)
|
||||
{
|
||||
lock (ltLock)
|
||||
{
|
||||
System.IO.File.AppendAllText(LEVEL_TRIGGER_LOG, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,473 @@
|
||||
/*
|
||||
SaeJ211FilterUtility.cs
|
||||
|
||||
$Log: FilterUtility.cs,v $
|
||||
Revision 1.3 2008/11/11 21:56:41 DTS\paul.hrissikopoulos
|
||||
Added Brian's suggested filtering changes.
|
||||
|
||||
Revision 1.2 2007/01/26 21:53:50 Paul Hrissikopoulos
|
||||
Added bulk of October 2003 SAE J211-compliant filter utility implementation.
|
||||
|
||||
Revision 1.1 2007/01/13 00:42:00 Paul Hrissikopoulos
|
||||
Added initial support for October 2003-compliant filtering.
|
||||
|
||||
Revision 1.3 2006/10/26 22:06:47 Paul Hrissikopoulos
|
||||
Added channel data filtering.
|
||||
|
||||
Revision 1.2 2006/10/23 16:07:16 Paul Hrissikopoulos
|
||||
Added data filtering phase and related support.
|
||||
|
||||
Revision 1.1 2006/10/18 23:44:11 Paul Hrissikopoulos
|
||||
Added SaeJ211FilterUtility class.
|
||||
|
||||
Copyright © 2006
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Utilities.SaeJ211
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility for filtering data according to the NHTSA implementation of the
|
||||
/// SAE J211 standard.
|
||||
/// </summary>
|
||||
public class FilterUtility : Exceptional
|
||||
{
|
||||
/// <summary>
|
||||
/// Get/set the calibration scaling factor to be applied to data, post-filtering.
|
||||
/// Useful for "last minute" scaling or inversion. Defaults to "1.0".
|
||||
/// </summary>
|
||||
public double CalibrationFactor
|
||||
{
|
||||
get => _CalibrationFactor.Value;
|
||||
set => _CalibrationFactor.Value = value;
|
||||
}
|
||||
private readonly RangeRestrictedDoubleProperty _CalibrationFactor
|
||||
= new RangeRestrictedDoubleProperty(-1.0, 1.0, 1.0, true);
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the sampling rate (samples/sec) of the data to be filtered. This
|
||||
/// property must be set by user before the data can be filtered.
|
||||
/// </summary>
|
||||
public double SampleRate
|
||||
{
|
||||
get => _SampleRate.Value;
|
||||
set => _SampleRate.Value = value;
|
||||
}
|
||||
private readonly RangeRestrictedDoubleProperty _SampleRate
|
||||
= new RangeRestrictedDoubleProperty(0.0, 1000000000.0, 0, false);
|
||||
|
||||
/// <summary>
|
||||
/// Get/set SAE Channel Filter Class to be applied to data. This property must
|
||||
/// be set by user before the data can be filtered.
|
||||
/// </summary>
|
||||
public ChannelFilter Cfc
|
||||
{
|
||||
get => _ChannelFilter.Value;
|
||||
set
|
||||
{
|
||||
_ChannelFilter.Value = value;
|
||||
_cfc = new CfcValueAttributeCoder().DecodeAttributeValue(_ChannelFilter.Value);
|
||||
}
|
||||
}
|
||||
private readonly Property<ChannelFilter> _ChannelFilter
|
||||
= new Property<ChannelFilter>(
|
||||
typeof(FilterUtility).Namespace + ".FilterUtility.ChannelFilter",
|
||||
ChannelFilter.Unfiltered,
|
||||
false
|
||||
);
|
||||
double _cfc;
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the <see cref="double"/> ad hoc frequency of this filter.
|
||||
/// </summary>
|
||||
public double AdHocFrequency
|
||||
{
|
||||
get => _AdHocFrequency.Value;
|
||||
set => _AdHocFrequency.Value = value;
|
||||
}
|
||||
private readonly Property<double> _AdHocFrequency
|
||||
= new Property<double>(
|
||||
typeof(FilterUtility).Namespace + ".FilterUtility",
|
||||
-1,
|
||||
false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the zero baseline flag. Defaults to "false".
|
||||
/// </summary>
|
||||
public bool ZeroBaseline
|
||||
{
|
||||
get => _ZeroBaseline.Value;
|
||||
set => _ZeroBaseline.Value = value;
|
||||
}
|
||||
private readonly Property<bool> _ZeroBaseline
|
||||
= new Property<bool>(
|
||||
typeof(FilterUtility).Namespace + ".FilterUtility.ZeroBaseline",
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the size (in sec) of the padding added to the beginning and ending of
|
||||
/// the data before filtering to "squelch out" startup spikes. A negative value
|
||||
/// will cause pad to default to 5% of data size.
|
||||
/// </summary>
|
||||
public double PadSize
|
||||
{
|
||||
get => _PadSize.Value;
|
||||
set => _PadSize.Value = value;
|
||||
}
|
||||
private readonly Property<double> _PadSize
|
||||
= new Property<double>(
|
||||
typeof(FilterUtility).Namespace + ".FilterUtility.PadSize",
|
||||
-1.0,
|
||||
true
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Types of pre/post-padding data population available.
|
||||
/// </summary>
|
||||
public enum DataPaddingType
|
||||
{
|
||||
/// <summary>
|
||||
/// Create data padding by repeatedly copying value of first and last samples.
|
||||
/// </summary>
|
||||
FirstAndLast,
|
||||
|
||||
/// <summary>
|
||||
/// Create data padding by mirroring data at beginning and end of data vector.
|
||||
/// </summary>
|
||||
Mirror,
|
||||
|
||||
/// <summary>
|
||||
/// Pad the data with zeros
|
||||
/// </summary>
|
||||
Zero
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the type of data padding appended/prepended to the data prior to
|
||||
/// being subjected to the filtering algorithm.
|
||||
/// </summary>
|
||||
public DataPaddingType DataPadding
|
||||
{
|
||||
get => _DataPadding.Value;
|
||||
set => _DataPadding.Value = value;
|
||||
}
|
||||
private readonly Property<DataPaddingType> _DataPadding
|
||||
= new Property<DataPaddingType>(
|
||||
typeof(FilterUtility).Namespace + ".FilterUtility.DataPaddingType",
|
||||
DataPaddingType.Mirror,
|
||||
true
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get the string that describes the type of filtering performed by this object.
|
||||
/// </summary>
|
||||
public string Type => "Butterworth, 4-pole";
|
||||
|
||||
public uint NumberOfPreDataPointsToInclude
|
||||
{
|
||||
get => _NumberOfPreDataPointsToInclude.Value;
|
||||
set => _NumberOfPreDataPointsToInclude.Value = value;
|
||||
}
|
||||
|
||||
private readonly Property<uint> _NumberOfPreDataPointsToInclude
|
||||
= new Property<uint>(typeof(FilterUtility).Namespace + ".FilterUtility.NumberOfPreDataPointsToInclude",
|
||||
0, true);
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the SaeJ211FilterUtility class.
|
||||
/// </summary>
|
||||
public FilterUtility()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert the specified frequency to an equivalent CFC value. Note that the
|
||||
/// "Big 4" CFC values get slightly special treatment.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="frequency">
|
||||
/// The <see cref="double"/> frequency to be converted.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="double"/> CFC equivalent of the specified frequency.
|
||||
/// </returns>
|
||||
///
|
||||
private double FrequencyToCfc(double frequency)
|
||||
{
|
||||
try
|
||||
{
|
||||
double cfc = -1;
|
||||
foreach (ChannelFilter filter in Enum.GetValues(typeof(ChannelFilter)))
|
||||
{
|
||||
if (frequency == (int)filter)
|
||||
{
|
||||
cfc = new CfcValueAttributeCoder().DecodeAttributeValue(filter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cfc >= 0 ? cfc : frequency * 0.6;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new FilterUtility.Exception("encountered problem converting frequency to CFC value", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void InvalidDataDelegate();
|
||||
public delegate void SetProgressDelegate(double value = -1D);
|
||||
/// <summary>
|
||||
/// Apply the SAE J211 filter algorithm (4-pole, phaseless, lo-pass) to the specified
|
||||
/// data using to the current FilterTool properties.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="data">
|
||||
/// An array of <see cref="double"/>s containing the raw data to be filtered.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="bUseLegacyTDCFilterAdjustment"></param>
|
||||
/// <param name="invalidDataFunc"></param>
|
||||
/// <returns>
|
||||
/// An array of <see cref="double"/>s containing the filtered data.
|
||||
/// </returns>
|
||||
///
|
||||
public virtual double[] ApplyFilter(double[] data, InvalidDataDelegate invalidDataFunc = null, bool bUseLegacyTDCFilterAdjustment = false,
|
||||
SetProgressDelegate setProgress = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null != invalidDataFunc)
|
||||
{
|
||||
var invalids = from d in data where double.IsNaN(d) select d;
|
||||
if (invalids.Any())
|
||||
{
|
||||
invalidDataFunc();
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPLEMENTATION NOTE:
|
||||
//
|
||||
// Pads the data with 5% of the original buffer size fore and aft to "squelch" out
|
||||
// filter start-up spikes. Optionally zeros baseline by subtracting the average
|
||||
// of the first 5% of the original data points (skips data which is padded by this
|
||||
// method). Optionally scales the data after filtering.
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (null == data)
|
||||
throw new ArgumentNullException("attempted to apply filter to null data buffer reference");
|
||||
|
||||
else
|
||||
{
|
||||
if (Cfc == ChannelFilter.Unfiltered) return data;
|
||||
if (Cfc == ChannelFilter.UnfilteredZero) { return data; }
|
||||
double t, pi, wd, wa, d0, d1, d2, e1, e2;
|
||||
double f1, f2, f3, f4, f5;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Formula setup
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
t = 1.0 / SampleRate;
|
||||
pi = 4.0 * System.Math.Atan(1.0);
|
||||
wd = 2.0 * pi * (Cfc == ChannelFilter.AdHoc ? FrequencyToCfc(AdHocFrequency) : _cfc) * 2.0775;
|
||||
wa = (System.Math.Sin(wd * (t / 2.0))) / (System.Math.Cos(wd * (t / 2.0))); // The original formula
|
||||
d0 = (wa * wa) / (1 + System.Math.Sqrt(2.0) * wa + (wa * wa));
|
||||
d1 = 2.0 * d0;
|
||||
d2 = d0;
|
||||
e1 = -2.0 * ((wa * wa) - 1) / (1 + System.Math.Sqrt(2.0) * wa + (wa * wa));
|
||||
e2 = (-1 + System.Math.Sqrt(2.0) * wa - (wa * wa)) / (1 + System.Math.Sqrt(2.0) * wa + (wa * wa));
|
||||
|
||||
var DataEnd = data.Length - 1;
|
||||
int Pad;
|
||||
|
||||
if (PadSize >= 0.0)
|
||||
{
|
||||
Pad = (int)(PadSize * SampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate padding as either 5% of all data, or the time required
|
||||
// for theoretical filter stabilization.
|
||||
Pad = (int)System.Math.Max(0.05 * DataEnd, 4 / AdHocFrequency * SampleRate);
|
||||
}
|
||||
|
||||
var Z = new double[2 * Pad + data.Length];
|
||||
var A = new double[2 * Pad + data.Length];
|
||||
var paddedData = new double[2 * Pad + data.Length];
|
||||
|
||||
var FirstIndexOfBeginPad = 0;
|
||||
var LastIndexOfBeginPad = Pad - 1;
|
||||
if ((DataPadding == DataPaddingType.Mirror) && (Pad - FirstIndexOfBeginPad >= data.Length))
|
||||
{ // Avoid fault in Mirror mode
|
||||
DataPadding = DataPaddingType.FirstAndLast;
|
||||
}
|
||||
switch (DataPadding)
|
||||
{ //
|
||||
// Populate the start-side pad according to this instance's current
|
||||
// DataPadding setting.
|
||||
//
|
||||
case DataPaddingType.FirstAndLast:
|
||||
for (var i = FirstIndexOfBeginPad; i <= LastIndexOfBeginPad; i++)
|
||||
paddedData[i] = data[0]; // 1st point of data
|
||||
break;
|
||||
|
||||
case DataPaddingType.Mirror:
|
||||
for (var i = FirstIndexOfBeginPad; i <= LastIndexOfBeginPad; i++)
|
||||
paddedData[i] = data[Pad - i]; // Mirror of data
|
||||
break;
|
||||
|
||||
case DataPaddingType.Zero:
|
||||
for (var i = FirstIndexOfBeginPad; i <= LastIndexOfBeginPad; i++)
|
||||
paddedData[i] = 0;
|
||||
break;
|
||||
default:
|
||||
|
||||
throw new FilterUtility.Exception("implementor attempted to use an undefined data padding type");
|
||||
}
|
||||
|
||||
// Copy raw data into newData after initial pad.
|
||||
var FirstIndexOfData = LastIndexOfBeginPad + 1;
|
||||
var LastIndexOfData = FirstIndexOfData + DataEnd;
|
||||
for (var i = FirstIndexOfData; i <= LastIndexOfData; i++)
|
||||
paddedData[i] = data[i - Pad];
|
||||
|
||||
var FirstIndexOfEndPad = LastIndexOfData + 1;
|
||||
var LastIndexOfEndPad = LastIndexOfData + Pad;
|
||||
switch (DataPadding)
|
||||
{ //
|
||||
// Populate the end-side pad according to this instance's current
|
||||
// DataPadding setting.
|
||||
//
|
||||
case DataPaddingType.FirstAndLast:
|
||||
for (var i = FirstIndexOfEndPad; i <= LastIndexOfEndPad; i++)
|
||||
paddedData[i] = data[DataEnd]; // Last point of data
|
||||
break;
|
||||
|
||||
case DataPaddingType.Mirror:
|
||||
for (var i = FirstIndexOfEndPad; i <= LastIndexOfEndPad; i++)
|
||||
paddedData[i] = paddedData[2 * LastIndexOfData - i]; // Mirror of data
|
||||
break;
|
||||
|
||||
case DataPaddingType.Zero:
|
||||
for (var i = FirstIndexOfEndPad; i <= LastIndexOfEndPad; i++)
|
||||
paddedData[i] = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw new FilterUtility.Exception("implementor attempted to use an undefined data padding type");
|
||||
}
|
||||
|
||||
var PaddedDataEnd = LastIndexOfEndPad; // DataEnd + 2 * Pad;
|
||||
|
||||
|
||||
// You need to set initial values before the calculation
|
||||
for (var i = 0; i <= 9; i++)
|
||||
Z[PaddedDataEnd] += 0.1 * paddedData[i];
|
||||
Z[PaddedDataEnd - 1] = Z[PaddedDataEnd];
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Data passed through filter backward
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
long travel = (PaddedDataEnd - 2);
|
||||
var progress = 0D;
|
||||
for (var j = travel; j >= 0; j--)
|
||||
{
|
||||
f1 = (d0 * paddedData[j]); // Breaking
|
||||
f2 = (d1 * paddedData[j + 1]); // down
|
||||
f3 = (d2 * paddedData[j + 2]); // a big
|
||||
f4 = (e1 * Z[j + 1]); // formula
|
||||
f5 = (e2 * Z[j + 2]); // into smaller "groups".
|
||||
Z[j] = f1 + f2 + f3 + f4 + f5; // Putting the "groups" back together
|
||||
var percent = System.Math.Floor(33D * ((travel - j) / (double)travel));
|
||||
if (percent > progress) { setProgress?.Invoke(percent); progress = percent; }
|
||||
}
|
||||
setProgress?.Invoke(33);
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Data passed through filter forward
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// You need to set initial values before the calculation
|
||||
for (var i = 0; i <= 9; i++)
|
||||
A[0] += 0.1 * Z[i];
|
||||
A[1] = A[0];
|
||||
|
||||
for (var k = 3; k <= PaddedDataEnd; k++)
|
||||
{
|
||||
f1 = (d0 * Z[k]); // Breaking
|
||||
f2 = (d1 * Z[k - 1]); // down
|
||||
f3 = (d2 * Z[k - 2]); // a big
|
||||
f4 = (e1 * A[k - 1]); // formula
|
||||
f5 = (e2 * A[k - 2]); // into smaller "groups".
|
||||
A[k] = f1 + f2 + f3 + f4 + f5; // Putting the "groups" back together
|
||||
var percent = System.Math.Floor(33 + 33D * ((PaddedDataEnd - k) / (double)PaddedDataEnd));
|
||||
if (percent > progress) { setProgress?.Invoke(percent); progress = percent; }
|
||||
}
|
||||
setProgress?.Invoke(66);
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Prepare baseline calculation, if required
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
var baselineSum = 0.0;
|
||||
|
||||
// Compute baseline if it's going to be applied.
|
||||
if (ZeroBaseline)
|
||||
for (var n = Pad; n <= (2 * Pad); n++)
|
||||
baselineSum += A[n];
|
||||
|
||||
// Baseline adjustment.
|
||||
var adjust = baselineSum / Pad;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Apply baseline and/or calibration factor, then finalize filtered data
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
var filteredIndex = 0;
|
||||
var filteredData = new double[data.Length];
|
||||
//8747 - TDC data shifts one point when filtered
|
||||
//this allows us to preserve that shift on demand
|
||||
var numOfPreDataPointsToInclude = NumberOfPreDataPointsToInclude;
|
||||
if (bUseLegacyTDCFilterAdjustment)
|
||||
{
|
||||
numOfPreDataPointsToInclude++;
|
||||
}
|
||||
travel = (PaddedDataEnd - (Pad + numOfPreDataPointsToInclude)) - (Pad - numOfPreDataPointsToInclude);
|
||||
for (var k = (int)(Pad - numOfPreDataPointsToInclude); k <= (PaddedDataEnd - (Pad + numOfPreDataPointsToInclude)); k++)
|
||||
{
|
||||
// Zero baseline, if requested.
|
||||
if (ZeroBaseline)
|
||||
A[k] = A[k] - adjust;
|
||||
|
||||
// Multiplying by the calibration factor unless factor is 1.0
|
||||
// AFTER the filtering has been finished.
|
||||
if (1.0 != CalibrationFactor)
|
||||
A[k] = A[k] * CalibrationFactor;
|
||||
|
||||
// Copy finished product into return buffer.
|
||||
filteredData[filteredIndex++] = A[k];
|
||||
var percent = System.Math.Floor(66D + 33D * (filteredIndex / (double)travel));
|
||||
if (percent > progress) { setProgress?.Invoke(percent); progress = percent; }
|
||||
}
|
||||
setProgress?.Invoke(100);
|
||||
// The deed is done. Share the pain.
|
||||
return filteredData;
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new FilterUtility.Exception("encountered problem SAE J211-filtering data", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* TextLogger.LogPathnameNotInitializedException.cs
|
||||
*
|
||||
* Copyright © 2010
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities.Logging
|
||||
{ // ***see TextLogger.cs***
|
||||
public partial class TextLogger
|
||||
{
|
||||
/// <summary>
|
||||
/// Representation of a failed attempt to convert a "Large" interface data type to one of
|
||||
/// the smaller data types in the "standard" interface.
|
||||
/// </summary>
|
||||
private class LogPathnameNotInitializedException : ApplicationException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="Logging.TextLogger.LogPathnameNotInitializedException"/> class.
|
||||
/// </summary>
|
||||
public LogPathnameNotInitializedException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="Logging.TextLogger.LogPathnameNotInitializedException"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public LogPathnameNotInitializedException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the
|
||||
/// <see cref="Logging.TextLogger.LogPathnameNotInitializedException"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The inner <see cref="System.Exception"/> behind this enclosing
|
||||
/// exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public LogPathnameNotInitializedException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
public class PropertyComparer<T> : IComparer<T>
|
||||
{
|
||||
private readonly IComparer _comparer;
|
||||
private PropertyDescriptor _propertyDescriptor;
|
||||
private int _reverse;
|
||||
|
||||
public PropertyComparer(PropertyDescriptor property, ListSortDirection direction)
|
||||
{
|
||||
_propertyDescriptor = property;
|
||||
var comparerForPropertyType = typeof(Comparer<>).MakeGenericType(property.PropertyType);
|
||||
_comparer =
|
||||
(IComparer)
|
||||
comparerForPropertyType.InvokeMember("Default",
|
||||
BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.Public, null, null, null);
|
||||
SetListSortDirection(direction);
|
||||
}
|
||||
|
||||
#region IComparer<T> Members
|
||||
|
||||
public int Compare(T x, T y)
|
||||
{
|
||||
return _reverse * _comparer.Compare(_propertyDescriptor.GetValue(x), _propertyDescriptor.GetValue(y));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void SetPropertyDescriptor(PropertyDescriptor descriptor)
|
||||
{
|
||||
_propertyDescriptor = descriptor;
|
||||
}
|
||||
|
||||
private void SetListSortDirection(ListSortDirection direction)
|
||||
{
|
||||
_reverse = direction == ListSortDirection.Ascending ? 1 : -1;
|
||||
}
|
||||
|
||||
public void SetPropertyAndDirection(PropertyDescriptor descriptor, ListSortDirection direction)
|
||||
{
|
||||
SetPropertyDescriptor(descriptor);
|
||||
SetListSortDirection(direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* DoubleLargeArray.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="T:IO.MemoryMap.LargeArray" /> of doubles
|
||||
/// </summary>
|
||||
public class DoubleLargeArray : LargeArray<double>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of a <see cref="IO.MemoryMap.DoubleLargeArray"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="size">
|
||||
/// The <see cref="ulong"/> size of the collection.
|
||||
/// </param>
|
||||
///
|
||||
public DoubleLargeArray(ulong size)
|
||||
: this(size, null, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of a <see cref="IO.MemoryMap.DoubleLargeArray"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="size">
|
||||
/// The <see cref="ulong"/> size of the collection.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="scratchFileDirectory">
|
||||
/// The <see cref="string"/> name of the directory where this LargeArray will store the temporary
|
||||
/// serializations of its items. If null, then the default location will be used.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="scratchFilePrefix">
|
||||
/// The <see cref="string"/> file name prefix under which this LargeArray will store temporary
|
||||
/// serializations of its items. Initialized to DefaultFilePrefix's value at object
|
||||
/// creation, unless an alternate is specified by the user. If null, then the default prefix
|
||||
/// will be used.
|
||||
/// </param>
|
||||
///
|
||||
public DoubleLargeArray(ulong size, string scratchFileDirectory, string scratchFilePrefix)
|
||||
: base(size, scratchFileDirectory, scratchFilePrefix)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="uint"/> size of the datum handled by this class.
|
||||
/// </summary>
|
||||
public override uint DatumSize => sizeof(double);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Get the "zero" value for this class' datum type.
|
||||
/// </summary>
|
||||
protected override double DatumClearValue => 0.0;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Get the datum value at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">
|
||||
/// The <see cref="T:System.UInt64" /> index of the datum to be returned.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The value of the <see cref="T:System.Double" /> datum at the specified index.
|
||||
/// </returns>
|
||||
protected override double GetDatumAtIndex(ulong index)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (index > long.MaxValue)
|
||||
throw new ApplicationException("overflowed an Int64 variable with a UInt64 value");
|
||||
var bytes = new byte[DatumSize];
|
||||
for (var i = 0; i < DatumSize; i++)
|
||||
bytes[i] = ViewArray[(long)(DatumSize * index) + i];
|
||||
return BitConverter.ToDouble(bytes, 0);
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem getting datum at index " + index, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the datum value at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="datum">
|
||||
/// The <see cref="T:System.Double" /> datum to be written to the specified index.
|
||||
/// </param>
|
||||
/// <param name="index">
|
||||
/// The <see cref="T:System.UInt64" /> index at which the specified datum value will be written.
|
||||
/// </param>
|
||||
protected override void SetDatumAtIndex(double datum, ulong index)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (index > long.MaxValue)
|
||||
throw new ApplicationException("overflowed an Int64 variable with a UInt64 value");
|
||||
var bytes = BitConverter.GetBytes(datum);
|
||||
Debug.Assert(bytes.Length == DatumSize);
|
||||
for (var i = 0; i < DatumSize; i++)
|
||||
ViewArray[(long)(DatumSize * index) + i] = bytes[i];
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem setting datum (" + datum + ") at index " + index, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Creates a new object that is a copy of the current instance.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A new <see cref="T:System.Object" /> that is a copy of the current instance.
|
||||
/// </returns>
|
||||
public override object Clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clone = new DoubleLargeArray(Size);
|
||||
for (var i = 0UL; i < clone.LargeCount; i++)
|
||||
clone[i] = this[i];
|
||||
return clone;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem cloning " + GetType().FullName, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the value at the specified index.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="index">
|
||||
/// The <see cref="ulong"/> index of the datum to be referenced.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="double"/> value of the datum at the specified index.
|
||||
/// </returns>
|
||||
///
|
||||
public new double this[ulong index]
|
||||
{
|
||||
get => (short)base[index];
|
||||
|
||||
set => base[index] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
AttributeExtractor.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to ease extracting custom attributes from their attached objects.
|
||||
/// </summary>
|
||||
/// <typeparam name="TAttributeType"></typeparam>
|
||||
public class AttributeExtractor<TAttributeType> : Exceptional
|
||||
{
|
||||
/// <summary>
|
||||
/// Extract an attribute of this class' declared type from the specified target.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="target">
|
||||
/// The <see cref="Object"/> to which the sought attribute is attached.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The attribute type specified upon AttributeExtractor creation.
|
||||
/// </returns>
|
||||
///
|
||||
public TAttributeType ExtractAttachedAttributeFromObject(object target)
|
||||
{
|
||||
try
|
||||
{
|
||||
ICustomAttributeProvider info = target.GetType();
|
||||
var attributes = info.GetCustomAttributes(typeof(TAttributeType), false) as TAttributeType[];
|
||||
if (attributes != null)
|
||||
{
|
||||
if (attributes.Length < 1)
|
||||
throw new Exception("attempted to extract non-existent \"" + typeof(TAttributeType) + "\" attribute");
|
||||
if (attributes.Length > 1)
|
||||
throw new Exception("attempted to extract \"" + typeof(TAttributeType) + "\" attribute from object decorated with multiple attributes; there should be only one");
|
||||
}
|
||||
return attributes[0];
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
string targetString;
|
||||
throw new Exception("encountered problem extracting attached \"" + typeof(TAttributeType) + "\"attribute value from object " + (null != (targetString = target.ToString()) ? ("\"" + targetString + "\"") : "<<NULL>>"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract a list of attached attributes from the specified property. An object and property name
|
||||
/// must be supplied, for attempts to directly reference the property will result in get/set invocation.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="propertyContainer">
|
||||
/// The <see cref="Object"/> that contains the property under query.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="propertyName">
|
||||
/// The <see cref="string"/> name of the property to be queried.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// A <see cref="T:List"/> of attached attributes of the type specified during the creation
|
||||
/// of this instance of AttributeExtractor.
|
||||
/// </returns>
|
||||
///
|
||||
public List<TAttributeType> ExtractAttachedAttributesFromProperty(object propertyContainer, string propertyName)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null == propertyContainer)
|
||||
throw new ArgumentNullException("cannot extract property from null property container reference");
|
||||
if (string.IsNullOrEmpty(propertyName))
|
||||
throw new ArgumentException("cannot extract property with null/empty string name");
|
||||
try
|
||||
{
|
||||
return new List<TAttributeType>(propertyContainer.GetType().GetProperty(propertyName).GetCustomAttributes(typeof(TAttributeType), false) as TAttributeType[]);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
throw new Exception("attribute does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
string propertyContainerString;
|
||||
throw new Exception("encountered problem extracting attached XML tag attribute values from property " + (null != propertyName ? ("\"" + propertyName + "\"") : "<<NULL>>") + " on object " + (null != (propertyContainerString = propertyContainer.ToString()) ? ("\"" + propertyContainerString + "\"") : "<<NULL>>"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract an attached attributes from the specified property of the type declared during the
|
||||
/// creation of this instance of AttributeExtractor. An object and property name must be supplied,
|
||||
/// for attempts to directly reference the property will result in get/set invocation.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="propertyContainer">
|
||||
/// The <see cref="Object"/> that contains the property under query.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="propertyName">
|
||||
/// The <see cref="string"/> name of the property to be queried.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// An attribute of the type specified during the creation of this instance of AttributeExtractor,
|
||||
/// if one is attached; null otherwise.
|
||||
/// </returns>
|
||||
///
|
||||
public TAttributeType ExtractAttachedAttributeFromProperty(object propertyContainer, string propertyName)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null == propertyContainer)
|
||||
throw new ArgumentNullException("cannot extract property from null property container reference");
|
||||
if (string.IsNullOrEmpty(propertyName))
|
||||
throw new ArgumentException("cannot extract property with null/empty string name");
|
||||
var attributes = ExtractAttachedAttributesFromProperty(propertyContainer, propertyName);
|
||||
if (attributes.Count < 1)
|
||||
throw new Exception("attempted to extract non-existent \"" + typeof(TAttributeType) + "\" attribute");
|
||||
if (attributes.Count > 1)
|
||||
throw new Exception("attempted to extract \"" + typeof(TAttributeType) + "\" attribute from object decorated with multiple attributes; there should be only one");
|
||||
return attributes[0];
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
string propertyContainerString;
|
||||
throw new Exception("encountered problem extracting attached XML tag attribute value from property " + (null != propertyName ? ("\"" + propertyName + "\"") : "<<NULL>>") + " on object " + (null != (propertyContainerString = propertyContainer.ToString()) ? ("\"" + propertyContainerString + "\"") : "<<NULL>>"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,430 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using DTS.Common.Utilities.Properties;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Common.Utilities.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// this class encapsulating writing to the log
|
||||
///
|
||||
/// </summary>
|
||||
public static class APILogger
|
||||
{
|
||||
private static readonly object ProcessLock = new object();
|
||||
private static readonly Dictionary<string, Stack<Stopwatch>> _processes = new Dictionary<string, Stack<Stopwatch>>();
|
||||
public static int LogLevel { get; set; } = 3;
|
||||
public static void StartProcess(string name)
|
||||
{
|
||||
lock (ProcessLock)
|
||||
{
|
||||
if (!_processes.ContainsKey(name)) { _processes[name] = new Stack<Stopwatch>(); }
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
_processes[name].Push(sw);
|
||||
Log($"Starting process: [{name}] ({_processes[name].Count})");
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopProcess(string name)
|
||||
{
|
||||
lock (ProcessLock)
|
||||
{
|
||||
if (!_processes.ContainsKey(name) || 0 == _processes[name].Count)
|
||||
{
|
||||
Log($"Stopping process: [{name}] (0)");
|
||||
return;
|
||||
}
|
||||
var sw = _processes[name].Pop();
|
||||
sw.Stop();
|
||||
var ts = new TimeSpan(sw.ElapsedTicks);
|
||||
Log($"Stopping process: [{name}], {TimespanToHumanReadable(ts)}");
|
||||
}
|
||||
}
|
||||
private static string TimespanToHumanReadable(TimeSpan ts)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (ts.TotalDays > 1)
|
||||
{
|
||||
sb.Append($"{System.Math.Floor(ts.TotalDays):0} days, ");
|
||||
}
|
||||
sb.Append($"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds}.{ts.Milliseconds:000}");
|
||||
return sb.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// describes an event that should be raised when there's an error that needs to be handled by an application
|
||||
/// </summary>
|
||||
public delegate void ErrorRaisedEventDelegate(string msg);
|
||||
|
||||
private static ErrorRaisedEventDelegate _OnErrorRaised;
|
||||
/// <summary>
|
||||
/// Error handler called when errors are raised
|
||||
/// </summary>
|
||||
public static ErrorRaisedEventDelegate OnErrorRaised
|
||||
{
|
||||
get => _OnErrorRaised;
|
||||
set => _OnErrorRaised = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// raises an error, if an error handler is set, calls error handler
|
||||
/// </summary>
|
||||
public static void RaiseError(string error)
|
||||
{
|
||||
OnErrorRaised?.Invoke(error);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static string GetCurrentMethod()
|
||||
{
|
||||
var st = new StackTrace();
|
||||
var sf = st.GetFrame(1);
|
||||
|
||||
return sf.GetMethod().Name;
|
||||
}
|
||||
|
||||
private static bool _bDoPerformanceLog;
|
||||
public static void SetDoPerformanceLog(bool bDoLog)
|
||||
{
|
||||
_bDoPerformanceLog = bDoLog;
|
||||
}
|
||||
private static readonly object MyLock = new object();
|
||||
public static void DoPerformanceLog(string msg)
|
||||
{
|
||||
if (!_bDoPerformanceLog) { return; }
|
||||
var dt = DateTime.Now;
|
||||
var s = string.Format("{0:0000}-{1:00}-{2:00} {3:00}:{4:00}:{5:00}.{6:0000} ***{7}\r\n", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Millisecond, msg);
|
||||
lock (MyLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.AppendAllText("PERFLOG.LOG", s);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored - performance logging is only for statistics, we fail then we fail, just keep going
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// a function capable of logging a message
|
||||
/// </summary>
|
||||
/// <param name="msg">message to log</param>
|
||||
public delegate void Sink(string msg);
|
||||
|
||||
/// <summary>
|
||||
/// a consumer of log messages
|
||||
/// </summary>
|
||||
public static Sink Writer;
|
||||
|
||||
public static Sink ConfigurationLogWriter;
|
||||
public static Sink ConfigReadErrorLogWriter;
|
||||
|
||||
public static Sink StateWriter;
|
||||
|
||||
private static string LogException(Exception ex, bool bPrepend, bool bNewLine)
|
||||
{
|
||||
if (Writer == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
try
|
||||
{
|
||||
if (ex == null)
|
||||
{
|
||||
Writer("LogException: called with null exception");
|
||||
}
|
||||
else
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (bPrepend) { sb.Append(string.Concat(DateTime.Now.ToString(Resources.APILogging_DateTime_Format), " ")); }
|
||||
ExceptionFormater(ref sb, ex, 0);
|
||||
sb = sb.Replace(Environment.NewLine, " ");
|
||||
if (bNewLine) { sb.AppendLine(); }
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ownEx)
|
||||
{
|
||||
// and to be really paranoid...
|
||||
string orgMsg;
|
||||
if (ex == null)
|
||||
{
|
||||
orgMsg = "null exception";
|
||||
}
|
||||
else if (string.IsNullOrEmpty(ex.Message))
|
||||
{
|
||||
orgMsg = "blank exception message";
|
||||
}
|
||||
else
|
||||
{
|
||||
orgMsg = ex.Message;
|
||||
}
|
||||
try
|
||||
{
|
||||
Writer("APILogger: LogException threw an expection: " + ownEx.Message + " when handling: " + orgMsg);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
/// <summary>
|
||||
/// log an exception
|
||||
/// </summary>
|
||||
/// <param name="ex">exception to be logged</param>
|
||||
public static void LogException(Exception ex)
|
||||
{
|
||||
Writer(LogException(ex, true, true));
|
||||
}
|
||||
public const string EXCEPTIONSTART_STRING = "!! ";
|
||||
private static void ExceptionFormater(ref StringBuilder sb, Exception ex, int level)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (ex == null)
|
||||
return;
|
||||
var front = new string(' ', level);
|
||||
sb.Append(EXCEPTIONSTART_STRING);
|
||||
sb.AppendFormat(Resources.APILogging_ExceptionFormatter_ExceptionOfTypeOccurredString, front, level > 0 ? Resources.APILogging_ExceptionFormatter_InnerIndicationString : Resources.APILogging_ExceptionFormatter_NonInnerIndicationString, ex.GetType());
|
||||
if (null != ex.TargetSite)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_ModuleNameDisplayString, front, NullGuard(ex.TargetSite.Module.Name), NullGuard(ex.TargetSite.Name));
|
||||
}
|
||||
sb.AppendFormat(Resources.APILogging_ExceptionMessageDisplayString, front, NullGuard(ex.Message));
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
{
|
||||
// RW: It appears .NET 4.5 has a subtle difference in stack formatting. I don't see it, but it's breaking the Regex.
|
||||
// I'm not sure why it's using regex in the first place. This should work for both, but has not been tested with .NET 2.0
|
||||
string[] delimeters = { Environment.NewLine };
|
||||
var lines = ex.StackTrace.Split(delimeters, 2, StringSplitOptions.None);
|
||||
if (lines.Length > 0)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_StackTraceDisplayString, front, NullGuard(lines[0]));
|
||||
if (lines.Length > 1)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_StackTraceDisplayString, front, NullGuard(lines[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
// now call ourself with inner
|
||||
ex = ex.InnerException;
|
||||
level = level + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static string NullGuard(string s)
|
||||
{
|
||||
return s ?? Resources.Generic_NullIndicatorString;
|
||||
}
|
||||
|
||||
private static readonly string DATE_FORMAT = Resources.APILogging_DateTime_Format;
|
||||
private static string LogString(string str, bool bPrepend, bool bNewLine, bool bReplaceNewLines = true)
|
||||
{
|
||||
if (Writer == null)
|
||||
throw new Exception(Resources.APILogging_NullWriterDelegateString);
|
||||
var sb = new StringBuilder();
|
||||
if (bPrepend) { sb.Append($"{DateTime.Now.ToString(DATE_FORMAT)} "); }
|
||||
|
||||
if (bReplaceNewLines)
|
||||
{
|
||||
sb.Append(str.Replace(Environment.NewLine, " "));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(str);
|
||||
}
|
||||
|
||||
if (bNewLine) { sb.AppendLine(); }
|
||||
return sb.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// logs a string
|
||||
/// </summary>
|
||||
/// <param name="str">string to be logged</param>
|
||||
public static void LogString(string str)
|
||||
{
|
||||
Writer?.Invoke(LogString(str, true, true));
|
||||
}
|
||||
private static readonly object PhaseShiftLogLock = new object();
|
||||
/// <summary>
|
||||
/// logs a phase shift into a table
|
||||
/// </summary>
|
||||
/// <param name="serial"></param>
|
||||
/// <param name="msPhaseShift">MICROSECONDS of shift</param>
|
||||
/// <param name="originalT0"></param>
|
||||
/// <param name="modifiedTo"></param>
|
||||
/// <param name="samples"></param>
|
||||
/// <param name="rule"></param>
|
||||
public static void LogPhaseShift(string serial, double msPhaseShift, ulong originalT0, ulong modifiedTo, ulong samples, string rule)
|
||||
{
|
||||
try
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var s = string.Format("{0:0000}-{1:00}-{2:00} {3:00}:{4:00}:{5:00}.{6:0000}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\r\n",
|
||||
now.Year,
|
||||
now.Month,
|
||||
now.Day,
|
||||
now.Hour,
|
||||
now.Minute,
|
||||
now.Second,
|
||||
now.Millisecond,
|
||||
serial,
|
||||
samples,
|
||||
msPhaseShift,
|
||||
originalT0,
|
||||
modifiedTo,
|
||||
rule
|
||||
);
|
||||
lock (PhaseShiftLogLock)
|
||||
{
|
||||
|
||||
File.WriteAllLines("PHASE_SHIFT_LOG.txt", new[] { s });
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { Log(ex); }
|
||||
}
|
||||
|
||||
public static void StateLog(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
if (i > 0) { sb.Append(" "); }
|
||||
var s = paramlist[i] as string;
|
||||
if (paramlist[i] is DialogResult) { s = string.Format(" User selected {0}", ((DialogResult)paramlist[i])); }
|
||||
var ex = paramlist[i] as Exception;
|
||||
|
||||
if (null == s && null == ex && null != paramlist[i]) { s = paramlist[i].ToString(); }
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex) { sb.Append(LogException(ex, bPrepend, bNewLine)); }
|
||||
else if (null != s) { sb.Append(LogString(s, bPrepend, bNewLine, false)); }
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
StateWriter(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//if we fail to log there's not much more we can do ...
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
private const int LOG_LEVEL_DEBUG = 2;
|
||||
private static void LogEx(int logLevel, params object[] paramList)
|
||||
{
|
||||
if (logLevel >= LogLevel)
|
||||
{
|
||||
var newparams = new object[paramList.Length + 1];
|
||||
Array.Copy(new[] { $"LOG_LEVEL_{logLevel}" }, 0, newparams, 0, 1);
|
||||
Array.Copy(paramList, 0, newparams, 1, paramList.Length);
|
||||
Log(newparams);
|
||||
}
|
||||
}
|
||||
public static void DebugLog(params object[] paramList)
|
||||
{
|
||||
LogEx(LOG_LEVEL_DEBUG, paramList);
|
||||
}
|
||||
/// <summary>
|
||||
/// logs multiple parameters
|
||||
/// </summary>
|
||||
/// <param name="paramlist">
|
||||
/// collection of parameters, can be exceptions, strings, or an object with tostring
|
||||
/// </param>
|
||||
public static void Log(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
var obj = paramlist[i];
|
||||
if (i > 0) { sb.Append(" "); }
|
||||
var s = obj as string;
|
||||
if (obj is DialogResult) { s = $" User selected {(DialogResult)obj}"; }
|
||||
else if (obj is byte[])
|
||||
{
|
||||
s = BitConverter.ToString((byte[])obj).Replace("-", "");
|
||||
}
|
||||
else if (obj is object[] objArray)
|
||||
{
|
||||
s = string.Join(", ", objArray);
|
||||
}
|
||||
|
||||
var ex = obj as Exception;
|
||||
if (null == s && null == ex && null != obj) { s = obj.ToString(); }
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex) { sb.Append(LogException(ex, bPrepend, bNewLine)); }
|
||||
else if (null != s) { sb.Append(LogString(s, bPrepend, bNewLine)); }
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
Writer(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//if we fail to log there's not much more we can do ...
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// logs multiple parameters
|
||||
/// </summary>
|
||||
/// <param name="paramlist">
|
||||
/// collection of parameters, can be exceptions, strings, or an object with tostring
|
||||
/// </param>
|
||||
public static void ConfLog(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
sb.Append(" ");
|
||||
}
|
||||
var s = paramlist[i] as string;
|
||||
if (paramlist[i] is DialogResult)
|
||||
{
|
||||
s = $" User selected {(DialogResult)paramlist[i]}";
|
||||
}
|
||||
var ex = paramlist[i] as Exception;
|
||||
|
||||
if (null == s && null == ex && null != paramlist[i])
|
||||
{
|
||||
s = paramlist[i].ToString();
|
||||
}
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex)
|
||||
{
|
||||
sb.Append(LogException(ex, bPrepend, bNewLine));
|
||||
}
|
||||
else if (null != s)
|
||||
{
|
||||
sb.Append(LogString(s, bPrepend, bNewLine));
|
||||
}
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
ConfigurationLogWriter(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//as with the other log function, if we fail we don't have much backing we can do
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
RangeRestrictedIntProperty.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
|
||||
namespace DTS.Common.Utilities.DotNetProgrammingConstructs
|
||||
{
|
||||
/// <summary>
|
||||
/// A class to implement self-checking, on-error-auto-syntax-building
|
||||
/// range-restricted int properties.
|
||||
/// </summary>
|
||||
public partial class RangeRestrictedIntProperty : Property<int>
|
||||
{
|
||||
/// <summary>
|
||||
/// Determine whether or not the specified value is valid for this property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value">
|
||||
/// The <see cref="int"/> value to be validity checked.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// <see cref="bool"/> true if the value is valid; false otherwise.
|
||||
/// </returns>
|
||||
///
|
||||
public override bool IsValidValue(int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
return value >= MinimumValue && value <= MaximumValue;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format(Properties.Resources.RangeRestrictedIntProperty_IsValidValue_UnableToDetermineValidityString, value.ToString()),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a user-readable explanation as to why the specified value is
|
||||
/// not valid for this property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value">
|
||||
/// The <see cref="int"/> value to be described.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// A <see cref="string"/> description explaining why the specified value
|
||||
/// is not valid for this property.
|
||||
/// </returns>
|
||||
///
|
||||
public override string GetInvalidValueDescription(int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (value < MinimumValue)
|
||||
return string.Format(Properties.Resources.RangeRestrictedIntProperty_GetInvalidValueDescription_MinimumDescriptionString, value.ToString(), MinimumValue.ToString());
|
||||
else if (value > MaximumValue)
|
||||
return string.Format(Properties.Resources.RangeRestrictedIntProperty_GetInvalidValueDescription_MaximumDescriptionString, value.ToString(), MaximumValue.ToString());
|
||||
else
|
||||
return string.Format(Properties.Resources.RangeRestrictedIntProperty_GetInvalidValueDescription_ValidValueDescriptionString, value.ToString());
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format(Properties.Resources.RangeRestrictedIntProperty_GetInvalidValueDescription_GetDescriptionFailedString, value.ToString()),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The minimum <see cref="int"/> value permitted in this property.
|
||||
/// </summary>
|
||||
public int MinimumValue
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return _MinimumValue.Value;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Properties.Resources.RangeRestrictedIntProperty_MinimumValue_GetValueFailedString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
try { _MinimumValue.Value = value; }
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Properties.Resources.RangeRestrictedIntProperty_MinimumValue_SetValueFailedString, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private Property<int> _MinimumValue = new Property<int>(0, false);
|
||||
|
||||
/// <summary>
|
||||
/// The maximum <see cref="int"/> value permitted in this property.
|
||||
/// </summary>
|
||||
public int MaximumValue
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return _MaximumValue.Value;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Properties.Resources.RangeRestrictedIntProperty_MaximumValue_GetValueFailedString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
try { _MaximumValue.Value = value; }
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Properties.Resources.RangeRestrictedIntProperty_MaximumValue_SetValueFailedString, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private Property<int> _MaximumValue = new Property<int>(0, false);
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of a range-restricted integer property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="minimumValue">
|
||||
/// The minimum <see cref="int"/> value permitted in this property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="maximumValue">
|
||||
/// The maximum <see cref="int"/> value permitted in this property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="initialValue">
|
||||
/// The initial <see cref="int"/> value of this property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="isInitialized">
|
||||
/// <see cref="bool"/> true if this property is to be considered
|
||||
/// initialized after construction, false otherwise.
|
||||
/// </param>
|
||||
///
|
||||
public RangeRestrictedIntProperty(int minimumValue,
|
||||
int maximumValue,
|
||||
int initialValue,
|
||||
bool isInitialized)
|
||||
: base(initialValue, isInitialized)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (minimumValue > maximumValue)
|
||||
throw new InvalidRangeException(
|
||||
string.Format(
|
||||
Properties.Resources.RangeRestrictedIntProperty_MinMustBeLessThanMaxString, minimumValue.ToString(), maximumValue.ToString()));
|
||||
else
|
||||
{
|
||||
MinimumValue = minimumValue;
|
||||
MaximumValue = maximumValue;
|
||||
if (!IsValidValue(initialValue))
|
||||
throw new InvalidValueException(GetInvalidValueDescription(initialValue));
|
||||
else return;
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new ConstructionException(
|
||||
string.Format(Properties.Resources.Generic_EncounteredProblemConstructingClassString, GetType().FullName),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of a range-restricted integer property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="minimumValue">
|
||||
/// The minimum <see cref="int"/> value permitted in this property.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="maximumValue">
|
||||
/// The maximum <see cref="int"/> value permitted in this property.
|
||||
/// </param>
|
||||
///
|
||||
public RangeRestrictedIntProperty(int minimumValue, int maximumValue)
|
||||
: base(0, false)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (minimumValue > maximumValue)
|
||||
throw new InvalidRangeException(
|
||||
string.Format(
|
||||
Properties.Resources.RangeRestrictedIntProperty_MinMustBeLessThanMaxString, minimumValue.ToString(), maximumValue.ToString()));
|
||||
else
|
||||
{
|
||||
MinimumValue = minimumValue;
|
||||
MaximumValue = maximumValue;
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new ConstructionException(
|
||||
string.Format(
|
||||
Properties.Resources.Generic_EncounteredProblemConstructingClassString, GetType().FullName),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of a range-restricted integer property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="initialValue">
|
||||
/// This initial <see cref="int"/> value of the property.
|
||||
/// </param>
|
||||
///
|
||||
public RangeRestrictedIntProperty(int initialValue)
|
||||
: this(int.MinValue, int.MaxValue, initialValue, true)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows a view of a memory mapped file
|
||||
/// to be accessed via the index[] operator.
|
||||
/// </summary>
|
||||
public class FileMapViewArray : IDisposable
|
||||
{
|
||||
#region privates
|
||||
const long systemOffsetSize = 65536;
|
||||
protected Stream _view;
|
||||
protected MemoryMappedFile _file;
|
||||
protected MapAccess _mapAccess;
|
||||
protected byte[] buffer;
|
||||
|
||||
protected long _mapSize;
|
||||
protected long _offsetOfViewFromStartOfMap;
|
||||
protected int _viewSize;
|
||||
|
||||
void ResetView(long newViewStart)
|
||||
{
|
||||
// Make sure we scale the last view of the file to not overrun the end.
|
||||
var newViewSize =
|
||||
_mapSize - newViewStart > _viewSize ?
|
||||
_viewSize :
|
||||
(int)(_mapSize - newViewStart);
|
||||
|
||||
if (newViewSize < 1)
|
||||
newViewSize = 0x100;
|
||||
|
||||
// Moves the view if we reach the end.
|
||||
_view.Close();
|
||||
_view = _file.MapView(_mapAccess, newViewStart, newViewSize);
|
||||
_offsetOfViewFromStartOfMap = newViewStart;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public
|
||||
/// <summary>
|
||||
/// Clears all buffers for the stream and causes
|
||||
/// any unbuffered data to be written to the
|
||||
/// underlying device.
|
||||
/// </summary>
|
||||
public void forceFlush()
|
||||
{
|
||||
_view.Flush();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Indexor
|
||||
/// <summary>
|
||||
/// Returns a the byte at the requested index of the MemoryMap.
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public byte this[long index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index >= _mapSize || index < 0)
|
||||
throw new Exception("Index is out of range.");
|
||||
|
||||
try
|
||||
{
|
||||
// Get us to the right place
|
||||
var position = index - _offsetOfViewFromStartOfMap;
|
||||
if (position < _view.Length && position >= 0)
|
||||
{
|
||||
_view.Seek(position, SeekOrigin.Begin);
|
||||
return (byte)_view.ReadByte();
|
||||
}
|
||||
}
|
||||
catch (FileMapIOException)
|
||||
{
|
||||
}
|
||||
// We overran the view; move it:
|
||||
// Overunning means index is one (or more) greater (or less) than the greatest
|
||||
// 'valid' index, so we need to refocus to one back from where we are now.
|
||||
// Reset the view to the page containing the out-of-bounds index.
|
||||
|
||||
//this.ResetView(index);
|
||||
ResetView(index / systemOffsetSize * systemOffsetSize);
|
||||
// Try again.
|
||||
return this[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
_view.Seek(index, SeekOrigin.Begin);
|
||||
_view.WriteByte(value);
|
||||
}
|
||||
catch (FileMapIOException)
|
||||
{
|
||||
ResetView(index);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Master Constructor
|
||||
/// This constructor allows for specifying privilages
|
||||
/// for the stream and mapped file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">File from which to create mapping</param>
|
||||
/// <param name="access">Access level for the map view in memory. Must be consisten with the file mapping access.</param>
|
||||
/// <param name="protection">Access level for the file mapping.</param>
|
||||
/// <param name="fileMapSize">The size in bytes of the file mapping. Pass 0 to map the entire (existing and length>0) file.</param>
|
||||
/// <param name="offset">Off set from start of mapped file to start the view.</param>
|
||||
/// <param name="viewSize">The size of the view in memory. This is limited by physical system resources.</param>
|
||||
public FileMapViewArray(string fileName, MapAccess access, MapProtection protection, ulong offset, long fileMapSize, int viewSize)
|
||||
{
|
||||
long mapSize;
|
||||
//Check file exists and length > 0;
|
||||
if (File.Exists(fileName) && new FileInfo(Path.GetFullPath(fileName)).Length != 0)
|
||||
//passing 0 will map the whole file
|
||||
mapSize =
|
||||
fileMapSize != 0 ? fileMapSize : Path.GetFullPath(fileName).Length;
|
||||
|
||||
else //file didn't exist or length==0, doesn't matter, gotta create it with correct size
|
||||
{
|
||||
//can't pass 0 here
|
||||
if (fileMapSize == 0) throw new Exception("Cannot map an empty or non-existent file.");
|
||||
else
|
||||
{
|
||||
// fileMapSize used here just to get a file
|
||||
// with a non-trivial size.
|
||||
File.Create(fileName, (int)fileMapSize);
|
||||
//a value was passed for the size of the map
|
||||
mapSize = fileMapSize;
|
||||
}
|
||||
}
|
||||
|
||||
var map =
|
||||
MemoryMappedFile.Create(fileName, protection, mapSize);
|
||||
|
||||
var view = map.MapView(access, (long)(offset / systemOffsetSize * systemOffsetSize), (int)System.Math.Min(mapSize, viewSize));
|
||||
|
||||
buffer = new byte[1];
|
||||
_mapAccess = access;
|
||||
_viewSize = viewSize;
|
||||
|
||||
_mapSize = mapSize;
|
||||
_file = map;
|
||||
_view = view;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
//this._file.Close(); // RW 2896 - added close to dispose
|
||||
//CPB DM - this should happen post view flush()
|
||||
|
||||
// flush view then close file.
|
||||
_view.Flush();
|
||||
|
||||
_file.Close();
|
||||
|
||||
_view.Close();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
//the stream was probably closed by .NET
|
||||
}
|
||||
_view.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
Property.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
|
||||
namespace DTS.Common.Utilities.DotNetProgrammingConstructs
|
||||
{
|
||||
/// <summary>
|
||||
/// A class to implement self-checking, on-error-auto-syntax-building properties.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="Type">
|
||||
/// The property type.
|
||||
/// </typeparam>
|
||||
///
|
||||
public partial class Property<Type>
|
||||
: Exceptional
|
||||
{
|
||||
/// <summary>
|
||||
/// value of the property
|
||||
/// </summary>
|
||||
public Type Value
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
//if ( !_isValueInitialized )
|
||||
// throw new NotInitializedException(Properties.Resources.Property_Value_NotInitializedString );
|
||||
//else
|
||||
return _Value;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format(
|
||||
Properties.Resources.Property_Value_CouldNotGetValueString, !string.IsNullOrEmpty(_name) ? "\"" + _name + "\" " : ""),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsValidValue(value))
|
||||
throw new InvalidValueException(GetInvalidValueDescription(value));
|
||||
else
|
||||
{
|
||||
_Value = value;
|
||||
IsValueInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format(
|
||||
Properties.Resources.Property_Value_CouldNotSetValueString, !string.IsNullOrEmpty(_name) ? "\"" + _name + "\" " : ""),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private Type _Value;
|
||||
public bool IsValueInitialized { get; private set; } = false;
|
||||
|
||||
private string _name;
|
||||
|
||||
/// <summary>
|
||||
/// Determine whether or not the specified value is valid for this property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value">
|
||||
/// The value to be validity checked.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// <see cref="bool"/> true if the value is valid; false otherwise.
|
||||
/// </returns>
|
||||
///
|
||||
public virtual bool IsValidValue(Type value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get <see cref="bool"/> initialization status for this property.
|
||||
/// </summary>
|
||||
public bool IsInitialized => IsValueInitialized;
|
||||
|
||||
/// <summary>
|
||||
/// "Deinitialize" this property.
|
||||
/// </summary>
|
||||
public void UnInitialize()
|
||||
{
|
||||
IsValueInitialized = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a user-readable explanation as to why the specified value is
|
||||
/// not valid for this property.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="value">
|
||||
/// The value to be described.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// A <see cref="string"/> description explaining why the specified value
|
||||
/// is not valid for this property.
|
||||
/// </returns>
|
||||
///
|
||||
public virtual string GetInvalidValueDescription(Type value)
|
||||
{
|
||||
try
|
||||
{
|
||||
return string.Format(Properties.Resources.Property_GetInvalidValueDescription_CouldNotSetToValueString,
|
||||
!string.IsNullOrEmpty(_name) ? "\"" + _name + "\"" : "",
|
||||
null != value ? ("\"" + value.ToString() + "\"") : Properties.Resources.Generic_NullIndicatorString);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception(Properties.Resources.Property_GetInvalidValueDescription_GetDescriptionFailedString, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Property class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="name">
|
||||
/// The name of the property this implementation is standing in for, so that
|
||||
/// error messages will be more informative. If a null name is passed,
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="initialValue">
|
||||
/// The initial value of the property. Can be read if the property is almost
|
||||
/// marked as "initialized".
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="isInitialized">
|
||||
/// A <see cref="bool"/> switch that determines whether or not the property
|
||||
/// is to be considered initialized immediately after instantiation.
|
||||
/// </param>
|
||||
///
|
||||
public Property(string name, Type initialValue, bool isInitialized)
|
||||
{
|
||||
try
|
||||
{
|
||||
_name = name;
|
||||
_Value = initialValue;
|
||||
IsValueInitialized = isInitialized;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new ConstructionException(
|
||||
string.Format(
|
||||
Properties.Resources.Generic_EncounteredProblemConstructingClassString, GetType().FullName),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Property class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="initialValue">
|
||||
/// The initial value of the property. Can be read if the property is almost
|
||||
/// marked as "initialized".
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="isInitialized">
|
||||
/// A <see cref="bool"/> switch that determines whether or not the property
|
||||
/// is to be considered initialized immediately after instantiation.
|
||||
/// </param>
|
||||
///
|
||||
public Property(Type initialValue, bool isInitialized)
|
||||
: this(null, initialValue, isInitialized)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate user-readable string for this object.
|
||||
/// </summary>
|
||||
///
|
||||
/// <returns>
|
||||
/// A <see cref="string"/> representing the current state of the object.
|
||||
/// </returns>
|
||||
///
|
||||
public override string ToString()
|
||||
{
|
||||
try { return _Value.ToString(); }
|
||||
catch (System.Exception)
|
||||
{
|
||||
return base.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Property.ConstructionException.cs
|
||||
|
||||
$Log: Property.ConstructionException.cs,v $
|
||||
Revision 1.1 2007/12/13 23:57:33 Paul Hrissikopoulos
|
||||
Added ISO raw format.
|
||||
|
||||
Copyright © 2007
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities.DotNetProgrammingConstructs
|
||||
{
|
||||
// See "Property.cs".
|
||||
public partial class Property<Type>
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representation for property construction exceptions.
|
||||
/// </summary>
|
||||
public class ConstructionException
|
||||
: System.Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Property.ConstructionException class.
|
||||
/// </summary>
|
||||
public ConstructionException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Property.ConstructionException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public ConstructionException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Property.ConstructionException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message describing this exception instance.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The inner <see cref="System.Exception"/> behind this enclosing
|
||||
/// exception instance.
|
||||
/// </param>
|
||||
///
|
||||
public ConstructionException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* ShortLargeArray.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities.IO.MemoryMap
|
||||
{
|
||||
/// <summary>
|
||||
/// a <see cref="T:IO.MemoryMap.LargeArray" /> of
|
||||
/// <see cref="short" />
|
||||
/// </summary>
|
||||
public class ShortLargeArray : LargeArray<short>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of a <see cref="IO.MemoryMap.ShortLargeArray"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="size">
|
||||
/// The <see cref="ulong"/> size of the collection.
|
||||
/// </param>
|
||||
public ShortLargeArray(ulong size)
|
||||
: this(size, null, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of a <see cref="IO.MemoryMap.ShortLargeArray"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="size">
|
||||
/// The <see cref="ulong"/> size of the collection.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="scratchFileDirectory">
|
||||
/// The <see cref="string"/> name of the directory where this LargeArray will store the temporary
|
||||
/// serializations of its items. If null, then the default location will be used.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="scratchFilePrefix">
|
||||
/// The <see cref="string"/> file name prefix under which this LargeArray will store temporary
|
||||
/// serializations of its items. Initialized to DefaultFilePrefix's value at object
|
||||
/// creation, unless an alternate is specified by the user. If null, then the default prefix
|
||||
/// will be used.
|
||||
/// </param>
|
||||
///
|
||||
public ShortLargeArray(ulong size, string scratchFileDirectory, string scratchFilePrefix)
|
||||
: base(size, scratchFileDirectory, scratchFilePrefix)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="uint"/> size of the datum handled by this class.
|
||||
/// </summary>
|
||||
public override uint DatumSize => sizeof(short);
|
||||
|
||||
/// <summary>
|
||||
/// Get the "zero" value for this class' datum type.
|
||||
/// </summary>
|
||||
protected override short DatumClearValue => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Get the datum value at the specified index.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="index">
|
||||
/// The <see cref="ulong"/> index of the datum to be returned.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The value of the <see cref="short"/> datum at the specified index.
|
||||
/// </returns>
|
||||
///
|
||||
protected override short GetDatumAtIndex(ulong index)
|
||||
{
|
||||
try
|
||||
{
|
||||
short rv;
|
||||
if (index > long.MaxValue)
|
||||
throw new ApplicationException("overflowed an Int64 variable with a UInt64 value");
|
||||
rv = (short)(ViewArray[(long)((2 * index))] & 0xFFFF);
|
||||
rv += (short)((ViewArray[(long)((2 * index) + 1)] & 0xFFFF) << 8);
|
||||
return rv;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new ShortLargeArray.Exception("encountered problem getting datum at index " + index.ToString(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the datum value at the specified index.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="datum">
|
||||
/// The <see cref="short"/> datum to be written to the specified index.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="index">
|
||||
/// The <see cref="ulong"/> index at which the specified datum value will be written.
|
||||
/// </param>
|
||||
///
|
||||
protected override void SetDatumAtIndex(short datum, ulong index)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (index > long.MaxValue)
|
||||
throw new ApplicationException("overflowed an Int64 variable with a UInt64 value");
|
||||
(ViewArray[(long)((2 * index))]) = (byte)((datum) & 0xFFFF);
|
||||
(ViewArray[(long)((2 * index) + 1)]) = (byte)((datum >> 8) & 0xFFFF);
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new ShortLargeArray.Exception("encountered problem setting datum (" + datum.ToString() + ") at index " + index.ToString(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new object that is a copy of the current instance.
|
||||
/// </summary>
|
||||
///
|
||||
/// <returns>
|
||||
/// A new <see cref="System.Object"/> that is a copy of the current instance.
|
||||
/// </returns>
|
||||
///
|
||||
public override object Clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clone = new ShortLargeArray(Size);
|
||||
for (ulong i = 0; i < clone.LargeCount; i++)
|
||||
clone[i] = this[i];
|
||||
return clone;
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem cloning " + GetType().FullName, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the value at the specified index.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="index">
|
||||
/// The <see cref="ulong"/> index of the datum to be referenced.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
/// The <see cref="short"/> value of the datum at the specified index.
|
||||
/// </returns>
|
||||
///
|
||||
public new short this[ulong index]
|
||||
{
|
||||
get => base[index];
|
||||
|
||||
set => base[index] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* DataWindowAverager.WindowDoesNotExistException
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
// *** see DTS.Slice.Control.Event.cs ***
|
||||
public partial class DataWindowAverager
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Representation of an attempt to average over a window that does not exist within
|
||||
/// the specified dataset.
|
||||
/// </summary>
|
||||
public class WindowDoesNotExistException : ApplicationException
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Initialize an instance of the WindowDoesNotExistException class.
|
||||
/// </summary>
|
||||
///
|
||||
public WindowDoesNotExistException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the WindowDoesNotExistException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
public WindowDoesNotExistException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the WindowDoesNotExistException class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="msg">
|
||||
/// The <see cref="string"/> message to be associated with this exception.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="innerEx">
|
||||
/// The <see cref="System.Exception"/> responsible for this exception inception.
|
||||
/// </param>
|
||||
///
|
||||
public WindowDoesNotExistException(string msg, System.Exception innerEx)
|
||||
: base(msg, innerEx)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
} // *** end DataWindowAverager ***
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
public sealed class KeywordAlert
|
||||
{
|
||||
public static KeywordAlert Instance { get; } = new KeywordAlert();
|
||||
|
||||
private List<string> alerts = null;
|
||||
|
||||
private const string KeywordFile = "Keywords.txt";
|
||||
private KeywordAlert()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (System.IO.File.Exists(KeywordFile))
|
||||
{
|
||||
alerts = new List<string>(System.IO.File.ReadAllLines(KeywordFile));
|
||||
}
|
||||
}
|
||||
catch (System.Exception) { }
|
||||
}
|
||||
|
||||
public void ProcessMsg(string msg)
|
||||
{
|
||||
if (null != alerts)
|
||||
{
|
||||
System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(DoWork), msg);
|
||||
}
|
||||
}
|
||||
private void DoWork(object o)
|
||||
{
|
||||
var msg = o as string;
|
||||
var keys = alerts.ToArray();//avoid accessing the list since many threads may be operating simultaneously
|
||||
|
||||
var matches = from k in keys.AsParallel() where msg.Contains(k) select k;
|
||||
if (matches.Any())
|
||||
{
|
||||
var foundKeys = string.Join(", ", matches.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
Math.Nhtsa.Differentiation.cs
|
||||
|
||||
24 November 2009 - Adapted from old Dave codebase to generic DTS utility, with
|
||||
appropriate name change.
|
||||
|
||||
$Log: Math.Nhtsa.ChannelDifferentiation.cs,v $
|
||||
Revision 1.2 2007/04/20 17:40:42 Paul Hrissikopoulos
|
||||
Fixed bad range checking in sample rate property set accessor.
|
||||
|
||||
Revision 1.1 2007/02/05 17:17:08 Paul Hrissikopoulos
|
||||
Finished installing generic channel math framework + basic calculus operations.
|
||||
|
||||
Copyright © 2007
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities.Math.Nhtsa
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Representation of a NHTSA-based differentiation channel operation.
|
||||
/// </summary>
|
||||
public class Differentiation : DoubleListOperation
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get/set the sample rate for this data to be differentiated.
|
||||
/// </summary>
|
||||
public double SampleRate
|
||||
{
|
||||
get => _SampleRate.Value;
|
||||
set => _SampleRate.Value = value;
|
||||
}
|
||||
private Property<double> _SampleRate
|
||||
= new Property<double>(
|
||||
typeof(Differentiation).FullName + ".SampleRate",
|
||||
0.0,
|
||||
false
|
||||
);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Initialize an instance of the ChannelDifferentiation class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="domain">
|
||||
/// The System.Collections.Generic.IList of <see cref="double"/> domain for
|
||||
/// this operation.
|
||||
/// </param>
|
||||
///
|
||||
public Differentiation(IList<double> domain)
|
||||
: base(domain)
|
||||
{ //
|
||||
// I'd prefer to do this statically, but I don't know of any C# way to place a constraint
|
||||
// on a generic type that's already been determined by some ancestor we're inheriting from,
|
||||
// so for now we'll have to dynamically check it on object instantiation.
|
||||
//
|
||||
if (!(domain is ICloneable))
|
||||
throw new InvalidCastException("the domain type for " + typeof(Differentiation).FullName + " must be ICloneable");
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Initialize an instance of the Iso.ChannelDifferentiation class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="domain">
|
||||
/// The System.Collections.Generic.IList of <see cref="double"/> domain for
|
||||
/// this operation.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="sampleRate">
|
||||
/// The <see cref="int"/> sample rate of the channel to be differentiated.
|
||||
/// </param>
|
||||
///
|
||||
public Differentiation(IList<double> domain, int sampleRate)
|
||||
: this(domain)
|
||||
{
|
||||
try { SampleRate = sampleRate; }
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem constructing " + GetType().FullName, ex);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Get the System.Collections.Generic.IList of <see cref="double"/> result of
|
||||
/// the operation on the target domain.
|
||||
/// </summary>
|
||||
public override IList<double> Range
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null == Domain)
|
||||
throw new ArgumentNullException("attempted to differentiate null channel reference");
|
||||
|
||||
else if (0 >= SampleRate)
|
||||
throw new ArgumentOutOfRangeException("SampleRate must be greater than zero");
|
||||
|
||||
else if (!(Domain is ICloneable))
|
||||
throw new InvalidCastException("the domain type for " + typeof(Differentiation).FullName + " must be ICloneable");
|
||||
|
||||
else
|
||||
{
|
||||
var IndexOfLastSample = Domain.Count - 1;
|
||||
var deltaT = SampleRate / 2;
|
||||
var range = ((ICloneable)Domain).Clone() as IList<double>;
|
||||
|
||||
for (var t = 1; t < IndexOfLastSample; t++)
|
||||
range[t] = (Domain[t + 1] - Domain[t - 1]) * deltaT;
|
||||
|
||||
range[0] = (-7 * Domain[0]
|
||||
+ 6 * Domain[1]
|
||||
+ 3 * Domain[2]
|
||||
- 2 * Domain[3]) * deltaT / 3;
|
||||
|
||||
range[IndexOfLastSample] = (-7 * Domain[IndexOfLastSample]
|
||||
+ 6 * Domain[IndexOfLastSample - 1]
|
||||
+ 3 * Domain[IndexOfLastSample - 2]
|
||||
- 2 * Domain[IndexOfLastSample - 3]) * deltaT / 3;
|
||||
return range;
|
||||
}
|
||||
}
|
||||
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new Exception("encountered problem doing " + GetType().FullName + " operation", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
@@ -0,0 +1,574 @@
|
||||
/*
|
||||
* TextLogger.cs
|
||||
*
|
||||
* Copyright © 2010
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
// ReSharper disable EmptyGeneralCatchClause
|
||||
|
||||
namespace DTS.Common.Utilities.Logging
|
||||
{
|
||||
|
||||
// DEVELOPMENT NOTES:
|
||||
//
|
||||
// -> Keeping the regular logging functionality in place, we will have another logger that simply
|
||||
// writes the same thing to a temporary file. At the point we commit to a test ID, the temp
|
||||
// file will be moved to the associated test directory and logging will resume at that location.
|
||||
// Once the test is finished, another not-yet-test-related temp file will be created and the
|
||||
// process will continue from there.
|
||||
//
|
||||
// -> Due to existing limitations of the current Logging.TextLogger class it will
|
||||
// be necessary to fundamentally revamp so that it will be able to synchronize log message input
|
||||
// with logger control state changes so that, for example, we don't lose log events that happen
|
||||
// while we're changing the location of the "temp" log file, which requires time to close the old
|
||||
// file, move it, and then open the new write handle. The simplest solution to me seems to be a
|
||||
// queue for the write queue, so that when the "test ID is known" event fires is invoked in the
|
||||
// logger it goes something like this:
|
||||
//
|
||||
// 1) Cut-off processing of the the "pre-write queue" queue so that any subsequent log messages
|
||||
// are held for the moment.
|
||||
//
|
||||
// 2) Wait until the "write" queue finishes writing to temp log file.
|
||||
//
|
||||
// 3) Close write handle.
|
||||
//
|
||||
// 4) Move temp log file to test-specific location.
|
||||
//
|
||||
// 5) Open write handle.
|
||||
//
|
||||
// 6) Let "pre-write queue" start feeding "write" queue again.
|
||||
//
|
||||
// -> Do we need to add parameters for the pre/write queues? Could make that part of the
|
||||
// mechanism to disconnect them from the feeders and let them evaporate when it's time to
|
||||
// switch filenames. Could we do that? Just alter the behavior to be evaporate on shutdown,
|
||||
// activate it, and then create a new instance of the cycle with the new filename.
|
||||
//
|
||||
// -> Everytime the filename is set, the object should just allocate a new write cycle,
|
||||
// after flaging the previous one for termination.
|
||||
//
|
||||
// -> Ok, we're going to associate a "handle" structure with the write cycle that will
|
||||
// contain the queue, control booleans, trigger events, etc. That way we really can just
|
||||
// set the "termination" bool to true, trigger a cycle and then just let go of the balloon
|
||||
// when we're ready to start another write cycle associated with another log pathname. The
|
||||
// expired queue closure will finish writing, then close the writer and wait for disposal.
|
||||
// This will also simplify things as we won't need to hammer the bugs out of this rather
|
||||
// baroque pausable two-queue system.
|
||||
//
|
||||
// -> Furthermore, the new write cycle closure will be created and launched (and the old
|
||||
// one set for disposal) by the set accessor of the TextWriter's LogPathname property.
|
||||
// That way you really don't have to think about anything; just change the name and keep
|
||||
// logging and all should be well.
|
||||
//
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// A class to implement a threaded log file.
|
||||
/// Problems encountered by the writing thread will be reported thru the callback function.
|
||||
/// The logger is re/started whenever it is assigned a new log filepath.
|
||||
/// </summary>
|
||||
public partial class TextLogger : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="WriteCycleHandle"/> associated with the current
|
||||
/// active log file.
|
||||
/// </summary>
|
||||
protected WriteCycleHandle CurrentLoggingCycle
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shut down the current write cycle.
|
||||
/// </summary>
|
||||
protected void EndCurrentWriteCycle()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null == CurrentLoggingCycle) return;
|
||||
CurrentLoggingCycle.TerminateWriteCycle = true;
|
||||
CurrentLoggingCycle.CycleTrigger.Set();
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem ending current writing cycle", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open a log file with the specified name and start processing log messages into it. If another
|
||||
/// log file is currently active, it will be closed, flushed and disposed.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="logPathname">
|
||||
/// The <see cref="string"/> pathname of the logfile to receive new log messages.
|
||||
/// </param>
|
||||
///
|
||||
protected void StartNewWriteCycle(string logPathname)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(logPathname))
|
||||
throw new NullReferenceException("log pathname cannot be empty/null");
|
||||
if (null != CurrentLoggingCycle)
|
||||
{
|
||||
lock (CurrentLoggingCycle.WriteQueue)
|
||||
{
|
||||
EndCurrentWriteCycle();
|
||||
}
|
||||
QueueWriteCycle(CurrentLoggingCycle = new WriteCycleHandle(logPathname, new Queue<string>(), null, OnWriteException, false));
|
||||
}
|
||||
else
|
||||
QueueWriteCycle(CurrentLoggingCycle = new WriteCycleHandle(logPathname, new Queue<string>(), null, OnWriteException, false));
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encounterd problem starting new logging cycle", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the name/location of the currently active log file without dropping any
|
||||
/// incoming messages.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="newPathName">
|
||||
/// The new path name <see cref="string"/> for the active log file.
|
||||
/// </param>
|
||||
///
|
||||
public void MoveLogTo(string newPathName)
|
||||
{
|
||||
try
|
||||
{
|
||||
APILogger.Log("Moving file");
|
||||
//
|
||||
// Here's the plan: have a common lock around the old and new queues that result when you
|
||||
// add a new log file. When it comes time to do a "move", take the lock, mark the old queue handle
|
||||
// for termination, and on the termination callback return create the new file. Can it be that simple?
|
||||
//
|
||||
lock (this)
|
||||
{
|
||||
CurrentLoggingCycle.OnWriteCycleTermination = delegate
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Path.GetFullPath(LogPathname).Equals(Path.GetFullPath(newPathName)) &&
|
||||
File.Exists(LogPathname))
|
||||
{
|
||||
if (File.Exists(newPathName))
|
||||
File.Delete(newPathName);
|
||||
File.Move(LogPathname, newPathName);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnWriteException?.Invoke(new ApplicationException("encountered problem moving log file to path " + (null != newPathName ? "\"" + newPathName + "\"" : "<NULL>"), ex));
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogPathname = newPathName;
|
||||
}
|
||||
};
|
||||
CurrentLoggingCycle.TerminateWriteCycle = true;
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem moving log to new path " + (null != newPathName ? "\"" + newPathName + "\"" : "<NULL>"), ex);
|
||||
}
|
||||
}
|
||||
private static readonly object LogPathNameLock = new object();
|
||||
/// <summary>
|
||||
/// Get/set the <see cref="string"/> pathname of the currently active log file.
|
||||
/// </summary>
|
||||
public string LogPathname
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null != _logPathname) { return _logPathname; }
|
||||
throw new LogPathnameNotInitializedException("the pathname has not been initialized");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
lock (LogPathNameLock)
|
||||
{
|
||||
// Do not use System.IO.Path.GetFullPath here to compare the new value to the old
|
||||
// because on XP SaveFileDialog temporarily changes the current directory
|
||||
// and GetFullPath uses GetCurrentDirectory. So, with an ECM connected, that will
|
||||
// cause errors from the text logger when CSV or ISO exports wait in SaveFileDialog.
|
||||
if (null == _logPathname || value != _logPathname)
|
||||
{
|
||||
// If we're actually changing the name/location of this thing, then let's stop writing the
|
||||
// old file and start in on the new one.
|
||||
//
|
||||
_logPathname = value;
|
||||
if (!ThreadPool.QueueUserWorkItem(delegate { StartNewWriteCycle(LogPathname); }))
|
||||
throw new ApplicationException(Properties.Resources.TextLogger_TextLogger_EnqueueWriterFailureString);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem setting log pathname", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _logPathname = null;
|
||||
|
||||
|
||||
public static void CompressLogFilesIntoZip(string sourcedir, string destFile)
|
||||
{
|
||||
var z = new ICSharpCode.SharpZipLib.Zip.FastZip();
|
||||
z.CreateZip(destFile, sourcedir, false, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the filename portion of the associated log's filename.
|
||||
/// </summary>
|
||||
public string LogFilename
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
// Consider the filename to be anything in the full log file name beyond the last path
|
||||
// separator character.
|
||||
//
|
||||
return Path.GetFileName(LogPathname);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem getting log file name", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A callback type for write queue events.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="writeQueue">
|
||||
/// The write queue's <see cref="string"/> queue.
|
||||
/// </param>
|
||||
///
|
||||
public delegate void WriteCycleCallback(Queue<string> writeQueue);
|
||||
|
||||
/// <summary>
|
||||
/// A callback type to be invoked when exceptions occur in the text writer's threaded
|
||||
/// writing method.
|
||||
/// </summary>
|
||||
/// <param name="ex"></param>
|
||||
public delegate void WriteCycleExceptionHandler(Exception ex);
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Logging.TextLogger.WriteCycleExceptionHandler"/> that well be invoked
|
||||
/// whenever the logger encounters an exceptional condition within the write cycle method.
|
||||
/// </summary>
|
||||
public WriteCycleExceptionHandler OnWriteException { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// text written to the start of a log (such as application version, etc)
|
||||
/// if null, no text is written
|
||||
/// </summary>
|
||||
public string LogStartMessage { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// The write loop that processes queued log messages. It is run in its own thread.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="writeCycle">
|
||||
/// The <see cref="TextLogger.WriteCycleHandle"/> associated with the
|
||||
/// log file to receive processed log messages.
|
||||
/// </param>
|
||||
///
|
||||
private void QueueWriteCycle(WriteCycleHandle writeCycle)
|
||||
{
|
||||
try
|
||||
{
|
||||
var fullPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
|
||||
writeCycle.FullLogFileName);
|
||||
while (!writeCycle.TerminateWriteCycle)
|
||||
{
|
||||
writeCycle.CycleTrigger.WaitOne();
|
||||
|
||||
// Do not use System.IO.File.Exists without explicitly specifying the full path,
|
||||
// based on System.Reflection.Assembly.GetExecutingAssembly().Location,
|
||||
// because on XP SaveFileDialog temporarily changes the current directory
|
||||
// and File.Exists uses GetCurrentDirectory. So, with an ECM connected, that will
|
||||
// cause errors from the text logger when CSV or ISO exports wait in SaveFileDialog.
|
||||
|
||||
var bFileExists = File.Exists(fullPath);
|
||||
|
||||
if (!bFileExists)
|
||||
{
|
||||
using (var fs = new FileStream(writeCycle.FullLogFileName, FileMode.Create))
|
||||
{
|
||||
fs.Close();
|
||||
}
|
||||
try
|
||||
{
|
||||
File.SetCreationTime(writeCycle.FullLogFileName, DateTime.Now);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
using (var fs = new FileStream(writeCycle.FullLogFileName, FileMode.Append))
|
||||
{
|
||||
using (var gs = new StreamWriter(fs))
|
||||
{
|
||||
lock (writeCycle.WriteQueue)
|
||||
{
|
||||
if (!bFileExists && null != LogStartMessage)
|
||||
{
|
||||
gs.Write(LogStartMessage);
|
||||
}
|
||||
while (writeCycle.WriteQueue.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
_loggingMutex.WaitOne();
|
||||
gs.Write(writeCycle.WriteQueue.Dequeue());
|
||||
}
|
||||
catch
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
finally { _loggingMutex.ReleaseMutex(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
_loggingMutex.WaitOne();
|
||||
CheckForLargeLogFileAndRename(writeCycle.FullLogFileName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
finally
|
||||
{
|
||||
_loggingMutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
|
||||
writeCycle.CycleCompletionTrigger.Set();
|
||||
writeCycle.OnWriteCycleTermination?.Invoke(writeCycle.WriteQueue);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (null != writeCycle.OnWriteCycleException)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.AppendAllText("LOGERROR.LOG", ex.StackTrace + Environment.NewLine + ex.Message);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
writeCycle.OnWriteCycleException(new ApplicationException("encountered problem processing text logger queue", ex));
|
||||
}
|
||||
if (!writeCycle.TerminateCycleOnException)
|
||||
QueueWriteCycle(writeCycle);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the <see cref="Logging.TextLogger"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="logPathname">
|
||||
/// The <see cref="string"/> pathname of the log file that will be generated by
|
||||
/// this class.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="onWriteException">
|
||||
/// The <see cref="TextLogger.WriteCycleExceptionHandler"/> to be invoked when
|
||||
/// an exception occurs in the queue processing loop.
|
||||
/// </param>
|
||||
///
|
||||
public TextLogger(string logPathname, WriteCycleExceptionHandler onWriteException)
|
||||
{
|
||||
try
|
||||
{
|
||||
OnWriteException = onWriteException;
|
||||
LogPathname = logPathname;
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem constructing " + typeof(TextLogger).FullName + " object", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an instance of the <see cref="TextLogger"/> class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="logPathname">
|
||||
/// The <see cref="string"/> pathname of the log file that will be generated by
|
||||
/// this class.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="onWriteException">
|
||||
/// The <see cref="TextLogger.WriteCycleExceptionHandler"/> to be invoked when
|
||||
/// an exception occurs in the queue processing loop.
|
||||
/// </param>
|
||||
/// <param name="maxLogFileSize"></param>
|
||||
public TextLogger(string logPathname, WriteCycleExceptionHandler onWriteException, int maxLogFileSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
OnWriteException = onWriteException;
|
||||
LogPathname = logPathname;
|
||||
MaximumLogFileSizeBytes = maxLogFileSize;
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem constructing " + typeof(TextLogger).FullName + " object", ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Write the specified string to the log file.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="message">
|
||||
/// The text <see cref="string"/> to be written to the log file.
|
||||
/// </param>
|
||||
///
|
||||
public void LogMessage(string message)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (null == CurrentLoggingCycle) { return; }
|
||||
lock (CurrentLoggingCycle.WriteQueue)
|
||||
{
|
||||
CurrentLoggingCycle.WriteQueue.Enqueue($"{message} {Environment.NewLine}");
|
||||
CurrentLoggingCycle.CycleTrigger.Set();
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem logging message " + (null != message ? "\"" + message + "\"" : "<NULL>"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the remaining items in the queue and then release all resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (CurrentLoggingCycle.WriteQueue)
|
||||
EndCurrentWriteCycle();
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("encountered problem disposing instance of " + typeof(TextLogger).FullName, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The byte-size at which the log file should be archived.
|
||||
/// </summary>
|
||||
public int MaximumLogFileSizeBytes { get; set; } = 1000000;
|
||||
|
||||
private readonly Mutex _loggingMutex = new Mutex(false, "SLICEWare_Log");
|
||||
|
||||
public volatile bool ReRollLog = false;
|
||||
/// <summary>
|
||||
/// Check the size of the specified file and if it exceeds the maximum log file size
|
||||
/// then give it an archival name and open a new logfile for subsequent data. A
|
||||
/// cut 'n paste transplant from the original TextLogger.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="fileName">
|
||||
/// The new archival filename <see cref="string"/> for the log file if it exceeds the
|
||||
/// maximum specified byte-size.
|
||||
/// </param>
|
||||
///
|
||||
protected void CheckForLargeLogFileAndRename(string fileName)
|
||||
{
|
||||
if (!File.Exists(fileName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var logFileInfo = new FileInfo(fileName);
|
||||
if (MaximumLogFileSizeBytes >= logFileInfo.Length && !ReRollLog) return;
|
||||
try
|
||||
{
|
||||
ReRollLog = false;
|
||||
|
||||
// Set the new file name to the time stamp of the file
|
||||
var baseFileName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName));
|
||||
|
||||
// Rather than rely on locale specific date/time strings, construct it ourself so
|
||||
// that it will always be yyyy-mm-dd hh.mm. This will cause the file names to sort
|
||||
// chronologically based on name, and should create a consistent file name result
|
||||
// for technical support
|
||||
var dateTimeStamp = logFileInfo.LastWriteTime.ToString("yyyy-MM-dd HH.mm.ss");
|
||||
|
||||
var tempFileName = baseFileName + "TEMP";
|
||||
|
||||
if (File.Exists(tempFileName)) { File.Delete(tempFileName); }
|
||||
|
||||
File.Move(fileName, tempFileName);
|
||||
var newFileName = baseFileName + " " + dateTimeStamp + ".log.bz2";
|
||||
try
|
||||
{
|
||||
using (var fs = new FileStream(newFileName, FileMode.Create))
|
||||
{
|
||||
using (var fs2 = new FileStream(tempFileName, FileMode.Open))
|
||||
{
|
||||
ICSharpCode.SharpZipLib.BZip2.BZip2.Compress(fs2, fs, true, 9);
|
||||
}
|
||||
}
|
||||
File.Delete(tempFileName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
newFileName = baseFileName + " " + dateTimeStamp + Path.GetExtension(fileName);
|
||||
try { File.Move(fileName, newFileName); }
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
var newName = fileName + ".LOGERROR";
|
||||
try { File.Move(fileName, newName); }
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle( "DTS.Common.Utilities" )]
|
||||
[assembly: AssemblyDescription( "" )]
|
||||
[assembly: AssemblyConfiguration( "" )]
|
||||
[assembly: AssemblyCompany( "DTS" )]
|
||||
[assembly: AssemblyProduct( "DTS.Common.Utilities" )]
|
||||
[assembly: AssemblyCopyright( "Copyright © DTS 2008" )]
|
||||
[assembly: AssemblyTrademark( "" )]
|
||||
[assembly: AssemblyCulture( "" )]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible( false )]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid( "533f783c-0c84-46cc-a368-2393869717f0" )]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion( "1.0.0.0" )]
|
||||
[assembly: AssemblyFileVersion( "1.0.0.0" )]
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* UpdateNotifyingList.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
public class UpdateNotifyingList<T> : Exceptional
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the UpdateNotifyingList class.
|
||||
/// </summary>
|
||||
public UpdateNotifyingList()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set the notification-bound items in this list.
|
||||
/// </summary>
|
||||
public List<T> Items
|
||||
{
|
||||
get => _Items.Value;
|
||||
set
|
||||
{
|
||||
try
|
||||
{ //
|
||||
// Update list items and then notify all subscribers.
|
||||
//
|
||||
_Items.Value = value;
|
||||
OnUpdate(value);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw new UpdateNotifyingList<T>.Exception("encountered problem setting UpdateNotifyingList.Items", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private Property<List<T>> _Items
|
||||
= new Property<List<T>>("NotifyingList", null, false);
|
||||
|
||||
/// <summary>
|
||||
/// Callback method to be invoked whenever the notifying list is updated.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="updatedContents">
|
||||
/// The updated contents of the notifying list.
|
||||
/// </param>
|
||||
///
|
||||
public delegate void OnUpdateCallback(List<T> updatedContents);
|
||||
|
||||
/// <summary>
|
||||
/// Subscribers to be notified whenever this list is changed.
|
||||
/// </summary>
|
||||
public event OnUpdateCallback OnUpdate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for HexEncoding.
|
||||
/// </summary>
|
||||
/// <remarks>This class has only static methods and appears to never be instantiated,
|
||||
/// so I'm marking it static as well
|
||||
/// there are built in classes for encoding and converting hex as well, but the behavior
|
||||
/// here may deviate slightly
|
||||
/// </remarks>
|
||||
public static class HexEncoding
|
||||
{
|
||||
/// <summary>
|
||||
/// returns the number of bytes needed to represent hex string
|
||||
/// </summary>
|
||||
/// <param name="hexString">hex string to calculate</param>
|
||||
/// <returns>number of bytes</returns>
|
||||
/// <remarks>doesn't count non hex characters
|
||||
/// odd number of characters, last character is discarded
|
||||
/// </remarks>
|
||||
public static int GetByteCount(string hexString)
|
||||
{
|
||||
var numHexChars = 0;
|
||||
char c;
|
||||
// remove all none A-F, 0-9, characters
|
||||
for (var i = 0; i < hexString.Length; i++)
|
||||
{
|
||||
c = hexString[i];
|
||||
if (IsHexDigit(c))
|
||||
numHexChars++;
|
||||
}
|
||||
// if odd number of characters, discard last character
|
||||
if (numHexChars % 2 != 0)
|
||||
{
|
||||
numHexChars--;
|
||||
}
|
||||
return numHexChars / 2; // 2 characters per byte
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a byte array from the hexadecimal string. Each two characters are combined
|
||||
/// to create one byte. First two hexadecimal characters become first byte in returned array.
|
||||
/// Non-hexadecimal characters are ignored.
|
||||
/// </summary>
|
||||
/// <param name="hexString">string to convert to byte array</param>
|
||||
/// <param name="discarded">number of characters in string ignored</param>
|
||||
/// <returns>byte array, in the same left-to-right order as the hexString</returns>
|
||||
public static byte[] GetBytes(string hexString, out int discarded)
|
||||
{
|
||||
discarded = 0;
|
||||
var newString = "";
|
||||
char c;
|
||||
// remove all none A-F, 0-9, characters
|
||||
for (var i = 0; i < hexString.Length; i++)
|
||||
{
|
||||
c = hexString[i];
|
||||
if (IsHexDigit(c))
|
||||
newString += c;
|
||||
else
|
||||
discarded++;
|
||||
}
|
||||
// if odd number of characters, discard last character
|
||||
if (newString.Length % 2 != 0)
|
||||
{
|
||||
discarded++;
|
||||
newString = newString.Substring(0, newString.Length - 1);
|
||||
}
|
||||
|
||||
var byteLength = newString.Length / 2;
|
||||
var bytes = new byte[byteLength];
|
||||
string hex;
|
||||
var j = 0;
|
||||
for (var i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
hex = new String(new Char[] { newString[j], newString[j + 1] });
|
||||
bytes[i] = HexToByte(hex);
|
||||
j = j + 2;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a string representation out of byte array
|
||||
/// </summary>
|
||||
/// <param name="bytes">an array of hex characters packed 2 per byte</param>
|
||||
/// <returns>string representation of hex characters in byte array, no spaces between bytes</returns>
|
||||
public static string ToString(byte[] bytes)
|
||||
{
|
||||
var hexString = "";
|
||||
for (var i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
hexString += bytes[i].ToString("X2");
|
||||
}
|
||||
return hexString;
|
||||
}
|
||||
/// <summary>
|
||||
/// Determines if given string is in proper hexadecimal string format
|
||||
/// </summary>
|
||||
/// <param name="hexString">string representing sequence of hex digits, no spaces</param>
|
||||
/// <returns>true if all characters are hex digits, false otherwise</returns>
|
||||
public static bool InHexFormat(string hexString)
|
||||
{
|
||||
var hexFormat = true;
|
||||
|
||||
foreach (var digit in hexString)
|
||||
{
|
||||
if (!IsHexDigit(digit))
|
||||
{
|
||||
hexFormat = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return hexFormat;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true is c is a hexadecimal digit (A-F, a-f, 0-9)
|
||||
/// </summary>
|
||||
/// <param name="c">Character to test</param>
|
||||
/// <returns>true if hex digit, false if not</returns>
|
||||
public static bool IsHexDigit(char c)
|
||||
{
|
||||
int numChar;
|
||||
var numA = Convert.ToInt32('A');
|
||||
var num1 = Convert.ToInt32('0');
|
||||
c = char.ToUpper(c);
|
||||
numChar = Convert.ToInt32(c);
|
||||
if (numChar >= numA && numChar < (numA + 6))
|
||||
return true;
|
||||
if (numChar >= num1 && numChar < (num1 + 10))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts 1 or 2 character string into equivalant byte value
|
||||
/// </summary>
|
||||
/// <param name="hex">1 or 2 character string</param>
|
||||
/// <returns>byte</returns>
|
||||
private static byte HexToByte(string hex)
|
||||
{
|
||||
if (hex.Length > 2 || hex.Length <= 0)
|
||||
throw new ArgumentException("hex must be 1 or 2 characters in length");
|
||||
var newByte = byte.Parse(hex, System.Globalization.NumberStyles.HexNumber);
|
||||
return newByte;
|
||||
}
|
||||
|
||||
public static string HexAsciiConvert(string hex)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
for (var i = 0; i < hex.Length; i += 2)
|
||||
{
|
||||
var hs = hex.Substring(i, 2);
|
||||
var converted = Convert.ToUInt32(hs, 16);
|
||||
if (converted == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
sb.Append(Convert.ToChar(converted));
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Common/DTS.Common.Utilities/.svn/wc.db
Normal file
BIN
Common/DTS.Common.Utilities/.svn/wc.db
Normal file
Binary file not shown.
0
Common/DTS.Common.Utilities/.svn/wc.db-journal
Normal file
0
Common/DTS.Common.Utilities/.svn/wc.db-journal
Normal file
430
Common/DTS.Common.Utilities/APILogging.cs
Normal file
430
Common/DTS.Common.Utilities/APILogging.cs
Normal file
@@ -0,0 +1,430 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using DTS.Common.Utilities.Properties;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Common.Utilities.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// this class encapsulating writing to the log
|
||||
///
|
||||
/// </summary>
|
||||
public static class APILogger
|
||||
{
|
||||
private static readonly object ProcessLock = new object();
|
||||
private static readonly Dictionary<string, Stack<Stopwatch>> _processes = new Dictionary<string, Stack<Stopwatch>>();
|
||||
public static int LogLevel { get; set; } = 3;
|
||||
public static void StartProcess(string name)
|
||||
{
|
||||
lock (ProcessLock)
|
||||
{
|
||||
if (!_processes.ContainsKey(name)) { _processes[name] = new Stack<Stopwatch>(); }
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
_processes[name].Push(sw);
|
||||
Log($"Starting process: [{name}] ({_processes[name].Count})");
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopProcess(string name)
|
||||
{
|
||||
lock (ProcessLock)
|
||||
{
|
||||
if (!_processes.ContainsKey(name) || 0 == _processes[name].Count)
|
||||
{
|
||||
Log($"Stopping process: [{name}] (0)");
|
||||
return;
|
||||
}
|
||||
var sw = _processes[name].Pop();
|
||||
sw.Stop();
|
||||
var ts = new TimeSpan(sw.ElapsedTicks);
|
||||
Log($"Stopping process: [{name}], {TimespanToHumanReadable(ts)}");
|
||||
}
|
||||
}
|
||||
private static string TimespanToHumanReadable(TimeSpan ts)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (ts.TotalDays > 1)
|
||||
{
|
||||
sb.Append($"{System.Math.Floor(ts.TotalDays):0} days, ");
|
||||
}
|
||||
sb.Append($"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds}.{ts.Milliseconds:000}");
|
||||
return sb.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// describes an event that should be raised when there's an error that needs to be handled by an application
|
||||
/// </summary>
|
||||
public delegate void ErrorRaisedEventDelegate(string msg);
|
||||
|
||||
private static ErrorRaisedEventDelegate _OnErrorRaised;
|
||||
/// <summary>
|
||||
/// Error handler called when errors are raised
|
||||
/// </summary>
|
||||
public static ErrorRaisedEventDelegate OnErrorRaised
|
||||
{
|
||||
get => _OnErrorRaised;
|
||||
set => _OnErrorRaised = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// raises an error, if an error handler is set, calls error handler
|
||||
/// </summary>
|
||||
public static void RaiseError(string error)
|
||||
{
|
||||
OnErrorRaised?.Invoke(error);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static string GetCurrentMethod()
|
||||
{
|
||||
var st = new StackTrace();
|
||||
var sf = st.GetFrame(1);
|
||||
|
||||
return sf.GetMethod().Name;
|
||||
}
|
||||
|
||||
private static bool _bDoPerformanceLog;
|
||||
public static void SetDoPerformanceLog(bool bDoLog)
|
||||
{
|
||||
_bDoPerformanceLog = bDoLog;
|
||||
}
|
||||
private static readonly object MyLock = new object();
|
||||
public static void DoPerformanceLog(string msg)
|
||||
{
|
||||
if (!_bDoPerformanceLog) { return; }
|
||||
var dt = DateTime.Now;
|
||||
var s = string.Format("{0:0000}-{1:00}-{2:00} {3:00}:{4:00}:{5:00}.{6:0000} ***{7}\r\n", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Millisecond, msg);
|
||||
lock (MyLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.AppendAllText("PERFLOG.LOG", s);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored - performance logging is only for statistics, we fail then we fail, just keep going
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// a function capable of logging a message
|
||||
/// </summary>
|
||||
/// <param name="msg">message to log</param>
|
||||
public delegate void Sink(string msg);
|
||||
|
||||
/// <summary>
|
||||
/// a consumer of log messages
|
||||
/// </summary>
|
||||
public static Sink Writer;
|
||||
|
||||
public static Sink ConfigurationLogWriter;
|
||||
public static Sink ConfigReadErrorLogWriter;
|
||||
|
||||
public static Sink StateWriter;
|
||||
|
||||
private static string LogException(Exception ex, bool bPrepend, bool bNewLine)
|
||||
{
|
||||
if (Writer == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
try
|
||||
{
|
||||
if (ex == null)
|
||||
{
|
||||
Writer("LogException: called with null exception");
|
||||
}
|
||||
else
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
if (bPrepend) { sb.Append(string.Concat(DateTime.Now.ToString(Resources.APILogging_DateTime_Format), " ")); }
|
||||
ExceptionFormater(ref sb, ex, 0);
|
||||
sb = sb.Replace(Environment.NewLine, " ");
|
||||
if (bNewLine) { sb.AppendLine(); }
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ownEx)
|
||||
{
|
||||
// and to be really paranoid...
|
||||
string orgMsg;
|
||||
if (ex == null)
|
||||
{
|
||||
orgMsg = "null exception";
|
||||
}
|
||||
else if (string.IsNullOrEmpty(ex.Message))
|
||||
{
|
||||
orgMsg = "blank exception message";
|
||||
}
|
||||
else
|
||||
{
|
||||
orgMsg = ex.Message;
|
||||
}
|
||||
try
|
||||
{
|
||||
Writer("APILogger: LogException threw an expection: " + ownEx.Message + " when handling: " + orgMsg);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
/// <summary>
|
||||
/// log an exception
|
||||
/// </summary>
|
||||
/// <param name="ex">exception to be logged</param>
|
||||
public static void LogException(Exception ex)
|
||||
{
|
||||
Writer(LogException(ex, true, true));
|
||||
}
|
||||
public const string EXCEPTIONSTART_STRING = "!! ";
|
||||
private static void ExceptionFormater(ref StringBuilder sb, Exception ex, int level)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (ex == null)
|
||||
return;
|
||||
var front = new string(' ', level);
|
||||
sb.Append(EXCEPTIONSTART_STRING);
|
||||
sb.AppendFormat(Resources.APILogging_ExceptionFormatter_ExceptionOfTypeOccurredString, front, level > 0 ? Resources.APILogging_ExceptionFormatter_InnerIndicationString : Resources.APILogging_ExceptionFormatter_NonInnerIndicationString, ex.GetType());
|
||||
if (null != ex.TargetSite)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_ModuleNameDisplayString, front, NullGuard(ex.TargetSite.Module.Name), NullGuard(ex.TargetSite.Name));
|
||||
}
|
||||
sb.AppendFormat(Resources.APILogging_ExceptionMessageDisplayString, front, NullGuard(ex.Message));
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
{
|
||||
// RW: It appears .NET 4.5 has a subtle difference in stack formatting. I don't see it, but it's breaking the Regex.
|
||||
// I'm not sure why it's using regex in the first place. This should work for both, but has not been tested with .NET 2.0
|
||||
string[] delimeters = { Environment.NewLine };
|
||||
var lines = ex.StackTrace.Split(delimeters, 2, StringSplitOptions.None);
|
||||
if (lines.Length > 0)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_StackTraceDisplayString, front, NullGuard(lines[0]));
|
||||
if (lines.Length > 1)
|
||||
{
|
||||
sb.AppendFormat(Resources.APILogging_StackTraceDisplayString, front, NullGuard(lines[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
// now call ourself with inner
|
||||
ex = ex.InnerException;
|
||||
level = level + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static string NullGuard(string s)
|
||||
{
|
||||
return s ?? Resources.Generic_NullIndicatorString;
|
||||
}
|
||||
|
||||
private static readonly string DATE_FORMAT = Resources.APILogging_DateTime_Format;
|
||||
private static string LogString(string str, bool bPrepend, bool bNewLine, bool bReplaceNewLines = true)
|
||||
{
|
||||
if (Writer == null)
|
||||
throw new Exception(Resources.APILogging_NullWriterDelegateString);
|
||||
var sb = new StringBuilder();
|
||||
if (bPrepend) { sb.Append($"{DateTime.Now.ToString(DATE_FORMAT)} "); }
|
||||
|
||||
if (bReplaceNewLines)
|
||||
{
|
||||
sb.Append(str.Replace(Environment.NewLine, " "));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(str);
|
||||
}
|
||||
|
||||
if (bNewLine) { sb.AppendLine(); }
|
||||
return sb.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// logs a string
|
||||
/// </summary>
|
||||
/// <param name="str">string to be logged</param>
|
||||
public static void LogString(string str)
|
||||
{
|
||||
Writer?.Invoke(LogString(str, true, true));
|
||||
}
|
||||
private static readonly object PhaseShiftLogLock = new object();
|
||||
/// <summary>
|
||||
/// logs a phase shift into a table
|
||||
/// </summary>
|
||||
/// <param name="serial"></param>
|
||||
/// <param name="msPhaseShift">MICROSECONDS of shift</param>
|
||||
/// <param name="originalT0"></param>
|
||||
/// <param name="modifiedTo"></param>
|
||||
/// <param name="samples"></param>
|
||||
/// <param name="rule"></param>
|
||||
public static void LogPhaseShift(string serial, double msPhaseShift, ulong originalT0, ulong modifiedTo, ulong samples, string rule)
|
||||
{
|
||||
try
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var s = string.Format("{0:0000}-{1:00}-{2:00} {3:00}:{4:00}:{5:00}.{6:0000}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\r\n",
|
||||
now.Year,
|
||||
now.Month,
|
||||
now.Day,
|
||||
now.Hour,
|
||||
now.Minute,
|
||||
now.Second,
|
||||
now.Millisecond,
|
||||
serial,
|
||||
samples,
|
||||
msPhaseShift,
|
||||
originalT0,
|
||||
modifiedTo,
|
||||
rule
|
||||
);
|
||||
lock (PhaseShiftLogLock)
|
||||
{
|
||||
|
||||
File.WriteAllLines("PHASE_SHIFT_LOG.txt", new[] { s });
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { Log(ex); }
|
||||
}
|
||||
|
||||
public static void StateLog(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
if (i > 0) { sb.Append(" "); }
|
||||
var s = paramlist[i] as string;
|
||||
if (paramlist[i] is DialogResult) { s = string.Format(" User selected {0}", ((DialogResult)paramlist[i])); }
|
||||
var ex = paramlist[i] as Exception;
|
||||
|
||||
if (null == s && null == ex && null != paramlist[i]) { s = paramlist[i].ToString(); }
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex) { sb.Append(LogException(ex, bPrepend, bNewLine)); }
|
||||
else if (null != s) { sb.Append(LogString(s, bPrepend, bNewLine, false)); }
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
StateWriter(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//if we fail to log there's not much more we can do ...
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
private const int LOG_LEVEL_DEBUG = 2;
|
||||
private static void LogEx(int logLevel, params object[] paramList)
|
||||
{
|
||||
if (logLevel >= LogLevel)
|
||||
{
|
||||
var newparams = new object[paramList.Length + 1];
|
||||
Array.Copy(new[] { $"LOG_LEVEL_{logLevel}" }, 0, newparams, 0, 1);
|
||||
Array.Copy(paramList, 0, newparams, 1, paramList.Length);
|
||||
Log(newparams);
|
||||
}
|
||||
}
|
||||
public static void DebugLog(params object[] paramList)
|
||||
{
|
||||
LogEx(LOG_LEVEL_DEBUG, paramList);
|
||||
}
|
||||
/// <summary>
|
||||
/// logs multiple parameters
|
||||
/// </summary>
|
||||
/// <param name="paramlist">
|
||||
/// collection of parameters, can be exceptions, strings, or an object with tostring
|
||||
/// </param>
|
||||
public static void Log(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
var obj = paramlist[i];
|
||||
if (i > 0) { sb.Append(" "); }
|
||||
var s = obj as string;
|
||||
if (obj is DialogResult) { s = $" User selected {(DialogResult)obj}"; }
|
||||
else if (obj is byte[])
|
||||
{
|
||||
s = BitConverter.ToString((byte[])obj).Replace("-", "");
|
||||
}
|
||||
else if (obj is object[] objArray)
|
||||
{
|
||||
s = string.Join(", ", objArray);
|
||||
}
|
||||
|
||||
var ex = obj as Exception;
|
||||
if (null == s && null == ex && null != obj) { s = obj.ToString(); }
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex) { sb.Append(LogException(ex, bPrepend, bNewLine)); }
|
||||
else if (null != s) { sb.Append(LogString(s, bPrepend, bNewLine)); }
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
Writer(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//if we fail to log there's not much more we can do ...
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// logs multiple parameters
|
||||
/// </summary>
|
||||
/// <param name="paramlist">
|
||||
/// collection of parameters, can be exceptions, strings, or an object with tostring
|
||||
/// </param>
|
||||
public static void ConfLog(params object[] paramlist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < paramlist.Length; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
sb.Append(" ");
|
||||
}
|
||||
var s = paramlist[i] as string;
|
||||
if (paramlist[i] is DialogResult)
|
||||
{
|
||||
s = $" User selected {(DialogResult)paramlist[i]}";
|
||||
}
|
||||
var ex = paramlist[i] as Exception;
|
||||
|
||||
if (null == s && null == ex && null != paramlist[i])
|
||||
{
|
||||
s = paramlist[i].ToString();
|
||||
}
|
||||
|
||||
var bPrepend = 0 == i;
|
||||
var bNewLine = paramlist.Length == i + 1;
|
||||
if (null != ex)
|
||||
{
|
||||
sb.Append(LogException(ex, bPrepend, bNewLine));
|
||||
}
|
||||
else if (null != s)
|
||||
{
|
||||
sb.Append(LogString(s, bPrepend, bNewLine));
|
||||
}
|
||||
}
|
||||
var msg = sb.ToString();
|
||||
ConfigurationLogWriter(msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//as with the other log function, if we fail we don't have much backing we can do
|
||||
Trace.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user