LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Network stream within JKI State Machine

I'm still very new to LabVIEW, so please excuse any naive assumptions of mine. 
I've decided to use a JKI state machine to handle my UI events and interpret these events with commands in different states, which then have to to be sent to a RTOS.

This leaves me with two questions.

 

1) Is ist advisable to use a network stream within the state machine?

The number of commands which would have to be sent is rather small, so I would assume the UI would stay responsive. 

 

2) how do I create a reference to a network stream, so that I can add that to my data cluster?

0 Kudos
Message 1 of 6
(2,974 Views)

To keep the UI responsive, don't use long running loops inside any of the states.  If you need to use a loop, just call the same state over and over instead. Also you might want to add a call to the IDLE state before going back to your loop so that the event structure has a chance to execute and keep the UI responsive. 

 

As far as adding a network stream to your data cluster, just create your network stream in the Data:Initialize state and close it in the Data:Cleanup state. 

aputman
0 Kudos
Message 2 of 6
(2,951 Views)

@aputman wrote:

To keep the UI responsive, don't use long running loops inside any of the states.  If you need to use a loop, just call the same state over and over instead. Also you might want to add a call to the IDLE state before going back to your loop so that the event structure has a chance to execute and keep the UI responsive. 

 


Yes, I do something very similar when running "loops". Part of my shift register data is a string called "timeout state" which runs if the event structure times out. When I start the loop, I set the timeout to a small value, say 100ms, and when I finish the loop, I set it back to -1, or just change the timeout state to an empty string. This works as long as you don't need your state to run every 100ms, because then a user interaction would screw it up.

0 Kudos
Message 3 of 6
(2,945 Views)

I was just wondering if it is possible to create a reference of an uninitialized stream? 
This way I could have a separate state like, "stream: Initialize" . But if that's not possible, then the initialization of the stream in the "Data: Initialize" must do.

 

And regarding the unresponsiveness I was mostly concerned with the stream locking up the interface in case of a disconnect. But in that case the User should probably not be able to send any commands.

0 Kudos
Message 4 of 6
(2,906 Views)

From the Create Writer or Reader, you can create a constant from the endpoint output.  You can wire this up to your data cluster and replace it with a valid reference at a later time.  Is this what you mean?

networkStream.png

aputman
0 Kudos
Message 5 of 6
(2,899 Views)

Thanks, that was exactly what i was looking for.

0 Kudos
Message 6 of 6
(2,883 Views)