![]() |
![]() |
![]() |
![]() |
![]() |
Changing the System
There are a number of commands in the simulator monitor that change the behavior of the system. These commands should be used with care, since it is no longer the original system that is simulated after such a command has been issued. These commands are still useful, especially in debugging situations, for making minor changes so that it is possible to continue the simulation after an error has been detected. They can also be used to force the system into certain situations, that otherwise would require a large number of transitions to be attained.
What You Will Learn
- To change and add commands in the Command window
- To create a process manually
- To change the process scope
- To change the value of a process variable
- To change the state of a process
- To set and reset a timer manually
Some Preparations
In the following two exercises, you will be changing processes and timers. Before continuing, you will set up the simulation and the Simulator UI in a suitable way.
- Restart the simulator.
- Open the Command window through the View menu. You will now change the commands executed in the Command window. The List-Process command is to be replaced by Examine-PId, and a new command, List-Timer, will be added.
- In the List-Process command module, select Edit from the Command menu to the far right. (This menu works in the same way as the Group menu in the button modules.)
- In the dialog, change the command to examine-pid and click OK.
- Go to the Command window's menu bar and select Add Command from the Command menu. In the dialog, enter the command list-timer and click OK.
- A new command module is added to the window. Resize the window so that all three modules are visible.
- Set the system trace value to 6 to get full trace.
- Execute the two first transitions so the processes Main and Demon are started.
- If the GR trace in the SDL Editor window makes it difficult to see the output in the Command window, set the system GR trace to 0.
Creating a Process
In this exercise, we will put the system in the state it would be in after the reception of a Newgame signal. This will be accomplished without actually sending the signal. Instead, we will manually create an instance of process type Game, using the Create command.
- Create the Game process by selecting the Create Process entry (in the Change menu). Select the process Game, and click OK.
- In the next dialog, select the parent process Main and click OK. This sets up the Parent-Offspring link between the process instances.
- To complete the actions taken when a Newgame signal is received, you must also set the GameP variable in Main, and put Main in the state Game_On. This is done with the commands Assign-Value and Nextstate. However, these commands operate on the process next to execute, which at this stage is Game, as can be seen in the ready queue printed in the Command window.
- Therefore, you first have to change the current process, also known as the process scope.
- Change the scope by selecting Set Scope in the Examine menu. Select the process Main in the dialog and click OK.
- Assign the GameP variable by selecting Variable in the Change menu. In the dialogs that follow, select the variable GameP, and enter the PId value Game:1.
- To put the Main process in the correct state, use the State entry in the Change menu. Select the state Game_On and click OK.
- The system is now in exactly the state it would be in after the reception of a Newgame signal. Even though you have changed the process scope, the next transition to be executed is still the start transition of Game. (You can check this by viewing the process ready queue. See Figure 109.)
- Execute the next transition and check that the Game process is started.
Changing the State of Timers
In this exercise, we will execute Set and Reset actions on timers directly in the monitor system. At this stage, the timer T is active, as it has been set by the Demon process. You can check this by looking at the List-Timer module in the Command window.
- Reset the timer by choosing Reset Timer in the Change menu. Select the timer T and click OK.
- Try to execute the next transition and note the message printed:
No process instance scheduled for a transition- Choose Set Timer in the Change menu, select the timer T and enter a time value of 10.
- Execute the next transition and check that the timer was set at time 10 (look at the trace in the main window).
*** TIMER signal was sent* Timer : T* Receiver : Demon:1*** Now : 10.0000
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |