/****************************************************************************/
/* Copyright 1992 MBARI                                                     */
/****************************************************************************/
/* Summary  : Moog Thruster Motor Controller Interface Module for VxWorks   */
/* Filename : thruster.c                                                    */
/* Author   : Andrew Pearce                                                 */
/* Project  : New ROV                                                       */
/* Version  : Version 1.0                                                   */
/* Created  : 05/19/92                                                      */
/* Modified : 10/08/92                                                      */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/* $Header: autoEnable.c,v 1.2 96/03/11 08:47:52 pean Exp $
 * $Log:        autoEnable.c,v $
 * Revision 1.2  96/03/11  08:47:52  08:47:52  pean (Andrew Pearce)
 * No change
 *
 * Revision 1.1  93/07/01  14:39:06  14:39:06  pean (Andrew Pearce)
 * Initial revision
 *
 * Revision 1.1  92/06/29  10:16:44  10:16:44  pean (Andrew Pearce 408-647-3746)
 * Initial revision
 *
 */
/****************************************************************************/

#include <vxWorks.h>                /* vxWorks system declarations          */
#include <lstLib.h>                 /* vxWorks linked list library          */
#include <strLib.h>                 /* vxWorks string library functions     */
#include <taskLib.h>                /* vxWorks task library functions       */
#include <wdLib.h>                  /* vxWorks watch dog timer functions    */
#include <semLib.h>                 /* vxWorks semaphore functions          */

#include <mbariTypes.h>             /* mbari style guide type declarations  */
#include <ModNum.h>                 /* mbari module numbers for error code  */
#include <usrTime.h>                /* mbari time and date functions        */
#include <datamgr.h>                /* Data Manager declarations            */
#include <dm_errno.h>               /* Data Manager error declarations      */

#include <thrusterDM.h>

    STATUS
autoEnable( Void )
{
    DM_Item Items[6];
    motorEnableState  motorEnable = ENABLE_MOTOR;
    Int32       i;

    dm_create("THRUSTER.PORT_HORIZ.ENABLE", 1, &Items[0], DM_ENUM, 1, DM_ENDT);
    dm_create("THRUSTER.STBD_HORIZ.ENABLE", 1, &Items[1], DM_ENUM, 1, DM_ENDT);
    dm_create("THRUSTER.PORT_VERT.ENABLE",  1, &Items[2], DM_ENUM, 1, DM_ENDT);
    dm_create("THRUSTER.STBD_VERT.ENABLE",  1, &Items[3], DM_ENUM, 1, DM_ENDT);
    dm_create("THRUSTER.FWD_LAT.ENABLE",    1, &Items[4], DM_ENUM, 1, DM_ENDT);
    dm_create("THRUSTER.AFT_LAT.ENABLE",    1, &Items[5], DM_ENUM, 1, DM_ENDT);

    FOREVER
    {
        for (i = 0; i < 6; i++)
        {
            dm_urgent_open(Items[i], DM_STATIC);
            dm_write(Items[i], (char *) &motorEnable, sizeof(motorEnable), 0);
            dm_urgent_close(Items[i]);
        }

        taskDelay(sysClkRateGet());
    }
}
