Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Modelichart Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ModeliChart
Modelichart Backend
Commits
7213fa73
Commit
7213fa73
authored
7 years ago
by
Tim Übelhör
Browse files
Options
Downloads
Patches
Plain Diff
Fixed loading Fmu modelDescription.
No crash on modeli load. Printing error to console instead.
parent
38f7177e
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Files/FmuFile.cpp
+14
-6
14 additions, 6 deletions
Files/FmuFile.cpp
Files/FmuFile.hpp
+2
-0
2 additions, 0 deletions
Files/FmuFile.hpp
Main/main.cpp
+13
-6
13 additions, 6 deletions
Main/main.cpp
with
29 additions
and
12 deletions
Files/FmuFile.cpp
+
14
−
6
View file @
7213fa73
...
...
@@ -15,12 +15,8 @@ namespace Files
// Unzip the fmu
_unzippedPath
=
CreateModelPath
(
controllerId
,
instanceName
);
Unzipper
::
Unzip
(
path
,
_unzippedPath
);
// Parse the model description
std
::
string
xmlPath
=
_unzippedPath
+
"/modelDescription.xml"
;
pt
::
ptree
desc
;
pt
::
read_xml
(
xmlPath
,
desc
);
_modelName
=
desc
.
get
<
std
::
string
>
(
"fmiModelDescription.CoSimulation.<xmlattr>.modelIdentifier"
);
_guid
=
desc
.
get
<
std
::
string
>
(
"fmiModelDescription.<xmlattr>.guid"
);
// Load the description
loadModelDescription
();
}
FmuFile
::
FmuFile
(
const
std
::
vector
<
unsigned
char
>&
buffer
,
std
::
string
controllerId
,
std
::
string
instanceName
)
:
_instanceName
(
instanceName
)
...
...
@@ -28,6 +24,8 @@ namespace Files
// Path where the extracted Model is stored
_unzippedPath
=
CreateModelPath
(
controllerId
,
instanceName
);
Unzipper
::
Unzip
(
buffer
,
_unzippedPath
);
// Load the description
loadModelDescription
();
}
FmuFile
::~
FmuFile
()
...
...
@@ -35,6 +33,16 @@ namespace Files
fs
::
remove_all
(
_unzippedPath
);
}
void
FmuFile
::
loadModelDescription
()
{
// Parse the model description
std
::
string
xmlPath
=
_unzippedPath
+
"/modelDescription.xml"
;
pt
::
ptree
desc
;
pt
::
read_xml
(
xmlPath
,
desc
);
_modelName
=
desc
.
get
<
std
::
string
>
(
"fmiModelDescription.CoSimulation.<xmlattr>.modelIdentifier"
);
_guid
=
desc
.
get
<
std
::
string
>
(
"fmiModelDescription.<xmlattr>.guid"
);
}
std
::
string
FmuFile
::
CreateModelPath
(
std
::
string
controllerId
,
std
::
string
instanceName
)
{
fs
::
path
dir
(
MODEL_DIR
);
...
...
This diff is collapsed.
Click to expand it.
Files/FmuFile.hpp
+
2
−
0
View file @
7213fa73
...
...
@@ -13,6 +13,8 @@ namespace Files
std
::
string
_instanceName
;
std
::
string
_modelName
;
std
::
string
_guid
;
/// Loads the information from the modelDescription.xml
void
loadModelDescription
();
// Relative path to the dir where the modeles will be stored
const
std
::
string
MODEL_DIR
=
"MODELS"
;
// The path where the extracted fmu is stored
...
...
This diff is collapsed.
Click to expand it.
Main/main.cpp
+
13
−
6
View file @
7213fa73
...
...
@@ -40,6 +40,8 @@ int main(int argc, char *argv[])
auto
fmuEngine
=
std
::
make_shared
<
Simulation
::
FmuEngine
>
(
std
::
to_string
(
port
));
// Load the modeli file into the engine
if
(
vm
.
count
(
"modeli"
))
{
try
{
Files
::
ModeliFile
modeliFile
(
vm
[
"modeli"
].
as
<
std
::
string
>
());
for
(
auto
fmuFile
:
modeliFile
.
GetFmus
())
...
...
@@ -51,6 +53,11 @@ int main(int argc, char *argv[])
fmuEngine
->
AddChannelLink
(
channelLink
);
}
}
catch
(
std
::
exception
err
)
{
std
::
cout
<<
"Failed loading the modeli file: "
<<
err
.
what
()
<<
std
::
endl
;
}
}
// start the tcp server
Network
::
TcpServer
server
(
port
,
fmuEngine
);
std
::
thread
serverThread
([
&
server
]()
{
server
.
Run
();
});
...
...
@@ -61,7 +68,7 @@ int main(int argc, char *argv[])
std
::
string
cinString
;
while
(
cinString
!=
"exit"
)
{
// DEBUG
std::cin >> cinString;
std
::
cin
>>
cinString
;
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
1
));
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment