slaclab / slactwin

Other
2 stars 0 forks source link

Server API for live monitoring #39

Closed moellep closed 1 week ago

moellep commented 2 weeks ago

There needs to be a live monitoring API for the client to get the most recent runSummaryId, and also to watch for updates.

This could be one API with a runSummaryId argument, and if the id is empty, the most recent is returned immediately, otherwise the client would send the current runSummaryId it is viewing live, and the server would return a new runSummaryId when new data is available.

robnagler commented 1 week ago

I think the best approach is to use a simulation. This will reuse all the existing paths for dynamic updates. Moreover, once we fix runStatus to be a single request with many replies, this gets full asynchrony for free. Many apps use outputInfo to hold arbitrary state, which gets stored in the supervisor db so the round trips for runStatus are efficient in one way and not efficient in another. If the browser window is closed (for whatever reason), reopening just gets the last runStatus, because the simulation can run for as long as we like in this environment.

The UI would simply request runStatus (like it does now). If the simulation is not running, it would start it, and wait for the result before displaying anything. If it is running, then it would display the result immediately. This is how all persistent simulations work now so it's all standard paths except that the UI would restart the simulation any time it was in is live mode and when it isn't in live mode it cancels the simulation. This would be the standard interaction for the UI (if sim isn't running, start it and wait for first reply before displaying), because the simulation will end at some point (we don't want unlimited time limits).

robnagler commented 1 week ago

Simulation model is liveMonitor. The model needs machine_name and twin_name. If these change, the simulation would be restarted.