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 { /// /// This class describes what should be downloaded from the DAS to the PC. /// public class DownloadRequest : IDownloadRequest { /// /// 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. /// public const byte ALL_CHANNELS = 0xFF; /// /// From which event do we want to download data? /// public ushort EventNumber { get; set; } /// /// Which channel? (set to ALL_CHANNELS for all) /// public byte DASChannelNumber { get; set; } /// /// The first sample you want. /// public virtual ulong StartSample { get; set; } /// /// The last sample you want. /// public virtual ulong EndSample { get; set; } /// /// 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. /// public ulong SamplesToSkip { get; set; } /// /// /// public double StartRecordTimestampSec { get; set; } /// /// /// public double TriggerTimestampSec { get; set; } /// /// /// public double StartRecordTimestampNanoSec { get; set; } /// /// /// public double TriggerTimestampNanoSec { get; set; } /// /// /// 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); } } } }