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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/smartdashboard/SendableBase.h"
|
2017-12-04 23:28:33 -08:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/livewindow/LiveWindow.h"
|
2017-12-04 23:28:33 -08:00
|
|
|
|
|
|
|
|
using namespace frc;
|
|
|
|
|
|
|
|
|
|
SendableBase::SendableBase(bool addLiveWindow) {
|
|
|
|
|
if (addLiveWindow) LiveWindow::GetInstance()->Add(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SendableBase::~SendableBase() { LiveWindow::GetInstance()->Remove(this); }
|
|
|
|
|
|
|
|
|
|
std::string SendableBase::GetName() const {
|
|
|
|
|
std::lock_guard<wpi::mutex> lock(m_mutex);
|
|
|
|
|
return m_name;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
void SendableBase::SetName(const wpi::Twine& name) {
|
2017-12-04 23:28:33 -08:00
|
|
|
std::lock_guard<wpi::mutex> lock(m_mutex);
|
|
|
|
|
m_name = name.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string SendableBase::GetSubsystem() const {
|
|
|
|
|
std::lock_guard<wpi::mutex> lock(m_mutex);
|
|
|
|
|
return m_subsystem;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
void SendableBase::SetSubsystem(const wpi::Twine& subsystem) {
|
2017-12-04 23:28:33 -08:00
|
|
|
std::lock_guard<wpi::mutex> lock(m_mutex);
|
|
|
|
|
m_subsystem = subsystem.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SendableBase::AddChild(std::shared_ptr<Sendable> child) {
|
|
|
|
|
LiveWindow::GetInstance()->AddChild(this, child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SendableBase::AddChild(void* child) {
|
|
|
|
|
LiveWindow::GetInstance()->AddChild(this, child);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
void SendableBase::SetName(const wpi::Twine& moduleType, int channel) {
|
2018-05-13 17:09:56 -07:00
|
|
|
SetName(moduleType + wpi::Twine('[') + wpi::Twine(channel) + wpi::Twine(']'));
|
2017-12-04 23:28:33 -08:00
|
|
|
}
|
|
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
void SendableBase::SetName(const wpi::Twine& moduleType, int moduleNumber,
|
2017-12-04 23:28:33 -08:00
|
|
|
int channel) {
|
2018-04-29 23:33:19 -07:00
|
|
|
SetName(moduleType + wpi::Twine('[') + wpi::Twine(moduleNumber) +
|
|
|
|
|
wpi::Twine(',') + wpi::Twine(channel) + wpi::Twine(']'));
|
2017-12-04 23:28:33 -08:00
|
|
|
}
|