-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
group institution deploying #450
Open
bam241
wants to merge
7
commits into
cyclus:main
Choose a base branch
from
bam241:managerinst_deploying
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
940eeb8
working group_inst
bam241 08f4047
working group_inst
bam241 0c2e2a1
removeing cout..
bam241 c37fdcb
add test
bam241 f590548
temp
bam241 eaa4e54
cleaning
bam241 a332fa4
Merge branch 'master' into managerinst_deploying
katyhuff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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); | ||
} | ||
} | ||
|
||
|
||
|
||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
extern "C" cyclus::Agent* ConstructGroupInst(cyclus::Context* ctx) { | ||
return new GroupInst(ctx); | ||
} | ||
|
||
} // namespace cycamore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same description that is in manager_inst. Some clarification of about what distinguishes the two would be helpful. |
||
|
||
/// 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<std::string> prototypes; | ||
}; | ||
|
||
} // namespace cycamore | ||
|
||
#endif // CYCAMORE_SRC_MANAGER_INST_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include "context.h" | ||
#include "group_inst.h" | ||
#include "institution_tests.h" | ||
#include "agent_tests.h" | ||
|
||
|
||
TEST(GroupInstTests, BuildTimes) { | ||
std::string config = | ||
" <prototypes>" | ||
" <val>foobar1</val>" | ||
" <val>foobar2</val>" | ||
" <val>foobar3</val>" | ||
" </prototypes>" | ||
; | ||
|
||
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)); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you also want to be able to decommission the group?