\hypertarget{control_8c}{
\section{control.c File Reference}
\label{control_8c}\index{control.c@{control.c}}
}
Principal routines of the charge injection calibration utility.  


{\tt \#include $<$lci\_\-p.h$>$}\par
{\tt \#include $<$LCI/LCI\_\-msgs.h$>$}\par
{\tt \#include $<$LCI/LCI\_\-cmddefs.h$>$}\par
{\tt \#include $<$LCI/LCI\_\-cmdxtrn.h$>$}\par
{\tt \#include $<$LCI\_\-DB/schema.h$>$}\par
{\tt \#include $<$LSEC/LSEC.h$>$}\par
{\tt \#include $<$CDM/CDM\_\-pubdefs.h$>$}\par
{\tt \#include $<$CPU\_\-DB/CPU\_\-DB\_\-pubdefs.h$>$}\par
{\tt \#include $<$IMM/RBM\_\-pubdefs.h$>$}\par
{\tt \#include $<$IMM/FPM\_\-pubdefs.h$>$}\par
{\tt \#include $<$EDS/EBF\_\-match.h$>$}\par
{\tt \#include $<$EDS/EBF\_\-cid.h$>$}\par
{\tt \#include $<$FBS/FBS\_\-pubrtos.h$>$}\par
{\tt \#include $<$CCSDS/CCSDS\_\-pkt.h$>$}\par
{\tt \#include $<$LSF/LSF\_\-cpu.h$>$}\par
{\tt \#include $<$LSF/LSF\_\-origin.h$>$}\par
{\tt \#include $<$LSF/LSF\_\-reason.h$>$}\par
{\tt \#include $<$MSG/MSG\_\-pubdefs.h$>$}\par
{\tt \#include $<$ITC/ITC\_\-pubdefs.h$>$}\par
{\tt \#include $<$LEM/list.h$>$}\par
{\tt \#include $<$PBS/BSWP.h$>$}\par
{\tt \#include $<$PBS/FPA.h$>$}\par
{\tt \#include $<$PBS/MBA.h$>$}\par
{\tt \#include $<$PBS/SEM.h$>$}\par
{\tt \#include $<$PBS/WCT.h$>$}\par
{\tt \#include $<$LCBD/LCBD.h$>$}\par
{\tt \#include $<$string.h$>$}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{control_8c_fcbf0f417b3621f3890f945515149aa7}{LCI\_\-abort} (void)
\begin{CompactList}\small\item\em Abort a calibration. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_c8845f2cdd3fa2018106b9e6bd54fbe9}{LCI\_\-calibrate} (unsigned latccfg, unsigned lcicfg, unsigned lcirunid, ITC\_\-NodeID iniNode, ITC\_\-TaskID iniTask, ITC\_\-QueueID iniQueue)
\begin{CompactList}\small\item\em Start a new calibration. \item\end{CompactList}\item 
void \hyperlink{control_8c_01e47d0c7b36ac0cba0556ecad721dac}{LCI\_\-cb\_\-statusFree} (ITC\_\-QueueItem $\ast$qitem, unsigned int status, void $\ast$prm0, void $\ast$prm1, void $\ast$prm2, unsigned int tx)
\begin{CompactList}\small\item\em ITC send completion callback. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_defc818848c6f17bb096455177ad34ed}{LCI\_\-comp} (unsigned comp)
\begin{CompactList}\small\item\em Set the calibration compression level. \item\end{CompactList}\item 
unsigned int \hyperlink{control_8c_539ec71864d6b5fc0ff74c950d8fc15e}{LCI\_\-cycle} (void $\ast$prm, const struct \hyperlink{struct__ITC__QueueItem}{\_\-ITC\_\-QueueItem} $\ast$qitem, void $\ast$pay, unsigned int len)
\begin{CompactList}\small\item\em Perform a single calibration cycle. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_909c3b4b041de8bfb062510e084fc793}{LCI\_\-cycles} (void)
\begin{CompactList}\small\item\em Get the calibration cycle count. \item\end{CompactList}\item 
void \hyperlink{control_8c_d710fdeaf0a0093fe3cea760c7a0ad67}{LCI\_\-deleteController} (\hyperlink{lci__p_8h_40322e35bea571c2bacd12d2a52ce720}{LCI\_\-controller} $\ast$cnt)
\begin{CompactList}\small\item\em Free the calibration controller structure. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_24343f001c0a9a2926398db94cff4fc5}{LCI\_\-getRunInfo} (\hyperlink{struct__LCI__runInfo}{LCI\_\-runInfo} $\ast$info)
\begin{CompactList}\small\item\em Get extended information about the calibration run. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_0a2dd589898b35c95b7f87855ed67ddb}{LCI\_\-init} (unsigned capacity, unsigned cpuid, unsigned srcid)
\begin{CompactList}\small\item\em Initialize the calibration system. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_472232a9e411b7729f097642d5dd1dd0}{LCI\_\-initialise} (void)
\begin{CompactList}\small\item\em Initialize the calibration system from its config database. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_b8c7c1df2b2bf96872e109c230d83937}{LCI\_\-monitor} (unsigned mon)
\begin{CompactList}\small\item\em Set the calibration monitoring level. \item\end{CompactList}\item 
\hyperlink{lci__p_8h_40322e35bea571c2bacd12d2a52ce720}{LCI\_\-controller} $\ast$ \hyperlink{control_8c_26ed3fab76f83fe71864791092b2db7f}{LCI\_\-newController} (unsigned cap, unsigned cpuid, unsigned srcid)
\begin{CompactList}\small\item\em Create calibration controller structure. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_507830f45fcf4580bf928f90d58631fe}{LCI\_\-sizeofRunInfo} (void)
\begin{CompactList}\small\item\em Get the size of the extended calibration run information. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_90c1754fe33dbd8aa659d59b3734fcd1}{LCI\_\-start} (const TASK\_\-attr $\ast$attr)
\begin{CompactList}\small\item\em Start the LCI task. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_6de72ca775513507fbb19431949dc62b}{LCI\_\-startCycle} (void)
\begin{CompactList}\small\item\em Request the next calibration cycle. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_bdd61cff8129f3677b0e1ed6cdeb60d8}{LCI\_\-startTask} (void)
\begin{CompactList}\small\item\em Start the LCI task using its config database. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_866532c88fb7c94bbea3082270718521}{LCI\_\-status} (void)
\begin{CompactList}\small\item\em Get the calibration state. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_b990de0d4b06a814804b8f30e8f45f15}{LCI\_\-stopTask} (void)
\begin{CompactList}\small\item\em Stop the LCI task. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_189dae1a7ccb27b31bac5fb6dc89c9e7}{LCI\_\-teardown} (void)
\begin{CompactList}\small\item\em Tear down the calibration system. \item\end{CompactList}\item 
unsigned \hyperlink{control_8c_850580a01eab761f5bc4ee718512c6cb}{LCI\_\-terminate} (unsigned status)
\begin{CompactList}\small\item\em Terminate a calibration. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Principal routines of the charge injection calibration utility. 

\begin{Desc}
\item[Author:]James Swain \& Owen Saxton\end{Desc}
{\bf \$Id:} \hyperlink{control_8c}{control.c},v 1.34 2011/03/29 19:32:57 saxton Exp \$ 

\subsection{Function Documentation}
\hypertarget{control_8c_fcbf0f417b3621f3890f945515149aa7}{
\index{control.c@{control.c}!LCI\_\-abort@{LCI\_\-abort}}
\index{LCI\_\-abort@{LCI\_\-abort}!control.c@{control.c}}
\subsubsection[{LCI\_\-abort}]{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-abort (void)}}
\label{control_8c_fcbf0f417b3621f3890f945515149aa7}


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 

Referenced by LCI\_\-ABORT().\hypertarget{control_8c_c8845f2cdd3fa2018106b9e6bd54fbe9}{
\index{control.c@{control.c}!LCI\_\-calibrate@{LCI\_\-calibrate}}
\index{LCI\_\-calibrate@{LCI\_\-calibrate}!control.c@{control.c}}
\subsubsection[{LCI\_\-calibrate}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-calibrate (unsigned {\em latccfg}, \/  unsigned {\em lcicfg}, \/  unsigned {\em lcirunid}, \/  ITC\_\-NodeID {\em iniNode}, \/  ITC\_\-TaskID {\em iniTask}, \/  ITC\_\-QueueID {\em iniQueue})}}
\label{control_8c_c8845f2cdd3fa2018106b9e6bd54fbe9}


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.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em latccfg}]File ID for the LATC configuration master to use with this calibration\item[{\em lcicfg}]File ID for the LCI configuration file to use to drive this calibration\item[{\em lcirunid}]Run ID to use in the datagrams\item[{\em iniNode}]Node ID of the task that initiated the calibration (used to send a message back when the calibration completes)\item[{\em iniTask}]Task ID of the task that initiated the calibration (used to send a message back when the calibration completes)\item[{\em iniQueue}]ID of the queue that will receive the status message.\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-STATE}]LCI is not in the correct state to start a calibration \item[{\em ITC\_\-ALOCFAIL}]Memory allocation failure \item[{\em ITC\_\-FPAGET}]Memory allocation from FPA failed \item[{\em ITC\_\-SENDNID}]Invalid/unreachable destination node \item[{\em ITC\_\-SENDQID}]Invalid/unreachable destination queue \item[{\em ITC\_\-SHRMEM}]Shared memory pool stopping/stopped \item[{\em ITC\_\-SUCCESS}]If an item is sent to the LCI bulk queue \end{description}
\end{Desc}


References LCI\_\-collClearCounts(), LCI\_\-collRunInit(), LCI\_\-collTime(), LCI\_\-confBufferModel(), LCI\_\-confCache(), LCI\_\-confMode(), LCI\_\-confNodeId(), LCI\_\-confOpenFid(), LCI\_\-confTimes(), LCI\_\-startCycle(), and LCI\_\-terminate().

Referenced by LCI\_\-CALIBRATE().\hypertarget{control_8c_01e47d0c7b36ac0cba0556ecad721dac}{
\index{control.c@{control.c}!LCI\_\-cb\_\-statusFree@{LCI\_\-cb\_\-statusFree}}
\index{LCI\_\-cb\_\-statusFree@{LCI\_\-cb\_\-statusFree}!control.c@{control.c}}
\subsubsection[{LCI\_\-cb\_\-statusFree}]{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-cb\_\-statusFree (ITC\_\-QueueItem $\ast$ {\em qitem}, \/  unsigned int {\em status}, \/  void $\ast$ {\em prm0}, \/  void $\ast$ {\em prm1}, \/  void $\ast$ {\em prm2}, \/  unsigned int {\em tx})}}
\label{control_8c_01e47d0c7b36ac0cba0556ecad721dac}


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.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em qitem}]Queue item to be returned to the pool\item[{\em status}]Success or failure of the ITC delivery\item[{\em prm0}]User defined parameter 0 (pointer to the FPM pool)\item[{\em prm1}]User defined (NULL)\item[{\em prm2}]User defined (NULL)\item[{\em tx}]Transmission status \end{description}
\end{Desc}
\hypertarget{control_8c_defc818848c6f17bb096455177ad34ed}{
\index{control.c@{control.c}!LCI\_\-comp@{LCI\_\-comp}}
\index{LCI\_\-comp@{LCI\_\-comp}!control.c@{control.c}}
\subsubsection[{LCI\_\-comp}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-comp (unsigned {\em comp})}}
\label{control_8c_defc818848c6f17bb096455177ad34ed}


Set the calibration compression level. 

This routine sets the LCI compression level and returns the old value. This feature is used only for testing.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em comp}]Compression level to set\begin{itemize}
\item LSEC\_\-COMP\_\-NORM Normal\item LSEC\_\-COMP\_\-ONLY None, send only data for type\item LSEC\_\-COMP\_\-NONE None, send all data\end{itemize}
\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Previous compression level \end{Desc}
\hypertarget{control_8c_539ec71864d6b5fc0ff74c950d8fc15e}{
\index{control.c@{control.c}!LCI\_\-cycle@{LCI\_\-cycle}}
\index{LCI\_\-cycle@{LCI\_\-cycle}!control.c@{control.c}}
\subsubsection[{LCI\_\-cycle}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int LCI\_\-cycle (void $\ast$ {\em prm}, \/  const struct {\bf \_\-ITC\_\-QueueItem} $\ast$ {\em qitem}, \/  void $\ast$ {\em pay}, \/  unsigned int {\em len})}}
\label{control_8c_539ec71864d6b5fc0ff74c950d8fc15e}


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.

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-ABORTED}]if the abort flag was found to be set at the start of the cycle \item[{\em LCI\_\-FOPER}]if there is an error during the read or the configuration is incomplete \item[{\em LCI\_\-QITEM}]The attempt to allocate a QueueItem fails \item[{\em ITC\_\-ALOCFAIL}]Memory allocation failure \item[{\em ITC\_\-FPAGET}]Memory allocation from FPA failed \item[{\em ITC\_\-SENDNID}]Invalid/unreachable destination node \item[{\em ITC\_\-SENDQID}]Invalid/unreachable destination queue \item[{\em ITC\_\-SHRMEM}]Shared memory pool stopping/stopped \item[{\em LCI\_\-SUCCESS}]if the calibration cycle is successfully completed \end{description}
\end{Desc}


References LCI\_\-MON\_\-CYCLES, LCI\_\-startCycle(), and LCI\_\-terminate().

Referenced by LCI\_\-init().\hypertarget{control_8c_909c3b4b041de8bfb062510e084fc793}{
\index{control.c@{control.c}!LCI\_\-cycles@{LCI\_\-cycles}}
\index{LCI\_\-cycles@{LCI\_\-cycles}!control.c@{control.c}}
\subsubsection[{LCI\_\-cycles}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-cycles (void)}}
\label{control_8c_909c3b4b041de8bfb062510e084fc793}


Get the calibration cycle count. 

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

\begin{Desc}
\item[Returns:]Number of cycles performed since the last command to calibrate was issued \end{Desc}
\hypertarget{control_8c_d710fdeaf0a0093fe3cea760c7a0ad67}{
\index{control.c@{control.c}!LCI\_\-deleteController@{LCI\_\-deleteController}}
\index{LCI\_\-deleteController@{LCI\_\-deleteController}!control.c@{control.c}}
\subsubsection[{LCI\_\-deleteController}]{\setlength{\rightskip}{0pt plus 5cm}void LCI\_\-deleteController ({\bf LCI\_\-controller} $\ast$ {\em cnt})}}
\label{control_8c_d710fdeaf0a0093fe3cea760c7a0ad67}


Free the calibration controller structure. 

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

References LCI\_\-collDelete(), and LCI\_\-confDelete().

Referenced by LCI\_\-init(), LCI\_\-newController(), and LCI\_\-teardown().\hypertarget{control_8c_24343f001c0a9a2926398db94cff4fc5}{
\index{control.c@{control.c}!LCI\_\-getRunInfo@{LCI\_\-getRunInfo}}
\index{LCI\_\-getRunInfo@{LCI\_\-getRunInfo}!control.c@{control.c}}
\subsubsection[{LCI\_\-getRunInfo}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-getRunInfo ({\bf LCI\_\-runInfo} $\ast$ {\em info})}}
\label{control_8c_24343f001c0a9a2926398db94cff4fc5}


Get extended information about the calibration run. 

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

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em info}]The address of a block to be filled with the current run information.\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-SUCCESS}]success always \end{description}
\end{Desc}


