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:
- create a state machine
- specify a correlation
- create a variable
- Create a new state machine as follows:
- Right-click the BSM_VendingMachine module
and choose from the list.
- In the New Business State Machine wizard,
name the state machine VendingMachine and click Next.
- 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.
A new state machine is created, and appears in the editor
as shown in this image: 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.
- 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.
- Click the plus icon in the Correlation Properties category.
- In the Add Correlation Property dialog,
change the name to id.
- Select string and click OK.
- With the id correlation property selected, click the
Properties tab to open the Properties view. In the Description tab
of the Properties view, select each operation in turn, click Add,
and specify property aliases as shown in the following table. In the XPath Expression builder, click Insert Simple
XPath and browse to the necessary path. Double click your
selection and click OK.
Operation |
Alias |
on |
/id |
deposit |
/coin/id |
select |
/selection/id |
cancel |
/id |
off |
/id |
- Create a variable to hold the running total of coins that
have been deposited:
- Click the plus icon (
) in the Variables category.
- In the Add Variable dialog, name
the new variable to total.
- Select double as the type, and
click OK.
- 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 (
).
Save your work. You will notice that there are now only four
errors reported in the problems view.