CTRE_Phoenix  5.19.4
VictorSPX.h
1 #pragma once
2 #if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
3 #pragma warning (push)
4 #pragma warning (disable : 4250)
5 #endif
6 
7 #include "ctre/phoenix/motorcontrol/can/BaseMotorController.h"
8 #include "ctre/phoenix/CustomParamConfiguration.h"
9 
10 namespace ctre {
11 namespace phoenix {
12 namespace motorcontrol{
13 namespace can {
14 
23 
25  selectedFeedbackSensor(RemoteFeedbackDevice::None)
26  {
27  }
28 
32  std::string toString() {
33  return toString("");
34  }
35 
41  std::string toString(std::string prependString) {
42 
43  std::string retstr = prependString + ".selectedFeedbackSensor = " + FeedbackDeviceRoutines::toString(selectedFeedbackSensor) + ";\n";
44  retstr += BasePIDSetConfiguration::toString(prependString);
45  return retstr;
46  }
47 };
48 
53  private:
54  static VictorSPXPIDSetConfiguration _default;
55  public:
62  static bool SelectedFeedbackSensorDifferent (const VictorSPXPIDSetConfiguration & settings) { return (!(settings.selectedFeedbackSensor == _default.selectedFeedbackSensor)); }
63  static bool SelectedFeedbackCoefficientDifferent (const VictorSPXPIDSetConfiguration & settings) { return (!(settings.selectedFeedbackCoefficient == _default.selectedFeedbackCoefficient)); }
65 };
66 
127 
129  forwardLimitSwitchSource(RemoteLimitSwitchSource_Deactivated),
130  reverseLimitSwitchSource(RemoteLimitSwitchSource_Deactivated),
131  forwardLimitSwitchDeviceID(0),
132  reverseLimitSwitchDeviceID(0),
133  forwardLimitSwitchNormal(LimitSwitchNormal_NormallyOpen),
134  reverseLimitSwitchNormal(LimitSwitchNormal_NormallyOpen),
135  sum0Term (RemoteFeedbackDevice::None),
136  sum1Term (RemoteFeedbackDevice::None),
137  diff0Term(RemoteFeedbackDevice::None),
138  diff1Term(RemoteFeedbackDevice::None)
139  {
140  }
141 
145  std::string toString() {
146  return toString("");
147  }
148 
154  std::string toString(std::string prependString) {
155  std::string retstr = primaryPID.toString(prependString + ".primaryPID");
156  retstr += auxiliaryPID.toString(prependString + ".auxiliaryPID");
157  retstr += prependString + ".forwardLimitSwitchSource = " + LimitSwitchRoutines::toString(forwardLimitSwitchSource) + ";\n";
158  retstr += prependString + ".reverseLimitSwitchSource = " + LimitSwitchRoutines::toString(reverseLimitSwitchSource) + ";\n";
159  retstr += prependString + ".forwardLimitSwitchDeviceID = " + std::to_string(forwardLimitSwitchDeviceID) + ";\n";
160  retstr += prependString + ".reverseLimitSwitchDeviceID = " + std::to_string(reverseLimitSwitchDeviceID) + ";\n";
161  retstr += prependString + ".forwardLimitSwitchNormal = " + LimitSwitchRoutines::toString(forwardLimitSwitchNormal) + ";\n";
162  retstr += prependString + ".reverseLimitSwitchNormal = " + LimitSwitchRoutines::toString(reverseLimitSwitchNormal) + ";\n";
163  retstr += prependString + ".sum0Term = " + FeedbackDeviceRoutines::toString(sum0Term) + ";\n";
164  retstr += prependString + ".sum1Term = " + FeedbackDeviceRoutines::toString(sum1Term) + ";\n";
165  retstr += prependString + ".diff0Term = " + FeedbackDeviceRoutines::toString(diff0Term) + ";\n";
166  retstr += prependString + ".diff1Term = " + FeedbackDeviceRoutines::toString(diff1Term) + ";\n";
167  retstr += BaseMotorControllerConfiguration::toString(prependString);
168 
169  return retstr;
170  }
171 };
172 
177  private:
178  static struct VictorSPXConfiguration _default;
179  public:
186  static bool ForwardLimitSwitchSourceDifferent (const VictorSPXConfiguration & settings) { return (!(settings.forwardLimitSwitchSource == _default.forwardLimitSwitchSource)) || !settings.enableOptimizations; }
187  static bool ReverseLimitSwitchSourceDifferent (const VictorSPXConfiguration & settings) { return (!(settings.reverseLimitSwitchSource == _default.reverseLimitSwitchSource)) || !settings.enableOptimizations; }
188  static bool ForwardLimitSwitchDeviceIDDifferent (const VictorSPXConfiguration & settings) { return (!(settings.forwardLimitSwitchDeviceID == _default.forwardLimitSwitchDeviceID)) || !settings.enableOptimizations; }
189  static bool ReverseLimitSwitchDeviceIDDifferent (const VictorSPXConfiguration & settings) { return (!(settings.reverseLimitSwitchDeviceID == _default.reverseLimitSwitchDeviceID)) || !settings.enableOptimizations; }
190  static bool ForwardLimitSwitchNormalDifferent (const VictorSPXConfiguration & settings) { return (!(settings.forwardLimitSwitchNormal == _default.forwardLimitSwitchNormal)) || !settings.enableOptimizations; }
191  static bool ReverseLimitSwitchNormalDifferent (const VictorSPXConfiguration & settings) { return (!(settings.reverseLimitSwitchNormal == _default.reverseLimitSwitchNormal)) || !settings.enableOptimizations; }
192  static bool Sum0TermDifferent (const VictorSPXConfiguration & settings) { return (!(settings.sum0Term == _default.sum0Term)) || !settings.enableOptimizations; }
193  static bool Sum1TermDifferent (const VictorSPXConfiguration & settings) { return (!(settings.sum1Term == _default.sum1Term)) || !settings.enableOptimizations; }
194  static bool Diff0TermDifferent (const VictorSPXConfiguration & settings) { return (!(settings.diff0Term == _default.diff0Term)) || !settings.enableOptimizations; }
195  static bool Diff1TermDifferent (const VictorSPXConfiguration & settings) { return (!(settings.diff1Term == _default.diff1Term)) || !settings.enableOptimizations; }
196 
197  static bool ForwardLimitSwitchDifferent (const VictorSPXConfiguration & settings) {
198  return ForwardLimitSwitchDeviceIDDifferent(settings) || ForwardLimitSwitchNormalDifferent(settings) || ForwardLimitSwitchSourceDifferent(settings);
199  }
200  static bool ReverseLimitSwitchDifferent (const VictorSPXConfiguration & settings) {
201  return ReverseLimitSwitchDeviceIDDifferent(settings) || ReverseLimitSwitchNormalDifferent(settings) || ReverseLimitSwitchSourceDifferent(settings);
202  }
204 };
205 
211 
212 private:
224  ctre::phoenix::ErrorCode ConfigurePID(const VictorSPXPIDSetConfiguration &pid, int pidIdx, int timeoutMs, bool enableOptimizations);
225 public:
232  VictorSPX(int deviceNumber);
233  virtual ~VictorSPX() {
234  }
235  VictorSPX(VictorSPX const&) = delete;
236  VictorSPX& operator=(VictorSPX const&) = delete;
237 
238  // ------ Set output routines. ----------//
256  void Set(ctre::phoenix::motorcontrol::VictorSPXControlMode mode, double value);
294  void Set(ctre::phoenix::motorcontrol::VictorSPXControlMode mode, double demand0, ctre::phoenix::motorcontrol::DemandType demand1Type, double demand1);
295 
296  //------ Simulation API ----------//
301 
302  //------ All Configs ----------//
313  void GetPIDConfigs(VictorSPXPIDSetConfiguration &pid, int pidIdx = 0, int timeoutMs = 50);
325  virtual ctre::phoenix::ErrorCode ConfigAllSettings(const VictorSPXConfiguration &allConfigs, int timeoutMs = 50);
335  virtual void GetAllConfigs(VictorSPXConfiguration &allConfigs, int timeoutMs = 50);
336 
337  /* ----- virtual re-directs ------- */
338  virtual void Set(ctre::phoenix::motorcontrol::ControlMode mode, double value);
339  virtual void Set(ctre::phoenix::motorcontrol::ControlMode mode, double demand0, ctre::phoenix::motorcontrol::DemandType demand1Type, double demand1);
340 
341 };// class VictorSPX
342 } // namespace can
343 } // namespace motorcontrol
344 } // namespace phoenix
345 } // namespace ctre
346 
347 #if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
348 #pragma warning (pop)
349 #endif
double selectedFeedbackCoefficient
Definition: BaseMotorController.h:53
bool enableOptimizations
Definition: CustomParamConfiguration.h:22
std::string toString()
Definition: VictorSPX.h:145
int reverseLimitSwitchDeviceID
Definition: VictorSPX.h:102
static std::string toString(FeedbackDevice value)
Definition: FeedbackDevice.h:250
RemoteFeedbackDevice sum0Term
Definition: VictorSPX.h:114
VictorSPXControlMode
Definition: ControlMode.h:143
RemoteFeedbackDevice sum1Term
Definition: VictorSPX.h:118
Definition: ErrorCode.h:4
ErrorCode
Definition: ErrorCode.h:7
RemoteFeedbackDevice selectedFeedbackSensor
Definition: VictorSPX.h:22
static std::string toString(LimitSwitchSource value)
Definition: LimitSwitchType.h:109
RemoteLimitSwitchSource
Definition: LimitSwitchType.h:34
std::string toString()
Definition: VictorSPX.h:32
VictorSPXPIDSetConfiguration primaryPID
Definition: VictorSPX.h:74
LimitSwitchNormal
Definition: LimitSwitchType.h:61
std::string toString(std::string prependString)
Definition: VictorSPX.h:41
int forwardLimitSwitchDeviceID
Definition: VictorSPX.h:96
DemandType
Definition: DemandType.h:9
Definition: IMotorController.h:29
static bool SelectedFeedbackSensorDifferent(const VictorSPXPIDSetConfiguration &settings)
Definition: VictorSPX.h:62
RemoteLimitSwitchSource reverseLimitSwitchSource
Definition: VictorSPX.h:90
RemoteFeedbackDevice diff0Term
Definition: VictorSPX.h:122
VictorSPXPIDSetConfiguration auxiliaryPID
Definition: VictorSPX.h:78
Definition: BaseMotorController.h:576
Definition: VictorSPXSimCollection.h:25
ControlMode
Definition: ControlMode.h:10
LimitSwitchNormal forwardLimitSwitchNormal
Definition: VictorSPX.h:106
static bool ForwardLimitSwitchSourceDifferent(const VictorSPXConfiguration &settings)
Definition: VictorSPX.h:186
LimitSwitchNormal reverseLimitSwitchNormal
Definition: VictorSPX.h:110
std::string toString()
Definition: BaseMotorController.h:472
std::string toString()
Definition: BaseMotorController.h:63
RemoteFeedbackDevice
Definition: FeedbackDevice.h:169
RemoteFeedbackDevice diff1Term
Definition: VictorSPX.h:126
std::string toString(std::string prependString)
Definition: VictorSPX.h:154
RemoteLimitSwitchSource forwardLimitSwitchSource
Definition: VictorSPX.h:84