Class AlchemistExecutionContext
-
- 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<S> implements SpatiallyEmbeddedDevice<D>, LocalizedDevice, TimeAwareDevice<D>
-
-
Field Summary
Fields Modifier and Type Field Description public final static Molecule
USE_ROUTES_AS_DISTANCES
public final static Molecule
APPROXIMATE_NBR_RANGE
public final RandomGenerator
randomGenerator
-
Constructor Summary
Constructors Constructor Description AlchemistExecutionContext(Environment<Object, P> environment, Node<Object> localNode, Reaction<Object> reaction, RandomGenerator random, AlchemistNetworkManager networkManager)
AlchemistExecutionContext(Environment<Object, P> environment, Node<Object> localNode, ProtelisDevice<P> protelisDevice, Reaction<Object> reaction, RandomGenerator random, AlchemistNetworkManager networkManager)
-
Method Summary
Modifier and Type Method Description RandomGenerator
getRandomGenerator()
double
distanceTo(DeviceUID target)
Computes the distance between two nodes, through getDistanceBetweenNodes. double
distanceTo(int target)
Computes the distance between two nodes, through getDistanceBetweenNodes. boolean
equals(Object obj)
Tuple
getCoordinates()
Number
getCurrentTime()
P
getDevicePosition()
DeviceUID
getDeviceUID()
Environment<Object, P>
getEnvironmentAccess()
int
hashCode()
Field<Number>
nbrDelay()
Field<Number>
nbrLag()
Field<Double>
nbrRange()
Field<Tuple>
nbrVector()
double
nextRandomDouble()
double
routingDistance(Node<Object> dest)
Computes the distance along a map. double
routingDistance(Number dest)
Computes the distance along a map. double
routingDistance(GeoPosition dest)
Computes the distance along a map. double
routingDistance(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
getPersistent, 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, Node<Object> localNode, Reaction<Object> reaction, RandomGenerator random, AlchemistNetworkManager networkManager)
- Parameters:
environment
- the simulation EnvironmentlocalNode
- the local Nodereaction
- the Reaction hosting the programrandom
- the RandomGenerator for this simulationnetworkManager
- the AlchemistNetworkManager to be used
-
AlchemistExecutionContext
AlchemistExecutionContext(Environment<Object, P> environment, Node<Object> localNode, ProtelisDevice<P> protelisDevice, Reaction<Object> reaction, RandomGenerator random, AlchemistNetworkManager networkManager)
- Parameters:
environment
- the simulation EnvironmentlocalNode
- the local NodeprotelisDevice
- the local ProtelisDevicereaction
- the Reaction hosting the programrandom
- the RandomGenerator for this simulationnetworkManager
- the AlchemistNetworkManager to be used
-
-
Method Detail
-
getRandomGenerator
RandomGenerator getRandomGenerator()
- Returns:
the internal RandomGenerator
-
distanceTo
double distanceTo(DeviceUID target)
Computes the distance between two nodes, through getDistanceBetweenNodes.
- Parameters:
target
- the target device- Returns:
the distance
-
distanceTo
double distanceTo(int target)
Computes the distance between two nodes, through getDistanceBetweenNodes.
- Parameters:
target
- the target device- Returns:
the distance
-
getCoordinates
Tuple getCoordinates()
-
getCurrentTime
Number getCurrentTime()
-
getDevicePosition
P getDevicePosition()
- Returns:
the device position, in form of Position
-
getDeviceUID
DeviceUID getDeviceUID()
-
getEnvironmentAccess
Environment<Object, P> getEnvironmentAccess()
- Returns:
experimental access to the simulated environment, for building oracles
-
hashCode
int hashCode()
-
nbrDelay
Field<Number> nbrDelay()
- Returns:
The same behavior of MIT Proto's nbrdelay (forward view).
-
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- Returns:
the distance on a map
-
routingDistance
double routingDistance(Number dest)
Computes the distance along a map. Requires a MapEnvironment.
- Parameters:
dest
- the destination, in form of Node ID.- Returns:
the distance on a map
-
routingDistance
double routingDistance(GeoPosition dest)
Computes the distance along a map. Requires a MapEnvironment.
- Parameters:
dest
- the destination- Returns:
the distance on a map
-
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]- Returns:
the distance on a map
-
-
-
-