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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Use the EMS to Create an Engine Simulator Part 4

No ratings

 

Step 6: Record Data

 

Now that we have a place to permanently store the values coming from the EMS engine simulator,

we'll write a Service to take samples and place them within the Info Table.

 

Part of that Service, though, will be incrementing the identifier, so we'll need to create one last Property.

 

  1. Ensure that you're on the Properties and Alerts tab of EdgeThing.

  2. At the top-left, click + Add.
     

    46-esim-new-property.png

     

  3. In the Name field of the slide-out on the right, type identifier.

  4. Change the Base Type to NUMBER.

  5. Click Persistent.

  6. Click Has Default Value.

  7. In the Has Default Value field, type 0.

    47-esim-identifier.png

     

  8. At the top-right, click the "Check" button for Done.

  9. At the top, click Save.

    12-elps-identifier-added.png

     

Store the Property Values

 

With all the pieces in place, we can now create our Service to add entries to our Info Table Property.

 

  1. At the top of EdgeThing, click Services.
     

    13-elps-services.png

  2. At the top-left, click + Add.

    39-esim-services-add.png

     

  3. On the "+ Add" drop-down, select Local (JavaScript).

  4. In the Service Info > Name field, type recordService.
     

    41-esim-service-name.png

     

  5. Expand Me/Entities > Properties.
     

    42-esim-me-entities-properties.png

     

  6. Click the arrow beside infoTableProperty.
     

    43-esim-me-infotableproperty.png

     

  7. Type .AddRow({ after me.infoTableProperty to being the process of calling the "AddRow()" function.
     

    44-esim-addrow.png

     

We now have called the function which will add a row of information to the Info Table Property, one entry for each column of the formatting Data Shape.

 

We just need to specify which values go into which column.

 

  1. Add the following lines to store the individual Identifier count into the first column of the Info Table Property:

         identifier:me.identifier,
  2. Because we want the identifier in the stored data to increment on each run, and we want to start the count at 1 (and the Default Value is 0), add the following line to the top of the Service:

     me.identifier=me.identifier+1;
     

    49-esim-identifier-gets-identifier.png

     

     

  3. Add the low_grease value with the following line:

         low_grease:me.low_grease,
  4. Add the following lines to store the five frequency bands of the first sensor:

         s1_fb1:me.s1_fb1,
         s1_fb2:me.s1_fb2,
         s1_fb3:me.s1_fb3,
         s1_fb4:me.s1_fb4,
         s1_fb5:me.s1_fb5,
  5. Add the final lines to store the five frequency bands of the second sensor and close out the AddRow() function:

         s2_fb1:me.s2_fb1,
         s2_fb2:me.s2_fb2,
         s2_fb3:me.s2_fb3,
         s2_fb4:me.s2_fb4,
         s2_fb5:me.s2_fb5
     });
  6. You completed Service should look like the following:

     me.identifier=me.identifier+1;
    
     me.infoTableProperty.AddRow({
         identifier:me.identifier,
         low_grease:me.low_grease,
         s1_fb1:me.s1_fb1,
         s1_fb2:me.s1_fb2,
         s1_fb3:me.s1_fb3,
         s1_fb4:me.s1_fb4,
         s1_fb5:me.s1_fb5,
         s2_fb1:me.s2_fb1,
         s2_fb2:me.s2_fb2,
         s2_fb3:me.s2_fb3,
         s2_fb4:me.s2_fb4,
         s2_fb5:me.s2_fb5
     });
     

    50-esim-final-service-code.png

     

  7. At the top, click Done.

  8. At the top, click Save.
     

    14-elps-recordservice-saved.png

 

 

Run the Service

 

With our Service completed, let's run it to store a sampling of the data coming from our EMS Engine Simulator.

 

  1. Under the Execute column in the center, on the recordService row, click the "Play" icon for Execute service.


    52-esim-execute-service.png

  2. At the bottom-right, click Execute.
     

    53-esim-execute.png

     

  3. At the bottom-right, click Done.

  4. At the top, click Properties and Alerts.


    54-esim-properties-and-alerts.png

     

  5. Under the Value column, on the infoTableProperty row, click the "Pencil" icon for Set value of property.


    55-esim-set-value-property.png

     
  6. Note that the Service has captured a snap-shot of the vibration data and grease condition and permanently stored it within the Info Table Property.

You now have not only an Engine Simulator that is constantly sending data from a remote EMS, but a way to permanently record data at points that you deem significant.

 

Feel free to return to the Service and call it several more times. Each time, the values coming from the Engine Simulator will be stored in another entry in the Info Table Property.

 

56-esim-recorded-engine-simulator-values.png

 

 

Step 7: Next Steps

 

Congratulations! You've successfully completed the Use the EMS to Create an Engine Simulator guide, and learned how to:

 

  • 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

 

The next guide in the Vehicle Predictive Pre-Failure Detection with ThingWorx Platform

learning path is Engine Simulator Data Storage.


Learn More


We recommend the following resources to continue your learning experience:

CapabilityGuide
Build

Engine Simulator Data Storage

BuildImplement Services, Events and Subscriptions

Additional Resources

If you have questions, issues, or need additional information, refer to:

ResourceLink
CommunityDeveloper Community Forum
SupportAnalytics Builder Help Center

 

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