Skip to content

Commit cf142bc

Browse files
committed
loop component start and next input
1 parent 1fbdff3 commit cf142bc

22 files changed

+135
-87
lines changed

scripts/DC Power App/DC Power.app

253 Bytes
Binary file not shown.

scripts/DC Power App/DC Power.eez-project

+38-45
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"fullyLoaded": true,
32
"settings": {
43
"general": {
54
"projectVersion": "v3",
@@ -132,9 +131,9 @@
132131
"components": [
133132
{
134133
"type": "StartActionComponent",
135-
"left": -687,
136-
"top": 17,
137-
"width": 78,
134+
"left": -679,
135+
"top": 8,
136+
"width": 89,
138137
"height": 31,
139138
"wireID": "33a7da7a-645d-43cc-a391-4f31636cb85c",
140139
"customInputs": [],
@@ -144,8 +143,8 @@
144143
"type": "SCPIActionComponent",
145144
"left": -245,
146145
"top": -145,
147-
"width": 437,
148-
"height": 87,
146+
"width": 434,
147+
"height": 83,
149148
"wireID": "9a5fc5c4-c7a6-4257-c380-281d79c76fa4",
150149
"customInputs": [],
151150
"customOutputs": [
@@ -160,7 +159,7 @@
160159
"type": "SwitchActionComponent",
161160
"left": -245,
162161
"top": -29,
163-
"width": 610,
162+
"width": 609,
164163
"height": 98,
165164
"wireID": "614718bd-2a71-4db1-b7bd-7a3d34ca9fb9",
166165
"customInputs": [
@@ -183,8 +182,8 @@
183182
},
184183
{
185184
"type": "SetVariableActionComponent",
186-
"left": 409,
187-
"top": 17,
185+
"left": 447,
186+
"top": 132,
188187
"width": 245,
189188
"height": 70,
190189
"wireID": "9de50f96-88d6-4a51-c978-f15cfef2b442",
@@ -197,7 +196,7 @@
197196
"type": "EndActionComponent",
198197
"left": 424,
199198
"top": 243,
200-
"width": 64,
199+
"width": 89,
201200
"height": 31,
202201
"wireID": "6c0d00c0-76b9-41c9-c7f3-86f914ccd122",
203202
"customInputs": [],
@@ -207,8 +206,8 @@
207206
"type": "LoopActionComponent",
208207
"left": -533,
209208
"top": 17,
210-
"width": 197,
211-
"height": 70,
209+
"width": 232,
210+
"height": 83,
212211
"wireID": "71acb5a9-df39-48cb-b0f6-6ce84d5cdaa9",
213212
"customInputs": [],
214213
"customOutputs": [],
@@ -243,12 +242,6 @@
243242
"target": "6c0d00c0-76b9-41c9-c7f3-86f914ccd122",
244243
"input": "@seqin"
245244
},
246-
{
247-
"source": "9de50f96-88d6-4a51-c978-f15cfef2b442",
248-
"output": "@seqout",
249-
"target": "71acb5a9-df39-48cb-b0f6-6ce84d5cdaa9",
250-
"input": "@seqin"
251-
},
252245
{
253246
"source": "71acb5a9-df39-48cb-b0f6-6ce84d5cdaa9",
254247
"output": "done",
@@ -265,7 +258,13 @@
265258
"source": "33a7da7a-645d-43cc-a391-4f31636cb85c",
266259
"output": "@seqout",
267260
"target": "71acb5a9-df39-48cb-b0f6-6ce84d5cdaa9",
268-
"input": "@seqin"
261+
"input": "start"
262+
},
263+
{
264+
"source": "9de50f96-88d6-4a51-c978-f15cfef2b442",
265+
"output": "@seqout",
266+
"target": "71acb5a9-df39-48cb-b0f6-6ce84d5cdaa9",
267+
"input": "next"
269268
}
270269
],
271270
"localVariables": [
@@ -282,9 +281,9 @@
282281
"components": [
283282
{
284283
"type": "SwitchActionComponent",
285-
"left": -95,
284+
"left": -70,
286285
"top": -98,
287-
"width": 324,
286+
"width": 320,
288287
"height": 98,
289288
"wireID": "2ea4bf9b-4718-4dd4-dac6-16d94e9e52cf",
290289
"customInputs": [],
@@ -304,7 +303,7 @@
304303
"type": "SCPIActionComponent",
305304
"left": -232,
306305
"top": 114,
307-
"width": 290,
306+
"width": 288,
308307
"height": 171,
309308
"wireID": "61a121d1-7d28-4ba1-ce14-2c16e4241bfe",
310309
"customInputs": [],
@@ -317,7 +316,7 @@
317316
"type": "StartActionComponent",
318317
"left": -463,
319318
"top": -98,
320-
"width": 78,
319+
"width": 89,
321320
"height": 31,
322321
"wireID": "c8fae56f-f0e1-411a-dc28-98028ba46a40",
323322
"customInputs": [],
@@ -327,7 +326,7 @@
327326
"type": "EndActionComponent",
328327
"left": 411,
329328
"top": 130,
330-
"width": 64,
329+
"width": 89,
331330
"height": 31,
332331
"wireID": "6913dc22-04a7-48a9-819f-2758c0a8f595",
333332
"customInputs": [],
@@ -337,8 +336,8 @@
337336
"type": "LoopActionComponent",
338337
"left": -337,
339338
"top": -98,
340-
"width": 196,
341-
"height": 70,
339+
"width": 232,
340+
"height": 83,
342341
"wireID": "ab1654cb-0106-4b17-e919-7336cedf39fb",
343342
"customInputs": [],
344343
"customOutputs": [],
@@ -362,34 +361,34 @@
362361
"input": "@seqin"
363362
},
364363
{
365-
"source": "c8fae56f-f0e1-411a-dc28-98028ba46a40",
364+
"source": "ab1654cb-0106-4b17-e919-7336cedf39fb",
366365
"output": "@seqout",
367-
"target": "ab1654cb-0106-4b17-e919-7336cedf39fb",
366+
"target": "2ea4bf9b-4718-4dd4-dac6-16d94e9e52cf",
368367
"input": "@seqin"
369368
},
370369
{
371370
"source": "ab1654cb-0106-4b17-e919-7336cedf39fb",
372-
"output": "@seqout",
373-
"target": "2ea4bf9b-4718-4dd4-dac6-16d94e9e52cf",
371+
"output": "done",
372+
"target": "6913dc22-04a7-48a9-819f-2758c0a8f595",
374373
"input": "@seqin"
375374
},
376375
{
377-
"source": "61a121d1-7d28-4ba1-ce14-2c16e4241bfe",
376+
"source": "c8fae56f-f0e1-411a-dc28-98028ba46a40",
378377
"output": "@seqout",
379378
"target": "ab1654cb-0106-4b17-e919-7336cedf39fb",
380-
"input": "@seqin"
379+
"input": "start"
381380
},
382381
{
383-
"source": "ab1654cb-0106-4b17-e919-7336cedf39fb",
384-
"output": "done",
385-
"target": "6913dc22-04a7-48a9-819f-2758c0a8f595",
386-
"input": "@seqin"
382+
"source": "61a121d1-7d28-4ba1-ce14-2c16e4241bfe",
383+
"output": "@seqout",
384+
"target": "ab1654cb-0106-4b17-e919-7336cedf39fb",
385+
"input": "next"
387386
},
388387
{
389388
"source": "61a121d1-7d28-4ba1-ce14-2c16e4241bfe",
390389
"output": "@error",
391390
"target": "ab1654cb-0106-4b17-e919-7336cedf39fb",
392-
"input": "@seqin"
391+
"input": "next"
393392
}
394393
],
395394
"localVariables": [
@@ -1059,8 +1058,8 @@
10591058
},
10601059
{
10611060
"type": "SCPIActionComponent",
1062-
"left": 404,
1063-
"top": 464,
1061+
"left": 408,
1062+
"top": 466,
10641063
"width": 241,
10651064
"height": 63,
10661065
"wireID": "5693c38e-f63f-4110-87b3-1f4bb6f1330c",
@@ -1608,12 +1607,6 @@
16081607
"target": "7e96a386-870e-448d-ce3f-6f887af57a7e",
16091608
"input": "@seqin"
16101609
},
1611-
{
1612-
"source": "e3c1ef21-075d-49fc-aa3b-84e346e23490",
1613-
"output": "action",
1614-
"target": "dc8ff753-e716-4a75-b0da-9c49864521f4",
1615-
"input": "@seqin"
1616-
},
16171610
{
16181611
"source": "7e882d1c-c85b-4b72-835b-c51d82dcaa8a",
16191612
"output": "action",

src/eez/flow/components.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void executeComponent(FlowState *flowState, unsigned componentIndex) {
6767
executeSwitchComponent(flowState, componentIndex);
6868
} else if (component->type == defs_v3::COMPONENT_TYPE_LOG_ACTION) {
6969
executeLogComponent(flowState, componentIndex);
70-
} else if (component->type == defs_v3::COMPONENT_TYPE_SCPI_ACTION) {
70+
} else if (component->type == defs_v3::COMPONENT_TYPE_SCPIACTION) {
7171
executeScpiComponent(flowState, componentIndex);
7272
} else if (component->type == defs_v3::COMPONENT_TYPE_CALL_ACTION_ACTION) {
7373
executeCallActionComponent(flowState, componentIndex);

src/eez/flow/components/call_action.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void executeCallActionComponent(FlowState *flowState, unsigned componentIndex) {
5555

5656
if (actionFlowState->numActiveComponents == 0) {
5757
freeFlowState(actionFlowState);
58-
propagateValue(flowState, componentIndex);
58+
propagateValueThroughSeqout(flowState, componentIndex);
5959
} else {
6060
flowState->numActiveComponents++;
6161

src/eez/flow/components/constant.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void executeConstantComponent(FlowState *flowState, unsigned componentIndex) {
3535

3636
propagateValue(flowState, componentIndex, 1, sourceValue);
3737

38-
propagateValue(flowState, componentIndex);
38+
propagateValueThroughSeqout(flowState, componentIndex);
3939
}
4040

4141
} // namespace flow

src/eez/flow/components/delay.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void executeDelayComponent(FlowState *flowState, unsigned componentIndex) {
6767
if (millis() >= delayComponentExecutionState->waitUntil) {
6868
ObjectAllocator<DelayComponenentExecutionState>::deallocate(delayComponentExecutionState);
6969
flowState->componenentExecutionStates[componentIndex] = nullptr;
70-
propagateValue(flowState, componentIndex);
70+
propagateValueThroughSeqout(flowState, componentIndex);
7171
} else {
7272
if (!addToQueue(flowState, componentIndex)) {
7373
throwError(flowState, componentIndex, "Execution queue is full\n");

src/eez/flow/components/end.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace flow {
2828
void executeEndComponent(FlowState *flowState, unsigned componentIndex) {
2929
if (flowState->parentFlowState && flowState->isAction) {
3030
flowState->parentFlowState->numActiveComponents--;
31-
propagateValue(flowState->parentFlowState, flowState->parentComponentIndex);
31+
propagateValueThroughSeqout(flowState->parentFlowState, flowState->parentComponentIndex);
3232
} else {
3333
scripting::stopScript();
3434
}

src/eez/flow/components/input.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void executeInputComponent(FlowState *flowState, unsigned componentIndex) {
5555
auto flowInputIndex = parentComponentInputs[parentComponentInputIndex];
5656

5757
auto parentFlow = flowState->flowDefinition->flows.item(assets, flowState->parentFlowState->flowIndex);
58-
if (flowInputIndex >= parentFlow->nInputValues) {
58+
if (flowInputIndex >= parentFlow->componentInputs.count) {
5959
throwError(flowState, componentIndex, "Input action component, invalid input index of parent component\n");
6060
return;
6161
}

src/eez/flow/components/log.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void executeLogComponent(FlowState *flowState, unsigned componentIndex) {
4545
logInfo(flowState, componentIndex, valueStr);
4646
}
4747

48-
propagateValue(flowState, componentIndex);
48+
propagateValueThroughSeqout(flowState, componentIndex);
4949
}
5050

5151
} // namespace flow

src/eez/flow/components/loop.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ void executeLoopComponent(FlowState *flowState, unsigned componentIndex) {
4242

4343
auto loopComponentExecutionState = (LoopComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex];
4444

45+
// restart loop if entered through "start" input
46+
static const unsigned START_INPUT_INDEX = 0;
47+
auto startInputIndex = component->inputs.ptr(assets)[START_INPUT_INDEX];
48+
if (flowState->values[startInputIndex].type != VALUE_TYPE_UNDEFINED) {
49+
if (loopComponentExecutionState) {
50+
ObjectAllocator<LoopComponenentExecutionState>::deallocate(loopComponentExecutionState);
51+
loopComponentExecutionState = nullptr;
52+
}
53+
}
54+
4555
if (!loopComponentExecutionState) {
4656
Value dstValue;
4757
if (!evalAssignableExpression(flowState, componentIndex, component->assignableExpressionEvalInstructions, dstValue)) {
@@ -78,7 +88,7 @@ void executeLoopComponent(FlowState *flowState, unsigned componentIndex) {
7888
loopComponentExecutionState->stepValue = stepValue;
7989
flowState->componenentExecutionStates[componentIndex] = loopComponentExecutionState;
8090

81-
propagateValue(flowState, componentIndex);
91+
propagateValueThroughSeqout(flowState, componentIndex);
8292
} else {
8393
auto value = op_add(loopComponentExecutionState->dstValue, loopComponentExecutionState->stepValue);
8494
if (op_great_eq(value, loopComponentExecutionState->toValue).toBool()) {
@@ -88,7 +98,7 @@ void executeLoopComponent(FlowState *flowState, unsigned componentIndex) {
8898
propagateValue(flowState, componentIndex, 1);
8999
} else {
90100
assignValue(flowState, componentIndex, loopComponentExecutionState->dstValue, value);
91-
propagateValue(flowState, componentIndex);
101+
propagateValueThroughSeqout(flowState, componentIndex);
92102
}
93103
}
94104
}

src/eez/flow/components/output.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void executeOutputComponent(FlowState *flowState, unsigned componentIndex) {
4242
}
4343

4444
auto inputIndex = component->inputs.ptr(assets)[0];
45-
if (inputIndex >= flowState->flow->nInputValues) {
45+
if (inputIndex >= flowState->flow->componentInputs.count) {
4646
throwError(flowState, componentIndex, "Output action component, invalid input index\n");
4747
return;
4848
}

src/eez/flow/components/scpi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void executeScpiComponent(FlowState *flowState, unsigned componentIndex) {
236236
ObjectAllocator<ScpiComponentExecutionState>::deallocate(scpiComponentExecutionState);
237237
flowState->componenentExecutionStates[componentIndex] = nullptr;
238238

239-
propagateValue(flowState, componentIndex);
239+
propagateValueThroughSeqout(flowState, componentIndex);
240240
return;
241241
}
242242

src/eez/flow/components/set_variable.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void executeSetVariableComponent(FlowState *flowState, unsigned componentIndex)
4848

4949
assignValue(flowState, componentIndex, dstValue, srcValue);
5050

51-
propagateValue(flowState, componentIndex);
51+
propagateValueThroughSeqout(flowState, componentIndex);
5252
}
5353

5454
} // namespace flow

src/eez/flow/components/start.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace eez {
2424
namespace flow {
2525

2626
void executeStartComponent(FlowState *flowState, unsigned componentIndex) {
27-
propagateValue(flowState, componentIndex);
27+
propagateValueThroughSeqout(flowState, componentIndex);
2828
}
2929

3030
} // namespace flow

src/eez/flow/components/switch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void executeSwitchComponent(FlowState *flowState, unsigned componentIndex) {
5353
}
5454
}
5555

56-
propagateValue(flowState, componentIndex);
56+
propagateValueThroughSeqout(flowState, componentIndex);
5757
}
5858

5959
} // namespace flow

src/eez/flow/debugger.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ void onFlowStateCreated(FlowState *flowState) {
439439
auto flow = flowState->flow;
440440

441441
for (uint32_t i = 0; i < flow->localVariables.count; i++) {
442-
auto pValue = &flowState->values[flow->nInputValues + i];
442+
auto pValue = &flowState->values[flow->componentInputs.count + i];
443443

444444
char buffer[100];
445445
snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\t",
@@ -453,7 +453,7 @@ void onFlowStateCreated(FlowState *flowState) {
453453
writeValue(*pValue);
454454
}
455455

456-
for (uint32_t i = 0; i < flow->nInputValues; i++) {
456+
for (uint32_t i = 0; i < flow->componentInputs.count; i++) {
457457
auto pValue = &flowState->values[i];
458458

459459
char buffer[100];

src/eez/flow/expression.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bool evalExpression(FlowState *flowState, int componentIndex, const uint8_t *ins
4343
return false;
4444
}
4545
} else if (instructionType == EXPR_EVAL_INSTRUCTION_TYPE_PUSH_LOCAL_VAR) {
46-
if (!stack.push(&flowState->values[flow->nInputValues + instructionArg])) {
46+
if (!stack.push(&flowState->values[flow->componentInputs.count + instructionArg])) {
4747
return false;
4848
}
4949
} else if (instructionType == EXPR_EVAL_INSTRUCTION_TYPE_PUSH_GLOBAL_VAR) {

0 commit comments

Comments
 (0)