2014-05-29 14:25:09 -04:00
|
|
|
#include <jni.h>
|
2014-05-29 18:11:01 -04:00
|
|
|
#include "Log.hpp"
|
|
|
|
|
#include "HAL/HAL.hpp"
|
2014-05-29 14:25:09 -04:00
|
|
|
|
|
|
|
|
#include "edu_wpi_first_wpilibj_hal_SolenoidJNI.h"
|
|
|
|
|
|
2015-11-01 09:11:52 -08:00
|
|
|
#include "HALUtil.h"
|
|
|
|
|
|
2014-05-30 14:04:05 -04:00
|
|
|
TLogLevel solenoidJNILogLevel = logERROR;
|
2014-05-29 14:25:09 -04:00
|
|
|
|
|
|
|
|
#define SOLENOIDJNI_LOG(level) \
|
|
|
|
|
if (level > solenoidJNILogLevel) ; \
|
|
|
|
|
else Log().Get(level)
|
|
|
|
|
|
2015-11-01 09:11:52 -08:00
|
|
|
extern "C" {
|
2014-05-29 14:25:09 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
|
|
|
|
* Method: initializeSolenoidPort
|
2015-11-01 09:11:52 -08:00
|
|
|
* Signature: (J)J
|
2014-05-29 14:25:09 -04:00
|
|
|
*/
|
2015-11-01 09:11:52 -08:00
|
|
|
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_initializeSolenoidPort
|
|
|
|
|
(JNIEnv *env, jclass, jlong port_pointer)
|
2014-05-29 14:25:09 -04:00
|
|
|
{
|
|
|
|
|
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI initializeSolenoidPort";
|
|
|
|
|
|
2015-11-01 09:11:52 -08:00
|
|
|
SOLENOIDJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)port_pointer;
|
|
|
|
|
char *aschars = (char *)port_pointer;
|
2014-05-29 14:25:09 -04:00
|
|
|
SOLENOIDJNI_LOG(logDEBUG) << '\t' << (int)aschars[0] << '\t' << (int)aschars[1] << std::endl;
|
|
|
|
|
|
2015-11-01 09:11:52 -08:00
|
|
|
int32_t status = 0;
|
|
|
|
|
void* solenoid_port_pointer = initializeSolenoidPort((void*)port_pointer, &status);
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2015-11-01 09:11:52 -08:00
|
|
|
SOLENOIDJNI_LOG(logDEBUG) << "Status = " << status;
|
|
|
|
|
SOLENOIDJNI_LOG(logDEBUG) << "Solenoid Port Pointer = " << solenoid_port_pointer;
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2015-11-01 09:11:52 -08:00
|
|
|
int *asints = (int *)solenoid_port_pointer;
|
2014-05-29 14:25:09 -04:00
|
|
|
SOLENOIDJNI_LOG(logDEBUG) << '\t' << asints[0] << '\t' << asints[1] << std::endl;
|
2015-11-01 09:11:52 -08:00
|
|
|
|
|
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return (jlong)solenoid_port_pointer;
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
2015-10-20 10:37:04 -07:00
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
|
|
|
|
* Method: freeSolenoidPort
|
|
|
|
|
* Signature: (J)V
|
|
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_freeSolenoidPort
|
|
|
|
|
(JNIEnv *env, jclass, jlong id)
|
|
|
|
|
{
|
|
|
|
|
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI initializeSolenoidPort";
|
|
|
|
|
|
|
|
|
|
SOLENOIDJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
|
|
|
|
|
freeSolenoidPort((void*)id);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-29 14:25:09 -04:00
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
|
|
|
|
* Method: getPortWithModule
|
2015-11-01 09:11:52 -08:00
|
|
|
* Signature: (BB)J
|
2014-05-29 14:25:09 -04:00
|
|
|
*/
|
2015-11-01 09:11:52 -08:00
|
|
|
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPortWithModule
|
2014-05-29 14:25:09 -04:00
|
|
|
(JNIEnv *env, jclass, jbyte module, jbyte channel)
|
|
|
|
|
{
|
2015-11-01 09:11:52 -08:00
|
|
|
void* port_pointer = getPortWithModule(module, channel);
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2015-11-01 09:11:52 -08:00
|
|
|
return (jlong)port_pointer;
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
|
|
|
|
* Method: setSolenoid
|
2015-11-01 09:11:52 -08:00
|
|
|
* Signature: (JZ)V
|
2014-05-29 14:25:09 -04:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_setSolenoid
|
2015-11-01 09:11:52 -08:00
|
|
|
(JNIEnv *env, jclass, jlong solenoid_port, jboolean value)
|
2014-05-29 14:25:09 -04:00
|
|
|
{
|
|
|
|
|
SOLENOIDJNI_LOG(logDEBUG) << "Calling SolenoidJNI SetSolenoid";
|
|
|
|
|
|
2015-11-01 09:11:52 -08:00
|
|
|
SOLENOIDJNI_LOG(logDEBUG) << "Solenoid Port Pointer = " << (void*)solenoid_port;
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2015-11-01 09:11:52 -08:00
|
|
|
int32_t status = 0;
|
|
|
|
|
setSolenoid((void*)solenoid_port, value, &status);
|
|
|
|
|
CheckStatus(env, status);
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
|
|
|
|
* Method: getSolenoid
|
2015-11-01 09:11:52 -08:00
|
|
|
* Signature: (J)Z
|
2014-05-29 14:25:09 -04:00
|
|
|
*/
|
2015-11-01 09:11:52 -08:00
|
|
|
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getSolenoid
|
|
|
|
|
(JNIEnv *env, jclass, jlong solenoid_port)
|
2014-05-29 14:25:09 -04:00
|
|
|
{
|
2015-11-01 09:11:52 -08:00
|
|
|
int32_t status = 0;
|
|
|
|
|
jboolean val = getSolenoid((void*)solenoid_port, &status);
|
|
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
2014-12-26 19:40:39 -05:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
|
|
|
|
* Method: getPCMSolenoidBlackList
|
2015-11-01 09:11:52 -08:00
|
|
|
* Signature: (J)I
|
2014-12-26 19:40:39 -05:00
|
|
|
*/
|
2015-11-01 09:11:52 -08:00
|
|
|
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidBlackList
|
|
|
|
|
(JNIEnv *env, jclass, jlong solenoid_port)
|
2014-12-26 19:40:39 -05:00
|
|
|
{
|
2015-11-01 09:11:52 -08:00
|
|
|
int32_t status = 0;
|
|
|
|
|
jint val = getPCMSolenoidBlackList((void*)solenoid_port, &status);
|
|
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
|
|
|
|
* Method: getPCMSolenoidVoltageStickyFault
|
2015-11-01 09:11:52 -08:00
|
|
|
* Signature: (J)Z
|
2014-12-26 19:40:39 -05:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageStickyFault
|
2015-11-01 09:11:52 -08:00
|
|
|
(JNIEnv *env, jclass, jlong solenoid_port)
|
2014-12-26 19:40:39 -05:00
|
|
|
{
|
2015-11-01 09:11:52 -08:00
|
|
|
int32_t status = 0;
|
|
|
|
|
bool val = getPCMSolenoidVoltageStickyFault((void*)solenoid_port, &status);
|
|
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
|
|
|
|
* Method: getPCMSolenoidVoltageFault
|
2015-11-01 09:11:52 -08:00
|
|
|
* Signature: (J)Z
|
2014-12-26 19:40:39 -05:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageFault
|
2015-11-01 09:11:52 -08:00
|
|
|
(JNIEnv *env, jclass, jlong solenoid_port)
|
2014-12-26 19:40:39 -05:00
|
|
|
{
|
2015-11-01 09:11:52 -08:00
|
|
|
int32_t status = 0;
|
|
|
|
|
bool val = getPCMSolenoidVoltageFault((void*)solenoid_port, &status);
|
|
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return val;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
|
|
|
|
* Method: clearAllPCMStickyFaults
|
2015-11-01 09:11:52 -08:00
|
|
|
* Signature: (J)V
|
2014-12-26 19:40:39 -05:00
|
|
|
*/
|
|
|
|
|
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_clearAllPCMStickyFaults
|
2015-11-01 09:11:52 -08:00
|
|
|
(JNIEnv *env, jclass, jlong solenoid_port)
|
2014-12-26 19:40:39 -05:00
|
|
|
{
|
2015-11-01 09:11:52 -08:00
|
|
|
int32_t status = 0;
|
|
|
|
|
clearAllPCMStickyFaults_sol((void*)solenoid_port, &status);
|
|
|
|
|
CheckStatus(env, status);
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2015-11-01 09:11:52 -08:00
|
|
|
|
|
|
|
|
} // extern "C"
|