/*
 *
 * Copyright © 1996 Norlinvest Ltd. All rights reserved.
 * EDComX, EDSpice, EDWin, EE Designer, CompCAD, CAD 1000,
 * CAD ABC and Visionics are trade marks of Norlinvest Ltd.
 * Copyright © 1983 - 2002.
 *
 */

#ifndef __PRIMSTRUCT__
#define __PRIMSTRUCT__

///////////// Windows DLL interface ////////////////////////////////////////

#include <Windows.h>

#pragma warning(disable :4244)
#pragma warning(disable :4305)
#pragma warning(disable :4761)

#ifndef DLL
  #define DLL __stdcall
#endif

/////////////////////////////////////////////////////////////////////////////
// Mixed-Mode Analog/Digital primitive module header structure

typedef struct ppar {
   WORD    mask;    // parameter level mask
   char   *parn1;   // abbreviated parameter name
   char   *parn2;   // full parameter name
   float   defpar;  // parameter default value
} PRIMPAR;

typedef struct ppin {
   char  *pinname;      // pin sim name
   WORD   pintype : 4,  // pin sim type
          pinid   : 12; // pin sim id
} PRIMPIN;

enum { PT_NULL = 0, PT_IN = 1, PT_OUT = 2, PT_IO = 3, PT_ANG = 4 };

#define MASK(group, select) (group << 12) + (select)

typedef struct prim {
   LPCSTR   pname;      // ptr to primitive name string
   WORD     status;     // primitive status
   BYTE     entries;    // number of analog pins
   BYTE     inodes;     // number of internal analog nodes
   BYTE     inputs;     // number of digital input pins
   BYTE     outputs;    // number of digital output pins
   BYTE     bidirect;   // number of digital i/o pins
   BYTE     pins;       // number of pins (entries+inputs+outputs+bidirect)
   WORD     params;     // number of parameters
   WORD     wdatlen;    // length of primitive work area in bytes
   PRIMPIN *pintab;     // ptr to pin name table, size = pins;
   PRIMPAR *par;        // ptr to primitive parameter table, size = params;
   LPCSTR   helpfile;   // ptr to help file name string
   LPCSTR   helpkey;    // ptr to primitive help key string
} PRIMSTRUCT;

// primitive "status" field bit definition:
//
#define PS_INTGND     0x01   // has internal connection to ground
#define PS_OVFTEST    0x02   // iterated by linear-segment approximation
#define PS_MODEL      0x04   // CompValue is always a model name
#define PS_NONLINEAR  0x08   // nonlinear, requires BP calc before AC sim.
#define PS_MODEPAR    0x10   // has grouped parameters using level mask

typedef void (CALLBACK* MSGPROC)(LPCSTR lpMsgStr);

#ifndef _DLLCODE_
#define _DLLCODE_
#endif

#ifdef _DLLCODE_
#define MESSAGE(msg) (*lpMsg)(msg)
MSGPROC lpMsg;
#endif

#endif // __PRIMSTRUCT__
