using NIDAQmx.DAQmxEnum;
using NIDAQmxConst;
using System.Runtime.CompilerServices;

namespace NIDAQmx
{
    public class AITiming : BaseDevice
    {
        internal AITiming(DAQmxSession session, string deviceName) : base(session, deviceName)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AI.DAQmxGetDevAIMaxSingleChanRate>()(DeviceName, ref maxSingleChanRate));
            _Session.CheckResult(_Session.GetDelegate<Internal.AI.DAQmxGetDevAIMaxMultiChanRate>()(DeviceName, ref maxMultiChanRate));
            _Session.CheckResult(_Session.GetDelegate<Internal.AI.DAQmxGetDevAIMinRate>()(DeviceName, ref minRate));
            _Session.CheckResult(_Session.GetDelegate<Internal.AI.DAQmxGetDevAISimultaneousSamplingSupported>()(DeviceName, ref simultaneousSamplingSupported));
            _Session.CheckResult(_Session.GetDelegate<Internal.AI.DAQmxGetDevAINumSampTimingEngines>()(DeviceName, ref numSampTimingEngines));
            SampleModes[] modes = new SampleModes[Enum.GetValues<SampleModes>().Length];
            _Session.CheckResult(_Session.GetDelegate<Internal.AI.DAQmxGetDevAISampModes>()(DeviceName, ref modes[0], (uint)modes.Length));
            SampModes = modes.Where(x => x != 0).ToArray();
        }
        private double maxSingleChanRate;
        private double maxMultiChanRate;
        private double minRate;
        private bool simultaneousSamplingSupported;
        private uint numSampTimingEngines;
        public double MaxSingleChanRate => maxSingleChanRate;
        public double MaxMultiChanRate => maxMultiChanRate;
        public double MinRate => minRate;
        public bool SimultaneousSamplingSupported => simultaneousSamplingSupported;
        public uint NumSampTimingEngines => numSampTimingEngines;
        public SampleModes[] SampModes { get; }
    }
}
