Developing Apama Applications > Developing Apama Applications in Event Modeler > Overview of Using Event Modeler > How rules define scenario behavior
How rules define scenario behavior
States matter because of the distinct behavior that the scenario instance will follow while in a particular state. And that is defined in each state’s set of rules. A state can have one or more rules defined in it. Each rule has the following structure; “if a condition is true then do the following …”.
The center panel has two parts — Global Rules and Local Rules. A global rule can apply to more than one state. A local rule can apply to exactly one state. When you select a state in the Event Flow tab, the rules defined for that state appear in the Rules panel.
Each rule has a condition part, denoted by When, and an action part, indicated by Then. The part indicated by thesymbol is just a descriptive comment that you can set to whatever you like. You can hide or show the comment by selecting in the Event Modeler toolbar. The start state illustrated in the previous topic has two local rules, including this rule:
Sample local rule
This is stating:
*when true, which means: always do this,
*then do the following:
*carry out the start operation on the following block instances
*  Market Depth 1
*  Market Depth 2
*  Spread Calculator
*  Spread Data Distribution Calculator
*  Position Calculator 1
*  Position Calculator 2
*  P&L Calculator
*set the StatusMessage variable to “Waiting for price data
* continue, that is, evaluate the next local rule
Variables: For now it is enough to know that, as in other programming environments, scenario variables are placeholders for useful information that the scenario needs to keep track of and perhaps modify during its execution. They also identify the information that will be required by a running instance of the scenario from the end-user in order to configure and start it off, as well as representing the information that will be sent back to be displayed to the user as progress updates or results.
*Variables are typed; each can be of type text, number, choice or true/false.
*Variables are described in About scenario variables.
Blocks: Likewise, blocks are ready-packaged modules that you can import and use within your scenarios. They can accept inputs, execute some logic of their own, and generate output. A block can consist of Input feeds (which contain one or more input fields), Output feeds (which contain one or more output fields), Parameters, and Operations. Block parameters and fields are typed; each can be of type text, number, choice or true/false. Blocks are described in About blocks.
In addition to the standard blocks provided with Event Modeler, you can build custom blocks in Apama Studio.
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.