machyaer Posted March 4, 2011 Report Share Posted March 4, 2011 Hello to everybody, I'm looking for the best programming solution to be implemented in an ethernet and/or serial communication. I attach an image of the sketch of the two solution I've thought. Let me know which of them is the best and/or if there is something better. Thanks Max Quote Link to comment
jgcode Posted March 4, 2011 Report Share Posted March 4, 2011 Does not look like there is any serial or Ethernet code there We might be able to comment better if you are able to post more of what you have done and trying to do. Quote Link to comment
hooovahh Posted March 4, 2011 Report Share Posted March 4, 2011 If you're looking for architecture suggestions, what's wrong with the standard queue driven state machine? You can have an Init case, and close case that can be used to restart the driver if there is an unexpected crash. With a sequence architecture like both of your examples, there isn't any way to perform a close and restart operation (maybe in the bottom one but I still don't like it). If you want to stick with simple I would suggest using the top option, but replace the while loop with a while loop and an event structure in it, so there doesn't need to be polling for controls, but you also have a timeout for reading if desired. Quote Link to comment
machyaer Posted March 6, 2011 Author Report Share Posted March 6, 2011 If you're looking for architecture suggestions, what's wrong with the standard queue driven state machine? You can have an Init case, and close case that can be used to restart the driver if there is an unexpected crash. With a sequence architecture like both of your examples, there isn't any way to perform a close and restart operation (maybe in the bottom one but I still don't like it). If you want to stick with simple I would suggest using the top option, but replace the while loop with a while loop and an event structure in it, so there doesn't need to be polling for controls, but you also have a timeout for reading if desired. Thanks, this was my goal. I will choose the first solution with the event structure because of I'm not so familiar with the state machines. Max 1 Quote Link to comment
Mark Yedinak Posted March 10, 2011 Report Share Posted March 10, 2011 Thanks, this was my goal. I will choose the first solution with the event structure because of I'm not so familiar with the state machines. Max I would recommend against that. Take the time to learn how to use state machines. They are much more flexible and much easier to maintain. I would definitely avoid using sequence frames in any form or fashion. They are not a recommended construct and generally should only be used to impose data flow where none exists. Even then, this should be limited to a single frame with a small bit of code. State machines are not that difficult to learn and they are a very powerful tool. Quote Link to comment
machyaer Posted March 10, 2011 Author Report Share Posted March 10, 2011 I would recommend against that. Take the time to learn how to use state machines. They are much more flexible and much easier to maintain. I would definitely avoid using sequence frames in any form or fashion. They are not a recommended construct and generally should only be used to impose data flow where none exists. Even then, this should be limited to a single frame with a small bit of code. State machines are not that difficult to learn and they are a very powerful tool. Thanks Mark, at tha moment I find easier to use one of the two solution posted, but I'm studying in order to implement the state machine solution asap. Bye Max Quote Link to comment
Tim Erickson Posted March 11, 2011 Report Share Posted March 11, 2011 I use a state machine that has two parallel loops in the meat of it. If the connection is lost, it will attempt to reconnect on a separate port. The code for the connect is in separate states of the state machine. The screen shots show the cRIO TCP Server run state and the HMI TCP Client run state. Let me know if you have any specific questions. I am limited to what code I can share but am can at lease offer screen shots. Quote Link to comment
Mark Yedinak Posted March 11, 2011 Report Share Posted March 11, 2011 Thanks Mark, at tha moment I find easier to use one of the two solution posted, but I'm studying in order to implement the state machine solution asap. Bye Max The reason I am strongly suggesting state machines is that they are not that difficult to implement (essentially a case structure inside a while loop) and that both ways you are proposing are considered poor choices in LabVIEW. Better to begin learning the preferred methods than to establish bad habits using the poor choices. It becomes difficult to "unlearn" how to do something. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.