本文整理汇总了Java中jason.asSemantics.ActionExec.setResult方法的典型用法代码示例。如果您正苦于以下问题:Java ActionExec.setResult方法的具体用法?Java ActionExec.setResult怎么用?Java ActionExec.setResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jason.asSemantics.ActionExec
的用法示例。
在下文中一共展示了ActionExec.setResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isActionFeedback
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
boolean isActionFeedback(ACLMessage m) {
// check if there are feedbacks on requested action executions
if (m.getOntology() != null && m.getOntology().equals(JadeEnvironment.actionOntology)) {
String irt = m.getInReplyTo();
if (irt != null) {
ActionExec a = myPA.remove(irt);
// was it a pending action?
if (a != null) {
if (m.getContent().equals("ok")) {
a.setResult(true);
} else {
a.setResult(false);
}
actionExecuted(a);
} else {
logger.log(Level.SEVERE, "Error: received feedback for an Action that is not pending. The message is "+m);
}
}
return true;
}
return false;
}
示例2: notifyActionSuccess
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
protected void notifyActionSuccess(Op op, Structure action, ActionExec actionExec) {
Object[] values = op.getParamValues();
for (int i = 0; i < action.getArity(); i++) {
if (action.getTerm(i).isVar()) { // isVar means is a variable AND is not bound (see Jason impl)
try {
boolean bound = bind(values[i], action.getTerm(i), actionExec);
if (!bound) {
// env.logger.severe("INTERNAL ERROR: binding failed "+values[i]+" "+action.getTerm(i));
actionExec.setResult(false);
Literal reason = ASSyntax.createLiteral("bind_param_error", action.getTerm(i), ASSyntax.createString(values[i]));
actionExec.setFailureReason(reason, "Error binding parameters: " + action.getTerm(i) + " with " + values[i]);
super.actionExecuted(actionExec);
return;
}
} catch (Exception ex) {
ex.printStackTrace();
return;
}
}
}
actionExec.setResult(true);
super.actionExecuted(actionExec);
}
示例3: isActionFeedback
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
boolean isActionFeedback(ACLMessage m) {
// check if there are feedbacks on requested action executions
if (m.getOntology() != null && m.getOntology().equals(JadeEnvironment.actionOntology)) {
String irt = m.getInReplyTo();
if (irt != null) {
ActionExec a = myPA.remove(irt);
// was it a pending action?
if (a != null) {
a.setResult(m.getContent().equals("ok"));
actionExecuted(a);
} else {
logger.log(Level.SEVERE, "Error: received feedback for an Action that is not pending. The message is "+m);
}
}
return true;
}
return false;
}
示例4: act
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
@Override
public void act(ActionExec action, List<ActionExec> feedback) {
final Structure term = action.getActionTerm();
switch (term.getFunctor()) {
case "printList":
final String nodeName = System.getProperty("jboss.node.name");
logger.info(getAgent().getAid().getName() + " hosted by " + nodeName + " says: " + term.getTerm(0));
try {
Thread.sleep((int) (Math.random() * 1000) + 500);
} catch (InterruptedException ex) {
}
action.setResult(true);
break;
default:
action.setResult(false);
action.setFailureReason(Literal.parseLiteral("unknownAction"), "Unknown action.");
break;
}
feedback.add(action);
}
示例5: actionExecuted
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
public void actionExecuted(String agName, Structure actTerm, boolean success, Object infraData) {
ActionExec action = (ActionExec)infraData;
action.setResult(success);
CentralisedAgArch ag = masRunner.getAg(agName);
if (ag != null) // the agent may was killed
ag.actionExecuted(action);
}
示例6: startNextStep
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
public void startNextStep(int step, List<Literal> p) {
perceptions = p;
List<ActionExec> feedback = getTS().getC().getFeedbackActions();
while (!toExecute.isEmpty()) {
ActionExec action = toExecute.poll();
action.setResult(true);
feedback.add(action);
}
getTS().newMessageHasArrived();
setCycle(step);
}
示例7: act
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
public void act() {
ActionExec acExec = getTS().getC().getAction();
if (acExec == null) {
return;
}
Term acTerm = acExec.getActionTerm();
logger.info("doing: "+acTerm);
if (acTerm.getFunctor().equals("do")){
clima.send(acTerm.getTerm(0).toString()); //, removeQuotes(acTerm.getTerm(1).toString()));
acExec.setResult(true);
}
getTS().getC().getFeedbackActions().add(acExec);
}
示例8: newCycle
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
void newCycle() {
cycleCounter++;
if (getSimStep() == 1) cycleCounter = 1;
StringBuilder notsent = new StringBuilder();
if (toExecute.size() > 1) {
notsent.append(" The following was not sent: ");
}
// set all actions as successfully executed
List<ActionExec> feedback = getTS().getC().getFeedbackActions();
synchronized (feedback) {
while (!toExecute.isEmpty()) {
ActionExec action = toExecute.poll();
action.setResult(true);
feedback.add(action);
if (!toExecute.isEmpty())
notsent.append(action.getActionTerm()+" ");
}
}
go(); // reset the wait
// prepare msg to print out
String w = "";
if (lastActionInCurrentCycle == null && cycleCounter > 10) { // ignore problem in the first cycles (the agent is still in setup!)
addRestart();
w = "*** ";
}
String timetoact = ". ";
if (lastActionInCurrentCycle != null && timestartcycle > 0) {
timetoact = " (act in "+ (timeLastAction - timestartcycle) +" ms)";
}
timestartcycle = System.currentTimeMillis();
logger.info(w+"Last sent action was "+lastActionInCurrentCycle+" for cycle "+getSimStep()+ timetoact + notsent);
setLastAct(lastActionInCurrentCycle);
lastActionInCurrentCycle = null;
}
示例9: notifyActionFailure
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
protected void notifyActionFailure(ActionExec actionExec, Term reason, String msg) {
// logger.info("notified failure for "+actionExec.getActionTerm()+" - reason: "+reason);
actionExec.setResult(false);
Literal descr = null;
if (reason != null) {
descr = ASSyntax.createLiteral("env_failure_reason", reason);
}
actionExec.setFailureReason(descr, msg);
super.actionExecuted(actionExec);
}
示例10: act
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
@Override
public void act(ActionExec action) {
getTS().getLogger().info("Agent " + getAgName() + " is doing: " + action.getActionTerm());
// set that the execution was ok
action.setResult(true);
actionExecuted(action);
}
示例11: act
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
@Override
public void act(ActionExec action) { //, List<ActionExec> feedback) {
if (action.getActionTerm().getFunctor().startsWith("show_winner")) {
jt.append("Winner of auction " + action.getActionTerm().getTerm(0));
jt.append(" is " + action.getActionTerm().getTerm(1) + "\n");
action.setResult(true);
actionExecuted(action);
auction.setEnabled(true); // enable GUI button
} else {
super.act(action); // send the action to the environment to be performed.
}
}
示例12: act
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
/** called by the TS to ask the execution of an action in the environment */
@Override
public void act(ActionExec action) {
//if (logger.isLoggable(Level.FINE)) logger.fine("doing: " + action.getActionTerm());
if (isRunning()) {
if (infraEnv != null) {
infraEnv.act(getAgName(), action);
} else {
action.setResult(false);
action.setFailureReason(new Atom("noenv"), "no environment configured!");
actionExecuted(action);
}
}
}
示例13: act
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
@Override
public void act(ActionExec action) {
actions.add(action.getActionTerm());
if (getEnvInfraTier() != null) {
super.act(action);
} else {
action.setResult(true);
actionExecuted(action);
}
}
示例14: onActionFeedback
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
public void onActionFeedback(ActionFeedbackMessage msg) {
ActionExec action = scheduledActions.remove(msg.getUserData());
if (action != null) {
action.setResult(msg.isSuccess());
getTS().getC().addFeedbackAction(action);
}
}
示例15: act
import jason.asSemantics.ActionExec; //导入方法依赖的package包/类
@Override
public void act(ActionExec action, List<ActionExec> feedback) {
Structure term = action.getActionTerm();
boolean processed = true;
switch (term.getFunctor()) {
case "participantReady":
if (waitingParticipants.decrementAndGet() == 0) {
Literal lit = Literal.parseLiteral("sendCfps");
try {
getTS().getAg().addBel(lit);
} catch (RevisionFailedException ex) {
ex.printStackTrace();
}
}
break;
case "cfpStarted":
startTime = System.currentTimeMillis();
receivedSolutions = new AtomicInteger(0);
break;
case "taskCompleted":
int done = receivedSolutions.incrementAndGet();
if (done == numParticipants)
logger.info("Total time: " + (System.currentTimeMillis() - startTime) + " ms");
break;
default:
super.act(action, feedback);
processed = false;
}
if (processed) {
action.setResult(true);
feedback.add(action);
}
}