SCXML Based AD

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 17

11111111 MAVENIR INTERNAL

1 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

SCXML Based Application Development

Release: 1.0
22222222 MAVENIR INTERNAL
2 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

CONTENTS

SCXML BASED APPLICATION DEVELOPMENT...........................................................1

RELEASE: 1.0...................................................................................................................1

REVISION HISTORY.........................................................................................................4

1 INTRODUCTION..........................................................................................................5
1.1 Target Audience......................................................................................................................................................5

1.2 Purpose....................................................................................................................................................................5

1.3 Acronyms................................................................................................................................................................5

1.4 References...............................................................................................................................................................5

2 STATE MACHINE ENGINE (SME)..............................................................................5

3 SME PACKAGES.........................................................................................................9

4 IMPLEMENTING A NEW SME PACKAGE..................................................................9


4.1 Package Implementation class..............................................................................................................................9

4.2 Package context class...........................................................................................................................................10

4.3 Command class.....................................................................................................................................................10

4.4 Event class.............................................................................................................................................................10

5 SCXML SERVICE.......................................................................................................11
5.1 Initializing SME....................................................................................................................................................11

5.2 Initiating a new SME session and posting events..............................................................................................11

5.3 Events / Responses from SME.............................................................................................................................12

6 LIST OF CURRENTLY SUPPORTED SME PACKAGES.........................................12

7 DEVIATIONS/EXTENSIONS W.R.T SCXML STANDARD........................................14


7.1 SME Definitions file.............................................................................................................................................14

7.2 Event Data Model.................................................................................................................................................14

7.3 <invokescxm> tag.................................................................................................................................................15

7.4 <done> tag.............................................................................................................................................................15

7.5 <pushevent>/<popevent> tag..............................................................................................................................15


33333333 MAVENIR INTERNAL
3 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

8 EXAMPLE SCXML.....................................................................................................15

9 SCXML CODING GUIDELINES.................................................................................16


9.1 Syntax/Naming conventions................................................................................................................................16

9.2 Modularity and Reusability.................................................................................................................................17

9.3 Things to avoid.....................................................................................................................................................17


44444444 MAVENIR INTERNAL
4 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

Revision History

Issue Date Reason for Change Author


1.0 2015-01-27 Initial Dattatreya, Siddharth
55555555 MAVENIR INTERNAL
5 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

1 Introduction
1.1 Target Audience
This document is intended to be a reference guide for developers implementing SCXML based
applications.

1.2 Purpose
SCXML or State Chart XML is an XML-based markup language that provides a generic state-
machine based execution environment. Mavenir’s State Machine Engine (SME) framework
interprets and executes application logic written using SCXML.
This document provides an introduction to the SME framework and shows how to implement new
application packages and commands based on SME. The list of currently supported packages and
commands are also listed. Additionally, the deviations of the SME implementation w.r.t the SCXML
standard and the non-standard extensions to SCXML that have been adopted are mentioned in this
document.

1.3 Acronyms
SCXML – State Chart Extensible Markup Language
SME – State Machine Engine

1.4 References
[1] http://www.w3.org/TR/scxml/
[2] http://en.wikipedia.org/wiki/SCXML
[3] Reference code can be found at – mmx/sme, vendor/expreval, appCommon/smepkgs,
tas/vmAsMgr/vmAsApp/services/scxmlsvc

2 State Machine Engine (SME)


This section describes the SME framework. The code related to SME and the expression evaluation
library used by SME can be found at mmx/sme and vendor/expreval in the branches PLAT-C_6_1,
PLAT-C_6_2 and PLAT-R6.

1. State Machine Initialization:


Application will perform following steps to initialize the SME
66666666 MAVENIR INTERNAL
6 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

Application SMEStateMachineEngine

initialize

registerPackage

registerPackage

registerDefintions

parseStateMachine

 Initialize accepts Application Logger and TimeZone related information


 All packages required by the application must be registered with SME
 There may be some Definition files used to convert short form of variable usage to
their long form. All required definitions also need to be registered with SME
 Last step is to provide all scxml buffers to be used during runtime.

