IBM Visualization Data Explorer Programmer's Reference

[ Bottom of Page | Previous Page | Next Page | Table of Contents | Partial Table of Contents | Index ]


17.3 Example 2: maptoplane.c

The second example which we will discuss is maptoplane.c. This sample program starts the Data Explorer user interface in -edit mode, and then loads a visual program (see Figure 13).

Figure 13. maptoplane.net

Figure map2plan not
displayed.


The visual program contains two DXLInput tool which can receive values from the DXLink program. One is named file_to_import, and the other is named maptoplane_point. The DXLink program sends the filename to file_to_import, and then sends several different values to maptoplane_point. The program is run and for each execution, statistics are computed on the resulting MapToPlane. The maximum value on the plane is passed to a DXLOutput tool labeled maptoplane_max. In maptoplane.c, a handler has been installed for output coming from maptoplane_max, and the handler simply prints the value to the terminal.

#include <stdio.h>
#include "dx/dxl.h"
#ifndef BASE
#define BASE "/usr/local/dx"
#endif
void SyncAfterExecute(DXLConnection *conn)
{
  int status=1;
   while (status) {
      sleep(1);
      if (DXLIsMessagePending(conn))
         DXLHandlePendingMessages(conn);
      DXLGetExecutionStatus(conn, &status);
   }
}
/*
 * this routine simply prints the maximum value as received from the
 * DXLOutput tool
 */
void max_handler(DXLConnection *conn, const char *name, const char *value,
                 void *data)
{
   printf("max value = %s\n", value);
}
main(int argc, char *argv[])
{
    DXLConnection *conn = NULL;
    char result[100];
    int status;
    /*
     * Start Data explorer user interface in -edit mode, with certain
     * in -edit mode, with certain menus turned off.
     */
    conn = DXLStartDX("dx -edit -noExitOptions -noExecuteMenus -noConnectionMenus",
                      NULL);
    if (conn == NULL)
    {
        fprintf(stderr,"Could not connect\n");
        perror("DXLStartDX");
        exit(1);
    }
    /*
     *  Set the handler for the DXLOutput tool which is labelled
     *  "maptoplane_max"
     */
    DXLSetValueHandler(conn, "maptoplane_max", max_handler, NULL);
    /*
     * Load the visual program to run. Set the value of the DXLInput
     * tool which is labelled "file_to_import".
     * Also set the value of the DXLInput tool which is labelled
     * "maptoplane_point".
     */
    DXLLoadVisualProgram(conn, BASE"/samples/dxlink/maptoplane.net");
    DXLSetString(conn, "file_to_import","/usr/local/dx/samples/data/temperature");
    DXLSetValue(conn, "maptoplane_point", "[0 5000 5000]");
    /*
     * Execute the visual program and check for input from maptoplane_max.
     */
    DXLExecuteOnce(conn);
    SyncAfterExecute(conn);
    /* Change the value for the DXLInput tool labelled "maptoplane_point
     * and execute again.
     */
    DXLSetValue(conn, "maptoplane_point", "[10000 5000 5000]");
    DXLExecuteOnce(conn);
    SyncAfterExecute(conn);
    /* Change the value for the DXLInput tool labelled "maptoplane_point
     * and execute again.
     */
    DXLSetValue(conn, "maptoplane_point", "[20000 5000 5000]");
    DXLExecuteOnce(conn);
    SyncAfterExecute(conn);
    /* Change the value for the DXLInput tool labelled "maptoplane_point
     * and execute again.
     */
    DXLSetValue(conn, "maptoplane_point", "[30000 5000 5000]");
    DXLExecuteOnce(conn);
    SyncAfterExecute(conn);
    /* Change the value for the DXLInput tool labelled "maptoplane_point
     * and execute again.
     */
    DXLSetValue(conn, "maptoplane_point", "[50000 5000 5000]");
    DXLExecuteOnce(conn);
    SyncAfterExecute(conn);
    printf("Hit return to quit:");
    gets(result);
    DXLExitDX(conn);
}


[ Top of Page | Previous Page | Next Page | Table of Contents | Partial Table of Contents | Index ]
[Data Explorer Documentation | QuickStart Guide | User's Guide | User's Reference | Programmer's Reference | Installation and Configuration Guide ]

[Data Explorer Home Page]


[IBM Home Page | Order | Search | Contact IBM | Legal ]