/*
 * FPL.H
 *
 * FPL Header File.
 *
 * Copyright (c) Siemens AG 1993.  All rights reserved.
 *
 * $Header:   P:/VCS/FPL/FPL.H_V   1.1   09 Dec 1993 17:00:42   ror  $
 */

#ifdef WINDOWS
#include <windows.h>
#else
#define FAR		    far
#define PASCAL
#define VOID		    void
typedef VOID far	   *GLOBALHANDLE;
typedef char far	   *LPSTR;
typedef int		    BOOL;
typedef unsigned short      WORD;
typedef unsigned long       DWORD;
typedef signed long	    LONG;
typedef WORD FAR	   *LPWORD;
typedef VOID		   *HWND;
typedef char		    HINSTANCE;
#define MAKELONG(low, high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
#endif

/* FPL Object types */

#define OBJ_PROJECT	    0
#define OBJ_PACKAGE	    1
#define OBJ_RULEBASE	    2
#define OBJ_VAR 	    3
#define OBJ_MEMBER	    4
#define OBJ_RULE	    5
#define OBJ_CONNECT	    6
#define OBJ_SIM 	    7
#define OBJ_CHART	    8
#define OBJ_MODEL	    9
#define OBJ_DEBUG	    10
#define OBJ_EMIT	    11
#define OBJ_EXTERNAL	    12
#define OBJ_USER	    13
#define OBJ_PROCUNIT	    14

/* FPL data types */

typedef double		    FLOAT;
typedef unsigned char	    UBYTE;
typedef signed char	    SBYTE;
typedef unsigned short int  UWORD;
typedef signed short int    SWORD;
typedef signed long	    SLONG;
typedef unsigned long	    ULONG;
typedef UBYTE		    FUBYTE;
typedef SBYTE		    FSBYTE;
typedef UWORD		    FUWORD;
typedef SWORD		    FSWORD;

/* Far pointers to FPL data types */

typedef FLOAT FAR	    *LPFLOAT;
typedef UBYTE FAR	    *LPUBYTE;
typedef SBYTE FAR	    *LPSBYTE;
typedef UWORD FAR	    *LPUWORD;
typedef SWORD FAR	    *LPSWORD;
typedef SLONG FAR	    *LPSLONG;
typedef ULONG FAR	    *LPULONG;
typedef FUBYTE FAR	    *LPFUBYTE;
typedef FSBYTE FAR	    *LPFSBYTE;
typedef FUWORD FAR	    *LPFUWORD;
typedef FSWORD FAR	    *LPFSWORD;

/* FPL parameter types */

#define TYPE_FLOAT	    'A'
#define TYPE_UBYTE	    'B'
#define TYPE_SBYTE	    'C'
#define TYPE_UWORD	    'D'
#define TYPE_SWORD	    'E'
#define TYPE_SLONG	    'F'
#define TYPE_ULONG	    'G'
#define TYPE_FUBYTE	    'H'
#define TYPE_FSBYTE	    'I'
#define TYPE_FUWORD	    'J'
#define TYPE_FSWORD	    'K'
#define TYPE_FLOAT_ADDR     'a'
#define TYPE_UBYTE_ADDR     'b'
#define TYPE_SBYTE_ADDR     'c'
#define TYPE_UWORD_ADDR     'd'
#define TYPE_SWORD_ADDR     'e'
#define TYPE_SLONG_ADDR     'f'
#define TYPE_ULONG_ADDR     'g'
#define TYPE_FUBYTE_ADDR    'h'
#define TYPE_FSBYTE_ADDR    'i'
#define TYPE_FUWORD_ADDR    'j'
#define TYPE_FSWORD_ADDR    'k'

/* FPL parameter union */

