Sunteți pe pagina 1din 36

User Functions API.

doc



Flex.Win
User Functions API

Document History
Revision Date Author Description
1 10-Feb-2002 AT Initial Draft
2 11-Feb-2002 ACH IPC description added
3 14-Feb-2002 AT Updated
4 08-Apr-2002 ACH Translated to English
5 10-Apr-2002 AT Updated
6 30-Apr-2002 AT Updated
7 28-Apr-2002 ACH Additional description for console name field
8 09-May-2002 DC Added description for existing user_func users
9 15-Aug-2002 AT Changed SRVIPCGetConsoleList description
10 11-Sep-2002 ACH Description for SRVIPCGetControlInfo() added
11 12-Sep-2002 ACH Fixed description for SRVIPCGetControlInfo()
12 16-Oct-2003 AT Changed SRVIPCInputStrBox() description. $PASS$ added
13 09-Dec-2004 DC Updated description for SRVIPCStartApplication
14 01-Jul-2009 VS Added descriptions for SRVIPCPlaySound(),
SRVIPCStopSound(), SRVIPCOpenDisplayEx(),
SRVIPCModal() and FlexView API ShowDatabaseEditor()
15 10-Oct-2009 AC RealFlex 6.4.63 compatible functions updated
16 02-Nov-2009 AC Some comment for examples fixed














User Functions API.doc Page 2 of 36
User Functions API.doc Page 3 of 36
Table of contents
RealFlex User functions API. ..........................................................................................................4
Introduction. ................................................................................................................................4
API description. ...........................................................................................................................7
SRVIPCOpen...............................................................................................................................7
SRVIPCClose ..............................................................................................................................8
SRVIPCSetTimeout.....................................................................................................................8
SRVIPCSetTimeoutMode ...........................................................................................................8
SRVIPCGetConsoleList ..............................................................................................................9
SRVIPCGetConsoleName.........................................................................................................10
SRVIPCGetConsoleType ..........................................................................................................10
SRVIPCMessageBox.................................................................................................................11
SRVIPCInfoBox........................................................................................................................13
SRVIPCCloseInfoBox...............................................................................................................14
SRVIPCInputStrBox .................................................................................................................14
SRVIPCInputNumBox ..............................................................................................................16
SRVIPCMenu............................................................................................................................18
SRVIPCCheckList.....................................................................................................................20
SRVIPCOpenDisplay................................................................................................................22
SRVIPCReplaceDisplay............................................................................................................23
SRVIPCCloseDisplay................................................................................................................24
SRVIPCSendTextMessage........................................................................................................25
SRVIPCPrintReport...................................................................................................................26
SRVIPCStartApplication...........................................................................................................27
SRVIPCGetControlInfo.............................................................................................................28
SRVIPCPlaySound....................................................................................................................31
SRVIPCStopSound....................................................................................................................32
SRVIPCOpenDisplayEx............................................................................................................32
SRVIPCModal...........................................................................................................................34
FlexView User function API .........................................................................................................35
ShowDatabaseEditor .................................................................................................................35
User Functions API.doc Page 4 of 36
RealFlex User functions API.

Introduction.

This document contains description of application program interface (API) designed to write
QNX applications that can interact with remote FlexView consoles. First of all this API intended
for QNX applications that use user_func functionality of RealFlex. The following picture
illustrates interaction between QNX application and FlexView console.

The key part of this scheme is FlexServ. User application can be started from FlexView console
or from CSL or superkey script from RealFlex. In the case, where application is started from
FlexView console using context menu, it will emulate behaviour of RealFlex context user
function menu. FlexServ always provides connection between QNX application and FlexView
console.

API is implemented using POSIX queues (mqueue) and special internal protocol. Using this
method user application can open special dialogs, messages, information, input or menu
windows at FlexView console.



User Functions API.doc Page 5 of 36
User application sends special messages to FlexView. FlexView opens menu window or other
user interface elements, process user input and sends reply to user application queue.
Also FlexView can start user application program using standard piping mechanism. In this case
all application output would be redirected to FlexView console. I.e a FlexView user can start an
application which was compiled and runs on QNX, but have all it output displayed on the
FlexView window.


FlexView opens special window for such application. All QNX application output through stdout
and stderr will be redirected to this FlexView window. Any users input in this FlexView
window will be redirected to application. User input can be read by QNX application using
standard input functions such as fgets(),
fgetch() and etc.

For example:
#include <stdio.h>
#include <stdlib.h>

int main( void )
{
char buffer[80];
printf( Hello, world!\n );
while( fgets( buffer, 80, stdin ) != NULL )
fputs( buffer, stdout );
return EXIT_SUCCESS;
}
If user run this application from FlexView console, the the application runs on the QNX PC and
then Hello, world! will appear in FlexView console window.
Command line parameters that can be passed to an application when it is started from FlexView
console are:
<database type>
<tag index>
<PCU index>
<tag name>
<PCU name>
<FlexView console name>
User can specify any names for this parameters using FlexView menu editor.

User Functions API.doc Page 6 of 36

