Defining a Deployment, Generating and Running code with the Beagle Java platform
AutoFOCUS supports a special platform, which was inspired by the BeagleBone development board provided by BeagleBoard.
However, Beagle-specific hardware sensors and actuators (i.e. UART communication and direct processor pin access) have not been released yet.
Therefore, AF3 Phoenix 2.4.1 only contains the platform elements usable with any Java-based platform.
Tutorial Example "STLC Beagle Java Deployment"
In the following, we will make use of the tutorial example "STLC Beagle Java Deployment",
which is available from the AF3 menu "File -> Open AF3 Example -> Load STLC Beagle Java Deployment Example".
This model is a slightly extended version of the standard Simple Traffic Lights Controller with two platform architectures and
two corresponding deployments.
The component architecture was extended with a diagnostics component, which receives data from the controller's diagnosis
sub-component. These components create additional network traffic and console outputs in the distributed deployment.
The model contains two platform architectures modeled with the Beagle platform elements: one single ECU architecture, which
does not make use of remote UDP-based communication (note that it uses UDP locally), and a two ECU architecture, which
also uses remote UDP communication.
This tutorial will explain the following steps:
- Model elements and their properties available for the Beagle platform architecture
- Setup of the compilation environment
- Running the deployment generator
- Executing the code
- Running the system for a fixed amount of logical rounds.
- Windows support
Beagle Platform Architecture Model Elements
-
BagleBone A5 - the main ECU model element, which has one UDP connector (configured with IP address 127.0.0.1 and
port number 64001) by default. The properties of the ECU are the computation period in milliseconds (> 25 and
equal in all UDP connected boards) and the virtual keyboard TCP port (between 50000 and 65000, with 64000 as default).
-
Virtual Key - an input sensor, which generates a boolean value and can only be assigned to boolean inputs of the
deployed components. Each such sensor can be assigned a keycode (as defined by java.awt.KeyEvent, e.g. 'a' is 65,
'b' is 66, ...).
-
UDP-based Master/Slave Network - the network model element used to connect two or more beagle ECUs. Its master
period
-
UDP Network Connector - the connector element used to add connection points to the network model element. Each beagle
ECU usually has its connector already configured, so these elements are only needed an connection anchors for the network
element.
-
ConsoleOutput - an output actuator, which prints the current value of the deployed component ports (or NoVal) to
the Java standard output console. It supports all component architecture and data dictionary types.
Setup of the Compile environment for the generated source
First, switch to the Storage perspective in AF3 and create general project by right-clicking in the Navigator view and using the context menu.
This project will later be used by the deployment generator to put the generated source, the beagle HAL library and the start scripts there.
The easiest way to compile the generated source is to import this project into a standard Eclipse Java Development instance workspace.
This way, you can generate the code from AF3 into the project, switch to the Eclipse instance and refresh the imported project
with the new disk data and let Eclipse take care of the compilation.
Here is an example of the fully configured Eclipse project (already with generated source and scripts):
Note that all the directories and shell scripts are created by the generator.
In order to transform the the project created by AF3 (which is not a Java project, yet),
You may have to edit/add the files .project and .classpath.
Here is the example content used in the Eclipse project depicted above.
Running the deployment generator
Run the deployment generator from the context menu for the deployment model element in the AF3 modeling perspective
and select the created project as the target directory.
After the code was generated, switch to the Eclipse Java Development environment and refresh the imported project from there.
Since You setup the project to be a Java project, it should automatically be compiled.
Executing the Code
In order to execute the code, you must have setup your Java installation properly.
You can then open several terminals and run the start scripts.
In the following picture, You see that the master system beagle0 was started next to the virtual keyboard application,
while the slave system beagle1 was started on a separate
terminal.
The master startup indicates that initialized its communication ports and to wait for the slave system to appear.
Meanwhile, the virtual keyboard application should have appeared on your screen (its an empty AWT frame with a gray background).
Once You give this frame the focus and hit the 'a' key you should see the event in the master system's output.
Finally, once the slave system was also started and the initialization was successful, both units detected each other.
Now, the master clock started ticking and the slave unit printed the values of the ports deployed to its console output actuators.
The system will now run until one of the processes is killed. Notice, the PIDs that are printed during the master and slave system startup (2632 and 2642, in th example).
It is sufficient to kill the master system process, since slave units will terminate after they have not received a master clock signal for three expected periods.
Running the system for a fixed amount of logical rounds.
You can pass a positive integer argument to the start script of the master unit, in order to make it shutdown after that amount of logical execution rounds.
Again, the slave units will terminate themselves shortly after the master disappears.
However, you may get an exception from the virtual keyboard application if you type any key after the master is gone.
This feature is available to support testing without having to kill the background processes, manually.
Windows support
Since the current version of this beagle implementation is pure Java, it can also be run on Windows machines.
Please, inspect the create run scripts and make the corresponding terminal commands or create a corresponding set of batch files.