Skip to content

Commit

Permalink
Fix: Add event callback API (eclipse-ecal#420) and Call and CallAsync…
Browse files Browse the repository at this point in the history
… API (eclipse-ecal#372)

* add service event callbacks (fix for eclipse-ecal#420)
* add timeout parameter for service calls
* redesign of service API to support multiple service responses for a single service call
* redesign of service gate logic (separate gate added for client entities)
* clients registration layer added (clients can be visualized in eCALMon later in extra fix)
* service latency measurement samples added
* new service / client method "IsConnected" added
* service c implementation split in two separate header files (old header file deprecated)
* multiple new service unit gtests added to test new API

Co-authored-by: Aleksandar Brakmić <[email protected]>
  • Loading branch information
rex-schilasky and brakmic-aleksandar authored Jan 26, 2022
1 parent fe7ba1c commit 17f576b
Show file tree
Hide file tree
Showing 111 changed files with 4,331 additions and 1,635 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,7 @@ if(BUILD_ECAL_TESTS)
# ------------------------------------------------------
# test ecal
# ------------------------------------------------------
# TODO: check this for github actions (ubuntu) - send failed because of broken pipe
#add_subdirectory(testing/ecal/clientserver_test)
#add_subdirectory(testing/ecal/clientserver_test) THIS TEST IS NOT ABLE TO RUN ON GH ACTIONS
add_subdirectory(testing/ecal/core_test)
add_subdirectory(testing/ecal/event_test)
add_subdirectory(testing/ecal/expmap_test)
Expand Down
4 changes: 2 additions & 2 deletions app/rec/rec_server_cli/src/commands/activate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ namespace eCAL
return eCAL::rec::Error(eCAL::rec::Error::ErrorCode::TOO_MANY_PARAMETERS, EcalUtils::String::Join(" ", std::vector<std::string>(std::next(argv.begin()), argv.end())));

// Service call
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::rec_server::GenericRequest request_pb;
eCAL::pb::rec_server::ServiceResult response_pb;

bool success = remote_rec_server_service->Call(hostname, "Activate", request_pb, service_info, response_pb);
bool success = remote_rec_server_service->Call(hostname, "Activate", request_pb, service_response, response_pb);

// Service call failed
if (!success)
Expand Down
9 changes: 5 additions & 4 deletions app/rec/rec_server_cli/src/commands/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ namespace eCAL
{
eCAL::rec::Error Command::GetRemoteStatus(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, eCAL::rec_server::RecServerStatus& status_output)
{
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::rec_server::Status status_pb;
bool success = remote_rec_server_service->Call(hostname, "GetStatus", eCAL::pb::rec_server::GenericRequest(), service_info, status_pb);

bool success = remote_rec_server_service->Call(hostname, "GetStatus", eCAL::pb::rec_server::GenericRequest(), service_response, status_pb);

if (!success)
{
Expand All @@ -56,11 +57,11 @@ namespace eCAL
eCAL::rec::Error Command::GetRemoteConfig(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, eCAL::rec_server::RecServerConfig& config_output)
{
// Service call
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::rec_server::GenericRequest request_pb;
eCAL::pb::rec_server::RecServerConfig response_pb;

bool success = remote_rec_server_service->Call(hostname, "GetConfig", request_pb, service_info, response_pb);
bool success = remote_rec_server_service->Call(hostname, "GetConfig", request_pb, service_response, response_pb);

// Service call failed
if (!success)
Expand Down
5 changes: 3 additions & 2 deletions app/rec/rec_server_cli/src/commands/comment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,14 @@ namespace eCAL
}

// Service call
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::rec_server::AddCommentRequest request_pb;
eCAL::pb::rec_server::ServiceResult response_pb;

request_pb.set_meas_id(meas_id);
request_pb.set_comment(*comment);
bool success = remote_rec_server_service->Call(hostname, "AddComment", request_pb, service_info, response_pb);

bool success = remote_rec_server_service->Call(hostname, "AddComment", request_pb, service_response, response_pb);

// Service call failed
if (!success)
Expand Down
4 changes: 2 additions & 2 deletions app/rec/rec_server_cli/src/commands/deactivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ namespace eCAL
return eCAL::rec::Error::CURRENTLY_RECORDING;

// Service call
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::rec_server::GenericRequest request_pb;
eCAL::pb::rec_server::ServiceResult response_pb;

bool success = remote_rec_server_service->Call(hostname, "DeActivate", request_pb, service_info, response_pb);
bool success = remote_rec_server_service->Call(hostname, "DeActivate", request_pb, service_response, response_pb);

// Service call failed
if (!success)
Expand Down
8 changes: 4 additions & 4 deletions app/rec/rec_server_cli/src/commands/delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace eCAL

// (Try to) parse measurement ID
int64_t meas_id = 0;
if (argv.size() == 1)
// if (argv.size() == 1) this is always true
{
try
{
Expand All @@ -80,7 +80,7 @@ namespace eCAL

// (Try to) parse measurement ID
int64_t meas_id = 0;
if (argv.size() == 1)
// if (argv.size() == 1) this is always true
{
try
{
Expand Down Expand Up @@ -114,12 +114,12 @@ namespace eCAL
return eCAL::rec::Error(eCAL::rec::Error::ErrorCode::MEAS_ID_NOT_FOUND, std::to_string(meas_id));

// Service call
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::rec_server::GenericMeasurementRequest request_pb;
eCAL::pb::rec_server::ServiceResult response_pb;

request_pb.set_meas_id(meas_id);
bool success = remote_rec_server_service->Call(hostname, "DeleteMeasurement", request_pb, service_info, response_pb);
bool success = remote_rec_server_service->Call(hostname, "DeleteMeasurement", request_pb, service_response, response_pb);

// Service call failed
if (!success)
Expand Down
4 changes: 2 additions & 2 deletions app/rec/rec_server_cli/src/commands/load_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ namespace eCAL
return eCAL::rec::Error(eCAL::rec::Error::ErrorCode::CURRENTLY_RECORDING);

// Service call
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::rec_server::LoadConfigRequest request_pb;
eCAL::pb::rec_server::ServiceResult response_pb;

request_pb.set_config_path(argv[0]);

bool success = remote_rec_server_service->Call(hostname, "LoadConfigFile", request_pb, service_info, response_pb);
bool success = remote_rec_server_service->Call(hostname, "LoadConfigFile", request_pb, service_response, response_pb);

// Service call failed
if (!success)
Expand Down
4 changes: 2 additions & 2 deletions app/rec/rec_server_cli/src/commands/record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ namespace eCAL

// Start recording
{
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::rec_server::GenericRequest request_pb;
eCAL::pb::rec_server::JobStartedResponse response_pb;

bool success = remote_rec_server_service->Call(hostname, "StartRecording", request_pb, service_info, response_pb);
bool success = remote_rec_server_service->Call(hostname, "StartRecording", request_pb, service_response, response_pb);

// Service call failed
if (!success)
Expand Down
4 changes: 2 additions & 2 deletions app/rec/rec_server_cli/src/commands/save_pre_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ namespace eCAL
// TODO: Also check if pre-buffering was enabled (Currently not supported by the API)

// Service call
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::rec_server::GenericRequest request_pb;
eCAL::pb::rec_server::JobStartedResponse response_pb;

bool success = remote_rec_server_service->Call(hostname, "SaveBuffer", request_pb, service_info, response_pb);
bool success = remote_rec_server_service->Call(hostname, "SaveBuffer", request_pb, service_response, response_pb);

// Service call failed
if (!success)
Expand Down
4 changes: 2 additions & 2 deletions app/rec/rec_server_cli/src/commands/stop_recording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ namespace eCAL
return eCAL::rec::Error::NOT_RECORDING;

// Service call
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::rec_server::GenericRequest request_pb;
eCAL::pb::rec_server::ServiceResult response_pb;

bool success = remote_rec_server_service->Call(hostname, "StopRecording", request_pb, service_info, response_pb);
bool success = remote_rec_server_service->Call(hostname, "StopRecording", request_pb, service_response, response_pb);

// Service call failed
if (!success)
Expand Down
4 changes: 2 additions & 2 deletions app/rec/rec_server_cli/src/commands/upload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ namespace eCAL
}

// Service call
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::rec_server::GenericMeasurementRequest request_pb;
eCAL::pb::rec_server::ServiceResult response_pb;

request_pb.set_meas_id(meas_id);
bool success = remote_rec_server_service->Call(hostname, "UploadMeasurement", request_pb, service_info, response_pb);
bool success = remote_rec_server_service->Call(hostname, "UploadMeasurement", request_pb, service_response, response_pb);

// Service call failed
if (!success)
Expand Down
14 changes: 8 additions & 6 deletions app/rec/rec_server_core/src/recorder/remote_recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ namespace eCAL
if (this_loop_action.IsSettings())
{
auto set_config_pb = SettingsToSettingsPb(this_loop_action.settings_);
eCAL::SServiceInfo service_info;
eCAL::SServiceResponse service_response;
eCAL::pb::rec_client::Response response;

bool call_successfull = recorder_service_.Call(hostname_, "SetConfig", set_config_pb, service_info, response);
bool call_successfull = recorder_service_.Call(hostname_, "SetConfig", set_config_pb, service_response, response);
if (IsInterrupted()) return;

{
Expand Down Expand Up @@ -310,10 +310,10 @@ namespace eCAL

eCAL::pb::rec_client::CommandRequest command_request_pb = RecorderCommandToCommandPb(this_loop_action.command_);

eCAL::SServiceInfo service_info;
eCAL::SServiceResponse service_response;
eCAL::pb::rec_client::Response response_pb;

bool call_successfull = recorder_service_.Call(hostname_, "SetCommand", command_request_pb, service_info, response_pb);
bool call_successfull = recorder_service_.Call(hostname_, "SetCommand", command_request_pb, service_response, response_pb);

{
std::unique_lock<decltype(io_mutex_)> io_lock(io_mutex_);
Expand Down Expand Up @@ -371,12 +371,14 @@ namespace eCAL
{
eCAL::pb::rec_client::GetStateRequest request;

eCAL::SServiceInfo service_info;
eCAL::SServiceResponse service_response;
eCAL::pb::rec_client::State state_response_pb;

// Retrieve the state from the client
auto before_call_timestamp = eCAL::Time::ecal_clock::now();
bool call_success = recorder_service_.Call(hostname_, "GetState", request, service_info, state_response_pb);

bool call_success = recorder_service_.Call(hostname_, "GetState", request, service_response, state_response_pb);

auto after_call_timestamp = eCAL::Time::ecal_clock::now();
if (IsInterrupted()) return;

Expand Down
4 changes: 2 additions & 2 deletions app/sys/sys_cli/src/commands/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace eCAL
{
eCAL::sys::Error Command::GetRemoteSysStatus(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::sys::Service>>& remote_ecalsys_service, eCAL::pb::sys::State& state_output) const
{
SServiceInfo service_info;
bool success = remote_ecalsys_service->Call(hostname, "GetStatus", eCAL::pb::sys::GenericRequest(), service_info, state_output);
SServiceResponse service_response;
bool success = remote_ecalsys_service->Call(hostname, "GetStatus", eCAL::pb::sys::GenericRequest(), service_response, state_output);

if (!success)
{
Expand Down
6 changes: 3 additions & 3 deletions app/sys/sys_cli/src/commands/restart_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace eCAL

eCAL::sys::Error RestartTask::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::sys::Service>>& remote_ecalsys_service, const std::vector<std::string>& argv) const
{
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::sys::TaskRequest task_request_pb;
eCAL::pb::sys::Response response_pb;

Expand Down Expand Up @@ -122,7 +122,7 @@ namespace eCAL
}
}

bool success = remote_ecalsys_service->Call(hostname, "RestartTasks", task_request_pb, service_info, response_pb);
bool success = remote_ecalsys_service->Call(hostname, "RestartTasks", task_request_pb, service_response, response_pb);

if (!success)
{
Expand All @@ -132,7 +132,7 @@ namespace eCAL
{
if (response_pb.result() != eCAL::pb::sys::Response::success)
{
return eCAL::sys::Error(eCAL::sys::Error::ErrorCode::SERVICE_CALL_RETURNED_ERROR, service_info.host_name + ": " + response_pb.error());
return eCAL::sys::Error(eCAL::sys::Error::ErrorCode::SERVICE_CALL_RETURNED_ERROR, service_response.host_name + ": " + response_pb.error());
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions app/sys/sys_cli/src/commands/start_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace eCAL

eCAL::sys::Error StartTask::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::sys::Service>>& remote_ecalsys_service, const std::vector<std::string>& argv) const
{
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::sys::TaskRequest task_request_pb;
eCAL::pb::sys::Response response_pb;

Expand Down Expand Up @@ -122,7 +122,7 @@ namespace eCAL
}
}

bool success = remote_ecalsys_service->Call(hostname, "StartTasks", task_request_pb, service_info, response_pb);
bool success = remote_ecalsys_service->Call(hostname, "StartTasks", task_request_pb, service_response, response_pb);

if (!success)
{
Expand All @@ -132,7 +132,7 @@ namespace eCAL
{
if (response_pb.result() != eCAL::pb::sys::Response::success)
{
return eCAL::sys::Error(eCAL::sys::Error::ErrorCode::SERVICE_CALL_RETURNED_ERROR, service_info.host_name + ": " + response_pb.error());
return eCAL::sys::Error(eCAL::sys::Error::ErrorCode::SERVICE_CALL_RETURNED_ERROR, service_response.host_name + ": " + response_pb.error());
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions app/sys/sys_cli/src/commands/stop_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace eCAL

eCAL::sys::Error StopTask::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::sys::Service>>& remote_ecalsys_service, const std::vector<std::string>& argv) const
{
SServiceInfo service_info;
SServiceResponse service_response;
eCAL::pb::sys::TaskRequest task_request_pb;
eCAL::pb::sys::Response response_pb;

Expand Down Expand Up @@ -122,7 +122,7 @@ namespace eCAL
}
}

bool success = remote_ecalsys_service->Call(hostname, "StopTasks", task_request_pb, service_info, response_pb);
bool success = remote_ecalsys_service->Call(hostname, "StopTasks", task_request_pb, service_response, response_pb);

if (!success)
{
Expand All @@ -132,7 +132,7 @@ namespace eCAL
{
if (response_pb.result() != eCAL::pb::sys::Response::success)
{
return eCAL::sys::Error(eCAL::sys::Error::ErrorCode::SERVICE_CALL_RETURNED_ERROR, service_info.host_name + ": " + response_pb.error());
return eCAL::sys::Error(eCAL::sys::Error::ErrorCode::SERVICE_CALL_RETURNED_ERROR, service_response.host_name + ": " + response_pb.error());
}
else
{
Expand Down
12 changes: 6 additions & 6 deletions app/sys/sys_core/src/connection/remote_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ namespace eCAL

eCAL::pb::sys_client::StartTaskRequest start_task_request_pb = eCAL::sys_client::proto_helpers::ToProtobuf(evaluated_task_list);

eCAL::SServiceInfo service_info;
eCAL::SServiceResponse service_response;
eCAL::pb::sys_client::TaskResponse response_pb;

{
std::lock_guard<decltype(connection_mutex_)> connection_lock(connection_mutex_);
sys_client_service_.Call(m_hostname, "StartTasks", start_task_request_pb, service_info, response_pb);
sys_client_service_.Call(m_hostname, "StartTasks", start_task_request_pb, service_response, response_pb);
}

std::vector<int32_t> return_values;
Expand All @@ -59,12 +59,12 @@ namespace eCAL

eCAL::pb::sys_client::StopTaskRequest stop_task_request_pb = eCAL::sys_client::proto_helpers::ToProtobuf(evaluated_task_list);

eCAL::SServiceInfo service_info;
eCAL::SServiceResponse service_response;
eCAL::pb::sys_client::TaskResponse response_pb;

{
std::lock_guard<decltype(connection_mutex_)> connection_lock(connection_mutex_);
sys_client_service_.Call(m_hostname, "StopTasks", stop_task_request_pb, service_info, response_pb);
sys_client_service_.Call(m_hostname, "StopTasks", stop_task_request_pb, service_response, response_pb);
}

std::vector<bool> return_values;
Expand All @@ -90,12 +90,12 @@ namespace eCAL

eCAL::pb::sys_client::TaskList task_list_pb = eCAL::sys_client::proto_helpers::ToProtobuf(evaluated_task_list);

eCAL::SServiceInfo service_info;
eCAL::SServiceResponse service_response;
eCAL::pb::sys_client::MatchTaskResponse response_pb;

{
std::lock_guard<decltype(connection_mutex_)> connection_lock(connection_mutex_);
sys_client_service_.Call(m_hostname, "MatchTasks", task_list_pb, service_info, response_pb);
sys_client_service_.Call(m_hostname, "MatchTasks", task_list_pb, service_response, response_pb);
}

return eCAL::sys_client::proto_helpers::FromProtobuf(response_pb);
Expand Down
1 change: 1 addition & 0 deletions build_win/win_make_all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pushd %~dp0\..
call build_win\win_make_cmake.bat
call build_win\win_make_build.bat
call build_win\win_make_setup.bat
call build_win\win_make_python_wheel.bat

popd
2 changes: 1 addition & 1 deletion build_win/win_make_cmake.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ call build_win\win_set_vars.bat
echo Downloading NPCAP
powershell -Command "& '%~dp0\download_npcap.ps1'"

set "CMAKE_OPTIONS_COMPLETE=-DCMAKE_INSTALL_PREFIX=_install -DBUILD_ECAL_TESTS=ON -DECAL_THIRDPARTY_BUILD_GTEST=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_DOCS=ON -DECAL_NPCAP_SUPPORT=ON"
set "CMAKE_OPTIONS_COMPLETE=-DCMAKE_INSTALL_PREFIX=_install -DBUILD_PY_BINDING=ON -DBUILD_ECAL_TESTS=ON -DECAL_THIRDPARTY_BUILD_GTEST=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_DOCS=ON -DECAL_NPCAP_SUPPORT=ON"
set "CMAKE_OPTIONS_SDK=-DCMAKE_INSTALL_PREFIX=_install -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DBUILD_DOCS=OFF -DBUILD_APPS=OFF -DBUILD_SAMPLES=OFF -DBUILD_TIME=ON -DBUILD_PY_BINDING=OFF -DBUILD_CSHARP_BINDING=OFF -DBUILD_ECAL_TESTS=OFF -DECAL_LAYER_ICEORYX=OFF -DECAL_INCLUDE_PY_SAMPLES=OFF -DECAL_INSTALL_SAMPLE_SOURCES=OFF -DCPACK_PACK_WITH_INNOSETUP=OFF -DECAL_NPCAP_SUPPORT=ON"

if not exist "%BUILD_DIR_COMPLETE%" mkdir "%BUILD_DIR_COMPLETE%"
Expand Down
Loading

0 comments on commit 17f576b

Please sign in to comment.