// 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.

#include <jni.h>

#include "CallbackStore.hpp"
#include "org_wpilib_hardware_hal_simulation_DutyCycleDataJNI.h"
#include "wpi/hal/simulation/DutyCycleData.h"

using namespace wpi::hal;

extern "C" {

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    registerInitializedCallback
 * Signature: (ILjava/lang/Object;Z)I
 */
JNIEXPORT jint JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_registerInitializedCallback
  (JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
  return sim::AllocateCallback(env, index, callback, initialNotify,
                               &HALSIM_RegisterDutyCycleInitializedCallback);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    cancelInitializedCallback
 * Signature: (II)V
 */
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_cancelInitializedCallback
  (JNIEnv* env, jclass, jint index, jint handle)
{
  return sim::FreeCallback(env, handle, index,
                           &HALSIM_CancelDutyCycleInitializedCallback);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    getInitialized
 * Signature: (I)Z
 */
JNIEXPORT jboolean JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_getInitialized
  (JNIEnv*, jclass, jint index)
{
  return HALSIM_GetDutyCycleInitialized(index);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    setInitialized
 * Signature: (IZ)V
 */
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_setInitialized
  (JNIEnv*, jclass, jint index, jboolean value)
{
  HALSIM_SetDutyCycleInitialized(index, value);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    registerFrequencyCallback
 * Signature: (ILjava/lang/Object;Z)I
 */
JNIEXPORT jint JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_registerFrequencyCallback
  (JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
  return sim::AllocateCallback(env, index, callback, initialNotify,
                               &HALSIM_RegisterDutyCycleFrequencyCallback);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    cancelFrequencyCallback
 * Signature: (II)V
 */
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_cancelFrequencyCallback
  (JNIEnv* env, jclass, jint index, jint handle)
{
  return sim::FreeCallback(env, handle, index,
                           &HALSIM_CancelDutyCycleFrequencyCallback);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    getFrequency
 * Signature: (I)D
 */
JNIEXPORT jdouble JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_getFrequency
  (JNIEnv*, jclass, jint index)
{
  return HALSIM_GetDutyCycleFrequency(index);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    setFrequency
 * Signature: (ID)V
 */
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_setFrequency
  (JNIEnv*, jclass, jint index, jdouble value)
{
  HALSIM_SetDutyCycleFrequency(index, value);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    registerOutputCallback
 * Signature: (ILjava/lang/Object;Z)I
 */
JNIEXPORT jint JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_registerOutputCallback
  (JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
  return sim::AllocateCallback(env, index, callback, initialNotify,
                               &HALSIM_RegisterDutyCycleOutputCallback);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    cancelOutputCallback
 * Signature: (II)V
 */
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_cancelOutputCallback
  (JNIEnv* env, jclass, jint index, jint handle)
{
  return sim::FreeCallback(env, handle, index,
                           &HALSIM_CancelDutyCycleOutputCallback);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    getOutput
 * Signature: (I)D
 */
JNIEXPORT jdouble JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_getOutput
  (JNIEnv*, jclass, jint index)
{
  return HALSIM_GetDutyCycleOutput(index);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    setOutput
 * Signature: (ID)V
 */
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_setOutput
  (JNIEnv*, jclass, jint index, jdouble value)
{
  HALSIM_SetDutyCycleOutput(index, value);
}

/*
 * Class:     org_wpilib_hardware_hal_simulation_DutyCycleDataJNI
 * Method:    resetData
 * Signature: (I)V
 */
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_simulation_DutyCycleDataJNI_resetData
  (JNIEnv*, jclass, jint index)
{
  HALSIM_ResetDutyCycleData(index);
}

}  // extern "C"
