-
Notifications
You must be signed in to change notification settings - Fork 2
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
PhET-iO design for scenes #193
Comments
I'll work on this. |
I implemented this and it can be called like: await phetioClient.invokeAsync('centerAndVariability.medianScreen.model','getCurrentSceneData'); or await phetioClient.invokeAsync('centerAndVariability.variabilityScreen.model','getCurrentSceneData'); It contains the state data for everything pertinent to that scene. For instance, the variability screen shows MAD values but the median screen does not. Let's review this in an upcoming phet-io check-in. Also tagging for #136 |
We reviewed this with @catherinecarter and @matthew-blackman and it seems like it is ready to close. But we want to share it with @kathy-phet at an upcoming team meeting so she is aware, and to get any other feedback. |
@catherinecarter did we review this with @kathy-phet? Or is that still for an upcoming meeting. |
If my memory serves me well, I believe we ran this by @kathy-phet, but I'm not 100% sure. I'll run it by her before saying yes here. |
@kathy-phet is hoping to have another look at the second part of the comment from the top of this issue. Simplified data structure to give the main pedagogical things for the data that's currently be displayed so no one needs to do back-processing to know what scene you're on. One array data structure to capture what's currently on the screen.
Requesting a meeting with MS, MB, KP, SR to discuss. |
In the conversation above, we also noted that Jotting down a note that may inform us when we meet with @matthew-blackman. Here is the code a client could use to get the current screen, current scene, and mean value on that scene. It uses one phet-io API call and processes the state. I'm not saying this is obvious or easy, but it is something we could document in the examples.md document: // Get the entire state from the sim
const state = await phetioClient.invokeAsync('phetioEngine','getState');
// Identify which screen is currently selected
const screen = state['centerAndVariability.homeScreen.model.selectedScreenProperty'].value.phetioID;
// Identify which scene within that screen is currently selected
const scene = state[screen+'.model.selectedSceneModelProperty'].value.phetioID
// Access whatever data measures are of interest
const mean = state[scene+'.meanValueProperty'].value |
I elaborated on the code above to use a better model property for the selected screen, and also a better way of getting the scene for screen 1-2. // Get the entire state from the sim
const state = await phetioClient.invokeAsync( 'phetioEngine', 'getState' );
// Identify which screen is currently selected
const screen = state[ 'centerAndVariability.general.model.screens.selectedScreenProperty' ].value.phetioID;
if ( screen === 'centerAndVariability.homeScreen' ) {
console.log( 'home screen is selected' )
}
else {
// Identify which scene within that screen is currently selected
const scene = screen === 'centerAndVariability.meanAndMedianScreen' ? 'centerAndVariability.meanAndMedianScreen.model.sceneModel' :
screen === 'centerAndVariability.medianScreen' ? 'centerAndVariability.medianScreen.model.sceneModel' :
// Variability screen has different scenes
state[ screen + '.model.selectedSceneModelProperty' ].value.phetioID
// Access whatever data measures are of interest
const mean = state[ scene + '.meanValueProperty' ].value
const median = state[ scene + '.medianValueProperty' ].value
console.log( 'mean=' + mean );
console.log( 'median=' + median );
} |
In discussion with @kathy-phet @matthew-blackman @marlitas and @samreid, we agreed we want to proceed by documenting this in the examples.md rather than adding a new API for feature (which would require development/maintenance/migration rules) for this. We will start with the code in the preceding comment. @kathy-phet says we will decide on a sim-by-sim basis if other sims have a need for something like this. As clients begin to use this, we will get a better sense of whether this is OK or whether we would need to add more support. |
Tagging for #136 |
Closing since the remaining work will be done in #136 |
Reopened for discussion today |
We discussed this may be a more appropriate level for examples.md, in order to find what scene is selected, and to get some data for the selected scene: const scene = (await phetioClient.invokeAsync('centerAndVariability.variabilityScreen.model.selectedSceneModelProperty','getValue')).phetioID;
await phetioClient.invokeAsync(scene + '.meanValueProperty', 'getValue'); |
Here's a cleaner version: const sceneElement = await phetioClient.invokeAsync('centerAndVariability.variabilityScreen.model.selectedSceneModelProperty','getValue');
await phetioClient.invokeAsync(sceneElement.phetioID + '.meanValueProperty', 'getValue'); |
Leaving @catherinecarter assigned to make sure this is documented in the examples. |
Thanks. I've copied your code from above and have it recorded in examples. Closing. |
From #164, we split up the model into scenes. @kathy-phet said:
Hey Sam, Cathy,
Agree with the above in terms of the what changes when you select a different player (just the data). Everything else stays the same - so you can easily compare data sets.
In thinking about PhET-iO of this aspect, I was thinking that each player should have the following data available under it:
So that with the PhET-iO interface you can always access the data for each player, even if they are not the one that is visible.
Then there could be the a data structure in PhET-iO that is the "currently displayed values" that is read only. So that if you built a "save data" function to pull values into your system, you always get the visible data using the same static PhET-iO Element ID.
The text was updated successfully, but these errors were encountered: