@opalkelly/frontpanel-react-components 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/FrontPanel/FrontPanel.props.d.ts +1 -0
- package/dist/cjs/types/components/FrontPanelSelectEntry/FrontPanelSelectEntry.d.ts +1 -0
- package/dist/cjs/types/primitives/Application/Application.props.d.ts +1 -0
- package/dist/cjs/types/primitives/Label/Label.props.d.ts +1 -0
- package/dist/cjs/types/primitives/SelectEntry/SelectEntry.d.ts +1 -0
- package/dist/cjs/types/primitives/Toggle/Toggle.props.d.ts +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/FrontPanel/FrontPanel.props.d.ts +1 -0
- package/dist/esm/types/components/FrontPanelSelectEntry/FrontPanelSelectEntry.d.ts +1 -0
- package/dist/esm/types/primitives/Application/Application.props.d.ts +1 -0
- package/dist/esm/types/primitives/Label/Label.props.d.ts +1 -0
- package/dist/esm/types/primitives/SelectEntry/SelectEntry.d.ts +1 -0
- package/dist/esm/types/primitives/Toggle/Toggle.props.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +3 -5
- package/src/components/FrontPanel/FrontPanel.props.ts +5 -1
- package/src/components/FrontPanelIndicator/FrontPanelIndicator.tsx +3 -3
- package/src/components/FrontPanelNumberDisplay/FrontPanelNumberDisplay.tsx +5 -5
- package/src/components/FrontPanelNumberEntry/FrontPanelNumberEntry.tsx +8 -8
- package/src/components/FrontPanelPushButton/FrontPanelPushButton.tsx +5 -5
- package/src/components/FrontPanelRangeSlider/FrontPanelRangeSlider.tsx +4 -4
- package/src/components/FrontPanelSelectEntry/FrontPanelSelectEntryRoot.tsx +7 -7
- package/src/components/FrontPanelToggleSwitch/FrontPanelToggleSwitch.tsx +4 -4
- package/src/components/FrontPanelTriggerButton/FrontPanelTriggerButton.tsx +3 -3
- package/src/contexts/FrontPanelContext.ts +5 -1
@@ -52,8 +52,8 @@ const FrontPanelPushButton = React.forwardRef<
|
|
52
52
|
const targetWireBitMask = 1 << fpEndpoint.bitOffset;
|
53
53
|
|
54
54
|
const onButtonUp = React.useCallback(async (): Promise<void> => {
|
55
|
-
if (device != null && workQueue != null) {
|
56
|
-
await workQueue.
|
55
|
+
if ((device != null) && (workQueue != null)) {
|
56
|
+
await workQueue.post(async () => {
|
57
57
|
device.setWireInValue(fpEndpoint.epAddress, 0, targetWireBitMask);
|
58
58
|
await device.updateWireIns();
|
59
59
|
});
|
@@ -61,8 +61,8 @@ const FrontPanelPushButton = React.forwardRef<
|
|
61
61
|
}, [device, workQueue, fpEndpoint, targetWireBitMask, workQueue]);
|
62
62
|
|
63
63
|
const onButtonDown = React.useCallback(async (): Promise<void> => {
|
64
|
-
if (device != null && workQueue != null) {
|
65
|
-
await workQueue.
|
64
|
+
if ((device != null) && (workQueue != null)) {
|
65
|
+
await workQueue.post(async () => {
|
66
66
|
device.setWireInValue(fpEndpoint.epAddress, 0xffffffff, targetWireBitMask);
|
67
67
|
await device.updateWireIns();
|
68
68
|
});
|
@@ -73,7 +73,7 @@ const FrontPanelPushButton = React.forwardRef<
|
|
73
73
|
<Button
|
74
74
|
{...buttonProps}
|
75
75
|
ref={forwardedRef}
|
76
|
-
disabled={disabled || device == null}
|
76
|
+
disabled={disabled || (device == null)}
|
77
77
|
onButtonUp={onButtonUp}
|
78
78
|
onButtonDown={onButtonDown}
|
79
79
|
/>
|
@@ -64,7 +64,7 @@ const FrontPanelRangeSlider = React.forwardRef<
|
|
64
64
|
|
65
65
|
const onUpdateWireValue = React.useCallback(
|
66
66
|
(sender?: IFrontPanel): void => {
|
67
|
-
if (sender != null && workQueue != null) {
|
67
|
+
if ((sender != null) && (workQueue != null)) {
|
68
68
|
const sourceWireValue = sender.getWireInValue(fpEndpoint.epAddress);
|
69
69
|
const sourceValue =
|
70
70
|
(BigInt(sourceWireValue) & targetWireBitMask) >> BigInt(fpEndpoint.bitOffset);
|
@@ -78,8 +78,8 @@ const FrontPanelRangeSlider = React.forwardRef<
|
|
78
78
|
|
79
79
|
const onSelectedValueChangeHandler = React.useCallback(
|
80
80
|
(value: number) => {
|
81
|
-
if (device != null && workQueue != null) {
|
82
|
-
workQueue.
|
81
|
+
if ((device != null) && (workQueue != null)) {
|
82
|
+
workQueue.post(async () => {
|
83
83
|
device.setWireInValue(
|
84
84
|
fpEndpoint.epAddress,
|
85
85
|
value << fpEndpoint.bitOffset,
|
@@ -100,7 +100,7 @@ const FrontPanelRangeSlider = React.forwardRef<
|
|
100
100
|
<RangeSlider
|
101
101
|
{...rootProps}
|
102
102
|
ref={forwardedRef}
|
103
|
-
disabled={disabled || device == null}
|
103
|
+
disabled={disabled || (device == null)}
|
104
104
|
defaultValue={Number(value)}
|
105
105
|
maximumValue={maximumValue}
|
106
106
|
onValueChange={onSelectedValueChangeHandler}
|
@@ -68,7 +68,7 @@ const FrontPanelSelectEntryRoot: React.FC<FrontPanelSelectEntryRootCombinedProps
|
|
68
68
|
|
69
69
|
const onUpdateWireValue = React.useCallback(
|
70
70
|
(sender?: IFrontPanel): void => {
|
71
|
-
if (sender != null && workQueue != null) {
|
71
|
+
if ((sender != null) && (workQueue != null)) {
|
72
72
|
// Get the wire value for the endpoint
|
73
73
|
let sourceWireValue = sender.getWireInValue(fpEndpoint.epAddress);
|
74
74
|
let targetWireBitMask = targetWireSpanBitMask & 0xffffffffn;
|
@@ -82,8 +82,8 @@ const FrontPanelSelectEntryRoot: React.FC<FrontPanelSelectEntryRootCombinedProps
|
|
82
82
|
|
83
83
|
for (
|
84
84
|
let sourceWireAddress = fpEndpoint.epAddress + 1;
|
85
|
-
sourceWireAddress <= WIREIN_ADDRESS_RANGE.
|
86
|
-
currentWireSpanBitMask > 0n;
|
85
|
+
(sourceWireAddress <= WIREIN_ADDRESS_RANGE.maximum) &&
|
86
|
+
(currentWireSpanBitMask > 0n);
|
87
87
|
sourceWireAddress++
|
88
88
|
) {
|
89
89
|
// Get the wire value for the next endpoint
|
@@ -108,9 +108,9 @@ const FrontPanelSelectEntryRoot: React.FC<FrontPanelSelectEntryRootCombinedProps
|
|
108
108
|
|
109
109
|
const onSelectedValueChangeHandler = React.useCallback(
|
110
110
|
(value: string) => {
|
111
|
-
if (device != null && workQueue != null) {
|
111
|
+
if ((device != null) && (workQueue != null)) {
|
112
112
|
const targetWireSpanValue = BigInt(value);
|
113
|
-
workQueue.
|
113
|
+
workQueue.post(async () => {
|
114
114
|
let targetWireBitMask = targetWireSpanBitMask & 0xffffffffn;
|
115
115
|
let targetWireValue = Number(
|
116
116
|
(targetWireSpanValue << BigInt(fpEndpoint.bitOffset)) & targetWireBitMask
|
@@ -132,7 +132,7 @@ const FrontPanelSelectEntryRoot: React.FC<FrontPanelSelectEntryRootCombinedProps
|
|
132
132
|
|
133
133
|
for (
|
134
134
|
let wireIndex = 1;
|
135
|
-
wireIndex < maxWireCount && currentWireSpanBitMask > 0n;
|
135
|
+
(wireIndex < maxWireCount) && (currentWireSpanBitMask > 0n);
|
136
136
|
wireIndex++
|
137
137
|
) {
|
138
138
|
targetWireBitMask = currentWireSpanBitMask & 0xffffffffn;
|
@@ -169,7 +169,7 @@ const FrontPanelSelectEntryRoot: React.FC<FrontPanelSelectEntryRootCombinedProps
|
|
169
169
|
return (
|
170
170
|
<SelectEntry.Root
|
171
171
|
{...rootProps}
|
172
|
-
disabled={disabled || device == null}
|
172
|
+
disabled={disabled || (device == null)}
|
173
173
|
value={value.toString()}
|
174
174
|
onValueChange={onSelectedValueChangeHandler}
|
175
175
|
/>
|
@@ -59,7 +59,7 @@ const FrontPanelToggleSwitch = React.forwardRef<
|
|
59
59
|
|
60
60
|
const onUpdateWireValue = React.useCallback(
|
61
61
|
(sender?: IFrontPanel): void => {
|
62
|
-
if (sender != null && workQueue != null) {
|
62
|
+
if ((sender != null) && (workQueue != null)) {
|
63
63
|
// Set the toggle state based on the value of the target bit of the Wire endpoint
|
64
64
|
const sourceWireValue = sender.getWireInValue(fpEndpoint.epAddress);
|
65
65
|
const sourceBitValue = (sourceWireValue & targetWireBitMask) === targetWireBitMask;
|
@@ -74,8 +74,8 @@ const FrontPanelToggleSwitch = React.forwardRef<
|
|
74
74
|
|
75
75
|
const onToggleStateChanged = React.useCallback(
|
76
76
|
async (state: ToggleState): Promise<void> => {
|
77
|
-
if (device != null && workQueue != null) {
|
78
|
-
await workQueue.
|
77
|
+
if ((device != null) && (workQueue != null)) {
|
78
|
+
await workQueue.post(async () => {
|
79
79
|
// Set the value of the target bit of the Wire endpoint based on the toggle state
|
80
80
|
const targetWireValue: WireValue = state === ToggleState.On ? 0xffffffff : 0;
|
81
81
|
|
@@ -98,7 +98,7 @@ const FrontPanelToggleSwitch = React.forwardRef<
|
|
98
98
|
<ToggleSwitch
|
99
99
|
ref={forwardedRef}
|
100
100
|
{...buttonProps}
|
101
|
-
disabled={disabled || device == null}
|
101
|
+
disabled={disabled || (device == null)}
|
102
102
|
state={state}
|
103
103
|
onToggleStateChanged={onToggleStateChanged}
|
104
104
|
/>
|
@@ -52,8 +52,8 @@ const FrontPanelTriggerButton = React.forwardRef<
|
|
52
52
|
const { fpEndpoint, disabled, ...buttonProps } = props;
|
53
53
|
|
54
54
|
const onButtonDown = React.useCallback(async (): Promise<void> => {
|
55
|
-
if (device != null && workQueue != null) {
|
56
|
-
await workQueue.
|
55
|
+
if ((device != null) && (workQueue != null)) {
|
56
|
+
await workQueue.post(async () => {
|
57
57
|
await device.activateTriggerIn(fpEndpoint.epAddress, fpEndpoint.bitOffset);
|
58
58
|
});
|
59
59
|
}
|
@@ -63,7 +63,7 @@ const FrontPanelTriggerButton = React.forwardRef<
|
|
63
63
|
<Button
|
64
64
|
{...buttonProps}
|
65
65
|
ref={forwardedRef}
|
66
|
-
disabled={disabled || device == null}
|
66
|
+
disabled={disabled || (device == null)}
|
67
67
|
onButtonDown={onButtonDown}
|
68
68
|
/>
|
69
69
|
);
|
@@ -7,7 +7,11 @@
|
|
7
7
|
|
8
8
|
import React from "react";
|
9
9
|
|
10
|
-
import {
|
10
|
+
import {
|
11
|
+
IFrontPanel,
|
12
|
+
IFrontPanelEventSource,
|
13
|
+
WorkQueue
|
14
|
+
} from "@opalkelly/frontpanel-alloy-core";
|
11
15
|
|
12
16
|
export type FrontPanelContextValue = {
|
13
17
|
device?: IFrontPanel;
|