node-red-contrib-prib-functions 0.18.0 → 0.19.2
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.
- package/README.md +16 -17
- package/dataAnalysis/pca.js +399 -0
- package/documentation/loadInjector.png +0 -0
- package/matrix/matrix.js +48 -2
- package/matrix/matrixNode.html +144 -154
- package/matrix/matrixNode.js +26 -9
- package/package.json +16 -5
- package/test/01-base.js +88 -0
- package/test/data/.flow.json.backup +3192 -0
- package/test/data/flow.json +3212 -0
- package/test/data/settings.js +544 -0
- package/test/matrix/02base.js +36 -0
- package/testing/data/countries.csv +250 -0
- package/testing/hostAvailable.html +0 -2
- package/testing/load-injector.html +76 -21
- package/testing/load-injector.js +35 -54
- package/testing/test.js +1 -0
- package/transform/transform.html +61 -19
- package/transform/transform.js +110 -6
- package/documentation/LoadInjector.JPG +0 -0
package/matrix/matrixNode.html
CHANGED
|
@@ -7,30 +7,22 @@
|
|
|
7
7
|
name: {value:null},
|
|
8
8
|
action: {value: "create",required:true},
|
|
9
9
|
args: {value:[]},
|
|
10
|
-
arg: {value:null},
|
|
11
|
-
|
|
12
|
-
column: {value:null},
|
|
13
|
-
"
|
|
14
|
-
end: {value:null},
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
matrix: {value:"payload"},
|
|
27
|
-
"matrix-type": {value:"msg"},
|
|
28
|
-
start: {value:null},
|
|
29
|
-
"start-type": {value:"num"},
|
|
30
|
-
target: {value:"_matrix"},
|
|
31
|
-
"target-type": {value:"msg"},
|
|
32
|
-
value: {value:"payload"},
|
|
33
|
-
"value-type": {value:"msg"}
|
|
10
|
+
arg: {value:null},"arg-type": {value:"msg"},
|
|
11
|
+
call:{value:null},
|
|
12
|
+
column: {value:null},"column-type": {value:"num"},
|
|
13
|
+
columns: {value:null},"columns-type": {value:"num"},
|
|
14
|
+
end: {value:null},"end-type": {value:"num"},
|
|
15
|
+
factor: {value:null},"factor-type": {value:"num"},
|
|
16
|
+
matrix: {value:"payload"},"matrix-type": {value:"msg"},
|
|
17
|
+
precision: {value:3},"precision-type": {value:"num"},
|
|
18
|
+
row: {value:3},"row-type": {value:"num"},
|
|
19
|
+
rows: {value:3},"rows-type": {value:"num"},
|
|
20
|
+
rowTarget: {value:null},"rowTarget-type": {value:"num"},
|
|
21
|
+
source: {value:"_matrix"},"source-type": {value:"msg"},
|
|
22
|
+
start: {value:null},"start-type": {value:"num"},
|
|
23
|
+
target: {value:"_matrix"},"target-type": {value:"msg"},
|
|
24
|
+
value: {value:"payload"},"value-type": {value:"msg"},
|
|
25
|
+
vector: {value:"payload"},"vector-type": {value:"msg"}
|
|
34
26
|
},
|
|
35
27
|
inputs: 1,
|
|
36
28
|
outputs: 2,
|
|
@@ -44,148 +36,151 @@
|
|
|
44
36
|
},
|
|
45
37
|
oneditprepare: function() {
|
|
46
38
|
const node=this;
|
|
47
|
-
|
|
39
|
+
node.properties=[];
|
|
40
|
+
node.editors=[];
|
|
41
|
+
const actions={
|
|
42
|
+
define:{label:"Define",show:["target"],args:["rows","columns"]},
|
|
43
|
+
defineEmpty:{label:"Define Empty",show:["target"],args:["rows","columns"]},
|
|
44
|
+
create:{label:"Create",show:["target"],args:[]},
|
|
45
|
+
createLike:{label:"Create Like",show:["source","target"],args:[]},
|
|
46
|
+
clone:{label:"Clone",show:["source","target"],args:[]},
|
|
47
|
+
add:{label:"Add",show:["source"],args:["matrix"]},
|
|
48
|
+
addRow:{label:"Add Row",show:["source"],args:["row","vector"]},
|
|
49
|
+
addRow2Row:{label:"Add Row to Row",show:["source"],args:["row","target","factor","start","end"]},
|
|
50
|
+
addCell:{label:"Add to Cell",show:["source"],args:["row","column","value"]},
|
|
51
|
+
subtractCell:{label:"Subtract Cell",show:["source","target"],args:["row","column","value"]},
|
|
52
|
+
multiple:{label:"Multiple",show:["source","target"],args:[]},
|
|
53
|
+
multipleCell:{label:"Multiple Cell",show:["source","target"],args:["rows","columns","value"]},
|
|
54
|
+
divideCell:{label:"Divide Cell",show:["source"],args:["rows","columns","value"]},
|
|
55
|
+
divideRow:{label:"Divide Row",show:["source"],args:["row","factor","start","end"]},
|
|
56
|
+
transpose:{label:"Transpose",show:["source","target"],args:[]},
|
|
57
|
+
getAdjoint:{label:"Adjoint",show:["source","target"],args:[]},
|
|
58
|
+
getCofactor:{label:"Cofactor",show:["source","target"],args:[]},
|
|
59
|
+
getComplementMinor:{label:"Complement Minor",show:["source","target"],args:[]},
|
|
60
|
+
getIdentity:{label:"Identity",show:["source","target"],args:[]},
|
|
61
|
+
getInverse:{label:"Inverse",show:["source","target"],args:[]},
|
|
62
|
+
getInverseAdjointMethod:{label:"Inverse (Adjoint Method)",show:["source","target"],args:[]},
|
|
63
|
+
getInverseGaussJordan:{label:"Inverse (Gauss Jordan Method)",show:["source","target"],args:[]},
|
|
64
|
+
norm:{label:"Norm",show:["source","target"],args:[]},
|
|
65
|
+
getDeterminant:{label:"Determinant",show:["source","target"],args:[]},
|
|
66
|
+
getDeterminantUsingCofactor:{label:"Determinant (Cofactor)",show:["source","target"],args:[]},
|
|
67
|
+
getDeterminantUsingCofactor:{label:"Determinant (Row Echelon Form)",show:["source","target"],args:[]},
|
|
68
|
+
backwardSubstitution:{label:"Backward Substitution",show:["source"],args:[]},
|
|
69
|
+
forwardElimination:{label:"Forward Elimination",show:["source"],args:[]},
|
|
70
|
+
gaussianElimination:{label:"Gaussian Elimination",show:["source"],args:[]},
|
|
71
|
+
reducedRowEchelonForm:{label:"Reduced Row EchelonForm",show:["source"],args:[]},
|
|
72
|
+
rowEchelonForm:{label:"Row Echelon Form",show:["source"],args:[]},
|
|
73
|
+
equalsNearly:{label:"Nearly Equals",show:["source"],args:[]},
|
|
74
|
+
testIsSquare:{label:"Is Square",show:["source"],args:[]},
|
|
75
|
+
get:{label:"Get Cell",show:["source","target"],args:[]},
|
|
76
|
+
sumRow:{label:"Sum Row",show:["source","target"],args:[]},
|
|
77
|
+
swapRows:{label:"Swap Rows",show:["source"],args:[]},
|
|
78
|
+
toArray:{label:"To Array Object",show:["source","target"],args:[]},
|
|
79
|
+
runningSum:{label:"Running Sum",show:["source","target"],args:[]},
|
|
80
|
+
getVandermonde:{label:"Vandermonde",show:["target"],args:["vector","columns"]},
|
|
81
|
+
create:{label:"Create",show:[,"target"],args:["rows","columns"]},
|
|
82
|
+
createForEachCellPairSet:{label:"Create Pair Set Cells",show:["source","target"],args:["matrix","call"],default:{call:"(baseCellValue,matrixCellValue)=>{}"}},
|
|
83
|
+
findRowColumn:{label:"Find in Row",show:["source"],args:["row","call","start","end"],default:{call:"(value,row,column,offset,vector)=>true"}},
|
|
84
|
+
forRowCells:{label:"Row Cells",show:["source"],args:["row","call","start","end"],default:{call:"()=>{}"}},
|
|
85
|
+
fillArray:{label:"fill",show:["source"],args:["matrix"]},
|
|
86
|
+
findColumnRow:{label:"Find in Column",show:["source"],args:["column","call","start","end"],default:{call:"()=>{}"}},
|
|
87
|
+
forColumnCells:{label:"Column Cells",show:["source"],args:["column","call","start","end"],default:{call:"()=>{}"}},
|
|
88
|
+
forEachCell:{label:"For Each Cell",show:["source"],args:["call"],default:{call:"()=>{}"}},
|
|
89
|
+
forEachRow:{label:"For Each Row",show:["source"],args:["call"],default:{call:"()=>{}"}},
|
|
90
|
+
forEachCellPairSet:{label:"For Each Cell Pair Set",show:["source"],args:["matrix","call"],default:{call:"()=>{}"}},
|
|
91
|
+
getIndex:{label:"Get Vector Offset",show:["source","target"],args:["row","column"]},
|
|
92
|
+
getZeroed:{label:"Get Zeroed",show:["source","target"],args:["row","column"]},
|
|
93
|
+
getMatrix:{label:"get Sub Matrix",show:["source","target"],args:["row","column","rows","columns"]},
|
|
94
|
+
getRow:{label:"Get Row",show:["source","target"],args:["row"]},
|
|
95
|
+
maxAbsColumn:{label:"Column Maximum Absolute",show:["source","target"],args:["column","start"]},
|
|
96
|
+
maxColumn:{label:"Column Max",show:["source","target"],args:["column","start"]},
|
|
97
|
+
multiplyRow:{label:"Multiply Row",show:["source"],args:["row","factor"]},
|
|
98
|
+
reduceRow:{label:"Reduce Row",show:["source","target"],args:["row","call","value"],default:{call:"(agregatevalue,cellValue,row,column)=>agregatevalue+cellValue"}},
|
|
99
|
+
set:{label:"Set Cell",show:["source"],args:["row","column","value"]},
|
|
100
|
+
setRow:{label:"Set Row",show:["source"],args:["vector","row"]},
|
|
101
|
+
reduce:{label:"Reduce Cells",show:["source","target"],args:["call","value"],default:{call:"()=>{}"}}
|
|
102
|
+
};
|
|
48
103
|
const baseDiv=$("#node-inputDynamicBase");
|
|
49
104
|
function defineProperty(property,...types) {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
$('<label for="node-input-'+property.name+'" style="white-space: nowrap"><i class="icon-'+(property.icon||'-bookmark')+'"></i> '+property.label+'</label>'),
|
|
54
|
-
inputNode,typeNode
|
|
55
|
-
]);
|
|
105
|
+
const element=$('<div/>',{ "class": "form-row form-row-http-in-"+property.name+" hide" }).append(
|
|
106
|
+
$('<label for="node-input-'+property.name+'" style="white-space: nowrap"><i class="fa fa-'+(property.icon||'bookmark')+'"></i> '+property.label+'</label>'),
|
|
107
|
+
);
|
|
56
108
|
element.appendTo(baseDiv);
|
|
57
|
-
properties.push(property.name);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
109
|
+
node.properties.push(property.name);
|
|
110
|
+
if(types[0]=="edit") {
|
|
111
|
+
element.append($('<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-'+property.name+'-editor"></div>'));
|
|
112
|
+
node.editors[property.name] = RED.editor.createEditor({
|
|
113
|
+
id: 'node-input-'+property.name+'-editor',
|
|
114
|
+
mode: 'ace/mode/'+property.mode||"text",
|
|
115
|
+
value: node[property.name]||property.default
|
|
116
|
+
});
|
|
117
|
+
} else {
|
|
118
|
+
const inputNode=$('<input type="text" id="node-input-'+property.name+'"/>').val(node[property.name]);
|
|
119
|
+
const typeNode=$('<input type="hidden" id="node-input-'+property.name+'-type"/>');
|
|
120
|
+
element.append([inputNode,typeNode]);
|
|
121
|
+
const typeValue=node[property.name+"-type"];
|
|
122
|
+
if(typeValue) typeNode.val(typeValue);
|
|
123
|
+
$("#node-input-"+property.name).typedInput({
|
|
124
|
+
type:typeValue||types[0],
|
|
125
|
+
types:types,
|
|
126
|
+
typeField: "#node-input-"+property.name+"-type"
|
|
127
|
+
});
|
|
128
|
+
}
|
|
65
129
|
}
|
|
66
|
-
defineProperty({name:"source" ,label:"Source" ,icon:"
|
|
130
|
+
defineProperty({name:"source" ,label:"Source" ,icon:"crosshairs"},"msg","flow","global");
|
|
67
131
|
defineProperty({name:"arg" ,label:"Argument" ,icon:"tag"},"num","json","msg","flow","global","env");
|
|
68
|
-
defineProperty({name:"matrix" ,label:"Matrix" ,icon:"
|
|
69
|
-
defineProperty({name:"target" ,label:"Target" ,icon:"
|
|
70
|
-
defineProperty({name:"column" ,label:"Column" ,icon:"
|
|
71
|
-
defineProperty({name:"
|
|
72
|
-
defineProperty({name:"
|
|
73
|
-
defineProperty({name:"
|
|
74
|
-
defineProperty({name:"
|
|
75
|
-
defineProperty({name:"
|
|
76
|
-
defineProperty({name:"
|
|
77
|
-
defineProperty({name:"
|
|
132
|
+
defineProperty({name:"matrix" ,label:"Matrix" ,icon:"th"},"msg","flow","global");
|
|
133
|
+
defineProperty({name:"target" ,label:"Target" ,icon:"save"},"msg","flow","global");
|
|
134
|
+
defineProperty({name:"column" ,label:"Column" ,icon:"bars fa-rotate-90"},"num","msg","flow","global");
|
|
135
|
+
defineProperty({name:"columns" ,label:"Columns" ,icon:"bars fa-rotate-90"},"num","msg","flow","global");
|
|
136
|
+
defineProperty({name:"row" ,label:"Row" ,icon:"bars"},"num","msg","flow","global");
|
|
137
|
+
defineProperty({name:"rows" ,label:"Rows" ,icon:"bars"},"num","msg","flow","global");
|
|
138
|
+
defineProperty({name:"value" ,label:"Value" ,icon:"tachometer"},"num","msg","flow","global");
|
|
139
|
+
defineProperty({name:"rowTarget",label:"Target Row" ,icon:"bars"},"num","msg","flow","global");
|
|
140
|
+
defineProperty({name:"factor" ,label:"Factor" ,icon:"adjust"},"num","msg","flow","global");
|
|
141
|
+
defineProperty({name:"precision",label:"Precision" ,icon:"tachometer"},"num","msg","flow","global");
|
|
142
|
+
defineProperty({name:"start" ,label:"Start" ,icon:"tachometer"},"num","msg","flow","global");
|
|
143
|
+
defineProperty({name:"end" ,label:"End" ,icon:"tachometer"},"num","msg","flow","global");
|
|
144
|
+
defineProperty({name:"size" ,label:"Size" ,icon:"tachometer"},"num","msg","flow","global");
|
|
145
|
+
defineProperty({name:"vector" ,label:"Vector" ,icon:"ellipsis-h"},"json","msg","flow","global");
|
|
146
|
+
defineProperty({name:"call" ,label:"Call" ,icon:"js",mode:"javascript"},"edit");
|
|
78
147
|
|
|
148
|
+
const options=Object.keys(actions).reduce((previousValue,property)=>previousValue.concat({value:property,label:actions[property].label}),
|
|
149
|
+
[]);
|
|
79
150
|
const actionNode=$("#node-input-action");
|
|
80
151
|
actionNode.typedInput({
|
|
81
152
|
types: [{
|
|
82
153
|
value: "actionType",
|
|
83
|
-
options:
|
|
84
|
-
|
|
85
|
-
{value:"defineEmpty", label:"Define Empty"},
|
|
86
|
-
{value:"create", label:"Create"},
|
|
87
|
-
{value:"createLike", label:"Create Like"},
|
|
88
|
-
{value:"clone", label:"Clone"},
|
|
89
|
-
{value:"add", label:"Add"},
|
|
90
|
-
{value:"addRow2Row", label:"Add Row to Row"},
|
|
91
|
-
{value:"addCell", label:"Add to Cell"},
|
|
92
|
-
{value:"addRow", label:"Add Row"},
|
|
93
|
-
{value:"subtractCell", label:"Subtract Cell"},
|
|
94
|
-
{value:"multiple", label:"Multiple"},
|
|
95
|
-
{value:"multipleCell", label:"Multiple Cell"},
|
|
96
|
-
{value:"divideCell", label:"Divide Cell"},
|
|
97
|
-
{value:"divideRow", label:"Divide Row"},
|
|
98
|
-
{value:"transpose", label:"Transpose"},
|
|
99
|
-
{value:"getAdjoint", label:"Adjoint"},
|
|
100
|
-
{value:"getCofactor", label:"Cofactor"},
|
|
101
|
-
{value:"getComplementMinor", label:"Complement Minor"},
|
|
102
|
-
{value:"getIdentity", label:"Identity"},
|
|
103
|
-
{value:"getInverse", label:"Inverse"},
|
|
104
|
-
{value:"getInverseAdjointMethod",label:"Inverse (Adjoint Method)"},
|
|
105
|
-
{value:"getInverseGaussJordan" ,label:"Inverse (Gauss Jordan Method)"},
|
|
106
|
-
{value:"getDeterminant", label:"Determinant"},
|
|
107
|
-
{value:"getDeterminantUsingCofactor",label:"Determinant (Cofactor)"},
|
|
108
|
-
{value:"getDeterminantUsingCofactor",label:"Determinant (Row Echelon Form)"},
|
|
109
|
-
{value:"backwardSubstitution", label:"Backward Substitution"},
|
|
110
|
-
{value:"forwardElimination", label:"Forward Elimination"},
|
|
111
|
-
{value:"gaussianElimination", label:"Gaussian Elimination"},
|
|
112
|
-
{value:"reducedRowEchelonForm", label:"Reduced Row EchelonForm"},
|
|
113
|
-
{value:"rowEchelonForm", label:"Row Echelon Form"},
|
|
114
|
-
{value:"equalsNearly", label:"Nearly Equals"},
|
|
115
|
-
{value:"testIsSquare", label:"Is Square"},
|
|
116
|
-
{value:"get", label:"Get Cell"},
|
|
117
|
-
{value:"sumRow", label:"Sum Row"},
|
|
118
|
-
{value:"swapRows", label:"Swap Rows"},
|
|
119
|
-
{value:"toArray", label:"To Array Object"}
|
|
120
|
-
]
|
|
121
|
-
}]
|
|
154
|
+
options: options
|
|
155
|
+
}]
|
|
122
156
|
});
|
|
123
|
-
|
|
124
|
-
//Matrix.prototype.findRowColumn=function(row,call,startColumn=0,endColumn=this.columns-1){
|
|
125
|
-
//Matrix.prototype.forRowCells=function(row,call,startColumn=0,endColumn=this.columns-1){
|
|
126
|
-
//Matrix.prototype.fillArray=function(a){
|
|
127
|
-
//Matrix.prototype.findColumnRow=function(column,call,startRow=0,endRow=this.rows-1){
|
|
128
|
-
//Matrix.prototype.forColumnCells=function(column,call,startRow=0,endRow=this.rows-1){
|
|
129
|
-
//Matrix.prototype.forEachCell=function(call){
|
|
130
|
-
//Matrix.prototype.forEachRow=function(call){
|
|
131
|
-
//Matrix.prototype.forEachCellPairSet=function(matrix,call){
|
|
132
|
-
//Matrix.prototype.getIndex=function(row, column){
|
|
133
|
-
//Matrix.prototype.getZeroed=function(row, column){
|
|
134
|
-
//Matrix.prototype.getMatrix=function(row,column,rows,columns){
|
|
135
|
-
//Matrix.prototype.getRow=function(row){
|
|
136
|
-
//Matrix.prototype.maxAbsColumn=function(column,startRow=0){
|
|
137
|
-
//Matrix.prototype.maxColumn=function(column,startRow=0){
|
|
138
|
-
//Matrix.prototype.multiplyRow=function(row,factor){
|
|
139
|
-
//Matrix.prototype.reduceRow=function(row,call,value=0){
|
|
140
|
-
//Matrix.prototype.set=function(row,column,value){
|
|
141
|
-
//Matrix.prototype.setRow=function(vector,row){
|
|
142
|
-
actionNode.change(function() {
|
|
157
|
+
actionNode.change(function() {
|
|
143
158
|
action=$(this).val();
|
|
144
|
-
let show=["source","target"];
|
|
145
159
|
node.args=[];
|
|
146
|
-
properties.forEach(property=>$(".form-row-http-in-"+property).hide());
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
show=["source"];
|
|
150
|
-
} else if(["equalsNearly"].includes(action)) {
|
|
151
|
-
show=["source"];
|
|
152
|
-
node.args=["matrix"];
|
|
153
|
-
} else if(["define"].includes(action)) {
|
|
154
|
-
show=["target"];
|
|
155
|
-
node.args=["row","column"];
|
|
156
|
-
} else if(["addCell","subtractCell","multiplyCell","divideCell"].includes(action)) {
|
|
157
|
-
show=["source"];
|
|
158
|
-
node.args=["row","column","value"];
|
|
159
|
-
} else if(["get","getComplementMinor","getCofactor"].includes(action)) {
|
|
160
|
-
show=["source","target"];
|
|
161
|
-
node.args=["row","column"];
|
|
162
|
-
} else if(["sumRow"].includes(action)){
|
|
163
|
-
node.args=["row"];
|
|
164
|
-
} else if(["define"].includes(action)){
|
|
165
|
-
show=["target"];
|
|
166
|
-
node.args=["row","column"];
|
|
167
|
-
} else if(["defineEmpty"].includes(action)){
|
|
168
|
-
show=["target"];
|
|
169
|
-
node.args=["row","column"];
|
|
170
|
-
} else if(["swapRows"].includes(action)){
|
|
171
|
-
show=["source"];
|
|
172
|
-
node.args["row","rowTarget"];
|
|
173
|
-
} else if(["addRow2Row"].includes(action)){
|
|
174
|
-
show=["source"];
|
|
175
|
-
node.args["row","rowTarget","factor","start","end"];
|
|
176
|
-
} else if(["divideRow"].includes(action)){
|
|
177
|
-
show=["source"];
|
|
178
|
-
node.args["row","factor","start","end"];
|
|
179
|
-
} else if(["toArray"].includes(action)){
|
|
180
|
-
node.args["precision"];
|
|
181
|
-
};
|
|
160
|
+
node.properties.forEach(property=>$(".form-row-http-in-"+property).hide());
|
|
161
|
+
const actionDef=actions[action];
|
|
162
|
+
node.args=actionDef.args;
|
|
182
163
|
node.args.forEach(property=>$(".form-row-http-in-"+property).show());
|
|
183
|
-
show.forEach(property=>$(".form-row-http-in-"+property).show());
|
|
164
|
+
actionDef.show.forEach(property=>$(".form-row-http-in-"+property).show());
|
|
165
|
+
|
|
184
166
|
});
|
|
185
167
|
},
|
|
186
168
|
oneditsave: function() {
|
|
169
|
+
const node=this;
|
|
170
|
+
Object.keys(node.editors).forEach(property=>{
|
|
171
|
+
const editor=node.editors[property];
|
|
172
|
+
node[property]=editor.getValue();
|
|
173
|
+
editor.destroy();
|
|
174
|
+
delete editor;
|
|
175
|
+
})
|
|
187
176
|
},
|
|
188
|
-
|
|
177
|
+
oneditcancel: function() {
|
|
178
|
+
const node=this;
|
|
179
|
+
Object.keys(node.editors).forEach(property=>{
|
|
180
|
+
const editor=node.editors[property];
|
|
181
|
+
editor.destroy();
|
|
182
|
+
delete editor;
|
|
183
|
+
});
|
|
189
184
|
},
|
|
190
185
|
resizeRule: function(file,newWidth) {
|
|
191
186
|
}
|
|
@@ -199,14 +194,9 @@
|
|
|
199
194
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
200
195
|
</div>
|
|
201
196
|
<div class="form-row">
|
|
202
|
-
<label for="node-input-action" style="white-space: nowrap"><i class="
|
|
197
|
+
<label for="node-input-action" style="white-space: nowrap"><i class="fa fa-cog"></i> Action</label>
|
|
203
198
|
<input type="text" id="node-input-action">
|
|
204
199
|
</div>
|
|
205
|
-
<div class="form-row form-row-http-in-source1Propertyx hide">
|
|
206
|
-
<label for="node-input-source1Propertyx" style="white-space: nowrap"><i class="icon-bookmark"></i> Sourcex`</label>
|
|
207
|
-
<input type="text" id="node-input-source1Propertyx">
|
|
208
|
-
<input type="hidden" id="node-input-source1Propertyx-type">
|
|
209
|
-
</div>
|
|
210
200
|
<div id="node-inputDynamicBase"/>
|
|
211
201
|
</script>
|
|
212
202
|
|
package/matrix/matrixNode.js
CHANGED
|
@@ -25,6 +25,7 @@ function evalInFunction(node,propertyName){
|
|
|
25
25
|
const propertyType=propertyName+"-type";
|
|
26
26
|
switch (node[propertyType]){
|
|
27
27
|
case "num":
|
|
28
|
+
case "json":
|
|
28
29
|
return evalFunction(propertyName,"()=>"+property);
|
|
29
30
|
case "node":
|
|
30
31
|
return evalFunction(propertyName,"()=>nodeContext.get("+property+")");
|
|
@@ -46,6 +47,14 @@ function evalInFunction(node,propertyName){
|
|
|
46
47
|
throw Error(property+" "+ex.message);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
function argsArray(node,msg) {
|
|
51
|
+
const args=[];
|
|
52
|
+
node.argFunction.forEach(callFunction=> {
|
|
53
|
+
const result=callFunction(msg);
|
|
54
|
+
args.push(result);
|
|
55
|
+
});
|
|
56
|
+
return args;
|
|
57
|
+
}
|
|
49
58
|
module.exports = function (RED) {
|
|
50
59
|
function matrixNode(n) {
|
|
51
60
|
RED.nodes.createNode(this,n);
|
|
@@ -83,12 +92,7 @@ module.exports = function (RED) {
|
|
|
83
92
|
const sourceIn=node.getSource(msg);
|
|
84
93
|
if(sourceIn==null) throw Error("source data not found");
|
|
85
94
|
const sourceMatrix=(sourceIn instanceof Matrix?sourceIn:new Matrix(sourceIn));
|
|
86
|
-
|
|
87
|
-
node.argFunction.forEach(callFunction=> {
|
|
88
|
-
const result=callFunction(msg);
|
|
89
|
-
args.push(result);
|
|
90
|
-
});
|
|
91
|
-
return sourceMatrix[node.action].apply(sourceMatrix,args);
|
|
95
|
+
return sourceMatrix[node.action].apply(sourceMatrix,argsArray(node,msg));
|
|
92
96
|
}
|
|
93
97
|
function baseProcessAndSet(msg){
|
|
94
98
|
const result=baseProcess(msg);
|
|
@@ -102,21 +106,33 @@ module.exports = function (RED) {
|
|
|
102
106
|
}
|
|
103
107
|
function defineProcess(msg){
|
|
104
108
|
if(logger.active) logger.sendInfo({label:"define",arg:{rows:node.row,columns:node.column}});
|
|
105
|
-
const sourceMatrix=new Matrix({rows:node.
|
|
109
|
+
const sourceMatrix=new Matrix({rows:node.rows,columns:node.columns});
|
|
106
110
|
node.setData.apply(node,[sourceMatrix,msg]);
|
|
107
111
|
}
|
|
108
112
|
function defineEmptyProcess(msg){
|
|
109
113
|
if(logger.active) logger.sendInfo({label:"define",arg:{rowsMax:node.row,columns:node.column}});
|
|
110
|
-
const sourceMatrix=new Matrix({rowsMax:node.
|
|
114
|
+
const sourceMatrix=new Matrix({rowsMax:node.rows,columns:node.columns});
|
|
111
115
|
node.setData.apply(node,[sourceMatrix,msg]);
|
|
112
116
|
}
|
|
117
|
+
function createSize(msg){
|
|
118
|
+
const sourceMatrix=new Matrix({rows:node.size,columns:node.size});
|
|
119
|
+
node.setData.apply(node,[sourceMatrix[node.action](),msg]);
|
|
120
|
+
}
|
|
121
|
+
function createDummy(msg){
|
|
122
|
+
const sourceMatrix=new Matrix(1,1);
|
|
123
|
+
node.setData.apply(node,[sourceMatrix[node.action].apply(sourceMatrix,argsArray(node,msg)),msg]);
|
|
124
|
+
}
|
|
113
125
|
node.msgProcess=baseProcess;
|
|
114
126
|
if(["define"].includes(node.action)){
|
|
115
127
|
node.msgProcess=defineProcess;
|
|
116
128
|
}else if(["defineEmpty"].includes(node.action)){
|
|
117
129
|
node.msgProcess=defineEmptyProcess;
|
|
118
130
|
}else if(["create"].includes(node.action)){
|
|
119
|
-
|
|
131
|
+
node.msgProcess=createProcess;
|
|
132
|
+
}else if(["runningSum"].includes(node.action)){
|
|
133
|
+
node.msgProcess=createSize;
|
|
134
|
+
}else if(["getVandermonde"].includes(node.action)){
|
|
135
|
+
node.msgProcess=createDummy;
|
|
120
136
|
}else{
|
|
121
137
|
if(node.action.startsWith("get")
|
|
122
138
|
|| ["create","createLike","clone","transpose","sumRow","createForEachCellPairSet",
|
|
@@ -126,6 +142,7 @@ module.exports = function (RED) {
|
|
|
126
142
|
}
|
|
127
143
|
}
|
|
128
144
|
} catch(ex) {
|
|
145
|
+
logger.sendError({label:"setup",error:ex.message,stack:ex.stack})
|
|
129
146
|
error(node,ex,"Invalid setup "+ex.message);
|
|
130
147
|
return;
|
|
131
148
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-prib-functions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.2",
|
|
4
4
|
"description": "Node-RED added node functions.",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"avsc": "^5.6.1",
|
|
7
|
+
"compressiontool": "*",
|
|
7
8
|
"fast-xml-parser": "^3.19.0",
|
|
8
|
-
"node-red-contrib-logger": "
|
|
9
|
+
"node-red-contrib-logger": "latest",
|
|
10
|
+
"node-red-contrib-noderedbase": ">=0.0.16",
|
|
9
11
|
"xlsx": "^0.17.0"
|
|
10
12
|
},
|
|
11
13
|
"devDependencies": {
|
|
@@ -14,11 +16,12 @@
|
|
|
14
16
|
"bcrypt": "^5.0.1",
|
|
15
17
|
"bl": "^5.0.0",
|
|
16
18
|
"mocha": "^9.2.2",
|
|
17
|
-
"node-red": "^
|
|
18
|
-
"node-red-node-test-helper": "^0.
|
|
19
|
+
"node-red": "^3.0.2",
|
|
20
|
+
"node-red-node-test-helper": "^0.3.0"
|
|
19
21
|
},
|
|
20
22
|
"scripts": {
|
|
21
|
-
"test": "mocha \"test/matrix/**/*.js\""
|
|
23
|
+
"test": "mocha \"test/matrix/**/*.js\"",
|
|
24
|
+
"startNodeRed": "pwd; node-red --title '***test nodered***' --setting ./test/data/settings.js ./test/data/flow.json"
|
|
22
25
|
},
|
|
23
26
|
"repository": {
|
|
24
27
|
"type": "git",
|
|
@@ -36,11 +39,14 @@
|
|
|
36
39
|
"backward substitution",
|
|
37
40
|
"compare",
|
|
38
41
|
"Complement Minor",
|
|
42
|
+
"compression",
|
|
39
43
|
"CMA",
|
|
40
44
|
"cumulative",
|
|
41
45
|
"Cumulative Moving Average",
|
|
42
46
|
"data",
|
|
43
47
|
"data analysis",
|
|
48
|
+
"decompression",
|
|
49
|
+
"deflate",
|
|
44
50
|
"delta",
|
|
45
51
|
"determinant",
|
|
46
52
|
"distance",
|
|
@@ -53,9 +59,11 @@
|
|
|
53
59
|
"gauss jordan",
|
|
54
60
|
"Gauss Jordan Inverse",
|
|
55
61
|
"gaussian elimination",
|
|
62
|
+
"gzip",
|
|
56
63
|
"host available",
|
|
57
64
|
"host status",
|
|
58
65
|
"identity",
|
|
66
|
+
"inflate",
|
|
59
67
|
"injector",
|
|
60
68
|
"inverse",
|
|
61
69
|
"inverse matrix",
|
|
@@ -97,6 +105,7 @@
|
|
|
97
105
|
"translate",
|
|
98
106
|
"transform",
|
|
99
107
|
"transpose",
|
|
108
|
+
"unzip",
|
|
100
109
|
"variance",
|
|
101
110
|
"weighted",
|
|
102
111
|
"Weighted Moving Average",
|
|
@@ -106,9 +115,11 @@
|
|
|
106
115
|
"xcel",
|
|
107
116
|
"xml",
|
|
108
117
|
"XML",
|
|
118
|
+
"zip",
|
|
109
119
|
"Z-score"
|
|
110
120
|
],
|
|
111
121
|
"node-red": {
|
|
122
|
+
"version": ">=2.0.0",
|
|
112
123
|
"nodes": {
|
|
113
124
|
"append": "append/append.js",
|
|
114
125
|
"dataAnalysis": "dataAnalysis/dataAnalysis.js",
|
package/test/01-base.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const assert=require('assert');
|
|
2
|
+
const should=require("should");
|
|
3
|
+
const helper=require("node-red-node-test-helper");
|
|
4
|
+
const storageDefinition=require("../nodes/storageDefinition.js");
|
|
5
|
+
const storageRead = require('../nodes/storageRead.js');
|
|
6
|
+
|
|
7
|
+
helper.init(require.resolve('node-red'));
|
|
8
|
+
|
|
9
|
+
function getAndTestNodeProperties(o) {
|
|
10
|
+
const n = helper.getNode(o.id);
|
|
11
|
+
for(let p in o) n.should.have.property(p, o[p]);
|
|
12
|
+
return n;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const blockStorage={
|
|
16
|
+
id : "blockStorage",
|
|
17
|
+
type : "Storage Definition",
|
|
18
|
+
name : "Block Storage",
|
|
19
|
+
action: "blockStorage",
|
|
20
|
+
sourceProperty:"blockStorageFile",
|
|
21
|
+
blockSize:4096
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const StorageReadBlock={
|
|
25
|
+
id : "StorageReadBlockid",
|
|
26
|
+
type : "Storage Read",
|
|
27
|
+
name : "Block Storage",
|
|
28
|
+
target:"payload",
|
|
29
|
+
"target-type":"msg",
|
|
30
|
+
key:"topic"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function testFlow(done,node,data,result) {
|
|
34
|
+
const flow = [
|
|
35
|
+
Object.assign(node,{wires : [ [ "outHelper" ],["errorHelper"] ]}),
|
|
36
|
+
{id :"outHelper", type : "helper"},
|
|
37
|
+
{id :"errorHelper", type : "helper"}
|
|
38
|
+
];
|
|
39
|
+
helper.load(storageDefinition, flow, function() {
|
|
40
|
+
const n=getAndTestNodeProperties(node);
|
|
41
|
+
const outHelper = helper.getNode("outHelper");
|
|
42
|
+
const errorHelper = helper.getNode("errorHelper");
|
|
43
|
+
outHelper.on("input", function(msg) {
|
|
44
|
+
console.log("outHelper "+JSON.stringify(msg.payload));
|
|
45
|
+
if(JSON.stringify(msg.payload)==JSON.stringify(result)) {
|
|
46
|
+
done();
|
|
47
|
+
} else {
|
|
48
|
+
console.log("mismatch expected: "+JSON.stringify(result) +" returned: "+JSON.stringify(msg.payload));
|
|
49
|
+
done("mismatch");
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
errorHelper.on("input", function(msg) {
|
|
53
|
+
console.log("errorHelper "+JSON.stringify(msg));
|
|
54
|
+
done("error check log output");
|
|
55
|
+
});
|
|
56
|
+
n.receive({
|
|
57
|
+
topic:"test",
|
|
58
|
+
payload : data
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe('Storage Defintion', function() {
|
|
64
|
+
beforeEach(function(done) {
|
|
65
|
+
helper.startServer(done);
|
|
66
|
+
});
|
|
67
|
+
afterEach(function(done) {
|
|
68
|
+
helper.unload();
|
|
69
|
+
helper.stopServer(done);
|
|
70
|
+
});
|
|
71
|
+
it("load config", function(done) {
|
|
72
|
+
helper.load(storageDefinition,[], function() {
|
|
73
|
+
const n=getAndTestNodeProperties(storageDefinition);
|
|
74
|
+
});
|
|
75
|
+
done();
|
|
76
|
+
});
|
|
77
|
+
it("load read", function(done) {
|
|
78
|
+
helper.load(storageDefinition,storageRead,[], function() {
|
|
79
|
+
const n=getAndTestNodeProperties(storageDefinition);
|
|
80
|
+
});
|
|
81
|
+
done();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('read 1', function(done) {
|
|
85
|
+
const msg={topic:1}
|
|
86
|
+
testFlow(done,storageDefinition,msg,msg);
|
|
87
|
+
});
|
|
88
|
+
});
|