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