This functionality allows the user to have the same operation as the older style USER
SUPPLIED PROC. that is available in RealFlex/LanFlex. E.g
The user can right-click on any tag on the FlexView console and select USER SUPPLIED PROC
and it will call a QNX application called user_func with a list of parameters passed to user_func
-t DatabaseType -i PointIndex c ConsoleName
(Note this is the default setting and the user can change the application name and the list of
parameter that are passed to the application using User Proc Editor)
The QNX application can use the DatabaseType and PointIndex , but must also use the
ConsoleName parameter. The QNX application has to include some of the functions listed in this
document to communicate back to the FlexView console which activated the program.


User Functions API.doc Page 7 of 36

API description.

User QNX application must perform following steps.

1) Get FlexView console name from command line parameters
Use FlexView option User Function to create the QNX application name to be
used and list of parameters e.g indicate which console is used. This can be
selected from a list of options within FlexView.
e.g user_func c $(ConsoleName)
2) Open connection with FlexServ (QNX application)
3) Open different dialogs at FlexView console
Use FlexView Options Menu editor to create these.
4) Process user input (QNX application)
5) Close connection with FlexServ (QNX application)

SRVIPCOpen

#include <ServIPC.h>

IPCQUEUE *SRVIPCOpen(int iSize, int iMsgsNum, int nFlags);

This function opens connection with FlexServ. It opens two queues - FlexServ queue and
application queue.
Parameters of application queue specified by iSize and iMsgsNum parameters.
1 can be used for iSize and iMsgsNum parameters. In this case SRVIPCOpen will choose these
parameters itself.
By default IPC has 20 seconds timeout interval for all user input interface functions. To change
timeout value use SRVIPCSetTimeout() function.

Parameters:
iSize
specifies message size of application input queue (ignored for RF6)
iMsgsNum
specifies maximum message size in application input queue (ignored for RF6)
nFlags
0 open IPC for read/write
IPCFLAG_WRONLY open IPC for write only (ignored for RF6)

Return value:
Returns pointer to IPCQUEUE structure or NULL pointer if operation failed

User Functions API.doc Page 8 of 36
SRVIPCClose

#include <ServIPC.h>
void SRVIPCClose(IPCQUEUE *pQueue);

Close connection with FlexServ. This function closes application and FlexServ queues and frees
memory used by IPCQUEUE structure.

Parameters:
pQueue
pointer to an open connection.


SRVIPCSetTimeout

#include <ServIPC.h>
void SRVIPCSetTimeout(IPCQUEUE *pQueue, unsigned int uTimeOut);

This function sets timeout interval for all user input functions except SRVIPCInfoBox.

Parameters:
pQueue
pointer to an open connection.
uTimeout
Specifies the duration, in seconds, of the timeout period for all user input interface functions
except SRVIPCInfoBox.

Example:

#include <ServIPC.h>
// Open IPC with default queue parameters
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
// Set timeout to 5 minutes
if (pIpc != NULL)
SRVIPCSetTimeout(pIpc, 300);


SRVIPCSetTimeoutMode

#include <ServIPC.h>
void SRVIPCSetTimeoutMode(IPCQUEUE *pQueue, unsigned int uMode);

This function sets timeout mode for user input functions. Default mode is RETURN_DEFAULT
user input function returns default value. If uMode set to RETURN_ERROR then user input
functions on timeout will return -2 to indicate time out;

Parameters:
pQueue
pointer to an open connection.
uMode
RETURN_DEFAULT or RETURN_ERROR.
User Functions API.doc Page 9 of 36

Example:

#include <ServIPC.h>
// Open IPC with default queue parameters
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
// Set timeout return value to RETURN_ERROR
if (pIpc != NULL)
SRVIPCSetTimeoutMode(pIpc, RETURN_ERROR);


SRVIPCGetConsoleList

#include <ServIPC.h>
int SRVIPCGetCosoleList(IPCQUEUE *pQueue, char **pBufferList);

The SRVIPCGetCosoleList function fills given buffer with FlexView console names currently
connected to RealFlex system. For RF6 the very last name specifies local RF6 host name.

Parameters:
pQueue
Pointer to an open connection.
pBufferList
An array of pointers which receives list of names of all FlexView console currently connected to
RealFlex system. The following example shows the buffer contents with <null> representing the
terminating null character.

FW1<null>FW2<null>FW4<null><null>

Return value:
If the function succeeds, the return value is the number of consoles, connected to RF.
If the function fails, the return value is -1.

Example:

// open connection and get list of all connected FlexView consoles
#include <ServIPC.h>
// Open IPC with default queue parameters
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
char *pBuffer;
// get list of console names
if (SRVIPCGetConsoleList(pQueue, &pBuffer) != -1) {
char *pConsole = pBuffer;
while(*pConsole != \0) {
printf(FlexView console name: %s\n, pConsole); // print name
pConsole += strlen(pConsole) + 1; // move to the next name
}
// do to forget to free buffer allocated by SRVIPCGetConsoleList
free(pBuffer);
}


User Functions API.doc Page 10 of 36


SRVIPCGetConsoleName

Available in RealFlex 6.4.63 and higher

#include <ServIPC.h>
int SRVIPCGetCosoleName(IPCQUEUE *pQueue, char *pszConsoleName,
size_t nNameLen, IPCTYPE type);

Reads name of RealFlex console on which application is running.

Parameters:
pQueue
Pointer to an open connection.
pszConsoleName
A buffer where the function can store the console name.
nNameLen
The size of the buffer
type
Reserved, must be 0

Return value:
0 success
-1 an error occurred

Example:

// open connection and get list of all connected FlexView consoles
#include <ServIPC.h>
// Open IPC with default queue parameters
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
char name[80];
// get current RealFlex console name
if (SRVIPCGetConsoleName(pQueue, name, sizeof(name), 0) != -1) {
printf(Running on %s\n, buffer);
}



SRVIPCGetConsoleType

Available in RealFlex 6.4.63 and higher

#include <ServIPC.h>
IPCTYPE SRVIPCGetConsoleType(const IPCQUEUE *pQueue,
const char *pszConsoleName);

Returns type of console by its name.

Parameters:
pQueue
User Functions API.doc Page 11 of 36
Pointer to an open connection.
pszConsoleName
The name of console that you want to test

Return value:
One of the following constants:
IPCTYPE_ERROR - error, or console not found
IPCTYPE_NONE - console name not found
IPCTYPE_FLEXVIEW this is FlexView console
IPCTYPE_RF_LOCAL this is local RealFlex console
IPCTYPE_RF_PEER - reserved for future
IPCTYPE_PSEUDO - RealFlex pseudo console - CSL_CONSOLE or ALARMRELAY

Example:

// open connection and get list of all connected FlexView consoles
#include <ServIPC.h>
// Open IPC with default queue parameters
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);

// check console name
if (SRVIPCGetConsoleType(pQueue, argv[1]) == IPCTYPE_RF_LOCAL) {
printf(%s is local RealFlex console\n, argv[1]);
}



SRVIPCMessageBox

#include <ServIPC.h>
int SRVIPCMessageBox(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszTitle,
int iID,
const char *pszMessage,
unsigned int uStyle,
const char *pszButtons);

The SRVIPCMessageBox function creates, displays, and operates a message box. The message
box contains an application-defined message and title, plus up to five push buttons.
If program were started thru a pipe then dialog box would be opened in Main application
window. Dialog box would be titled as defined in pszTitle variable. Message defined by
pszMessage would be printed in dialog box. Dialog box would have buttons specified by
pszButtons string.

Supported by RealFlex 6 consoles starting with version 6.4.63.




User Functions API.doc Page 12 of 36
Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
String specifies the name of FlexView console for dialog box. Dialog box would be opened at
console specified by this parameter
pszTitle
Pointer to a null-terminated string that contains the dialog box title.
iID
Dialogs ID in range of 1 to 65535. Must be unique for each dialog box defined in the system.
pszMessage
Pointer to a null-terminated string that contains the message to be displayed
uStyle
To display an icon in the message box, specify one of the following values.
IPCBOX_WARNING - An exclamation-point icon appears in the message box.
IPCBOX_INFORMATION - An icon consisting of a lowercase letter i in a circle appears in the
message box.
IPCBOX_QUESTION - A question-mark icon appears in the message box.
IPCBOX_ERROR - A stop-sign icon appears in the message box.
pszButtons
String with buttons titles. Titles should be separated by colon. Up to five button titles can be
defined. Default button is specified by $. If default button is not specified then first one will be
used as default for return value by timeout.

Return value:
Function returns the number of selected button starting from 1.
Function returns 0 if user press Esc key.
If the function fails, the return value is -1. (there is no console with name specified)

Example:

// open MessageBox with Yes and No buttons
#include <ServIPC.h>
// Open IPC with default queue parameters
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL) {
int nButton = SRVIPCMessageBox(pIpc, FW1, Warning, 101,
Are you sure?, IPCBOX_QUESTION , Yes:$No);
if (nButton == 1) // Yes

else if(nButton == 2) // No

else if(nButton == 0) // Esc
else if(nButton == -1)// Error
}

User Functions API.doc Page 13 of 36
SRVIPCInfoBox

#include <ServIPC.h>

int SRVIPCInfoBox(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszTitle,
int iID,
unsigned int uStyle,
const char *pszMessage);

Function displays information window. This function returns immediately after sending message
to consoles and application can continue. Information box will remain open on FlexView
console while user application works. Application can close this box by calling
SRVIPCCloseInfoBox(). If application call SRVIPCInfoBox() with the same iID, then the
content of information box will be updated. If application call SRVIPCInfoBox() with different
iID, then FlexView will open new information box.

Supported by RealFlex 6 consoles starting with version 6.4.63.

Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
String specifies the name of FlexView console for info box. Info box would be opened at console
specified by this parameter. pszConsoleName can contain a comma separated list of console
patterns. Simbols * and ? are used as for file masks in the command line shell.
For example: X*, AR*. The Information box would be opened at all consoles match with
these patterns.
pszTitle
Pointer to a null-terminated string that contains the dialog box title.
iID
Unique ID for this info box in range 1 to 65535. This id is used by SRVIPCCloseInfoBox()
function to close information box.
uStyle
To display an icon in the message box, specify one of the following values.
IPCBOX_WARNING - An exclamation-point icon appears in the message box.
IPCBOX_INFORMATION - An icon consisting of a lowercase letter i in a circle appears in the
message box.
IPCBOX_QUESTION - A question-mark icon appears in the message box.
IPCBOX_ERROR - A stop-sign icon appears in the message box.
pszMessage
Pointer to a null-terminated string that contains the message to be displayed

Return values:
0 if success
If the function fails, the return value is -1.



User Functions API.doc Page 14 of 36
SRVIPCCloseInfoBox

