mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[build] Upgrade CI to clang-format 10.0 (#1961)
MacOS no longer ships 6.0, and Arch Linux's mesa GPU drivers are no longer compatible with LLVM 6.0.
This commit is contained in:
@@ -3,24 +3,29 @@ Language: Cpp
|
||||
BasedOnStyle: Google
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: false
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
@@ -29,6 +34,7 @@ BraceWrapping:
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
@@ -38,6 +44,7 @@ BraceWrapping:
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
@@ -50,6 +57,7 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: false
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
@@ -58,15 +66,25 @@ ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '^<ext/.*\.h>'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
- Regex: '^<.*'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentCaseLabels: true
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
@@ -76,32 +94,74 @@ MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Never
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PointerAlignment: Left
|
||||
RawStringFormats:
|
||||
- Language: Cpp
|
||||
Delimiters:
|
||||
- cc
|
||||
- CC
|
||||
- cpp
|
||||
- Cpp
|
||||
- CPP
|
||||
- 'c++'
|
||||
- 'C++'
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
- Language: TextProto
|
||||
Delimiters:
|
||||
- pb
|
||||
- PB
|
||||
- proto
|
||||
- PROTO
|
||||
EnclosingFunctions:
|
||||
- EqualsProto
|
||||
- EquivToProto
|
||||
- PARSE_PARTIAL_TEXT_PROTO
|
||||
- PARSE_TEST_PROTO
|
||||
- PARSE_TEXT_PROTO
|
||||
- ParseTextOrDie
|
||||
- ParseTextProtoOrDie
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
ReflowComments: true
|
||||
SortIncludes: false
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
Standard: Auto
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
...
|
||||
|
||||
62
azure-templates/clang-format.sh
Executable file
62
azure-templates/clang-format.sh
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
################################################################################
|
||||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
# See https://llvm.org/LICENSE.txt for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
################################################################################
|
||||
#
|
||||
# This script will install the llvm toolchain on the different
|
||||
# Debian and Ubuntu versions
|
||||
|
||||
set -eux
|
||||
|
||||
# read optional command line argument
|
||||
LLVM_VERSION=10
|
||||
if [ "$#" -eq 1 ]; then
|
||||
LLVM_VERSION=$1
|
||||
fi
|
||||
|
||||
DISTRO=$(lsb_release -is)
|
||||
VERSION=$(lsb_release -sr)
|
||||
DIST_VERSION="${DISTRO}_${VERSION}"
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -A LLVM_VERSION_PATTERNS
|
||||
LLVM_VERSION_PATTERNS[9]="-9"
|
||||
LLVM_VERSION_PATTERNS[10]="-10"
|
||||
LLVM_VERSION_PATTERNS[11]=""
|
||||
|
||||
if [ ! ${LLVM_VERSION_PATTERNS[$LLVM_VERSION]+_} ]; then
|
||||
echo "This script does not support LLVM version $LLVM_VERSION"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
LLVM_VERSION_STRING=${LLVM_VERSION_PATTERNS[$LLVM_VERSION]}
|
||||
|
||||
# find the right repository name for the distro and version
|
||||
case "$DIST_VERSION" in
|
||||
Debian_9* ) REPO_NAME="deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch$LLVM_VERSION_STRING main" ;;
|
||||
Debian_10* ) REPO_NAME="deb http://apt.llvm.org/buster/ llvm-toolchain-buster$LLVM_VERSION_STRING main" ;;
|
||||
Debian_unstable ) REPO_NAME="deb http://apt.llvm.org/unstable/ llvm-toolchain$LLVM_VERSION_STRING main" ;;
|
||||
Debian_testing ) REPO_NAME="deb http://apt.llvm.org/unstable/ llvm-toolchain$LLVM_VERSION_STRING main" ;;
|
||||
Ubuntu_16.04 ) REPO_NAME="deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial$LLVM_VERSION_STRING main" ;;
|
||||
Ubuntu_18.04 ) REPO_NAME="deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic$LLVM_VERSION_STRING main" ;;
|
||||
Ubuntu_18.10 ) REPO_NAME="deb http://apt.llvm.org/cosmic/ llvm-toolchain-cosmic$LLVM_VERSION_STRING main" ;;
|
||||
Ubuntu_19.04 ) REPO_NAME="deb http://apt.llvm.org/disco/ llvm-toolchain-disco$LLVM_VERSION_STRING main" ;;
|
||||
Ubuntu_19.10 ) REPO_NAME="deb http://apt.llvm.org/eoan/ llvm-toolchain-eoan$LLVM_VERSION_STRING main" ;;
|
||||
Ubuntu_20.04 ) REPO_NAME="deb http://apt.llvm.org/focal/ llvm-toolchain-focal$LLVM_VERSION_STRING main" ;;
|
||||
* )
|
||||
echo "Distribution '$DISTRO' in version '$VERSION' is not supported by this script (${DIST_VERSION})."
|
||||
exit 2
|
||||
esac
|
||||
|
||||
|
||||
# install everything
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
|
||||
add-apt-repository "${REPO_NAME}"
|
||||
apt-get update
|
||||
apt-get install -y clang-format-$LLVM_VERSION
|
||||
@@ -3,7 +3,7 @@
|
||||
parameters:
|
||||
jobName: ''
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
vmImage: 'Ubuntu 18.04'
|
||||
|
||||
jobs:
|
||||
- job: Styleguide
|
||||
@@ -18,12 +18,16 @@ jobs:
|
||||
|
||||
steps:
|
||||
- script: |
|
||||
sudo apt-get update -q
|
||||
sudo apt-get install gnupg lsb-release software-properties-common -y
|
||||
chmod +x azure-templates/clang-format.sh
|
||||
sudo ./azure-templates/clang-format.sh 10
|
||||
sudo pip3 install wpiformat
|
||||
displayName: 'Install wpiformat'
|
||||
|
||||
- script: |
|
||||
git checkout -b master
|
||||
wpiformat -clang 6.0
|
||||
wpiformat -clang 10
|
||||
displayName: 'Run wpiformat'
|
||||
|
||||
- script: |
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -62,21 +62,21 @@ int ConfigurableSourceImpl::CreateProperty(const wpi::Twine& name,
|
||||
int maximum, int step,
|
||||
int defaultValue, int value) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
int ndx = CreateOrUpdateProperty(name,
|
||||
[=] {
|
||||
return std::make_unique<PropertyImpl>(
|
||||
name, kind, minimum, maximum, step,
|
||||
defaultValue, value);
|
||||
},
|
||||
[&](PropertyImpl& prop) {
|
||||
// update all but value
|
||||
prop.propKind = kind;
|
||||
prop.minimum = minimum;
|
||||
prop.maximum = maximum;
|
||||
prop.step = step;
|
||||
prop.defaultValue = defaultValue;
|
||||
value = prop.value;
|
||||
});
|
||||
int ndx = CreateOrUpdateProperty(
|
||||
name,
|
||||
[=] {
|
||||
return std::make_unique<PropertyImpl>(name, kind, minimum, maximum,
|
||||
step, defaultValue, value);
|
||||
},
|
||||
[&](PropertyImpl& prop) {
|
||||
// update all but value
|
||||
prop.propKind = kind;
|
||||
prop.minimum = minimum;
|
||||
prop.maximum = maximum;
|
||||
prop.step = step;
|
||||
prop.defaultValue = defaultValue;
|
||||
value = prop.value;
|
||||
});
|
||||
m_notifier.NotifySourceProperty(*this, CS_SOURCE_PROPERTY_CREATED, name, ndx,
|
||||
kind, value, wpi::Twine{});
|
||||
return ndx;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -14,12 +14,13 @@
|
||||
|
||||
int main() {
|
||||
auto inst = nt::GetDefaultInstance();
|
||||
nt::AddLogger(inst,
|
||||
[](const nt::LogMessage& msg) {
|
||||
std::fputs(msg.message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
},
|
||||
0, UINT_MAX);
|
||||
nt::AddLogger(
|
||||
inst,
|
||||
[](const nt::LogMessage& msg) {
|
||||
std::fputs(msg.message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
},
|
||||
0, UINT_MAX);
|
||||
nt::StartClient(inst, "127.0.0.1", 10000);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -34,12 +34,13 @@ void callback1(const nt::RpcAnswer& answer) {
|
||||
|
||||
int main() {
|
||||
auto inst = nt::GetDefaultInstance();
|
||||
nt::AddLogger(inst,
|
||||
[](const nt::LogMessage& msg) {
|
||||
std::fputs(msg.message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
},
|
||||
0, UINT_MAX);
|
||||
nt::AddLogger(
|
||||
inst,
|
||||
[](const nt::LogMessage& msg) {
|
||||
std::fputs(msg.message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
},
|
||||
0, UINT_MAX);
|
||||
|
||||
nt::StartServer(inst, "rpc_local.ini", "", 10000);
|
||||
auto entry = nt::GetEntry(inst, "func1");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -14,12 +14,13 @@
|
||||
|
||||
int main() {
|
||||
auto inst = nt::GetDefaultInstance();
|
||||
nt::AddLogger(inst,
|
||||
[](const nt::LogMessage& msg) {
|
||||
std::fputs(msg.message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
},
|
||||
0, UINT_MAX);
|
||||
nt::AddLogger(
|
||||
inst,
|
||||
[](const nt::LogMessage& msg) {
|
||||
std::fputs(msg.message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
},
|
||||
0, UINT_MAX);
|
||||
nt::StartServer(inst, "persistent.ini", "", 10000);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -135,18 +135,18 @@ void NetworkConnection::ReadThreadMain() {
|
||||
WireDecoder decoder(is, m_proto_rev, m_logger);
|
||||
|
||||
set_state(kHandshake);
|
||||
if (!m_handshake(*this,
|
||||
[&] {
|
||||
decoder.set_proto_rev(m_proto_rev);
|
||||
auto msg = Message::Read(decoder, m_get_entry_type);
|
||||
if (!msg && decoder.error())
|
||||
DEBUG0(
|
||||
"error reading in handshake: " << decoder.error());
|
||||
return msg;
|
||||
},
|
||||
[&](wpi::ArrayRef<std::shared_ptr<Message>> msgs) {
|
||||
m_outgoing.emplace(msgs);
|
||||
})) {
|
||||
if (!m_handshake(
|
||||
*this,
|
||||
[&] {
|
||||
decoder.set_proto_rev(m_proto_rev);
|
||||
auto msg = Message::Read(decoder, m_get_entry_type);
|
||||
if (!msg && decoder.error())
|
||||
DEBUG0("error reading in handshake: " << decoder.error());
|
||||
return msg;
|
||||
},
|
||||
[&](wpi::ArrayRef<std::shared_ptr<Message>> msgs) {
|
||||
m_outgoing.emplace(msgs);
|
||||
})) {
|
||||
set_state(kDead);
|
||||
m_active = false;
|
||||
goto done;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -1053,14 +1053,15 @@ unsigned int Storage::CallRpc(unsigned int local_id, StringRef params) {
|
||||
conn_info.last_update = wpi::Now();
|
||||
conn_info.protocol_version = 0x0300;
|
||||
unsigned int call_uid = msg->seq_num_uid();
|
||||
m_rpc_server.ProcessRpc(local_id, call_uid, name, msg->str(), conn_info,
|
||||
[=](StringRef result) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_rpc_results.insert(std::make_pair(
|
||||
RpcIdPair{local_id, call_uid}, result));
|
||||
m_rpc_results_cond.notify_all();
|
||||
},
|
||||
rpc_uid);
|
||||
m_rpc_server.ProcessRpc(
|
||||
local_id, call_uid, name, msg->str(), conn_info,
|
||||
[=](StringRef result) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_rpc_results.insert(
|
||||
std::make_pair(RpcIdPair{local_id, call_uid}, result));
|
||||
m_rpc_results_cond.notify_all();
|
||||
},
|
||||
rpc_uid);
|
||||
} else {
|
||||
auto dispatcher = m_dispatcher;
|
||||
lock.unlock();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -233,13 +233,13 @@ NT_EntryListener NetworkTable::AddEntryListener(const Twine& key,
|
||||
unsigned int flags) const {
|
||||
size_t prefix_len = m_path.size() + 1;
|
||||
auto entry = GetEntry(key);
|
||||
return nt::AddEntryListener(entry.GetHandle(),
|
||||
[=](const EntryNotification& event) {
|
||||
listener(const_cast<NetworkTable*>(this),
|
||||
event.name.substr(prefix_len), entry,
|
||||
event.value, event.flags);
|
||||
},
|
||||
flags);
|
||||
return nt::AddEntryListener(
|
||||
entry.GetHandle(),
|
||||
[=](const EntryNotification& event) {
|
||||
listener(const_cast<NetworkTable*>(this), event.name.substr(prefix_len),
|
||||
entry, event.value, event.flags);
|
||||
},
|
||||
flags);
|
||||
}
|
||||
|
||||
void NetworkTable::RemoveEntryListener(NT_EntryListener listener) const {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -260,27 +260,29 @@ NT_EntryListener NT_AddEntryListener(NT_Inst inst, const char* prefix,
|
||||
size_t prefix_len, void* data,
|
||||
NT_EntryListenerCallback callback,
|
||||
unsigned int flags) {
|
||||
return nt::AddEntryListener(inst, StringRef(prefix, prefix_len),
|
||||
[=](const EntryNotification& event) {
|
||||
NT_EntryNotification c_event;
|
||||
ConvertToC(event, &c_event);
|
||||
callback(data, &c_event);
|
||||
DisposeEntryNotification(&c_event);
|
||||
},
|
||||
flags);
|
||||
return nt::AddEntryListener(
|
||||
inst, StringRef(prefix, prefix_len),
|
||||
[=](const EntryNotification& event) {
|
||||
NT_EntryNotification c_event;
|
||||
ConvertToC(event, &c_event);
|
||||
callback(data, &c_event);
|
||||
DisposeEntryNotification(&c_event);
|
||||
},
|
||||
flags);
|
||||
}
|
||||
|
||||
NT_EntryListener NT_AddEntryListenerSingle(NT_Entry entry, void* data,
|
||||
NT_EntryListenerCallback callback,
|
||||
unsigned int flags) {
|
||||
return nt::AddEntryListener(entry,
|
||||
[=](const EntryNotification& event) {
|
||||
NT_EntryNotification c_event;
|
||||
ConvertToC(event, &c_event);
|
||||
callback(data, &c_event);
|
||||
DisposeEntryNotification(&c_event);
|
||||
},
|
||||
flags);
|
||||
return nt::AddEntryListener(
|
||||
entry,
|
||||
[=](const EntryNotification& event) {
|
||||
NT_EntryNotification c_event;
|
||||
ConvertToC(event, &c_event);
|
||||
callback(data, &c_event);
|
||||
DisposeEntryNotification(&c_event);
|
||||
},
|
||||
flags);
|
||||
}
|
||||
|
||||
NT_EntryListenerPoller NT_CreateEntryListenerPoller(NT_Inst inst) {
|
||||
@@ -335,14 +337,15 @@ NT_Bool NT_WaitForEntryListenerQueue(NT_Inst inst, double timeout) {
|
||||
NT_ConnectionListener NT_AddConnectionListener(
|
||||
NT_Inst inst, void* data, NT_ConnectionListenerCallback callback,
|
||||
NT_Bool immediate_notify) {
|
||||
return nt::AddConnectionListener(inst,
|
||||
[=](const ConnectionNotification& event) {
|
||||
NT_ConnectionNotification event_c;
|
||||
ConvertToC(event, &event_c);
|
||||
callback(data, &event_c);
|
||||
DisposeConnectionNotification(&event_c);
|
||||
},
|
||||
immediate_notify != 0);
|
||||
return nt::AddConnectionListener(
|
||||
inst,
|
||||
[=](const ConnectionNotification& event) {
|
||||
NT_ConnectionNotification event_c;
|
||||
ConvertToC(event, &event_c);
|
||||
callback(data, &event_c);
|
||||
DisposeConnectionNotification(&event_c);
|
||||
},
|
||||
immediate_notify != 0);
|
||||
}
|
||||
|
||||
NT_ConnectionListenerPoller NT_CreateConnectionListenerPoller(NT_Inst inst) {
|
||||
@@ -639,14 +642,15 @@ uint64_t NT_Now(void) { return wpi::Now(); }
|
||||
|
||||
NT_Logger NT_AddLogger(NT_Inst inst, void* data, NT_LogFunc func,
|
||||
unsigned int min_level, unsigned int max_level) {
|
||||
return nt::AddLogger(inst,
|
||||
[=](const LogMessage& msg) {
|
||||
NT_LogMessage msg_c;
|
||||
ConvertToC(msg, &msg_c);
|
||||
func(data, &msg_c);
|
||||
NT_DisposeLogMessage(&msg_c);
|
||||
},
|
||||
min_level, max_level);
|
||||
return nt::AddLogger(
|
||||
inst,
|
||||
[=](const LogMessage& msg) {
|
||||
NT_LogMessage msg_c;
|
||||
ConvertToC(msg, &msg_c);
|
||||
func(data, &msg_c);
|
||||
NT_DisposeLogMessage(&msg_c);
|
||||
},
|
||||
min_level, max_level);
|
||||
}
|
||||
|
||||
NT_LoggerPoller NT_CreateLoggerPoller(NT_Inst inst) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -11,12 +11,13 @@
|
||||
#include "ntcore.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
nt::AddLogger(nt::GetDefaultInstance(),
|
||||
[](const nt::LogMessage& msg) {
|
||||
std::fputs(msg.message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
},
|
||||
0, UINT_MAX);
|
||||
nt::AddLogger(
|
||||
nt::GetDefaultInstance(),
|
||||
[](const nt::LogMessage& msg) {
|
||||
std::fputs(msg.message.c_str(), stderr);
|
||||
std::fputc('\n', stderr);
|
||||
},
|
||||
0, UINT_MAX);
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
int ret = RUN_ALL_TESTS();
|
||||
return ret;
|
||||
|
||||
@@ -580,7 +580,8 @@ void HALSIMGUI_AddExecute(void* param, void (*execute)(void*)) {
|
||||
void HALSIMGUI_AddWindow(const char* name, void* param, void (*display)(void*),
|
||||
int32_t flags) {
|
||||
if (display) {
|
||||
HALSimGui::AddWindow(name, [=] { display(param); }, flags);
|
||||
HALSimGui::AddWindow(
|
||||
name, [=] { display(param); }, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,14 +51,16 @@ void CommandBase::SetSubsystem(const wpi::Twine& subsystem) {
|
||||
|
||||
void CommandBase::InitSendable(frc::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Command");
|
||||
builder.AddStringProperty(".name", [this] { return GetName(); }, nullptr);
|
||||
builder.AddBooleanProperty("running", [this] { return IsScheduled(); },
|
||||
[this](bool value) {
|
||||
bool isScheduled = IsScheduled();
|
||||
if (value && !isScheduled) {
|
||||
Schedule();
|
||||
} else if (!value && isScheduled) {
|
||||
Cancel();
|
||||
}
|
||||
});
|
||||
builder.AddStringProperty(
|
||||
".name", [this] { return GetName(); }, nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
"running", [this] { return IsScheduled(); },
|
||||
[this](bool value) {
|
||||
bool isScheduled = IsScheduled();
|
||||
if (value && !isScheduled) {
|
||||
Schedule();
|
||||
} else if (!value && isScheduled) {
|
||||
Cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,15 +37,17 @@ PIDCommand::PIDCommand(PIDController controller,
|
||||
std::function<double()> measurementSource,
|
||||
double setpoint, std::function<void(double)> useOutput,
|
||||
std::initializer_list<Subsystem*> requirements)
|
||||
: PIDCommand(controller, measurementSource, [setpoint] { return setpoint; },
|
||||
useOutput, requirements) {}
|
||||
: PIDCommand(
|
||||
controller, measurementSource, [setpoint] { return setpoint; },
|
||||
useOutput, requirements) {}
|
||||
|
||||
PIDCommand::PIDCommand(PIDController controller,
|
||||
std::function<double()> measurementSource,
|
||||
double setpoint, std::function<void(double)> useOutput,
|
||||
wpi::ArrayRef<Subsystem*> requirements)
|
||||
: PIDCommand(controller, measurementSource, [setpoint] { return setpoint; },
|
||||
useOutput, requirements) {}
|
||||
: PIDCommand(
|
||||
controller, measurementSource, [setpoint] { return setpoint; },
|
||||
useOutput, requirements) {}
|
||||
|
||||
void PIDCommand::Initialize() { m_controller.Reset(); }
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -22,26 +22,28 @@ SubsystemBase::SubsystemBase() {
|
||||
|
||||
void SubsystemBase::InitSendable(frc::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Subsystem");
|
||||
builder.AddBooleanProperty(".hasDefault",
|
||||
[this] { return GetDefaultCommand() != nullptr; },
|
||||
nullptr);
|
||||
builder.AddStringProperty(".default",
|
||||
[this]() -> std::string {
|
||||
auto command = GetDefaultCommand();
|
||||
if (command == nullptr) return "none";
|
||||
return command->GetName();
|
||||
},
|
||||
nullptr);
|
||||
builder.AddBooleanProperty(".hasCommand",
|
||||
[this] { return GetCurrentCommand() != nullptr; },
|
||||
nullptr);
|
||||
builder.AddStringProperty(".command",
|
||||
[this]() -> std::string {
|
||||
auto command = GetCurrentCommand();
|
||||
if (command == nullptr) return "none";
|
||||
return command->GetName();
|
||||
},
|
||||
nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
".hasDefault", [this] { return GetDefaultCommand() != nullptr; },
|
||||
nullptr);
|
||||
builder.AddStringProperty(
|
||||
".default",
|
||||
[this]() -> std::string {
|
||||
auto command = GetDefaultCommand();
|
||||
if (command == nullptr) return "none";
|
||||
return command->GetName();
|
||||
},
|
||||
nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
".hasCommand", [this] { return GetCurrentCommand() != nullptr; },
|
||||
nullptr);
|
||||
builder.AddStringProperty(
|
||||
".command",
|
||||
[this]() -> std::string {
|
||||
auto command = GetCurrentCommand();
|
||||
if (command == nullptr) return "none";
|
||||
return command->GetName();
|
||||
},
|
||||
nullptr);
|
||||
}
|
||||
|
||||
std::string SubsystemBase::GetName() const {
|
||||
|
||||
@@ -96,11 +96,12 @@ class ProfiledPIDCommand
|
||||
std::function<Distance_t()> goalSource,
|
||||
std::function<void(double, State)> useOutput,
|
||||
std::initializer_list<Subsystem*> requirements)
|
||||
: ProfiledPIDCommand(controller, measurementSource,
|
||||
[&goalSource]() {
|
||||
return State{goalSource(), Velocity_t{0}};
|
||||
},
|
||||
useOutput, requirements) {}
|
||||
: ProfiledPIDCommand(
|
||||
controller, measurementSource,
|
||||
[&goalSource]() {
|
||||
return State{goalSource(), Velocity_t{0}};
|
||||
},
|
||||
useOutput, requirements) {}
|
||||
|
||||
/**
|
||||
* Creates a new PIDCommand, which controls the given output with a
|
||||
@@ -117,11 +118,12 @@ class ProfiledPIDCommand
|
||||
std::function<Distance_t()> goalSource,
|
||||
std::function<void(double, State)> useOutput,
|
||||
wpi::ArrayRef<Subsystem*> requirements = {})
|
||||
: ProfiledPIDCommand(controller, measurementSource,
|
||||
[&goalSource]() {
|
||||
return State{goalSource(), Velocity_t{0}};
|
||||
},
|
||||
useOutput, requirements) {}
|
||||
: ProfiledPIDCommand(
|
||||
controller, measurementSource,
|
||||
[&goalSource]() {
|
||||
return State{goalSource(), Velocity_t{0}};
|
||||
},
|
||||
useOutput, requirements) {}
|
||||
|
||||
/**
|
||||
* Creates a new PIDCommand, which controls the given output with a
|
||||
@@ -137,8 +139,9 @@ class ProfiledPIDCommand
|
||||
std::function<Distance_t()> measurementSource, State goal,
|
||||
std::function<void(double, State)> useOutput,
|
||||
std::initializer_list<Subsystem*> requirements)
|
||||
: ProfiledPIDCommand(controller, measurementSource,
|
||||
[goal] { return goal; }, useOutput, requirements) {}
|
||||
: ProfiledPIDCommand(
|
||||
controller, measurementSource, [goal] { return goal; }, useOutput,
|
||||
requirements) {}
|
||||
|
||||
/**
|
||||
* Creates a new PIDCommand, which controls the given output with a
|
||||
@@ -154,8 +157,9 @@ class ProfiledPIDCommand
|
||||
std::function<Distance_t()> measurementSource, State goal,
|
||||
std::function<void(double, State)> useOutput,
|
||||
wpi::ArrayRef<Subsystem*> requirements = {})
|
||||
: ProfiledPIDCommand(controller, measurementSource,
|
||||
[goal] { return goal; }, useOutput, requirements) {}
|
||||
: ProfiledPIDCommand(
|
||||
controller, measurementSource, [goal] { return goal; }, useOutput,
|
||||
requirements) {}
|
||||
|
||||
/**
|
||||
* Creates a new PIDCommand, which controls the given output with a
|
||||
@@ -172,8 +176,9 @@ class ProfiledPIDCommand
|
||||
Distance_t goal,
|
||||
std::function<void(double, State)> useOutput,
|
||||
std::initializer_list<Subsystem*> requirements)
|
||||
: ProfiledPIDCommand(controller, measurementSource,
|
||||
[goal] { return goal; }, useOutput, requirements) {}
|
||||
: ProfiledPIDCommand(
|
||||
controller, measurementSource, [goal] { return goal; }, useOutput,
|
||||
requirements) {}
|
||||
|
||||
/**
|
||||
* Creates a new PIDCommand, which controls the given output with a
|
||||
@@ -190,8 +195,9 @@ class ProfiledPIDCommand
|
||||
Distance_t goal,
|
||||
std::function<void(double, State)> useOutput,
|
||||
wpi::ArrayRef<Subsystem*> requirements = {})
|
||||
: ProfiledPIDCommand(controller, measurementSource,
|
||||
[goal] { return goal; }, useOutput, requirements) {}
|
||||
: ProfiledPIDCommand(
|
||||
controller, measurementSource, [goal] { return goal; }, useOutput,
|
||||
requirements) {}
|
||||
|
||||
ProfiledPIDCommand(ProfiledPIDCommand&& other) = default;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -129,9 +129,9 @@ TEST_F(ButtonTest, AndTest) {
|
||||
bool pressed2 = false;
|
||||
WaitUntilCommand command([&finished] { return finished; });
|
||||
|
||||
(Trigger([&pressed1] { return pressed1; }) &&
|
||||
Trigger([&pressed2] { return pressed2; }))
|
||||
.WhenActive(&command);
|
||||
(Trigger([&pressed1] { return pressed1; }) && Trigger([&pressed2] {
|
||||
return pressed2;
|
||||
})).WhenActive(&command);
|
||||
pressed1 = true;
|
||||
scheduler.Run();
|
||||
EXPECT_FALSE(scheduler.IsScheduled(&command));
|
||||
@@ -148,18 +148,18 @@ TEST_F(ButtonTest, OrTest) {
|
||||
WaitUntilCommand command1([&finished] { return finished; });
|
||||
WaitUntilCommand command2([&finished] { return finished; });
|
||||
|
||||
(Trigger([&pressed1] { return pressed1; }) ||
|
||||
Trigger([&pressed2] { return pressed2; }))
|
||||
.WhenActive(&command1);
|
||||
(Trigger([&pressed1] { return pressed1; }) || Trigger([&pressed2] {
|
||||
return pressed2;
|
||||
})).WhenActive(&command1);
|
||||
pressed1 = true;
|
||||
scheduler.Run();
|
||||
EXPECT_TRUE(scheduler.IsScheduled(&command1));
|
||||
|
||||
pressed1 = false;
|
||||
|
||||
(Trigger([&pressed1] { return pressed1; }) ||
|
||||
Trigger([&pressed2] { return pressed2; }))
|
||||
.WhenActive(&command2);
|
||||
(Trigger([&pressed1] { return pressed1; }) || Trigger([&pressed2] {
|
||||
return pressed2;
|
||||
})).WhenActive(&command2);
|
||||
pressed2 = true;
|
||||
scheduler.Run();
|
||||
EXPECT_TRUE(scheduler.IsScheduled(&command2));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2011-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -66,6 +66,7 @@ void Trigger::ToggleWhenActive(Command* command) {
|
||||
void Trigger::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Button");
|
||||
builder.SetSafeState([=]() { m_sendablePressed = false; });
|
||||
builder.AddBooleanProperty("pressed", [=]() { return Grab(); },
|
||||
[=](bool value) { m_sendablePressed = value; });
|
||||
builder.AddBooleanProperty(
|
||||
"pressed", [=]() { return Grab(); },
|
||||
[=](bool value) { m_sendablePressed = value; });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2011-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -251,14 +251,15 @@ void Command::InitSendable(SendableBuilder& builder) {
|
||||
builder.AddStringProperty(
|
||||
".name", [=]() { return SendableRegistry::GetInstance().GetName(this); },
|
||||
nullptr);
|
||||
builder.AddBooleanProperty("running", [=]() { return IsRunning(); },
|
||||
[=](bool value) {
|
||||
if (value) {
|
||||
if (!IsRunning()) Start();
|
||||
} else {
|
||||
if (IsRunning()) Cancel();
|
||||
}
|
||||
});
|
||||
builder.AddBooleanProperty(".isParented", [=]() { return IsParented(); },
|
||||
nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
"running", [=]() { return IsRunning(); },
|
||||
[=](bool value) {
|
||||
if (value) {
|
||||
if (!IsRunning()) Start();
|
||||
} else {
|
||||
if (IsRunning()) Cancel();
|
||||
}
|
||||
});
|
||||
builder.AddBooleanProperty(
|
||||
".isParented", [=]() { return IsParented(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2011-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -122,11 +122,11 @@ void Subsystem::InitSendable(SendableBuilder& builder) {
|
||||
|
||||
builder.AddBooleanProperty(
|
||||
".hasDefault", [=]() { return m_defaultCommand != nullptr; }, nullptr);
|
||||
builder.AddStringProperty(".default",
|
||||
[=]() { return GetDefaultCommandName(); }, nullptr);
|
||||
builder.AddStringProperty(
|
||||
".default", [=]() { return GetDefaultCommandName(); }, nullptr);
|
||||
|
||||
builder.AddBooleanProperty(
|
||||
".hasCommand", [=]() { return m_currentCommand != nullptr; }, nullptr);
|
||||
builder.AddStringProperty(".command",
|
||||
[=]() { return GetCurrentCommandName(); }, nullptr);
|
||||
builder.AddStringProperty(
|
||||
".command", [=]() { return GetCurrentCommandName(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -52,8 +52,8 @@ double AnalogAccelerometer::PIDGet() { return GetAcceleration(); }
|
||||
|
||||
void AnalogAccelerometer::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Accelerometer");
|
||||
builder.AddDoubleProperty("Value", [=]() { return GetAcceleration(); },
|
||||
nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=]() { return GetAcceleration(); }, nullptr);
|
||||
}
|
||||
|
||||
void AnalogAccelerometer::InitAccelerometer() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -96,9 +96,9 @@ void AnalogEncoder::Reset() {
|
||||
|
||||
void AnalogEncoder::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("AbsoluteEncoder");
|
||||
builder.AddDoubleProperty("Distance", [this] { return this->GetDistance(); },
|
||||
nullptr);
|
||||
builder.AddDoubleProperty("Distance Per Rotation",
|
||||
[this] { return this->GetDistancePerRotation(); },
|
||||
nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Distance", [this] { return this->GetDistance(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Distance Per Rotation",
|
||||
[this] { return this->GetDistancePerRotation(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -230,6 +230,6 @@ void AnalogInput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
|
||||
void AnalogInput::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Analog Input");
|
||||
builder.AddDoubleProperty("Value", [=]() { return GetAverageVoltage(); },
|
||||
nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=]() { return GetAverageVoltage(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2014-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -69,6 +69,7 @@ int AnalogOutput::GetChannel() { return m_channel; }
|
||||
|
||||
void AnalogOutput::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Analog Output");
|
||||
builder.AddDoubleProperty("Value", [=]() { return GetVoltage(); },
|
||||
[=](double value) { SetVoltage(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=]() { return GetVoltage(); },
|
||||
[=](double value) { SetVoltage(value); });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2014-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -43,7 +43,10 @@ double BuiltInAccelerometer::GetZ() { return HAL_GetAccelerometerZ(); }
|
||||
|
||||
void BuiltInAccelerometer::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("3AxisAccelerometer");
|
||||
builder.AddDoubleProperty("X", [=]() { return GetX(); }, nullptr);
|
||||
builder.AddDoubleProperty("Y", [=]() { return GetY(); }, nullptr);
|
||||
builder.AddDoubleProperty("Z", [=]() { return GetZ(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"X", [=]() { return GetX(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Y", [=]() { return GetY(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Z", [=]() { return GetZ(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2014-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -206,13 +206,14 @@ void Compressor::ClearAllPCMStickyFaults() {
|
||||
|
||||
void Compressor::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Compressor");
|
||||
builder.AddBooleanProperty("Enabled", [=]() { return Enabled(); },
|
||||
[=](bool value) {
|
||||
if (value)
|
||||
Start();
|
||||
else
|
||||
Stop();
|
||||
});
|
||||
builder.AddBooleanProperty(
|
||||
"Enabled", [=]() { return Enabled(); },
|
||||
[=](bool value) {
|
||||
if (value)
|
||||
Start();
|
||||
else
|
||||
Stop();
|
||||
});
|
||||
builder.AddBooleanProperty(
|
||||
"Pressure switch", [=]() { return GetPressureSwitchValue(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -332,5 +332,6 @@ bool Counter::GetDirection() const {
|
||||
|
||||
void Counter::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Counter");
|
||||
builder.AddDoubleProperty("Value", [=]() { return Get(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=]() { return Get(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -73,5 +73,6 @@ int DigitalInput::GetChannel() const { return m_channel; }
|
||||
|
||||
void DigitalInput::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Digital Input");
|
||||
builder.AddBooleanProperty("Value", [=]() { return Get(); }, nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
"Value", [=]() { return Get(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -154,6 +154,6 @@ void DigitalOutput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
|
||||
void DigitalOutput::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Digital Output");
|
||||
builder.AddBooleanProperty("Value", [=]() { return Get(); },
|
||||
[=](bool value) { Set(value); });
|
||||
builder.AddBooleanProperty(
|
||||
"Value", [=]() { return Get(); }, [=](bool value) { Set(value); });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -93,8 +93,8 @@ int DutyCycle::GetSourceChannel() const { return m_source->GetChannel(); }
|
||||
|
||||
void DutyCycle::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Duty Cycle");
|
||||
builder.AddDoubleProperty("Frequency",
|
||||
[this] { return this->GetFrequency(); }, nullptr);
|
||||
builder.AddDoubleProperty("Output", [this] { return this->GetOutput(); },
|
||||
nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Frequency", [this] { return this->GetFrequency(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Output", [this] { return this->GetOutput(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -130,11 +130,11 @@ void DutyCycleEncoder::SetConnectedFrequencyThreshold(int frequency) {
|
||||
|
||||
void DutyCycleEncoder::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("AbsoluteEncoder");
|
||||
builder.AddDoubleProperty("Distance", [this] { return this->GetDistance(); },
|
||||
nullptr);
|
||||
builder.AddDoubleProperty("Distance Per Rotation",
|
||||
[this] { return this->GetDistancePerRotation(); },
|
||||
nullptr);
|
||||
builder.AddDoubleProperty("Is Connected",
|
||||
[this] { return this->IsConnected(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Distance", [this] { return this->GetDistance(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Distance Per Rotation",
|
||||
[this] { return this->GetDistancePerRotation(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Is Connected", [this] { return this->IsConnected(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -236,11 +236,12 @@ void Encoder::InitSendable(SendableBuilder& builder) {
|
||||
else
|
||||
builder.SetSmartDashboardType("Encoder");
|
||||
|
||||
builder.AddDoubleProperty("Speed", [=]() { return GetRate(); }, nullptr);
|
||||
builder.AddDoubleProperty("Distance", [=]() { return GetDistance(); },
|
||||
nullptr);
|
||||
builder.AddDoubleProperty("Distance per Tick",
|
||||
[=]() { return GetDistancePerPulse(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Speed", [=]() { return GetRate(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Distance", [=]() { return GetDistance(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Distance per Tick", [=]() { return GetDistancePerPulse(); }, nullptr);
|
||||
}
|
||||
|
||||
void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -25,5 +25,6 @@ double GyroBase::PIDGet() {
|
||||
|
||||
void GyroBase::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Gyro");
|
||||
builder.AddDoubleProperty("Value", [=]() { return GetAngle(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=]() { return GetAngle(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -70,6 +70,6 @@ void NidecBrushless::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Nidec Brushless");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=]() { StopMotor(); });
|
||||
builder.AddDoubleProperty("Value", [=]() { return Get(); },
|
||||
[=](double value) { Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=]() { return Get(); }, [=](double value) { Set(value); });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -229,16 +229,17 @@ void PIDBase::PIDWrite(double output) { SetSetpoint(output); }
|
||||
void PIDBase::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("PIDController");
|
||||
builder.SetSafeState([=]() { Reset(); });
|
||||
builder.AddDoubleProperty("p", [=]() { return GetP(); },
|
||||
[=](double value) { SetP(value); });
|
||||
builder.AddDoubleProperty("i", [=]() { return GetI(); },
|
||||
[=](double value) { SetI(value); });
|
||||
builder.AddDoubleProperty("d", [=]() { return GetD(); },
|
||||
[=](double value) { SetD(value); });
|
||||
builder.AddDoubleProperty("f", [=]() { return GetF(); },
|
||||
[=](double value) { SetF(value); });
|
||||
builder.AddDoubleProperty("setpoint", [=]() { return GetSetpoint(); },
|
||||
[=](double value) { SetSetpoint(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"p", [=]() { return GetP(); }, [=](double value) { SetP(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"i", [=]() { return GetI(); }, [=](double value) { SetI(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"d", [=]() { return GetD(); }, [=](double value) { SetD(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"f", [=]() { return GetF(); }, [=](double value) { SetF(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"setpoint", [=]() { return GetSetpoint(); },
|
||||
[=](double value) { SetSetpoint(value); });
|
||||
}
|
||||
|
||||
void PIDBase::Calculate() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -80,6 +80,7 @@ void PIDController::Reset() {
|
||||
|
||||
void PIDController::InitSendable(SendableBuilder& builder) {
|
||||
PIDBase::InitSendable(builder);
|
||||
builder.AddBooleanProperty("enabled", [=]() { return IsEnabled(); },
|
||||
[=](bool value) { SetEnabled(value); });
|
||||
builder.AddBooleanProperty(
|
||||
"enabled", [=]() { return IsEnabled(); },
|
||||
[=](bool value) { SetEnabled(value); });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -199,6 +199,7 @@ void PWM::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("PWM");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=]() { SetDisabled(); });
|
||||
builder.AddDoubleProperty("Value", [=]() { return GetRaw(); },
|
||||
[=](double value) { SetRaw(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=]() { return GetRaw(); },
|
||||
[=](double value) { SetRaw(value); });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -35,6 +35,7 @@ void PWMSpeedController::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Speed Controller");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=]() { SetDisabled(); });
|
||||
builder.AddDoubleProperty("Value", [=]() { return GetSpeed(); },
|
||||
[=](double value) { SetSpeed(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=]() { return GetSpeed(); },
|
||||
[=](double value) { SetSpeed(value); });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2014-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -139,10 +139,11 @@ void PowerDistributionPanel::ClearStickyFaults() {
|
||||
void PowerDistributionPanel::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("PowerDistributionPanel");
|
||||
for (int i = 0; i < SensorUtil::kPDPChannels; ++i) {
|
||||
builder.AddDoubleProperty("Chan" + wpi::Twine(i),
|
||||
[=]() { return GetCurrent(i); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Chan" + wpi::Twine(i), [=]() { return GetCurrent(i); }, nullptr);
|
||||
}
|
||||
builder.AddDoubleProperty("Voltage", [=]() { return GetVoltage(); }, nullptr);
|
||||
builder.AddDoubleProperty("TotalCurrent", [=]() { return GetTotalCurrent(); },
|
||||
nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Voltage", [=]() { return GetVoltage(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"TotalCurrent", [=]() { return GetTotalCurrent(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -57,8 +57,8 @@ double Servo::GetMinAngle() const { return kMinServoAngle; }
|
||||
|
||||
void Servo::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Servo");
|
||||
builder.AddDoubleProperty("Value", [=]() { return Get(); },
|
||||
[=](double value) { Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=]() { return Get(); }, [=](double value) { Set(value); });
|
||||
}
|
||||
|
||||
double Servo::GetServoAngleRange() const {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -93,6 +93,6 @@ void Solenoid::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Solenoid");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=]() { Set(false); });
|
||||
builder.AddBooleanProperty("Value", [=]() { return Get(); },
|
||||
[=](bool value) { Set(value); });
|
||||
builder.AddBooleanProperty(
|
||||
"Value", [=]() { return Get(); }, [=](bool value) { Set(value); });
|
||||
}
|
||||
|
||||
@@ -66,6 +66,6 @@ void SpeedControllerGroup::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Speed Controller");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=]() { StopMotor(); });
|
||||
builder.AddDoubleProperty("Value", [=]() { return Get(); },
|
||||
[=](double value) { Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=]() { return Get(); }, [=](double value) { Set(value); });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -177,8 +177,8 @@ void Ultrasonic::SetPIDSourceType(PIDSourceType pidSource) {
|
||||
|
||||
void Ultrasonic::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Ultrasonic");
|
||||
builder.AddDoubleProperty("Value", [=]() { return GetRangeInches(); },
|
||||
nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=]() { return GetRangeInches(); }, nullptr);
|
||||
}
|
||||
|
||||
void Ultrasonic::Initialize() {
|
||||
|
||||
@@ -119,12 +119,13 @@ void PIDController::Reset() {
|
||||
|
||||
void PIDController::InitSendable(frc::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("PIDController");
|
||||
builder.AddDoubleProperty("p", [this] { return GetP(); },
|
||||
[this](double value) { SetP(value); });
|
||||
builder.AddDoubleProperty("i", [this] { return GetI(); },
|
||||
[this](double value) { SetI(value); });
|
||||
builder.AddDoubleProperty("d", [this] { return GetD(); },
|
||||
[this](double value) { SetD(value); });
|
||||
builder.AddDoubleProperty("setpoint", [this] { return GetSetpoint(); },
|
||||
[this](double value) { SetSetpoint(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"p", [this] { return GetP(); }, [this](double value) { SetP(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"i", [this] { return GetI(); }, [this](double value) { SetI(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"d", [this] { return GetD(); }, [this](double value) { SetD(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"setpoint", [this] { return GetSetpoint(); },
|
||||
[this](double value) { SetSetpoint(value); });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -216,9 +216,9 @@ void DifferentialDrive::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("DifferentialDrive");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { StopMotor(); });
|
||||
builder.AddDoubleProperty("Left Motor Speed",
|
||||
[=]() { return m_leftMotor->Get(); },
|
||||
[=](double value) { m_leftMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Left Motor Speed", [=]() { return m_leftMotor->Get(); },
|
||||
[=](double value) { m_leftMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Right Motor Speed",
|
||||
[=]() { return m_rightMotor->Get() * m_rightSideInvertMultiplier; },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -107,13 +107,13 @@ void KilloughDrive::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("KilloughDrive");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { StopMotor(); });
|
||||
builder.AddDoubleProperty("Left Motor Speed",
|
||||
[=]() { return m_leftMotor->Get(); },
|
||||
[=](double value) { m_leftMotor->Set(value); });
|
||||
builder.AddDoubleProperty("Right Motor Speed",
|
||||
[=]() { return m_rightMotor->Get(); },
|
||||
[=](double value) { m_rightMotor->Set(value); });
|
||||
builder.AddDoubleProperty("Back Motor Speed",
|
||||
[=]() { return m_backMotor->Get(); },
|
||||
[=](double value) { m_backMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Left Motor Speed", [=]() { return m_leftMotor->Get(); },
|
||||
[=](double value) { m_leftMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Right Motor Speed", [=]() { return m_rightMotor->Get(); },
|
||||
[=](double value) { m_rightMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Back Motor Speed", [=]() { return m_backMotor->Get(); },
|
||||
[=](double value) { m_backMotor->Set(value); });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -120,9 +120,9 @@ void MecanumDrive::InitSendable(SendableBuilder& builder) {
|
||||
[=](double value) {
|
||||
m_frontRightMotor->Set(value * m_rightSideInvertMultiplier);
|
||||
});
|
||||
builder.AddDoubleProperty("Rear Left Motor Speed",
|
||||
[=]() { return m_rearLeftMotor->Get(); },
|
||||
[=](double value) { m_rearLeftMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Rear Left Motor Speed", [=]() { return m_rearLeftMotor->Get(); },
|
||||
[=](double value) { m_rearLeftMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Rear Right Motor Speed",
|
||||
[=]() { return m_rearRightMotor->Get() * m_rightSideInvertMultiplier; },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -30,7 +30,7 @@ void AddToSendableRegistry(frc::Sendable* sendable, std::string name) {
|
||||
} // namespace detail
|
||||
|
||||
void SendableCameraWrapper::InitSendable(SendableBuilder& builder) {
|
||||
builder.AddStringProperty(".ShuffleboardURI", [this] { return m_uri; },
|
||||
nullptr);
|
||||
builder.AddStringProperty(
|
||||
".ShuffleboardURI", [this] { return m_uri; }, nullptr);
|
||||
}
|
||||
} // namespace frc
|
||||
|
||||
@@ -339,12 +339,12 @@ class ProfiledPIDController
|
||||
|
||||
void InitSendable(frc::SendableBuilder& builder) override {
|
||||
builder.SetSmartDashboardType("ProfiledPIDController");
|
||||
builder.AddDoubleProperty("p", [this] { return GetP(); },
|
||||
[this](double value) { SetP(value); });
|
||||
builder.AddDoubleProperty("i", [this] { return GetI(); },
|
||||
[this](double value) { SetI(value); });
|
||||
builder.AddDoubleProperty("d", [this] { return GetD(); },
|
||||
[this](double value) { SetD(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"p", [this] { return GetP(); }, [this](double value) { SetP(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"i", [this] { return GetI(); }, [this](double value) { SetI(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"d", [this] { return GetD(); }, [this](double value) { SetD(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"goal", [this] { return GetGoal().position.template to<double>(); },
|
||||
[this](double value) { SetGoal(Distance_t{value}); });
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace frc {
|
||||
|
||||
template <class... Wheels>
|
||||
SwerveDriveKinematics(Translation2d, Wheels...)
|
||||
->SwerveDriveKinematics<1 + sizeof...(Wheels)>;
|
||||
-> SwerveDriveKinematics<1 + sizeof...(Wheels)>;
|
||||
|
||||
template <size_t NumModules>
|
||||
std::array<SwerveModuleState, NumModules>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2011-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -76,20 +76,21 @@ template <class T>
|
||||
void SendableChooser<T>::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("String Chooser");
|
||||
builder.GetEntry(kInstance).SetDouble(m_instance);
|
||||
builder.AddStringArrayProperty(kOptions,
|
||||
[=]() {
|
||||
std::vector<std::string> keys;
|
||||
for (const auto& choice : m_choices) {
|
||||
keys.push_back(choice.first());
|
||||
}
|
||||
builder.AddStringArrayProperty(
|
||||
kOptions,
|
||||
[=]() {
|
||||
std::vector<std::string> keys;
|
||||
for (const auto& choice : m_choices) {
|
||||
keys.push_back(choice.first());
|
||||
}
|
||||
|
||||
// Unlike std::map, wpi::StringMap elements
|
||||
// are not sorted
|
||||
std::sort(keys.begin(), keys.end());
|
||||
// Unlike std::map, wpi::StringMap elements
|
||||
// are not sorted
|
||||
std::sort(keys.begin(), keys.end());
|
||||
|
||||
return keys;
|
||||
},
|
||||
nullptr);
|
||||
return keys;
|
||||
},
|
||||
nullptr);
|
||||
builder.AddSmallStringProperty(
|
||||
kDefault,
|
||||
[=](wpi::SmallVectorImpl<char>&) -> wpi::StringRef {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -11,15 +11,16 @@
|
||||
// For more information, see:
|
||||
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
|
||||
ReplaceMePIDCommand::ReplaceMePIDCommand()
|
||||
: CommandHelper(frc2::PIDController(0, 0, 0),
|
||||
// This should return the measurement
|
||||
[] { return 0; },
|
||||
// This should return the setpoint (can also be a constant)
|
||||
[] { return 0; },
|
||||
// This uses the output
|
||||
[](double output) {
|
||||
// Use the output here
|
||||
}) {}
|
||||
: CommandHelper(
|
||||
frc2::PIDController(0, 0, 0),
|
||||
// This should return the measurement
|
||||
[] { return 0; },
|
||||
// This should return the setpoint (can also be a constant)
|
||||
[] { return 0; },
|
||||
// This uses the output
|
||||
[](double output) {
|
||||
// Use the output here
|
||||
}) {}
|
||||
|
||||
// Returns true when the command should end.
|
||||
bool ReplaceMePIDCommand::IsFinished() { return false; }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -12,15 +12,16 @@
|
||||
using namespace DriveConstants;
|
||||
|
||||
TurnToAngle::TurnToAngle(units::degree_t target, DriveSubsystem* drive)
|
||||
: CommandHelper(frc2::PIDController(kTurnP, kTurnI, kTurnD),
|
||||
// Close loop on heading
|
||||
[drive] { return drive->GetHeading().to<double>(); },
|
||||
// Set reference to target
|
||||
target.to<double>(),
|
||||
// Pipe output to turn robot
|
||||
[drive](double output) { drive->ArcadeDrive(0, output); },
|
||||
// Require the drive
|
||||
{drive}) {
|
||||
: CommandHelper(
|
||||
frc2::PIDController(kTurnP, kTurnI, kTurnD),
|
||||
// Close loop on heading
|
||||
[drive] { return drive->GetHeading().to<double>(); },
|
||||
// Set reference to target
|
||||
target.to<double>(),
|
||||
// Pipe output to turn robot
|
||||
[drive](double output) { drive->ArcadeDrive(0, output); },
|
||||
// Require the drive
|
||||
{drive}) {
|
||||
// Set the controller to be continuous (because it is an angle controller)
|
||||
m_controller.EnableContinuousInput(-180, 180);
|
||||
// Set the controller tolerance - the delta tolerance ensures the robot is
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -107,8 +107,7 @@ std::unique_ptr<NetworkStream> TCPConnector::connect_parallel(
|
||||
}
|
||||
++result->count;
|
||||
result->cv.notify_all();
|
||||
})
|
||||
.detach();
|
||||
}).detach();
|
||||
}
|
||||
|
||||
// wait for a result, timeout, or all finished
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -19,17 +19,18 @@ GetNameInfoReq::GetNameInfoReq() {
|
||||
|
||||
void GetNameInfo(Loop& loop, const std::shared_ptr<GetNameInfoReq>& req,
|
||||
const sockaddr& addr, int flags) {
|
||||
int err = uv_getnameinfo(loop.GetRaw(), req->GetRaw(),
|
||||
[](uv_getnameinfo_t* req, int status,
|
||||
const char* hostname, const char* service) {
|
||||
auto& h = *static_cast<GetNameInfoReq*>(req->data);
|
||||
if (status < 0)
|
||||
h.ReportError(status);
|
||||
else
|
||||
h.resolved(hostname, service);
|
||||
h.Release(); // this is always a one-shot
|
||||
},
|
||||
&addr, flags);
|
||||
int err = uv_getnameinfo(
|
||||
loop.GetRaw(), req->GetRaw(),
|
||||
[](uv_getnameinfo_t* req, int status, const char* hostname,
|
||||
const char* service) {
|
||||
auto& h = *static_cast<GetNameInfoReq*>(req->data);
|
||||
if (status < 0)
|
||||
h.ReportError(status);
|
||||
else
|
||||
h.resolved(hostname, service);
|
||||
h.Release(); // this is always a one-shot
|
||||
},
|
||||
&addr, flags);
|
||||
if (err < 0)
|
||||
loop.ReportError(err);
|
||||
else
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -49,13 +49,14 @@ void Loop::Close() {
|
||||
}
|
||||
|
||||
void Loop::Walk(std::function<void(Handle&)> callback) {
|
||||
uv_walk(m_loop,
|
||||
[](uv_handle_t* handle, void* func) {
|
||||
auto& h = *static_cast<Handle*>(handle->data);
|
||||
auto& f = *static_cast<std::function<void(Handle&)>*>(func);
|
||||
f(h);
|
||||
},
|
||||
&callback);
|
||||
uv_walk(
|
||||
m_loop,
|
||||
[](uv_handle_t* handle, void* func) {
|
||||
auto& h = *static_cast<Handle*>(handle->data);
|
||||
auto& f = *static_cast<std::function<void(Handle&)>*>(func);
|
||||
f(h);
|
||||
},
|
||||
&callback);
|
||||
}
|
||||
|
||||
void Loop::Fork() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -24,12 +24,13 @@ std::shared_ptr<Signal> Signal::Create(Loop& loop) {
|
||||
}
|
||||
|
||||
void Signal::Start(int signum) {
|
||||
Invoke(&uv_signal_start, GetRaw(),
|
||||
[](uv_signal_t* handle, int signum) {
|
||||
Signal& h = *static_cast<Signal*>(handle->data);
|
||||
h.signal(signum);
|
||||
},
|
||||
signum);
|
||||
Invoke(
|
||||
&uv_signal_start, GetRaw(),
|
||||
[](uv_signal_t* handle, int signum) {
|
||||
Signal& h = *static_cast<Signal*>(handle->data);
|
||||
h.signal(signum);
|
||||
},
|
||||
signum);
|
||||
}
|
||||
|
||||
} // namespace uv
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -34,12 +34,13 @@ void Timer::SingleShot(Loop& loop, Time timeout, std::function<void()> func) {
|
||||
}
|
||||
|
||||
void Timer::Start(Time timeout, Time repeat) {
|
||||
Invoke(&uv_timer_start, GetRaw(),
|
||||
[](uv_timer_t* handle) {
|
||||
Timer& h = *static_cast<Timer*>(handle->data);
|
||||
h.timeout();
|
||||
},
|
||||
timeout.count(), repeat.count());
|
||||
Invoke(
|
||||
&uv_timer_start, GetRaw(),
|
||||
[](uv_timer_t* handle) {
|
||||
Timer& h = *static_cast<Timer*>(handle->data);
|
||||
h.timeout();
|
||||
},
|
||||
timeout.count(), repeat.count());
|
||||
}
|
||||
|
||||
} // namespace uv
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -17,19 +17,20 @@ WorkReq::WorkReq() {
|
||||
}
|
||||
|
||||
void QueueWork(Loop& loop, const std::shared_ptr<WorkReq>& req) {
|
||||
int err = uv_queue_work(loop.GetRaw(), req->GetRaw(),
|
||||
[](uv_work_t* req) {
|
||||
auto& h = *static_cast<WorkReq*>(req->data);
|
||||
h.work();
|
||||
},
|
||||
[](uv_work_t* req, int status) {
|
||||
auto& h = *static_cast<WorkReq*>(req->data);
|
||||
if (status < 0)
|
||||
h.ReportError(status);
|
||||
else
|
||||
h.afterWork();
|
||||
h.Release(); // this is always a one-shot
|
||||
});
|
||||
int err = uv_queue_work(
|
||||
loop.GetRaw(), req->GetRaw(),
|
||||
[](uv_work_t* req) {
|
||||
auto& h = *static_cast<WorkReq*>(req->data);
|
||||
h.work();
|
||||
},
|
||||
[](uv_work_t* req, int status) {
|
||||
auto& h = *static_cast<WorkReq*>(req->data);
|
||||
if (status < 0)
|
||||
h.ReportError(status);
|
||||
else
|
||||
h.afterWork();
|
||||
h.Release(); // this is always a one-shot
|
||||
});
|
||||
if (err < 0)
|
||||
loop.ReportError(err);
|
||||
else
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -46,7 +46,8 @@ TEST(UvGetAddrInfo, BothNull) {
|
||||
fail_cb_called++;
|
||||
});
|
||||
|
||||
GetAddrInfo(loop, [](const addrinfo&) { FAIL(); }, Twine::createNull());
|
||||
GetAddrInfo(
|
||||
loop, [](const addrinfo&) { FAIL(); }, Twine::createNull());
|
||||
loop->Run();
|
||||
ASSERT_EQ(fail_cb_called, 1);
|
||||
}
|
||||
@@ -62,7 +63,8 @@ TEST(UvGetAddrInfo, FailedLookup) {
|
||||
});
|
||||
|
||||
// Use a FQDN by ending in a period
|
||||
GetAddrInfo(loop, [](const addrinfo&) { FAIL(); }, "xyzzy.xyzzy.xyzzy.");
|
||||
GetAddrInfo(
|
||||
loop, [](const addrinfo&) { FAIL(); }, "xyzzy.xyzzy.xyzzy.");
|
||||
loop->Run();
|
||||
ASSERT_EQ(fail_cb_called, 1);
|
||||
}
|
||||
@@ -73,7 +75,8 @@ TEST(UvGetAddrInfo, Basic) {
|
||||
auto loop = Loop::Create();
|
||||
loop->error.connect([](Error) { FAIL(); });
|
||||
|
||||
GetAddrInfo(loop, [&](const addrinfo&) { getaddrinfo_cbs++; }, "localhost");
|
||||
GetAddrInfo(
|
||||
loop, [&](const addrinfo&) { getaddrinfo_cbs++; }, "localhost");
|
||||
|
||||
loop->Run();
|
||||
|
||||
@@ -90,12 +93,13 @@ TEST(UvGetAddrInfo, Concurrent) {
|
||||
|
||||
for (int i = 0; i < CONCURRENT_COUNT; i++) {
|
||||
callback_counts[i] = 0;
|
||||
GetAddrInfo(loop,
|
||||
[i, &callback_counts, &getaddrinfo_cbs](const addrinfo&) {
|
||||
callback_counts[i]++;
|
||||
getaddrinfo_cbs++;
|
||||
},
|
||||
"localhost");
|
||||
GetAddrInfo(
|
||||
loop,
|
||||
[i, &callback_counts, &getaddrinfo_cbs](const addrinfo&) {
|
||||
callback_counts[i]++;
|
||||
getaddrinfo_cbs++;
|
||||
},
|
||||
"localhost");
|
||||
}
|
||||
|
||||
loop->Run();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -41,13 +41,14 @@ TEST(UvGetNameInfo, BasicIp4) {
|
||||
auto loop = Loop::Create();
|
||||
loop->error.connect([](Error) { FAIL(); });
|
||||
|
||||
GetNameInfo4(loop,
|
||||
[&](const char* hostname, const char* service) {
|
||||
ASSERT_NE(hostname, nullptr);
|
||||
ASSERT_NE(service, nullptr);
|
||||
getnameinfo_cbs++;
|
||||
},
|
||||
"127.0.0.1", 80);
|
||||
GetNameInfo4(
|
||||
loop,
|
||||
[&](const char* hostname, const char* service) {
|
||||
ASSERT_NE(hostname, nullptr);
|
||||
ASSERT_NE(service, nullptr);
|
||||
getnameinfo_cbs++;
|
||||
},
|
||||
"127.0.0.1", 80);
|
||||
|
||||
loop->Run();
|
||||
|
||||
@@ -60,13 +61,14 @@ TEST(UvGetNameInfo, BasicIp6) {
|
||||
auto loop = Loop::Create();
|
||||
loop->error.connect([](Error) { FAIL(); });
|
||||
|
||||
GetNameInfo6(loop,
|
||||
[&](const char* hostname, const char* service) {
|
||||
ASSERT_NE(hostname, nullptr);
|
||||
ASSERT_NE(service, nullptr);
|
||||
getnameinfo_cbs++;
|
||||
},
|
||||
"::1", 80);
|
||||
GetNameInfo6(
|
||||
loop,
|
||||
[&](const char* hostname, const char* service) {
|
||||
ASSERT_NE(hostname, nullptr);
|
||||
ASSERT_NE(service, nullptr);
|
||||
getnameinfo_cbs++;
|
||||
},
|
||||
"::1", 80);
|
||||
|
||||
loop->Run();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user