Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,7 @@ public static void ForceCurrent(this DCPowerSessionsBundle sessionsBundle, doubl
LevelRange = currentLevelRange,
LimitRange = voltageLimitRange
};
sessionsBundle.Do(sessionInfo =>
{
sessionInfo.Force(settings, sitePinInfo: null, waitForSourceCompletion);
});
sessionsBundle.ForceCurrent(settings, waitForSourceCompletion);
}

/// <summary>
Expand All @@ -320,7 +317,20 @@ public static void ForceCurrent(this DCPowerSessionsBundle sessionsBundle, IDict
LevelRange = currentLevelRange,
LimitRange = voltageLimitRange
};
sessionInfo.Force(settings, sitePinInfo, waitForSourceCompletion);
var channelOutput = sessionInfo.Session.Outputs[sitePinInfo.IndividualChannelString];
sessionInfo.ConfigureChannels(settings, channelOutput, sitePinInfo);
if ((sitePinInfo.CascadingInfo as GangingInfo)?.IsFollower == true)
{
channelOutput.InitiateChannels();
}
});
sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
var channelOutput = sessionInfo.Session.Outputs[sitePinInfo.IndividualChannelString];
if (!(sitePinInfo.CascadingInfo is GangingInfo ganging) || !ganging.IsFollower)
{
channelOutput.InitiateChannels(waitForSourceCompletion);
}
});
}

Expand All @@ -347,7 +357,20 @@ public static void ForceCurrent(this DCPowerSessionsBundle sessionsBundle, SiteD
LevelRange = currentLevelRange,
LimitRange = voltageLimitRange
};
sessionInfo.Force(settings, sitePinInfo, waitForSourceCompletion);
var channelOutput = sessionInfo.Session.Outputs[sitePinInfo.IndividualChannelString];
sessionInfo.ConfigureChannels(settings, channelOutput, sitePinInfo);
if ((sitePinInfo.CascadingInfo as GangingInfo)?.IsFollower == true)
{
channelOutput.InitiateChannels();
}
});
sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
var channelOutput = sessionInfo.Session.Outputs[sitePinInfo.IndividualChannelString];
if (!(sitePinInfo.CascadingInfo is GangingInfo ganging) || !ganging.IsFollower)
{
channelOutput.InitiateChannels(waitForSourceCompletion);
}
});
}

Expand All @@ -374,7 +397,20 @@ public static void ForceCurrent(this DCPowerSessionsBundle sessionsBundle, PinSi
LevelRange = currentLevelRange,
LimitRange = voltageLimitRange
};
sessionInfo.Force(settings, sitePinInfo, waitForSourceCompletion);
var channelOutput = sessionInfo.Session.Outputs[sitePinInfo.IndividualChannelString];
sessionInfo.ConfigureChannels(settings, channelOutput, sitePinInfo);
if ((sitePinInfo.CascadingInfo as GangingInfo)?.IsFollower == true)
{
channelOutput.InitiateChannels();
}
});
sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
var channelOutput = sessionInfo.Session.Outputs[sitePinInfo.IndividualChannelString];
if (!(sitePinInfo.CascadingInfo is GangingInfo ganging) || !ganging.IsFollower)
{
channelOutput.InitiateChannels(waitForSourceCompletion);
}
});
}

Expand All @@ -387,11 +423,34 @@ public static void ForceCurrent(this DCPowerSessionsBundle sessionsBundle, PinSi
/// Otherwise, the source delay amount is not directly accounted for by this method and the WaitForEvent must be manually invoked in proceeding code.</param>
public static void ForceCurrent(this DCPowerSessionsBundle sessionsBundle, DCPowerSourceSettings settings, bool waitForSourceCompletion = false)
{
sessionsBundle.Do(sessionInfo =>
settings.OutputFunction = DCPowerSourceOutputFunction.DCCurrent;
if (sessionsBundle.GangedPinGroupsCount == 0)
{
settings.OutputFunction = DCPowerSourceOutputFunction.DCCurrent;
sessionInfo.Force(settings, sitePinInfo: null, waitForSourceCompletion);
});
sessionsBundle.Do(sessionInfo =>
{
sessionInfo.Force(settings, sitePinInfo: null, waitForSourceCompletion);
});
}
else
{
sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
var channelOutput = sessionInfo.Session.Outputs[sitePinInfo.IndividualChannelString];
sessionInfo.ConfigureChannels(settings, channelOutput, sitePinInfo);
if ((sitePinInfo.CascadingInfo as GangingInfo)?.IsFollower == true)
{
channelOutput.InitiateChannels();
}
});
sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
if (!(sitePinInfo.CascadingInfo is GangingInfo ganging) || !ganging.IsFollower)
{
var channelOutput = sessionInfo.Session.Outputs[sitePinInfo.IndividualChannelString];
channelOutput.InitiateChannels(waitForSourceCompletion);
}
});
}
}

