using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NIDAQmx.DAQmxEnum;

namespace NIDAQmx
{
    public class Buffer : DAQmxBase
    {
        private void SetInputBufSize(UInt32 bufseize)
        {
            if (_Session.Error) return;
            _Session.CheckResult(GetDelagate<Internal.Buffer.DAQmxSetBufInputBufSize>().Invoke(_Session.TaskHandle,bufseize));
        }
        private UInt32 GetInputBufSize()
        {
            uint size = 0;
            _Session.CheckResult(GetDelagate<Internal.Buffer.DAQmxGetBufInputBufSize>().Invoke(_Session.TaskHandle, ref size));
            return size;
        }
        private UInt32 GetInputOnbrdBufSize()
        {
            uint size = 0;
            _Session.CheckResult(GetDelagate<Internal.Buffer.DAQmxGetBufInputOnbrdBufSize>().Invoke(_Session.TaskHandle, ref size));
            return size;
        }
        private void SetOutputBufSize(UInt32 bufseize)
        {
            if (_Session.Error) return;
            _Session.CheckResult(GetDelagate<Internal.Buffer.DAQmxSetBufOutputBufSize>().Invoke(_Session.TaskHandle, bufseize));
        }
        private UInt32 GetOutputBufSize()
        {
            uint size = 0;
            _Session.CheckResult(GetDelagate<Internal.Buffer.DAQmxGetBufOutputBufSize>().Invoke(_Session.TaskHandle, ref size));
            return size;
        }
        private void SetOutputOnbrdBufSize(UInt32 bufseize)
        {
            if (_Session.Error) return;
            _Session.CheckResult(GetDelagate<Internal.Buffer.DAQmxSetBufOutputOnbrdBufSize>().Invoke(_Session.TaskHandle, bufseize));
        }
        private UInt32 GetOutputOnbrdBufSize()
        {
            uint size = 0;
            _Session.CheckResult(GetDelagate<Internal.Buffer.DAQmxGetBufOutputOnbrdBufSize>().Invoke(_Session.TaskHandle, ref size));
            return size;
        }

        internal Buffer(DAQmxSession session) : base(session)
        {
        }
        public UInt32 InputBufSize
        {
            get=> GetInputBufSize();
            set => SetInputBufSize(value);
        }
        public void ResetInputBufSize()
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.Buffer.DAQmxResetBufInputBufSize>().Invoke(_Session.TaskHandle));
        }
        public UInt32 OutputBufSize
        {
            get => GetOutputBufSize();
            set => SetOutputBufSize(value);
        }
        public void ResetOutputBufSize()
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.Buffer.DAQmxResetBufOutputBufSize>().Invoke(_Session.TaskHandle));
        }
        public UInt32 OutputOnbrdBufSize
        {
            get => GetOutputOnbrdBufSize();
            set => SetOutputOnbrdBufSize(value);
        }
        public void ResetOutputOnbrdBufSize()
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.Buffer.DAQmxResetBufOutputOnbrdBufSize>().Invoke(_Session.TaskHandle));
        }
        public UInt32 InputOnbrdBufSize=>GetInputOnbrdBufSize();
    }
}