References \_\-LCI\_\-runInfo::cfgFid, \_\-LCI\_\-runInfo::endSec, \_\-LCI\_\-runInfo::endSub, \_\-LCI\_\-runInfo::latcFid, \_\-LCI\_\-runInfo::runId, \_\-LCI\_\-runInfo::spare, \_\-LCI\_\-runInfo::startSec, \_\-LCI\_\-runInfo::startSub, and \_\-LCI\_\-runInfo::status.\hypertarget{control_8c_0a2dd589898b35c95b7f87855ed67ddb}{
\index{control.c@{control.c}!LCI\_\-init@{LCI\_\-init}}
\index{LCI\_\-init@{LCI\_\-init}!control.c@{control.c}}
\subsubsection[{LCI\_\-init}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-init (unsigned {\em capacity}, \/  unsigned {\em cpuid}, \/  unsigned {\em srcid})}}
\label{control_8c_0a2dd589898b35c95b7f87855ed67ddb}


Initialize the calibration system. 

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

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em srcid}]ID of the source of data being processed through LCI\item[{\em cpuid}]ID of the CPU LCI is being run on\item[{\em capacity}]Maximum number of events per calibration cycle.\end{description}
\end{Desc}
\begin{Desc}
\item[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. \end{Desc}


References LCI\_\-Apid67c, LCI\_\-Apid67d, LCI\_\-cycle(), LCI\_\-deleteController(), LCI\_\-newController(), and LCI\_\-teardown().

Referenced by LCI\_\-initialise().\hypertarget{control_8c_472232a9e411b7729f097642d5dd1dd0}{
\index{control.c@{control.c}!LCI\_\-initialise@{LCI\_\-initialise}}
\index{LCI\_\-initialise@{LCI\_\-initialise}!control.c@{control.c}}
\subsubsection[{LCI\_\-initialise}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-initialise (void)}}
\label{control_8c_472232a9e411b7729f097642d5dd1dd0}


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 {\em capacity\/}, {\em cpuid\/} and {\em srcid\/} parameters.

\begin{Desc}
\item[Returns:]Any of the return codes from LCI\_\-init \end{Desc}


References LCI\_\-init().\hypertarget{control_8c_b8c7c1df2b2bf96872e109c230d83937}{
\index{control.c@{control.c}!LCI\_\-monitor@{LCI\_\-monitor}}
\index{LCI\_\-monitor@{LCI\_\-monitor}!control.c@{control.c}}
\subsubsection[{LCI\_\-monitor}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-monitor (unsigned {\em mon})}}
\label{control_8c_b8c7c1df2b2bf96872e109c230d83937}


Set the calibration monitoring level. 

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

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em mon}]Monitoring level to set, as the logical OR of the bits:\begin{itemize}
\item \hyperlink{lci__p_8h_6c78ed314019eb9e94961b1a4a202d064aa55081f5b131662fe3039f4c0d5a49}{LCI\_\-MON\_\-TIMES} Display timing information\item \hyperlink{lci__p_8h_6c78ed314019eb9e94961b1a4a202d0615de1777b4406d9ca2f5f571492c73c1}{LCI\_\-MON\_\-CYCLES} Display cycle information\end{itemize}
\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Previous monitoring level \end{Desc}
\hypertarget{control_8c_26ed3fab76f83fe71864791092b2db7f}{
\index{control.c@{control.c}!LCI\_\-newController@{LCI\_\-newController}}
\index{LCI\_\-newController@{LCI\_\-newController}!control.c@{control.c}}
\subsubsection[{LCI\_\-newController}]{\setlength{\rightskip}{0pt plus 5cm}{\bf LCI\_\-controller}$\ast$ LCI\_\-newController (unsigned {\em cap}, \/  unsigned {\em cpuid}, \/  unsigned {\em srcid})}}
\label{control_8c_26ed3fab76f83fe71864791092b2db7f}


