2016-05-25 20:23:37 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) FIRST 2016. 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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "HAL/HAL.h"
|
|
|
|
|
#include "HALUtil.h"
|
2016-07-14 00:17:29 -07:00
|
|
|
#include "HAL/cpp/Log.h"
|
2016-05-25 20:23:37 -07:00
|
|
|
#include "edu_wpi_first_wpilibj_hal_CompressorJNI.h"
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: initializeCompressor
|
2016-07-02 08:22:44 -07:00
|
|
|
* Signature: (B)I
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEXPORT jint JNICALL
|
2016-05-25 20:23:37 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_initializeCompressor(
|
|
|
|
|
JNIEnv *env, jclass, jbyte module) {
|
2016-07-02 08:22:44 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
auto handle = HAL_InitializeCompressor(module, &status);
|
2016-07-13 20:29:28 -07:00
|
|
|
CheckStatusRange(env, 0, HAL_GetNumPCMModules(), module, status);
|
2016-07-02 08:22:44 -07:00
|
|
|
|
|
|
|
|
return (jint)handle;
|
2016-05-25 20:23:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: checkCompressorModule
|
|
|
|
|
* Signature: (B)Z
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_checkCompressorModule(
|
|
|
|
|
JNIEnv *env, jclass, jbyte module) {
|
2016-07-09 00:24:26 -07:00
|
|
|
return HAL_CheckCompressorModule(module);
|
2016-05-25 20:23:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressor
|
|
|
|
|
* Signature: (J)Z
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressor(
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEnv *env, jclass, jint compressor_handle) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
bool val = HAL_GetCompressor((HAL_CompressorHandle)compressor_handle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
2016-07-09 01:12:37 -07:00
|
|
|
* Method: setCompressorClosedLoopControl
|
2016-05-25 20:23:37 -07:00
|
|
|
* Signature: (JZ)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2016-07-09 01:12:37 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_setCompressorClosedLoopControl(
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEnv *env, jclass, jint compressor_handle, jboolean value) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 01:12:37 -07:00
|
|
|
HAL_SetCompressorClosedLoopControl((HAL_CompressorHandle)compressor_handle, value, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
2016-07-09 01:12:37 -07:00
|
|
|
* Method: getCompressorClosedLoopControl
|
2016-05-25 20:23:37 -07:00
|
|
|
* Signature: (J)Z
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
2016-07-09 01:12:37 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorClosedLoopControl(
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEnv *env, jclass, jint compressor_handle) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 01:12:37 -07:00
|
|
|
bool val = HAL_GetCompressorClosedLoopControl((HAL_CompressorHandle)compressor_handle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
2016-07-09 01:12:37 -07:00
|
|
|
* Method: getCompressorPressureSwitch
|
2016-05-25 20:23:37 -07:00
|
|
|
* Signature: (J)Z
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
2016-07-09 01:12:37 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorPressureSwitch(
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEnv *env, jclass, jint compressor_handle) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 01:12:37 -07:00
|
|
|
bool val = HAL_GetCompressorPressureSwitch((HAL_CompressorHandle)compressor_handle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorCurrent
|
|
|
|
|
* Signature: (J)F
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jfloat JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrent(
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEnv *env, jclass, jint compressor_handle) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
float val = HAL_GetCompressorCurrent((HAL_CompressorHandle)compressor_handle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorCurrentTooHighFault
|
|
|
|
|
* Signature: (J)Z
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighFault(
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEnv *env, jclass, jint compressor_handle) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
bool val = HAL_GetCompressorCurrentTooHighFault((HAL_CompressorHandle)compressor_handle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorCurrentTooHighStickyFault
|
|
|
|
|
* Signature: (J)Z
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighStickyFault(
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEnv *env, jclass, jint compressor_handle) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
|
|
|
|
bool val =
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_GetCompressorCurrentTooHighStickyFault((HAL_CompressorHandle)compressor_handle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorShortedStickyFault
|
|
|
|
|
* Signature: (J)Z
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedStickyFault(
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEnv *env, jclass, jint compressor_handle) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
bool val = HAL_GetCompressorShortedStickyFault((HAL_CompressorHandle)compressor_handle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorShortedFault
|
|
|
|
|
* Signature: (J)Z
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedFault(
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEnv *env, jclass, jint compressor_handle) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
bool val = HAL_GetCompressorShortedFault((HAL_CompressorHandle)compressor_handle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorNotConnectedStickyFault
|
|
|
|
|
* Signature: (J)Z
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedStickyFault(
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEnv *env, jclass, jint compressor_handle) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
bool val = HAL_GetCompressorNotConnectedStickyFault((HAL_CompressorHandle)compressor_handle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorNotConnectedFault
|
|
|
|
|
* Signature: (J)Z
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedFault(
|
2016-07-02 08:22:44 -07:00
|
|
|
JNIEnv *env, jclass, jint compressor_handle) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
bool val = HAL_GetCompressorNotConnectedFault((HAL_CompressorHandle)compressor_handle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: clearAllPCMStickyFaults
|
|
|
|
|
* Signature: (J)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_clearAllPCMStickyFaults(
|
2016-07-09 01:12:37 -07:00
|
|
|
JNIEnv *env, jclass, jbyte module) {
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 01:12:37 -07:00
|
|
|
HAL_ClearAllPCMStickyFaults((uint8_t)module, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // extern "C"
|