mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
[hal] Update runtime enum to allow selecting roborio 2 (#3565)
In some cases, knowing roborio 2 might be useful. This also creates a higher level enum that might be usable later for the discussion on more complex runtime types.
This commit is contained in:
@@ -25,6 +25,13 @@
|
||||
#include "frc/livewindow/LiveWindow.h"
|
||||
#include "frc/smartdashboard/SmartDashboard.h"
|
||||
|
||||
static_assert(frc::RuntimeType::kRoboRIO ==
|
||||
static_cast<frc::RuntimeType>(HAL_Runtime_RoboRIO));
|
||||
static_assert(frc::RuntimeType::kRoboRIO2 ==
|
||||
static_cast<frc::RuntimeType>(HAL_Runtime_RoboRIO2));
|
||||
static_assert(frc::RuntimeType::kSimulation ==
|
||||
static_cast<frc::RuntimeType>(HAL_Runtime_Simulation));
|
||||
|
||||
using SetCameraServerSharedFP = void (*)(frc::CameraServerShared*);
|
||||
|
||||
using namespace frc;
|
||||
@@ -213,6 +220,10 @@ std::thread::id RobotBase::GetThreadId() {
|
||||
return m_threadId;
|
||||
}
|
||||
|
||||
RuntimeType RobotBase::GetRuntimeType() {
|
||||
return static_cast<RuntimeType>(HAL_GetRuntimeType());
|
||||
}
|
||||
|
||||
RobotBase::RobotBase() {
|
||||
m_threadId = std::this_thread::get_id();
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
#include "frc/RuntimeType.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -211,6 +212,13 @@ class RobotBase {
|
||||
|
||||
virtual void EndCompetition() = 0;
|
||||
|
||||
/**
|
||||
* Get the current runtime type.
|
||||
*
|
||||
* @return Current runtime type.
|
||||
*/
|
||||
static RuntimeType GetRuntimeType();
|
||||
|
||||
/**
|
||||
* Get if the robot is real.
|
||||
*
|
||||
|
||||
9
wpilibc/src/main/native/include/frc/RuntimeType.h
Normal file
9
wpilibc/src/main/native/include/frc/RuntimeType.h
Normal file
@@ -0,0 +1,9 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace frc {
|
||||
enum RuntimeType { kRoboRIO, kRoboRIO2, kSimulation };
|
||||
} // namespace frc
|
||||
Reference in New Issue
Block a user