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.
|
void |
beep(short frequency,
short duration)
Play a sound using the machine's built-in speaker.
|
void |
beep(java.lang.String pattern)
Utility method for playing beep codes.
|
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.
|
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.
|
int |
maxComponents()
The maximum number of components this machine can currently support.
|
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 |
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, savecanInteract, consumeCallBudget, isPaused, isRunning, node, pause, signal, start, stopMachineHost host()
void onHostChanged()
Architecture architecture()
java.util.Map<java.lang.String,java.lang.String> components()
int componentCount()
components()).int maxComponents()
onHostChanged().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.void beep(short frequency,
short duration)
frequency - the frequency of the tone to generate.duration - the duration of the tone to generate, in milliseconds.void beep(java.lang.String pattern)
beep(short, short),
except that this will play tones at a fixed frequency, and two different
durations - in a pattern as defined in the passed string.
This is useful for generating beep codes, such as for boot errors. It
has the advantage of only generating a single network packet, and
generating a single, longer sound sample for the full pattern. As such
the same considerations should be made as for beep(short, short),
i.e. prefer not to use overly long patterns.
The passed pattern must consist of dots (.) and dashes (-),
where a dot is short tone, and a dash is a long tone.
The audio will be played at the machine's host's location.pattern - the beep pattern to play.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.