Greetins UR Community,
I am trying to write an URscript on C# which will later be sent to the UR5 via port 30003.
A quick example of a program I wrote is the following:
string message = “def program():”;
message = message + “\r\nset_configurable_digital_out(0,True)”;
message = message + “\r\nsleep(2)”;
message = message + “\r\nset_configurable_digital_out(0, False)”;
message = message + “\r\nhalt\r\nend\r\n”;
This is a very simple program which sets an output to to 1 for two seconds and then sets it back to 0
I can run this program perfectly. However, the app I am currently developing is a little bit more sophisticated and I need a socket communication for various reasons. I studied the script manual but I was not successful into getting this done.
This is a short part of the code:
string message = “def program():”;
message = message + “\r\nset_configurable_digital_out(0, True)”;
message = message + “\r\nglobal var_1 = socket_open(192.168.3.250,10)”;
message = message + “\r\nwhile(var_1 == False):”;
message = message + “global var_1 = socket_open(192.168.3.250,10)”;
message = message + “sleep(0.3)”;
message = message + “end”;
message = message + “\global var_2 = socket_read_ascii_float(6)”;
I am certain this is not the way to do it, but I haven’t found any solution (unlike the former, this one does not run on C#).
Finally, I also struggled with setting a timer:
string message = “def program():”;
message = message + “\r\nset_configurable_digital_out(0, True)”;
message = message + “\r\ntimer_1 = 0”;
message = message + “\r\ntimer_1_is_counting = True”;
message = message + “\r\nsleep(2)”;
message = message + “\r\ntimer_1_is_counting = False”;
message = message + “\r\nset_configurable_digital_out(0, False)”;
message = message + “\r\npopup(timer_1)”;
message = message + “\r\nhalt\r\nend\r\n”;
This program runs but timer_1 is equal to 0 instead of 2.
Any help would be much appreciated.