Index: mttroot/mtt/lib/rep/cxxsim.cc ================================================================== --- mttroot/mtt/lib/rep/cxxsim.cc +++ mttroot/mtt/lib/rep/cxxsim.cc @@ -15,10 +15,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include #include namespace cxxsim { @@ -129,10 +130,11 @@ std::string vec; // vector: u, x, y, yz unsigned int num; // position of element in vector std::string cmp; // component std::string fnm; // full name unsigned int rpt; // number of repetitions + std::string cty; // causality }; typedef struct record record_t; std::list Lu; std::list Lx; @@ -189,23 +191,23 @@ std::string s; std::string t; unsigned int i; - // file.unsetf(ios::skipws); - file.setf(ios::skipws); + // file.unsetf(std::ios::skipws); + file.setf(std::ios::skipws); // read lines from file (no max length, unlike std::getline) while (file >> c){ s = ""; while (c != ';' && file){ if (c == '%'){ - file.unsetf(ios::skipws); + file.unsetf(std::ios::skipws); while ((c != '\n') && file){ file >> c; // eat comment } - file.setf(ios::skipws); + file.setf(std::ios::skipws); } else { if ((c != ' ') && (c != '\t')){ // strip whitespace s += c; } file >> c; @@ -402,16 +404,16 @@ void parameter::read (std::ifstream &file){ record_t r; while (file >> r.variable >> r.component){ if (r.variable.find("#") == 0){ - file.unsetf(ios::skipws); + file.unsetf(std::ios::skipws); char c = '\0'; while (c != '\n'){ file >> c; } - file.setf(ios::skipws); + file.setf(std::ios::skipws); } else { L.push_back(r); } } } @@ -469,11 +471,11 @@ std::list *p; record_t r; if (! file){ std::cerr << "warning: no structure data found (empty file)" << std::endl; } - while (file >> r.vec >> r.num >> r.cmp >> r.fnm >> r.rpt){ + while (file >> r.vec >> r.num >> r.cmp >> r.fnm >> r.rpt >> r.cty){ if (r.vec == "input"){ p = &(this->Lu); } else if (r.vec == "state"){ p = &(this->Lx); } else if (r.vec == "output"){ @@ -636,24 +638,24 @@ << " // get inputs and rates" << std::endl << " " << system_name << "_input(mttt,mttu,mttx,mtty);" << std::endl << " " << system_name << "_ode(mttt,mttu,mttx,mttdx,mtty);" << std::endl << std::endl << " // integrate states (euler)" << std::endl - << " for (i = 1; i < mttNx; i++){" << std::endl + << " for (i = 1; i <= mttNx; i++){" << std::endl << " mttx[i] += mttdx[i] * mttdt;" << std::endl << " }" << std::endl << std::endl << " // overwrite switch states" << std::endl << " " << system_name << "_logic(mttt,mttu,mttx,mttdx,mtty);" << std::endl << std::endl << " // write: time outputs time states" << std::endl << " std::cout << mttt << '\\t';" << std::endl - << " for (i = 1; i < mttNy; i++){" << std::endl + << " for (i = 1; i <= mttNy; i++){" << std::endl << " std::cout << mtty[i] << ' ';" << std::endl << " }" << std::endl << " std::cout << '\\t' << mttt;" << std::endl - << " for (i = 1; i < mttNx; i++){" << std::endl + << " for (i = 1; i <= mttNx; i++){" << std::endl << " std::cout << ' ' << mttx[i];" << std::endl << " }" << std::endl << " std::cout << std::endl;" << std::endl << " }" << std::endl << " return 0;" << std::endl