Controller Overview
One major part of the framework is the Controller class. This class performs setup
operations and executes the simulation. It has a lot of responsibility but for this
discussion we will focus on the parts that are important to the sample application.
A more detailed discussion of the Controller can be found in the
Framework Overview.
The first responsibility of the Controller is to load the Simulation.properties
file as you see from the command line when you ran the sample application. This
file tells the Controller what you want it to do for the simulation. Details of this file
will be discussed later when you have a more thorough understanding of what needs to be
done in order to build an application that uses the Framework.
For now it is enough to understand this file tells the Controller the following pieces of
information:
- The type of Physical System that is being used.
- What coordinate system the simulation is being performed in.
- What type of Physical Object is being studied and how many of them will be
used in the simulation
- What classes should be used to execute the simulation that you have developed.
- Should the simulation perform measurements? If so how often should a measurement
be taken? Where will the data for a measurement be stored?
- Should the Controller produce a final report that you have developed?
This may seem like a lot information and it is, but the Framework is extremely
flexible and highly configurable, and this file contains all of the information that
is needed to run your simulation.
After the Controller loads this information, it starts to process it and see if it can do
what it has been instructed it to do. It tries to create, in order, the following for you:
- The actual Simulation.
- A Physical System that is a collection of Physical Objects
- The Physical Objects needed by the Physical System.
- The Physical Algorithm needed to perform the Simulation.
- The Physical Measurement to be performed.
- A Data Source to store Physical Measurement information.
- If specified, a Final Report
This again may seem like a lot to create and be responsible for, but the
Framework has been developed so that you do not have to develop these mechanisms yourself to
perform these tasks.
If the Controller can create all of the items listed above, it then begins executing
the Simulation. At any point, if it can not create any of the items listed above,
it will produce a detailed error message alerting the user what caused the error. If possible
it will try and provide a hint as to how the error can be avoided, but this may not be a
feature of early releases of the Framework.
The Controller executes the Simulation by performing the following steps:
- Perform an iteration using the Physical Algorithm.
- If necessary, perform a Physical Measurement
- If necessary, store the Physical Measure to the Data Source
- Check if the Simulation should still be executing
- If the Simulation is running, then repeat from Step 1.
- If the Simulation has completed, then produce a Final Report if
necessary and write any remaining data to the Data Source.
The whole process of the Controller can be understood be understood in the
next section. A thorough understanding can be obtained by examining
the
source code.
Study the code and when you believe you have a general understanding of it, then you will
definitely be ready to go to the
Framework Overview section
which will explain in detail the guts of the Framework and how it is put together.