-
- All Implemented Interfaces:
-
org.protelis.vm.ExecutionContext,org.protelis.vm.LocalizedDevice,org.protelis.vm.SpatiallyEmbeddedDevice,org.protelis.vm.TimeAwareDevice
public final class AlchemistExecutionContext<P extends Position<P>> extends AbstractExecutionContext<AlchemistExecutionContext<P>> implements SpatiallyEmbeddedDevice<Double>, LocalizedDevice, TimeAwareDevice
-
-
Field Summary
Fields Modifier and Type Field Description public final static MoleculeUSE_ROUTES_AS_DISTANCESpublic final static MoleculeAPPROXIMATE_NBR_RANGEprivate final RandomGeneratorrandomGenerator
-
Constructor Summary
Constructors Constructor Description AlchemistExecutionContext(Environment<Object, P> environment, ProtelisNode<P> localNode, Reaction<Object> reaction, RandomGenerator random, AlchemistNetworkManager networkManager)
-
Method Summary
Modifier and Type Method Description RandomGeneratorgetRandomGenerator()doubledistanceTo(DeviceUID target)Computes the distance between two nodes, through getDistanceBetweenNodes. doubledistanceTo(int target)Computes the distance between two nodes, through getDistanceBetweenNodes. booleanequals(Object obj)TuplegetCoordinates()NumbergetCurrentTime()PgetDevicePosition()DeviceUIDgetDeviceUID()Environment<Object, P>getEnvironmentAccess()inthashCode()Field<Number>nbrDelay()Field<Double>nbrLag()Field<Double>nbrRange()Field<Tuple>nbrVector()doublenextRandomDouble()doubleroutingDistance(Node<Object> dest)Computes the distance along a map. doubleroutingDistance(Number dest)Computes the distance along a map. doubleroutingDistance(GeoPosition dest)Computes the distance along a map. doubleroutingDistance(Tuple dest)Computes the distance along a map. -
Methods inherited from class org.protelis.vm.impl.AbstractExecutionContext
buildField, buildFieldDeferred, commit, getDeltaTime, getExecutionEnvironment, getPersistent, getStoredState, getVariable, newCallStackFrame, putMultipleVariables, putVariable, restrictDomain, returnFromCallFrame, runInNewStackFrame, setGloballyAvailableReferences, setPersistent, setup -
Methods inherited from class org.protelis.vm.ExecutionContext
restrictDomain -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
AlchemistExecutionContext
AlchemistExecutionContext(Environment<Object, P> environment, ProtelisNode<P> localNode, Reaction<Object> reaction, RandomGenerator random, AlchemistNetworkManager networkManager)
- Parameters:
environment- the simulation EnvironmentlocalNode- the local ProtelisNodereaction- the Reaction hosting the programrandom- the RandomGenerator for this simulationnetworkManager- the AlchemistNetworkManager to be used
-
-
Method Detail
-
getRandomGenerator
RandomGenerator getRandomGenerator()
-
distanceTo
double distanceTo(DeviceUID target)
Computes the distance between two nodes, through getDistanceBetweenNodes.
- Parameters:
target- the target device
-
distanceTo
double distanceTo(int target)
Computes the distance between two nodes, through getDistanceBetweenNodes.
- Parameters:
target- the target device
-
getCoordinates
Tuple getCoordinates()
-
getCurrentTime
Number getCurrentTime()
-
getDevicePosition
P getDevicePosition()
-
getDeviceUID
DeviceUID getDeviceUID()
-
getEnvironmentAccess
Environment<Object, P> getEnvironmentAccess()
-
hashCode
int hashCode()
-
nbrVector
Field<Tuple> nbrVector()
-
nextRandomDouble
double nextRandomDouble()
-
routingDistance
double routingDistance(Node<Object> dest)
Computes the distance along a map. Requires a MapEnvironment.
- Parameters:
dest- the destination, in form of a destination node
-
routingDistance
double routingDistance(Number dest)
Computes the distance along a map. Requires a MapEnvironment.
- Parameters:
dest- the destination, in form of ProtelisNode ID.
-
routingDistance
double routingDistance(GeoPosition dest)
Computes the distance along a map. Requires a MapEnvironment.
- Parameters:
dest- the destination
-
routingDistance
double routingDistance(Tuple dest)
Computes the distance along a map. Requires a MapEnvironment.
- Parameters:
dest- the destination, as a Tuple of two values: [latitude, longitude]
-
-
-
-