Artifact 690d3775c354e2e3f80bb213fbb26bf5fb74a4c2d4a959b04836a71f288a1ab7:


#! /bin/sh

sys=$1
struc=${sys}_struc.txt
sympar=${sys}_sympar.txt
RTXI_H="${sys}_rtxi.h"
RTXI_CC="${sys}_rtxi.cc"
program=$(basename $0)
date=$(date)

cat <<EOF > ${RTXI_CC}
// -*-c++-*- Put Emacs into c++-mode

// Generated from $sympar and $struc by MTT
// using $program
// at $date

#include <${RTXI_H}>

extern "C" Plugin::Object *createRTXIPlugin(void) {
  return new ${sys}();
}

static DefaultGUIModel::variable_t vars[] = {
EOF

gawk '
  ($1=="input") {
    printf("  {\n");
    printf("    \"%s\",\n", $3);
    printf("    \"%s\",\n", $6);
    printf("    DefaultGUIModel::INPUT,\n");
    printf("  },\n");
  }
  ($1=="output") {
    printf("  {\n");
    printf("    \"%s\",\n", $3);
    printf("    \"%s\",\n", $6);
    printf("    DefaultGUIModel::OUTPUT,\n");
    printf("  },\n");
  }
' ${struc} >> ${RTXI_CC}

gawk '
  {
    printf("  {\n");
    printf("    \"%s\",\n", $1);
    printf("    \"\",\n");
    printf("    DefaultGUIModel::PARAMETER |");
    printf(" DefaultGUIModel::DOUBLE,\n");
    printf("  },\n");
  }
' $sympar >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
};

static size_t num_vars = sizeof(vars)/sizeof(DefaultGUIModel::variable_t);
// TODO: initialise from numpar
EOF

gawk '
  BEGIN { printf("static double\n"); }
  { printf("  %s=0.0,\n", $1); }
  END {printf("  ;\n"); }
' $sympar >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
static long i_count = 0;

${sys}::~${sys}(void) {}

// ${sys}::execute(void) is defined in ${sys}_ode2odes.cc

void ${sys}::update(DefaultGUIModel::update_flags_t flag) {
  setCaption("${sys}");
  switch(flag) {
    case INIT:
EOF

gawk '
  {
    printf("      setParameter(\"%s\",QString::number(%s));\n",
	 $1, $1);
  }
' $sympar >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
      break;
    case MODIFY:
EOF

gawk '
  {
    printf("      getParameter(\"%s\").toDouble();\n", $1);
  }
' $sympar >> ${RTXI_CC}

cat <<EOF >> ${RTXI_CC}
      break;
    default:
      break;
  }
}
EOF


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]