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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

logging readings with there own timestamp

IA_10816220
10-Marble

logging readings with there own timestamp

Hi,

 

I want to discuss something, lets say I have a sensor that sends me readings and also the time stamp of this readings, this timestamp is not the same as the timestamp of the machine that runs thingworx and the database, so i want thingworx to use this timestamp that came with the sensor data to store it in the database as the timestamp of the readings, so that when i try to query these readings and say i want it from timestamp 1 to timestamp 2 they will be stored in the database with timestamp 1 & 2 that has been set using a timestamp originally from the sensor data not the machine or server timestamp, 
when looked into it i found that i have to use this function in my subscribers and cancel the need to the log checkbox in the properties UI .

 

 

// Log multiple properties in a single ValueStream entry
Things["ValueStreamThingName"].AddStreamEntry({
    source: me.name,
    tags: undefined,
    timestamp: timestamp,
    values: {
        Temperature: me.Temperature,
        Humidity: me.Humidity,
        Pressure: me.Pressure
    }
});

 

 


Am I correct ? or there is a better or more generic way to do it, like put the function as something general for anything to use so that it can log its own data

thank you,

3 REPLIES 3

update 1 :

it works only if the property already has the "log" option checked ,

ok it seems like this code is not right or maybe old one , I am using this one now but i get an error 

 

let timestamp = new Date("2024-12-28T07:30:00");

Things["WaterQuality.VS"].AddIntegerValueStreamEntry({
	propertyName: me.name /* STRING */,
	value: me.flag3 /* INTEGER */,
	timestamp: timestamp /* DATETIME */,
	quality: undefined /* STRING {"defaultValue":"GOOD"} */
});

 

 

 

Log Messages
Error in: test.Eastern.Dammam2.WaterQuality.1.manual_log javascript service. Message ::No value stream found for effective value stream name for Thing [WaterQuality.VS]. 

 

 
so, I have a thing shape that has the above script above as a subscription, I have a thing template that has the same thing shape in it and also the value stream thing , and finally i have a sensor thing that has this thing template , in the same thing there are other properties that has the log checkbox marked and works fine so i believe the value stream is working and connected and everything, i can check the data in the database and the other proprties are fine but the one i try to log with the code is not logged 
so, any help 

Hi @IA_10816220 

what is the version of your Thingworx instance?

if possible, can you supply demo entities(Shape, Template, thing) to us?

have you tried login as Administrator?

v 9.6 
i will try Administrator and get back to you again but my current user have admin privileges
i will discuss with my manager sharing the data 
thank you

Announcements


Top Tags