aboutsummaryrefslogtreecommitdiffstats
path: root/Java/com_phidgets_FrequencyCounterPhidget.c
blob: dd3d38c79980010fa53f294516a35475a548329e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "../stdafx.h"
#include "phidget_jni.h"
#include "com_phidgets_FrequencyCounterPhidget.h"
#include "../cphidgetfrequencycounter.h"

EVENT_VARS(frequencyCounterCount, FrequencyCounterCount)

JNI_LOAD(frequencyCounter, FrequencyCounter)
	EVENT_VAR_SETUP(frequencyCounter, frequencyCounterCount, FrequencyCounterCount, III, V)
}

EVENT_HANDLER_INDEXED2(FrequencyCounter, frequencyCounterCount, FrequencyCounterCount, 
					  CPhidgetFrequencyCounter_set_OnCount_Handler, int, int)

JNI_CREATE(FrequencyCounter)

JNI_GETFUNC(FrequencyCounter, FrequencyInputCount, FrequencyInputCount, jint)
JNI_INDEXED_GETFUNC(FrequencyCounter, Frequency, Frequency, jdouble)
JNI_INDEXED_GETFUNC(FrequencyCounter, TotalTime, TotalTime, jlong)
JNI_INDEXED_GETFUNC(FrequencyCounter, TotalCount, TotalCount, jlong)
JNI_INDEXED_GETFUNC(FrequencyCounter, Timeout, Timeout, jint)
JNI_INDEXED_SETFUNC(FrequencyCounter, Timeout, Timeout, jint)
JNI_INDEXED_GETFUNCBOOL(FrequencyCounter, Enabled, Enabled)
JNI_INDEXED_SETFUNC(FrequencyCounter, Enabled, Enabled, jboolean)

JNIEXPORT jint JNICALL
Java_com_phidgets_FrequencyCounterPhidget_getFilter(JNIEnv *env, jobject obj, jint index)
{
	CPhidgetFrequencyCounterHandle h = (CPhidgetFrequencyCounterHandle)(uintptr_t)
	    (*env)->GetLongField(env, obj, handle_fid);
	int error;
	CPhidgetFrequencyCounter_FilterType v;
	if ((error = CPhidgetFrequencyCounter_getFilter(h, index, &v)))
		PH_THROW(error);
	return (jint)v;
}

JNI_INDEXED_SETFUNC(FrequencyCounter, Filter, Filter, jint)

JNIEXPORT void JNICALL
Java_com_phidgets_FrequencyCounterPhidget_reset(JNIEnv *env, jobject obj, jint index)
{
	CPhidgetFrequencyCounterHandle h = (CPhidgetFrequencyCounterHandle)(uintptr_t)
	    (*env)->GetLongField(env, obj, handle_fid);
	int error;

	if ((error = CPhidgetFrequencyCounter_reset(h, index)))
		PH_THROW(error);
}