Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
In this blog I will be inspecting the setup below, using the REST APIs exposed by the different components (log-analysis-free guaranteed).
The components are started in stages, and I will do some exploration between each stages :
The REST APIs
Configuration
See above diagram - Platform is listening on port 8084, no encryption, EMS and LSRs on the same host...
{
"ws_servers": [{
"host": "tws74neo",
"port": 8084
}
],
"appKey": "xxxxxx-5417-4248-bc01-yyyyyyy",
"logger": {
"level": "TRACE"
},
"ws_connection": {
"encryption": "none"
},
"auto_bind": [{
"name": "EMSGateway1",
"gateway": true
}, {
"name": "EMSOnlyThing",
"gateway": false
}, {
"name": "LUAThing2",
"host": "localhost",
"port": 8002,
"gateway": false
}, {
"name": "LUAThing1",
"gateway": false
}
],
"file": {
"virtual_dirs": [{
"emsrepository": "E:\\ptc\\ThingWorx\\EMS-5-3-2\\repositories\\data"
}
],
"staging_dir": "E:\\ptc\\ThingWorx\\EMS-5-3-2\\repositories\\staging"
}
}
scripts.log_level = "INFO"
scripts.LUAThing1 = {
file = "thing.lua",
template = "example",
}
scripts.sample = {
file = "sample.lua"
}
scripts.log_level = "INFO"
scripts.script_resource_port = 8002
scripts.LUAThing2 = {file = "thing.lua",
template = "example",
}
scripts.LUAOnlyThing = {
file = "thing.lua",
template = "example",
}
Request: Call the GetEdgeThings service on the EMSGateway1 thing | ||||||||||||||||||||||||||||||||||||||||||||||
POST | twx74neo:8084/Thingworx/Things/EMSGateway1/Services/GetEdgeThings | |||||||||||||||||||||||||||||||||||||||||||||
Response: As expected, only the remote things flagged as auto_bind are listed | ||||||||||||||||||||||||||||||||||||||||||||||
|
Request: Call the GetRemoteMetadata service on the LUAThing1 thing | |
POST | twx74neo:8084/Thingworx/Things/LUAThing1/Services/GetRemoteMetadata |
Response: As expected, remote properties / services and events are not available since the LSR associated with this thing is off. | |
Unable to Invoke Service GetRemoteMetadata on LUAThing1 : null |
Request: Call the GetEdgeThings service on the LocalEms virtual thing | |
POST | localhost:8000/Thingworx/Things/LocalEms/Services/GetEdgeThings |
Response: output is identical to the gateway thing on the platform | |
{ "name": "EMSGateway1", "host": "", "port": 8001, "path": "/", "keepalive": 60000, "timeout": 30000, "proto": "http", "user": "", "accept": "application/json" }, { "name": "EMSOnlyThing", "host": "", "port": 8001, "path": "/", "keepalive": 60000, "timeout": 30000, "proto": "http", "user": "", "accept": "application/json" }, { "name": "LUAThing1", "host": "", "port": 8001, "path": "/", "keepalive": 60000, "timeout": 30000, "proto": "http", "user": "", "accept": "application/json" }, { "name": "LUAThing2", "host": "localhost", "port": 8002, "path": "/", "keepalive": 60000, "timeout": 30000, "proto": "http", "user": "", "accept": "application/json"} |
N/A - no LSR process started yet.
Request: Call the GetEdgeThings service on the EMSGateway1 thing | ||||||||||||||||||||||||||||||||||||||||||||||
POST | twx74neo:8084/Thingworx/Things/EMSGateway1/Services/GetEdgeThings | |||||||||||||||||||||||||||||||||||||||||||||
Response: LUAThing1 is associated to an LUA script | ||||||||||||||||||||||||||||||||||||||||||||||
|
Request: Call the GetRemoteMetadata service on the LUAThing1 thing | |
POST | twx74neo:8084/Thingworx/Things/LUAThing1/Services/GetRemoteMetadata |
Response: Now that the Lua script for LUAThing1 is running, remote properties / services and events are available | |
{"isSystemObject":false,"propertyDefinitions":{"Script_Pushed_Datetime":{"sourceType":"ThingShape","aspects":{"isReadOnly":false,"dataChangeThreshold":0,"defaultValue":1495619610000,"isPersistent":false,"pushThreshold":0,"dataChangeType":"VALUE","cacheTime":0,"pushType":"ALWAYS"},"name":"Script_Pushed_Datetime","description":"","category":"","tags":[],"baseType":"DATETIME","ordinal":0},"Pushed_InMemory_Boolean":{"sourceType":"ThingShape","aspects":.... |
LocalEms::GetEdgeThings returns same output as EMSGateway::GetEdgeThings
Request: List all the scripts running in the first LSR | |||||||||||||||||
GET | localhost:8001/scripts?format=text/html | ||||||||||||||||
Response: We find our sample script and the script associated with LUAThing1 (the Thingworx script is part of the infrastructure and always there) | |||||||||||||||||
|
Request: Call the GetEdgeThings service on the EMSGateway1 thing | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
POST | twx74neo:8084/Thingworx/Things/EMSGateway1/Services/GetEdgeThings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Response: LUAOnlyThing is now listed and LUAThing2 is associated with a LUA script | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
LocalEms::GetEdgeThings returns same output as EMSGateway::GetEdgeThings
Request: List all the scripts running in the second LSR | |||||||||||||||||
GET | localhost:8002/scripts?format=text/html | ||||||||||||||||
Response: Returns the status of all the scripts currently loaded | |||||||||||||||||
|
{ "name": "EMSGateway1", "host": "", "port": 8001
{ "name": "EMSOnlyThing", "host": "", "port": 8001
Ports for EMSGateway1 and EMSOnlyThing should be 8000