GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > LCI / dev

Constituent: lci     Tag: mcp750


Interface   Data Structures   File List   Data Fields   Globals  

control.c File Reference

Principal routines of the charge injection calibration utility. More...

#include "LCI/LCI_msgs.h"
#include "LCI/LCI_cmddefs.h"
#include "LCI/LCI_cmdxtrn.h"
#include "control_p.h"
#include "collect.h"
#include "configure.h"
#include "consign.h"
#include "macros_p.h"
#include "CDM/CDM_pubdefs.h"
#include "CPU_DB/CPU_DB_pubdefs.h"
#include "EDS/EBF_match.h"
#include "EDS/EBF_cid.h"
#include "FBS/FBS_pubrtos.h"
#include "CCSDS/CCSDS_pkt.h"
#include "LCI_DB/schema.h"
#include "LSF/LSF_cpu.h"
#include "LSF/LSF_origin.h"
#include "LSF/LSF_reason.h"
#include "LSEC/compact.h"
#include "LATC/latc.h"
#include "MSG/MSG_pubdefs.h"
#include "ITC/ITC_pubdefs.h"
#include "PBS/BSWP.h"
#include "PBS/FPA.h"
#include "PBS/MBA.h"
#include "PBS/WCT.h"
#include <string.h>

Include dependency graph for control.c:


Defines

#define FALSE   0
 FALSE defined to be 0.
#define TRUE   1
 TRUE defined to be 1.
#define CHECK_CALL_TERMINATE(FUNC)
 Call a function and check the return value, calling LCI_terminate on error.
#define inline   __inline

Enumerations

enum  {
  LCI_DIAG_APID = 0x2d8,
  LCI_DFT_CAPACITY = 100,
  LCI_N_TERM_PKTS = 2,
  CSR_STALL = 200
}

Functions

static unsigned newITC (LCI_controller *cnt)
 Allocate a new ITC structure.
static void deleteITC (LCI_controller *cnt)
 Free the ITC structures.
static unsigned cycle (void)
 Perform a calibration cycle.
LCI_controllerLCI_newController (unsigned cap, unsigned cpuid, unsigned srcid)
 Create calibration controller structure.
void LCI_deleteController (LCI_controller *cnt)
 Free the calibration controller structure.
unsigned LCI_initialise (void)
 Initialize the calibration system from its config database.
unsigned LCI_init (unsigned capacity, unsigned cpuid, unsigned srcid)
 Initialize the calibration system.
unsigned LCI_startTask (void)
 Start the LCI task using its config database.
unsigned LCI_start (const TASK_attr *attr)
 Start the LCI task.
unsigned LCI_stopTask (void)
 Stop the LCI task.
unsigned LCI_teardown (void)
 Tear down the calibraion system.
unsigned LCI_calibrate (unsigned latccfg, unsigned lcicfg, unsigned lcirunid, ITC_NodeID iniNode, ITC_TaskID iniTask, ITC_QueueID iniQueue)
 Start a new calibration.
void LCI_abort (void)
 Abort a calibration.
unsigned LCI_startCycle (void)
 Request the next calibration cycle.
unsigned int LCI_cycle (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Perform a single calibration cycle.
unsigned LCI_terminate (unsigned status)
 Terminate a calibration.
void LCI_cb_statusFree (ITC_QueueItem *qitem, unsigned int status, void *prm0, void *prm1, void *prm2, unsigned int tx)
 ITC send completion callback.
unsigned LCI_status (void)
 Get the calibration state.
unsigned LCI_cycles (void)
 Get the calibration cycle count.
unsigned LCI_getRunInfo (LCI_runInfo *info)
 Get extended information about the calibration run.
unsigned LCI_sizeofRunInfo (void)
 Get the size of the extended calibration run information.
unsigned LCI_monitor (unsigned mon)
 Set the calibration monitoring level.

Variables

static LCI_controllerlci
 Static pointer to the single LCI control block.

Detailed Description

Principal routines of the charge injection calibration utility.

Author:
James Swain & Owen Saxton
Id
control.c,v 1.25 2007/08/26 21:47:27 saxton Exp

Define Documentation

#define CHECK_CALL_TERMINATE FUNC   ) 
 

Value:

{ \
  unsigned status = FUNC;\
  if (_msg_failure(status)) return LCI_terminate(status);\
}
Call a function and check the return value, calling LCI_terminate on error.


Function Documentation

unsigned cycle void   )  [inline, static]
 

Perform a calibration cycle.

This routine performs a configure-collect-compact-consign calibration cycle.

