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


Report the cumulative counter of time for which a flag is true as rate counter.  




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

\doxysubsection*{Data Fields}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+time\+\_\+cc\+\_\+cfg} \textbf{ cfg}
\item 
bool \textbf{ flag\+\_\+state}
\item 
uint64\+\_\+t \textbf{ total\+\_\+sum}
\begin{DoxyCompactList}\small\item\em Overall cumulative sum. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+timer\+\_\+list} \textbf{ timer}
\item 
uint64\+\_\+t \textbf{ start\+\_\+time}
\begin{DoxyCompactList}\small\item\em CLOCK\+\_\+\+MONOTONIC reading in microseconds, at the time when the \doxyref{osmo\+\_\+time\+\_\+cc}{p.}{structosmo__time__cc} instance started counting. \end{DoxyCompactList}\item 
uint64\+\_\+t \textbf{ last\+\_\+counted\+\_\+time}
\begin{DoxyCompactList}\small\item\em CLOCK\+\_\+\+MONOTONIC reading in microseconds, at the time when the \doxyref{osmo\+\_\+time\+\_\+cc}{p.}{structosmo__time__cc} last evaluated the flag state and possibly added to the cumulated sum. \end{DoxyCompactList}\item 
uint64\+\_\+t \textbf{ sum}
\begin{DoxyCompactList}\small\item\em Internal cumulative counter of time that flag\+\_\+state was true. \end{DoxyCompactList}\item 
uint64\+\_\+t \textbf{ reported\+\_\+sum}
\begin{DoxyCompactList}\small\item\em The amount of time that already reported cfg.\+rate\+\_\+ctr increments account for. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Report the cumulative counter of time for which a flag is true as rate counter. 

See also \doxyref{osmo\+\_\+time\+\_\+cc\+\_\+cfg}{p.}{structosmo__time__cc__cfg} for details on configuring.

Usage\+: \begin{DoxyVerb}struct my_obj {
        struct osmo_time_cc flag_cc;
};

void my_obj_init(struct my_obj *my_obj)
{
        osmo_time_cc_init(&my_obj->flag_cc);
        my_obj->flag_cc.cfg = (struct osmo_time_cc_cfg){
                        .gran_usec = 1000000,
                        .forget_sum_usec = 60000000,
                        .rate_ctr = rate_ctr_group_get_ctr(my_ctrg, MY_CTR_IDX),
                };
        // optional: set initial flag state, default is 'false':
        // osmo_time_cc_set_flag(&my_obj->flag_cc, false);
}

void my_obj_event(struct my_obj *my_obj, bool flag)
{
        osmo_time_cc_set_flag(&my_obj->flag_cc, flag);
}

void my_obj_destruct(struct my_obj *my_obj)
{
        osmo_time_cc_cleanup(&my_obj->flag_cc);
}
\end{DoxyVerb}
 

\doxysubsection{Field Documentation}
\mbox{\label{structosmo__time__cc_a2baaec831f2a84fc42e884b0db2fcda9}} 
\index{osmo\_time\_cc@{osmo\_time\_cc}!cfg@{cfg}}
\index{cfg@{cfg}!osmo\_time\_cc@{osmo\_time\_cc}}
\doxysubsubsection{cfg}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+time\+\_\+cc\+\_\+cfg} osmo\+\_\+time\+\_\+cc\+::cfg}

\mbox{\label{structosmo__time__cc_a81138b0a4b00edd05220d2b2e4a9e2b9}} 
\index{osmo\_time\_cc@{osmo\_time\_cc}!flag\_state@{flag\_state}}
\index{flag\_state@{flag\_state}!osmo\_time\_cc@{osmo\_time\_cc}}
\doxysubsubsection{flag\_state}
{\footnotesize\ttfamily bool osmo\+\_\+time\+\_\+cc\+::flag\+\_\+state}

