Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 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 @@ -511,10 +511,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 @@ -540,8 +537,9 @@ public static void ForceCurrent(this DCPowerSessionsBundle sessionsBundle, IDict
LevelRange = currentLevelRange,
LimitRange = voltageLimitRange
};
sessionInfo.Force(settings, sitePinInfo, waitForSourceCompletion);
sessionInfo.ConfigureAllChannelsAndInitiateGangedFollowerChannels(settings, sitePinInfo);
});
sessionsBundle.InitiateGangedLeaderAndNonGangedChannels(waitForSourceCompletion);
}

/// <summary>
Expand All @@ -567,8 +565,9 @@ public static void ForceCurrent(this DCPowerSessionsBundle sessionsBundle, SiteD
LevelRange = currentLevelRange,
LimitRange = voltageLimitRange
};
sessionInfo.Force(settings, sitePinInfo, waitForSourceCompletion);
sessionInfo.ConfigureAllChannelsAndInitiateGangedFollowerChannels(settings, sitePinInfo);
});
sessionsBundle.InitiateGangedLeaderAndNonGangedChannels(waitForSourceCompletion);
}

/// <summary>
Expand All @@ -594,8 +593,9 @@ public static void ForceCurrent(this DCPowerSessionsBundle sessionsBundle, PinSi
LevelRange = currentLevelRange,
LimitRange = voltageLimitRange
};
sessionInfo.Force(settings, sitePinInfo, waitForSourceCompletion);
sessionInfo.ConfigureAllChannelsAndInitiateGangedFollowerChannels(settings, sitePinInfo);
});
sessionsBundle.InitiateGangedLeaderAndNonGangedChannels(waitForSourceCompletion);
}

/// <summary>
Expand All @@ -607,11 +607,22 @@ 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.HasGangedChannels)
{
settings.OutputFunction = DCPowerSourceOutputFunction.DCCurrent;
sessionInfo.Force(settings, sitePinInfo: null, waitForSourceCompletion);
});
sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
sessionInfo.ConfigureAllChannelsAndInitiateGangedFollowerChannels(settings, sitePinInfo);
});
sessionsBundle.InitiateGangedLeaderAndNonGangedChannels(waitForSourceCompletion);
}
else
{
sessionsBundle.Do(sessionInfo =>
{
sessionInfo.Force(settings, sitePinInfo: null, waitForSourceCompletion);
});
}
}

/// <summary>
Expand Down Expand Up @@ -1500,6 +1511,28 @@ private static void ConfigureChannels(this DCPowerSessionInformation sessionInfo
channelOutput.Control.Commit();
}

private static void InitiateGangedLeaderAndNonGangedChannels(this DCPowerSessionsBundle sessionsBundle, bool waitForSourceCompletion = false)
{
sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
if (!IsFollowerOfGangedChannels(sitePinInfo.CascadingInfo))
{
var channelOutput = sessionInfo.Session.Outputs[sitePinInfo.IndividualChannelString];
channelOutput.InitiateChannels(waitForSourceCompletion);
}
});
}

private static void ConfigureAllChannelsAndInitiateGangedFollowerChannels(this DCPowerSessionInformation sessionInfo, DCPowerSourceSettings settings, SitePinInfo sitePinInfo)
{
var channelOutput = sessionInfo.Session.Outputs[sitePinInfo.IndividualChannelString];
sessionInfo.ConfigureChannels(settings, channelOutput, sitePinInfo);
if (IsFollowerOfGangedChannels(sitePinInfo.CascadingInfo))
{
channelOutput.InitiateChannels();
}
}

private static void InitiateChannels(this DCPowerOutput channelOutput, bool waitForSourceCompletion = false, double timeoutInSeconds = 5)
{
channelOutput.Control.Initiate();
Expand Down Expand Up @@ -1568,7 +1601,7 @@ 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)) / currentLimitDivisor;
dcOutput.Source.Voltage.CurrentLimitRange = settings.LimitRange ?? CalculateLimitRangeFromLimit(settings) / currentLimitDivisor;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,133 @@ public void DifferentSMUDevices_ForceCurrentWithAsymmetricLimitAndRangesSucceeds
sessionsBundle.ForceCurrentAsymmetricLimit(currentLevel: 0.1, voltageLimitHigh: 3, voltageLimitLow: -1, currentLevelRange: 0.5, voltageLimitRange: 5);
}

[Fact]
public void DifferentSMUDevicesGanged_ForceCurrentWithSymmetricLimit_DividedCurrentForced()
{
var sessionManager = Initialize("SMUGangPinGroup_SessionPerChannel.pinmap");
var sessionsBundle = sessionManager.DCPower(AllPinsGangedGroup);
sessionsBundle.GangPinGroup(ThreePinsGangedGroup);

sessionsBundle.ForceCurrent(currentLevel: 1.5, voltageLimit: 2);

sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
Assert.Equal(DCPowerComplianceLimitSymmetry.Symmetric, sessionInfo.AllChannelsOutput.Source.ComplianceLimitSymmetry);
if (sitePinInfo.CascadingInfo is GangingInfo)
{
AssertCurrentSettings(sessionInfo.AllChannelsOutput, expectedCurrentLevel: 0.5, expectedVoltageLimit: 2);
}
else
{
AssertCurrentSettings(sessionInfo.AllChannelsOutput, expectedCurrentLevel: 1.5, expectedVoltageLimit: 2);
}
AssertTriggerSettings(sitePinInfo, sessionInfo.AllChannelsOutput, sitePinInfo.SiteNumber == 0 ? "SMU_4137_C5_S02" : "SMU_4137_C5_S03");
});
}