Create calibration controller structure. 

This routine allocates memory for an LCI\_\-controller structure and all associated structures.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em srcid}]ID of the source of data being processed through LCI\item[{\em cpuid}]ID of the CPU LCI is being run on\item[{\em cap}]Capacity of the calibration task, the maximum number of events that can be collected each cycle\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to a new LCI\_\-controller \end{Desc}


References LCI\_\-collCreate(), LCI\_\-confCreate(), and LCI\_\-deleteController().

Referenced by LCI\_\-init().\hypertarget{control_8c_507830f45fcf4580bf928f90d58631fe}{
\index{control.c@{control.c}!LCI\_\-sizeofRunInfo@{LCI\_\-sizeofRunInfo}}
\index{LCI\_\-sizeofRunInfo@{LCI\_\-sizeofRunInfo}!control.c@{control.c}}
\subsubsection[{LCI\_\-sizeofRunInfo}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-sizeofRunInfo (void)}}
\label{control_8c_507830f45fcf4580bf928f90d58631fe}


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.

\begin{Desc}
\item[Returns:]The size, in bytes, of the extended run information. \end{Desc}
\hypertarget{control_8c_90c1754fe33dbd8aa659d59b3734fcd1}{
\index{control.c@{control.c}!LCI\_\-start@{LCI\_\-start}}
\index{LCI\_\-start@{LCI\_\-start}!control.c@{control.c}}
\subsubsection[{LCI\_\-start}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-start (const TASK\_\-attr $\ast$ {\em attr})}}
\label{control_8c_90c1754fe33dbd8aa659d59b3734fcd1}


Start the LCI task. 

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

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em attr}]Task attributes to use for the LCI task.\end{description}
\end{Desc}
\begin{Desc}
\item[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. \end{Desc}


Referenced by LCI\_\-startTask().\hypertarget{control_8c_6de72ca775513507fbb19431949dc62b}{
\index{control.c@{control.c}!LCI\_\-startCycle@{LCI\_\-startCycle}}
\index{LCI\_\-startCycle@{LCI\_\-startCycle}!control.c@{control.c}}
\subsubsection[{LCI\_\-startCycle}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-startCycle (void)}}
\label{control_8c_6de72ca775513507fbb19431949dc62b}


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.

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-QITEM}]The attempt to allocate a QueueItem fails \item[{\em ITC\_\-ALOCFAIL}]Memory allocation failure \item[{\em ITC\_\-FPAGET}]Memory allocation from FPA failed \item[{\em ITC\_\-SENDNID}]Invalid/unreachable destination node \item[{\em ITC\_\-SENDQID}]Invalid/unreachable destination queue \item[{\em ITC\_\-SHRMEM}]Shared memory pool stopping/stopped \item[{\em ITC\_\-SUCCESS}]If an item is sent to the LCI bulk queue \end{description}
\end{Desc}


!!! KULDGE - ITC won't accept a NULL payload pointer. 

Referenced by LCI\_\-calibrate(), and LCI\_\-cycle().\hypertarget{control_8c_bdd61cff8129f3677b0e1ed6cdeb60d8}{
\index{control.c@{control.c}!LCI\_\-startTask@{LCI\_\-startTask}}
\index{LCI\_\-startTask@{LCI\_\-startTask}!control.c@{control.c}}
\subsubsection[{LCI\_\-startTask}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-startTask (void)}}
\label{control_8c_bdd61cff8129f3677b0e1ed6cdeb60d8}


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.

\begin{Desc}
\item[Returns:]Any of the return codes from LCI\_\-startTask \end{Desc}


References LCI\_\-start().\hypertarget{control_8c_866532c88fb7c94bbea3082270718521}{
\index{control.c@{control.c}!LCI\_\-status@{LCI\_\-status}}
\index{LCI\_\-status@{LCI\_\-status}!control.c@{control.c}}
\subsubsection[{LCI\_\-status}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-status (void)}}
\label{control_8c_866532c88fb7c94bbea3082270718521}


Get the calibration state. 

This routine returns the current state of LCI.

\begin{Desc}
\item[Returns:]Current state of LCI \end{Desc}
\hypertarget{control_8c_b990de0d4b06a814804b8f30e8f45f15}{
\index{control.c@{control.c}!LCI\_\-stopTask@{LCI\_\-stopTask}}
\index{LCI\_\-stopTask@{LCI\_\-stopTask}!control.c@{control.c}}
\subsubsection[{LCI\_\-stopTask}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-stopTask (void)}}
\label{control_8c_b990de0d4b06a814804b8f30e8f45f15}


