@opalkelly/frontpanel-react-components 0.3.0 → 0.5.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/LICENSE +1 -1
- package/README.md +4 -8
- 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 +4 -4
- package/dist/cjs/types/components/types.d.ts +1 -1
- package/dist/cjs/types/contexts/FrontPanelContext.d.ts +3 -3
- 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 +4 -4
- package/dist/esm/types/components/types.d.ts +1 -1
- package/dist/esm/types/contexts/FrontPanelContext.d.ts +3 -3
- package/dist/index.d.ts +6 -6
- package/package.json +36 -38
- package/src/components/FrontPanel/FrontPanel.props.ts +6 -6
- package/src/components/FrontPanel/FrontPanel.tsx +2 -2
- package/src/components/FrontPanelIndicator/FrontPanelIndicator.tsx +5 -5
- package/src/components/FrontPanelNumberDisplay/FrontPanelNumberDisplay.tsx +5 -5
- package/src/components/FrontPanelNumberEntry/FrontPanelNumberEntry.stories.tsx +4 -7
- package/src/components/FrontPanelNumberEntry/FrontPanelNumberEntry.tsx +12 -12
- package/src/components/FrontPanelPushButton/FrontPanelPushButton.tsx +10 -10
- package/src/components/FrontPanelRangeSlider/FrontPanelRangeSlider.stories.tsx +5 -7
- package/src/components/FrontPanelRangeSlider/FrontPanelRangeSlider.tsx +10 -10
- package/src/components/FrontPanelSelectEntry/FrontPanelSelectEntry.stories.tsx +4 -7
- package/src/components/FrontPanelSelectEntry/FrontPanelSelectEntryRoot.tsx +12 -12
- package/src/components/FrontPanelToggleSwitch/FrontPanelToggleSwitch.tsx +11 -11
- package/src/components/FrontPanelTriggerButton/FrontPanelTriggerButton.tsx +5 -5
- package/src/components/types.ts +1 -1
- package/src/contexts/FrontPanelContext.ts +5 -5
- package/src/stories/decorators/FrontPanel.decorator.tsx +10 -8
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
import React from "react";
|
9
9
|
|
10
|
-
import {
|
10
|
+
import { IFPGADataPortClassic, WireValue } from "@opalkelly/frontpanel-platform-api";
|
11
11
|
|
12
12
|
import { ToggleState } from "../../core";
|
13
13
|
|
@@ -51,14 +51,14 @@ const FrontPanelToggleSwitch = React.forwardRef<
|
|
51
51
|
>((props, forwardedRef) => {
|
52
52
|
const [state, setState] = React.useState<ToggleState>(ToggleState.Off);
|
53
53
|
|
54
|
-
const {
|
54
|
+
const { fpgaDataPort, workQueue } = React.useContext(FrontPanelContext);
|
55
55
|
|
56
56
|
const { fpEndpoint, disabled, ...buttonProps } = props;
|
57
57
|
|
58
58
|
const targetWireBitMask = 1 << fpEndpoint.bitOffset;
|
59
59
|
|
60
60
|
const onUpdateWireValue = React.useCallback(
|
61
|
-
(sender?:
|
61
|
+
(sender?: IFPGADataPortClassic): void => {
|
62
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);
|
@@ -74,31 +74,31 @@ const FrontPanelToggleSwitch = React.forwardRef<
|
|
74
74
|
|
75
75
|
const onToggleStateChanged = React.useCallback(
|
76
76
|
async (state: ToggleState): Promise<void> => {
|
77
|
-
if ((
|
77
|
+
if ((fpgaDataPort != null) && (workQueue != null)) {
|
78
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
|
|
82
|
-
|
82
|
+
fpgaDataPort.setWireInValue(fpEndpoint.epAddress, targetWireValue, targetWireBitMask);
|
83
83
|
|
84
|
-
await
|
84
|
+
await fpgaDataPort.updateWireIns();
|
85
85
|
});
|
86
86
|
}
|
87
87
|
|
88
|
-
onUpdateWireValue(
|
88
|
+
onUpdateWireValue(fpgaDataPort);
|
89
89
|
},
|
90
|
-
[
|
90
|
+
[fpgaDataPort, workQueue, fpEndpoint, targetWireBitMask]
|
91
91
|
);
|
92
92
|
|
93
93
|
React.useEffect(() => {
|
94
|
-
onUpdateWireValue(
|
95
|
-
}, [
|
94
|
+
onUpdateWireValue(fpgaDataPort);
|
95
|
+
}, [fpgaDataPort, onUpdateWireValue]);
|
96
96
|
|
97
97
|
return (
|
98
98
|
<ToggleSwitch
|
99
99
|
ref={forwardedRef}
|
100
100
|
{...buttonProps}
|
101
|
-
disabled={disabled || (
|
101
|
+
disabled={disabled || (fpgaDataPort == null)}
|
102
102
|
state={state}
|
103
103
|
onToggleStateChanged={onToggleStateChanged}
|
104
104
|
/>
|
@@ -47,23 +47,23 @@ const FrontPanelTriggerButton = React.forwardRef<
|
|
47
47
|
FrontPanelTriggerButtonElement,
|
48
48
|
FrontPanelTriggerButtonCombinedProps
|
49
49
|
>((props, forwardedRef) => {
|
50
|
-
const {
|
50
|
+
const { fpgaDataPort, workQueue } = React.useContext(FrontPanelContext);
|
51
51
|
|
52
52
|
const { fpEndpoint, disabled, ...buttonProps } = props;
|
53
53
|
|
54
54
|
const onButtonDown = React.useCallback(async (): Promise<void> => {
|
55
|
-
if ((
|
55
|
+
if ((fpgaDataPort != null) && (workQueue != null)) {
|
56
56
|
await workQueue.post(async () => {
|
57
|
-
await
|
57
|
+
await fpgaDataPort.activateTriggerIn(fpEndpoint.epAddress, fpEndpoint.bitOffset);
|
58
58
|
});
|
59
59
|
}
|
60
|
-
}, [
|
60
|
+
}, [fpgaDataPort, workQueue, fpEndpoint]);
|
61
61
|
|
62
62
|
return (
|
63
63
|
<Button
|
64
64
|
{...buttonProps}
|
65
65
|
ref={forwardedRef}
|
66
|
-
disabled={disabled || (
|
66
|
+
disabled={disabled || (fpgaDataPort == null)}
|
67
67
|
onButtonDown={onButtonDown}
|
68
68
|
/>
|
69
69
|
);
|
package/src/components/types.ts
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
* See the LICENSE file found in the root directory of this project.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import { BitCount } from "@opalkelly/frontpanel-
|
8
|
+
import { BitCount } from "@opalkelly/frontpanel-platform-api";
|
9
9
|
|
10
10
|
export interface EndpointAddressProps {
|
11
11
|
epAddress: number;
|
@@ -8,15 +8,15 @@
|
|
8
8
|
import React from "react";
|
9
9
|
|
10
10
|
import {
|
11
|
-
|
12
|
-
|
11
|
+
IFPGADataPortClassic,
|
12
|
+
IFPGADataPortClassicEventSource,
|
13
13
|
WorkQueue
|
14
|
-
} from "@opalkelly/frontpanel-
|
14
|
+
} from "@opalkelly/frontpanel-platform-api";
|
15
15
|
|
16
16
|
export type FrontPanelContextValue = {
|
17
|
-
|
17
|
+
fpgaDataPort?: IFPGADataPortClassic;
|
18
18
|
workQueue?: WorkQueue;
|
19
|
-
eventSource?:
|
19
|
+
eventSource?: IFPGADataPortClassicEventSource;
|
20
20
|
};
|
21
21
|
|
22
22
|
const FrontPanelContext = React.createContext<FrontPanelContextValue>({});
|
@@ -11,26 +11,28 @@ import type { Decorator } from "@storybook/react";
|
|
11
11
|
|
12
12
|
import { FrontPanel } from "../../components";
|
13
13
|
|
14
|
-
import { MockFrontPanel, ByteCount } from "@opalkelly/frontpanel-
|
14
|
+
import { MockFrontPanel, ByteCount, WorkQueue } from "@opalkelly/frontpanel-platform-api";
|
15
15
|
|
16
|
-
const
|
16
|
+
const mockFPGADataPort: MockFrontPanel = new MockFrontPanel(32, 32);
|
17
|
+
|
18
|
+
const deviceWorkQueue: WorkQueue = new WorkQueue();
|
17
19
|
|
18
20
|
const InitializeMockDevice = () => {
|
19
21
|
// Initialize the WireOuts with unique values.
|
20
|
-
const wireOutBlock =
|
22
|
+
const wireOutBlock = mockFPGADataPort.WireOutBlock;
|
21
23
|
|
22
24
|
let byteId: ByteCount = 0;
|
23
25
|
|
24
|
-
for (let elementIndex = 0; elementIndex < wireOutBlock.
|
26
|
+
for (let elementIndex = 0; elementIndex < wireOutBlock.count; elementIndex++) {
|
25
27
|
let elementValue: number = byteId++;
|
26
28
|
for (let byteIndex = 1; byteIndex < 4; byteIndex++) {
|
27
29
|
elementValue |= byteId++ << (8 * byteIndex);
|
28
30
|
}
|
29
31
|
|
30
|
-
wireOutBlock.
|
31
|
-
wireOutBlock.
|
32
|
+
wireOutBlock.setValue(
|
33
|
+
wireOutBlock.baseAddress + elementIndex,
|
32
34
|
elementValue,
|
33
|
-
wireOutBlock.
|
35
|
+
wireOutBlock.mask
|
34
36
|
);
|
35
37
|
}
|
36
38
|
};
|
@@ -38,7 +40,7 @@ const InitializeMockDevice = () => {
|
|
38
40
|
const withFrontPanel: Decorator = (Story) => {
|
39
41
|
InitializeMockDevice();
|
40
42
|
return (
|
41
|
-
<FrontPanel
|
43
|
+
<FrontPanel fpgaDataPort={mockFPGADataPort} workQueue={deviceWorkQueue}>
|
42
44
|
<Story />
|
43
45
|
</FrontPanel>
|
44
46
|
);
|