@vitormnm/node-red-instructions-ladder-iec-61131-3 1.0.2 → 1.0.3
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 +0 -1
- package/instructions_ladder_IEC_61131_3.js +20 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
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,11 +197,11 @@ module.exports = function (RED) {
|
|
|
188
197
|
}
|
|
189
198
|
|
|
190
199
|
function writeNode(node, msg, config, sendMsg, result, resultOperation) {
|
|
191
|
-
|
|
200
|
+
|
|
192
201
|
const ladderFunc = config.ladderFunc;
|
|
193
202
|
const dest = config.dest;
|
|
194
203
|
const destType = config.destType;
|
|
195
|
-
|
|
204
|
+
|
|
196
205
|
switch (destType) {
|
|
197
206
|
case 'msg':
|
|
198
207
|
if (resultOperation) {
|