-
defprimitive
-
{
-
name { Printer }
-
-
-
desc
-
{
-
Print out one sample from each input port per line.
-
}
-
-
htmldoc
-
{
-
Print out one sample from each input port per line. The <b>fileName</b> state specifies the file to be written; the special names <stdout> and <cout>, which specify the standard output stream, and <stderr> and <cerr>, which specify the standard error stream, are also supported.
-
}
-
-
inmulti
-
{
-
name { input }
-
type { anytype }
-
}
-
-
defparameter
-
{
-
name { fileName }
-
type { filename }
-
default {"<stdout>"}
-
desc {"Filename for output."}
-
}
-
-
defparameter
-
{
-
name { Title }
-
type { string }
-
}
-
-
defparameter
-
{
-
name { EndCondition }
-
type { boolean }
-
default {"FALSE"}
-
desc {"If EndCondition is set to TRUE, the simulation will end when NumberOfItems
-
have been consumed or when the number of cycles in Run Length have
-
been executed, whichever comes first."}
-
}
-
-
defparameter
-
{
-
name { NumberOfItems }
-
type {int}
-
default {"1"}
-
desc {"The number of particles comsumed by an input port. If the primitive receives
-
NumberOfItems input particles and the parameter EndCondition is set to TRUE,
-
then the simulation will be finished."}
-
}
-
-
location
{ SDF main library
}
-
-
hinclude {"kernel/pt_fstream.h"}
-
-
protected
-
{
-
pt_ofstream *p_out;
-
int numItemsCounter;
-
bool mReqEnd;
-
}
-
-
constructor
-
{
-
p_out = 0;
-
}
-
-
setup
-
{
-
if(EndCondition)
-
{
-
willRequestEnd();
-
if(NumberOfItems < 1)
-
Error::abortRun(*this, " the value of the parameter NumberOfItems is less than 1");
-
}
-
numItemsCounter = 0;
-
mReqEnd = false;
-
-
// in case file was open from previous run w/o wrapup call
-
LOG_DEL; delete p_out;
-
LOG_NEW; p_out = new pt_ofstream(fileName);
-
}
-
-
go
-
{
-
if(!mReqEnd)
-
{
-
pt_ofstream& output = *p_out;
-
InSDFMPHIter nexti(input);
-
InSDFPort* p;
-
output << "\nPrint " << fullName() << endl;
-
if(!Title.null())
-
output << (constchar*)Title << endl;
-
-
while((p = nexti++) != 0)
-
output << ((*p)%0).print() << "\t";
-
output << "\n";
-
-
if(EndCondition && ++numItemsCounter == NumberOfItems)
-
{
-
mReqEnd = true;
-
requestEnd();
-
}
-
}
-
}
-
-
wrapup
-
{
-
LOG_DEL; delete p_out; // flush output
-
p_out = 0;
-
}
-
-
destructor
-
{
-
LOG_DEL; delete p_out; // flush output
-
}
-
}
-