\doxysection{osmo\+\_\+time\+\_\+cc\+\_\+cfg Struct Reference}
\label{structosmo__time__cc__cfg}\index{osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}}


Configuration for \doxyref{osmo\+\_\+time\+\_\+cc}{p.}{structosmo__time__cc}.  




{\ttfamily \#include $<$time\+\_\+cc.\+h$>$}

\doxysubsection*{Data Fields}
\begin{DoxyCompactItemize}
\item 
uint64\+\_\+t \textbf{ gran\+\_\+usec}
\begin{DoxyCompactList}\small\item\em Granularity in microseconds\+: nr of microseconds that one \doxyref{rate\+\_\+ctr}{p.}{structrate__ctr} increment represents. \end{DoxyCompactList}\item 
uint64\+\_\+t \textbf{ round\+\_\+threshold\+\_\+usec}
\begin{DoxyCompactList}\small\item\em Nr of microseconds above n $\ast$ gran\+\_\+usec at which to trigger a counter increment. \end{DoxyCompactList}\item 
uint64\+\_\+t \textbf{ forget\+\_\+sum\+\_\+usec}
\begin{DoxyCompactList}\small\item\em Forget counted sub-\/gran time after the flag was false for this long. \end{DoxyCompactList}\item 
struct \textbf{ rate\+\_\+ctr} $\ast$ \textbf{ rate\+\_\+ctr}
\begin{DoxyCompactList}\small\item\em Rate counter to report to, or NULL to not use it. \end{DoxyCompactList}\item 
int \textbf{ T\+\_\+gran}
\begin{DoxyCompactList}\small\item\em Update gran\+\_\+usec from this T timer value, or zero to not use any T timer. \end{DoxyCompactList}\item 
int \textbf{ T\+\_\+round\+\_\+threshold}
\begin{DoxyCompactList}\small\item\em Update round\+\_\+threshold\+\_\+usec from this T timer value, or zero to not use any T timer. \end{DoxyCompactList}\item 
int \textbf{ T\+\_\+forget\+\_\+sum}
\begin{DoxyCompactList}\small\item\em Update forget\+\_\+sum\+\_\+usec from this T timer value, or zero to not use any T timer. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+tdef} $\ast$ \textbf{ T\+\_\+defs}
\begin{DoxyCompactList}\small\item\em Look up T\+\_\+gran and T\+\_\+forget\+\_\+sum in this list of timers, or NULL to not use any T timers. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Configuration for \doxyref{osmo\+\_\+time\+\_\+cc}{p.}{structosmo__time__cc}. 

Report the cumulative counter of time for which a flag is true as rate counter. For example, for each second that the flag is true, increment a rate counter.

The flag to be monitored is reported by \doxyref{osmo\+\_\+time\+\_\+cc\+\_\+set\+\_\+flag()}{p.}{group__time__cc_ga1feb41a008ddeffe6b77a8d2569a14d4}.

The granularity defines how much time one rate counter increment represents\+: the default configuration is gran\+\_\+usec = 1000000, i.\+e. one rate counter increment represents one second.

Reporting as rate counter is configurable by round\+\_\+threshold\+\_\+usec and forget\+\_\+sum\+\_\+usec, examples\+:

round\+\_\+threshold\+\_\+usec\+:
\begin{DoxyItemize}
\item To get \char`\"{}ceil()\char`\"{} behavior, set round\+\_\+threshold\+\_\+usec = 1. This increments the rate counter for each gran\+\_\+usec period where the flag was seen true, even if it was true for only a very short fraction of a gran\+\_\+usec period.
\item To get \char`\"{}round()\char`\"{} behavior, set round\+\_\+threshold\+\_\+usec = half of gran\+\_\+usec. The rate counter increments when the flag has been true for 0.\+5 of a gran\+\_\+usec (and then again at 1.\+5 $\ast$ gran\+\_\+usec) of \textquotesingle{}true\textquotesingle{} flag. round\+\_\+threshold\+\_\+usec = 0 is a special value that means to use half of gran\+\_\+usec.
\item To get \char`\"{}floor()\char`\"{} behavior, set round\+\_\+threshold\+\_\+usec $>$= gran\+\_\+usec. The rate counter increments when reaching full gran\+\_\+usec periods of the flag being true.
\end{DoxyItemize}

