@vitormnm/node-red-instructions-ladder-iec-61131-3 1.0.2 → 1.0.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/README.md CHANGED
@@ -1,4 +1,3 @@
1
- # @vitormnm/node-red-instructions-ladder-iec-61131-3
2
1
 
3
2
  A Node-RED node that provides common **IEC 61131-3 Ladder Logic instructions** for building PLC-style logic flows directly inside Node-RED.
4
3
 
@@ -24,7 +24,7 @@
24
24
  RESET: { srcA: false, srcB: false, dest: true, category: 'Coil' }
25
25
  };
26
26
 
27
- RED.nodes.registerType('instructions-ladder-IEC-61131-3', {
27
+ RED.nodes.registerType('instructions-ladder-iec-61131-3', {
28
28
  category: 'function',
29
29
  color: '#C0392B',
30
30
  defaults: {
@@ -91,7 +91,7 @@
91
91
  <!-- ═══════════════════════════════════════════════════════════════════════
92
92
  Edit Dialog
93
93
  ═══════════════════════════════════════════════════════════════════════ -->
94
- <script type="text/html" data-template-name="instructions-ladder-IEC-61131-3">
94
+ <script type="text/html" data-template-name="instructions-ladder-iec-61131-3">
95
95
 
96
96
  <div class="form-row">
97
97
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
@@ -167,7 +167,7 @@
167
167
  <!-- ═══════════════════════════════════════════════════════════════════════
168
168
  Help Panel
169
169
  ═══════════════════════════════════════════════════════════════════════ -->
170
- <script type="text/html" data-help-name="instructions-ladder-IEC-61131-3">
170
+ <script type="text/html" data-help-name="instructions-ladder-iec-61131-3">
171
171
  <p>
172
172
  Simulates <strong>Ladder Logic</strong> instructions from
173
173
  <em>Studio 5000 Logix Designer</em> (Rockwell Automation) inside Node-RED.
@@ -130,13 +130,13 @@ module.exports = function (RED) {
130
130
  // ── Math (two operands) ───────────────────────────────────────────
131
131
  case 'ADD':
132
132
  computed = Number(valA) + Number(valB);
133
- result = true;
133
+ result = computed;
134
134
  resultOperation = true
135
135
  break;
136
136
  case 'SUB':
137
137
  computed = Number(valA) - Number(valB);
138
138
 
139
- result = true;
139
+ result = computed;
140
140
  resultOperation = true
141
141
  break;
142
142
  case 'MUL':
@@ -148,25 +148,33 @@ module.exports = function (RED) {
148
148
  if (Number(valB) === 0) { node.warn('MOD: Division by zero!'); result = false; break; }
149
149
  computed = Number(valA) % Number(valB);
150
150
 
151
- result = true;
151
+ result = computed;
152
152
  resultOperation = true
153
153
  break;
154
154
  case 'DIV':
155
155
  if (Number(valB) === 0) { node.warn('DIV: Division by zero!'); result = false; break; }
156
156
  computed = Number(valA) / Number(valB);
157
157
 
158
- result = true;
158
+ result = computed;
159
159
  resultOperation = true
160
160
  type = "Math"
161
161
  break;
162
162
 
163
163
  // ── Math (one operand) ────────────────────────────────────────────
164
164
  case 'MOV':
165
-
166
- result = true;
165
+ result = valA;
166
+ resultOperation = true
167
+ break;
168
+ case 'ABS':
169
+ computed = Math.abs(Number(valA));
170
+ result = computed;
171
+ resultOperation = true
172
+ break;
173
+ case 'SQR':
174
+ computed = Math.sqrt(Math.abs(Number(valA)));
175
+ result = computed;
176
+ resultOperation = true
167
177
  break;
168
- case 'ABS': computed = Math.abs(Number(valA)); result = true; break;
169
- case 'SQR': computed = Math.sqrt(Math.abs(Number(valA))); result = true; break;
170
178
 
171
179
  // ── Output Coils ──────────────────────────────────────────────────
172
180
  case 'SET':
@@ -174,8 +182,9 @@ module.exports = function (RED) {
174
182
  result = true;
175
183
  break;
176
184
  case 'RESET':
177
- resultOperation = true
178
185
  result = false;
186
+ resultOperation = true
187
+
179
188
  break;
180
189
 
181
190
  default:
@@ -188,7 +197,7 @@ module.exports = function (RED) {
188
197
  }
189
198
 
190
199
  function writeNode(node, msg, config, sendMsg, result, resultOperation) {
191
- console.log(config)
200
+
192
201
  const ladderFunc = config.ladderFunc;
193
202
  const dest = config.dest;
194
203
  const destType = config.destType;
@@ -242,5 +251,5 @@ module.exports = function (RED) {
242
251
  node.on('close', function () { node.status({}); });
243
252
  }
244
253
 
245
- RED.nodes.registerType('instructions-ladder-IEC-61131-3', instructions_ladder_IEC_61131_3);
254
+ RED.nodes.registerType('instructions-ladder-iec-61131-3', instructions_ladder_IEC_61131_3);
246
255
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitormnm/node-red-instructions-ladder-iec-61131-3",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -13,9 +13,9 @@
13
13
  "codesys"
14
14
  ],
15
15
  "node-red": {
16
- "nodes": {
17
16
  "version": ">=2.0.0",
18
- "instructions-ladder-IEC-61131-3": "instructions_ladder_IEC_61131_3.js"
17
+ "nodes": {
18
+ "instructions-ladder-iec-61131-3": "instructions_ladder_IEC_61131_3.js"
19
19
  }
20
20
  },
21
21
  "author": {