import React from "react";
import { observer } from "mobx-react";
import { ITreeNode, Tree } from "eez-studio-ui/tree";
import { Panel } from "project-editor/ui-components/Panel";
import { action, computed, makeObservable } from "mobx";
import { QueueTask, RuntimeBase } from "project-editor/flow/runtime/runtime";
import { IconAction } from "eez-studio-ui/action";
import { DebugInfoRuntime } from "project-editor/flow//runtime/debug-info-runtime";
import { getQueueTaskLabel } from "project-editor/flow/debugger/logs";
////////////////////////////////////////////////////////////////////////////////
export const QueuePanel = observer(
class QueuePanel extends React.Component<{
runtime: RuntimeBase;
}> {
render() {
const memTotal = this.props.runtime.totalMemory;
const memAlloc = memTotal - this.props.runtime.freeMemory;
return (
}
iconSize={16}
title="Resume (F5)"
onClick={() =>
this.props.runtime.resume()
}
enabled={
!this.props.runtime.isStopped &&
this.props.runtime.isPaused
}
/>,
}
iconSize={16}
title="Pause (F6)"
onClick={() =>
this.props.runtime.pause()
}
enabled={
!this.props.runtime.isStopped &&
!this.props.runtime.isPaused
}
/>,
}
iconSize={18}
style={{ marginTop: 4 }}
title="Step over (F10)"
onClick={() => {
this.props.runtime.runSingleStep(
"step-over"
);
}}
enabled={
!this.props.runtime.isStopped &&
this.props.runtime.isPaused &&
this.props.runtime.queue.length >
0
}
/>,
}
iconSize={18}
style={{ marginTop: 4 }}
title="Step into (F11)"
onClick={() => {
this.props.runtime.runSingleStep(
"step-into"
);
}}
enabled={
!this.props.runtime.isStopped &&
this.props.runtime.isPaused &&
this.props.runtime.queue.length >
0
}
/>,
}
iconSize={18}
style={{ marginTop: 4 }}
title="Step out (Shift + F11)"
onClick={() => {
this.props.runtime.runSingleStep(
"step-out"
);
}}
enabled={
!this.props.runtime.isStopped &&
this.props.runtime.isPaused &&
this.props.runtime.queue.length >
0
}
/>
]
}
body={}
/>
);
}
}
);
const QueueList = observer(
class QueueList extends React.Component<{ runtime: RuntimeBase }> {
constructor(props: { runtime: RuntimeBase }) {
super(props);
makeObservable(this, {
rootNode: computed,
selectNode: action.bound
});
}
get rootNode(): ITreeNode {
function getChildren(
queueTasks: QueueTask[]
): ITreeNode[] {
return queueTasks.map(queueTask => ({
id: queueTask.id.toString(),
label: {getQueueTaskLabel(queueTask)}
,
children: [],
selected: queueTask == selectedQueueTask,
expanded: false,
data: queueTask
}));
}
const selectedQueueTask = this.props.runtime.selectedQueueTask;
return {
id: "root",
label: "",
children: getChildren(this.props.runtime.queue),
selected: false,
expanded: true
};
}
selectNode(node?: ITreeNode) {
const queueTask = node && node.data;
if (queueTask) {
this.props.runtime.selectQueueTask(queueTask);
}
}
render() {
return (
);
}
}
);