-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from eclipse-ecal/samples-alignment
samples aligned with eclipse-ecal
- Loading branch information
Showing
20 changed files
with
890 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2019 Continental Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ========================= eCAL LICENSE ================================= | ||
|
||
cmake_minimum_required(VERSION 3.10) | ||
|
||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) | ||
|
||
project(process) | ||
|
||
find_package(eCAL REQUIRED) | ||
|
||
set(process_src | ||
src/process.cpp | ||
) | ||
|
||
ecal_add_sample(${PROJECT_NAME} ${process_src}) | ||
|
||
target_include_directories(${PROJECT_NAME} PRIVATE .) | ||
|
||
target_link_libraries (${PROJECT_NAME} | ||
eCAL::core | ||
) | ||
|
||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) | ||
|
||
ecal_install_sample(${PROJECT_NAME}) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER samples/cpp/misc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2019 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
#include <ecal/ecal.h> | ||
|
||
#ifdef ECAL_OS_WINDOWS | ||
const char* proc_name = "notepad.exe"; | ||
#else // ECAL_OS_WINDOWS | ||
const char* proc_name = "gedit"; | ||
#endif // ECAL_OS_WINDOWS | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
// initialize eCAL API | ||
eCAL::Initialize(argc, argv, "process", eCAL::Init::None); | ||
|
||
// start process | ||
eCAL::Process::StartProcess(proc_name, "", "", false, proc_smode_normal, false); | ||
|
||
// sleep 2 seconds | ||
eCAL::Process::SleepMS(2000); | ||
|
||
// stop process | ||
eCAL::Process::StopProcess(proc_name); | ||
|
||
// sleep 2 seconds | ||
eCAL::Process::SleepMS(2000); | ||
|
||
// start process | ||
int pid = eCAL::Process::StartProcess(proc_name, "", "", false, proc_smode_normal, false); | ||
|
||
// sleep 2 seconds | ||
eCAL::Process::SleepMS(2000); | ||
|
||
// stop notepad | ||
eCAL::Process::StopProcess(pid); | ||
|
||
// finalize eCAL API | ||
eCAL::Finalize(); | ||
|
||
return(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2019 Continental Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ========================= eCAL LICENSE ================================= | ||
|
||
cmake_minimum_required(VERSION 3.10) | ||
|
||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) | ||
|
||
project(time) | ||
|
||
find_package(eCAL REQUIRED) | ||
|
||
set(time_src | ||
src/time.cpp | ||
) | ||
|
||
ecal_add_sample(${PROJECT_NAME} ${time_src}) | ||
|
||
target_link_libraries(${PROJECT_NAME} eCAL::core) | ||
|
||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) | ||
|
||
ecal_install_sample(${PROJECT_NAME}) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER samples/cpp/misc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2019 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
#include <ecal/ecal.h> | ||
#include <iostream> | ||
#include <chrono> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
// initialize eCAL API | ||
eCAL::Initialize(argc, argv, "timer"); | ||
|
||
std::cout << "eCAL Time Interface : " << eCAL::Time::GetName() << std::endl; | ||
std::cout << "eCAL Time is Synchronized : " << eCAL::Time::IsSynchronized() << std::endl; | ||
std::cout << "eCAL Time is Master : " << eCAL::Time::IsMaster() << std::endl; | ||
std::cout << std::endl; | ||
eCAL::Process::SleepMS(3000); | ||
|
||
while(eCAL::Ok()) | ||
{ | ||
auto now = eCAL::Time::ecal_clock::now(); | ||
std::cout << "eCAL Time " << std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count() << " ms" << std::endl; | ||
eCAL::Process::SleepMS(100); | ||
} | ||
|
||
// finalize eCAL API | ||
eCAL::Finalize(); | ||
|
||
return(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2019 Continental Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ========================= eCAL LICENSE ================================= | ||
|
||
cmake_minimum_required(VERSION 3.10) | ||
|
||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) | ||
|
||
project(timer) | ||
|
||
find_package(eCAL REQUIRED) | ||
|
||
set(timer_src | ||
src/timer.cpp | ||
) | ||
|
||
ecal_add_sample(${PROJECT_NAME} ${timer_src}) | ||
|
||
target_link_libraries(${PROJECT_NAME} eCAL::core) | ||
|
||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) | ||
|
||
ecal_install_sample(${PROJECT_NAME}) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER samples/cpp/misc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2019 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
#include <ecal/ecal.h> | ||
#include <ecal/msg/string/publisher.h> | ||
|
||
#include <iostream> | ||
#include <functional> | ||
|
||
const int timout_ms = 10; | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
// initialize eCAL API | ||
eCAL::Initialize(argc, argv, "person publisher"); | ||
// set process state | ||
eCAL::Process::SetState(proc_sev_healthy, proc_sev_level1, "I feel good !"); | ||
|
||
eCAL::string::CPublisher<std::string> pub("hello"); | ||
eCAL::CTimer timer; | ||
|
||
timer.Start(timout_ms, [&pub](){ | ||
pub.Send("Hello world"); | ||
std::cout << "Sent: Hello world" << std::endl; | ||
}); | ||
|
||
// enter main loop | ||
while(eCAL::Ok()) | ||
{ | ||
// sleep 500 ms | ||
eCAL::Process::SleepMS(500); | ||
} | ||
|
||
timer.Stop(); | ||
// finalize eCAL API | ||
eCAL::Finalize(); | ||
|
||
return(0); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2022 Eclipse Foundation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ========================= eCAL LICENSE ================================= | ||
|
||
cmake_minimum_required(VERSION 3.10) | ||
|
||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) | ||
|
||
project(component1) | ||
|
||
find_package(eCAL REQUIRED) | ||
find_package(Protobuf REQUIRED) | ||
|
||
set(component1_src | ||
src/component1.cpp | ||
) | ||
|
||
set(component1_proto | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/component.proto | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/orchestrator.proto | ||
) | ||
ecal_add_sample(${PROJECT_NAME} ${component1_src}) | ||
PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${component1_proto}) | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
eCAL::core | ||
protobuf::libprotobuf | ||
) | ||
|
||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) | ||
|
||
ecal_install_sample(${PROJECT_NAME}) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER samples/cpp/orchestration) |
Oops, something went wrong.