Files
allwpilib/hal/src/main/native/cpp/jni/SolenoidJNI.cpp

201 lines
4.9 KiB
C++
Raw Normal View History

// 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>
2018-05-13 17:09:56 -07:00
#include "HALUtil.h"
#include "edu_wpi_first_hal_SolenoidJNI.h"
#include "hal/Ports.h"
#include "hal/Solenoid.h"
#include "hal/handles/HandlesInternal.h"
using namespace hal;
extern "C" {
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: initializeSolenoidPort
2016-07-02 09:24:54 -07:00
* Signature: (I)I
*/
2016-07-02 09:24:54 -07:00
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_initializeSolenoidPort
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
HAL_SolenoidHandle handle =
HAL_InitializeSolenoidPort((HAL_PortHandle)id, &status);
// Use solenoid channels, as we have to pick one.
CheckStatusRange(env, status, 0, HAL_GetNumSolenoidChannels(),
hal::getPortHandleChannel((HAL_PortHandle)id));
2016-07-02 09:24:54 -07:00
return (jint)handle;
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: checkSolenoidChannel
2018-05-13 17:09:56 -07:00
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_checkSolenoidChannel
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint channel)
{
return HAL_CheckSolenoidChannel(channel);
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: checkSolenoidModule
2018-05-13 17:09:56 -07:00
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_checkSolenoidModule
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint module)
{
return HAL_CheckSolenoidModule(module);
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: freeSolenoidPort
2016-07-02 09:24:54 -07:00
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_freeSolenoidPort
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint id)
{
HAL_FreeSolenoidPort((HAL_SolenoidHandle)id);
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: setSolenoid
2016-07-02 09:24:54 -07:00
* Signature: (IZ)V
*/
2018-05-13 17:09:56 -07:00
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_setSolenoid
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint solenoid_port, jboolean value)
{
int32_t status = 0;
HAL_SetSolenoid((HAL_SolenoidHandle)solenoid_port, value, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: getSolenoid
2016-07-02 09:24:54 -07:00
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_getSolenoid
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint solenoid_port)
{
int32_t status = 0;
jboolean val = HAL_GetSolenoid((HAL_SolenoidHandle)solenoid_port, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: getAllSolenoids
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_getAllSolenoids
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint module)
{
int32_t status = 0;
jint val = HAL_GetAllSolenoids(module, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: getPCMSolenoidBlackList
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_getPCMSolenoidBlackList
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint module)
{
int32_t status = 0;
jint val = HAL_GetPCMSolenoidBlackList(module, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: getPCMSolenoidVoltageStickyFault
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_getPCMSolenoidVoltageStickyFault
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint module)
{
int32_t status = 0;
bool val = HAL_GetPCMSolenoidVoltageStickyFault(module, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: getPCMSolenoidVoltageFault
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_getPCMSolenoidVoltageFault
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint module)
{
int32_t status = 0;
bool val = HAL_GetPCMSolenoidVoltageFault(module, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: clearAllPCMStickyFaults
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_clearAllPCMStickyFaults
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint module)
{
int32_t status = 0;
2016-07-09 01:12:37 -07:00
HAL_ClearAllPCMStickyFaults(module, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: setOneShotDuration
* Signature: (IJ)V
*/
2018-05-13 17:09:56 -07:00
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_setOneShotDuration
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint solenoid_port, jlong durationMS)
{
int32_t status = 0;
2018-05-13 17:09:56 -07:00
HAL_SetOneShotDuration((HAL_SolenoidHandle)solenoid_port, durationMS,
&status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_SolenoidJNI
* Method: fireOneShot
* Signature: (I)V
*/
2018-05-13 17:09:56 -07:00
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_SolenoidJNI_fireOneShot
2018-05-13 17:09:56 -07:00
(JNIEnv* env, jclass, jint solenoid_port)
{
int32_t status = 0;
HAL_FireOneShot((HAL_SolenoidHandle)solenoid_port, &status);
CheckStatus(env, status);
}
} // extern "C"