Skip to content
Version 6.1.0
Contact Us

BACnetStack_InsertTrendLogRecord

bool BACnetStack_InsertTrendLogRecord(
const uint32_t deviceInstance,
const uint32_t objectInstance,
const CASBACnetTime timestamp,
const uint8_t datumType,
const char * datumAsString,
const uint32_t datumLength,
const bool * statusFlags,
const uint32_t statusFlagsLength);

Adds a log record to a Trend Log object.

The record is passed as a string and decoded per datumType.

This is the restore half of the pair whose backup half is BACnetStack_ReadTrendLogRecord() below: a record read out with that export can be written back with this one. Trend Log Multiple has the same pair (BACnetStack_InsertTrendLogMultipleRecord() / BACnetStack_ReadTrendLogMultipleRecord()).

BACnet reference: ANSI/ASHRAE 135-2024 clause 12.25 (Trend Log Object Type).

Parameter Direction Description
deviceInstance in The instance of the device that contains the trend log object.
objectInstance in The instance of the trend log object.
timestamp in The timestamp of the record to insert, in UTC epoch seconds. The stack stores it as the Device’s local time, using the UTC_Offset (and Daylight_Savings_Status) your application serves for the Device at the time of the call. BACnetStack_ReadTrendLogRecord() converts it back with the offset served at the time of the read, so a backup and restore keeps each timestamp, but a record stored under the other Daylight_Savings_Status reads out one hour off.
datumType in The type of data to insert. Valid values: 0 = Log Status, 1 = Boolean, 2 = Real, 3 = Enumerated, 4 = Unsigned, 5 = Integer, 6 = Bitstring, 7 = Null, 8 = Error, 9 = Time Change, 10 = Any Value (a logged value of any other datatype, such as a Double or a CharacterString). Each value is the tag of a log-datum CHOICE arm of BACnetLogRecord (cl. 12.25, cl. 21): Log Status is a BACnetLogStatus BIT STRING, and Error is the failure arm.
datumAsString in The value in string form, e.g. Log Status “b101”, Boolean “true”/“false”, Real “123.45”, Enumerated “10”, Unsigned “25”, Integer “-10”, Bitstring “b10101” (an empty bitstring is “b”), Null “null”, Error “1-31” (a HYPHEN, per <errorClass>-<errorCode>), Time Change “3600.0”, Any Value the encoded value in hex, two digits per octet, e.g. “720041” for the CharacterString “A”, or “x” for a value with no elements. These are the same values and the same string forms BACnetStack_ReadTrendLogRecord() writes out, so a record read out inserts back with the same value, and reading it again gives the same string. For Null the empty string is accepted too. Any Value hex is stored as the value it decodes to: upper-case or otherwise non-canonical hex reads back in the stack’s lower-case encoding, and hex for a value that has a type of its own (a single Real, say) is still stored and read back as type 10.
datumLength in The length of datumAsString.
statusFlags in Optional bool[4] of the logged object’s Status_Flags at record time, a BACnetStatusFlags BIT STRING (cl. 21) as one bool per bit in bit order (in-alarm, fault, overridden, out-of-service); NULL if unused. Unlike BACnetStack_ReadTrendLogRecord()’s statusFlags, this one IS optional.
statusFlagsLength in Length of statusFlags (0 if unused).

true if successful; false if the object/device does not exist, a parameter is invalid, the datum fails to decode, or the log is stop-when-full and already full.

Topic: Schedules, calendars, trend logs and other object configuration. Declared in CASBACnetStackDLL.h.