<?xml version="1.0" encoding="ISO-8859-1"?>

<!--
     Written by Laurent Lemaitre - r29173@users.sourceforge.net
     Documentation:
       http://sourceforge.net/docman/display_doc.php?docid=18993&group_id=84289
     Target Interface: ngspice
     Supported by adms-1.x.x
     This file is used by adms - http://sourceforge.net/projects/mot-adms.
     adms is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
     adms is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
     You should have received a copy of the GNU General Public License
     along with adms; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-->

<!DOCTYPE admst SYSTEM "admst.dtd">
<admst version="2.3.0" xmlns:admst="http://mot-adms.sourceforge.net/xml-files/admst">


<admst:template match="code">
<admst:value-of select="attribute[name='ngspicename']/value"/>
<admst:variable name="module" select="%s"/>

#include &quot;ngspice/ngspice.h&quot;
#include &quot;ngspice/const.h&quot;
#include &quot;ngspice/cktdefs.h&quot;
#include &quot;$(module)defs.h&quot;
#include &quot;ngspice/ifsim.h&quot;
#include &quot;ngspice/sperror.h&quot;
#include &quot;ngspice/suffix.h&quot;

int $(module)ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *select)
{
  $(module)instance *instance = ($(module)instance*)inst;
  NG_IGNOREABLE(ckt);
  NG_IGNOREABLE(value);
  NG_IGNOREABLE(select);
  NG_IGNOREABLE(instance);
  switch (which) {
  <admst:for-each select="variable[parametertype='instance' and input='yes']">
    <admst:value-of select="name"/>
    <admst:text format="  case  $(module)_instance_%s  :\n"/>
    <admst:choose>
      <admst:when test="[type='real']">
        <admst:value-of select="name"/>
        <admst:text format="    value->rValue = instance->%s;\n"/>
      </admst:when>
      <admst:when test="[type='integer']">
        <admst:value-of select="name"/>
        <admst:text format="    value->iValue = instance->%s;\n"/>
      </admst:when>
      <admst:otherwise>
        <admst:fatal format="parameter of type 'string' not supported\n"/>
      </admst:otherwise>
    </admst:choose>
    <admst:text format="    return OK;\n"/>
  </admst:for-each>
  default:
    return(-1);
  }
  return(-1);
}

</admst:template>

<admst:for-each select="/module">
  <admst:value-of select="attribute[name='ngspicename']/value"/>
  <admst:open file="%sask.c">
    <admst:value-of select="/simulator/package_string"/>
    <admst:text format="/***\n*** Interface: %s\n"/>
    <admst:value-of select="/simulator/currentdate"/>
    <admst:value-of select="/simulator/fullname"/>
    <admst:text format=" *** created by: %s - %s ***/\n"/>
    <admst:apply-templates select="." match="code"/>
  </admst:open>
  <admst:value-of select="attribute[name='ngspicename']/value"/>
  <admst:message format="%sask.c: file created\n"/>
</admst:for-each>

</admst>
