Analytics Manager > Using the Tutorials > Tutorial: Create a Simulation Analysis Event
  
Tutorial: Create a Simulation Analysis Event
During the course of this tutorial, you will learn how to create an analysis provider and an analysis model. Once you enable the analysis model, you can create a simulation event on the TW_AS_SimulationDemo_AdditionSimulationThing thing. You can use the TW_AS_SimulationDemo_AnalysisSimulationDemoMashup demo mashup to generate jobs and view results.
1. Create the analysis provider.
* 
Note the following points:
In the Provider Name (Required) field, enter the name of the provider as ExcelProvider.
In the Connector (Required) field, click the icon, and select the TW.AnalysisServices.Excel.ExcelConnector connector.
For more information about creating an analysis provider, refer to Create an Analysis Provider.
2. Start the Microsoft Excel agent.
The Excel agent is packaged with the Analytics Extension. If the agent is not already installed, install and configure the agent so that it connects to your ThingWorx server. For more information, refer to Configure the Microsoft Excel Agent.
3. Create an Excel workbook for model computation. For the demo, you can use the Sample Excel Workbook provided for download in the Reference Documents section of the PTC eSupport Portal, or create your own. For details on how to set up the workbook, see Create an Excel Workbook.
4. Create an analysis model.
* 
Note the following points:
Ensure that the name of the model is addition in the Model Name (Required) field.
Enable the model that you have created.
For more information about creating an analysis model, refer to Create an Analysis Model.
5. Create an analysis event by entering the following details in all the fields correctly:
a. In the Source Type (Required) list, select Thing.
b. In the Source (Required) list, click the icon to search for one and select the TW_AS_SimulationDemo_AdditionSimulationThing thing.
You do not need to create the TW_AS_SimulationDemo_AdditionSimulationThing thing. This thing is available with the ThingWorx Analytics Extension.
c. In the Event (Required) list, select DataChange.
d. In the Property (Required) list, select X.
e. In the Provider Name (Required) list, select the provider (ExcelProvider) that you created in Step 1.
f. In the Model Name (Required) field, select the model (addition) that you created in Step 3.
g. Select the Run as Simulation check box.
h. Click Save to save the analysis event.
6. Complete the following steps to map inputs and results of the analysis event to the properties of the TW_AS_SimulationDemo_AdditionSimulationThing thing:
a. Select the analysis event that you created in Step 5, and click Map Data.
b. Click Inputs Mapping to map the properties of the TW_AS_SimulationDemo_AdditionSimulationThing thing to the input data shape.
c. In the Source Type (Required) field, select Thing from the drop-down list.
The TW_AS_SimulationDemo_AdditionSimulationThing is displayed in the Source (Required) field automatically.
d. Create the following input mappings:
Map the X property to the input data shape a to get the following input mapping:
a[NUMBER]=0.0 <-- TW_AS_SimulationDemo_AdditionSimulationThing[X]
Map the Y property to the input data shape b to get the following input mapping:
b[NUMBER]=0.0 <-- TW_AS_SimulationDemo_AdditionSimulationThing[Y]
e. Click Results Mapping to map the result data shape to the properties of the TW_AS_SimulationDemo_AdditionSimulationThing thing.
f. Create the following result mapping:
Map the results data shape c to the Z property to get the following result mapping:
c[NUMBER]=0.0 --> TW_AS_SimulationDemo_AdditionSimulationThing [Z]
For more information about inputs mapping, see Map Input Data. For information about results mapping, see Map Result Data.
7. On the Analysis Events page, select the event, and click Enable to enable the analysis event.
8. In ThingWorx Composer, search for and view the TW_AS_SimulationDemo_AnalysisSimulationDemoMashup mashup.
After you load this mashup in your browser, you can execute and observe analysis jobs.
9. After you load the mashup, it generates a random value for input field X every 2 seconds so that the Datachange event is triggered and results are generated every 2 seconds, unless the Stop simulation button is clicked. Use the following options on the mashup:
Click Set Properties to set the values for X and Y in the numeric fields in the mashup.
Click Start Simulation to enable the simulation event.
This option is grayed out if the analysis event is already enabled.
Click Stop Simulation to disable the analysis event, and put the simulation job, ONHOLD.
This option is grayed out if the analysis event is already disabled.
Results are available in the mashup as a tabular and graphical representation.
10. Alternatively, in ThingWorx Composer, you can change the value of the X property on the TW_AS_SimulationDemo_AdditionSimulationThing thing to trigger the event, and thus generate a new result on the analysis job. A simulation analysis job is always in the INPROCESS state.
You can also check the status and result of the analysis job. For more information, see Managing Jobs.