About Analysis device.insert features

i am inserting some arrays values using Analysis in this way:
for (var i=0; i < xarray.length; i++){
await device.insert({ variable: ‘plotx’, value: xarray[i], serie:100+i });
await device.insert({ variable: ‘ploty’, value: yarray[i], serie:100+i });
context.log(“X=”,xarray[i]," Y=",yarray[i]);
I see that this operation take ~1sec for any insert, and if i have to insert 100 values this is displayed very slowly into the dashboard.
The problem is that in the meantime analysis is involved in inserting data from a payload, if a new payload is ready the dashboard show lines mixed from both old and new payload…

Is possible to insert the whole array using device.insert with some operation like in the following example?:
await device.insert({variable:‘plot’, value: xarray, value_length=100, serie: 100+1});


Hi @mcatinoto,

You can actually insert an array of data TagoIO using the device.insert function.

Having that in mind, I suggest you do your data processing before, add it into an array and post all the data at once

This map will do what you need to do with the series, adding 1 for each item

const data_to_insert = xarray.map((x, i) => {
return {
variable: x.variable,
value: x.value,
serie: String(i),

Then you insert the array at once:

await device.insert(data_to_insert)


Thank you Aline, thanks to your suggestion i was able to solve the issue.


1 Like