From 940eeb841928dc2c6a089f8f87738a8dfc3c53f1 Mon Sep 17 00:00:00 2001 From: MOUGINOT B Date: Fri, 23 Sep 2016 10:16:26 -0500 Subject: [PATCH 1/6] working group_inst --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b626877cf5..b265dd9f27 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,8 @@ USE_CYCLUS("cycamore" "deploy_inst") USE_CYCLUS("cycamore" "manager_inst") +USE_CYCLUS("cycamore" "group_inst") + USE_CYCLUS("cycamore" "growth_region") USE_CYCLUS("cycamore" "storage") From 08f4047552542ebe747def0ab848f8d6b1eefa3f Mon Sep 17 00:00:00 2001 From: MOUGINOT B Date: Fri, 23 Sep 2016 10:16:39 -0500 Subject: [PATCH 2/6] working group_inst --- src/group_inst.cc | 31 ++++++++++++++++++++++++++++ src/group_inst.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/group_inst.cc create mode 100644 src/group_inst.h diff --git a/src/group_inst.cc b/src/group_inst.cc new file mode 100644 index 0000000000..6f9998e711 --- /dev/null +++ b/src/group_inst.cc @@ -0,0 +1,31 @@ +// Implements the GroupInst class +#include "group_inst.h" + +namespace cycamore { + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +GroupInst::GroupInst(cyclus::Context* ctx) : cyclus::Institution(ctx) { } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +GroupInst::~GroupInst() {} + + +void GroupInst::EnterNotify() { + cyclus::Institution::EnterNotify(); + + for (int i = 0; i < prototypes.size(); i++) { + std::string s_proto = prototypes[i]; + context()->SchedBuild(this, s_proto); //builds on next timestep + BuildNotify(this); + } + std::cout << "GROUP DEPLOY!!!! at " << context()->time() << std::endl; +} + + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +extern "C" cyclus::Agent* ConstructGroupInst(cyclus::Context* ctx) { + return new GroupInst(ctx); +} + +} // namespace cycamore diff --git a/src/group_inst.h b/src/group_inst.h new file mode 100644 index 0000000000..baa5a4c464 --- /dev/null +++ b/src/group_inst.h @@ -0,0 +1,51 @@ +#ifndef CYCAMORE_SRC_MANAGER_INST_H_ +#define CYCAMORE_SRC_MANAGER_INST_H_ + +#include "cyclus.h" +#include "cycamore_version.h" + +namespace cycamore { + +/// @class GroupInst +/// @section introduction Introduction +/// @section detailedBehavior Detailed Behavior +/// @warning The GroupInst is experimental +class GroupInst + : public cyclus::Institution, + public cyclus::toolkit::CommodityProducerManager, + public cyclus::toolkit::Builder { + public: + /// Default constructor + GroupInst(cyclus::Context* ctx); + + /// Default destructor + virtual ~GroupInst(); + + virtual std::string version() { return CYCAMORE_VERSION; } + + #pragma cyclus + + #pragma cyclus note {"doc": "An institution that owns and operates a " \ + "manually entered list of facilities in " \ + "the input file"} + + /// enter the simulation and register any children present + virtual void EnterNotify(); + + + private: + + #pragma cyclus var { \ + "tooltip": "producer facility prototypes", \ + "uilabel": "Producer Prototype List", \ + "uitype": ["oneormore", "prototype"], \ + "doc": "A set of facility prototypes that this institution can build. " \ + "All prototypes in this list must be based on an archetype that " \ + "implements the cyclus::toolkit::CommodityProducer interface", \ + } + std::vector prototypes; +}; + +} // namespace cycamore + +#endif // CYCAMORE_SRC_MANAGER_INST_H_ From 0c2e2a1bdeedab0582ecc26a447009594bf06c92 Mon Sep 17 00:00:00 2001 From: MOUGINOT B Date: Fri, 23 Sep 2016 13:20:04 -0500 Subject: [PATCH 3/6] removeing cout.. --- src/group_inst.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/group_inst.cc b/src/group_inst.cc index 6f9998e711..e29256f913 100644 --- a/src/group_inst.cc +++ b/src/group_inst.cc @@ -18,7 +18,6 @@ void GroupInst::EnterNotify() { context()->SchedBuild(this, s_proto); //builds on next timestep BuildNotify(this); } - std::cout << "GROUP DEPLOY!!!! at " << context()->time() << std::endl; } From c37fdcbefe1ae77fcdaeda8d38bae5bc6f894014 Mon Sep 17 00:00:00 2001 From: MOUGINOT B Date: Tue, 10 Jan 2017 17:14:16 -0600 Subject: [PATCH 4/6] add test --- src/group_inst_tests.cc | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/group_inst_tests.cc diff --git a/src/group_inst_tests.cc b/src/group_inst_tests.cc new file mode 100644 index 0000000000..4bc34bcc67 --- /dev/null +++ b/src/group_inst_tests.cc @@ -0,0 +1,56 @@ +#include + +#include "context.h" +#include "group_inst.h" +#include "institution_tests.h" +#include "agent_tests.h" + + +TEST(GroupInstTests, BuildTimes) { + std::string config = + " " + " foobar1" + " foobar2" + " foobar3" + " " + ; + + int simdur = 5; + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:GroupInst"), config, simdur); + sim.DummyProto("foobar1"); + sim.DummyProto("foobar2"); + sim.DummyProto("foobar3"); + int id = sim.Run(); + + cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar1';" + ); + stmt->Step(); + EXPECT_EQ(1, stmt->GetInt(0)); + + stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar2';" + ); + stmt->Step(); + EXPECT_EQ(1, stmt->GetInt(0)); + stmt = sim.db().db().Prepare( + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar3';" + ); + stmt->Step(); + EXPECT_EQ(1, stmt->GetInt(0)); +} + +// required to get functionality in cyclus agent unit tests library +cyclus::Agent* GroupInstitutionConstructor(cyclus::Context* ctx) { + return new cycamore::GroupInst(ctx); +} +#ifndef CYCLUS_AGENT_TESTS_CONNECTED +int ConnectAgentTests(); +static int cyclus_agent_tests_connected = ConnectAgentTests(); +#define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected +#endif // CYCLUS_AGENT_TESTS_CONNECTED + +INSTANTIATE_TEST_CASE_P(GroupInst, InstitutionTests, + Values(&GroupInstitutionConstructor)); +INSTANTIATE_TEST_CASE_P(GroupInst, AgentTests, + Values(&GroupInstitutionConstructor)); From f59054867c685ae95ef294fadad3f3c41b319fee Mon Sep 17 00:00:00 2001 From: Mouginot B Date: Tue, 28 Mar 2017 18:44:19 -0500 Subject: [PATCH 5/6] temp --- test | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test diff --git a/test b/test new file mode 100644 index 0000000000..e69de29bb2 From eaa4e54be963101000244bc17f20a29735b2f823 Mon Sep 17 00:00:00 2001 From: Mouginot B Date: Tue, 28 Mar 2017 18:44:27 -0500 Subject: [PATCH 6/6] cleaning --- test | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test diff --git a/test b/test deleted file mode 100644 index e69de29bb2..0000000000