Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Now, when starting the application, the brick tries to connect with the nxjconsoleviewer. Press the Connect button. If connected succesfully, RConsole.println(...) commands will be written to this window. 

...

Creating an Example Project

The following shows how to create simple project, that will turn on a light if a button is pressed.

Create a new project:

  1. Choose File > New > Project > SCCharts Project
  2. In the project creation wizard that opens, select Mindstorms NXJ as environment and hit finish
  3. The project wizard from the leJOS plugin opens. Set the project name to Flashlight and click finish.
  4. The project is created and the model file is opened in an editor (This might take a few seconds).

Edit the model:

Change the contents of the model file to the following code and save it.

Code Block
themeEclipse
titleFloodlight.sct
scchart Flashlight {
    
    @Wrapper TouchSensor, S4
    input bool button;
    
    @Wrapper Floodlight, S1
    output bool light;
    
    initial state lightOff
    --> lightOn with button / light = true;
    
    state lightOn
    --> lightOff with !button / light = false;
}

This model will start in the state lightOff. If the button is pressed, it will turn on the light and change to the corresponding state, where the light is turned off, as soon as the button is not pressed anymore.

The annotations on the input and output variable are used to define which wrapper code is used to set / read them. @Wrapper TouchSensor, S4 will set the input variable to true iff the touch sensor on the port S4 is pressed. @Wrapper Floodlight, S1 on the output variable will turn on the red led of the light sensor that is attatched to port S1 iff the variable is true.

Launch the project:

With the mouse over the SCT file in the project explorer, perform Right Click > Run As > KiCo Compilation.

A launch config is created, which compiles the model to Java code and creates wrapper code from the annotations in the model file. Afterwards this output is compiled and deployed to the Mindstorms brick, by using the shell commands that are defined in the Mindstorms NXJ environment.