Updates will be applied on October 27th between 12pm - 12:45pm EDT (UTC-0400). Gitlab may be slow during the maintenance window.

Commit e2145137 authored by Aaron Bray's avatar Aaron Bray
Browse files

Start of engine serialization refactoring

Renamed engine
Fixed most of the unit tests and systems
Moved ECG Interpolation back into CDM
parent 22a2d111
......@@ -36,6 +36,7 @@ protected:
static void Serialize(const cdm::ConsciousRespirationData& src, SEConsciousRespiration& dst);
static void Serialize(const SEConsciousRespiration& src, cdm::ConsciousRespirationData& dst);
public:
// Get the active command
virtual SEConsciousRespirationCommand* GetActiveCommand();
/// When the active command has been processed, remove it
......
......@@ -11,138 +11,123 @@ specific language governing permissions and limitations under the License.
**************************************************************************************/
#include "stdafx.h"
#include "system/equipment/ElectroCardioGram/SEElectroCardioGramInterpolatorWaveform.h"
#include "bind/ElectroCardioGramInterpolationWaveformData.hxx"
#include "system/equipment/ElectroCardioGram/SEElectroCardioGramWaveform.h"
#include "properties/SEScalarTime.h"
#include "properties/SEScalarElectricPotential.h"
#include "properties/SEFunctionElectricPotentialVsTime.h"
#include "bind/IntegerArray.hxx"
#include "bind/IntegerList.hxx"
SEElectroCardioGramInterpolatorWaveform::SEElectroCardioGramInterpolatorWaveform(Logger* logger) : Loggable(logger)
SEElectroCardioGramWaveform::SEElectroCardioGramWaveform(Logger* logger) : Loggable(logger)
{
m_TimeStep = nullptr;
m_Data = nullptr;
m_Rhythm = (cdm::eHeartRhythm) - 1;
m_LeadNumber = 0;
m_Rhythm = cdm::eHeartRhythm::NormalSinus;
m_LeadNumber = cdm::ElectroCardioGramWaveformData_eLead_NullLead;
}
SEElectroCardioGramInterpolatorWaveform::~SEElectroCardioGramInterpolatorWaveform()
SEElectroCardioGramWaveform::~SEElectroCardioGramWaveform()
{
Clear();
}
void SEElectroCardioGramInterpolatorWaveform::Clear()
void SEElectroCardioGramWaveform::Clear()
{
m_LeadNumber = 0;
m_Rhythm = (cdm::eHeartRhythm) - 1;
m_Rhythm = cdm::eHeartRhythm::NormalSinus;
m_LeadNumber = cdm::ElectroCardioGramWaveformData_eLead_NullLead;
SAFE_DELETE(m_TimeStep);
SAFE_DELETE(m_Data);
m_ActiveIndicies.clear();
}
bool SEElectroCardioGramInterpolatorWaveform::Load(const CDM::ElectroCardioGramInterpolationWaveformData& in)
void SEElectroCardioGramWaveform::Load(const cdm::ElectroCardioGramWaveformData& src, SEElectroCardioGramWaveform& dst)
{
Clear();
m_Rhythm = in.Rhythm();
m_LeadNumber = in.Lead();
GetData().Load(in.Data());
if (in.TimeStep().present())
GetTimeStep().Load(in.TimeStep().get());
if (in.ActiveIndicies().present())
{
for (size_t i = 0; i < in.ActiveIndicies().get().IntegerList().size(); i++)
m_ActiveIndicies.push_back(in.ActiveIndicies().get().IntegerList()[i]);
}
return true;
SEElectroCardioGramWaveform::Serialize(src, dst);
}
CDM::ElectroCardioGramInterpolationWaveformData* SEElectroCardioGramInterpolatorWaveform::Unload() const
void SEElectroCardioGramWaveform::Serialize(const cdm::ElectroCardioGramWaveformData& src, SEElectroCardioGramWaveform& dst)
{
CDM::ElectroCardioGramInterpolationWaveformData* data(new CDM::ElectroCardioGramInterpolationWaveformData());
Unload(*data);
return data;
dst.Clear();
dst.m_Rhythm = src.rhythm();
dst.m_LeadNumber = src.lead();
if (src.has_timestep())
SEScalarTime::Load(src.timestep(), dst.GetTimeStep());
if(src.has_data())
SEFunctionElectricPotentialVsTime::Load(src.data(), dst.GetData());
for (int i = 0; i < src.activeindicies_size(); i++)
dst.m_ActiveIndicies.push_back(src.activeindicies()[i]);
}
void SEElectroCardioGramInterpolatorWaveform::Unload(CDM::ElectroCardioGramInterpolationWaveformData& data) const
cdm::ElectroCardioGramWaveformData* SEElectroCardioGramWaveform::Unload(const SEElectroCardioGramWaveform& src)
{
cdm::ElectroCardioGramWaveformData* dst = new cdm::ElectroCardioGramWaveformData();
SEElectroCardioGramWaveform::Serialize(src,*dst);
return dst;
}
void SEElectroCardioGramWaveform::Serialize(const SEElectroCardioGramWaveform& src, cdm::ElectroCardioGramWaveformData& dst)
{
if (HasRhythm())
data.Rhythm(m_Rhythm);
if (HasLeadNumber())
data.Lead(m_LeadNumber);
if (HasData())
dst.set_rhythm(src.m_Rhythm);
dst.set_lead(src.m_LeadNumber);
if (src.HasData())
{
data.Data(std::unique_ptr<CDM::FunctionElectricPotentialVsTimeData>(m_Data->Unload()));
data.ActiveIndicies(std::unique_ptr<CDM::IntegerArray>(new CDM::IntegerArray()));
data.ActiveIndicies().get().IntegerList(std::unique_ptr<CDM::IntegerList>(new CDM::IntegerList()));
for (int i : m_ActiveIndicies)
data.ActiveIndicies().get().IntegerList().push_back(i);
dst.set_allocated_data(SEFunctionElectricPotentialVsTime::Unload(*src.m_Data));
for (int i : src.m_ActiveIndicies)
dst.add_activeindicies(i);
}
if (HasTimeStep())
data.TimeStep(std::unique_ptr<CDM::ScalarTimeData>(m_TimeStep->Unload()));
if (src.HasTimeStep())
dst.set_allocated_timestep(SEScalarTime::Unload(*src.m_TimeStep));
}
CDM::ElectroCardioGramWaveformLeadNumber SEElectroCardioGramInterpolatorWaveform::GetLeadNumber() const
cdm::ElectroCardioGramWaveformData_eLead SEElectroCardioGramWaveform::GetLeadNumber() const
{
return m_LeadNumber;
}
void SEElectroCardioGramInterpolatorWaveform::SetLeadNumber(CDM::ElectroCardioGramWaveformLeadNumber n)
void SEElectroCardioGramWaveform::SetLeadNumber(cdm::ElectroCardioGramWaveformData_eLead n)
{
m_LeadNumber = n;
}
bool SEElectroCardioGramInterpolatorWaveform::HasLeadNumber() const
bool SEElectroCardioGramWaveform::HasLeadNumber() const
{
return m_LeadNumber == 0 ? false : true;
return m_LeadNumber == cdm::ElectroCardioGramWaveformData_eLead_NullLead ? false : true;
}
void SEElectroCardioGramInterpolatorWaveform::InvalidateLeadNumber()
void SEElectroCardioGramWaveform::InvalidateLeadNumber()
{
m_LeadNumber = 0;
m_LeadNumber = cdm::ElectroCardioGramWaveformData_eLead_NullLead;
}
cdm::eHeartRhythm SEElectroCardioGramInterpolatorWaveform::GetRhythm() const
cdm::eHeartRhythm SEElectroCardioGramWaveform::GetRhythm() const
{
return m_Rhythm;
}
void SEElectroCardioGramInterpolatorWaveform::SetRhythm(cdm::eHeartRhythm rhythm)
void SEElectroCardioGramWaveform::SetRhythm(cdm::eHeartRhythm rhythm)
{
m_Rhythm = rhythm;
}
bool SEElectroCardioGramInterpolatorWaveform::HasRhythm() const
{
return m_Rhythm == ((cdm::eHeartRhythm) - 1) ? false : true;
}
void SEElectroCardioGramInterpolatorWaveform::InvalidateRhythm()
{
m_Rhythm = (cdm::eHeartRhythm) - 1;
}
bool SEElectroCardioGramInterpolatorWaveform::HasData() const
bool SEElectroCardioGramWaveform::HasData() const
{
return m_Data == nullptr ? false : m_Data->IsValid();
}
SEFunctionElectricPotentialVsTime& SEElectroCardioGramInterpolatorWaveform::GetData()
SEFunctionElectricPotentialVsTime& SEElectroCardioGramWaveform::GetData()
{
if (m_Data == nullptr)
m_Data = new SEFunctionElectricPotentialVsTime();
return *m_Data;
}
const SEFunctionElectricPotentialVsTime* SEElectroCardioGramInterpolatorWaveform::GetData() const
const SEFunctionElectricPotentialVsTime* SEElectroCardioGramWaveform::GetData() const
{
return m_Data;
}
bool SEElectroCardioGramInterpolatorWaveform::HasTimeStep() const
bool SEElectroCardioGramWaveform::HasTimeStep() const
{
return m_TimeStep == nullptr ? false : m_TimeStep->IsValid();
}
SEScalarTime& SEElectroCardioGramInterpolatorWaveform::GetTimeStep()
SEScalarTime& SEElectroCardioGramWaveform::GetTimeStep()
{
if (m_TimeStep == nullptr)
m_TimeStep = new SEScalarTime();
return *m_TimeStep;
}
double SEElectroCardioGramInterpolatorWaveform::GetTimeStep(const TimeUnit& unit) const
double SEElectroCardioGramWaveform::GetTimeStep(const TimeUnit& unit) const
{
if (m_TimeStep == nullptr)
return SEScalar::dNaN();
......
......@@ -11,37 +11,31 @@ specific language governing permissions and limitations under the License.
**************************************************************************************/
#pragma once
#include "bind/cdm/ElectroCardioGram.pb.h"
class DLL_DECL SEElectroCardioGramInterpolatorWaveform : public Loggable
class DLL_DECL SEElectroCardioGramWaveform : public Loggable
{
public:
SEElectroCardioGramInterpolatorWaveform(Logger* logger);
virtual ~SEElectroCardioGramInterpolatorWaveform();
SEElectroCardioGramWaveform(Logger* logger);
virtual ~SEElectroCardioGramWaveform();
virtual void Clear();// Deletes all members
static void Load(const cdm::PatientData& src, SEPatient& dst);
static cdm::PatientData* Unload(const SEPatient& src);
static void Load(const cdm::ElectroCardioGramWaveformData& src, SEElectroCardioGramWaveform& dst);
static cdm::ElectroCardioGramWaveformData* Unload(const SEElectroCardioGramWaveform& src);
protected:
static void Serialize(const cdm::PatientData& src, SEPatient& dst);
static void Serialize(const SEPatient& src, cdm::PatientData& dst);
virtual bool Load(const CDM::ElectroCardioGramInterpolationWaveformData& in);
virtual CDM::ElectroCardioGramInterpolationWaveformData* Unload() const;
protected:
virtual void Unload(CDM::ElectroCardioGramInterpolationWaveformData& data) const;
static void Serialize(const cdm::ElectroCardioGramWaveformData& src, SEElectroCardioGramWaveform& dst);
static void Serialize(const SEElectroCardioGramWaveform& src, cdm::ElectroCardioGramWaveformData& dst);
public:
virtual bool HasLeadNumber() const;
virtual CDM::ElectroCardioGramWaveformLeadNumber GetLeadNumber() const;
virtual void SetLeadNumber(CDM::ElectroCardioGramWaveformLeadNumber n);
virtual cdm::ElectroCardioGramWaveformData_eLead GetLeadNumber() const;
virtual void SetLeadNumber(cdm::ElectroCardioGramWaveformData_eLead n);
virtual void InvalidateLeadNumber();
virtual cdm::eHeartRhythm GetRhythm() const;
virtual void SetRhythm(cdm::eHeartRhythm name);
virtual bool HasRhythm() const;
virtual void InvalidateRhythm();
virtual bool HasData() const;
virtual SEFunctionElectricPotentialVsTime& GetData();
......@@ -55,9 +49,9 @@ public:
protected:
CDM::ElectroCardioGramWaveformLeadNumber m_LeadNumber;
cdm::eHeartRhythm m_Rhythm;
cdm::ElectroCardioGramWaveformData_eLead m_LeadNumber;
cdm::eHeartRhythm m_Rhythm;
SEScalarTime* m_TimeStep;
SEFunctionElectricPotentialVsTime* m_Data;
std::vector<unsigned int> m_ActiveIndicies;
std::vector<unsigned int> m_ActiveIndicies;
};
\ No newline at end of file
......@@ -11,28 +11,23 @@ specific language governing permissions and limitations under the License.
**************************************************************************************/
#include "stdafx.h"
#include "system/equipment/ElectroCardioGram/SEElectroCardioGramInterpolator.h"
#include "system/equipment/ElectroCardioGram/SEElectroCardioGramInterpolatorWaveform.h"
#include "bind/ElectroCardioGramInterpolationWaveformData.hxx"
#include "bind/ElectroCardioGramWaveformInterpolatorData.hxx"
#include "Serializer.h"
#include "system/equipment/ElectroCardioGram/SEElectroCardioGramWaveformInterpolator.h"
#include "properties/SEScalarTime.h"
#include "properties/SEScalarElectricPotential.h"
#include "properties/SEFunctionElectricPotentialVsTime.h"
#include "bind/ArrayTimeData.hxx"
#include "bind/DoubleArray.hxx"
#include <google/protobuf/text_format.h>
SEElectroCardioGramInterpolator::SEElectroCardioGramInterpolator(Logger* logger) : Loggable(logger)
SEElectroCardioGramWaveformInterpolator::SEElectroCardioGramWaveformInterpolator(Logger* logger) : Loggable(logger)
{
}
SEElectroCardioGramInterpolator::~SEElectroCardioGramInterpolator()
SEElectroCardioGramWaveformInterpolator::~SEElectroCardioGramWaveformInterpolator()
{
Clear();
}
void SEElectroCardioGramInterpolator::Clear()
void SEElectroCardioGramWaveformInterpolator::Clear()
{
for (auto i : m_Waveforms)
for (auto j : i.second)
......@@ -41,73 +36,62 @@ void SEElectroCardioGramInterpolator::Clear()
m_Leads.clear();
}
bool SEElectroCardioGramInterpolator::LoadWaveforms(const std::string& file, const SEScalarTime* timeStep)
void SEElectroCardioGramWaveformInterpolator::Load(const cdm::ElectroCardioGramWaveformListData& src, SEElectroCardioGramWaveformInterpolator& dst)
{
Clear();
std::stringstream ss;
if (file.empty())
{
ss << "Waveform file not provided: " << file << std::endl;
Error(ss);
return false;
}
Clear();
std::unique_ptr<CDM::ObjectData> data = Serializer::ReadFile(file, GetLogger());
CDM::ElectroCardioGramWaveformInterpolatorData* pData = dynamic_cast<CDM::ElectroCardioGramWaveformInterpolatorData*>(data.get());
if (pData == nullptr)
{
ss << "Waveform data file could not be read : " << file << std::endl;
Error(ss);
return false;
}
if (!Load(*pData))
{
ss << "Unable to load waveform file: " << file << std::endl;
Error(ss);
return false;
}
if (timeStep != nullptr)
Interpolate(*timeStep);
return true;
SEElectroCardioGramWaveformInterpolator::Serialize(src, dst);
}
bool SEElectroCardioGramInterpolator::Load(const CDM::ElectroCardioGramWaveformInterpolatorData& in)
void SEElectroCardioGramWaveformInterpolator::Serialize(const cdm::ElectroCardioGramWaveformListData& src, SEElectroCardioGramWaveformInterpolator& dst)
{
Clear();
for (auto& w : in.Waveform())
dst.Clear();
for (int i = 0; i<src.waveform_size(); i++)
{
SEElectroCardioGramInterpolatorWaveform* waveform = new SEElectroCardioGramInterpolatorWaveform(GetLogger());
if (!waveform->Load(w))
{
Error("Unable to load waveform");
return false;
}
else
m_Waveforms[waveform->GetLeadNumber()][waveform->GetRhythm()] = waveform;
SEElectroCardioGramWaveform* waveform = new SEElectroCardioGramWaveform(dst.GetLogger());
SEElectroCardioGramWaveform::Load(src.waveform()[i], *waveform);
dst.m_Waveforms[waveform->GetLeadNumber()][waveform->GetRhythm()] = waveform;
}
return true;
}
CDM::ElectroCardioGramWaveformInterpolatorData* SEElectroCardioGramInterpolator::Unload() const
cdm::ElectroCardioGramWaveformListData* SEElectroCardioGramWaveformInterpolator::Unload(const SEElectroCardioGramWaveformInterpolator& src)
{
CDM::ElectroCardioGramWaveformInterpolatorData* data(new CDM::ElectroCardioGramWaveformInterpolatorData());
Unload(*data);
return data;
cdm::ElectroCardioGramWaveformListData* dst = new cdm::ElectroCardioGramWaveformListData();
SEElectroCardioGramWaveformInterpolator::Serialize(src, *dst);
return dst;
}
void SEElectroCardioGramInterpolator::Unload(CDM::ElectroCardioGramWaveformInterpolatorData& data) const
void SEElectroCardioGramWaveformInterpolator::Serialize(const SEElectroCardioGramWaveformInterpolator& src, cdm::ElectroCardioGramWaveformListData& dst)
{
for (auto i : m_Waveforms)
for (auto i : src.m_Waveforms)
for (auto j : i.second)
data.Waveform().push_back(std::unique_ptr<CDM::ElectroCardioGramInterpolationWaveformData>(j.second->Unload()));
dst.mutable_waveform()->AddAllocated(SEElectroCardioGramWaveform::Unload(*j.second));
}
bool SEElectroCardioGramWaveformInterpolator::LoadFile(const std::string& file, const SEScalarTime* timeStep)
{
Clear();
cdm::ElectroCardioGramWaveformListData src;
std::ifstream file_stream(file, std::ios::in);
std::string fmsg((std::istreambuf_iterator<char>(file_stream)), std::istreambuf_iterator<char>());
if (!google::protobuf::TextFormat::ParseFromString(fmsg, &src))
return false;
SEElectroCardioGramWaveformInterpolator::Load(src, *this);
// If its a binary string in the file...
//std::ifstream binary_istream(patientFile, std::ios::in | std::ios::binary);
//src.ParseFromIstream(&binary_istream);
if (timeStep != nullptr)
Interpolate(*timeStep);
return true;
}
void SEElectroCardioGramInterpolator::Interpolate(const SEScalarTime& timeStep)
void SEElectroCardioGramWaveformInterpolator::Interpolate(const SEScalarTime& timeStep)
{
for (auto& l : m_Waveforms)
for(auto& w : l.second)
if (w.second!=nullptr)
Interpolate(*w.second, timeStep);
}
void SEElectroCardioGramInterpolator::Interpolate(SEElectroCardioGramInterpolatorWaveform& w, const SEScalarTime& timeStep)
void SEElectroCardioGramWaveformInterpolator::Interpolate(SEElectroCardioGramWaveform& w, const SEScalarTime& timeStep)
{
SEFunctionElectricPotentialVsTime& data = w.GetData();
SEScalarTime* waveformTimeStep = nullptr;
......@@ -135,12 +119,14 @@ void SEElectroCardioGramInterpolator::Interpolate(SEElectroCardioGramInterpolato
currentTime_s += timeStep_s;
}
SEFunctionElectricPotentialVsTime* iWaveForm = data.InterpolateToTime(iTime, TimeUnit::s); // creates the new waveform data
CDM_COPY(iWaveForm, (&data));
cdm::FunctionElectricPotentialVsTimeData* wfData = SEFunctionElectricPotentialVsTime::Unload(*iWaveForm);
SEFunctionElectricPotentialVsTime::Load(*wfData, data);
delete wfData;
delete iWaveForm;
}
}
bool SEElectroCardioGramInterpolator::CanInterpolateLeadPotential(CDM::ElectroCardioGramWaveformLeadNumber lead, cdm::eHeartRhythm rhythm) const
bool SEElectroCardioGramWaveformInterpolator::CanInterpolateLeadPotential(cdm::ElectroCardioGramWaveformData_eLead lead, cdm::eHeartRhythm rhythm) const
{
if (!HasWaveform(lead, rhythm))
return false;
......@@ -149,12 +135,12 @@ bool SEElectroCardioGramInterpolator::CanInterpolateLeadPotential(CDM::ElectroCa
return false;
return l->second != nullptr;
}
void SEElectroCardioGramInterpolator::SetLeadElectricPotential(CDM::ElectroCardioGramWaveformLeadNumber lead, SEScalarElectricPotential& ep)
void SEElectroCardioGramWaveformInterpolator::SetLeadElectricPotential(cdm::ElectroCardioGramWaveformData_eLead lead, SEScalarElectricPotential& ep)
{
m_Leads[lead] = &ep;
}
bool SEElectroCardioGramInterpolator::StartNewCycle(cdm::eHeartRhythm rhythm)
bool SEElectroCardioGramWaveformInterpolator::StartNewCycle(cdm::eHeartRhythm rhythm)
{
for (auto l2rw : m_Waveforms)
{
......@@ -178,7 +164,7 @@ bool SEElectroCardioGramInterpolator::StartNewCycle(cdm::eHeartRhythm rhythm)
/// CalculateWaveform takes data from all active iterators and sums them together. It also assigns
/// the unit of millivolts to the output. If there are no active iterators, the output defaults to 0.
//--------------------------------------------------------------------------------------------------
void SEElectroCardioGramInterpolator::CalculateWaveformsElectricPotential()
void SEElectroCardioGramWaveformInterpolator::CalculateWaveformsElectricPotential()
{
// Pull Data from our iterators
int idx;
......@@ -193,7 +179,7 @@ void SEElectroCardioGramInterpolator::CalculateWaveformsElectricPotential()
for (auto & r2w : m_Waveforms[l2s.first])//rhythm to indecies
{
int i = 0;
SEElectroCardioGramInterpolatorWaveform* waveform = r2w.second;
SEElectroCardioGramWaveform* waveform = r2w.second;
if (waveform == nullptr)
continue;
SEFunctionElectricPotentialVsTime& data = waveform->GetData();
......@@ -212,7 +198,7 @@ void SEElectroCardioGramInterpolator::CalculateWaveformsElectricPotential()
}
bool SEElectroCardioGramInterpolator::HasWaveform(CDM::ElectroCardioGramWaveformLeadNumber lead, cdm::eHeartRhythm rhythm) const
bool SEElectroCardioGramWaveformInterpolator::HasWaveform(cdm::ElectroCardioGramWaveformData_eLead lead, cdm::eHeartRhythm rhythm) const
{
auto l = m_Waveforms.find(lead);
if (l == m_Waveforms.end())
......@@ -222,17 +208,17 @@ bool SEElectroCardioGramInterpolator::HasWaveform(CDM::ElectroCardioGramWaveform
return false;
return w->second != nullptr;
}
SEElectroCardioGramInterpolatorWaveform& SEElectroCardioGramInterpolator::GetWaveform(CDM::ElectroCardioGramWaveformLeadNumber lead, cdm::eHeartRhythm rhythm)
SEElectroCardioGramWaveform& SEElectroCardioGramWaveformInterpolator::GetWaveform(cdm::ElectroCardioGramWaveformData_eLead lead, cdm::eHeartRhythm rhythm)
{
SEElectroCardioGramInterpolatorWaveform* w = m_Waveforms[lead][rhythm];
SEElectroCardioGramWaveform* w = m_Waveforms[lead][rhythm];
if (w == nullptr)
{
w = new SEElectroCardioGramInterpolatorWaveform(GetLogger());
w = new SEElectroCardioGramWaveform(GetLogger());
m_Waveforms[lead][rhythm] = w;
}
return *w;
}
const SEElectroCardioGramInterpolatorWaveform* SEElectroCardioGramInterpolator::GetWaveform(CDM::ElectroCardioGramWaveformLeadNumber lead, cdm::eHeartRhythm rhythm) const
const SEElectroCardioGramWaveform* SEElectroCardioGramWaveformInterpolator::GetWaveform(cdm::ElectroCardioGramWaveformData_eLead lead, cdm::eHeartRhythm rhythm) const
{
auto l = m_Waveforms.find(lead);
if (l == m_Waveforms.end())
......@@ -242,7 +228,7 @@ const SEElectroCardioGramInterpolatorWaveform* SEElectroCardioGramInterpolator::
return nullptr;
return w->second;
}
void SEElectroCardioGramInterpolator::RemoveWaveform(CDM::ElectroCardioGramWaveformLeadNumber lead, cdm::eHeartRhythm rhythm)
void SEElectroCardioGramWaveformInterpolator::RemoveWaveform(cdm::ElectroCardioGramWaveformData_eLead lead, cdm::eHeartRhythm rhythm)
{
auto l = m_Waveforms.find(lead);
if (l == m_Waveforms.end())
......
......@@ -11,30 +11,26 @@ specific language governing permissions and limitations under the License.
**************************************************************************************/
#pragma once
class SEElectroCardioGramInterpolatorWaveform;
#include "system/equipment/ElectroCardioGram/SEElectroCardioGramWaveform.h"
class DLL_DECL SEElectroCardioGramInterpolator : public Loggable
class DLL_DECL SEElectroCardioGramWaveformInterpolator : public Loggable
{
public:
SEElectroCardioGramInterpolator(Logger* logger);
virtual ~SEElectroCardioGramInterpolator();
SEElectroCardioGramWaveformInterpolator(Logger* logger);
virtual ~SEElectroCardioGramWaveformInterpolator();
virtual void Clear();// Deletes all members
static void Load(const cdm::PatientData& src, SEPatient& dst);
static cdm::PatientData* Unload(const SEPatient& src);
static void Load(const cdm::ElectroCardioGramWaveformListData& src, SEElectroCardioGramWaveformInterpolator& dst);
static cdm::ElectroCardioGramWaveformListData* Unload(const SEElectroCardioGramWaveformInterpolator& src);
protected:
static void Serialize(const cdm::PatientData& src, SEPatient& dst);
static void Serialize(const SEPatient& src, cdm::PatientData& dst);
virtual bool LoadWaveforms(const std::string& file, const SEScalarTime* timeStep = nullptr);
virtual bool Load(const CDM::ElectroCardioGramWaveformInterpolatorData& in);
virtual CDM::ElectroCardioGramWaveformInterpolatorData* Unload() const;
protected:
virtual void Unload(CDM::ElectroCardioGramWaveformInterpolatorData& data) const;
static void Serialize(const cdm::ElectroCardioGramWaveformListData& src, SEElectroCardioGramWaveformInterpolator& dst);
static void Serialize(const SEElectroCardioGramWaveformInterpolator& src, cdm::ElectroCardioGramWaveformListData& dst);
virtual bool LoadFile(const std::string& file, const SEScalarTime* timeStep = nullptr);
public:
virtual void Interpolate(const SEScalarTime& timeStep);
virtual bool StartNewCycle(cdm::eHeartRhythm rhythm);
......@@ -42,19 +38,19 @@ public:
// These are where the interpolator will put the interpolated electric potential data for each lead when you call CalculateWaveformsElectricPotential
// You must have a waveform for the lead of the current rhythm for these scalars to be populated
virtual bool CanInterpolateLeadPotential(CDM::ElectroCardioGramWaveformLeadNumber lead, cdm::eHeartRhythm rhythm) const;
virtual void SetLeadElectricPotential(CDM::ElectroCardioGramWaveformLeadNumber lead, SEScalarElectricPotential& ep);
virtual bool CanInterpolateLeadPotential(cdm::ElectroCardioGramWaveformData_eLead lead, cdm::eHeartRhythm rhythm) const;
virtual void SetLeadElectricPotential(cdm::ElectroCardioGramWaveformData_eLead lead, SEScalarElectricPotential& ep);
virtual bool HasWaveform(CDM::ElectroCardioGramWaveformLeadNumber lead, cdm::eHeartRhythm rhythm) const;
virtual SEElectroCardioGramInterpolatorWaveform& GetWaveform(CDM::ElectroCardioGramWaveformLeadNumber lead, cdm::eHeartRhythm rhythm);
virtual const SEElectroCardioGramInterpolatorWaveform* GetWaveform(CDM::ElectroCardioGramWaveformLeadNumber lead, cdm::eHeartRhythm rhythm) const;
virtual void RemoveWaveform(CDM::ElectroCardioGramWaveformLeadNumber lead, cdm::eHeartRhythm rhythm);
virtual bool HasWaveform(cdm::ElectroCardioGramWaveformData_eLead lead, cdm::eHeartRhythm rhythm) const;
virtual SEElectroCardioGramWaveform& GetWaveform(cdm::ElectroCardioGramWaveformData_eLead lead, cdm::eHeartRhythm rhythm);
virtual const SEElectroCardioGramWaveform* GetWaveform(cdm::ElectroCardioGramWaveformData_eLead lead, cdm::eHeartRhythm rhythm) const;
virtual void RemoveWaveform(cdm::ElectroCardioGramWaveformData_eLead lead, cdm::eHeartRhythm rhythm);
protected:
virtual void Interpolate(SEElectroCardioGramInterpolatorWaveform& waveform, const SEScalarTime& timeStep);
virtual void Interpolate(SEElectroCardioGramWaveform& waveform, const SEScalarTime& timeStep);
std::map<CDM::ElectroCardioGramWaveformLeadNumber, SEScalarElectricPotential*> m_Leads;
std::map<CDM::ElectroCardioGramWaveformLeadNumber, std::map<CDM::enumHeartRhythm, SEElectroCardioGramInterpolatorWaveform*>> m_Waveforms;
std::map<cdm::ElectroCardioGramWaveformData_eLead, SEScalarElectricPotential*> m_Leads;
std::map<cdm::ElectroCardioGramWaveformData_eLead, std::map<cdm::eHeartRhythm, SEElectroCardioGramWaveform*>> m_Waveforms;
};
\ No newline at end of file
......@@ -37,11 +37,11 @@ SEBloodChemistrySystem::SEBloodChemistrySystem(Logger* logger) : SESystem(logger
m_PlasmaVolume = nullptr;