#import <dpsclient/dpsclient.h>
#import "GloveWindow.h"
#import "PowerGlove.h"

@implementation GloveWindow

void timeHandler(DPSTimedEntry teNumber, double now, void *userData)
{
	[(id)userData getGloveData];
}

- initPowerGlove
{
    powerGlove = [[PowerGlove alloc] init];
    [powerGlove setxHyst:0 yHyst:0 zHyst:0];

    timerNum = DPSAddTimedEntry(0.10, 
    				&timeHandler, 
				self,
				NX_BASETHRESHOLD);
	return self;
}

- removePowerGlove
{
	DPSRemoveTimedEntry(timerNum);
	return self;
}

- getGloveData
{

	[GloveX setIntValue:   [powerGlove gloveX]];
	[GloveY setIntValue:   [powerGlove gloveY]];
	[GloveZ setIntValue:   [powerGlove gloveZ]];
	[GloveRot setIntValue: [powerGlove gloveRot]];
	[thumb setIntValue:    [powerGlove thumb]];
	[index setIntValue:    [powerGlove index]];
	[middle setIntValue:   [powerGlove middle]];
	[ring setIntValue:     [powerGlove ring]];
	return self;
}

- run:sender
{
    [self initPowerGlove];
	return self;
}

- stop:sender
{
    [self removePowerGlove];
	return self;
}


@end
