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

#include <rtai_in_drive.h>

Inheritance diagram for RTMBDynInDrive:
Collaboration diagram for RTMBDynInDrive:

Public Member Functions

 RTMBDynInDrive (unsigned int uL, const DriveHandler *pDH, const std::string &sFileName, const std::string &host, integer nd, const std::vector< doublereal > &v0, StreamDrive::Modifier *pMod, bool c, unsigned longn, bool bNonBlocking)
 
virtual ~RTMBDynInDrive (void)
 
virtual std::ostream & Restart (std::ostream &out) const
 
virtual void ServePending (const doublereal &t)
 
- Public Member Functions inherited from StreamDrive
 StreamDrive (unsigned int uL, const DriveHandler *pDH, const std::string &sFileName, integer nd, const std::vector< doublereal > &v0, bool c, StreamDrive::Modifier *pmod)
 
virtual ~StreamDrive (void)
 
void SetModifier (const Modifier *p)
 
const StreamDrive::ModifierpGetModifier (void) const
 
- Public Member Functions inherited from FileDrive
 FileDrive (unsigned int uL, const DriveHandler *pDH, const std::string &s, integer nd, const std::vector< doublereal > &v0)
 
virtual ~FileDrive (void)
 
virtual Drive::Type GetDriveType (void) const
 
virtual integer iGetNumDrives (void) const
 
virtual doublereal dGet (const doublereal &t, int i=1) const
 
- Public Member Functions inherited from Drive
 Drive (unsigned int uL, const DriveHandler *pDH)
 
virtual ~Drive (void)
 
- Public Member Functions inherited from WithLabel
 WithLabel (unsigned int uL=0, const std::string &sN="")
 
virtual ~WithLabel (void)
 
void PutLabel (unsigned int uL)
 
void PutName (const std::string &sN)
 
unsigned int GetLabel (void) const
 
const std::string & GetName (void) const
 

Protected Attributes

std::string host
 
unsigned long node
 
int port
 
bool bNonBlocking
 
void * mbx
 
int(* f_receive )(unsigned long node, int port, void *mbx, void *msg, int msg_size)
 
- Protected Attributes inherited from StreamDrive
int size
 
std::vector< char > buf
 
bool create
 
const ModifierpMod
 
- Protected Attributes inherited from FileDrive
std::string sFileName
 
integer iNumDrives
 
doublerealpdVal
 
- Protected Attributes inherited from Drive
const DriveHandlerpDrvHdl
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 

Additional Inherited Members

- Public Types inherited from Drive
enum  Type { UNKNOWN = -1, FILEDRIVE = 0, LASTDRIVETYPE }
 
enum  Bailout { BO_NONE = 0x0, BO_UPPER = 0x1, BO_LOWER = 0x2, BO_ANY = (BO_UPPER | BO_LOWER) }
 
- Static Protected Attributes inherited from Drive
static doublereal dReturnValue = 0.
 

Detailed Description

Definition at line 43 of file rtai_in_drive.h.

Constructor & Destructor Documentation

RTMBDynInDrive::RTMBDynInDrive ( unsigned int  uL,
const DriveHandler pDH,
const std::string &  sFileName,
const std::string &  host,
integer  nd,
const std::vector< doublereal > &  v0,
StreamDrive::Modifier pMod,
bool  c,
unsigned long  n,
bool  bNonBlocking 
)

Definition at line 40 of file rtai_in_drive.cc.

References ASSERT, StreamDrive::create, f_receive, MBDYN_EXCEPT_ARGS, mbx, node, port, and StreamDrive::size.

48 : StreamDrive(uL, pDH, sFileName, nd, v0, c, pMod),
50 mbx(NULL)
51 {
52  ASSERT(!sFileName.empty());
53 
54  if (create) {
55  ASSERT(node == 0);
56 
57  if (rtmbdyn_rt_mbx_init(sFileName.c_str(), size, &mbx)) {
58  silent_cerr("RTMBDyn mailbox(" << sFileName << ") "
59  "init failed" << std::endl);
61  }
62 
63  } else {
64  if (node) {
65  /* get port ... */
66  port = rtmbdyn_rt_request_port(node);
67  /* FIXME: what in case of failure? */
68  }
69 
70  if (rtmbdyn_RT_get_adr(node, port, sFileName.c_str(), &mbx)) {
71  silent_cerr("RTMBDyn mailbox(" << sFileName << ") "
72  "get_adr failed" << std::endl);
74  }
75  }
76 
77  if (bNonBlocking) {
78  f_receive = rtmbdyn_RT_mbx_receive_if;
79 
80  } else {
81  f_receive = rtmbdyn_RT_mbx_receive;
82  }
83 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
std::string sFileName
Definition: filedrv.h:46
int(* f_receive)(unsigned long node, int port, void *mbx, void *msg, int msg_size)
Definition: rtai_in_drive.h:54
unsigned long node
Definition: rtai_in_drive.h:48
std::string host
Definition: rtai_in_drive.h:47
#define ASSERT(expression)
Definition: colamd.c:977
static std::stack< cleanup * > c
Definition: cleanup.cc:59
static const std::vector< doublereal > v0
Definition: fixedstep.cc:45
StreamDrive(unsigned int uL, const DriveHandler *pDH, const std::string &sFileName, integer nd, const std::vector< doublereal > &v0, bool c, StreamDrive::Modifier *pmod)
Definition: streamdrive.cc:42
RTMBDynInDrive::~RTMBDynInDrive ( void  )
virtual

Definition at line 85 of file rtai_in_drive.cc.

References mbx.

86 {
87  /*
88  * destroy mailbox and so on
89  */
90  if (mbx) {
91  rtmbdyn_rt_mbx_delete(&mbx);
92  }
93 }

Member Function Documentation

std::ostream & RTMBDynInDrive::Restart ( std::ostream &  out) const
virtual

Implements FileDrive.

Definition at line 116 of file rtai_in_drive.cc.

117 {
118  return out << "0. /* RTMBDynInDrive not implemented yet */" << std::endl;
119 }
void RTMBDynInDrive::ServePending ( const doublereal t)
virtual

Implements Drive.

Definition at line 96 of file rtai_in_drive.cc.

References StreamDrive::buf, f_receive, FileDrive::iNumDrives, mbx, node, FileDrive::pdVal, port, and StreamDrive::size.

97 {
98  /*
99  * store in pdVal the values of all the channels
100  * served by the mailbox
101  */
102  int rc = f_receive(node, port, mbx, (void *)&buf[0], size);
103  if (!rc) {
104  doublereal *rbuf = (doublereal *)&buf[0] - 1;
105  for (int i = 1; i <= iNumDrives; i++) {
106  pdVal[i] = rbuf[i];
107  }
108 
109  } else {
110  /* FIXME: error */
111  }
112 }
std::vector< char > buf
Definition: streamdrive.h:65
integer iNumDrives
Definition: filedrv.h:47
int(* f_receive)(unsigned long node, int port, void *mbx, void *msg, int msg_size)
Definition: rtai_in_drive.h:54
doublereal * pdVal
Definition: filedrv.h:48
unsigned long node
Definition: rtai_in_drive.h:48
double doublereal
Definition: colamd.c:52

Member Data Documentation

bool RTMBDynInDrive::bNonBlocking
protected

Definition at line 50 of file rtai_in_drive.h.

int(* RTMBDynInDrive::f_receive)(unsigned long node, int port, void *mbx, void *msg, int msg_size)
protected

Definition at line 54 of file rtai_in_drive.h.

Referenced by RTMBDynInDrive(), and ServePending().

std::string RTMBDynInDrive::host
protected

Definition at line 47 of file rtai_in_drive.h.

void* RTMBDynInDrive::mbx
protected

Definition at line 52 of file rtai_in_drive.h.

Referenced by RTMBDynInDrive(), ServePending(), and ~RTMBDynInDrive().

unsigned long RTMBDynInDrive::node
protected

Definition at line 48 of file rtai_in_drive.h.

Referenced by RTMBDynInDrive(), and ServePending().

int RTMBDynInDrive::port
protected

Definition at line 49 of file rtai_in_drive.h.

Referenced by RTMBDynInDrive(), and ServePending().


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