mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
LiveWindow.updateValues() is now called from IterativeRobotBase on every loop iteration. Telemetry for all WPILib classes is enabled by default; it can be disabled for specific classes using LiveWindow.disableTelemetry(), or all telemetry can be disabled using LiveWindow.disableAllTelemetry(). This necessitated changing the hook methodology into other classes to be more property-based rather than each class providing multiple functions. This had the benefit of reducing boilerplate and increasing consistency. - Remove NamedSendable, add name to Sendable. - Provide SendableBase abstract class. - Deprecate LiveWindow addSensor/addActuator interfaces. - Add LiveWindow support to drive classes. - Add addChild() helper functions to Subsystem. - Fix inheritance hierarchy. Now only sensors inherit from SensorBase. Other devices inherit from some combination of SendableBase, ErrorBase, or nothing.
59 lines
1.9 KiB
C++
59 lines
1.9 KiB
C++
/*----------------------------------------------------------------------------*/
|
|
/* Copyright (c) 2011-2017 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. */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include <llvm/StringMap.h>
|
|
#include <llvm/StringRef.h>
|
|
|
|
#include "SmartDashboard/SendableChooserBase.h"
|
|
|
|
namespace frc {
|
|
|
|
/**
|
|
* The SendableChooser class is a useful tool for presenting a selection of
|
|
* options to the SmartDashboard.
|
|
*
|
|
* For instance, you may wish to be able to select between multiple autonomous
|
|
* modes. You can do this by putting every possible Command you want to run as
|
|
* an autonomous into a SendableChooser and then put it into the SmartDashboard
|
|
* to have a list of options appear on the laptop. Once autonomous starts,
|
|
* simply ask the SendableChooser what the selected value is.
|
|
*
|
|
* @tparam T The type of values to be stored
|
|
* @see SmartDashboard
|
|
*/
|
|
template <class T>
|
|
class SendableChooser : public SendableChooserBase {
|
|
llvm::StringMap<T> m_choices;
|
|
|
|
template <class U>
|
|
static U _unwrap_smart_ptr(const U& value);
|
|
|
|
template <class U>
|
|
static U* _unwrap_smart_ptr(const std::unique_ptr<U>& value);
|
|
|
|
template <class U>
|
|
static std::weak_ptr<U> _unwrap_smart_ptr(const std::shared_ptr<U>& value);
|
|
|
|
public:
|
|
~SendableChooser() override = default;
|
|
|
|
void AddObject(llvm::StringRef name, T object);
|
|
void AddDefault(llvm::StringRef name, T object);
|
|
|
|
auto GetSelected() -> decltype(_unwrap_smart_ptr(m_choices[""]));
|
|
|
|
void InitSendable(SendableBuilder& builder) override;
|
|
};
|
|
|
|
} // namespace frc
|
|
|
|
#include "SendableChooser.inc"
|