CYCLUS
timeseries.h
Go to the documentation of this file.
1 #ifndef CYCLUS_SRC_TOOLKIT_TIMESERIES_H_
2 #define CYCLUS_SRC_TOOLKIT_TIMESERIES_H_
3 
4 #include <string>
5 
6 #include "agent.h"
7 #include "context.h"
8 
9 namespace cyclus {
10 namespace toolkit {
11 
12 /// Time series types to be used in the RecordTimeSeries() functions.
13 /// These types have the following unit which *must* be adhered to strictly:
14 /// - POWER [MWe]
15 /// - ENRICH_SWU [kg SWU]
16 /// - ENRICH_FEED [kg]
21 };
22 
23 /// Records a per-time step quantity for a given type
24 template <TimeSeriesType T>
25 void RecordTimeSeries(cyclus::Agent* agent, double value);
26 
27 /// Records a per-time step quantity for a string
28 template <typename T>
29 void RecordTimeSeries(std::string tsname, cyclus::Agent* agent, T value) {
30  std::string tblname = "TimeSeries" + tsname;
31  agent->context()->NewDatum(tblname)
32  ->AddVal("AgentId", agent->id())
33  ->AddVal("Time", agent->context()->time())
34  ->AddVal("Value", value)
35  ->Record();
36 }
37 
38 } // namespace toolkit
39 } // namespace cyclus
40 
41 #endif // CYCLUS_SRC_TOOLKIT_TIMESERIES_H_
TimeSeriesType
Time series types to be used in the RecordTimeSeries() functions.
Definition: timeseries.h:17
void RecordTimeSeries(cyclus::Agent *agent, double value)
Records a per-time step quantity for a given type.
virtual int time()
Returns the current simulation timestep.
Definition: context.cc:225
Datum * AddVal(const char *field, boost::spirit::hold_any val, std::vector< int > *shape=NULL)
Add an arbitrary field-value pair to the datum.
Definition: datum.cc:12
The abstract base class used by all types of agents that live and interact in a simulation.
Definition: agent.h:51
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
Definition: agent.cc:14
Context * context() const
Returns this agent&#39;s simulation context.
Definition: agent.h:369
void Record()
Record this datum to its Recorder.
Definition: datum.cc:24
virtual const int id() const
The agent instance&#39;s unique ID within a simulation.
Definition: agent.h:354
Datum * NewDatum(std::string title)
See Recorder::NewDatum documentation.
Definition: context.cc:237