Files
allwpilib/wpilibj/src/athena/cpp/lib/SolenoidJNI.cpp

161 lines
4.7 KiB
C++
Raw Normal View History

/*----------------------------------------------------------------------------*/
/* 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 <jni.h>
#include "HAL/HAL.h"
#include "Log.h"
#include "edu_wpi_first_wpilibj_hal_SolenoidJNI.h"
#include "HALUtil.h"
TLogLevel solenoidJNILogLevel = logERROR;
#define SOLENOIDJNI_LOG(level) \
if (level > solenoidJNILogLevel) \
; \
else \
Log().Get(level)
extern "C" {
/*
* Class: edu_wpi_first_wpilibj_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_wpilibj_hal_SolenoidJNI_initializeSolenoidPort(
JNIEnv *env, jclass, jint port_handle) {
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI initializeSolenoidPort";
SOLENOIDJNI_LOG(logDEBUG) << "Port Handle = " << (HAL_PortHandle)port_handle;
int32_t status = 0;
HAL_SolenoidHandle handle =
HAL_InitializeSolenoidPort((HAL_PortHandle)port_handle, &status);
SOLENOIDJNI_LOG(logDEBUG) << "Status = " << status;
2016-07-02 09:24:54 -07:00
SOLENOIDJNI_LOG(logDEBUG) << "Solenoid Port Handle = " << handle;
CheckStatus(env, status);
2016-07-02 09:24:54 -07:00
return (jint)handle;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: freeSolenoidPort
2016-07-02 09:24:54 -07:00
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_freeSolenoidPort(
2016-07-02 09:24:54 -07:00
JNIEnv *env, jclass, jint id) {
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI initializeSolenoidPort";
SOLENOIDJNI_LOG(logDEBUG) << "Port Handle = " << (HAL_SolenoidHandle)id;
HAL_FreeSolenoidPort((HAL_SolenoidHandle)id);
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: setSolenoid
2016-07-02 09:24:54 -07:00
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_setSolenoid(
2016-07-02 09:24:54 -07:00
JNIEnv *env, jclass, jint solenoid_port, jboolean value) {
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI SetSolenoid";
2016-07-02 09:24:54 -07:00
SOLENOIDJNI_LOG(logDEBUG) << "Solenoid Port Handle = "
<< (HAL_SolenoidHandle)solenoid_port;
int32_t status = 0;
HAL_SetSolenoid((HAL_SolenoidHandle)solenoid_port, value, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: getSolenoid
2016-07-02 09:24:54 -07:00
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getSolenoid(
2016-07-02 09:24:54 -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_wpilibj_hal_SolenoidJNI
* Method: getAllSolenoids
2016-07-02 09:24:54 -07:00
* Signature: (B)Z
*/
JNIEXPORT jbyte JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getAllSolenoids(
2016-07-02 09:24:54 -07:00
JNIEnv *env, jclass, jbyte module) {
int32_t status = 0;
jbyte val = HAL_GetAllSolenoids(module, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: getPCMSolenoidBlackList
2016-07-02 09:24:54 -07:00
* Signature: (B)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidBlackList(
2016-07-02 09:24:54 -07:00
JNIEnv *env, jclass, jbyte module) {
int32_t status = 0;
jint val = HAL_GetPCMSolenoidBlackList(module, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: getPCMSolenoidVoltageStickyFault
2016-07-02 09:24:54 -07:00
* Signature: (B)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageStickyFault(
2016-07-02 09:24:54 -07:00
JNIEnv *env, jclass, jbyte module) {
int32_t status = 0;
bool val = HAL_GetPCMSolenoidVoltageStickyFault(module, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: getPCMSolenoidVoltageFault
2016-07-02 09:24:54 -07:00
* Signature: (B)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageFault(
2016-07-02 09:24:54 -07:00
JNIEnv *env, jclass, jbyte module) {
int32_t status = 0;
bool val = HAL_GetPCMSolenoidVoltageFault(module, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: clearAllPCMStickyFaults
2016-07-02 09:24:54 -07:00
* Signature: (B)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_clearAllPCMStickyFaults(
2016-07-02 09:24:54 -07:00
JNIEnv *env, jclass, jbyte module) {
int32_t status = 0;
2016-07-09 01:12:37 -07:00
HAL_ClearAllPCMStickyFaults(module, &status);
CheckStatus(env, status);
}
} // extern "C"