Skip to content

Commit

Permalink
- other service functions also moved to class PFServices and create_s…
Browse files Browse the repository at this point in the history
…ervice() with these member functions

- service reset_iq_parameter removed -> not available in PFSDP
  • Loading branch information
JnsHndr committed Oct 17, 2024
1 parent 517e50c commit 8dd19c0
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 211 deletions.
2 changes: 0 additions & 2 deletions src/pf_driver/include/pf_driver/pf/pf_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "pf_interfaces/srv/pfsdp_list_iq_parameters.hpp"
#include "pf_interfaces/srv/pfsdp_get_iq_parameter.hpp"
#include "pf_interfaces/srv/pfsdp_set_iq_parameter.hpp"
#include "pf_interfaces/srv/pfsdp_reset_iq_parameter.hpp"

class PFInterface
{
Expand Down Expand Up @@ -76,7 +75,6 @@ class PFInterface
rclcpp::Service<pf_interfaces::srv::PfsdpListIqParameters>::SharedPtr listiqparams_service_;
rclcpp::Service<pf_interfaces::srv::PfsdpGetIqParameter>::SharedPtr getiqparam_service_;
rclcpp::Service<pf_interfaces::srv::PfsdpSetIqParameter>::SharedPtr setiqparam_service_;
rclcpp::Service<pf_interfaces::srv::PfsdpResetIqParameter>::SharedPtr resetiqparam_service_;

std::string topic_;
std::string frame_id_;
Expand Down
97 changes: 30 additions & 67 deletions src/pf_driver/include/pf_driver/ros/pf_services.h
Original file line number Diff line number Diff line change
@@ -1,91 +1,54 @@
#pragma once

//#include <memory>
//#include <string>
//#include <utility>

#include "pf_driver/pf/pf_interface.h"
#include "pf_interfaces/srv/pfsdp_get_protocol_info.hpp"
#include "pf_interfaces/srv/pfsdp_reboot_device.hpp"
#include "pf_interfaces/srv/pfsdp_factory_reset.hpp"
#include "pf_interfaces/srv/pfsdp_get_protocol_info.hpp"
#include "pf_interfaces/srv/pfsdp_list_parameters.hpp"
#include "pf_interfaces/srv/pfsdp_get_parameter.hpp"
#include "pf_interfaces/srv/pfsdp_set_parameter.hpp"
#include "pf_interfaces/srv/pfsdp_reset_parameter.hpp"
#include "pf_interfaces/srv/pfsdp_list_parameters.hpp"
#include "pf_interfaces/srv/pfsdp_list_iq_parameters.hpp"
#include "pf_interfaces/srv/pfsdp_get_iq_parameter.hpp"
#include "pf_interfaces/srv/pfsdp_set_iq_parameter.hpp"
#include "pf_interfaces/srv/pfsdp_reset_iq_parameter.hpp"
#include "pf_interfaces/srv/pfsdp_list_iq_parameters.hpp"

void pfsdp_reboot_device(//PFInterface* pf,
//const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<pf_interfaces::srv::PfsdpRebootDevice::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpRebootDevice::Response> response);

void pfsdp_factory_reset(//PFInterface* pf,
//const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<pf_interfaces::srv::PfsdpFactoryReset::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpFactoryReset::Response> response);

void pfsdp_get_protocol_info(PFInterface* pf,
//const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<pf_interfaces::srv::PfsdpGetProtocolInfo::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpGetProtocolInfo::Response> response);

void pfsdp_list_parameters(//PFInterface* pf,
//const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<pf_interfaces::srv::PfsdpListParameters::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpListParameters::Response> response);

void pfsdp_get_parameter(//PFInterface* pf,
//const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<pf_interfaces::srv::PfsdpGetParameter::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpGetParameter::Response> response);
class PFServices
{
public:
PFServices(PFInterface *pf) : pf_(pf)
{
}

void pfsdp_set_parameter(//PFInterface* pf,
//const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<pf_interfaces::srv::PfsdpSetParameter::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpSetParameter::Response> response);
void pfsdp_get_protocol_info(const std::shared_ptr<pf_interfaces::srv::PfsdpGetProtocolInfo::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpGetProtocolInfo::Response> response);

void pfsdp_reset_parameter(//PFInterface* pf,
//const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<pf_interfaces::srv::PfsdpResetParameter::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpResetParameter::Response> response);
void pfsdp_reboot_device(const std::shared_ptr<pf_interfaces::srv::PfsdpRebootDevice::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpRebootDevice::Response> response);

void pfsdp_list_iq_parameters(//PFInterface* pf,
//const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<pf_interfaces::srv::PfsdpListIqParameters::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpListIqParameters::Response> response);
void pfsdp_factory_reset(const std::shared_ptr<pf_interfaces::srv::PfsdpFactoryReset::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpFactoryReset::Response> response);

void pfsdp_get_iq_parameter(//PFInterface* pf,
//const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<pf_interfaces::srv::PfsdpGetIqParameter::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpGetIqParameter::Response> response);
void pfsdp_list_parameters(const std::shared_ptr<pf_interfaces::srv::PfsdpListParameters::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpListParameters::Response> response);

void pfsdp_set_iq_parameter(//PFInterface* pf,
//const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<pf_interfaces::srv::PfsdpSetIqParameter::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpSetIqParameter::Response> response);
void pfsdp_get_parameter(const std::shared_ptr<pf_interfaces::srv::PfsdpGetParameter::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpGetParameter::Response> response);

void pfsdp_reset_iq_parameter(//PFInterface* pf,
//const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<pf_interfaces::srv::PfsdpResetIqParameter::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpResetIqParameter::Response> response);
void pfsdp_set_parameter(const std::shared_ptr<pf_interfaces::srv::PfsdpSetParameter::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpSetParameter::Response> response);

void pfsdp_reset_parameter(const std::shared_ptr<pf_interfaces::srv::PfsdpResetParameter::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpResetParameter::Response> response);

void pfsdp_list_iq_parameters(const std::shared_ptr<pf_interfaces::srv::PfsdpListIqParameters::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpListIqParameters::Response> response);

class PFServices
{
public:
PFServices(PFInterface *pf) : pf_(pf)
{
}
void pfsdp_get_iq_parameter(const std::shared_ptr<pf_interfaces::srv::PfsdpGetIqParameter::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpGetIqParameter::Response> response);

void pfsdp_get_protocol_info(const std::shared_ptr<pf_interfaces::srv::PfsdpGetProtocolInfo::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpGetProtocolInfo::Response> response)
{
pf_->pfsdp_info(response->protocol_name, response->version_major, response->version_minor, response->commands,
response->error_code, response->error_text);
}
void pfsdp_set_iq_parameter(const std::shared_ptr<pf_interfaces::srv::PfsdpSetIqParameter::Request> request,
std::shared_ptr<pf_interfaces::srv::PfsdpSetIqParameter::Response> response);

private:
PFInterface *pf_ = nullptr;
Expand Down
104 changes: 37 additions & 67 deletions src/pf_driver/src/pf/pf_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,79 +284,49 @@ void PFInterface::add_pf_services(void)
std::string basename = std::string(node_->get_namespace()) + std::string(node_->get_name()) + std::string("/pfsdp_");
std::string svcname;

std::shared_ptr<PFServices>pfServices = std::make_shared<PFServices>(this);
std::shared_ptr<PFServices>pf_services = std::make_shared<PFServices>(this);

svcname = basename + "get_protocol_info";
info_service_ = node_->create_service<pf_interfaces::srv::PfsdpGetProtocolInfo>(
//svcname.c_str(), std::bind(&pfsdp_get_protocol_info, this, std::placeholders::_1, std::placeholders::_2));
//svcname.c_str(), std::bind(&pfsdp_get_protocol_info, this, std::placeholders::_1,
// std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), &pfsdp_get_protocol_info);
//svcname.c_str(), std::bind(&pfsdp_get_protocol_info, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), std::bind(&PFServices::pfsdp_get_protocol_info, this, std::placeholders::_1, std::placeholders::_2));
svcname.c_str(), std::bind(&PFServices::pfsdp_get_protocol_info, pfServices, std::placeholders::_1, std::placeholders::_2));

//svcname = basename + "reboot_device";
//reboot_service_ = node_->create_service<pf_interfaces::srv::PfsdpRebootDevice>(
//svcname.c_str(), std::bind(&pfsdp_reboot_device, this, std::placeholders::_1,
// std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), &pfsdp_reboot_device);

//svcname = basename + "factory_reset";
//factory_service_ = node_->create_service<pf_interfaces::srv::PfsdpFactoryReset>(
//svcname.c_str(), std::bind(&pfsdp_factory_reset, this, std::placeholders::_1,
// std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), &pfsdp_factory_reset);

//svcname = basename + "list_parameters";
//listparams_service_ = node_->create_service<pf_interfaces::srv::PfsdpListParameters>(
//svcname.c_str(), std::bind(&pfsdp_list_parameters, this, std::placeholders::_1,
// std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), &pfsdp_list_parameters);

//svcname = basename + "get_parameter";
//getparam_service_ = node_->create_service<pf_interfaces::srv::PfsdpGetParameter>(
//svcname.c_str(), std::bind(&pfsdp_get_parameter, this, std::placeholders::_1,
// std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), &pfsdp_get_parameter);

//svcname = basename + "set_parameter";
//setparam_service_ = node_->create_service<pf_interfaces::srv::PfsdpSetParameter>(
//svcname.c_str(), std::bind(&pfsdp_set_parameter, this, std::placeholders::_1,
// std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), &pfsdp_set_parameter);

//svcname = basename + "reset_parameter";
//resetparam_service_ = node_->create_service<pf_interfaces::srv::PfsdpResetParameter>(
//svcname.c_str(), std::bind(&pfsdp_reset_parameter, this, std::placeholders::_1,
// std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), &pfsdp_reset_parameter);
svcname.c_str(), std::bind(&PFServices::pfsdp_get_protocol_info, pf_services, std::placeholders::_1, std::placeholders::_2));

svcname = basename + "reboot_device";
reboot_service_ = node_->create_service<pf_interfaces::srv::PfsdpRebootDevice>(
svcname.c_str(), std::bind(&PFServices::pfsdp_reboot_device, pf_services, std::placeholders::_1, std::placeholders::_2));

svcname = basename + "factory_reset";
factory_service_ = node_->create_service<pf_interfaces::srv::PfsdpFactoryReset>(
svcname.c_str(), std::bind(&PFServices::pfsdp_factory_reset, pf_services, std::placeholders::_1, std::placeholders::_2));

svcname = basename + "list_parameters";
listparams_service_ = node_->create_service<pf_interfaces::srv::PfsdpListParameters>(
svcname.c_str(), std::bind(&PFServices::pfsdp_list_parameters, pf_services, std::placeholders::_1, std::placeholders::_2));

svcname = basename + "get_parameter";
getparam_service_ = node_->create_service<pf_interfaces::srv::PfsdpGetParameter>(
svcname.c_str(), std::bind(&PFServices::pfsdp_get_parameter, pf_services, std::placeholders::_1, std::placeholders::_2));

svcname = basename + "set_parameter";
setparam_service_ = node_->create_service<pf_interfaces::srv::PfsdpSetParameter>(
svcname.c_str(), std::bind(&PFServices::pfsdp_set_parameter, pf_services, std::placeholders::_1, std::placeholders::_2));

svcname = basename + "reset_parameter";
resetparam_service_ = node_->create_service<pf_interfaces::srv::PfsdpResetParameter>(
svcname.c_str(), std::bind(&PFServices::pfsdp_reset_parameter, pf_services, std::placeholders::_1, std::placeholders::_2));

if (has_iq_parameters_)
{
//svcname = basename + "list_iq_parameters";
//listiqparams_service_ = node_->create_service<pf_interfaces::srv::PfsdpListIqParameters>(
//svcname.c_str(), std::bind(&pfsdp_list_iq_parameters, this, std::placeholders::_1,
// std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), &pfsdp_list_iq_parameters);

//svcname = basename + "get_iq_parameter";
//getiqparam_service_ = node_->create_service<pf_interfaces::srv::PfsdpGetIqParameter>(
//svcname.c_str(), std::bind(&pfsdp_get_iq_parameter, this, std::placeholders::_1,
// std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), &pfsdp_get_iq_parameter);

//svcname = basename + "set_iq_parameter";
//setiqparam_service_ = node_->create_service<pf_interfaces::srv::PfsdpSetIqParameter>(
//svcname.c_str(), std::bind(&pfsdp_set_iq_parameter, this, std::placeholders::_1,
// std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), &pfsdp_set_iq_parameter);

//svcname = basename + "reset_iq_parameter";
//resetiqparam_service_ = node_->create_service<pf_interfaces::srv::PfsdpResetIqParameter>(
//svcname.c_str(), std::bind(&pfsdp_reset_iq_parameter, this, std::placeholders::_1,
// std::placeholders::_2, std::placeholders::_3));
//svcname.c_str(), &pfsdp_reset_iq_parameter);
svcname = basename + "list_iq_parameters";
listiqparams_service_ = node_->create_service<pf_interfaces::srv::PfsdpListIqParameters>(
svcname.c_str(), std::bind(&PFServices::pfsdp_list_iq_parameters, pf_services, std::placeholders::_1, std::placeholders::_2));

svcname = basename + "get_iq_parameter";
getiqparam_service_ = node_->create_service<pf_interfaces::srv::PfsdpGetIqParameter>(
svcname.c_str(), std::bind(&PFServices::pfsdp_get_iq_parameter, pf_services, std::placeholders::_1, std::placeholders::_2));

svcname = basename + "set_iq_parameter";
setiqparam_service_ = node_->create_service<pf_interfaces::srv::PfsdpSetIqParameter>(
svcname.c_str(), std::bind(&PFServices::pfsdp_set_iq_parameter, pf_services, std::placeholders::_1, std::placeholders::_2));
}
}

Expand Down
Loading

0 comments on commit 8dd19c0

Please sign in to comment.