Im currently working on a communication with a machine, and the program node needs to wait until the machine is finished positioning. after the machine is positioned, the UR can move again.
In the programnodecontribution, implementing a while loop (see below) in generatescript will freeze the screen and render it useless.
// declaration:
private String message_Done = "0"; //message from the machine ("0" & "0") where "1" is done
//in generateScript(ScriptWriter writer) {
// use this loop to keep the node busy until the machine is at its position.
while(message_Done.equals("0")){
updatePreview();
writer.sleep(0.1);
}
}
private void updatePreview() {
String title = ""; // used to set the ip adress in the preview
try {
// Provide a real-time preview of the daemon state
title = getInstallation().getXmlRpcDaemonInterface().getTitle(); // get ip adress
message_Done = getInstallation().getXmlRpcDaemonInterface().getDone(); // get machine status
} catch (Exception e) {
System.err.println("Could not retrieve essential data from the daemon process for the preview.");
title = "<Daemon disconnected>";
}
titlePreviewLabel.setText(title); // set preview
}
The machine has variable positions, so it isn’t a fixed wait time. without the while loop implemented it will just jump over the program node immediately. And another wait node (using a guessed number of seconds) has to be used to stop the program in order for it to work.
After the movement of the machine is done the UR can move again.
Anybody an idea? Thanks in advance!