/**
 * 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.
 */

import { ByteCount, DataProgressCallback } from "./CoreDataTypes";

import IFrontPanel from "./IFrontPanel";

/**
 * 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>;
}

export default IDeviceFPGA;
