Skip to content

Commit

Permalink
Added IDD element for JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyalj committed Mar 2, 2015
1 parent 61d43ea commit 9059c9b
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 116 deletions.
9 changes: 9 additions & 0 deletions idd/Energy+.idd.in
Original file line number Diff line number Diff line change
Expand Up @@ -91771,6 +91771,15 @@ Meter:CustomDecrement,
A46, \field Key Name 22
A47; \field Output Variable or Meter Name 22

Output:JSON,
\memo Output from EnergyPlus can be written to JSON format files.
\unique-object
A1 ; \field Option Type
\type choice
\key TimeSeries
\key TimeSeriesAndTabular


Output:SQLite,
\memo Output from EnergyPlus can be written to an SQLite format file.
\unique-object
Expand Down
10 changes: 10 additions & 0 deletions src/EnergyPlus/EnergyPlusPgm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <InputProcessor.hh>
#include <OutputProcessor.hh>
#include <Psychrometrics.hh>
#include <ResultsSchema.hh>
#include <ScheduleManager.hh>
#include <SimulationManager.hh>
#include <UtilityRoutines.hh>
Expand Down Expand Up @@ -223,9 +224,11 @@ EnergyPlusPgm( std::string const & filepath )
using namespace FileSystem;
using namespace InputProcessor;
using namespace OutputProcessor;
using namespace ResultsFramework;
using namespace SimulationManager;
using ScheduleManager::ReportOrphanSchedules;
using FluidProperties::ReportOrphanFluids;
using ResultsFramework::OutputSchema;
using Psychrometrics::ShowPsychrometricSummary;

// Disable C++ i/o synching with C methods for speed
Expand Down Expand Up @@ -380,6 +383,13 @@ EnergyPlusPgm( std::string const & filepath )

ProcessInput();

OutputSchema->InitializeSchema();

if (OutputSchema->TimeSeriesEnabled())
DisplayString("Found true");
else
DisplayString("Found false");

ManageSimulation();

ShowMessage( "Simulation Error Summary *************" );
Expand Down
180 changes: 107 additions & 73 deletions src/EnergyPlus/OutputProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4106,7 +4106,7 @@ namespace OutputProcessor {
using DataGlobals::eso_stream;
using DataStringGlobals::NL;
using General::strip_trailing_zeros;
using ResultsSchema::OutputSchema;
using namespace ResultsFramework;

// Locals

Expand Down Expand Up @@ -4154,14 +4154,17 @@ namespace OutputProcessor {
ProduceMinMaxString( MaxOut, maxValueDate, reportingInterval );

// add to daily TS data store
if ( reportingInterval == ReportDaily)
OutputSchema.RIDailyTSData.AddToCurrentRRow(repVal);
// add to monthly TS data store
if (reportingInterval == ReportMonthly)
OutputSchema.RIMonthlyTSData.AddToCurrentRRow(repVal);
// add to run period TS data store
if (reportingInterval == ReportSim)
OutputSchema.RIRunPeriodTSData.AddToCurrentRRow(repVal);
if (OutputSchema->TimeSeriesEnabled())
{
if (reportingInterval == ReportDaily)
OutputSchema->RIDailyTSData.AddToCurrentRRow(repVal);
// add to monthly TS data store
if (reportingInterval == ReportMonthly)
OutputSchema->RIMonthlyTSData.AddToCurrentRRow(repVal);
// add to run period TS data store
if (reportingInterval == ReportSim)
OutputSchema->RIRunPeriodTSData.AddToCurrentRRow(repVal);
}

if ( sqlite ) {
sqlite->createSQLiteReportDataRecord( reportID, repVal, reportingInterval, minValue, minValueDate, MaxValue, maxValueDate );
Expand Down Expand Up @@ -4618,7 +4621,7 @@ namespace OutputProcessor {
using DataGlobals::eso_stream;
using DataStringGlobals::NL;
using General::strip_trailing_zeros;
using ResultsSchema::OutputSchema;
using namespace ResultsFramework;

// Locals

Expand Down Expand Up @@ -4655,15 +4658,18 @@ namespace OutputProcessor {
ProduceMinMaxString( MinOut, minValueDate, reportingInterval );
ProduceMinMaxString( MaxOut, maxValueDate, reportingInterval );

// add to daily TS data store
if (reportingInterval == ReportDaily)
OutputSchema.RIDailyTSData.AddToCurrentIRow(repVal);
// add to monthly TS data store
if (reportingInterval == ReportMonthly)
OutputSchema.RIMonthlyTSData.AddToCurrentIRow(repVal);
// add to run period TS data store
if (reportingInterval == ReportSim)
OutputSchema.RIRunPeriodTSData.AddToCurrentIRow(repVal);
if (OutputSchema->TimeSeriesEnabled())
{
// add to daily TS data store
if (reportingInterval == ReportDaily)
OutputSchema->RIDailyTSData.AddToCurrentIRow(repVal);
// add to monthly TS data store
if (reportingInterval == ReportMonthly)
OutputSchema->RIMonthlyTSData.AddToCurrentIRow(repVal);
// add to run period TS data store
if (reportingInterval == ReportSim)
OutputSchema->RIRunPeriodTSData.AddToCurrentIRow(repVal);
}

rminValue = minValue;
rmaxValue = MaxValue;
Expand Down Expand Up @@ -4978,7 +4984,7 @@ SetupOutputVariable(
using InputProcessor::MakeUPPERCase;
using InputProcessor::SameString;
using General::TrimSigDigits;
using namespace ResultsSchema;
using namespace ResultsFramework;

// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
Expand Down Expand Up @@ -5247,7 +5253,7 @@ SetupOutputVariable(
using InputProcessor::SameString;
using General::TrimSigDigits;
using DataOutputs::FindItemInVariableList;
using namespace ResultsSchema;
using namespace ResultsFramework;

// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
Expand Down Expand Up @@ -5516,7 +5522,7 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
using DataEnvironment::DSTIndicator;
using DataEnvironment::EndMonthFlag;
using General::EncodeMonDayHrMin;
using ResultsSchema::OutputSchema;
using namespace ResultsFramework;

// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
Expand Down Expand Up @@ -5573,21 +5579,27 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
rxTime = ( MinuteNow - StartMinute ) / double( MinutesPerTimeStep );

// R and I data frames for ZoneVar
if (IndexType == ZoneVar && OutputSchema.RIDetailedZoneTSData.RDataFrameEnabled == false)
OutputSchema.InitializeRTSDataFrame(ReportEach, RVariableTypes, NumOfRVariable, ZoneVar);
if (IndexType == ZoneVar && OutputSchema.RIDetailedZoneTSData.IDataFrameEnabled == false)
OutputSchema.InitializeITSDataFrame(ReportEach, IVariableTypes, NumOfIVariable, ZoneVar);

// R and I data frames for HVACVar
if (IndexType == HVACVar && OutputSchema.RIDetailedHVACTSData.RDataFrameEnabled == false)
OutputSchema.InitializeRTSDataFrame(ReportEach, RVariableTypes, NumOfRVariable, HVACVar);
if (IndexType == HVACVar && OutputSchema.RIDetailedHVACTSData.IDataFrameEnabled == false)
OutputSchema.InitializeITSDataFrame(ReportEach, IVariableTypes, NumOfIVariable, HVACVar);
if (OutputSchema->TimeSeriesEnabled())
{
if (IndexType == ZoneVar && OutputSchema->RIDetailedZoneTSData.RDataFrameEnabled == false)
OutputSchema->InitializeRTSDataFrame(ReportEach, RVariableTypes, NumOfRVariable, ZoneVar);
if (IndexType == ZoneVar && OutputSchema->RIDetailedZoneTSData.IDataFrameEnabled == false)
OutputSchema->InitializeITSDataFrame(ReportEach, IVariableTypes, NumOfIVariable, ZoneVar);

// R and I data frames for HVACVar
if (IndexType == HVACVar && OutputSchema->RIDetailedHVACTSData.RDataFrameEnabled == false)
OutputSchema->InitializeRTSDataFrame(ReportEach, RVariableTypes, NumOfRVariable, HVACVar);
if (IndexType == HVACVar && OutputSchema->RIDetailedHVACTSData.IDataFrameEnabled == false)
OutputSchema->InitializeITSDataFrame(ReportEach, IVariableTypes, NumOfIVariable, HVACVar);
}

std::string ts = std::to_string(Month) + "/" + std::to_string(DayOfMonth) + " " + std::to_string(HourOfDay) + ":" + std::to_string(TimeValue(1).CurMinute) + ":00";

if (IndexType == ZoneVar) OutputSchema.RIDetailedZoneTSData.NewRow(ts);
if (IndexType == HVACVar) OutputSchema.RIDetailedHVACTSData.NewRow(ts);
if (OutputSchema->TimeSeriesEnabled())
{
if (IndexType == ZoneVar) OutputSchema->RIDetailedZoneTSData.NewRow(ts);
if (IndexType == HVACVar) OutputSchema->RIDetailedHVACTSData.NewRow(ts);
}

// Main "Record Keeping" Loops for R and I variables
for ( Loop = 1; Loop <= NumOfRVariable; ++Loop ) {
Expand Down Expand Up @@ -5653,8 +5665,11 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
WriteRealData( rVar.ReportID, rVar.ReportIDChr, rVar.Which );
++StdOutputRecordCount;

if (IndexType == ZoneVar) OutputSchema.RIDetailedZoneTSData.AddToCurrentRRow(rVar.Which);
if (IndexType == HVACVar) OutputSchema.RIDetailedHVACTSData.AddToCurrentRRow(rVar.Which);
if (OutputSchema->TimeSeriesEnabled())
{
if (IndexType == ZoneVar) OutputSchema->RIDetailedZoneTSData.AddToCurrentRRow(rVar.Which);
if (IndexType == HVACVar) OutputSchema->RIDetailedHVACTSData.AddToCurrentRRow(rVar.Which);
}
}
}

Expand Down Expand Up @@ -5719,8 +5734,11 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
WriteIntegerData( iVar.ReportID, iVar.ReportIDChr, iVar.Which );
++StdOutputRecordCount;

if (IndexType == ZoneVar) OutputSchema.RIDetailedZoneTSData.AddToCurrentIRow(iVar.Which);
if (IndexType == HVACVar) OutputSchema.RIDetailedHVACTSData.AddToCurrentIRow(iVar.Which);
if (OutputSchema->TimeSeriesEnabled())
{
if (IndexType == ZoneVar) OutputSchema->RIDetailedZoneTSData.AddToCurrentIRow(iVar.Which);
if (IndexType == HVACVar) OutputSchema->RIDetailedHVACTSData.AddToCurrentIRow(iVar.Which);
}
}
}

Expand All @@ -5733,13 +5751,15 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
// TimeStep Block (Report on Zone TimeStep)

if ( EndTimeStepFlag ) {

if (OutputSchema.RITimestepTSData.RDataFrameEnabled == false)
OutputSchema.InitializeRTSDataFrame(ReportTimeStep, RVariableTypes, NumOfRVariable);
if (OutputSchema.RITimestepTSData.IDataFrameEnabled == false)
OutputSchema.InitializeITSDataFrame(ReportTimeStep, IVariableTypes, NumOfIVariable);
std::string ts = std::to_string(Month) + "/" + std::to_string(DayOfMonth) + " " + std::to_string(HourOfDay) + ":" + std::to_string(int(TimeValue(1).CurMinute)) + ":00";
OutputSchema.RITimestepTSData.NewRow(ts);
if (OutputSchema->TimeSeriesEnabled())
{
if (OutputSchema->RITimestepTSData.RDataFrameEnabled == false)
OutputSchema->InitializeRTSDataFrame(ReportTimeStep, RVariableTypes, NumOfRVariable);
if (OutputSchema->RITimestepTSData.IDataFrameEnabled == false)
OutputSchema->InitializeITSDataFrame(ReportTimeStep, IVariableTypes, NumOfIVariable);
std::string ts = std::to_string(Month) + "/" + std::to_string(DayOfMonth) + " " + std::to_string(HourOfDay) + ":" + std::to_string(int(TimeValue(1).CurMinute)) + ":00";
OutputSchema->RITimestepTSData.NewRow(ts);
}

for ( IndexType = 1; IndexType <= 2; ++IndexType ) {
for ( Loop = 1; Loop <= NumOfRVariable; ++Loop ) {
Expand Down Expand Up @@ -5785,7 +5805,8 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
WriteRealData( rVar.ReportID, rVar.ReportIDChr, rVar.TSValue );
++StdOutputRecordCount;
// add to timestep TS data store
OutputSchema.RITimestepTSData.AddToCurrentRRow(rVar.TSValue);
if (OutputSchema->TimeSeriesEnabled())
OutputSchema->RITimestepTSData.AddToCurrentRRow(rVar.TSValue);

}
rVar.TSValue = 0.0;
Expand Down Expand Up @@ -5826,7 +5847,8 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo

WriteIntegerData( iVar.ReportID, iVar.ReportIDChr, _, iVar.TSValue );
++StdOutputRecordCount;
OutputSchema.RITimestepTSData.AddToCurrentIRow(iVar.TSValue);
if (OutputSchema->TimeSeriesEnabled())
OutputSchema->RITimestepTSData.AddToCurrentIRow(iVar.TSValue);
}
iVar.TSValue = 0.0;
iVar.thisTSStored = false;
Expand All @@ -5849,10 +5871,13 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
WriteTimeStampFormatData( eso_stream, ReportHourly, TimeStepStampReportNbr, TimeStepStampReportChr, DayOfSim, DayOfSimChr, true, Month, DayOfMonth, HourOfDay, _, _, DSTIndicator, DayTypes( CurDayType ) );
}

if (OutputSchema.RIHourlyTSData.RDataFrameEnabled == false)
OutputSchema.InitializeRTSDataFrame(ReportHourly, RVariableTypes, NumOfRVariable);
std::string ts = std::to_string(Month) + "/" + std::to_string(DayOfMonth) + " " + std::to_string(HourOfDay) + ":00:00";
OutputSchema.RIHourlyTSData.NewRow(ts);
if (OutputSchema->TimeSeriesEnabled())
{
if (OutputSchema->RIHourlyTSData.RDataFrameEnabled == false)
OutputSchema->InitializeRTSDataFrame(ReportHourly, RVariableTypes, NumOfRVariable);
std::string ts = std::to_string(Month) + "/" + std::to_string(DayOfMonth) + " " + std::to_string(HourOfDay) + ":00:00";
OutputSchema->RIHourlyTSData.NewRow(ts);
}

for ( IndexType = 1; IndexType <= 2; ++IndexType ) { // Zone, HVAC
TimeValue( IndexType ).CurMinute = 0.0;
Expand All @@ -5874,7 +5899,8 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
++StdOutputRecordCount;
rVar.Stored = false;
// add time series value for hourly to data store
OutputSchema.RIHourlyTSData.AddToCurrentRRow(rVar.Value);
if (OutputSchema->TimeSeriesEnabled())
OutputSchema->RIHourlyTSData.AddToCurrentRRow(rVar.Value);
}
rVar.StoreValue += rVar.Value;
++rVar.NumStored;
Expand All @@ -5901,7 +5927,8 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
WriteIntegerData( iVar.ReportID, iVar.ReportIDChr, _, iVar.Value );
++StdOutputRecordCount;
iVar.Stored = false;
OutputSchema.RIHourlyTSData.AddToCurrentIRow(iVar.Value);
if (OutputSchema->TimeSeriesEnabled())
OutputSchema->RIHourlyTSData.AddToCurrentIRow(iVar.Value);
}
iVar.StoreValue += iVar.Value;
++iVar.NumStored;
Expand All @@ -5928,13 +5955,15 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
}
WriteTimeStampFormatData( eso_stream, ReportDaily, DailyStampReportNbr, DailyStampReportChr, DayOfSim, DayOfSimChr, true, Month, DayOfMonth, _, _, _, DSTIndicator, DayTypes( CurDayType ) );
}

if (OutputSchema.RIDailyTSData.RDataFrameEnabled == false)
OutputSchema.InitializeRTSDataFrame(ReportDaily, RVariableTypes, NumOfRVariable);
if (OutputSchema.RIDailyTSData.IDataFrameEnabled == false)
OutputSchema.InitializeITSDataFrame(ReportDaily, IVariableTypes, NumOfIVariable);
std::string ts = std::to_string(Month) + "/" + std::to_string(DayOfMonth) + " " + std::to_string(HourOfDay) + ":00:00";
OutputSchema.RIDailyTSData.NewRow(ts);
if (OutputSchema->TimeSeriesEnabled())
{
if (OutputSchema->RIDailyTSData.RDataFrameEnabled == false)
OutputSchema->InitializeRTSDataFrame(ReportDaily, RVariableTypes, NumOfRVariable);
if (OutputSchema->RIDailyTSData.IDataFrameEnabled == false)
OutputSchema->InitializeITSDataFrame(ReportDaily, IVariableTypes, NumOfIVariable);
std::string ts = std::to_string(Month) + "/" + std::to_string(DayOfMonth) + " " + std::to_string(HourOfDay) + ":00:00";
OutputSchema->RIDailyTSData.NewRow(ts);
}

NumHoursInMonth += 24;
for ( IndexType = 1; IndexType <= 2; ++IndexType ) {
Expand Down Expand Up @@ -5967,12 +5996,15 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
WriteTimeStampFormatData( eso_stream, ReportMonthly, MonthlyStampReportNbr, MonthlyStampReportChr, DayOfSim, DayOfSimChr, false, Month );
}

if (OutputSchema.RIMonthlyTSData.RDataFrameEnabled == false)
OutputSchema.InitializeRTSDataFrame(ReportMonthly, RVariableTypes, NumOfRVariable);
if (OutputSchema.RIMonthlyTSData.IDataFrameEnabled == false)
OutputSchema.InitializeITSDataFrame(ReportMonthly, IVariableTypes, NumOfIVariable);
std::string ts = std::to_string(Month) + "/" + std::to_string(DayOfMonth) + " " + std::to_string(HourOfDay) + ":00:00";
OutputSchema.RIMonthlyTSData.NewRow(ts);
if (OutputSchema->TimeSeriesEnabled())
{
if (OutputSchema->RIMonthlyTSData.RDataFrameEnabled == false)
OutputSchema->InitializeRTSDataFrame(ReportMonthly, RVariableTypes, NumOfRVariable);
if (OutputSchema->RIMonthlyTSData.IDataFrameEnabled == false)
OutputSchema->InitializeITSDataFrame(ReportMonthly, IVariableTypes, NumOfIVariable);
std::string ts = std::to_string(Month) + "/" + std::to_string(DayOfMonth) + " " + std::to_string(HourOfDay) + ":00:00";
OutputSchema->RIMonthlyTSData.NewRow(ts);
}

NumHoursInSim += NumHoursInMonth;
EndMonthFlag = false;
Expand Down Expand Up @@ -6004,13 +6036,15 @@ UpdateDataandReport( int const IndexTypeKey ) // What kind of data to update (Zo
WriteTimeStampFormatData( eso_stream, ReportSim, RunPeriodStampReportNbr, RunPeriodStampReportChr, DayOfSim, DayOfSimChr, false );
}

if (OutputSchema.RIRunPeriodTSData.RDataFrameEnabled == false)
OutputSchema.InitializeRTSDataFrame(ReportSim, RVariableTypes, NumOfRVariable);
if (OutputSchema.RIRunPeriodTSData.IDataFrameEnabled == false)
OutputSchema.InitializeITSDataFrame(ReportSim, IVariableTypes, NumOfIVariable);
std::string ts = std::to_string(Month) + "/" + std::to_string(DayOfMonth) + " " + std::to_string(HourOfDay) + ":00:00";
OutputSchema.RIRunPeriodTSData.NewRow(ts);

if (OutputSchema->TimeSeriesEnabled())
{
if (OutputSchema->RIRunPeriodTSData.RDataFrameEnabled == false)
OutputSchema->InitializeRTSDataFrame(ReportSim, RVariableTypes, NumOfRVariable);
if (OutputSchema->RIRunPeriodTSData.IDataFrameEnabled == false)
OutputSchema->InitializeITSDataFrame(ReportSim, IVariableTypes, NumOfIVariable);
std::string ts = std::to_string(Month) + "/" + std::to_string(DayOfMonth) + " " + std::to_string(HourOfDay) + ":00:00";
OutputSchema->RIRunPeriodTSData.NewRow(ts);
}
for ( IndexType = 1; IndexType <= 2; ++IndexType ) { // Zone, HVAC
for ( Loop = 1; Loop <= NumOfRVariable; ++Loop ) {
if ( RVariableTypes( Loop ).IndexType == IndexType ) {
Expand Down
Loading

7 comments on commit 9059c9b

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResultsSchema (sanyalj) - x86_64-MacOS-10.9-clang: Tests Failed

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResultsSchema (sanyalj) - i386-Windows-7-VisualStudio-12: Tests Failed

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResultsSchema (sanyalj) - Win64-Windows-7-VisualStudio-12: Tests Failed

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResultsSchema (sanyalj) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed)

Build Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResultsSchema (sanyalj) - x86_64-Linux-Ubuntu-14.04-gcc-4.8-UnitTestsCoverage-Debug: Coverage Too Low

Build Badge Test Badge Coverage Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResultsSchema (sanyalj) - x86_64-Linux-Ubuntu-14.04-gcc-4.8-IntegrationCoverage-Debug: Tests Failed

Build Badge Test Badge Coverage Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResultsSchema (sanyalj) - x86_64-Linux-Ubuntu-14.04-gcc-4.8: Tests Failed

Build Badge Test Badge

Please # to comment.