You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, device variables are only updated when the device calls set(), which it has to do in loop() to push updates onto Grandeur, which in most of the cases is redundant data. We can add a function to the SDK that watches a variable, and calls the underlying when an update occurs. Like a stream of data. A variable can be piped to its version on Grandeur.
This looks useful to me. Tell me your thoughts about it.
The text was updated successfully, but these errors were encountered:
If the user does something like state = 1 (basically just updates the variable), sdk detects the update and if it's different from the previous value, it calls data.set("state", /* New State Value */). And when an update occurs on Grandeur we simply put the new value into the state variable.
My idea is to implement this with references.
map allVariableReferences;
map allVariableValues;
data.pipe(String path, Var& reference) {
allVariableReferences[path] = reference;
}
project.loop() {
// Check all references to see if any of their values is updated and call data.set// for any variable that is.
allVariableReferences.forEach([=](String path, Var& reference) {
if(allVariableValues[path] != reference) {
data.set(path, reference);
allVariableValues[path] = reference;
}
});
}
/** when update packet is received */
allVariableReferences[payload["event"] + "/" +payload["path"]] = payload["data"];
instanceofMA
changed the title
Setting a device variable only when it changes
Setting a device variable only when it changes: Implementing data streams.
Feb 18, 2021
Currently, device variables are only updated when the device calls
set()
, which it has to do inloop()
to push updates onto Grandeur, which in most of the cases is redundant data. We can add a function to the SDK that watches a variable, and calls the underlying when an update occurs. Like a stream of data. A variable can be piped to its version on Grandeur.This looks useful to me. Tell me your thoughts about it.
The text was updated successfully, but these errors were encountered: