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

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.
@@ -7,18 +7,20 @@
7
7
  name: {value:null},
8
8
  action: {value: "create",required:true},
9
9
  args: {value:[]},
10
- arg: {value:null},"arg-type": {value:"msg"},
11
10
  call:{value:null},
12
- column: {value:null},"column-type": {value:"num"},
13
- columns: {value:null},"columns-type": {value:"num"},
11
+ column: {value:2},"column-type": {value:"num"},
12
+ columns: {value:2},"columns-type": {value:"num"},
13
+ dataType: {value:"Float32Array"},"columns-type": {value:"Float32Array"},
14
14
  end: {value:null},"end-type": {value:"num"},
15
15
  factor: {value:null},"factor-type": {value:"num"},
16
+ initialState:{value:"setZero"},
16
17
  matrix: {value:"payload"},"matrix-type": {value:"msg"},
17
18
  precision: {value:3},"precision-type": {value:"num"},
18
19
  row: {value:3},"row-type": {value:"num"},
19
20
  rows: {value:3},"rows-type": {value:"num"},
20
21
  rowTarget: {value:null},"rowTarget-type": {value:"num"},
21
22
  source: {value:"_matrix"},"source-type": {value:"msg"},
23
+ sourceArray: {value:"payload"},"sourceArray-type": {value:"msg,json,flow,global"},
22
24
  start: {value:null},"start-type": {value:"num"},
23
25
  target: {value:"_matrix"},"target-type": {value:"msg"},
24
26
  value: {value:"payload"},"value-type": {value:"msg"},
@@ -35,70 +37,70 @@
35
37
  return this.name || ("Matrix "+this.action||"*** new ***");
36
38
  },
37
39
  oneditprepare: function() {
40
+ console.log("+++")
38
41
  const node=this;
39
42
  node.properties=[];
40
43
  node.editors=[];
41
44
  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
45
  add:{label:"Add",show:["source"],args:["matrix"]},
48
46
  addRow:{label:"Add Row",show:["source"],args:["row","vector"]},
49
47
  addRow2Row:{label:"Add Row to Row",show:["source"],args:["row","target","factor","start","end"]},
50
48
  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
49
  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"]},
50
+ create:{label:"Create", show:["target"],args:["initialState","rows","columns","dataType"]},
51
+ createLike:{label:"Create Like",show:["source","target"],args:[]},
52
+ clone:{label:"Clone",show:["source","target"],args:[]},
82
53
  createForEachCellPairSet:{label:"Create Pair Set Cells",show:["source","target"],args:["matrix","call"],default:{call:"(baseCellValue,matrixCellValue)=>{}"}},
54
+ define:{label:"Define",show:["target"],args:["rows","columns","dataType"]},
55
+ defineEmpty:{label:"Define Empty",show:["target"],args:["rows","columns","dataType"]},
56
+ divideCell:{label:"Divide Cell",show:["source"],args:["rows","columns","value"]},
57
+ divideRow:{label:"Divide Row",show:["source"],args:["row","factor","start","end"]},
58
+ equalsNearly:{label:"Nearly Equals",show:["source"],args:[]},
59
+ fillArray:{label:"Fill",show:["source"],args:["matrix"]},
60
+ findColumnRow:{label:"Find in Column",show:["source"],args:["column","call","start","end"],default:{call:"()=>{}"}},
83
61
  findRowColumn:{label:"Find in Row",show:["source"],args:["row","call","start","end"],default:{call:"(value,row,column,offset,vector)=>true"}},
84
62
  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
63
  forColumnCells:{label:"Column Cells",show:["source"],args:["column","call","start","end"],default:{call:"()=>{}"}},
88
64
  forEachCell:{label:"For Each Cell",show:["source"],args:["call"],default:{call:"()=>{}"}},
89
65
  forEachRow:{label:"For Each Row",show:["source"],args:["call"],default:{call:"()=>{}"}},
90
66
  forEachCellPairSet:{label:"For Each Cell Pair Set",show:["source"],args:["matrix","call"],default:{call:"()=>{}"}},
67
+ forwardElimination:{label:"Forward Elimination",show:["source"],args:[]},
68
+ gaussianElimination:{label:"Gaussian Elimination",show:["source"],args:[]},
69
+ get:{label:"Get Cell",show:["source","target"],args:[]},
70
+ getAdjoint:{label:"Adjoint",show:["source","target"],args:[]},
71
+ getCofactor:{label:"Cofactor",show:["source","target"],args:[]},
72
+ getComplementMinor:{label:"Complement Minor",show:["source","target"],args:[]},
73
+ getDeterminant:{label:"Determinant",show:["source","target"],args:[]},
74
+ getDeterminantUsingCofactor:{label:"Determinant (Cofactor)",show:["source","target"],args:[]},
75
+ getDeterminantUsingCofactor:{label:"Determinant (Row Echelon Form)",show:["source","target"],args:[]},
76
+ getIdentity:{label:"Identity",show:["source","target"],args:[]},
77
+ getInverse:{label:"Inverse",show:["source","target"],args:[]},
78
+ getInverseAdjointMethod:{label:"Inverse (Adjoint Method)",show:["source","target"],args:[]},
79
+ getInverseGaussJordan:{label:"Inverse (Gauss Jordan Method)",show:["source","target"],args:[]},
91
80
  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"]},
81
+ getMatrix:{label:"Get Sub Matrix",show:["source","target"],args:["row","column","rows","columns"]},
94
82
  getRow:{label:"Get Row",show:["source","target"],args:["row"]},
83
+ getVandermonde:{label:"Vandermonde",show:["target"],args:["vector","columns"]},
84
+ getZeroed:{label:"Get Zeroed",show:["source","target"],args:["row","column"]},
95
85
  maxAbsColumn:{label:"Column Maximum Absolute",show:["source","target"],args:["column","start"]},
96
86
  maxColumn:{label:"Column Max",show:["source","target"],args:["column","start"]},
87
+ multiple:{label:"Multiple",show:["source","target"],args:[]},
88
+ multipleCell:{label:"Multiple Cell",show:["source","target"],args:["rows","columns","value"]},
97
89
  multiplyRow:{label:"Multiply Row",show:["source"],args:["row","factor"]},
90
+ norm:{label:"Norm",show:["source","target"],args:[]},
98
91
  reduceRow:{label:"Reduce Row",show:["source","target"],args:["row","call","value"],default:{call:"(agregatevalue,cellValue,row,column)=>agregatevalue+cellValue"}},
92
+ reduce:{label:"Reduce Cells",show:["source","target"],args:["call","value"],default:{call:"()=>{}"}},
93
+ reducedRowEchelonForm:{label:"Reduced Row EchelonForm",show:["source"],args:[]},
94
+ rowEchelonForm:{label:"Row Echelon Form",show:["source"],args:[]},
95
+ runningSum:{label:"Running Sum",show:["source","target"],args:[]},
99
96
  set:{label:"Set Cell",show:["source"],args:["row","column","value"]},
100
97
  setRow:{label:"Set Row",show:["source"],args:["vector","row"]},
101
- reduce:{label:"Reduce Cells",show:["source","target"],args:["call","value"],default:{call:"()=>{}"}}
98
+ subtractCell:{label:"Subtract Cell",show:["source","target"],args:["row","column","value"]},
99
+ sumRow:{label:"Sum Row",show:["source","target"],args:[]},
100
+ swapRows:{label:"Swap Rows",show:["source"],args:[]},
101
+ testIsSquare:{label:"Is Square",show:["source"],args:[]},
102
+ toArray:{label:"To Array Object",show:["source","target"],args:[]},
103
+ transpose:{label:"Transpose",show:["source","target"],args:[]}
102
104
  };
103
105
  const baseDiv=$("#node-inputDynamicBase");
104
106
  function defineProperty(property,...types) {
@@ -118,16 +120,46 @@
118
120
  const inputNode=$('<input type="text" id="node-input-'+property.name+'"/>').val(node[property.name]);
119
121
  const typeNode=$('<input type="hidden" id="node-input-'+property.name+'-type"/>');
120
122
  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
- });
123
+ if(types[0] instanceof Array) {
124
+ $("#node-input-"+property.name).typedInput({
125
+ type:property.name,
126
+ types:[{value: property.name,
127
+ options: types[0]
128
+ }]})
129
+ } else {
130
+ const typeValue=node[property.name+"-type"];
131
+ if(typeValue) typeNode.val(typeValue);
132
+ $("#node-input-"+property.name).typedInput({
133
+ type:typeValue||types[0],
134
+ types:types,
135
+ typeField: "#node-input-"+property.name+"-type"
136
+ });
137
+ }
128
138
  }
129
139
  }
