MVI56E-LDM ♦ ControlLogix Platform
ThingWorx-LDM Interface Library
ThingWorx® Add-On
Quick Start Guide
ProSoft Technology, Inc.
Page 37 of 49
8.2.2 Callback Function Declarations
Functions - Callbacks, which are called by ThingWorx-LDM Interface Library
during runtime and should be implemented by the user application (default
implementations are provided in sample application):
int tw_ldm_read_value(tw_tag* tag, plc_value* value);
Called to read value of a tag from underlying PLC.
Input argument
tag
carries information about tag which is being read.
It is expected that implemented function returns read value in output argument
value
in case of success and returns 0.
int tw_ldm_write_value(tw_tag* tag, plc_value* value);
Called to write new value to a tag.
int tw_ldm_is_connected_to_plc(void);
If the module is connected to the PLC, then it returns 1. Otherwise, returns 0.
This function is called by the ThingWorx-LDM library for each Thing when it is
polled, if for the thing in the configuration file field
IsConnectedPropertyName
is
set to name of the property used to detect state of the PLC connection. If this
field omitted or set to empty value, then this function will not be called.
int tw_ldm_get_status(char is_verbose, char** buffer, uint16_t max_size);
Used to get information on current status of communication with the underlying
PLC.
If input argument
is_verbose
is not 0, then more detailed information is returned.
If it is 0, then brief information is returned.
Result is copied into provided by the argument
buffer
memory buffer. It might be
pre-allocated by the caller. In this case its size is passed in
max_size
argument.
If buffer points to NULL, then
max_size
still can be used to limit size of returned
text.
Function is expected to return 0 in case of success.
When argument
is_verbose
has non-zero value, sample application
tw-ldm-
interface-sample-app
returns content of log file in the buffer.
Examples of using of those functions can be found in source code of the
sample
application. Particularly, function tw_ldm_get_status is mapped to the ThingWorx
SteamSensor thing’s GetStatus service. It is called when in the SteamSensor
mashup, value in the field Get Status is edited: it is passed as input argument,
and returned in the buffer output argument value is displayed in the text area field
following below Get Status field.