\hypertarget{simplehsm_8c}{
\section{simplehsm/simplehsm.c File Reference}
\label{simplehsm_8c}\index{simplehsm/simplehsm.c@{simplehsm/simplehsm.c}}
}
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$tchar.h$>$}\par
{\tt \#include \char`\"{}simplehsm.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{simplehsm_8c_637aef0e0ae28c979dfca2a40b3db6c3}{simplehsm\_\-initialize} (\hyperlink{structsimplehsm__t}{simplehsm\_\-t} $\ast$\hyperlink{oven_8c_b0f5f1813e601676237fefa2690bf4a5}{hsm}, \hyperlink{simplehsm_8h_cbcc44b14ee70c1d2ed54b95afcd5e62}{stfunc} top\_\-state)
\item 
BOOL \hyperlink{simplehsm_8c_ec6a0d82fdc3b8b36cb558f8b1dbdb52}{\_\-is\_\-parent} (\hyperlink{structsimplehsm__t}{simplehsm\_\-t} $\ast$\hyperlink{oven_8c_b0f5f1813e601676237fefa2690bf4a5}{hsm}, \hyperlink{simplehsm_8h_cbcc44b14ee70c1d2ed54b95afcd5e62}{stfunc} parent\_\-state, \hyperlink{simplehsm_8h_cbcc44b14ee70c1d2ed54b95afcd5e62}{stfunc} child\_\-state)
\item 
void \hyperlink{simplehsm_8c_6ac1c80fcdb3a59dce721b607e32dada}{simplehsm\_\-transition\_\-state\_\-ex} (\hyperlink{structsimplehsm__t}{simplehsm\_\-t} $\ast$\hyperlink{oven_8c_b0f5f1813e601676237fefa2690bf4a5}{hsm}, \hyperlink{simplehsm_8h_cbcc44b14ee70c1d2ed54b95afcd5e62}{stfunc} new\_\-state, BOOL to\_\-deep\_\-hist)
\item 
void \hyperlink{simplehsm_8c_8f6b1a50131e7af8e84ce6813b4f4416}{simplehsm\_\-transition\_\-state} (\hyperlink{structsimplehsm__t}{simplehsm\_\-t} $\ast$\hyperlink{oven_8c_b0f5f1813e601676237fefa2690bf4a5}{hsm}, \hyperlink{simplehsm_8h_cbcc44b14ee70c1d2ed54b95afcd5e62}{stfunc} new\_\-state)
\item 
void \hyperlink{simplehsm_8c_b9c54e2a8f46c47d522c33f84707785f}{simplehsm\_\-init\_\-transition\_\-state} (\hyperlink{structsimplehsm__t}{simplehsm\_\-t} $\ast$\hyperlink{oven_8c_b0f5f1813e601676237fefa2690bf4a5}{hsm}, \hyperlink{simplehsm_8h_cbcc44b14ee70c1d2ed54b95afcd5e62}{stfunc} new\_\-state)
\item 
void \hyperlink{simplehsm_8c_407ab0f0bd0669839eac2736d61ca89d}{simplehsm\_\-signal\_\-current\_\-state} (\hyperlink{structsimplehsm__t}{simplehsm\_\-t} $\ast$\hyperlink{oven_8c_b0f5f1813e601676237fefa2690bf4a5}{hsm}, int signal, void $\ast$param)
\item 
BOOL \hyperlink{simplehsm_8c_203f7e57dd3cbbb47ca40e153df26a1b}{simplehsm\_\-is\_\-in\_\-state} (\hyperlink{structsimplehsm__t}{simplehsm\_\-t} $\ast$\hyperlink{oven_8c_b0f5f1813e601676237fefa2690bf4a5}{hsm}, \hyperlink{simplehsm_8h_cbcc44b14ee70c1d2ed54b95afcd5e62}{stfunc} state)
\item 
void \hyperlink{simplehsm_8c_909ebd632f31475debde70641ee5d4f3}{simplehsm\_\-record\_\-deephist} (\hyperlink{structsimplehsm__t}{simplehsm\_\-t} $\ast$\hyperlink{oven_8c_b0f5f1813e601676237fefa2690bf4a5}{hsm}, \hyperlink{simplehsm_8h_cbcc44b14ee70c1d2ed54b95afcd5e62}{stfunc} history\_\-parent, \hyperlink{simplehsm_8h_cbcc44b14ee70c1d2ed54b95afcd5e62}{stfunc} history\_\-state)
\item 
\hyperlink{simplehsm_8h_cbcc44b14ee70c1d2ed54b95afcd5e62}{stfunc} \hyperlink{simplehsm_8c_d6258e9de296788479e0071b43a02ef7}{simplehsm\_\-retrieve\_\-deephist} (\hyperlink{structsimplehsm__t}{simplehsm\_\-t} $\ast$\hyperlink{oven_8c_b0f5f1813e601676237fefa2690bf4a5}{hsm}, \hyperlink{simplehsm_8h_cbcc44b14ee70c1d2ed54b95afcd5e62}{stfunc} history\_\-parent)
\end{CompactItemize}


\label{_details}
\hypertarget{_details}{}
\subsection{Detailed Description}
\begin{Desc}
\item[Author:]Daniel Newton $<$\href{mailto:djpnewton@gmail.com}{\tt djpnewton@gmail.com}$>$ \end{Desc}
\begin{Desc}
\item[Version:]1.0\end{Desc}
\hypertarget{simplehsm_8h_LICENSE}{}\subsection{LICENSE}\label{simplehsm_8h_LICENSE}
Copyright (c) 2009 Daniel Newton

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \char`\"{}Software\char`\"{}), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED \char`\"{}AS IS\char`\"{}, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\hypertarget{simplehsm_8h_DESCRIPTION}{}\subsection{DESCRIPTION}\label{simplehsm_8h_DESCRIPTION}
The simplehsm C implementation 

\subsection{Function Documentation}
\hypertarget{simplehsm_8c_ec6a0d82fdc3b8b36cb558f8b1dbdb52}{
\index{simplehsm.c@{simplehsm.c}!\_\-is\_\-parent@{\_\-is\_\-parent}}
\index{\_\-is\_\-parent@{\_\-is\_\-parent}!simplehsm.c@{simplehsm.c}}
\subsubsection[{\_\-is\_\-parent}]{\setlength{\rightskip}{0pt plus 5cm}BOOL \_\-is\_\-parent ({\bf simplehsm\_\-t} $\ast$ {\em hsm}, \/  {\bf stfunc} {\em parent\_\-state}, \/  {\bf stfunc} {\em child\_\-state})}}
\label{simplehsm_8c_ec6a0d82fdc3b8b36cb558f8b1dbdb52}


Check is one state is the parent of another.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hsm}]The state machine to check \item[{\em parent\_\-state}]The parent state to check \item[{\em child\_\-state}]The child state to check \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]True if the parent\_\-state parameter is a parent to the child\_\-state parameter \end{Desc}
\hypertarget{simplehsm_8c_b9c54e2a8f46c47d522c33f84707785f}{
\index{simplehsm.c@{simplehsm.c}!simplehsm\_\-init\_\-transition\_\-state@{simplehsm\_\-init\_\-transition\_\-state}}
\index{simplehsm\_\-init\_\-transition\_\-state@{simplehsm\_\-init\_\-transition\_\-state}!simplehsm.c@{simplehsm.c}}
\subsubsection[{simplehsm\_\-init\_\-transition\_\-state}]{\setlength{\rightskip}{0pt plus 5cm}void simplehsm\_\-init\_\-transition\_\-state ({\bf simplehsm\_\-t} $\ast$ {\em hsm}, \/  {\bf stfunc} {\em new\_\-state})}}
\label{simplehsm_8c_b9c54e2a8f46c47d522c33f84707785f}


Initiate an initial transition to a new state (this function should only be used from a \hyperlink{simplehsm_8h_8855e78111bd42430381e45a77b08b21e06d9cbab66716ec34598717c5d973a4}{SIG\_\-INIT} state event).

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hsm}]The state machine to transition \item[{\em new\_\-state}]The state to transition to \end{description}
\end{Desc}
\hypertarget{simplehsm_8c_637aef0e0ae28c979dfca2a40b3db6c3}{
\index{simplehsm.c@{simplehsm.c}!simplehsm\_\-initialize@{simplehsm\_\-initialize}}
\index{simplehsm\_\-initialize@{simplehsm\_\-initialize}!simplehsm.c@{simplehsm.c}}
\subsubsection[{simplehsm\_\-initialize}]{\setlength{\rightskip}{0pt plus 5cm}void simplehsm\_\-initialize ({\bf simplehsm\_\-t} $\ast$ {\em hsm}, \/  {\bf stfunc} {\em top\_\-state})}}
\label{simplehsm_8c_637aef0e0ae28c979dfca2a40b3db6c3}


Initialise a simplehsm state machine.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hsm}]The state machine to initialise \item[{\em top\_\-state}]The topmost (and initial) state of the hierarchy \end{description}
\end{Desc}
\hypertarget{simplehsm_8c_203f7e57dd3cbbb47ca40e153df26a1b}{
\index{simplehsm.c@{simplehsm.c}!simplehsm\_\-is\_\-in\_\-state@{simplehsm\_\-is\_\-in\_\-state}}
\index{simplehsm\_\-is\_\-in\_\-state@{simplehsm\_\-is\_\-in\_\-state}!simplehsm.c@{simplehsm.c}}
\subsubsection[{simplehsm\_\-is\_\-in\_\-state}]{\setlength{\rightskip}{0pt plus 5cm}BOOL simplehsm\_\-is\_\-in\_\-state ({\bf simplehsm\_\-t} $\ast$ {\em hsm}, \/  {\bf stfunc} {\em state})}}
\label{simplehsm_8c_203f7e57dd3cbbb47ca40e153df26a1b}


Check if a state machine is currently in a certain state.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hsm}]The state machine to check \item[{\em state}]The state to check \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]True if the state machine is currently in the specified state \end{Desc}
\hypertarget{simplehsm_8c_909ebd632f31475debde70641ee5d4f3}{
\index{simplehsm.c@{simplehsm.c}!simplehsm\_\-record\_\-deephist@{simplehsm\_\-record\_\-deephist}}
\index{simplehsm\_\-record\_\-deephist@{simplehsm\_\-record\_\-deephist}!simplehsm.c@{simplehsm.c}}
\subsubsection[{simplehsm\_\-record\_\-deephist}]{\setlength{\rightskip}{0pt plus 5cm}void simplehsm\_\-record\_\-deephist ({\bf simplehsm\_\-t} $\ast$ {\em hsm}, \/  {\bf stfunc} {\em history\_\-parent}, \/  {\bf stfunc} {\em history\_\-state})}}
\label{simplehsm_8c_909ebd632f31475debde70641ee5d4f3}


Record deep history psuedostate.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hsm}]The state machine \item[{\em history\_\-parent}]The parent state of the deep history psuedostate \item[{\em history\_\-state}]The state to return to if transitioning to the deep history psuedostate \end{description}
\end{Desc}
\hypertarget{simplehsm_8c_d6258e9de296788479e0071b43a02ef7}{
\index{simplehsm.c@{simplehsm.c}!simplehsm\_\-retrieve\_\-deephist@{simplehsm\_\-retrieve\_\-deephist}}
\index{simplehsm\_\-retrieve\_\-deephist@{simplehsm\_\-retrieve\_\-deephist}!simplehsm.c@{simplehsm.c}}
\subsubsection[{simplehsm\_\-retrieve\_\-deephist}]{\setlength{\rightskip}{0pt plus 5cm}{\bf stfunc} simplehsm\_\-retrieve\_\-deephist ({\bf simplehsm\_\-t} $\ast$ {\em hsm}, \/  {\bf stfunc} {\em history\_\-parent})}}
\label{simplehsm_8c_d6258e9de296788479e0071b43a02ef7}