#include <ServIPC.h>

int SRVIPCCloseInfoBox(const IPCQUEUE *pQueue,
const char *pszConsoleName,
int iID);

This function closes information box opened by SRVIPCInfoBox() function. This function
closes information box with Id specified by iID at console pszConsoleName.

Supported by RealFlex 6 consoles starting with version 6.4.63.

Return values:
0 if success
If the function fails, the return value is -1.


SRVIPCInputStrBox

#include <ServIPC.h>

int SRVIPCInputStrBox(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszTitle,
int iID,
const char *pszMessage,
const char *pszButtons,
char *pszText,
int iStrlen);

Function displays string input box at FlexView console. User can type text and press one of two
buttons (default buttons are OK and CANCEL).

Supported by RealFlex 6 consoles starting with version 6.4.63.

Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
String specifies the name of FlexView console for dialog box. Dialog box would be opened at
console specified by this parameter
pszTitle
Dialog box title.
Note: Starting from FlexView 3.0.4 opening pszTitle with $PASS$ causes all characters entered
into the edit box to be displayed as an asterisk (*). $PASS$ is omitted when dialog box title
displayed. E.g. if pszTitle points to $PASS$Password needed then dialog box with title
Password needed will be opened.
iID
Unique id for this dialog in range 1 to 65535.
pszMessage
Pointer to a null-terminated string that contains the message to be displayed
User Functions API.doc Page 15 of 36
pszButtons
Pointer to colon separated string with buttons definitions. If this pointer is NULL the OK and
CANCEL buttons would be displayed. $OK:CANCEL is a default value for this parameter.
$ sign specifies default button. Up to two buttons can be specified.
pszText
The buffer for user input. If pszText contains text when function is called then this text will be
displayed as a default input value for the user.
iStrlen
Specifies the size of the text buffer not including terminating null, so buffer must be at least
iStrLen + 1 in size. User will be able to enter only iStrlen characters.

Return values:
Function returns the number of selected button starting from 1. pszText receives string
entered by user.
0 if user press Esc.
If the function fails, the return value is -1.

Example:

#include <ServIPC.h>
// Open IPC with default queue parameters
char szText[80];
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL) {
int item = SRVIPCInputStrBox(pIpc, argv[1], "String box", 1001,
"Enter some text","OK:CANCEL",
szText, sizeof(szText) - 1);
if (item == 1) {
printf(User pressed OK. Text \%s\\n, szText);
}
}

User Functions API.doc Page 16 of 36
SRVIPCInputNumBox

#include <ServIPC.h>

int SRVIPCInputNumBox(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszTitle,
int iID,
const char *pszMessage,
const char *pszButtons,
IPCNUMBER *pnInput);

typedef struct _tagIPCINT
{
int iValue; // default value/entered value
int iMin; // minimal value
int iMax; // maximum value
int iStep; // step value for spin control
}IPCINT;

typedef struct _tagIPCDOUBLE
{
double dbValue; // default value/entered value
double dbMin; // minimal value
double dbMax; // maximum value
double dbStep; // step value for spin control
}IPCDOUBLE;


typedef struct _tagIPCNUMBER
{
unsigned int cbSize; // structure size
unsigned int nFlags;
union {
IPCINT i;
IPCDOUBLE db.
}value;
}IPCNUMBER;

Function displays input box at FlexView console for numbers. User types number and press one
of two buttons (default buttons are OK and CANCEL).

Supported by RealFlex 6 consoles starting with version 6.4.63.

Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
String specifies the name of FlexView console for dialog box. Dialog box would be opened at
console specified by this parameter
pszTitle
Dialog title
iID
Unique id for this dialog in range 1 to 65535
pszMessage
Pointer to a null-terminated string that contains the message to be displayed
User Functions API.doc Page 17 of 36
pszButtons
Pointer to colon separated string with buttons definitions. If this pointer is NULL the OK and
CANCEL buttons would be displayed. $OK:CANCEL is a default value for this parameter.
$ sign specifies default button. Up to two buttons can be specified.
pnInput
Pointer to the buffer structure for user input. pnInput can contain default value to be displayed.
pnInput->nFlags can be one or more of the following values.
IPCN_INT IPCINT member should be used for user input
IPCN_DOUBLE IPCDOUBLE member should be used for user input
IPCN_SIGNED user can input negative numbers
IPCN_LIMITS minimum and maximum values are valid and to be used for user input filtering
IPCN_SPIN step member is valid and spin control can be used for user input


Return values:
Function returns the number of selected button starting from 1. pnInput receives value
entered by user.
0 if user press Esc
If the function fails, the return value is -1.

Example:

// input integer number from -100 to 100 range
#include <ServIPC.h>
// Open IPC with default queue parameters
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL) {
IPCNUMBER ipcNum;
memset(&ipcNum, 0, sizeof(IPCNUMBER));
ipcNum.cbSize = sizeof(IPCNUMBER);
ipcNum.nFlags = IPC_INT | IPC_SIGNED | IPC_LIMITS | IPC_SPIN;
ipcNum.i.iValue = 20;
ipcNum.i.iMin = -100;
ipcNum.i.iMax = 100;
ipcNum.i.iStep = 1;
int iItem = SRVIPCInputNumBox(pIpc, FW1, Enter integer, 103,
$OK:Exit, &ipcNum);
if (iItem < 0) {
// error processing
return;
}
if (iItem == 1) {
int iUserValue = ipcNum.i.iValue;
}
}


User Functions API.doc Page 18 of 36
SRVIPCMenu

#include <ServIPC.h>

int SRVIPCMenu(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszTitle,
int iID,
const char *menuItems);

Function displays menu at FlexView console. Menu items are defined by string
menuIntems. This string has following format:


ID1,menu item 1:ID2,menu item 2: :IDn,menu item n

ID1 IDn unsigned integer numbers chosen by programmer (must be > 0)

menu item 1 menu item n are text string which will be displayed in menu.

Menu item which begins with $ symbol would be default menu item. Mouse cursor will be
positioned at default menu item.

Double colon specifies menu separator.



Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
String specifies the name of FlexView console for menu window. Menu window would be
opened at console specified by this parameter
pszTitle
Menu window title
iID
Unique id for this menu in range of 1 to 65535.
menuItems
The string with menu items definitions. See description above.

Return values:
the menu item ID selected by user
0 if user refused all choices (closed menu without any menu item choose)
If the function fails, the return value is -1.

User Functions API.doc Page 19 of 36
Example:

// open menu on FlexView console
#include <ServIPC.h>
// Open IPC with default queue parameters
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL) {
// Set timeout to 5 minutes
if (pIpc != NULL)
SRVIPCSetTimeout(pIpc, 300);

int iItem = SRVIPCMenu(pIpc, FW1, PRW 8L SIGNAL, 102,
1,$Depart:2,Hold:3,Route Start::4,Cancel all automatics::5,Exit);
if (iItem < 0) {
// error processing
return;
}
switch(iItem) {
case 0: // Selection not made

case 1: // Depart

case 2: // Hold

case 3: // Route Start

case 4: // Cancel

case 5: // exit

}
}


User Functions API.doc Page 20 of 36
SRVIPCCheckList

#include <ServIPC.h>

int SRVIPCCheckList(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszTitle,
int iID,
const char *checkItems,
const char *pszButtons,
char *pszInputItems,
int iInputSize);

Function displays check box list at FlexView console. User choose list of items then press OK or
CANCEL button. If user press OK then this function returns list of items picked by user.

The list of items picked by user has following form:

ID1,text 1:ID2,text 2: :IDn,text n

ID1 IDn unsigned integer numbers chosen by programmer (must be > 0)

text 1 text n are text string which will be displayed for check boxes.

If text field started with $ sign then check box will be displayed in check state.

Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
String specifies the name of FlexView console for check box window. Check box window would
be opened at console specified by this parameter
pszTitle
Check box window title
iID
Unique id for this check box in range of 1 to 65535.
checkItems
The string with check box items definitions. Has the same form as menuItems string for
SRVIPCMenu() function.
pszButtons
Colon separated string with buttons definitions. If it is NULL the OK and CANCEL buttons
would be displayed. $OK:CANCEL is a default value for this parameter. $ sign specifies
default button. Up to two buttons can be specified.
pszInputItems
Pointer to a buffer that receives a series of null-terminated strings, one for each check box ID
selected by user, that end with a second null character. The following example shows the buffer
contents with <null> representing the terminating null character.

ID1<null>ID3<null>ID4<null><null>

iInputSize
size of string allocated for pszInputItems
User Functions API.doc Page 21 of 36

Return value:
0 no selection were made or user press Esc
>0 number of button pressed by user. In this case pszInputItems will contain list of IDs
of check boxes picked by user separated by <null>.
If the function fails, the return value is -1.

Example:

// open check box list on a FlexView console
#include <ServIPC.h>
// Open IPC with default queue parameters
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL) {
char szOptions[80];
int iItem = SRVIPCCheckList(pIpc, FW1, Select signals, 105,
1,$Left:2,$Right:3,$Stop, Execute, szOptions, 80);
if (iItem < 0) {
// error processing
return;
}

if (iItem == 1) {
// if user selected Left and Stop then szOptions will contain
// 1\02\0\0
char *pParse = szOptions;
while(*pParse != \0) {
int iID = atoi(pParse); // get ID of check box
pParse += strlen(pParse) + 1; // move to the next ID
}
}
}


User Functions API.doc Page 22 of 36
SRVIPCOpenDisplay

#include <ServIPC.h>

int SRVIPCOpenDisplay(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszDisplayName);

Function opens display with name pszDisplayName on console pszConsoleName.

Supported by RealFlex 6 consoles starting with version 6.4.63.

Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
Null-terminated string specifies the name of FlexView console where display will be open. The
list of comma separated console patterns can be used. Simbols * and ? are used as for file
masks in the command line shell. For example: X*, AR*. The display would be opened at all
consoles match with these patterns.
pszDisplayName
Null-terminated string specifies the name of display to be opened on FlexView console.

Return value:
0 if success
-1 if error occured

Example:

#include <ServIPC.h>

IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL) {
if ( SRVIPCOpenDisplay(pIpc, FW1, DISPLAY1) == -1) {
// error is occurred
}
}

User Functions API.doc Page 23 of 36
SRVIPCReplaceDisplay

#include <ServIPC.h>

int SRVIPCReplaceDisplay(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszOldDisplay,
const char *pszNewDisplay);

Function tries to open display with pszNewDisplay name instead of pszOldDisplay on console
pszConsoleName.

Supported by RealFlex 6 consoles starting with version 6.4.63.

Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
Null-terminated string specifies the name of FlexView console where display will be open. The
list of comma separated console patterns can be used. Simbols * and ? are used as for file
masks in the command line shell. For example: X*, AR*. The command would be issued at all
consoles match with this pattern.

pszOldDisplay
Null-terminated string specifies the name of display to be closed on FlexView console.
pszNewDisplay
Null-terminated string specifies the name of display to be opened on FlexView console.

Remark:
If pszOldDisplay is NULL and pszNewDisplay specifies name of existing display then this
display will be opened. If pszOldDisplay specifies name of existing display and this display is
opened then this display will be closed.

Return value:
0 if success
-1 if error occured

Example:

#include <ServIPC.h>

IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL) {
// Open display DISPLAY1
SRVIPCReplaceDisplay(pIpc, NULL, DISPLAY1);
// Replace it with display DISPLAY2
SRVIPCReplaceDisplay(pIpc, DISPLAY1, DISPLAY2);
// Close DISPLAY2
SRVIPCReplaceDisplay(pIpc, DISPLAY2, NULL);
}

User Functions API.doc Page 24 of 36
SRVIPCCloseDisplay

#include <ServIPC.h>

int SRVIPCCloseDisplay(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszDisplayName);

Function closes display with name pszDisplayName on console pszConsoleName.

Supported by RealFlex 6 consoles starting with version 6.4.63.

Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
Null-terminated string specifies the name of FlexView console where display will be open. The
list of comma separated console patterns can be used. Simbols * and ? are used as for file
masks in the command line shell. For example: X*, AR*. The display would be opened at all
consoles match with these patterns.
pszDisplayName
Null-terminated string specifies the name of display to be closed on FlexView console.

Return value:
0 if success
-1 if error occurred

Example:

#include <ServIPC.h>

IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL) {
if ( SRVIPCOpenDisplay(pIpc, FW1, DISPLAY1) == -1) {
// error is occurred
}
}


User Functions API.doc Page 25 of 36
SRVIPCSendTextMessage

#include <ServIPC.h>

int SRVIPCSendTextMessage(const IPCQUEUE *pQueue,
const char *pszConsole,
const char *pszSubject,
const char *pszMessage);

Function sends a text message to FlexView console. The message can contain two parts:
message subject and message body. Message subject is displayed in a separate field at FlexView
console.

Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
String specifies the name of FlexView console where message will be send to. The list of comma
separated console patterns can be used. Simbols * and ? are used as for file masks in the
command line shell. For example: X*, AR*. The message would be sent to all consoles match
with this pattern.
pszSubject
Null-terminated string with a subject of the message. It will be displayed in the special Subject
field.
pszMessage
Null-terminated string with a message body.

Return value:
0 if success
-1 if error occurred

User Functions API.doc Page 26 of 36
SRVIPCPrintReport

#include <ServIPC.h>

int SRVIPCPrintReport(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszReportName, unsigned uFlags);

Function sends a request to console pszConsoleName to print report specified by
pszReportName.

Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
Null-terminated string specifies the name of FlexView console where display will be open. The
list of comma separated console patterns can be used. Simbols * and ? are used as for file
masks in the command line shell. For example: X*, AR*. The report would be printed at all
consoles match with this pattern.
pszReportName
Null-terminated string specifies the name of display to be opened on FlexView console.
uFlags
Specifies the type of report. This parameter can be one of the following values.

Value Meaning
IPCR_SYSTEM Print one of predefined RealFlex reports.
IPCR_USER pszReportName specifies one of user defined RealFlex reports.
IPCR_FLEXWIN pszReportName specifies one of user defined FlexView (xls)
reports.

In addition, for IPCR_SYSTEM you must specify one the following flags.

Value Meaning
IPCP_SYS Print System summary.
IPCP_COMM Print Communication summary.
IPCP_ANALOG Print Analog summary.
IPCP_METER Print Meter summary.
IPCP_STATUS Print Status summary.
IPCP_TANK Print Tank summary.
IPCP_ALARM Print Active Alarm summary.
IPCP_EVENT Print Historical Events summary.

If IPCR_SYSTEM | IPCP_SYS specified and pszReportName equals NULL then System
Summary will be printed for all PCU existing in RealFlex. To print System Summary for one
PCU only, pszReportName must specify name of PCU.

In addition, you must specify one the following flags.
User Functions API.doc Page 27 of 36
Value Meaning
IPCP_PRINTER Print report on default FlexView printer
IPCP_FILE Save report to a file. Overwrite existing file.
IPCP_APPEND Save report to a file. Create new file, add time stamp to file name.


Return value:
0 if success
-1 if error occurred

Example:

// Save System Summary for WATER PCU to file with tagstamp.
#include <ServIPC.h>
// Open IPC with default queue parameters
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL) {
// Create file SYS.WATER.YYYYMMDDHHMMSS
SRVIPCPrintReport(pIpc, Operator1, WATER, IPCR_SYSTEM |
IPCP_SYS | IPCP_APPEND);

}


SRVIPCStartApplication

#include <ServIPC.h>