forget\+\_\+sum\+\_\+usec\+: This is a tradeoff between the accuracy of the reported rate counter and making sure that the events reported are not irrelevantly long ago.
\begin{DoxyItemize}
\item To keep sub-\/granularity-\/period surplus time forever, set forget\+\_\+sum\+\_\+usec = 0.
\item To keep surplus time for up to a minute, set forget\+\_\+sum\+\_\+usec = 60000000 (60 seconds).
\item To get rid of \char`\"{}leftover\char`\"{} time (almost) immediately after the flag goes false, set forget\+\_\+sum\+\_\+usec = 1.
\item If gran\+\_\+usec is set to one second and forget\+\_\+sum\+\_\+usec is set to one minute, the reported rate counter has a possible inaccuracy of 1/60th, but makes sure that no timings older than a minute affect the current reports.
\end{DoxyItemize}

Reporting modes in detail\+:

The \doxyref{rate\+\_\+ctr}{p.}{structrate__ctr} increments when the cumulative counter passes round\+\_\+threshold\+\_\+usec (default\+: half of gran\+\_\+usec). \begin{DoxyVerb}                   sum ^
                       |                                          ________
                       |                                         /
                       |                                        /
                       |                                       /
              3*gran --+--------------------------------------+
                       |                                     /:
                       |                                    / :
                       | - - - - - - - - - - - - - - - - - /  :
                       |                                  /.  :
                       |                                 / .  :
              2*gran --+--------------------------------+  .  :
                       |                               /:  .  :
                       |                              / :  .  :
                       | - - - - - - - - - -_________/  :  .  :
                       |                   /         .  :  .  :
                       |                  /          .  :  .  :
              1*gran --+-----------------+           .  :  .  :
                       |                /:           .  :  .  :
                       |               / :           .  :  .  :
                       | - - - - - - -/  :           .  :  .  :
                       |             /.  :           .  :  .  :
                       | ....-------' .  :           .  :  .  :
                    0  +------------------------------------------------------------------------> elapsed time
                                      .  :           .  :  .  :
                          _   _      _______         ____________
              flag:    __| |_| |____| .  :  |_______|.  :  .  :  |__________
                       f t f t f    t .  :  f       t.  :  .  :  f
\end{DoxyVerb}
 round\+\_\+threshold\+\_\+usec \+: . \+: . \+: . \+: = 1 usec\+: 0 1 . \+:2 . \+:3 . \+:4 = \char`\"{}ceil()\char`\"{} = 0 == gran\+\_\+usec/2\+: 0 1 \+: 2 \+: 3 \+: = \char`\"{}round()\char`\"{} $>$= gran\+\_\+usec\+: 0 1 2 3 = \char`\"{}floor()\char`\"{} 

\doxysubsection{Field Documentation}
\mbox{\label{structosmo__time__cc__cfg_af7181e34adbc13ec64a3ab90bbc3c0e2}} 
\index{osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}!forget\_sum\_usec@{forget\_sum\_usec}}
\index{forget\_sum\_usec@{forget\_sum\_usec}!osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}}
\doxysubsubsection{forget\_sum\_usec}
{\footnotesize\ttfamily uint64\+\_\+t osmo\+\_\+time\+\_\+cc\+\_\+cfg\+::forget\+\_\+sum\+\_\+usec}



Forget counted sub-\/gran time after the flag was false for this long. 

\mbox{\label{structosmo__time__cc__cfg_a93be973a22fb778609777a0882c612f8}} 
\index{osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}!gran\_usec@{gran\_usec}}
\index{gran\_usec@{gran\_usec}!osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}}
\doxysubsubsection{gran\_usec}
{\footnotesize\ttfamily uint64\+\_\+t osmo\+\_\+time\+\_\+cc\+\_\+cfg\+::gran\+\_\+usec}



