X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gr-trellis%2Fsrc%2Flib%2Ffsm.cc;h=5950b56b9d2ae612fad5597e66bf4e3d1707eab0;hb=a72819e861caaabdea0ac41f5f5e387cb61d3513;hp=2cf1a6d5abb64b2aedacbc4368e2556b625ce4e0;hpb=319caa5a3882142be42e03b0f20488730f5d208e;p=debian%2Fgnuradio diff --git a/gr-trellis/src/lib/fsm.cc b/gr-trellis/src/lib/fsm.cc index 2cf1a6d5..5950b56b 100644 --- a/gr-trellis/src/lib/fsm.cc +++ b/gr-trellis/src/lib/fsm.cc @@ -6,7 +6,7 @@ * * GNU Radio 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, or (at your option) + * the Free Software Foundation; either version 3, or (at your option) * any later version. * * GNU Radio is distributed in the hope that it will be useful, @@ -16,13 +16,17 @@ * * You should have received a copy of the GNU General Public License * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. */ #include +#include +#include +#include #include #include +#include #include "base.h" #include "fsm.h" @@ -47,7 +51,7 @@ fsm::fsm(const fsm &FSM) d_O=FSM.O(); d_NS=FSM.NS(); d_OS=FSM.OS(); - d_PS=FSM.PS(); + d_PS=FSM.PS(); // is this going to make a deep copy? d_PI=FSM.PI(); d_TMi=FSM.TMi(); d_TMl=FSM.TMl(); @@ -82,16 +86,30 @@ fsm::fsm(const char *name) if((fsmfile=fopen(name,"r"))==NULL) throw std::runtime_error ("fsm::fsm(const char *name): file open error\n"); //printf("file open error in fsm()\n"); + + if(fscanf(fsmfile,"%d %d %d\n",&d_I,&d_S,&d_O) == EOF) { + if(ferror(fsmfile) != 0) + throw std::runtime_error ("fsm::fsm(const char *name): file read error\n"); + } - fscanf(fsmfile,"%d %d %d\n",&d_I,&d_S,&d_O); d_NS.resize(d_I*d_S); d_OS.resize(d_I*d_S); for(int i=0;i &G) for(int s=0;s ii(n); + dec2base(i,FSM.I(),ii); + std::vector oo(n); + int ns=s; + for(int k=0;k" << std::endl; + + for( int stage_num = 0;stage_num < number_stages;stage_num ++){ + // draw states + for ( int state_num = 0;state_num < d_S ; state_num ++ ) { + trellis_fname << "" << std::endl; + //draw branches + if(stage_num != number_stages-1){ + for( int branch_num = 0;branch_num < d_I; branch_num++){ + trellis_fname << "" << std::endl; + } + } + } + } + // label the stages + trellis_fname << "" << std::endl; + for( int stage_num = 0;stage_num < number_stages ;stage_num ++){ + trellis_fname << "" << std::endl; + trellis_fname << stage_num << std::endl; + trellis_fname << "" << std::endl; + } + trellis_fname << "" << std::endl; + + // label the states + trellis_fname << "" << std::endl; + for( int state_num = 0;state_num < d_S ; state_num ++){ + trellis_fname << "" << std::endl; + trellis_fname << state_num << std::endl; + trellis_fname << "" << std::endl; + } + trellis_fname << "" << std::endl; + + trellis_fname << "" << std::endl; +// std::cout << "################## END SVG TRELLIS PIC ##################### " << std::endl; + trellis_fname.close(); +} +//###################################################################### +//# Write trellis specification to a text file, +//# in the same format used when reading FSM files +//###################################################################### +void fsm::write_fsm_txt(std::string filename) +{ + std::ofstream trellis_fname (filename.c_str()); + if (!trellis_fname) {std::cout << "file not found " << std::endl ; exit(-1);} + trellis_fname << d_I << ' ' << d_S << ' ' << d_O << std::endl; + trellis_fname << std::endl; + for(int i=0;i