Instrument readouts and controls

Momentary Button <smart-momentary-button>

MomentaryButton is an operator button with three action modes.

<smart-momentary-button> · 9 properties, 5 methods, 6 events · source/modules/smart.momentarybutton.js

Usage in Blazor

The Razor component is <MomentaryButton> 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

<MomentaryButton @ref="momentaryButton" Label="Start"
    OnPress="OnPress" />

@code {
    MomentaryButton momentaryButton;

    void OnPress(Event ev)
    {
        MomentaryButtonPressEventDetail detail = ev["Detail"];
    }

    // void Press()
    void Call() => momentaryButton.Press();
}

Properties

ParameterType, defaultDescription
Label
label
stringSets or retrieves the word on the button. It carries the meaning the kind colour cannot.
Mode
mode
MomentaryButtonMode
momentary
Sets or retrieves the action mode. momentary raises press and release as they happen; hold raises activate after holdDuration and reports an early release; confirm arms on the first press and raises activate on a second press within confirmTimeout. A confirm press counts when it is let go of on the button; a press that slides off, is cancelled or is ended by an interlock neither arms nor activates.
HoldDuration
holdDuration
int
1000
Sets or retrieves how long a hold-mode button must be held before it acts, in milliseconds.
ConfirmTimeout
confirmTimeout
int
5000
Sets or retrieves how long a confirm-mode button stays armed after the first press, in milliseconds. The timeout disarms it without acting.
Kind
kind
MomentaryButtonKind
normal
Sets or retrieves the button style following the colour conventions of push button panels: a green ring for a start button, a red ring for a stop button, and a round mushroom head for an emergency stop. The colour is applied to the ring, not the whole face, so the label stays readable.
State
state
stringSets or retrieves the device feedback reported by the plant, as a word such as running, stopped, open, closed or fault, shown as a lit lamp. An empty value shows no lamp. The property is set by the application from the feedback tag, not by the button. The button is announced as pressed (aria-pressed) only while the state is an on word - anything but stopped, closed, off, fault, tripped or unknown.
Interlocked
interlocked
bool
false
Determines whether the button is interlocked. An interlocked button stays readable and focusable, shows interlockReason, ends any press in progress without acting, disarms an armed button, and raises blocked instead of acting.
InterlockReason
interlockReason
stringSets or retrieves why the button will not act, shown under it while interlocked and read out when pressed.
Density
density
MomentaryButtonDensity
normal
Sets or retrieves the target size. touch makes the button 60px high for a gloved hand.

Methods

MethodDescription
void Press()Begins a press, as a pointer or the keyboard would. The method is public so that an application can drive the button from its own input, for example a physical key on a pendant. It does nothing while the button is pressed, disabled or interlocked; an interlocked button raises the blocked event. A button that is not on a page cannot be pressed.
void Release()Ends a press. A release always follows a press, so a momentary action is always stopped. A press also ends at once, as a cancelled press, when the button is removed or moved to another parent, disabled, hidden, when the focus or the pointer leaves it, or when the window loses the focus or the page is hidden. A cancelled press releases a momentary button and ends a hold early, but is not a step of a confirm. A second finger on a held button neither presses nor releases it, and a held key that repeats does not press again.
Task<bool> IsPressed()Returns whether the button is currently pressed.
Task<bool> IsArmed()Returns whether a confirm-mode button is armed and waiting for its second press.
void Disarm()Disarms a button in confirm mode without activating it.

Events

Every event is an EventCallback<Event>; Event is a dictionary and ev["Detail"] converts to the detail class named under the event.

EventDescription and detail
OnPress
press
MomentaryButtonPressEventDetail
This event is triggered when a momentary button is pressed.
At double The time of the press, in milliseconds since the epoch.
OnRelease
release
MomentaryButtonReleaseEventDetail
This event is triggered when a momentary button is released, or a hold button is let go before holdDuration.
Duration double How long it was held, in milliseconds.
Early bool true when a hold was let go too early to act.
OnActivate
activate
MomentaryButtonActivateEventDetail
This event is triggered when a hold button has been held for holdDuration, or a confirm button is pressed the second time.
Mode string 'hold' or 'confirm'.
Duration double The hold duration met, for a hold.
OnArm
arm
MomentaryButtonArmEventDetail
This event is triggered when a confirm button is pressed the first time.
Timeout double How long it stays armed, in milliseconds.
OnDisarm
disarm
no detail
This event is triggered when an armed confirm button times out or is disarmed without acting.
OnBlocked
blocked
MomentaryButtonBlockedEventDetail
This event is triggered when an interlocked button is pressed. Nothing acts.
Reason string The interlockReason.

Types

enum MomentaryButtonMode

MomentaryButtonMode.Momentary "momentary" MomentaryButtonMode.Hold "hold" MomentaryButtonMode.Confirm "confirm"

enum MomentaryButtonKind

MomentaryButtonKind.Normal "normal" MomentaryButtonKind.Start "start" MomentaryButtonKind.Stop "stop" MomentaryButtonKind.Emergency "emergency"

enum MomentaryButtonDensity

MomentaryButtonDensity.Normal "normal" MomentaryButtonDensity.Touch "touch"

CSS variables

The component declares 8 CSS variables; the CSS page shows how to set them.

--smart-momentary-size --smart-momentary-background --smart-momentary-border --smart-momentary-accent --smart-momentary-start --smart-momentary-stop --smart-momentary-lamp --smart-momentary-warning-text