Source Code for Project Cool


The following source files, led by gray banners, contain all the class functions needed for Project Cool.  The sections highlighted by a yellow background Color are manually entered.  Code sections with white background color are generated by the SansGUI Source Code Framework.  The source files are compiled into a dynamic linked library to be invoked by SansGUI during simulation runs.

For more details about this example, please read A Tour of SansGUI Examples in the SansGUI Getting Started Guide.

Implementation in Fortran (CVF)

Functions in Class Base.CoffeeCup     [Go To Top]

! Base_CoffeeCup.f
! - DLL routines for class <Component>Base.CoffeeCup
! DATE: Monday, May 22, 2000 TIME: 01:37:20 PM
! The skeleton of this file is generated by SansGUI(tm)

! Attribute indices in class version [1.0.alpha.4]
! 1: fTemp - Temperature
! 2: fR - Cooling Constant

! ======================================================================
! SG_xEval - Evaluation
! ----------------------------------------------------------------------
      integer function SG_xEval_Base_CoffeeCup(self,                    &
     &                  simCtrl, chgChild,                              &
     &                  pRefObjs, iRefObjs,                             &
     &                  pAdjObjs, iAdjObjs,                             &
     &                  pLnkObjs, iLnkObjs,                             &
     &                  cMessage, cCommand, pOutFile )
!DEC$ IF DEFINED (_DLL)
!DEC$ ATTRIBUTES DLLEXPORT :: SG_xEval_Base_CoffeeCup
!DEC$ END IF
      include "SGdllf.h"

      ! TODO: declare your local variables here

      ! fTemp and fR are from self
      ! fDt and fRoomT are from simCtrl
      real*4, dimension(*) :: fTemp, fR
      real*4, dimension(*) :: fDt, fRoomT
      ! declare pointers for aliases
      POINTER(PTR_fTEMP, fTemp)
      POINTER(PTR_fR, fR)
      POINTER(PTR_fDT, fDt)
      POINTER(PTR_fROOMT, fRoomT)
      ! use parameters for attribute indices, clearer code
      integer, parameter :: SG_NDX_FTEMP = 1
      integer, parameter :: SG_NDX_FR = 2
      integer, parameter :: SG_NDX_FDT = 10
      integer, parameter :: SG_NDX_FROOMT = 12

      if (self%nSGobjSchema .ne. SG_OBJ_SCHEMA) then
          SG_xEval_Base_CoffeeCup = SG_R_SCHM
          return
      end if

      ! TODO: put your simulator code here

      ! first connect zValues pointer to that of self
      PTR_zValues = self%pzValues
      ! connect the pointers to actual data storage in self
      PTR_fTEMP = zValues(SG_NDX_FTEMP)%vData
      PTR_fR = zValues(SG_NDX_FR)%vData

      ! now connect zValues pointer to that of simCtrl
      ! we are reusing PTR_zValues so it will no longer point to self%pzValues
      PTR_zValues = simCtrl%pzValues
      ! connect the pointers to actual data storage in simCtrl
      PTR_fDT = zValues(SG_NDX_FDT)%vData
      PTR_fROOMT = zValues(SG_NDX_FROOMT)%vData

      ! now do the calculation
      fTemp(1) = fTemp(1) + (-fR(1) * (fTemp(1) - fRoomT(1)) * fDt(1))

      SG_xEval_Base_CoffeeCup = SG_R_OK
      return
      end

Functions in Class Collection.Clock     [Go To Top]

! Collection_Clock.f
! - DLL routines for class <Reference>Collection.Clock
! DATE: Monday, May 22, 2000 TIME: 01:37:20 PM
! The skeleton of this file is generated by SansGUI(tm)

! ======================================================================
! SG_xEval - Evaluation
! ----------------------------------------------------------------------
      integer function SG_xEval_Collection_Clock(self,                  &
     &                  simCtrl, chgChild,                              &
     &                  pRefObjs, iRefObjs,                             &
     &                  pAdjObjs, iAdjObjs,                             &
     &                  pLnkObjs, iLnkObjs,                             &
     &                  cMessage, cCommand, pOutFile )
!DEC$ IF DEFINED (_DLL)
!DEC$ ATTRIBUTES DLLEXPORT :: SG_xEval_Collection_Clock
!DEC$ END IF
      include "SGdllf.h"

      ! TODO: declare your local variables here

      ! two variables of interest, current time and time increment
      real*4, dimension(*) :: fTime, fDt
      ! declare pointer aliases
      POINTER(PTR_fTIME, fTime)
      POINTER(PTR_fDT, fDt)
      ! use parameters for attribute indices
      integer, parameter :: SG_NDX_FDT = 10
      integer, parameter :: SG_NDX_FTIME = 11

      if (self%nSGobjSchema .ne. SG_OBJ_SCHEMA) then
          SG_xEval_Collection_Clock = SG_R_SCHM
          return
      end if

      ! TODO: put your simulator code here

      ! connect pointer alias to the actual storage; all are arrays
      ! first connect zValues array to simCtrl object
      PTR_zValues = simCtrl%pzValues
      ! now connect each pointer to the data storage
      PTR_fDT = zValues(SG_NDX_FDT)%vData
      PTR_fTIME = zValues(SG_NDX_FTIME)%vData

      ! actual calculation - we only care about the first elements
      fTime(1) = fTime(1) + fDt(1)

      SG_xEval_Collection_Clock = SG_R_OK
      return
      end

 


SansGUI Modeling and Simulation Environment version 1.2

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

http://protodesign-inc.com