UNPKG

@opalkelly/frontpanel-platform-api

Version:

TypeScript definitions for Opal Kelly FrontPanel Platform API

1,110 lines (1,063 loc) 40.5 kB
/** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Type representing a count of bytes. */ type ByteCount = number; /** * Type representing a count of bits. */ type BitCount = number; /** * Type representing a callback function that reports the progress of a data transfer. * @param total - The total number of bytes to transfer. * @param completed - The number of bytes that have been transferred. */ type DataProgressCallback = (total: ByteCount, completed: ByteCount) => void; /** * Copyright (c) 2025 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Enumeration representing types of device interfaces. */ declare enum DeviceInterfaceType { UNKNOWN = 0, USB2 = 1, PCIE = 2, USB3 = 3 } /** * Copyright (c) 2025 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Enumeration representing USB speed designations. */ declare enum UsbSpeedDesignation { UNKNOWN = 0, FULL_SPEED = 1, HIGH_SPEED = 2, SUPER_SPEED = 3 } /** * Interface representing information about a USB device interface. */ interface DeviceUsbInterfaceInfo { /** * The USB speed designation of the device interface. */ readonly speedDesignation: UsbSpeedDesignation; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Interface that provides information about the device. */ interface IDeviceInfo { /** * The device ID of the device. */ get deviceID(): string; /** * The serial number of the device. */ get serialNumber(): string; /** * The product ID of the device. */ get productID(): number; /** * The product name of the device. */ get productName(): string; /** * The interface type supported by the device. */ get interfaceType(): DeviceInterfaceType; /** * The information detailing the interface of the device. */ get interfaceInfo(): DeviceUsbInterfaceInfo | undefined; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Type representing the address of an endpoint. */ type EndpointAddress = number; /** * Represents the address of a bit within an endpoint. */ type EndpointBitAddress = { /** * The address of the endpoint. */ epAddress: EndpointAddress; /** * The offset from the LSB of the endpoint, measured in bits. */ bitOffset: BitCount; }; /** * Type representing a Register address. */ type RegisterAddress = number; /** * Type representing the width of a Register address, measured in bits. */ type RegisterAddressWidth = BitCount; /** * Type representing Register data. */ type RegisterData = number; /** * Type representing the width of Register data, measured in bits. */ type RegisterDataWidth = BitCount; /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Type representing the address of a Wire endpoint. */ type WireAddress = EndpointAddress; /** * Type representing the width of a Wire endpoint, measured in bits. */ type WireWidth = BitCount; /** * Type representing the value of a Wire endpoint. */ type WireValue = number; type WireMask = number; /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Type representing the address of a Trigger vector endpoint. */ type TriggerVectorAddress = EndpointAddress; /** * Type representing a Trigger vector. */ type TriggerVector = number; /** * Type representing the width of a Trigger vector, measured in bits. */ type TriggerVectorWidth = BitCount; /** * Type representing a Trigger vector mask. */ type TriggerVectorMask = number; /** * Type representing the state of a Trigger, which is a boolean. */ type TriggerState = boolean; /** * Type representing the address of a Trigger. */ type TriggerAddress = EndpointBitAddress; /** * Copyright (c) 2025 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Type representing the address of a Pipe endpoint. */ type PipeAddress = EndpointAddress; /** * Type representing the width of a Pipe endpoint, measured in bits. */ type PipeWidth = BitCount; /** * Copyright (c) 2025 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Interface representing information about the FrontPanel host. */ interface FrontPanelHostInfo { readonly wireWidth: WireWidth; readonly triggerWidth: TriggerVectorWidth; readonly pipeWidth: PipeWidth; readonly registerAddressWidth: RegisterAddressWidth; readonly registerDataWidth: RegisterDataWidth; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Interface that provides the methods that may be used to interact * with a FrontPanel device. */ interface IFrontPanel { /** * The FrontPanel information for the device FPGA. */ get hostInterfaceInfo(): FrontPanelHostInfo; /** * Gets the value of a WireIn at the specified address. * @param address - The address of the WireIn endpoint. * @returns {WireValue} - The value of the WireIn. */ getWireInValue(address: WireAddress): WireValue; /** * Sets the value of the WireIn at the specified address. * @param address - The address of the WireIn endpoint. * @param value - The value to set. * @param mask - The mask to apply to the value. */ setWireInValue(address: WireAddress, value: WireValue, mask: WireMask): void; /** * Transfers current WireIn values to the FPGA. * @returns {Promise<void>} - A promise that resolves when all WireIns have been transfered. */ updateWireIns(): Promise<void>; /** * Gets the value of the WireOut at the specified address. * @param address - The address of the WireOut endpoint. * @returns {WireValue} - The value of the WireOut. */ getWireOutValue(address: WireAddress): WireValue; /** * Retrieves current WireOut values from the FPGA. * @returns {Promise<void>} - A promise that resolves when all WireOuts have been updated. */ updateWireOuts(): Promise<void>; /** * Activates the TriggerIn at the specified address and bit. * @param address - The address of the TriggerIn vector endpoint. * @param bit - The bit of the TriggerIn vector to activate. * @returns {Promise<void>} - A promise that resolves when the TriggerIn has been activated. */ activateTriggerIn(address: TriggerVectorAddress, bit: number): Promise<void>; /** * Gets the TriggerOut vector at the specified address. * @param address - The address of the TriggerOut vector endpoint. * @returns {TriggerVector} - The TriggerOut vector. */ getTriggerOutVector(address: TriggerVectorAddress): TriggerVector; /** * Checks if the TriggerOut at the specified address and mask is active. * @param address - The address of the TriggerOut vector endpoint. * @param mask - The mask to apply to the TriggerOut vector. * @returns {boolean} - True if the TriggerOut is active, otherwise false. */ isTriggered(address: TriggerVectorAddress, mask: TriggerVectorMask): boolean; /** * Retrieves the current TriggerOut vectors from the FPGA. * @returns {Promise<void>} - A promise that resolves when all TriggerOuts have been updated. */ updateTriggerOuts(): Promise<void>; /** * Writes data to the PipeIn at the specified address. * @param address - The address of the PipeIn endpoint. * @param length - The length of the data to write in bytes. * @param data - The buffer containing the data to write. * @returns {Promise<ByteCount>} - A promise that resolves when the data has been written * indicating the number of bytes that were successfully written. */ writeToPipeIn(address: PipeAddress, length: ByteCount, data: ArrayBuffer): Promise<ByteCount>; /** * Writes data to the Block Throttle PipeIn at the specified address. * @param address - The address of the PipeIn endpoint. * @param blockSize - The size of the blocks to write in bytes. * @param length - The length of the data to write in bytes. * @param data - The buffer containing the data to write. * @returns {Promise<ByteCount>} - A promise that resolves when the data has been written * indicating the number of bytes that were successfully written. */ writeToBlockPipeIn(address: PipeAddress, blockSize: ByteCount, length: ByteCount, data: ArrayBuffer): Promise<ByteCount>; /** * Reads data from the PipeOut at the specified address. * @param address - The address of the PipeOut endpoint. * @param length - The length of the data to read in bytes. * @param buffer - The buffer to store the data that is read. * @returns {Promise<ByteCount>} - A promise that resolves when the data has been read * indicating the number of bytes that were successfully read. */ readFromPipeOut(address: PipeAddress, length: ByteCount, buffer: ArrayBuffer): Promise<ByteCount>; /** * Reads data from the Block Throttle PipeOut at the specified address. * @param address - The address of the PipeOut endpoint. * @param blockSize - The size of the blocks to read in bytes. * @param length - The length of the data to read in bytes. * @param buffer - The buffer to store the data that is read. * @returns {Promise<ByteCount>} - A promise that resolves when the data has been read * indicating the number of bytes that were successfully read. */ readFromBlockPipeOut(address: PipeAddress, blockSize: ByteCount, length: ByteCount, buffer: ArrayBuffer): Promise<ByteCount>; /** * Reads the value of the Register at the specified address. * @param address - The address of the Register. * @returns {Promise<RegisterValue>} - A promise that resolves to the value of the Register. */ readRegister(address: RegisterAddress): Promise<RegisterData>; /** * Reads the data of the Registers at the specified addresses and stores the data in the * corresponding array element. * @param registers - The array containing address and data pairs for each register. * @returns {Promise<void>} - A promise that resolves when all the registers have * been read. */ readRegisters(registers: Array<{ address: RegisterAddress; data: RegisterData; }>): Promise<void>; /** * Writes a value to the Register at the specified address. * @param address - The address of the Register. * @param value - The value to write. * @returns {Promise<void>} - A promise that resolves when the value has been written. */ writeRegister(address: RegisterAddress, value: RegisterData): Promise<void>; /** * Writes data to each of the Registers at the specified addresses. * @param registers - The array containing address and data pairs for each register. * @returns {Promise<void>} - A promise that resolves when the register values have been written. */ writeRegisters(registers: Array<{ address: RegisterAddress; data: RegisterData; }>): Promise<void>; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Interface that provides the methods that may be used to interact * with the FPGA on a device. */ interface IDeviceFPGA { /** * Configures the FPGA with the specified data. * @param data - The buffer containing the configuration data. * @param length - The length of the configuration data in bytes. * @param progressCallback - Optional callback that reports the progress of the configuration. * @returns {Promise<void>} - A promise that resolves when the configuration is complete. */ loadConfiguration(data: ArrayBuffer, length: ByteCount, progressCallback?: DataProgressCallback): Promise<void>; /** * Clears the FPGA configuration. * @returns {Promise<void>} - A promise that resolves when the configuration has been cleared. */ clearConfiguration(): Promise<void>; /** * Gets the FrontPanel interface if the device is configured. * @returns {Promise<IFrontPanel>} - A promise that resolves to a FrontPanel interface if the FPGA * is configured with the host gateware, otherwise null. */ getFrontPanel(): Promise<IFrontPanel>; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Interface that provides the methods that may be used to interact * with the device. */ interface IDevice { /** * Determines if the Device is currently open. * @returns {Promise<boolean>} - Promise that resolves to true if the Device * is open, otherwise false. */ isOpen(): Promise<boolean>; /** * Retrieves the device information. * @returns {Promise<IDeviceInfo>} - Promise that resolves to a Device * information interface. */ getInfo(): Promise<IDeviceInfo>; /** * The FPGA interface for the device. * @returns {IDeviceFPGA} - The FPGA interface for the Device. */ getFPGA(): IDeviceFPGA; /** * Closes the Device. * @returns {boolean} - True if the Device was successfully closed, otherwise false. */ close(): boolean; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Interface representing an event subscription. */ interface IEventSubscription { /** * Cancels the event subscription. * @returns {boolean} - Returns true if the cancellation was successful, false otherwise. */ cancel(): boolean; } /** * Copyright (c) 2025 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Type representing a Device event handler. * @param sender - The sender of the event. * @param serialNumber - The serial number of the device. */ type DeviceEventHandler = (sender: IDeviceManager, serialNumber: string) => void; /** * Type representing an asynchronous Device event handler. * @param sender - The sender of the event. * @param serialNumber - The serial number of the device. * @returns {Promise<void>} - A promise that resolves when the event handling is complete. */ type DeviceEventAsyncHandler = (sender: IDeviceManager, serialNumber: string) => Promise<void>; /** * Interface representing a Device event. */ interface IDeviceEvent { /** * Subscribes a handler to the event. * @param handler - The handler function to subscribe to the event. * @returns {IEventSubscription} - The subscription object, which can be used to cancel the subscription. */ subscribe(handler: DeviceEventHandler): IEventSubscription; /** * Subscribes an asynchronous handler to the event. * @param handler - The asynchronous handler function to subscribe to the event. * @returns {IEventSubscription} - The subscription object, which can be used to cancel the subscription. */ subscribeAsync(handler: DeviceEventAsyncHandler): IEventSubscription; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Interface that provides the methods that may be used to open a * device and start/stop monitoring device connection/disconnection * events. */ interface IDeviceManager { /** * Retrieves an interface to a specific device identified by its * serial number. * @param {string} serialNumber - The serial number of the device. * @returns {Promise<IDevice>} - A promise that resolves to an * interface for the Device. */ openDevice(serialNumber: string): Promise<IDevice>; /** * Starts monitoring for device connection and disconnection events. * @returns {Promise<boolean>} - A promise that resolves to True if * device monitoring was started successfully, otherwise false. */ startMonitoring(): Promise<boolean>; /** * Stops monitoring for device connection and disconnection events. * @returns {Promise<boolean>} - A promise that resulves to True if * device monitoring was stopped successfully, otherwise false. */ stopMonitoring(): Promise<boolean>; /** * Event that notifies subscribers when a Device has been connected. */ get deviceConnectedEvent(): IDeviceEvent; /** * Event that notifies subscribers when a Device has been disconnected. */ get deviceDisconnectedEvent(): IDeviceEvent; } /** * Copyright (c) 2025 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Class representing a device event. */ declare class DeviceEvent implements IDeviceEvent { private readonly _Target; /** * Creates a new instance of a Device event. */ constructor(); /** * Dispatches the event to all subscribed handlers. * @param sender - The sender of the event. * @param serialNumber - The serial number of the device. * @returns {boolean} - Returns true after the event has been dispatched. */ dispatch(sender: IDeviceManager, serialNumber: string): boolean; /** * Subscribes a handler to the event. * @param handler - The handler function to subscribe to the event. * @returns {IEventSubscription} - The subscription object, which can be used to cancel the subscription. */ subscribe(handler: DeviceEventHandler): IEventSubscription; /** * Subscribes an asynchronous handler to the event. * @param handler - The asynchronous handler function to subscribe to the event. * @returns {IEventSubscription} - The subscription object, which can be used to cancel the subscription. */ subscribeAsync(handler: DeviceEventAsyncHandler): IEventSubscription; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Type representing a FrontPanel event handler. * @param sender - The sender of the event. */ type FrontPanelEventHandler = (sender: IFrontPanel) => void; /** * Type representing an asynchronous FrontPanel event handler. * @param sender - The sender of the event. * @returns {Promise<void>} - A promise that resolves when the event handling is complete. */ type FrontPanelEventAsyncHandler = (sender: IFrontPanel) => Promise<void>; /** * Interface representing a FrontPanel event. */ interface IFrontPanelEvent { /** * Subscribes a handler to the event. * @param handler - The handler function to subscribe to the event. * @returns {IEventSubscription} - The subscription object, which can be used to cancel the subscription. */ subscribe(handler: FrontPanelEventHandler): IEventSubscription; /** * Subscribes an asynchronous handler to the event. * @param handler - The asynchronous handler function to subscribe to the event. * @returns {IEventSubscription} - The subscription object, which can be used to cancel the subscription. */ subscribeAsync(handler: FrontPanelEventAsyncHandler): IEventSubscription; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Class representing a FrontPanel event. */ declare class FrontPanelEvent implements IFrontPanelEvent { private readonly _Target; /** * Creates a new instance of a FrontPanel event. */ constructor(); /** * Dispatches the event to all subscribed handlers. * @param sender - The sender of the event. * @returns {boolean} - Returns true after the event has been dispatched. */ dispatch(sender: IFrontPanel): boolean; /** * Subscribes a handler to the event. * @param handler - The handler function to subscribe to the event. * @returns {IEventSubscription} - The subscription object, which can be used to cancel the subscription. */ subscribe(handler: FrontPanelEventHandler): IEventSubscription; /** * Subscribes an asynchronous handler to the event. * @param handler - The asynchronous handler function to subscribe to the event. * @returns {IEventSubscription} - The subscription object, which can be used to cancel the subscription. */ subscribeAsync(handler: FrontPanelEventAsyncHandler): IEventSubscription; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Interface representing an object that provides FrontPanel events used * to monitor updates to WireOuts and TriggerOuts. */ interface IFrontPanelEventSource { /** * Event that notifies subscribers when WireOut values change. */ get wireOutValuesChangedEvent(): IFrontPanelEvent; /** * Event that notifies subscribers when TriggerOut values change. */ get triggerOutValuesChangedEvent(): IFrontPanelEvent; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Class representing a timer that periodically updates WireOuts and TriggerOuts and dispatches * events to notify subscribers of changes. */ declare class FrontPanelPeriodicUpdateTimer implements IFrontPanelEventSource { /** * Event that is dispatched when WireOut values change. */ private readonly _Device; /** * Event that notifies subscribers when WireOut values change. */ private readonly _WireOutValuesChangedEvent; /** * Event that notifies subscribers when TriggerOut values change. */ private readonly _TriggerOutValuesChangedEvent; /** * Reference to the update timer loop used to identify when the timer * loop has started and when it has exited. */ private _UpdateTimer; /** * The period in milliseconds between updates. */ private _UpdatePeriodMilliseconds; /** * Flag indicating whether the timer loop is currently running. */ private _IsRunning; /** * Flag indicating that the timer loop should exit on the next iteration. */ private _IsStopPending; /** * Function that cancels the timeout used to wait for the next update period. */ private _CancelTimeout?; /** * Event that notifies subscribers when WireOut values change. */ get wireOutValuesChangedEvent(): IFrontPanelEvent; /** * Event that notifies subscribers when TriggerOut values change. */ get triggerOutValuesChangedEvent(): IFrontPanelEvent; /** * Creates a new instance of the FrontPanelPeriodicUpdateTimer. * @param device - The interface to the FrontPanel device that is the source of WireOuts and TriggerOuts. * @param periodMilliseconds - The period in milliseconds between updates. */ constructor(device: IFrontPanel, periodMilliseconds: number); /** * Starts the update timer loop if it is not already running. * @returns true if the timer loop was successfully started; false if the timer loop was already started. */ start(): Promise<boolean>; /** * Stops the update timer loop and returns a promise that resolves when the loop has exited. * @returns A promise that resolves when the timer loop has exited. */ stop(): Promise<void>; /** * The main loop for the update timer. It periodically updates WireOuts and TriggerOuts, and * dispatches the events. * @returns A promise that resolves when the timer loop has exited. */ private updateTimerLoop; /** * Updates the WireOuts and dispatches the WireOutValuesChangedEvent. */ private updateWireOuts; /** * Updates the TriggerOuts and dispatches the TriggerOutValuesChangedEvent. */ private updateTriggerOuts; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Type representing a task that can be posted to a work queue. * A task is defined as a function that returns a promise which resolves to void. */ type Task = () => Promise<void>; /** * Class representing a work queue used to execute asynchronous tasks sequentially in the order they are queued. */ declare class WorkQueue { private _Queue; /** * Creates a new instance of WorkQueue. */ constructor(); /** * Posts an asynchronous task to the work queue. The task will be executed after all previously queued tasks have completed. * @param task - The task to post to the queue. * @returns {Promise<void>} - A promise that resolves when the task that was posted to the queue is complete. */ post(task: Task): Promise<void>; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Represents a range of addresses with a minimum and maximum address value. */ type AddressRange = { maximum: number; minimum: number; }; /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Address range for WireIn endpoints. */ declare const WIREIN_ADDRESS_RANGE: AddressRange; /** * Address range for WireOut endpoints. */ declare const WIREOUT_ADDRESS_RANGE: AddressRange; /** * Address range for TriggerIn endpoints. */ declare const TRIGGERIN_ADDRESS_RANGE: AddressRange; /** * Address range for TriggerOut endpoints. */ declare const TRIGGEROUT_ADDRESS_RANGE: AddressRange; /** * Address range for PipeIn endpoints. */ declare const PIPEIN_ADDRESS_RANGE: AddressRange; /** * Address range for PipeOut endpoints */ declare const PIPEOUT_ADDRESS_RANGE: AddressRange; /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ declare global { interface Window { FrontPanelAPI: { /** * The Device Manager object. */ deviceManager: IDeviceManager; }; } } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Type representing the address of a data element. */ type ElementAddress = number; /** * Type representing the value of a data element. */ type ElementValue = number; /** * Type representing the mask for a data element. */ type ElementMask = number; /** * Class representing a block of data elements that mimic FrontPanel endpoints to allow * testing using a web browser. */ declare class MockDataBlock { private readonly _BaseAddress; private readonly _Mask; private readonly _Values; /** * Gets the base address of the data block. */ get baseAddress(): ElementAddress; /** * Gets the number of data elements in the block. */ get count(): number; /** * Gets the mask for the data elements in the block. */ get mask(): ElementMask; /** * Creates a new instance of MockDataBlock. * @param baseAddress - The address of the first data element in the block. * @param data - The array of data elements that make up the block. * @param width - The width of the data elements, measured in bits. */ constructor(baseAddress: ElementAddress, data: ElementValue[], width: number); /** * Gets the value of a specific data element. * @param address - The address of the element. * @returns {Promise<TData | null>} - A promise that resolves to the value of the element, or null if the address is out of range. */ getValue(address: ElementAddress): ElementValue | null; /** * Sets the value of a specific data element. * @param address - The address of the data element. * @param value - The value to set. * @param mask - The mask to use when setting the value. * @returns {Promise<boolean>} - A promise that resolves to true if the value was set successfully, or false otherwise. */ setValue(address: ElementAddress, value: ElementValue, mask: ElementMask): boolean; /** * Creates a new instance of MockDataBlock using a range of addresses. * @param addressRange - The range of addresses of data elements to associate with the block. * @param width - The width of the data elements, measured in bits. * @returns {MockDataBlock} - The new instance of MockDataBlock. */ static FromAddressRange(addressRange: AddressRange, width: number): MockDataBlock; } /** * Copyright (c) 2024 Opal Kelly Incorporated * * This source code is licensed under the FrontPanel license. * See the LICENSE file found in the root directory of this project. */ /** * Class representing a mock implementation of the IFrontPanel interface used for testing. */ declare class MockFrontPanel implements IFrontPanel { /** * Address range for WireIn endpoints. */ static readonly WIREIN_ADDRESS_RANGE: AddressRange; /** * Address range for WireOut endpoints. */ static readonly WIREOUT_ADDRESS_RANGE: AddressRange; /** * Address range for TriggerIn endpoints. */ static readonly TRIGGERIN_ADDRESS_RANGE: AddressRange; /** * Address range for TriggerOut endpoints. */ static readonly TRIGGEROUT_ADDRESS_RANGE: AddressRange; /** * Address range for PipeIn endpoints. */ static readonly PIPEIN_ADDRESS_RANGE: AddressRange; /** * Address range for PipeOut endpoints */ static readonly PIPEOUT_ADDRESS_RANGE: AddressRange; /** * Address range for Register endpoints */ static readonly REGISTER_ADDRESS_RANGE: AddressRange; private readonly _WireInBlock; private readonly _WireOutBlock; private readonly _TriggerOutVectors; private readonly _RegisterBlock; private readonly _HostInterfaceInfo; /** * The WireIn data block */ get WireInBlock(): MockDataBlock; /** * The WireOut data block */ get WireOutBlock(): MockDataBlock; /** * The TriggerOut data block */ get TriggerOutBlock(): MockDataBlock; /** * The Register data block */ get RegisterBlock(): MockDataBlock; get hostInterfaceInfo(): FrontPanelHostInfo; /** * * @param wireWidth - The width of the mock WireIn and WireOut endpoints, measured in bits. * @param triggerVectorWidth - The width of the mock TriggerOut vectors, measured in bits. */ constructor(wireWidth: WireWidth, triggerVectorWidth: TriggerVectorWidth); /** * Gets the value of the mock WireIn endpoint at the specified address. * @param address - The address of the WireIn endpoint. * @returns {WireValue} - The value of the mock WireIn endpoint. */ getWireInValue(address: WireAddress): WireValue; /** * Sets the value of the mock WireIn endpoint at the specified address. * @param address - The address of the mock WireIn endpoint. * @param value - The value to set. * @param mask - The mask to apply to the value. */ setWireInValue(address: WireAddress, value: WireValue, mask: WireMask): void; /** * Updates all mock WireIn endpoints. * @returns {Promise<void>} - A promise that resolves when all mock WireIn endpoints have been updated. */ updateWireIns(): Promise<void>; /** * Gets the value of the mock WireOut endpoint at the specified address. * @param address - The address of the wire out. * @returns {WireValue} - The value of the wire out. */ getWireOutValue(address: WireAddress): WireValue; /** * Updates all mock WireOut endpoints. * @returns {Promise<void>} - A promise that resolves when all mock WireOut endpoints have been updated. */ updateWireOuts(): Promise<void>; /** * Activates the mock TriggerIn endpoint at the specified address and bit. * @param address - The address of the mock TriggerIn vector. * @param bit - The bit to activate. * @returns {Promise<void>} - A promise that resolves when the mock TriggerIn endpoint has been activated. */ activateTriggerIn(address: TriggerVectorAddress, bit: number): Promise<void>; /** * Gets the mock TriggerOut vector at the specified address. * @param address - The address of the mock TriggerOut vector. * @returns {TriggerVector} - The mock TriggerOut vector. */ getTriggerOutVector(address: TriggerVectorAddress): TriggerVector; /** * Checks if the mock TriggerOut endpoint at the specified address is active by applying the mask. * @param address - The address of the mock TriggerOut vector. * @param mask - The mask to apply to the mock TriggerOut vector. * @returns {boolean} - True if the TriggerOut endpoint is active, or false otherwise. */ isTriggered(address: TriggerVectorAddress, mask: TriggerVectorMask): boolean; /** * Updates all mock TriggerOut vectors. * @returns {Promise<void>} - A promise that resolves when all mock TriggerOut vectors have been updated. */ updateTriggerOuts(): Promise<void>; /** * Writes data to the PipeIn at the specified address. * @param address - The address of the PipeIn endpoint. * @param length - The length of the data to write in bytes. * @param data - The buffer containing the data to write. * @returns {Promise<ByteCount>} - A promise that resolves when the data has been written * indicating the number of bytes that were successfully written. */ writeToPipeIn(_address: PipeAddress, _length: ByteCount, _data: ArrayBuffer): Promise<ByteCount>; /** * Writes data to the Block Throttle PipeIn at the specified address. * @param address - The address of the PipeIn endpoint. * @param blockSize - The size of the blocks to write in bytes. * @param length - The length of the data to write in bytes. * @param data - The buffer containing the data to write. * @returns {Promise<ByteCount>} - A promise that resolves when the data has been written * indicating the number of bytes that were successfully written. */ writeToBlockPipeIn(_address: PipeAddress, _blockSize: ByteCount, _length: ByteCount, _data: ArrayBuffer): Promise<ByteCount>; /** * Reads data from the PipeOut at the specified address. * @param address - The address of the PipeOut endpoint. * @param length - The length of the data to read in bytes. * @param buffer - The buffer to store the data that is read. * @returns {Promise<ByteCount>} - A promise that resolves when the data has been read * indicating the number of bytes that were successfully read. */ readFromPipeOut(_address: PipeAddress, _length: ByteCount, _buffer: ArrayBuffer): Promise<ByteCount>; /** * Reads data from the Block Throttle PipeOut at the specified address. * @param address - The address of the PipeOut endpoint. * @param blockSize - The size of the blocks to read in bytes. * @param length - The length of the data to read in bytes. * @param buffer - The buffer to store the data that is read. * @returns {Promise<ByteCount>} - A promise that resolves when the data has been read * indicating the number of bytes that were successfully read. */ readFromBlockPipeOut(_address: PipeAddress, _blockSize: ByteCount, _length: ByteCount, _buffer: ArrayBuffer): Promise<ByteCount>; /** * Reads the value of the mock Register at the specified address. * @param address - The address of the mock Register. * @returns {Promise<RegisterData>} - A promise that resolves to the data of the mock Register. */ readRegister(address: RegisterAddress): Promise<RegisterData>; /** * Reads the data of the Registers at the specified addresses and stores the data in the * corresponding array element. * @param registers - The array containing address and data pairs for each register. * @returns {Promise<void>} - A promise that resolves when all the registers have * been read. */ readRegisters(_registers: Array<{ address: RegisterAddress; data: RegisterData; }>): Promise<void>; /** * Writes a value to the mock Register at the specified address. * @param address - The address of the mock Register. * @param value - The value to write. * @returns {Promise<void>} - A promise that resolves when the value has been written. */ writeRegister(address: RegisterAddress, value: RegisterData): Promise<void>; /** * Writes data to each of the Registers at the specified addresses. * @param registers - The array containing address and data pairs for each register. * @returns {Promise<void>} - A promise that resolves when the register values have been written. */ writeRegisters(_registers: Array<{ address: RegisterAddress; data: RegisterData; }>): Promise<void>; } export { type AddressRange, type BitCount, type ByteCount, type DataProgressCallback, DeviceEvent, type DeviceEventAsyncHandler, type DeviceEventHandler, DeviceInterfaceType, type DeviceUsbInterfaceInfo, type EndpointAddress, type EndpointBitAddress, FrontPanelEvent, type FrontPanelEventAsyncHandler, type FrontPanelEventHandler, type FrontPanelHostInfo, FrontPanelPeriodicUpdateTimer, type IDevice, type IDeviceEvent, type IDeviceFPGA, type IDeviceInfo, type IDeviceManager, type IEventSubscription, type IFrontPanel, type IFrontPanelEvent, type IFrontPanelEventSource, MockFrontPanel, PIPEIN_ADDRESS_RANGE, PIPEOUT_ADDRESS_RANGE, type PipeAddress, type PipeWidth, type RegisterAddress, type RegisterAddressWidth, type RegisterData, type RegisterDataWidth, TRIGGERIN_ADDRESS_RANGE, TRIGGEROUT_ADDRESS_RANGE, type Task, type TriggerAddress, type TriggerState, type TriggerVector, type TriggerVectorAddress, type TriggerVectorMask, type TriggerVectorWidth, UsbSpeedDesignation, WIREIN_ADDRESS_RANGE, WIREOUT_ADDRESS_RANGE, type WireAddress, type WireMask, type WireValue, type WireWidth, WorkQueue };