130
- defineProperty({name:"source" ,label:"Source" ,icon:"crosshairs"},"msg","flow","global");
140
+ defineProperty({name:"initialState",label:"Initially" ,icon:"tag"},[
141
+ { value: "setZero", label: "Zeros"},
142
+ { value: "setRandom", label: "Random Numbers"},
143
+ { value: "setIdentity", label: "Identity"},
144
+ { value: "setOne", label: "all 1"},
145
+ ]);
146
+
147
+ defineProperty({name:"dataType",label:"number Type" ,icon:"tag"},[
148
+ { value: "Float32Array", label: "float32 -3.4e38 to 3.4e38" },
149
+ { value: "Float64Array", label: "double/float64 -1.8e308 to 1.8e308" }, { value: "Int8Array", label: "byte -128 to 122" },
150
+ { value: "Uint8Array", label: "octet 0 to 255" },
151
+ { value: "Uint8ClampedArray", label: "octet clamped 0 to 255" },
152
+ { value: "Int16Array", label: "short -32768 to 32767" },
153
+ { value: "Uint16Array", label: "short unsigned 0 to 65535" },
154
+ { value: "Int32Array", label: " long -2147483648 to 2147483647" },
155
+ { value: "Uint32Array", label: "long unsgined 0 to 4294967295" },
156
+ { value: "BigInt64Array", label: "bigint 2**-263 to 2**263" },
157
+ { value: "BigUint64Array", label: "bigint unsigned 0 to 2**264" },
158
+ ]);
159
+
160
+
161
+
162
+ defineProperty({name:"source" ,label:"Source" ,icon:"crosshairs"},"msg","json","flow","global");
131
163
  defineProperty({name:"arg" ,label:"Argument" ,icon:"tag"},"num","json","msg","flow","global","env");
132
164
  defineProperty({name:"matrix" ,label:"Matrix" ,icon:"th"},"msg","flow","global");
133
165
  defineProperty({name:"target" ,label:"Target" ,icon:"save"},"msg","flow","global");
@@ -145,8 +177,10 @@
145
177
  defineProperty({name:"vector" ,label:"Vector" ,icon:"ellipsis-h"},"json","msg","flow","global");
146
178
  defineProperty({name:"call" ,label:"Call" ,icon:"js",mode:"javascript"},"edit");
147
179
 
148
- const options=Object.keys(actions).reduce((previousValue,property)=>previousValue.concat({value:property,label:actions[property].label}),
149
- []);
180
+ const options=Object.keys(actions)
181
+ .sort((a,b) => actions[a].label<actions[b].label?-1:0)
182
+ .reduce((previousValue,property)=>previousValue.concat({value:property,label:actions[property].label}),
183
+ []);
150
184
  const actionNode=$("#node-input-action");
151
185
  actionNode.typedInput({
152
186
  types: [{
@@ -154,7 +188,7 @@
154
188
  options: options
155
189
  }]
156
190
  });
