Skip to content

Commit

Permalink
Merge pull request #2660 from GMLC-TDC/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
phlptp authored Jul 9, 2024
2 parents 4e1c24e + 60644d4 commit 8f64719
Show file tree
Hide file tree
Showing 19 changed files with 254 additions and 85 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Checks: "
misc-*,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
-misc-use-anonymous-namespace,
cert-*,
-cert-err58-cpp,
portability-*,
Expand Down Expand Up @@ -67,6 +68,8 @@ WarningsAsErrors: "
misc-*,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
-misc-include-cleaner,
-misc-use-anonymous-namespace,
cert-*,
-cert-err58-cpp,
portability-*,
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
- id: dockerfile_lint
args: [--rulefile, ./config/Docker/docker_rules.yml, --dockerfile]
- repo: https://github.com/psf/black
rev: 24.3.0
rev: 24.4.2
hooks:
- id: black
args: ["--line-length=100"]
Expand All @@ -22,7 +22,7 @@ repos:
hooks:
- id: remove-tabs
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: mixed-line-ending
Expand Down Expand Up @@ -74,7 +74,7 @@ repos:
"--exclude-file=./config/spelling_ignorelines.txt",
]
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.2
rev: v18.1.5
hooks:
- id: clang-format
types:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
A note on future revisions.
Everything within a major version number should be code compatible (with the exception of experimental interfaces). The most notable example of an experimental interface is the support for multiple source inputs. The APIs to deal with this will change in future minor releases. Everything within a single minor release should be network compatible with other federates on the same minor release number. Compatibility across minor release numbers may be possible in some situations but we are not going to guarantee this as those components are subject to performance improvements and may need to be modified at some point. Patch releases will be limited to bug fixes and other improvements not impacting the public API or network compatibility. Check the [Public API](./docs/Public_API.md) for details on what is included and excluded from the public API and version stability.

## [3.5.3][] - 2024-07-08

Patch release with fixes for potential interface definitions and some compiler warnings

### Fixed

- Fixed some compiler warnings on the connector

### Added

- Added support for "potential_interface_templates" object in json configuration
- Added support for arrays of tags
- Added support for "fields" object in potential interface template definitions

## [3.5.2][] - 2024-04-08

Patch release with fixes for certain compiler builds, a fix to the test core leading to some sporadic test failures, and fixing a discrepancy in the handing of config files with the helics_apps.
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE AND NOT HELICS_D
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
endif()

project(HELICS VERSION 3.5.2)
project(HELICS VERSION 3.5.3)

# -----------------------------------------------------------------------------
# HELICS Version number
# -----------------------------------------------------------------------------
set(HELICS_VERSION_BUILD)
# use ISO date YYYY-MM-DD
set(HELICS_DATE "2024-04-08")
set(HELICS_DATE "2024-07-08")

set(HELICS_VERSION_UNDERSCORE
"${HELICS_VERSION_MAJOR}_${HELICS_VERSION_MINOR}_${HELICS_VERSION_PATCH}"
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ branches:
- main
- develop

version: 3.5.2.{build}
version: 3.5.3.{build}

image: Visual Studio 2019

Expand Down
1 change: 0 additions & 1 deletion docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ This document contains tentative plans for changes and improvements of note in u
- Some sort of rollback operations
- Remote procedure call type of federate
- Plugin architecture for user defined cores
- Separate octave interface
- Enable mesh networking in HELICS
3 changes: 3 additions & 0 deletions docs/developer-guide/typeConversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ There are defined conversions from all known available types to all others.
- BOOL -> (val!=0)?"1":"0"

[^1]: conversion to double is lossless only if the value actually fits in a double mantissa value.

[^2]: for a named point conversion, if the value doesn't fit in double the string translation is placed in the string field and a NaN value in the value segment to ensure no data loss.

### Conversion from String
Expand Down Expand Up @@ -155,7 +156,9 @@ Similar to getDoubleFromString in conversion of vectors. It will convert most re
- BOOL -> (vectorNorm(val)!=0)?"1":"0"

[^3]: vectorNorm is the sqrt of the inner product of the vector.

[^4]: vectorString is comma-separated string of the numerical values enclosed in `[]`, for example `[45.7,22.7,17.8]`. This is a JSON compatible string format.

[^5]: if the vector is a single element the NAMED_POINT translation is equivalent to a double translation.

### Conversion from Complex Vector
Expand Down
8 changes: 5 additions & 3 deletions src/helics/application_api/Federate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ Federate::~Federate()
// LCOV_EXCL_START
catch (...) // do not allow a throw inside the destructor
{
// finalize may throw but we can't allow that
;
}
// LCOV_EXCL_STOP
}
Expand Down Expand Up @@ -1542,7 +1544,7 @@ void Federate::registerConnectorInterfacesJsonDetail(Json::Value& json)
registerConnectorInterfacesJsonDetail(json["helics"]);
}

