Skip to content

Commit

Permalink
Merge branch 'master' of github.com:eclipse-ecal/ecal into feature/pu…
Browse files Browse the repository at this point in the history
…bsub_sattr_configuration_0
  • Loading branch information
Peguen committed Oct 14, 2024
2 parents 112b98b + 51ed6f0 commit be55606
Show file tree
Hide file tree
Showing 81 changed files with 341 additions and 215 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -508,7 +508,7 @@ void EcalmonTreeWidget::loadGuiSettings(const QString& group)

QVector<int> group_by_columns;
int auto_expand = 0;
for (auto column_variant : settings.value("group_by_columns").toList())
for (const auto& column_variant : settings.value("group_by_columns").toList())
{
int column = column_variant.toInt();
if ((column >= 0) && (column < group_tree_model_->columnCount()))
Expand Down
5 changes: 3 additions & 2 deletions app/mon/mon_gui/src/widgets/models/host_tree_item.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -167,8 +167,9 @@ void HostTreeItem::update(const eCAL::pb::Monitoring& monitoring_pb)
data_received_bytes_ = 0;

// Fill variables with accumulated data
for (auto topic : monitoring_pb.topics())
for (int i = 0; i <monitoring_pb.topics_size(); ++i)
{
const auto& topic = monitoring_pb.topics(i);
if (QString(topic.hname().c_str()).compare(host_name_, Qt::CaseSensitivity::CaseInsensitive) == 0)
{
QString direction = topic.direction().c_str();
Expand Down
36 changes: 2 additions & 34 deletions app/mon/mon_gui/src/widgets/models/topic_tree_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,43 +82,11 @@ QVariant TopicTreeItem::data(Columns column, Qt::ItemDataRole role) const
}
else if (column == Columns::TENCODING)
{
// When the monitor didn't tell us the topic encoding, we ask eCAL::Util instead
// Why this logic only for type, not descriptor? (and thus encoding?)
const std::string monitor_topic_encoding = topic_.tdatatype().encoding();
if (!monitor_topic_encoding.empty())
{
return monitor_topic_encoding.c_str();
}
else
{
const std::string monitor_topic_name = topic_.tname();
if (!monitor_topic_name.empty())
{
eCAL::SDataTypeInformation topic_info;
eCAL::Registration::GetTopicDataTypeInformation(monitor_topic_name, topic_info);
return topic_info.encoding.c_str();
}
}
return topic_.tdatatype().encoding().c_str();
}
else if (column == Columns::TTYPE)
{
// When the monitor didn't tell us the topic type, we ask eCAL::Util instead
// Why this logic only for type, not descriptor? (and thus encoding?)
const std::string monitor_topic_type = topic_.tdatatype().name();
if (!monitor_topic_type.empty())
{
return monitor_topic_type.c_str();
}
else
{
const std::string monitor_topic_name = topic_.tname();
if (!monitor_topic_name.empty())
{
eCAL::SDataTypeInformation topic_info;
eCAL::Registration::GetTopicDataTypeInformation(monitor_topic_name, topic_info);
return topic_info.name.c_str();
}
}
return topic_.tdatatype().name().c_str();
}
else if (column == Columns::TDESC)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -221,6 +221,6 @@ void VisualisationWidget::checkForMorePublishersWithSameTopic(const eCAL::pb::Mo
}
}
ui_.textEdit->clear();
for (auto publisher : publishers)
for (const auto& publisher : publishers)
ui_.textEdit->append(publisher);
}
1 change: 1 addition & 0 deletions build_win/nanopb/compile-nanopb.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python compile-nanopb.py --nano_pb_path c:\nanopb\nanopb-0.4.9 --ecal_repository "..\.."
112 changes: 112 additions & 0 deletions build_win/nanopb/compile-nanopb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import sys
import re
import subprocess
import logging
from pathlib import Path
import shutil
import argparse

def setup_logging():
"""Sets up the logging configuration."""
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')


def list_files(directory: Path, extension: str) -> list[Path]:
"""Returns a list of files with specific extension in the given directory."""
if not directory.exists():
logging.error(f"Directory {directory} does not exist.")
return []
return list(directory.glob(f"*{extension}"))


def copy_files(source_dir: Path, target_dir: Path, file_types: list[str]):
"""Copies files of specific types from source to target directory."""
target_dir.mkdir(parents=True, exist_ok=True)
for file_type in file_types:
for file in source_dir.glob(file_type):
try:
shutil.copy2(file, target_dir)
logging.info(f"Copied {file.name} to {target_dir}")
except Exception as e:
logging.error(f"Error copying {file.name} to {target_dir}: {e}")


def check_nanopb_compiler_exists(compiler_path: Path):
"""Checks if the nanopb_generator exists."""
if not compiler_path.exists():
logging.error(f"nanopb generator not found at {compiler_path}")
sys.exit(1)