Retrive deep history psuedostate.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hsm}]The state machine \item[{\em history\_\-parent}]The parent state of the deep history psuedostate \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The state to transition to via the deep history psuedostate \end{Desc}
\hypertarget{simplehsm_8c_407ab0f0bd0669839eac2736d61ca89d}{
\index{simplehsm.c@{simplehsm.c}!simplehsm\_\-signal\_\-current\_\-state@{simplehsm\_\-signal\_\-current\_\-state}}
\index{simplehsm\_\-signal\_\-current\_\-state@{simplehsm\_\-signal\_\-current\_\-state}!simplehsm.c@{simplehsm.c}}
\subsubsection[{simplehsm\_\-signal\_\-current\_\-state}]{\setlength{\rightskip}{0pt plus 5cm}void simplehsm\_\-signal\_\-current\_\-state ({\bf simplehsm\_\-t} $\ast$ {\em hsm}, \/  int {\em signal}, \/  void $\ast$ {\em param})}}
\label{simplehsm_8c_407ab0f0bd0669839eac2736d61ca89d}


Send a signal to the state machine.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hsm}]The state machine to signal \item[{\em signal}]The signal flag \item[{\em param}]An optional parameter to accompany the signal \end{description}
\end{Desc}
\hypertarget{simplehsm_8c_8f6b1a50131e7af8e84ce6813b4f4416}{
\index{simplehsm.c@{simplehsm.c}!simplehsm\_\-transition\_\-state@{simplehsm\_\-transition\_\-state}}
\index{simplehsm\_\-transition\_\-state@{simplehsm\_\-transition\_\-state}!simplehsm.c@{simplehsm.c}}
\subsubsection[{simplehsm\_\-transition\_\-state}]{\setlength{\rightskip}{0pt plus 5cm}void simplehsm\_\-transition\_\-state ({\bf simplehsm\_\-t} $\ast$ {\em hsm}, \/  {\bf stfunc} {\em new\_\-state})}}
\label{simplehsm_8c_8f6b1a50131e7af8e84ce6813b4f4416}


Initiate a transition to a new state.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hsm}]The state machine to transition \item[{\em new\_\-state}]The state to transition to \end{description}
\end{Desc}
\hypertarget{simplehsm_8c_6ac1c80fcdb3a59dce721b607e32dada}{
\index{simplehsm.c@{simplehsm.c}!simplehsm\_\-transition\_\-state\_\-ex@{simplehsm\_\-transition\_\-state\_\-ex}}
\index{simplehsm\_\-transition\_\-state\_\-ex@{simplehsm\_\-transition\_\-state\_\-ex}!simplehsm.c@{simplehsm.c}}
\subsubsection[{simplehsm\_\-transition\_\-state\_\-ex}]{\setlength{\rightskip}{0pt plus 5cm}void simplehsm\_\-transition\_\-state\_\-ex ({\bf simplehsm\_\-t} $\ast$ {\em hsm}, \/  {\bf stfunc} {\em new\_\-state}, \/  BOOL {\em to\_\-deep\_\-hist})}}
\label{simplehsm_8c_6ac1c80fcdb3a59dce721b607e32dada}


Initiate a transition to a new state.

This function will:\begin{itemize}
\item replace the target state with the deep history target if required\item store a deep history target state if exiting a composite state with a deep history child\item perform the exit/entry chain from the current state to the target state\end{itemize}


\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hsm}]The state machine to transition \item[{\em new\_\-state}]The state to transition to \item[{\em to\_\-deep\_\-hist}]Whether to transition to the states internal deep history psuedostate \end{description}
\end{Desc}
