DLL Callback Functions

From Planimate Knowledge Base
Revision as of 13:05, 7 November 2011 by Rick (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A DLL written for Planimate to call (in a routine) has a number of callback functions available to it. These give access to advanced services.

Reallocate Table Rows

This enables changing the memory allocation in a table direct parameter (PL_DLLPARAM_TABLEDIRECT) and is useful when the DLL needs an output table to grow to hold more rows. Existing row data in the table is retained, the new rows are not initialised. This only affects the table memory allocation, not the current table rows in use.

typedef int CALLBACK tPL_ReallocateTDTable(PLDLLHandle * pl_handle,
PLRoutineInfo *,
int which_input,
int new_rows);

Generate Breakpoint

This enables a DLL to display text in the breakpoint/debugging dialog.

typedef int CALLBACK tPL_Breakpoint(PLDLLHandle * pl_handle,
const char * msg);

Pop Up Message

This enables a DLL To pop up a MessageBox.

typedef int CALLBACK tPL_Message(PLDLLHandle * pl_handle,<br> const char * msg);

Real Time Broadcast

This enables a DLL to trigger a real time broadcast. The callback will occur after interval (in milliseconds).

typedef int CALLBACK tPL_RealTimeBC(PLDLLHandle * pl_handle,
int interval);

Read System Integer

This enables reading of integer system properties, as defined in the accompanying enum.

enum
{
PLRSI_ENGINESTATE,
PLRSI_CURRENTPENDING,
PLRSI_PLMDLVERSION
};

typedef int CALLBACK tPL_ReadSystemInt(PLDLLHandle * pl_handle,
int ordinal);

Read System Double

This enables reading of double-precision system properties, including the model clock.

enum
{
PLRSD_CLOCK,
PLRSD_ADVANCETOTIME
};

typedef double CALLBACK tPL_ReadSystemDouble(PLDLLHandle * pl_handle,
int ordinal);

Parse Text To Value

This enables using Planimate's text parsing services to convert formatted text to a number. UNITS.HPP contains the valid units. Label Lists and Text formats are not supported. Planimate will use its current active Run Start Date for the 0-epoch for calendar dates.

typedef int CALLBACK tPL_Parse(const char * text,<br> int units,<br> double & result);

Format Value To Text

typedef int CALLBACK tPL_Format(double value,
                                int    units,
                                char * into_buf,
                                int into_buf_size);

Get Column Name

This enables the name of a Table Direct table column to be read by the DLL.

typedef int CALLBACK tPL_GetColumnName(PLTableHandle * t,
                                       int    c,
                                       char * into_buf,
                                       int    into_buf_size);

Set Table Direct Cell

This enables setting a table cell through Planimate's table formatting services. It will parse the "to" text using the column's format. "Text" formatted columns are supported. Label formatted columns are supported for existing labels only.

typedef int CALLBACK tPL_SetTDCell(PLTableHandle * t,
                                   int          r,
                                   int          c,
                                   const char * to);

Get Table Direct Cell

This enables reading a table cell in its text formatted form. It supports all format types including Label List and Text formatted columns.

typedef int CALLBACK tPL_GetTDCell(PLTableHandle * t,
                                   int    r,
                                   int    c,
                                   char * into_buf,
                                   int    into_buf_size); 

Find Table Column

This returns the 0-based column index of a table with a matching column name. It returns -1 if no column found.

typedef int CALLBACK tPL_FindTDColumn(PLTableHandle * t,
                                      const char    * column_name);