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