optional

static void 
FreeStringArray(
  array_t* array 
)
Frees an array of strings.

Side Effects none

See Also optional
Defined in simMain.c

Sim_Atom_t * 
SimAtomAlloc(
  Atm_Atom_t * atom 
)
It allocates a SimAtom and setting its fields.

Side Effects required

See Also SimAtomFree
Defined in sim.c

static char * 
SimAtomControlVariablesConvertToString(
  Sim_Atom_t * simAtom 
)
This routine returns a string of variables controlled by the atom represented by the simAtom. If the simAtom represents an external variable, then (a copy) of the variable name is returned.

Side Effects User should free the returned string after use.

See Also optional
Defined in simMain.c

static void 
SimAtomDecrementNumAwaitingAtoms(
  array_t * successorAtomList, 
  lsList  queue 
)
This function decrements the numAwaitingAtom field in the array of SimAtoms. If the field reaches zero, then the SimAtom will be added to the queue. If the simAtom is an agent, it will be added to the front of the queue. If it is not an agent, then it will be added to the end of the queue.

Side Effects required

See Also optional
Defined in simDependency.c

char * 
SimAtomDependencyInfoReadName(
  SimAtomDependencyInfo_t * simAtmInfo 
)
This returns the name of the module whose atom dependeny info is stored.

Side Effects It is an error to call this function with a NULL dependency info.

See Also optional
Defined in simDependency.c

void 
SimAtomDependencyInfoUpdate(
  Mdl_Module_t * module, 
  SimAtomDependencyInfo_t * simAtomDependencyInfo 
)
This function updates the current Atom Dependency Info to reflect the await dependency of atoms in the module. For each external variables, it creates an "external atom" that controls it.

Side Effects required

See Also optional
Defined in simDependency.c

Sim_Atom_t * 
SimAtomDup(
  Sim_Atom_t * simAtom 
)
It duplicates a simAtom. It doesn't duplicate all the fields because of lack of information. For example, the successorAtom field is not duplicated, because very likely the successorAtoms will also be duplicated.

Side Effects The atom should be freed.

See Also SimAtomFree
Defined in sim.c

void 
SimAtomFree(
  Sim_Atom_t * simAtom 
)
Frees an SimAtom.

Side Effects required

See Also SimAtomAlloc
Defined in sim.c

static int 
SimChoiceCmd(
  ClientData  clientData, 
  Tcl_Interp * interp, 
  int  argc, 
  char** argv 
)
Command for sim_choice

Side Effects required

Defined in simMain.c

void 
SimComputeChoice(
  Sim_Info_t * simInfo 
)
This computes the choice from the partialState and prevState in the simInfo. The choice is a list of (partial) Enum_States, and it is then stored in the Choice field of the simInfo.

Side Effects required

See Also optional
Defined in sim.c

void 
SimDependencyInfoSetIsUserAtom(
  SimAtomDependencyInfo_t * simAtomDependencyInfo, 
  array_t * atomArray, 
  boolean  isUserAtom 
)
This function clears all the isUsrAtom flag in the atom table of the supplied SimAtomDependencyInfo.

Side Effects required

See Also optional
Defined in simDependency.c

static int 
SimEndCmd(
  ClientData  clientData, 
  Tcl_Interp * interp, 
  int  argc, 
  char** argv 
)
Command for sim_end

Side Effects required

Defined in simMain.c

static int 
SimInfoCmd(
  ClientData  clientData, 
  Tcl_Interp * interp, 
  int  argc, 
  char** argv 
)
Implements the sim_info command

Side Effects required

Defined in simMain.c

static boolean 
SimIsInitialRound(
  Sim_Info_t * simInfo 
)
optional

Side Effects required

See Also optional
Defined in simMain.c

static boolean 
SimIsStartOfRound(
  Sim_Info_t * simInfo 
)
optional

Side Effects required

See Also optional
Defined in simMain.c

static boolean 
SimIsUserTurn(
  Sim_Info_t * simInfo 
)
optional

Side Effects required

See Also optional
Defined in simMain.c

static void 
SimListConcatenate(
  lsList  list1, 
  lsList  list2 
)
Appends the elements of list2 to the end of list1. The elements themselves are not copied. If list2 is not needed anymore, then it should be freed (do not free the content).

Side Effects list1 is modified.

Defined in sim.c

Sim_Info_t* 
SimManagerDeleteSimInfo(
  char* moduleName 
)
This routine deletes the simInfo of the module from the simulation manager. It returns a pointer to the simInfo if it is present, and NIL otherwise.

Side Effects The user should free the returned pointer after use.

See Also optional
Defined in sim.c

void 
SimManagerInit(
    
)
This routine initializes the global simulation manager. One point to note is that the simulation manager is only visible within the sim package.

Side Effects required

See Also optional
Defined in sim.c

Sim_Info_t* 
SimManagerReadSimInfo(
  char* moduleName 
)
This routine returns the simInfo of the given module. If the module has no simInfo, ie. not simulated before, this routine returns NIL.

Side Effects Should not free the pointer.

See Also optional
Defined in sim.c

static int 
SimModeCmd(
  ClientData  clientData, 
  Tcl_Interp * interp, 
  int  argc, 
  char** argv 
)
required

Side Effects required

Defined in simMain.c

static char * 
SimModeOfSimulation(
  Sim_Info_t * simInfo 
)
optional

Side Effects required

See Also optional
Defined in simMain.c

static boolean 
SimModuleIsInfinite(
  Mdl_Module_t * module 
)
This routine checks if the module contains any variables that are of infinite domain, namely variables that are of type int or nat. If so, return TRUE, else return FALSE. This is a conservative test since modules that contain these variables may not be infinite.

Side Effects required

See Also optional
Defined in simMain.c

static array_t * 
SimObtainAtomArrayFromAtomNames(
  Mdl_Module_t * module, 
  array_t * nameArray 
)
optional

Side Effects required

See Also optional
Defined in simMain.c

static int 
SimPrevStatePrintCmd(
  ClientData  clientData, 
  Tcl_Interp * interp, 
  int  argc, 
  char** argv 
)
sim_prev_state_print

Side Effects required

Defined in simMain.c

SimAtomDependencyInfo_t * 
SimReadAtomDependencyInfo(
  Sim_Manager_t * simManager 
)
optional

Side Effects required

See Also optional
Defined in sim.c

static int 
SimSelectCmd(
  ClientData  clientData, 
  Tcl_Interp * interp, 
  int  argc, 
  char** argv 
)
Picks the choice during simulation.

Side Effects required

Defined in simMain.c

boolean 
SimSimAtomIsExternalVariable(
  Sim_Atom_t * simAtom 
)
Checks if the given simAtom is an external variable. Returns TRUE if so, FALSE otherwise.

Side Effects required

See Also optional
Defined in sim.c

void 
SimSimInfoAddToManager(
  Sim_Info_t* simInfo 
)
It adds the simInfo to the simulation manager.

Side Effects required

See Also SimManagerDeleteSimInfo
Defined in sim.c

Sim_Info_t* 
SimSimInfoAlloc(
  Mdl_Module_t * module 
)
Allocates and initialize the simInfo for the given module.

Side Effects Should free the returned pointer after use.

See Also SimSimInfoFree
Defined in sim.c

void 
SimSimInfoFree(
  Sim_Info_t* simInfo 
)
It frees up the simInfo.

Side Effects required

See Also optional
Defined in sim.c

lsList 
SimSimInfoReadChoice(
  Sim_Info_t * simInfo 
)
returns the list of choices.

Side Effects required

See Also optional
Defined in sim.c

int 
SimSimInfoReadIndex(
  Sim_Info_t * simInfo 
)
Returns the index in the simInfo.

Side Effects required

See Also SimSimInfoIndexSet
Defined in sim.c

char * 
SimSimInfoReadName(
  Sim_Info_t * simInfo 
)
This returns the name of the module which is simulated by the simInfo.

Side Effects Should not free the returned string.

See Also optional
Defined in sim.c

Enum_State_t * 
SimSimInfoReadPartialState(
  Sim_Info_t * simInfo 
)
Returns the partialState.

Side Effects required

See Also optional
Defined in sim.c

Enum_State_t * 
SimSimInfoReadPrevState(
  Sim_Info_t * simInfo 
)
Returns the prevState from the simInfo.

Side Effects required

See Also optional
Defined in sim.c

array_t * 
SimSimInfoReadSimAtomOrder(
  Sim_Info_t * simInfo 
)
Returns the array of simAtomOrder in the simInfo.

Side Effects required

See Also optional
Defined in sim.c

Enum_VarInfo_t * 
SimSimInfoReadVarInfo(
  Sim_Info_t * simInfo 
)
returns the varInfo.

Side Effects required

See Also optional
Defined in sim.c

void 
SimSimInfoSetChoice(
  Sim_Info_t * simInfo, 
  lsList  choice 
)
Sets the Choice field in the simInfo. The choice field is a lsList of Enum_States, which are the possible extension of the current partial state. Partial state is stored in the partialState field of the SimInfo.

Side Effects required

See Also optional
Defined in sim.c

void 
SimSimInfoSetIndex(
  Sim_Info_t * simInfo, 
  int  index 
)
Sets the Index field in the simInfo. The index field indicates which atom to execute next. If the module is empty, the index field has value -1

Side Effects required

See Also optional
Defined in sim.c

void 
SimSimInfoSetPartialState(
  Sim_Info_t * simInfo, 
  Enum_State_t * partialState 
)
The PartialState is a Enum_State that stores the partialState.

Side Effects required

See Also optional
Defined in sim.c

void 
SimSimInfoSetPrevState(
  Sim_Info_t* simInfo, 
  Enum_State_t* prevState 
)
The PrevState field is a Enum_State that stores the previous state.

Side Effects required

See Also optional
Defined in sim.c

void 
SimSimInfoSetSimAtomOrder(
  Sim_Info_t * simInfo, 
  array_t* simAtomOrder 
)
The SimAtomOrder is an array of Sim_Atoms, which are ordered according to the sequence of execution of the atoms.

Side Effects required

See Also optional
Defined in sim.c

void 
SimSimInfoSetVarInfo(
  Sim_Info_t * simInfo, 
  Enum_VarInfo_t * varInfo 
)
The varInfo is a Enum_VarInfo which stores the module infomation needed by the enum package for executing the module.

Side Effects required

See Also optional
Defined in sim.c

boolean 
SimSimulationStart(
  Mdl_Module_t * module, 
  array_t * atomArray, 
  boolean  isUserAtom 
)
This function starts the simulation for a given module.

Side Effects required

See Also optional
Defined in sim.c

static int 
SimStartCmd(
  ClientData  clientData, 
  Tcl_Interp * interp, 
  int  argc, 
  char** argv 
)
Command for sim_start

Side Effects required

Defined in simMain.c

void 
SimStateUpdateWithChoice(
  Sim_Info_t * simInfo, 
  int  index which choice?
)
This routine takes an array of variable pointers, as well as an array of values (in long), and update the partial states. It then calls the SimComputeChoice to update the choices available.

Side Effects required

See Also optional
Defined in sim.c

array_t * 
SimTopologicalSort(
  SimAtomDependencyInfo_t * simAtmInfo 
)
This function employs the non-depth-first-search version of topological sort. It returns an array of the simAtoms. Any atom that awaits another atom will come later in the list. Any atom that is not specified as agent in the formula will come as late as possible, while respecting the await dependency.

Side Effects Users should free the array, but not the simAtoms

See Also optional
Defined in simDependency.c

int 
Sim_Init(
  Tcl_Interp * interp, 
  Main_Manager_t * manager 
)
This function is needed by tcl/tk to initialize this package. Initialization includes registering of commands and initialization of internal data structures used by this package.

Side Effects SimManagerInit() is called and a "global" data structure, namely the simulation manager is created.

See Also optional
Defined in simMain.c

void 
Sim_SimAtomArrayFree(
  array_t * simAtomArray 
)
This routine frees an array of simAtoms. This is useful to free the array returned by Sim_SimAtomReturnSortedArray.

Side Effects required

See Also optional
Defined in sim.c

Atm_Atom_t* 
Sim_SimAtomReadAtom(
  Sim_Atom_t* simAtom 
)
This function returns a pointer to the atom that is represented by this simAtom.

Side Effects User should not free the returned pointer.

See Also optional
Defined in sim.c

boolean 
Sim_SimAtomReadIsUserAtom(
  Sim_Atom_t* simAtom 
)
This function returns true if the simAtom is an user atom, i.e. atom controlled by the user.

Side Effects required

See Also optional
Defined in sim.c

char* 
Sim_SimAtomReadName(
  Sim_Atom_t* simAtom 
)
This function returns the name of the simAtom.

Side Effects User should not free the returned string.

See Also optional
Defined in sim.c

array_t * 
Sim_SimAtomReturnSortedArray(
  Mdl_Module_t * module, 
  array_t * atomArray, 
  int  isUserAtom 
)
Given a module, an array of users atoms (Atm_Atom_t *), and the type of the atoms (are they userAtoms?), this routine creates the simAtoms for the module and returns an array of topologically sorted simAtoms. Note that the non-user atoms will come as late as possible in the linearization so that the user will have the least knowledge of how the non-user atom behaves.

Side Effects The atomDependencyInfo will be updated. The sorted array will be returned. User should free the array (Sim_SimAtomArrayFree) after use.

See Also Sim_SimAtomArrayFree
Defined in sim.c

Last updated on 980624 22h11