-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hooks to make PhET-iO API calls on 'step' #570
Comments
There is discussion and a proposal in phetsims/axon#222 (comment) about how to deal with Action and listeners. In this case, it would mean instrumenting |
|
@zepumph pointed out in another thread that this method is asynchronous, and it is unnecessary to have both |
I don't know what happens on a frame well enough to know whether we would need control over the start or the end of the frame. I think what would be important is that we don't get model values that are mid-way calculated .. e.g. PV before being updated and NT from after being updates. We need them to be either all calculated or all before the calculation update. |
My vote would be for instrumenting the |
Because of the asynchronous nature of phet-io when communicating from the sim frame to the wrapper frame, all calculations would be done in the sim for a given frame before the wrapper get's any messages for that frame. |
I agree with @kathy-phet's comment in #570 (comment), but that pertains to a specific case, Graphing Quadratics. The question about whether both pre and post callbacks are needed is a general question. If the answer is "no", that's fine. I just want to make sure we're considering this generally, not doing something specific for Graphing Quadratics. |
I think Chris means Gas Properties. |
Sorry, yeah, Gas Properties (the other "G" sim :) |
This is pending discussion in https://github.com/phetsims/phet-io/issues/1543, on hold until we discuss there. |
Some questions for @zepumph before we proceed:
Please reassign to me after answering. |
Yes I believe so. Currently there are no Emitters that are phetioPlayback:true, but all the wrapper-side cares about is the "emitted" event, which Actions and Emitters send (in handlePlaybackEvent.js: // handle playback Actions
else if ( event.name === 'emitted' ) {
const orderedArgs = event.metadata.dataKeys.map( argumentName => event.data[ argumentName ] );
totalInvokes++;
phetioClient.invoke( event.phetioID, 'execute', orderedArgs, completedInvoke );
}
Yes sorry. Any one of these, no preference. |
"Each time the model is stepped" is not the same as "the end of every frame". |
@pixelzoom can you please assign to the designer(s) for this sim for clarification? |
Since this issue is a breakout from meeting notes in phetsims/gas-properties#30 (comment), assigning to @arouinfar. |
From a design perspective, it doesn't seem particularly important to have the emitter fire while the sim is paused, but it also doesn't seem harmful. While the sim is playing, does |
There is no standard interface for pausing and running models, so something would have to be done on a sim-by-sim basis for this. I'm not sure it is worth the effort. If the client only wants updates when the model is running, they could add a check that says
PhET-iO used to have a way to pass an API call "schema" to the core side to evaluate at a specific time synchronously, but we dropped support for that and now have to use the asynchronous method from above. |
I'm still not sure what the requirements are here, so I don't know what additional feedback to give. The closest I can find to a requirement is what @kathy-phet alluded to in #570 (comment):
No idea what PV and NT mean. And I would think that view values would be as important as model values. But this sounds like a desire to have a way to get notification that all values have finished changing, and you can safely check values without getting any intermediate values. If I interpret that correctly, then |
I don't think an asynchronous conversation is going to be very productive here, so I've added this issue to the agenda for next Thursday's phet-io meeting. |
We discussed this at phet-io meeting today, and designers and devs feel like the way @samreid outlined in #570 (comment) will work for this use case, and if, in the future, the asynchronous behavior is not acceptable, then we can investigate adding support for running commands inside the sim frame. @pixelzoom how does this sound to you? Anything else here? |
I've never been clear on the requirements, and this issue was opened at the request of designers. So if designers are OK with what @samreid proposed in #570 (comment), then that sounds fine to me. Should an example be added to client-facing documentation? |
Maybe it would be nice to start a "FAQ" section of the wrapper index, that can expand for some use cases that devs have as they do. Part of me feels like this goes beyond the scope of our client facing doc right now, and I'm tentative to add to our current wrapper index before it gets a face lift. |
I think we can close this issue. There is no good place to add client facing documentation at this time. If we feel like this is an important feature for a sim, then it can be added its client guide. Closing |
From 7/18/19 Gas Properties design meeting notes in phetsims/gas-properties#30 (comment):
The use case is to allow the client to get an array of particle speeds each time the model is stepped.
The answer is "not currently supported". There are some ideas in the Slack discussion below, but no final decision. @kathy-phet @ariel-phet @arouinfar FYI, prioritization needed.
Slack discussion
Chris Malley 3:14 PM
Does PhET-iO provide clients with a way to optionally call a function on each call to Sim
stepSimulation
? The use case is in Gas Properties, where the design team would like to provide an API function that allows the client to get an array of particle speeds each time the model is stepped.Michael Kauzmann:house_with_garden: 3:15 PM
@jessegreenberg @samreid and I were just looking at that! We noticed that
stepSimulationAction
is anAction
, so we can't add listeners to it for PhET-iONot sure if @samreid or @jessegreenberg made an issue.
Mainly we noted that phetsims/axon#241 wasn't complete, because
ActionIO
has anaddListener
function which is buggy.Chris Malley 3:17 PM
Listen to
frameStartedEmitter
orframeEndedEmitter
?Michael Kauzmann:house_with_garden: 3:18 PM
Yes perhaps that is the solution, though they aren't currently instrumented. That seems like adding unneeded complexity. That said I think that may be the best/easiest solution.
Chris Malley 3:18 PM
It also provides the flexibility to be notified before or after the step has occurred.
Michael Kauzmann:house_with_garden: 3:19 PM
So you think that perhaps instrumenting both is the way to go?
Chris Malley 3:19 PM
This is one of 3 “Ask PhET-iO Team” action items that I have from last week’s Gas Properties PhET-iO meeting. Perhaps I should create an issue for each of them? See phetsims/gas-properties#30 (comment)
The other alternative would be a sim-specific
{Emitter} particleSystemChanged
that fires each time the particle system has changed. But I’m hesitant to add any more overhead that occurs in step.Michael Kauzmann:house_with_garden: 3:21 PM
Sounds excellent. Also it would be good to note that since phet-io listeners are inherently async, perhaps only the frame ended emitter should be instrumented, because likely the frame will complete before the thread executes anything from the wrapper frame.
The text was updated successfully, but these errors were encountered: