001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.wpilibj.simulation; 006 007import edu.wpi.first.hal.simulation.SimulatorJNI; 008 009public final class SimHooks { 010 private SimHooks() {} 011 012 /** 013 * Override the HAL runtime type (simulated/real). 014 * 015 * @param type runtime type 016 */ 017 public static void setHALRuntimeType(int type) { 018 SimulatorJNI.setRuntimeType(type); 019 } 020 021 public static void waitForProgramStart() { 022 SimulatorJNI.waitForProgramStart(); 023 } 024 025 public static void setProgramStarted() { 026 SimulatorJNI.setProgramStarted(); 027 } 028 029 public static boolean getProgramStarted() { 030 return SimulatorJNI.getProgramStarted(); 031 } 032 033 /** Restart the simulator time. */ 034 public static void restartTiming() { 035 SimulatorJNI.restartTiming(); 036 } 037 038 /** Pause the simulator time. */ 039 public static void pauseTiming() { 040 SimulatorJNI.pauseTiming(); 041 } 042 043 /** Resume the simulator time. */ 044 public static void resumeTiming() { 045 SimulatorJNI.resumeTiming(); 046 } 047 048 /** 049 * Check if the simulator time is paused. 050 * 051 * @return true if paused 052 */ 053 public static boolean isTimingPaused() { 054 return SimulatorJNI.isTimingPaused(); 055 } 056 057 /** 058 * Advance the simulator time and wait for all notifiers to run. 059 * 060 * @param deltaSeconds the amount to advance (in seconds) 061 */ 062 public static void stepTiming(double deltaSeconds) { 063 SimulatorJNI.stepTiming((long) (deltaSeconds * 1e6)); 064 } 065 066 /** 067 * Advance the simulator time and return immediately. 068 * 069 * @param deltaSeconds the amount to advance (in seconds) 070 */ 071 public static void stepTimingAsync(double deltaSeconds) { 072 SimulatorJNI.stepTimingAsync((long) (deltaSeconds * 1e6)); 073 } 074}