typedef union
{
    FLOAT float_value;
    UBYTE ubyte_value;
    SBYTE sbyte_value;
    UWORD uword_value;
    SWORD sword_value;
    SLONG slong_value;
    ULONG ulong_value;
    FUBYTE fubyte_value;
    FSBYTE fsbyte_value;
    FUWORD fuword_value;
    FSWORD fsword_value;
    LPFLOAT float_ptr;
    LPUBYTE ubyte_ptr;
    LPSBYTE sbyte_ptr;
    LPUWORD uword_ptr;
    LPSWORD sword_ptr;
    LPSLONG slong_ptr;
    LPULONG ulong_ptr;
    LPFUBYTE fubyte_ptr;
    LPFSBYTE fsbyte_ptr;
    LPFUWORD fuword_ptr;
    LPFSWORD fsword_ptr;
} IOVALUE;

/* FPL output membership function types for user defined IDMs */

#define OMBF_POINTS	0
#define OMBF_SFUNC	1
#define OMBF_ZFUNC	2
#define OMBF_PIFUNC	3
#define OMBF_EXPR       4

/*
 * MODEL graphic initialization structure
 *
 * This structure is passed to your MODEL graphic window when it is
 * initialized during a simulation.
 *
 * hWndFrame is the parent of any dialog windows you need to create.
 * hWndMDIClient is the parent of the MODEL graphic window you create.
 * hAppInst is the instance handle for the copy of SieFuzzy that is running.
 */

typedef struct
{
    HWND hWndFrame;
    HWND hWndMDIClient;
    HINSTANCE hAppInst;
} GRAPHICINIT;

/* Miscellaneous definitions */

typedef char                OBJTYPE;        /* type of an object */
typedef GLOBALHANDLE        OBJHANDLE;      /* handle to an object */
typedef GLOBALHANDLE FAR   *LPGLOBALHANDLE; /* far pointer to a GLOBALHANDLE */
typedef BOOL FAR           *LPBOOL;         /* far pointer to a BOOL */
typedef IOVALUE FAR        *LPIOVALUE;      /* far pointer to an IOVALUE */
typedef GRAPHICINIT FAR    *LPGRAPHICINIT;  /* far pointer to a GRAPHICINIT */

/* Function prototypes */

BOOL FAR PASCAL FPLAddObject (OBJHANDLE FPLHandle,
			      LPSTR object,
			      OBJTYPE objtype,
			      LPSTR class_name,
			      LPSTR parent_name,
			      LPBOOL busy);
OBJHANDLE FAR PASCAL FPLChangeObject (OBJHANDLE FPLHandle,
				      LPSTR objname,
				      LPSTR varname,
				      LPSTR object,
				      LPBOOL busy);
VOID FAR PASCAL FPLClean (LPGLOBALHANDLE);
BOOL FAR PASCAL FPLDeleteObject (OBJHANDLE FPLHandle,
				 LPSTR objname,
				 LPSTR varname);
VOID FAR PASCAL FPLGetError (LPSTR ErrorText,
			     int MaxLen,
			     LPWORD LastError,
			     LPWORD ErrorCount,
			     LPWORD WarningCount);
long FAR PASCAL FPLGetVersion (VOID);
int FAR PASCAL FPLKeyword (LPSTR s);
OBJHANDLE FAR PASCAL FPLNew (VOID);
OBJHANDLE FAR PASCAL FPLOpen (LPSTR filename,
			      LPBOOL busy,
			      GLOBALHANDLE reserved);
BOOL FAR PASCAL FPLRegister (BOOL ErrorDisplay, HWND hWndParent);
BOOL FAR PASCAL FPLSave (OBJHANDLE hproject,
			 LPSTR filename,
			 LPSTR buf,
			 long maxlen,
			 LPSTR objname,
			 LPSTR varname);
VOID FAR PASCAL FPLSetErrorFile (int errfile);
VOID FAR PASCAL FPLGetProjectName(OBJHANDLE hObjProject, LPSTR lpszProjectName);
BOOL FAR PASCAL FPLIsNameOK(OBJHANDLE hObjProject, LPSTR lpszName);
