Commit a4e7fc57 authored by Mohamed Ahmed's avatar Mohamed Ahmed

Debug_2

parent 4380980b
......@@ -17,7 +17,7 @@ ara::core::Future<timeService::getTimeOutput> getTime::operator()()
srv.request.srv_id = "x" + std::to_string(getTime::instanceID_);
//srv.request.srv_cmd = "start"; //Start offering service
if(getTimeClient.call(srv)){
ROS_INFO("\nHours: %i\nMinutes: %i\nSeconds: %i", srv.response.hours,srv.response.minutes,srv.response.seconds);
ROS_INFO("ID_: %i\nHours: %i\nMinutes: %i\nSeconds: %i", srv.request.srv_id, srv.response.hours,srv.response.minutes,srv.response.seconds);
returnValue.hours = srv.response.hours;
returnValue.minutes = srv.response.minutes;
returnValue.seconds = srv.response.seconds;
......
......@@ -30,7 +30,7 @@ void Timeactivity::run()
if (nullptr != m_proxy)
{
ROS_INFO("**************");
//ROS_INFO("**************");
std::chrono::time_point<std::chrono::system_clock> deadline
= std::chrono::system_clock::now() + std::chrono::milliseconds(DEADLINE);
......@@ -67,15 +67,11 @@ void Timeactivity::run()
{
std::cout << currentTime << " From service instance: " << INSTANCE_COLOR_40 << "40" << END_COLOR << std::endl;
}
else if(serviceInstances_ == 60)
{
std::cout << currentTime << " From service instance: " << INSTANCE_COLOR_40 << "60" << END_COLOR << std::endl;
}
}
else
{
std::cout << "\rERROR: There is no handle!!" << std::endl;
//std::cout << "\rERROR: There is no handle!!" << std::endl;
}
}
......@@ -84,7 +80,7 @@ void Timeactivity::run()
void Timeactivity::serviceAvailabilityCallback(ara::com::ServiceHandleContainer<proxy::timeServiceProxy::HandleType> handles,
ara::com::FindServiceHandle handler)
{
std::cout << END_COLOR << START_COLOR_CLIENT << " Number of services is found is: "<< handles.size() << std::endl;
//std::cout << END_COLOR << START_COLOR_CLIENT << " Number of services is found is: "<< handles.size() << std::endl;
if (handles.size() > 0)
{
// std::cout << "" << std::endl;
......
......@@ -71,7 +71,7 @@ void callback(const timeClient::srv_info &msg)
{
for(int i=0; i<timeServiceProxy::handlesVec.size();i++){
auto temp = timeServiceProxy::handlesVec[i].GetInstanceId();
ROS_INFO("Srv_ID_%i: %i", i, temp);
//ROS_INFO("Srv_ID_%i: %i", i, temp);
if(timeServiceProxy::handlesVec[i].GetInstanceId() == timeServiceProxy::instanceID_)
return;
}
......
cmake_minimum_required(VERSION 2.8.3)
project(timeClient)
## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
message_generation
)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##
################################################
## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
## Generate messages in the 'msg' folder
add_message_files(
FILES
time.msg
srv_info.msg
# Message1.msg
# Message2.msg
)
## Generate services in the 'srv' folder
add_service_files(
FILES
time_srv.srv
# Service2.srv
)
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs
)
################################################
## Declare ROS dynamic reconfigure parameters ##
################################################
## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed
## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES timeClient
CATKIN_DEPENDS message_runtime
# DEPENDS system_lib
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
## Declare a C++ library
# add_library(${PROJECT_NAME}
# src/${PROJECT_NAME}/timeClient.cpp
# )
## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
# add_executable(${PROJECT_NAME}_node src/timeClient_node.cpp)
## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
# ${catkinsc_ros_LIBRARIES}
# )
#############
## Install ##
#############
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark executables for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
# install(TARGETS ${PROJECT_NAME}_node
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark libraries for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
# install(TARGETS ${PROJECT_NAME}
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
# )
## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )
## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
#############
## Testing ##
#############
## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_timeClient.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
add_subdirectory(./timeClient/)
\ No newline at end of file
//Disclaimer here !!!
// Any AP application should include this.
//#include <ara/exec/execution_client.h>
// TODO: Make the abstract class a thread-safe.
class APapp
{
public:
// The Application procedure (initialization -> running -> termination)
int Run();
// Called by the signal handler to instruct the app to terminate, Or
// it can be called by any instance or the main for self termianting apps.
static void Terminate();
APapp();
virtual ~APapp();
protected:
// All instances are reported of terminating the application.
static bool TerminateApp_;
// Execution client, used to communicate with execution manager.
// ara::exec::ExecutionClient exec_client;
private:
// Global Initialization
void Initializing();
// Global preparation for running App
void Running();
// Global termination steps pre-requisites.
void Terminating();
// App-specific Initialization
virtual void InitializeApp() = 0;
// App specific main running Loop.
// Should respond to TerminateApp_ when becomes true.
virtual void RunningLoop() = 0;
// App specific termination, saving contexts and releasing.
virtual void TerminatingApp() = 0;
};
#ifndef _COLORS_H
#define _COLORS_H
#define START_COLOR_CLIENT "\033[33mTimeClient: \033[39m"
#define START_COLOR_SERVICE_20 "\033[95mTimeService: \033[39m"
#define START_COLOR_SERVICE_40 "\033[96mTimeService: \033[39m"
#define END_COLOR "\033[39m"
#define INSTANCE_COLOR_20 "\033[95m"
#define INSTANCE_COLOR_40 "\033[96m"
#endif
#include <iostream>
#include <cstdlib>
#include <csignal>
#include "../../common/inc/APapp.hpp"
#include "../../common/inc/colors.hpp"
using std::cout;
using std::endl;
// I have did this (non good) practice because the pipes or,
// any other method of communication is prohibitted in application level.
bool APapp::TerminateApp_ = false;
static void signalHandler(int signum)
{
APapp::Terminate();
//std::cout << "Signal handler called" << endl;
}
APapp::APapp()
{
};
APapp::~APapp()
{
};
void APapp::Terminate()
{
TerminateApp_ = true;
}
void APapp::Initializing()
{
// signal handler
//cout << "signal handler registering" << endl;
std::signal(SIGTERM, signalHandler);
//app initialize
InitializeApp();
};
void APapp::Running()
{
cout << END_COLOR << START_COLOR_CLIENT << "Report Running!!!" << endl;
//exec_client.ReportExecutionState(ara::exec::ExecutionState::kRunning);
// App loop, should contain the while condition depending on TerminateApp_.
RunningLoop();
};
void APapp::Terminating()
{
cout << START_COLOR_CLIENT << "Report Terminating" << endl;
//exec_client.ReportExecutionState(ara::exec::ExecutionState::kTerminating);
// App terminating
TerminatingApp();
cout << START_COLOR_CLIENT << "App terminated" << endl;
};
int APapp::Run()
{
try
{
Initializing();
Running();
Terminating();
return EXIT_SUCCESS;
}
catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
}
catch(...)
{
// General Error catch
}
return EXIT_FAILURE; // GENERAL ERROR
}
<launch>
<group ns="test_ns">
<node name="timeProxy" pkg="timeClient" type="timeClient"/>
</group>
</launch>
\ No newline at end of file
string skeleton_id
string proxy_id
bool data
\ No newline at end of file
string srv_ns
string current_state
string previous_state
\ No newline at end of file
string skeleton_id #service instance id
string event_id #To identify among different events that're offered by this service
string state #Unsubscribed, Pending, or Subscribed
string policy #Update criteria, kLatestN or kNewestN
uint32 cache_size # size of local cashe that'll be used for this event.
\ No newline at end of file
uint8 hours
uint8 minutes
uint8 seconds
\ No newline at end of file
<?xml version="1.0"?>
<package format="2">
<name>timeClient</name>
<version>0.0.0</version>
<description>The timeClient package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="ibrahim@todo.todo">ibrahim</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/timeClient</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
<!-- The *depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<!-- <depend>roscpp</depend> -->
<!-- Note that this is equivalent to the following: -->
<!-- <build_depend>roscpp</build_depend> -->
<!-- <exec_depend>roscpp</exec_depend> -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use build_export_depend for packages you need in order to build against this package: -->
<!-- <build_export_depend>message_generation</build_export_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use exec_depend for packages you need at runtime: -->
<!-- <exec_depend>message_runtime</exec_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>std_msgs</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
string srv_id
string srv_cmd
string method_id
---
uint8 hours
uint8 minutes
uint8 seconds
\ No newline at end of file
# --------------------------------------------------------------------------
# | _ _ _______ .----. _____ _____ |
# | /\ | | | |__ __| . ____ . / ____| /\ | __ \ |
# | / \ | | | | | | . / __ \ . | (___ / \ | |__) | |
# | / /\ \| | | | | | . / / / / v \___ \ / /\ \ | _ / |
# | / /__\ \ |__| | | | . / /_/ / . ____) / /__\ \| | \ \ |
# | /________\____/ |_| ^ \____/ . |_____/________\_| \_\ |
# | . _ _ . |
# --------------------------------------------------------------------------
#
# All Rights Reserved.
# Any use of this source code is subject to a license agreement with the
# AUTOSAR development cooperation.
# More information is available at www.autosar.org.
#
# Disclaimer
#
# This work (specification and/or software implementation) and the material
# contained in it, as released by AUTOSAR, is for the purpose of information
# only. AUTOSAR and the companies that have contributed to it shall not be
# liable for any use of the work.
#
# The material contained in this work is protected by copyright and other
# types of intellectual property rights. The commercial exploitation of the
# material contained in this work requires a license to such intellectual
# property rights.
#
# This work may be utilized or reproduced without any modification, in any
# form or by any means, for informational purposes only. For any other
# purpose, no part of the work may be utilized or reproduced, in any form
# or by any means, without permission in writing from the publisher.
#
# The work has been developed for automotive applications only. It has
# neither been developed, nor tested for non-automotive applications.
#
# The word AUTOSAR and the AUTOSAR logo are registered trademarks.
# --------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.5)
add_subdirectory(src)
#ifndef _WATCH_H
#define _WATCH_H
#include <ostream>
using std::ostream;
class CTime
{
public:
CTime(int hours=0, int minutes=0, int seconds=0);
void setTime(int hours=0, int minutes=0, int seconds=0);
friend ostream& operator<<(ostream &os, const CTime& obj);
private:
int _hours;
int _minutes;
int _seconds;
};
#endif // _WATCH_H
#include "../../common/inc/APapp.hpp"
#include "timeClient_activity.hpp"
class Watchapp : public APapp
{
public:
Watchapp();
~Watchapp();
private:
void InitializeApp() override;
void RunningLoop() override;
void TerminatingApp() override;
Timeactivity _timeClientActivity;
};