Skip to content

Commit 4d67a9f

Browse files
[core] registration provider refactoring (#1647)
* Split logic for registration providers into different files.
1 parent a58f6af commit 4d67a9f

10 files changed

+511
-230
lines changed

ecal/core/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,22 @@ endif()
278278
######################################
279279
if (ECAL_CORE_REGISTRATION)
280280
set(ecal_registration_src
281+
src/registration/ecal_process_registration.cpp
282+
src/registration/ecal_process_registration.h
281283
src/registration/ecal_registration_provider.cpp
282284
src/registration/ecal_registration_provider.h
283285
src/registration/ecal_registration_receiver.cpp
284286
src/registration/ecal_registration_receiver.h
287+
src/registration/ecal_registration_sender.h
288+
src/registration/ecal_registration_sender_udp.cpp
289+
src/registration/ecal_registration_sender_udp.h
285290
)
286291
if(ECAL_CORE_REGISTRATION_SHM)
287292
list(APPEND ecal_registration_src
288293
src/registration/ecal_registration_receiver_shm.cpp
289294
src/registration/ecal_registration_receiver_shm.h
295+
src/registration/ecal_registration_sender_shm.cpp
296+
src/registration/ecal_registration_sender_shm.h
290297
src/registration/shm/ecal_memfile_broadcast.cpp
291298
src/registration/shm/ecal_memfile_broadcast.h
292299
src/registration/shm/ecal_memfile_broadcast_reader.cpp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/* ========================= eCAL LICENSE =================================
2+
*
3+
* Copyright (C) 2016 - 2024 Continental Corporation
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* ========================= eCAL LICENSE =================================
18+
*/
19+
20+
/**
21+
* @brief Functions to generate Process Registration / Unregistration samples.
22+
*
23+
**/
24+
25+
#include "ecal_process_registration.h"
26+
27+
#include <ecal/ecal_init.h>
28+
#include <ecal/ecal_process.h>
29+
#include "ecal_global_accessors.h"
30+
#include "ecal_globals.h"
31+
#include "time/ecal_timegate.h"
32+
33+
eCAL::Registration::Sample eCAL::Registration::GetProcessRegisterSample()
34+
{
35+
Registration::Sample process_sample;
36+
process_sample.cmd_type = bct_reg_process;
37+
auto& process_sample_process = process_sample.process;
38+
process_sample_process.hname = eCAL::Process::GetHostName();
39+
process_sample_process.hgname = eCAL::Process::GetHostGroupName();
40+
process_sample_process.pid = eCAL::Process::GetProcessID();
41+
process_sample_process.pname = eCAL::Process::GetProcessName();
42+
process_sample_process.uname = eCAL::Process::GetUnitName();
43+
process_sample_process.pparam = eCAL::Process::GetProcessParameter();
44+
process_sample_process.state.severity = static_cast<Registration::eProcessSeverity>(g_process_severity);
45+
process_sample_process.state.severity_level = static_cast<Registration::eProcessSeverityLevel>(g_process_severity_level);
46+
process_sample_process.state.info = g_process_info;
47+
#if ECAL_CORE_TIMEPLUGIN
48+
if (g_timegate() == nullptr)
49+
{
50+
process_sample_process.tsync_state = Registration::eTSyncState::tsync_none;
51+
}
52+
else
53+
{
54+
if (!g_timegate()->IsSynchronized())
55+
{
56+
process_sample_process.tsync_state = Registration::eTSyncState::tsync_none;
57+
}
58+
else
59+
{
60+
switch (g_timegate()->GetSyncMode())
61+
{
62+
case CTimeGate::eTimeSyncMode::realtime:
63+
process_sample_process.tsync_state = Registration::eTSyncState::tsync_realtime;
64+
break;
65+
case CTimeGate::eTimeSyncMode::replay:
66+
process_sample_process.tsync_state = Registration::eTSyncState::tsync_replay;
67+
break;
68+
default:
69+
process_sample_process.tsync_state = Registration::eTSyncState::tsync_none;
70+
break;
71+
}
72+
}
73+
process_sample_process.tsync_mod_name = g_timegate()->GetName();
74+
}
75+
#endif
76+
77+
// eCAL initialization state
78+
const unsigned int comp_state(g_globals()->GetComponents());
79+
process_sample_process.component_init_state = static_cast<int32_t>(comp_state);
80+
std::string component_info;
81+
if ((comp_state & eCAL::Init::Publisher) != 0u) component_info += "|pub";
82+
if ((comp_state & eCAL::Init::Subscriber) != 0u) component_info += "|sub";
83+
if ((comp_state & eCAL::Init::Logging) != 0u) component_info += "|log";
84+
if ((comp_state & eCAL::Init::TimeSync) != 0u) component_info += "|time";
85+
if (!component_info.empty()) component_info = component_info.substr(1);
86+
process_sample_process.component_init_info = component_info;
87+
88+
process_sample_process.ecal_runtime_version = eCAL::GetVersionString();
89+
90+
return process_sample;
91+
}
92+
93+
eCAL::Registration::Sample eCAL::Registration::GetProcessUnregisterSample()
94+
{
95+
Registration::Sample process_sample;
96+
process_sample.cmd_type = bct_unreg_process;
97+
auto& process_sample_process = process_sample.process;
98+
process_sample_process.hname = eCAL::Process::GetHostName();
99+
process_sample_process.pid = eCAL::Process::GetProcessID();
100+
process_sample_process.pname = eCAL::Process::GetProcessName();
101+
process_sample_process.uname = eCAL::Process::GetUnitName();
102+
103+
return process_sample;
104+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* ========================= eCAL LICENSE =================================
2+
*
3+
* Copyright (C) 2016 - 2024 Continental Corporation
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* ========================= eCAL LICENSE =================================
18+
*/
19+
20+
/**
21+
* @brief Functions to generate Process Registration / Unregistration samples.
22+
*
23+
**/
24+
25+
#pragma once
26+
27+
#include "serialization/ecal_struct_sample_registration.h"
28+
29+
namespace eCAL
30+
{
31+
namespace Registration
32+
{
33+
Sample GetProcessRegisterSample();
34+
35+
Sample GetProcessUnregisterSample();
36+
}
37+
}

0 commit comments

Comments
 (0)