GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LIM / dev > lim_unit_test / sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

lim_util_sim.c File Reference

Simulate LCI, LDF, LPA, and LTC tasks. More...

#include <string.h>
#include <CCSDS/CCSDS_pkt.h>
#include <ITC/ITC_pubdefs.h>
#include <LIM/LIM_msgs.h>
#include <MSG/MSG_pubdefs.h>
#include <PBS/SEM.h>
#include <PBS/WUT.h>
#include <LIM/../src/LIM_pool.h>
#include <LIM/../src/LIM_task.h>
#include <lim_unit_test.h>
#include <lim_util_sim.h>

Classes

struct  _SIM_Control
 Control information for simulated tasks. More...

Typedefs

typedef struct _SIM_Control SIM_Control
 Typedef for _SIM_Control.

Functions

static WUT_cb_status sim_wut_handler (void *prm, WUT_tmr *wut)
 Handle wake-up timer expiration.
static unsigned int sim_handle_abort (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Abort commands.
static unsigned int sim_handle_active (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Active commands.
static unsigned int sim_handle_calc_info (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Calc-Info commands.
static unsigned int sim_handle_closeout (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Closeout commands.
static unsigned int sim_handle_complete (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Complete commands.
static unsigned int sim_handle_idle (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Idle commands.
static unsigned int sim_handle_other (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Other commands.
static unsigned int sim_handle_reconfig (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Reconfig commands.
static unsigned int sim_handle_repoint (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Repoint commands.
static unsigned int sim_start_timer (SIM_Control *sim_p, const ITC_QueueItem *qitem_p, unsigned int delay_usecs)
 Start a timer that will send a Complete message.
static unsigned int sim_handle_start (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Start commands.
static unsigned int sim_handle_restart (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Restart commands.
static unsigned int sim_handle_stop (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle Stop commands.
static unsigned int sim_handle_bulk (void *prm, const ITC_QueueItem *qitem_p, void *pay_p, unsigned int len)
 Handle BULK queue messages.
static int sim_init_task (test_Test_Descriptor *td_p, int id, LIM_Task **task_pp, char *name, ITC_TaskID tid, ITC_ApidDef *apid_def_1_p, ITC_ApidDef *apid_def_2_p, ITC_ApidDef *apid_def_3_p, ITC_cb_Processor *bulk_cb_p)
 Initialize a single simulated task.
int SIM_init_tasks (test_Test_Descriptor *td_p)
 Initialize the simulated tasks.
int SIM_start_tasks (test_Test_Descriptor *td_p)
 Start the simulated tasks.
static int sim_stop_task (test_Test_Descriptor *td_p, int id, LIM_Task *task_p)
 Stop a single simulated task.
int SIM_stop_tasks (test_Test_Descriptor *td_p)
 Stop the simulated tasks.
static int sim_shutdown_task (test_Test_Descriptor *td_p, int id, LIM_Task *task_p)
 Shutdown a single simulated task.
int SIM_shutdown_tasks (test_Test_Descriptor *td_p)
 Shutdown the simulated tasks.
void SIM_clear_stats (test_Test_Descriptor *td_p)
 Clear simulated task statistics.
int SIM_check_stats (test_Test_Descriptor *td_p, test_Cmd_Counts *exp_lci_p, test_Cmd_Counts *exp_ldf_p, test_Cmd_Counts *exp_lpa_p, test_Cmd_Counts *exp_ltc_p)
 Verify expected simulated task statistics.
int SIM_check_parms (test_Test_Descriptor *td_p, test_Start_Parms *exp_lpa_p)
 Verify expected simulated task start parameters.

Variables

static ITC_CommandItem sim_Item_GBM []
 GBM Dispatch table.
static ITC_CommandItem sim_Item_LCI []
 LCI Dispatch table.
static ITC_CommandItem sim_Item_LDF []
 LDF Dispatch table.
static ITC_CommandItem sim_Item_LPA []
 LPA Dispatch table.
static ITC_CommandItem sim_Item_LPA_IDLE []
 LPA_IDLE Dispatch table.
static ITC_CommandItem sim_Item_LTC []
 LTC Dispatch table.
static ITC_CommandList sim_List_GBM = { DIM (sim_Item_GBM), 0, sim_Item_GBM }
 GBM Dispatch control block.
static ITC_CommandList sim_List_LCI = { DIM (sim_Item_LCI), 0, sim_Item_LCI }
 LCI Dispatch control block.
static ITC_CommandList sim_List_LDF = { DIM (sim_Item_LDF), 0, sim_Item_LDF }
 LDF Dispatch control block.
static ITC_CommandList sim_List_LPA = { DIM (sim_Item_LPA), 0, sim_Item_LPA }
 LPA Dispatch control block.
static ITC_CommandList sim_List_LTC = { DIM (sim_Item_LTC), 0, sim_Item_LTC }
 LTC Dispatch control block.
static ITC_CommandList sim_List_LPA_IDLE
 LPA_IDLE Dispatch control block.
static ITC_ApidDef sim_Def_GBM = { SIM_APID_GBM, 0, &sim_List_GBM }
 GBM APID control block.
static ITC_ApidDef sim_Def_LCI = { SIM_APID_LCI, 0, &sim_List_LCI }
 LCI APID control block.
static ITC_ApidDef sim_Def_LDF = { SIM_APID_LDF, 0, &sim_List_LDF }
 LDF APID control block.
static ITC_ApidDef sim_Def_LPA = { SIM_APID_LPA, 0, &sim_List_LPA }
 LPA APID control block.
static ITC_ApidDef sim_Def_LTC = { SIM_APID_LTC, 0, &sim_List_LTC }
 LTC APID control block.
static ITC_ApidDef sim_Def_LPA_IDLE
 LPA APID control block.


Detailed Description

Simulate LCI, LDF, LPA, and LTC tasks.

**  CVS $Id: lim_util_sim.c,v 1.29 2011/03/30 22:23:43 apw Exp $
**  

Function Documentation

int SIM_check_parms ( test_Test_Descriptor td_p,
test_Start_Parms exp_lpa_p 
)

Verify expected simulated task start parameters.

Parameters:
td_p Pointer to test descriptor.
exp_lpa_p Pointer to expected LPA task start parameters.
Return values:
0 Success.
-1 Failure.

References LIM_task_get_extra_ptr(), _test_Test_Descriptor::lpa_ctl_p, test_Delay(), test_Parm_Compare(), test_Pop_State(), and test_Push_State().

Referenced by CMD_rcv_cmd(), and WRAP_send_cmd().

int SIM_check_stats ( test_Test_Descriptor td_p,
test_Cmd_Counts exp_lci_p,
test_Cmd_Counts exp_ldf_p,
test_Cmd_Counts exp_lpa_p,
test_Cmd_Counts exp_ltc_p 
)

Verify expected simulated task statistics.

Parameters:
td_p Pointer to test descriptor.
exp_lci_p Pointer to expected LCI task counts.
exp_ldf_p Pointer to expected LDF task counts.
exp_lpa_p Pointer to expected LPA task counts.
exp_ltc_p Pointer to expected LTC task counts.
Return values:
0 Success.
-1 Failure.

References _test_Test_Descriptor::lci_ctl_p, _test_Test_Descriptor::ldf_ctl_p, LIM_task_get_extra_ptr(), _test_Test_Descriptor::lpa_ctl_p, _test_Test_Descriptor::ltc_ctl_p, test_Count_Compare(), test_Delay(), test_Pop_State(), and test_Push_State().

Referenced by CMD_rcv_cmd(), and WRAP_send_cmd().

void SIM_clear_stats ( test_Test_Descriptor td_p  ) 

unsigned int sim_handle_abort ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Abort commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _test_Cmd_Counts::abort, _SIM_Control::adjust_usecs, _SIM_Control::cmd_counts, _SIM_Control::desc, LIM_task_get_extra_ptr(), and _SIM_Control::qitem_p.

unsigned int sim_handle_active ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Active commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _test_Cmd_Counts::active, _SIM_Control::cmd_counts, _SIM_Control::desc, LIM_task_get_extra_ptr(), and _SIM_Control::qitem_p.

unsigned int sim_handle_bulk ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle BULK queue messages.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References sim_handle_complete(), sim_handle_reconfig(), and sim_handle_restart().

Referenced by SIM_init_tasks().

unsigned int sim_handle_calc_info ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Calc-Info commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _test_Cmd_Counts::calc_info, _SIM_Control::cmd_counts, _SIM_Control::desc, and LIM_task_get_extra_ptr().

unsigned int sim_handle_closeout ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Closeout commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _test_Cmd_Counts::closeout, _SIM_Control::cmd_counts, _SIM_Control::desc, and LIM_task_get_extra_ptr().

unsigned int sim_handle_complete ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Complete commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _SIM_Control::cmd_counts, _test_Cmd_Counts::complete, _SIM_Control::desc, and LIM_task_get_extra_ptr().

Referenced by sim_handle_bulk().

unsigned int sim_handle_idle ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Idle commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _SIM_Control::cmd_counts, _SIM_Control::desc, _test_Cmd_Counts::idle, and LIM_task_get_extra_ptr().

unsigned int sim_handle_other ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Other commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _SIM_Control::cmd_counts, _SIM_Control::desc, LIM_task_get_extra_ptr(), _test_Cmd_Counts::other, and _SIM_Control::qitem_p.

unsigned int sim_handle_reconfig ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Reconfig commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _SIM_Control::adjust_usecs, _SIM_Control::cmd_counts, _SIM_Control::desc, LIM_task_get_extra_ptr(), _test_Start_Parms::mode, _SIM_Control::qitem_p, _test_Cmd_Counts::reconfig, and _SIM_Control::start_parms.

Referenced by sim_handle_bulk().

unsigned int sim_handle_repoint ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Repoint commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _SIM_Control::cmd_counts, _SIM_Control::desc, LIM_task_get_extra_ptr(), and _test_Cmd_Counts::repoint.

unsigned int sim_handle_restart ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Restart commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _SIM_Control::cmd_counts, _SIM_Control::desc, LIM_task_get_extra_ptr(), _SIM_Control::qitem_p, _test_Cmd_Counts::restart, and sim_start_timer().

Referenced by sim_handle_bulk().

unsigned int sim_handle_start ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Start commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _SIM_Control::cmd_counts, _SIM_Control::desc, LIM_task_get_extra_ptr(), _SIM_Control::qitem_p, sim_start_timer(), _test_Cmd_Counts::start, _SIM_Control::start_parms, _SIM_Control::stop_fail, and test_Sleep_Sec().

unsigned int sim_handle_stop ( void *  prm,
const ITC_QueueItem *  qitem_p,
void *  pay_p,
unsigned int  len 
) [static]

Handle Stop commands.

Parameters:
prm Context parameter (pointer to task control info).
qitem_p Pointer to queue item.
pay_p Pointer to queue item payload.
len Length of queue item payload, in bytes.
Returns:
MSG code.

References _SIM_Control::adjust_usecs, _SIM_Control::cmd_counts, _SIM_Control::desc, LIM_task_get_extra_ptr(), _SIM_Control::qitem_p, _test_Cmd_Counts::stop, and _SIM_Control::stop_fail.

int sim_init_task ( test_Test_Descriptor td_p,
int  id,
LIM_Task **  task_pp,
char *  name,
ITC_TaskID  tid,
ITC_ApidDef *  apid_def_1_p,
ITC_ApidDef *  apid_def_2_p,
ITC_ApidDef *  apid_def_3_p,
ITC_cb_Processor *  bulk_cb_p 
) [static]

Initialize a single simulated task.

Parameters:
td_p Pointer to test descriptor.
id ID to use for user messages.
task_pp Location to store pointer to task control info.
name Name of the task.
tid ID of the task.
apid_def_1_p Pointer to first set of cmd handler definitions.
apid_def_2_p Pointer to second set of cmd handler definitions.
apid_def_3_p Pointer to third set of cmd handler definitions.
bulk_cb_p Callback function for BULK queue messages.
Return values:
0 Success.
-1 Failure.

References _SIM_Control::active_usecs, _SIM_Control::adjust_usecs, _SIM_Control::desc, LIM_pool_alloc(), LIM_task_add_apid(), LIM_task_add_queue(), LIM_task_add_raw(), LIM_task_get_extra_ptr(), LIM_task_init_begin(), LIM_task_init_end(), _SIM_Control::poll_usecs, _SIM_Control::pool_p, _SIM_Control::qitem_p, _test_Test_Descriptor::sim_pool_p, test_NULL_Compare(), test_Pop_State(), test_Push_State(), test_Status_Success(), and _SIM_Control::wut.

Referenced by SIM_init_tasks().

int SIM_init_tasks ( test_Test_Descriptor td_p  ) 

int sim_shutdown_task ( test_Test_Descriptor td_p,
int  id,
LIM_Task task_p 
) [static]

Shutdown a single simulated task.

Parameters:
td_p Pointer to test descriptor.
id ID to use for user messages.
task_p Pointer to control information for the task.
Return values:
0 Success.
-1 Failure.

References _SIM_Control::cmd_counts, LIM_pool_alloc(), LIM_task_get_extra_ptr(), LIM_task_remove_queue(), LIM_task_shutdown_begin(), LIM_task_shutdown_end(), _SIM_Control::start_parms, test_Generic_Error(), test_Pop_State(), test_Push_State(), test_Status_Success(), and _SIM_Control::wut.

Referenced by SIM_shutdown_tasks().

int SIM_shutdown_tasks ( test_Test_Descriptor td_p  ) 

int SIM_start_tasks ( test_Test_Descriptor td_p  ) 

Start the simulated tasks.

Parameters:
td_p Pointer to test descriptor.
Return values:
0 Success.
-1 Failure.

References _test_Test_Descriptor::lci_ctl_p, _test_Test_Descriptor::ldf_ctl_p, LIM_task_start(), _test_Test_Descriptor::lpa_ctl_p, _test_Test_Descriptor::ltc_ctl_p, test_Pop_State(), test_Push_State(), and test_Status_Success().

Referenced by lim_test_command(), lim_test_init(), and lim_test_mode().

unsigned int sim_start_timer ( SIM_Control sim_p,
const ITC_QueueItem *  qitem_p,
unsigned int  delay_usecs 
) [static]

Start a timer that will send a Complete message.

Parameters:
sim_p Pointer to task control info.
qitem_p Pointer to queue item of the incoming command.
delay_usecs Completion delay, in microseconds.
Returns:
MSG code.

References _SIM_Control::active_usecs, _SIM_Control::adjust_usecs, _SIM_Control::desc, LIM_pool_alloc(), _SIM_Control::poll_usecs, _SIM_Control::pool_p, _SIM_Control::qitem_p, sim_wut_handler(), and _SIM_Control::wut.

Referenced by sim_handle_restart(), and sim_handle_start().

int sim_stop_task ( test_Test_Descriptor td_p,
int  id,
LIM_Task task_p 
) [static]

Stop a single simulated task.

Parameters:
td_p Pointer to test descriptor.
id ID to use for user messages.
task_p Pointer to control information for the task.
Return values:
0 Success.
-1 Failure.

References LIM_task_get_extra_ptr(), LIM_task_stop(), test_Pop_State(), test_Push_State(), and test_Status_Success().

Referenced by SIM_stop_tasks().

int SIM_stop_tasks ( test_Test_Descriptor td_p  ) 

Stop the simulated tasks.

Parameters:
td_p Pointer to test descriptor.
Return values:
0 Success.
-1 Failure.

References _test_Test_Descriptor::lci_ctl_p, _test_Test_Descriptor::ldf_ctl_p, _test_Test_Descriptor::lpa_ctl_p, _test_Test_Descriptor::ltc_ctl_p, sim_stop_task(), test_Delay(), test_Pop_State(), and test_Push_State().

Referenced by lim_test_command(), and lim_test_shutdown().

WUT_cb_status sim_wut_handler ( void *  prm,
WUT_tmr *  wut 
) [static]

Handle wake-up timer expiration.

Parameters:
prm Pointer to simulated task control info.
wut Pointer to wake-up timer.
Returns:
WUT status.

References _SIM_Control::active_usecs, _SIM_Control::adjust_usecs, _SIM_Control::poll_usecs, and _SIM_Control::qitem_p.

Referenced by sim_start_timer().


Variable Documentation

ITC_ApidDef sim_Def_LPA_IDLE [static]

Initial value:

 { SIM_APID_LPA_IDLE,
                                         0,
                                         &sim_List_LPA_IDLE }
LPA APID control block.

Referenced by SIM_init_tasks().

ITC_CommandItem sim_Item_GBM [static]

Initial value:

    {
        { SIM_FC_GBM_CALC_INFO, 10, &sim_handle_calc_info },
        { SIM_FC_GBM_CLOSEOUT,  10, &sim_handle_closeout  },
        { SIM_FC_GBM_REPOINT,   10, &sim_handle_repoint   },
    }
GBM Dispatch table.

ITC_CommandItem sim_Item_LCI [static]

Initial value:

    {
        { SIM_FC_CAL_START, 10, &sim_handle_start },
        { SIM_FC_CAL_ABORT, 10, &sim_handle_abort },
        { SIM_FC_CAL_OTHER, 10, &sim_handle_other },
    }
LCI Dispatch table.

ITC_CommandItem sim_Item_LDF [static]

Initial value:

    {
        { SIM_FC_DIAG_START, 10, &sim_handle_start },
        { SIM_FC_DIAG_ABORT, 10, &sim_handle_abort },
        { SIM_FC_DIAG_OTHER, 10, &sim_handle_other },
    }
LDF Dispatch table.

ITC_CommandItem sim_Item_LPA [static]

Initial value:

    {
        { SIM_FC_PHYS_START,   10, &sim_handle_start  },
        { SIM_FC_PHYS_STOP,    10, &sim_handle_stop   },
        { SIM_FC_PHYS_ACTIVE,  10, &sim_handle_active },
        { SIM_FC_PHYS_IDLE_1,  10, &sim_handle_idle   },
    }
LPA Dispatch table.

ITC_CommandItem sim_Item_LPA_IDLE [static]

Initial value:

    {
        { SIM_FC_PHYS_IDLE_2,  10, &sim_handle_idle   },
    }
LPA_IDLE Dispatch table.

ITC_CommandItem sim_Item_LTC [static]

Initial value:

    {
        { SIM_FC_LTC_STOP, 10, &sim_handle_stop },
    }
LTC Dispatch table.

ITC_CommandList sim_List_LPA_IDLE [static]

Initial value:

LPA_IDLE Dispatch control block.


Generated on Wed Mar 30 15:28:23 2011 by  doxygen 1.5.8