Stop the LCI task. 

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

\begin{Desc}
\item[Returns:]LCI\_\-STATE if the state is not WAITING, an error status code from ITC\_\-stopTask or LCI\_\-SUCCESS if all goes well \end{Desc}
\hypertarget{control_8c_189dae1a7ccb27b31bac5fb6dc89c9e7}{
\index{control.c@{control.c}!LCI\_\-teardown@{LCI\_\-teardown}}
\index{LCI\_\-teardown@{LCI\_\-teardown}!control.c@{control.c}}
\subsubsection[{LCI\_\-teardown}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-teardown (void)}}
\label{control_8c_189dae1a7ccb27b31bac5fb6dc89c9e7}


Tear down the calibration system. 

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

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LCI\_\-STATE}]If the LCI task is not in the INITIALISED state\item[{\em LCI\_\-SUCCESS}]If all goes well \end{description}
\end{Desc}


References LCI\_\-Apid67c, LCI\_\-Apid67d, and LCI\_\-deleteController().

Referenced by LCI\_\-init().\hypertarget{control_8c_850580a01eab761f5bc4ee718512c6cb}{
\index{control.c@{control.c}!LCI\_\-terminate@{LCI\_\-terminate}}
\index{LCI\_\-terminate@{LCI\_\-terminate}!control.c@{control.c}}
\subsubsection[{LCI\_\-terminate}]{\setlength{\rightskip}{0pt plus 5cm}unsigned LCI\_\-terminate (unsigned {\em status})}}
\label{control_8c_850580a01eab761f5bc4ee718512c6cb}


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.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em status}]Termination status of the last calibration cycle, and hence of the whole calibration\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em ITC\_\-SUCCESS}]Success \item[{\em LCI\_\-QITEM}]The attempt to allocate a QueueItem fails \item[{\em ITC\_\-ALOCFAIL}]Memory allocation failure \item[{\em ITC\_\-FPAGET}]Memory allocation from FPA failed \item[{\em ITC\_\-SENDNID}]Invalid/unreachable destination node \item[{\em ITC\_\-SENDQID}]Invalid/unreachable destination queue \item[{\em ITC\_\-SHRMEM}]Shared memory pool stopping/stopped \end{description}
\end{Desc}


References LCI\_\-collCounts(), LCI\_\-collRunTerm(), LCI\_\-confBufferModel(), LCI\_\-confClose(), and LCI\_\-MON\_\-TIMES.

Referenced by LCI\_\-calibrate(), and LCI\_\-cycle().