Return values:
LCI_ENDOFILE if there are no more configurations to read
LCI_FOPER if there is an error during the read or the configuration is incomplete
LCI_QITEM The attempt to allocate a QueueItem fails
ITC_ALOCFAIL Memory allocation failure
ITC_FPAGET Memory allocation from FPA failed
ITC_SENDNID Invalid/unreachable destination node
ITC_SENDQID Invalid/unreachable destination queue
ITC_SHRMEM Shared memory pool stopping/stopped
ITC_SUCCESS if the calibration cycle is successful

void deleteITC LCI_controller cnt  )  [inline, static]
 

Free the ITC structures.

This routine frees the ITC resource associated with an LCI structure.

Parameters:
cnt Pointer to the LCI structure containing pointers to the ITC structures to destroy

void LCI_abort void   ) 
 

Abort a calibration.

This routine is called when an abort calibration telecommand is received. If the current state is calibrating, it changes the state to aborting

unsigned LCI_calibrate unsigned  latccfg,
unsigned  lcicfg,
unsigned  lcirunid,
ITC_NodeID  iniNode,
ITC_TaskID  iniTask,
ITC_QueueID  iniQueue
 

Start a new calibration.

This routine is called when a start calibration telecommand is received. It first uses LATC to perform an initial LAT configuration then peforms a configure, collect, compact, consign cycle for each LCI configuration in the LCI file.

Parameters:
latccfg File ID for the LATC configuration master to use with this calibration
lcicfg File ID for the LCI configuration file to use to drive this calibration
lcirunid Run ID to use in the datagrams
iniNode Node ID of the task that initiated the calibration (used to send a message back when the calibration completes)
iniTask Task ID of the task that initiated the calibration (used to send a message back when the calibration completes)
iniQueue ID of the queue that will receive the status message.
Return values:
LCI_STATE LCI is not in the correct state to start a calibration
ITC_ALOCFAIL Memory allocation failure
ITC_FPAGET Memory allocation from FPA failed
ITC_SENDNID Invalid/unreachable destination node
ITC_SENDQID Invalid/unreachable destination queue
ITC_SHRMEM Shared memory pool stopping/stopped
ITC_SUCCESS If an item is sent to the LCI bulk queue

void LCI_cb_statusFree ITC_QueueItem *  qitem,
unsigned int  status,
void *  prm0,
void *  prm1,
void *  prm2,
unsigned int  tx
 

ITC send completion callback.

Completion call-back for use with ITC when sending the status back to the task that initiated calibration - just returns the qitem to the pool.

Parameters:
qitem Queue item to be returned to the pool
status Success or failure of the ITC delivery
prm0 User defined parameter 0 (pointer to the FPM pool)
prm1 User defined (NULL)
prm2 User defined (NULL)
tx Transmission status

unsigned int LCI_cycle void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len
 

Perform a single calibration cycle.

This routine is called when a calibration cycle request is received. Provided there is configuration data to read and the abort flag has not been set, it performs a single calibration cycle and queues the next one if this one is successful.

Return values:
LCI_ABORTED if the abort flag was found to be set at the start of the cycle
LCI_FOPER if there is an error during the read or the configuration is incomplete
LCI_QITEM The attempt to allocate a QueueItem fails
ITC_ALOCFAIL Memory allocation failure
ITC_FPAGET Memory allocation from FPA failed
ITC_SENDNID Invalid/unreachable destination node
ITC_SENDQID Invalid/unreachable destination queue
ITC_SHRMEM Shared memory pool stopping/stopped
LCI_SUCCESS if the calibration cycle is successfully completed

unsigned LCI_cycles void   ) 
 

Get the calibration cycle count.

This rouine returns the number of cycles performed since the last calibration command was issued.

Returns:
Number of cycles performed since the last command to calibrate was issued

void LCI_deleteController LCI_controller cnt  ) 
 

Free the calibration controller structure.

This routine frees all the resources associated with the LCI task.

unsigned LCI_getRunInfo LCI_runInfo info  ) 
 

Get extended information about the calibration run.

This routine fills a block of information detailing the current state of calibration runs.

Parameters:
info The address of a block to be filled with the current run information.
Return values:
LCI_SUCCESS success always

unsigned LCI_init unsigned  capacity,
unsigned  cpuid,
unsigned  srcid
 

Initialize the calibration system.

This routine performs resource allocation, initializes the ITC message queues, and sets the state to INITIALISED.

