2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2016-01-02 03:02:34 -08:00
|
|
|
|
2016-05-25 22:40:15 -07:00
|
|
|
#pragma once
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2020-01-12 22:37:24 -08:00
|
|
|
#include <functional>
|
2021-06-15 23:06:03 -07:00
|
|
|
|
|
|
|
|
#include <wpi/deprecated.h>
|
2016-09-05 13:55:31 -07:00
|
|
|
|
2021-06-13 16:38:05 -07:00
|
|
|
namespace wpi {
|
2019-09-14 15:22:54 -05:00
|
|
|
class Sendable;
|
2021-06-13 16:38:05 -07:00
|
|
|
} // namespace wpi
|
|
|
|
|
|
|
|
|
|
namespace frc {
|
2019-09-14 15:22:54 -05:00
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* The LiveWindow class is the public interface for putting sensors and
|
2017-11-16 00:33:51 -08:00
|
|
|
* actuators on the LiveWindow.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
|
|
|
|
class LiveWindow {
|
2015-06-25 15:07:55 -04:00
|
|
|
public:
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Get an instance of the LiveWindow main class.
|
|
|
|
|
*
|
|
|
|
|
* This is a singleton to guarantee that there is only a single instance
|
|
|
|
|
* regardless of how many times GetInstance is called.
|
2021-06-15 23:06:03 -07:00
|
|
|
* @deprecated Use the static methods unless guaranteeing LiveWindow is
|
|
|
|
|
* instantiated
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2021-06-15 23:06:03 -07:00
|
|
|
WPI_DEPRECATED("Use static methods")
|
2021-05-09 18:16:07 -07:00
|
|
|
static LiveWindow* GetInstance();
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2021-06-15 23:06:03 -07:00
|
|
|
/**
|
|
|
|
|
* Set function to be called when LiveWindow is enabled.
|
|
|
|
|
*
|
|
|
|
|
* @param func function (or nullptr for none)
|
|
|
|
|
*/
|
|
|
|
|
static void SetEnabledCallback(std::function<void()> func);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set function to be called when LiveWindow is disabled.
|
|
|
|
|
*
|
|
|
|
|
* @param func function (or nullptr for none)
|
|
|
|
|
*/
|
|
|
|
|
static void SetDisabledCallback(std::function<void()> func);
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Enable telemetry for a single component.
|
|
|
|
|
*
|
2021-10-14 18:09:38 -07:00
|
|
|
* @param component sendable
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2021-06-15 23:06:03 -07:00
|
|
|
static void EnableTelemetry(wpi::Sendable* component);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Disable telemetry for a single component.
|
|
|
|
|
*
|
2021-10-14 18:09:38 -07:00
|
|
|
* @param component sendable
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2021-06-15 23:06:03 -07:00
|
|
|
static void DisableTelemetry(wpi::Sendable* component);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Disable ALL telemetry.
|
|
|
|
|
*/
|
2021-06-15 23:06:03 -07:00
|
|
|
static void DisableAllTelemetry();
|
2017-12-04 23:28:33 -08:00
|
|
|
|
2021-06-15 23:06:03 -07:00
|
|
|
static bool IsEnabled();
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Change the enabled status of LiveWindow.
|
|
|
|
|
*
|
|
|
|
|
* If it changes to enabled, start livewindow running otherwise stop it
|
|
|
|
|
*/
|
2021-06-15 23:06:03 -07:00
|
|
|
static void SetEnabled(bool enabled);
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Tell all the sensors to update (send) their values.
|
|
|
|
|
*
|
|
|
|
|
* Actuators are handled through callbacks on their value changing from the
|
|
|
|
|
* SmartDashboard widgets.
|
|
|
|
|
*/
|
2021-06-15 23:06:03 -07:00
|
|
|
static void UpdateValues();
|
2014-06-13 17:45:10 -04:00
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
private:
|
2021-06-15 23:06:03 -07:00
|
|
|
LiveWindow() = default;
|
2018-12-07 22:38:22 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the entries, without using a mutex or lock.
|
|
|
|
|
*/
|
2021-06-15 23:06:03 -07:00
|
|
|
static void UpdateValuesUnsafe();
|
2013-12-15 18:30:16 -05:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|