Skip to content

How to Create Inputs and Outputs With Measures

Anya Petersen edited this page Jul 13, 2023 · 2 revisions

This guide provides guidance on creating inputs and outputs using measures. This guide builds on the information in Getting Started With Alfalfa Measures Part 1 and Part 2.

Creating an Output

Output objects wrap lower level IDF Objects and provide an interface for extended functions: display names, units, associated zones, etc.

Constructing an Output

output_variable # Either an Output Variable or an EMS Output Variable
output = OpenStudio::Alfalfa::Output.new(output_variable)

Registering an Output

Once an Output object is created it won't be exposed via Alfalfa until it is registered. This can be done as follows

register_output(output)

You can also skip the step of constructing an output by calling register_output with the output variable

register_output(output_variable)

Creating an Input

Similar to Output objects Input objects wrap lower level IDF objects and add Alfalfa specific functionality.

Constructing an Input

input_variable # Either an External Interface Variable, Actuator, or Schedule
input = OpenStudio::Alfalfa::Input.new(input_variable)

Registering an Input

Once an Input object is created it won't be exposed via Alfalfa until it is registered. This can be done as follows

register_input(input)

You can also skip the step of constructing an output by calling register_input with the input variable

register_input(input_variable)

Adding an Enable to an Input

An enabled input consists of two inputs. One of which conveys the value from Alfalfa, the other reports whether or not the value is currently set in Alfalfa (1 if set, 0 if unset). This is useful for actuators which need Null to be written to them in order to not override the model logic.

This can be done Manually as follows or by utilizing the library function.

input_variable # Valid Input Variable Type
input_enable_variable # Valid Input Variable Type

# create and register Input object
input = register_input(input_variable)
# create and don't register enable Input object
input_enable = OpenStudio::Alfalfa::Input.new(input_enable_variable)
# set the enable_variable property of the input to the new input_enable object
input.enable_variable = input_enable

Now when a user writes to the input the value of input_enable will be 1. This can be read by an EMS program and incorporated into control logic.

Adding an Echo to an Input

By default if you try to read the value of an Input with the Alfalfa API you won't get anything. To associate an Output with an Input you can use the echo property of the input to point it to the corresponding Output.

input # Input object
output # Output object

# Set echo property of Input to Output
input.echo = output

# If Points are not already registered, register them
register_input(input)
register_output(output)

Model Configuration

Openstudio

Tutorials

Guides

Reference

Modelica

Guides

Alfalfa Interaction

Tutorials

Guides

Reference

Explanation

Alfalfa Development

Guides

General

Reference

Explanation

Clone this wiki locally