MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
StreamDriveEcho Class Reference

#include <streamdrive.h>

Collaboration diagram for StreamDriveEcho:

Public Member Functions

 StreamDriveEcho (const DriveHandler *pDrvHdl, std::string &sOutFileName, int iPrecision, doublereal dShift)
 
 ~StreamDriveEcho (void)
 
bool bIsEcho (void) const
 
bool Init (const std::string &msg, unsigned uLabel, unsigned nChannels)
 
void EchoPrepare (const doublereal *pbuf, unsigned nChannels)
 
void Echo (const doublereal *pbuf, unsigned nChannels)
 

Private Attributes

const DriveHandlerpDrvHdl
 
std::string sOutFileName
 
std::vector< doublerealechoBuf
 
std::ofstream outFile
 
int iPrecision
 
doublereal dShift
 

Detailed Description

Definition at line 90 of file streamdrive.h.

Constructor & Destructor Documentation

StreamDriveEcho::StreamDriveEcho ( const DriveHandler pDrvHdl,
std::string &  sOutFileName,
int  iPrecision,
doublereal  dShift 
)

Definition at line 208 of file streamdrive.cc.

References NO_OP.

209 : pDrvHdl(pDrvHdl),
211 iPrecision(iPrecision),
212 dShift(dShift)
213 {
214  NO_OP;
215 }
const DriveHandler * pDrvHdl
Definition: streamdrive.h:92
#define NO_OP
Definition: myassert.h:74
std::string sOutFileName
Definition: streamdrive.h:93
doublereal dShift
Definition: streamdrive.h:97
StreamDriveEcho::~StreamDriveEcho ( void  )

Definition at line 217 of file streamdrive.cc.

References NO_OP.

218 {
219  NO_OP;
220 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

bool StreamDriveEcho::bIsEcho ( void  ) const
void StreamDriveEcho::Echo ( const doublereal pbuf,
unsigned  nChannels 
)

Definition at line 264 of file streamdrive.cc.

References DriveHandler::dGetTime(), dShift, echoBuf, outFile, and pDrvHdl.

Referenced by BufferStreamDrive_base::ServePending().

265 {
266  for (unsigned i = 0; i < size ; i++) {
267  if (pbuf[i] != echoBuf[i]) {
268  // changed; need to write
269  outFile << (pDrvHdl->dGetTime() + dShift);
270  for (unsigned j = 0; j < size ; j++) {
271  outFile << " " << pbuf[j];
272  }
273  outFile << std::endl;
274  break;
275  }
276  }
277 }
const DriveHandler * pDrvHdl
Definition: streamdrive.h:92
std::vector< doublereal > echoBuf
Definition: streamdrive.h:94
std::ofstream outFile
Definition: streamdrive.h:95
doublereal dGetTime(void) const
Definition: drive.h:386
doublereal dShift
Definition: streamdrive.h:97

Here is the call graph for this function:

void StreamDriveEcho::EchoPrepare ( const doublereal pbuf,
unsigned  nChannels 
)

Definition at line 256 of file streamdrive.cc.

References echoBuf.

Referenced by BufferStreamDrive_base::ServePending().

257 {
258  for (unsigned i = 1; i < size; i++) {
259  echoBuf[i] = pbuf[i];
260  }
261 }
std::vector< doublereal > echoBuf
Definition: streamdrive.h:94
bool StreamDriveEcho::Init ( const std::string &  msg,
unsigned  uLabel,
unsigned  nChannels 
)

Definition at line 223 of file streamdrive.cc.

References echoBuf, iPrecision, MBDYN_EXCEPT_ARGS, outFile, and sOutFileName.

Referenced by BufferStreamDrive_base::BufferStreamDrive_base().

224 {
225  outFile.open(sOutFileName.c_str());
226  if (!outFile) {
227  silent_cerr(msg << "(" << uLabel << "): "
228  "unable to open echo file '" << sOutFileName << "'" << std::endl);
230  }
231  echoBuf.resize(nChannels);
232 
233  if (iPrecision > 0) {
234  outFile.precision(iPrecision);
235  }
236  outFile.setf(std::ios::scientific);
237 
238  outFile
239  << "# generated by SocketStreamDrive(" << uLabel << ")"
240  << std::endl;
241  if (nChannels == 1) {
242  outFile
243  << "# Time, Channel #1"
244  << std::endl;
245 
246  } else {
247  outFile
248  << "# Time, Channels #1-" << nChannels
249  << std::endl;
250  }
251 
252  return true;
253 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
std::vector< doublereal > echoBuf
Definition: streamdrive.h:94
std::ofstream outFile
Definition: streamdrive.h:95
struct mbrtai_msg_t msg
std::string sOutFileName
Definition: streamdrive.h:93

Member Data Documentation

doublereal StreamDriveEcho::dShift
private

Definition at line 97 of file streamdrive.h.

Referenced by Echo().

std::vector<doublereal> StreamDriveEcho::echoBuf
private

Definition at line 94 of file streamdrive.h.

Referenced by Echo(), EchoPrepare(), and Init().

int StreamDriveEcho::iPrecision
private

Definition at line 96 of file streamdrive.h.

Referenced by Init().

std::ofstream StreamDriveEcho::outFile
private

Definition at line 95 of file streamdrive.h.

Referenced by Echo(), and Init().

const DriveHandler* StreamDriveEcho::pDrvHdl
private

Definition at line 92 of file streamdrive.h.

Referenced by Echo().

std::string StreamDriveEcho::sOutFileName
private

Definition at line 93 of file streamdrive.h.

Referenced by Init().


The documentation for this class was generated from the following files: