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

Syntax of updating the property VTQ

mnaeem
14-Alexandrite

Syntax of updating the property VTQ

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

1 ACCEPTED SOLUTION

Accepted Solutions
mnaeem
14-Alexandrite
(To:slangley)

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

View solution in original post

14 REPLIES 14
PaiChung
22-Sapphire I
(To:mnaeem)

You can use this service: 

UpdatePropertyValues

mnaeem
14-Alexandrite
(To:PaiChung)

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!

PaiChung
22-Sapphire I
(To:mnaeem)

You are looking to do this from an agent?

Usually you would use 'UpdateSubscribedProperties' for that.

mnaeem
14-Alexandrite
(To:PaiChung)

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.

PaiChung
22-Sapphire I
(To:mnaeem)

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

mnaeem
14-Alexandrite
(To:PaiChung)

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...)

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.

mnaeem
14-Alexandrite
(To:PaiChung)

Hi @PaiChung ,

There are no push subscribed/update subscribed in the example for the agent.

I really need to solve it.

 

Thank You,

Naeem

PaiChung
22-Sapphire I
(To:mnaeem)

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.

slangley
23-Emerald II
(To:mnaeem)

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

mnaeem
14-Alexandrite
(To:slangley)

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

mnaeem
14-Alexandrite
(To:slangley)

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!

mnaeem
14-Alexandrite
(To:mnaeem)

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

slangley
23-Emerald II
(To:mnaeem)

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

mnaeem
14-Alexandrite
(To:slangley)

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

Announcements