Commit 14cc3509 authored by Thibaut Démare's avatar Thibaut Démare

Add the 'wait step' command

parent d9ce2b19
package org.graphstream.gama.extension.receiver;
import msi.gama.common.interfaces.IKeyword;
import msi.gama.precompiler.ISymbolKind;
import msi.gama.precompiler.GamlAnnotations.facet;
import msi.gama.precompiler.GamlAnnotations.facets;
import msi.gama.precompiler.GamlAnnotations.inside;
import msi.gama.precompiler.GamlAnnotations.symbol;
import msi.gama.runtime.IScope;
import msi.gama.runtime.exceptions.GamaRuntimeException;
import msi.gaml.descriptions.IDescription;
import msi.gaml.expressions.IExpression;
import msi.gaml.statements.AbstractStatement;
import msi.gaml.statements.IStatement;
import msi.gaml.types.IType;
import org.graphstream.gama.extension.GSManager;
import org.graphstream.gama.extension.IKeywordGSAdditional;
@symbol(name = IKeywordGSAdditional.WAIT_STEP, kind = ISymbolKind.SINGLE_STATEMENT, with_sequence = false)
@inside(kinds = { ISymbolKind.BEHAVIOR, ISymbolKind.SINGLE_STATEMENT })
@facets(value = { @facet(name = IKeywordGSAdditional.RECEIVERID, type = IType.STRING, optional = false),
@facet(name = IKeyword.RETURN, type = IType.NEW_TEMP_ID, optional = false)})
public class WaitStepStatement extends AbstractStatement implements IStatement{
final IExpression receiverid;
final String returnVal;
public WaitStepStatement(IDescription desc) {
super(desc);
receiverid = getFacet(IKeywordGSAdditional.RECEIVERID);
returnVal = getLiteral(IKeyword.RETURN);
}
@Override
protected Object privateExecuteIn(IScope scope) throws GamaRuntimeException {
String r = (String)(receiverid.value(scope));
GSReceiver receiver = GSManager.getReceiver(r);
Double step = receiver.waitStep();
// and we return the attribute list
scope.setVarValue(returnVal, step);
return step;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment