Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Use the EMS to Create an Engine Simulator Part 1

No ratings


Use the Edge MicroServer (EMS) to simulate an engine with vibration sensors.




The Edge MicroServer (EMS) facilitates connectivity from Edge devices to ThingWorx Foundation.


It’s often easier, though, to start development with simulated Edge values rather than hooking up sensors.


This guide will show you how to simulate vibration values of an engine using the EMS.





  • Modify an EMS Template
  • Provision Thing Properties and Values from an EMS rather than Foundation
  • Send information from an EMS to Foundation
  • Store large amounts of data in an InfoTable Property
  • Create a simulator for testing


NOTE:  The estimated time to complete all parts of this guide is 30 minutes.



Step 1: Scenario


MotorCo manufactures, sells, and services commercial motors.


Recently, MotorCo has been developing a new motor, and they already have a working prototype.


However, they’ve noticed that the motor has a chance to FAIL CATASTROPHICALLY if it’s not properly serviced to replace lost grease on a key moving part.




In order to prevent this type of failure in the field, MotorCo has decided to instrument their motors with sensors which record vibration.


The hope is that these sensors can detect certain vibrations which indicate required maintenance before a failure occurs.


In this guide, you’ll begin this monitoring process by using ThingWorx Foundation to monitor and record vibration data from the prototype motor. In particular, you will learn how to provision Thing Properties and Values from an EMS, as well as how to permanently store these values for analysis in an Info Table Property.


These types of modifications to an EMS can be extremely helpful for the automotive segment in particular. For instance, each car that comes off the factory line could have custom, auto-generated EMS scripting that would dynamically create Foundation information for each car in the fleet. This could be a massive time-savings versus manually generating Thing Properties directly within Foundation.


Because the motor is still in the process of being instrumented with sensors, you’ll get all the functionality in-place beforehand by constructing a motor simulator using the Edge MicroServer (EMS).



Step 2: Modify config.lua


In the previous Use the Edge MicroServer (EMS) to Connect to ThingWorx  guide, you installed the EMS on a Windows PC, configured it to talk to ThingWorx Foundation, and then created an EdgeThing on Foundation to complete the connectivity.


This guide assumes that you have already completed that Windows EMS guide and have an active EMS connection to the EdgeThing.


Perform the following steps to modify this connection to increase the task rate of the EMS, which we'll use in the following steps to update Properties more quickly.


  1. On your Windows PC, select the Windows PowerShell window where the luaScriptResource.exe program is running.



  2. Type Ctrl-C to close the luaScriptResource.exe operation, i.e. hold the Control key and hit the C key.


  3. Minimize the luaScriptResource.exe PowerShell window, and activate the wsemse.exe PowerShell window.

    03-esim-wsems-powershell (1).png


  4. Type Ctrl-C to close the wsems.exe operation.



  5. Return to Foundation, and note that EdgeThing is not connected.



  6. Navigate to the C:\CDEMO_EMSE\etc directory.



  7. Open config.lua in your prefered text-editor.



  8. Change scanRate to 1000.

  9. Add the following line below the scanRate line: taskRate = 1000,



  10. The final code of config.lua should be the following

    Note that the EMS may have slightly modified your config.lua file, such as adding a data_security_key line. Leave these EMS-generated modifications alone.

    scripts.log_level = "WARN"
    scripts.script_resource_ssl = false
    scripts.script_resource_authenticate = false
    scripts.EdgeThing = {
        file = "thing.lua",
        template = "YourEdgeThingTemplate",
        scanRate = 1000,
        taskRate = 1000,
        sw_update_dir = "C:\\CDEMO_EMS\\updates"
  11. Save the config.lua file.



Click here to view Part 2 of this guide.

Version history
Last update:
‎Mar 07, 2023 02:16 PM
Updated by:
Labels (2)