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

io.github.agentsoz.abmjack.env.GenericActionStateCursor Maven / Gradle / Ivy

Go to download

Allows the use of JACK (aosgrp.com/products/jack) as the underlying BDI system

There is a newer version: 2.0.1
Show newest version
package io.github.agentsoz.abmjack.env;

/*
 * #%L
 * BDI-ABM Integration Package
 * %%
 * Copyright (C) 2014 - 2015 by its authors. See AUTHORS file.
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */
import aos.jack.util.cursor.Change;
import io.github.agentsoz.bdiabm.data.ActionContent.State;

/**
 * 
 * @author Alex Lutman
 *
 */
public class GenericActionStateCursor extends Change {
    private ActionList actionData;
	private String actionID;

    public GenericActionStateCursor(ActionList actionData, String actionID){
        super(actionData, false);
		this.actionData = actionData;
		this.actionID = actionID;
		actionData.insert(actionID, State.INITIATED, null);
	}

	public boolean condition() {
		//keep waiting until the action's state is neither INITIATED or RUNNING
		State s = actionData.getState(actionID);
		if(s == null) {
			return false;
		}
		if(s.equals(State.INITIATED)) {
			return false;
		}
		else if(s.equals(State.RUNNING)) {
			return false;
		}
		return true;
		
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy