GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 85.2% 23 / 0 / 27
Functions: 100.0% 1 / 0 / 1
Branches: 60.0% 33 / 0 / 55

src/energyplus/ForwardTranslator/ForwardTranslateGeneratorPhotovoltaic.cpp
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 #include "../ForwardTranslator.hpp"
7
8 #include "../../model/Model.hpp"
9 #include "../../model/GeneratorPhotovoltaic.hpp"
10 #include "../../model/GeneratorPhotovoltaic_Impl.hpp"
11 #include "../../model/PlanarSurface.hpp"
12 #include "../../model/PhotovoltaicPerformance.hpp"
13
14 #include <utilities/idd/Generator_Photovoltaic_FieldEnums.hxx>
15 #include "../../utilities/idd/IddEnums.hpp"
16 #include <utilities/idd/IddEnums.hxx>
17
18 using namespace openstudio::model;
19
20 using namespace std;
21
22 namespace openstudio {
23
24 namespace energyplus {
25
26 2 boost::optional<IdfObject> ForwardTranslator::translateGeneratorPhotovoltaic(model::GeneratorPhotovoltaic& modelObject) {
27
28 // We are going to check for required properties such as Surface before we register the object
29 // IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Generator_Photovoltaic, modelObject);
30
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 IdfObject idfObject(openstudio::IddObjectType::Generator_Photovoltaic);
31 // Name
32
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setName(modelObject.nameString());
33
34
1/1
✓ Branch 1 taken 2 times.
2 PhotovoltaicPerformance performance = modelObject.photovoltaicPerformance();
35
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<IdfObject> performanceIdf = translateAndMapModelObject(performance);
36
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (performanceIdf) {
37
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 idfObject.setString(Generator_PhotovoltaicFields::PhotovoltaicPerformanceObjectType, performanceIdf->iddObject().name());
38
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 idfObject.setString(Generator_PhotovoltaicFields::ModulePerformanceName, performanceIdf->name().get());
39 } else {
40 ✗ LOG(Error,
41 "Generator:Photovoltaic '" << idfObject.name().get() << "' missing required field 'Module Performance Name', it will not be translated.");
42 ✗ return boost::none;
43 }
44
45
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<PlanarSurface> surface = modelObject.surface();
46 2 bool hasSurface = false;
47
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (surface) {
48
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 boost::optional<IdfObject> surfaceIdf = translateAndMapModelObject(*surface);
49
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (surfaceIdf) {
50
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 idfObject.setString(Generator_PhotovoltaicFields::SurfaceName, surfaceIdf->name().get());
51 2 hasSurface = true;
52 }
53 2 }
54
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (!hasSurface) {
55 ✗ LOG(Error, "Generator:Photovoltaic '" << idfObject.name().get() << "' missing required field 'Surface Name', it will not be translated.");
56 ✗ return boost::none;
57 }
58
59 // at this point, we can register the new object
60
1/1
✓ Branch 1 taken 2 times.
2 m_idfObjects.push_back(idfObject);
61
62
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setString(Generator_PhotovoltaicFields::HeatTransferIntegrationMode, modelObject.heatTransferIntegrationMode());
63
64
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setDouble(Generator_PhotovoltaicFields::NumberofSeriesStringsinParallel, modelObject.numberOfModulesInParallel());
65
66
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setDouble(Generator_PhotovoltaicFields::NumberofModulesinSeries, modelObject.numberOfModulesInSeries());
67
68
1/1
✓ Branch 1 taken 2 times.
2 return idfObject;
69 2 }
70
71 } // namespace energyplus
72
73 } // namespace openstudio
74