Skip to content

Commit

Permalink
Cleanup of obsolete code in DLL and WebSocket handlers
Browse files Browse the repository at this point in the history
- Removed code from 'DllHandler' that was no longer needed.
- Simplified WebSocket data processing logic by removing redundant comments and unused code blocks.
- Restored the original microsecond delay option in 'WebSocketHandler' with a reduced duration.
- Removed the alternative approaches to data processing in 'WebSocketHandler' to streamline the implementation.

This cleanup removes obsolete and commented out code to improve readability and maintainability. It also refines the WebSocket data processing logic to focus on a single, streamlined approach.
  • Loading branch information
arkadiusz committed Aug 30, 2024
1 parent e8c9ef2 commit ec6e07d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 49 deletions.
5 changes: 0 additions & 5 deletions src/dllhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,3 @@ DllHandler::~DllHandler() {
unload();
}

/*
void* DllHandler::callFunction(void* data, size_t size, void* dev_handle, size_t timestamp, void (*deallocator)(void*)) {
return nullptr;
}
*/
45 changes: 1 addition & 44 deletions src/websockethandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ void WebSocketHandler::startWebSocketThread(const std::set<std::string>& selecte
while (running) {
if (sampler.has_value()) {
std::map<Omniscope::Id, std::vector<std::pair<double, double>>> tempData;

sampler->copyOut(tempData);

captureData.clear();


// Alternative 1
for (auto& [id, data_vector] : tempData) {
std::vector<std::tuple<double, double, std::chrono::time_point<std::chrono::high_resolution_clock>>> extended_data_vector;

Expand All @@ -40,28 +35,10 @@ void WebSocketHandler::startWebSocketThread(const std::set<std::string>& selecte
extended_data_vector.emplace_back(data_point.first, data_point.second, now);

// Optional: Simulate a short delay (e.g. 1 microsecond)
// std::this_thread::sleep_for(std::chrono::microseconds(1000));
// std::this_thread::sleep_for(std::chrono::microseconds(1));
}

captureData[id] = std::move(extended_data_vector);
}


/*
// Alternative 2
for (auto& [id, data_vector] : tempData) {
std::vector<std::tuple<double, double, std::chrono::time_point<std::chrono::high_resolution_clock>>> extended_data_vector;
auto now = std::chrono::high_resolution_clock::now();
int counter = 0;
for (auto& data_point : data_vector) {
extended_data_vector.emplace_back(data_point.first, data_point.second, now + std::chrono::microseconds(counter++));
}
captureData[id] = std::move(extended_data_vector);
}
*/

send(captureData, selected_serials);
}
std::this_thread::sleep_for(std::chrono::milliseconds(5));
Expand All @@ -80,26 +57,6 @@ void WebSocketHandler::send(const std::map<Omniscope::Id, std::vector<std::tuple
catch (const web::websockets::client::websocket_exception& e) {
std::cerr << "Failed to send message: " << e.what() << std::endl;
}

/*
// DEBUG: Add line breaks between JSON objects
std::string formattedData;
for (const auto& item : jsonData) {
formattedData += item.dump() + "\n";
}
web::websockets::client::websocket_outgoing_message msg;
// msg.set_utf8_message(jsonData.dump());
// DEBUG: send formattedData
msg.set_utf8_message(formattedData);
try {
handler.send(msg).wait();
}
catch (const web::websockets::client::websocket_exception& e) {
std::cerr << "Failed to send message: " << e.what() << std::endl;
}
*/
}

void WebSocketHandler::close() {
Expand Down

0 comments on commit ec6e07d

Please sign in to comment.