Skip to content
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

Start of the Web console #185

Merged
merged 21 commits into from
Feb 7, 2025
Merged

Start of the Web console #185

merged 21 commits into from
Feb 7, 2025

Conversation

ekr-cfa
Copy link
Collaborator

@ekr-cfa ekr-cfa commented Jan 31, 2025

This is a very primitive Web console. The way it's structured is that there are a series of individual widgets each of which is responsible for displaying some aspect of the simulation. Each widget is individually responsible for retrieving its own information and showing it within its own region. The existing widgets are:

  • The time of the simulation
  • The population
  • All global properties

All of these use a shared API object that takes care of communication with the Ixa Web API.

Finally, there is a next button which runs the simulation to the next time step. This works by:

  • Executing the next() API call with t set to t + 1.
  • Polling the API until the simulation time has incremented.
  • Triggering a refresh of each widget.

Note that this will not stop the next time that simulation time increments but rather the next time the simulation reenters the Web API at a time greater than the previous time. This is because the Web API doesn't respond to requests continuously but only when the simulation is paused. The reason for polling is because the request for the next time might time out (though I actually may need to suppress errors in this case, which I'm not sure I have done).

@ekr-cfa
Copy link
Collaborator Author

ekr-cfa commented Jan 31, 2025

image

static/app.js Outdated Show resolved Hide resolved

export default async function getApi() {
if (!api) {
api = await new Api();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit weird in that it doesn't actually need to be async, but we could address that in a follow up

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to leave this as is in case we discover we do need an async phase.

static/app.js Outdated

function App() {
let app = makeAppState();
let properties = ["InfectionStatus"];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unused I think

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's cruft.

let properties = ["InfectionStatus"];

return html`
<div><${Time} app=${app} /></div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should actually be receiving the generation value (that's what useEffect should use to determine it should update) v.s. the update function – only things that trigger an update should get the update function (like the next button)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

@ekr-cfa ekr-cfa requested a review from k88hudson-cfa February 7, 2025 14:35
@ekr-cfa ekr-cfa marked this pull request as ready for review February 7, 2025 16:41
@ekr-cfa ekr-cfa merged commit bf043eb into main Feb 7, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants