src/energyplus/ReverseTranslator/ReverseTranslateOutputJSON.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 "../ReverseTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/OutputJSON.hpp" | ||
| 9 | #include "../../model/OutputJSON_Impl.hpp" | ||
| 10 | |||
| 11 | #include <utilities/idd/Output_JSON_FieldEnums.hxx> | ||
| 12 | #include <utilities/idd/IddEnums.hxx> | ||
| 13 | |||
| 14 | using namespace openstudio::model; | ||
| 15 | |||
| 16 | namespace openstudio { | ||
| 17 | |||
| 18 | namespace energyplus { | ||
| 19 | |||
| 20 | 3 | boost::optional<ModelObject> ReverseTranslator::translateOutputJSON(const WorkspaceObject& workspaceObject) { | |
| 21 | 3 | boost::optional<ModelObject> result; | |
| 22 | |||
| 23 | // This is a Unique ModelObject | ||
| 24 |
1/1✓ Branch 1 taken 3 times.
|
3 | auto modelObject = m_model.getUniqueModelObject<OutputJSON>(); |
| 25 | |||
| 26 | // Option Type: Required String | ||
| 27 |
2/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | if (boost::optional<std::string> _optionType = workspaceObject.getString(Output_JSONFields::OptionType)) { |
| 28 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | modelObject.setOptionType(_optionType.get()); |
| 29 | } else { | ||
| 30 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot find required property 'Option Type'"); | |
| 31 | ✗ | return result; | |
| 32 | 3 | } | |
| 33 | |||
| 34 | // Output JSON: Optional Boolean | ||
| 35 |
2/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | if (boost::optional<std::string> _outputJSON = workspaceObject.getString(Output_JSONFields::OutputJSON, true)) { |
| 36 |
5/5✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 2 times.
|
9 | if (istringEqual("Yes", _outputJSON.get())) { |
| 37 |
1/1✓ Branch 1 taken 1 time.
|
1 | modelObject.setOutputJSON(true); |
| 38 | } else { | ||
| 39 |
1/1✓ Branch 1 taken 2 times.
|
2 | modelObject.setOutputJSON(false); |
| 40 | } | ||
| 41 | 3 | } | |
| 42 | |||
| 43 | // Output CBOR: Optional Boolean | ||
| 44 |
2/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | if (boost::optional<std::string> _outputCBOR = workspaceObject.getString(Output_JSONFields::OutputCBOR, true)) { |
| 45 |
5/5✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 2 times.
|
9 | if (istringEqual("Yes", _outputCBOR.get())) { |
| 46 |
1/1✓ Branch 1 taken 1 time.
|
1 | modelObject.setOutputCBOR(true); |
| 47 | } else { | ||
| 48 |
1/1✓ Branch 1 taken 2 times.
|
2 | modelObject.setOutputCBOR(false); |
| 49 | } | ||
| 50 | 3 | } | |
| 51 | |||
| 52 | // Output MessagePack: Optional Boolean | ||
| 53 |
2/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | if (boost::optional<std::string> _outputMessagePack = workspaceObject.getString(Output_JSONFields::OutputMessagePack, true)) { |
| 54 |
5/5✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 2 times.
|
9 | if (istringEqual("Yes", _outputMessagePack.get())) { |
| 55 |
1/1✓ Branch 1 taken 1 time.
|
1 | modelObject.setOutputMessagePack(true); |
| 56 | } else { | ||
| 57 |
1/1✓ Branch 1 taken 2 times.
|
2 | modelObject.setOutputMessagePack(false); |
| 58 | } | ||
| 59 | 3 | } | |
| 60 | |||
| 61 |
1/1✓ Branch 1 taken 3 times.
|
3 | result = modelObject; |
| 62 | 3 | return result; | |
| 63 | |||
| 64 | 3 | } // End of translate function | |
| 65 | |||
| 66 | } // end namespace energyplus | ||
| 67 | } // end namespace openstudio | ||
| 68 |