public InternalActionLiteral(Atom ns, Structure p, Agent ag) : base(ns, p) { if (ag != null) { ia = ag.GetIA(GetFunctor()); } }
public InternalAction GetIA(Agent ag) { if (ia == null && ag != null) { ia = ag.GetIA(GetFunctor()); } return(ia); }
public static JasonityException CreateWrongArgumentNb(InternalAction ia) { string msg; if (ia.GetMinArgs() == ia.GetMaxArgs()) { if (ia.GetMinArgs() == 1) { msg = " One argument is expected."; } else { msg = " " + ia.GetMinArgs() + " arguments are expected."; } } else { msg = " From " + ia.GetMinArgs() + " to " + ia.GetMaxArgs() + " arguments are expected."; } return(new JasonityException("The internal action '" + ia.GetMaxArgs() + " arguments are expected.")); }
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()); }
public void SetIA(string iaName, InternalAction ia) { internalActions.Add(iaName, ia); }
public static JasonityException CreateWrongArgument(InternalAction ia, string reason) { return(new JasonityException("Wrong argument for internal action '" + ia.GetType().Name + "': " + reason, WRONG_ARGS)); }
//used by cloneNS private InternalActionLiteral(Atom ns, InternalActionLiteral l) : base(ns, (Structure)l) { this.ia = l.ia; }
//used by capply private InternalActionLiteral(InternalActionLiteral l, Unifier u) : base((Structure)l, u) { this.ia = l.ia; }
//used by clone public InternalActionLiteral(InternalActionLiteral l) : base(l.GetNS(), (Structure)l) { this.ia = l.ia; }
public void SetIA(InternalAction ia) { this.ia = ia; }