001/* Copyright (C) Cross The Road Electronics 2024 */ 002package com.ctre.phoenix.motorcontrol.can; 003 004import com.ctre.phoenix.CustomParamConfiguration; 005import com.ctre.phoenix.motorcontrol.can.TalonSRXPIDSetConfiguration; 006import com.ctre.phoenix.motorcontrol.LimitSwitchNormal; 007import com.ctre.phoenix.motorcontrol.LimitSwitchSource; 008import com.ctre.phoenix.motorcontrol.FeedbackDevice; 009 010/** 011 * Configurables available to TalonSRX 012 */ 013public class BaseTalonConfiguration extends com.ctre.phoenix.motorcontrol.can.BaseMotorControllerConfiguration { 014 015 /** 016 * Primary PID configuration 017 */ 018 public BaseTalonPIDSetConfiguration primaryPID; 019 /** 020 * Auxiliary PID configuration 021 */ 022 public BaseTalonPIDSetConfiguration auxiliaryPID; 023 /** 024 * Forward Limit Switch Source 025 * 026 * User can choose between the feedback connector, remote Talon SRX, CANifier, or deactivate the feature 027 */ 028 public LimitSwitchSource forwardLimitSwitchSource; 029 /** 030 * Reverse Limit Switch Source 031 * 032 * User can choose between the feedback connector, remote Talon SRX, CANifier, or deactivate the feature 033 */ 034 public LimitSwitchSource reverseLimitSwitchSource; 035 /** 036 * Forward limit switch device ID 037 * 038 * Limit Switch device id isn't used unless device is a remote 039 */ 040 public int forwardLimitSwitchDeviceID; 041 /** 042 * Reverse limit switch device ID 043 * 044 * Limit Switch device id isn't used unless device is a remote 045 */ 046 public int reverseLimitSwitchDeviceID; 047 /** 048 * Forward limit switch normally open/closed 049 */ 050 public LimitSwitchNormal forwardLimitSwitchNormal; 051 /** 052 * Reverse limit switch normally open/closed 053 */ 054 public LimitSwitchNormal reverseLimitSwitchNormal; 055 /** 056 * Feedback Device for Sum 0 Term 057 * Note the FeedbackDevice enum holds all possible sensor types. Consult product documentation to confirm what is available. 058 * Alternatively the product specific enum can be used instead (see below). 059 * <p> 060 * <code> 061 * configs.sum0Term = TalonSRXFeedbackDevice.QuadEncoder.toFeedbackDevice(); 062 * configs.sum0Term = TalonFXFeedbackDevice.IntegratedSensor.toFeedbackDevice(); 063 * </code> 064 * </p> 065 */ 066 public FeedbackDevice sum0Term; 067 /** 068 * Feedback Device for Sum 1 Term 069 * Note the FeedbackDevice enum holds all possible sensor types. Consult product documentation to confirm what is available. 070 * Alternatively the product specific enum can be used instead (see below). 071 * <p> 072 * <code> 073 * configs.sum1Term = TalonSRXFeedbackDevice.QuadEncoder.toFeedbackDevice(); 074 * configs.sum1Term = TalonFXFeedbackDevice.IntegratedSensor.toFeedbackDevice(); 075 * </code> 076 * </p> 077 */ 078 public FeedbackDevice sum1Term; 079 /** 080 * Feedback Device for Diff 0 Term 081 * Note the FeedbackDevice enum holds all possible sensor types. Consult product documentation to confirm what is available. 082 * Alternatively the product specific enum can be used instead (see below). 083 * <p> 084 * <code> 085 * configs.diff0Term = TalonSRXFeedbackDevice.QuadEncoder.toFeedbackDevice(); 086 * configs.diff0Term = TalonFXFeedbackDevice.IntegratedSensor.toFeedbackDevice(); 087 * </code> 088 * </p> 089 */ 090 public FeedbackDevice diff0Term; 091 /** 092 * Feedback Device for Diff 1 Term 093 * Note the FeedbackDevice enum holds all possible sensor types. Consult product documentation to confirm what is available. 094 * Alternatively the product specific enum can be used instead (see below). 095 * <p> 096 * <code> 097 * configs.diff1Term = TalonSRXFeedbackDevice.QuadEncoder.toFeedbackDevice(); 098 * configs.diff1Term = TalonFXFeedbackDevice.IntegratedSensor.toFeedbackDevice(); 099 * </code> 100 * </p> 101 */ 102 public FeedbackDevice diff1Term; 103 104 105 public BaseTalonConfiguration(FeedbackDevice defaultFeedbackDevice) { 106 primaryPID = new BaseTalonPIDSetConfiguration(defaultFeedbackDevice); 107 auxiliaryPID = new BaseTalonPIDSetConfiguration(defaultFeedbackDevice); 108 109 forwardLimitSwitchSource = LimitSwitchSource.FeedbackConnector; 110 reverseLimitSwitchSource = LimitSwitchSource.FeedbackConnector; 111 forwardLimitSwitchDeviceID = 0; 112 reverseLimitSwitchDeviceID = 0; 113 forwardLimitSwitchNormal = LimitSwitchNormal.NormallyOpen; 114 reverseLimitSwitchNormal = LimitSwitchNormal.NormallyOpen; 115 sum0Term = defaultFeedbackDevice; 116 sum1Term = defaultFeedbackDevice; 117 diff0Term = defaultFeedbackDevice; 118 diff1Term = defaultFeedbackDevice; 119 } 120 121 /** 122 * @return String representation of all the configs 123 */ 124 public String toString() { 125 return toString(""); 126 } 127 128 /** 129 * @param prependString 130 * String to prepend to all the configs 131 * @return String representation of all the configs 132 */ 133 public String toString(String prependString) { 134 135 136 String retstr = primaryPID.toString(prependString + ".primaryPID"); 137 retstr += auxiliaryPID.toString(prependString + ".auxiliaryPID"); 138 retstr += prependString + ".forwardLimitSwitchSource = " + forwardLimitSwitchSource.toString() + ";\n"; 139 retstr += prependString + ".reverseLimitSwitchSource = " + reverseLimitSwitchSource.toString() + ";\n"; 140 retstr += prependString + ".forwardLimitSwitchDeviceID = " + String.valueOf(forwardLimitSwitchDeviceID) + ";\n"; 141 retstr += prependString + ".reverseLimitSwitchDeviceID = " + String.valueOf(reverseLimitSwitchDeviceID) + ";\n"; 142 retstr += prependString + ".forwardLimitSwitchNormal = " + forwardLimitSwitchNormal.toString() + ";\n"; 143 retstr += prependString + ".reverseLimitSwitchNormal = " + reverseLimitSwitchNormal.toString() + ";\n"; 144 retstr += prependString + ".sum0Term = " + sum0Term.toString() + ";\n"; 145 retstr += prependString + ".sum1Term = " + sum1Term.toString() + ";\n"; 146 retstr += prependString + ".diff0Term = " + diff0Term.toString() + ";\n"; 147 retstr += prependString + ".diff1Term = " + diff1Term.toString() + ";\n"; 148 retstr += super.toString(prependString); 149 150 return retstr; 151 } 152 153} 154