Difference between revisions of "Exercise - Simulating a Program"

From Flowcode Help
Jump to navigationJump to search
Line 22: Line 22:
 
: The lamp comes on and the 'Simulation Delay' window opens, as Flowcode simulates the ten second delay.
 
: The lamp comes on and the 'Simulation Delay' window opens, as Flowcode simulates the ten second delay.
 
: At the end of this, the lamp goes off.
 
: At the end of this, the lamp goes off.
* You can repeat the process as many times as you like. When you are ready, click on the 'Stop simulation' button, (or press the Shift and F5 keys.)[[File:gen_exerciseSimulatingFirstFlowcode_simstopicon_01.png|30px]]
+
* You can repeat the process as many times as you like. When you are ready, click on the 'Stop simulation' icon, (or press the Shift and F5 keys.)[[File:gen_exerciseSimulatingFirstFlowcode_simstopicon_01.png|30px]]
  
  
Line 28: Line 28:
 
: When things don't go according to plan, it is useful to simulate the program step-by-step, (meaning icon-by-icon.)
 
: When things don't go according to plan, it is useful to simulate the program step-by-step, (meaning icon-by-icon.)
 
: To do this:
 
: To do this:
:* Click on the 'Step Into' icon, (or press the F8 key.)
+
:* Click on the 'Step Into' icon, (or press the F8 key.)[[File:gen_exerciseSimulatingFirstFlowcode_stepintoicon_01.png|30px]].
 +
:: A red box appears around the first icon in the flowchart.
 +
:: When you click on the icon again, the program executes that icon, and the red box moves onto the next icon.
 +
:: In this way, you can check whether or not the expected actions happen.
 +
* At any point, click on the 'Stop simulation' icon to end the simulation.
 +
: For more information, see [[
  
  
 
==What Next?==
 
==What Next?==

Revision as of 10:22, 13 June 2013

This exercise looks at testing the flowchart 'Lamp1.fcf' which you developed in the exercises Creating Your First Flowchart and Adding Devices to Your First Flowchart.
The first part of this process is to simulate the flowchart. This tests the program only, and not the hardware. It is done within the Flowcode program itself, and does not require that any hardware is present. For more details about simulation, see Overview of Simulation.



Load the Flowcode Flowchart

(For help with this, see the exercise Opening an Existing Flowchart)


Run the simulation

  • Click on the 'Run' icon,(or hit the F5 function key.)30px
The 'Simulation debugger window may open - ignore it for now! (For more information, see Simulation Debugger)
  • Nothing happens until you switch the lamp on. To do this, click momentarily on the push switch.
The lamp comes on and the 'Simulation Delay' window opens, as Flowcode simulates the ten second delay.
At the end of this, the lamp goes off.
  • You can repeat the process as many times as you like. When you are ready, click on the 'Stop simulation' icon, (or press the Shift and F5 keys.)30px


Step through the simulation

When things don't go according to plan, it is useful to simulate the program step-by-step, (meaning icon-by-icon.)
To do this:
  • Click on the 'Step Into' icon, (or press the F8 key.)30px.
A red box appears around the first icon in the flowchart.
When you click on the icon again, the program executes that icon, and the red box moves onto the next icon.
In this way, you can check whether or not the expected actions happen.
  • At any point, click on the 'Stop simulation' icon to end the simulation.
For more information, see [[


What Next?