/****************************************************************************/
/* Copyright 2004 MBARI.													*/
/* MBARI Proprietary Information. All rights reserved.						*/
/****************************************************************************/

#include <mbariTypes.h>		/* MBARI type definitions			*/
#include <mbariConst.h>		/* MBARI constants					*/
#include <oasis.h>			/* OASIS controller definitions		*/
#include <task.h>			/* OASIS task dispatcher			*/
#include <remote.h>						/* Remote I/O library			*/
#include <debug.h>

Void wakeOnOff_drv(Driver *dp);
Void wakeOneShot_drv(Driver *dp);

/************************************************************************/
/* Function : wakeOnOff_drv												*/
/* Purpose	: Simple driver to turn wake bits on and off				*/
/* Inputs	: Driver Pointer											*/
/* Outputs	: None														*/
/************************************************************************/
		Void
wakeOnOff_drv( Driver *dp )
{
	/* set the wake bits */
	remOutput((Nat32)dp->drv_parms[PARM0], TRUE);
	/* wait for the specified time */
	delay_secs(dp->drv_parms[TIMEOUT]);
	/* set the wake bits */
	remOutput((Nat32)dp->drv_parms[PARM0], FALSE);
}

/************************************************************************/
/* Function : wakeOneShot_drv											*/
/* Purpose	: Simple driver to fire a wake bit once						*/
/* Inputs	: Driver Pointer											*/
/* Outputs	: None														*/
/************************************************************************/
		Void
wakeOneShot_drv( Driver *dp )
{
	/* if this is the second time through fire the one shot */
	if ( dp->drv_cnt == 1)
	{
		dprintf("%s firing one shot\r\n", dp->drv_name);
		
		/* set the wake bits */
		remOutput((Nat32)dp->drv_parms[PARM0], TRUE);
		/* wait for the specified time */
		delay_secs(dp->drv_parms[TIMEOUT]);
		/* set the wake bits */
		remOutput((Nat32)dp->drv_parms[PARM0], FALSE);
		
		dprintf("%s one shot complete\r\n", dp->drv_name);

		/* set the interval to zero as this driver has done it's thing */
		dp->drv_parms[INTERVAL] = 0;
	}
	
	/* count the times you've come through this neck of the woods */
	++dp->drv_cnt;
}

