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.phoenixpro.controls;
008
009import com.ctre.phoenix6.StatusCode;
010import com.ctre.phoenix6.controls.jni.ControlJNI;
011import com.ctre.phoenix6.controls.jni.ControlConfigJNI;
012
013/**
014 * Applies full neutral-brake by shorting motor leads together.
015 *
016 * @deprecated Classes in the phoenixpro package will be removed in 2024.
017 *             Users should instead use classes from the phoenix6 package.
018 */
019@Deprecated(forRemoval = true)
020public class StaticBrake extends ControlRequest
021{
022    private boolean applyConfigsOnRequest;
023    
024
025    
026    /**
027     * The period at which this control will update at.
028     * This is designated in Hertz, with a minimum of 20 Hz
029     * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
030     * <p>
031     * If this field is set to 0 Hz, the control request will
032     * be sent immediately as a one-shot frame. This may be useful
033     * for advanced applications that require outputs to be
034     * synchronized with data acquisition. In this case, we
035     * recommend not exceeding 50 ms between control calls.
036     */
037    public double UpdateFreqHz = 100; // Default to 100Hz
038
039    /**
040     * The timeout when sending configs associated with this control
041     */
042    public double configTimeout = 0.1;
043
044    /**
045     * Applies full neutral-brake by shorting motor leads together.
046     *
047     * @deprecated Classes in the phoenixpro package will be removed in 2024.
048     *             Users should instead use classes from the phoenix6 package.
049     */
050    @Deprecated(forRemoval = true)
051    public StaticBrake()
052    {
053        super("StaticBrake");
054        
055    }
056
057    @Override
058    public String toString()
059    {
060        String ss = "class: StaticBrake\n";
061        
062        return ss;
063    }
064
065    @Override
066    public StatusCode sendRequest(String network, int deviceHash, boolean cancelOtherRequests)
067    {
068
069        String ss = "";
070        
071        ControlConfigJNI.JNI_RequestConfigApply(network, deviceHash, configTimeout, ss, applyConfigsOnRequest);
072        applyConfigsOnRequest = false;
073        return StatusCode.valueOf(ControlJNI.JNI_RequestControlStaticBrake(
074                network, deviceHash, UpdateFreqHz, cancelOtherRequests));
075    }
076    
077    /**
078     * Sets the period at which this control will update at.
079     * This is designated in Hertz, with a minimum of 20 Hz
080     * (every 50 ms) and a maximum of 1000 Hz (every 1 ms).
081     * <p>
082     * If this field is set to 0 Hz, the control request will
083     * be sent immediately as a one-shot frame. This may be useful
084     * for advanced applications that require outputs to be
085     * synchronized with data acquisition. In this case, we
086     * recommend not exceeding 50 ms between control calls.
087     *
088     * @param newUpdateFreqHz Parameter to modify
089     * @return Itself
090     */
091    public StaticBrake withUpdateFreqHz(double newUpdateFreqHz)
092    {
093        UpdateFreqHz = newUpdateFreqHz;
094        return this;
095    }
096    /**
097     * Forces configs to be applied the next time this is used in a setControl.
098     * <p>
099     * This is not necessary in the majority of cases, because Phoenix will make sure configs are
100     * properly set when they are not already set
101     */
102    public void forceApplyConfigs() { applyConfigsOnRequest = true; }
103}
104