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.
- package/.github/workflows/codeql-analysis.yml +3 -3
- package/.github/workflows/npmpublish.yml +6 -6
- package/.vs/VSWorkspaceState.json +7 -0
- package/.vs/node-red-contrib-prib-functions/v17/.wsuo +0 -0
- package/README.md +22 -19
- package/arima/index.js +18 -0
- package/dataAnalysis/arrayAllRowsSwap.js +15 -0
- package/dataAnalysis/arrayCompareToPrecision.js +34 -0
- package/dataAnalysis/arrayDifference.js +14 -0
- package/dataAnalysis/arrayDifferenceSeasonal.js +15 -0
- package/dataAnalysis/arrayDifferenceSeasonalSecondOrder.js +20 -0
- package/dataAnalysis/arrayDifferenceSecondOrder.js +14 -0
- package/dataAnalysis/arrayForEachRange.js +38 -0
- package/dataAnalysis/arrayOverlay.js +13 -0
- package/dataAnalysis/arrayProduct.js +11 -0
- package/dataAnalysis/arrayRandom.js +14 -0
- package/dataAnalysis/arrayReduceRange.js +11 -0
- package/dataAnalysis/arrayScale.js +11 -0
- package/dataAnalysis/arraySum.js +11 -0
- package/dataAnalysis/arraySumSquared.js +11 -0
- package/dataAnalysis/arraySwap.js +11 -0
- package/dataAnalysis/dataAnalysis.html +31 -14
- package/dataAnalysis/dataAnalysis.js +10 -1
- package/dataAnalysis/generateMatrixFunction.js +89 -0
- package/dataAnalysis/generateVectorFunction.js +25 -0
- package/dataAnalysis/pca.js +546 -0
- package/dataAnalysis/svd.js +239 -0
- package/documentation/loadInjector.png +0 -0
- package/echart/echart.html +68 -0
- package/echart/echart.js +85 -0
- package/echart/icons/chart-671.png +0 -0
- package/echart/lib/echarts.js +95886 -0
- package/lib/Chart.js +177 -0
- package/lib/Column.js +99 -0
- package/lib/GraphDB.js +14 -0
- package/lib/Table.js +185 -0
- package/lib/objectExtensions.js +361 -0
- package/matrix/matrix.js +50 -50
- package/matrix/matrixNode.html +144 -154
- package/matrix/matrixNode.js +26 -9
- package/monitor/BarGauge.js +8 -0
- package/monitor/Dataset.js +29 -0
- package/monitor/DialGauge.js +109 -0
- package/monitor/DialNeedle.js +36 -0
- package/monitor/Format.js +74 -0
- package/monitor/centerElement.js +14 -0
- package/monitor/compareElements.js +95 -0
- package/monitor/defs.js +23 -0
- package/monitor/extensions.js +906 -0
- package/monitor/functions.js +36 -0
- package/monitor/json2xml.js +103 -0
- package/monitor/monitorSystem.html +198 -0
- package/monitor/monitorSystem.js +322 -0
- package/monitor/svgHTML.js +179 -0
- package/monitor/svgObjects.js +64 -0
- package/package.json +31 -8
- package/test/00-objectExtensions.js +94 -0
- package/test/01-base.js +88 -0
- package/test/04-tables.js +33 -0
- package/test/data/.config.nodes.json +608 -0
- package/test/data/.config.nodes.json.backup +608 -0
- package/test/data/.config.runtime.json +4 -0
- package/test/data/.config.runtime.json.backup +3 -0
- package/test/data/.config.users.json +21 -0
- package/test/data/.config.users.json.backup +21 -0
- package/test/data/.flow.json.backup +3433 -0
- package/test/data/float32vector10.npy +0 -0
- package/test/data/flow.json +3433 -0
- package/test/data/int2matrix2x3.npy +0 -0
- package/test/data/package-lock.json +158 -0
- package/test/data/package.json +11 -0
- package/test/data/settings.js +544 -0
- package/test/dataAnalysisExtensions.js +472 -0
- package/test/dataAnalysisPCA.js +54 -0
- package/test/dataAnalysisSVD.js +31 -0
- package/test/euclideanDistance.js +2 -2
- package/test/matrix/02base.js +36 -0
- package/test/transformNumPy.js +132 -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/NumPy.js +303 -0
- package/transform/transform.html +73 -19
- package/transform/transform.js +144 -8
- 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
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function Dataset(settings) {
|
|
2
|
+
Object.assign(this,{values:[]},settings)
|
|
3
|
+
}
|
|
4
|
+
Dataset.prototype.addValue=function(v){
|
|
5
|
+
if(this.min==null) {
|
|
6
|
+
this.max=v
|
|
7
|
+
this.min=v
|
|
8
|
+
this.range=0
|
|
9
|
+
this.average=v
|
|
10
|
+
} else {
|
|
11
|
+
if(this.min>v){
|
|
12
|
+
this.min=v
|
|
13
|
+
this.range=this.max-this.min
|
|
14
|
+
} else if(this.max<v){
|
|
15
|
+
this.max=v
|
|
16
|
+
this.range=this.max-this.min
|
|
17
|
+
}
|
|
18
|
+
this.average+=(v-this.average)/(this.values.length+1)
|
|
19
|
+
}
|
|
20
|
+
this.values.push(v)
|
|
21
|
+
}
|
|
22
|
+
Dataset.prototype.getMax=function(){return this.max}
|
|
23
|
+
Dataset.prototype.getMin=function(){return this.min}
|
|
24
|
+
Dataset.prototype.getAverage=function(){return this.average}
|
|
25
|
+
Dataset.prototype.getFirst=function(){return this.values[0]}
|
|
26
|
+
Dataset.prototype.getRange=function(){return this.range}
|
|
27
|
+
Dataset.prototype.getLast=function(){return this.value.slice(-1)}
|
|
28
|
+
|
|
29
|
+
module.exports=Dataset
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const defs=require("./defs.js")
|
|
2
|
+
const DialNeedle=require("./DialNeedle.js")
|
|
3
|
+
const boundValue=(v,max=100,min=0)=>Math.min(Math.max(v, min), max)
|
|
4
|
+
const pi2=2 * Math.PI
|
|
5
|
+
const pi2DegreeFactor=180 / Math.PI
|
|
6
|
+
const toRadians=(degrees)=> degrees / pi2DegreeFactor
|
|
7
|
+
const toDegrees=(radians)=> radians * pi2DegreeFactor
|
|
8
|
+
function DialGauge(settings) {
|
|
9
|
+
Object.assign(this,{radius:100,value:0,gapAngle:80,color:"gray",min:0,max:100,title:"%"},settings)
|
|
10
|
+
this.range=this.max-this.min
|
|
11
|
+
if(this.range<=0) throw Error("invalid range, min>=max")
|
|
12
|
+
this.strokeWidth = this.radius * 0.3;
|
|
13
|
+
this.circumference = this.radius * pi2
|
|
14
|
+
this.dashOffset = this.circumference * this.gapAngle/380;
|
|
15
|
+
this.gaugeAngleArea=360-this.gapAngle
|
|
16
|
+
this.angleFactor=this.gaugeAngleArea/this.range
|
|
17
|
+
this.halfStrokeGap=(this.circumference-this.dashOffset)/2
|
|
18
|
+
this.strokeInnerRadius=this.radius - this.strokeWidth / 2
|
|
19
|
+
this.strokeInnerCircumference= this.strokeInnerRadius * pi2
|
|
20
|
+
this.strokeDashOffset = this.strokeInnerCircumference * this.gaugeAngleArea/360;
|
|
21
|
+
this.gauge={action:"circle",fill:"transparent",
|
|
22
|
+
cx:this.radius,cy:this.radius,r:this.strokeInnerRadius,stroke:"lightgray","stroke-width":this.strokeWidth,
|
|
23
|
+
"stroke-dasharray":this.getDashArray(this.max),
|
|
24
|
+
transform:{rotate:{angle:90+parseInt(this.gapAngle/2),x:this.radius,y:this.radius}}}
|
|
25
|
+
this.needle=new DialNeedle({radius:this.radius,startAngle:-this.gaugeAngleArea/2})
|
|
26
|
+
this.svg=this.getSvg()
|
|
27
|
+
}
|
|
28
|
+
DialGauge.prototype.get=function(value){
|
|
29
|
+
return this.svg
|
|
30
|
+
}
|
|
31
|
+
DialGauge.prototype.getSvg=function(){
|
|
32
|
+
const group=[]
|
|
33
|
+
group.push(Object.assign({},this.gauge,{stroke:"red"}))
|
|
34
|
+
group.push(Object.assign({},this.gauge,{stroke:"orange","stroke-dasharray":this.getDashArray(80)}))
|
|
35
|
+
group.push(Object.assign({},this.gauge,{stroke:"yellow","stroke-dasharray":this.getDashArray(60)}))
|
|
36
|
+
group.push(Object.assign({},this.gauge,{stroke:"lightgreen","stroke-dasharray":this.getDashArray(40)}))
|
|
37
|
+
group.push(Object.assign({},this.gauge,{stroke:"green","stroke-dasharray":this.getDashArray(20)}))
|
|
38
|
+
group.push(Object.assign({},this.gauge,{id:"dialColor",stroke:"lightgray","stroke-dasharray":this.getDashArrayReverse(0)}))
|
|
39
|
+
/*
|
|
40
|
+
group.push({action:"clipPath",id:"clipGauge",children:[
|
|
41
|
+
Object.assign({},this.gauge,{id:"dialColor1","stroke-dasharray":this.getDashArray(0),"stroke-miterlimit":"10",stroke:"none",class:"heatGrad"})
|
|
42
|
+
]})
|
|
43
|
+
group.push({action:"style",children:["circle.heatGrad {background: conic-gradient(red, orange, yellow, green); }"]})
|
|
44
|
+
group.push({action:"use",href:{id:"clipGauge"}})
|
|
45
|
+
*/
|
|
46
|
+
group.push(this.getScale())
|
|
47
|
+
group.push({action:"text",x:this.radius,y:this.radius*1.5,"dominant-baseline":"middle","text-anchor":"middle",children:[this.title]})
|
|
48
|
+
group.push(this.needle.get(0))
|
|
49
|
+
return {action:"g",height:2*this.radius,children:[group]}
|
|
50
|
+
/*
|
|
51
|
+
{action:"clipPath",children:[
|
|
52
|
+
Object.assign({},this.gauge,{id:"dialColor","stroke-dasharray":this.getDashArray(0),stroke:"none",class:"grad"})
|
|
53
|
+
]},
|
|
54
|
+
{action:"style",children:["circle.grad {background: conic-gradient(red, orange, yellow, green); }"]},
|
|
55
|
+
{action:"setConicGradient",id:"clip"},
|
|
56
|
+
*/
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
DialGauge.prototype.getUpdate=function(value){
|
|
60
|
+
return [this.needle.getUpdate((value-this.min)*this.angleFactor),{action:"update",id:"dialColor","stroke-dasharray":this.getDashArrayReverse(value)}]
|
|
61
|
+
}
|
|
62
|
+
DialGauge.prototype.setMax=function(value){
|
|
63
|
+
this.max = value
|
|
64
|
+
this.range=this.max-this.min
|
|
65
|
+
if(this.range<=0) throw Error("invalid range, min>=max")
|
|
66
|
+
this.angleFactor=this.gaugeAngleArea/this.range
|
|
67
|
+
return this
|
|
68
|
+
}
|
|
69
|
+
DialGauge.prototype.getDashArray=function(value){
|
|
70
|
+
const ratio=(value-this.min)/this.range
|
|
71
|
+
const dash=this.strokeDashOffset*ratio
|
|
72
|
+
const gap=this.strokeInnerCircumference-dash
|
|
73
|
+
return dash+","+gap
|
|
74
|
+
}
|
|
75
|
+
DialGauge.prototype.getDashArrayReverse=function(value){
|
|
76
|
+
const ratio=(value-this.min)/this.range
|
|
77
|
+
const gap=this.strokeDashOffset*ratio
|
|
78
|
+
const dash=this.strokeDashOffset*(1-ratio)
|
|
79
|
+
return "0,"+gap+","+dash+","+this.strokeDashOffset
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
DialGauge.prototype.getScale=function() {
|
|
83
|
+
const sr1 = this.radius;
|
|
84
|
+
const sr2 = this.radius - this.strokeWidth-5;
|
|
85
|
+
const srT = sr2 - 10;
|
|
86
|
+
const objDef=[]
|
|
87
|
+
let n = 0;
|
|
88
|
+
const increment=toRadians(this.gaugeAngleArea/10)
|
|
89
|
+
for (let sr = toRadians(-this.gaugeAngleArea); sr <= 0; sr += increment) {
|
|
90
|
+
const sra=sr + toRadians(90 - this.gapAngle/2)
|
|
91
|
+
const saCos=Math.cos(sra)
|
|
92
|
+
const saSin=Math.sin(sra)
|
|
93
|
+
objDef.push({action:"line",
|
|
94
|
+
x1:this.radius + sr1 * saCos,
|
|
95
|
+
y1:this.radius + sr1 * saSin,
|
|
96
|
+
x2:this.radius + sr2 * saCos,
|
|
97
|
+
y2:this.radius + sr2 * saSin}
|
|
98
|
+
)
|
|
99
|
+
objDef.push({action:"text",
|
|
100
|
+
x:this.radius + srT * saCos,
|
|
101
|
+
y:this.radius + srT * saSin,
|
|
102
|
+
children:[String(n*10)]
|
|
103
|
+
})
|
|
104
|
+
n++
|
|
105
|
+
}
|
|
106
|
+
return objDef;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports=DialGauge
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function DialNeedle(settings) {
|
|
2
|
+
Object.assign(this,{
|
|
3
|
+
radius:100,
|
|
4
|
+
startAngle:0,
|
|
5
|
+
id:"needle",
|
|
6
|
+
baseDialSize:20,
|
|
7
|
+
value:{min:0,max:100}
|
|
8
|
+
},settings)
|
|
9
|
+
Object.assign(this,{
|
|
10
|
+
endAngle:this.endAngle??360-this.startAngle,
|
|
11
|
+
center:this.center??{x:this.radius,y:this.radius}
|
|
12
|
+
})
|
|
13
|
+
this.value.range=this.value.max-this.value.min
|
|
14
|
+
this.ratio=(this.endAngle-this.startAngle)/this.range,
|
|
15
|
+
this.svg=this.getSvg();
|
|
16
|
+
}
|
|
17
|
+
DialNeedle.prototype.get=function(value){
|
|
18
|
+
return this.svg
|
|
19
|
+
}
|
|
20
|
+
DialNeedle.prototype.getSvg=function(id=""){
|
|
21
|
+
return {action:"g",id:id+this.id,children:[
|
|
22
|
+
{action:"path",transform:{rotate:{angle:this.startAngle,x:this.radius,y:this.radius}},d:[
|
|
23
|
+
{action:"moveTo",x:this.radius,y:0},
|
|
24
|
+
{action:"deltaLineTo",x:-this.baseDialSize,y:this.radius},
|
|
25
|
+
{action:"deltaArc",radius:{x:this.baseDialSize,y:this.baseDialSize},x:this.baseDialSize*2,y:0},
|
|
26
|
+
{action:"Z"}
|
|
27
|
+
],
|
|
28
|
+
fill:this.color,stroke:this.color
|
|
29
|
+
}
|
|
30
|
+
]}
|
|
31
|
+
}
|
|
32
|
+
DialNeedle.prototype.getUpdate=function(angle){
|
|
33
|
+
if(angle>360 || angle < -360) throw Error("angle > 360 or < -360, angle: "+angle)
|
|
34
|
+
return {action:"update",id:this.id,transform:{rotate:{angle,x:this.radius,y:this.radius}}}
|
|
35
|
+
}
|
|
36
|
+
module.exports=DialNeedle
|