MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
extedge.cc File Reference
#include "mbconfig.h"
#include "dataman.h"
#include "extedge.h"
#include "except.h"
#include "solver.h"
#include <fstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <cstdlib>
#include <unistd.h>
#include <cerrno>
#include <cstring>
Include dependency graph for extedge.cc:

Go to the source code of this file.

Functions

int mbedge_goto_eol (std::istream &fin, char *buf, size_t bufsiz)
 
char * mbedge_eat_sep (char *buf, size_t &buflen)
 
char * mbedge_eat_field (char *buf, size_t &buflen, const char *val)
 
ExtFileHandlerBaseReadExtFileHandlerEDGE (DataManager *pDM, MBDynParser &HP, unsigned int uLabel)
 

Variables

static const char * sEDGEcmd2str []
 

Function Documentation

char* mbedge_eat_field ( char *  buf,
size_t &  buflen,
const char *  val 
)

Definition at line 94 of file extedge.cc.

References ASSERT.

Referenced by ExtFileHandlerEDGE::CheckFlag(), ExtRigidForceEDGE::Recv(), ExtModalForceEDGE::Recv(), and StructExtEDGEForce::RecvFromStream().

95 {
96  ASSERT(buflen > 0);
97 
98  size_t vallen = strlen(val);
99  if (buflen < vallen) {
100  return 0;
101  }
102 
103  if (strncmp(buf, val, vallen) == 0) {
104  buflen -= vallen;
105  return &buf[vallen];
106  }
107 
108  return 0;
109 }
#define ASSERT(expression)
Definition: colamd.c:977
static doublereal buf[BUFSIZE]
Definition: discctrl.cc:333
char* mbedge_eat_sep ( char *  buf,
size_t &  buflen 
)

Definition at line 74 of file extedge.cc.

References ASSERT, and buf.

Referenced by ExtFileHandlerEDGE::CheckFlag(), ExtRigidForceEDGE::Recv(), ExtModalForceEDGE::Recv(), and StructExtEDGEForce::RecvFromStream().

75 {
76  size_t len = buflen;
77 
78  ASSERT(buflen > 0);
79 
80  while (len > 0) {
81  if (buf[0] == '\n' || buf[0] == '\0' || (buf[0] != ',' && !std::isspace(buf[0]))) {
82  buflen = len;
83  return buf;
84  }
85 
86  len--;
87  buf++;
88  }
89 
90  return 0;
91 }
#define ASSERT(expression)
Definition: colamd.c:977
static doublereal buf[BUFSIZE]
Definition: discctrl.cc:333
int mbedge_goto_eol ( std::istream &  fin,
char *  buf,
size_t  bufsiz 
)

Definition at line 49 of file extedge.cc.

Referenced by ExtFileHandlerEDGE::CheckFlag(), ExtRigidForceEDGE::Recv(), ExtModalForceEDGE::Recv(), and StructExtEDGEForce::RecvFromStream().

50 {
51  size_t i;
52 
53  for (i = 0; i < bufsiz; i++) {
54  buf[i] = fin.get();
55 
56  if (!fin) {
57  return -1;
58  }
59 
60  if (buf[i] == '\n') {
61  buf[i] = '\0';
62  break;
63  }
64  }
65 
66  if (i == bufsiz) {
67  return -1;
68  }
69 
70  return 0;
71 }
static doublereal buf[BUFSIZE]
Definition: discctrl.cc:333
ExtFileHandlerBase* ReadExtFileHandlerEDGE ( DataManager pDM,
MBDynParser HP,
unsigned int  uLabel 
)

Definition at line 757 of file extedge.cc.

References IncludeParser::GetFileName(), IncludeParser::GetLineData(), MBDYN_EXCEPT_ARGS, mbsleep_init(), ReadExtFileParams(), and SAFENEWWITHCONSTRUCTOR.

Referenced by ReadExtFileHandler().

760 {
761  ExtFileHandlerBase *pEFH = 0;
762 
763  const char *s = HP.GetFileName();
764  if (s == 0) {
765  silent_cerr("ExtForceEDGE(" << uLabel << "): "
766  "unable to get flag file name "
767  "at line " << HP.GetLineData() << std::endl);
769  }
770  std::string fflagname = s;
771 
772  s = HP.GetFileName();
773  if (s == 0) {
774  silent_cerr("ExtForceEDGE(" << uLabel << "): "
775  "unable to get data file name "
776  "at line " << HP.GetLineData() << std::endl);
778  }
779  std::string fdataname = s;
780 
781  mbsleep_t SleepTime = mbsleep_init(1);
782  std::streamsize Precision = 0;
783  ReadExtFileParams(pDM, HP, uLabel, SleepTime, Precision);
784 
786  ExtFileHandlerEDGE(fflagname, fdataname, SleepTime, Precision));
787 
788  return pEFH;
789 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
unsigned long mbsleep_t
Definition: mbsleep.h:51
virtual const char * GetFileName(enum Delims Del=DEFAULTDELIM)
Definition: parsinc.cc:673
mbsleep_t mbsleep_init(long t)
Definition: mbsleep.c:38
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
void ReadExtFileParams(DataManager *pDM, MBDynParser &HP, unsigned int uLabel, mbsleep_t &SleepTime, std::streamsize &Precision)
Definition: extforce.cc:845

Here is the call graph for this function:

Variable Documentation

const char* sEDGEcmd2str[]
static
Initial value:
= {
"INITIALIZING",
"BUSY",
"READ_READY",
"MBDYN_WRITE_DONE",
"GOTO_NEXT_STEP",
"QUIT",
0
}

Definition at line 158 of file extedge.cc.