BACnet.Protocol.ObjectTypes.PulseConverter (bacstack v0.1.0-dev.1)

Copy Markdown View Source

The Pulse Converter object turns a raw pulse train (from a physical input) into engineering-unit rate or total values over a configurable time window. It is especially useful for demand metering (kW, gpm, etc.) where you want a smoothed rate without having to count every pulse yourself.

The object references a pulse source via input_reference (i.e. pointing at an a Binary Input that produces pulses) and maintains a present_value (scaled engineering units), an adjust_value for manual correction, a raw count, and timing properties (update_time, count_change_time). The converter never generates pulses itself; it only observes an external source.

Object Description (ASHRAE 135)

The Pulse Converter object type defines a standardized object that represents a process whereby ongoing measurements made of some quantity, such as electric power or water or natural gas usage, and represented by pulses or counts, might be monitored over some time interval.

Pulse Converter objects that support intrinsic reporting shall apply the OUT_OF_RANGE event algorithm.

Behaviour and Operation

Pulse Converter objects turn a raw pulse or count source into a rate or integrated engineering value over a time window. The local application or a periodic task must feed pulses into the object (via the referenced input_reference pointing at Binary Input).

The object then computes present_value (scaled by scale_factor and adjusted by adjust_value) and maintains timing properties. Clients read the derived rate/total; they do not write pulses.

out_of_service can pause the conversion while a test value is forced into present_value. The reliability property and corresponding FAULT state are also to be decoupled.

Developer Implementation Notes (geared to device server / application authors)

The generated code handles storage + basic mechanics (validation, implicit_relationships, readonly annotations as hints to your server, etc.). You must drive "special" live properties and side effects yourself, analogous to maintaining present_value on inputs via update_property/3 (never direct mutation). Read notes below + generated tables for details.

