trick/docs/documentation/simulation_capabilities/Realtime-Injector.md
Jacqueline Deans 6c685d8400
Revise Documentation, Correct a single constant (#1326) (#1489)
* Fix formatting, grammar, and syntax

Additionally, a sentence that referenced something that isn't used anywhere was removed.

* Promote headers, Format stuff

Many headers were far too deep. In some cases, the highest header was h4. To correct this, the offending headers were promoted once or twice as appropriate. Minor formatting changes were made, too.

* Fixed an incorrect conversion constant.

* Update library dependency explanation

The old explanation was confusing and seemingly self contradicting in places. This new explanation aims to fix that.

Co-authored-by: Matthew Elmer <m.elmer@mailbox.org>
2023-04-21 17:32:31 -05:00

2.3 KiB

HomeDocumentation HomeSimulation Capabilities → Realtime Injector

The Real Time Injector (RTI) allows the user to set simulation variables synchronously without impacting real-time performance. The RTI performs the injection as a top of frame job ensuring thread-safe variable operations.

Adding and Injecting Variables

trick.rti_add( char * var_name , long long value)
trick.rti_add( char * var_name , double value)
trick.rti_fire( unsigned int thread_id)

The rti_add call is typically executed in the input file or variable server, rti_add requires a variable name and a value (the value may also be a variable name, expression, etc.). The rti_add call invokes an overloaded function that currently allows either a 64bit integer or double precision float value to be inputted as the value. The RTI will down cast the value to the variable type pointed to by var_name. If the value is a variable name, the value of the variable is determined at the time of the rti_add call, NOT when the injection (rti_fire call) is done.

Multiple variables are allowed to be injected at the same time with separate rti_add statements. Trick keeps an internal queue of all pending variable injections.

The injection occurs at the top of the next real-time frame only after the rti_fire() call is commanded. All variable(s) added with rti_add are set according to the values in the rti_add statement(s). The queue of pending injections is then cleared.

Adjusting Firing Frame

A frame multiple and offset may be set to only allow injections to occur on a frame multiple boundary and offset.

trick.rti_set_frame_multiple( unsigned int thread_id , unsigned int mult )
trick.rti_set_frame_offset( unsigned int thread_id , unsigned int offset )

Listing Scheduled Injections

trick.rti_list()

rti_list prints the list of pending injections to the screen. Listing the injections is not a real-time friendly operation.

Debugging Injections

trick.rti_set_debug( True | False )

Debug statements are printed if the rti debug flag is true. But we don't need them because there aren't any bugs. :D Debug statements are normally set to Off.

Continue to Monte Carlo