2. As part of application startup, it will read the SCXML buffers from DB and input them to
SME through parseStateMachine API. SME parses them and creates a state machine
structure. Parsed output will look like below.
77777777 MAVENIR INTERNAL
7 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

Each of the scxml buffer will translate to one StateMachine structure, which contains one or
more States. Each state in turn contains optional onentry, optional onexit blocks and a set of
transitions and a set of invokescxml commands.

Onentry and Onexit blocks are executable contents containing one or more commands to
execute. Transitions specify an event on which transition should occur and an executable
content block to be executed before transition. Invokescxml command is used to start
executing another statemachine. Parameters can be passed to invoke a scxml.

ExecutableContent is a set of commands either provided by SME or implemented by


packages. Commands provided by SME are
a. assign : to assign a value to a location
b. log : to output some information to log file
c. if/elseif/else : conditional statements
d. done : return from a statemachine to parent statemachine
e. pushevent : save the current event in statemachine for later use
f. popevent : retrieve the pushed event

All expressions present in conditional statements, assign, log, invokescxml are parsed and
executed using a 3rd party expression evaluation library (present in the following cvs path
vendor/expreval).

3. SME RunTime:

Following flow represents the interaction b/w application and SME at run time.
88888888 MAVENIR INTERNAL
8 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

Application ISMEAppContext SMEStateMachineEngine ISMEStateMac ISMEStateMac


hine hineContext

1: create

2: createContext(ISMEAppContext)

3: createContext

4: create

5: ISMEStateMachineContext

6: ISMEStateMachine, ISMEStateMachineContext

7: begin(ISMEStateMachineContext)

8: Start executing SCXML

9: return (StateMachineStateEn)

handleEvent continues till SME


returns STATEMACHINE_END
10: handleEvent(ISMEEventToStateMachine, ISMEStateMachineContext)

11: continue executing SCXML

12: return(StateMachineStateEn)

on getting
STATEMACHINE_END
13: releaseContext(ISMEStateMachineContext)

14: delete

a. Whenever a new session is created in application, corresponding contexts have to be


created on SME. Application will create an instance of ISMEAppContext and invoke
createContext on SME. SME will create a context and return the ISMEStateMachine,
ISMEStateMachineContext.
b. Application will invoke begin on ISMEStateMachine to start executing the scxml. Scxml
execution continues till a point where it has to wait for an instruction to complete or the
execution ends.
c. Application feeds further events through API handleEvent and statemachine contines
executing the scxml from the point it left previously. Step c continues till scxml reaches
end point which it will indicate to Application.
99999999 MAVENIR INTERNAL
9 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

d. On getting return value as STATE_MACHINE_END, application will invoke


releaseContext to release the SME’s context for this session.

4. Package commands:

SME allows various packages to plugin their functionality by providing command objects which are
parsed and executed along with SME basic commands. These extension commands are provided by
registered packages.

3 SME Packages
A package is a set of SCXML executables or commands which work together to implement a
specific functionality. Each package has a unique namespace associated with it.
A package can be generic enough to be reused across many applications or may be specific to an
application. All generic packages are implemented and placed under appCommon/smepkgs in the
branch APPCMN-R6. All application specific packages can be placed under the application’s code
hierarchy.

For example, a set of commands can be created for database interaction and grouped under the
database package. Some examples of commands under the database package –

<database:loadprocedure procname="$ProcedureName"/>

<database:assignparameter procname="$ProcedureName" paramname="subscriberNum" paramtype="input"


datatype="string" value="$trn:DVTGPN_DIGITS"/>

<database:assignparameter procname="$ProcedureName" paramname="submitTime" paramtype="input"


datatype="string" value="$CurrentDateTime"/>

<database:executeprocedure procname="$ProcedureName" proctype="INSERT"/>

As shown in above example, all commands belonging to the database package have the “database:”
prefix or namespace.

4 Implementing a new SME package


To implement a new package, the following steps need to be followed –

4.1 Package Implementation class


Write a new package implementation class which extends smepkg::PackageImpl, for ex –

class DatabasePackageImpl : public smepkg::PackageImpl

The package implementation class is responsible for several functions like –


 Creating/deleting the package context
 Creating/deleting event objects
 To retrieve package specific data and return to SME (using getAppData())
1010101010101010 MAVENIR INTERNAL
10 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

 To set values for package variables from SCXML (using setAppData())

4.2 Package context class


Write a new package context class. This class holds the package specific data corresponding to a
session/call. For ex,

class DatabasePackageContext : public sme::ISMEPackageContext

4.3 Command class


Each of the commands that the package implements is written as a new class which extends sme::
ISMEPackageCommandHandle. For ex,

class MsmlAssignParameterCommand : public ISMEPackageCommandHandle

There are 2 methods which every command class has to implement –

virtual bool preProcess(SMEPackageCommand* pPkgCommand,


ISMEDataKeyResolver* pDataKeyResolver);
virtual bool execute(ISMEAppContext* pAppContext, ISMEPackageContext* pPackageContext,
ISMEDataValueSet* pDataValueSet);

Whenever SME encounters a package command when parsing the SCXML, it calls
createPackageCommandHandle() on the registered package implementation class to create a
command object. Please note that each package implementation class provides its own
implementation for createPackageCommandHandle() to create all the command objects supported by
the package. Once the command object is created by the package and returned to SME, preProcess()
is called by the SME on the command object.
The function execute() SME calls execute() on the command object at runtime when the
corresponding SCXML command is encountered.

4.4 Event class


All the events that the package needs to handle also need to be implemented. Several events can be
handled by a single class or each event can be handled by a separate class.

class MsmlSuccessResponseEvent : public ISMEEventToStateMachine

Each event class is required to implement 2 functions –


virtual SMERet getEventParam(const std::string& paramname, SMEValue& val);
virtual SMERet getEventName(std::string& eventName);

getEventName() is called by SME to get the name of the event. getEventParam() is called by SME
whenever SCXML accesses event data (using syntax of the form $_event.xxxx).

5 SCXML Service
In VMAS application, the SCXML service module is responsible for initializing SME at startup and
for driving the execution of the SME at runtime for every call/session. SCXML service delivers
1111111111111111 MAVENIR INTERNAL
11 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

events from the application to SME and vice versa. Reference code can be found at
tas/vmAsMgr/vmAsApp/services/scxmlsvc in branches VMAS-R1, VMAS-C-1_0.

5.1 Initializing SME


The following steps are executed in order to parse the SCXML files at startup –
 Register the required packages with SME
o Packages are registered with the SME using SMEStateMachineEngine::
registerPackage(). The reference code can be found at ScxmlSvcMgr::InitSME().
 Load the SME Definitions file(s) if any (please refer to section 7.1 for overview on SME
definition files)
o The reference code can be found at ScxmlSvcMgr::RegisterSMEDefinitions()
 Load any data required by the packages, for example MSML templates in case of
MSML/MRF package
o This step is dependent on whether the package initialization requires any data to be
loaded into the package or not. The reference code can be found at
ScxmlSvcMgr::LoadTemplateData() which is used for initializing template data into
MSML and REST packages.
 Parse and create state machine
o To parse SCXMLs and create state machine, SMEStateMachineEngine::
parseStateMachine() function is used. Reference code can be found at
ScxmlSvcMgr::CreateStateMachine().

5.2 Initiating a new SME session and posting events


SCXML service receives the event to start a new SME session from the application. This can happen
for example, when a new INVITE is received. SCXML service creates a new SME context and
initiates its execution.

ISMEStateMachineContext* pStateMachineCtx = m_pSME->createContext(scxml, pScxmlAppCtx, pStateMachine);


StateMachineStateEn result = pStateMachine->begin(pStateMachineCtx);
ScxmlSvcMgr::BeginStateMachineExecution() contains the reference code which implements this.

SCXML service also handles all the events that have to be posted towards SME. The implementation
of the same can be found in ScxmlSvcMgr::OnEvent().
SME requires that each event be represented by an event object. Each package is responsible for
creating the event objects for the events it handles. SCXML service acts as a broker and gets the
appropriate event object from the package chosen based on the input event type as shown in the
below code snippet –

smepkg::PackageImpl* pEventHandler = ResolveEvent(msgType, packageEventType);


ISMEEventToStateMachine* pEvent = pEventHandler->CreateEvent(packageEventType, msg.data);

The created event object is then posted to the SME using ISMEStateMachine::handleEvent().
1212121212121212 MAVENIR INTERNAL
12 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

5.3 Events / Responses from SME


Events or responses from the SCXML/SME towards the application are posted by executing a
package command. If the handling of the event requires the application to interact with an external
entity, then it is achieved by the ‘Service’ module associated with the package.
For example, in MCA (Missed Call Alert) application, there is an McaDbSvc module which helps the
‘database’ package to interact with ‘genericDbMgr’ process to execute stored procedures in Oracle.
Consider the below command –
<database:executeprocedure procname="$ProcedureName" proctype="INSERT"/>
In DatabaseExecuteProcedureCmd::execute() method, an event is posted towards the McaDbSvc in
order to handle the execution of the stored procedure as shown below –
pPackageImpl->GetAppInterface()->SendMsg(EVENT_DATABASE_REQUEST,
dbRequest, dbReqSize, pAppContext);
McaDbSvc sends MX message to genericDbMgr in order to execute the stored procedure.

6 List of currently supported SME packages


The generic SME packages currently supported and placed under appCommon/smepkgs are –

Apart from the above there is a ‘time’ package included by default with the SME. VMAS has also
defined 2 packages specific to itself – vmas and vmasdb.

The commands supported under the generic appCommon packages and time package are listed
below.

Database Package: This package can be used for executing Oracle stored procedures from SCXML.
Command name Parameters Description
loadprocedure To choose a specified stored
procedure to be executed
assignparameter To assign input and output
parameters to the stored
procedure loaded
executeprocedure To execute a given stored
procedure
getrecordcount To get the number of records
1313131313131313 MAVENIR INTERNAL
13 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

in the returned cursor


storecursor To store the cursor returned as
a result of stored procedure
execution
getnextrecord To move to the next record in
the cursor

MAP Package: This package provides for performing few MAP requests.
Command name Parameters Description
registerss Sends RegisterSS MAP
command to HLR
activatess Sends ActivateSS MAP
command to HLR
erasess Sends EraseSS MAP
command to HLR
srism Sends SRISM to HLR

MSML Package: This package can be used to send MSML requests over SIP INFO message to the
MRF.
Command name Parameters Description
loadtemplate To load a specified MSML
template
assignparameter To assign values to the ‘$’
variables in the template
sendmessage To send out the MSML request

REST Package: This package supports sending REST requests over HTTP to entities like MStore.
Command name Parameters Description
loadtemplate To load a specified REST
template
assignparameter To assign values to the ‘$’
variables in the template
sendmessage To send out the REST request
getfolderdata To retrieve data from a folder
getobjectindex To get the index of a specific
object in the object list
getobjectdata To get the data corresponding
to a specific object
sortobject To sort an object list

SMPP Package: This package supports few SMPP operations like submit_sm.
Command name Parameters Description
loadtemplate To choose the SMPP request
to be submitted
assignparameter To assign values to the
variables in the request loaded
1414141414141414 MAVENIR INTERNAL
14 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

sendmessage To submit the SMPP request

TMM Package: This package can be used for pegging counters from SCXML.
Command name Parameters Description
setcounter To peg a specified counter

Translation Package: This package can be used for applying translation from SCXML.
Command name Parameters Description
applytranslation To apply translation based on
profile name

Time Package: This package provides few Date/Time utility functions and also supports creation /
deletion of timers.
Command name Parameters Description
getgmt To get the current time in UTC

7 Deviations/Extensions w.r.t SCXML standard


7.1 SME Definitions file
SME provides a way to replace $variables defined in the SCXML with their actual values before
SCXML parsing takes place. This is a preprocessor feature in SME, similar to #define in C/C++. It is
provided to make the SCXMLs more readable. It could be used for example to replace a variable
name with its XPath expression at runtime like in the below example -
<?xml version="1.0" encoding="UTF-8"?>
<definition>
<parameter>
<name>$saved_message_count_path</name>
<value>$_event.count(//flag/name[text()='\Saved'])</value>
</parameter>
<parameter>
<name>$new_message_count_path</name>
<value>$_event.count(//flagList[not(normalize-space())])</value>
</parameter>
</definition>
The SME definitions file is registered with the SME using
SMEStateMachineEngine::registerDefintions(const string& defID, const string& defBuffer).
In the example given, assuming that we have registered the SME definitions file with the defID
“mstoredef”, the expression $mstoredef: new_message_count_path is replaced by the SME
preprocessor with $_event.count(//flag/name[text()='\Saved']) before the SCXML parsing takes
place.

7.2 Event Data Model


SME doesn’t mandate any specific data model to be followed while writing SCXML. Event data
parsing is application specific.
$_event.a/b/c -> xpath
$_event.abc_def -> package specific
1515151515151515 MAVENIR INTERNAL
15 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

7.3 <invokescxm> tag


This is used to invoke a scxml from within another scxml. An event will be created with the event
name and the parameters specified along with this tag and sent to invoked scxml.

7.4 <done> tag


SME has introduced a new tag <done> with parameters to return from an SCXML(to parent). An
event will be formed and sent back to parent in this case

7.5 <pushevent>/<popevent> tag


SME provides the current event to be stored for later usage through pushevent. Later the same event
can be retrieved using popevent.

8 Example SCXML
The SCXML files corresponding to VMAS and MCA services can be found at cust/scripts/vha and
cust/scripts/mca in CUST-R6 branch.
An example SCXML file from MCA application is given below. This file defines the entry point for
MCA application. Based on the incoming session-creating events like new INVITE received or
SMPP deliver_sm received, the file invokes the corresponding SCXMLs - RegisterMCA.scxml
(which handles the INVITE received event), NotifyUser.scxml(which implements sending
MCA/NotifyMe SMS on receiving the deliver_sm) etc.
<?xml version="1.0" encoding="UTF-8"?>
<scxml initial="initial" version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
xmlns:mrf="www.mavenir.com/packages/mrf" xmlns:mstore="www.mavenir.com/packages/mstore"
xmlns:trn="www.mavenir.com/packages/trn" xmlns:vmas="www.mavenir.com/packages/vmas"
xmlns:vmasdb="www.mavenir.com/packages/vmasdb" xmlns:tmm="www.mavenir.com/packages/tmm"
xmlns:time="www.mavenir.com/packages/time" xmlns:smpp="www.mavenir.com/packages/smpp"
xmlns:database="www.mavenir.com/packages/database" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">
<datamodel>
<data expr="9999" type="string" id="SequenceNum"/>
<data expr="" type="string" id="SubscriberNum"/>
<data expr="" id="MessageID" type="string"/>
<data expr="smsc8215" id="SmscID" type="string"/>
</datamodel>
<state id="initial">
<onentry>
<assign location="$vmas:ueprofile.COS"
expr="$vmasdb:ServiceParameters.MCA_DEFAULT_COS"/>
<assign location="$SmscID" expr="$vmasdb:ServiceParameters.smscID"/>
</onentry>
<transition event="vmas.invite.received" target="CheckFeatureEnabled"/>
<transition event="smpp.deliver_sm.success" cond="$_event.command_status ==
'DELIVERED'" target="InvokeNotifyUser">
<assign location="$SequenceNum" expr="$_event.sequence_number"/>
<assign location="$MessageID" expr="$_event.message_id"/>
<assign location="$SubscriberNum" expr="$_event.dest_addr"/>
</transition>
<transition event="smpp.deliver_sm.failure" target="InvokeRetrySilentSM">
<assign location="$SequenceNum" expr="$_event.sequence_number"/>
<assign location="$SubscriberNum" expr="$_event.dest_addr"/>
</transition>
</state>
<state id="CheckFeatureEnabled">
<transition cond="$vmasdb:cos.MCA_FEATURE_FLAG != 'Yes' &amp;&amp;
$vmasdb:cos.NOTIFY_FEATURE_FLAG != 'Yes'" target="final">
<vmas:setinternalcausecode id="CC_MCA_AS_DEPOSIT_FAIL"/>
<vmas:sendsipresponse method="INVITE"/>
</transition>
<transition target="CheckIfMCACall"/>
1616161616161616 MAVENIR INTERNAL
16 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

</state>
<state id="CheckIfMCACall">
<onentry>
<trn:applytranslation trnname="PRTCT"/>
<trn:applytranslation trnname="TRN"/>
</onentry>
<transition cond="$trn:SVCCAUSE == 'MCA_APP' &amp;&amp; $trn:CLIAVLBL == true"
target="InvokeRegisterMCA"/>
<transition cond="$trn:SVCCAUSE != 'MCA_APP'" target="final"/>
<transition cond="$trn:CLIAVLBL == false" target="final">
<vmas:setinternalcausecode id="CC_MCA_AS_DEPOSIT_FAIL"/>
<vmas:sendsipresponse method="INVITE"/>
</transition>
</state>
<state id="InvokeRegisterMCA">
<invokescxml event="RegisterMCA" target="RegisterMCA.scxml"/>
<transition event="RegisterMCA.success" target="final"/>
<transition event="RegisterMCA.failure" target="final"/>
</state>
<state id="InvokeNotifyUser">
<invokescxml event="NotifyUser" target="NotifyUser.scxml">
<param name="sequence_number" expr="$SequenceNum"/>
<param name="message_id" expr="$MessageID"/>
<param name="dest_addr" expr="$SubscriberNum"/>
</invokescxml>
<transition event="NotifyUser.success" target="final"/>
<transition event="NotifyUser.failure" target="final"/>
</state>
<state id="InvokeRetrySilentSM">
<invokescxml event="RetrySilentSM" target="RetrySilentSM.scxml">
<param name="sequence_number" expr="$SequenceNum"/>
<param name="dest_addr" expr="$SubscriberNum"/>
</invokescxml>
<transition event="RetrySilentSM.success" target="final"/>
<transition event="RetrySilentSM.failure" target="final"/>
</state>
<state id="final">
<onentry>
<done/>
</onentry>
</state>
</scxml>

9 SCXML Coding Guidelines


It is recommended to follow the guidelines mentioned in this section while writing SCXMLs to
ensure uniformity and readability.

9.1 Syntax/Naming conventions


 State names should begin with a capital letter. There should be no ‘underscore’ characters in
state names. Every word in a state name should begin with a capital letter. For ex,
“DepositMessage”, “CheckIfRecordingIsValid” etc. Do not use “deposit_message”,
“apply_translation” etc.
 Command names should be in small case and should have the package prefix. For example,
<trn:applytranslation …>. The names of the attributes of a command should also be in small
case.
 Events handled by a particular package should have the package prefix in the event name. For
example, “smpp.submitsm.success”. It is recommended to use small case for package event
names.
 The event name to be used while invoking an SCXML should have the SCXML name as the
prefix. Similar convention is to be followed for event names returned by an invoked SCXML.
 Within a state, tags should be defined in following order if present - <onentry></onentry>
<transition></transition><invokescxml></invokescxml><onexit></onexit>
1717171717171717 MAVENIR INTERNAL
17 (17)
Prepared by No.

Name: SCXML Based Application Development


Approved Checked Date Rev Reference

12/01/2015 1a

 There shouldn’t be multiple invokescxml within a state without condition ‘cond’.


 For variables of type int, do not use comparison with values inside ‘’.For example,
<data expr="0" id="RecordingDone" type="int"/> use it in condition as below:
cond="$RecordingDone==1" rather than cond="$RecordingDone==’1’"
 Handle all the events returned by invoked scxml in the State from Invoking scxml.
 Use &gt; &lt; &amp; &amp; instead of > < or &&.

9.2 Modularity and Reusability


 Wherever possible, the common functions used at multiple places in the call flow need to be
present in a reusable SCXML. Some examples are the reusable MRF and MStore SCXMLS
like mrfPlayPrompt.scxml, mailboxOperations.scxml etc.
 It is recommended to have 1 SCXML file per SDL diagram given in the FRS. This ensures
1:1 mapping between the SDLs and SCXMLs.
 If there is a common event to be handled by many states in an SCXML, consider using a
parent state for these states and handling the event there

9.3 Things to avoid


 Avoid loops in the SCXML call hierarchy. For example, if SCXML A calls B, B calls C and
there is a transition required from C to A when some event occurs, then it is recommended
that C returns to B and B returns to A, instead of C invoking A.

You might also like