This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
namespace DTS.Common.Interface.DASFactory.Download
{
public interface IDownloadRequest
{
/// <summary>
/// From which event do we want to download data?
/// </summary>
ushort EventNumber { get; set; }
/// <summary>
/// Which channel? (set to ALL_CHANNELS for all)
/// </summary>
byte DASChannelNumber { get; set; }
/// <summary>
/// The first sample you want.
/// </summary>
ulong StartSample { get; set; }
/// <summary>
/// The last sample you want.
/// </summary>
ulong EndSample { get; set; }
/// <summary>
/// This is used for sub-sampling data, 0 (or 1) means don't sub-sample, 2 means
/// give me every other sample and so on. The number of samples requested
/// (EndSample-StartSample+1) must be an multiple of SamplesToSkip.
/// </summary>
ulong SamplesToSkip { get; set; }
/// <summary>
///
/// </summary>
double StartRecordTimestampSec { get; set; }
/// <summary>
///
/// </summary>
double TriggerTimestampSec { get; set; }
/// <summary>
///
/// </summary>
double StartRecordTimestampNanoSec { get; set; }
/// <summary>
///
/// </summary>
double TriggerTimestampNanoSec { get; set; }
/// <summary>
///
/// </summary>
bool PTPMasterSync { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
namespace DTS.Common.Enums.Sensors.SensorsList
{
public enum StreamOutSettingFields
{
Included,
SerialNumber,
Description,
LastModifiedBy,
LastModified,
UDPProfile,
UDPAddress,
UDPTimeChannelId,
UDPDataChannelId,
UDPTmNSConfig,
IRIGTimeDataPacketIntervalMs,
TMATSIntervalMs
}
}

View File

@@ -0,0 +1,99 @@
using System;
namespace DTS.Common.Interface.DASFactory.Download
{
public interface IDownload
{
/// <summary>
/// What do you want to download?
/// </summary>
IDownloadRequest WhatToDownload { get; set; }
void SetWhatToDownload(IDownloadRequest request, bool bSetInDb = true);
/// <summary>
/// The Retrieved information about stored events.
/// </summary>
IDownloadReport EventInfo { get; set; }
void SetEventInfo(IDownloadReport eventInfo, bool bSetInDb = true);
/// <summary>
/// QueryDownloadedStatus will fill this array (indexed by event number, true if
/// HasBeenDownloaded was set for this event, false otherwise)
/// </summary>
bool[] EventDownloadedStatus { get; set; }
void SetEventDownloadStatus(bool[] status, bool storeInDb = true);
/// <summary>
/// DASFactory will fill this array (indexed by event number).
/// </summary>
Guid[] EventGuids { get; set; }
void SetEventGuids(Guid[] guids, bool storeInDb = true);
/// <summary>
/// DASFactory will fill this array (indexed by event number).
/// </summary>
ushort[] FaultFlags { get; set; }
void SetEventFaultFlags(ushort[] flags, bool storeInDb = true);
/// <summary>
/// any extended fault flags1, if there are multiple events then each event is an additional index
/// however downloads are always done one event at a time
/// </summary>
uint[] ExtendedFaultFlags1 { get; set; }
/// <summary>
/// any extended fault flags2, if there are multiple events then each event is an additional index
/// however downloads are always done one event at a time
/// </summary>
uint[] ExtendedFaultFlags2 { get; set; }
/// <summary>
/// any extended fault flags3, if there are multiple events then each event is an additional index
/// however downloads are always done one event at a time
/// </summary>
uint[] ExtendedFaultFlags3 { get; set; }
/// <summary>
/// any extended fault flags4, if there are multiple events then each event is an additional index
/// however downloads are always done one event at a time
/// </summary>
uint[] ExtendedFaultFlags4 { get; set; }
/// <summary>
/// sets the properties for extended fault flags, first array is always events, second array is extended fault flags
/// there are currently 4 extended fault flags in SLICE
/// http://manuscript.dts.local/f/cases/39223/
/// </summary>
/// <param name="flags"></param>
void SetExtendedFaultFlags(uint[][] flags);
/// <summary>
/// DASFactory will fill this array (indexed by event number).
/// </summary>
byte[] ArmAttempts { get; set; }
void SetEventArmAttemps(byte[] armAttempts, bool storeInDb = true);
}
public interface IDownloadPathAware
{
string EventPath { get; set; }
}
public static class DownloadExtendedFaultFunctions
{
public static void SetExtendedFaultFlags(uint[][] flags, IDownload download)
{
if (null == flags || 0 == flags.Length)
{
ClearExtendedFaultFlags(download);
return;
}
download.ExtendedFaultFlags1 = new uint[flags.Length];
download.ExtendedFaultFlags2 = new uint[flags.Length];
download.ExtendedFaultFlags3 = new uint[flags.Length];
download.ExtendedFaultFlags4 = new uint[flags.Length];
for (var i = 0; i < flags.Length; i++)
{
download.ExtendedFaultFlags1[i] = flags[i].Length > 0 ? flags[i][0] : 0;
download.ExtendedFaultFlags2[i] = flags[i].Length > 1 ? flags[i][1] : 0;
download.ExtendedFaultFlags3[i] = flags[i].Length > 2 ? flags[i][2] : 0;
download.ExtendedFaultFlags4[i] = flags[i].Length > 3 ? flags[i][3] : 0;
}
}
public static void ClearExtendedFaultFlags(IDownload download)
{
download.ExtendedFaultFlags1 = null;
download.ExtendedFaultFlags2 = null;
download.ExtendedFaultFlags3 = null;
download.ExtendedFaultFlags4 = null;
}
}
}

View File

@@ -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 GroupsXMLClass
{
[XmlElement("Group")]
public List<GroupXMLClass> Group { get; set; }
}
}

View File

@@ -0,0 +1,117 @@
using DTS.Common.Utilities.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace DTS.Common.Classes
{
/// <summary>
/// This class represents work requested of the services framework
/// </summary>
public class ServiceCall
{
public bool Started { get; set; } = false;
/// <summary>
/// the work to be done when service call is made
/// </summary>
public Action WorkAction { get; set; }
/// <summary>
/// indicates the service call is complete
/// </summary>
public void MarkDone()
{
ServiceQueue.MarkFinished(this);
}
public string Name { get; set; }
public ServiceCall(string name)
{
Name = name;
}
}
/// <summary>
/// this class handles calls of the services framework by doing a little managing of who gets to run and when
/// </summary>
public class ServiceQueue
{
/// <summary>
/// just a lock to keep resource access thread safe
/// </summary>
private static readonly object QueueLock = new object();
/// <summary>
/// this is sort of a Queue, actions are enqueued when the are instantiated,
/// but using a list allows us to re-order then when needed and to remove items that are no longer needed and haven't been
/// started yet
/// </summary>
private readonly List<ServiceCall> ServiceCalls = new List<ServiceCall>();
/// <summary>
/// the singleton/the instance of the queue
/// </summary>
private static ServiceQueue _serviceQueue = new ServiceQueue();
/// <summary>
/// adds a new item for the services framework to handle
/// </summary>
/// <param name="call"></param>
public static void Enqueue(ServiceCall call)
{
lock (QueueLock)
{
//adds work item to the queue
_serviceQueue.ServiceCalls.Add(call);
//start the item if it's the only item in the queue
if (1 == _serviceQueue.ServiceCalls.Count)
{
StartWork();
}
}
}
/// <summary>
/// starts a call into the services framework
/// </summary>
private static void StartWork()
{
lock (QueueLock)
{
//if there's any calls in the queue, launch the first
if (_serviceQueue.ServiceCalls.Any())
{
var work = _serviceQueue.ServiceCalls[0];
//to prevent multiple startworks from starting the same work, just make sure it's not started
if (work.Started) { return; }
work.Started = true;
Task.Run(() => { work.WorkAction(); });
}
}
}
/// <summary>
/// marks a servicecall as finished, if it's the current work item the next work item will be started if any
/// </summary>
/// <param name="call"></param>
public static void MarkFinished(ServiceCall call)
{
lock (QueueLock)
{
if (!_serviceQueue.ServiceCalls.Any() || !_serviceQueue.ServiceCalls.Contains(call))
{
return;
}
if (_serviceQueue.ServiceCalls[0] != call)
{
//it wasn't being actively worked on, just remove
_serviceQueue.ServiceCalls.Remove(call);
return;
}
//this was the current work item, so we are free to start a new item
_serviceQueue.ServiceCalls.RemoveAt(0);
if (_serviceQueue.ServiceCalls.Any())
{
StartWork();
}
}
}
}
}