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
91bc991c
Commit
91bc991c
authored
Apr 28, 2018
by
fmg005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fixes and modified a few methods
parent
c00a3922
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
15 deletions
+29
-15
HardwareSimulator.cpp
HardwareSimulator.cpp
+24
-11
example.cpp
example.cpp
+1
-1
include/HardwareSimulator.h
include/HardwareSimulator.h
+4
-3
No files found.
HardwareSimulator.cpp
View file @
91bc991c
...
...
@@ -9,25 +9,36 @@ my_serial, CLA::LOGGER* logger):m_serial(my_serial), m_logger(logger) {
HardwareSimulator
::
HardwareSimulator
(
serial
::
Serial
*
my_serial
,
CLA
::
LOGGER
*
logger
,
CLA
::
Environment
*
env
)
:
m_serial
(
my_serial
),
m_logger
(
logger
),
m_env
(
env
)
{
nextUpdateTime
=
0
;
respondToData
=
&
HardwareSimulator
::
update
IBP
;
respondToData
=
&
HardwareSimulator
::
SetInitial
IBP
;
}
void
HardwareSimulator
::
update
(
std
::
unique_ptr
<
PhysiologyEngine
>&
engine
)
{
systolic_pressure
=
engine
->
GetCardiovascularSystem
()
->
GetSystolicArterialPressure
(
PressureUnit
::
mmHg
);
((
this
)
->*
respondToData
)(
engine
);
}
void
HardwareSimulator
::
SetInitialIBP
(
std
::
unique_ptr
<
PhysiologyEngine
>&
engine
)
{
systolic_pressure
=
engine
->
GetCardiovascularSystem
()
->
GetSystolicArterialPressure
(
PressureUnit
::
mmHg
);
diastolic_pressure
=
engine
->
GetCardiovascularSystem
()
->
GetDiastolicArterialPressure
(
PressureUnit
::
mmHg
);
((
this
)
->*
respondToData
)(
systolic_pressure
,
diastolic_pressure
);
SetIBP
(
1
,
systolic_pressure
,
diastolic_pressure
);
nextUpdateTime
=
m_env
->
time_index
+
DELAY_5_SECONDS
;
//cout<< engine->GetSimulationTime(TimeUnit::s)<<endl;
respondToData
=
&
HardwareSimulator
::
updateIBP
;
}
void
HardwareSimulator
::
updateIBP
(
double
syst
,
double
diast
)
{
void
HardwareSimulator
::
updateIBP
(
std
::
unique_ptr
<
PhysiologyEngine
>&
engine
)
{
if
(
m_env
->
time_index
==
nextUpdateTime
)
{
SetIBP
(
1
,
syst
,
diast
);
nextUpdateTime
+=
DELAY_5_SECONDS
;
systolic_pressure
=
engine
->
GetCardiovascularSystem
()
->
GetSystolicArterialPressure
(
PressureUnit
::
mmHg
);
diastolic_pressure
=
engine
->
GetCardiovascularSystem
()
->
GetDiastolicArterialPressure
(
PressureUnit
::
mmHg
);
SetIBP
(
1
,
systolic_pressure
,
diastolic_pressure
);
nextUpdateTime
=
m_env
->
time_index
+
DELAY_5_SECONDS
;
//cout<< engine->GetSimulationTime(TimeUnit::s)<<endl;
respondToData
=
&
HardwareSimulator
::
updateIBP
;
}
}
void
HardwareSimulator
::
LoadConfig
(
std
::
unique_ptr
<
PhysiologyEngine
>&
engine
,
const
char
*
file_path
)
{
void
HardwareSimulator
::
LoadConfig
(
const
char
*
file_path
)
{
try
{
cfg
.
readFile
(
file_path
);
// Read configration file
}
...
...
@@ -37,9 +48,9 @@ void HardwareSimulator::LoadConfig(std::unique_ptr<PhysiologyEngine>& engine, co
catch
(
const
ParseException
&
pex
)
{
m_logger
->
error
(
"Error parsing configuration file"
);
}
double
time_step
=
engine
->
GetTimeStep
(
TimeUnit
::
s
);
DELAY_5_SECONDS
=
cfg
.
lookup
(
"prosim.delay_5_sec"
);
DELAY_5_SECONDS
=
DELAY_5_SECONDS
/
time_
step
;
// 5 seconds delay
DELAY_5_SECONDS
=
DELAY_5_SECONDS
/
m_env
->
engine_time
step
;
// 5 seconds delay
}
bool
HardwareSimulator
::
isOpen
()
{
...
...
@@ -92,7 +103,9 @@ void HardwareSimulator::SetOxygenSat(double rate) {
}
/* IBP range: 0-300 */
void
HardwareSimulator
::
SetIBP
(
int
channel
,
double
syst
,
double
diast
)
{
void
HardwareSimulator
::
SetIBP
(
int
channel
,
double
systolic_p
,
double
diastolic_p
)
{
int
syst
=
static_cast
<
int
>
(
systolic_p
);
int
diast
=
static_cast
<
int
>
(
diastolic_p
);
string
s_syst
=
to_string
(
syst
);
string
s_diast
=
to_string
(
diast
);
string
s_channel
=
to_string
(
channel
);
...
...
example.cpp
View file @
91bc991c
...
...
@@ -13,7 +13,7 @@ int main() {
/*serial instance arguments*/
std
::
string
port
=
"/dev/ttySB0"
;
// arbitrary port
std
::
string
port
=
"/dev/tty
U
SB0"
;
// arbitrary port
uint32_t
baudrate
=
115200
;
serial
::
Timeout
timeout
=
serial
::
Timeout
();
serial
::
bytesize_t
bytesize
=
serial
::
eightbits
;
...
...
include/HardwareSimulator.h
View file @
91bc991c
...
...
@@ -47,10 +47,11 @@ public:
void
SetRemoteMode
();
void
SetLocalMode
();
string
GetCurrentMode
();
void
updateIBP
(
double
,
double
);
void
(
HardwareSimulator
::*
respondToData
)(
double
,
double
);
void
updateIBP
(
std
::
unique_ptr
<
PhysiologyEngine
>&
);
void
SetInitialIBP
(
std
::
unique_ptr
<
PhysiologyEngine
>&
);
void
(
HardwareSimulator
::*
respondToData
)(
std
::
unique_ptr
<
PhysiologyEngine
>&
);
void
update
(
std
::
unique_ptr
<
PhysiologyEngine
>&
);
void
LoadConfig
(
std
::
unique_ptr
<
PhysiologyEngine
>&
,
const
char
*
);
void
LoadConfig
(
const
char
*
);
};
#endif
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