Class ProtelisDevice
-
- All Implemented Interfaces:
-
it.unibo.alchemist.model.NodeProperty
,java.io.Serializable
,org.protelis.lang.datatype.DeviceUID
,org.protelis.vm.ExecutionEnvironment
public final class ProtelisDevice<P extends Position<P>> implements NodeProperty<Any>, ExecutionEnvironment, DeviceUID
Base implementation of ProtelisDevice. Requires an environment to work.
-
-
Field Summary
Fields Modifier and Type Field Description private final Integer
id
private final Map<RunProtelisProgram<?>, AlchemistNetworkManager>
networkManagers
private final Environment<Object, P>
environment
private final Node<Object>
node
-
Constructor Summary
Constructors Constructor Description ProtelisDevice(Environment<Object, P> environment, Node<Object> node, Map<RunProtelisProgram<?>, AlchemistNetworkManager> networkManagers)
ProtelisDevice(Environment<Object, P> environment, Node<Object> node)
-
Method Summary
Modifier and Type Method Description final Integer
getId()
final Map<RunProtelisProgram<?>, AlchemistNetworkManager>
getNetworkManagers()
All the AlchemistNetworkManagers in this node. final Environment<Object, P>
getEnvironment()
Node<Object>
getNode()
final Unit
addNetworkManger(RunProtelisProgram<?> program, AlchemistNetworkManager networkManager)
Adds a new AlchemistNetworkManager. final List<RunProtelisProgram<?>>
allProtelisPrograms()
Finds all the RunProtelisPrograms installed on this node. ProtelisDevice<P>
cloneOnNewNode(Node<Object> node)
Object
get(String id)
Returns the value associated with id. Object
get(String id, Object defaultValue)
Returns the value associated with id. final AlchemistNetworkManager
getNetworkManager(RunProtelisProgram<?> program)
Boolean
has(String id)
Returns true if node contains id. Boolean
put(String key, Object value)
Stores a value associated with key. final Boolean
putField(String key, Field<?> value)
Stores a value associated with key. Object
remove(String id)
Removes the value associated with id. Set<String>
keySet()
Return all stored variables names. Unit
commit()
Called just after the VM is executed, to finalize information of the execution for the environment. Unit
setup()
Called just before the VM is executed, to enable and preparations needed in the environment. String
toString()
-
-
Constructor Detail
-
ProtelisDevice
ProtelisDevice(Environment<Object, P> environment, Node<Object> node, Map<RunProtelisProgram<?>, AlchemistNetworkManager> networkManagers)
-
ProtelisDevice
ProtelisDevice(Environment<Object, P> environment, Node<Object> node)
-
-
Method Detail
-
getNetworkManagers
final Map<RunProtelisProgram<?>, AlchemistNetworkManager> getNetworkManagers()
All the AlchemistNetworkManagers in this node.
-
getEnvironment
final Environment<Object, P> getEnvironment()
-
addNetworkManger
final Unit addNetworkManger(RunProtelisProgram<?> program, AlchemistNetworkManager networkManager)
Adds a new AlchemistNetworkManager.
- Parameters:
program
- the RunProtelisProgramnetworkManager
- the AlchemistNetworkManager
-
allProtelisPrograms
final List<RunProtelisProgram<?>> allProtelisPrograms()
Finds all the RunProtelisPrograms installed on this node.
-
cloneOnNewNode
ProtelisDevice<P> cloneOnNewNode(Node<Object> node)
-
getNetworkManager
final AlchemistNetworkManager getNetworkManager(RunProtelisProgram<?> program)
- Parameters:
program
- the RunProtelisProgram- Returns:
the AlchemistNetworkManager for this specific RunProtelisProgram
-
commit
Unit commit()
Called just after the VM is executed, to finalize information of the execution for the environment.
-
setup
Unit setup()
Called just before the VM is executed, to enable and preparations needed in the environment.
-
-
-
-