Learn R Programming

eplusr (version 0.8.3)

idf_object: EnergyPlus IDF object

Description

IdfObject is an abstraction of a single object in an Idf. It provides more detail methods to modify objects. IdfObject can only be created from the parent Idf object, using $object, $object_in_class() and $search_object(). This is because that initialization of an IdfObject needs some shared data from parent Idf object.

Arguments

Value

idfobj$get_value(which = NULL, all = FALSE, simplify = FALSE)
idfobj$set_value(..., default = TRUE)
idfobj$FieldName
idfobj[[Field]]
idfobj$FieldName <- Value
idfobj[[Field]] <- Value
idfobj$possible_value(which = NULL)

$get_value() returns a named list containing values of specified fields. If simplify is FALSE, then all values will be converted into character and the converted character vector will be returned. Note that the field names will be converted into valid R names, i.e. all characters other than letters and numbers will be replaced by underscore("_").

$set_value() sets values of current object.

eplusr also provides custom S3 method of $, [[ and also $<- and [[<- to make it more convenient to get and set a single value of an IdfObject. Basically, idfobj$FieldName and idfobj[[Field is equivalent to idfobj$get_value(Field)[[1]]; idfobj$FieldName <- Value and idfobj[[Field]] <- Value is equivalent to idfobj$set_value(Field = Value), where FieldName is a single valid field name and Field is a single valid field index or name.

$possible_value() return all possible values for specified fields, including auto-value (autosize and autocalculate), default value, value range, choices and references. Underneath, it returns a data.table with custom printing method.

Arguments

  • which: An integer vector of field indexes or a character vector of field names. Field names can be given in "lower-style", e.g. "Thermal Resistance" can be given as "thermal_resistance".

  • all: If TRUE, values of all fields, including empty fields will be returned as well. Default: FALSE

  • simplify: If TRUE, values of fields will be converted into characters and the converted character vector will be returned.

  • ...: Values to set. Field names of value can be given. If not named, the input values will be set to fields according to their order of appearance.

  • default: If TRUE, all empty fields will be filled with their default values if possible.

  • FieldName: A single length character vector of one valid field name where all characters except letters and numbers are replaced by underscores.

  • Field: A single length character vector of one valid field name or a single length integer vector of one valid field index. Same as above, field names should be given in a style where all characters except letters and numbers are replaced by underscores.

  • Value: A single length vector of value to set.

Usage

idfobj$id()
idfobj$name()
idfobj$definition()
idfobj$get_comment()
idfobj$set_comment(comment, append = TRUE, width = 0L)
idfobj$get_value(which = NULL, all = NULL, simplify = FALSE)
idfobj$set_value(..., defaults = TRUE)
idfobj$FieldName
idfobj[[Field]]
idfobj$FieldName <- Value
idfobj[[Field]] <- Value
idfobj$possible_value(which = NULL)
idfobj$validate()
idfobj$is_valid()
idfobj$ref_from_object()
idfobj$ref_by_object()
idfobj$has_ref_by()
idfobj$has_ref_from()
idfobj$has_ref()
idfobj$table(all = FALSE, unit = TRUE, wide = FALSE, string_value = TRUE, in_ip = eplusr_option("view_in_ip"))
idfobj$string(comment = TRUE, leading = 4L, sep_at = 29L)
idfobj$print(comment = TRUE, auto_sep = FALSE)
print(iddobj)

Basic Info

idfobj$id()
idfobj$name()
idfobj$group_name()
idfobj$class_name()

$id() returns the object ID.

$name() returns the object name. If the class does not have name attribute, then NA will returned.

$group_name() returns the group name of this object belongs to.

$class_name() returns the class name of this object belongs to.

Definition

idfobj$definition()

$definition() returns the definition, i.e. the IddObject, of current class. For details of IddObject, please see IddObject class.

Comment

idfobj$get_comment()
idfobj$set_comment(comment, append = TRUE, width = 0L)

$get_comment() returns the comments of current object.

$set_comment() sets comments of current object.

Arguments

  • comment: A character vector.

  • append: If TRUE, comment will be appended to existing comments. If FALSE, comment will be prepended to existing currents. If NULL, existing comments will be deleted. Default: FALSE

  • width: An integer to indicate where to break long comment lines. If 0, no breaking will be made.

Validation

idfobj$validate()
idfobj$is_valid()

$validate() will check if there are errors in current object under different strictness level.

$is_valid() will check if there are no errors in current object under different strictness level.

The strictness level can be changed using eplusr_option(). Default is "final".There are three different validate levels, i.e. "none", "draft" and "final":

  • For "none", none validation will be done;

  • For "draft", checking of invalid autosize, autocalculate, numeric, integer, and choice field values will be done;

  • For "final", besides above, checking of missing required objects, duplicated unique objects, object name conflicts, missing required fields and invalid field value reference will also be done.

Cross Reference

idfobj$ref_from_object()
idfobj$ref_by_object()
idfobj$has_ref_from()
idfobj$has_ref_by()
idfobj$has_ref()

$ref_from_object() will return other objects that current object references from.

$ref_by_object() will return other objects that reference current object.

$has_ref_from() and $has_ref_by will return TRUE if current object has referenced from other objects or has been referenced by other objects, respectively.

$has_ref() will return TRUE if current object has either referenced from other objects or has been referenced by other objects.

Data Extraction

idfobj$table(all = FALSE, unit = TRUE, wide = FALSE, string_value = TRUE, in_ip = eplusr_option("view_in_ip"))

$table() will return a data.table that contains all data of current object.

Arguments

  • all: If TRUE, values of all fields, including empty fields will be returned as well. Default: FALSE

  • unit: If TRUE, field names with units will be returned. Default: TRUE.

  • wide: If TRUE, a wide table will be returned. Default: FALSE.

  • string_value: If TRUE, all field values will be returned as character. Default: TRUE

  • in_ip: If TRUE, IP units and values will be returned. Default: the value of eplusr_option("view_in_ip").

Formatting

idfobj$string(comment = TRUE, leading = 4L, sep_at = 29L)

$string() will return the text format of current object.

Arguments

  • comment: If FALSE, all comments will not be included.

  • leading: An integer to indicate the number of spaces before each fields. Default: 4.

  • sep_at: An integer to indicate the character width where to separate values and field names. Default: 29.

Print

idfobj$print(comment = TRUE, auto_sep = FALSE)
print(idfobj)

Arguments

  • comment: If FALSE, all comments will not be included.

  • auto_sep: If TRUE, values and field names will be separate at the largest character length of values. Default: FALSE.

See Also

Idf class