borynet.com Logo

Interface with IOMON 3.0

by Christopher M. Borys, May 15, 2008

There are several ways to interface the I/O monitor engine (IOMON). For simplicity and minimal effort there is ready to use IOMONVIEW utility program providing various ways to show current status and signal values. For more complex yet not too "heavy" there is PHP interface. PHP script interfacing IOMON can be developed without any additional tools or compilation process. PHP also fits well into web interface allowing for nice graphics and interactive user input as well. The PHP interface is free and comes with several sample programs installed on the based system. There is also C/C++ interface allowing for development of customized programs going way beyond capabilities of PHP. The C/C++ interface can be purchased from BORYNET as an add-on development kit for Linux i386 platform only.

IOMONVIEW

The most simple to use is the included utility program iomonview. IOMONVIEW communicates with IOMON via shared memory and displays current information to the standard output which is your console. When logged in to DCS, type:

$> iomonview -h
Usage: iomonview [options]
This program shows the content of iomon output saved in shared memory.
It is a simple facility to allowing to display current values of signals and alarms.
  -a, --alarm         alarms only
  -A  --all           all (-as): analog and alarms
  -d, --delim ARG     delimeter string
  -f, --file ARG      use file as template
  -h, --help          help
  -n, --count ARG     count how many times to loop: ARG=0 means forever.
  -s, --signal        signal values
  -w, --wait ARG      time of waiting (sleep) between reads in seconds. Default 1

To show one time values of signal processed by IOMON just type:

$> iomonview

To repeat the display 5 times:

$> iomonview -n 5

To repeat the display 20 times with 5 seconds intervals:

$> iomonview -n 20 -w 5

To indefinitely continue displaying the signals type with 10 seconds inverval. +C to stop.

$> iomonview -n 0 -w 10

The iomonview can also be helpful to check the current status of IOMON remotely using ssh.

remote-host$> ssh root@mydcs iomonview
Customizing the output from iomon

By default, the signals are separated by the comma and space ", ". This, however, can be modified with an option "-d" which allows for user defined delimiter. The following example demonstrates how to place each singal on a separated line:

$> iomon -n 10 -d "\n"

Much more powerful, is the option to use template file. When this option is used, the iomonview reads the template, replaces the references to signals in the template, and displays it to standard out. The template may include description text and commands to clear the screen. The signals are reference using the following convention: ${SIGNAL-NAME}.
For example, let's assume we have a temperature signal TEMP01 and its current value is 76.43 F. The template file does contain following line:

'Outside temperature:     ${TEMP01} [F]'
When run through iomonview:
$> iomonview -f template
we would get an output like:
Outside temperature:     76.43 [F]

PHP

Another powerful interface tool is the PHP scripting. The IOMON includes an interface PHP class IOMShMem (iomshmem.php). The class allows to do more complex operations on signals without the need of external tools or compilation process. To best undestand how it works let consider the example below:

    1   #! /usr/bin/php
    2   MY PHP TEST FOR SHARED MEMORY
    3   Open();
    7   if ($shm === false)
    8   {
    9           echo "ERROR: IOMON not running or not connected.";
   10           exit;
   11   }
   12   echo "iom_version=$iom_version\n";
   13
   14
   15   for($i=0; $i < 20; $i++)
   16   {
   17           $iov = $shm->GetInput();
   18           if ($iov===false)
   19           {
   20                   echo 'Exit on ERROR ('.$shm->ErrMsg.")\n";
   21                   break;
   22           }
   23           $iov = trim($iov);
   24           if (strlen($iov) == 0)
   25           {
   26                   echo "ERROR: IOMON not running or not connected.";
   27                   break;
   28           }
   29
   30           eval($iov);
   31
   32           echo "\nInput Values\n";
   33           foreach ($SIGIN as $key=>$val)
   34                   echo "$key=$val\n";
   35
   36           echo "\n\nPARAMETERS\n";
   37           foreach ($PARAM as $key=>$val)
   38                   echo "$key=$val\n";
   39           sleep(2);
   40   }
   41   $shm->Close();
   42   ?>
   43
  • Lines 1-3: start the php script.
  • Line 4: include the IOMShMem class that will be used to access shared memory.
  • Line 5: create an class instance; a variable $shm to access the shared memory and to perform operations.
  • Line 6: attempt to open share memory. If returns false, most likely the IOMON is nor running or not operating correctly.
  • Line 15: a loop for 20 iterations
  • Lines 17-22: Read the input block. If successful, this block contains all the signals and parameters.
  • Lines 23-28: Make sure the block is not empty.
  • Line 30: The block is formatted in PHP style. In fact, the block contains PHP arrays $SIGIN and $PARAM. After executing 'eval()', these arrays become accessible.
  • Lines 32-38: A example how to print the content of $SIGIN and $PARAM array.
  • Line 39: Sleep a while for another iteration to continue.
  • Line 42: Close shared memory access.
  • Web Access

    A similar PHP code can be incorporated right into a status page at the DCS Web Server. Whether using CGI shell script and iomonview or PHP IOMShMem class the result is similar: the signal values are displayed and available to the user. This way the signal values would be available to any client on the network using HTTP protocol. To be fancy, one might include automatic refresh request with status page.

    <!-- Auto refresh 15 sec = 15000  -->
    <BODY onload="window.setTimeout('window.location.reload()',15000);">
    
    Contact Us Search Legal Designed by