mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -7,7 +7,7 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
BooleanEvent::BooleanEvent(EventLoop* loop, std::function<bool()> condition)
|
||||
: m_loop(loop), m_signal(std::move(condition)) {
|
||||
@@ -67,10 +67,10 @@ BooleanEvent BooleanEvent::Falling() {
|
||||
});
|
||||
}
|
||||
|
||||
BooleanEvent BooleanEvent::Debounce(units::second_t debounceTime,
|
||||
frc::Debouncer::DebounceType type) {
|
||||
BooleanEvent BooleanEvent::Debounce(wpi::units::second_t debounceTime,
|
||||
wpi::math::Debouncer::DebounceType type) {
|
||||
return BooleanEvent(
|
||||
this->m_loop,
|
||||
[debouncer = frc::Debouncer(debounceTime, type),
|
||||
[debouncer = wpi::math::Debouncer(debounceTime, type),
|
||||
state = m_state]() mutable { return debouncer.Calculate(*state); });
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "wpi/system/Errors.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
namespace {
|
||||
struct RunningSetter {
|
||||
@@ -22,7 +22,7 @@ struct RunningSetter {
|
||||
|
||||
EventLoop::EventLoop() {}
|
||||
|
||||
void EventLoop::Bind(wpi::unique_function<void()> action) {
|
||||
void EventLoop::Bind(wpi::util::unique_function<void()> action) {
|
||||
if (m_running) {
|
||||
throw FRC_MakeError(err::Error,
|
||||
"Cannot bind EventLoop while it is running");
|
||||
@@ -32,7 +32,7 @@ void EventLoop::Bind(wpi::unique_function<void()> action) {
|
||||
|
||||
void EventLoop::Poll() {
|
||||
RunningSetter runSetter{m_running};
|
||||
for (wpi::unique_function<void()>& action : m_bindings) {
|
||||
for (wpi::util::unique_function<void()>& action : m_bindings) {
|
||||
action();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,33 +11,33 @@
|
||||
#include "wpi/nt/NetworkTable.hpp"
|
||||
#include "wpi/nt/NetworkTableInstance.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
NetworkBooleanEvent::NetworkBooleanEvent(EventLoop* loop,
|
||||
nt::BooleanTopic topic)
|
||||
wpi::nt::BooleanTopic topic)
|
||||
: NetworkBooleanEvent{loop, topic.Subscribe(false)} {}
|
||||
|
||||
NetworkBooleanEvent::NetworkBooleanEvent(EventLoop* loop,
|
||||
nt::BooleanSubscriber sub)
|
||||
wpi::nt::BooleanSubscriber sub)
|
||||
: BooleanEvent{
|
||||
loop,
|
||||
[sub = std::make_shared<nt::BooleanSubscriber>(std::move(sub))] {
|
||||
[sub = std::make_shared<wpi::nt::BooleanSubscriber>(std::move(sub))] {
|
||||
return sub->GetTopic().GetInstance().IsConnected() && sub->Get();
|
||||
}} {}
|
||||
|
||||
NetworkBooleanEvent::NetworkBooleanEvent(
|
||||
EventLoop* loop, std::shared_ptr<nt::NetworkTable> table,
|
||||
EventLoop* loop, std::shared_ptr<wpi::nt::NetworkTable> table,
|
||||
std::string_view topicName)
|
||||
: NetworkBooleanEvent{loop, table->GetBooleanTopic(topicName)} {}
|
||||
|
||||
NetworkBooleanEvent::NetworkBooleanEvent(EventLoop* loop,
|
||||
std::string_view tableName,
|
||||
std::string_view topicName)
|
||||
: NetworkBooleanEvent{loop, nt::NetworkTableInstance::GetDefault(),
|
||||
: NetworkBooleanEvent{loop, wpi::nt::NetworkTableInstance::GetDefault(),
|
||||
tableName, topicName} {}
|
||||
|
||||
NetworkBooleanEvent::NetworkBooleanEvent(EventLoop* loop,
|
||||
nt::NetworkTableInstance inst,
|
||||
wpi::nt::NetworkTableInstance inst,
|
||||
std::string_view tableName,
|
||||
std::string_view topicName)
|
||||
: NetworkBooleanEvent{loop, inst.GetTable(tableName), topicName} {}
|
||||
|
||||
Reference in New Issue
Block a user