All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scenarioTWO.plans.AlreadyPreparedP Maven / Gradle / Ivy

The newest version!
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  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 scenarioTWO.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 scenarioTWO.events.EvacAlert;
import scenarioTWO.agents.EvacResident;
import java.lang.Object;
import aos.jack.jak.cursor.Cursor;
import aos.jack.jak.fsm.FSM;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import aos.jack.jak.core.Jak;

public class AlreadyPreparedP extends aos.jack.jak.plan.Plan {
    final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger("");
    public scenarioTWO.events.EvacAlert evacalert_h;
    public scenarioTWO.agents.EvacResident evac_res;
    private static aos.jack.jak.plan.ExMap[] __exMap_body;
    private static java.lang.String[] __tt__body = {
            "scenarioTWO/plans/AlreadyPreparedP.plan",
            "body",
            "40",
            "38"};
    private final static java.lang.String[] __planVariableNames = {
            "logger",
            "evacalert_h",
            "evac_res"};
    private final static java.lang.String[] __planVariableTypes = {
            "Logger",
            "EvacAlert",
            "scenarioTWO.agents.EvacResident"};
    private final static java.lang.String[] __reasoningMethods = {
            "body"};
    public AlreadyPreparedP()
    {
    }
    
    private AlreadyPreparedP(aos.jack.jak.task.Task __t, scenarioTWO.plans.AlreadyPreparedP __env)
    {
        __agent = __env.__agent;
        __ns = __env.__ns;
        __planTask = __t;
        __logic = __t.logic;
        evacalert_h = __env.evacalert_h;
        evac_res = (scenarioTWO.agents.EvacResident) __ns.getIF(scenarioTWO.agents.EvacResident.class);
    }
    
    public boolean init_sentinel(aos.jack.jak.agent.NameSpace __a)
    {
        evacalert_h = (scenarioTWO.events.EvacAlert) __a.findEvent("scenarioTWO.events.EvacAlert");
        if (evacalert_h == null) {
            warning("EvacAlert evacalert_h: 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 scenarioTWO.plans.AlreadyPreparedP.__bodyFSM();
    }
    
    private AlreadyPreparedP(scenarioTWO.events.EvacAlert __ev, aos.jack.jak.task.Task __t, scenarioTWO.plans.AlreadyPreparedP __env)
    {
        this(__t,__env);
        this.evacalert_h = __ev;
    }
    
    protected aos.jack.jak.logic.Signature eventSignature(int __log)
    {
        return evacalert_h.getSignature(__log);
    }
    
    public java.lang.String handledEvent()
    {
        return "scenarioTWO.events.EvacAlert";
    }
    
    public boolean __relevant(aos.jack.jak.event.Event __e)
    {
        return __ns.isEnabled();
    }
    
    public aos.jack.jak.plan.Plan createPlan(aos.jack.jak.event.Event __e, aos.jack.jak.task.Task __t)
    {
        if (!(__e instanceof scenarioTWO.events.EvacAlert)) 
            return null;
        scenarioTWO.events.EvacAlert __e1 = (scenarioTWO.events.EvacAlert) __e;
        return new scenarioTWO.plans.AlreadyPreparedP(__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(evacalert_h);
            }
            case 2: 
            {
                return aos.util.ToObject.box(evac_res);
            }
            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 (((evac_res.kidsNeedPickUp == false && evac_res.relsNeedPickUp == false)?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 {
        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 + "-AlreadyPreparedP.body:" + java.lang.Integer.toString(__state));
                    if (__task.nsteps > 0) {
                        __task.nsteps-- ;
                        if (__task.nsteps == 0) 
                            agent.changeFocus();
                    }
                    if (__state < 10) {
                        __status = super.stdrun(scenarioTWO.plans.AlreadyPreparedP.this,__status);
                        if (__status != CONTINUE || agent.changing_focus) 
                            return __status;
                        continue;
                    }
                    __curstate = __state;
                    switch (__state) {
                        default: 
                        {
                            aos.jack.jak.core.Jak.error("AlreadyPreparedP.body: Illegal state");
                            return FAILED_STATE;
                        }
                        //* (40) 			evac_res.log("already prepared to evacuate at departure time");
                        case 10: 
                        {
                            __breakLevel = 0;
                            __state = 11;
                            evac_res.log("already prepared to evacuate at departure time");
                            break;
                        }
                        //* (38) 	body()
                        case 11: 
                        {
                            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 scenarioTWO.plans.AlreadyPreparedP.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("scenarioTWO.plans.AlreadyPreparedP.body");
        }
        
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy