From 7ed7e346b26e4aaa45b5ff70cc52887466f04fb0 Mon Sep 17 00:00:00 2001 From: vdeo Date: Fri, 8 Nov 2024 12:13:06 -1000 Subject: [PATCH 1/5] [pyFps] prepend . when passing FPS keys down to MILK --- python_module/CacaoProcessTools.cpp | 122 +++++++++++++++------------- python_module/pyFps.hpp | 6 +- 2 files changed, 72 insertions(+), 56 deletions(-) diff --git a/python_module/CacaoProcessTools.cpp b/python_module/CacaoProcessTools.cpp index f4b78f10..8b696c1e 100644 --- a/python_module/CacaoProcessTools.cpp +++ b/python_module/CacaoProcessTools.cpp @@ -23,36 +23,36 @@ int fps_value_to_key(pyFps &cls, switch(switch_fps_type) { - case FPS_type::ONOFF: - return functionparameter_SetParamValue_ONOFF(cls, - key.c_str(), py::bool_(value)); - case FPS_type::INT32: - case FPS_type::UINT32: - case FPS_type::INT64: - case FPS_type::UINT64: - return functionparameter_SetParamValue_INT64(cls, - key.c_str(), - py::int_(value)); - case FPS_type::FLOAT32: - return functionparameter_SetParamValue_FLOAT32(cls, - key.c_str(), - py::float_(value)); - case FPS_type::FLOAT64: - return functionparameter_SetParamValue_FLOAT64(cls, - key.c_str(), - py::float_(value)); - case FPS_type::STRING: - case FPS_type::STREAMNAME: - case FPS_type::DIRNAME: - case FPS_type::EXECFILENAME: - case FPS_type::FILENAME: - case FPS_type::FITSFILENAME: - return functionparameter_SetParamValue_STRING( - cls, - key.c_str(), - std::string(py::str(value)).c_str()); - default: - return EXIT_FAILURE; + case FPS_type::ONOFF: + return functionparameter_SetParamValue_ONOFF(cls, + key.c_str(), py::bool_(value)); + case FPS_type::INT32: + case FPS_type::UINT32: + case FPS_type::INT64: + case FPS_type::UINT64: + return functionparameter_SetParamValue_INT64(cls, + key.c_str(), + py::int_(value)); + case FPS_type::FLOAT32: + return functionparameter_SetParamValue_FLOAT32(cls, + key.c_str(), + py::float_(value)); + case FPS_type::FLOAT64: + return functionparameter_SetParamValue_FLOAT64(cls, + key.c_str(), + py::float_(value)); + case FPS_type::STRING: + case FPS_type::STREAMNAME: + case FPS_type::DIRNAME: + case FPS_type::EXECFILENAME: + case FPS_type::FILENAME: + case FPS_type::FITSFILENAME: + return functionparameter_SetParamValue_STRING( + cls, + key.c_str(), + std::string(py::str(value)).c_str()); + default: + return EXIT_FAILURE; } } @@ -61,29 +61,29 @@ fps_value_from_key(pyFps &cls, const std::string &key, const FPS_type fps_type) { switch(fps_type) { - case FPS_type::ONOFF: - return py::bool_(functionparameter_GetParamValue_ONOFF(cls, key.c_str())); - case FPS_type::INT32: - case FPS_type::UINT32: - case FPS_type::INT64: - case FPS_type::UINT64: - return py::int_( - functionparameter_GetParamValue_INT64(cls, key.c_str())); - case FPS_type::FLOAT32: - return py::float_( - functionparameter_GetParamValue_FLOAT32(cls, key.c_str())); - case FPS_type::FLOAT64: - return py::float_( - functionparameter_GetParamValue_FLOAT64(cls, key.c_str())); - case FPS_type::STRING: - case FPS_type::STREAMNAME: - case FPS_type::DIRNAME: - case FPS_type::EXECFILENAME: - case FPS_type::FILENAME: - case FPS_type::FITSFILENAME: - return py::str(functionparameter_GetParamPtr_STRING(cls, key.c_str())); - default: - return py::none(); + case FPS_type::ONOFF: + return py::bool_(functionparameter_GetParamValue_ONOFF(cls, key.c_str())); + case FPS_type::INT32: + case FPS_type::UINT32: + case FPS_type::INT64: + case FPS_type::UINT64: + return py::int_( + functionparameter_GetParamValue_INT64(cls, key.c_str())); + case FPS_type::FLOAT32: + return py::float_( + functionparameter_GetParamValue_FLOAT32(cls, key.c_str())); + case FPS_type::FLOAT64: + return py::float_( + functionparameter_GetParamValue_FLOAT64(cls, key.c_str())); + case FPS_type::STRING: + case FPS_type::STREAMNAME: + case FPS_type::DIRNAME: + case FPS_type::EXECFILENAME: + case FPS_type::FILENAME: + case FPS_type::FITSFILENAME: + return py::str(functionparameter_GetParamPtr_STRING(cls, key.c_str())); + default: + return py::none(); } } @@ -410,13 +410,25 @@ If entry already exists, do not modify it Parameters: name [in]: the name of the shared memory file to connect - create [in]: flag for creating of shared memory identifier - NBparamMAX [in]: Max number of parameters )pbdoc", py::arg("entry_name"), py::arg("entry_desc"), py::arg("fptype")) + .def("add_entry", + &pyFps::add_entry_w_flags, + R"pbdoc(Add parameter to database with custom flags + +If entry already exists, do not modify it + +Parameters: + name [in]: the name of the shared memory file to connect +)pbdoc", + py::arg("entry_name"), + py::arg("entry_desc"), + py::arg("fptype"), + py::arg("fpflag")) + .def("get_status", &pyFps::get_status) .def("set_status", &pyFps::set_status) .def("disconnect", &pyFps::disconnect) diff --git a/python_module/pyFps.hpp b/python_module/pyFps.hpp index c764ea4d..0fc98da4 100644 --- a/python_module/pyFps.hpp +++ b/python_module/pyFps.hpp @@ -221,7 +221,10 @@ class pyFps uint32_t fptype) { keys_[entry_name] = static_cast(fptype); - return function_parameter_add_entry(&fps_, entry_name.c_str(), + // We need to prepend a . to entry to abide by FPS conventions + // See fps_add_entry.c + std::string preprended = "." + entry_name; + return function_parameter_add_entry(&fps_, preprended.c_str(), entry_desc.c_str(), fptype, FPFLAG_DEFAULT_INPUT, nullptr, nullptr); } @@ -241,6 +244,7 @@ class pyFps uint32_t fptype, uint64_t fpflag) { keys_[entry_name] = static_cast(fptype); + std::string preprended = "." + entry_name; return function_parameter_add_entry(&fps_, entry_name.c_str(), entry_desc.c_str(), fptype, fpflag, nullptr, nullptr); From baec4caea604c7bcddf138341383c678f90159df Mon Sep 17 00:00:00 2001 From: "vdeo@AORTS" Date: Fri, 8 Nov 2024 22:33:35 +0000 Subject: [PATCH 2/5] [pyFps] typo fix; expose basic FPS flags through CPT; doc --- python_module/CacaoProcessTools.cpp | 13 +++++++++++++ python_module/pyFps.hpp | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/python_module/CacaoProcessTools.cpp b/python_module/CacaoProcessTools.cpp index 8b696c1e..18ef4a41 100644 --- a/python_module/CacaoProcessTools.cpp +++ b/python_module/CacaoProcessTools.cpp @@ -154,6 +154,14 @@ PYBIND11_MODULE(CacaoProcessTools, m) .value("FPSNAME", FPS_type::FPSNAME) .export_values(); + py::enum_(m, "FPS_flags") + .value("DEFAULT_INPUT", FPS_flags::DEFAULT_INPUT) + .value("DEFAULT_OUTPUT", FPS_flags::DEFAULT_OUTPUT) + .value("DEFAULT_INPUT_STREAM", FPS_flags::DEFAULT_INPUT_STREAM) + .value("DEFAULT_OUTPUT_STREAM", FPS_flags::DEFAULT_OUTPUT_STREAM) + .export_values(); + + py::class_(m, "timespec") .def(py::init()) .def_readwrite("tv_sec", ×pec::tv_sec) @@ -410,6 +418,8 @@ If entry already exists, do not modify it Parameters: name [in]: the name of the shared memory file to connect + comment [in]: description + fptype [in]: datatype )pbdoc", py::arg("entry_name"), py::arg("entry_desc"), @@ -423,6 +433,9 @@ If entry already exists, do not modify it Parameters: name [in]: the name of the shared memory file to connect + comment [in]: description + fptype [in]: datatype + fpflag [in]: fps flags )pbdoc", py::arg("entry_name"), py::arg("entry_desc"), diff --git a/python_module/pyFps.hpp b/python_module/pyFps.hpp index 0fc98da4..63b63ba1 100644 --- a/python_module/pyFps.hpp +++ b/python_module/pyFps.hpp @@ -223,8 +223,8 @@ class pyFps keys_[entry_name] = static_cast(fptype); // We need to prepend a . to entry to abide by FPS conventions // See fps_add_entry.c - std::string preprended = "." + entry_name; - return function_parameter_add_entry(&fps_, preprended.c_str(), + std::string prepended = "." + entry_name; + return function_parameter_add_entry(&fps_, prepended.c_str(), entry_desc.c_str(), fptype, FPFLAG_DEFAULT_INPUT, nullptr, nullptr); } @@ -244,8 +244,8 @@ class pyFps uint32_t fptype, uint64_t fpflag) { keys_[entry_name] = static_cast(fptype); - std::string preprended = "." + entry_name; - return function_parameter_add_entry(&fps_, entry_name.c_str(), + std::string prepended = "." + entry_name; + return function_parameter_add_entry(&fps_, prepended.c_str(), entry_desc.c_str(), fptype, fpflag, nullptr, nullptr); } From dded15737e9d18c2c0ee526c4c2a9a05428f79dd Mon Sep 17 00:00:00 2001 From: kyohoon-ahn Date: Mon, 18 Nov 2024 01:37:33 +0000 Subject: [PATCH 3/5] [pyFPS] add DEFAULT_STATUS flag in binding --- python_module/CacaoProcessTools.cpp | 1 + python_module/pyFps.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/python_module/CacaoProcessTools.cpp b/python_module/CacaoProcessTools.cpp index 18ef4a41..95df0d6b 100644 --- a/python_module/CacaoProcessTools.cpp +++ b/python_module/CacaoProcessTools.cpp @@ -159,6 +159,7 @@ PYBIND11_MODULE(CacaoProcessTools, m) .value("DEFAULT_OUTPUT", FPS_flags::DEFAULT_OUTPUT) .value("DEFAULT_INPUT_STREAM", FPS_flags::DEFAULT_INPUT_STREAM) .value("DEFAULT_OUTPUT_STREAM", FPS_flags::DEFAULT_OUTPUT_STREAM) + .value("DEFAULT_STATUS", FPS_flags::DEFAULT_STATUS) .export_values(); diff --git a/python_module/pyFps.hpp b/python_module/pyFps.hpp index 63b63ba1..f2df2500 100644 --- a/python_module/pyFps.hpp +++ b/python_module/pyFps.hpp @@ -65,6 +65,7 @@ enum FPS_flags : uint64_t DEFAULT_OUTPUT = FPFLAG_DEFAULT_OUTPUT, DEFAULT_INPUT_STREAM = FPFLAG_DEFAULT_INPUT_STREAM, DEFAULT_OUTPUT_STREAM = FPFLAG_DEFAULT_OUTPUT_STREAM, + DEFAULT_STATUS = FPFLAG_DEFAULT_STATUS, }; class pyFps From 4fd51c82fcc36cf4e543e0f7af40b8bb7379fb0a Mon Sep 17 00:00:00 2001 From: vdeo Date: Tue, 26 Nov 2024 17:53:40 -1000 Subject: [PATCH 4/5] [pyFPS] Expose kwarray for FPS metadata. --- python_module/CacaoProcessTools.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/python_module/CacaoProcessTools.cpp b/python_module/CacaoProcessTools.cpp index 95df0d6b..bdf9745f 100644 --- a/python_module/CacaoProcessTools.cpp +++ b/python_module/CacaoProcessTools.cpp @@ -752,6 +752,7 @@ Requires setup performed by milk-fpsinit, which performs the following setup // })) .def_readonly("name", &FUNCTION_PARAMETER_STRUCT_MD::name) .def_readonly("description", &FUNCTION_PARAMETER_STRUCT_MD::description) + .def_readonly("kwarray", &FUNCTION_PARAMETER_STRUCT_MD::keywordarray) .def_readonly("workdir", &FUNCTION_PARAMETER_STRUCT_MD::workdir) .def_readonly("datadir", &FUNCTION_PARAMETER_STRUCT_MD::datadir) .def_readonly("confdir", &FUNCTION_PARAMETER_STRUCT_MD::confdir) From c129cbe9c946e0c8844a940cbdbbca38e39362bf Mon Sep 17 00:00:00 2001 From: vdeo Date: Tue, 26 Nov 2024 18:18:12 -1000 Subject: [PATCH 5/5] [pyFPS] uint64 FPS calls fix. --- python_module/CacaoProcessTools.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/python_module/CacaoProcessTools.cpp b/python_module/CacaoProcessTools.cpp index bdf9745f..5b485729 100644 --- a/python_module/CacaoProcessTools.cpp +++ b/python_module/CacaoProcessTools.cpp @@ -24,22 +24,20 @@ int fps_value_to_key(pyFps &cls, switch(switch_fps_type) { case FPS_type::ONOFF: - return functionparameter_SetParamValue_ONOFF(cls, - key.c_str(), py::bool_(value)); + return functionparameter_SetParamValue_ONOFF(cls, key.c_str(), + py::bool_(value)); case FPS_type::INT32: case FPS_type::UINT32: case FPS_type::INT64: + return functionparameter_SetParamValue_INT64(cls, key.c_str(), py::int_(value)); case FPS_type::UINT64: - return functionparameter_SetParamValue_INT64(cls, - key.c_str(), + return functionparameter_SetParamValue_UINT64(cls, key.c_str(), py::int_(value)); case FPS_type::FLOAT32: - return functionparameter_SetParamValue_FLOAT32(cls, - key.c_str(), + return functionparameter_SetParamValue_FLOAT32(cls, key.c_str(), py::float_(value)); case FPS_type::FLOAT64: - return functionparameter_SetParamValue_FLOAT64(cls, - key.c_str(), + return functionparameter_SetParamValue_FLOAT64(cls, key.c_str(), py::float_(value)); case FPS_type::STRING: case FPS_type::STREAMNAME: @@ -66,9 +64,11 @@ fps_value_from_key(pyFps &cls, const std::string &key, const FPS_type fps_type) case FPS_type::INT32: case FPS_type::UINT32: case FPS_type::INT64: - case FPS_type::UINT64: return py::int_( functionparameter_GetParamValue_INT64(cls, key.c_str())); + case FPS_type::UINT64: + return py::int_( + functionparameter_GetParamValue_UINT64(cls, key.c_str())); case FPS_type::FLOAT32: return py::float_( functionparameter_GetParamValue_FLOAT32(cls, key.c_str()));