Source Code Framework


generate/do-it.gif    Multi-Programming Languages

Generate simulator routine skeleton for DLL creation.

SansGUI Source Code Framework

For in-process simulator development, the SansGUI Source Code Framework takes the specifications of class attributes and functions and generates the skeleton code for each class. This process is performed when a new version of the Object Library is generated from a Schema Definition. The source files are compiled into a dynamic linked library (DLL), which is distributed to the simulation users for execution in the SansGUI Run-Time Environment.

 

Generate/source_code_framework.gif

Specification of Class Attributes

The class attributes are entered and maintained in the Right Pane of a Schema Definition.

generate/attributes.jpg

Specification of Class Functions

The class functions to be implemented are specified in three groups, as shown in the following figure. The developer use the check boxes to select the functions needed. The boxes in the Override column, if checked, is to indicate that the routines can be overridden by the user in the SansGUI Run-Time environment.

generate/functions.jpg

Example Skeleton Code in C/C++ (MSVC)

 

/* Base_Source_Variable.c

 * - DLL routines for class <Component>Base.Source.Variable

 * DATE: Wednesday, April 24, 2002 TIME: 10:55:37 AM

 * The skeleton of this file is generated by SansGUI(tm)

 */

 

#include <stdio.h>

#include "SGdll.h"

 

#ifdef __cplusplus

extern "C"

{

#endif

 

SG_EXPORT SG_SIM_FUNC SG_xInit_Base_Source_Variable;

SG_EXPORT SG_SIM_FUNC SG_xPreEval_Base_Source_Variable;

 

#ifdef __cplusplus

}

#endif

 

/* Macros for attribute indices in class version [1.0.0.0] */

#define SG_NDX_FCONCENTRATION 0 /* fConcentration - Initial Concentration */

#define SG_NDX_FSTEADY 1 /* fSteady - Steady State Concentration */

#define SG_NDX_FCURRENT 2 /* fCurrent - Current Concentration */

 

/* ============================================================

 * SG_xInit - Initialization

 * ------------------------------------------------------------

 */

SG_RET_CODE SG_xInit_Base_Source_Variable(SG_OBJ *const self,

                        SG_OBJ *const simCtrl, SG_OBJ *const chgChild,

                        SG_OBJ *const refObjs[], const INT *const piRefObjs,

                        SG_OBJ *const adjObjs[], const INT *const piAdjObjs,

                        SG_OBJ *const lnkObjs[], const INT *const piLnkObjs,

                        TCHAR *const cMessage, const INT iMsgLen,

                        TCHAR *const cCommand, const INT iCmdLen,

                        SG_FILE *const pOutFile )

{

    /* TODO: declare your local variables here */

 

    if (!SG_IsSchemaOK(self->nSGobjSchema))

        return SG_R_SCHM;

 

    /* TODO: put your simulator code here */

 

    return SG_R_OK;

}

 

/* ============================================================

 * SG_xPreEval - Pre-Evaluation

 * ------------------------------------------------------------

 */

SG_RET_CODE SG_xPreEval_Base_Source_Variable(SG_OBJ *const self,

                        SG_OBJ *const simCtrl, SG_OBJ *const chgChild,

                        SG_OBJ *const refObjs[], const INT *const piRefObjs,

                        SG_OBJ *const adjObjs[], const INT *const piAdjObjs,

                        SG_OBJ *const lnkObjs[], const INT *const piLnkObjs,

                        TCHAR *const cMessage, const INT iMsgLen,

                        TCHAR *const cCommand, const INT iCmdLen,

                        SG_FILE *const pOutFile )

{

    /* TODO: declare your local variables here */

 

    if (!SG_IsSchemaOK(self->nSGobjSchema))

        return SG_R_SCHM;

 

    /* TODO: put your simulator code here */

 

    return SG_R_OK;

}

Example Skeleton Code in Fortran (CVF)

 

! Base_Source_Variable.f

! - DLL routines for class <Component>Base.Source.Variable

! DATE: Wednesday, April 24, 2002 TIME: 10:55:38 AM

! The skeleton of this file is generated by SansGUI(tm)

 

! Attribute indices in class version [1.0.0.0]

! 1: fConcentration - Initial Concentration

! 2: fSteady - Steady State Concentration

! 3: fCurrent - Current Concentration

 

! ======================================================================

! SG_xInit - Initialization

! ----------------------------------------------------------------------

      integer function SG_xInit_Base_Source_Variable(self, &

     & simCtrl, chgChild, &

     & pRefObjs, iRefObjs, &

     & pAdjObjs, iAdjObjs, &

     & pLnkObjs, iLnkObjs, &

     & cMessage, cCommand, pOutFile )

!DEC$ IF DEFINED (_DLL)

!DEC$ ATTRIBUTES DLLEXPORT :: SG_xInit_Base_Source_Variable

!DEC$ END IF

      include "SGdllf.h"

 

      ! TODO: declare your local variables here

 

      if (self%nSGobjSchema .ne. SG_OBJ_SCHEMA) then

          SG_xInit_Base_Source_Variable = SG_R_SCHM

          return

      end if

 

      ! TODO: put your simulator code here

 

      SG_xInit_Base_Source_Variable = SG_R_OK

      return

      end

 

! ======================================================================

! SG_xPreEval - Pre-Evaluation

! ----------------------------------------------------------------------

      integer function SG_xPreEval_Base_Source_Variable(self, &

     & simCtrl, chgChild, &

     & pRefObjs, iRefObjs, &

     & pAdjObjs, iAdjObjs, &

     & pLnkObjs, iLnkObjs, &

     & cMessage, cCommand, pOutFile )

!DEC$ IF DEFINED (_DLL)

!DEC$ ATTRIBUTES DLLEXPORT :: SG_xPreEval_Base_Source_Variable

!DEC$ END IF

      include "SGdllf.h"

 

      ! TODO: declare your local variables here

 

      if (self%nSGobjSchema .ne. SG_OBJ_SCHEMA) then

          SG_xPreEval_Base_Source_Variable = SG_R_SCHM

          return

      end if

 

      ! TODO: put your simulator code here

 

      SG_xPreEval_Base_Source_Variable = SG_R_OK

      return

      end

See Also

 



C:\FH_Suite\htmlgifs\home.gif Single API Function Prototype Multi-Programming Languages

SansGUI Modeling and Simulation Environment version 1.2

Copyright © 2000-2003 ProtoDesign, Inc. All rights reserved.

http://protodesign-inc.com