2017-12-04 23:28:33 -08:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
2017-12-04 23:28:33 -08:00
|
|
|
/* 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 <string>
|
|
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
#include <wpi/mutex.h>
|
2017-12-04 23:28:33 -08:00
|
|
|
|
|
|
|
|
#include "Sendable.h"
|
|
|
|
|
|
|
|
|
|
namespace frc {
|
|
|
|
|
|
|
|
|
|
class SendableBase : public Sendable {
|
|
|
|
|
public:
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Creates an instance of the sensor base.
|
|
|
|
|
*
|
|
|
|
|
* @param addLiveWindow if true, add this Sendable to LiveWindow
|
|
|
|
|
*/
|
2017-12-04 23:28:33 -08:00
|
|
|
explicit SendableBase(bool addLiveWindow = true);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
~SendableBase() override;
|
|
|
|
|
|
|
|
|
|
using Sendable::SetName;
|
|
|
|
|
|
|
|
|
|
std::string GetName() const final;
|
2018-04-29 23:33:19 -07:00
|
|
|
void SetName(const wpi::Twine& name) final;
|
2017-12-04 23:28:33 -08:00
|
|
|
std::string GetSubsystem() const final;
|
2018-04-29 23:33:19 -07:00
|
|
|
void SetSubsystem(const wpi::Twine& subsystem) final;
|
2017-12-04 23:28:33 -08:00
|
|
|
|
|
|
|
|
protected:
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Add a child component.
|
|
|
|
|
*
|
|
|
|
|
* @param child child component
|
|
|
|
|
*/
|
2017-12-04 23:28:33 -08:00
|
|
|
void AddChild(std::shared_ptr<Sendable> child);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a child component.
|
|
|
|
|
*
|
|
|
|
|
* @param child child component
|
|
|
|
|
*/
|
2017-12-04 23:28:33 -08:00
|
|
|
void AddChild(void* child);
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Sets the name of the sensor with a channel number.
|
|
|
|
|
*
|
|
|
|
|
* @param moduleType A string that defines the module name in the label for
|
|
|
|
|
* the value
|
|
|
|
|
* @param channel The channel number the device is plugged into
|
|
|
|
|
*/
|
2018-04-29 23:33:19 -07:00
|
|
|
void SetName(const wpi::Twine& moduleType, int channel);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the name of the sensor with a module and channel number.
|
|
|
|
|
*
|
|
|
|
|
* @param moduleType A string that defines the module name in the label for
|
|
|
|
|
* the value
|
|
|
|
|
* @param moduleNumber The number of the particular module type
|
|
|
|
|
* @param channel The channel number the device is plugged into (usually
|
|
|
|
|
* PWM)
|
|
|
|
|
*/
|
2018-04-29 23:33:19 -07:00
|
|
|
void SetName(const wpi::Twine& moduleType, int moduleNumber, int channel);
|
2017-12-04 23:28:33 -08:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
mutable wpi::mutex m_mutex;
|
|
|
|
|
std::string m_name;
|
|
|
|
|
std::string m_subsystem = "Ungrouped";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace frc
|