public static void ConfigureSupply(NIDCPower supplyHandle, SupplyConfiguration supplyConfig, string channelNames = "")
        {
            supplyHandle.Source.Mode = DCPowerSourceMode.SinglePoint;

            supplyHandle.Outputs[channelNames].Source.Output.Function   = supplyConfig.OutputFunction;
            supplyHandle.Outputs[channelNames].Source.TransientResponse = supplyConfig.TransientResponseMode;

            switch (supplyConfig.OutputFunction)
            {
            case DCPowerSourceOutputFunction.DCVoltage:
                supplyHandle.Outputs[channelNames].Source.Voltage.CurrentLimitAutorange = DCPowerSourceCurrentLimitAutorange.On;
                supplyHandle.Outputs[channelNames].Source.Voltage.VoltageLevelAutorange = DCPowerSourceVoltageLevelAutorange.On;

                supplyHandle.Outputs[channelNames].Source.Voltage.VoltageLevel = supplyConfig.VoltageLevel_V;
                supplyHandle.Outputs[channelNames].Source.Voltage.CurrentLimit = supplyConfig.CurrentLimit_A;
                break;

            case DCPowerSourceOutputFunction.DCCurrent:
                supplyHandle.Outputs[channelNames].Source.Current.CurrentLevelAutorange = DCPowerSourceCurrentLevelAutorange.On;
                supplyHandle.Outputs[channelNames].Source.Current.VoltageLimitAutorange = DCPowerSourceVoltageLimitAutorange.On;

                supplyHandle.Outputs[channelNames].Source.Current.CurrentLevel = supplyConfig.CurrentLevel_A;
                supplyHandle.Outputs[channelNames].Source.Current.VoltageLimit = supplyConfig.VoltageLimit_V;
                break;

            default:
                throw new NotImplementedException("Pulse voltage/current is not implemented.");
            }

            if (supplyConfig.TransientResponseMode == DCPowerSourceTransientResponse.Custom)
            {
                switch (supplyConfig.OutputFunction)
                {
                case DCPowerSourceOutputFunction.DCVoltage:
                    supplyHandle.Outputs[channelNames].Source.CustomTransientResponse.Voltage.CompensationFrequency =
                        supplyConfig.CustomTransientConfig.CompensationFrequency;
                    supplyHandle.Outputs[channelNames].Source.CustomTransientResponse.Voltage.GainBandwidth =
                        supplyConfig.CustomTransientConfig.GainBandwidth;
                    supplyHandle.Outputs[channelNames].Source.CustomTransientResponse.Voltage.PoleZeroRatio =
                        supplyConfig.CustomTransientConfig.PoleZeroRatio;
                    break;

                case DCPowerSourceOutputFunction.DCCurrent:
                    supplyHandle.Outputs[channelNames].Source.CustomTransientResponse.Current.CompensationFrequency =
                        supplyConfig.CustomTransientConfig.CompensationFrequency;
                    supplyHandle.Outputs[channelNames].Source.CustomTransientResponse.Current.GainBandwidth =
                        supplyConfig.CustomTransientConfig.GainBandwidth;
                    supplyHandle.Outputs[channelNames].Source.CustomTransientResponse.Current.PoleZeroRatio =
                        supplyConfig.CustomTransientConfig.PoleZeroRatio;
                    break;
                }
            }
        }
        static void Main()
        {
            string    channelNames = "0";
            NIDCPower dcPower      = new NIDCPower("4139", channelNames, false);

            // Configure instrument settings
            SupplyConfiguration supplyConfig = SupplyConfiguration.GetDefault();

            supplyConfig.OutputFunction = DCPowerSourceOutputFunction.DCVoltage;
            supplyConfig.VoltageLevel_V = 3;
            supplyConfig.CurrentLevel_A = 1;

            ConfigureSupply(dcPower, supplyConfig, channelNames);

            // Configure measurement related parameters
            MeasurementConfiguration measConfig = new MeasurementConfiguration
            {
                MeasureWhenMode = DCPowerMeasurementWhen.AutomaticallyAfterSourceComplete,
                SenseMode       = DCPowerMeasurementSense.Remote,
                // A MeasurementMode of "Record" acquires multiple smaples over the requested measurement
                // time at the supply's maximum sampling rate. "Single Point" will take a single measurement
                // over that duration and average the power and current results.
                MeasurementMode            = MeasurementModeConfiguration.Record,
                MeasurementTime_s          = 2e-3,
                MeasurementTriggerTerminal = "PXI_Trig0"
            };

            ConfigureMeasurement(dcPower, measConfig, channelNames);

            TurnSupplyOnOrOff(dcPower, SupplyPowerMode.PowerOn, channelNames);

            MeasurementResults results = MeasureSupplyIV(dcPower, channelNames);

            // Calculate the average of the acquired results
            results = Utilities.CalculateAverageIV(results);

            Console.WriteLine($"The average voltage measured was {results.Voltage_V[0]} with a current of {results.Current_A[0]}");
            Console.WriteLine("Press any key to turn off the supply and exit the program.");

            Console.ReadKey();

            TurnSupplyOnOrOff(dcPower, SupplyPowerMode.PowerOff, channelNames);

            CloseSupply(dcPower, channelNames);
        }
        /// <summary>
        /// This example illustrates how to use the NI-DCPower APIs to configure the SMU and measure the results.
        /// </summary>
        static void Main()
        {
            string    channelNames = "0";
            NIDCPower dcPower      = new NIDCPower("4139", channelNames, false);

            // Configure instrument settings
            SupplyConfiguration supplyConfig = SupplyConfiguration.GetDefault();

            supplyConfig.OutputFunction = DCPowerSourceOutputFunction.DCVoltage;
            supplyConfig.VoltageLevel_V = 3;
            supplyConfig.CurrentLevel_A = 0.001;
            supplyConfig.VoltageLimit_V = 3;
            supplyConfig.CurrentLimit_A = 0.001;

            ConfigureSupply(dcPower, supplyConfig, channelNames);

            // Configure measurement related parameters
            MeasurementConfiguration measConfig = MeasurementConfiguration.GetDefault();

            measConfig.MeasureWhenMode   = DCPowerMeasurementWhen.AutomaticallyAfterSourceComplete;
            measConfig.MeasurementTime_s = 2e-3;

            ConfigureMeasurement(dcPower, measConfig, channelNames);

            TurnSupplyOnOrOff(dcPower, SupplyPowerMode.PowerOn, channelNames);

            MeasurementResults results = MeasureSupplyIV(dcPower, channelNames);

            // Calculate the average of the acquired results
            results = Utilities.CalculateAverageIV(results);

            Console.WriteLine($"The average voltage measured was {results.Voltage_V[0]} with a current of {results.Current_A[0]}");
            Console.WriteLine("Press any key to turn off the supply and exit the program.");

            Console.ReadKey();

            TurnSupplyOnOrOff(dcPower, SupplyPowerMode.PowerOff, channelNames);

            CloseSupply(dcPower);
        }
        static void Main()
        {
            string    channelNames = "0";
            NIDCPower dcPower      = new NIDCPower("4139", channelNames, false);

            SupplyConfiguration supplyConfig = new SupplyConfiguration();

            supplyConfig.SetDefaults();

            supplyConfig.OutputFunction        = DCPowerSourceOutputFunction.DCVoltage;
            supplyConfig.VoltageLevel_V        = 3;
            supplyConfig.CurrentLevel_A        = 1;
            supplyConfig.TransientResponseMode = DCPowerSourceTransientResponse.Fast;

            ConfigureSupply(dcPower, supplyConfig, channelNames);

            MeasurementConfiguration measConfig = new MeasurementConfiguration
            {
                MeasureWhenMode            = DCPowerMeasurementWhen.AutomaticallyAfterSourceComplete,
                SenseMode                  = DCPowerMeasurementSense.Remote,
                MeasurementMode            = MeasurementConfiguration.MeasurementModeConfiguration.SinglePoint,
                MeasurementTime_s          = 2e-3,
                MeasurementTriggerTerminal = "PXI_Trig0"
            };

            ConfigureMeasurement(dcPower, measConfig, channelNames);

            TurnSupplyOnOrOff(dcPower, SupplyPowerMode.PowerOn, channelNames);

            MeasurementResults results = MeasureSupplyIV(dcPower, channelNames);

            results = Utilities.CalculateAverageIV(results, 3);

            TurnSupplyOnOrOff(dcPower, SupplyPowerMode.PowerOff, channelNames);

            CloseSupply(dcPower, channelNames);
        }