First time here? Check out the Help page!
1 | initial version |
Hi All
I just updated the "Export Meter to csv" for the OpenStudio Application 1.1.0, because I found the original one from BCL doesn't work anymore with new OpenStudio Application. Thus I learned from other OpenStudio measure and modified the original one. Thanks mdahlhausen for the original measure. It is great measure.
The modified measure.rb works well. As I do not have enough points to upload the .rb file, just put the related parts below.
1: the reporting class name
class ExportMetertoCSV < OpenStudio::Measure::ReportingMeasure
2: the arguments function
def arguments(model=nil)
args = OpenStudio::Measure::OSArgumentVector.new
#make an argument for the variable name
meter_name = OpenStudio::Measure::OSArgument.makeStringArgument("meter_name",true)
meter_name.setDisplayName("Enter Meter Name.")
args << meter_name
#make an argument for the reporting frequency
reporting_frequency_chs = OpenStudio::StringVector.new
reporting_frequency_chs << "Hourly"
reporting_frequency_chs << "Zone Timestep"
reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)
reporting_frequency.setDisplayName("Reporting Frequency.")
reporting_frequency.setDefaultValue("Hourly")
args << reporting_frequency
3: the sql file related part in run function
def run(runner, user_arguments)
super(runner, user_arguments)
# use the built-in error checking
if !runner.validateUserArguments(arguments, user_arguments)
return false
end
#assign the user inputs to variables
meter_name = runner.getStringArgumentValue("meter_name",user_arguments)
reporting_frequency = runner.getStringArgumentValue("reporting_frequency",user_arguments)
#check the user_name for reasonableness
if meter_name == ""
runner.registerError("No variable name was entered.")
return false
end
setup = OsLib_Reporting.setup(runner)
unless setup
return false
end
model = setup[:model]
sql = setup[:sqlFile]
2 | Suggested edit |
Hi All
I just updated the "Export Meter to csv" for the OpenStudio Application 1.1.0, because I found the original one from BCL doesn't work anymore with new OpenStudio Application. Thus I learned from other OpenStudio measure and modified the original one. Thanks mdahlhausen for the original measure. It is great measure.
The modified measure.rb works well. As I do not have enough points to upload the .rb file, just put the related parts below.
1: the reporting class name
class ExportMetertoCSV < OpenStudio::Measure::ReportingMeasure
2: the arguments function
def arguments(model=nil)
args = OpenStudio::Measure::OSArgumentVector.new
#make an argument for the variable name
meter_name = OpenStudio::Measure::OSArgument.makeStringArgument("meter_name",true)
meter_name.setDisplayName("Enter Meter Name.")
args << meter_name
#make an argument for the reporting frequency
reporting_frequency_chs = OpenStudio::StringVector.new
reporting_frequency_chs << "Hourly"
reporting_frequency_chs << "Zone Timestep"
reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)
reporting_frequency.setDisplayName("Reporting Frequency.")
reporting_frequency.setDefaultValue("Hourly")
args << reporting_frequency
3: the sql file related part in run function
def run(runner, user_arguments)
super(runner, user_arguments)
# use the built-in error checking
if !runner.validateUserArguments(arguments, user_arguments)
return false
end
#assign the user inputs to variables
meter_name = runner.getStringArgumentValue("meter_name",user_arguments)
reporting_frequency = runner.getStringArgumentValue("reporting_frequency",user_arguments)
#check the user_name for reasonableness
if meter_name == ""
runner.registerError("No variable name was entered.")
return false
end
setup = OsLib_Reporting.setup(runner)
unless setup
return false
end
model = setup[:model]
sql = setup[:sqlFile]