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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Medical Data Storage and Display Part 2

No ratings

 

 

Step 4: Create Thing

 

Now that we have a Data Shape to format the combination of data coming from the various sub-systems, we can now instantiate a Thing with an Info Table Property to hold all of said data.

 

  1. Click Browse > Modeling > Things.

    13-mlpd-things.png

     

  2. Click + New.
  3. In the Name field, type MDSD_Thing.
  4. If Project is not already set, search for and select PTCDefaultProject.
  5. In the Base Thing Template field, search for and select Generic Thing.

    01-msd-new-thing.png

     

  6. At the top, click Save.

 

Add Info Table Property

 

We now have a Thing to aggregate the MRI sub-system information, but we still need a Property to perform the actual storage.

 

We'll use an Info Table Property for this, with the columns of the Info Table formatted by the Data Shape we created in the previous step.

 

  1. At the top, click Properties and Alerts.

    15-mlpd-properties.png

     

  2. Click + Add.

    33_mdsd_add_property.png

     

  3. On the right in the Name field, type MDSD_InfoTable_Property.
  4. Change the Base Type to INFOTABLE.
  5. In the Data Shape field, search for and select MDSD_DataShape.

    34_mdsd_infotable_property.png

     

  6. Check the box for Persistent.

    56_mdsd_persistent.png

     

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

    16-mlpd-thing-saved.png

     

 

Step 5: Create Service

 

Now that we have a Thing with an Info Table Property to store our aggregated data from multiple MRI sub-systems, we need to develop a Service which will grab said data and propagate that information into the Info Table Property.

 

  1. At the top of MDSD_Thing, click Services.

     

    17-mlpd-services.png

  2. Click + Add.

     

    37_mdsd_add_service.png

  3. Under Service Info in the Name field, type MDSD_Aggregation_Service.

     

    38_mdsd_service_name.png

 

Access to MRI Sub-systems

 

We now need to access the various sub-systems of the MRI that are already talking to ThingWorx Foundation.

 

Once again, we'll only be doing so for two sub-systems in this MVP example. But the general premise will extend to as many remote devices as is necessary.

 

You will simply add more references as additional sub-systems are needed.

 

  1. In the Javascript code window, copy-and-paste in var embedded_properties = Things["MDSD_Embedded_Thing"].GetPropertyValues();
    • This provides a reference to the embedded microcontroller's Properties.
    • All Things are accessible in Foundation via the "Things" array, and you simply need to provide the Thing-name to index into the array; this functions similarly to a "global" variable, so that any Thing can reference any other Thing.
    • The built-in GetPropertyValues Service simply returns the values of all Properties of the Thing being referenced.
  2. In the Javascript code window, copy-and-paste in var pc_properties = Things["MDSD_PC_Thing"].GetPropertyValues();
    • This provides a reference to the PC's Properties.

       

      39_mdsd_javascript_thing_references.png

 

Add Values to Info Table

 

Now that we have references to the sub-systems, we'll add their individual Property values to each field of the Info Table Property.

 

We'll do this via the built-in AddRow() Service.

 

  1. To begin an AddRow Service call, copy-and-paste me.MDSD_InfoTable_Property.AddRow({

    • The me reference is MDSD_Thing, since we're inside said Entity.
    • The MDSD_InfoTable_Property is the Property we added in this guide's previous step.
    • The built-in AddRow Service will add each following Property value to a field of the Info Table formatted by the previously-created Data Shape.

    40_mdsd_addrow.png

     

  2. Copy-and-paste Coolant_Percent:embedded_properties.Coolant_Percent,

    • This stores the embedded microcontroller's "Coolant Percent" in the first field of a row of the aggregated Info Table.

    41_mdsd_coolant_percent.png

     

  3. Copy-and-paste Field_Strength:embedded_properties.Field_Strength,

    • Likewise, this references the second Property of the embedded microcontroller to store in the second field of the Info Table.

    42_mdsd_field_strength.png

     

  4. Copy-and-paste Magnet_Temperature:embedded_properties.Magnet_Temperature,

    43_mdsd_magnet_temperature.png

     

  5. Now that we have all the embedded microcontroller's values, copy-and-paste the following lines for the PC's values:

    Number_of_Scans:pc_properties.Number_of_Scans,SSD_Space_Open:pc_properties.SSD_Space_Open,
    Unused_RAM:pc_properties.Unused_RAM,
    44_mdsd_pc_properties.png

     

  6. We also want to record the Timestamp (via the built-in Date Service) when these entries were added; copy-and-paste Timestamp:Date.now()

    45_mdsd_timestamp.png

     

  7. Finally, close off the AddRow Service with some braces, i.e. copy-and-paste });

    46_mdsd_full_javascript.png

     

  8. Review the entire Service in Foundation and ensure that it matches the Javascript code below.

    var embedded_properties = Things["MDSD_Embedded_Thing"].GetPropertyValues();
    var pc_properties = Things["MDSD_PC_Thing"].GetPropertyValues();me.MDSD_InfoTable_Property.AddRow({
        Coolant_Percent:embedded_properties.Coolant_Percent,
        Field_Strength:embedded_properties.Field_Strength,
        Magnet_Temperature:embedded_properties.Magnet_Temperature,
        Number_of_Scans:pc_properties.Number_of_Scans,    SSD_Space_Open:pc_properties.SSD_Space_Open,
        Unused_RAM:pc_properties.Unused_RAM,
        Timestamp:Date.now()
    });
  9. For the MDSD_Aggregation_Service, click Done.
  10. Click Save.

    18-mlpd-service-saved.png

     