def run_nanopb_generator(proto_files: list[Path], compiler: Path, ecal_pb_base_path: Path, ecal_pb_sub_path: Path, target_dir: Path):
"""Runs the nanopb generator for each proto file."""
for proto_file_path in proto_files:
proto_file_name = proto_file_path.name

command = [
str(compiler),
"-I" + str(ecal_pb_base_path),
"-I" + str(ecal_pb_base_path / ecal_pb_sub_path),
"-D" + str(target_dir / ecal_pb_sub_path),
"-e" + ".npb",
proto_file_name
]

logging.info(f"Running: {' '.join(command)}")

try:
result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, cwd=proto_file_path.parent)
logging.info(f"Success: {proto_file_name} processed.")
logging.debug(result.stdout)
except subprocess.CalledProcessError as e:
logging.error(f"Error running nanopb_generator for {proto_file_name}: {e.stderr}")


def main(nano_pb_path: Path, ecal_repository: Path):
setup_logging()

# Define paths based on the provided arguments
ecal_pb_base_path = Path(ecal_repository / "ecal/core_pb/src")
ecal_pb_sub_path = Path("ecal/core/pb")
ecal_target_path = Path("../../core/src/serialization/nanopb")

# Combine paths and list .proto files
proto_files_dir = ecal_pb_base_path / ecal_pb_sub_path
ecal_pb_files = list_files(proto_files_dir, ".proto")

# Check if nanopb generator exists
nano_pb_compiler = nano_pb_path / "generator-bin/nanopb_generator.exe"
check_nanopb_compiler_exists(nano_pb_compiler)

# Check if any .proto files are found
if not ecal_pb_files:
logging.error(f"No .proto files found in {proto_files_dir}")
sys.exit(1)

# Prepare target directory
absolute_target_path = (ecal_pb_base_path / ecal_target_path).resolve()
absolute_target_path.mkdir(parents=True, exist_ok=True)

# Copy nanopb common decoder and encoder to target nanopb directory
target_nanopb_dir = absolute_target_path
copy_files(nano_pb_path, target_nanopb_dir, ["*.c", "*.h"])

# Run nanopb_generator for each .proto file
run_nanopb_generator(ecal_pb_files, nano_pb_compiler, ecal_pb_base_path, ecal_pb_sub_path, absolute_target_path)


if __name__ == "__main__":
# Set up argument parsing
parser = argparse.ArgumentParser(description="Process nanopb and eCAL protobuf files.")
parser.add_argument("--nano_pb_path", type=Path, required=True, help="Path to the nanopb directory")
parser.add_argument("--ecal_repository", type=Path, required=True, help="Path to the eCAL repository")

# Parse the arguments
args = parser.parse_args()

# Resolve paths to absolute paths to support relative paths
nano_pb_path = Path(args.nano_pb_path).resolve()
ecal_repository = Path(args.ecal_repository).resolve()

