using NIDAQmx.DAQmxEnum;
using NIDAQmxConst;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace NIDAQmx
{
    public sealed class AIChannel : InChannel
    {
        internal AIChannel(DAQmxSession session) : base(session)
        {
            AttributeSession = new ChannelAttributeSession(_Session);
        }
        internal override ChannelAttributeSession AttributeSession { get; }
        public void ReadAnalog(int numSampsPerChan,double timeout,bool fillMode,ref double value, uint arraySizeInSamps,ref int sampsPerChanRead)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.DataRead.DAQmxReadAnalogF64>()(_Session.TaskHandle, numSampsPerChan, timeout, fillMode, ref value, arraySizeInSamps, ref sampsPerChanRead, IntPtr.Zero));
        }
        public void ReadAnalogScalar(double timeout,ref double value)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.DataRead.DAQmxReadAnalogScalarF64>()(_Session.TaskHandle, timeout, ref value, IntPtr.Zero));
        }
        public void ReadBinary(int numSampsPerChan,double timeout,bool fillMode,ref short readArray,uint arraySizeInSamps,ref int sampsPerChanRead)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.DataRead.DAQmxReadBinaryI16>()(_Session.TaskHandle, numSampsPerChan, timeout, fillMode, ref readArray, arraySizeInSamps, ref sampsPerChanRead, IntPtr.Zero));
        }
        public void ReadBinary(int numSampsPerChan, double timeout, bool fillMode, ref int readArray, uint arraySizeInSamps, ref int sampsPerChanRead)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.DataRead.DAQmxReadBinaryI32>()(_Session.TaskHandle, numSampsPerChan, timeout, fillMode, ref readArray, arraySizeInSamps, ref sampsPerChanRead, IntPtr.Zero));
        }
        public void ReadBinary(int numSampsPerChan, double timeout, bool fillMode, ref ushort readArray, uint arraySizeInSamps, ref int sampsPerChanRead)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.DataRead.DAQmxReadBinaryU16>()(_Session.TaskHandle, numSampsPerChan, timeout, fillMode, ref readArray, arraySizeInSamps, ref sampsPerChanRead, IntPtr.Zero));
        }
        public void ReadBinary(int numSampsPerChan, double timeout, bool fillMode, ref uint readArray, uint arraySizeInSamps, ref int sampsPerChanRead)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.DataRead.DAQmxReadBinaryU32>()(_Session.TaskHandle, numSampsPerChan, timeout, fillMode, ref readArray, arraySizeInSamps, ref sampsPerChanRead, IntPtr.Zero));
        }
        internal void CreateVoltage(string physicalChannel,string nameToAssignToChannel,double min,double max,TerminalConfig terminalConfig = TerminalConfig.Default, AIVoltageUnits units = AIVoltageUnits.Volts, string customScaleName ="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIVoltageChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, min, max, units, customScaleName));
            if(_Session.Error)
            {
                throw new Exception($"Create Voltage Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateCurrent(string physicalChannel, string nameToAssignToChannel, double min, double max, AnalogCurrentUnit units,AICurrentShuntResistorLoc shuntResistorLoc,double extShuntResistorVal,TerminalConfig terminalConfig = TerminalConfig.Default, string customScaleName = "")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAICurrentChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, min, max, units,shuntResistorLoc,extShuntResistorVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create Current Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateVoltageRMS(string physicalChannel, string nameToAssignToChannel, double min, double max,TerminalConfig terminalConfig = TerminalConfig.Default, AIVoltageUnits units = AIVoltageUnits.Volts, string customScaleName = "")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIVoltageRMSChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, min, max, units, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create Voltage RMS Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateCurrentRMS(string physicalChannel, string nameToAssignToChannel, double min, double max, AnalogCurrentUnit units, AICurrentShuntResistorLoc shuntResistorLoc, double extShuntResistorVal, TerminalConfig terminalConfig = TerminalConfig.Default, string customScaleName = "")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAICurrentRMSChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, min, max, units, shuntResistorLoc, extShuntResistorVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create Current RMS Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateThrmcpl(string physicalChannel, string nameToAssignToChannel,string cjcChannel, double min, double max,AITempUnits units = AITempUnits.DegC,ThrmcplType type = ThrmcplType.N,ThrmcplCJCSrc src = ThrmcplCJCSrc.Chan,double cjcval=0)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIThrmcplChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel,  min, max, units,  type,src,cjcval, cjcChannel));
            if (_Session.Error)
            {
                throw new Exception($"Create Thrmcpl Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateRTD(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, AITempUnits units, RTDType rtdType, AIResistanceCfg resistanceConfig, AIExcitSrc currentExcitSource, double currentExcitVal, double r0)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIRTDChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, rtdType, resistanceConfig, currentExcitSource, currentExcitVal, r0));
            if (_Session.Error)
            {
                throw new Exception($"Create RTD Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateThrmstrIex(string physicalChannel, string nameToAssignToChannel, double minVal, double maxVal, AITempUnits units, AIResistanceCfg resistanceConfig, AIExcitSrc currentExcitSource, double currentExcitVal, double a, double b, double c)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIThrmstrChanIex>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, resistanceConfig, currentExcitSource, currentExcitVal, a,b,c));
            if (_Session.Error)
            {
                throw new Exception($"Create ThrmstrIex Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateThrmstrVex(string physicalChannel, string nameToAssignToChannel, double minVal, double maxVal, AITempUnits units, AIResistanceCfg resistanceConfig, AIExcitSrc currentExcitSource, double currentExcitVal, double a, double b, double c,double r1)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIThrmstrChanVex>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, resistanceConfig, currentExcitSource, currentExcitVal, a, b, c,r1));
            if (_Session.Error)
            {
                throw new Exception($"Create ThrmstrVex Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateStrainGage(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, StrainUnits units, StrainGageCfg strainConfig, AIExcitSrc voltageExcitSource, double voltageExcitVal, double gageFactor, double initialBridgeVoltage, double nominalGageResistance, double poissonRatio, double leadWireResistance,  string customScaleName = "")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIStrainGageChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, strainConfig, voltageExcitSource, voltageExcitVal, gageFactor,initialBridgeVoltage,nominalGageResistance,poissonRatio,leadWireResistance,customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create StrainGage Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateRosetteStrainGage(string physicalChannel,
                string nameToAssignToChannel,
                double minVal,
                double maxVal,
                RosetteStrainGageRosetteType rosetteType,
                double gageOrientation,
                RosetteStrainGageRosetteMeasType[] rosetteMeasTypes,
                StrainGageCfg strainConfig,
                int voltageExcitSource,
                double voltageExcitVal,
                double gageFactor,
                double nominalGageResistance,
                double poissonRatio,
                double leadWireResistance)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIRosetteStrainGageChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, rosetteType,gageOrientation,ref rosetteMeasTypes[0],(uint)rosetteMeasTypes.Length, strainConfig, voltageExcitSource, voltageExcitVal, gageFactor, nominalGageResistance, poissonRatio, leadWireResistance));
            if (_Session.Error)
            {
                throw new Exception($"Create RosetteStrainGage Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateForceBridgeTwoPointLin(string physicalChannel,
                string nameToAssignToChannel,
                double minVal,
                double maxVal,
                ForceUnits units,
                AIBridgeCfg bridgeConfig,
                int voltageExcitSource,
                double voltageExcitVal,
                double nominalBridgeResistance,
                double firstElectricalVal,
                double secondElectricalVal,
                AIBridgeElectricalUnits electricalUnits,
                double firstPhysicalVal,
                double secondPhysicalVal,
                AIBridgePhysicalUnits physicalUnits,
                string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIForceBridgeTwoPointLinChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units,bridgeConfig,voltageExcitSource,voltageExcitVal,nominalBridgeResistance,firstElectricalVal,secondElectricalVal,electricalUnits,firstPhysicalVal,secondPhysicalVal,physicalUnits,customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create ForceBridgeTwoPointLin Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateForceBridgeTable(
                string physicalChannel,
                string nameToAssignToChannel,
                double minVal,
                double maxVal,
                ForceUnits units,
                AIBridgeCfg bridgeConfig,
                int voltageExcitSource,
                double voltageExcitVal,
                double nominalBridgeResistance,
                double[] electricalVals,
                AIBridgeElectricalUnits electricalUnits,
                double[] physicalVals,
                AIBridgePhysicalUnits physicalUnits,
                string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIForceBridgeTableChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, bridgeConfig, voltageExcitSource, voltageExcitVal, nominalBridgeResistance, ref electricalVals[0], (uint)electricalVals.Length, electricalUnits, ref physicalVals[0], (uint)physicalVals.Length, physicalUnits, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create ForceBridgeTable Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateForceBridgePolynomial(
                string physicalChannel,
                string nameToAssignToChannel,
                double minVal,
                double maxVal,
                ForceUnits units,
                AIBridgeCfg bridgeConfig,
                int voltageExcitSource,
                double voltageExcitVal,
                double nominalBridgeResistance,
                double[] forwardCoeffs,
                double[] reverseCoeffs,
                AIBridgeElectricalUnits electricalUnits,
                AIBridgePhysicalUnits physicalUnits,
                string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIForceBridgePolynomialChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, bridgeConfig, voltageExcitSource, voltageExcitVal, nominalBridgeResistance, ref forwardCoeffs[0], (uint)forwardCoeffs.Length, ref reverseCoeffs[0], (uint)reverseCoeffs.Length,electricalUnits, physicalUnits, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create ForceBridgePolynomial Channel fail");
            }
            ChannelName = physicalChannel;
        }

        internal void CreatePressureBridgeTwoPointLin(
                string physicalChannel,
                string nameToAssignToChannel,
                double minVal,
                double maxVal,
                AIPressureUnits units,
                AIBridgeCfg bridgeConfig,
                int voltageExcitSource,
                double voltageExcitVal,
                double nominalBridgeResistance,
                double firstElectricalVal,
                double secondElectricalVal,
                AIBridgeElectricalUnits electricalUnits,
                double firstPhysicalVal,
                double secondPhysicalVal,
                AIBridgePhysicalUnits physicalUnits,
                string customScaleName = "")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIPressureBridgeTwoPointLinChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, bridgeConfig, voltageExcitSource, voltageExcitVal, nominalBridgeResistance, firstElectricalVal, secondElectricalVal,electricalUnits,firstPhysicalVal, secondPhysicalVal,  physicalUnits, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create PressureBridgeTwoPointLin Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreatePressureBridgeTable(
                string physicalChannel,
                string nameToAssignToChannel,
                double minVal,
                double maxVal,
                AIPressureUnits units,
                AIBridgeCfg bridgeConfig,
                int voltageExcitSource,
                double voltageExcitVal,
                double nominalBridgeResistance,
                double[] electricalVals,
                AIBridgeElectricalUnits electricalUnits,
                double[] physicalVals,
                AIBridgePhysicalUnits physicalUnits,
                string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIPressureBridgeTableChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, bridgeConfig, voltageExcitSource, voltageExcitVal, nominalBridgeResistance, ref electricalVals[0], (uint)electricalVals.Length, electricalUnits, ref physicalVals[0], (uint)physicalVals.Length, physicalUnits, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create PressureBridgeTable Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreatePressureBridgePolynomial(
                string physicalChannel,
                string nameToAssignToChannel,
                double minVal,
                double maxVal,
                AIPressureUnits units,
                AIBridgeCfg bridgeConfig,
                int voltageExcitSource,
                double voltageExcitVal,
                double nominalBridgeResistance,
                double[] forwardCoeffs,
                double[] reverseCoeffs,
                AIBridgeElectricalUnits electricalUnits,
                AIBridgePhysicalUnits physicalUnits,
                string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIPressureBridgePolynomialChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, bridgeConfig, voltageExcitSource, voltageExcitVal, nominalBridgeResistance, ref forwardCoeffs[0], (uint)forwardCoeffs.Length,ref reverseCoeffs[0],(uint)reverseCoeffs.Length, electricalUnits,  physicalUnits, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create PressureBridgePolynomial Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTorqueBridgeTwoPointLin(
                string physicalChannel,
                string nameToAssignToChannel,
                double minVal,
                double maxVal,
                AITorqueUnits units,
                AIBridgeCfg bridgeConfig,
                int voltageExcitSource,
                double voltageExcitVal,
                double nominalBridgeResistance,
                double firstElectricalVal,
                double secondElectricalVal,
                AIBridgeElectricalUnits electricalUnits,
                double firstPhysicalVal,
                double secondPhysicalVal,
                AIBridgePhysicalUnits physicalUnits,
                string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAITorqueBridgeTwoPointLinChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, bridgeConfig, voltageExcitSource, voltageExcitVal, nominalBridgeResistance, firstElectricalVal, secondElectricalVal, electricalUnits,firstPhysicalVal,secondPhysicalVal, physicalUnits, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TorqueBridgeTwoPointLin Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTorqueBridgeTable(
                string physicalChannel,
                string nameToAssignToChannel,
                double minVal,
                double maxVal,
                AITorqueUnits units,
                AIBridgeCfg bridgeConfig,
                int voltageExcitSource,
                double voltageExcitVal,
                double nominalBridgeResistance,
                double[] electricalVals,
                AIBridgeElectricalUnits electricalUnits,
                double[] physicalVals,
                AIBridgePhysicalUnits physicalUnits,
                string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAITorqueBridgeTableChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, bridgeConfig, voltageExcitSource, voltageExcitVal, nominalBridgeResistance, ref electricalVals[0], (uint)electricalVals.Length, electricalUnits, ref physicalVals[0], (uint)physicalVals.Length, physicalUnits, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TorqueBridgeTable Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTorqueBridgePolynomial(
                string physicalChannel,
                string nameToAssignToChannel,
                double minVal,
                double maxVal,
                AITorqueUnits units,
                AIBridgeCfg bridgeConfig,
                AIExcitSrc voltageExcitSource,
                double voltageExcitVal,
                double nominalBridgeResistance,
                double[] forwardCoeffs,
                double[] reverseCoeffs,
                AIBridgeElectricalUnits electricalUnits,
                AIBridgePhysicalUnits physicalUnits,
                string customScaleName ="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAITorqueBridgePolynomialChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, bridgeConfig, voltageExcitSource, voltageExcitVal, nominalBridgeResistance, ref forwardCoeffs[0], (uint)forwardCoeffs.Length, ref reverseCoeffs[0],(uint)reverseCoeffs.Length, electricalUnits, physicalUnits, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TorqueBridgePolynomial Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateBridge(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, AIBridgeUnits units, AIBridgeCfg bridgeConfig, AIExcitSrc voltageExcitSource, double voltageExcitVal, double nominalBridgeResistance,string customScaleName ="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIBridgeChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, bridgeConfig, voltageExcitSource, voltageExcitVal, nominalBridgeResistance, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create Bridge Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateVoltageWithExcit(string physicalChannel,string nameToAssignToChannel, TerminalConfig terminalConfig, double minVal, double maxVal, AIVoltageUnits units, AIBridgeCfg bridgeConfig, AIExcitSrc voltageExcitSource, double voltageExcitVal, bool useExcitForScaling, string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIVoltageChanWithExcit>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel,terminalConfig, minVal, maxVal, units, bridgeConfig, voltageExcitSource, voltageExcitVal, useExcitForScaling, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create VoltageWithExcit Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTempBuiltInSensor(string physicalChannel,string nameToAssignToChannel, AITempUnits units)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAITempBuiltInSensorChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, units));
            if (_Session.Error)
            {
                throw new Exception($"Create TempBuiltInSensor Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateAccel(string physicalChannel, string nameToAssignToChannel, TerminalConfig terminalConfig, double minVal, double maxVal, AccelUnits units, double sensitivity, AccelSensitivityUnits sensitivityUnits, AIExcitSrc currentExcitSource, double currentExcitVal,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIAccelChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel,terminalConfig,minVal,maxVal, units,sensitivity,sensitivityUnits,currentExcitSource,currentExcitVal,customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create Accel Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateVelocityIEPE(string physicalChannel,string nameToAssignToChannel, TerminalConfig terminalConfig, double minVal, double maxVal, VelocityUnits units, double sensitivity, VelocityIEPESensorSensitivityUnits sensitivityUnits, AIExcitSrc currentExcitSource, double currentExcitVal, string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIVelocityIEPEChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, minVal, maxVal, units, sensitivity, sensitivityUnits, currentExcitSource, currentExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create VelocityIEPE Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateForceIEPE(string physicalChannel,string nameToAssignToChannel, TerminalConfig terminalConfig, double minVal, double maxVal, ForceUnits units, double sensitivity, ForceIEPESensorSensitivityUnits sensitivityUnits, AIExcitSrc currentExcitSource, double currentExcitVal,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIForceIEPEChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, minVal, maxVal, units, sensitivity, sensitivityUnits, currentExcitSource, currentExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create ForceIEPE Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateMicrophone(string physicalChannel,string nameToAssignToChannel, TerminalConfig terminalConfig, SoundPressureUnits units, double micSensitivity, double maxSndPressLevel, AIExcitSrc currentExcitSource, double currentExcitVal,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIMicrophoneChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, units, micSensitivity, maxSndPressLevel, currentExcitSource, currentExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create Microphone Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateCharge(string physicalChannel, string nameToAssignToChannel, TerminalConfig terminalConfig, double minVal, double maxVal, AIChargeUnits units,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIChargeChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig,  minVal, maxVal, units, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create Charge Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateAccelCharge(string physicalChannel,string nameToAssignToChannel, TerminalConfig terminalConfig, double minVal, double maxVal, AccelUnits units, double sensitivity, AccelChargeSensitivityUnits sensitivityUnits,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIAccelChargeChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, minVal, maxVal, units,sensitivity,sensitivityUnits, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create AccelCharge Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateAccel4WireDCVoltage(string physicalChannel,string nameToAssignToChannel, TerminalConfig terminalConfig, double minVal, double maxVal, AccelUnits units, double sensitivity, AccelSensitivityUnits sensitivityUnits, AIExcitSrc voltageExcitSource, double voltageExcitVal, bool useExcitForScaling, string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIAccel4WireDCVoltageChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, minVal, maxVal, units, sensitivity, sensitivityUnits,voltageExcitSource,voltageExcitVal,useExcitForScaling, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create Accel4WireDCVoltage Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreatePosLVDT(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, LVDTUnits units, double sensitivity, LVDTSensitivityUnits sensitivityUnits, AIExcitSrc voltageExcitSource, double voltageExcitVal, double voltageExcitFreq, ACExcitWireMode ACExcitWireMode, string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIPosLVDTChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, sensitivity, sensitivityUnits, voltageExcitSource, voltageExcitVal, voltageExcitFreq,ACExcitWireMode, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create PosLVDT Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreatePosRVDT(string physicalChannel, string nameToAssignToChannel, double minVal, double maxVal, RVDTUnits units, double sensitivity, RVDTSensitivityUnits sensitivityUnits, AIExcitSrc voltageExcitSource, double voltageExcitVal, double voltageExcitFreq, ACExcitWireMode ACExcitWireMode, string customScaleName = "")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIPosRVDTChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, sensitivity, sensitivityUnits, voltageExcitSource, voltageExcitVal, voltageExcitFreq, ACExcitWireMode, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create PosRVDT Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreatePosEddyCurrProxProbe(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, LVDTUnits units, double sensitivity, EddyCurrentProxSensitivityUnits sensitivityUnits,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIPosEddyCurrProxProbeChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, sensitivity, sensitivityUnits, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create PosEddyCurrProxProbe Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateDeviceTemp(string physicalChannel,string nameToAssignToChannel, AITempUnits units)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIDeviceTempChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, units));
            if (_Session.Error)
            {
                throw new Exception($"Create DeviceTemp Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSVoltage(string physicalChannel,string nameToAssignToChannel, TerminalConfig terminalConfig, double minVal, double maxVal, AIVoltageUnits units,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIVoltageChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, minVal, maxVal, units, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSVoltage Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSCurrent(string physicalChannel, string nameToAssignToChannel, double min, double max, AnalogCurrentUnit units, AICurrentShuntResistorLoc shuntResistorLoc, double extShuntResistorVal, TerminalConfig terminalConfig = TerminalConfig.Default, string customScaleName = "")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAICurrentChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, min, max, units, shuntResistorLoc, extShuntResistorVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSCurrent Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSThrmcpl(string physicalChannel, string nameToAssignToChannel, string cjcChannel, double min, double max, AITempUnits units = AITempUnits.DegC, ThrmcplCJCSrc src = ThrmcplCJCSrc.Chan, double cjcval = 0)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIThrmcplChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, min, max, units,  src, cjcval, cjcChannel));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSThrmcpl Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSRTD(string physicalChannel, string nameToAssignToChannel, double minVal, double maxVal, AITempUnits units, AIResistanceCfg resistanceConfig, AIExcitSrc currentExcitSource, double currentExcitVal)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIRTDChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units,  resistanceConfig, currentExcitSource, currentExcitVal));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSRTD Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSThrmstrIex(string physicalChannel, string nameToAssignToChannel, double minVal, double maxVal, AITempUnits units, AIResistanceCfg resistanceConfig, AIExcitSrc currentExcitSource, double currentExcitVal)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIThrmstrChanIex>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, resistanceConfig, currentExcitSource, currentExcitVal));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSThrmstrIex Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSThrmstrVex(string physicalChannel, string nameToAssignToChannel, double minVal, double maxVal, AITempUnits units, AIResistanceCfg resistanceConfig, AIExcitSrc currentExcitSource, double currentExcitVal,double r1)
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIThrmstrChanVex>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, resistanceConfig, currentExcitSource, currentExcitVal,r1));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSThrmstrVex Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateFreqVoltage(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, AIFreqUnits units, double thresholdLevel, double hysteresis,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIFreqVoltageChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, thresholdLevel, hysteresis, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create FreqVoltage Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateResistance(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, ResistanceUnits units, AIResistanceCfg resistanceConfig, AIExcitSrc currentExcitSource, double currentExcitVal,string customScaleName ="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateAIResistanceChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, resistanceConfig, currentExcitSource,currentExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create Resistance Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSResistance(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, ResistanceUnits units, AIResistanceCfg resistanceConfig, AIExcitSrc currentExcitSource, double currentExcitVal, string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIResistanceChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, resistanceConfig, currentExcitSource, currentExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSResistance Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSStrainGage(string physicalChannel, string nameToAssignToChannel, double minVal, double maxVal, StrainUnits units,  AIExcitSrc voltageExcitSource, double voltageExcitVal, double initialBridgeVoltage, double leadWireResistance, string customScaleName = "")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIStrainGageChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units,  voltageExcitSource, voltageExcitVal, initialBridgeVoltage,leadWireResistance, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSStrainGage Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSForceBridge(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, ForceUnits units, AIExcitSrc voltageExcitSource, double voltageExcitVal,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIForceBridgeChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, voltageExcitSource, voltageExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSForceBridge Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSPressureBridge(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, AIPressureUnits units, AIExcitSrc voltageExcitSource, double voltageExcitVal, string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIPressureBridgeChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, voltageExcitSource, voltageExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSPressureBridge Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSTorqueBridge(string physicalChannel, string nameToAssignToChannel, double minVal, double maxVal, AITorqueUnits units, AIExcitSrc voltageExcitSource, double voltageExcitVal,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAITorqueBridgeChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, voltageExcitSource, voltageExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSTorqueBridge Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSBridge(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, AIBridgeUnits units, AIExcitSrc voltageExcitSource, double voltageExcitVal,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIBridgeChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, voltageExcitSource, voltageExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSBridge Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSAccel(string physicalChannel, string nameToAssignToChannel, TerminalConfig terminalConfig, double minVal, double maxVal, AccelUnits units, AIExcitSrc currentExcitSource, double currentExcitVal, string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIAccelChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel,terminalConfig, minVal, maxVal, units, currentExcitSource, currentExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSAccel Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSForceIEPE(string physicalChannel,string nameToAssignToChannel, TerminalConfig terminalConfig, double minVal, double maxVal, ForceUnits units, AIExcitSrc currentExcitSource, double currentExcitVal, string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIForceIEPEChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, minVal, maxVal, units, currentExcitSource, currentExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create ForceIEPE Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSMicrophone(string physicalChannel, string nameToAssignToChannel, TerminalConfig terminalConfig, SoundPressureUnits units, double maxSndPressLevel, AIExcitSrc currentExcitSource, double currentExcitVal,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIMicrophoneChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, terminalConfig,  units,maxSndPressLevel, currentExcitSource, currentExcitVal, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSMicrophone Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSPosLVDT(string physicalChannel, string nameToAssignToChannel, double minVal, double maxVal, LVDTUnits units, AIExcitSrc voltageExcitSource, double voltageExcitVal, double voltageExcitFreq, ACExcitWireMode ACExcitWireMode,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIPosLVDTChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal,maxVal, units, voltageExcitSource,voltageExcitVal,voltageExcitFreq,ACExcitWireMode, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSPosLVDT Channel fail");
            }
            ChannelName = physicalChannel;
        }
        internal void CreateTEDSAIPosRVDT(string physicalChannel,string nameToAssignToChannel, double minVal, double maxVal, RVDTUnits units, AIExcitSrc voltageExcitSource, double voltageExcitVal, double voltageExcitFreq, ACExcitWireMode ACExcitWireMode,string customScaleName="")
        {
            _Session.CheckResult(_Session.GetDelegate<Internal.AICreate.DAQmxCreateTEDSAIPosRVDTChan>()(_Session.TaskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, units, voltageExcitSource, voltageExcitVal, voltageExcitFreq, ACExcitWireMode, customScaleName));
            if (_Session.Error)
            {
                throw new Exception($"Create TEDSPosRVDT Channel fail");
            }
            ChannelName = physicalChannel;
        }
    }

}