int SRVIPCStartApplication(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszApplicationName,
const char *pszCommandLine);
The SRVIPCStartApplication function starts user application on FlexView console.
Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
String specifies the name of FlexView console. The list of comma separated console patterns can
be used. Simbols * and ? are used as for file masks in the command line shell. For example:
X*, AR*. The application would be started at all consoles match with this pattern.
pszApplicationName
Pointer to a null-terminated string that specifies the module to execute. The specified module can
be a Windows-based application. It can be some other type of module (for example, MS-DOS or
OS/2) if the appropriate subsystem is available on the local FlexView computer.
The string can specify the full path and file name of the module to execute or it can specify a
partial name. In the case of a partial name, the function uses the current drive and current
directory to complete the specification. The function will not use the search path. If the file name
does not contain an extension, .exe is assumed. Therefore, if the file name extension is .com, this
parameter must include the .com extension.
User Functions API.doc Page 28 of 36
pszApplicationName can be NULL. In that case, the module name must be the first white space-
delimited token in the pszCommandLine string.

pszCommandLine
Pointer to a null-terminated string that specifies the command line to execute. The
pszCommandLine parameter can be NULL. In that case, the function uses the string pointed to
by pszApplicationName as the command line.
If pszApplicationName is NULL, the first white-space delimited token of the command line
specifies the module name. If you are using a long file name that contains a space, use quoted
strings to indicate where the file name ends and the arguments begin. If the file name does not
contain an extension, .exe is appended. Therefore, if the file name extension is .com, this
parameter must include the .com extension. If the file name ends in a period (.) with no
extension, or if the file name contains a path, .exe is not appended. If the file name does not
contain a directory path, the system searches for the executable file in the following sequence:
1. The directory where FlexView is installed.
2. The Windows system directory.
3. The Windows directory.
4. The directories that are listed in the PATH environment variable.
Return value:
0 if success
-1 if error occurred


SRVIPCGetControlInfo

#include <ServIPC.h>

int SRVIPCGetControlInfo(const IPCQUEUE *pQueue,
struct IPCCONTROL *pControl,
int flags);

FlexServ stores special record IPCCONTROL for every tag controlled from FlexView
console. SRVIPCGetControlInfo() checks and reads IPCCONTROL structure for specified tag to
get information about FlexView console
struct IPCCONTROL
{
int iDbType; // tag database type (ANALOG_DB, STATUS_DB, )
int iDbIndex; // tag index
char szConsoleName[34]; // FlexView console name
time_t time; // time when controlled
union {
char status[2]; // from -> to
float analog[2]; // from -> to
long meter[2]; // from -> to
};
char text[2][21]; // description from -> to
};

User Functions API.doc Page 29 of 36
By default FlexServ stores 10 IPCCONTROL structures. To change length of buffer use h
command line parameter for FlexServ.
Note: This function is not supported by RealFlex 6 server.
Parameters:

pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pControl
Pointer to output control structure. pControl->iDbType and pControl->iDbIndex should contain
database type of the database index of tag which would be checked.
flags
CTL_PEEK check if control structure for given tag exists in FlexServ buffer. If structure exists
function reads it but does not remove from buffer.
CTL_READ read control info and remove it from server buffer

CTL_READ should be used to avoid following situation:
1. FlexView console "A" sends control to status point
2. FlexServ stores control in to buffer
3. User defined routine reads it from buffer, but does not remove it from
buffer, so it is still available for reading next time.
4. Userss routine uses FlexView "A" console name to open message on
5. Operator from RealFlex console sends control
6. Users routine reads console name from step 2 and sends message to
FlexView "A" console, instead of opening message on RealFlex console.

Return value:
0 success. Control information structure found and copied to pControl.
-1 control information structure was not found


User Functions API.doc Page 30 of 36
Example:

// check if status point was controlled from FlexView console
#include <ServIPC.h>
IPCCONTROL info;
int iPcuIndex, iTagIndex;

