Ejemplo n.º 1
0
 public IEnumerator <Unifier> LogicalConsecuence(Agent ag, Unifier un)
 {
     if (ag == null || ag.GetReasoner().GetUserAgArch().IsRunning())
     {
         try
         {
             InternalAction ia = GetIA(ag);
             if (!ia.CanBeUsedInContext())
             {
                 Debug.Log(GetErrorMsg() + ": internal action" + GetFunctor() + " cannot be used in context or rules");
                 return(LogExpr.EMPTY_UNIF_LIST.GetEnumerator());
             }
             //calls IA's execute method
             object oresult = ia.Execute(ag.GetReasoner(), un, ia.PrepareArguments(this, un));
             if (oresult.GetType() == typeof(bool) && (bool)oresult)
             {
                 return(LogExpr.CreateUnifEnumerator(un));
             }
             else if (oresult.GetType() == typeof(IEnumerator <>))
             {
                 return((IEnumerator <Unifier>)oresult);
             }
         }
         catch (Exception e)
         {
             Debug.Log("*-*-*" + GetFunctor() + " concurrent exception - try later" + e.ToString());
             try
             {
                 Thread.Sleep(2000);
             }
             catch (Exception e1)
             {
                 return(LogicalConsecuence(ag, un));
             }
         }
     }
     return(LogExpr.EMPTY_UNIF_LIST.GetEnumerator());
 }
Ejemplo n.º 2
0
 public override IEnumerator <Unifier> LogicalConsequence(Agent ag, Unifier un)
 {
     return(LogExpr.CreateUnifEnumerator(un));
 }