InAndOut-Designer - Wiki
Wiki
InAndOut-Designer
Create a new project#
1.Launch Cisco Unified Application designer
2.Select File -> New Project and give the Project name and Project location in "New Project Application Designer".
3.Now define Application script and Select Triggering event for InAndOut Application
- For InAndOut application the script is triggered by the Incoming Call Event i.e. Metreos.CallControl.IncomingCall
4.Your CUAD canvas now contains created default script (script1) and OnIncomingCall tabs
5.For this application it needs user inputs to process, like the destination DN to call, How many digits to rip off (Like we specify for a route pattern discarding digits).To get user input we need to add rows in Installer.
In the Project Explorer Right Click on Project Name and Select Add Installer -> New Installer
6.Save the created script "script1" if it prompts you to save.
7.Add the input fields required for InAndOut Application
Define Global variables#
1.We need to define global variables for destination DN, either application has to generate the destination DN automatically, how many digits to discard. As we are getting these variables from application and need to pass on to next actions to make call and hanging the call etc actions. Since local variable are only available for particular action level, we are creating these global variables.
Note: cuae engineers use naming convention 'g_' for global variables.
2.To define a global variable select the script1 tab in the canvas.
3.Right-click on the variables folder and select Add New Item
4.Select name of the variable, follow the above steps to create required global variables.
5. The variables g_to, g_ripOffDigits, g_useConfigDN, and g_useFromDN can all be initialized now. Select the variable g_to in the script1 canvas. Navigate to the lower right hand side of the screen to the Properties box. Click on the InitializeWith field and select Config.to from the drop-down list also configure variable type while intializing. Following this procedure, also initialize g_ripOffDigits, g_useConfigDN, and g_useFromDN with the corresponding Config variables. We will initialize OutgoingCallId, IncomingCallId, and g_whichMediaServer later.
Handle IncomingCall Event:#
1. We need to implement the handlers for different events generated. Here in our application we need to implement event "OnIncomingCall". To do this click on OnIncomingCall tab
2.After receiving a call we need to accept that call to get callid, from where the call is coming in. To implement this drag "AcceptCall" action from toolbox of CallControl. The designer will automatically connects the start node with accept call action
Capturing Variables#
1. As there could be many calls coming in and we need to tell which call to accept. OnIncomingCall event carries "CallId" with it.
For capturing the call id we need to create a local variable. This could be done by following process
- Right click on canvas and select "Variables Tray".
- Right click in variables tray and select "Add New Item". Set the name of the variable as "CallId".
- To initialize the value of the new local variable CallId to the event variable CallId, move the mouse to the properties frame. For the new CallId variable click on the drop-down select button next to InitializeWith and select the event variable CallId.
2.Selecting AcceptCall will bring you the properties of AcceptCall in properties frame displayed at lower right hand corner of the designer. The very first parameter under the Action Parameters set in AcceptCall is the parameter CallId. To bind the CallId parameter to the CallId local variable expand the CallId parameter by clicking on the + to the left of CallId. This will open the properties for the parameter. For the User Type set the property to variable. For the VAR name select CallId.
3. Using AcceptCall's Result Data, store MmsId in g_whichMediaServer and CallId in IncomingCallId.
Now we have to write logic in C# programming to process the handlers by the inputs given by user through input fields provided by Installers.
1.place "CustomCode" action from Application Components.
- here Custom code is required to accommodate SIP Protocol, if user wants to discard any leading digits and to auto increment DN to call the destination. Connect AcceptCall and CustomCode action by drawing a line called condition branch(Place mouse cursor on center of AcceptCall action then 'dot' will appear in the center of the icon and your cursor will turn into a 'hand'. Once your cursor has become a 'hand', click and drag the cursor from the AcceptCall action to the CustomCode action). It is labeled as "default" means if AcceptCall action is complete then default conditional-step is CustomCode.
2.Selecting customcode action will display Basic properties of CustomCode at lower right-hand side of the designer. The very first property is the "Code", Click on the button available in Code. It will open a 'Code Editor' to write the our own code to execute.Click on 'Ok' after writing the code that will automatically save the code.
- Write this code in the editor and then click 'Ok'
public static string Execute(ref string From, ref string g_to, bool g_useConfigDN, bool g_useFromDN, string OriginalTo, int g_ripOffDigits, LogWriter log){ Add to provide flexability when testing SMA-1150 if (!g_useConfigDN){if (g_useFromDN){ Add to support SIP Phone In / SIP Trunk out testing int num; num=System.Convert.ToInt32(From.Substring(g_ripOffDigits)) + 1; g_to = num.ToString(); } else { g_to=OriginalTo.Substring(g_ripOffDigits); } } return IApp.VALUE_SUCCESS; } }}}
3.Place 'MakeCall' action from CallControl group.This action will create two new events (we will handle these very soon) in the project - "OnMakeCall_Complete" and "OnMakeCall_Failed". Now Pass the control from CustomCode to MakeCall action by default condition connector.
Configure MakeCall Action#
MakeCall action requires :
- Conference(true/false) - To Enable conference
- ConferenceId
- From - Calling phone DN
- Hairpin - true/false
- To - DN to call
- Result Data CallId - Outgoing call id
Create new local variable 'From' to hold DN from where the call is coming in and initialise with 'From. Link 'From' to the MakeCall property 'From', Enable conference by typing 'true', ConferenceId as '0' (infact any integer), Hairpin to true.
Create a global variable 'OutgoingCallId'. We need this to end the call when MakeCall action is completed/failed. Set MakeCall 'Result Data' parameter with this variable 'OutgoingCallId'
- If MakeCall is successful then we need to close the current running function , if MakeCall is not successful then the script has to closed by hanging the dialed phone
If MakeCall action is successful then it will raise OnMakeCall_Complete event If MakeCall action is failed then it will raise OnMakeCall_Failed event.
- To close the function drag "EndFunction" action from Application Components tools and place in the canvas. Connect "MakeCall" and "EndFunction" with a condition branch connector.
- Click on the "default" label of the connector. From the drop down list select "Success"
- Drag and place the "Hangup" action tool from CallControl tools, draw a branch condition connector from output end of "MakeCall" action to input end of "Hangup"
- Initialize "Hangup" action parameters
- Place the "EndScript" action from 'Application components' tools. Connect "Hangup" action to "EndScript"
Process OnMakeCall_Complete:#
- Drag and place a AnswerCall action from CallControl tools, draw a branch connector from output end of "Start" node to input end of "AnswerCall" action
- Create a local variable "ConferenceId" by right clicking in the variable's tray and initialize with "ConferenceId".
- Set AnswerCall's parameter CallId to variable IncomingCallId.
- Initialize "AnswerCall" action parameters with appropriate variables or values as shown in picture.
- If the "AnswerCall" action is successfully handled (i.e Call has been received at the other end), then we need to close the function end, if not the application has to end the call by invoking "Hangup" event and then closing the script.Initialize Hangup action's CallId parameter with "OutgoingCallId".
Process OnMakeCall_Failed:#
- If the "MakeCall" event is failed (i.e Call has not been generated), then the application has to end the call by invoking "Hangup" event and then closing the script.Initialize Hangup action's CallId parameter with "IncomingCallId".
Handling Remote Hangup#
If an active call is hanged up remotely then we need to properly end the call from the receiving end as well as at the calling end.
To do this
1.Click on the Script tab
2.Place a RemoteHangup event from CallControl tools this will automatically creates a new tab in the canvas
3.Click on the OnRemotehangUp event tab. Place 'Compare' action from 'Application Components'. This will automatically connect with Start node.
4.R-Click on the variable tray and create a new local variable CallId. Initialize with CallId.
5.Configure Compare action value1 with global variable 'IncomingCallId' and Value2 with CallId.
6.Place two 'HangUp' actions from CallControl tools one underneath and one beside the compare action.
7.Connect two HangUp actions with Compare action's condition. Give equal condition to one and unequal to other.
8.Configure the equal HangUp action with OutgoingCallId. Configure the unequal HangUp action with IncomingCallId.
9.Place a EndScript action and connect both HangUp actions to it.
Handling StartTx, StartRx, StopTx Events#
1.Click in script1 tab and add StartTx, StartRx, StopTx events from call control tools. Each will automatically create OnStartTx, OnStartRx, and OnStopTx tabs respectively.
2.Place an EndFunction action in each of these events that will automatically be connected with Start.
Building & Deploying#
1. Select Build -> Build Project. The output of the build will be displayed at the bottom of the screen.
2. When the build is successful, the application needs to be deployed in order to run. To configure the deployment options, select Tools -> Options -> Connectivity. Make sure to enter the correct server address, username, and password.
3. Now to deploy, go to Build -> Deploy. The output of the deployment will be displayed at the bottom of the screen.
Configure the Application#
Logon to the application manager. Go to Applications -> Find/List Applications. Select InAndOut_cuad. Configure the various parameters as necessary and select "Apply".
Add a Trigger#
1. Go to Applications -> Find/List Triggers. Select InAndOut_cuad. Specify the trigger "to" and "######". Select "Add Parameter".