node-red-trexmes-commands 1.1.0 → 1.1.1
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 +40 -0
- package/package.json +4 -1
- package/src/assets/1.jpg +0 -0
- package/src/locales/en-US/trexcommands.html +2 -136
- package/src/trexcommands.html +26 -2
- package/src/trexcommands.js +46 -1
package/README.md
CHANGED
|
@@ -9,7 +9,47 @@ Run the following command in the root directory of your Node-RED install
|
|
|
9
9
|
npm install node-red-trexmes-commands
|
|
10
10
|
|
|
11
11
|
# Usage
|
|
12
|
+
The following operations can be performed with this node by communicating with the Trex-Mes system.
|
|
13
|
+
- Load Job Plan
|
|
14
|
+
- Finish Production
|
|
15
|
+
- Start Stoppage
|
|
16
|
+
- Change Stoppage
|
|
17
|
+
- Finish Stoppage
|
|
18
|
+
- Login Employee
|
|
19
|
+
- Logout Employee
|
|
20
|
+
- Shifted Shift
|
|
21
|
+
- Start Test Mode
|
|
22
|
+
- Finish Test Mode
|
|
23
|
+
- Create Deffect
|
|
12
24
|
|
|
25
|
+
For configuration, first MS SQL server connection setting must be made. In addition, the "company" company identification id and the identification id of the personnel who will perform the transaction should be defined as default in the connection features, specifically for the Trex system.
|
|
26
|
+
|
|
27
|
+
Then, the relevant operation is selected from the "Operation Type" combo contained in the node.
|
|
28
|
+
The Json sample data requested as input is displayed on the node for each operation.
|
|
29
|
+
|
|
30
|
+
For example, the input example for "Load Job Plan" should be as follows
|
|
31
|
+
```sh
|
|
32
|
+
{
|
|
33
|
+
"WorkstationId": 10,
|
|
34
|
+
"PlanId": 123
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
When json data is sent in accordance with this sample data, the relevant operation is performed.
|
|
39
|
+
|
|
40
|
+
As an operation return, for example, when the operation is successful for the "Loas Job Plan" operation, the following information is returned.
|
|
41
|
+
```sh
|
|
42
|
+
{
|
|
43
|
+
"COMMANDID":91,
|
|
44
|
+
"ISPROCESSED":true,
|
|
45
|
+
"ISSUCCESS":1,
|
|
46
|
+
"MESSAGE":"LoadPlan Success"
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The example can be found in the node-red import examples page.
|
|
51
|
+
|
|
52
|
+

|
|
13
53
|
|
|
14
54
|
# Requirements
|
|
15
55
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-trexmes-commands",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A node-red node to execute commands for Trex Mes Systems",
|
|
5
5
|
"main": "trexcommands.js",
|
|
6
6
|
"dependencies": {
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"src/"
|
|
18
18
|
],
|
|
19
|
+
"directories": {
|
|
20
|
+
"example": "examples"
|
|
21
|
+
},
|
|
19
22
|
"keywords": [
|
|
20
23
|
"node-red",
|
|
21
24
|
"trex-mes",
|
package/src/assets/1.jpg
ADDED
|
Binary file
|
|
@@ -17,141 +17,7 @@
|
|
|
17
17
|
<script type="text/html" data-help-name="trexMes-CMD">
|
|
18
18
|
<p>Node for Node-RED to trexMes Commands</p>
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
<dl class="message-properties">
|
|
22
|
-
Examples have been included to help you do some common tasks.
|
|
23
|
-
<a onclick="RED.actions.invoke('core:show-examples-import-dialog')" href="#">Click here</a> to import an example or press the hamburger menu <a class="button" href="#"><i class="fa fa-bars"></i></a> select <b>import</b> then <b>examples</b> or press <kbd>ctrl+i</kbd>
|
|
24
|
-
</dl>
|
|
25
|
-
|
|
26
|
-
<h3>Query Mode...</h3>
|
|
27
|
-
<div style="padding-left: 15px;">
|
|
28
|
-
<p>Select the execution mode, this can be "Query", "Stored procedure" or "Bulk Insert"</p>
|
|
29
|
-
<div class="form-tips" style="width: 100%">
|
|
30
|
-
TIP: Query mode can be set in the UI or dynamically via msg, flow, global or env. The value sent must be either "query", "execute" or "bulk"
|
|
31
|
-
</div>
|
|
32
|
-
<p>INFO: TVP variables are only supported in stored procedures. Some variable types are not supported by the underlying SQL driver.
|
|
33
|
-
</p>
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<h3>Query...</h3>
|
|
37
|
-
<div style="padding-left: 15px;">
|
|
38
|
-
<p>Enter the query or stored procedure name to execute. It is possible to use <i><a href="http://mustache.github.io/mustache.5.html" target="_new">mustache</a></i> format to access properties of the msg, flow context and global context.</p>
|
|
39
|
-
<div class="form-tips" style="width: 100%">
|
|
40
|
-
TIP: Query can be set in the UI or dynamically via msg, flow, global or env. The value sent can also contain mustache items.
|
|
41
|
-
</div>
|
|
42
|
-
<br>
|
|
43
|
-
<p>Query Examples (with mustache and parameters)...
|
|
44
|
-
<ul>
|
|
45
|
-
<li><code style="white-space: normal;">SELECT TOP {{{flow.maxRows}}} * FROM [MyTable] WHERE Name = @name AND quantity >= {{{global.minQty}}}</code></li>
|
|
46
|
-
<li><code style="white-space: normal;">INSERT INTO [MyTable] (id, name, quantity) VALUES (@id, '{{{payload.name}}}', {{{payload.qty}}})</code></li>
|
|
47
|
-
<li><code style="white-space: normal;">UPDATE [MyTable] SET quantity = @quantity WHERE id = {{{payload.id}}}</code></li>
|
|
48
|
-
<li><code style="white-space: normal;">DELETE FROM [MyTable] WHERE id = @id</code></li>
|
|
49
|
-
</ul>
|
|
50
|
-
</p>
|
|
51
|
-
<div class="form-tips" style="width: 100%">Query mode tips...
|
|
52
|
-
<ul>
|
|
53
|
-
<li>To access <code>msg</code> properties, just use the variable name. e.g.
|
|
54
|
-
<code>SELECT top {{{payload}}} * from [MyTable]</code></li>
|
|
55
|
-
<li>To access <code>flow</code> and <code>global</code> properties,
|
|
56
|
-
specify them in the mustache e.g.
|
|
57
|
-
<code>SELECT {{{flow.name}}} FROM {{{global.table_name}}}</code></li>
|
|
58
|
-
<li>To prevent certain characters being escaped, use triple curly brackets. e.g.
|
|
59
|
-
<code>{{{flow.my_string}}}</code> </li>
|
|
60
|
-
</ul>
|
|
61
|
-
</div>
|
|
62
|
-
<div class="form-tips" style="width: 100%">Execute tips...
|
|
63
|
-
<ul>
|
|
64
|
-
<li>The query should be just the name of the stored procedure (don't include <code>exec</code>)</li>
|
|
65
|
-
<li>Parameters can be entered in the procedure query
|
|
66
|
-
(but are not necessary - just enter the matching parameter name in the <code>Parameters</code> list) </li>
|
|
67
|
-
</ul>
|
|
68
|
-
</div>
|
|
69
|
-
<div class="form-tips" style="width: 100%">Bulk Insert tips...
|
|
70
|
-
<ul>
|
|
71
|
-
<li>The query should be just the name table to bulk insert into</li>
|
|
72
|
-
<li>Data to bulk insert must be provided to the <code>Rows (bulk data)</code> field as either ...
|
|
73
|
-
<ul>
|
|
74
|
-
<li>an array of array rows e.g. <code>[ [col1_value, col2_value], [col1_value, col2_value] ]</code></li>
|
|
75
|
-
<li>an array of object rows e.g. <code>[ {col1:"value", col2:"value"}, {col1:"value", col2:"value"} ]</code></li>
|
|
76
|
-
</ul>
|
|
77
|
-
</li>
|
|
78
|
-
</ul>
|
|
79
|
-
</div>
|
|
80
|
-
|
|
81
|
-
<br>
|
|
82
|
-
<p>INFO: When the 'Result type' is set to 'Driver output'...
|
|
83
|
-
<ul>
|
|
84
|
-
<li>Multiple results can be returned in the <code>recordsets</code> array if multiple queries are
|
|
85
|
-
executed.</li>
|
|
86
|
-
<li>It is recommended the user checks the value(s) in the <code>rowsAffected</code> property to confirm
|
|
87
|
-
operation - especially when performing INSERT, UPDATE and DELETE operations.</li>
|
|
88
|
-
</ul>
|
|
89
|
-
</p>
|
|
90
|
-
</div>
|
|
91
|
-
|
|
92
|
-
<h3>Parameters...</h3>
|
|
93
|
-
<div style="padding-left: 15px;">
|
|
94
|
-
<p>Input and Output Parameters can be specified for a query or procedure. In bulk mode, the parameters represent the columns of the table</p>
|
|
95
|
-
<div class="form-tips" style="width: 100%">
|
|
96
|
-
TIP: Query can be set in the UI or dynamically via msg, flow, global in the following format...<br>
|
|
97
|
-
<code><pre style="white-space: pre;">[
|
|
98
|
-
{
|
|
99
|
-
"output": false,
|
|
100
|
-
"name": "parameter name",
|
|
101
|
-
"type": "parameter type",
|
|
102
|
-
"value": "parameter value"
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"output": true,
|
|
106
|
-
"name": "parameter name",
|
|
107
|
-
"type": "parameter type"
|
|
108
|
-
}
|
|
109
|
-
]</pre></code>
|
|
110
|
-
</div>
|
|
111
|
-
<br>
|
|
112
|
-
<p>Query Examples (with parameters)...
|
|
113
|
-
<div style="padding-left: 15px;">
|
|
114
|
-
<code style="font-weight: bold;">Query</code>
|
|
115
|
-
<div style="padding-left: 15px;">
|
|
116
|
-
<code style="white-space: normal;">SELECT TOP {{{payload.maxRows}}} * FROM [MyTable] WHERE Name = @name AND quantity >= @minQty</code>
|
|
117
|
-
</div>
|
|
118
|
-
</div>
|
|
119
|
-
<div style="padding-left: 15px;">
|
|
120
|
-
<code style="font-weight: bold;">Parameters</code>
|
|
121
|
-
<ul>
|
|
122
|
-
<li>
|
|
123
|
-
<span>In/Out </span><code style="white-space: normal;">input</code>
|
|
124
|
-
<span>, Name </span><code style="white-space: normal;">name</code>
|
|
125
|
-
<span>, Type </span><code style="white-space: normal;">varchar(20)</code>
|
|
126
|
-
<span>, Value </span><code style="white-space: normal;">stephen</code>
|
|
127
|
-
</li>
|
|
128
|
-
<li>
|
|
129
|
-
<span>In/Out </span><code style="white-space: normal;">input</code>
|
|
130
|
-
<span>, Name </span><code style="white-space: normal;">minQty</code>
|
|
131
|
-
<span>, Type </span><code style="white-space: normal;">int</code>
|
|
132
|
-
<span>, Value </span><code style="white-space: normal;">5</code>
|
|
133
|
-
</li>
|
|
134
|
-
</ul>
|
|
135
|
-
</div>
|
|
136
|
-
</p>
|
|
137
|
-
</div>
|
|
138
|
-
|
|
139
|
-
<h3>Output options...</h3>
|
|
140
|
-
<div style="padding-left: 15px;">
|
|
141
|
-
<h4>Output property</h4>
|
|
142
|
-
<ul>
|
|
143
|
-
<li>The field to write the results to. Typically this is <code>msg.payload</code></li>
|
|
144
|
-
</ul>
|
|
145
|
-
<h4>Output type (not used for "Bulk Insert" mode)</h4>
|
|
146
|
-
<ul>
|
|
147
|
-
<li><b>Original output</b>: The property specified by 'Output property' will be populated with a single recordset (if
|
|
148
|
-
any). This is the same as earlier mssql-plus version - for compatibility</li>
|
|
149
|
-
<li><b>Driver output</b>: The property specified by 'Output property' will be populated with the result of the query
|
|
150
|
-
direct from the driver output. This format can return multiple recordsets and other information. Add a
|
|
151
|
-
debug node to see all available properties returned.</li>
|
|
152
|
-
</ul>
|
|
153
|
-
</div>
|
|
154
|
-
|
|
20
|
+
|
|
155
21
|
<h3>Error Handling...</h3>
|
|
156
22
|
<div style="padding-left: 15px;">
|
|
157
23
|
<ul>
|
|
@@ -163,4 +29,4 @@
|
|
|
163
29
|
</ul>
|
|
164
30
|
</div>
|
|
165
31
|
|
|
166
|
-
</script>
|
|
32
|
+
</script>
|
package/src/trexcommands.html
CHANGED
|
@@ -336,7 +336,13 @@
|
|
|
336
336
|
{ value: '4|Finish Production', label: 'Finish Production', hasValue: false },
|
|
337
337
|
{ value: '5|Start Stoppage', label: 'Start Stoppage', hasValue: false },
|
|
338
338
|
{ value: '6|Change Stoppage', label: 'Change Stoppage', hasValue: false },
|
|
339
|
-
{ value: '7|Finish Stoppage', label: 'Finish Stoppage', hasValue: false }
|
|
339
|
+
{ value: '7|Finish Stoppage', label: 'Finish Stoppage', hasValue: false },
|
|
340
|
+
{ value: '9|Login Employee', label: 'Login Employee', hasValue: false },
|
|
341
|
+
{ value: '10|Logout Employee', label: 'Logout Employee', hasValue: false },
|
|
342
|
+
{ value: '13|Shifted Shift', label: 'Shifted Shift', hasValue: false },
|
|
343
|
+
{ value: '14|Start Test Mode', label: 'Start Test Mode', hasValue: false },
|
|
344
|
+
{ value: '15|Finish Test Mode', label: 'Finish Test Mode', hasValue: false },
|
|
345
|
+
{ value: '16|Create Deffect', label: 'Create Deffect', hasValue: false }
|
|
340
346
|
],
|
|
341
347
|
typeField: $('#node-input-modeOptType'),
|
|
342
348
|
default: 'Load Job Plan'
|
|
@@ -361,7 +367,25 @@
|
|
|
361
367
|
}
|
|
362
368
|
else if(operationMode.startsWith('7|')) { //Finish Stoppage
|
|
363
369
|
data = '{ "WorkstationId": 10 }';
|
|
364
|
-
}
|
|
370
|
+
}
|
|
371
|
+
else if(operationMode.startsWith('9|')) { //Login Employee
|
|
372
|
+
data = '{ "WorkstationId": 10, "EmployeeId": 11 }';
|
|
373
|
+
}
|
|
374
|
+
else if(operationMode.startsWith('10|')) { //Logout Employee
|
|
375
|
+
data = '{ "WorkstationId": 10, "EmployeeId": 11 }';
|
|
376
|
+
}
|
|
377
|
+
else if(operationMode.startsWith('13|')) { //Shifted Shift
|
|
378
|
+
data = '{ "WorkstationId": 10, "LineId": 11 }';
|
|
379
|
+
}
|
|
380
|
+
else if(operationMode.startsWith('14|')) { //Start Test Mode
|
|
381
|
+
data = '{ "WorkstationId": 10, "StoppageCauseId": 11 }';
|
|
382
|
+
}
|
|
383
|
+
else if(operationMode.startsWith('15|')) { //Finish Test Mode
|
|
384
|
+
data = '{ "WorkstationId": 10 }';
|
|
385
|
+
}
|
|
386
|
+
else if(operationMode.startsWith('16|')) { //Create Deffect
|
|
387
|
+
data = '{ "WorkstationId": 10, "DefectId": 11,"StockId": 12, "Quantity": 15.5 }';
|
|
388
|
+
}
|
|
365
389
|
node.editor.setValue(JSON.stringify(JSON.parse(data),null, 2));
|
|
366
390
|
|
|
367
391
|
});
|
package/src/trexcommands.js
CHANGED
|
@@ -66,7 +66,52 @@ module.exports = function (RED) {
|
|
|
66
66
|
else if(payload.operationMode == "7" ) { // Finish Stoppage
|
|
67
67
|
result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId });
|
|
68
68
|
result.isOk = true;
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
|
+
else if(payload.operationMode == "9" ) { // Login Employee
|
|
71
|
+
if(!payload.EmployeeId){
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId, "EmployeeId": payload.EmployeeId });
|
|
75
|
+
result.isOk = true;
|
|
76
|
+
}
|
|
77
|
+
else if(payload.operationMode == "10" ) { // Logout Employee
|
|
78
|
+
if(!payload.EmployeeId){
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId, "EmployeeId": payload.EmployeeId });
|
|
82
|
+
result.isOk = true;
|
|
83
|
+
}
|
|
84
|
+
else if(payload.operationMode == "13" ) { // Shifted Shift
|
|
85
|
+
if(!payload.LineId){
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId, "LineId": payload.LineId });
|
|
89
|
+
result.isOk = true;
|
|
90
|
+
}
|
|
91
|
+
else if(payload.operationMode == "14" ) { // Start Test Mode
|
|
92
|
+
if(!payload.StoppageCauseId){
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId, "StoppageCauseId": payload.StoppageCauseId });
|
|
96
|
+
result.isOk = true;
|
|
97
|
+
}
|
|
98
|
+
else if(payload.operationMode == "15" ) { // Finish Test Mode
|
|
99
|
+
result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId });
|
|
100
|
+
result.isOk = true;
|
|
101
|
+
}
|
|
102
|
+
else if(payload.operationMode == "16" ) { // Create Deffect
|
|
103
|
+
if(!payload.DefectId){
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
if(!payload.StockId){
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
if(!payload.Quantity){
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId, "DefectId": payload.DefectId, "StockId": payload.StockId, "Quantity": payload.Quantity, "ReferenceQuantityType": 0 });
|
|
113
|
+
result.isOk = true;
|
|
114
|
+
}
|
|
70
115
|
return result;
|
|
71
116
|
}
|
|
72
117
|
|