-
Notifications
You must be signed in to change notification settings - Fork 0
/
SnapDSS.xml
17 lines (17 loc) · 23.5 KB
/
SnapDSS.xml
1
2
3
4
5
6
7
8
<blocks app="Snap4Arduino 1.2.4
, http://snap4arduino.rocks" version="1"><block-definition s="new data stream from %'reporters' with names %'names'" type="reporter" category="other"><header></header><code></code><inputs><input type="%mult%repRing"></input><input type="%mult%txt"></input></inputs><script><block s="doDeclareVariables"><list><l>valNames</l><l>i</l><l>reps</l><l>j</l></list></block><block s="doSetVar"><l>valNames</l><block s="reportNewList"><list></list></block></block><block s="doSetVar"><l>reps</l><block s="reportNewList"><list></list></block></block><block s="doSetVar"><l>names</l><block s="reportCONS"><l>date</l><block var="names"/></block></block><block s="doSetVar"><l>reporters</l><block s="reportCONS"><block s="reifyReporter"><autolambda><block s="reportDate"><l><option>time in milliseconds</option></l></block></autolambda><list></list></block><block var="reporters"/></block></block><block s="doReport"><block s="reportNewList"><list><block var="names"/><block s="reportNewList"><list></list></block><block var="reporters"/><l></l></list></block></block></script><scripts><script x="406" y="200"><block s="doRepeat"><block s="reportListLength"><block var="reporters"/></block><script><block s="doChangeVar"><l>i</l><l>1</l></block><block s="doAddToList"><block s="reportJoinWords"><list><l>val</l><block var="i"/></list></block><block var="valNames"/></block><block s="doAddToList"><block s="reportListItem"><block var="i"/><block var="reporters"/></block><block var="reps"/></block></script></block></script><script x="105.99511818749988" y="262.0000010000001"><block s="reportNewList"><list><block var="valNames"/><block s="reportNewList"><list></list></block><block var="reps"/><l></l></list></block></script></scripts></block-definition><block-definition s="get next %'name' from stream %'s'" type="reporter" category="other"><header></header><code></code><inputs><input type="%txt"></input><input type="%l"></input></inputs><script><block s="doIf"><block s="reportOr"><block s="reportEquals"><block var="s"/><l></l></block><block s="reportNot"><block s="reportListContainsItem"><block s="reportListItem"><l>1</l><block var="s"/></block><block var="name"/></block></block></block><script><block s="doReport"><l></l></block></script></block><block s="doDeclareVariables"><list><l>i</l></list></block><block s="doUntil"><block s="reportEquals"><block s="reportListItem"><block var="i"/><block s="reportListItem"><l>1</l><block var="s"/></block></block><block var="name"/></block><script><block s="doChangeVar"><l>i</l><l>1</l></block></script></block><block s="doReport"><block s="evaluate"><block s="reportListItem"><block var="i"/><block s="reportListItem"><l>3</l><block var="s"/></block></block><list></list></block></block></script></block-definition><block-definition s="select %'func' ( %'vals' ) from stream %'s' [ last %'n' %'querytype' ]" type="reporter" category="other"><header></header><code></code><inputs><input type="%txt"><options>avg
sum
max
min
values</options></input><input type="%mult%txt"></input><input type="%l"></input><input type="%n"></input><input type="%s" readonly="true">values<options>values
seconds</options></input></inputs><script><block s="doDeclareVariables"><list><l>config</l><l>data</l><l>i</l><l>valsInternal</l></list></block><block s="doSetVar"><l>vals</l><block s="reportCONS"><l>date</l><block var="vals"/></block></block><block s="doSetVar"><l>config</l><l>0</l></block><block s="doSetVar"><l>i</l><l>0</l></block><block s="doRepeat"><block s="reportListLength"><block s="reportListItem"><l>2</l><block var="s"/></block></block><script><block s="doChangeVar"><l>i</l><l>1</l></block><block s="doIf"><block s="reportAnd"><block s="reportEquals"><block s="reportListItem"><l>1</l><block s="reportListItem"><block var="i"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block><block var="func"/></block><block s="reportAnd"><block s="reportEquals"><block s="reportListItem"><l>2</l><block s="reportListItem"><block var="i"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block><block var="vals"/></block><block s="reportAnd"><block s="reportEquals"><block s="reportListItem"><l>3</l><block s="reportListItem"><block var="i"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block><block var="n"/></block><block s="reportEquals"><block s="reportListItem"><l>5</l><block s="reportListItem"><block var="i"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block><block var="querytype"/></block></block></block></block><script><block s="doSetVar"><l>config</l><block var="i"/></block></script></block></script></block><block s="doIf"><block s="reportEquals"><block var="config"/><l>0</l></block><script><block s="doSetVar"><l>config</l><block s="reportSum"><block var="i"/><l>1</l></block></block><block s="doAddToList"><block s="reportNewList"><list><block var="func"/><block var="vals"/><block var="n"/><block s="reportNewList"><list></list></block><block var="querytype"/></list></block><block s="reportListItem"><l>2</l><block var="s"/></block></block></script></block><block s="doReplaceInList"><l>4</l><block var="s"/><block var="config"/></block><block s="doIfElse"><block s="reportEquals"><block var="querytype"/><l>values</l></block><script><block s="doUntil"><block s="reportLessThan"><block s="reportListLength"><block s="reportListItem"><l>4</l><block s="reportListItem"><block var="config"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block></block><block var="n"/></block><script><block s="doDeleteFromList"><l>1</l><block s="reportListItem"><l>4</l><block s="reportListItem"><block var="config"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block></block></script></block></script><script><block s="doIf"><block s="reportEquals"><block var="querytype"/><l>seconds</l></block><script><block s="doDeclareVariables"><list><l>a</l></list></block><block s="doSetVar"><l>a</l><block s="reportListLength"><block s="reportListItem"><l>4</l><block s="reportListItem"><block var="config"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block></block></block><block s="doUntil"><block s="reportEquals"><block var="a"/><l>0</l></block><script><block s="doIf"><block s="reportLessThan"><block s="reportListItem"><l>1</l><block s="reportListItem"><block var="a"/><block s="reportListItem"><l>4</l><block s="reportListItem"><block var="config"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block></block></block><block s="reportDifference"><block s="reportDate"><l><option>time in milliseconds</option></l></block><block s="reportProduct"><block var="n"/><l>1000</l></block></block></block><script><block s="doDeleteFromList"><block var="a"/><block s="reportListItem"><l>4</l><block s="reportListItem"><block var="config"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block></block></script></block><block s="doChangeVar"><l>a</l><l>-1</l></block></script></block></script></block></script></block><block s="doSetVar"><l>data</l><block s="reportNewList"><list></list></block></block><custom-block s="for each %upvar of %l %cs"><l>item</l><block var="vals"/><script><block s="doAddToList"><custom-block s="get next %txt from stream %l"><block var="item"/><block var="s"/></custom-block><block var="data"/></block></script></custom-block><block s="doAddToList"><block var="data"/><block s="reportListItem"><l>4</l><block s="reportListItem"><block var="config"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block></block><block s="doDeclareVariables"><list><l>res</l><l>tmplist</l></list></block><block s="doSetVar"><l>res</l><block s="reportNewList"><list></list></block></block><custom-block s="for each %upvar of %l %cs"><l>val</l><block var="vals"/><script><block s="doIf"><block s="reportAnd"><block s="reportNot"><block s="reportEquals"><block var="val"/><l>date</l></block></block><block s="reportListContainsItem"><block s="reportListItem"><l>1</l><block var="s"/></block><block var="val"/></block></block><script><block s="doDeclareVariables"><list><l>vid</l></list></block><block s="doSetVar"><l>tmplist</l><block s="reportNewList"><list></list></block></block><block s="doUntil"><block s="reportEquals"><block s="reportListItem"><block var="vid"/><block s="reportListItem"><l>2</l><block s="reportListItem"><block var="config"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block></block><block var="val"/></block><script><block s="doChangeVar"><l>vid</l><l>1</l></block></script></block><custom-block s="for each %upvar of %l %cs"><l>item</l><block s="reportListItem"><l>4</l><block s="reportListItem"><block var="config"/><block s="reportListItem"><l>2</l><block var="s"/></block></block></block><script><block s="doAddToList"><block s="reportListItem"><block var="vid"/><block var="item"/></block><block var="tmplist"/></block></script></custom-block></script></block></script></custom-block><block s="doIf"><block s="reportEquals"><block var="func"/><l>avg</l></block><script><block s="doAddToList"><block s="evaluate"><block s="reifyReporter"><autolambda><custom-block s="average of list %l"><l/></custom-block></autolambda><list></list></block><list><block var="tmplist"/></list></block><block var="res"/></block></script></block><block s="doIf"><block s="reportEquals"><block var="func"/><l>min</l></block><script><block s="doAddToList"><block s="evaluate"><block s="reifyReporter"><autolambda><custom-block s="minimum of list %l"><l/></custom-block></autolambda><list></list></block><list><block var="tmplist"/></list></block><block var="res"/></block></script></block><block s="doIf"><block s="reportEquals"><block var="func"/><l>max</l></block><script><block s="doAddToList"><block s="evaluate"><block s="reifyReporter"><autolambda><custom-block s="maximum of list %l"><l/></custom-block></autolambda><list></list></block><list><block var="tmplist"/></list></block><block var="res"/></block></script></block><block s="doIf"><block s="reportEquals"><block var="func"/><l>sum</l></block><script><block s="doAddToList"><block s="evaluate"><block s="reifyReporter"><autolambda><custom-block s="sum of list %l"><l/></custom-block></autolambda><list></list></block><list><block var="tmplist"/></list></block><block var="res"/></block></script></block><block s="doIf"><block s="reportEquals"><block var="func"/><l>values</l></block><script><block s="doReport"><custom-block s="show values from list %l"><block var="tmplist"/></custom-block></block></script></block><block s="doIfElse"><block s="reportGreaterThan"><block s="reportListLength"><block var="res"/></block><l>1</l></block><script><block s="doReport"><block var="res"/></block></script><script><block s="doReport"><block s="reportListItem"><l>1</l><block var="res"/></block></block></script></block></script></block-definition><block-definition s="average of list %'list'" type="reporter" category="lists"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>tmp</l></list></block><block s="doSetVar"><l>tmp</l><l>0</l></block><custom-block s="for each %upvar of %l %cs"><l>item</l><block var="list"/><script><block s="doChangeVar"><l>tmp</l><block var="item"/></block></script></custom-block><block s="doReport"><block s="reportQuotient"><block var="tmp"/><block s="reportListLength"><block var="list"/></block></block></block></script></block-definition><block-definition s="minimum of list %'list'" type="reporter" category="lists"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>tmp</l></list></block><block s="doSetVar"><l>tmp</l><block s="reportListItem"><l>1</l><block var="list"/></block></block><custom-block s="for each %upvar of %l %cs"><l>item</l><block var="list"/><script><block s="doIf"><block s="reportLessThan"><block var="item"/><block var="tmp"/></block><script><block s="doSetVar"><l>tmp</l><block var="item"/></block></script></block></script></custom-block><block s="doReport"><block var="tmp"/></block></script></block-definition><block-definition s="maximum of list %'list'" type="reporter" category="lists"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>tmp</l></list></block><block s="doSetVar"><l>tmp</l><block s="reportListItem"><l>1</l><block var="list"/></block></block><custom-block s="for each %upvar of %l %cs"><l>item</l><block var="list"/><script><block s="doIf"><block s="reportGreaterThan"><block var="item"/><block var="tmp"/></block><script><block s="doSetVar"><l>tmp</l><block var="item"/></block></script></block></script></custom-block><block s="doReport"><block var="tmp"/></block></script></block-definition><block-definition s="sum of list %'list'" type="reporter" category="lists"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>tmp</l></list></block><block s="doSetVar"><l>tmp</l><l>0</l></block><custom-block s="for each %upvar of %l %cs"><l>item</l><block var="list"/><script><block s="doChangeVar"><l>tmp</l><block var="item"/></block></script></custom-block><block s="doReport"><block var="tmp"/></block></script></block-definition><block-definition s="show values from list %'l'" type="reporter" category="other"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doReport"><block var="l"/></block></script></block-definition><block-definition s="for each %'item' of %'data' %'action'" type="command" category="lists"><header></header><code></code><inputs><input type="%upvar"></input><input type="%l"></input><input type="%cs"></input></inputs><script><block s="doUntil"><custom-block s="empty? %l"><block var="data"/></custom-block><script><block s="doSetVar"><l>item</l><block s="reportListItem"><l>1</l><block var="data"/></block></block><block s="doRun"><block var="action"/><list><block s="reportListItem"><l>1</l><block var="data"/></block></list></block><block s="doSetVar"><l>data</l><block s="reportCDR"><block var="data"/></block></block></script></block></script></block-definition><block-definition s="create data stream system" type="reporter" category="other"><header></header><code></code><inputs></inputs><script><block s="doReport"><block s="reportNewList"><list><block s="reportNewList"><list></list></block><block s="reportBoolean"><l><bool>false</bool></l></block></list></block></block></script></block-definition><block-definition s="add stream %'s' to data stream system %'dss'" type="command" category="other"><header></header><code></code><inputs><input type="%l"></input><input type="%l"></input></inputs><script><block s="doAddToList"><block var="s"/><block s="reportListItem"><l>1</l><block var="dss"/></block></block></script></block-definition><block-definition s="start data stream system %'dss'" type="command" category="other"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doReplaceInList"><l>2</l><block var="dss"/><block s="reportBoolean"><l><bool>false</bool></l></block></block><block s="fork"><block s="reifyScript"><script><block s="doForever"><script><block s="doWarp"><script><custom-block s="for each %upvar of %l %cs"><l>stream</l><block s="reportListItem"><l>1</l><block var="dss"/></block><script><custom-block s="for each %upvar of %l %cs"><l>query</l><block s="reportListItem"><l>2</l><block var="stream"/></block><script><block s="doRun"><block s="reifyReporter"><autolambda><custom-block s="select %txt ( %mult%txt ) from stream %l [ last %n %s ]"><block s="reportListItem"><l>1</l><block var="query"/></block><block s="reportCDR"><block s="reportListItem"><l>2</l><block var="query"/></block></block><block var="stream"/><block s="reportListItem"><l>3</l><block var="query"/></block><block s="reportListItem"><l>5</l><block var="query"/></block></custom-block></autolambda><list></list></block><list></list></block></script></custom-block></script></custom-block></script></block><block s="doIf"><block s="reportEquals"><block s="reportListItem"><l>2</l><block var="dss"/></block><block s="reportBoolean"><l><bool>true</bool></l></block></block><script><block s="doStopThis"><l><option>this block</option></l></block></script></block><block s="doWait"><l>.5</l></block></script></block></script><list></list></block><list></list></block></script></block-definition><block-definition s="stop data stream system %'dss'" type="command" category="other"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doReplaceInList"><l>2</l><block var="dss"/><block s="reportBoolean"><l><bool>true</bool></l></block></block></script></block-definition><block-definition s="empty? %'data'" type="predicate" category="lists"><header></header><code></code><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="reportEquals"><block var="data"/><block s="reportNewList"><list></list></block></block></block></script></block-definition><block-definition s="combine with %'function' items of %'data'" type="reporter" category="lists"><header></header><code></code><inputs><input type="%repRing"></input><input type="%l"></input></inputs><script><block s="doWarp"><script><block s="doIf"><custom-block s="empty? %l"><block s="reportCDR"><block var="data"/></block></custom-block><script><block s="doReport"><block s="reportListItem"><l>1</l><block var="data"/></block></block></script></block><block s="doReport"><block s="evaluate"><block var="function"/><list><block s="reportListItem"><l>1</l><block var="data"/></block><custom-block s="combine with %repRing items of %l"><block var="function"/><block s="reportCDR"><block var="data"/></block></custom-block></list></block></block></script></block></script></block-definition><block-definition s="plot %'features'" type="command" category="other"><header></header><code></code><inputs><input type="%cs"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list></list><l>//while(typeof(Plotly) === 'undefined')
if(document.getElementById("plotly_div") === null)
{
 var sc = document.createElement('script');
 sc.setAttribute("type","text/javascript");
 sc.setAttribute("src", "https://cdn.plot.ly/plotly-1.20.0.min.js");
 document.getElementsByTagName("head")[0].appendChild(sc);
 var d = document.createElement('div');
 d.setAttribute("id","plotly_div");
 //d.style.display="none";
 document.getElementsByTagName("body")[0].appendChild(d);
}
 
