< Previous | Next >

Creating the state machine

With the necessary artifacts in place, you can now create the state machine, and configure it appropriately.

In this step, you will do the following:
  1. Create a new state machine as follows:
    1. Right-click the BSM_VendingMachine module and choose New > Business State Machine from the list.
    2. In the New Business State Machine wizard, name the state machine VendingMachine and click Next.
    3. On the Select an Interface page, choose VendingMachineInterface from the Interface drop down list, expand the on operation, select, id : string, and click Finish. This is the first operation, and it starts the vending machine.
      The Select an Interface wizard showing the proper selections.
    A new state machine is created, and appears in the editor as shown in this image:
    The state machine as it first appears
    You will also notice a number of errors in the workspace in the form of red "X's". There is an error for every operation in the interface that we haven't included in the implementation yet (so far, only on is used), and there is one error for every operation referring to the correlation set. We will fix the correlation set next.
  2. Specify a correlation. A correlation defines properties that are used to distinguish one instance of a state machine from another within a runtime environment. For each operation (event) that the state machine responds to, a property alias locates the input that corresponds to each correlation property that is defined.
    1. Click the plus icon (The plus symbol) in the Correlation Properties category.
    2. In the Add Correlation Property dialog, change the name to id.
    3. Select string and click OK.
    4. In the Description tab of the Properties area, select each operation in turn, click Add, and specify property aliases as shown in the following table. You will be working with the XPath Expression builder, so you can browse to the necessary path, and double click your selection.
      Operation Alias
      on /id
      deposit /coin/id
      select /selection/id
      cancel /id
      off /id
  3. Create a variable to hold the running total of coins that have been deposited:
    1. Click the plus icon (The plus symbol) in the Variables category.
    2. In the Add Variable dialog, name the new variable to total.
    3. Select double as the type, and click OK.
  4. There are errors in the problems view that are related to the default correlation property that was created when you created the business state machine. This property is not used in the sample, and can be deleted. In the Correlation Properties category, click CorrelationProperty1. Click the delete icon (The delete symbol).
Save your work. You will notice that there are now only four errors reported in the problems view.
< Previous | Next >





Feedback



This information center is powered by Eclipse technology. (http://www.eclipse.org)