本文整理汇总了C#中IScope.SetCoupling方法的典型用法代码示例。如果您正苦于以下问题:C# IScope.SetCoupling方法的具体用法?C# IScope.SetCoupling怎么用?C# IScope.SetCoupling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScope
的用法示例。
在下文中一共展示了IScope.SetCoupling方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MeasureAutoArrangeSettings
public static Dictionary<AnalogChannel, AnalogWaveProperties> MeasureAutoArrangeSettings(IScope scope, AnalogChannel aciveChannel, Action<float> progressReport)
{
float progress = 0f;
progressReport(progress);
//stop scope streaming
scope.DataSourceScope.Stop();
//Prepare scope for test
if (scope is SmartScope)
(scope as SmartScope).SetDisableVoltageConversion(false);
//set to timerange wide enough to capture 50Hz, but slightly off so smallest chance of aliasing
const float initialTimeRange = 0.0277f;
scope.AcquisitionMode = AcquisitionMode.AUTO;
scope.AcquisitionLength = initialTimeRange;
scope.SetViewPort(0, scope.AcquisitionLength);
//s.AcquisitionDepth = 4096;
scope.TriggerHoldOff = 0;
scope.SendOverviewBuffer = false;
AnalogTriggerValue atv = new AnalogTriggerValue();
atv.channel = AnalogChannel.ChA;
atv.direction = TriggerDirection.RISING;
atv.level = 5000;
scope.TriggerAnalog = atv;
foreach (AnalogChannel ch in AnalogChannel.List)
scope.SetCoupling(ch, Coupling.DC);
scope.CommitSettings();
progress += .1f;
progressReport(progress);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// VERTICAL == VOLTAGE
//set to largest input range
float maxRange = 1.2f / 1f * 36f;
foreach (AnalogChannel ch in AnalogChannel.List)
scope.SetVerticalRange(ch, -maxRange / 2f, maxRange / 2f);
float[] minValues = new float[] { float.MaxValue, float.MaxValue };
float[] maxValues = new float[] { float.MinValue, float.MinValue };
//measure min and max voltage over 3 full ranges
for (int i = -1; i < 2; i++)
{
progress += .1f;
progressReport(progress);
foreach (AnalogChannel ch in AnalogChannel.List)
scope.SetYOffset(ch, (float)i * maxRange);
scope.CommitSettings();
System.Threading.Thread.Sleep(100);
scope.ForceTrigger();
//fetch data
DataPackageScope p = FetchLastFrame(scope);
p = FetchLastFrame(scope); //needs this second fetch as well to get voltage conversion on ChanB right?!?
if (p == null)
{
Logger.Error("Didn't receive data from scope, aborting");
return null;
}
//check if min or max need to be updated (only in case this measurement was not saturated)
float[] dataA = (float[])p.GetData(DataSourceType.Viewport, AnalogChannel.ChA).array;
float[] dataB = (float[])p.GetData(DataSourceType.Viewport, AnalogChannel.ChB).array;
float minA = dataA.Min();
float maxA = dataA.Max();
float minB = dataB.Min();
float maxB = dataB.Max();
if (minA != p.SaturationLowValue[AnalogChannel.ChA] && minA != p.SaturationHighValue[AnalogChannel.ChA] && minValues[0] > minA) minValues[0] = minA;
if (minB != p.SaturationLowValue[AnalogChannel.ChB] && minB != p.SaturationHighValue[AnalogChannel.ChB] && minValues[1] > minB) minValues[1] = minB;
if (maxA != p.SaturationLowValue[AnalogChannel.ChA] && maxA != p.SaturationHighValue[AnalogChannel.ChA] && maxValues[0] < maxA) maxValues[0] = maxA;
if (maxB != p.SaturationLowValue[AnalogChannel.ChB] && maxB != p.SaturationHighValue[AnalogChannel.ChB] && maxValues[1] < maxB) maxValues[1] = maxB;
}
//calc ideal voltage range and offset
float sizer = 3; //meaning 3 waves would fill entire view
float[] coarseAmplitudes = new float[2];
coarseAmplitudes[0] = maxValues[0] - minValues[0];
coarseAmplitudes[1] = maxValues[1] - minValues[1];
float[] desiredOffsets = new float[2];
desiredOffsets[0] = (maxValues[0] + minValues[0]) / 2f;
desiredOffsets[1] = (maxValues[1] + minValues[1]) / 2f;
float[] desiredRanges = new float[2];
desiredRanges[0] = coarseAmplitudes[0] * sizer;
desiredRanges[1] = coarseAmplitudes[1] * sizer;
//intervene in case the offset is out of range for this range
if (desiredRanges[0] < Math.Abs(desiredOffsets[0]))
desiredRanges[0] = Math.Abs(desiredOffsets[0]);
if (desiredRanges[1] < Math.Abs(desiredOffsets[1]))
desiredRanges[1] = Math.Abs(desiredOffsets[1]);
//set fine voltage range and offset
scope.SetVerticalRange(AnalogChannel.ChA, -desiredRanges[0] / 2f, desiredRanges[0] / 2f);
//.........这里部分代码省略.........