@@ -22,13 +22,14 @@ import {
22
22
import { Flow } from "project-editor/flow/flow" ;
23
23
import { FlowTabState } from "project-editor/flow/flow-tab-state" ;
24
24
import { ConnectionLine } from "project-editor/flow/connection-line" ;
25
- import { CatchErrorActionComponent } from "project-editor/flow/components/actions" ;
26
25
import { Component , Widget } from "project-editor/flow/component" ;
27
26
import { IEezObject } from "project-editor/core/object" ;
28
27
import type {
29
28
IComponentState ,
30
29
IDataContext ,
31
- IFlowContext
30
+ IFlowContext ,
31
+ IFlowState ,
32
+ IRuntime
32
33
} from "project-editor/flow/flow-interfaces" ;
33
34
import { Page } from "project-editor/features/page/page" ;
34
35
import {
@@ -88,7 +89,7 @@ export enum StateMachineAction {
88
89
89
90
export type SingleStepMode = "step-into" | "step-over" | "step-out" ;
90
91
91
- export abstract class RuntimeBase {
92
+ export abstract class RuntimeBase implements IRuntime {
92
93
state : State = State . STARTING ;
93
94
isDebuggerActive = false ;
94
95
@@ -375,17 +376,6 @@ export abstract class RuntimeBase {
375
376
}
376
377
}
377
378
378
- removeQueueTasksForFlowState ( flowState : FlowState ) {
379
- runInAction ( ( ) => {
380
- const queueTasksBefore = flowState . runtime . queue . length ;
381
- flowState . runtime . queue = flowState . runtime . queue . filter (
382
- queueTask => queueTask . flowState != flowState
383
- ) ;
384
- const queueTasksAfter = flowState . runtime . queue . length ;
385
- flowState . numActiveComponents -= queueTasksBefore - queueTasksAfter ;
386
- } ) ;
387
- }
388
-
389
379
skipNextQueueTask ( nextQueueTask : QueueTask ) {
390
380
if ( this . state != State . PAUSED ) {
391
381
return false ;
@@ -522,8 +512,6 @@ export abstract class RuntimeBase {
522
512
) ;
523
513
}
524
514
525
- sendResultToWorker ( messageId : number , result : any , finalResult ?: boolean ) { }
526
-
527
515
onBreakpointAdded ( component : Component ) { }
528
516
529
517
onBreakpointRemoved ( component : Component ) { }
@@ -844,7 +832,7 @@ export abstract class RuntimeBase {
844
832
onKeyDown ( e : KeyboardEvent ) { }
845
833
}
846
834
847
- export class FlowState {
835
+ export class FlowState implements IFlowState {
848
836
id = guid ( ) ;
849
837
componentStates = new Map < Component , ComponentState > ( ) ;
850
838
flowStates : FlowState [ ] = [ ] ;
@@ -867,7 +855,6 @@ export class FlowState {
867
855
isFinished : observable ,
868
856
setComponentExecutionState : action ,
869
857
isRunning : computed ,
870
- hasAnyDiposableComponent : computed ,
871
858
finish : action ,
872
859
timelinePosition : observable ,
873
860
setComponentAsyncState : action
@@ -983,50 +970,19 @@ export class FlowState {
983
970
) ;
984
971
}
985
972
986
- get hasAnyDiposableComponent ( ) {
987
- for ( let [ _ , componentState ] of this . componentStates ) {
988
- if ( componentState . dispose ) {
989
- return true ;
990
- }
991
- }
992
- return false ;
993
- }
994
-
995
973
finish ( ) {
996
974
this . runtime . destroyObjectLocalVariables ( this ) ;
997
975
this . flowStates . forEach ( flowState => flowState . finish ( ) ) ;
998
- this . componentStates . forEach ( componentState => componentState . finish ( ) ) ;
999
976
this . runtime . logs . addLogItem ( new ActionEndLogItem ( this ) ) ;
1000
977
this . isFinished = true ;
1001
978
}
1002
979
1003
- findCatchErrorActionComponent ( ) : ComponentState | undefined {
1004
- const catchErrorActionComponent = this . flow . components . find (
1005
- component => component instanceof CatchErrorActionComponent
1006
- ) ;
1007
- if ( catchErrorActionComponent ) {
1008
- return this . getComponentState ( catchErrorActionComponent ) ;
1009
- }
1010
-
1011
- if ( this . parentFlowState ) {
1012
- return this . parentFlowState . findCatchErrorActionComponent ( ) ;
1013
- }
1014
-
1015
- return undefined ;
1016
- }
1017
-
1018
980
log ( type : LogItemType , message : string , component : Component | undefined ) {
1019
981
this . runtime . logs . addLogItem (
1020
982
new LogItem ( type , message , this , component )
1021
983
) ;
1022
984
}
1023
985
1024
- logScpi ( message : string , component : Component ) {
1025
- this . runtime . logs . addLogItem (
1026
- new LogItem ( "scpi" , message , this , component )
1027
- ) ;
1028
- }
1029
-
1030
986
get debugInfo ( ) : any {
1031
987
return {
1032
988
id : this . id ,
@@ -1085,22 +1041,17 @@ export class FlowState {
1085
1041
1086
1042
export class ComponentState implements IComponentState {
1087
1043
inputsData = new Map < string , any > ( ) ;
1088
- unreadInputsData = new Set < string > ( ) ;
1089
1044
isRunning : boolean = false ;
1090
1045
asyncState : boolean = false ;
1091
1046
executionState : any ;
1092
- dispose : ( ( ) => void ) | undefined = undefined ;
1093
1047
1094
1048
constructor ( public flowState : FlowState , public component : Component ) {
1095
1049
makeObservable ( this , {
1096
1050
inputsData : observable ,
1097
- unreadInputsData : observable ,
1098
1051
isRunning : observable ,
1099
1052
asyncState : observable ,
1100
1053
executionState : observable ,
1101
- dispose : observable ,
1102
- setInputData : action ,
1103
- markInputsDataRead : action
1054
+ setInputData : action
1104
1055
} ) ;
1105
1056
}
1106
1057
@@ -1110,42 +1061,6 @@ export class ComponentState implements IComponentState {
1110
1061
1111
1062
setInputData ( input : string , inputData : any ) {
1112
1063
this . inputsData . set ( input , inputData ) ;
1113
- this . unreadInputsData . add ( input ) ;
1114
- }
1115
-
1116
- markInputsDataRead ( ) {
1117
- this . unreadInputsData . clear ( ) ;
1118
- }
1119
-
1120
- get connectedSequenceInputsSet ( ) {
1121
- const inputConnections = new Set < string > ( ) ;
1122
- for ( const connectionLine of this . flowState . flow . connectionLines ) {
1123
- if (
1124
- connectionLine . targetComponent == this . component &&
1125
- this . sequenceInputs . find (
1126
- input => input . name == connectionLine . input
1127
- )
1128
- ) {
1129
- inputConnections . add ( connectionLine . input ) ;
1130
- }
1131
- }
1132
- return inputConnections ;
1133
- }
1134
-
1135
- get sequenceInputs ( ) {
1136
- return this . component . inputs . filter ( input => input . isSequenceInput ) ;
1137
- }
1138
-
1139
- get mandatoryDataInputs ( ) {
1140
- return this . component . inputs . filter (
1141
- input => ! input . isSequenceInput && ! input . isOptionalInput
1142
- ) ;
1143
- }
1144
-
1145
- finish ( ) {
1146
- if ( this . dispose ) {
1147
- this . dispose ( ) ;
1148
- }
1149
1064
}
1150
1065
1151
1066
get debugInfo ( ) {
0 commit comments