stage = this.parentThatIsA(StageMorph);
document.getElementById("plotly_div").setAttribute("width", stage.width());
document.getElementById("plotly_div").setAttribute("height", stage.height());
document.getElementById("plotly_div").style.position = "absolute";
document.getElementById("plotly_div").style.left = stage.topLeft().x+"px";
document.getElementById("plotly_div").style.top = stage.topLeft().y+"px";
document.getElementById("plotly_div").style.display = "block";

myplot = {};
myplot.data = [];
myplot.layout = {width: stage.width(), height: stage.height(), margin: { l: 50, r: 50, b: 50, t: 50}};
myplot.layout.shapes = [];</l></block><list></list></block><block s="doWait"><l>1</l></block><block s="doRun"><block var="features"/><list></list></block><block s="doRun"><block s="reportJSFunction"><list></list><l>var sprite = this,
 stage = sprite.parentThatIsA(StageMorph),
 context = stage.penTrails().getContext('2d'),
 left = sprite.center().x - stage.left(),
 right = sprite.center().y - stage.top(),
 img = new Image(),
 mystage = stage;

Plotly.newPlot('plotly_div',myplot.data,myplot.layout);//.then(
/* function(gd) {
 Plotly.toImage(gd,{height:stage.height(),width:stage.width()}).then(
 function(url) {
 
 if (isWarped) {endWarp(); }

 img.src = url;
 
 context.save();
 context.translate(left, top);
 context.drawImage(img,x,y);
 context.restore();

 stage.changed();

 if (isWarped) {sprite.startWarp(); }
 }
 )
 }
);
*/

