Pre-processing in loop

Is it possible to pre-process data (e.g average/sort values from an Array) in a loop and send this to the Thinger.io server?

I ask this because ‘out []‘ is outside the loop.

Can you give an example how to do this?

Thanks,
Tracker06

ps. I’m not an expert in this

‘out []‘ is outside the loop like a sort of function.
It will be called periodically from the thing.handle() within the loop.
So prepare (average/sort etc…) your variables in the loop.
You can also stream variables ant any pace…

Yes sure, something like this should work:

thing["YourThing"] >> []( pson & out){
    int value;      //or float or whatever you need
    //do stuff with the value and main variables, for example.
    out["YourVariable"] = value;
	};

And in the commented line do the operation(s) you want to do and it will run each time the value will be uploaded to the cloud or the “thing” is consulted.

Hope this helps.

Thanks,

It is more clear now.
I will playing around with this the coming week.

succeeded :grinning:

1 Like