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

BasicStandard passes now, Serialization does something.. but it's not right

parent a2c84575
<?xml version="1.0" encoding="UTF-8"?>
<Scenario xmlns="uri:/mil/tatrc/physiology/datamodel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" contentVersion="BioGears_6.1.0-beta" xsi:schemaLocation="">
<Name>InitialStableState</Name>
<Description>Start the engine at a state, this is for debugging said state</Description>
<EngineStateFile>./states/testing/Inhaler_OneActuation@31.xml</EngineStateFile>
<!--
<AutoSerialization>
<Directory>./states/testing/</Directory>
<FileName>Loaded_Inhaler_OneActuation</FileName>
<AfterActions>On</AfterActions>
<Period value="1" unit="s"/>
<PeriodTimeStamps>On</PeriodTimeStamps>
<ReloadState>On</ReloadState>
</AutoSerialization>
-->
<Action xsi:type="AdvanceTimeData">
<Time value="2" unit="min"/>
</Action>
</Scenario>
Name: "BasicStandard"
Description: "Basic scenario measuring patient vitals with no insults or interventions"
EngineStateFile :"./states/StandardMale@0s.pba"
# Base system data required for all scenario verification
DataRequestManager
{
DataRequest { Category:Patient PropertyName:"Weight" Unit:"kg" DecimalFormat{Precision:1} }
DataRequest { Category:Physiology PropertyName:"HeartRate" Unit:"1/min" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"HeartStrokeVolume" Unit:"mL" DecimalFormat{Precision:1} }
DataRequest { Category:Physiology PropertyName:"BloodVolume" Unit:"L" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"ExtravascularFluidVolume" Unit:"L" DecimalFormat{Precision:1} }
DataRequest { Category:Physiology PropertyName:"ArterialPressure" Unit:"mmHg" DecimalFormat{Precision:1} }
DataRequest { Category:Physiology PropertyName:"MeanArterialPressure" Unit:"mmHg" DecimalFormat{Precision:1} }
DataRequest { Category:Physiology PropertyName:"SystolicArterialPressure" Unit:"mmHg" DecimalFormat{Precision:0} }
DataRequest { Category:Physiology PropertyName:"DiastolicArterialPressure" Unit:"mmHg" DecimalFormat{Precision:1} }
DataRequest { Category:Physiology PropertyName:"CardiacOutput" Unit:"L/min" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"HemoglobinContent" Unit:"g" DecimalFormat{Precision:0} }
DataRequest { Category:Physiology PropertyName:"CentralVenousPressure" Unit:"mmHg" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"PulmonaryCapillariesWedgePressure" Unit:"mmHg" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"TidalVolume" Unit:"mL" DecimalFormat{Precision:3} }
DataRequest { Category:Physiology PropertyName:"TotalLungVolume" Unit:"L" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"RespirationRate" Unit:"1/min" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"OxygenSaturation" Unit:"unitless" DecimalFormat{Precision:3} }
DataRequest { Category:Physiology PropertyName:"CarbonDioxideSaturation" Unit:"unitless" DecimalFormat{Precision:3} }
DataRequest { Category:Physiology PropertyName:"EndTidalCarbonDioxideFraction" Unit:"unitless" DecimalFormat{Precision:4} }
DataRequest { Category:Physiology PropertyName:"TotalAlveolarVentilation" Unit:"L/min" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"TranspulmonaryPressure" Unit:"cmH2O" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"CoreTemperature" Unit:"degC" DecimalFormat{Precision:1} }
DataRequest { Category:Physiology PropertyName:"SkinTemperature" Unit:"degC" DecimalFormat{Precision:1} }
DataRequest { Category:Physiology PropertyName:"RespiratoryExchangeRatio" Unit:"unitless" DecimalFormat{Precision:3} }
DataRequest { Category:Physiology PropertyName:"OxygenConsumptionRate" Unit:"mL/min" DecimalFormat{Precision:0} }
DataRequest { Category:Physiology PropertyName:"CarbonDioxideProductionRate" Unit:"mL/min" DecimalFormat{Precision:0} }
DataRequest { Category:Physiology PropertyName:"GlomerularFiltrationRate" Unit:"mL/min" DecimalFormat{Precision:0} }
DataRequest { Category:Physiology PropertyName:"RenalBloodFlow" Unit:"L/min" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"UrineProductionRate" Unit:"mL/min" DecimalFormat{Precision:3} }
DataRequest { Category:Physiology PropertyName:"LeftAfferentArterioleResistance" Unit:"mmHg min/mL" DecimalFormat{Precision:4} }
DataRequest { Category:Physiology PropertyName:"RightAfferentArterioleResistance" Unit:"mmHg min/mL" DecimalFormat{Precision:4} }
DataRequest { Category:GasCompartment CompartmentName:"LeftAlveoli" PropertyName:"Pressure" Unit:"cmH2O" DecimalFormat{Precision:0} }
DataRequest { Category:GasCompartment CompartmentName:"LeftAlveoli" SubstanceName:"Oxygen" PropertyName:"PartialPressure" Unit:"mmHg" DecimalFormat{Precision:0} }
DataRequest { Category:GasCompartment CompartmentName:"LeftAlveoli" SubstanceName:"CarbonDioxide" PropertyName:"PartialPressure" Unit:"mmHg" DecimalFormat{Precision:1} }
DataRequest { Category:GasCompartment CompartmentName:"RightAlveoli" PropertyName:"Pressure" Unit:"cmH2O" DecimalFormat{Precision:0} }
DataRequest { Category:GasCompartment CompartmentName:"RightAlveoli" SubstanceName:"Oxygen" PropertyName:"PartialPressure" Unit:"mmHg" DecimalFormat{Precision:0} }
DataRequest { Category:GasCompartment CompartmentName:"RightAlveoli" SubstanceName:"CarbonDioxide" PropertyName:"PartialPressure" Unit:"mmHg" DecimalFormat{Precision:1} }
DataRequest { Category:GasCompartment CompartmentName:"Carina" SubstanceName:"Oxygen" PropertyName:"PartialPressure" Unit:"cmH2O" DecimalFormat{Precision:0} }
DataRequest { Category:GasCompartment CompartmentName:"Carina" SubstanceName:"CarbonDioxide" PropertyName:"PartialPressure" Unit:"cmH2O" DecimalFormat{Precision:1} }
DataRequest { Category:LiquidCompartment CompartmentName:"Aorta" SubstanceName:"Oxygen" PropertyName:"PartialPressure" Unit:"mmHg" DecimalFormat{Precision:1} }
DataRequest { Category:LiquidCompartment CompartmentName:"Aorta" SubstanceName:"CarbonDioxide" PropertyName:"PartialPressure" Unit:"mmHg" DecimalFormat{Precision:1} }
DataRequest { Category:LiquidCompartment CompartmentName:"VenaCava" SubstanceName:"Oxygen" PropertyName:"PartialPressure" Unit:"mmHg" DecimalFormat{Precision:1} }
DataRequest { Category:LiquidCompartment CompartmentName:"VenaCava" SubstanceName:"CarbonDioxide" PropertyName:"PartialPressure" Unit:"mmHg" DecimalFormat{Precision:1} }
DataRequest { Category:LiquidCompartment CompartmentName:"RightTubules" SubstanceName:"Sodium" PropertyName:"Concentration" Unit:"g/L" DecimalFormat{Precision:2} }
DataRequest { Category:LiquidCompartment CompartmentName:"LeftTubules" SubstanceName:"Sodium" PropertyName:"Concentration" Unit:"g/L" DecimalFormat{Precision:2} }
DataRequest { Category:Substance SubstanceName:"Oxygen" PropertyName:"AlveolarTransfer" Unit:"mL/s" DecimalFormat{Precision:2} }
DataRequest { Category:Substance SubstanceName:"CarbonDioxide" PropertyName:"AlveolarTransfer" Unit:"mL/s" DecimalFormat{Precision:2} }
DataRequest { Category:Substance SubstanceName:"Epinephrine" PropertyName:"BloodConcentration" Unit:"ug/L" DecimalFormat{Precision:6} }
# Specific to this scenario
DataRequest { Category:Substance SubstanceName:"Epinephrine" PropertyName:"SystemicMassCleared" Unit:"ug" DecimalFormat{Precision:8} }
DataRequest { Category:Physiology PropertyName:"ChymeAbsorbtionRate" Unit:"mL/min" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"StomachContents-Carbohydrate" Unit:"g" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"StomachContents-Fat" Unit:"g" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"StomachContents-Protein" Unit:"g" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"StomachContents-Calcium" Unit:"g" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"StomachContents-Sodium" Unit:"g" DecimalFormat{Precision:2} }
DataRequest { Category:Physiology PropertyName:"StomachContents-Water" Unit:"mL" DecimalFormat{Precision:0} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineChyme" PropertyName:"Volume" Unit:"mL" DecimalFormat{Precision:0} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineChyme" SubstanceName:"Glucose" PropertyName:"Mass" Unit:"g" DecimalFormat{Precision:2} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineChyme" SubstanceName:"Tristearin" PropertyName:"Mass" Unit:"g" DecimalFormat{Precision:2} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineChyme" SubstanceName:"Calcium" PropertyName:"Mass" Unit:"g" DecimalFormat{Precision:2} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineChyme" SubstanceName:"Sodium" PropertyName:"Mass" Unit:"g" DecimalFormat{Precision:2} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineChyme" SubstanceName:"Urea" PropertyName:"Mass" Unit:"g" DecimalFormat{Precision:2} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineVasculature" PropertyName:"Volume" Unit:"mL" DecimalFormat{Precision:0} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineVasculature" PropertyName:"Pressure" Unit:"mmHg" DecimalFormat{Precision:1} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineVasculature" SubstanceName:"Glucose" PropertyName:"Concentration" Unit:"mg/dL" DecimalFormat{Precision:1} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineVasculature" SubstanceName:"Tristearin" PropertyName:"Concentration" Unit:"mg/dL" DecimalFormat{Precision:0} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineVasculature" SubstanceName:"Calcium" PropertyName:"Concentration" Unit:"mg/L" DecimalFormat{Precision:1} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineVasculature" SubstanceName:"Sodium" PropertyName:"Concentration" Unit:"g/L" DecimalFormat{Precision:2} }
DataRequest { Category:LiquidCompartment CompartmentName:"SmallIntestineVasculature" SubstanceName:"Urea" PropertyName:"Concentration" Unit:"mg/dL" DecimalFormat{Precision:1} }
# Data needed for scenario condition validation
DataRequest { Category:Physiology PropertyName:"HeartEjectionFraction" DecimalFormat{Precision:3} }
DataRequest { Category:Physiology PropertyName:"SystemicVascularResistance" Unit:"mmHg s/mL" DecimalFormat{Precision:3} }
DataRequest { Category:LiquidCompartment CompartmentName:"Pericardium" PropertyName:"Volume" Unit:"mL" DecimalFormat{Precision:0} }
DataRequest { Category:LiquidCompartment CompartmentName:"Pericardium" PropertyName:"Pressure" Unit:"mmHg" DecimalFormat{Precision:2} }
}
AnyAction
{
AdvanceTime
{
Time { ScalarTime {Value: 2.0 Unit: "min"} }
}
}
......@@ -4,5 +4,5 @@ InitialParameters { PatientFile:"StandardMale.pba" }
AnyAction
{
SerializeStateData { }
Serialize { }
}
......@@ -69,7 +69,7 @@ public:
/// Engine will be in a cleared state if this method fails.
/// Note the provided configuration will overwrite any configuration options in the state with its contents (Use with caution!)
//--------------------------------------------------------------------------------------------------
virtual bool LoadState(const std::string& file, const SEScalarTime* simTime=nullptr, const SEEngineConfiguration* config = nullptr) = 0;
virtual bool LoadStateFile(const std::string& filename, const SEScalarTime* simTime=nullptr, const SEEngineConfiguration* config = nullptr) = 0;
//--------------------------------------------------------------------------------------------------
/// \brief
......@@ -89,7 +89,7 @@ public:
/// State object will be returned.
/// Engine will be in a cleared state if this method fails.
//--------------------------------------------------------------------------------------------------
virtual std::unique_ptr<google::protobuf::Message> SaveState(const std::string& file = "") = 0;
virtual std::unique_ptr<google::protobuf::Message> SaveState(const std::string& filename = "") = 0;
//--------------------------------------------------------------------------------------------------
/// \brief
......
......@@ -145,7 +145,7 @@ cdm::NutritionData* SENutrition::Unload(const SENutrition& src)
void SENutrition::Serialize(const SENutrition& src, cdm::NutritionData& dst)
{
if (src.HasCarbohydrate())
dst.set_allocated_calcium(SEScalarMass::Unload(*src.m_Carbohydrate));
dst.set_allocated_carbohydrate(SEScalarMass::Unload(*src.m_Carbohydrate));
if (src.HasCarbohydrateDigestionRate())
dst.set_allocated_carbohydratedigestionrate(SEScalarMassPerTime::Unload(*src.m_CarbohydrateDigestionRate));
if (src.HasFat())
......
......@@ -37,6 +37,34 @@ void SEActionManager::Clear()
m_ProcessedActions.Clear();// amb Does this delete?
}
void SEActionManager::Load(const cdm::ActionListData& src, SEActionManager& dst)
{
SEActionManager::Serialize(src, dst);
}
void SEActionManager::Serialize(const cdm::ActionListData& src, SEActionManager& dst)
{
for (int i = 0; i < src.anyaction_size(); i++)
{
SEAction* a = SEAction::Load(src.anyaction()[i], dst.m_Substances);
dst.ProcessAction(*a);
delete a;
}
}
cdm::ActionListData* SEActionManager::Unload(const SEActionManager& src)
{
cdm::ActionListData* dst = new cdm::ActionListData();
SEActionManager::Serialize(src, *dst);
return dst;
}
void SEActionManager::Serialize(const SEActionManager& src, cdm::ActionListData& dst)
{
SEPatientActionCollection::Serialize(src.m_PatientActions, dst);
SEEnvironmentActionCollection::Serialize(src.m_EnvironmentActions, dst);
SEAnesthesiaMachineActionCollection::Serialize(src.m_AnesthesiaMachineActions, dst);
SEInhalerActionCollection::Serialize(src.m_InhalerActions, dst);
}
bool SEActionManager::ProcessAction(const SEAction& action)
{
if (!action.IsValid())
......
......@@ -28,6 +28,14 @@ public:
void Clear();
static void Load(const cdm::ActionListData& src, SEActionManager& dst);
static cdm::ActionListData* Unload(const SEActionManager& src);
protected:
static void Serialize(const cdm::ActionListData& src, SEActionManager& dst);
static void Serialize(const SEActionManager& src, cdm::ActionListData& dst);
public:
bool ProcessAction(const SEAction& action);// Will make a copy
SEPatientActionCollection& GetPatientActions() { return m_PatientActions; }
......
......@@ -64,6 +64,38 @@ void SEAnesthesiaMachineActionCollection::Clear()
RemoveYPieceDisconnect();
}
void SEAnesthesiaMachineActionCollection::Serialize(const SEAnesthesiaMachineActionCollection& src, cdm::ActionListData& dst)
{
if (src.HasConfiguration())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_Configuration));
if (src.HasOxygenTankPressureLoss())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_OxygenTankPressureLoss));
if (src.HasOxygenWallPortPressureLoss())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_OxygenWallPortPressureLoss));
if (src.HasExpiratoryValveLeak())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_ExpiratoryValveLeak));
if (src.HasExpiratoryValveObstruction())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_ExpiratoryValveObstruction));
if (src.HasInspiratoryValveLeak())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_InspiratoryValveLeak));
if (src.HasInspiratoryValveObstruction())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_InspiratoryValveObstruction));
if (src.HasMaskLeak())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_MaskLeak));
if (src.HasSodaLimeFailure())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_SodaLimeFailure));
if (src.HasTubeCuffLeak())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_TubeCuffLeak));
if (src.HasVaporizerFailure())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_VaporizerFailure));
if (src.HasVentilatorPressureLoss())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_VentilatorPressureLoss));
if (src.HasYPieceDisconnect())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_YPieceDisconnect));
}
bool SEAnesthesiaMachineActionCollection::ProcessAction(const SEAnesthesiaMachineAction& action, cdm::AnyAnesthesiaMachineActionData& any)
{
const SEAnesthesiaMachineConfiguration* config = dynamic_cast<const SEAnesthesiaMachineConfiguration*>(&action);
......@@ -252,7 +284,7 @@ void SEAnesthesiaMachineActionCollection::RemoveOxygenTankPressureLoss()
SAFE_DELETE(m_OxygenTankPressureLoss);
}
bool SEAnesthesiaMachineActionCollection::HasOxygenWallPortPressureLoss()
bool SEAnesthesiaMachineActionCollection::HasOxygenWallPortPressureLoss() const
{
return m_OxygenWallPortPressureLoss == nullptr ? false : true;
}
......
......@@ -47,7 +47,7 @@ public:
SEOxygenTankPressureLoss* GetOxygenTankPressureLoss() const;
void RemoveOxygenTankPressureLoss();
bool HasOxygenWallPortPressureLoss();
bool HasOxygenWallPortPressureLoss() const;
SEOxygenWallPortPressureLoss* GetOxygenWallPortPressureLoss();
void RemoveOxygenWallPortPressureLoss();
......@@ -95,6 +95,7 @@ public:
protected:
void Clear();
static void Serialize(const SEAnesthesiaMachineActionCollection& src, cdm::ActionListData& dst);
bool ProcessAction(const SEAnesthesiaMachineAction& action, cdm::AnyAnesthesiaMachineActionData& any);
SEAnesthesiaMachineConfiguration* m_Configuration;
......
......@@ -45,6 +45,48 @@ void SEConditionManager::Clear()
m_Conditions.Clear(); // amd does this delete?
}
void SEConditionManager::Load(const cdm::ConditionListData& src, SEConditionManager& dst)
{
SEConditionManager::Serialize(src, dst);
}
void SEConditionManager::Serialize(const cdm::ConditionListData& src, SEConditionManager& dst)
{
for (int i = 0; i < src.anycondition_size(); i++)
{
SECondition* c = SECondition::Load(src.anycondition()[i],dst.m_Substances);
dst.ProcessCondition(*c);
delete c;
}
}
cdm::ConditionListData* SEConditionManager::Unload(const SEConditionManager& src)
{
cdm::ConditionListData* dst = new cdm::ConditionListData();
SEConditionManager::Serialize(src, *dst);
return dst;
}
void SEConditionManager::Serialize(const SEConditionManager& src, cdm::ConditionListData& dst)
{
if (src.HasChronicAnemia())
dst.mutable_anycondition()->AddAllocated(SECondition::Unload(*src.m_Anemia));
if (src.HasConsumeMeal())
dst.mutable_anycondition()->AddAllocated(SECondition::Unload(*src.m_ConsumeMeal));
if (src.HasChronicObstructivePulmonaryDisease())
dst.mutable_anycondition()->AddAllocated(SECondition::Unload(*src.m_COPD));
if (src.HasChronicVentricularSystolicDysfunction())
dst.mutable_anycondition()->AddAllocated(SECondition::Unload(*src.m_ChronicVentricularSystolicDysfunction));
if (src.HasImpairedAlveolarExchange())
dst.mutable_anycondition()->AddAllocated(SECondition::Unload(*src.m_ImpairedAlveolarExchange));
if (src.HasChronicPericardialEffusion())
dst.mutable_anycondition()->AddAllocated(SECondition::Unload(*src.m_PericardialEffusion));
if (src.HasLobarPneumonia())
dst.mutable_anycondition()->AddAllocated(SECondition::Unload(*src.m_LobarPneumonia));
if (src.HasChronicRenalStenosis())
dst.mutable_anycondition()->AddAllocated(SECondition::Unload(*src.m_RenalStenosis));
if (src.HasInitialEnvironmentConditions())
dst.mutable_anycondition()->AddAllocated(SECondition::Unload(*src.m_InitialEnvironmentConditions));
}
bool SEConditionManager::ProcessCondition(const SECondition& condition)
{
if (!condition.IsValid())
......
......@@ -35,6 +35,14 @@ public:
void Clear();
static void Load(const cdm::ConditionListData& src, SEConditionManager& dst);
static cdm::ConditionListData* Unload(const SEConditionManager& src);
protected:
static void Serialize(const cdm::ConditionListData& src, SEConditionManager& dst);
static void Serialize(const SEConditionManager& src, cdm::ConditionListData& dst);
public:
bool ProcessCondition(const SECondition& condition);// Will make a copy
// Not too many conditions, so just have one manager
......@@ -73,7 +81,7 @@ public:
SEInitialEnvironmentConditions* GetInitialEnvironmentConditions() const;
// This is here in case you want to take all the conditions from an engine and write them out so you can reproduce the same engine state later
const cdm::ConditionListData& GetActionList() { return m_Conditions; }// I don't really have anything that does that yet...
const cdm::ConditionListData& GetConditionList() { return m_Conditions; }// I don't really have anything that does that yet...
protected:
......
......@@ -38,6 +38,14 @@ void SEEnvironmentActionCollection::Clear()
RemoveThermalApplication();
}
void SEEnvironmentActionCollection::Serialize(const SEEnvironmentActionCollection& src, cdm::ActionListData& dst)
{
if (src.HasChange())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_Change));
if (src.HasThermalApplication())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_ThermalApplication));
}
bool SEEnvironmentActionCollection::ProcessAction(const SEEnvironmentAction& action, cdm::AnyEnvironmentActionData& any)
{
const SEChangeEnvironmentConditions* conditions = dynamic_cast<const SEChangeEnvironmentConditions*>(&action);
......
......@@ -34,6 +34,7 @@ public:
protected:
void Clear();
static void Serialize(const SEEnvironmentActionCollection& src, cdm::ActionListData& dst);
bool ProcessAction(const SEEnvironmentAction& action, cdm::AnyEnvironmentActionData& any);
SEChangeEnvironmentConditions* m_Change;
......
......@@ -30,6 +30,11 @@ void SEInhalerActionCollection::Clear()
RemoveConfiguration();
}
void SEInhalerActionCollection::Serialize(const SEInhalerActionCollection& src, cdm::ActionListData& dst)
{
if (src.HasConfiguration())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_Configuration));
}
bool SEInhalerActionCollection::ProcessAction(const SEInhalerAction& action, cdm::AnyInhalerActionData& any)
{
......
......@@ -31,6 +31,7 @@ public:
protected:
void Clear();
static void Serialize(const SEInhalerActionCollection& src, cdm::ActionListData& dst);
bool ProcessAction(const SEInhalerAction& action, cdm::AnyInhalerActionData& any);
SEInhalerConfiguration* m_Configuration;
......
......@@ -80,6 +80,67 @@ void SEPatientActionCollection::Clear()
DELETE_MAP_SECOND(m_SubstanceCompoundInfusions);
}
void SEPatientActionCollection::Serialize(const SEPatientActionCollection& src, cdm::ActionListData& dst)
{
if (src.HasAcuteStress())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_AcuteStress));
if (src.HasAirwayObstruction())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_AirwayObstruction));
if (src.HasApnea())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_Apnea));
if (src.HasAsthmaAttack())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_AsthmaAttack));
if (src.HasBrainInjury())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_BrainInjury));
if (src.HasBronchoconstriction())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_Bronchoconstriction));
if (src.HasCardiacArrest())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_CardiacArrest));
if (src.HasChestCompression())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_ChestCompression));
if (src.HasLeftChestOcclusiveDressing())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_LeftChestOcclusiveDressing));
if (src.HasRightChestOcclusiveDressing())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_RightChestOcclusiveDressing));
if (src.HasConsciousRespiration())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_ConsciousRespiration));
if (src.HasConsumeNutrients())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_ConsumeNutrients));
if (src.HasExercise())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_Exercise));
if (src.HasHemorrhage())
{
for (auto itr : src.m_Hemorrhages)
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*itr.second));
}
if (src.HasIntubation())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_Intubation));
if (src.HasMechanicalVentilation())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_MechanicalVentilation));
if (src.HasLeftNeedleDecompression())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_LeftNeedleDecompression));
if (src.HasRightNeedleDecompression())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_RightNeedleDecompression));
if (src.HasPericardialEffusion())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_PericardialEffusion));
if (src.HasLeftClosedTensionPneumothorax())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_LeftClosedTensionPneumothorax));
if (src.HasLeftOpenTensionPneumothorax())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_LeftOpenTensionPneumothorax));
if (src.HasRightClosedTensionPneumothorax())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_RightClosedTensionPneumothorax));
if (src.GetRightClosedTensionPneumothorax())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_RightOpenTensionPneumothorax));
for (auto itr : src.m_SubstanceBolus)
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*itr.second));
for (auto itr : src.m_SubstanceInfusions)
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*itr.second));
for (auto itr : src.m_SubstanceCompoundInfusions)
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*itr.second));
if (src.HasUrinate())
dst.mutable_anyaction()->AddAllocated(SEAction::Unload(*src.m_Urinate));
}
bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, cdm::AnyPatientActionData& any)
{
......
......@@ -163,6 +163,7 @@ public:
protected:
void Clear();
static void Serialize(const SEPatientActionCollection& src, cdm::ActionListData& dst);
bool ProcessAction(const SEPatientAction& action, cdm::AnyPatientActionData& any);
SEAcuteStress* m_AcuteStress;
......
......@@ -91,7 +91,7 @@ bool SEScenarioExec::Execute(const SEScenario& scenario, const std::string& resu
// Initialize the engine with a state or initial parameters
if (scenario.HasEngineStateFile())
{
m_Engine.LoadState(scenario.GetEngineStateFile());
m_Engine.LoadStateFile(scenario.GetEngineStateFile());
// WE ARE OVERWRITING ANY DATA REQUESTS IN THE STATE WITH WHATS IN THE SCENARIO!!!
// Make a copy of the data requests, note this clears out data requests from the engine
cdm::DataRequestManagerData* drData = SEDataRequestManager::Unload(scenario.GetDataRequestManager());
......
......@@ -174,7 +174,7 @@ void SESubstanceClearance::Serialize(const cdm::SubstanceData_ClearanceData& src
dst.m_RenalDynamic = RenalDynamic::Regulation;
dst.SetChargeInBlood(src.renalclearance().regulation().chargeinblood());
SEScalar0To1::Load(src.renalclearance().regulation().fractionunboundinplasma(), dst.GetFractionUnboundInPlasma());
SEScalar::Load(src.renalclearance().regulation().reabsorptionratio(), dst.GetRenalReabsorptionRate());
SEScalar::Load(src.renalclearance().regulation().reabsorptionratio(), dst.GetRenalReabsorptionRatio());
SEScalarMassPerTime::Load(src.renalclearance().regulation().transportmaximum(), dst.GetRenalTransportMaximum());
}
else if (src.renalclearance().has_clearance())
......
......@@ -292,6 +292,7 @@ bool SESubstanceManager::LoadSubstanceDirectory()
}
SESubstance* sub = new SESubstance(GetLogger());
SESubstance::Load(*subData, *sub);
//SESubstance::Unload(*sub); // This is here to debug serialization if I have to
m_OriginalSubstanceData[sub] = subData;
AddSubstance(*sub);
}
......
......@@ -94,7 +94,7 @@ void SEElectroCardioGram::Serialize(const SEElectroCardioGram& src, cdm::Electro
{
if (src.HasLead1ElectricPotential())
dst.set_allocated_lead1electricpotential(SEScalarElectricPotential::Unload(*src.m_Lead1ElectricPotential));
if (src.HasLead3ElectricPotential())
if (src.HasLead2ElectricPotential())
dst.set_allocated_lead2electricpotential(SEScalarElectricPotential::Unload(*src.m_Lead2ElectricPotential));
if (src.HasLead3ElectricPotential())
dst.set_allocated_lead3electricpotential(SEScalarElectricPotential::Unload(*src.m_Lead3ElectricPotential));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment