#ifndef _lpsDm_H
#define _lpsDm_H

/****************************************************************************/
/* Copyright 1992 to 1993, MBARI                                            */
/****************************************************************************/
/* Summary  : IBC LPS Board Data Manager Function Prototypes for VxWorks    */
/* Filename : lpsDm.h                                                       */
/* Author   : Andrew Pearce                                                 */
/* Project  : New ROV                                                       */
/* Version  : Version 1.0                                                   */
/* Created  : 04/08/93                                                      */
/* Modified : 06/08/93                                                      */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/* $Header: lpsDm.h,v 1.1 93/07/01 14:38:16 pean Exp $
 * $Log:        lpsDm.h,v $
 * Revision 1.1  93/07/01  14:38:16  14:38:16  pean (Andrew Pearce)
 * Initial revision
 *
 *
 */
/********************** IBC LPS Data Manager Item Names *********************/

#define LPS_VICOR_ENABLE 0xff           /* Vicor Output Enable Channel      */

#define LPS_SW0_CURRENT_DM                      "SW0_CURRENT"
#define LPS_SW1_CURRENT_DM                      "SW1_CURRENT"
#define LPS_SW2_CURRENT_DM                      "SW2_CURRENT"
#define LPS_SW3_CURRENT_DM                      "SW3_CURRENT"

#define LPS_SW0_CURRENT_WARN_THRESH_DM          "SW0_CURRENT_WARN_THRESH"
#define LPS_SW0_CURRENT_ALARM_THRESH_DM         "SW0_CURRENT_ALARM_THRESH"
#define LPS_SW1_CURRENT_WARN_THRESH_DM          "SW1_CURRENT_WARN_THRESH"
#define LPS_SW1_CURRENT_ALARM_THRESH_DM         "SW1_CURRENT_ALARM_THRESH"
#define LPS_SW2_CURRENT_WARN_THRESH_DM          "SW2_CURRENT_WARN_THRESH"
#define LPS_SW2_CURRENT_ALARM_THRESH_DM         "SW2_CURRENT_ALARM_THRESH"
#define LPS_SW3_CURRENT_WARN_THRESH_DM          "SW3_CURRENT_WARN_THRESH"
#define LPS_SW3_CURRENT_ALARM_THRESH_DM         "SW3_CURRENT_ALARM_THRESH"

#define LPS_SWITCH_TEMP_DM                      "SWITCH_TEMP"
#define LPS_SWITCH_TEMP_WARN_THRESH_DM          "SWITCH_TEMP_WARN_THRESH"
#define LPS_SWITCH_TEMP_ALARM_THRESH_DM         "SWITCH_TEMP_ALARM_THRESH"
#define LPS_SWITCH_TEMP_ALARM_DM                "SWITCH_TEMP_ALARM"

#define LPS_VICOR_TEMP_DM                       "VICOR_TEMP"
#define LPS_VICOR_TEMP_WARN_THRESH_DM           "VICOR_TEMP_WARN_THRESH"
#define LPS_VICOR_TEMP_ALARM_THRESH_DM          "VICOR_TEMP_ALARM_THRESH"
#define LPS_VICOR_TEMP_ALARM_DM                 "VICOR_TEMP_ALARM"

#define LPS_VICOR_VOLTAGE_DM                    "VOLTAGE"
#define LPS_VICOR_VOLTAGE_WARN_THRESH_DM        "VOLTAGE_WARN_THRESH"
#define LPS_VICOR_VOLTAGE_ALARM_THRESH_DM       "VOLTAGE_ALARM_THRESH"
#define LPS_VICOR_VOLTAGE_ALARM_DM              "VOLTAGE_ALARM"

#define LPS_SW0_CURRENT_ALARM_DM                "SW0_CURRENT_ALARM"
#define LPS_SW1_CURRENT_ALARM_DM                "SW1_CURRENT_ALARM"
#define LPS_SW2_CURRENT_ALARM_DM                "SW2_CURRENT_ALARM"
#define LPS_SW3_CURRENT_ALARM_DM                "SW3_CURRENT_ALARM"

#ifdef INCLUDE_PROTOTYPES

typedef struct                      /* IBC LPS Board Data Manager Item      */
{
    DM_Item sw0Current;             /* Switch 0 Current                     */
    DM_Item sw1Current;             /* Switch 1 Current                     */
    DM_Item sw2Current;             /* Switch 2 Current                     */
    DM_Item sw3Current;             /* Switch 3 Current                     */

    DM_Item sw0CurrentWarnThresh;
    DM_Item sw0CurrentAlarmThresh;
    DM_Item sw1CurrentWarnThresh;
    DM_Item sw1CurrentAlarmThresh;
    DM_Item sw2CurrentWarnThresh;
    DM_Item sw2CurrentAlarmThresh;
    DM_Item sw3CurrentWarnThresh;
    DM_Item sw3CurrentAlarmThresh;

    DM_Item sw0CurrentAlarm;
    DM_Item sw1CurrentAlarm;
    DM_Item sw2CurrentAlarm;
    DM_Item sw3CurrentAlarm;

    DM_Item vicorVoltage;            /* Vicor Output Voltage                 */
    DM_Item vicorVoltageWarnThresh;
    DM_Item vicorVoltageAlarmThresh;
    DM_Item vicorVoltageAlarm;       /* Vicor Output Voltage                 */

    DM_Item vicorTemp;               /* Vicor Temperature                    */
    DM_Item vicorTempWarnThresh;
    DM_Item vicorTempAlarmThresh;
    DM_Item vicorTempAlarm;          /* Vicor Temperature                    */

    DM_Item switchTemp;              /* Switch Temperature                   */
    DM_Item switchTempWarnThresh;
    DM_Item switchTempAlarmThresh;
    DM_Item switchTempAlarm;

                                     /* Pointer to switchEntry structure     */
    switchEntry *deviceSwitch[LPS_MAX_CHANS];

} ibcLpsDmItems;

typedef struct                      /* IBC LPS Board Item Update Bits        */
{
    DWord sw0CurWarnBit;
    DWord sw0CurAlarmBit;
    DWord sw1CurWarnBit;
    DWord sw1CurAlarmBit;
    DWord sw2CurWarnBit;
    DWord sw2CurAlarmBit;
    DWord sw3CurWarnBit;
    DWord sw3CurAlarmBit;

    DWord vicorTempWarnBit;
    DWord vicorTempAlarmBit;

    DWord vicorVoltageWarnBit;
    DWord vicorVoltageAlarmBit;

    DWord switchTempWarnBit;
    DWord switchTempAlarmBit;
} lpsUpdateBits;


#ifdef __STDC__

STATUS createIbcLpsDmItems( ibcLpsDmItems *lpsDmItems, const char *ibcDmPrefix,
   const char *ibcDataCon, Int16 lpsBoardNum );

Void initIbcLpsProvider( ibcLpsDmItems *lpsItems, Period period );

Void initIbcLpsAlarmProvider( ibcLpsDmItems *lpsItems );

DWord initIbcLpsConsumer( ibcLpsDmItems *lpsItems, lpsUpdateBits *lpsBits,
   SEM_ID updateSem );

STATUS ibcConnectLpsDmItems( ibcLpsDmItems *lps,   switchEntry *device,
   const char *dataConName,  const char *itemName,   Nat16 lpsChan,
   char *current,            char *currentAlarm,
   char *currentWarnThresh,  char *currentAlarmThresh );

STATUS updateIbcLpsDm( sio32Chan *sio32DataChan, Word boardAddr,
   ibcLpsDmItems *lps );

STATUS updateIbcLpsAlarmsDm( sio32Chan *sio32DataChan, Word boardAddr,
   ibcLpsDmItems *lps );

Void updateIbcLpsDmItems( sio32Chan *sio32DataChan, Word boardAddr,
   ibcLpsDmItems *lps, const char *ibcDataCon );

STATUS setLpsVoltageThresh( sio32Chan *sio32DataChan, Word boardAddr,
   ibcLpsDmItems *lpsItems, Nat16 voltageWarn, Nat16 voltageAlarm );

Void ibcLpsUpdateCheck( sio32Chan *sio32DataChan, Word boardAddr,
   ibcLpsDmItems *lpsItems, lpsUpdateBits *lpsBits, DM_Group lpsGroup );

MBool processIbcLpsSRQ( Word srqRequest, Byte *buffer, Word lpsBoardAddr,
   ibcLpsDmItems *lps );

STATUS writeLpsCurrentThresholds( sio32Chan* sio32DataChan, Word boardAddr,
    ibcLpsDmItems* lpsItems );

STATUS writeLpsVoltageThresholds( sio32Chan* sio32DataChan, Word boardAddr,
    ibcLpsDmItems* lpsItems );

STATUS writeLpsTempThresholds( sio32Chan *sio32DataChan, Word boardAddr,
    ibcLpsDmItems* lpsItems );

#endif /* __STDC__ */

#endif /* INCLUDE_PROTOTYPES */


#endif
