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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Updating time of a property in Thingworx using lua

mnaeem
15-Moonstone

Updating time of a property in Thingworx using lua

Hi,

Trying to update time of the property on thingworx using following code

ts = 1578034820000    -epoch unix time in miliseconds

local data = {}
data.value = valore
data.time = ts
data.quality = "Good"
me:setProperty(nome, nil, nil, data)

 

,but except time it is updating value and quality of the property.

 

Tried to update after converting ts into different formats, but in vain.

Thank you!

 

Best Regards,

Naeem

ACCEPTED SOLUTION

Accepted Solutions
c_lowy
16-Pearl
(To:mnaeem)

Hello @mnaeem ,

 

We just created the following article that clarifies this behavior and should help you with the issue you encountered : Timestamp is lost when pushing property from Lua Script Resource in ThingWorx.

 

Best regards,

Charlotte Lowy

View solution in original post

6 REPLIES 6

We can reproduce this behavior and we will open a case in you name for further investigation.

Regards.

mnaeem
15-Moonstone
(To:smainente)

Thank you @smainente ,

I really need assistance in this issue.

I'd be really thankful to you.

 

Best Regards,

Muhammad Naeem Akhtar

c_lowy
16-Pearl
(To:mnaeem)

Hello @mnaeem ,

 

We just created the following article that clarifies this behavior and should help you with the issue you encountered : Timestamp is lost when pushing property from Lua Script Resource in ThingWorx.

 

Best regards,

Charlotte Lowy

mnaeem
15-Moonstone
(To:c_lowy)

Thank you @c_lowy 

It's really helpful in the use case asked in the question.

In another use case I'd like to update VTQ of the property using updatePropertyValues in Lua Script. I couldn't find any guide to call Thingworx services in agent (LUA EMS).

 

Best Regards,

Naeem

Hi @mnaeem,

Why do you need to use the updatePropertyValues service instead of of the built in property push mechanism of the EMS/LSR ? What are you trying to implement ?

mnaeem
15-Moonstone
(To:smainente)

Hi @smainente 

In the following coding I have many if conditions, and I'd like to decrease lines of my code


lineToRead[i] = array of 3 entries

for i = 1, #lineToRead do
    if lineToRead[2] == "PencilCounter" then
    properties.Signal_Pencil.time = tonumber(lineToRead[1])*1000
    properties.Signal_Pencil.value = tonumber(lineToRead[3])
    log.info(p_data.name, "Signal_"..lineToRead[2].." is "..lineToRead[3])
elseif lineToRead[2] == "RPM" then
    properties.Signal_RPM.time = ........
    properties.Signal_RPM.value = ......

    log.info(p_data.name, "Signal_"..lineToRead[2].." is "..lineToRead[3])
elseif lineToRead[2]=="I15" then
    ....................
elseif lineToRead[2]=="I20" then
    ............. and so on

 

 

Announcements


Top Tags