\mbox{\label{structosmo__time__cc_a657c939b1574a736235defbe1fe5f8f1}} 
\index{osmo\_time\_cc@{osmo\_time\_cc}!last\_counted\_time@{last\_counted\_time}}
\index{last\_counted\_time@{last\_counted\_time}!osmo\_time\_cc@{osmo\_time\_cc}}
\doxysubsubsection{last\_counted\_time}
{\footnotesize\ttfamily uint64\+\_\+t osmo\+\_\+time\+\_\+cc\+::last\+\_\+counted\+\_\+time}



CLOCK\+\_\+\+MONOTONIC reading in microseconds, at the time when the \doxyref{osmo\+\_\+time\+\_\+cc}{p.}{structosmo__time__cc} last evaluated the flag state and possibly added to the cumulated sum. 

\mbox{\label{structosmo__time__cc_ab049651207b2d4207c38320c2fa6a881}} 
\index{osmo\_time\_cc@{osmo\_time\_cc}!reported\_sum@{reported\_sum}}
\index{reported\_sum@{reported\_sum}!osmo\_time\_cc@{osmo\_time\_cc}}
\doxysubsubsection{reported\_sum}
{\footnotesize\ttfamily uint64\+\_\+t osmo\+\_\+time\+\_\+cc\+::reported\+\_\+sum}



The amount of time that already reported cfg.\+rate\+\_\+ctr increments account for. 

This may be ahead of or behind \textquotesingle{}sum\textquotesingle{}, depending on cfg.\+round\+\_\+threshold\+\_\+usec. \mbox{\label{structosmo__time__cc_abb648f545ea2521e6688f4c39324a469}} 
\index{osmo\_time\_cc@{osmo\_time\_cc}!start\_time@{start\_time}}
\index{start\_time@{start\_time}!osmo\_time\_cc@{osmo\_time\_cc}}
\doxysubsubsection{start\_time}
{\footnotesize\ttfamily uint64\+\_\+t osmo\+\_\+time\+\_\+cc\+::start\+\_\+time}



CLOCK\+\_\+\+MONOTONIC reading in microseconds, at the time when the \doxyref{osmo\+\_\+time\+\_\+cc}{p.}{structosmo__time__cc} instance started counting. 

\mbox{\label{structosmo__time__cc_a296baa4bd538ac56e9a07bee8c48010a}} 
\index{osmo\_time\_cc@{osmo\_time\_cc}!sum@{sum}}
\index{sum@{sum}!osmo\_time\_cc@{osmo\_time\_cc}}
\doxysubsubsection{sum}
{\footnotesize\ttfamily uint64\+\_\+t osmo\+\_\+time\+\_\+cc\+::sum}



Internal cumulative counter of time that flag\+\_\+state was true. 

It may get reset to zero regularly, depending on cfg.\+forget\+\_\+sum\+\_\+usec. This is the basis for incrementing cfg.\+rate\+\_\+ctr. \mbox{\label{structosmo__time__cc_a96ef07961091e1f8926b8d98ff9684b9}} 
\index{osmo\_time\_cc@{osmo\_time\_cc}!timer@{timer}}
\index{timer@{timer}!osmo\_time\_cc@{osmo\_time\_cc}}
\doxysubsubsection{timer}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+timer\+\_\+list} osmo\+\_\+time\+\_\+cc\+::timer}

\mbox{\label{structosmo__time__cc_a09624b09c014251d80d28f8d0938c086}} 
\index{osmo\_time\_cc@{osmo\_time\_cc}!total\_sum@{total\_sum}}
\index{total\_sum@{total\_sum}!osmo\_time\_cc@{osmo\_time\_cc}}
\doxysubsubsection{total\_sum}
{\footnotesize\ttfamily uint64\+\_\+t osmo\+\_\+time\+\_\+cc\+::total\+\_\+sum}



Overall cumulative sum. 

Does not get reset for the entire lifetime of an \doxyref{osmo\+\_\+time\+\_\+cc}{p.}{structosmo__time__cc}. (Informational only, not used by the \doxyref{osmo\+\_\+time\+\_\+cc}{p.}{structosmo__time__cc} implementation.) 

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