if (json.isMember("potential_interfaces")) {
if (json.isMember("potential_interfaces") || json.isMember("potential_interface_templates")) {
if (!potManager) {
potManager = std::make_unique<PotentialInterfacesManager>(coreObject.get(), this);
}
Expand Down Expand Up @@ -2060,9 +2062,9 @@ void Federate::logMessage(int level, std::string_view message) const
if (coreObject) {
coreObject->logMessage(fedID, level, message);
} else if (level <= HELICS_LOG_LEVEL_WARNING) {
std::cerr << message << std::endl;
std::cerr << message << '\n';
} else {
std::cout << message << std::endl;
std::cout << message << '\n';
}
}

Expand Down
71 changes: 46 additions & 25 deletions src/helics/application_api/PotentialInterfacesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,55 @@ void PotentialInterfacesManager::loadPotentialInterfaces(Json::Value& json)
{
static const std::set<std::string> interfaceTypes{
"publications", "inputs", "endpoints", "filters", "translators", "datasinks"};
if (!json.isMember("potential_interfaces")) {
return;
}
const auto& interfaces = json["potential_interfaces"];
for (const auto& itype : interfaceTypes) {
if (interfaces.isMember(itype)) {
auto tInterface = interfaces[itype];
auto& pMap = potInterfaces[itype];
for (auto& ispec : tInterface) {
auto name = fileops::getName(ispec);
pMap[name] = ispec;
if (json.isMember("potential_interfaces")) {
const auto& interfaces = json["potential_interfaces"];
for (const auto& itype : interfaceTypes) {
if (interfaces.isMember(itype)) {
auto tInterface = interfaces[itype];
auto& pMap = potInterfaces[itype];
for (auto& ispec : tInterface) {
auto name = fileops::getName(ispec);
pMap[name] = ispec;
}
}
std::string tempString = itype;
tempString.pop_back();
tempString += "_templates";
if (interfaces.isMember(tempString)) {
auto templateInterfaces = interfaces[tempString];
auto& tMap = potInterfaceTemplates[itype];
for (auto& tspec : templateInterfaces) {
auto name = fileops::getName(tspec);
if (name.find("}${") != std::string::npos) {
throw(helics::InvalidParameter(
std::string(
"template key definitions must not be adjacent, they must have separator characters [") +
name + ']'));
}
tMap[name] = tspec;
}
}
}
std::string tempString = itype;
tempString.pop_back();
tempString += "_templates";
if (interfaces.isMember(tempString)) {
auto templateInterfaces = interfaces[tempString];
auto& tMap = potInterfaceTemplates[itype];
for (auto& tspec : templateInterfaces) {
auto name = fileops::getName(tspec);
if (name.find("}${") != std::string::npos) {
throw(helics::InvalidParameter(
std::string(
"template key definitions must not be adjacent, they must have separator characters [") +
name + ']'));
}
if (json.isMember("potential_interface_templates")) {
const auto& interfaces = json["potential_interface_templates"];
for (const auto& itype : interfaceTypes) {
std::string tempString = itype;
tempString.pop_back();
tempString += "_templates";
if (interfaces.isMember(tempString)) {
auto templateInterfaces = interfaces[tempString];
auto& tMap = potInterfaceTemplates[itype];
for (auto& tspec : templateInterfaces) {
auto name = fileops::getName(tspec);
if (name.find("}${") != std::string::npos) {
throw(helics::InvalidParameter(
std::string(
"template key definitions must not be adjacent, they must have separator characters [") +
name + ']'));
}
tMap[name] = tspec;
}
tMap[name] = tspec;
}
}
}
Expand Down
31 changes: 21 additions & 10 deletions src/helics/apps/Connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ SPDX-License-Identifier: BSD-3-Clause
#include <optional>
#include <regex>
#include <set>
#include <string_view>
#include <tuple>
#include <type_traits>
#include <unordered_map>
Expand Down Expand Up @@ -119,13 +120,20 @@ bool TemplateMatcher::loadTemplate(const Json::Value& iTemplate)
intermediaries.push_back(templateName.substr(0, tnameIndex));
}
std::vector<std::string> valueNames;
int index{0};
std::size_t index{0};
while (tnameIndex != std::string::npos) {
auto close = templateName.find_first_of('}', tnameIndex);
const std::string tname = templateName.substr(tnameIndex + 2, close - tnameIndex - 2);
if (!iTemplate.isMember(tname)) {
return false;
if (iTemplate.isMember("fields")) {
if (!iTemplate["fields"].isMember(tname)) {
return false;
}
} else {
if (!iTemplate.isMember(tname)) {
return false;
}
}

valueNames.push_back(tname);

tnameIndex = templateName.find("${", close + 1);
Expand All @@ -143,8 +151,10 @@ bool TemplateMatcher::loadTemplate(const Json::Value& iTemplate)

templatePossibilities.resize(valueNames.size());
keys.resize(valueNames.size());
const Json::Value& fieldRoot = (iTemplate.isMember("fields")) ? iTemplate["fields"] : iTemplate;

for (index = 0; index < valueNames.size(); ++index) {
for (const auto& val : iTemplate[valueNames[index]]) {
for (const auto& val : fieldRoot[valueNames[index]]) {
std::pair<std::string, std::string> typeAndUnits;
std::string_view keyval;
if (val.isArray()) {
Expand All @@ -167,6 +177,7 @@ bool TemplateMatcher::loadTemplate(const Json::Value& iTemplate)
templatePossibilities[index].emplace(keyval, typeAndUnits);
}
}

initialize();
return true;
}
Expand Down Expand Up @@ -594,15 +605,15 @@ Connector::Connector(std::string_view appName, const FederateInfo& fedInfo):
}

Connector::Connector(std::string_view appName,
const std::shared_ptr<Core>& core,
const std::shared_ptr<Core>& coreObj,
const FederateInfo& fedInfo):
App(appName, core, fedInfo), core((fed) ? fed->getCorePointer() : nullptr)
App(appName, coreObj, fedInfo), core((fed) ? fed->getCorePointer() : nullptr)
{
initialSetup();
}

Connector::Connector(std::string_view appName, CoreApp& core, const FederateInfo& fedInfo):
App(appName, core, fedInfo), core((fed) ? fed->getCorePointer() : nullptr)
Connector::Connector(std::string_view appName, CoreApp& coreObj, const FederateInfo& fedInfo):
App(appName, coreObj, fedInfo), core((fed) ? fed->getCorePointer() : nullptr)
{
initialSetup();
}
Expand Down Expand Up @@ -645,7 +656,7 @@ bool Connector::addConnectionVector(const std::vector<std::string>& connection)
newTags.push_back(connection[2]);
}

for (int ii = 3; ii < connection.size(); ++ii) {
for (std::size_t ii = 3; ii < connection.size(); ++ii) {
newTags.push_back(connection[ii]);
}
addConnection(connection[0], connection[1], direction, newTags);
Expand All @@ -664,7 +675,7 @@ void Connector::addConnection(std::string_view interface1,
}
auto iview1 = addInterface(interface1);
auto iview2 = addInterface(interface2);
Connection conn{iview1, iview2, direction, std::move(svtags)};
Connection conn{iview1, iview2, direction, std::move(svtags), nullptr};
if (iview1.compare(0, 6, "REGEX:") == 0) {
switch (direction) {
case InterfaceDirection::TO_FROM:
Expand Down
8 changes: 4 additions & 4 deletions src/helics/apps/Connector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ class HELICS_CXX_EXPORT Connector: public App {
explicit Connector(std::string_view name, const FederateInfo& fedInfo);
/**constructor taking a federate information structure and using the given core
@param name the name of the federate (can be empty to use defaults from fedInfo)
@param core a pointer to core object which the federate can join
@param coreObj a pointer to core object which the federate can join
@param fedInfo a federate information structure
*/
Connector(std::string_view name,
const std::shared_ptr<Core>& core,
const std::shared_ptr<Core>& coreObj,
const FederateInfo& fedInfo);
/**constructor taking a federate information structure and using the given core
@param name the name of the federate (can be empty to use defaults from fedInfo)
@param core a coreApp object that can be joined
@param coreObj a coreApp object that can be joined
@param fedInfo a federate information structure
*/
Connector(std::string_view name, CoreApp& core, const FederateInfo& fedInfo);
Connector(std::string_view name, CoreApp& coreObj, const FederateInfo& fedInfo);
/**constructor taking a file with the required information
@param appName the name of the app
@param configString JSON, TOML or text file or JSON string defining the federate information and
Expand Down
2 changes: 1 addition & 1 deletion src/helics/apps/helicsApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ std::vector<int> AppTextParser::preParseFile(const std::vector<char>& klines)
}

++counts[0];
for (int ii = 0; ii < klines.size(); ++ii) {
for (std::size_t ii = 0; ii < klines.size(); ++ii) {
if (str[fc] == klines[ii]) {
++counts[ii + 1];
}
Expand Down
Loading

0 comments on commit 8f64719

Please sign in to comment.