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.configs; 008 009import com.ctre.phoenix6.StatusCode; 010import com.ctre.phoenix6.configs.jni.ConfigJNI; 011import com.ctre.phoenix6.spns.*; 012 013/** 014 * Configs that directly affect current limiting features. 015 * <p> 016 * Includes Motor Invert and various limit features. 017 * 018 * @deprecated Classes in the phoenixpro package will be removed in 2024. 019 * Users should instead use classes from the phoenix6 package. 020 */ 021@Deprecated(forRemoval = true) 022public class CurrentLimitsConfigs implements ParentConfiguration 023{ 024 /** 025 * The amount of current allowed in the motor (motoring and regen 026 * current). This is only applicable for non-torque current control 027 * modes. Note this requires the corresponding enable to be true. 028 * 029 * <ul> 030 * <li> <b>Minimum Value:</b> 0.0 031 * <li> <b>Maximum Value:</b> 800.0 032 * <li> <b>Default Value:</b> 0 033 * <li> <b>Units:</b> A 034 * </ul> 035 */ 036 public double StatorCurrentLimit = 0; 037 /** 038 * Enable motor stator current limiting. 039 * 040 * <ul> 041 * <li> <b>Default Value:</b> False 042 * </ul> 043 */ 044 public boolean StatorCurrentLimitEnable = false; 045 /** 046 * The amount of supply current allowed. This is only applicable for 047 * non-torque current control modes. Note this requires the 048 * corresponding enable to be true. Use SupplyCurrentThreshold and 049 * SupplyTimeThreshold to allow brief periods of high-current before 050 * limiting occurs. 051 * 052 * <ul> 053 * <li> <b>Minimum Value:</b> 0.0 054 * <li> <b>Maximum Value:</b> 800.0 055 * <li> <b>Default Value:</b> 0 056 * <li> <b>Units:</b> A 057 * </ul> 058 */ 059 public double SupplyCurrentLimit = 0; 060 /** 061 * Enable motor supply current limiting. 062 * 063 * <ul> 064 * <li> <b>Default Value:</b> False 065 * </ul> 066 */ 067 public boolean SupplyCurrentLimitEnable = false; 068 /** 069 * Delay supply current limiting until current exceeds this threshold 070 * for longer than SupplyTimeThreshold. This allows current draws 071 * above SupplyCurrentLimit for a fixed period of time. This has no 072 * effect if SupplyCurrentLimit is greater than this value. 073 * 074 * <ul> 075 * <li> <b>Minimum Value:</b> 0.0 076 * <li> <b>Maximum Value:</b> 511 077 * <li> <b>Default Value:</b> 0 078 * <li> <b>Units:</b> A 079 * </ul> 080 */ 081 public double SupplyCurrentThreshold = 0; 082 /** 083 * Allows unlimited current for a period of time before current 084 * limiting occurs. Current threshold is the maximum of 085 * SupplyCurrentThreshold and SupplyCurrentLimit. 086 * 087 * <ul> 088 * <li> <b>Minimum Value:</b> 0.0 089 * <li> <b>Maximum Value:</b> 1.275 090 * <li> <b>Default Value:</b> 0 091 * <li> <b>Units:</b> sec 092 * </ul> 093 */ 094 public double SupplyTimeThreshold = 0; 095 096 @Override 097 public String toString() 098 { 099 String ss = "Config Group: CurrentLimits\n"; 100 ss += "Name: \"StatorCurrentLimit\" Value: \"" + StatorCurrentLimit + "A\"" + "\n"; 101 ss += "Name: \"StatorCurrentLimitEnable\" Value: \"" + StatorCurrentLimitEnable + "\"" + "\n"; 102 ss += "Name: \"SupplyCurrentLimit\" Value: \"" + SupplyCurrentLimit + "A\"" + "\n"; 103 ss += "Name: \"SupplyCurrentLimitEnable\" Value: \"" + SupplyCurrentLimitEnable + "\"" + "\n"; 104 ss += "Name: \"SupplyCurrentThreshold\" Value: \"" + SupplyCurrentThreshold + "A\"" + "\n"; 105 ss += "Name: \"SupplyTimeThreshold\" Value: \"" + SupplyTimeThreshold + "sec\"" + "\n"; 106 return ss; 107 } 108 109 /** 110 * 111 */ 112 public StatusCode deserialize(String string) 113 { 114 StatorCurrentLimit = ConfigJNI.Deserializedouble(SpnValue.Config_StatorCurrentLimit.value, string); 115 StatorCurrentLimitEnable = ConfigJNI.Deserializeboolean(SpnValue.Config_StatorCurrLimitEn.value, string); 116 SupplyCurrentLimit = ConfigJNI.Deserializedouble(SpnValue.Config_SupplyCurrentLimit.value, string); 117 SupplyCurrentLimitEnable = ConfigJNI.Deserializeboolean(SpnValue.Config_SupplyCurrLimitEn.value, string); 118 SupplyCurrentThreshold = ConfigJNI.Deserializedouble(SpnValue.Config_SupplyCurrThres.value, string); 119 SupplyTimeThreshold = ConfigJNI.Deserializedouble(SpnValue.Config_SupplyTimeThres.value, string); 120 return StatusCode.OK; 121 } 122 123 /** 124 * 125 */ 126 public String serialize() 127 { 128 String ss = ""; 129 ss += ConfigJNI.Serializedouble(1427, StatorCurrentLimit); 130 ss += ConfigJNI.Serializeboolean(1428, StatorCurrentLimitEnable); 131 ss += ConfigJNI.Serializedouble(1429, SupplyCurrentLimit); 132 ss += ConfigJNI.Serializeboolean(1430, SupplyCurrentLimitEnable); 133 ss += ConfigJNI.Serializedouble(1505, SupplyCurrentThreshold); 134 ss += ConfigJNI.Serializedouble(1506, SupplyTimeThreshold); 135 return ss; 136 } 137} 138