GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 0 / 1 / 1
Functions: -% 0 / 1 / 1
Branches: -% 0 / 1 / 1

src/alfalfa/AlfalfaJSON.hpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #ifndef ALFALFA_ALFALFA_HPP
7 #define ALFALFA_ALFALFA_HPP
8
9 #include "AlfalfaAPI.hpp"
10
11 #include "AlfalfaPoint.hpp"
12
13 #include "../utilities/core/Path.hpp"
14 #include "../utilities/core/Logger.hpp"
15 #include "../utilities/core/Optional.hpp"
16 #include "../utilities/idf/IdfObject.hpp"
17
18 #include <json/json.h>
19
20 #include <vector>
21 #include <string>
22
23 namespace openstudio {
24 namespace alfalfa {
25 namespace detail {
26 class AlfalfaJSON_Impl;
27 }
28
29 class ALFALFA_API AlfalfaJSON
30 {
31 public:
32 /** @name Constructors and Destructors */
33
34 AlfalfaJSON();
35
36 AlfalfaJSON(const std::string& s);
37
38 AlfalfaJSON(const openstudio::path& p);
39
40 bool save() const;
41
42 bool saveAs(const openstudio::path& p);
43
44 Json::Value toJSON() const;
45
46 /**
47 * Expose a point with a constant output value.
48 * display_name is required
49 */
50 boost::optional<AlfalfaPoint> exposeConstant(float value, const std::string& display_name);
51
52 /**
53 * Expose a point with a meter as an output.
54 * display_name is optional and by default will reflect the name of the meter.
55 */
56 boost::optional<AlfalfaPoint> exposeMeter(const std::string& meter_name, const std::string& display_name = std::string());
57
58 /**
59 * Expose a point with an actuator as input and ouput value.
60 * display_name is optional and by default will reflect the parameters of the actuator.
61 */
62 boost::optional<AlfalfaPoint> exposeActuator(const std::string& component_name, const std::string& component_type,
63 const std::string& control_type, const std::string& display_name = std::string());
64
65 /**
66 * Expose point with Output Variable as output value.
67 * display_name is optional and by default will reflect the parameters of the output variable.
68 */
69 boost::optional<AlfalfaPoint> exposeOutputVariable(const std::string& variable_key, const std::string& variable_name,
70 const std::string& display_name = std::string());
71
72 /**
73 * Expose point with Global Variable as output and input value.
74 * display_name is optional and by default will reflect the parameters of the global variable.
75 */
76 boost::optional<AlfalfaPoint> exposeGlobalVariable(const std::string& variable_name, const std::string& display_name = std::string());
77
78 /**
79 * Expose a point in the Alfalfa API
80 */
81 void exposePoint(const AlfalfaPoint& point);
82
83 /**
84 * Expose a point in the Alfalfa API from a ModelObject or IdfObject
85 * display_name is optional and by default will be infered from the displayName for model objects or parameters for idf objects.
86 * Valid idf_object types are EnergyManagementSystemActuator and IdfObject(IddObjectType::EnergyManagementSystem_Actuator) for actuators,
87 * OutputVariable, EnergyManagementSystemOutputVariable, IdfObject(IddObjectType::Output_Variable) and IdfObject(IddObjectType::EnergyManagementSystem_OutputVariable) for output variables,
88 * OutputMeter and IdfObject(IddObjectType::Output_Meter) for meters,
89 * and EnergyManagementSystemGlobalVariable and IdfObject(IddObjectType::EnergyManagementSystem_GlobalVariable) for global variables.
90 */
91 boost::optional<AlfalfaPoint> exposeFromObject(const openstudio::IdfObject& idf_object, const std::string& display_name = std::string());
92
93 /**
94 * Expose a point in the alfalfa API from an AlfalfaComponent.
95 * display_name is optional and by default will be infered from the contents of the component.
96 * Input and Ouput of the point will reflect the capabilities of the component.
97 */
98 boost::optional<AlfalfaPoint> exposeFromComponent(const AlfalfaComponent& component, const std::string& display_name = std::string());
99
100 /**
101 * Get a vector of all points currently exported to the Alfalfa API
102 */
103 std::vector<AlfalfaPoint> points() const;
104
105 private:
106 static boost::optional<std::string> getName(const openstudio::IdfObject& idf_object);
107
108 std::shared_ptr<detail::AlfalfaJSON_Impl> m_impl;
109
110 // configure logging
111 − REGISTER_LOGGER("openstudio.AlfalfaJSON");
112 };
113
114 } // namespace alfalfa
115 } // namespace openstudio
116
117 #endif
118