node-red-contrib-prib-functions 0.18.0 → 0.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/.github/workflows/codeql-analysis.yml +3 -3
  2. package/.github/workflows/npmpublish.yml +6 -6
  3. package/.vs/VSWorkspaceState.json +7 -0
  4. package/.vs/node-red-contrib-prib-functions/v17/.wsuo +0 -0
  5. package/README.md +22 -19
  6. package/arima/index.js +18 -0
  7. package/dataAnalysis/arrayAllRowsSwap.js +15 -0
  8. package/dataAnalysis/arrayCompareToPrecision.js +34 -0
  9. package/dataAnalysis/arrayDifference.js +14 -0
  10. package/dataAnalysis/arrayDifferenceSeasonal.js +15 -0
  11. package/dataAnalysis/arrayDifferenceSeasonalSecondOrder.js +20 -0
  12. package/dataAnalysis/arrayDifferenceSecondOrder.js +14 -0
  13. package/dataAnalysis/arrayForEachRange.js +38 -0
  14. package/dataAnalysis/arrayOverlay.js +13 -0
  15. package/dataAnalysis/arrayProduct.js +11 -0
  16. package/dataAnalysis/arrayRandom.js +14 -0
  17. package/dataAnalysis/arrayReduceRange.js +11 -0
  18. package/dataAnalysis/arrayScale.js +11 -0
  19. package/dataAnalysis/arraySum.js +11 -0
  20. package/dataAnalysis/arraySumSquared.js +11 -0
  21. package/dataAnalysis/arraySwap.js +11 -0
  22. package/dataAnalysis/dataAnalysis.html +31 -14
  23. package/dataAnalysis/dataAnalysis.js +10 -1
  24. package/dataAnalysis/generateMatrixFunction.js +89 -0
  25. package/dataAnalysis/generateVectorFunction.js +25 -0
  26. package/dataAnalysis/pca.js +546 -0
  27. package/dataAnalysis/svd.js +239 -0
  28. package/documentation/loadInjector.png +0 -0
  29. package/echart/echart.html +68 -0
  30. package/echart/echart.js +85 -0
  31. package/echart/icons/chart-671.png +0 -0
  32. package/echart/lib/echarts.js +95886 -0
  33. package/lib/Chart.js +177 -0
  34. package/lib/Column.js +99 -0
  35. package/lib/GraphDB.js +14 -0
  36. package/lib/Table.js +185 -0
  37. package/lib/objectExtensions.js +361 -0
  38. package/matrix/matrix.js +50 -50
  39. package/matrix/matrixNode.html +144 -154
  40. package/matrix/matrixNode.js +26 -9
  41. package/monitor/BarGauge.js +8 -0
  42. package/monitor/Dataset.js +29 -0
  43. package/monitor/DialGauge.js +109 -0
  44. package/monitor/DialNeedle.js +36 -0
  45. package/monitor/Format.js +74 -0
  46. package/monitor/centerElement.js +14 -0
  47. package/monitor/compareElements.js +95 -0
  48. package/monitor/defs.js +23 -0
  49. package/monitor/extensions.js +906 -0
  50. package/monitor/functions.js +36 -0
  51. package/monitor/json2xml.js +103 -0
  52. package/monitor/monitorSystem.html +198 -0
  53. package/monitor/monitorSystem.js +322 -0
  54. package/monitor/svgHTML.js +179 -0
  55. package/monitor/svgObjects.js +64 -0
  56. package/package.json +31 -8
  57. package/test/00-objectExtensions.js +94 -0
  58. package/test/01-base.js +88 -0
  59. package/test/04-tables.js +33 -0
  60. package/test/data/.config.nodes.json +608 -0
  61. package/test/data/.config.nodes.json.backup +608 -0
  62. package/test/data/.config.runtime.json +4 -0
  63. package/test/data/.config.runtime.json.backup +3 -0
  64. package/test/data/.config.users.json +21 -0
  65. package/test/data/.config.users.json.backup +21 -0
  66. package/test/data/.flow.json.backup +3433 -0
  67. package/test/data/float32vector10.npy +0 -0
  68. package/test/data/flow.json +3433 -0
  69. package/test/data/int2matrix2x3.npy +0 -0
  70. package/test/data/package-lock.json +158 -0
  71. package/test/data/package.json +11 -0
  72. package/test/data/settings.js +544 -0
  73. package/test/dataAnalysisExtensions.js +472 -0
  74. package/test/dataAnalysisPCA.js +54 -0
  75. package/test/dataAnalysisSVD.js +31 -0
  76. package/test/euclideanDistance.js +2 -2
  77. package/test/matrix/02base.js +36 -0
  78. package/test/transformNumPy.js +132 -0
  79. package/testing/data/countries.csv +250 -0
  80. package/testing/hostAvailable.html +0 -2
  81. package/testing/load-injector.html +76 -21
  82. package/testing/load-injector.js +35 -54
  83. package/testing/test.js +1 -0
  84. package/transform/NumPy.js +303 -0
  85. package/transform/transform.html +73 -19
  86. package/transform/transform.js +144 -8
  87. package/documentation/LoadInjector.JPG +0 -0
@@ -0,0 +1,74 @@
1
+ const Format={
2
+ NumberToAbbreviated:(value)=>{
3
+ if(typeof value!='number') value=parseFloat(value);
4
+ if (value>Math.pow(10,16)) return Math.round(value/Math.pow(10,15)).toString()+'P'
5
+ if (value>Math.pow(10,13)) return Math.round(value/Math.pow(10,12)).toString()+'T'
6
+ if (value>Math.pow(10,10)) return Math.round(value/Math.pow(10,9)).toString()+'G'
7
+ if (value>Math.pow(10,7)) return Math.round(value/Math.pow(10,6)).toString()+'M'
8
+ if (value>Math.pow(10,4)) return Math.round(value/Math.pow(10,3)).toString()+'K'
9
+ if (value == Math.round(value)) return value.toString()
10
+ if (value>=10000) return value.toFixed(0).toString()
11
+ if (value>=1000) return value.toFixed(1).toString()
12
+ if (value>=100) return value.toFixed(2).toString()
13
+ if (value>=10) return value.toFixed(3).toString()
14
+ return value.toString()
15
+ },
16
+ HexToString: (value)=>{
17
+ if(value==null) return null;
18
+ let valueString = '';
19
+ for (let i = 0; i < value.length; i += 2)
20
+ valueString += String.fromCharCode(parseInt(value.substr(i, 2), 16));
21
+ return valueString;
22
+ },
23
+ padLeadZero:(value,size)=>"000000000000".substr(0,size-value.toString().length)+value,
24
+ toString:(type,value)=>{
25
+ switch (type) {
26
+ case 'timestamp' :
27
+ case 'datetime' :
28
+ case 'time' :
29
+ case 'date' :
30
+ var ts = new Date();
31
+ ts.setTime(parseInt(value));
32
+ var axisLabel='';
33
+ switch (this.dataType[0]) {
34
+ case 'timestamp' :
35
+ case 'date' :
36
+ case 'datetime' :
37
+ if (this.precision[0] >= 1440) axisLabel+=ts.getFullYear()+'-';
38
+ if (this.precision[0] >= 1440) axisLabel+=Format.padLeadZero(ts.getMonth()+1,2)+'-';
39
+ if (this.precision[0] >= 1440) axisLabel+=Format.padLeadZero(ts.getDate(),2);
40
+ if (this.precision[0] >= 1440) axisLabel+=' ';
41
+ case 'time' :
42
+ if (this.precision[0] >= 360) axisLabel+=Format.padLeadZero(ts.getHours(),2)+':';
43
+ if (this.precision[0] >= 60) axisLabel+=Format.padLeadZero(ts.getMinutes(),2)+':';
44
+ if (this.precision[0] >= 1) axisLabel+=Format.padLeadZero(ts.getSeconds(),2);
45
+ }
46
+ return axisLabel;
47
+ case 'int' :
48
+ case 'real' :
49
+ case 'number' :
50
+ return format.NumberToAbbreviated(value)
51
+ }
52
+ return value.toString();
53
+ },
54
+ StringToHex:(value)=>{
55
+ if(value==null) return null;
56
+ let hex = '';
57
+ for(let i=0;i<value.length;i++)
58
+ hex += ''+value.charCodeAt(i).toString(16);
59
+ return hex;
60
+ },
61
+ xmlEncodeString(value) {
62
+ if(value==null) return null;
63
+ return value.toString().replace(/([\&"<>])/g, function(str, item) {
64
+ return {
65
+ '&': '&amp;',
66
+ '"': '&quot;',
67
+ '<': '&lt;',
68
+ '>': '&gt;'
69
+ }[item];
70
+ });
71
+ }
72
+ }
73
+
74
+ module.exports=Format
@@ -0,0 +1,14 @@
1
+ function centerElement(elementIdToCenter) {
2
+ if(elementIdToCenter == null) return;
3
+ const toCenter = document.getElementById(elementIdToCenter);
4
+ const width = toCenter.getWidth();
5
+ const height = toCenter.getHeight();
6
+ const elementParent = toCenter.ancestors();
7
+ const Pwidth = elementParent[0].getWidth();
8
+ const Pheight = elementParent[0].getHeight();
9
+ width = parseInt(Pwidth/2, 10) - parseInt(width/2, 10);
10
+ height = parseInt(Pheight/2, 10) - parseInt(height/2, 10);
11
+ toCenter.setStyle({'top': height + 'px'});
12
+ toCenter.setStyle({'left': width + 'px'});
13
+ }
14
+ module.exports=centerElement
@@ -0,0 +1,95 @@
1
+ function compareNodes(oldNode, newNode, compare) { // this function under construction
2
+ if( compare==null)
3
+ var compare= {
4
+ attribute: {
5
+ match: function(attribute) {
6
+ }
7
+ ,mismatch: function(oldAttribute,newAttribute) {
8
+ return '<attribute key="'+oldAttribute.nodeName+'" old="'+oldAttribute.nodeValue+'" new="'+newAttribute.nodeValue+'"/>';
9
+ }
10
+ ,missingNew: function(attribute) {
11
+ return '<attribute key="'+attribute.nodeName+'" new="'+attribute.nodeValue+'"/>';
12
+ }
13
+ ,missingOld : function(attribute) {
14
+ return '<attribute key="'+attribute.nodeName+'" old="'+attribute.nodeValue+'"/>';
15
+ }
16
+ }
17
+ ,node: {
18
+ isSameElement: function(oldNode,newNode) {
19
+ if(oldNode.nodeType != newNode.nodeType) return false;
20
+ if(oldNode.nodeType != 1) return true;
21
+ return (oldNode.nodeName = newNode.nodeName);
22
+ }
23
+ ,match: function(node) {
24
+ }
25
+ ,mismatch: function(oldNode,newNode) {
26
+ return '<pair><new th>"'+node.nodeValue+'</new></node>'
27
+ }
28
+ ,missingNew: function(node) {
29
+ return '<node key="'+node.nodeName+'"><new>"'+node.nodeValue+'</new></node>'
30
+ }
31
+ ,missingOld : function(node) {
32
+ return '<node key="'+node.nodeName+'"><old>"'+node.nodeValue+'</old></node>'
33
+ }
34
+ }
35
+ };
36
+ var diff="";
37
+ if(oldNode == null)
38
+ var oldAttributes=[] , oldNodes=[];
39
+ else
40
+ var oldAttributes=oldNode.attributes , oldNodes=oldNode.childNodes;
41
+ if(newNode == null)
42
+ var newAttributes=[] , newNodes=[];
43
+ else
44
+ var newAttributes=newNode.attributes , newNodes=oldNode.childNodes;
45
+ if( !compare.node.isSameElement(oldNode,newNode)
46
+ || oldNode.nodeValue != newNode.nodeValue )
47
+ diff += compare.node.mismatch(oldNode,newNode);
48
+ else
49
+ diff += compare.node.match(oldNode,newNode);
50
+ var o=0;n=0;
51
+ while (o<oldAttributes.length || n<newAttributes.length) {
52
+ var oldAttribute=oldAttributes[o],newAttribute=newAttributes[n];
53
+ if(oldAttributes.nodeName==newAttribute.nodeName) {
54
+ if(oldAttribute.nodeValue==newAttribute.nodeValue)
55
+ diff += compare.attribute.match(oldAttribute);
56
+ else
57
+ diff += compare.attribute.mismatch(oldAttribute,newAttribute);
58
+ o++;n++;
59
+ continue;
60
+ }
61
+ if(oldAttribute.nodeName>newAttribute.nodeName) {
62
+ diff += compare.attribute.missingNew(newAttribute);
63
+ n++;
64
+ continue;
65
+ }
66
+ diff+= compare.attribute.missingOld(oldAttribute);
67
+ o++;
68
+ }
69
+ for (o=o;oldAttributes.length;o++) diff += compare.attribute.missingOld(oldAttributes[o]);
70
+ for (n=n;newAttributes.length;n++) diff += compare.attribute.missingANew(newAttributes[n]);
71
+ o=0;n=0;
72
+ while (o<oldNodes.length || n<newNodes.length) {
73
+ var oldNode=oldNodes[o]; newNode=newNodes[n];
74
+ if(compare.node.isSameElement(oldNode,newNode)) {
75
+ diff+=compareNodes(oldNode,newNode,compare);
76
+ n++;o++;
77
+ continue;
78
+ }
79
+ for (i=o;i<oldNodes.length;i++) // search for same element
80
+ if(compare.node.isSameElement(oldNodes[i],newNode)) break;
81
+ for (j=n;j<newNodes.length;j++) // search for same element
82
+ if(compare.node.isSameElement(oldNode,newNodes[j])) break;
83
+
84
+ if(i>=oldNodes.length) i=9999;
85
+ if(j>=newNodes.length) j=9999;
86
+ if((i-o)>(j-n))
87
+ for (n=n;n<j;n++) compare.node.missingNew(newNodes[n]);
88
+ else
89
+ for (o=o;o<i;o++) compare.node.missingOld(oldNodes[o]);
90
+ continue;
91
+ }
92
+ for (o=o;o<oldNodes.length;o++) compare.node.missingOld(oldNodes[o]);
93
+ for (n=n;n<newNodes.length;n++) compare.node.missingNew(newNodes[n]);
94
+ }
95
+
@@ -0,0 +1,23 @@
1
+ const heatGradient=[
2
+ {action:"stop",offset:"5%","stop-color":"lightgreen"},
3
+ {action:"stop",offset:"80%","stop-color":"yellow"},
4
+ {action:"stop",offset:"95%","stop-color":"red`"}
5
+ ]
6
+ const heatGradientReverse=[
7
+ {action:"stop",offset:"95%","stop-color":"lightgreen"},
8
+ {action:"stop",offset:"20%","stop-color":"yellow"},
9
+ {action:"stop",offset:"5%","stop-color":"red`"}
10
+ ]
11
+
12
+ const defs=
13
+ {action:"defs",children:[
14
+ {action:"style",children:[".red2green { background: conic-gradient(red, orange, yellow, green)}"]},
15
+ {action:"linearGradient",id:"heatGradientAcross",children:heatGradient},
16
+ {action:"linearGradient",id:"heatGradientAcrossCircle",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:heatGradient},
17
+ {action:"linearGradient",id:"heatGradientAcrossReverse",children:heatGradientReverse},
18
+ {action:"linearGradient",id:"heatGradientDown",children:heatGradient,gradientTransform:"rotate(90)"},
19
+ {action:"linearGradient",id:"heatGradientDownReverse",children:heatGradientReverse,gradientTransform:"rotate(90)"},
20
+ {action:"radialGradient",id:"heatGradientRadial",cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%",children:heatGradient}
21
+ ]}
22
+
23
+ module.exports=defs