// Open IPC with default queue parameters
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL) {
// check if status record CONTROL on PCU SYSTEM
// was controlled from FlexView console
iPcuIndex = db_io(PCU_DB, g, 0, SYSTEM, );
iTagIndex = db_io(STATUS_DB, g, iPcuIndex, CONTROL, );

memset(&info, 0, sizeof(info));
info.iDbType = STATUS_DB;
info.iDbIndex = tagindex;
printf("tag SYSTEM:S:CONTROL );
if (SRVIPCGetControlInfo(pQueue, &info, CTL_READ) == 0) {
printf("was changed from console
%s from %d to %d at %s",
info.szConsoleName,
info.status[0],
info.status[1],
ctime(&info.time));
}
else {
printf("was not changed from any of FlexView console\n");
}
}

User Functions API.doc Page 31 of 36
SRVIPCPlaySound

Available in RealFlex 6.4.60 and higher

#include <ServIPC.h>

int SRVIPCPlaySound(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszSoundName,
unsigned uFlags);
The SRVIPCPlaySound function plays the user sound file on FlexView console.
Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
String specifies the name of FlexView console. The list of comma separated console patterns can
be used. Symbols * and ? are used as for file masks in the command line shell. For example:
X*, AR*. The application would be started at all consoles match with this pattern.
pszSoundName
Pointer to a null-terminated string that specifies the sound file to play.
The string can specify the full path and file name of the sound file to play or it can specify a file
name only. In that case, the function tries to play sound file from the %PROJECT% /sound
directory on FlexView PC.
uFlags
IPCS_REPEAT if this flag is specified then FlexView will be play the sound in the cycle.
Otherwise it will be played only once.

If sound is already played on some FlexView console, the new call of the SRVIPCPlaySound()
for the same console will replace the playing sound with the new one.

Return value:
0 if success
-1 if error occurred


User Functions API.doc Page 32 of 36
SRVIPCStopSound

Available in RealFlex 6.4.60 and higher

#include <ServIPC.h>

int SRVIPCStopSound(const IPCQUEUE *pQueue,
const char *pszConsoleName);
The SRVIPCStopSound function stops the user sound currently playing on FlexView console.
Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
String specifies the name of FlexView console. The list of comma separated console patterns can
be used. Simbols * and ? are used as for file masks in the command line shell. For example:
X*, AR*. The application would be started at all consoles match with this pattern.

Return value:
0 if success
-1 if error occurred


SRVIPCOpenDisplayEx

Available in RealFlex 6.4.60 and higher

#include <ServIPC.h>

int SRVIPCOpenDisplay(const IPCQUEUE *pQueue,
const char *pszConsoleName,
const char *pszDisplayName,
const char *pszPcuGroup,
const char *pszPcu,
unsigned uFlags
);

If uFlags == 0 than this function opens display specified by pszDisplaName parameter. If
uFlags == 1 than this function works with opened display only.

Function activates specified pszPcu for gived pszPcuGroup.

Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
Null-terminated string specifies the name of FlexView console where display will be open. The
list of comma separated console patterns can be used. Simbols * and ? are used as for file
masks in the command line shell. For example: X*, AR*. The display would be opened at all
consoles match with these patterns.
pszDisplayName
User Functions API.doc Page 33 of 36
Null-terminated string specifies the name of display to be opened on FlexView console.
pszPcuGroup
Null-terminated string specifies the name of PCU group dynamic to be changed
pszPcu
Null-terminated string specifies the name PCU to be activated at given PCU group
uFlags
0 to open new display, 1 select PCU on existing display.

Return value:
0 if success
-1 if error occured

Example:

#include <ServIPC.h>

IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL) {
if ( SRVIPCOpenDisplay(pIpc, FW1,
DISPLAY1, PCU_GROUP_1, PCU_5) == -1) {
// error is occurred
}
}

User Functions API.doc Page 34 of 36
SRVIPCModal

Available in RealFlex 6.4.60 and higher

#include <ServIPC.h>

INT SRVIPCModal(const IPCQUEUE* pQueue,
const char* pszConsoleName, bool bModal);

The SRVIPCModal function sets modal mode for dialogs displayed on FlexView

Parameters:
pQueue
Pointer to IPCQUEUE structure (obtained by SRVIPCOpen() call)
pszConsoleName
Null-terminated string specifies the name of FlexView console where display will be open. The
list of comma separated console patterns can be used. Simbols * and ? are used as for file
masks in the command line shell. For example: X*, AR*. The display would be opened at all
consoles match with these patterns.
bModal
If this flag is specified then all dialogs on FlexView shown by SRVIPCMessageBox,
SRVIPCInfoBox and other FlexServ API functions will be displayed in modal mode. Otherwise
the dialogs wll be shown not modal.

Return value:
0 if success
-1 if error occured

Example:

#include <ServIPC.h>
IPCQUEUE *pIpc = SRVIPCOpen(-1, -1, 0);
if (pIpc != NULL)
{
SPVIRCModal(pIpc, FW1, true);
int nButton = SRVIPCMessageBox(pIpc, FW1, Warning, 101,
Are you sure?,
IPCBOX_QUESTION , Yes:$No);
SPVIRCModal(pIpc, FW1, FALSE);
}

User Functions API.doc Page 35 of 36
FlexView User function API
This API provides access to FlexView functions.

API is installed in API folder in Flex.View install path. FlexView API contents:
FlexViewAPI.dll
FlexViewAPI.h
FlexViewAPI.lib

ShowDatabaseEditor
Available in FlexView 3.1.56 and higher

#include FlexViewAPI.h

int ShowDatabaseEditor(LPCTSTR szPcuName, LPCTSTR szDbName, LPCTSTR
szTagName, UINT uFlags = 0);

ShowDatabaseEditor() allows to open database editor for specific database tag on local machine
running FlexView. FlexView should be started before this function call.

Parameters:
szPcuName
PCU Name

szDbName
Database name (analog, status, meter, tank)

szTagName
Tag name


Return Value:
0 success
Any other value means error

Example:

#include "stdafx.h"
#include "FlexViewAPI.h"

int _tmain(int argc, _TCHAR* argv[])
{
ShowDatabaseEditor("RTU_1", "analog", "AI_00_01");
return 0;
}

User Functions API.doc Page 36 of 36












RealFlex Technologies,
526 Kingwood Drive, Suite 310,
Kingwood, Texas, 77339, USA
Tel: +1 281 348 2341, Fax: +1 281 348 2340
Email: sales@realflex.com
http://www.realflex.com/


or

RealFlex Technologies Ltd,
Limerick Business Complex,
Raheen Business Park, Limerick, Ireland.
Tel: +353 61 308884, Fax +353 61 308883,
Email: sales@realflex.com
http://www.realflex.com/

S-ar putea să vă placă și