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

jadex.micro.testcases.nfproperties.FakeFreeMemoryProperty 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.testcases.nfproperties;

import jadex.bridge.nonfunctional.AbstractNFProperty;
import jadex.bridge.nonfunctional.NFPropertyMetaInfo;
import jadex.bridge.sensor.unit.MemoryUnit;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;

/**
 *  Property simulating a random amount of free memory.
 *
 */
public class FakeFreeMemoryProperty extends AbstractNFProperty
{
	/**
	 * Creates the property.
	 */
	public FakeFreeMemoryProperty()
	{
		super(new NFPropertyMetaInfo("fakefreemem", Long.class, MemoryUnit.class, true, 3000, true, null));
	}
	
	/**
	 *  Returns the property value.
	 */
	public IFuture getValue(MemoryUnit unit)
	{
		long ret = (long) Math.round(Math.random() * 17179869184.0);
		if(unit!=null)
		{
			ret = unit.convert(ret);
		}
		
		return new Future(ret);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy