[RMP 8.3.1]
Streaming Outputs
The sample app for streaming outputs is somewhat unlike my application. I could use some clarification about how to use the API.
My Application
My application is essentially a finite state machine that acquires some points and sends them down to the motion controller.
In the case of streaming outputs, we will get a “piece” of motion in which one or more outputs will be enabled. That same chunk of motion data may or may not have a corresponding “clear” of the outputs. The signal to clear will come some time later.
I will never be able to know ahead of time which outputs could be set/clear or, when a specific output is to be set, precisely when it will be cleared. I’ll know later when it’s to be cleared, but I won’t know at the time when I want it to be set.
API Questions
StreamingOutputsEnableSet(…)
When do I want to enable/disable streaming outputs?
Are they enabled any time I want RMP to either set or clear the output?
If they are disabled, will RMP ever try to set/clear the output as a result of the motion ID being executed? (The documentation makes it sound like this is the case, but I just want to be sure.)
Would I want to disable when I know that I no longer have any (active) outputs that I want to set/clear as the result of executing motion?
I can imagine that I’d want to enable streaming outputs as soon as I start streaming motion and disable them when I stop streaming motion, but I don’t know if that’s the intended use of the API function.
There’s a seeming discrepancy between the API doc and the topic regarding ...Enable(false)
. (Emphasis added)
Setting to false resets the current index to 0, but does not free the array backing.
StreamingOutputsEnableSet()
…
FALSE - resets the current index to 0, and clears the vector backing.
StreamingOutputsClear(…)
(The sample doesn’t use this function.)
This discards any existing streamed outputs (even if they have not triggered)?
In my application, would I want to use this any time other than when I disable streaming outputs?
StreamingOutputsAdd(…)
I only need to ...Add(...)
when I want the output to change, right?
Will RMP remove the item from the Streaming Output List (SOL) as soon as the corresponding motion ID has executed? Will subsequent calls to MovePT(...)
fail if streaming is still enabled (i.e. if the SOL is empty)? This sounds unlikely, but why is it an error to enable streaming outputs without adding an output? Especially since there’s no API function for detecting the state of streaming outputs, it seems like I’d have keep track of whether I’ve ever called this turned it on or off rather than query RMP, who probably knows better.
There must be sufficient space in the Streaming Output List before adding this output
How large can the list be?
ptPointIndex
Is the point index paramater used here a number from the space of motion IDs, like what’s returned from MotionIdGet()? (It seems like it would be, but the parameter is an int32_t
whereas the motion ID is an int16_t
.) The name of the parameter, ptPointIndex
, suggests that it might be an index into the array of points I’m about to give to MovePT(...)
. My reading of the docs suggests the latter (something in the MotionElementIdExecutingGet()
space). (The sample doesn’t clarify this distinction, but the topic makes it sound like I should use an index into the array of points rather than a motion ID.)
onMask, offMask
When the output is to be set (by RMP), will it use both the onMask
and offMask
? In other words, will I always want to set one of these parameters to 0, depending on whether I want to “set” or “clear” the output (for a typical digital output)?
For niche cases, when neither of these masks is zero, which one is applied first?
Application Architecture
I can imagine a few ways to implement this, but I’d prefer to use the cleanest. Even better than cleanest is “what works,” so your advice here will be most useful.
Always Enabled
This method would seem to fit best with the FSM-style behavior of my application.
- When I start streaming motion, I enable streaming outputs.
- (I
...Add(...)
an output to the first batch of motion points I send so that callingMovePT(...)
doesn’t croak.) - I stream motion like normal, and occasionally
...Add(...)
an output that either sets or clears the output. - When I stop streaming motion, I disable and clear the outputs.
Output Micromanager
I don’t prefer this method, but if this is how the API wants to be used, I suppose that’s more important.
- As soon as I know I need to set an output…
1. If outputs aren’t enable them, enable them.
1....Add(...)
the output. - As soon as I know I need to clear an output…
...Add(...)
the output- As soon as the motion ID where I cleared it has executed
- If there are no more active outputs, disable streaming outputs