
io.github.agentsoz.bushfire.jack.plans.PlanAreasP Maven / Gradle / Ivy
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
This code is generated by JAC version 5.6 by
Agent Oriented Software. http://www.agent-software.com.au
DO NOT ALTER THIS CODE AND DO NOT REMOVE THIS COMMENT
*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
package io.github.agentsoz.bushfire.jack.plans;
import aos.jack.jak.plan.Plan;
import aos.jack.jak.plan.PlanFSM;
import aos.jack.jak.plan.ExMap;
import aos.jack.jak.agent.NameSpace;
import aos.jack.jak.event.Event;
import aos.jack.jak.task.Task;
import aos.jack.jak.core.Generator;
import aos.jack.jak.logic.Signature;
import io.github.agentsoz.bushfire.jack.events.PlanAllAreasG;
import io.github.agentsoz.bushfire.jack.events.DoScheduleG;
import io.github.agentsoz.bushfire.jack.events.Decide_shelterG;
import io.github.agentsoz.bushfire.jack.events.Decide_routeG;
import io.github.agentsoz.bushfire.jack.events.Calc_viable_sheltersG;
import io.github.agentsoz.bushfire.jack.agents.EvacController;
import io.github.agentsoz.bushfire.jack.data.Areas;
import org.slf4j.Logger;
import java.util.List;
import java.lang.Object;
import aos.jack.jak.cursor.Cursor;
import aos.jack.jak.fsm.FSM;
import org.slf4j.LoggerFactory;
import aos.jack.jak.core.Jak;
/**
* @author Sewwandi Perera
*/
public class PlanAreasP extends aos.jack.jak.plan.Plan {
final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger("");
public io.github.agentsoz.bushfire.jack.events.PlanAllAreasG ev;
public io.github.agentsoz.bushfire.jack.events.DoScheduleG p_DoScheduleG;
public io.github.agentsoz.bushfire.jack.events.Decide_shelterG p_Decide_shelterG;
public io.github.agentsoz.bushfire.jack.events.Decide_routeG p_Decide_routeG;
public io.github.agentsoz.bushfire.jack.events.Calc_viable_sheltersG p_Calc_viable_sheltersG;
public io.github.agentsoz.bushfire.jack.agents.EvacController enc;
public io.github.agentsoz.bushfire.jack.data.Areas areas;
private static aos.jack.jak.plan.ExMap[] __exMap_body;
private static java.lang.String[] __tt__body = {
"io/github/agentsoz/bushfire/jack/plans/PlanAreasP.plan",
"body",
"50",
"51",
"54",
"56",
"56",
"57",
"58",
"56",
"61",
"47"};
private final static java.lang.String[] __planVariableNames = {
"logger",
"ev",
"p_DoScheduleG",
"p_Decide_shelterG",
"p_Decide_routeG",
"p_Calc_viable_sheltersG",
"enc",
"areas"};
private final static java.lang.String[] __planVariableTypes = {
"org.slf4j.Logger",
"PlanAllAreasG",
"io.github.agentsoz.bushfire.jack.events.DoScheduleG",
"io.github.agentsoz.bushfire.jack.events.Decide_shelterG",
"io.github.agentsoz.bushfire.jack.events.Decide_routeG",
"io.github.agentsoz.bushfire.jack.events.Calc_viable_sheltersG",
"EvacController",
"io.github.agentsoz.bushfire.jack.data.Areas"};
private final static java.lang.String[] __reasoningMethods = {
"body"};
private final static java.lang.String[] __fsmVariableNames_body = {
"areaNames",
"i"};
private final static java.lang.String[] __fsmTypes_body = {
"List",
"int"};
private final static java.lang.String[] __fsmLocalNames_body = {
"__local__21_0",
"__local__21_1"};
static boolean relevant(io.github.agentsoz.bushfire.jack.events.PlanAllAreasG ev)
{
return true;
}
public java.lang.String getDocumentation()
{
return "/**\n * @author Sewwandi Perera\n */\n";
}
public PlanAreasP()
{
}
private PlanAreasP(aos.jack.jak.task.Task __t, io.github.agentsoz.bushfire.jack.plans.PlanAreasP __env)
{
__agent = __env.__agent;
__ns = __env.__ns;
__planTask = __t;
__logic = __t.logic;
ev = __env.ev;
p_DoScheduleG = __env.p_DoScheduleG;
p_Decide_shelterG = __env.p_Decide_shelterG;
p_Decide_routeG = __env.p_Decide_routeG;
p_Calc_viable_sheltersG = __env.p_Calc_viable_sheltersG;
enc = (io.github.agentsoz.bushfire.jack.agents.EvacController) __ns.getIF(io.github.agentsoz.bushfire.jack.agents.EvacController.class);
areas = __env.areas;
}
public boolean init_sentinel(aos.jack.jak.agent.NameSpace __a)
{
ev = (io.github.agentsoz.bushfire.jack.events.PlanAllAreasG) __a.findEvent("io.github.agentsoz.bushfire.jack.events.PlanAllAreasG");
if (ev == null) {
warning("PlanAllAreasG ev: is not found in the capability/agent this plan comes from");
return false;
}
p_DoScheduleG = (io.github.agentsoz.bushfire.jack.events.DoScheduleG) __a.findEvent("io.github.agentsoz.bushfire.jack.events.DoScheduleG");
if (p_DoScheduleG == null) {
warning("DoScheduleG p_DoScheduleG: is not found in the capability/agent this plan comes from");
return false;
}
p_Decide_shelterG = (io.github.agentsoz.bushfire.jack.events.Decide_shelterG) __a.findEvent("io.github.agentsoz.bushfire.jack.events.Decide_shelterG");
if (p_Decide_shelterG == null) {
warning("Decide_shelterG p_Decide_shelterG: is not found in the capability/agent this plan comes from");
return false;
}
p_Decide_routeG = (io.github.agentsoz.bushfire.jack.events.Decide_routeG) __a.findEvent("io.github.agentsoz.bushfire.jack.events.Decide_routeG");
if (p_Decide_routeG == null) {
warning("Decide_routeG p_Decide_routeG: is not found in the capability/agent this plan comes from");
return false;
}
p_Calc_viable_sheltersG = (io.github.agentsoz.bushfire.jack.events.Calc_viable_sheltersG) __a.findEvent("io.github.agentsoz.bushfire.jack.events.Calc_viable_sheltersG");
if (p_Calc_viable_sheltersG == null) {
warning("Calc_viable_sheltersG p_Calc_viable_sheltersG: is not found in the capability/agent this plan comes from");
return false;
}
areas = (io.github.agentsoz.bushfire.jack.data.Areas) lookupNamedObject("areas","io.github.agentsoz.bushfire.jack.data.Areas",0);
if (areas == null) {
warning("Areas areas: is not found in the capability/agent this plan comes from");
return false;
}
return true;
}
public aos.jack.jak.plan.Plan freeze()
{
return this;
}
public aos.jack.jak.plan.Plan unfreeze()
{
return this;
}
public java.lang.Object genObject(int __index)
{
switch (__index) {
}
aos.jack.jak.core.Jak.error("illegal Object Construction");
return null;
}
public aos.jack.jak.cursor.Cursor genCursor(int __index)
throws java.lang.Exception
{
switch (__index) {
}
aos.jack.jak.core.Jak.error("illegal Cursor Construction");
return null;
}
public aos.jack.jak.fsm.FSM genFSM(int __index)
throws java.lang.Exception
{
switch (__index) {
}
aos.jack.jak.core.Jak.error("illegal FSM Construction");
return null;
}
public boolean testCondition(int __index)
throws java.lang.Exception
{
switch (__index) {
}
aos.jack.jak.core.Jak.error("illegal test Construction");
return false;
}
public aos.jack.jak.plan.PlanFSM body()
{
return new io.github.agentsoz.bushfire.jack.plans.PlanAreasP.__bodyFSM();
}
private PlanAreasP(io.github.agentsoz.bushfire.jack.events.PlanAllAreasG __ev, aos.jack.jak.task.Task __t, io.github.agentsoz.bushfire.jack.plans.PlanAreasP __env)
{
this(__t,__env);
this.ev = __ev;
}
protected aos.jack.jak.logic.Signature eventSignature(int __log)
{
return ev.getSignature(__log);
}
public java.lang.String handledEvent()
{
return "io.github.agentsoz.bushfire.jack.events.PlanAllAreasG";
}
public boolean __relevant(aos.jack.jak.event.Event __e)
{
return __ns.isEnabled() && relevant(((io.github.agentsoz.bushfire.jack.events.PlanAllAreasG) __e));
}
public aos.jack.jak.plan.Plan createPlan(aos.jack.jak.event.Event __e, aos.jack.jak.task.Task __t)
{
if (!(__e instanceof io.github.agentsoz.bushfire.jack.events.PlanAllAreasG))
return null;
io.github.agentsoz.bushfire.jack.events.PlanAllAreasG __e1 = (io.github.agentsoz.bushfire.jack.events.PlanAllAreasG) __e;
return new io.github.agentsoz.bushfire.jack.plans.PlanAreasP(__e1,__t,this);
}
public java.lang.String[] variableNames()
{
return __planVariableNames;
}
public java.lang.String[] variableTypes()
{
return __planVariableTypes;
}
public java.lang.Object getVariable(int n)
{
switch (n) {
case 0:
{
return aos.util.ToObject.box(logger);
}
case 1:
{
return aos.util.ToObject.box(ev);
}
case 2:
{
return aos.util.ToObject.box(p_DoScheduleG);
}
case 3:
{
return aos.util.ToObject.box(p_Decide_shelterG);
}
case 4:
{
return aos.util.ToObject.box(p_Decide_routeG);
}
case 5:
{
return aos.util.ToObject.box(p_Calc_viable_sheltersG);
}
case 6:
{
return aos.util.ToObject.box(enc);
}
case 7:
{
return aos.util.ToObject.box(areas);
}
default:
{
throw new java.lang.IndexOutOfBoundsException("Plan " + this + " does not have variable number " + n);
}
}
}
public java.lang.String[] reasoningMethods()
{
return mergeReasoningMethods(__reasoningMethods,super.reasoningMethods());
}
public aos.jack.jak.cursor.Cursor context()
{
try {
return (((true)?aos.jack.jak.cursor.Cursor.trueCursor:aos.jack.jak.cursor.Cursor.falseCursor));
}
catch (java.lang.Exception e) {
e.printStackTrace();
return aos.jack.jak.cursor.Cursor.falseCursor;
}
}
class __bodyFSM extends aos.jack.jak.plan.PlanFSM implements aos.jack.jak.core.Generator {
java.util.List __local__21_0;
int __local__21_1;
private int __breakLevel = 0;
public int run(int __status)
throws java.lang.Throwable
{
do {
try {
if (__tothrow != null)
throw __tothrow;
if ((aos.jack.jak.core.Jak.debugging & aos.jack.jak.core.Jak.LOG_PLANS) != 0)
aos.util.logging.LogMsg.log(this,aos.jack.jak.core.Jak.LOG_PLANS,__task + "-PlanAreasP.body:" + java.lang.Integer.toString(__state));
if (__task.nsteps > 0) {
__task.nsteps-- ;
if (__task.nsteps == 0)
agent.changeFocus();
}
if (__state < 10) {
__status = super.stdrun(io.github.agentsoz.bushfire.jack.plans.PlanAreasP.this,__status);
if (__status != CONTINUE || agent.changing_focus)
return __status;
continue;
}
__curstate = __state;
switch (__state) {
default:
{
aos.jack.jak.core.Jak.error("PlanAreasP.body: Illegal state");
return FAILED_STATE;
}
//* (50) logger.trace("PlanAreasP is initiated");
case 10:
{
__breakLevel = 0;
__state = 11;
logger.trace("PlanAreasP is initiated");
break;
}
//* (51) @subtask(p_Calc_viable_sheltersG.post());
case 11:
{
__task.push(p_Calc_viable_sheltersG.post());
__state = -__state;
__subtask_pass = 12;
__subtask_fail = 4;
return SUBTASK;
}
//* (54) List areaNames = areas.getAllAreaNames();
case 12:
{
__local__21_0 = areas.getAllAreaNames();
__state = 13;
break;
}
//* (56) for(int i = 0 ; i < areaNames.size() ; i++){
case 13:
{
__local__21_1 = 0;
__state = 14;
break;
}
//* (56) for(int i = 0 ; i < areaNames.size() ; i++){
case 14:
{
if (__local__21_1 < __local__21_0.size())
__state = 15;
else
__state = 18;
break;
}
//* (57) @subtask(p_Decide_shelterG.post(areaNames.get(i).toString()));
case 15:
{
__breakLevel = 4;
__task.push(p_Decide_shelterG.post(__local__21_0.get(__local__21_1).toString()));
__state = -__state;
__subtask_pass = 16;
__subtask_fail = 4;
return SUBTASK;
}
//* (58) @subtask(p_Decide_routeG.post(areaNames.get(i).toString()));
case 16:
{
__task.push(p_Decide_routeG.post(__local__21_0.get(__local__21_1).toString()));
__state = -__state;
__subtask_pass = 17;
__subtask_fail = 4;
return SUBTASK;
}
//* (56) for(int i = 0 ; i < areaNames.size() ; i++){
case 17:
{
__state = 14;
__local__21_1++ ;
break;
}
//* (61) @subtask(p_DoScheduleG.post());
case 18:
{
__task.push(p_DoScheduleG.post());
__state = -__state;
__subtask_pass = 19;
__subtask_fail = 4;
return SUBTASK;
}
//* (47) #reasoning method
case 19:
{
if (__pending == null)
__state = PASSED_STATE;
__tothrow = __pending;
break;
}
}
}
catch (java.lang.Throwable e) {
handleException(e,__exMap_body);
}
}
while (!agent.changing_focus);
return CONTINUE;
}
public java.lang.String methodName()
{
return "body";
}
__bodyFSM()
{
}
public java.lang.String stateInfo()
{
int n = __curstate;
java.lang.String file = __tt__body[0];
java.lang.String method = __tt__body[1];
if (n < 0)
n = -n;
n -= (10 - 2);
java.lang.String line = (n < 2)?"??":__tt__body[n];
return file + ":" + line + " " + method + " [" + __curstate + "]";
}
public java.lang.Object genObject(int __index)
{
switch (__index) {
}
aos.jack.jak.core.Jak.error("illegal Object Construction");
return null;
}
public aos.jack.jak.cursor.Cursor genCursor(int __index)
throws java.lang.Exception
{
switch (__index) {
}
aos.jack.jak.core.Jak.error("illegal Cursor Construction");
return null;
}
public aos.jack.jak.fsm.FSM genFSM(int __index)
throws java.lang.Exception
{
switch (__index) {
}
aos.jack.jak.core.Jak.error("illegal FSM Construction");
return null;
}
public boolean testCondition(int __index)
throws java.lang.Exception
{
switch (__index) {
}
aos.jack.jak.core.Jak.error("illegal test Construction");
return false;
}
public aos.jack.jak.plan.Plan getPlan()
{
return io.github.agentsoz.bushfire.jack.plans.PlanAreasP.this;
}
protected aos.jack.jak.fsm.FSM fail()
{
return getPlan().fail();
}
protected aos.jack.jak.fsm.FSM pass()
{
return getPlan().pass();
}
public void enter()
{
__trace = agent.trace("io.github.agentsoz.bushfire.jack.plans.PlanAreasP.body");
}
public java.lang.Object getVariable(int n)
{
switch (n) {
case 0:
{
return aos.util.ToObject.box(__local__21_0);
}
case 1:
{
return aos.util.ToObject.box(__local__21_1);
}
default:
{
throw new java.lang.IndexOutOfBoundsException("Reasoning Method " + methodName() + " does not have variable number " + n);
}
}
}
public java.lang.String[] variableNames()
{
return __fsmVariableNames_body;
}
public java.lang.String[] variableTypes()
{
return __fsmTypes_body;
}
public java.lang.String[] variableLocalNames()
{
return __fsmLocalNames_body;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy