public interface Machine extends ManagedEnvironment, Context
Machine.create(MachineHost).| Modifier and Type | Method and Description |
|---|---|
void |
addUser(java.lang.String name)
Add a player to the machine's list of users, by username.
|
Architecture |
architecture()
The underlying architecture of the machine.
|
int |
componentCount()
The number of connected components.
|
java.util.Map<java.lang.String,java.lang.String> |
components()
The list of components attached to this machine.
|
double |
cpuTime()
The time spent running the underlying architecture in execution threads,
i.e.
|
boolean |
crash(java.lang.String message)
Crashes the computer.
|
java.lang.String |
getBootAddress()
Get the address of the file system component from which to try to boot.
|
double |
getCostPerTick()
Gets the amount of energy this machine consumes per tick when it is
running.
|
MachineHost |
host()
The owner of the machine, usually a tile entity hosting the machine.
|
java.lang.Object[] |
invoke(java.lang.String address,
java.lang.String method,
java.lang.Object[] args)
Makes the machine call a component callback.
|
java.lang.Object[] |
invoke(Value value,
java.lang.String method,
java.lang.Object[] args)
Makes the machine call a value callback.
|
java.lang.String |
lastError()
A string with the last error message.
|
java.util.Map<java.lang.String,Callback> |
methods(java.lang.Object value)
Get a list of all methods and their annotations of the specified object.
|
void |
onHostChanged()
This must be called from the host when something relevant to the
machine changes, such as a change in the amount of available memory.
|
Signal |
popSignal()
Tries to pop a signal from the queue and returns it.
|
boolean |
removeUser(java.lang.String name)
Removes a player as a user from this machine, by username.
|
void |
setBootAddress(java.lang.String value)
Set the address of the file system component from which to try to boot.
|
void |
setCostPerTick(double value)
Sets the amount of energy this machine consumes per tick when it is
running.
|
java.lang.String |
tmpAddress()
The address of the file system that holds the machine's temporary files
(tmpfs).
|
double |
upTime()
The time that has passed since the machine was started, in seconds.
|
java.lang.String[] |
users()
The list of users registered on this machine.
|
long |
worldTime()
The current world time.
|
canUpdate, updatenode, onConnect, onDisconnect, onMessageload, saveMachineHost host()
void onHostChanged()
Architecture architecture()
java.lang.String getBootAddress()
void setBootAddress(java.lang.String value)
value - the new address to try to boot from.java.util.Map<java.lang.String,java.lang.String> components()
int componentCount()
components()).double getCostPerTick()
void setCostPerTick(double value)
value - the energy consumed per tick by the machine.java.lang.String tmpAddress()
java.lang.String lastError()
crash(String) method), or when it fails to start (which,
technically, is also a crash).
When the machine started, this is reset to null.long worldTime()
double upTime()
double cpuTime()
Architecture.runThreaded(boolean) since
the machine was last started, in seconds.boolean crash(java.lang.String message)
Context.stop(), except that it also
sets the error message in the machine. This message can be seen when the
Analyzer is used on computer cases, for example.message - the message to set.Signal popSignal()
java.util.Map<java.lang.String,Callback> methods(java.lang.Object value)
Value
or a Environment. This is useful for
custom architectures, to allow providing a list of callback methods to
evaluated programs.value - the value to get the method listing for.java.lang.Object[] invoke(java.lang.String address,
java.lang.String method,
java.lang.Object[] args)
throws java.lang.Exception
address - the address of the component to call the method on.method - the name of the method to call.args - the list of arguments to pass to the callback.LimitReachedException - when the called method supports direct
calling, but the number of calls in this
tick has exceeded the allowed limit.java.lang.IllegalArgumentException - if there is no such component.java.lang.Exception - if the callback throws an exception.java.lang.Object[] invoke(Value value, java.lang.String method, java.lang.Object[] args) throws java.lang.Exception
value - the value to call the method on.method - the name of the method to call.args - the list of arguments to pass to the callback.LimitReachedException - when the called method supports direct
calling, but the number of calls in this
tick has exceeded the allowed limit.java.lang.IllegalArgumentException - if there is no such component.java.lang.Exception - if the callback throws an exception.java.lang.String[] users()
Context.canInteract(String). Exposed for
informative purposes only, for example to expose it to user code. Note
that the returned array is a copy of the internal representation of the
user list. Changing it has no influence on the actual list.void addUser(java.lang.String name)
throws java.lang.Exception
name - the name of the player to add as a user.java.lang.Exception - if
boolean removeUser(java.lang.String name)
name - the name of the player to remove.