GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LIH / V0-2-7 > lih / linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

LIH_limit.c File Reference

Control functions the ADC limit monitoring facility. More...

#include <string.h>
#include <CCSDS/CCSDS_pkt.h>
#include <CDM/CDM_pubdefs.h>
#include <LIH_DB/LIH_DB_ADCdefs.h>
#include <LIH_DB/LIH_DB_schema.h>
#include <LSF/LSF.h>
#include <LSF/LSF_ids.h>
#include <MDB/MDB_pubdefs.h>
#include <PBS/MBA.h>
#include <PBS/RW.ih>
#include <ZLIB/zlib.h>
#include <LIH/LIH_msgs.h>
#include <LIH/LIH_tlmdefs.h>
#include <LIH_prvdefs.h>

Functions

static void sendCTDB_cb (ITC_QueueItem *qitem, unsigned int status, void *prm0, void *prm1, void *prm2, unsigned int tx)
 Clean up after sending an alert message.
static void sendSDI_cb (ITC_QueueItem *qitem, unsigned int status, void *prm0, void *prm1, void *prm2, unsigned int tx)
 Clean up after sending a trace snapshot to the SDI.
static void * zlibAlloc (void *prm, unsigned int cnt, unsigned int siz)
 Allocate memory for ZLIB.
static void zlibFree (void *prm, void *add)
 Free memory for ZLIB.
static __inline unsigned int isInvalid (const LIH_DB_Limit *adc)
 Check an ADC limit set.
unsigned int LIH_limitAble (unsigned int able)
 Enable/disable taking actions on the basis of ADC states.
unsigned int LIH_limitAction (LIH_DB_ADC adx, LIH_DB_ADCState prv, LIH_DB_ADCState cur, int alert, int diag, int msg)
 Change nag time for an ADC/state.
unsigned int LIH_limitCheck (LIH_Control *hcb, unsigned int adx, unsigned short *val, WCT_time tim, WCT_time_sat_u sat)
 Test ADC limits and take requested action.
unsigned int LIH_limitCheckCDM (LIH_DB_Schema *ldb)
 Check the contents of an LIH CDM database.
void LIH_limitExternalDefault (LIH_Control *hcb, LIH_DB_Schema *ldb)
 Use an external default limit set to initialize the limit table.
void LIH_limitExternalTable (LIH_Control *hcb, LIH_DB_Schema *ldb)
 Use an external default limit set to initialize the limit table.
void LIH_limitInternalDefault (LIH_Control *hcb)
 Use internal defaults to initialize the limit table.
unsigned int LIH_limitLimit (LIH_DB_ADC adx, const signed short limit[LIH_DB_L_LIMIT])
 Set the limit boundaries for monitoring an ADC.
unsigned int LIH_limitNag (LIH_DB_ADC adx, LIH_DB_ADCState state, unsigned int delta)
 Change nag time for an ADC/state.
unsigned int LIH_limitPersist (LIH_DB_ADC adx, unsigned int persist)
 Change persistence time for an ADC.
unsigned int LIH_limitSendAdc (LIH_DB_ADC adx)
 Send the limit set for an ADC via diagnostic telemetry.
unsigned int LIH_limitSendAll (unsigned int reason, unsigned int source, unsigned int ident)
 Test ADC limits and take requested action.
unsigned int LIH_limitSettle (LIH_DB_ADC adx, unsigned int settle)
 Limit the time an ADC state has to settle.

Variables

static const char * LIH_AdcStateString [LIH_DB_L_ADC_STATE]
 String constants for the various ADC limit states.
static const char * s_able [2] = { "disabled", "enabled" }
 Strings used in enable/disable error reporting.
static const char * s_pktType [2] = { "an alert", "a diagnostic" }
 Strings used in telemetry error reporting.


Detailed Description

Control functions the ADC limit monitoring facility.

CVS $Id: LIH_limit.c,v 1.8 2011/03/29 22:38:00 apw Exp $
Author:
A.P.Waite
LIH_limit.c provides all the control functions (enabling/disabling, setting limits and so on) for managing the ADC limit monitoring facility.

Function Documentation

static __inline unsigned int isInvalid ( const LIH_DB_Limit *  adc  )  [static]

Check an ADC limit set.

Parameters:
adc (in) An ADC limit set
Return values:
0 ADC limit definitions is valid
1 ADC limit definitions is not valid

Referenced by LIH_limitCheckCDM().

unsigned int LIH_limitAble ( unsigned int  able  ) 

Enable/disable taking actions on the basis of ADC states.

Parameters:
able (in) Enable/disable state (boolean, 1 => enable)

References _LIH_Control::enable, and LIH_hcb.

Referenced by LIH_EnableActions().

unsigned int LIH_limitAction ( LIH_DB_ADC  adx,
LIH_DB_ADCState  prv,
LIH_DB_ADCState  cur,
int  alert,
int  diag,
int  msg 
)

Change nag time for an ADC/state.

Parameters:
adx (in) ADC index on which to set set a nag time
prv (in) ADC state on previous read
cur (in) ADC state on current read
alert (in) Send alert (-1 => no change, 0 => don't, 1 => do)
diag (in) Send diag (-1 => no change, 0 => don't, 1 => do)
msg (in) Send msg (-1 => no change, 0 => don't, 1-3 => severity)

References LIH_hcb, and _LIH_Control::tbl.

Referenced by LIH_SetActionsAdc().

unsigned int LIH_limitCheck ( LIH_Control hcb,
unsigned int  adx,
unsigned short *  val,
WCT_time  tim,
WCT_time_sat_u  sat 
)

Test ADC limits and take requested action.

Parameters:
hcb (in) Control block
adx (in) ADC index
val (in/out) ADC value
tim (in) ADC acquisition timestamp (internal representation)
sat (in) ADC acquisition timestamp (satellite representation)
Return values:
0 Output of corresponding diagnostic packet -not- requested
1 Output of corresponding diagnostic packet -requested-

References _LIH_LimitAlert_Tlm::adx, _LIH_Control::afp, _LIH_LimitSave::confirm, _LIH_LimitAlert_Tlm::cur, _LIH_LimitSave::deltaNag, _LIH_LimitSave::deltaPersist, _LIH_LimitSave::deltaSettle, _LIH_Control::enable, _LIH_LimitSave::lastTime, LIH_Adc2source, LIH_Adc2string, LIH_K_SETTLE_SETTLING, LIH_K_SETTLE_STABLE, LIH_K_SETTLE_UNSTABLE, LIH_LIMITALERT_TLM_APID, _LIH_LimitAlert_Tlm::limit, _LIH_LimitAlert_Tlm::name, _LIH_Source::off, _LIH_LimitAlert_Tlm::prv, _LIH_Control::sav, sendCTDB_cb(), _LIH_LimitSave::settleState, _LIH_LimitSave::suspect, _LIH_Control::tbl, and _LIH_LimitAlert_Tlm::value.

Referenced by AEMacquire(), PDUacquire(), and TEMacquire().

unsigned int LIH_limitCheckCDM ( LIH_DB_Schema *  ldb  ) 

Check the contents of an LIH CDM database.

Parameters:
ldb (in) Handle to the CDM database data

References isInvalid().

Referenced by initializeLimits(), and LIH_LoadLimits().

void LIH_limitExternalDefault ( LIH_Control hcb,
LIH_DB_Schema *  ldb 
)

Use an external default limit set to initialize the limit table.

Parameters:
hcb (in) LIH control block
ldb (in) Handle to the CDM database data
Warning:
This routine does no validation. It assumes that the database file has already been validted using LIH_limitCheckCDM().
LIH_limitExternalDefault() uses the default limit set in the CDM to initialize all ADC limits to default values. If there is no default limit set in the CDM, this routine does nothing.

References _LIH_Control::tbl.

Referenced by initializeLimits(), and LIH_LoadLimits().

void LIH_limitExternalTable ( LIH_Control hcb,
LIH_DB_Schema *  ldb 
)

Use an external default limit set to initialize the limit table.

Parameters:
hcb (in) LIH control block
ldb (in) Handle to the CDM database data
Warning:
This routine does no validation. It assumes that the database file has already been validated using LIH_limitCheckCDM().
LIH_limitExternalTable() uses the list of individual ADC limit sets in the CDM database to set up individual ADC limits. The list is allowed to be empty.

References _LIH_Control::tbl.

Referenced by initializeLimits(), and LIH_LoadLimits().

void LIH_limitInternalDefault ( LIH_Control hcb  ) 

Use internal defaults to initialize the limit table.

Parameters:
hcb (in) LIH control block

References _LIH_Control::tbl.

Referenced by initializeLimits().

unsigned int LIH_limitLimit ( LIH_DB_ADC  adx,
const signed short  limit[LIH_DB_L_LIMIT] 
)

Set the limit boundaries for monitoring an ADC.

Parameters:
adx (in) ADC index on which to set limits
limit (in) New limit set (negative => leave value as is)

References LIH_hcb, and _LIH_Control::tbl.

Referenced by LIH_SetLimitsAdc().

unsigned int LIH_limitNag ( LIH_DB_ADC  adx,
LIH_DB_ADCState  state,
unsigned int  delta 
)

Change nag time for an ADC/state.

Parameters:
adx (in) ADC index on which to set a nag time
state (in) ADC state on which to set a nag time
delta (in) Interval between nags (milliseconds, 0 => don't nag)

References LIH_hcb, and _LIH_Control::tbl.

Referenced by LIH_SetNagTimesAdc().

unsigned int LIH_limitPersist ( LIH_DB_ADC  adx,
unsigned int  persist 
)

Change persistence time for an ADC.

Parameters:
adx (in) ADC index on which to set the persistence
persist (in) Persistence time (milliseconds, 0 => no persistence)

References LIH_hcb, and _LIH_Control::tbl.

Referenced by LIH_SetPersistAdc().

unsigned int LIH_limitSendAdc ( LIH_DB_ADC  adx  ) 

unsigned int LIH_limitSendAll ( unsigned int  reason,
unsigned int  source,
unsigned int  ident 
)

unsigned int LIH_limitSettle ( LIH_DB_ADC  adx,
unsigned int  settle 
)

Limit the time an ADC state has to settle.

Parameters:
adx (in) ADC index on which to set the persistence
settle (in) Maximum settling time (milliseconds)

References LIH_hcb, and _LIH_Control::tbl.

Referenced by LIH_SetSettleAdc().

static void sendCTDB_cb ( ITC_QueueItem *  qitem,
unsigned int  status,
void *  prm0,
void *  prm1,
void *  prm2,
unsigned int  tx 
) [static]

Clean up after sending an alert message.

Parameters:
qitem (in) Queue item
status (in) Status from ITC_send()
prm0 (in) User param 0 (LIH control block)
prm1 (in) User param 1 (unused)
prm2 (in) User param 2 (unused)
tx (in) Failure during send phase of ITC_send() (unused)
sendCTDB_cb() is the callback routine that's called once a telemetry record has been delivered (a standard ITC completion routine).

Referenced by LIH_limitCheck(), and LIH_limitSendAdc().

static void sendSDI_cb ( ITC_QueueItem *  qitem,
unsigned int  status,
void *  prm0,
void *  prm1,
void *  prm2,
unsigned int  tx 
) [static]

Clean up after sending a trace snapshot to the SDI.

Parameters:
qitem (in) Queue item
status (in) Status from ITC_send()
prm0 (in) User param 0 (Snapshot buffer)
prm1 (in) User param 1 (unused)
prm2 (in) User param 2 (unused)
tx (in) Failure during send phase of ITC_send() (unused)
sendSDI_cb() is a standard ITC completion routine. It simply frees the the snapshot back into its FPA pool (unless it's the start line trace ... it never frees the start line trace).

References _LIH_Control::lock.

Referenced by LIH_limitSendAll().

static void * zlibAlloc ( void *  prm,
unsigned int  cnt,
unsigned int  siz 
) [static]

Allocate memory for ZLIB.

Parameters:
prm (in) User parameter (unused)
cnt (in) Count of objects
siz (in) Size of object (in bytes)
Return values:
NULL Cannot allocate
x Pointer to allocated memory
Allocate memory for ZLIB.

Referenced by LIH_limitSendAll().

static void zlibFree ( void *  prm,
void *  add 
) [static]

Free memory for ZLIB.

Parameters:
prm (in) User parameter (unused)
add (in) Address to free
Return values:
NULL Cannot allocate
x Pointer to allocated memory
Free memory for ZLIB.

Referenced by LIH_limitSendAll().


Variable Documentation

static const char LIH_AdcStateString[LIH_DB_L_ADC_STATE] [static]

Initial value:

 
{
    "unread",
    "red low",
    "yellow low",
    "green",
    "yellow high",
    "red high",
    "unphysical",
    "unstable"
}
String constants for the various ADC limit states.


Generated on Fri Sep 30 19:15:35 2011 by  doxygen 1.5.8