Granularity in microseconds\+: nr of microseconds that one \doxyref{rate\+\_\+ctr}{p.}{structrate__ctr} increment represents. 

A typical value is gran\+\_\+usec = 1000000, meaning one rate counter increment represents one second. When zero, use 1000000. \mbox{\label{structosmo__time__cc__cfg_aa01fa71082702abfeebac2d62ac12b3a}} 
\index{osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}!rate\_ctr@{rate\_ctr}}
\index{rate\_ctr@{rate\_ctr}!osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}}
\doxysubsubsection{rate\_ctr}
{\footnotesize\ttfamily struct \textbf{ rate\+\_\+ctr}$\ast$ osmo\+\_\+time\+\_\+cc\+\_\+cfg\+::rate\+\_\+ctr}



Rate counter to report to, or NULL to not use it. 

\mbox{\label{structosmo__time__cc__cfg_aceacac547554ccb755b66114af5971ae}} 
\index{osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}!round\_threshold\_usec@{round\_threshold\_usec}}
\index{round\_threshold\_usec@{round\_threshold\_usec}!osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}}
\doxysubsubsection{round\_threshold\_usec}
{\footnotesize\ttfamily uint64\+\_\+t osmo\+\_\+time\+\_\+cc\+\_\+cfg\+::round\+\_\+threshold\+\_\+usec}



Nr of microseconds above n $\ast$ gran\+\_\+usec at which to trigger a counter increment. 

When zero, use half a gran\+\_\+usec. \mbox{\label{structosmo__time__cc__cfg_af64ab35d0ec6ed887d568d5ec226c6db}} 
\index{osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}!T\_defs@{T\_defs}}
\index{T\_defs@{T\_defs}!osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}}
\doxysubsubsection{T\_defs}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+tdef}$\ast$ osmo\+\_\+time\+\_\+cc\+\_\+cfg\+::\+T\+\_\+defs}



Look up T\+\_\+gran and T\+\_\+forget\+\_\+sum in this list of timers, or NULL to not use any T timers. 

\mbox{\label{structosmo__time__cc__cfg_a18a69cabb36510378162fbf66b818cd5}} 
\index{osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}!T\_forget\_sum@{T\_forget\_sum}}
\index{T\_forget\_sum@{T\_forget\_sum}!osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}}
\doxysubsubsection{T\_forget\_sum}
{\footnotesize\ttfamily int osmo\+\_\+time\+\_\+cc\+\_\+cfg\+::\+T\+\_\+forget\+\_\+sum}



Update forget\+\_\+sum\+\_\+usec from this T timer value, or zero to not use any T timer. 

\mbox{\label{structosmo__time__cc__cfg_addce4e6f974d5a0d734388dd9b3eb52b}} 
\index{osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}!T\_gran@{T\_gran}}
\index{T\_gran@{T\_gran}!osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}}
\doxysubsubsection{T\_gran}
{\footnotesize\ttfamily int osmo\+\_\+time\+\_\+cc\+\_\+cfg\+::\+T\+\_\+gran}



Update gran\+\_\+usec from this T timer value, or zero to not use any T timer. 

\mbox{\label{structosmo__time__cc__cfg_aea10d0878ae511a70182038011fa02a4}} 
\index{osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}!T\_round\_threshold@{T\_round\_threshold}}
\index{T\_round\_threshold@{T\_round\_threshold}!osmo\_time\_cc\_cfg@{osmo\_time\_cc\_cfg}}
\doxysubsubsection{T\_round\_threshold}
{\footnotesize\ttfamily int osmo\+\_\+time\+\_\+cc\+\_\+cfg\+::\+T\+\_\+round\+\_\+threshold}



Update round\+\_\+threshold\+\_\+usec from this T timer value, or zero to not use any T timer. 



The documentation for this struct was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
include/osmocom/core/\textbf{ time\+\_\+cc.\+h}\end{DoxyCompactItemize}
