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

ThingWorx mashup metric/imperial

reengle
7-Bedrock

ThingWorx mashup metric/imperial

Hello,

 

I have a situation where data are read from a source that always stores them in imperial units.  All widgets in the project need to have the ability to be universally switchable such that they can show the converted values for metric and also the appropriate units at runtime.  Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
AdamR
12-Amethyst
(To:reengle)

There are a few ways you could handle this.  Of course you will need a reference to conversion values.  This could be pretty much any source, DataTable, Infotable Property (since there won't be too many rows) or even a external web service that can return the values.

I would then create a simple service to pass in a value (or a table of values) and return the same value (or table) in the new units.

The next step would be when to convert the values.  This could be in each individual service that gets the data and prior to returning it to the mashup wrap the service to call the conversion service for each value.  This is the simplest but would make your query run every time a new unit was selected.

Another option is to actually put the service on the mashup side in a function and pass each value through that based on what is selected.  This would be a bit a painful to setup and maintain but would be less time hitting the data source.  You would also need to query and return the conversion table into a mashup parameter (or keep it in a global session parameter) so it was always accessible via the script function.

View solution in original post

3 REPLIES 3
AdamR
12-Amethyst
(To:reengle)

There are a few ways you could handle this.  Of course you will need a reference to conversion values.  This could be pretty much any source, DataTable, Infotable Property (since there won't be too many rows) or even a external web service that can return the values.

I would then create a simple service to pass in a value (or a table of values) and return the same value (or table) in the new units.

The next step would be when to convert the values.  This could be in each individual service that gets the data and prior to returning it to the mashup wrap the service to call the conversion service for each value.  This is the simplest but would make your query run every time a new unit was selected.

Another option is to actually put the service on the mashup side in a function and pass each value through that based on what is selected.  This would be a bit a painful to setup and maintain but would be less time hitting the data source.  You would also need to query and return the conversion table into a mashup parameter (or keep it in a global session parameter) so it was always accessible via the script function.

reengle
7-Bedrock
(To:AdamR)

Thanks, Adam. I'll poke around with your suggestions.

slangley
23-Emerald II
(To:reengle)

Hi @reengle.

 

If you found the previous post helpful, please mark it as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon

Announcements