Home | History | Annotate | Download | only in MacServices
      1 /*
      2  * MeasurementSrvSM.h
      3  *
      4  * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  *
     11  *  * Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  *  * Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in
     15  *    the documentation and/or other materials provided with the
     16  *    distribution.
     17  *  * Neither the name Texas Instruments nor the names of its
     18  *    contributors may be used to endorse or promote products derived
     19  *    from this software without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 /** \file MeasurementSrv.h
     35  *  \brief This file include private definitions for the Measurement SRV state machine.
     36  *  \author Ronen Kalish
     37  *  \date 08-November-2005
     38  */
     39 
     40 #ifndef __MEASUREMENT_SRV_SM_H__
     41 #define __MEASUREMENT_SRV_SM_H__
     42 
     43 
     44 /*
     45  ***********************************************************************
     46  *	Constant definitions.
     47  ***********************************************************************
     48  */
     49 
     50 
     51 /*
     52  ***********************************************************************
     53  *	Enums.
     54  ***********************************************************************
     55  */
     56 
     57 /** \enum measurement_SRVSMEvents_e
     58  * \brief enumerates the different measurement SRV state machine events.
     59  */
     60 typedef enum
     61 {
     62     MSR_SRV_EVENT_MEASURE_START_REQUEST       = 0,
     63     MSR_SRV_EVENT_DRIVER_MODE_SUCCESS,
     64     MSR_SRV_EVENT_DRIVER_MODE_FAILURE,
     65     MSR_SRV_EVENT_START_SUCCESS,
     66     MSR_SRV_EVENT_START_FAILURE,
     67     MSR_SRV_EVENT_ALL_TYPES_COMPLETE,
     68     MSR_SRV_EVENT_STOP_COMPLETE,
     69     MSR_SRV_EVENT_MEASURE_STOP_REQUEST,
     70     MSR_SRV_NUM_OF_EVENTS
     71 } measurement_SRVSMEvents_e;
     72 
     73 /** \enum measurement_SRVSMStates_e
     74  * \brief enumerates the different measurement SRV state machine states.
     75  */
     76 typedef enum
     77 {
     78     MSR_SRV_STATE_IDLE                      =0,
     79     MSR_SRV_STATE_WAIT_FOR_DRIVER_MODE,
     80     MSR_SRV_STATE_WAIT_FOR_MEASURE_START,
     81     MSR_SRV_STATE_MEASURE_IN_PROGRESS,
     82     MSR_SRV_STATE_WAIT_FOR_MEASURE_STOP,
     83     MSR_SRV_NUM_OF_STATES
     84 } measurements_SRVSMStates_e;
     85 
     86 
     87 /*
     88  ***********************************************************************
     89  *	Typedefs.
     90  ***********************************************************************
     91  */
     92 
     93 
     94 /*
     95  ***********************************************************************
     96  *	Structure definitions.
     97  ***********************************************************************
     98 */
     99 
    100 /*
    101  ***********************************************************************
    102  *	External data definitions.
    103  ***********************************************************************
    104  */
    105 
    106 /*
    107  ***********************************************************************
    108  *	External functions definitions
    109  ***********************************************************************
    110  */
    111 
    112 /**
    113  * \author Ronen Kalish\n
    114  * \date 08-November-2005\n
    115  * \brief Initialize the measurement SRV SM.\n
    116  *
    117  * Function Scope \e Public.\n
    118  * \param hMeasurementSrv - handle to the Measurement SRV object.\n
    119  * \return TI_OK if successful, TI_NOK otherwise.\n
    120  */
    121 TI_STATUS measurementSRVSM_init( TI_HANDLE hMeasurementSRV );
    122 
    123 /**
    124  * \author Ronen Kalish\n
    125  * \date 08-November-2005\n
    126  * \brief Processes an event.\n
    127  *
    128  * Function Scope \e Public.\n
    129  * \param hMeasurementSrv - handle to the measurement SRV object.\n
    130  * \param currentState - the current scan SRV SM state.\n
    131  * \param event - the event to handle.\n
    132  * \return TI_OK if successful, TI_NOK otherwise.\n
    133  */
    134 TI_STATUS measurementSRVSM_SMEvent( TI_HANDLE hMeasurementSrv, measurements_SRVSMStates_e* currentState,
    135                                     measurement_SRVSMEvents_e event );
    136 
    137 /**
    138  * \author Ronen Kalish\n
    139  * \date 08-November-2005\n
    140  * \brief Handle a MEASURE_START_REQUEST event by requesting driver mode.\n
    141  *
    142  * Function Scope \e Public.\n
    143  * \param hMeasurementSrv - handle to the Measurement SRV object.\n
    144  * \return always TI_OK.\n
    145  */
    146 TI_STATUS measurementSRVSM_requestDriverMode( TI_HANDLE hMeasurementSRV );
    147 
    148 /**
    149  * \author Ronen Kalish\n
    150  * \date 08-November-2005\n
    151  * \brief Handle a DRIVER_MODE_SUCCESS event by sending start measure command to the FW.\n
    152  *
    153  * Function Scope \e Public.\n
    154  * \param hMeasurementSrv - handle to the Measurement SRV object.\n
    155  * \return always TI_OK.\n
    156  */
    157 TI_STATUS measurementSRVSM_requestMeasureStart( TI_HANDLE hMeasurementSRV );
    158 
    159 /**
    160  * \author Ronen Kalish\n
    161  * \date 08-November-2005\n
    162  * \brief Handle a START_SUCCESS event by starting different measure types and setting timers.\n
    163  *
    164  * Function Scope \e Public.\n
    165  * \param hMeasurementSrv - handle to the Measurement SRV object.\n
    166  * \return always TI_OK.\n
    167  */
    168 TI_STATUS measurementSRVSM_startMeasureTypes( TI_HANDLE hMeasurementSRV );
    169 
    170 /**
    171  * \author Ronen Kalish\n
    172  * \date 08-November-2005\n
    173  * \brief Handle an ALL_TYPE_COMPLETE event by sending a stop measure command to the FW.\n
    174  *
    175  * Function Scope \e Public.\n
    176  * \param hMeasurementSrv - handle to the Measurement SRV object.\n
    177  * \return always TI_OK.\n
    178  */
    179 TI_STATUS measurementSRVSM_requestMeasureStop( TI_HANDLE hMeasurementSRV );
    180 
    181 /**
    182  * \author Ronen Kalish\n
    183  * \date 08-November-2005\n
    184  * \brief Handle a STOP_COMPLETE event by exiting driver mode and calling the complete CB.\n
    185  *
    186  * Function Scope \e Public.\n
    187  * \param hMeasurementSrv - handle to the Measurement SRV object.\n
    188  * \return always TI_OK.\n
    189  */
    190 TI_STATUS measurementSRVSM_completeMeasure( TI_HANDLE hMeasurementSRV );
    191 
    192 /**
    193  * \author Ronen Kalish\n
    194  * \date 08-November-2005\n
    195  * \brief Handle a STOP_REQUEST event when in WAIT_FOR_DRIVER_MODE state by exiting driver mode.
    196  *
    197  * Function Scope \e Public.\n
    198  * \param hMeasurementSrv - handle to the Measurement SRV object.\n
    199  * \return always TI_OK.\n
    200  */
    201 TI_STATUS measurementSRVSM_stopFromWaitForDriverMode( TI_HANDLE hMeasurementSRV );
    202 
    203 /**
    204  * \author Ronen Kalish\n
    205  * \date 27-November-2005\n
    206  * \brief handle a STOP_REQUEST event when in WAIT_FOR_DRIVER_MODE by marking negative result status
    207  * \brief and callin the ordinary stop function
    208  *
    209  * Function Scope \e Public.\n
    210  * \param hMeasurementSrv - handle to the Measurement SRV object.\n
    211  * \return always TI_OK.\n
    212  */
    213 TI_STATUS measurementSRVSM_stopFromWaitForMeasureStart( TI_HANDLE hMeasurementSRV );
    214 
    215 /**
    216  * \author Ronen Kalish\n
    217  * \date 08-November-2005\n
    218  * \brief handle a STOP_REQUEST event when in MEASURE_IN_PROGRESS by stopping all measure types and
    219  * \brief requesting measure stop from the FW.\n
    220  *
    221  * Function Scope \e Public.\n
    222  * \param hMeasurementSrv - handle to the Measurement SRV object.\n
    223  * \return always TI_OK.\n
    224  */
    225 TI_STATUS measurementSRVSM_stopFromMeasureInProgress( TI_HANDLE hMeasurementSRV );
    226 
    227 /**
    228  * \author Ronen Kalish\n
    229  * \date 08-November-2005\n
    230  * \brief handle a DRIVER_MODE_FAILURE event by calling the response CB.\n
    231  *
    232  * Function Scope \e Public.\n
    233  * \param hMeasurementSrv - handle to the Measurement SRV object.\n
    234  * \return always TI_OK.\n
    235  */
    236 TI_STATUS measurementSRVSM_DriverModeFailure( TI_HANDLE hMeasurementSRV );
    237 
    238 /**
    239  * \author Ronen Kalish\n
    240  * \date 08-November-2005\n
    241  * \brief handle a START_FAILURE event by exiting driver mode and calling the complete CB.\n
    242  *
    243  * Function Scope \e Public.\n
    244  * \param hMeasurementSrv - handle to the Measurement SRV object.\n
    245  * \return always TI_OK.\n
    246  */
    247 TI_STATUS measurementSRVSM_measureStartFailure( TI_HANDLE hMeasurementSRV );
    248 
    249 /**
    250  * \author Ronen Kalish\n
    251  * \date 23-December-2005\n
    252  * \brief Handles a stop request when no stop is needed (SM is either idle or already send stop command to FW.\n
    253  *
    254  * Function Scope \e Private.\n
    255  * \param hMeasurementSrv - handle to the measurement SRV object.\n
    256  * \return always TI_OK.\n
    257  */
    258 TI_STATUS measurementSRVSRVSM_dummyStop( TI_HANDLE hmeasurementSrv );
    259 
    260 #endif /* __MEASUREMENT_SRV_SM_H__ */
    261 
    262