Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pulse Physiology Suite
engine
Commits
530b53b4
Commit
530b53b4
authored
Jun 01, 2018
by
Aaron Bray
Browse files
Better support for using the advance callback
parent
1da59ff3
Changes
6
Hide whitespace changes
Inline
Side-by-side
cdm/cpp/engine/SEAdvanceHandler.h
View file @
530b53b4
...
...
@@ -2,6 +2,7 @@
See accompanying NOTICE file for details.*/
#pragma once
class
PhysiologyEngine
;
class
CDM_DECL
SEAdvanceHandler
{
...
...
@@ -10,6 +11,7 @@ public:
SEAdvanceHandler
(
bool
on_stabilization
)
{
m_OnStabilization
=
on_stabilization
;
}
virtual
~
SEAdvanceHandler
(){};
bool
OnForStabilization
()
{
return
m_OnStabilization
;
}
virtual
void
SetStabilizationCallback
(
bool
b
){
m_OnStabilization
=
b
;
}
virtual
void
OnAdvance
(
double
time_s
,
const
PhysiologyEngine
&
engine
)
=
0
;
...
...
engine/cpp/Controller/Controller.cpp
View file @
530b53b4
...
...
@@ -66,6 +66,7 @@
#include
"properties/SEScalarMassPerMass.h"
#include
"properties/SEScalarMassPerVolume.h"
#include
"properties/SEScalarTime.h"
#include
"engine/SEAdvanceHandler.h"
#include
"utils/DataTrack.h"
#include
"utils/FileUtils.h"
#include
<google/protobuf/text_format.h>
...
...
@@ -79,12 +80,16 @@ PulseController::PulseController(const std::string& logFileName) : PulseControll
{
myLogger
=
true
;
m_DataTrack
=
nullptr
;
m_EventHandler
=
nullptr
;
m_AdvanceHandler
=
nullptr
;
}
PulseController
::
PulseController
(
Logger
*
logger
)
:
Loggable
(
logger
)
{
myLogger
=
false
;
m_DataTrack
=
nullptr
;
m_EventHandler
=
nullptr
;
m_AdvanceHandler
=
nullptr
;
if
(
!
m_Logger
->
HasForward
())
// Don't override a forwarder, if there already is one there
m_Logger
->
SetForward
(
this
);
...
...
@@ -200,6 +205,7 @@ bool PulseController::Initialize(const PulseConfiguration* config)
Info
(
"Initializing Substances"
);
m_Substances
->
InitializeSubstances
();
// Sets all concentrations and such of all substances for all compartments, need to do this after we figure out what's in the environment
Info
(
"Initializing Systems"
);
m_CardiovascularSystem
->
Initialize
();
m_RespiratorySystem
->
Initialize
();
...
...
@@ -216,6 +222,7 @@ bool PulseController::Initialize(const PulseConfiguration* config)
m_ECG
->
Initialize
();
m_Inhaler
->
Initialize
();
AdvanceCallback
(
-
1
);
return
true
;
}
...
...
engine/cpp/Controller/Controller.h
View file @
530b53b4
...
...
@@ -53,12 +53,10 @@ protected:
EngineState
m_State
;
public:
PulseController
(
Logger
*
logger
);
PulseController
(
const
std
::
string
&
logfileName
);
virtual
~
PulseController
();
EngineState
GetState
();
DataTrack
&
GetDataTrack
();
...
...
@@ -111,6 +109,7 @@ public:
void
SetIntubation
(
cdm
::
eSwitch
s
);
bool
CreateCircuitsAndCompartments
();
virtual
void
AdvanceCallback
(
double
time_s
)
{};
protected:
void
SetupCardiovascular
();
void
SetupRenal
();
...
...
@@ -175,5 +174,7 @@ protected:
// Flag to destroy the logger or not
bool
myLogger
;
SEEventHandler
*
m_EventHandler
;
SEAdvanceHandler
*
m_AdvanceHandler
;
};
engine/cpp/Controller/Engine.cpp
View file @
530b53b4
...
...
@@ -22,7 +22,6 @@
#include
"Equipment/ECG.h"
#include
"Equipment/Inhaler.h"
#include
"PulseConfiguration.h"
#include
"engine/SEAdvanceHandler.h"
PROTO_PUSH
#include
"bind/engine/EngineState.pb.h"
PROTO_POP
...
...
@@ -38,6 +37,7 @@ PROTO_POP
#include
"compartment/SECompartmentManager.h"
#include
"engine/SEEngineStabilization.h"
#include
"engine/SEEngineTracker.h"
#include
"engine/SEAdvanceHandler.h"
#include
"scenario/SEDataRequestManager.h"
#include
"scenario/SEScenario.h"
#include
"scenario/SEAction.h"
...
...
@@ -64,8 +64,6 @@ PULSE_DECL std::unique_ptr<PhysiologyEngine> CreatePulseEngine(Logger* logger)
PulseEngine
::
PulseEngine
(
Logger
*
logger
)
:
PulseController
(
logger
)
{
m_State
=
EngineState
::
NotReady
;
m_EventHandler
=
nullptr
;
m_AdvanceHandler
=
nullptr
;
m_EngineTrack
=
new
SEEngineTracker
(
*
this
);
m_DataTrack
=
&
m_EngineTrack
->
GetDataTrack
();
}
...
...
@@ -73,8 +71,6 @@ PulseEngine::PulseEngine(Logger* logger) : PulseController(logger)
PulseEngine
::
PulseEngine
(
const
std
::
string
&
logFileName
)
:
PulseController
(
logFileName
)
{
m_State
=
EngineState
::
NotReady
;
m_EventHandler
=
nullptr
;
m_AdvanceHandler
=
nullptr
;
m_EngineTrack
=
new
SEEngineTracker
(
*
this
);
m_DataTrack
=
&
m_EngineTrack
->
GetDataTrack
();
}
...
...
@@ -534,6 +530,15 @@ void PulseEngine::AdvanceModelTime(double time, const TimeUnit& unit)
AdvanceModelTime
();
}
void
PulseEngine
::
AdvanceCallback
(
double
time_s
)
{
if
(
m_AdvanceHandler
)
{
if
(
time_s
>=
0
||
m_AdvanceHandler
->
OnForStabilization
())
m_AdvanceHandler
->
OnAdvance
(
time_s
,
*
this
);
}
}
bool
PulseEngine
::
ProcessAction
(
const
SEAction
&
action
)
{
if
(
!
IsReady
())
...
...
engine/cpp/Controller/Engine.h
View file @
530b53b4
...
...
@@ -68,13 +68,13 @@ public:
virtual
const
SECompartmentManager
&
GetCompartments
()
const
;
virtual
void
AdvanceCallback
(
double
time_s
);
protected:
virtual
bool
IsReady
()
const
;
virtual
bool
InitializeEngine
(
const
std
::
vector
<
const
SECondition
*>*
conditions
=
nullptr
,
const
SEEngineConfiguration
*
config
=
nullptr
);
SEEventHandler
*
m_EventHandler
;
SEAdvanceHandler
*
m_AdvanceHandler
;
SEEngineTracker
*
m_EngineTrack
;
std
::
stringstream
m_ss
;
};
\ No newline at end of file
engine/cpp/Systems/Cardiovascular.cpp
View file @
530b53b4
...
...
@@ -1604,6 +1604,7 @@ void Cardiovascular::TuneCircuit()
stableTime_s
=
0
;
while
(
!
stable
)
{
m_data
.
AdvanceCallback
(
-
1
);
HeartDriver
();
m_circuitCalculator
->
Process
(
*
m_CirculatoryCircuit
,
m_dT_s
);
CalculateVitalSigns
();
...
...
Write
Preview
Supports
Markdown
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