diff --git a/CMakeLists.txt b/CMakeLists.txt
index b1d31c1..a22e74d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,11 +1,6 @@
cmake_minimum_required(VERSION 3.22)
project(graph)
-include(CMakePrintHelpers)
-
-set(CMAKE_C_COMPILER clang)
-set(CMAKE_CXX_COMPILER clang++)
-
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user
deleted file mode 100644
index cc3a60c..0000000
--- a/CMakeLists.txt.user
+++ /dev/null
@@ -1,197 +0,0 @@
-
-
-
-
-
- EnvironmentId
- {4f657d63-be8b-425f-9d8c-4dd5085ebe29}
-
-
- ProjectExplorer.Project.ActiveTarget
- 0
-
-
- ProjectExplorer.Project.EditorSettings
-
- true
- false
- true
-
- Cpp
-
- CppGlobal
-
-
-
- QmlJS
-
- QmlJSGlobal
-
-
- 2
- UTF-8
- false
- 4
- false
- 80
- true
- true
- 1
- false
- true
- false
- 0
- true
- true
- 0
- 8
- true
- false
- 1
- true
- true
- true
- *.md, *.MD, Makefile
- false
- true
- true
-
-
-
- ProjectExplorer.Project.PluginSettings
-
-
- true
- false
- true
- true
- true
- true
-
-
- 0
- true
-
- true
- true
- Builtin.DefaultTidyAndClazy
- 6
-
-
-
- true
-
-
-
-
- ProjectExplorer.Project.Target.0
-
- Desktop
- Desktop
- Desktop
- {23592716-1d94-4067-93fe-e6827d70d9cc}
- 0
- 0
- 0
-
- Build
- false
-
- -DCMAKE_GENERATOR:STRING=Unix Makefiles
--DCMAKE_BUILD_TYPE:STRING=Build
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
- /home/laci/prog/graph
- /home/laci/prog/graph/build
-
-
-
-
- all
-
- false
-
- true
- Build
- CMakeProjectManager.MakeStep
-
- 1
- Build
- Build
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- Build
- CMakeProjectManager.MakeStep
-
- 1
- Clean
- Clean
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Build
- CMakeProjectManager.CMakeBuildConfiguration
-
- 1
-
-
- 0
- Deploy
- Deploy
- ProjectExplorer.BuildSteps.Deploy
-
- 1
-
- false
- ProjectExplorer.DefaultDeployConfiguration
-
- 1
-
- true
- true
- true
-
- 2
-
- server
- CMakeProjectManager.CMakeRunConfiguration.server
- server
- false
- true
- true
- false
- true
- /home/laci/prog/graph/build
-
- 1
-
-
-
- ProjectExplorer.Project.TargetCount
- 1
-
-
- ProjectExplorer.Project.Updater.FileVersion
- 22
-
-
- Version
- 22
-
-
diff --git a/src/graph/plugins/http/CMakeLists.txt b/src/graph/plugins/http/CMakeLists.txt
index ab4ce36..6b88d2a 100644
--- a/src/graph/plugins/http/CMakeLists.txt
+++ b/src/graph/plugins/http/CMakeLists.txt
@@ -2,6 +2,5 @@ find_package(nlohmann_json 3 REQUIRED)
file(GLOB_RECURSE HTTP_SOURCES "./*.cpp")
add_library(http SHARED ${HTTP_SOURCES})
-target_link_libraries(http librum.a nlohmann_json::nlohmann_json)
-# target_link_libraries(http librum.a libflags-cpp.so)
+target_link_libraries(http librum.a libflags-cpp.a nlohmann_json::nlohmann_json)
set_target_properties(http PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins")
\ No newline at end of file
diff --git a/src/graph/plugins/http/http.cpp b/src/graph/plugins/http/http.cpp
index 99c80fd..2389d99 100644
--- a/src/graph/plugins/http/http.cpp
+++ b/src/graph/plugins/http/http.cpp
@@ -1,10 +1,10 @@
+#include
#include
#include
#include
#include
#include
#include
-// #include
#include
#include
#include
@@ -13,27 +13,26 @@
using namespace Rum::HTTP;
using json = nlohmann::json;
-// using namespace Flags;
+using namespace Flags;
Server* server;
extern "C" {
-plugin_t plugin = {.version = 1, .run_method = &run, .destroy_method = &destroy};
+plugin_t plugin = {.version = 1, .run_method = &run, .destroy_method = &destroy, .update_callback = nullptr, .argc = 0, .argv = nullptr};
int run() {
- // Parser parser;
- // int* port = parser.add("port", "http port", false, 8080);
- // int* workers = parser.add("workers", "number of worker threads", false, 10);
-
- // bool* help = parser.add("help", "print help", false, false);
-
- // if (!parser.parse(plugin.argc, plugin.argv) || *help) {
- // parser.help();
- // }
-
- // server = new Server(*port, *workers, DEFAULT_BUFFER_SIZE);
try {
- server = new Server(8080, 10, DEFAULT_BUFFER_SIZE);
+ Parser parser;
+ int* port = parser.add("port", "http port", false, 8080);
+ int* workers = parser.add("workers", "number of worker threads", false, 10);
+
+ bool* help = parser.add("help", "print help", false, false);
+
+ if (!parser.parse(plugin.argc, plugin.argv) || *help) {
+ parser.help();
+ }
+
+ server = new Server(*port, *workers, DEFAULT_BUFFER_SIZE);
server->add_path("/add", [](const Request& req, Response& resp) {
URI uri = req.copy_uri();
@@ -77,7 +76,7 @@ int run() {
}
plugin.update_callback(data["chart"].template get(), data["series"].template get().c_str(), points.data(), points.size());
- } catch (nlohmann::detail::parse_error e) {
+ } catch (nlohmann::detail::parse_error& e) {
std::cerr << e.what() << std::endl;
}
});
@@ -86,7 +85,7 @@ int run() {
server->listen();
return 0;
- } catch (Rum::TCP::Error e) {
+ } catch (Rum::TCP::Error& e) {
std::cerr << e.what() << std::endl;
delete server;
return 1;
diff --git a/src/graph/server/gui/mainwindow.cpp b/src/graph/server/gui/mainwindow.cpp
index bde399c..ea96c66 100644
--- a/src/graph/server/gui/mainwindow.cpp
+++ b/src/graph/server/gui/mainwindow.cpp
@@ -41,7 +41,7 @@ void addData(unsigned int chartIndex, const char* seriesName, const point_t* poi
}
void MainWindow::addData(unsigned int chartIndex, const char* seriesName, const point_t* points, int count) {
- if (chartIndex < 0 || chartIndex >= charts.size())
+ if (chartIndex >= charts.size())
return;
QString name(seriesName);
@@ -169,7 +169,7 @@ void MainWindow::on_action_Load_triggered() {
});
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
thread->start();
- } catch (std::runtime_error e) {
+ } catch (std::runtime_error& e) {
std::cout << e.what() << std::endl;
QMessageBox::critical(this, "Error", "Failed to load plugin!\n" + file, QMessageBox::StandardButton::Ignore);
}
diff --git a/test/test.py b/test/test.py
index 59cfdee..f171350 100755
--- a/test/test.py
+++ b/test/test.py
@@ -14,17 +14,21 @@ def sine():
sleep(0.01)
def sine_array():
- x = np.linspace(0, 2*np.pi, 1)
- y = np.sin(x)
+ start = 0
+ while True:
+ x = np.linspace(start, start+0.5, 100)
+ y = np.sin(x)
- data = {
- "chart": 0,
- "series": "R1",
- "points": [ {"x": i[0], "y":i[1]} for i in zip(x,y) ]
- }
+ start += 0.5
- r = requests.post("http://0.0.0.0:8080/add", json=data, headers={"Connection":"close"})
- print(r.request.body, len(r.request.body))
+ data = {
+ "chart": 0,
+ "series": "R1",
+ "points": [ {"x": i[0], "y":i[1]} for i in zip(x,y) ]
+ }
+
+ r = requests.post("http://0.0.0.0:8080/add", json=data, headers={"Connection":"close"})
+ sleep(0.25)
def star():
points = [
@@ -42,7 +46,7 @@ def star():
def main():
#sine()
sine_array()
- #star()
+ #star()
if __name__ == "__main__":
main()