Special / live properties and expected developer behaviour

  • present_value: The converted engineering value (rate or total) = (count or input pulses) scale_factor + adjust_value. *Dev must: Maintain count by observing the input_reference if present, and update present_value after your conversion math. This is the live derived input.

  • count, count_change_time, count_before_change: Raw pulse count tracking (similar to Accumulator's change tracking). Dev must: When pulses arrive (from hardware or by reading the input_reference object), update count, and on manual adjustment via adjust_value or resets, populate the before/change times. These enable detecting adjustments.

  • input_reference (ObjectPropertyRef): Points to source of pulses (typically a BinaryInput). Dev must: If set, your periodic task or change listener must read the source (local or remote ReadProperty) and use it to modify count and present_value. If the object is remote, handle communication errors via reliability.

  • adjust_value: Manual offset/correction. Dev must: Allow writes; your conversion should include it.

  • scale_factor: Conversion factor. Dev must: Set at creation from meter characteristics; usually static.

  • cov_increment, cov_period: For COV on the converted value. Dev must: Normal PV updates will trigger COV logic using these.

  • out_of_service, status_flags, reliability: Dev must: While out_of_service is true, allow forcing present_value for test; suspend normal input_reference polling and count updates. Maintain reliability from source health, if out_of_service is false. The in_alarm/fault/out_of_service bits of status_flags are auto-managed by the object (overridden is local matter).

  • high_limit, low_limit, deadband: For out of range on the converted value. Dev must: After PV/count changes, re-eval the algorithm and drive notifications.

Examples

Creating a Pulse Converter:

iex> {:ok, pc} = BACnet.Protocol.ObjectTypes.PulseConverter.create(400, "UsageRate", %{}); pc.object_name
"UsageRate"

See Also



The following part has been automatically generated.

Click to expand This module defines a BACnet object of the type `pulse_converter`. The following properties are defined: | Property | Revision | Required | Readonly | Protected | Intrinsic | |----------|----------|----------|----------|-----------|-----------| | acked_transitions | | | X | | X | | adjust_value | | X | | | | | count | | X | X | | | | count_before_change | | X | X | | | | count_change_time | | X | X | | | | cov_increment | | | | | | | cov_period | | | | | | | deadband | | | | | X | | description | | | | | | | device_type | | | | | | | event_algorithm_inhibit | | | | | X | | event_algorithm_inhibit_ref | | | | | X | | event_detection_enable | | | | | X | | event_enable | | | | | X | | event_message_texts | | | X | | X | | event_message_texts_config | | | | | X | | event_state | | X | | | | | event_timestamps | | | X | | X | | high_limit | | | | | X | | input_reference | | | | | | | limit_enable | | | | | X | | low_limit | | | | | X | | notification_class | | | | | X | | notify_type | | | | | X | | object_instance | | X | X | | | | object_name | | X | X | | | | out_of_service | | X | | | | | present_value | | X | X | | | | profile_location | 19 | | | | | | profile_name | | | | | | | reliability | | | | | | | reliability_evaluation_inhibit | | | | | | | scale_factor | | X | X | | | | status_flags | | X | X | | | | tags | 19 | | | | | | time_delay | | | | | X | | time_delay_normal | | | | | X | | units | | X | | | | | update_time | | X | X | | | The following properties have additional semantics: | Property | Has Default | Has Init | Implicit Relationships | Validators | Annotations | |----------|-------------|----------|------------------------|------------|-------------| | adjust_value | X | | | | | | count | X | | | | | | count_before_change | X | | | | | | count_change_time | X | | | | | | cov_increment | X | | | | | | cov_period | X | | cov_increment | | | | deadband | X | | | | | | event_algorithm_inhibit_ref | | | event_algorithm_inhibit | | | | high_limit | X | | | | | | low_limit | X | | | | | | present_value | X | | | | | | profile_location | | | | Fun | `revision: 19` | | reliability | | | reliability_evaluation_inhibit | | | | scale_factor | X | | | | | | tags | | | | | `revision: 19` | | units | X | | | | | | update_time | X | | | | | The following table shows the default values and/or init functions: | Property | Default Value | Init Function | |----------|---------------|---------------| | adjust_value | `0.0` | | | count | `0` | | | count_before_change | `0` | | | count_change_time | `%BACnet.Protocol.BACnetDateTime{...}` | | | cov_increment | `0.1` | | | cov_period | `0` | | | deadband | `0.0` | | | high_limit | `0.0` | | | low_limit | `0.0` | | | present_value | `0.0` | | | scale_factor | `1.0` | | | units | `:no_units` | | | update_time | `%BACnet.Protocol.BACnetDateTime{...}` | |

Summary

Types

Common object options for creation - all are optional.

Options accepted when creating or configuring a Pulse Converter object.

Available property names for this object.

The structure for property errors.

t()

Represents an Pulse Converter object. All keys should be treated as read-only, all updates should go only through update_property/3.

Functions

Adds an optional property to an object. Remote objects can not be mutated using this operation.

Creates a new object struct with the defined properties. Optional properties are not created when not given, only required, given and dependency properties are created. Properties with a value of nil are ignored.

Auto generated function to get the names of all properties this object supports.

Auto generated function to get the annotations for the given property name.

Auto generated function to get the list of annotations for each property.

Auto generated function to get the names of properties used for COV reporting.

Auto generated function to get the names of intrinsic properties.

Get the BACnet object identifier.

Auto generated function to get the names of optional properties.

Get the list of properties the object has.

Auto generated function to get a map of property name to type.

Get a property's value from an object.

Auto generated function to get the names of protected properties.

Auto generated function to get the names of readonly properties.

Auto generated function to get the names of required properties.

Checks if the given object has the given property.

Checks if the given object has Intrinsic Reporting enabled.

Checks if the given property is writable.

Removes an optional property from an object. This function is idempotent. Remote objects can not be mutated using this operation.

Auto generated function to check whether the object type supports intrinsic reporting.

Updates a property of an object.

Types

common_object_opts()

@type common_object_opts() ::
  {:allow_numeric_constants, boolean()}
  | {:allow_unknown_properties, boolean()}
  | {:ignore_unknown_properties, boolean()}
  | {:revision, BACnet.Protocol.Constants.protocol_revision()}
  | {:skip_property_validation_remote_object, boolean() | :value}

Common object options for creation - all are optional.

  • allow_numeric_constants - Constants are atoms and thus unknown constants or vendor extensions are integers and thus are rejected. Enabling this option will allow integers (non_neg_integer()) for properties with a Constants.type() spec.
  • allow_unknown_properties - Properties that are unknown to the object implementation are usually rejected. With this option, unknown properties (numeric identifiers usually means we dont know them) are accepted and put into a separate map. This does mean we can not validate or write them. Types of the values can be anything at this point. While you can read unknown properties with atom or integer as property identifier, you can only remove numeric unknown property identifiers from an object. Property identifiers of type atom are only accepted, if it is a remote object (object implementation is only enforced if it is a local object). Numeric property identifiers are accepted regardless of remote object or not. For remote objects, this means you have to write "raw values" (usually Encoding structs).
  • ignore_unknown_properties - Properties that are unknown to the object implementation are usually rejected. With this option, unknown properties get ignored, as if they were not specified.
  • revision - The BACnet protocol revision to check required properties against. Optional properties are regardless of revision available. See BACnet.Protocol.Constants.protocol_revision/0 for the available revisions.
  • skip_property_validation_remote_object - Skips property validation for remote objects. Sometimes it is possible that the value is invalid as per BACnet specification (i.e. value 0 for a multistate object), but you still want those to be represented. Value true neither type nor value are validated. Value :value means the type is still validated and only the value validator is not run (if present). The property's validator_fun will also be skipped.

object_opts()

@type object_opts() :: common_object_opts()

Options accepted when creating or configuring a Pulse Converter object.

property_name()

@type property_name() ::
  :acked_transitions
  | :adjust_value
  | :count
  | :count_before_change
  | :count_change_time
  | :cov_increment
  | :cov_period
  | :deadband
  | :description
  | :device_type
  | :event_algorithm_inhibit
  | :event_algorithm_inhibit_ref
  | :event_detection_enable
  | :event_enable
  | :event_message_texts
  | :event_message_texts_config
  | :event_state
  | :event_timestamps
  | :high_limit
  | :input_reference
  | :limit_enable
  | :low_limit
  | :notification_class
  | :notify_type
  | :object_instance
  | :object_name
  | :out_of_service
  | :present_value
  | :profile_location
  | :profile_name
  | :reliability
  | :reliability_evaluation_inhibit
  | :scale_factor
  | :status_flags
  | :tags
  | :time_delay
  | :time_delay_normal
  | :units
  | :update_time

Available property names for this object.

property_update_error()

@type property_update_error() ::
  {:error,
   {error :: atom(),
    property :: BACnet.Protocol.Constants.property_identifier()}}

The structure for property errors.

t()

@type t() :: %BACnet.Protocol.ObjectTypes.PulseConverter{
  _metadata: internal_metadata(),
  _unknown_properties: %{
    optional(atom() | non_neg_integer()) =>
      term()
      | BACnet.Protocol.ApplicationTags.Encoding.t()
      | [BACnet.Protocol.ApplicationTags.Encoding.t()]
  },
  acked_transitions: BACnet.Protocol.EventTransitionBits.t() | nil,
  adjust_value: float(),
  count: non_neg_integer(),
  count_before_change: non_neg_integer(),
  count_change_time: BACnet.Protocol.BACnetDateTime.t(),
  cov_increment: float() | nil,
  cov_period: non_neg_integer() | nil,
  deadband: float() | nil,
  description: String.t() | nil,
  device_type: String.t() | nil,
  event_algorithm_inhibit: boolean() | nil,
  event_algorithm_inhibit_ref: BACnet.Protocol.ObjectPropertyRef.t() | nil,
  event_detection_enable: boolean() | nil,
  event_enable: BACnet.Protocol.EventTransitionBits.t() | nil,
  event_message_texts: BACnet.Protocol.EventMessageTexts.t() | nil,
  event_message_texts_config: BACnet.Protocol.EventMessageTexts.t() | nil,
  event_state:
    BACnet.Protocol.Constants.event_state()
    | (reserved_or_vendor_extension :: non_neg_integer()),
  event_timestamps: BACnet.Protocol.EventTimestamps.t() | nil,
  high_limit: float() | nil,
  input_reference: BACnet.Protocol.ObjectPropertyRef.t() | nil,
  limit_enable: BACnet.Protocol.LimitEnable.t() | nil,
  low_limit: float() | nil,
  notification_class: non_neg_integer() | nil,
  notify_type:
    BACnet.Protocol.Constants.notify_type()
    | (reserved_or_vendor_extension :: non_neg_integer())
    | nil,
  object_instance: non_neg_integer(),
  object_name: String.t(),
  out_of_service: boolean(),
  present_value: float(),
  profile_location: String.t() | nil,
  profile_name: String.t() | nil,
  reliability:
    BACnet.Protocol.Constants.reliability()
    | (reserved_or_vendor_extension :: non_neg_integer())
    | nil,
  reliability_evaluation_inhibit: boolean() | nil,
  scale_factor: float(),
  status_flags: BACnet.Protocol.StatusFlags.t(),
  tags: BACnet.Protocol.BACnetArray.t(BACnet.Protocol.NameValue.t()) | nil,
  time_delay: non_neg_integer() | nil,
  time_delay_normal: non_neg_integer() | nil,
  units:
    BACnet.Protocol.Constants.engineering_unit()
    | (reserved_or_vendor_extension :: non_neg_integer()),
  update_time: BACnet.Protocol.BACnetDateTime.t()
}

Represents an Pulse Converter object. All keys should be treated as read-only, all updates should go only through update_property/3.

Functions

add_property(object, property, value)

@spec add_property(t(), BACnet.Protocol.Constants.property_identifier(), term()) ::
  {:ok, t()} | property_update_error()

Adds an optional property to an object. Remote objects can not be mutated using this operation.

Please note that properties of services can not be dynamically added and instead the object must be newly created using create/4.

create(instance_number, object_name, properties \\ %{}, opts \\ [])

@spec create(
  non_neg_integer(),
  String.t(),
  %{optional(property_name() | atom() | non_neg_integer()) => term()},
  [object_opts() | internal_metadata()]
) :: {:ok, t()} | property_update_error()

Creates a new object struct with the defined properties. Optional properties are not created when not given, only required, given and dependency properties are created. Properties with a value of nil are ignored.

Only properties that are required for specific services (i.e. Intrinsic Reporting) are automatically created.

By default, a default cov_increment of 0.1 is used. It is strongly advised to change this to something reasonable for the application.

get_all_properties()

@spec get_all_properties() :: [BACnet.Protocol.Constants.property_identifier()]

Auto generated function to get the names of all properties this object supports.

get_annotation(name)

@spec get_annotation(property_name()) :: [term()]

Auto generated function to get the annotations for the given property name.

get_annotations()

@spec get_annotations() :: [{name :: property_name(), values :: [term()]}]

Auto generated function to get the list of annotations for each property.

get_cov_properties()

@spec get_cov_properties() :: [BACnet.Protocol.Constants.property_identifier()]

Auto generated function to get the names of properties used for COV reporting.

get_intrinsic_properties()

@spec get_intrinsic_properties() :: [BACnet.Protocol.Constants.property_identifier()]

Auto generated function to get the names of intrinsic properties.

get_object_identifier(object)

@spec get_object_identifier(t()) :: BACnet.Protocol.ObjectIdentifier.t()

Get the BACnet object identifier.

get_optional_properties()

@spec get_optional_properties() :: [BACnet.Protocol.Constants.property_identifier()]

Auto generated function to get the names of optional properties.

get_properties(object)

@spec get_properties(t()) :: [BACnet.Protocol.Constants.property_identifier()]

Get the list of properties the object has.

get_properties_type_map()

@spec get_properties_type_map() :: map()

Auto generated function to get a map of property name to type.

get_property(object, property)

Get a property's value from an object.

get_protected_properties()

@spec get_protected_properties() :: [BACnet.Protocol.Constants.property_identifier()]

Auto generated function to get the names of protected properties.

Protected is an annotation and the object modules prevent writing to this property directly in code. The protected properties are either written on creation or updated automatically depending on other properties being written to. Some properties are only written once at creation and never updated.

get_readonly_properties()

@spec get_readonly_properties() :: [BACnet.Protocol.Constants.property_identifier()]

Auto generated function to get the names of readonly properties.

Readonly is only an annotation that the property should be write protected on the BACnet side, there is no actual write protection in the object. This is a hint to the device server. If you need actual write protection, see protected.

get_required_properties()

@spec get_required_properties() :: [BACnet.Protocol.Constants.property_identifier()]

Auto generated function to get the names of required properties.

has_property?(object, property)

Checks if the given object has the given property.

See BACnet.Protocol.ObjectsUtility.has_property?/2 for implementation details.

intrinsic_reporting?(object)

@spec intrinsic_reporting?(t()) :: boolean()

Checks if the given object has Intrinsic Reporting enabled.

property_writable?(object, property)

@spec property_writable?(t(), BACnet.Protocol.Constants.property_identifier()) ::
  boolean()

Checks if the given property is writable.

Check BACnet.Protocol.ObjectsUtility.property_writable?/2 for a basic run-down.

remove_property(object, property)

@spec remove_property(
  t(),
  BACnet.Protocol.Constants.property_identifier() | non_neg_integer()
) ::
  {:ok, t()} | property_update_error()

Removes an optional property from an object. This function is idempotent. Remote objects can not be mutated using this operation.

Please note that properties of services can not be dynamically removed and instead the object must be newly created using create/4. Required properties can not be removed.

supports_intrinsic()

@spec supports_intrinsic() :: boolean()

Auto generated function to check whether the object type supports intrinsic reporting.

update_property(object, property, value)

@spec update_property(t(), BACnet.Protocol.Constants.property_identifier(), term()) ::
  {:ok, t()} | property_update_error()

Updates a property of an object.