mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Fix main function initialization (#1176)
I don't have a good way to ensure this always works, so this is going to be a documentation issue. But initializeHardwareConfiguration is now reentrant, so we can just have all tests call it.
This commit is contained in:
committed by
Peter Johnson
parent
f5b1028b5a
commit
89d15f061b
@@ -10,9 +10,10 @@
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
#include <HAL/HAL.h>
|
||||
|
||||
#include "Buttons/ButtonScheduler.h"
|
||||
#include "Commands/Subsystem.h"
|
||||
#include "HLUsageReporting.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -166,7 +167,8 @@ void Scheduler::InitSendable(SendableBuilder& builder) {
|
||||
}
|
||||
|
||||
Scheduler::Scheduler() {
|
||||
HLUsageReporting::ReportScheduler();
|
||||
HAL_Report(HALUsageReporting::kResourceType_Command,
|
||||
HALUsageReporting::kCommand_Scheduler);
|
||||
SetName("Scheduler");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2016-2018 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "HLUsageReporting.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
HLUsageReportingInterface* HLUsageReporting::impl = nullptr;
|
||||
|
||||
void HLUsageReporting::SetImplementation(HLUsageReportingInterface* i) {
|
||||
impl = i;
|
||||
}
|
||||
|
||||
void HLUsageReporting::ReportScheduler() {
|
||||
if (impl != nullptr) {
|
||||
impl->ReportScheduler();
|
||||
}
|
||||
}
|
||||
|
||||
void HLUsageReporting::ReportSmartDashboard() {
|
||||
if (impl != nullptr) {
|
||||
impl->ReportSmartDashboard();
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2016-2018 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "Internal/HardwareHLReporting.h"
|
||||
|
||||
#include <HAL/HAL.h>
|
||||
|
||||
using namespace frc;
|
||||
|
||||
void HardwareHLReporting::ReportScheduler() {
|
||||
HAL_Report(HALUsageReporting::kResourceType_Command,
|
||||
HALUsageReporting::kCommand_Scheduler);
|
||||
}
|
||||
|
||||
void HardwareHLReporting::ReportSmartDashboard() {
|
||||
HAL_Report(HALUsageReporting::kResourceType_SmartDashboard, 0);
|
||||
}
|
||||
@@ -14,8 +14,6 @@
|
||||
|
||||
#include "CameraServerShared.h"
|
||||
#include "DriverStation.h"
|
||||
#include "HLUsageReporting.h"
|
||||
#include "Internal/HardwareHLReporting.h"
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "RobotState.h"
|
||||
#include "SmartDashboard/SmartDashboard.h"
|
||||
@@ -80,9 +78,6 @@ RobotBase::RobotBase() : m_ds(DriverStation::GetInstance()) {
|
||||
}
|
||||
m_threadId = std::this_thread::get_id();
|
||||
|
||||
RobotState::SetImplementation(DriverStation::GetInstance());
|
||||
HLUsageReporting::SetImplementation(new HardwareHLReporting());
|
||||
|
||||
SetupCameraServerShared();
|
||||
|
||||
auto inst = nt::NetworkTableInstance::GetDefault();
|
||||
|
||||
@@ -7,52 +7,24 @@
|
||||
|
||||
#include "RobotState.h"
|
||||
|
||||
#include "Base.h"
|
||||
#include "DriverStation.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
std::shared_ptr<RobotStateInterface> RobotState::impl;
|
||||
|
||||
void RobotState::SetImplementation(RobotStateInterface& i) {
|
||||
impl = std::shared_ptr<RobotStateInterface>(
|
||||
&i, NullDeleter<RobotStateInterface>());
|
||||
}
|
||||
|
||||
void RobotState::SetImplementation(std::shared_ptr<RobotStateInterface> i) {
|
||||
impl = i;
|
||||
}
|
||||
|
||||
bool RobotState::IsDisabled() {
|
||||
if (impl != nullptr) {
|
||||
return impl->IsDisabled();
|
||||
}
|
||||
return true;
|
||||
return DriverStation::GetInstance().IsDisabled();
|
||||
}
|
||||
|
||||
bool RobotState::IsEnabled() {
|
||||
if (impl != nullptr) {
|
||||
return impl->IsEnabled();
|
||||
}
|
||||
return false;
|
||||
return DriverStation::GetInstance().IsEnabled();
|
||||
}
|
||||
|
||||
bool RobotState::IsOperatorControl() {
|
||||
if (impl != nullptr) {
|
||||
return impl->IsOperatorControl();
|
||||
}
|
||||
return true;
|
||||
return DriverStation::GetInstance().IsOperatorControl();
|
||||
}
|
||||
|
||||
bool RobotState::IsAutonomous() {
|
||||
if (impl != nullptr) {
|
||||
return impl->IsAutonomous();
|
||||
}
|
||||
return false;
|
||||
return DriverStation::GetInstance().IsAutonomous();
|
||||
}
|
||||
|
||||
bool RobotState::IsTest() {
|
||||
if (impl != nullptr) {
|
||||
return impl->IsTest();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool RobotState::IsTest() { return DriverStation::GetInstance().IsTest(); }
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
#include "SmartDashboard/SmartDashboard.h"
|
||||
|
||||
#include <HAL/HAL.h>
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <networktables/NetworkTableInstance.h>
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "HLUsageReporting.h"
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "SmartDashboard/SendableBuilderImpl.h"
|
||||
#include "WPIErrors.h"
|
||||
@@ -40,7 +40,7 @@ class Singleton {
|
||||
private:
|
||||
Singleton() {
|
||||
table = nt::NetworkTableInstance::GetDefault().GetTable("SmartDashboard");
|
||||
HLUsageReporting::ReportSmartDashboard();
|
||||
HAL_Report(HALUsageReporting::kResourceType_SmartDashboard, 0);
|
||||
}
|
||||
Singleton(const Singleton&) = delete;
|
||||
Singleton& operator=(const Singleton&) = delete;
|
||||
|
||||
Reference in New Issue
Block a user