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.
Getting Started with Resource Picker in Blazor
Smart.Blazor.Industrial targets .NET 6 and later, for Blazor Server and Blazor WebAssembly.
The Resource Picker component is part of the Smart.Blazor.Industrial NuGet package, which contains all 54 Industrial components as Razor components. The package includes the Smart.Industrial runtime in its wwwroot and does not depend on Smart.Blazor.
Quick start
- Install the package:
dotnet add package Smart.Blazor.Industrial
- Add the styles and the runtime to the application page (
App.razor,_Host.cshtmlorindex.html):
<link rel="stylesheet" href="_content/Smart.Blazor.Industrial/css/smart.default.css" /> <link rel="stylesheet" href="_content/Smart.Blazor.Industrial/css/smart.industrial-elements.css" /> <link rel="stylesheet" href="_content/Smart.Blazor.Industrial/css/smart.industrial.css" /> <script src="_content/Smart.Blazor.Industrial/js/smart.blazor.js"></script> <script src="_content/Smart.Blazor.Industrial/js/smart.industrial.js"></script>
- Register the services in
Program.csand add the namespace to_Imports.razor:
using Smart.Blazor.Industrial; builder.Services.AddSmartIndustrial();
@using Smart.Blazor.Industrial
- Use the component in a page. In a Blazor Web App (.NET 8 and later) the page needs an interactive render mode:
@rendermode InteractiveServeras below,InteractiveWebAssemblyorInteractiveAuto, or one render mode for the whole app on<Routes @rendermode="InteractiveServer" />inApp.razor. Without it the component renders as an empty box and its parameters and events do not arrive. On .NET 6 and 7 leave the@rendermodeline out. The parameters are the component's properties in PascalCase; the events areEventCallbacks namedOn<EventName>. This is the first element of the demo:
@page "/" @* .NET 8 and later: an interactive render mode, on the page or for the whole app *@ @rendermode InteractiveServer <ResourcePicker Label="Instrument" Value="GPIB0::16::INSTR" AllowCustom="true" OnRefreshRequest="OnRefreshRequest" /> @code { void OnRefreshRequest(Event ev) { // The event carries no detail. // Write the request to the plant here, then set the parameter from the value the plant reports. } } - The component raises
OnRefreshRequestas a request and does not change its own value: the handler writes to the plant, and the parameter is set from the value the plant reports. - Set the license key once, in
Program.cs:Smart.Blazor.Industrial.License.Key = "YOUR-KEY";
Parameters
The most used parameters of <ResourcePicker>; the API page lists them all.
| Parameter | Type |
|---|---|
Resources | IEnumerable<object> |
Value | string |
Kinds | IEnumerable<object> |
AllowCustom | bool |
AvailableOnly | bool |
Refreshable | bool |
Busy | bool |
Label | string |
Placeholder | string |
Readonly | bool |
OnReady | Action<ResourcePicker> |
ChildContent | RenderFragment |
Events
OnChange, OnRefreshRequest, OnOpen, OnClose
The frameworks guide describes the parameter types, the naming rules and the request/confirm round trip in C#.