ADDED mttroot/mtt/bin/capitalise_initial Index: mttroot/mtt/bin/capitalise_initial ================================================================== --- /dev/null +++ mttroot/mtt/bin/capitalise_initial @@ -0,0 +1,6 @@ +#! /bin/sh + +phrase="$*" +initial=$(echo $phrase | sed 's/\(.\).*/\1/') +Initial=$(echo $initial | tr [a-z] [A-Z]) +echo $phrase | sed s/$initial/$Initial/ ADDED mttroot/mtt/bin/trans/sympar2rtxi_txt2cc Index: mttroot/mtt/bin/trans/sympar2rtxi_txt2cc ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/sympar2rtxi_txt2cc @@ -0,0 +1,108 @@ +#! /bin/sh + +sys=$1 +Sys=$(capitalise_initial $sys) +struc=${sys}_struc.txt +sympar=${sys}_sympar.txt +RTXI_H="${Sys}_rtxi.h" +RTXI_CC="${Sys}_rtxi.cc" +program=$(basename $0) +date=$(date) + +cat < ${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 <> ${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 <> ${RTXI_CC} +static long i_count = 0; + +${Sys}::~${Sys}(void) {} + +void ${Sys}::execute(void) { + // TODO: call ode2odes functions +} + +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 <> ${RTXI_CC} + break; + case MODIFY: +EOF + +gawk ' + { + printf(" getParameter(\"%s\").toDouble();\n", $1); + } +' $sympar >> ${RTXI_CC} + +cat <> ${RTXI_CC} + break; + default: + break; + } +} +EOF ADDED mttroot/mtt/bin/trans/sympar2rtxi_txt2h Index: mttroot/mtt/bin/trans/sympar2rtxi_txt2h ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/sympar2rtxi_txt2h @@ -0,0 +1,44 @@ +#! /bin/sh + +sys=$1 +Sys=$(capitalise_initial $sys) +sympar=${sys}_sympar.txt +RTXI_H="${Sys}_rtxi.h" +program=$(basename $0) +date=$(date) + +cat < ${RTXI_H} +// -*-c++-*- Put Emacs into c++-mode + +// Generated from $sympar by MTT +// using $program +// at $date + +#include +#include + +class $Sys : public DefaultGUIModel +{ + +public: + + $Sys(void); + virtual ~$Sys(void); + + virtual void execute(void); + +protected: + + virtual void update(DefaultGUIModel::update_flags_t); + +private: + +EOF + +gawk ' + { printf(" double %s;\n", $1); } +' $sympar >> ${RTXI_H} + +cat <> ${RTXI_H} +}; +EOF