/******************************************************************************/
/* Copyright 1992 MBARI                                                       */
/******************************************************************************/
/* Summary  : Stop Sensor Data Recording Module for Tiburon Control System    */
/* Filename : stopRecord.c                                                    */
/* Author   : Janice Tarrant                                                  */
/* Project  : Tiburon                                                         */
/* Version  : Version 1.0                                                     */
/* Created  : 12/06/93                                                        */
/* Modified :                                                                 */
/* Archived :                                                                 */
/******************************************************************************/
/* Modification History :                                                     */
/* $Header$
 * $Log$
 *
 */
/******************************************************************************/

#include <vxWorks.h>            /* VxWorks system declarations                */
#include <stdioLib.h>           /* VxWorks standard I/O library               */
#include <wdLib.h>              /* VxWorks watchdog timer library             */
#include <semLib.h>             /* VxWorks semaphore library                  */
#include <systime.h>            /* VxWorks system time declarations           */
#include <strLib.h>             /* VxWorks string library                     */
#include <taskLib.h>            /* VxWorks task library                       */
#include <mbariTypes.h>         /* MBARI style guide type declarations        */
#include <usrTime.h>            /* MBARI time declarations                    */
#include <datamgr.h>            /* data manager declarations                  */
#include <dm_errno.h>           /* data manager error declarations            */
#include <controlDM.h>          /* control system data manager definitions    */

#include "controlDM.h"          /* control system definitions                 */

#define RECORD_PRIORITY  75     /* record task priority                       */


/******************************************************************************/
/* Function : stopRecordTask                                                  */
/* Purpose  : Stops sensor data recording task.                               */
/* Inputs   : None.                                                           */
/* Outputs  : Returns ERROR on fatal error.                                   */
/******************************************************************************/
    STATUS
stopRecordTask(Void)
{
    DM_Item stopRecordDmi;              /* stop recording data manager item   */
    MBool   stopRecording = TRUE;       /* stop recording flag                */
    Errno   status;                     /* data manager error code            */

/* set record task priority                                                   */
    taskPrioritySet(taskIdSelf(), RECORD_PRIORITY);

/* lookup data manager item handle                                            */
    stopRecordDmi = dm_lookup(STOP_RECORDING_DM, 0);
    if (checkLookup(stopRecordDmi, STOP_RECORDING_DM) == ERROR)
        return(ERROR);

/* start provider and write value                                             */
    status = dm_start_multiple(stopRecordDmi);
    status = dm_write(stopRecordDmi, (Void *) &stopRecording,
                      sizeof(stopRecording), (DM_Time * ) NULL);
    if (checkWrite(status, "Stop Data Recording - stop recording flag")
        == ERROR)
        return(ERROR);

    return(OK);

} /* stopRecordTask */