[Fact]
public void DifferentSMUDevicesGanged_ForcePerPinCurrentsWithSymmetricLimit_CorrectCurrentsForced()
{
var sessionManager = Initialize("SMUGangPinGroup_SessionPerChannel.pinmap");
var sessionsBundle = sessionManager.DCPower(AllPinsGangedGroup);
sessionsBundle.GangPinGroup(ThreePinsGangedGroup);

sessionsBundle.ForceCurrent(currentLevels: new Dictionary<string, double>() { ["VCC1"] = 3, ["VCC2"] = 3, ["VCC3"] = 3, ["VCC4"] = 1, ["VCC5"] = 1 }, voltageLimit: 5);

sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
Assert.Equal(DCPowerComplianceLimitSymmetry.Symmetric, sessionInfo.AllChannelsOutput.Source.ComplianceLimitSymmetry);
if (sitePinInfo.CascadingInfo is GangingInfo)
{
AssertCurrentSettings(sessionInfo.AllChannelsOutput, expectedCurrentLevel: 1, expectedVoltageLimit: 5);
}
else
{
AssertCurrentSettings(sessionInfo.AllChannelsOutput, expectedCurrentLevel: 1, expectedVoltageLimit: 5);
}
AssertTriggerSettings(sitePinInfo, sessionInfo.AllChannelsOutput, sitePinInfo.SiteNumber == 0 ? "SMU_4137_C5_S02" : "SMU_4137_C5_S03");
});
}

[Fact]
public void DifferentSMUDevicesGanged_ForcePerSiteCurrentsWithSymmetricLimit_CorrectCurrentsForced()
{
var sessionManager = Initialize("SMUGangPinGroup_SessionPerChannel.pinmap");
var sessionsBundle = sessionManager.DCPower(AllPinsGangedGroup);
sessionsBundle.GangPinGroup(AllPinsGangedGroup);

var currentLevels = new SiteData<double>(new double[] { 1, 3 });
sessionsBundle.ForceCurrent(currentLevels, voltageLimit: 3);

sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
if (sitePinInfo.SiteNumber == 0)
{
AssertCurrentSettings(sessionInfo.AllChannelsOutput, expectedCurrentLevel: 0.2, expectedVoltageLimit: 3);
}
else
{
AssertCurrentSettings(sessionInfo.AllChannelsOutput, expectedCurrentLevel: 0.6, expectedVoltageLimit: 3);
}
AssertTriggerSettings(sitePinInfo, sessionInfo.AllChannelsOutput, sitePinInfo.SiteNumber == 0 ? "SMU_4137_C5_S02" : "SMU_4137_C5_S03");
});
}

[Fact]
public void DifferentSMUDevicesGanged_ForcePerPinPerSiteCurrentsWithSymmetricLimit_CorrectCurrentsForced()
{
var sessionManager = Initialize("SMUGangPinGroup_SessionPerChannel.pinmap");
var sessionsBundle = sessionManager.DCPower(AllPinsGangedGroup);
sessionsBundle.GangPinGroup(AllPinsGangedGroup);

var currentLevels = new PinSiteData<double>(new Dictionary<string, IDictionary<int, double>>()
{
["VCC1"] = new Dictionary<int, double>() { [0] = 4, [1] = 2.5 },
["VCC2"] = new Dictionary<int, double>() { [0] = 4, [1] = 2.5 },
["VCC3"] = new Dictionary<int, double>() { [0] = 4, [1] = 2.5 },
["VCC4"] = new Dictionary<int, double>() { [0] = 4, [1] = 2.5 },
["VCC5"] = new Dictionary<int, double>() { [0] = 4, [1] = 2.5 }
});
sessionsBundle.ForceCurrent(currentLevels, voltageLimit: 4.5);

sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
if (sitePinInfo.SiteNumber == 0)
{
AssertCurrentSettings(sessionInfo.AllChannelsOutput, expectedCurrentLevel: 0.8, expectedVoltageLimit: 4.5);
}
else
{
AssertCurrentSettings(sessionInfo.AllChannelsOutput, expectedCurrentLevel: 0.5, expectedVoltageLimit: 4.5);
}
AssertTriggerSettings(sitePinInfo, sessionInfo.AllChannelsOutput, sitePinInfo.SiteNumber == 0 ? "SMU_4137_C5_S02" : "SMU_4137_C5_S03");
});
}

[Fact]
public void DifferentSMUDevicesGanged_ForceCurrentWithSingleSettingsObject_CorrectCurrentForced()
{
var sessionManager = Initialize("SMUGangPinGroup_SessionPerChannel.pinmap");
var sessionsBundle = sessionManager.DCPower(AllPinsGangedGroup);
sessionsBundle.GangPinGroup(FourPinsGangedGroup);

sessionsBundle.ForceCurrent(new DCPowerSourceSettings() { Level = 2, Limit = 2.6 });

sessionsBundle.Do((sessionInfo, sitePinInfo) =>
{
Assert.Equal(DCPowerSourceOutputFunction.DCCurrent, sessionInfo.AllChannelsOutput.Source.Output.Function);
if (sitePinInfo.CascadingInfo is GangingInfo)
{
AssertCurrentSettings(sessionInfo.AllChannelsOutput, 0.5, 2.6);
}
else
{
AssertCurrentSettings(sessionInfo.AllChannelsOutput, 2, 2.6);
}
AssertTriggerSettings(sitePinInfo, sessionInfo.AllChannelsOutput, sitePinInfo.SiteNumber == 0 ? "SMU_4137_C5_S02" : "SMU_4137_C5_S03");
});
}

[Theory]
[Trait(nameof(HardwareConfiguration), nameof(HardwareConfiguration.GP3))]
[Trait(nameof(HardwareConfiguration), nameof(HardwareConfiguration.Lungyuan))]
Expand Down
Loading