Skip to content

Commit 0e103b6

Browse files
Update the niscope example to have pin arrays (#146)
* use pin array in niscope examples * remove todo comment
1 parent fc36445 commit 0e103b6

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

examples/niscope_acquire_waveform/NIScopeAcquireWaveform.measui

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<SourceFile Checksum="A19DB348CDDCAC7B9CA6BE5D640DAF5189870C1FB6F1610D8B69C8812DAA45CC24A0C0D3C392A2EF0BA48FC8B1151B29308AF497E535910116C8288570E9FC65" Timestamp="1D908E207EF0128" xmlns="http://www.ni.com/PlatformFramework">
2+
<SourceFile Checksum="9F19483937B5911601BA232FD2FD1F09EB2AD566C29343FF39339996C8723EE04BF6C59EA55E830E226610ECA534CDE94461AE2DA9DA8118FE59953D59FA607F" Timestamp="1D91459EDAF150E" xmlns="http://www.ni.com/PlatformFramework">
33
<SourceModelFeatureSet>
4-
<ParsableNamespace AssemblyFileVersion="9.7.0.2225" FeatureSetName="Configuration Based Software Core" Name="http://www.ni.com/ConfigurationBasedSoftware.Core" OldestCompatibleVersion="6.3.0.49152" Version="6.3.0.49152" />
5-
<ParsableNamespace AssemblyFileVersion="9.7.0.2225" FeatureSetName="LabVIEW Controls" Name="http://www.ni.com/Controls.LabVIEW.Design" OldestCompatibleVersion="8.1.0.49152" Version="8.1.0.49152" />
6-
<ParsableNamespace AssemblyFileVersion="23.0.0.2225" FeatureSetName="InstrumentStudio Measurement UI" Name="http://www.ni.com/InstrumentFramework/ScreenDocument" OldestCompatibleVersion="22.1.0.1" Version="22.1.0.1" />
7-
<ParsableNamespace AssemblyFileVersion="9.7.0.2225" FeatureSetName="Editor" Name="http://www.ni.com/PanelCommon" OldestCompatibleVersion="6.1.0.0" Version="6.1.0.49152" />
8-
<ParsableNamespace AssemblyFileVersion="9.7.0.2225" FeatureSetName="Editor" Name="http://www.ni.com/PlatformFramework" OldestCompatibleVersion="8.1.0.49152" Version="8.1.0.49152" />
9-
<ApplicationVersionInfo Build="23.0.0.2225" Name="MeasurementLink UI Editor" Version="23.0.0.2225" />
4+
<ParsableNamespace AssemblyFileVersion="9.7.0.2637" FeatureSetName="Configuration Based Software Core" Name="http://www.ni.com/ConfigurationBasedSoftware.Core" OldestCompatibleVersion="6.3.0.49152" Version="6.3.0.49152" />
5+
<ParsableNamespace AssemblyFileVersion="9.7.0.2637" FeatureSetName="LabVIEW Controls" Name="http://www.ni.com/Controls.LabVIEW.Design" OldestCompatibleVersion="8.1.0.49152" Version="8.1.0.49152" />
6+
<ParsableNamespace AssemblyFileVersion="23.0.0.2637" FeatureSetName="InstrumentStudio Measurement UI" Name="http://www.ni.com/InstrumentFramework/ScreenDocument" OldestCompatibleVersion="22.1.0.1" Version="22.1.0.1" />
7+
<ParsableNamespace AssemblyFileVersion="9.7.0.2637" FeatureSetName="Editor" Name="http://www.ni.com/PanelCommon" OldestCompatibleVersion="6.1.0.0" Version="6.1.0.49152" />
8+
<ParsableNamespace AssemblyFileVersion="9.7.0.2637" FeatureSetName="Editor" Name="http://www.ni.com/PlatformFramework" OldestCompatibleVersion="8.1.0.49152" Version="8.1.0.49152" />
9+
<ApplicationVersionInfo Build="23.0.0.2637" Name="MeasurementLink UI Editor" Version="23.0.0.2637" />
1010
</SourceModelFeatureSet>
1111
<Screen ClientId="{058ec218-444b-4e09-9a76-99dd0791f991}" ConfigurationParameters="{&quot;@type&quot;:&quot;type.googleapis.com/ni.measurementlink.measurement.v1.MeasurementConfigurations&quot;,&quot;pinNames&quot;:&quot;Pin1,Pin2&quot;,&quot;verticalRange&quot;:5.0,&quot;verticalCoupling&quot;:&quot;DC&quot;,&quot;inputImpedance&quot;:1000000.0,&quot;minSampleRate&quot;:10000000.0,&quot;minRecordLength&quot;:40000,&quot;triggerSource&quot;:&quot;Pin1&quot;,&quot;triggerLevel&quot;:0.5,&quot;triggerSlope&quot;:&quot;Positive&quot;,&quot;autoTrigger&quot;:false,&quot;triggerCoupling&quot;:&quot;DC&quot;,&quot;timeout&quot;:5.0}" DisplayName="NI-SCOPE Acquire Waveform (Py)" Id="7ecb9046d80c4b899a7ab0120284de3c" ServiceClass="ni.examples.NIScopeAcquireWaveform_Python" xmlns="http://www.ni.com/InstrumentFramework/ScreenDocument">
1212
<ScreenSurface BackgroundColor="[SMSolidColorBrush]#ffffffff" Height="[float]530" Id="34c8bbb4a92c4d419c8d8e74e2c9c68b" Left="[float]0" PanelSizeMode="Fixed" Top="[float]0" Width="[float]910" xmlns="http://www.ni.com/ConfigurationBasedSoftware.Core">
@@ -35,8 +35,8 @@
3535
<Label Height="[float]0" Id="b675e3e875884df1a7b766c6b1f99264" LabelOwner="[UIModel]2fbc891cc72242fbb131d9666757a75b" Left="[float]12" Text="[string]Auto trigger" Top="[float]109" Visible="[bool]False" Width="[float]0" xmlns="http://www.ni.com/PanelCommon" />
3636
<ChannelStringControl AcceptsReturn="[bool]False" BaseName="[string]String" Channel="[string]{058ec218-444b-4e09-9a76-99dd0791f991}/Configuration/trigger_coupling" Enabled="[bool]True" Height="[float]24" HorizontalScrollBarVisibility="[ScrollBarVisibility]Hidden" Id="33095df9112541bb95fb4f9a3b9c34b5" IsLabelBoundToChannel="[bool]False" Label="[UIModel]4d0ab39332564d478749a852891f6194" Left="[float]135" Text="[string]DC" Top="[float]86" VerticalScrollBarVisibility="[ScrollBarVisibility]Auto" Width="[float]72" />
3737
<Label Height="[float]16" Id="4d0ab39332564d478749a852891f6194" LabelOwner="[UIModel]33095df9112541bb95fb4f9a3b9c34b5" Left="[float]135" Text="[string]Trigger Coupling" Top="[float]66" Width="[float]88" xmlns="http://www.ni.com/PanelCommon" />
38-
<ChannelPinSelector AllowUndefinedValues="[bool]True" BaseName="[string]Pin" Channel="[string]{058ec218-444b-4e09-9a76-99dd0791f991}/Configuration/trigger_source" DataType="[Type]String" Enabled="[bool]True" Height="[float]24" Id="80ba77279b36457d9ac495179c38a309" Label="[UIModel]9d8dba7edc23437eab89be566857fb49" Left="[float]12" Top="[float]33" Width="[float]100" xmlns="http://www.ni.com/InstrumentFramework/ScreenDocument" />
39-
<Label Height="[float]16" Id="9d8dba7edc23437eab89be566857fb49" LabelOwner="[UIModel]80ba77279b36457d9ac495179c38a309" Left="[float]12" Text="[string]trigger_source" Top="[float]13" Width="[float]76" xmlns="http://www.ni.com/PanelCommon" />
38+
<ChannelPinSelector AllowUndefinedValues="[bool]True" BaseName="[string]Pin" Channel="[string]{058ec218-444b-4e09-9a76-99dd0791f991}/Configuration/trigger_source" DataType="[Type]String" Enabled="[bool]True" Height="[float]24" Id="80ba77279b36457d9ac495179c38a309" IsLabelBoundToChannel="[bool]False" Label="[UIModel]9d8dba7edc23437eab89be566857fb49" Left="[float]12" Top="[float]33" Width="[float]100" xmlns="http://www.ni.com/InstrumentFramework/ScreenDocument" />
39+
<Label Height="[float]16" Id="9d8dba7edc23437eab89be566857fb49" LabelOwner="[UIModel]80ba77279b36457d9ac495179c38a309" Left="[float]12" Text="[string]Source" Top="[float]13" Width="[float]37" xmlns="http://www.ni.com/PanelCommon" />
4040
</ScreenSurfaceCanvas>
4141
<Label Height="[float]16" Id="d3204b2cf2ff4d9f804e0d35af7d8247" LabelOwner="[UIModel]1bbbff8ff8624d6580b40159945404d9" Left="[float]22" Text="[string]Trigger" Top="[float]331" Width="[float]37" xmlns="http://www.ni.com/PanelCommon" />
4242
<ChannelNumericText AdaptsToType="[bool]True" BaseName="[string]Numeric" Channel="[string]{058ec218-444b-4e09-9a76-99dd0791f991}/Configuration/timeout" Enabled="[bool]True" Height="[float]24" Id="e7b1f32ae0314730aa611edc3386bb7d" IsLabelBoundToChannel="[bool]False" Label="[UIModel]1e346b6974e9451aa4ee0c455e72832e" Left="[float]288" Top="[float]371" UnitAnnotation="[string]" ValueFormatter="[string]LV:G5" ValueType="[Type]Double" Width="[float]70" />
@@ -88,7 +88,7 @@
8888
</ArrayGraphTools>
8989
<Label Height="[float]16" Id="70c9d2a112534b1ab3299bade5d80dbd" LabelOwner="[UIModel]9aaf1f2747e7459193238f220d4b8b33" Left="[float]288" Text="[string]Waveforms" Top="[float]21" Width="[float]59" xmlns="http://www.ni.com/PanelCommon" />
9090
<ChannelPinSelector AllowUndefinedValues="[bool]True" BaseName="[string]Pin" Channel="[string]{058ec218-444b-4e09-9a76-99dd0791f991}/Configuration/pin_names" DataType="[Type]String" Enabled="[bool]True" Height="[float]24" Id="121806bc7ce94bf2810e969e17827ac1" IsLabelBoundToChannel="[bool]False" Label="[UIModel]bb9069c6a58347209a1111168c6be0c7" Left="[float]22" SelectedResource="[NI_Core_DataValues_TagRefnum]Pin1" Top="[float]33" Width="[float]244" xmlns="http://www.ni.com/InstrumentFramework/ScreenDocument" />
91-
<Label Height="[float]16" Id="bb9069c6a58347209a1111168c6be0c7" LabelOwner="[UIModel]121806bc7ce94bf2810e969e17827ac1" Left="[float]22" Text="[string]Pin names" Top="[float]13" Width="[float]55" xmlns="http://www.ni.com/PanelCommon" />
91+
<Label Height="[float]16" Id="bb9069c6a58347209a1111168c6be0c7" LabelOwner="[UIModel]121806bc7ce94bf2810e969e17827ac1" Left="[float]22" Text="[string]Pin names" Top="[float]13" Width="[float]54" xmlns="http://www.ni.com/PanelCommon" />
9292
</ScreenSurface>
9393
</Screen>
9494
</SourceFile>

examples/niscope_acquire_waveform/measurement.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@
4949

5050

5151
@measurement_service.register_measurement
52-
# TODO: Make pin_names PinArray1D
5352
@measurement_service.configuration(
5453
"pin_names",
55-
nims.DataType.Pin,
56-
"Pin1,Pin2,Pin3,Pin4",
54+
nims.DataType.PinArray1D,
55+
["Pin1", "Pin2", "Pin3", "Pin4"],
5756
instrument_type=nims.session_management.INSTRUMENT_TYPE_NI_SCOPE,
5857
)
5958
@measurement_service.configuration("vertical_range", nims.DataType.Double, 5.0)
@@ -116,11 +115,10 @@ def cancel_callback():
116115
)
117116

118117
with contextlib.ExitStack() as stack:
119-
pin_list = [p.strip() for p in pin_names.split(",")]
120118
reservation = stack.enter_context(
121119
session_management_client.reserve_sessions(
122120
context=measurement_service.context.pin_map_context,
123-
pin_or_relay_names=pin_list,
121+
pin_or_relay_names=pin_names,
124122
instrument_type_id=nims.session_management.INSTRUMENT_TYPE_NI_SCOPE,
125123
timeout=-1,
126124
)
@@ -135,7 +133,7 @@ def cancel_callback():
135133
session_info = reservation.session_info[0]
136134
channel_names = session_info.channel_list
137135
channel_list = [c.strip() for c in channel_names.split(",")]
138-
pin_to_channel = dict(zip(pin_list, channel_list))
136+
pin_to_channel = dict(zip(pin_names, channel_list))
139137
if trigger_source in pin_to_channel:
140138
trigger_source = pin_to_channel[trigger_source]
141139

0 commit comments

Comments
 (0)