Skip to content

Commit

Permalink
feature: working on recorder implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
klonyyy committed Dec 8, 2024
1 parent 0aac87a commit 57e355e
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ target_include_directories(${EXECUTABLE} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/PlotGroupHandler
${CMAKE_CURRENT_SOURCE_DIR}/src/CSVStreamer
${CMAKE_CURRENT_SOURCE_DIR}/src/VariableHandler
${CMAKE_CURRENT_SOURCE_DIR}/src/DataHandler)
${CMAKE_CURRENT_SOURCE_DIR}/src/DataHandler
${CMAKE_CURRENT_SOURCE_DIR}/src/Recorder)

target_include_directories(${EXECUTABLE} SYSTEM PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/third_party/stlink/inc/
Expand Down
6 changes: 5 additions & 1 deletion src/DataHandler/ViewerDataHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
#include <string>

#include "JlinkDebugProbe.hpp"
#include "Recorder.hpp"
#include "StlinkDebugProbe.hpp"

ViewerDataHandler::ViewerDataHandler(PlotGroupHandler* plotGroupHandler, VariableHandler* variableHandler, PlotHandler* plotHandler, PlotHandler* tracePlotHandler, std::atomic<bool>& done, std::mutex* mtx, spdlog::logger* logger) : DataHandlerBase(plotGroupHandler, variableHandler, plotHandler, tracePlotHandler, done, mtx, logger)
{
dataHandle = std::thread(&ViewerDataHandler::dataHandler, this);
recorder = std::make_shared<Recorder>(variableHandler);
}
ViewerDataHandler::~ViewerDataHandler()
{
Expand Down Expand Up @@ -219,13 +221,15 @@ void ViewerDataHandler::createSampleList()
}
}

/* mark actively sampled varaibles */
/* mark actively sampled variables */
for (auto variable : *variableHandler)
{
variable->setIsCurrentlySampled(false);
if (std::find(sampleList.begin(), sampleList.end(), std::pair<uint32_t, uint8_t>(variable->getAddress(), variable->getSize())) != sampleList.end())
variable->setIsCurrentlySampled(true);
}

recorder->init();
}

void ViewerDataHandler::prepareCSVFile()
Expand Down
3 changes: 3 additions & 0 deletions src/DataHandler/ViewerDataHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "IDebugProbe.hpp"
#include "MovingAverage.hpp"
#include "VariableHandler.hpp"
#include "Recorder.hpp"

class ViewerDataHandler : public DataHandlerBase
{
Expand Down Expand Up @@ -68,5 +69,7 @@ class ViewerDataHandler : public DataHandlerBase
Settings settings{};
std::unordered_map<std::string, double> csvEntry;

std::shared_ptr<Recorder> recorder;

SampleListType sampleList;
};
18 changes: 17 additions & 1 deletion src/Gui/GuiGroupEdit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,26 @@ class GroupEditWindow
std::string oldName = editedGroup->getName();
plotGroupHandler->renameGroup(oldName, name);
}

else
popup.show("Error!", "Group already exists!", 1.5f);
}

PlotGroup::Type groupType = editedGroup->getType();

GuiHelper::drawTextAlignedToSize("type:", alignment);
ImGui::SameLine();
ImGui::RadioButton("sampling", (int32_t*)(&groupType), 0);
ImGui::SameLine();
ImGui::RadioButton("recorder", (int32_t*)(&groupType), 1);
ImGui::SameLine();
ImGui::HelpMarker("A sampling group is sampled asynchonously in regular intervals without additional software on target's side. \r\n A recorder group is a group used for registering high frequency signals with predefined intervals. Recorder file and sampling function execution is needed for proper operation.");

if (groupType == PlotGroup::Type::RECORDER)
{
ImGui::Text("Recorder");
}

editedGroup->setType(groupType);
}

private:
Expand Down
19 changes: 19 additions & 0 deletions src/PlotGroupHandler/PlotGroupHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class PlotGroup
std::shared_ptr<Plot> plot;
};

typedef enum
{
SAMPLING = 0,
RECORDER = 1
} Type;

PlotGroup(const std::string& name) : name(name)
{
}
Expand Down Expand Up @@ -76,9 +82,22 @@ class PlotGroup
{ return pair.second.visibility; });
}

Type getType() const
{
return type;
}

void setType(Type type)
{
this->type = type;
}

private:
std::string name;
std::map<std::string, PlotEntry> group;

Type type = Type::SAMPLING;

};

class PlotGroupHandler
Expand Down
38 changes: 38 additions & 0 deletions src/Recorder/Recorder.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

#include "Variable.hpp"

class Recorder
{
typedef struct Settings
{
const std::string state;
const std::string timestepUs;
const std::string maxBufferSize;
} Settings;

public:
Recorder(VariableHandler* variableHandler) : variableHandler(variableHandler)
{
}

void init()
{
variableHandler->addVariable(std::make_shared<Variable>(settings.state));
variableHandler->addVariable(std::make_shared<Variable>(settings.timestepUs));
variableHandler->addVariable(std::make_shared<Variable>(settings.maxBufferSize));
}

void perform()
{
}

private:
Settings settings{
.state{"____recorder.state"},
.timestepUs{"____recorder.timestepUs"},
.maxBufferSize{"____recorder.maxBufferSize"},
};

VariableHandler* variableHandler;
};

0 comments on commit 57e355e

Please sign in to comment.