init
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DTS.Common.Interface.DASFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// RealTime Interface for an DAS unit.
|
||||
/// </summary>
|
||||
public interface IRealTime
|
||||
{
|
||||
/// <summary>
|
||||
/// The list of channels from which to recieve Real Time Data.
|
||||
/// </summary>
|
||||
List<int> RealtimeDASChannels { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Slice6 Axis 1, 2, 3 (X, Y, Z) tilt data in degrees.
|
||||
/// </summary>
|
||||
List<double> TiltAxisData { get; set; }
|
||||
/// <summary>
|
||||
/// The S6/S6A realtime UDP stream address.
|
||||
/// </summary>
|
||||
string UDPStreamAddress { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace DTS.Common.Classes.DSP
|
||||
{
|
||||
/// <summary>
|
||||
/// collection for all dsp filters
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S101:Types should be named in PascalCase", Justification = "Acronym")]
|
||||
public class DSPFilterCollection : Collection<DSPFilterType>
|
||||
{
|
||||
private static readonly object MyLock = new object();
|
||||
private static DSPFilterCollection _instance = null;
|
||||
public static DSPFilterCollection GetDSPFilterCollection()
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (null != _instance) { return _instance; }
|
||||
WriteDefaultFileIfMissing(DSP_FILTER_XML_FILE);
|
||||
_instance = ReadFile(DSP_FILTER_XML_FILE);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
private const string DSP_FILTER_XML_FILE = "DSPFilters.xml";
|
||||
|
||||
private DSPFilterCollection(DSPFilterType[] filters)
|
||||
{
|
||||
foreach (var filter in filters) { Add(filter); }
|
||||
}
|
||||
public DSPFilterCollection() { }
|
||||
|
||||
public const int BUTTERWORTH = 13;
|
||||
public const int FIR45TAP = 14;
|
||||
public const int NONE = 0;
|
||||
|
||||
public enum DSPFilterDefaults
|
||||
{
|
||||
[Display(Name ="None", Description = "Default and legacy setting for streaming")]
|
||||
[Scaler(double.NaN)]
|
||||
None = NONE,
|
||||
[Display(Name = "6th IIR Butterworth", Description = "6 - pole IIR Butterworth Low Pass")]
|
||||
[Scaler(double.NaN)]
|
||||
Butterworth = BUTTERWORTH,
|
||||
[Display(Name = "45-Tap FIR", Description = "finite impulse response filter with 45 taps")]
|
||||
[Scaler(double.NaN)]
|
||||
FIR = FIR45TAP
|
||||
}
|
||||
|
||||
private static DSPFilterCollection CreateDefaultCollection()
|
||||
{
|
||||
var list = new List<DSPFilterType>
|
||||
{
|
||||
new DSPFilterType(DSPFilterDefaults.None, new DASRestriction[] { new DASRestriction() }),
|
||||
new DSPFilterType(DSPFilterDefaults.Butterworth, new DASRestriction[]
|
||||
{
|
||||
new DASRestriction(HardwareTypes.SLICE6_AIR.ToString(), 28),
|
||||
new DASRestriction(HardwareTypes.SLICE6_AIR_BR.ToString(), -1),
|
||||
new DASRestriction(HardwareTypes.SLICE6_AIR_TC.ToString(), -1)
|
||||
}),
|
||||
new DSPFilterType(DSPFilterDefaults.FIR, new DASRestriction[]
|
||||
{
|
||||
new DASRestriction(HardwareTypes.SLICE6_AIR.ToString(), 28),
|
||||
new DASRestriction(HardwareTypes.SLICE6_AIR_BR.ToString(), -1),
|
||||
new DASRestriction(HardwareTypes.SLICE6_AIR_TC.ToString(), -1)
|
||||
})
|
||||
};
|
||||
|
||||
var collection = new DSPFilterCollection(list.ToArray());
|
||||
return collection;
|
||||
}
|
||||
|
||||
private static void WriteDefaultFileIfMissing(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath)) { return; }
|
||||
var collection = CreateDefaultCollection();
|
||||
|
||||
var serializer = new XmlSerializer(typeof(DSPFilterCollection));
|
||||
var settings = new XmlWriterSettings() { Indent = true };
|
||||
|
||||
using (var writer = XmlWriter.Create(filePath, settings))
|
||||
{
|
||||
serializer.Serialize(writer, collection);
|
||||
}
|
||||
}
|
||||
|
||||
private static DSPFilterCollection ReadFile(string filePath)
|
||||
{
|
||||
var deserializer = new XmlSerializer(typeof(DSPFilterCollection));
|
||||
using (var fs = new FileStream(filePath, FileMode.Open))
|
||||
{
|
||||
var cs = (DSPFilterCollection)deserializer.Deserialize(fs);
|
||||
return cs;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// returns the matching filter, or None if not found, or if none isn't found then the first entry
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
public DSPFilterType GetFilter(string s)
|
||||
{
|
||||
var match = Items.FirstOrDefault(x => x.DisplayString == s);
|
||||
if (null != match) { return match; }
|
||||
match = Items.FirstOrDefault(x => x.EnumValue == 0);
|
||||
if (null != match) { return match; }
|
||||
return Items[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace DTS.Common.Enums
|
||||
{
|
||||
public enum UartDataFormat
|
||||
{
|
||||
Binary,
|
||||
PlainText,
|
||||
NMEA
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Practices.Prism.Modularity;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Common
|
||||
{
|
||||
public class AggregateModuleCatalog : IModuleCatalog
|
||||
{
|
||||
private readonly List<IModuleCatalog> _catalogs = new List<IModuleCatalog>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AggregateModuleCatalog"/> class.
|
||||
/// </summary>
|
||||
public AggregateModuleCatalog()
|
||||
{
|
||||
_catalogs.Add(new ModuleCatalog());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of catalogs.
|
||||
/// </summary>
|
||||
/// <value>A read-only collection of catalogs.</value>
|
||||
private IEnumerable<IModuleCatalog> Catalogs => _catalogs.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Adds the catalog to the list of catalogs
|
||||
/// </summary>
|
||||
/// <param name="catalog">The catalog to add.</param>
|
||||
public void AddCatalog(IModuleCatalog catalog)
|
||||
{
|
||||
if (catalog == null)
|
||||
throw new ArgumentNullException($"catalog");
|
||||
|
||||
_catalogs.Add(catalog);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the <see cref="ModuleInfo"/> classes that are in the <see cref="ModuleCatalog"/>.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public IEnumerable<ModuleInfo> Modules
|
||||
{
|
||||
get { return Catalogs.SelectMany(x => x.Modules); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the list of <see cref="ModuleInfo"/>s that <paramref name="moduleInfo"/> depends on.
|
||||
/// </summary>
|
||||
/// <param name="moduleInfo">The <see cref="ModuleInfo"/> to get the <see cref="ModuleCatalog"/>.</param>
|
||||
/// <returns>
|
||||
/// An enumeration of <see cref="ModuleInfo"/> that <paramref name="moduleInfo"/> depends on.
|
||||
/// </returns>
|
||||
public IEnumerable<ModuleInfo> GetDependentModules(ModuleInfo moduleInfo)
|
||||
{
|
||||
var catalog = _catalogs.Single(x => x.Modules.Contains(moduleInfo));
|
||||
return catalog.GetDependentModules(moduleInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the collection of <see cref="ModuleInfo"/>s that contain both the <see cref="ModuleInfo"/>s in
|
||||
/// <paramref name="modules"/>, but also all the modules they depend on.
|
||||
/// </summary>
|
||||
/// <param name="modules">The modules to get the dependencies for.</param>
|
||||
/// <returns>
|
||||
/// A collection of <see cref="ModuleInfo"/> that contains both all <see cref="ModuleInfo"/>s in <paramref name="modules"/>
|
||||
/// and also all the <see cref="ModuleInfo"/> they depend on.
|
||||
/// </returns>
|
||||
public IEnumerable<ModuleInfo> CompleteListWithDependencies(IEnumerable<ModuleInfo> modules)
|
||||
{
|
||||
var modulesGroupedByCatalog = modules.GroupBy(module => _catalogs.Single(catalog => catalog.Modules.Contains(module)));
|
||||
return modulesGroupedByCatalog.SelectMany(x => x.Key.CompleteListWithDependencies(x));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the catalog, which may load and validate the modules.
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
foreach (var catalog in Catalogs)
|
||||
{
|
||||
catalog.Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="ModuleInfo"/> to the <see cref="ModuleCatalog"/>.
|
||||
/// </summary>
|
||||
/// <param name="moduleInfo">The <see cref="ModuleInfo"/> to add.</param>
|
||||
public void AddModule(ModuleInfo moduleInfo)
|
||||
{
|
||||
_catalogs[0].AddModule(moduleInfo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.Common.Interface.DASFactory
|
||||
{
|
||||
public interface ITimeSynchronization
|
||||
{
|
||||
bool SupportsTimeSynchronization { get; }
|
||||
DateTime SystemBaseTime { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace DTS.Common.XMLUtils
|
||||
{
|
||||
public class DASListXMLClass
|
||||
{
|
||||
[XmlElement("DASList")]
|
||||
|
||||
public List<DASHardwareXMLClass> DASList { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user