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

jadex.micro.examples.mandelbrot.ProgressService Maven / Gradle / Ivy

Go to download

The Jadex micro applications package contains several example applications, benchmarks and testcases using micro agents.

There is a newer version: 4.0.267
Show newest version
package jadex.micro.examples.mandelbrot;

import jadex.bridge.service.annotation.Service;
import jadex.bridge.service.annotation.ServiceComponent;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;

/**
 *  Progress service implementation.
 */
@Service
public class ProgressService implements IProgressService
{
	//-------- attributes --------
	
	/** The agent. */
	@ServiceComponent
	protected CalculateAgent agent;
	
	//-------- methods --------
	
	/**
	 *  Get the progress (percentage as integer) of a given task.
	 *  @param taskid	The id of the task.
	 *  @return	A future object holding the progress as a percentage integer value.
	 */
	public IFuture getProgress(Object taskid)
	{
		int	ret;
		
		// Task in progress.
		if(taskid.equals(agent.getTaskId()))
		{
//			System.out.println("progress: "+agent.getProgress());
			ret	= agent.getProgress();
		}
		
		// Task not yet started.
		else
		{
//			System.out.println("no progress: "+taskid+", "+agent.getTaskId());
			ret	= 0;
		}
		
		return new Future(Integer.valueOf(ret));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy