/** * Determine if the encoder is stopped. * * Using the MaxPeriod value, a boolean is returned that is true if the encoder * is considered stopped and false if it is still moving. A stopped encoder is * one where the most recent pulse width exceeds the MaxPeriod. * * @return True if the encoder is considered stopped. */ bool Encoder::GetStopped() const { if (StatusIsFatal()) return true; if (m_counter) { return m_counter->GetStopped(); } else { int32_t status = 0; bool value = getEncoderStopped(m_encoder, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); return value; } }
/* * Class: edu_wpi_first_wpilibj_hal_EncoderJNI * Method: getEncoderStopped * Signature: (J)Z */ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderStopped (JNIEnv * env, jclass, jlong id) { ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderStopped"; ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id; int32_t status = 0; jboolean returnValue = getEncoderStopped((void*)id, &status); ENCODERJNI_LOG(logDEBUG) << "Status = " << status; ENCODERJNI_LOG(logDEBUG) << "getEncoderStoppedResult = " << returnValue; CheckStatus(env, status); return returnValue; }
/* * Class: edu_wpi_first_wpilibj_hal_EncoderJNI * Method: getEncoderStopped * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B */ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderStopped (JNIEnv * env, jclass, jobject id, jobject status) { ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderStopped"; void ** javaId = (void**)env->GetDirectBufferAddress(id); ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; jbyte returnValue = getEncoderStopped(*javaId, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ENCODERJNI_LOG(logDEBUG) << "getEncoderStoppedResult = " << returnValue; return returnValue; }