2016-05-25 20:23:37 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-05-13 17:09:56 -07:00
|
|
|
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
|
2016-05-25 20:23:37 -07:00
|
|
|
/* 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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
#include "HALUtil.h"
|
2016-05-25 20:23:37 -07:00
|
|
|
#include "edu_wpi_first_wpilibj_hal_CompressorJNI.h"
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "hal/Compressor.h"
|
|
|
|
|
#include "hal/Ports.h"
|
|
|
|
|
#include "hal/Solenoid.h"
|
|
|
|
|
#include "hal/cpp/Log.h"
|
2016-05-25 20:23:37 -07:00
|
|
|
|
2016-10-31 23:04:49 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2016-05-25 20:23:37 -07:00
|
|
|
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
|
2018-05-13 17:09:56 -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-10-06 11:04:38 -07:00
|
|
|
CheckStatusRange(env, status, 0, HAL_GetNumPCMModules(), module);
|
2018-05-13 17:09:56 -07:00
|
|
|
|
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
|
2018-05-13 17:09:56 -07:00
|
|
|
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
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (I)Z
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressor
|
|
|
|
|
(JNIEnv* env, jclass, jint compressorHandle)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2016-08-12 13:45:28 -07:00
|
|
|
bool val = HAL_GetCompressor((HAL_CompressorHandle)compressorHandle, &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
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (IZ)V
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_setCompressorClosedLoopControl
|
|
|
|
|
(JNIEnv* env, jclass, jint compressorHandle, jboolean value)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
HAL_SetCompressorClosedLoopControl((HAL_CompressorHandle)compressorHandle,
|
|
|
|
|
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
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (I)Z
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorClosedLoopControl
|
|
|
|
|
(JNIEnv* env, jclass, jint compressorHandle)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
bool val = HAL_GetCompressorClosedLoopControl(
|
|
|
|
|
(HAL_CompressorHandle)compressorHandle, &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
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (I)Z
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorPressureSwitch
|
|
|
|
|
(JNIEnv* env, jclass, jint compressorHandle)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
bool val = HAL_GetCompressorPressureSwitch(
|
|
|
|
|
(HAL_CompressorHandle)compressorHandle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorCurrent
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (I)D
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
JNIEXPORT jdouble JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrent
|
|
|
|
|
(JNIEnv* env, jclass, jint compressorHandle)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
double val =
|
|
|
|
|
HAL_GetCompressorCurrent((HAL_CompressorHandle)compressorHandle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorCurrentTooHighFault
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (I)Z
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighFault
|
|
|
|
|
(JNIEnv* env, jclass, jint compressorHandle)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
bool val = HAL_GetCompressorCurrentTooHighFault(
|
|
|
|
|
(HAL_CompressorHandle)compressorHandle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorCurrentTooHighStickyFault
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (I)Z
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighStickyFault
|
|
|
|
|
(JNIEnv* env, jclass, jint compressorHandle)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
bool val = HAL_GetCompressorCurrentTooHighStickyFault(
|
|
|
|
|
(HAL_CompressorHandle)compressorHandle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorShortedStickyFault
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (I)Z
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedStickyFault
|
|
|
|
|
(JNIEnv* env, jclass, jint compressorHandle)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
bool val = HAL_GetCompressorShortedStickyFault(
|
|
|
|
|
(HAL_CompressorHandle)compressorHandle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorShortedFault
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (I)Z
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedFault
|
|
|
|
|
(JNIEnv* env, jclass, jint compressorHandle)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
bool val = HAL_GetCompressorShortedFault(
|
|
|
|
|
(HAL_CompressorHandle)compressorHandle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorNotConnectedStickyFault
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (I)Z
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedStickyFault
|
|
|
|
|
(JNIEnv* env, jclass, jint compressorHandle)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
bool val = HAL_GetCompressorNotConnectedStickyFault(
|
|
|
|
|
(HAL_CompressorHandle)compressorHandle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: getCompressorNotConnectedFault
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (I)Z
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedFault
|
|
|
|
|
(JNIEnv* env, jclass, jint compressorHandle)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
bool val = HAL_GetCompressorNotConnectedFault(
|
|
|
|
|
(HAL_CompressorHandle)compressorHandle, &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
|
|
|
|
* Method: clearAllPCMStickyFaults
|
2018-05-13 17:09:56 -07:00
|
|
|
* Signature: (B)V
|
2016-05-25 20:23:37 -07:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL
|
2018-05-13 17:09:56 -07:00
|
|
|
Java_edu_wpi_first_wpilibj_hal_CompressorJNI_clearAllPCMStickyFaults
|
|
|
|
|
(JNIEnv* env, jclass, jbyte module)
|
|
|
|
|
{
|
2016-05-25 20:23:37 -07:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
HAL_ClearAllPCMStickyFaults(static_cast<int32_t>(module), &status);
|
2016-05-25 20:23:37 -07:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // extern "C"
|