Universal Robots Forum

IF-ELSE with XMLRPC.. generateScript method

MyNode
    └-- IF Node (user created node)
    │      └---- something...
    └-- ELSE Node (user created node)
           └---- something...

The IF node condition is a boolean value read by XML-RPC.

In installation node,

rpc_daemon = rpc_factory("xmlrpc", "http://127.0.0.1:40405/RPC2")

IF node condition is…

IF( rpc_daemon.get_selection() == true )

the return value of “get_selection()” function is boolean.

How do I implement the generateScript() function?

In my opinion…
MyNode :

public void generateScript(ScriptWriter writer) {
    writer.writeChildren();
}

IF Node:

public void generateScript(ScriptWriter writer) {
    writer.appendLine("is_selected = " + getInstallation().getXMLRPCVariable() + ".get_selection()");
    writer.appendLine("if (is_selected == True):");
    writer.writeChildren();
    if( elseNodeExist == false )
        writer.appendLine("end");
}

ELSE Node:

public void generateScript(ScriptWriter writer) {
    writer.appendLine("else:");
    writer.writeChildren();
    writer.appendLine("end");
}

Am I right?