Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

dlogger.cpp

Go to the documentation of this file.
00001 
00026 #include "dlogger.h"
00027 #include <iomanip>
00028 
00029 using namespace std;
00030 
00032 namespace punnets_common {
00034 
00035 const int lev_shift = 0;
00036 
00037 void tlogger::activate(tscheduler &scheduler, ntime_t current_time)
00038 { 
00039     out << setprecision(15) << current_time;
00040 
00041     int lev = 0;
00042     
00043     for( vector< neuentry >::iterator i = neus.begin(); i != neus.end(); i++ )
00044     {
00045         if( i->delay != 0.0 )
00046             out << "\t" << setprecision(15) << current_time - i->delay;
00047         out << "\t" << setprecision(15) << 
00048             (i->neuron->getLastFire() >= current_time - step ? 
00049                 i->lastthr + 1.0 : 
00050                 i->neuron->getCurrentSigLevel(current_time) ) + lev + i->offset;
00051         i->lastthr = i->neuron->getCurrentThrLevel(current_time);
00052         if( i->logopt & showthr )
00053             out << "\t" << setprecision(15) << i->lastthr + lev + i->offset;
00054         if( i->logopt & showext )
00055             out << "\t" << setprecision(15) << i->neuron->getCurrentExtInput(current_time) + lev + i->offset;
00056         if( i->logopt & showpart )
00057         {
00058             if( i->neuron->getLastSimulate() >= current_time - step )
00059             {
00060                 switch( i->neuron->getLastSimulateType() )
00061                 {
00062                     case 0:
00063                     default:
00064                         out << " -10 = = ="; break;
00065                     case 1:
00066                         out << " = -10 = ="; break;
00067                     case 2:
00068                         out << " = = -10 ="; break;
00069                     case 3:
00070                         out << " = = = -10"; break;
00071                 }
00072             }
00073             else
00074                 out << " = = = =";
00075         }
00076         lev += lev_shift;
00077     }
00078     for( vector<pair<tsynapse_base *, ntime_t> >::iterator i = syns.begin(); i != syns.end(); i++ )
00079     {
00080         if( i->second != 0.0 )
00081             out << "\t" << setprecision(15) << current_time - i->second;
00082         out << "\t" << setprecision(15) << i->first->getWeight();// + lev;
00083 //      lev += lev_shift;
00084     }
00085     out << endl;
00086     if( current_time + step < until + delaymax )
00087         scheduler.scheduleEvent(current_time + step, *this);
00088 };
00089 
00090 void tlogger::gnuplot_def(ostream &os, string logfile)
00091 {
00092 //  cerr << "min/max: " << delaymin << "/" << delaymax << endl;
00093 //  os << "set term X11" << endl;
00094     os << "set y2tics" << endl;
00095     os << "plot [" << from << ":" << until << "]";
00096 
00097     string delim = "";
00098     int column = 1;
00099     for( vector< neuentry >::iterator i = neus.begin(); i != neus.end(); i++ )
00100     {
00101         int xcol = (i->delay == 0.0 ? 1 : ++column);
00102         os << delim << " \\" << endl << "\t'" << logfile << "' " << 
00103             "using " << xcol << ":" << (++column) << " axes x1y1 " << 
00104             "title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";
00105         if( i->delay != 0.0 )
00106             os << "(delay " << i->delay << ")";
00107         if( i->offset != 0.0 )
00108             os << "(offset " << i->offset << ")";
00109         os << " signal\" with lines";
00110         delim = ",";
00111 
00112         if( i->logopt & showthr )
00113         {
00114             os << delim << " \\" << endl << "\t'" << logfile << "' " << 
00115                 "using " << xcol << ":" << (++column) << " axes x1y1 " << 
00116                 "title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";
00117             if( i->delay != 0.0 )
00118                 os << "(delay " << i->delay << ")";
00119             if( i->offset != 0.0 )
00120                 os << "(offset " << i->offset << ")";
00121             os << " threshold\" with dots";
00122             delim = ",";
00123         }
00124         if( i->logopt & showext )
00125         {
00126             os << delim << " \\" << endl << "\t'" << logfile << "' " << 
00127                 "using " << xcol << ":" << (++column) << " axes x1y1 " << 
00128                 "title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";
00129             if( i->delay != 0.0 )
00130                 os << "(delay " << i->delay << ")";
00131             if( i->offset != 0.0 )
00132                 os << "(offset " << i->offset << ")";
00133             os << " external\" with dots";
00134             delim = ",";
00135         }
00136         if( i->logopt & showpart )
00137         {
00138             os << delim << " \\" << endl << "\t'" << logfile << "' " << 
00139                 "using " << xcol << ":" << (++column) << " axes x1y1 " << 
00140                 "title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";
00141             if( i->delay != 0.0 )
00142                 os << "(delay " << i->delay << ")";
00143             if( i->offset != 0.0 )
00144                 os << "(offset " << i->offset << ")";
00145             os << " partition 0\" with impulses";
00146             delim = ",";
00147 
00148             os << delim << " \\" << endl << "\t'" << logfile << "' " << 
00149                 "using " << xcol << ":" << (++column) << " axes x1y1 " << 
00150                 "title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";
00151             if( i->delay != 0.0 )
00152                 os << "(delay " << i->delay << ")";
00153             if( i->offset != 0.0 )
00154                 os << "(offset " << i->offset << ")";
00155             os << " partition 1\" with impulses";
00156 
00157             os << delim << " \\" << endl << "\t'" << logfile << "' " << 
00158                 "using " << xcol << ":" << (++column) << " axes x1y1 " << 
00159                 "title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";
00160             if( i->delay != 0.0 )
00161                 os << "(delay " << i->delay << ")";
00162             if( i->offset != 0.0 )
00163                 os << "(offset " << i->offset << ")";
00164             os << " partition 2\" with impulses";
00165 
00166             os << delim << " \\" << endl << "\t'" << logfile << "' " << 
00167                 "using " << xcol << ":" << (++column) << " axes x1y1 " << 
00168                 "title \"" << i->neuron->getClassName() << " '" << i->neuron->getName() << "'";
00169             if( i->delay != 0.0 )
00170                 os << "(delay " << i->delay << ")";
00171             if( i->offset != 0.0 )
00172                 os << "(offset " << i->offset << ")";
00173             os << " partition delta_t\" with impulses";
00174         }
00175     }
00176     for( vector<pair<tsynapse_base *, ntime_t> >::iterator i = syns.begin(); i != syns.end(); i++ )
00177     {
00178         int xcol = (i->second == 0.0 ? 1 : ++column);
00179         os << delim << " \\" << endl << "\t'" << logfile << "' " << 
00180             "using " << xcol << ":" << (++column) << " axes x1y2 " <<
00181             "title \"" << i->first->getClassName() << " '" << i->first->getSrc().getName() << "' -> '" << i->first->getDest().getName() << "'";
00182         if( i->second != 0.0 )
00183             os << "(delay " << i->second << ")";
00184         os << "\" with lines";
00185         delim = ",";
00186     }
00187 
00188     os << endl;
00189     os << "pause -1" << endl;
00190 }
00191 
00192 
00194 } // namespace punnets_common

Generated on Mon Jun 16 15:42:25 2003 for Punnets by doxygen1.2.18