Datapoint Write Functions

You can use a datapoint write callback function to respond to a datapoint write request from IDL to a custom driver.  A datapoint write request originates from an IAP/MQ datapoint write request to a custom driver.  The IAP/MQ datapoint write request is typically the result of a datapoint write request from an IAP/MQ client. In response to an IAP/MQ write request to IDL, IDL calls the DpWrite callback function that was registered during the custom driver init process. 

A datapoint write request may specify a write at normal priority or an override priority and may relinquish an active override.  Writes to datapoints consider whether the custom driver has its own native priority array and whether it is writable, such as in BACnet. This is specified through the XIF using the Priority Array and Writable Normal Value columns.  An entry in the Writable Normal Value column specifies whether an input datapoint supports a writable normal value (that is, a writable relinquish default value).  A write to a datapoint on a BACnet device with an unwritable relinquish default is treated as a write at priority 16.  An entry in the Priority Array column specifies whether the device has a priority array for the datapoint.

Based on the Priority Array and Writable Normal Value columns, IDL calls the custom driver write callback function, DpWrite, as follows:

  • For an input datapoint:
    1. If Priority Array is true:
      1. if Writable Normal Value is true and the value of any priority has changed or an override has been relinquished, call DpWrite(prio, rel, val).
      2. if Writable Normal Value is false
        1. If the value of normal priority has changed, write to priority 16 because normal is non-writable by calling DpWrite(16, 0, val).
        2. If the value of any override has changed or relinquished, call DpWrite(prio, rel, val).
    2. If Priority Array is false and the value of any priority has changed or an override has been relinquished, write the value of only the highest priority that is valid by calling DpWrite(0, 0, val).
  • For an output datapoint:
    1. If Priority Array is true and the value of priority 17 has changed, call DpWrite(prio:17, rel:0, val).

Datapoint Write Callback Function

DpWrite

IdlErrorCodes DpWrite(int callback_index, IdlDev *dev, IdlDatapoint *dp, int prio, int relinquish, double value));

When a datapoint write is complete, the custom driver reports the result to the IDL using IdlDpWriteResult.

Datapoint Write Related Functions

IdlDpWriteCallbackSet

void IdlDpWriteCallbackSet(Idl *idl, int (*DpWrite)(int, IdlDev *, IdlDatapoint *, int, int, double));

Must be called by the custom driver prior to calling IdlInit.


IdlDpWriteResult

void IdlDpWriteResult(int callbackIndex, IdlDev *dev, IdlDatapoint *dp, int idlError);

Must be called by the custom driver at the end of the callback function before exiting.