public static MeasurementResults MeasureSupplyIV(NIDCPower supplyHandle, string channelNames = "")
        {
            MeasurementResults results;

            DCPowerMeasurementWhen measureMode = supplyHandle.Measurement.Configuration.MeasureWhen;
            int samplesToFetch = supplyHandle.Outputs[channelNames].Measurement.RecordLength;

            supplyHandle.Control.Initiate();
            switch (measureMode)
            {
            case DCPowerMeasurementWhen.OnMeasureTrigger:
            case DCPowerMeasurementWhen.AutomaticallyAfterSourceComplete:
                DCPowerFetchResult fetchResult = supplyHandle.Measurement.Fetch(channelNames, new PrecisionTimeSpan(1), samplesToFetch);
                results.Voltage_V = fetchResult.VoltageMeasurements;
                results.Current_A = fetchResult.CurrentMeasurements;
                break;

            case DCPowerMeasurementWhen.OnDemand:
            default:
                DCPowerMeasureResult measureResult = supplyHandle.Measurement.Measure(channelNames);
                results.Voltage_V = measureResult.VoltageMeasurements;
                results.Current_A = measureResult.CurrentMeasurements;
                break;
            }
            supplyHandle.Control.Abort();
            //Calculate power
            results.Power_W = new double[results.Voltage_V.Length];

            for (int i = 0; i < results.Voltage_V.Length; i++)
            {
                results.Power_W[i] = results.Voltage_V[i] * results.Current_A[i];
            }
            return(results);
        }
Beispiel #2
0
 public void SetDefaults()
 {
     MeasureWhenMode            = DCPowerMeasurementWhen.OnMeasureTrigger;
     SenseMode                  = DCPowerMeasurementSense.Local;
     MeasurementTriggerTerminal = DCPowerDigitalEdgeMeasureTriggerInputTerminal.PxiTriggerLine0.ToString();
     MeasurementMode            = MeasurementModeConfiguration.SinglePoint;
     MeasurementTime_s          = 1e-3;
 }