01-28-2020 03:31 PM
Hi Everyone,
I am controlling a motor and a camera at the same time. In the first frame, I wanted the camera to view what is going on until the motor finishes executing its last command in the visa write "S G". In the second frame, the camera will save the images.
If there is a better way, I am open to changing my code. Sorry this is a simplified version of my code so it is not very usable especially since the visa write is calling my specific hardware.
1. How do I make the camera stop viewing in the first frame? I am not sure how to make a stopping condition.
01-28-2020 04:05 PM
Use a state machine.
01-28-2020 06:46 PM - edited 01-28-2020 06:47 PM
As altenbach suggested, you should read about (and then probably use) a State Machine. Another possibility might be a Queued Message Handler (QMH) or similar (you can find many posts with Google etc).
Since it appears that you know the duration of your "Motor Run Time", you might want to use a flow somewhat like the following:
That's just a quick suggestion, but it might give you some ideas.
01-29-2020 10:02 PM
This is fairly simple to do with a State-Machine-like architecture (I use a variant of the QMH that uses Messenger Channels). You only need to know if you are starting a new Video, continuing an existing Video, transitioning out of saving a Video (such as closing the AVI file), or "doing nothing but displaying". I actually have two such CMH's (Channel message Handler) running in parallel -- one handles acquiring images and displaying them, the other handles creating the Video, including all of the file handling.
Bob Schor