/// <summary>
Expand Down Expand Up @@ -892,7 +951,25 @@ public static void ConfigureTransientResponse(this NIDCPower session, string cha
/// <param name="channelString">The channel string. Empty string means all channels in the session.</param>
public static void ConfigureSourceSettings(this DCPowerSessionInformation sessionInfo, DCPowerSourceSettings settings, string channelString = "")
{
var channelOutput = string.IsNullOrEmpty(channelString) ? sessionInfo.AllChannelsOutput : sessionInfo.Session.Outputs[channelString];
sessionInfo.ConfigureSourceSettings(settings, string.IsNullOrEmpty(channelString) ? sessionInfo.AllChannelsOutput : sessionInfo.Session.Outputs[channelString], sitePinInformation: null);
}

/// <summary>
/// Configures <see cref="DCPowerSourceSettings"/>.
/// </summary>
/// <param name="sessionInfo">The <see cref="DCPowerSessionInformation"/> object.</param>
/// <param name="settings">The source settings to configure.</param>
/// <param name="channelOutput">The <see cref="DCPowerOutput"/> object</param>
/// <param name="sitePinInformation">The <see cref="SitePinInfo"/> object</param>
public static void ConfigureSourceSettings(this DCPowerSessionInformation sessionInfo, DCPowerSourceSettings settings, DCPowerOutput channelOutput, SitePinInfo sitePinInformation)
{
string channelString = channelOutput.Name;
var sitePinInfoList = sitePinInformation != null ? new List<SitePinInfo>() { sitePinInformation } : sessionInfo.AssociatedSitePinList.Where(sitePin => channelString.Contains(sitePin.IndividualChannelString));

if (sitePinInformation != null && channelOutput.Name.Split(',').Length > 1)
{
// throw new NISemiconductorTestException(string.Format(CultureInfo.InvariantCulture, ResourceStrings.DCPower_MultipleChannelOutputsDetected, channelOutput));
}
channelOutput.Source.Mode = DCPowerSourceMode.SinglePoint;
if (settings.LimitSymmetry.HasValue)
{
Expand All @@ -908,26 +985,29 @@ public static void ConfigureSourceSettings(this DCPowerSessionInformation sessio
}
if (settings.TransientResponse.HasValue)
{
string channelStringToUse = string.IsNullOrEmpty(channelString) ? sessionInfo.AllChannelsString : channelString;
if (sessionInfo.AllInstrumentsAreTheSameModel)
{
sessionInfo.Session.ConfigureTransientResponse(channelStringToUse, sessionInfo.ModelString, settings.TransientResponse.Value);
sessionInfo.Session.ConfigureTransientResponse(channelString, sessionInfo.ModelString, settings.TransientResponse.Value);
}
else
{
foreach (var sitePinInfo in sessionInfo.AssociatedSitePinList.Where(sitePin => channelStringToUse.Contains(sitePin.IndividualChannelString)))
foreach (var sitePinInfo in sitePinInfoList)
{
sessionInfo.Session.ConfigureTransientResponse(sitePinInfo.IndividualChannelString, sitePinInfo.ModelString, settings.TransientResponse.Value);
}
}
}
if (settings.OutputFunction.Equals(DCPowerSourceOutputFunction.DCVoltage))
{
ConfigureVoltageSettings(channelOutput, settings);
}
else
foreach (var sitePinInfo in sitePinInfoList)
{
ConfigureCurrentSettings(channelOutput, settings);
if (settings.OutputFunction.Equals(DCPowerSourceOutputFunction.DCVoltage))
{
ConfigureVoltageSettings(channelOutput, settings, sitePinInfo);
}
else
{
ConfigureCurrentSettings(channelOutput, settings, sitePinInfo);
}
ConfigureTriggerForGanging(sitePinInfo, channelOutput);
}
}

Expand All @@ -939,19 +1019,19 @@ private static void Force(this DCPowerSessionInformation sessionInfo, DCPowerSou
{
var channelString = sitePinInfo?.IndividualChannelString ?? sessionInfo.AllChannelsString;
var channelOutput = sessionInfo.Session.Outputs[channelString];
sessionInfo.ConfigureChannels(settings, channelOutput, channelString, sitePinInfo);
sessionInfo.InitiateChannels(channelOutput, waitForSourceCompletion);
sessionInfo.ConfigureChannels(settings, channelOutput, sitePinInfo);
channelOutput.InitiateChannels(waitForSourceCompletion);
}

private static void ConfigureChannels(this DCPowerSessionInformation sessionInfo, DCPowerSourceSettings settings, DCPowerOutput channelOutput, string channelString = "", SitePinInfo sitePinInfo = null)
private static void ConfigureChannels(this DCPowerSessionInformation sessionInfo, DCPowerSourceSettings settings, DCPowerOutput channelOutput, SitePinInfo sitePinInfo = null)
{
channelOutput.Control.Abort();
sessionInfo.ConfigureSourceSettings(settings, channelString);
sessionInfo.ConfigureSourceSettings(settings, channelOutput, sitePinInfo);
channelOutput.Source.Output.Enabled = true;
channelOutput.Control.Commit();
}

private static void InitiateChannels(this DCPowerSessionInformation sessionInfo, DCPowerOutput channelOutput, bool waitForSourceCompletion = false)
private static void InitiateChannels(this DCPowerOutput channelOutput, bool waitForSourceCompletion = false)
{
channelOutput.Control.Initiate();
if (waitForSourceCompletion)
Expand Down Expand Up @@ -988,25 +1068,27 @@ internal static bool IsFirstChannelOfSession(this SitePinInfo sitePinInfo, DCPow
return sessionInfo.AllChannelsString.StartsWith(sitePinInfo.IndividualChannelString, StringComparison.InvariantCulture);
}

private static void ConfigureVoltageSettings(DCPowerOutput dcOutput, DCPowerSourceSettings settings)
private static void ConfigureVoltageSettings(DCPowerOutput dcOutput, DCPowerSourceSettings settings, SitePinInfo sitePinInfo = null)
{
var currentLimitDivisor = (sitePinInfo?.CascadingInfo as GangingInfo)?.ChannelsCount ?? 1;

if (settings.Level.HasValue)
{
dcOutput.Source.Voltage.VoltageLevel = settings.Level.Value;
}
if (settings.LimitSymmetry == DCPowerComplianceLimitSymmetry.Symmetric && settings.Limit.HasValue)
{
dcOutput.Source.Voltage.CurrentLimit = settings.Limit.Value;
dcOutput.Source.Voltage.CurrentLimit = settings.Limit.Value / currentLimitDivisor;
}
else
{
if (settings.LimitHigh.HasValue)
{
dcOutput.Source.Voltage.CurrentLimitHigh = settings.LimitHigh.Value;
dcOutput.Source.Voltage.CurrentLimitHigh = settings.LimitHigh.Value / currentLimitDivisor;
}
if (settings.LimitLow.HasValue)
{
dcOutput.Source.Voltage.CurrentLimitLow = settings.LimitLow.Value;
dcOutput.Source.Voltage.CurrentLimitLow = settings.LimitLow.Value / currentLimitDivisor;
}
}
if (settings.LevelRange.HasValue || settings.Level.HasValue)
Expand All @@ -1017,15 +1099,21 @@ private static void ConfigureVoltageSettings(DCPowerOutput dcOutput, DCPowerSour
|| (settings.LimitSymmetry == DCPowerComplianceLimitSymmetry.Symmetric && settings.Limit.HasValue)
|| (settings.LimitSymmetry == DCPowerComplianceLimitSymmetry.Asymmetric && (settings.LimitHigh.HasValue || settings.LimitLow.HasValue)))
{
dcOutput.Source.Voltage.CurrentLimitRange = settings.LimitRange ?? CalculateLimitRangeFromLimit(settings);
dcOutput.Source.Voltage.CurrentLimitRange = settings.LimitRange ?? CalculateLimitRangeFromLimit(settings) / currentLimitDivisor;
}
}

private static void ConfigureCurrentSettings(DCPowerOutput dcOutput, DCPowerSourceSettings settings)
private static void ConfigureCurrentSettings(DCPowerOutput dcOutput, DCPowerSourceSettings settings, SitePinInfo sitePinInfo = null)
{
var currentLevel = settings.Level.Value;
if (sitePinInfo?.CascadingInfo is GangingInfo gangingInfo)
{
currentLevel /= gangingInfo.ChannelsCount;
}

if (settings.Level.HasValue)
{
dcOutput.Source.Current.CurrentLevel = settings.Level.Value;
dcOutput.Source.Current.CurrentLevel = currentLevel;
}
if (settings.LimitSymmetry == DCPowerComplianceLimitSymmetry.Symmetric && settings.Limit.HasValue)
{
Expand All @@ -1044,7 +1132,7 @@ private static void ConfigureCurrentSettings(DCPowerOutput dcOutput, DCPowerSour
}
if (settings.LevelRange.HasValue || settings.Level.HasValue)
{
dcOutput.Source.Current.CurrentLevelRange = settings.LevelRange ?? Math.Abs(settings.Level.Value);
dcOutput.Source.Current.CurrentLevelRange = settings.LevelRange ?? Math.Abs(currentLevel);
}
if (settings.LimitRange.HasValue
|| (settings.LimitSymmetry == DCPowerComplianceLimitSymmetry.Symmetric && settings.Limit.HasValue)
Expand All @@ -1061,6 +1149,15 @@ private static double CalculateLimitRangeFromLimit(DCPowerSourceSettings setting
: Math.Max(Math.Abs(settings.LimitHigh.Value), Math.Abs(settings.LimitLow.Value));
}

private static void ConfigureTriggerForGanging(SitePinInfo sitePinInfo, DCPowerOutput channelOutput)
{
if (sitePinInfo?.CascadingInfo is GangingInfo gangingInfo && gangingInfo.IsFollower)
{
channelOutput.Triggers.SourceTrigger.Type = DCPowerSourceTriggerType.DigitalEdge;
channelOutput.Triggers.SourceTrigger.DigitalEdge.Configure(gangingInfo.TriggerName, DCPowerTriggerEdge.Rising);
}
}

#endregion private and internal methods
}
}
Loading
Loading