node-red-trexmes-commands 0.0.1 → 1.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-trexmes-commands",
3
- "version": "0.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "A node-red node to execute commands for Trex Mes Systems",
5
5
  "main": "trexcommands.js",
6
6
  "dependencies": {
@@ -20,9 +20,9 @@
20
20
  "node-red",
21
21
  "trex-mes",
22
22
  "trex",
23
- "mes"
23
+ "mes"
24
24
  ],
25
- "author": "asafyurdakul",
25
+ "author": "asafyurdakul",
26
26
  "license": "GPL-3.0-or-later",
27
27
  "engines": {
28
28
  "node": ">=16"
@@ -333,24 +333,35 @@
333
333
  const modeField = $('#node-input-modeOpt').typedInput({
334
334
  types: [
335
335
  { value: '1|Load Job Plan', label: 'Load Job Plan', hasValue: false },
336
- { value: '2|Change Job Plan', label: 'Change Job Plan', hasValue: false },
337
- { value: '3|Save Production', label: 'Save Production', hasValue: false }
336
+ { value: '4|Finish Production', label: 'Finish Production', hasValue: false },
337
+ { value: '5|Start Stoppage', label: 'Start Stoppage', hasValue: false },
338
+ { value: '6|Change Stoppage', label: 'Change Stoppage', hasValue: false },
339
+ { value: '7|Finish Stoppage', label: 'Finish Stoppage', hasValue: false }
338
340
  ],
339
341
  typeField: $('#node-input-modeOptType'),
340
342
  default: 'Load Job Plan'
341
343
  });
342
344
 
343
- //show/hide rows field depending on query type
345
+ //show expected data sample
344
346
  modeField.on('change', function() {
345
347
  const operationMode = $(this).typedInput('type');
346
348
 
347
349
  let data = '{}';
348
- if(operationMode.startsWith('1|')) {
350
+ if(operationMode.startsWith('1|')) { // Load Job Plan
349
351
  data = '{ "WorkstationId": 10 , "PlanId": 123 }';
350
352
  }
351
- else if(operationMode.startsWith('2|')) {
352
- data = '{"deneme": "123"}';
353
+ else if(operationMode.startsWith('4|')) { //Finish Production
354
+ data = '{ "WorkstationId": 10 }';
353
355
  }
356
+ else if(operationMode.startsWith('5|')) { //Start Stoppage
357
+ data = '{ "WorkstationId": 10 , "StoppageCauseId": 11 }';
358
+ }
359
+ else if(operationMode.startsWith('6|')) { //Change Stoppage
360
+ data = '{ "WorkstationId": 10 , "StoppageCauseId": 11 }';
361
+ }
362
+ else if(operationMode.startsWith('7|')) { //Finish Stoppage
363
+ data = '{ "WorkstationId": 10 }';
364
+ }
354
365
  node.editor.setValue(JSON.stringify(JSON.parse(data),null, 2));
355
366
 
356
367
  });
@@ -45,13 +45,28 @@ module.exports = function (RED) {
45
45
  result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId, "PlanId": payload.PlanId });
46
46
  result.isOk = true;
47
47
  }
48
- else if(payload.operationMode == "2" ) { // Change Job Plan
49
-
48
+ else if(payload.operationMode == "4" ) { // Finish Production
49
+ result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId, "Quantity": 0, "ReferenceQuantityType": 0, "IsQuantityApproved": false });
50
+ result.isOk = true;
50
51
  }
51
- else if(payload.operationMode == "3" ) { // Save Production
52
-
52
+ else if(payload.operationMode == "5" ) { // Start Stoppage
53
+ if(!payload.StoppageCauseId){
54
+ return result;
55
+ }
56
+ result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId, "StoppageCauseId": payload.StoppageCauseId });
57
+ result.isOk = true;
53
58
  }
54
-
59
+ else if(payload.operationMode == "6" ) { // Change Stoppage
60
+ if(!payload.StoppageCauseId){
61
+ return result;
62
+ }
63
+ result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId, "StoppageCauseId": payload.StoppageCauseId });
64
+ result.isOk = true;
65
+ }
66
+ else if(payload.operationMode == "7" ) { // Finish Stoppage
67
+ result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId });
68
+ result.isOk = true;
69
+ }
55
70
  return result;
56
71
  }
57
72
 
@@ -372,7 +387,7 @@ module.exports = function (RED) {
372
387
  }
373
388
  //Process onay bekleniyor
374
389
  setTimeout(function () {
375
- query = "select COMMANDID,ISPROCESSED from NGPCOMMANDQUEUE where COMMANDID=" + commandId;
390
+ query = "select Q.COMMANDID,Q.ISPROCESSED,P.ISSUCCESS,P.MESSAGE from NGPCOMMANDQUEUE Q join NGPCOMMANDRESPONSE P on Q.COMMANDID = P.COMMANDID where P.COMMANDID=" + commandId;
376
391
  //node.log(query);
377
392
  trexmesCN.execSql("", query, [], {}, function (err, data, info) {
378
393
  if (err) {
@@ -380,23 +395,34 @@ module.exports = function (RED) {
380
395
  } else {
381
396
  setResult(msg, node.outField, data, node.returnType);
382
397
  let isProcessed = 0;
398
+ let isSuccess = 0;
399
+ let message = "";
383
400
  if(msg.payload.length>0) {
384
401
  isProcessed = msg.payload[0].ISPROCESSED;
402
+ isSuccess = msg.payload[0].ISSUCCESS;
403
+ message = msg.payload[0].MESSAGE;
385
404
  }
386
405
  node.send(msg);
387
- if(isProcessed == 1) {
406
+ if( isProcessed == 1 && isSuccess == 1) {
388
407
  node.status({
389
408
  fill: 'green',
390
409
  shape: 'dot',
391
410
  text: 'done'
392
411
  });
393
412
  }
413
+ else if( isProcessed == 1 && isSuccess == 0) {
414
+ node.status({
415
+ fill: 'yellow',
416
+ shape: 'dot',
417
+ text: 'done with error: ' + message
418
+ });
419
+ }
394
420
  else {
395
421
  node.status({
396
- fill: 'orange',
422
+ fill: 'blue',
397
423
  shape: 'dot',
398
424
  text: 'command not processed in 2 sec.'
399
- });
425
+ });
400
426
  }
401
427
  }
402
428
  });