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 * </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 * </code> 074 * </p> 075 */ 076 public FeedbackDevice sum1Term; 077 /** 078 * Feedback Device for Diff 0 Term 079 * Note the FeedbackDevice enum holds all possible sensor types. Consult product documentation to confirm what is available. 080 * Alternatively the product specific enum can be used instead (see below). 081 * <p> 082 * <code> 083 * configs.diff0Term = TalonSRXFeedbackDevice.QuadEncoder.toFeedbackDevice(); 084 * </code> 085 * </p> 086 */ 087 public FeedbackDevice diff0Term; 088 /** 089 * Feedback Device for Diff 1 Term 090 * Note the FeedbackDevice enum holds all possible sensor types. Consult product documentation to confirm what is available. 091 * Alternatively the product specific enum can be used instead (see below). 092 * <p> 093 * <code> 094 * configs.diff1Term = TalonSRXFeedbackDevice.QuadEncoder.toFeedbackDevice(); 095 * </code> 096 * </p> 097 */ 098 public FeedbackDevice diff1Term; 099 100 101 public BaseTalonConfiguration(FeedbackDevice defaultFeedbackDevice) { 102 primaryPID = new BaseTalonPIDSetConfiguration(defaultFeedbackDevice); 103 auxiliaryPID = new BaseTalonPIDSetConfiguration(defaultFeedbackDevice); 104 105 forwardLimitSwitchSource = LimitSwitchSource.FeedbackConnector; 106 reverseLimitSwitchSource = LimitSwitchSource.FeedbackConnector; 107 forwardLimitSwitchDeviceID = 0; 108 reverseLimitSwitchDeviceID = 0; 109 forwardLimitSwitchNormal = LimitSwitchNormal.NormallyOpen; 110 reverseLimitSwitchNormal = LimitSwitchNormal.NormallyOpen; 111 sum0Term = defaultFeedbackDevice; 112 sum1Term = defaultFeedbackDevice; 113 diff0Term = defaultFeedbackDevice; 114 diff1Term = defaultFeedbackDevice; 115 } 116 117 /** 118 * @return String representation of all the configs 119 */ 120 public String toString() { 121 return toString(""); 122 } 123 124 /** 125 * @param prependString 126 * String to prepend to all the configs 127 * @return String representation of all the configs 128 */ 129 public String toString(String prependString) { 130 131 132 String retstr = primaryPID.toString(prependString + ".primaryPID"); 133 retstr += auxiliaryPID.toString(prependString + ".auxiliaryPID"); 134 retstr += prependString + ".forwardLimitSwitchSource = " + forwardLimitSwitchSource.toString() + ";\n"; 135 retstr += prependString + ".reverseLimitSwitchSource = " + reverseLimitSwitchSource.toString() + ";\n"; 136 retstr += prependString + ".forwardLimitSwitchDeviceID = " + String.valueOf(forwardLimitSwitchDeviceID) + ";\n"; 137 retstr += prependString + ".reverseLimitSwitchDeviceID = " + String.valueOf(reverseLimitSwitchDeviceID) + ";\n"; 138 retstr += prependString + ".forwardLimitSwitchNormal = " + forwardLimitSwitchNormal.toString() + ";\n"; 139 retstr += prependString + ".reverseLimitSwitchNormal = " + reverseLimitSwitchNormal.toString() + ";\n"; 140 retstr += prependString + ".sum0Term = " + sum0Term.toString() + ";\n"; 141 retstr += prependString + ".sum1Term = " + sum1Term.toString() + ";\n"; 142 retstr += prependString + ".diff0Term = " + diff0Term.toString() + ";\n"; 143 retstr += prependString + ".diff1Term = " + diff1Term.toString() + ";\n"; 144 retstr += super.toString(prependString); 145 146 return retstr; 147 } 148 149} 150