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.configs; 008 009import com.ctre.phoenix6.StatusCode; 010import com.ctre.phoenix6.configs.jni.ConfigJNI; 011import com.ctre.phoenix6.spns.*; 012 013/** 014 * Configs related to constants used for differential control of a 015 * mechanism. 016 * <p> 017 * Includes the differential peak outputs. 018 */ 019public class DifferentialConstantsConfigs implements ParentConfiguration 020{ 021 /** 022 * Maximum differential output during duty cycle based differential 023 * control modes. 024 * 025 * <ul> 026 * <li> <b>Minimum Value:</b> 0.0 027 * <li> <b>Maximum Value:</b> 2.0 028 * <li> <b>Default Value:</b> 2 029 * <li> <b>Units:</b> fractional 030 * </ul> 031 */ 032 public double PeakDifferentialDutyCycle = 2; 033 /** 034 * Maximum differential output during voltage based differential 035 * control modes. 036 * 037 * <ul> 038 * <li> <b>Minimum Value:</b> 0.0 039 * <li> <b>Maximum Value:</b> 32 040 * <li> <b>Default Value:</b> 32 041 * <li> <b>Units:</b> V 042 * </ul> 043 */ 044 public double PeakDifferentialVoltage = 32; 045 /** 046 * Maximum differential output during torque current based 047 * differential control modes. 048 * 049 * <ul> 050 * <li> <b>Minimum Value:</b> 0.0 051 * <li> <b>Maximum Value:</b> 1600 052 * <li> <b>Default Value:</b> 1600 053 * <li> <b>Units:</b> A 054 * </ul> 055 */ 056 public double PeakDifferentialTorqueCurrent = 1600; 057 058 /** 059 * Modifies this configuration's PeakDifferentialDutyCycle parameter and returns itself for 060 * method-chaining and easier to use config API. 061 * <p> 062 * Maximum differential output during duty cycle based differential 063 * control modes. 064 * 065 * <ul> 066 * <li> <b>Minimum Value:</b> 0.0 067 * <li> <b>Maximum Value:</b> 2.0 068 * <li> <b>Default Value:</b> 2 069 * <li> <b>Units:</b> fractional 070 * </ul> 071 * 072 * @param newPeakDifferentialDutyCycle Parameter to modify 073 * @return Itself 074 */ 075 public DifferentialConstantsConfigs withPeakDifferentialDutyCycle(double newPeakDifferentialDutyCycle) 076 { 077 PeakDifferentialDutyCycle = newPeakDifferentialDutyCycle; 078 return this; 079 } 080 /** 081 * Modifies this configuration's PeakDifferentialVoltage parameter and returns itself for 082 * method-chaining and easier to use config API. 083 * <p> 084 * Maximum differential output during voltage based differential 085 * control modes. 086 * 087 * <ul> 088 * <li> <b>Minimum Value:</b> 0.0 089 * <li> <b>Maximum Value:</b> 32 090 * <li> <b>Default Value:</b> 32 091 * <li> <b>Units:</b> V 092 * </ul> 093 * 094 * @param newPeakDifferentialVoltage Parameter to modify 095 * @return Itself 096 */ 097 public DifferentialConstantsConfigs withPeakDifferentialVoltage(double newPeakDifferentialVoltage) 098 { 099 PeakDifferentialVoltage = newPeakDifferentialVoltage; 100 return this; 101 } 102 /** 103 * Modifies this configuration's PeakDifferentialTorqueCurrent parameter and returns itself for 104 * method-chaining and easier to use config API. 105 * <p> 106 * Maximum differential output during torque current based 107 * differential control modes. 108 * 109 * <ul> 110 * <li> <b>Minimum Value:</b> 0.0 111 * <li> <b>Maximum Value:</b> 1600 112 * <li> <b>Default Value:</b> 1600 113 * <li> <b>Units:</b> A 114 * </ul> 115 * 116 * @param newPeakDifferentialTorqueCurrent Parameter to modify 117 * @return Itself 118 */ 119 public DifferentialConstantsConfigs withPeakDifferentialTorqueCurrent(double newPeakDifferentialTorqueCurrent) 120 { 121 PeakDifferentialTorqueCurrent = newPeakDifferentialTorqueCurrent; 122 return this; 123 } 124 125 126 127 @Override 128 public String toString() 129 { 130 String ss = "Config Group: DifferentialConstants\n"; 131 ss += "Name: \"PeakDifferentialDutyCycle\" Value: \"" + PeakDifferentialDutyCycle + "fractional\"" + "\n"; 132 ss += "Name: \"PeakDifferentialVoltage\" Value: \"" + PeakDifferentialVoltage + "V\"" + "\n"; 133 ss += "Name: \"PeakDifferentialTorqueCurrent\" Value: \"" + PeakDifferentialTorqueCurrent + "A\"" + "\n"; 134 return ss; 135 } 136 137 /** 138 * 139 */ 140 public StatusCode deserialize(String to_deserialize) 141 { 142 PeakDifferentialDutyCycle = ConfigJNI.Deserializedouble(SpnValue.Config_PeakDiffDC.value, to_deserialize); 143 PeakDifferentialVoltage = ConfigJNI.Deserializedouble(SpnValue.Config_PeakDiffV.value, to_deserialize); 144 PeakDifferentialTorqueCurrent = ConfigJNI.Deserializedouble(SpnValue.Config_PeakDiffTorqCurr.value, to_deserialize); 145 return StatusCode.OK; 146 } 147 148 /** 149 * 150 */ 151 public String serialize() 152 { 153 String ss = ""; 154 ss += ConfigJNI.Serializedouble(SpnValue.Config_PeakDiffDC.value, PeakDifferentialDutyCycle); 155 ss += ConfigJNI.Serializedouble(SpnValue.Config_PeakDiffV.value, PeakDifferentialVoltage); 156 ss += ConfigJNI.Serializedouble(SpnValue.Config_PeakDiffTorqCurr.value, PeakDifferentialTorqueCurrent); 157 return ss; 158 } 159} 160