Commit 708eb034 authored by Mohamed Ahmed's avatar Mohamed Ahmed
Browse files

Debug_3

parent 1facc2ee
#include "ara/com/timeservice_common.h"
#include "ara/core/future.h"
#include "ara/core/promise.h"
// ROS includes
#include <ros/ros.h>
#include "ros/this_node.h"
#include "ros/master.h"
#include "std_msgs/Int64.h"
#include "std_msgs/String.h"
#include "std_msgs/Bool.h"
#include "timeClient/time_srv.h"
#include "timeClient/srv_info.h"
namespace events
{
class BrakeEvent {
ros::NodeHandle rosHandler_;
/**
* \brief Shortcut for the events data type.
*/
using SampleType = timeService::RadarObjects;
/**
* \brief The application expects the CM to subscribe the event.
*
* The Communication Management shall try to subscribe and resubscribe
* until \see Unsubscribe() is called explicitly.
* The error handling shall be kept within the Communication Management
.
*
* The function returns immediately. If the user wants to get notified,
* when subscription has succeeded, he needs to register a handler
* via \see SetSubscriptionStateChangeHandler(). This handler gets
* then called after subscription was successful.
*
* \param maxSampleCount maximum number of samples, which can be held.
*/
public:
BrakeEvent();
BrakeEvent(ros::NodeHandle& proxyNodeHandler);
/**
* \brief The application expects the CM to subscribe the event.
*
* The Communication Management shall try to subscribe and resubscribe
* until \see Unsubscribe() is called explicitly.
* The error handling shall be kept within the Communication Management
.
*
* The function returns immediately. If the user wants to get notified,
* when subscription has succeeded, he needs to register a handler
* via \see SetSubscriptionStateChangeHandler(). This handler gets
* then called after subscription was successful.
*
* \param maxSampleCount maximum number of samples, which can be held.
*/
//void Subscribe(size_t maxSampleCount);
/**
* \brief Query current subscription state.
*
* \return Current state of the subscription.
*/
//ara::com::SubscriptionState GetSubscriptionState() const;
/**
* \brief Unsubscribe from the service.
*/
//void Unsubscribe();
/**
* \brief Get the number of currently free/available sample slots.
*
* \return number from 0 - N (N = count given in call to Subscribe())
or an ErrorCode in case of number of currently held samples
*
already exceeds the max number given in Subscribe().
*
*/
//ara::core::Result<size_t> GetFreeSampleCount() const noexcept;
/**
* Setting a receive handler signals the Communication Management
* implementation to use event style mode.
* I.e. the registered handler gets called asynchronously by the
* Communication Management as soon as new event data arrives for
* that event. If user wants to have strict polling behavior,
* where you decide when to check for new data via GetNewSamples() he
* should NOT register a handler.
*
* Handler may be overwritten anytime during runtime.
*
* Provided Handler needs not to be re-entrant since the
* Communication Management implementation has to serialize calls
* to the handler: Handler gets called once by the MW, when new
* events arrived since the last call to GetNewSamples().
*
* When application calls GetNewSamples() again in the context of the
* receive handler, MW must - in case new events arrived in the
* meantime - defer next call to receive handler until after
* the previous call to receive handler has been completed.
*/
//void SetReceiveHandler(ara::com::EventReceiveHandler handler);
/**
* Remove handler set by SetReceiveHandler()
*/
//void UnsetReceiveHandler();
/**
* Setting a subscription state change handler, which shall get
* called by the Communication Management implementation as soon
* as the subscription state of this event has changed.
*
* Communication Management implementation will serialize calls
* to the registered handler. If multiple changes of the
* subscription state take place during the runtime of a
* previous call to a handler, the Communication Management
* aggregates all changes to one call with the last/effective
* state.
*
* Handler may be overwritten during runtime.
*/
//void SetSubscriptionStateChangeHandler(ara::com::SubscriptionStateChangeHandler handler);
/**
* \brief Get new data from the Communication Management
* buffers and provide it in callbacks to the given callable f.
*
* \pre BrakeEvent::Subscribe has been called before
* (and not be withdrawn by BrakeEvent::Unsubscribe)
*
* \param f
* \parblock
* callback, which shall be called with new sample.
*
* This callable has to fulfill signature
* void(ara::com::SamplePtr<SampleType const>)
* \parblockend
*
* \param maxNumberOfSamples
* \parblock
* upper bound of samples to be fetched from middleware buffers.
* Default value means "no restriction", i.e. all newly arrived samples
* are fetched as long as there are free sample slots.
* \parblockend
*
* \return Result, which contains the number of samples,
* which have been fetched and presented to user via calls to f or an
* ErrorCode in case of error (e.g. precondition not fullfilled)
*/
//template <typename F>
//ara::core::Result<size_t> GetNewSamples(F&& f, size_t maxNumberOfSamples = std::numeric_limits<size_t>::max());
};
}
\ No newline at end of file
......@@ -7,7 +7,6 @@
#include "ara/com/instance_identifier.h"
#include "ara/core/future.h"
#include "getTime.hpp"
#include "timeServiceEvent.hpp"
void callback(const timeClient::srv_info &msg);
......@@ -146,7 +145,6 @@ public:
static ara::com::FindServiceHandler<HandleType> proxyHandler; // possible disaster in case multiple objects in the same process
static std::vector<timeServiceProxy::HandleType> handlesVec;
methods::getTime getTime;
events::BrakeEvent BrakeEvent;
void callback(const timeClient::srv_info &msg);
......
......@@ -71,7 +71,7 @@ void Timeactivity::run()
}
else
{
//std::cout << "\rERROR: There is no handle!!" << std::endl;
std::cout << "\rERROR: There is no handle!!" << std::endl;
}
}
......
#include "../inc/timeServiceEvent.hpp"
using namespace events;
BrakeEvent::BrakeEvent(ros::NodeHandle& proxyNodeHandler) :
rosHandler_(proxyNodeHandler)
{
}
//void BrakeEvent::Subscribe(size_t maxSampleCount)
//{}
//void BrakeEvent::Unsubscribe(){}
//ara::com::SubscriptionState BrakeEvent::GetSubscriptionState() const{}
//void BrakeEvent::SetReceiveHandler(ara::com::EventReceiveHandler handler){}
//void BrakeEvent::SetSubscriptionStateChangeHandler(ara::com::SubscriptionStateChangeHandler handler){}
//ara::core::Result<size_t> BrakeEvent::GetNewSamples(F&& f, size_t maxNumberOfSamples = std::numeric_limits<size_t>::max()){}
......@@ -21,8 +21,7 @@ timeServiceProxy::timeServiceProxy(HandleType &handle):
srv_ID("x" + std::to_string(handle.GetInstanceId().GetInstanceId())),
rosHandler_(ros::NodeHandle(srv_ID)),
proxyClient(rosHandler_.serviceClient<timeClient::time_srv>("timeService")),
getTime(rosHandler_, proxyClient),
BrakeEvent(rosHandler_)
getTime(rosHandler_, proxyClient)
{
std::cout<<"\nHello From Proxy Constructor\n"<<srv_ID<<std::endl;
}
......@@ -65,7 +64,7 @@ void callback(const timeClient::srv_info &msg)
{
std::string str = msg.srv_ns.substr(1);
timeServiceProxy::instanceID_ = std::stoi(str);
//std::cout<<"\ncurrent_state: "<< msg.current_state;
std::cout<<"\ncurrent_state: "<< msg.current_state;
//std::cout<<"\nprevious_state: "<< msg.previous_state;
if(msg.current_state == "on") //First time to see the serviceat this time
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment