Пример #1
0
globle void RemoveAllActivations(
    void *theEnv)
{
    struct activation *tempPtr, *theActivation;
    struct salienceGroup *theGroup, *tempGroup;

    theActivation = GetDefruleModuleItem(theEnv,NULL)->agenda;
    while (theActivation != NULL)
    {
        tempPtr = theActivation->next;
        RemoveActivation(theEnv,theActivation,TRUE,TRUE);
        theActivation = tempPtr;
    }

    theGroup = GetDefruleModuleItem(theEnv,NULL)->groupings;
    while (theGroup != NULL)
    {
        tempGroup = theGroup->next;
        rtn_struct(theEnv,salienceGroup,theGroup);
        theGroup = tempGroup;
    }
}
Пример #2
0
globle void EnvFocus(
  void *theEnv,
  void *vTheModule)
  {
   struct defmodule *theModule = (struct defmodule *) vTheModule;
   struct focus *tempFocus;

   /*==================================================*/
   /* Make the specified module be the current module. */
   /* If the specified module is the current focus,    */
   /* then no further action is needed.                */
   /*==================================================*/

   EnvSetCurrentModule(theEnv,(void *) theModule);
   if (EngineData(theEnv)->CurrentFocus != NULL)
     { if (EngineData(theEnv)->CurrentFocus->theModule == theModule) return; }

   /*=====================================*/
   /* If the focus is being watched, then */
   /* print an information message.       */
   /*=====================================*/

#if DEBUGGING_FUNCTIONS
   if (EngineData(theEnv)->WatchFocus)
     {
      EnvPrintRouter(theEnv,WTRACE,"==> Focus ");
      EnvPrintRouter(theEnv,WTRACE,ValueToString(theModule->name));
      if (EngineData(theEnv)->CurrentFocus != NULL)
        {
         EnvPrintRouter(theEnv,WTRACE," from ");
         EnvPrintRouter(theEnv,WTRACE,ValueToString(EngineData(theEnv)->CurrentFocus->theModule->name));
        }
      EnvPrintRouter(theEnv,WTRACE,"\n");
     }
#endif

   /*=======================================*/
   /* Add the new focus to the focus stack. */
   /*=======================================*/

   tempFocus = get_struct(theEnv,focus);
   tempFocus->theModule = theModule;
   tempFocus->theDefruleModule = GetDefruleModuleItem(theEnv,theModule);
   tempFocus->next = EngineData(theEnv)->CurrentFocus;
   EngineData(theEnv)->CurrentFocus = tempFocus;
   EngineData(theEnv)->FocusChanged = TRUE;
  }
Пример #3
0
globle void EnvReorderAgenda(
    void *theEnv,
    void *vTheModule)
{
    struct activation *theActivation, *tempPtr;
    struct defmodule *theModule = (struct defmodule *) vTheModule;
    int allModules = FALSE;
    struct defruleModule *theModuleItem;
    struct salienceGroup *theGroup, *tempGroup;

    /*=============================================*/
    /* If the module specified is a NULL pointer,  */
    /* then every module has its agenda reordered. */
    /*=============================================*/

    if (theModule == NULL)
    {
        allModules = TRUE;
        theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);
    }

    /*========================*/
    /* Reorder the agenda(s). */
    /*========================*/

    for (;
            theModule != NULL;
            theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))
    {
        /*=================================*/
        /* Get the list of activations and */
        /* remove them from the agenda.    */
        /*=================================*/

        theModuleItem = GetDefruleModuleItem(theEnv,theModule);
        theActivation = theModuleItem->agenda;
        theModuleItem->agenda = NULL;

        theGroup = theModuleItem->groupings;
        while (theGroup != NULL)
        {
            tempGroup = theGroup->next;
            rtn_struct(theEnv,salienceGroup,theGroup);
            theGroup = tempGroup;
        }

        theModuleItem->groupings = NULL;

        /*=========================================*/
        /* Reorder the activations by placing them */
        /* back on the agenda one by one.          */
        /*=========================================*/

        while (theActivation != NULL)
        {
            tempPtr = theActivation->next;
            theActivation->next = NULL;
            theActivation->prev = NULL;
            theGroup = ReuseOrCreateSalienceGroup(theEnv,theModuleItem,theActivation->salience);
            PlaceActivation(theEnv,&(theModuleItem->agenda),theActivation,theGroup);
            theActivation = tempPtr;
        }

        /*===============================================*/
        /* Return if only one agenda is being reordered. */
        /*===============================================*/

        if (! allModules) return;
    }
}