Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cla_prosim_driver
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fmg005
cla_prosim_driver
Commits
a37fa6fd
Commit
a37fa6fd
authored
Apr 28, 2018
by
fmg005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified files
parent
91bc991c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
12 deletions
+14
-12
.gitignore
.gitignore
+1
-0
SimulationEngine.cpp
SimulationEngine.cpp
+11
-10
include/CLA_Logger.h
include/CLA_Logger.h
+2
-2
No files found.
.gitignore
View file @
a37fa6fd
builds/
logs/
results/
serial/
include/configure_prosim_paths.h
SimulationEngine.cpp
View file @
a37fa6fd
...
...
@@ -11,8 +11,6 @@
#include "CLA_Logger.h"
#include "SimulationEngine.h"
// Include the various types you will be using in your code
#include "scenario/SEDataRequestManager.h"
#include "patient/actions/SEHemorrhage.h"
...
...
@@ -51,7 +49,6 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
// Create the engine and load the patient
std
::
unique_ptr
<
PhysiologyEngine
>
pe
=
CreatePulseEngine
(
prosim_results_dir
+
"SimulationEngine_"
+
patient_name
+
".log"
);
pe
->
GetLogger
()
->
Info
(
"CLA_Prosim Simulation"
);
//if (!pe->LoadStateFile("./states/StandardMale@0s.pba"))
if
(
!
pe
->
LoadStateFile
(
pulse_state_dir
+
patient_name
+
"@0s.pba"
))
{
pe
->
GetLogger
()
->
Error
(
"Could not load state, check the error"
);
...
...
@@ -64,13 +61,13 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
pe
->
GetEngineTracker
()
->
GetDataRequestManager
().
SetResultsFilename
(
prosim_results_dir
+
"PulseSimEngine_"
+
patient_name
+
".txt"
);
SEHemorrhage
hemorrhageLeg
;
double
initialMAP
=
75.0
;
double
currentMAP
;
double
initialMAP
=
70.0
;
CLA
::
Environment
sim_env
;
Global_LoadConfig
(
pe
,
cfg
,
filepath
,
&
sim_env
);
/*serial instance arguments*/
std
::
string
port
=
"/dev/tty
SB
0"
;
// arbitrary port
std
::
string
port
=
"/dev/tty
ACM
0"
;
// arbitrary port
uint32_t
baudrate
=
115200
;
serial
::
Timeout
timeout
=
serial
::
Timeout
();
serial
::
bytesize_t
bytesize
=
serial
::
eightbits
;
...
...
@@ -82,17 +79,19 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
flowcontrol
);
CLA
::
LOGGER
logger
;
/* for timestamped logs */
HardwareSimulator
prosim
(
&
myserial
,
&
logger
,
&
sim_env
);
prosim
.
LoadConfig
(
pe
,
filepath
);
prosim
.
LoadConfig
(
filepath
);
//sim_env.logger = std::make_shared<SimulationLogger>(prosim_results_dir"SimulationEngineLog_"+patient_name+".txt");
bool
STOP
=
false
;
// Execute stop hemmorrhage only once; without this it be executed for each timestep
bool
DEVICES_START
=
false
;
prosim
.
SetRemoteMode
();
// stop when the set time is reached
while
(
sim_env
.
time_index
<=
sim_env
.
simulation_timesteps
)
{
// event_hemorrage_start
if
(
sim_env
.
time_index
==
sim_env
.
simulation_injury_start_timestep
)
{
if
(
sim_env
.
time_index
==
sim_env
.
simulation_injury_start_timestep
)
{
// Hemorrhage Starts - instantiate a hemorrhage action and have the engine process it
cout
<<
"
\n
Hemorrhage Started at: "
<<
pe
->
GetSimulationTime
(
TimeUnit
::
s
)
<<
endl
;
hemorrhageLeg
.
SetCompartment
(
pulse
::
VascularCompartment
::
RightLeg
);
...
...
@@ -104,7 +103,7 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
currentMAP
=
pe
->
GetCardiovascularSystem
()
->
GetMeanArterialPressure
(
PressureUnit
::
mmHg
);
if
(
currentMAP
<=
initialMAP
&&
STOP
){
if
(
currentMAP
<=
initialMAP
&&
STOP
)
{
cout
<<
"
\n
Hemorrhage Stoppd at: "
<<
pe
->
GetSimulationTime
(
TimeUnit
::
s
)
<<
endl
;
hemorrhageLeg
.
SetCompartment
(
pulse
::
VascularCompartment
::
RightLeg
);
hemorrhageLeg
.
GetRate
().
SetValue
(
0
,
VolumePerTimeUnit
::
mL_Per_min
);
...
...
@@ -113,9 +112,11 @@ void Simulation(const string patient_name, const std::shared_ptr<Config>& cfg, c
DEVICES_START
=
true
;
// instruct devices to start
cout
<<
"START DEVICES"
<<
endl
;
}
if
(
DEVICES_START
)
{
if
(
DEVICES_START
)
{
prosim
.
update
(
pe
);
}
}
// track patient data
pe
->
GetEngineTracker
()
->
TrackData
(
pe
->
GetSimulationTime
(
TimeUnit
::
s
));
pe
->
AdvanceModelTime
();
...
...
include/CLA_Logger.h
View file @
a37fa6fd
...
...
@@ -42,7 +42,7 @@ namespace CLA {
void
info
(
const
T
&
t
)
{
ss
<<
t
;
m_logstream
<<
current_time
(
true
)
<<
","
<<
set_level
(
LOGGER
::
INFO
)
<<
","
+
ss
.
str
()
+
"
\n
"
;
cout
<<
current_time
(
false
)
<<
"
:"
<<
set_level
(
LOGGER
::
INFO
)
<<
":
"
+
ss
.
str
()
<<
endl
;
cout
<<
current_time
(
false
)
<<
"
("
<<
set_level
(
LOGGER
::
INFO
)
<<
")
"
+
ss
.
str
()
<<
endl
;
ss
.
str
(
""
);
ss
.
clear
();
}
...
...
@@ -53,7 +53,7 @@ namespace CLA {
ss
<<
t
;
m_logstream
<<
current_time
(
true
)
<<
","
<<
set_level
(
LOGGER
::
WARNING
)
<<
","
+
ss
.
str
()
+
"
\n
"
;
cout
<<
current_time
(
false
)
<<
"
:"
<<
set_level
(
LOGGER
::
WARNING
)
<<
":
"
+
ss
.
str
()
<<
endl
;
cout
<<
current_time
(
false
)
<<
"
("
<<
set_level
(
LOGGER
::
WARNING
)
<<
")
"
+
ss
.
str
()
<<
endl
;
ss
.
str
(
""
);
ss
.
clear
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment