Modeling of continuous time behavior Modeling of continuous time behavior There are three types of behaviors typical of embedded systems: Љ Simple means implemented in functions and operations Љ Continuous means expressed by items such as PID control loops or digital filters Љ Reactive means state-based behavior Although the Rational Rhapsody GUI directly supports only simple and reactive behaviors, you can implement all three types. To address the continuous time aspects, you can reference or include any code you are currently using to express continuous behavior in any of the operations defined within Rational Rhapsody.
This means that if you are defining your continuous behavior elements manually, you can continue to do so. If you are using another tool to define your continuous behavior and that tool generates code, you can include that code. Interrupt handlers The ability to add an interrupt handler depends on operating system support. Typically, a static function without parameters is added by passing its address to an operating system operation like InstallIntHdlr (operating system-dependent). The static function can be either a special singleton object or a function defined within a package. This operation must use compiler-specific utilities to get to the registers.
Eventually, it must return and execute a return from the interrupt instruction. You can pass the data from the interrupt handler to the CPU (assuming that the interrupt handler needs to), in the following ways: Љ Generate an event (using the GEN() macro), which then goes via the operating system to the reactive object (which should be in a different thread). Љ Use a rendezvous object with a read/write toggle lock. The interrupt handler checks whether the lock is in the write state, then updates the data and puts the lock in the read state. The reader (in another thread) periodically checks the lock and only reads when it is in the read state.
If it is in that state, the reader reads the data and updates the lock to its write state. This can easily be extended to a queue structure. Љ Write the interrupt handler manually outside Rational Rhapsody and send it to the operating system message queue for the target thread. Typically, if the operating system does not support interrupt handlers directly, you store the current handler in your function and write the address of the function in the appropriate place in the interrupt vector table. When the interrupt goes off, either the new function replaces the old interrupt handler (meaning when it is done it simply returns) or it chains to it (calls the original).
In any Rational Rhapsody 785