001/*
002 * Copyright (C) Cross The Road Electronics.  All rights reserved.
003 * License information can be found in CTRE_LICENSE.txt
004 * For support and suggestions contact support@ctr-electronics.com or file
005 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
006 */
007package com.ctre.phoenix6.controls;
008
009import java.util.Map;
010
011import com.ctre.phoenix6.CANBus;
012import com.ctre.phoenix6.StatusCode;
013
014import edu.wpi.first.units.measure.*;
015
016/**
017 * Common interface implemented by all control requests.
018 */
019public interface ControlRequest {
020    StatusCode sendRequest(CANBus network, int deviceHash);
021
022    /**
023     * Sets the frequency at which this control will update.
024     * This is designated in Hertz, with a minimum of 20 Hz
025     * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
026     * Some update frequencies are not supported and will be
027     * promoted up to the next highest supported frequency.
028     * <p>
029     * If this field is set to 0 Hz, the control request will
030     * be sent immediately as a one-shot frame. This may be useful
031     * for advanced applications that require outputs to be
032     * synchronized with data acquisition. In this case, we
033     * recommend not exceeding 50 ms between control calls.
034     *
035     * @param newUpdateFreqHz Parameter to modify
036     * @return Itself
037     */
038    ControlRequest withUpdateFreqHz(double newUpdateFreqHz);
039    /**
040     * Sets the frequency at which this control will update.
041     * This is designated in Hertz, with a minimum of 20 Hz
042     * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
043     * Some update frequencies are not supported and will be
044     * promoted up to the next highest supported frequency.
045     * <p>
046     * If this field is set to 0 Hz, the control request will
047     * be sent immediately as a one-shot frame. This may be useful
048     * for advanced applications that require outputs to be
049     * synchronized with data acquisition. In this case, we
050     * recommend not exceeding 50 ms between control calls.
051     *
052     * @param newUpdateFreqHz Parameter to modify
053     * @return Itself
054     */
055    ControlRequest withUpdateFreqHz(Frequency newUpdateFreqHz);
056
057    /**
058     * Gets the name of this control request.
059     *
060     * @return Name of the control request
061     */
062    String getName();
063
064    /**
065     * Gets information about this control request.
066     *
067     * @return Map of control parameter names and corresponding applied values
068     */
069    Map<String, String> getControlInfo();
070}