Parameters:
srcid ID of the source of data being processed through LCI
cpuid ID of the CPU LCI is being run on
capacity Maximum number of events per calibration cycle.
Returns:
LCI_SUCCESS if all goes well, otherwise one of many errors from LCI (typically LCI_MEMERROR if an allocation fails), PBS, IMM or ITC.

unsigned LCI_initialise void   ) 
 

Initialize the calibration system from its config database.

This routine is normally called at system initialization time to initialize the calibration system . It uses a configuration database to supply the capacity, cpuid and srcid parameters.

Returns:
Any of the return codes from LCI_init

unsigned LCI_monitor unsigned  mon  ) 
 

Set the calibration monitoring level.

This routine sets the LCI monitoring level and returns the old value.

Parameters:
mon Monitoring level to set
Returns:
Previous monitoring level

LCI_controller* LCI_newController unsigned  cap,
unsigned  cpuid,
unsigned  srcid
 

Create calibration controller structure.

This routine allocates memory for an LCI_controller structure and all associated structures.

Parameters:
srcid ID of the source of data being processed through LCI
cpuid ID of the CPU LCI is being run on
cap Capacity of the calibration task, the maximum number of events that can be collected each cycle
Returns:
Pointer to a new LCI_controller

unsigned LCI_sizeofRunInfo void   ) 
 

Get the size of the extended calibration run information.

This routine returns the size of the area needed to hold the extended run information for the last calibration.

Returns:
The size, in bytes, of the extended run information.

unsigned LCI_start const TASK_attr *  attr  ) 
 

Start the LCI task.

This routine starts the LCI task and waits for it be up and running before setting the state to WAITING.

Parameters:
attr Task attributes to use for the LCI task.
Returns:
Error status code from ITC_startTaskW, LCI_STATE if the state is not INITIALISED, LCI_ATTRIBS if the task attribute pointer is NULL or LCI_SUCCESS if all goes well.

unsigned LCI_startCycle void   ) 
 

Request the next calibration cycle.

This routine is called whenever the next (or first) calibration cycle is to be performed. It puts an empty item to the LCI bulk queue to initiate the cycle. This indirection is needed to allow any abort requests to be processed in a timely manner.

Return values:
LCI_QITEM The attempt to allocate a QueueItem fails
ITC_ALOCFAIL Memory allocation failure
ITC_FPAGET Memory allocation from FPA failed
ITC_SENDNID Invalid/unreachable destination node
ITC_SENDQID Invalid/unreachable destination queue
ITC_SHRMEM Shared memory pool stopping/stopped
ITC_SUCCESS If an item is sent to the LCI bulk queue
!!! KULDGE - ITC won't accept a NULL payload pointer.

unsigned LCI_startTask void   ) 
 

Start the LCI task using its config database.

This routine is normally called during system initialization. It starts the LCI task using the CPU configuration database to supply its attributes.

Returns:
Any of the return codes from LCI_startTask

unsigned LCI_status void   ) 
 

Get the calibration state.

This routine returns the current state of LCI.

Returns:
Current state of LCI

unsigned LCI_stopTask void   ) 
 

Stop the LCI task.

This routine stops the LCI task and sets the state to INITIALISED.

Returns:
LCI_STATE if the state is not WAITING, an error status code from ITC_stopTask or LCI_SUCCESS if all goes well

unsigned LCI_teardown void   ) 
 

Tear down the calibraion system.

This routine frees all the resources associated with the LCI task.

Return values:
LCI_STATE If the LCI task is not in the INITIALISED state
LCI_SUCCESS If all goes well

unsigned LCI_terminate unsigned  status  ) 
 

Terminate a calibration.

This routine finishes out the calibration by sending a status message back to the originating task and setting the state to WAITING.

Parameters:
status Termination status of the last calibration cycle, and hence of the whole calibration
Return values:
LCI_QITEM The attempt to allocate a QueueItem fails
ITC_ALOCFAIL Memory allocation failure
ITC_FPAGET Memory allocation from FPA failed
ITC_SENDNID Invalid/unreachable destination node
ITC_SENDQID Invalid/unreachable destination queue
ITC_SHRMEM Shared memory pool stopping/stopped
ITC_SUCCESS If the item is sent

unsigned newITC LCI_controller cnt  )  [inline, static]
 

Allocate a new ITC structure.

This routine obtains the ITC resources needed by the calibration task.

Parameters:
cnt Pointer to LCI_controller structure to attach ITC structure to.
Returns:
Status code from RBM_createRing or LCI_MEMERROR


Generated on Mon Aug 27 02:39:48 2007 by  doxygen 1.4.4