From a9261bab65f3580b18c9bfe0d0526f24ff65686f Mon Sep 17 00:00:00 2001 From: Katie Mummah Date: Thu, 5 Sep 2024 13:37:24 -0500 Subject: [PATCH] move inv resource creation to Build from EnterNotify --- CHANGELOG.rst | 2 +- src/source.cc | 14 +++++++++++--- src/source.h | 4 ++++ src/source_tests.cc | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7b7b39630..2b65a2d37 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,7 +7,7 @@ Since last release **Added:** * Added package parameter to storage (#603, #612, #616) -* Added package parameter to source (#613, #617) +* Added package parameter to source (#613, #617, #623) * Added default keep packaging to reactor (#618, #619) **Changed:** diff --git a/src/source.cc b/src/source.cc index 99b578645..74eb03e56 100644 --- a/src/source.cc +++ b/src/source.cc @@ -54,20 +54,27 @@ std::string Source::str() { } void Source::EnterNotify() { + cyclus::Facility::EnterNotify(); + +} + +void Source::Build(cyclus::Agent* parent) { + Facility::Build(parent); + using cyclus::CompMap; using cyclus::Composition; using cyclus::Material; - cyclus::Facility::EnterNotify(); - RecordPosition(); // create all source inventory and place into buf cyclus::Material::Ptr all_inv; Composition::Ptr blank_comp = Composition::CreateFromMass(CompMap()); - all_inv = (outrecipe.empty() || context() == NULL) ? \ Material::Create(this, inventory_size, blank_comp) : \ Material::Create(this, inventory_size, context()->GetRecipe(outrecipe)); + std::cerr << "Source created all inv with state id " << all_inv->state_id() << std::endl; inventory.Push(all_inv); + + RecordPosition(); } std::set::Ptr> Source::GetMatlBids( @@ -152,6 +159,7 @@ void Source::GetMatlTrades( if (shippable_trades > 0) { double qty = it->amt; + std::cerr << "source trade amount " << qty << std::endl; Material::Ptr m = inventory.Pop(qty); std::vector m_pkgd = m->Package(context()->GetPackage(package)); diff --git a/src/source.h b/src/source.h index 0024f20f4..db179d93a 100644 --- a/src/source.h +++ b/src/source.h @@ -71,6 +71,10 @@ class Source : public cyclus::Facility, virtual void EnterNotify(); + /// --- Facility Members --- + /// perform module-specific tasks when entering the simulation + virtual void Build(cyclus::Agent* parent); + virtual void GetMatlTrades( const std::vector< cyclus::Trade >& trades, std::vector, diff --git a/src/source_tests.cc b/src/source_tests.cc index 10208e733..d2ea3ec2b 100644 --- a/src/source_tests.cc +++ b/src/source_tests.cc @@ -15,7 +15,7 @@ void SourceTest::SetUp() { trader = tc.trader(); InitParameters(); SetUpSource(); - src_facility->EnterNotify(); + src_facility->Build(NULL); } void SourceTest::TearDown() {