本文整理汇总了Java中jason.asSemantics.ActionExec类的典型用法代码示例。如果您正苦于以下问题:Java ActionExec类的具体用法?Java ActionExec怎么用?Java ActionExec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActionExec类属于jason.asSemantics包,在下文中一共展示了ActionExec类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: act
import jason.asSemantics.ActionExec; //导入依赖的package包/类
@Override
public void act(ActionExec action) { //, List<ActionExec> feedback) {
if (!isRunning()) return;
if (getEnvironmentAg() == null) return;
try {
Term acTerm = action.getActionTerm();
logger.fine("doing: " + acTerm);
String rw = "id"+jadeAg.incReplyWithId();
ACLMessage m = new ACLMessage(ACLMessage.REQUEST);
m.addReceiver(environmentAID);
m.setOntology(JadeEnvironment.actionOntology);
m.setContent(acTerm.toString());
m.setReplyWith(rw);
myPA.put(rw, action);
jadeAg.send(m);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error sending action " + action, e);
}
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:22,代码来源:JasonBridgeArch.java
示例2: 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;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:23,代码来源:JasonBridgeArch.java
示例3: execute
import jason.asSemantics.ActionExec; //导入依赖的package包/类
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
Circumstance C = ts.getC();
Trigger teGoal = new Trigger(TEOperator.add, TEType.achieve, (Literal)args[0]);
// search in PA
for (ActionExec a: C.getPendingActions().values())
if (a.getIntention().hasTrigger(teGoal, un))
return un.unifies(args[1], aAct);
// search in PI
Map<String, Intention> pi = C.getPendingIntentions();
for (String reason: pi.keySet())
if (pi.get(reason).hasTrigger(teGoal, un))
return un.unifies(args[1], new StringTermImpl(reason));
return false;
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:21,代码来源:suspended.java
示例4: addActionInSchedule
import jason.asSemantics.ActionExec; //导入依赖的package包/类
/** this method is called by the agents to request some action performance */
public void addActionInSchedule(final LocalMinerArch ag, final ActionExec act) {
synchronized (finished) {
if (finished[getAgNbFromName(ag.getAgName())] != null) { // the agent already did an action in this cycle
logger.warning("** Agent "+ag.getAgName()+" is trying two action is the same cycle! This action was ignored.");
} else {
executor.execute(new Runnable() {
public void run() {
Structure acTerm = act.getActionTerm();
if (executeAction(ag.getAgName(), acTerm)) {
act.setResult(true);
} else {
act.setResult(false);
}
addExecutedAction(new ActRequest(ag,act));
};
});
}
}
}
开发者ID:jason-lang,项目名称:apps,代码行数:22,代码来源:CycledEnvironment.java
示例5: 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);
}
开发者ID:CArtAgO-lang,项目名称:cartago,代码行数:24,代码来源:CAgentArch.java
示例6: act
import jason.asSemantics.ActionExec; //导入依赖的package包/类
@Override
public void act(ActionExec action) {
if (!isRunning()) return;
if (getEnvironmentAg() == null) return;
try {
Term acTerm = action.getActionTerm();
logger.fine("doing: " + acTerm);
String rw = "id"+jadeAg.incReplyWithId();
ACLMessage m = new ACLMessage(ACLMessage.REQUEST);
m.addReceiver(environmentAID);
m.setOntology(JadeEnvironment.actionOntology);
m.setContent(acTerm.toString());
m.setReplyWith(rw);
myPA.put(rw, action);
jadeAg.send(m);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error sending action " + action, e);
}
}
开发者ID:jason-lang,项目名称:jason,代码行数:22,代码来源:JasonBridgeArch.java
示例7: 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;
}
开发者ID:jason-lang,项目名称:jason,代码行数:19,代码来源:JasonBridgeArch.java
示例8: 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);
}
开发者ID:gcvt,项目名称:siebog,代码行数:21,代码来源:HAAgArch.java
示例9: 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);
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:8,代码来源:CentralisedEnvironment.java
示例10: 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());
super.act(action);
if (isRunning() && infraEnv != null)
infraEnv.act(getAgName(), action);
}
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:9,代码来源:CentralisedAgArch.java
示例11: 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);
}
开发者ID:jason-lang,项目名称:apps,代码行数:14,代码来源:ACArchitecture.java
示例12: act
import jason.asSemantics.ActionExec; //导入依赖的package包/类
synchronized public void act(ActionExec action, List<ActionExec> feedback) {
if (isRunning()) {
if (waitingExecution) {
toExecute.add(action);
} else {
waitingExecution = true;
//getTS().getAg().getLogger().info("doing: " + action.getActionTerm());
CentralisedEnvironment jEnv = RunCentralisedMAS.getRunner().getEnvironmentInfraTier();
if (jEnv != null) {
MiningEnvironment env = (MiningEnvironment)jEnv.getUserEnvironment();
env.addActionInSchedule(this, action);
}
}
}
}
开发者ID:jason-lang,项目名称:apps,代码行数:16,代码来源:LocalMinerArch.java
示例13: actFinished
import jason.asSemantics.ActionExec; //导入依赖的package包/类
synchronized public void actFinished(ActionExec action) {
List<ActionExec> feedback = getTS().getC().getFeedbackActions();
feedback.add(action);
waitingExecution = false;
// if there is an action waiting for execution
if (!toExecute.isEmpty()) {
action = toExecute.poll();
// if the action is for an intention already dropped (it is not in PA anymore), ignore it
if (getTS().getC().getPendingActions().containsKey(action.getIntention().getId())) {
act(action, feedback);
}
}
getTS().newMessageHasArrived(); // in case the agent is sleeping...
}
开发者ID:jason-lang,项目名称:apps,代码行数:16,代码来源:LocalMinerArch.java
示例14: addAction
import jason.asSemantics.ActionExec; //导入依赖的package包/类
void addAction(ActionExec action) {
if (action == null) return;
logger.info("adding action "+action.getActionTerm()+" to be executed.");
lock.lock();
try {
if (lastAction != null)
toExecute.offer(lastAction);
lastAction = action;
} finally {
lock.unlock();
}
}
开发者ID:jason-lang,项目名称:apps,代码行数:13,代码来源:ACArchitecture.java
示例15: addAction
import jason.asSemantics.ActionExec; //导入依赖的package包/类
void addAction(ActionExec action) {
if (action == null) return;
logger.info("adding action "+action.getActionTerm()+" to be executed.");
lock.lock();
try {
if (lastAction != null)
toExecute.offer(lastAction);
lastAction = action;
} finally {
lock.unlock();
}
}
开发者ID:jason-lang,项目名称:apps,代码行数:13,代码来源:ACArchitecture.java
示例16: 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);
}
开发者ID:jason-lang,项目名称:apps,代码行数:15,代码来源:ClimaArchitecture.java
示例17: addAction
import jason.asSemantics.ActionExec; //导入依赖的package包/类
void addAction(ActionExec action) {
lock.lock();
try {
if (lastAction != null)
toExecute.offer(lastAction);
lastAction = action;
} finally {
lock.unlock();
}
}
开发者ID:jason-lang,项目名称:apps,代码行数:11,代码来源:ACArchitecture.java
示例18: 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;
}
开发者ID:jason-lang,项目名称:apps,代码行数:39,代码来源:ACArchitecture.java
示例19: bind
import jason.asSemantics.ActionExec; //导入依赖的package包/类
protected boolean bind(Object obj, Term term, ActionExec act) {
try {
Term t = lib.objectToTerm(obj);
Unifier un = act.getIntention().peek().getUnif();
// System.out.println("BINDING obj "+obj+" term "+t+" with "+term);
return un.unifies(t, term);
} catch (Exception ex) {
return false;
}
}
开发者ID:CArtAgO-lang,项目名称:cartago,代码行数:11,代码来源:CAgentArch.java
示例20: 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);
}
开发者ID:CArtAgO-lang,项目名称:cartago,代码行数:11,代码来源:CAgentArch.java
注:本文中的jason.asSemantics.ActionExec类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论