Test Service

 

Before going further, we should test the Service to ensure that it is correctly adding entries to the aggregate Info Table Property.

 

  1. On the MDSD_Aggregation_Service row, under the Execute column, click the Play icon.

    50_mdsd_play_icon.png

     

  2. At the bottom-right of the Execute Service pop-up, click Execute.

    51_mdsd_execute.png

     

  3. Click Done, and return to Properties and Alerts.

    • Notice under the Value column that the Info Table Property now has an entry.

    53_mdsd_properties_and_alerts.png

     

  4. Under the Value column, click the Pencil icon for Edit.

    54_mdsd_property_edit.png

     

  5. Review the values and confirm that every field has a valid entry.
    • Note that your values will differ from those in the picture due to the random nature of the simulator.
  6. On the pop-up, click Cancel.
  7. At the top, click Save.

 

 

Step 6: Create Mashup

 

Now that we have a Thing that has logically aggregated the infomation into a single Info Table Property (and a Service to carry out said aggregation), we can start to visualize the data with a Mashup.

 

For more information on Mashups, reference the Create Your Application UI guide.

 

  1. Click Browse > Visualization > Mashups.

    19-mlpd-mashups.png

     

  2. Click + New.

    01-uiv92-new-mashup-popup.png

     

  3. On the New Mashup Pop-up, leave the defaults, and click OK.
  4. In the Name field, type MDSD_Mashup.

    61_mdsd_mashup_name.png

     

  5. If Project is not already set, search for and select PTCDefaultProject.
  6. At the top, click Save.

    20-mlpd-mashup-saved.png

     

  7. At the top, click Design.

    21-mlpd-design.png

     

  8. At the top-left, click the Layout tab.

    64_mdsd_layout.png

     

  9. For Positioning, select the Static radio-button.

    65_mdsd_static.png

     

  10. At the top-left, click the Widgets tab.
  11. At the top, click Save.

    22-mlpd-mashup-saved.png

     

Widgets

 

We now have a "Static Positioning" Mashup, which will let us drag-and-drop Widgets without them auto-expanding to fill the entire space. This will alow us to have multiple Widgets without worrying about sub-dividing the Mashup.

 

In particular, we're interested in the Grid Widget to display our aggregated data, as well as a Button Widget to call the Service to perform the aggregation.

 

  1. On the left in the Filter Widgets field, type grid.

    23-mlpd-filter-grid.png

     

  2. Drag-and-drop a Grid Advanced Widget onto the central Canvas area.

    24-mlpd-drag-drop-grid.png

     

  3. In the Filter Widgets field, type button.

    69_mdsd_filter_button.png

     

  4. Drag-and-drop a Button Widget onto the central Canvas area.

    70_mdsd_drag-drop-button.png

     

  5. Re-size (by clicking-and-stretching) and move the two Widgets such that they look roughly like the picture below.

    25-mlpd-stretch-widgets.png

     

  6. Click the Button Widget to select it.
  7. In the Filter Properties field of the bottom-left Properties section, type label.

    26-mlpd-filter-label.png

     

  8. In the Label field, type Retrieve MRI Statistics, and then hit the Tab keyboard key to lock in the change.

    27-mlpd-label-text.png

     

  9. At the top, click Save.

    28-mlpd-mashup-saved.png

     

 

Click here to view Part 3 of this guide.

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