实操指南:Java Settings类的运用示例
最编程
2024-02-21 15:55:49
...
实例1: tryToIncludeMindInspectorForAg
import jason.runtime.Settings; //导入依赖的package包/类
private boolean tryToIncludeMindInspectorForAg(String path) {
try {
Agent ag = registeredAgents.get(getAgNameFromPath(path));
if (ag != null) {
AgArch arch = ag.getTS().getUserAgArch();
if (arch != null) {
// should add a new conf for mindinspector, otherwise will start a new gui for the agent
arch.getTS().getSettings().addOption(Settings.MIND_INSPECTOR,"web(cycle,html,no_history)");
MindInspectorAgArch miArch = new MindInspectorAgArch();
arch.insertAgArch(miArch);
miArch.init();
miArch.addAgState();
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
实例2: changeToDebugMode
import jason.runtime.Settings; //导入依赖的package包/类
/** change the current running MAS to debug mode */
void changeToDebugMode() {
try {
if (control == null) {
control = new CentralisedExecutionControl(new ClassParameters(ExecutionControlGUI.class.getName()), this);
for (CentralisedAgArch ag : ags.values()) {
ag.setControlInfraTier(control);
Settings stts = ag.getTS().getSettings();
stts.setVerbose(2);
stts.setSync(true);
ag.getLogger().setLevel(Level.FINE);
ag.getTS().getLogger().setLevel(Level.FINE);
ag.getTS().getAg().getLogger().setLevel(Level.FINE);
}
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Error entering in debug mode", e);
}
}
实例3: createArchs
import jason.runtime.Settings; //导入依赖的package包/类
/**
* Creates the user agent architecture, default architecture is
* jason.architecture.AgArch. The arch will create the agent that creates
* the TS.
*/
public void createArchs(List<String> agArchClasses, String agClass, ClassParameters bbPars, String asSrc, Settings stts, RunCentralisedMAS masRunner) throws JasonException {
try {
this.masRunner = masRunner;
Agent.create(this, agClass, bbPars, asSrc, stts);
insertAgArch(this);
createCustomArchs(agArchClasses);
// mind inspector arch
if (stts.getUserParameter(Settings.MIND_INSPECTOR) != null) {
insertAgArch( (AgArch)Class.forName( Config.get().getMindInspectorArchClassName()).newInstance() );
getFirstAgArch().init();
}
setLogger();
} catch (Exception e) {
running = false;
throw new JasonException("as2j: error creating the agent class! - "+e.getMessage(), e);
}
}
实例4: addInitialGoalsFromProjectInBB
import jason.runtime.Settings; //导入依赖的package包/类
protected void addInitialGoalsFromProjectInBB() {
String sGoals = getTS().getSettings().getUserParameter(Settings.INIT_GOALS);
if (sGoals != null) {
try {
for (Term t: ASSyntax.parseList("["+sGoals+"]")) {
Literal g = ((Literal)t).forceFullLiteralImpl();
g.makeVarsAnnon();
if (! g.hasSource())
g.addAnnot(BeliefBase.TSelf);
getTS().getC().addAchvGoal(g,Intention.EmptyInt);
}
} catch (Exception e) {
logger.log(Level.WARNING, "Initial goals from project '["+sGoals+"]' is not a list of literals.");
}
}
}
实例5: initAg
import jason.runtime.Settings; //导入依赖的package包/类
@Override
public void initAg(String agClass, ClassParameters bbPars, String asSrc, Settings stts) throws JasonException {
super.initAg(agClass, bbPars, asSrc, stts);
logger = Logger.getLogger(ACArchitecture.class.getName()+"."+getAgName());
String username = stts.getUserParameter("username");
if (username.startsWith("\"")) username = username.substring(1,username.length()-1);
String password = stts.getUserParameter("password");
if (password.startsWith("\"")) password = password.substring(1,password.length()-1);
proxy = new ACProxy( this,
stts.getUserParameter("host"),
Integer.parseInt(stts.getUserParameter("port")),
username,
password);
proxy.start();
}
推荐阅读
-
实操指南:智能客服领域中的深度学习技术运用
-
实操指南:掌握Mysql行级锁的运用与避免死锁的方法
-
实操指南:Bootstrap响应式网格布局在手机、平板与桌面电脑的应用示例
-
实操演示:Java BaseResponse类的第四个应用场景——onResponse方法示例
-
实操示例:在Java中运用ChannelMatcher类
-
实操示例:在Java中运用WebSocketClientProtocolHandler类
-
实战Go语言中SHA-512的运用:性能提升与安全实操指南
-
实操指南:在浏览器内运用ImageMagick的WebAssembly技术
-
实操演示:Java中Cosine相似度计算类的运用示例
-
实操指南:Java ESAPI类的运用案例