Add DriverStation NetworkTables HAL Extension (#829)

This commit is contained in:
Jaci R
2017-12-30 14:55:31 +11:00
committed by Peter Johnson
parent 76b182600a
commit 8d1dee16be
6 changed files with 410 additions and 0 deletions

View 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();
};