Hello,
To update the property VTQ on Thingworx platform using lua EMS is the following possible.
properties.propertyName={baseType="NUMBER", pushType="ALWAYS", value=0}
--To update on thingworx
local variableName = propertyName
properties.variableName.value = <someValue>
I tried it in different ways but it's giving me an error.
Thank You,
Naeem
Solved! Go to Solution.
Hi @slangley ,
Unfortunately I'm unable to find the solution and I've changed the way reading reading csv file on Thingworx platform instead of through agent.
Copying the file from agent to the server and then reading it on server.
It was the fastest way.
Thank You,
naeem
You can use this service:
Thank You @PaiChung
properties.Signal_Q30={baseType="NUMBER", pushType="ALWAYS", value=0}
serviceDefinitions.GetSystemProperties(
output { baseType="BOOLEAN", description="" },
description { "updates properties" }
)
services.GetSystemProperties = function(me, headers, query, data)
log.trace("[TemplateRilevatore]","########### in GetSystemProperties#############")
queryHardware()
-- if properties are successfully updated, return HTTP 200 code with a true service return value
return 200, true
end
function queryHardware()
nome = "Signal_Q30"
valore = 2
serviceName(nome, valore)
end
I'd like to call a service in place of serviceName, which has been written on thingworx platform.
Thank you!
You are looking to do this from an agent?
Usually you would use 'UpdateSubscribedProperties' for that.
Yes I'm trying to do this from the agent (Thingwworx WebSocket-based Edge Microserver (WS EMS) and Lua Script Resources (LSR)).
I'd like to understand how can I call a service (e.g UpdatePropertyValues or UpdateSubscribedPropertyValues etc) written on thingworx platform from the agent.
I'm not much of an expert when it comes to the agent.
I think the pushsubscribed/update subscribed should be in the example for the agent.
besides that, I know that you can invoke any platform service after being connected, I forget the syntax though
Thank You @PaiChung ,
I tried to invoke the service using
me.serviceName({input1 = inputValue, input2 = inputValue}) --1 way
me.serviceName({input1: inputValue, input2: inputValue}) --2 way
me.serviceName(input1 = inputValue, input2 = inputValue) --3 way
--4 way (Opened a new topic as well https://community.ptc.com/t5/ThingWorx-Developers/Updating-time-of-a-property-in-Thingworx-using-lua/m-p/643191)
ts = 1578034820000 -epoch unix time in miliseconds
nome = "Signal"
local data = {}
data.value = 2
data.time = ts
data.quality = "Good"
me:setProperty(nome, nil, nil, data)
in 4th way it's not updating the time.
Actually I'd like to update value, time and quality of the property through agent.
Hi @PaiChung ,
There are no push subscribed/update subscribed in the example for the agent.
I really need to solve it.
Thank You,
Naeem
Unfortunately I don't know much about coding within the agent.
but you should be able to call the service I indicated form the agent.
Hi @mnaeem.
If you have found a solution to your question, please post it here for the benefit of others with the same question.
Regards.
--Sharon
Hi @slangley ,
Unfortunately I'm unable to find the solution and I've changed the way of solving my problem now I'm reading csv file on Thingworx platform instead of through agent.
Copying the file from agent to the server and then reading it on server.
Best Regards,
Naeem
Hi @slangley ,
After reading this article it is possible to update the time property as well.
https://www.ptc.com/en/support/article?n=CS319572&source=Case%20Viewer
Thank You for support!
Thank You @Chandler1 ,
I'm talking about calling services of Thingworx in agent (LUA EMS).
For example:
properties.Signal_Q30={baseType="NUMBER", pushType="ALWAYS", value=0}
serviceDefinitions.GetSystemProperties(
output { baseType="BOOLEAN", description="" },
description { "updates properties" }
)
services.GetSystemProperties = function(me, headers, query, data)
log.trace("[TemplateRilevatore]","########### in GetSystemProperties#############")
queryHardware()
-- if properties are successfully updated, return HTTP 200 code with a true service return value
return 200, true
end
function queryHardware()
name = "Signal_Q30"
value = 2
UpdatePropertyValue(name, value) --Service on Thingworx platform
end
Hi @mnaeem.
I realize that you've already marked a solution to this post, but since a couple of replies have since been received, I want to be sure you don't have any remaining questions. Please let us know.
Regards.
--Sharon
Hi @slangley ,
Unfortunately I'm unable to find the solution and I've changed the way reading reading csv file on Thingworx platform instead of through agent.
Copying the file from agent to the server and then reading it on server.
It was the fastest way.
Thank You,
naeem