2020-12-26 14:12:05 -08:00
|
|
|
// 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.
|
2018-05-11 12:38:23 -07:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-07-15 23:48:09 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2026-01-04 00:41:53 -08:00
|
|
|
#include "wpi/hal/DriverStationTypes.hpp"
|
2026-03-13 17:19:39 -07:00
|
|
|
#include "wpi/hal/HAL.h"
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/units/time.hpp"
|
2018-05-11 12:38:23 -07:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
namespace wpi::sim {
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Override the HAL runtime type (simulated/real).
|
|
|
|
|
*
|
|
|
|
|
* @param type runtime type
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void SetRuntimeType(HAL_RuntimeType type);
|
2020-06-26 20:46:13 -07:00
|
|
|
|
2025-11-29 10:10:01 -08:00
|
|
|
/**
|
|
|
|
|
* Waits until the user program has started.
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void WaitForProgramStart();
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2025-11-29 10:10:01 -08:00
|
|
|
/**
|
|
|
|
|
* Sets flag that indicates if the user program has started.
|
|
|
|
|
*
|
|
|
|
|
* @param started true if started
|
|
|
|
|
*/
|
|
|
|
|
void SetProgramStarted(bool started);
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2025-11-29 10:10:01 -08:00
|
|
|
/**
|
|
|
|
|
* Returns true if the user program has started.
|
|
|
|
|
*
|
|
|
|
|
* @return True if the user program has started.
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
bool GetProgramStarted();
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2025-12-12 21:25:57 -07:00
|
|
|
/**
|
|
|
|
|
* Sets the user program state (control word).
|
|
|
|
|
*
|
|
|
|
|
* @param controlWord control word
|
|
|
|
|
*/
|
|
|
|
|
void SetProgramState(wpi::hal::ControlWord controlWord);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the user program state (control word).
|
|
|
|
|
*
|
|
|
|
|
* @return Control word
|
|
|
|
|
*/
|
|
|
|
|
wpi::hal::ControlWord GetProgramState();
|
|
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Restart the simulator time.
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void RestartTiming();
|
2018-08-16 01:17:59 -04:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Pause the simulator time.
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void PauseTiming();
|
2020-06-20 23:47:55 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Resume the simulator time.
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
void ResumeTiming();
|
2020-06-20 23:47:55 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Check if the simulator time is paused.
|
|
|
|
|
*
|
|
|
|
|
* @return true if paused
|
|
|
|
|
*/
|
2020-07-15 23:48:09 -07:00
|
|
|
bool IsTimingPaused();
|
2020-06-20 23:47:55 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Advance the simulator time and wait for all notifiers to run.
|
|
|
|
|
*
|
2021-10-29 15:07:05 -07:00
|
|
|
* @param delta the amount to advance (in seconds)
|
2021-01-11 21:55:45 -08:00
|
|
|
*/
|
2025-11-07 20:00:05 -05:00
|
|
|
void StepTiming(wpi::units::second_t delta);
|
2020-06-20 23:47:55 -07:00
|
|
|
|
2021-01-11 21:55:45 -08:00
|
|
|
/**
|
|
|
|
|
* Advance the simulator time and return immediately.
|
|
|
|
|
*
|
2021-10-29 15:07:05 -07:00
|
|
|
* @param delta the amount to advance (in seconds)
|
2021-01-11 21:55:45 -08:00
|
|
|
*/
|
2025-11-07 20:00:05 -05:00
|
|
|
void StepTimingAsync(wpi::units::second_t delta);
|
2020-09-27 13:27:53 -07:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
} // namespace wpi::sim
|