# Call the main function with resolved absolute paths
main(nano_pb_path, ecal_repository)
62 changes: 31 additions & 31 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,29 +329,29 @@ endif()
# serialization
######################################
set(ecal_serialization_src
src/serialization/nanopb/nanopb/pb.h
src/serialization/nanopb/nanopb/pb_common.c
src/serialization/nanopb/nanopb/pb_common.h
src/serialization/nanopb/nanopb/pb_decode.c
src/serialization/nanopb/nanopb/pb_decode.h
src/serialization/nanopb/nanopb/pb_encode.c
src/serialization/nanopb/nanopb/pb_encode.h
src/serialization/nanopb/ecal.pb.c
src/serialization/nanopb/ecal.pb.h
src/serialization/nanopb/host.pb.c
src/serialization/nanopb/host.pb.h
src/serialization/nanopb/layer.pb.c
src/serialization/nanopb/layer.pb.h
src/serialization/nanopb/logging.pb.c
src/serialization/nanopb/logging.pb.h
src/serialization/nanopb/monitoring.pb.c
src/serialization/nanopb/monitoring.pb.h
src/serialization/nanopb/process.pb.c
src/serialization/nanopb/process.pb.h
src/serialization/nanopb/service.pb.c
src/serialization/nanopb/service.pb.h
src/serialization/nanopb/topic.pb.c
src/serialization/nanopb/topic.pb.h
src/serialization/nanopb/pb.h
src/serialization/nanopb/pb_common.c
src/serialization/nanopb/pb_common.h
src/serialization/nanopb/pb_decode.c
src/serialization/nanopb/pb_decode.h
src/serialization/nanopb/pb_encode.c
src/serialization/nanopb/pb_encode.h
src/serialization/nanopb/ecal/core/pb/ecal.npb.c
src/serialization/nanopb/ecal/core/pb/ecal.npb.h
src/serialization/nanopb/ecal/core/pb/host.npb.c
src/serialization/nanopb/ecal/core/pb/host.npb.h
src/serialization/nanopb/ecal/core/pb/layer.npb.c
src/serialization/nanopb/ecal/core/pb/layer.npb.h
src/serialization/nanopb/ecal/core/pb/logging.npb.c
src/serialization/nanopb/ecal/core/pb/logging.npb.h
src/serialization/nanopb/ecal/core/pb/monitoring.npb.c
src/serialization/nanopb/ecal/core/pb/monitoring.npb.h
src/serialization/nanopb/ecal/core/pb/process.npb.c
src/serialization/nanopb/ecal/core/pb/process.npb.h
src/serialization/nanopb/ecal/core/pb/service.npb.c
src/serialization/nanopb/ecal/core/pb/service.npb.h
src/serialization/nanopb/ecal/core/pb/topic.npb.c
src/serialization/nanopb/ecal/core/pb/topic.npb.h
src/serialization/ecal_serialize_common.cpp
src/serialization/ecal_serialize_common.h
src/serialization/ecal_serialize_logging.cpp
Expand Down Expand Up @@ -451,20 +451,20 @@ endif()
# builder
######################################
set (ecal_builder_src
src/builder/logging_attribute_builder.cpp
src/builder/monitoring_attribute_builder.cpp
src/builder/registration_attribute_builder.cpp
src/logging/builder/udp_attribute_builder.cpp
src/config/builder/logging_attribute_builder.cpp
src/config/builder/monitoring_attribute_builder.cpp
src/config/builder/registration_attribute_builder.cpp
src/logging/config/builder/udp_attribute_builder.cpp
src/pubsub/config/builder/reader_attribute_builder.cpp
src/pubsub/config/builder/writer_attribute_builder.cpp
src/readwrite/config/builder/shm_attribute_builder.cpp
src/readwrite/config/builder/tcp_attribute_builder.cpp
src/readwrite/config/builder/udp_attribute_builder.cpp
src/readwrite/tcp/config/builder/data_reader_tcp_attribute_builder.cpp
src/readwrite/udp/config/builder/udp_attribute_builder.cpp
src/registration/builder/udp_shm_attribute_builder.cpp
src/registration/builder/sample_applier_attribute_builder.cpp
src/registration/udp/builder/udp_attribute_builder.cpp
src/registration/config/builder/udp_shm_attribute_builder.cpp
src/registration/config/builder/sample_applier_attribute_builder.cpp
src/registration/udp/config/builder/udp_attribute_builder.cpp
)


Expand Down Expand Up @@ -706,8 +706,8 @@ target_link_libraries(${PROJECT_NAME}
target_include_directories(${PROJECT_NAME}
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/serialization/>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/serialization/nanopb>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/serialization/nanopb/nanopb>
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

#include "logging/attributes/logging_attributes.h"
#include "logging/config/attributes/logging_attributes.h"
#include "ecal/config/logging.h"
#include "ecal/config/registration.h"
#include "ecal/config/transport_layer.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

#include "monitoring/attributes/monitoring_attributes.h"
#include "monitoring/config/attributes/monitoring_attributes.h"

#include <ecal/config/monitoring.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

#include "registration/attributes/registration_attributes.h"
#include "registration/config/attributes/registration_attributes.h"

#include <ecal/ecal_config.h>

Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/ecal_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
#include "service/ecal_service_singleton_manager.h"
#endif

#include "builder/registration_attribute_builder.h"
#include "builder/monitoring_attribute_builder.h"
#include "builder/logging_attribute_builder.h"
#include "config/builder/registration_attribute_builder.h"
#include "config/builder/monitoring_attribute_builder.h"
#include "config/builder/logging_attribute_builder.h"

namespace eCAL
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "io/udp/ecal_udp_receiver_attr.h"
#include "io/udp/ecal_udp_sender_attr.h"

#include "logging/attributes/logging_attributes.h"
#include "logging/config/attributes/logging_attributes.h"

namespace eCAL
{
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/logging/ecal_log_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "ecal_log_impl.h"
#include "serialization/ecal_serialize_logging.h"
#include "builder/udp_attribute_builder.h"
#include "config/builder/udp_attribute_builder.h"
#include <mutex>
#include <cstdio>

Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/logging/ecal_log_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <ecal/ecal_log_level.h>
#include <ecal/types/logging.h>

#include "attributes/logging_attributes.h"
#include "config/attributes/logging_attributes.h"
#include "ecal_global_accessors.h"

#include <atomic>
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/monitoring/ecal_monitoring_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include <ecal/types/monitoring.h>

#include "attributes/monitoring_attributes.h"
#include "config/attributes/monitoring_attributes.h"

#include <memory>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/monitoring/ecal_monitoring_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <string>
#include <vector>

#include "monitoring/attributes/monitoring_attributes.h"
#include "monitoring/config/attributes/monitoring_attributes.h"

namespace eCAL
{
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/monitoring/ecal_monitoring_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <ecal/types/monitoring.h>

#include "ecal_def.h"
#include "monitoring/attributes/monitoring_attributes.h"
#include "monitoring/config/attributes/monitoring_attributes.h"
#include "monitoring/ecal_monitoring_filter.h"

#include "serialization/ecal_serialize_sample_registration.h"
Expand Down
Loading

0 comments on commit be55606

Please sign in to comment.