Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modeler 4.7: Import connections and ports #2662

Open
wants to merge 41 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3043877
Raise exception when converting port types
payetvin Feb 24, 2025
7fc5869
Remove description from PortType class
payetvin Feb 24, 2025
0fdcc80
Correct behavior for tests when field is empty
payetvin Feb 24, 2025
ec8a1b7
Merge branch 'develop' into feature/4.7-port-connections
payetvin Feb 24, 2025
1e93123
fix comments
payetvin Feb 25, 2025
b37fb2a
Check if port id already present
payetvin Feb 25, 2025
e9d5114
fix compile
payetvin Feb 25, 2025
2c6346c
add port and portype
payetvin Feb 25, 2025
c386e5e
add base function to convert pfdef, add pfdef to system model
payetvin Feb 25, 2025
4daa665
check for port exists
payetvin Feb 25, 2025
2492c0c
add exception
payetvin Feb 26, 2025
2052ec0
remove warnings in test_full
payetvin Feb 26, 2025
3c473ed
check for field
payetvin Feb 26, 2025
dadac24
remove warning
payetvin Feb 27, 2025
c444167
Convert expression and add portfielddef
payetvin Feb 27, 2025
73992eb
rm Antares::
payetvin Feb 27, 2025
4117a1c
format
payetvin Feb 27, 2025
4c21b62
fix unit tests
payetvin Feb 27, 2025
6294d5d
fix unit tests
payetvin Feb 27, 2025
731dcfa
check for constaints
payetvin Feb 27, 2025
1d96fdd
custom exceptions
payetvin Feb 27, 2025
9bbeaaf
test empty fields
payetvin Feb 27, 2025
9dd078d
port already exists
payetvin Feb 27, 2025
37ccf22
wrong value type
payetvin Feb 27, 2025
7f27d65
test id already exists
payetvin Feb 27, 2025
7627cb5
fix port test case
payetvin Feb 27, 2025
b2c9958
test YmlModel::toString
payetvin Feb 28, 2025
e55ff51
test port id
payetvin Feb 28, 2025
7648a60
type not found
payetvin Feb 28, 2025
e94953c
constraint already exists
payetvin Feb 28, 2025
9290c7f
Basic test case for port def
payetvin Feb 28, 2025
cd2020c
add function to add pfd to builder
payetvin Feb 28, 2025
4171bc5
test pfd field and definition
payetvin Feb 28, 2025
174b020
c
payetvin Feb 28, 2025
43e7905
error cases for portfielddefintion
payetvin Feb 28, 2025
6e3fa47
move function def to begining of the header
payetvin Mar 3, 2025
e3b9d7f
emplace back
payetvin Mar 5, 2025
8410866
use iterators
payetvin Mar 7, 2025
3b51a6c
custom ex if port in definition
payetvin Mar 7, 2025
308ec27
add test base
payetvin Mar 7, 2025
0381386
Add port to convertor visitor
payetvin Mar 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/expressions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ add_library(expressions-iterators
iterators/pre-order.cpp
include/antares/expressions/iterators/pre-order.h
)
add_library(Antares::expressions-iterators ALIAS expressions-iterators)

target_link_libraries(expressions-iterators PRIVATE expressions)

Expand Down
1 change: 1 addition & 0 deletions src/io/inputs/model-converter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target_link_libraries(model-converter
Antares::yml-model
Antares::antlr-interface
Antares::expressions
Antares::expressions-iterators
)

install(DIRECTORY include/antares
Expand Down
21 changes: 19 additions & 2 deletions src/io/inputs/model-converter/convertorVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ class NoParameterOrVariableWithThisName: public std::runtime_error
}
};

class NoPortWithThisId: public std::runtime_error
{
public:
explicit NoPortWithThisId(const std::string& name):
runtime_error("No port found for this identifier: " + name)
{
}
};

// to silent warning, convert bool to unsigned int
static constexpr unsigned int convertBool(bool in)
{
Expand Down Expand Up @@ -212,9 +221,17 @@ class NotImplemented: public std::runtime_error
};

// TODO implement this
std::any ConvertorVisitor::visitPortField([[maybe_unused]] ExprParser::PortFieldContext* context)
std::any ConvertorVisitor::visitPortField(ExprParser::PortFieldContext* context)
{
throw NotImplemented("Node portfield not implemented yet");
for (const auto& port: model_.ports)
{
if (port.id == context->IDENTIFIER()[0]->getText())
{
return static_cast<Node*>(registry_.create<PortFieldNode>(port.id, port.type));
}
}

throw NoPortWithThisId(context->IDENTIFIER()[0]->getText());
}

std::any ConvertorVisitor::visitNumber(ExprParser::NumberContext* context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,62 @@ class Node;

namespace Antares::IO::Inputs::ModelConverter
{

Study::SystemModel::Library convert(const YmlModel::Library& library);

// EXCEPTIONS
class UnknownTypeException: public std::runtime_error
{
public:
explicit UnknownTypeException(YmlModel::ValueType type);
explicit UnknownTypeException(const std::string& type);
};

class PortWithThisIdAlreadyExists: public std::runtime_error
{
public:
explicit PortWithThisIdAlreadyExists(const std::string& id);
};

class PortTypeWithThisIdAlreadyExists: public std::runtime_error
{
public:
explicit PortTypeWithThisIdAlreadyExists(const std::string& id);
};

class ConstraintWithThisIdAlreadyExists: public std::runtime_error
{
public:
explicit ConstraintWithThisIdAlreadyExists(const std::string& id);
};

class PortTypeDoesntContainsFields: public std::runtime_error
{
public:
explicit PortTypeDoesntContainsFields(const std::string& id);
};

class PortTypeNotFound: public std::runtime_error
{
public:
explicit PortTypeNotFound(const std::string& portId, const std::string& portTypeId);
};

class PortNotFoundForDefinition: public std::runtime_error
{
public:
explicit PortNotFoundForDefinition(const std::string& portId);
};

class FieldNotFoundForDefinition: public std::runtime_error
{
public:
explicit FieldNotFoundForDefinition(const std::string& portId, const std::string& fieldId);
};

class PortInDefinition: public std::runtime_error
{
public:
explicit PortInDefinition(const std::string& portId, const std::string& portInDefId);
};

Study::SystemModel::Library convert(const YmlModel::Library& library);
} // namespace Antares::IO::Inputs::ModelConverter
Loading
Loading