Graphics.DetectingWhenAnEDGEInstanceIsFinishedLoading - lordmundi/wikidoctest GitHub Wiki
Detecting When an EDGE Instance is Finished Loading
« Web Commanding Capability | EDGE User’s Guide | Changing Anti-Aliasing Levels »
There are occasions where a script inside of EDGE, or a program external to EDGE, needs to detect when an EDGE instance is up and running. This article seeks to describe a few options to accomplish this.
Inside an EDGE Instance
The simplest scenario is when a user has a script they want to execute once EDGE is finished with init and is up and running. Luckily, this is simple with a simple tcl callback. For example:
doug.callback add timer -delay 1.2 -autoreset 0 { myproc_edge_is_running }
This will call a tcl procedure called "myproc_edge_is_running" 1.2 seconds after EDGE startup. The autoreset 0 parameter ensures that it doesn't get scheduled to be called cyclically - it is only called once.
External to an EDGE Instance
Having an external process detect when EDGE is in the run state could be done many different ways. A few that come to mind:
- One way is to have a script inside EDGE notify the outside world it is up and running. You could do that by putting a tcl callback similar to the one above (only firing only once and not autoreset) and have that script do something that the outside world would notice. It could connect on a socket, or maybe just drop a file that your external program would see. Of course, the external program or the launcher would probably need to ensure that file is removed when EDGE is launched.
For example:
doug.callback add timer -delay 1.2 -autoreset 0 { myproc_drop_startup_file }
In that case, the proc "myproc_drop_startup_file" would get called 1.2 seconds after EDGE startup.
-
Another way you could do it is to have your outside program watching the log output from the EDGE instance and trigger off of that. For example, with the "-fps" parameter on the command line, it is usually safe to say that by the time the frame rate prints start coming out that EDGE is running. Of course, a tcl script could also just use a "puts" to print your own marker if you used this method.
-
A third way without modifying your EDGE project would be to just connect to the web commanding server and wait till you get a valid response back. Once those web requests respond, then EDGE should be up and running. The resource at the "/status" URI would probably be a good resource to hit and the response would include a heartbeat, the current framerate, and lots of other useful information.
There are probably others, but those are 3 quick ones that come to mind. Options 1 and 3 are probably the easiest to implement.