⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 engine.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 3 页
字号:
   return;  }  /***********************************************//* HaltCommand: Causes rule execution to halt. *//***********************************************/globle VOID HaltCommand()  {   ArgCountCheck("halt",EXACTLY,0);   HaltRules = CLIPS_TRUE;  }  #if DEBUGGING_FUNCTIONS/*********************************************************//* SetBreak: C access routine for the set-break command. *//*********************************************************/globle VOID SetBreak(theRule)  VOID *theRule;  {   struct defrule *thePtr;   for (thePtr = (struct defrule *) theRule;        thePtr != NULL;        thePtr = thePtr->disjunct)     { thePtr->afterBreakpoint = 1; }  }/***************************************************************//* RemoveBreak: C access routine for the remove-break command. *//***************************************************************/globle BOOLEAN RemoveBreak(theRule)  VOID *theRule;  {   struct defrule *thePtr;   int rv = CLIPS_FALSE;   for (thePtr = (struct defrule *) theRule;        thePtr != NULL;        thePtr = thePtr->disjunct)     {      if (thePtr->afterBreakpoint == 1)        {         thePtr->afterBreakpoint = 0;         rv = CLIPS_TRUE;        }     }   return(rv);  }/**************************************************//* RemoveAllBreakpoints: Removes all breakpoints. *//**************************************************/globle VOID RemoveAllBreakpoints()  {   VOID *theRule;   VOID *theDefmodule = NULL;      while ((theDefmodule = GetNextDefmodule(theDefmodule)) != NULL)     {      theRule = NULL;      while ((theRule = GetNextDefrule(theRule)) != NULL)        { RemoveBreak(theRule); }     }  }/*************************************************************//* ShowBreaks: C access routine for the show-breaks command. *//*************************************************************/globle VOID ShowBreaks(logicalName,vTheModule)  char *logicalName;  VOID *vTheModule;  {     ListItemsDriver(logicalName,(struct defmodule *) vTheModule,                   NULL,NULL,#if ANSI_COMPILER                   GetNextDefrule,(char *(*)(VOID *)) GetConstructNameString,#else                   GetNextDefrule,(char *(*)()) GetConstructNameString,#endif                   NULL,DefruleHasBreakpoint);   }/************************************************************************************//* DefruleHasBreakpoint: Indicates whether the specified rule has a breakpoint set. *//************************************************************************************/globle BOOLEAN DefruleHasBreakpoint(theRule)  VOID *theRule;  {   return(((struct defrule *) theRule)->afterBreakpoint);  }/*****************************************//* SetBreakCommand: CLIPS access routine *//*   for the set-break command.          *//*****************************************/globle VOID SetBreakCommand()  {   DATA_OBJECT argPtr;   char *argument;   VOID *defrulePtr;   if (ArgCountCheck("set-break",EXACTLY,1) == -1) return;   if (ArgTypeCheck("set-break",1,SYMBOL,&argPtr) == CLIPS_FALSE) return;   argument = DOToString(argPtr);   if ((defrulePtr = FindDefrule(argument)) == NULL)     {      CantFindItemErrorMessage("defrule",argument);      return;     }   SetBreak(defrulePtr);  }/********************************************//* RemoveBreakCommand: CLIPS access routine *//*   for the remove-break command.          *//********************************************/globle VOID RemoveBreakCommand()  {   DATA_OBJECT argPtr;   char *argument;   int nargs;   VOID *defrulePtr;   if ((nargs = ArgCountCheck("remove-break",NO_MORE_THAN,1)) == -1)     { return; }   if (nargs == 0)     {      RemoveAllBreakpoints();      return;     }   if (ArgTypeCheck("remove-break",1,SYMBOL,&argPtr) == CLIPS_FALSE) return;   argument = DOToString(argPtr);   if ((defrulePtr = FindDefrule(argument)) == NULL)     {      CantFindItemErrorMessage("defrule",argument);      return;     }   if (RemoveBreak(defrulePtr) == CLIPS_FALSE)     {      PrintCLIPS(WERROR,"Rule ");      PrintCLIPS(WERROR,argument);      PrintCLIPS(WERROR," does not have a breakpoint set.\n");     }  }/*******************************************//* ShowBreaksCommand: CLIPS access routine *//*   for the show-breaks command.          *//*******************************************/globle VOID ShowBreaksCommand()  {   int numArgs, error;   struct defmodule *theModule;      if ((numArgs = ArgCountCheck("show-breaks",NO_MORE_THAN,1)) == -1) return;   if (numArgs == 1)     {      theModule = GetModuleName("show-breaks",1,&error);      if (error) return;     }   else     { theModule = ((struct defmodule *) GetCurrentModule()); }   ShowBreaks(WDISPLAY,theModule);  }  /***********************************************//* ListFocusStackCommand: CLIPS access routine *//*   for the list-focus-stack command.         *//***********************************************/globle VOID ListFocusStackCommand()  {   if (ArgCountCheck("list-focus-stack",EXACTLY,0) == -1) return;   ListFocusStack(WDISPLAY);  }  /****************************************//* ListFocusStack: C access routine for *//*   the list-focus-stack command.      *//****************************************/globle VOID ListFocusStack(logicalName)  char *logicalName;  {   struct focus *theFocus;           for (theFocus = CurrentFocus;        theFocus != NULL;        theFocus = theFocus->next)     {      PrintCLIPS(logicalName,GetDefmoduleName(theFocus->theModule));      PrintCLIPS(logicalName,"\n");     }  }  #endif/***********************************************//* GetFocusStackFunction: CLIPS access routine *//*   for the get-focus-stack function.         *//***********************************************/globle VOID GetFocusStackFunction(returnValue)  DATA_OBJECT_PTR returnValue;  {   if (ArgCountCheck("get-focus-stack",EXACTLY,0) == -1) return;   GetFocusStack(returnValue);  }  /***************************************//* GetFocusStack: C access routine for *//*   the get-focus-stack function.     *//***************************************/globle VOID GetFocusStack(returnValue)  DATA_OBJECT_PTR returnValue;  {   struct focus *theFocus;   struct multifield *theList;   long count = 0;         /*===========================================*/   /* If there is no current focus, then return */   /* a multifield value of length zero.        */   /*===========================================*/      if (CurrentFocus == NULL)     {      SetpType(returnValue,MULTIFIELD);      SetpDOBegin(returnValue,1);      SetpDOEnd(returnValue,0);      SetpValue(returnValue,(VOID *) CreateMultifield(0L));      return;     }     /*=====================================================*/   /* Determine the number of modules on the focus stack. */   /*=====================================================*/      for (theFocus = CurrentFocus; theFocus != NULL; theFocus = theFocus->next)     { count++; }      /*=============================================*/   /* Create a multifield of the appropriate size */   /* in which to store the module names.         */   /*=============================================*/      SetpType(returnValue,MULTIFIELD);   SetpDOBegin(returnValue,1);   SetpDOEnd(returnValue,count);   theList = (struct multifield *) CreateMultifield(count);   SetpValue(returnValue,(VOID *) theList);      /*=================================================*/   /* Store the module names in the multifield value. */   /*=================================================*/      for (theFocus = CurrentFocus, count = 1;         theFocus != NULL;         theFocus = theFocus->next, count++)     {       SetMFType(theList,count,SYMBOL);      SetMFValue(theList,count,theFocus->theModule->name);     }  }  /******************************************//* PopFocusFunction: CLIPS access routine *//*   for the pop-focus function.          *//******************************************/globle SYMBOL_HN *PopFocusFunction()  {   struct defmodule *theModule;      ArgCountCheck("pop-focus",EXACTLY,0);      theModule = (struct defmodule *) PopFocus();   if (theModule == NULL) return((SYMBOL_HN *) CLIPSFalseSymbol);   return(theModule->name);  }/******************************************//* GetFocusFunction: CLIPS access routine *//*   for the get-focus function.          *//******************************************/globle SYMBOL_HN *GetFocusFunction()  {   struct defmodule *rv;      ArgCountCheck("get-focus",EXACTLY,0);   rv = (struct defmodule *) WRGetFocus();    if (rv == NULL) return((SYMBOL_HN *) CLIPSFalseSymbol);     return(rv->name);  }  /**********************************//* GetFocus: C access routine for *//*   the get-focus function.      *//**********************************/globle VOID *WRGetFocus()  {   if (CurrentFocus == NULL) return(NULL);      return((VOID *) CurrentFocus->theModule);  }  /**************************************//* FocusCommand: CLIPS access routine *//*   for the focus function.          *//**************************************/globle int FocusCommand()  {   DATA_OBJECT argPtr;   char *argument;   struct defmodule *theModule;   int argCount, i;   /*=====================================================*/   /* Check for the correct number and type of arguments. */   /*=====================================================*/         if ((argCount = ArgCountCheck("focus",AT_LEAST,1)) == -1)     { return(CLIPS_FALSE); }   /*===========================================*/   /* Focus on the specified defrule module(s). */   /*===========================================*/      for (i = argCount; i > 0; i--)     {      if (ArgTypeCheck("focus",i,SYMBOL,&argPtr) == CLIPS_FALSE)        { return(CLIPS_FALSE); }      argument = DOToString(argPtr);      theModule = (struct defmodule *) FindDefmodule(argument);         if (theModule == NULL)        {         CantFindItemErrorMessage("defmodule",argument);         return(CLIPS_FALSE);        }           Focus((VOID *) theModule);     }      /*===================================================*/   /* Return TRUE to indicate success of focus command. */   /*===================================================*/      return(CLIPS_TRUE);  }  /********************************************************************//* GetFocusChanged: Returns the value of the variable FocusChanged. *//********************************************************************/globle int GetFocusChanged()  {    return(FocusChanged);  }/*****************************************************************//* SetFocusChanged: Sets the value of the variable FocusChanged. *//*****************************************************************/globle VOID SetFocusChanged(value)  int value;  {   FocusChanged = value;  }#endif /* DEFRULE_CONSTRUCT */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -