Table of Contents

Understanding the example application loop.xml

In the previous tutorial, we have seen how to compile the sample library and how to execute an application related to it, namely the application described in file loop.xml. In order to follow the explanations below, you may read the page concerning ARCS main concepts.

Contextual part

This application must load the component library we previously compiled (sample, you can notice you can strip the library name from its lib prefix as well as its extension. This way it is portable between unix-like systems and windows). It is composed of three components:

In the application is also defined a constant that gives the number of iterations the loop must perform.

Configurational part

In this configuration, there is only one main process. It is controlled by the statemachine we previously defined. Therefore, we find two sheets named start and end (the same names as the names of the states from the statemachine). The empty sheet end is signaling it is the end of the application. The sheet start connects loop with display component and loop with statemachine. The actual run is started with the postconnection invocation.

Running behaviour

In our application, setIterations(int) starts the loop with a given number of iteration. Each iteration sends a newIteration(int) signal connected to the display(int) slot of display component, causing the display of the emitted integer. Once the loop is finished, it sends the sendToken(QString) signal with a token end. It triggers a change of state in the statemachine that goes into the final state end. Then the start sheet is undone and the end sheet is started and triggers the end of the application.

XML Description of the application

<application mode="event">
  <context> <!-- beginning of contextual part -->
    <libraries>
      <library path="../../sample/sample"/>
    </libraries>
    <components>
      <component id="b" type="Loop" />
      <component id="d" type="DisplayInt" />
      <component id="s" type="StateMachine">
        <statemachine>
          <first name="start"/>
          <last name="end"/>
          <transitions>
            <transition source="start" token="end" destination="end"/>
          </transitions>
        </statemachine>
      </component>
    </components>
    <constants>
      <constant id="iterations" type="int">5</constant>
    </constants>
  </context>
 
  <processes> <!-- beginning of the configurational part -->
    <process controller="s">
      <sheet id="start">
        <connections>
          <link source="b" signal="newIteration(int)" destination="d" slot="display(int)"/>
          <link source="b" signal="sendToken(QString)" destination="s" slot="setToken(QString)" />
        </connections>
        <postconnections>
          <invoke destination="b" slot="setIterations(int)" type="constant">iterations</invoke>
        </postconnections>
      </sheet>
      <sheet id="end"/>
    </process>
  </processes>  
</application>