Constructor
new Commander(optionsopt)
- Source:
Creates a new Commander instance.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Commander options. Properties
|
Members
commandNames :Array.<string>
- Source:
All supported command names.
Type:
- Array.<string>
commands :object.<string, commands.Command>
- Source:
All supported commands indexed by their names.
Type:
- object.<string, commands.Command>
Methods
(static) multi(optionsopt) → {Commander}
- Source:
Factory for a Commander that deals with multiple physical traffic lights. It will greedily get all available traffic lights for use.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Commander options. Properties
|
Returns:
A multiple traffic lights commander.
- Type
- Commander
(static) single(optionsopt) → {Commander}
- Source:
Factory for a Commander that deals with a single physical traffic light. It will get the first available traffic light for use.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Commander options. Properties
|
Returns:
A single traffic light commander.
- Type
- Commander
cancel()
- Source:
Cancels any currently executing command.
close()
- Source:
Called to close this instance. Should be done as the last operation before exiting the process.
help(commandName)
- Source:
Logs the help info for the given command name.
Parameters:
Name | Type | Description |
---|---|---|
commandName |
string | Name of the command to log help info. |
logInfo()
- Source:
Logs information about known traffic lights.
(async) run(command, resetopt)
- Source:
Executes a command asynchronously.
If the same command is already running, does nothing.
If another command is running, cancels it, resets the traffic light,
and runs the new command.
If no command is running, executes the given command, optionally
resetting the traffic light based on the reset
parameter.
If there's no traffic light to run the command, stores it for later when
one becomes available. Logs messages appropriately.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
command |
string | Command to execute. |
||
reset |
boolean |
<optional> |
false
|
Whether to reset the traffic light before executing the command. |
(async) runDefinitions(command)
- Source:
Executes a command with definitions asynchronously.
Parameters:
Name | Type | Description |
---|---|---|
command |
string | Command to execute. Should only contain command
definitions ( |
(async) runDefinitionsFile(filePath, encodingopt)
- Source:
Executes a file with command definitions asynchronously.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
filePath |
string | Path to the file to execute.
Should only contain command definitions ( |
||
encoding |
string |
<optional> |
'utf8'
|
Encoding of the file. |
(async) runFile(filePath, resetopt, encodingopt)
- Source:
Executes a command file asynchronously.
If the same command is already running, does nothing.
If another command is running, cancels it, resets the traffic light,
and runs the new command.
If no command is running, executes the given command, optionally
resetting the traffic light based on the reset
parameter.
If there's no traffic light to run the command, stores it for later when
one becomes available. Logs messages appropriately.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
filePath |
string | Path to the file to execute. |
||
reset |
boolean |
<optional> |
false
|
Whether to reset the traffic light before executing the command. |
encoding |
string |
<optional> |
'utf8'
|
Encoding of the file. |