Test and measurement
Resource Picker <smart-resource-picker>
ResourcePicker selects an instrument or a channel: it lists the resources the application has found, grouped by interface and named by alias, filters them as text is typed, and reads a typed resource string before it is accepted.
<smart-resource-picker> · 10 properties, 5 methods, 4 events · source/modules/smart.resourcepicker.js
Usage in Blazor
The Razor component is <ResourcePicker> in Smart.Blazor.Industrial: every property is a parameter in PascalCase, every event an EventCallback<Event> named On<Event> whose ev["Detail"] is the typed detail class, and the methods are called on the @ref. String choices are enums. In a Blazor Web App (.NET 8 and later) the page needs an interactive render mode, for example @rendermode InteractiveServer; a statically rendered component stays empty.
@using Smart.Blazor.Industrial
@* .NET 8 and later: an interactive render mode, on the page or for the whole app *@
@rendermode InteractiveServer
<ResourcePicker @ref="resourcePicker" Value="GPIB0::16::INSTR"
OnRefreshRequest="OnRefreshRequest" />
@code {
ResourcePicker resourcePicker;
void OnRefreshRequest(Event ev)
{
// the event carries no detail
}
// void Open()
void Call() => resourcePicker.Open();
}
Properties
| Parameter | Type, default | Description |
|---|---|---|
Resources | IEnumerable<object> | Sets or retrieves the resources found. Each is an object with name (the resource string), alias, description, kind (gpib, tcpip, usb, serial, pxi, daq or other; worked out from the name when absent), available and an optional id. A plain string is taken as a resource name; null and anything else that is not an object is skipped, with one console warning per list. |
Value | string | Sets or retrieves the resource string in force. |
Kinds | IEnumerable<object> | Sets or retrieves the kinds listed. Empty lists every kind. |
AllowCustom | bool | Accepts a typed resource the list does not have, once it parses as a resource name. |
AvailableOnly | bool | Lists only the resources that are available. |
Refreshable | bool | Shows the refresh button, which raises refreshRequest. |
Busy | bool | Shows discovery in progress: the refresh button waits and the empty list says so. The application sets it while it searches. |
Label | string | Sets or retrieves the label above the field, which also names the combobox. |
Placeholder | string | Sets or retrieves the text shown when nothing is selected. Empty uses the localized default. |
Readonly | bool | Shows the value without allowing a change. |
Methods
| Method | Description |
|---|---|
void Open() | Opens the list. |
void Close() | Closes the list and shows the value again. |
void Select(string name) | Selects a resource by name and raises change. A name the list does not have is taken only when custom entries are allowed and it parses; otherwise the hint says so.name string The resource string or id. |
Task<object> Parse(string name) | Also available as a static method of the class. Reads a resource string into its parts by the VISA resource syntax (IVI VPP-4.3): { kind, interface, ... } with the fields of its kind - board, address (0 to 30) and secondary (0 to 30, or 96 to 126 as the bus code some tools write; reported as written) for GPIB; board, host, addressType (ipv4, ipv6 or hostname), device, port, socket and protocol (vxi-11, hislip or socket) for LAN, where the host is an IPv4 address of four octets 0 to 255, an RFC 1123 host name or an IPv6 address - in brackets as VISA writes it (TCPIP0::[fe80::1]::inst0::INSTR), or bare where that is unambiguous, and the port is 0 to 65535; vendor, product (0 to 0xFFFF), serial and interfaceNumber for USB; board and port for serial (ASRL3, ASRLCOM3, and device paths such as ASRL/dev/ttyUSB0, whose board is null); board, bus (0 to 255), device (0 to 31), function (0 to 7), chassis and slot for PXI, from any of its three forms - PXI[bus]::device[::function], PXI[interface]::[bus-]device[.function] and PXI[interface]::CHASSISn::SLOTn[::FUNCn] - where only the last names a slot and the others give slot null, since a PCI device number is not a slot; device, channelType, channel and channelEnd for DAQ. The trailing ::INSTR may be left out, as the syntax allows. Text that is not a resource, including one that breaks these ranges (GPIB0::31::INSTR, TCPIP0::999.1.1.1::INSTR, PXI0::2::11::INSTR), is { kind: "other", name, reason } with reason the rule it broke in English, or null; empty text is null.name string The resource string. |
Task<bool> IsValid(string name) | Also available as a static method of the class. True for a name the picker recognises as a resource: one that parse() reads as a kind other than "other", within the VISA ranges.name string The resource string. |
Events
Every event is an EventCallback<Event>; Event is a dictionary and ev["Detail"] converts to the detail class named under the event.
| Event | Description and detail |
|---|---|
OnChange | This event is triggered when a resource is selected from the list or typed and accepted.Value string The resource string.PreviousValue string The one before.Resource object The entry of the list, or null for a typed resource.Parsed object The parts of the name, as parse() reads them. |
OnRefreshRequest | This event is triggered when the refresh button is pressed. The application performs the discovery, sets busy while it runs and assigns the resources it found. |
OnOpen | This event is triggered when the list opens. |
OnClose | This event is triggered when the list closes. |
CSS variables
The component declares 4 CSS variables; the CSS page shows how to set them.
--smart-resource-height --smart-resource-background --smart-resource-border --smart-resource-list-background