delete myplot.data;
delete myplot.layout.shapes;
delete myplot.layout;
myplot = null;</l></block><list></list></block></script></block-definition><block-definition s="plot: values %'vals' as %'type' chart with name %'name' color %'rgb' (r,g,b)" type="command" category="other"><header></header><code></code><inputs><input type="%l"></input><input type="%txt" readonly="true">bar<options>bar
line</options></input><input type="%txt"></input><input type="%s"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>name</l><l>values</l><l>type</l><l>rgb</l></list><l>values = "" + values;



















var valuesArray = values.split(",");

var trace={y:valuesArray,type:type,name:name};



















if(rgb != null && rgb.length > 1) {























 trace.color = "rgb("+rgb+")";
 trace.marker = {};
 trace.marker.color = trace.color;
}

myplot.data.push(trace);</l></block><list><block var="name"/><custom-block s="combine with %repRing items of %l"><block s="reifyReporter"><autolambda><block s="reportJoinWords"><list><block var="#1"/><l>,</l><block var="#2"/></list></block></autolambda><list><l>#1</l><l>#2</l></list></block><block var="vals"/></custom-block><block var="type"/><block var="rgb"/></list></block></script></block-definition><block-definition s="plot: horizontal line at y = %'y' with color %'color' (r,g,b)" type="command" category="other"><header></header><code></code><inputs><input type="%n"></input><input type="%s"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>y</l><l>rgb</l></list><l>s = {























 type: 'line',























 xref: 'paper',























 y0: y,























 y1: y,























 x0: 0,























 x1: 1,
 line: {
 }
};

if(rgb != null && rgb.length > 1) {
 s.line.color = "rgb("+rgb+")";
}

myplot.layout.shapes.push(s);</l></block><list><block var="y"/><block var="color"/></list></block></script></block-definition><block-definition s="plot: hide" type="command" category="other"><header></header><code></code><inputs></inputs><script><block s="doRun"><block s="reportJSFunction"><list></list><l>document.getElementById("plotly_div").style.display = "none";</l></block><list></list></block></script></block-definition></blocks>