Ensenso::NxLibCommand

class Ensenso.NxLibCommand

This class simplifies the execution of NxLib commands. The command name must be specified on construction. The Parameters() and Result() functions provide access to the corresponding Parameters and Result nodes of the tree. The Execute() then writes the previously specified command name into the Command item and allows for synchronous and asynchronous command execution.

Public Functions

NxLibCommand (string commandName, string nodeName = "")

Constructor.

Throws NxLibException.

Param commandName

Name of the command to execute.

Param nodeName

Name of the execution slot the command should run in.

NxLibItem Parameters ()

The command’s parameters, that will be fetched before the commands executes.

Return

NxLibItem, where the parameters are stored.

NxLibItem Result ()

The command’s results, after the command finsishes, or an error in which case the results hold the error case.

Return

NxLibItem, where the results are stored.

void Execute (bool wait = true)

Executes the current command.

Throws NxLibException.

Param wait

If true, the call blocks and waits, till the execution finishes.

void Execute (out int returnCode, bool wait = true)

Executes the current command.

Param returnCode

The error code of the operation.

Param wait

If true, the call blocks and waits, till the execution finishes.

void Execute (string commandName, bool wait = true)

Executes the current command.

Throws NxLibException.

Param commandName

The command to be carried out.

Param wait

If true, the call blocks and waits, till the execution finishes.

void Execute (out int returnCode, string commandName, bool wait = true)

Executes the current command.

Param returnCode

The error code of the operation.

Param commandName

The command to be carried out.

Param wait

If true, the call blocks and waits, till the execution finishes.

bool Finished ()

Checks whether the command execution has already finished.

Throws NxLibException.

Return

True, when NxLib is not currently executing a command, i.e. the Command node is Null. False Otherwise.

bool Successful ()

Checks whether the previous command execution was successful.

Throws NxLibException.

Return

true, when the previous NxLib command execution was successful, i.e. there is no ErrorSymbol node in the Result node.Otherwise false.

Private Functions

void CheckReturnCode (int returnCode)

Checks the given returnCode and throws an NxLibException, if its value is not NxLib.OperationSucceeded.

Throws NxLibException.

Param returnCode

The returnCode, which is going to be checked for any error code value.

NxLibItem Slot ()
bool Finished (out int returnCode)

Checks whether the command execution has already finished.

Param returnCode

The error code of operation.

Return

True, when NxLib is not currently executing a command, i.e. the Command node is Null. False Otherwise.

bool Successful (out int returnCode)

Checks whether the previous command execution was successful.

Param returnCode

The error code of operation.

Return

true, when the previous NxLib command execution was successful, i.e. there is no ErrorSymbol node in the Result node.Otherwise false.

Private Members

string CommandName

Name of the command to execute.

NxLibItem CommandItem

The NxLibItem the command is executed on. SubItems take the parameters and will also give back the result of the command executed.

NxLibItemToken Token

Is used for temporary slots to keep the commandItem alive, if, for example, the execution fails.