Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hi,
I am trying to capture location information (i.e. longitude, latitude and elevation) from a file on a Linux based device. I am basing my approach on the Vending machine example from the Thingworx Fundamentals course. My approach has been to modify simulator_script.lua to read the values for Prop_Equipment1Temp and Prop_Equipment1Hum from files rather than randomly generate the values as now.
I have been somewhat successful in this approach and now I can change the value of temperature and humidity in the files on the device and see the changes reflected back to my mashup on the Thingworx. server.
Now I want to add location information and bind to the geolocation property of my EdgeVendingMachine thing on the server.
I'm sure I will work it out in the end but if someone can point me in the right direction (i.e. which lua files I need to edit) I could save some time.
I'm not sure what line(s) I should add to simulator.lua and simulator_script.lua as the LOCATION type is a composite type rather than a simple string or number.
Any ideas welcome
thanks
Steve
Hi Steve, if you look at the example files included and search for Location you'll find some helpful information on how to accomplish that.
Look at the following files
/etc/custom/templates/example.lua
and the handler it invokes
/etc/thingworx/lua/handlers/generator.lua
Hopefully that gets you going in the right direction.
Hi Pai,
Thanks for the help. I thought about this first but noticed that any 'location' examples were in example.lua and the generator.lua script whereas temperature and humidity examples were in simulator.lua and simulator_script.lua so I never took it very far. Today I've been trying to combine the two together.
I Put
properties.Pushed_Random_Location = { baseType="LOCATION", pushType="ALWAYS", handler="generator", functionType="random"} from examples.lua
into the simulator script and I was able to bind the Pushed_Random_Location property to my EdgeVendingMachine2 thing but on running it , it didn't work. I got the error
[ERROR] 2013-11-06 15:01:35,790 EdgeVendingMachine2: Error occured in handler bb_generator.read. property: Pushed_Random_Location, msg: ....3-linux-arm/MicroServer/etc/thingworx/lua/utils.lua:256: bad argument #1 to 'find' (string expected, got nil)
Looking at the code I thought it might be missing the 'Value' parameter so I tried
properties.Pushed_Random_Location = { baseType="LOCATION", pushType="ALWAYS", value={ latitude=54.92, longitude=-1.82, elevation=103 }, handler="bb_generator", functionType="random"}
But I got the same error. Then I tried
properties.Pushed_InMemory_Location = { baseType="LOCATION", pushType="ALWAYS", value={ latitude=54.92, longitude=-1.82, elevation=103 }}
This gave no errors in the output but still didn't alter my location in Thingworx
I'll try a few more things tomorrow. If you can put me in touch with someone that has done this sort of thing before I'd much appreciate it.
Maybe if I tried this straight after I did the course instead of two months later I may have had a better chance.
Thanks for you help
Steve