157
- actionNode.change(function() {
191
+ actionNode.change(function() {
158
192
  action=$(this).val();
159
193
  node.args=[];
160
194
  node.properties.forEach(property=>$(".form-row-http-in-"+property).hide());
@@ -162,7 +196,6 @@
162
196
  node.args=actionDef.args;
163
197
  node.args.forEach(property=>$(".form-row-http-in-"+property).show());
164
198
  actionDef.show.forEach(property=>$(".form-row-http-in-"+property).show());
165
-
166
199
  });
167
200
  },
168
201
  oneditsave: function() {
@@ -23,6 +23,7 @@ function evalInFunction(node,propertyName){
23
23
  const property=node[propertyName];
24
24
  if(property==null) throw Error("no value for "+propertyName);
25
25
  const propertyType=propertyName+"-type";
26
+ if(! (propertyType in node)) return evalFunction(propertyName,"()=>node."+property)
26
27
  switch (node[propertyType]){
27
28
  case "num":
28
29
  case "json":
@@ -86,7 +87,11 @@ module.exports = function (RED) {
86
87
  }
87
88
  node.argFunction=[];
88
89
  node.args.forEach(property=>{
89
- node.argFunction.push(evalInFunction(node,property).bind(this));
90
+ try{
91
+ node.argFunction.push(evalInFunction(node,property).bind(this));
92
+ } catch(ex) {
93
+ throw Error("args "+property+" "+ex.message)
94
+ }
90
95
  })
91
96
  function baseProcess(msg){
92
97
  const sourceIn=node.getSource(msg);
@@ -99,14 +104,15 @@ module.exports = function (RED) {
99
104
  node.setData.apply(node,[result,msg]);
100
105
  }
101
106
  function createProcess(msg){
102
- const sourceIn=node.getSource(msg);
103
- if(sourceIn==null) throw Error("source data not found");
104
- const sourceMatrix=(sourceIn instanceof Matrix?sourceIn.clone():new Matrix(sourceIn));
107
+ if(logger.active) logger.sendInfo({label:"create",arg:{rowsMax:node.row,columns:node.column}});
108
+ const sourceMatrix=new Matrix({rowsMax:node.rows,columns:node.columns,dataType:node.dataType});
109
+ if(!(node.initialState in sourceMatrix)) throw Error("Invalid initial state "+node.initialState);
110
+ sourceMatrix[node.initialState]()
105
111
  node.setData.apply(node,[sourceMatrix,msg]);
106
112
  }
107
113
  function defineProcess(msg){
108
114
  if(logger.active) logger.sendInfo({label:"define",arg:{rows:node.row,columns:node.column}});
109
- const sourceMatrix=new Matrix({rows:node.rows,columns:node.columns});
115
+ const sourceMatrix=new Matrix({rows:node.rows,columns:node.columns,dataType:node.dataType});
110
116
  node.setData.apply(node,[sourceMatrix,msg]);
111
117
  }
112
118
  function defineEmptyProcess(msg){
@@ -152,6 +158,7 @@ module.exports = function (RED) {
152
158
  node.msgProcess(msg);
153
159
  node.send(msg);
154
160
  } catch(ex) {
161
+ error(node,ex,"Invalid "+ex.message)
155
162
  msg.error=ex.message;
156
163
  node.send([null,msg]);
157
164
  if(logger.active) logger.send({label:"error",node:node.id,action:node.action,exception:ex.message,stack:ex.stack});
@@ -44,6 +44,7 @@
44
44
  )
45
45
  } catch(ex) {
46
46
  svgUpdate=false
47
+ if(ex.message.startsWith("element id not found")) return
47
48
  console.error(ex.message + " for "+JSON.stringify(nodeDetails[id]))
48
49
  }
49
50
  }
@@ -79,7 +80,7 @@
79
80
  outputLabels: ["out"],
80
81
  icon: "icons8-heart-monitor-40.png",
81
82
  label: function() {
82
- console.error("*****+++++")
83
+ console.log("*****+++++")
83
84
  if(!nodeSvg.hasOwnProperty(this.id)) {
84
85
  nodeSvg[this.id]={element:document.getElementById(this.id),actions:[{action:"text",x:0 ,y:60 ,children:["Waiting Refresh"]}]}
85
86
  }
@@ -155,7 +155,7 @@ let metrics=[]
155
155
  const nodes=[]
156
156
  function getJson(){
157
157
  return nodes.reduce((p,node)=>{
158
- p[node.id]=node.getSendData(metrics[0])
158
+ p[node.id]=metrics.length?node.getSendData(metrics[0]):null
159
159
  return p;
160
160
  },{})
161
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-prib-functions",
3
- "version": "0.20.4",
3
+ "version": "0.21.0",
4
4
  "description": "Node-RED added node functions.",
5
5
  "dependencies": {
6
6
  "avsc": ">=5.7.7",
@@ -41,6 +41,8 @@
41
41
  "average",
42
42
  "avg",
43
43
  "AVRO",
44
+ "arima",
45
+ "ARMIA",
44
46
  "arvo",
45
47
  "backward substitution",
46
48
  "compare",
@@ -448,7 +448,7 @@
448
448
  },
449
449
  "node-red-contrib-prib-functions": {
450
450
  "name": "node-red-contrib-prib-functions",
451
- "version": "0.20.2",
451
+ "version": "0.21.0",
452
452
  "local": true,
453
453
  "user": true,
454
454
  "nodes": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "node-red": {
3
3
  "name": "node-red",
4
- "version": "3.1.11",
4
+ "version": "3.1.14",
5
5
  "local": false,
6
6
  "user": false,
7
7
  "nodes": {
@@ -448,7 +448,7 @@
448
448
  },
449
449
  "node-red-contrib-prib-functions": {
450
450
  "name": "node-red-contrib-prib-functions",
451
- "version": "0.20.2",
451
+ "version": "0.20.4",
452
452
  "local": true,
453
453
  "user": true,
454
454
  "nodes": {