mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Add DriverStation NetworkTables HAL Extension (#829)
This commit is contained in:
37
simulation/halsim_ds_nt/src/main/native/include/HALSimDsNt.h
Normal file
37
simulation/halsim_ds_nt/src/main/native/include/HALSimDsNt.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
#include <MockData/DriverStationData.h>
|
||||
#include <networktables/NetworkTableInstance.h>
|
||||
#include <support/mutex.h>
|
||||
|
||||
enum HALSimDSNT_Mode { teleop, auton, test };
|
||||
|
||||
class HALSimDSNT {
|
||||
public:
|
||||
std::shared_ptr<nt::NetworkTable> rootTable, modeTable, allianceTable;
|
||||
enum HALSimDSNT_Mode currentMode;
|
||||
bool isEnabled, lastIsEnabled, isEstop;
|
||||
std::atomic<bool> isAllianceRed, running;
|
||||
std::atomic<double> currentMatchTime, timingHz, allianceStation;
|
||||
std::thread loopThread;
|
||||
wpi::mutex modeMutex;
|
||||
|
||||
void Initialize();
|
||||
void HandleModePress(enum HALSimDSNT_Mode mode, bool isPressed);
|
||||
void UpdateModeButtons();
|
||||
void DoModeUpdate();
|
||||
void DoAllianceUpdate();
|
||||
void LoopFunc();
|
||||
void Flush();
|
||||
};
|
||||
Reference in New Issue
Block a user