verion which did not include the handling in RTService wth creating the
Json file
This commit is contained in:
@@ -1,13 +1,6 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7-a)
|
||||
|
||||
set(TOOLCHAIN_PREFIX home/markus/STM32MPU_workspace/STM32MP1-Ecosystem-V6.1.0/Distribution-Package-VRDevice/SDK/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux/)
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
|
||||
|
||||
#set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||
project(rt_service)
|
||||
|
||||
|
||||
# Find python and Boost - both are required dependencies
|
||||
@@ -31,7 +24,7 @@ add_library(rt_service MODULE rt_service.cpp)
|
||||
target_link_libraries(rt_service ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
|
||||
target_include_directories(rt_service PRIVATE ${PYTHON_INCLUDE_DIRS})
|
||||
|
||||
set(MY_RESOURCE_FILE rt_service.so)
|
||||
#set(MY_RESOURCE_FILE rt_service.so)
|
||||
#set_directory_properties(MY_EXTENSION_LIB /home/markus/git/vrpmwvweb/vrpmdvserver/extensions/)
|
||||
#file(COPY ${CMAKE_CURRENT_BINARY_DIR}/${MY_RESOURCE_FILE}
|
||||
# DESTINATION /home/markus/git/vrpmdvweb/vrpmdvserver/extensions/rt_service)
|
||||
@@ -1,69 +0,0 @@
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/list.hpp>
|
||||
#include <boost/python/extract.hpp>
|
||||
#include <string>
|
||||
//#include <sstream>
|
||||
//#include <vector>
|
||||
|
||||
struct RTService
|
||||
{
|
||||
// private:
|
||||
// /* data */
|
||||
|
||||
// public:
|
||||
// RT_Service(/* args */) {}
|
||||
|
||||
// ~RT_Service() {}
|
||||
|
||||
bool createMonitoring(std::string id) {
|
||||
//TODO ML: add this to the M4Core
|
||||
return true;
|
||||
}
|
||||
|
||||
bool deleteMonitoring(std::string id) {
|
||||
//TODO ML: add this to the M4Core
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string getMonitoringState(std::string id) {
|
||||
//TODO ask the M4Core for the Monitpring Status
|
||||
return "Start";
|
||||
}
|
||||
|
||||
boost::python::list getMonitoringStates() {
|
||||
//TODO ask the M4Core for the Monitpring Status
|
||||
boost::python::list list;
|
||||
return list;
|
||||
}
|
||||
|
||||
bool setMonitoringStatus(std::string id, std::string status) {
|
||||
//set the Status
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
BOOST_PYTHON_MODULE(rt_service)
|
||||
{
|
||||
class_<RTService>("RT_Service")
|
||||
.def("createMonitoring", &RTService::createMonitoring)
|
||||
.def("getMonitoringStatus", &RTService::getMonitoringState)
|
||||
.def("getAllMonitoringStat", &RTService::getMonitoringStates)
|
||||
.def("setMonitoringStatus", &RTService::setMonitoringStatus)
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//examples
|
||||
// long l = len(msgs);
|
||||
// std::stringstream ss;
|
||||
// for (long i = 0; i<l; ++i) {
|
||||
// if (i>0) ss << ", ";
|
||||
// std::string s = boost::python::extract<std::string>(msgs[i]);
|
||||
// ss << s;
|
||||
// }
|
||||
// mMsg = ss.str();
|
||||
119
vrpmdvserver/rt_service/rt_service.cpp.old
Normal file
119
vrpmdvserver/rt_service/rt_service.cpp.old
Normal file
@@ -0,0 +1,119 @@
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/list.hpp>
|
||||
#include <boost/python/extract.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/interprocess/ipc/message_queue.hpp>
|
||||
|
||||
//#include <sstream>
|
||||
//#include <vector>
|
||||
|
||||
struct RTService
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
const std::string RTSCOMMANDQUEUE = "RTSSERVICECOMMANDQUEUE";
|
||||
const int MAXMSGSIZE = 250;
|
||||
const int MAXMSGCOUNT = 25;
|
||||
boost::interprocess::message_queue m_mq;
|
||||
public:
|
||||
RTService(/* args */) :
|
||||
m_mq(boost::interprocess::open_or_create, RTSCOMMANDQUEUE.c_str(), MAXMSGCOUNT, MAXMSGSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
~RTService() {}
|
||||
|
||||
bool createMonitoring(std::string id, int samplerate, int sampleperiod, int downtime, std::string status) {
|
||||
//TODO ML: add this to the M4Core
|
||||
boost::property_tree::ptree pt;
|
||||
pt.put("id", id);
|
||||
pt.put("samplerate", samplerate);
|
||||
pt.put("sampleperiod", sampleperiod);
|
||||
pt.put("downtime", downtime);
|
||||
pt.put("status", status);
|
||||
return executeCmd(pt);
|
||||
}
|
||||
|
||||
bool deleteMonitoring(std::string id) {
|
||||
//TODO ML: add this to the M4Core
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string getMonitoringState(std::string id) {
|
||||
//TODO ask the M4Core for the Monitpring Status
|
||||
return "Start";
|
||||
}
|
||||
|
||||
boost::python::list getMonitoringStates() {
|
||||
//TODO ask the M4Core for the Monitpring Status
|
||||
boost::python::list list;
|
||||
return list;
|
||||
}
|
||||
|
||||
bool setMonitoringStatus(std::string id, std::string status) {
|
||||
//set the Status
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool executeCmd(boost::property_tree::ptree pt) {
|
||||
BOOST_TRY{
|
||||
|
||||
bool bCmdQueueRun = true;
|
||||
unsigned int priority;
|
||||
boost::interprocess::message_queue::size_type recvd_size;
|
||||
|
||||
while (bCmdQueueRun) {
|
||||
char rtsCmdbuffer [MAXMSGSIZE];
|
||||
boost::property_tree::write_json(rtsCmdbuffer,pt);
|
||||
|
||||
m_mq.send(rtsCmdbuffer, MAXMSGSIZE, 0);
|
||||
|
||||
m_mq.receive(rtsCmdbuffer, sizeof(rtsCmdbuffer), recvd_size, priority);
|
||||
//read json and go to cmd execution
|
||||
boost::property_tree::read_json(rtsCmdbuffer,pt);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// //Send 100 numbers
|
||||
// for(int i = 0; i < 100; ++i){
|
||||
// mq.send(&i, sizeof(i), 0);
|
||||
// }
|
||||
}
|
||||
BOOST_CATCH(interprocess_exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
BOOST_PYTHON_MODULE(rt_service)
|
||||
{
|
||||
class_<RTService>("RT_Service")
|
||||
.def("createMonitoring", &RTService::createMonitoring)
|
||||
.def("getMonitoringStatus", &RTService::getMonitoringState)
|
||||
.def("getAllMonitoringStat", &RTService::getMonitoringStates)
|
||||
.def("setMonitoringStatus", &RTService::setMonitoringStatus)
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//examples
|
||||
// long l = len(msgs);
|
||||
// std::stringstream ss;
|
||||
// for (long i = 0; i<l; ++i) {
|
||||
// if (i>0) ss << ", ";
|
||||
// std::string s = boost::python::extract<std::string>(msgs[i]);
|
||||
// ss << s;
|
||||
// }
|
||||
// mMsg = ss.str();
|
||||
Reference in New Issue
Block a user