mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Add braces to C++ single-line loops and conditionals (NFC) (#2973)
This makes code easier to read and more consistent between C++ and Java. Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
@@ -29,17 +29,23 @@ Compressor::Compressor(int pcmID) : m_module(pcmID) {
|
||||
}
|
||||
|
||||
void Compressor::Start() {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
SetClosedLoopControl(true);
|
||||
}
|
||||
|
||||
void Compressor::Stop() {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
SetClosedLoopControl(false);
|
||||
}
|
||||
|
||||
bool Compressor::Enabled() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
if (StatusIsFatal()) {
|
||||
return false;
|
||||
}
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
@@ -53,7 +59,9 @@ bool Compressor::Enabled() const {
|
||||
}
|
||||
|
||||
bool Compressor::GetPressureSwitchValue() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
if (StatusIsFatal()) {
|
||||
return false;
|
||||
}
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
@@ -67,7 +75,9 @@ bool Compressor::GetPressureSwitchValue() const {
|
||||
}
|
||||
|
||||
double Compressor::GetCompressorCurrent() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
if (StatusIsFatal()) {
|
||||
return 0;
|
||||
}
|
||||
int32_t status = 0;
|
||||
double value;
|
||||
|
||||
@@ -81,7 +91,9 @@ double Compressor::GetCompressorCurrent() const {
|
||||
}
|
||||
|
||||
void Compressor::SetClosedLoopControl(bool on) {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
int32_t status = 0;
|
||||
|
||||
HAL_SetCompressorClosedLoopControl(m_compressorHandle, on, &status);
|
||||
@@ -92,7 +104,9 @@ void Compressor::SetClosedLoopControl(bool on) {
|
||||
}
|
||||
|
||||
bool Compressor::GetClosedLoopControl() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
if (StatusIsFatal()) {
|
||||
return false;
|
||||
}
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
@@ -106,7 +120,9 @@ bool Compressor::GetClosedLoopControl() const {
|
||||
}
|
||||
|
||||
bool Compressor::GetCompressorCurrentTooHighFault() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
if (StatusIsFatal()) {
|
||||
return false;
|
||||
}
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
@@ -120,7 +136,9 @@ bool Compressor::GetCompressorCurrentTooHighFault() const {
|
||||
}
|
||||
|
||||
bool Compressor::GetCompressorCurrentTooHighStickyFault() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
if (StatusIsFatal()) {
|
||||
return false;
|
||||
}
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
@@ -135,7 +153,9 @@ bool Compressor::GetCompressorCurrentTooHighStickyFault() const {
|
||||
}
|
||||
|
||||
bool Compressor::GetCompressorShortedStickyFault() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
if (StatusIsFatal()) {
|
||||
return false;
|
||||
}
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
@@ -149,7 +169,9 @@ bool Compressor::GetCompressorShortedStickyFault() const {
|
||||
}
|
||||
|
||||
bool Compressor::GetCompressorShortedFault() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
if (StatusIsFatal()) {
|
||||
return false;
|
||||
}
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
@@ -163,7 +185,9 @@ bool Compressor::GetCompressorShortedFault() const {
|
||||
}
|
||||
|
||||
bool Compressor::GetCompressorNotConnectedStickyFault() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
if (StatusIsFatal()) {
|
||||
return false;
|
||||
}
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
@@ -177,7 +201,9 @@ bool Compressor::GetCompressorNotConnectedStickyFault() const {
|
||||
}
|
||||
|
||||
bool Compressor::GetCompressorNotConnectedFault() const {
|
||||
if (StatusIsFatal()) return false;
|
||||
if (StatusIsFatal()) {
|
||||
return false;
|
||||
}
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
@@ -191,7 +217,9 @@ bool Compressor::GetCompressorNotConnectedFault() const {
|
||||
}
|
||||
|
||||
void Compressor::ClearAllPCMStickyFaults() {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
int32_t status = 0;
|
||||
|
||||
HAL_ClearAllPCMStickyFaults(m_module, &status);
|
||||
@@ -201,17 +229,20 @@ void Compressor::ClearAllPCMStickyFaults() {
|
||||
}
|
||||
}
|
||||
|
||||
int Compressor::GetModule() const { return m_module; }
|
||||
int Compressor::GetModule() const {
|
||||
return m_module;
|
||||
}
|
||||
|
||||
void Compressor::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Compressor");
|
||||
builder.AddBooleanProperty(
|
||||
"Enabled", [=]() { return Enabled(); },
|
||||
[=](bool value) {
|
||||
if (value)
|
||||
if (value) {
|
||||
Start();
|
||||
else
|
||||
} else {
|
||||
Stop();
|
||||
}
|
||||
});
|
||||
builder.AddBooleanProperty(
|
||||
"Pressure switch", [=]() { return GetPressureSwitchValue(); }, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user