Files
DP44/DataPRO/IService/SLICE Service.Information.cs
2026-04-17 14:55:32 -04:00

121 lines
4.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
using System.Xml.Serialization;
using System.IO;
using DTS.DASLib.Communication;
using DTS.DASLib.Connection;
using DTS.DASLib.Connection.USBFramework;
using DTS.DASLib.Command.SLICE;
using DTS.DASLib.Command;
using DTS.DASLib.Service;
using DTS.Slice.Service;
using DTS.DASLib.Utility;
using DTS.DASLib.DASResource;
using DTS.DAS.Concepts;
namespace DTS.DASLib.Service
{
public partial class Slice<T>: Communication<T>,
IDASCommunication,
IConfigurationActions,
ICalibrateActions,
ITriggerCheckActions,
IRealTimeActions,
IArmActions,
IDownloadActions,
IInformationActions where T: IConnection, new()
{
#region Information
void IInformationActions.Query(ServiceCallback callback, object userData)
{
var info = new SliceServiceAsyncInfo(callback, userData);
LaunchAsyncWorker("Slice.Query", new WaitCallback(AsyncQueryInformation), info);
}
private void AsyncQueryInformation(object asyncInfo)
{
var info = asyncInfo as SliceServiceAsyncInfo;
try
{
var StackQuery = new QueryStackContents(this);
StackQuery.SyncExecute();
var dasInfo = new InfoResult();
dasInfo.Modules = new InfoResult.Module[StackQuery.SliceCount];
for(int sliceIdx = 0; sliceIdx < StackQuery.SliceCount; sliceIdx++)
{
var module = new InfoResult.Module();
module.ModuleNumber = sliceIdx;
module.MaxRecordingSamples = MaxNumberOfSamples; // this should be adjusted to real-life
module.NumberOfChannels = NumberOfChannelsPerModule;
module.SerialNumber = StackQuery.SerialNumber[sliceIdx];
module.SupportedGains = (uint[])GainList.Clone();
module.SupportedModes = new Test.Module.RecordingMode[2] { Test.Module.RecordingMode.CircularBuffer,
Test.Module.RecordingMode.RecorderMode };
module.SupportedSampleRates = (uint[])SamplerateList.Clone(); // this should be adjusted to real-life
module.TypeOfModule = InfoResult.Module.ModuleType.SliceBridge; // for now
dasInfo.Modules[sliceIdx] = module;
}
DASInfo = dasInfo;
info.Success();
}
catch(CanceledException)
{
info.Cancel();
}
catch(Exception ex)
{
info.Error(ex.Message, ex);
}
}
private void DASFactoryQueryInformation()
{
try
{
var StackQuery = new StackContentsQuery(this);
StackQuery.SyncExecute();
var dasInfo = new InfoResult();
dasInfo.Modules = new InfoResult.Module[StackQuery.SliceCount];
for(int sliceIdx = 0; sliceIdx < StackQuery.SliceCount; sliceIdx++)
{
var module = new InfoResult.Module();
module.ModuleNumber = sliceIdx;
module.MaxRecordingSamples = MaxNumberOfSamples; // this should be adjusted to real-life
module.NumberOfChannels = NumberOfChannelsPerModule;
module.SerialNumber = StackQuery.SerialNumber[sliceIdx];
module.SupportedGains = (uint[])GainList.Clone();
module.SupportedModes = new Test.Module.RecordingMode[2] { Test.Module.RecordingMode.CircularBuffer,
Test.Module.RecordingMode.RecorderMode };
module.SupportedSampleRates = (uint[])SamplerateList.Clone(); // this should be adjusted to real-life
module.TypeOfModule = InfoResult.Module.ModuleType.SliceBridge; // for now
dasInfo.Modules[sliceIdx] = module;
}
DASInfo = dasInfo;
info.Success();
}
catch(CanceledException)
{
info.Cancel();
}
catch(Exception ex)
{
info.Error(ex.Message, ex);
}
}
#endregion
}
}