@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.
Files changed (30) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -8
  3. package/dist/cjs/index.js +1 -1
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/types/components/FrontPanel/FrontPanel.props.d.ts +4 -4
  6. package/dist/cjs/types/components/types.d.ts +1 -1
  7. package/dist/cjs/types/contexts/FrontPanelContext.d.ts +3 -3
  8. package/dist/esm/index.js +1 -1
  9. package/dist/esm/index.js.map +1 -1
  10. package/dist/esm/types/components/FrontPanel/FrontPanel.props.d.ts +4 -4
  11. package/dist/esm/types/components/types.d.ts +1 -1
  12. package/dist/esm/types/contexts/FrontPanelContext.d.ts +3 -3
  13. package/dist/index.d.ts +6 -6
  14. package/package.json +36 -38
  15. package/src/components/FrontPanel/FrontPanel.props.ts +6 -6
  16. package/src/components/FrontPanel/FrontPanel.tsx +2 -2
  17. package/src/components/FrontPanelIndicator/FrontPanelIndicator.tsx +5 -5
  18. package/src/components/FrontPanelNumberDisplay/FrontPanelNumberDisplay.tsx +5 -5
  19. package/src/components/FrontPanelNumberEntry/FrontPanelNumberEntry.stories.tsx +4 -7
  20. package/src/components/FrontPanelNumberEntry/FrontPanelNumberEntry.tsx +12 -12
  21. package/src/components/FrontPanelPushButton/FrontPanelPushButton.tsx +10 -10
  22. package/src/components/FrontPanelRangeSlider/FrontPanelRangeSlider.stories.tsx +5 -7
  23. package/src/components/FrontPanelRangeSlider/FrontPanelRangeSlider.tsx +10 -10
  24. package/src/components/FrontPanelSelectEntry/FrontPanelSelectEntry.stories.tsx +4 -7
  25. package/src/components/FrontPanelSelectEntry/FrontPanelSelectEntryRoot.tsx +12 -12
  26. package/src/components/FrontPanelToggleSwitch/FrontPanelToggleSwitch.tsx +11 -11
  27. package/src/components/FrontPanelTriggerButton/FrontPanelTriggerButton.tsx +5 -5
  28. package/src/components/types.ts +1 -1
  29. package/src/contexts/FrontPanelContext.ts +5 -5
  30. 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 { IFrontPanel, WireValue } from "@opalkelly/frontpanel-alloy-core";
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 { device, workQueue } = React.useContext(FrontPanelContext);
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?: IFrontPanel): void => {
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 ((device != null) && (workQueue != null)) {
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
- device.setWireInValue(fpEndpoint.epAddress, targetWireValue, targetWireBitMask);
82
+ fpgaDataPort.setWireInValue(fpEndpoint.epAddress, targetWireValue, targetWireBitMask);
83
83
 
84
- await device.updateWireIns();
84
+ await fpgaDataPort.updateWireIns();
85
85
  });
86
86
  }
87
87
 
88
- onUpdateWireValue(device);
88
+ onUpdateWireValue(fpgaDataPort);
89
89
  },
90
- [device, workQueue, fpEndpoint, targetWireBitMask]
90
+ [fpgaDataPort, workQueue, fpEndpoint, targetWireBitMask]
91
91
  );
92
92
 
93
93
  React.useEffect(() => {
94
- onUpdateWireValue(device);
95
- }, [device, onUpdateWireValue]);
94
+ onUpdateWireValue(fpgaDataPort);
95
+ }, [fpgaDataPort, onUpdateWireValue]);
96
96
 
97
97
  return (
98
98
  <ToggleSwitch
99
99
  ref={forwardedRef}
100
100
  {...buttonProps}
101
- disabled={disabled || (device == null)}
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 { device, workQueue } = React.useContext(FrontPanelContext);
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 ((device != null) && (workQueue != null)) {
55
+ if ((fpgaDataPort != null) && (workQueue != null)) {
56
56
  await workQueue.post(async () => {
57
- await device.activateTriggerIn(fpEndpoint.epAddress, fpEndpoint.bitOffset);
57
+ await fpgaDataPort.activateTriggerIn(fpEndpoint.epAddress, fpEndpoint.bitOffset);
58
58
  });
59
59
  }
60
- }, [device, workQueue, fpEndpoint]);
60
+ }, [fpgaDataPort, workQueue, fpEndpoint]);
61
61
 
62
62
  return (
63
63
  <Button
64
64
  {...buttonProps}
65
65
  ref={forwardedRef}
66
- disabled={disabled || (device == null)}
66
+ disabled={disabled || (fpgaDataPort == null)}
67
67
  onButtonDown={onButtonDown}
68
68
  />
69
69
  );
@@ -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-alloy-core";
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
- IFrontPanel,
12
- IFrontPanelEventSource,
11
+ IFPGADataPortClassic,
12
+ IFPGADataPortClassicEventSource,
13
13
  WorkQueue
14
- } from "@opalkelly/frontpanel-alloy-core";
14
+ } from "@opalkelly/frontpanel-platform-api";
15
15
 
16
16
  export type FrontPanelContextValue = {
17
- device?: IFrontPanel;
17
+ fpgaDataPort?: IFPGADataPortClassic;
18
18
  workQueue?: WorkQueue;
19
- eventSource?: IFrontPanelEventSource;
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-alloy-core";
14
+ import { MockFrontPanel, ByteCount, WorkQueue } from "@opalkelly/frontpanel-platform-api";
15
15
 
16
- const mockDevice: MockFrontPanel = new MockFrontPanel(32, 32);
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 = mockDevice.WireOutBlock;
22
+ const wireOutBlock = mockFPGADataPort.WireOutBlock;
21
23
 
22
24
  let byteId: ByteCount = 0;
23
25
 
24
- for (let elementIndex = 0; elementIndex < wireOutBlock.Count; elementIndex++) {
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.SetValue(
31
- wireOutBlock.BaseAddress + elementIndex,
32
+ wireOutBlock.setValue(
33
+ wireOutBlock.baseAddress + elementIndex,
32
34
  elementValue,
33
- wireOutBlock.Mask
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 device={mockDevice}>
43
+ <FrontPanel fpgaDataPort={mockFPGADataPort} workQueue={deviceWorkQueue}>
42
44
  <Story />
43
45
  </FrontPanel>
44
46
  );