Skip to content

Commit

Permalink
repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenyhraz committed Jun 5, 2024
1 parent 65808f8 commit 814f574
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/Gui/Windows/MicroserviceEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ void MicroserviceEditorWindow::Render()
if (ImGui::Button("Run"))
LaunchAsync([&]() { Run(); });
ImGui::SameLine();
if (ImGui::Button("Run repeat"))
LaunchAsync([&]() { RunRepeat(); });
ImGui::SameLine();
if (ImGui::Button("Show flow"))
editor.ShowFlow();

Expand All @@ -36,6 +39,16 @@ void MicroserviceEditorWindow::Run()
LOG_SUCCESS("Workflow run completed");
}

void MicroserviceEditorWindow::RunRepeat()
{
for (int i = 0; i < 5; ++i)
{
Plot::Clear();
editor.workflow.Run();
}
LOG_SUCCESS("Workflow run completed");
}

void MicroserviceEditorWindow::TestInitialize()
{
editor.workflow.AddMicroservice<LoadImageMicroservice>();
Expand Down
1 change: 1 addition & 0 deletions src/Gui/Windows/MicroserviceEditorWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class MicroserviceEditorWindow : public Window
void TestInitialize();
void ShowFlow();
void Run();
void RunRepeat();

MicroserviceEditor editor;

Expand Down
7 changes: 2 additions & 5 deletions src/Microservice/Microservice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class Microservice

uintptr_t GetId() const { return reinterpret_cast<uintptr_t>(this); }
const std::string& GetName() const { return name; }
void Reset() { value = nullptr; }
};

struct OutputParameter
Expand Down Expand Up @@ -282,11 +281,9 @@ class Microservice
param.value = value;
}

void Reset() // call this on repeated workflows
void Reset()
{
for (auto& [name, param] : inputParameters)
param.Reset();

// call this on repeated workflows to recompute output parameters
for (auto& [name, param] : outputParameters)
param.Reset();
}
Expand Down
4 changes: 3 additions & 1 deletion src/Microservice/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
- [x] add strongly-typed UserParameters (manual params) and a way to edit them
- [ ] workflow save to / load from file - json
- [ ] derive more specific classes from Microservice for control flow - not all microservices have start / completed, e.g. plot / start
- [ ] repeated workflows - reset? / remove .has_value condition
- [ ] repeated workflows - reset / remove .has_value condition
- [ ] tracy profile
- [ ] simple workflow type - just follow output connections

# GUI
- [ ] gui layout save? - json
Expand Down
7 changes: 7 additions & 0 deletions src/Microservice/Workflow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,19 @@ class Workflow
return LOG_WARNING("Workflow '{}' does not contain any microservices", GetName());

ExecuteMicroservice(*microservices.front());
Reset();
}
catch (const std::exception& e)
{
LOG_ERROR("Workflow '{}' error: {}", GetName(), e.what());
}

void Reset()
{
for (auto& microservice : microservices)
microservice->Reset();
}

void Connect(Microservice::Connection&& connection)
{
if (not connection.outputMicroservice or not connection.inputMicroservice or not connection.outputParameter or not connection.inputParameter)
Expand Down

0 comments on commit 814f574

Please sign in to comment.