109 lines
3.6 KiB
C#
109 lines
3.6 KiB
C#
|
|
|
|
using DASFactoryDb.Download;
|
|
using DTS.Common.Interface.DASFactory;
|
|
using DTS.Common.Interface.DASFactory.Download;
|
|
using DTS.Common.Utilities.Logging;
|
|
using System;
|
|
|
|
namespace DTS.DASLib.Service
|
|
{
|
|
/// <summary>
|
|
/// This class describes what should be downloaded from the DAS to the PC.
|
|
/// </summary>
|
|
public class DownloadRequest : IDownloadRequest
|
|
{
|
|
/// <summary>
|
|
/// Setting the DASChannelNumber property of this object to this constant value will
|
|
/// download all channels from the DAS. Currently, this is the only option that is supported
|
|
/// so DASChannelNumber MUST be equal to this value.
|
|
/// </summary>
|
|
public const byte ALL_CHANNELS = 0xFF;
|
|
|
|
/// <summary>
|
|
/// From which event do we want to download data?
|
|
/// </summary>
|
|
public ushort EventNumber { get; set; }
|
|
|
|
/// <summary>
|
|
/// Which channel? (set to ALL_CHANNELS for all)
|
|
/// </summary>
|
|
public byte DASChannelNumber { get; set; }
|
|
|
|
/// <summary>
|
|
/// The first sample you want.
|
|
/// </summary>
|
|
public virtual ulong StartSample { get; set; }
|
|
|
|
/// <summary>
|
|
/// The last sample you want.
|
|
/// </summary>
|
|
public virtual 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>
|
|
public ulong SamplesToSkip { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public double StartRecordTimestampSec { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public double TriggerTimestampSec { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public double StartRecordTimestampNanoSec { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public double TriggerTimestampNanoSec { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public bool PTPMasterSync { get; set; }
|
|
|
|
public static void SetWhatToDownload(IDASCommunication das, IDownloadRequest request, bool bSetInDb)
|
|
{
|
|
if (null != request)
|
|
{
|
|
APILogger.Log($"WhatToDownload = Event: {request.EventNumber}, StartSample: {request.StartSample}, EndSample: {request.EndSample}");
|
|
}
|
|
das.WhatToDownload = request;
|
|
if (!bSetInDb || !DASFactoryDb.DbWrapper.Connected) { return; }
|
|
|
|
try
|
|
{
|
|
Download.ClearExistingDownloadRequests(das.RecordId);
|
|
if (null != request)
|
|
{
|
|
Download.DownloadRequestInsert(das.RecordId,
|
|
request.EventNumber,
|
|
request.DASChannelNumber,
|
|
request.StartSample,
|
|
request.EndSample,
|
|
request.SamplesToSkip,
|
|
request.StartRecordTimestampSec,
|
|
request.TriggerTimestampSec,
|
|
request.StartRecordTimestampNanoSec,
|
|
request.TriggerTimestampNanoSec,
|
|
request.PTPMasterSync);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
APILogger.Log(ex);
|
|
}
|
|
}
|
|
}
|
|
}
|