7 : cyclus::Institution(ctx),
12DeployInst::~DeployInst() {}
14void DeployInst::Build(cyclus::Agent* parent) {
15 cyclus::Institution::Build(parent);
16 BuildSched::iterator it;
17 std::set<std::string> protos;
18 for (
int i = 0; i < prototypes.size(); i++) {
19 std::string proto = prototypes[i];
24 if (lifetimes.size() == prototypes.size()) {
25 cyclus::Agent* a = context()->CreateAgent<Agent>(proto);
26 if (a->lifetime() != lifetimes[i]) {
27 a->lifetime(lifetimes[i]);
29 if (lifetimes[i] == -1) {
30 ss <<
"_life_forever";
32 ss <<
"_life_" << lifetimes[i];
35 if (protos.count(proto) == 0) {
37 context()->AddPrototype(proto, a);
42 int t = build_times[i];
43 for (
int j = 0; j < n_build[i]; j++) {
44 context()->SchedBuild(
this, proto, t);
49void DeployInst::EnterNotify() {
50 cyclus::Institution::EnterNotify();
51 int n = prototypes.size();
52 if (build_times.size() != n) {
54 ss <<
"prototype '" << prototype() <<
"' has " << build_times.size()
55 <<
" build_times vals, expected " << n;
56 throw cyclus::ValueError(ss.str());
57 }
else if (n_build.size() != n) {
59 ss <<
"prototype '" << prototype() <<
"' has " << n_build.size()
60 <<
" n_build vals, expected " << n;
61 throw cyclus::ValueError(ss.str());
62 }
else if (lifetimes.size() > 0 && lifetimes.size() != n) {
64 ss <<
"prototype '" << prototype() <<
"' has " << lifetimes.size()
65 <<
" lifetimes vals, expected " << n;
66 throw cyclus::ValueError(ss.str());
71void DeployInst::BuildNotify(Agent* a) {
75void DeployInst::DecomNotify(Agent* a) {
79void DeployInst::Register_(Agent* a) {
80 using cyclus::toolkit::CommodityProducer;
81 using cyclus::toolkit::CommodityProducerManager;
83 CommodityProducer* cp_cast =
dynamic_cast<CommodityProducer*
>(a);
84 if (cp_cast != NULL) {
85 LOG(cyclus::LEV_INFO3,
"mani") <<
"Registering agent "
86 << a->prototype() << a->id()
87 <<
" as a commodity producer.";
88 CommodityProducerManager::Register(cp_cast);
92void DeployInst::Unregister_(Agent* a) {
93 using cyclus::toolkit::CommodityProducer;
94 using cyclus::toolkit::CommodityProducerManager;
96 CommodityProducer* cp_cast =
dynamic_cast<CommodityProducer*
>(a);
98 CommodityProducerManager::Unregister(cp_cast);
102void DeployInst::WriteProducerInformation(
103 cyclus::toolkit::CommodityProducer* producer) {
105 set<cyclus::toolkit::Commodity,
106 cyclus::toolkit::CommodityCompare> commodities =
107 producer->ProducedCommodities();
108 set<cyclus::toolkit::Commodity, cyclus::toolkit::CommodityCompare>::
111 LOG(cyclus::LEV_DEBUG3,
"maninst") <<
" Clone produces " << commodities.size()
113 for (it = commodities.begin(); it != commodities.end(); it++) {
114 LOG(cyclus::LEV_DEBUG3,
"maninst") <<
" Commodity produced: " << it->name();
115 LOG(cyclus::LEV_DEBUG3,
"maninst") <<
" capacity: " <<
116 producer->Capacity(*it);
117 LOG(cyclus::LEV_DEBUG3,
"maninst") <<
" cost: " <<
122void DeployInst::RecordPosition() {
123 std::string specification = this->spec();
125 ->NewDatum(
"AgentPosition")
126 ->AddVal(
"Spec", specification)
127 ->AddVal(
"Prototype", this->prototype())
128 ->AddVal(
"AgentId",
id())
129 ->AddVal(
"Latitude", latitude)
130 ->AddVal(
"Longitude", longitude)
135 return new DeployInst(ctx);
DeployInst(cyclus::Context *ctx)
void RecordPosition()
Records an agent's latitude and longitude to the output db.
cyclus::Agent * ConstructDeployInst(cyclus::Context *ctx)
void Unregister_(cyclus::Agent *agent)
unregister a child
void Register_(cyclus::Agent *agent)
register a child
cyclus::toolkit::Position coordinates