02-09-2009 02:12 AM
Hi all, I have to make a connection through TCP/IP to a device to read some values. But when the machine where the device is installed on has no power supply, my device also has no power suply and the connection will fail. Now i had the idea to retry to make a connection every couple of minutes when an error is detected. In this case the program does not stop running an will connect automaticly when there is a possibility to connect. How can i solve this or are there any other suggestions for the problem?
Best Regards
Stefvg
Solved! Go to Solution.
02-09-2009 02:33 AM - edited 02-09-2009 02:34 AM
Hi Stefvg,
i find the idea very well. You can use a statemachine for it. One case is for the connection and another for the wait. Make the wait time not to big, so that it is easy possible to exit the program after a short time. If you need a bigger wait time, then you can use a counter as multiplier.
Mike
02-09-2009 02:37 AM
Hi, i don't realy understand what you mean. Do you mean a casestructure? Can you maybe give me a smal example of how to implement this because i am not that familiar with LV. Thanx
Best Regards
Stefvg
02-09-2009 02:56 AM
Hi Stefvg,
yes i meant a case structure. See the attached example.
Hope it helps.
Mike
02-09-2009 03:20 AM
Hi, I think this is exactly what i need. But when i save your vi and use it as a subvi in my vi, there is something wrong. I connect my parameters ip, port, wait time and connection id to your vi. When i run my vi, your vi blocks at the type cast in case connected. Do you know why this is happening? When i just make connection whitout your vi it works properly.
Best Regards
Stefvg
02-09-2009 03:27 AM
Hi Mike, I think i solved the problem. I just deleted the case connected en changed every name connected in exit. Now the subvi works like it should.
Thanks for your help.
Best Regards
Stefvg
02-09-2009 03:52 AM
Hi Stefvg,
yes this should work. I thought you insert your code into the provided structure.
Mike
02-09-2009 06:25 AM
Hi, I've implemented the Subvi in my vi and everything works just fine. But i am using some while loops and sequence structures in my program. Is it possible to add a button (or buttons) to abort an action and stop the entire program. An example: when i am trying to make a connection i am in the subvi until a connection is made or i push the emergency stop button. Now i actually want to stop making a connection when pushed at a button whitout stopping the whole program (with the emergency button). Or i want a button that stops the program no matter in which loop the program is in. Is this possible or not? I've added my program in attatchment.
Best Regards
Stefvg
02-09-2009 06:43 AM
Hi Stefvg,
you can use a button reference. Insert it into the connection vi and read the property "value" in every iteration.
Mike