42 const std::string& sFileName,
43 const std::string&
host,
44 integer nd,
const std::vector<doublereal>&
v0,
46 bool c,
unsigned long n,
49 host(host), node(n),
port(-1), bNonBlocking(bNonBlocking),
52 ASSERT(!sFileName.empty());
57 if (rtmbdyn_rt_mbx_init(sFileName.c_str(),
size, &
mbx)) {
58 silent_cerr(
"RTMBDyn mailbox(" << sFileName <<
") "
59 "init failed" << std::endl);
66 port = rtmbdyn_rt_request_port(
node);
70 if (rtmbdyn_RT_get_adr(
node,
port, sFileName.c_str(), &
mbx)) {
71 silent_cerr(
"RTMBDyn mailbox(" << sFileName <<
") "
72 "get_adr failed" << std::endl);
91 rtmbdyn_rt_mbx_delete(&
mbx);
118 return out <<
"0. /* RTMBDynInDrive not implemented yet */" << std::endl;
124 unsigned long node = (
unsigned long)-1;
129 if (HP.
IsKeyWord(
"stream" "drive" "name")) {
132 silent_cerr(
"RTMBDynInDrive(" << uLabel <<
"): "
133 "unable to read mailbox name "
137 }
else if (strlen(m) != 6) {
138 silent_cerr(
"RTMBDynInDrive(" << uLabel <<
"): "
139 "illegal mailbox name \"" << m <<
"\" "
140 "(must be exactly 6 chars) "
148 silent_cerr(
"RTMBDynInDrive(" << uLabel <<
"): "
149 "missing mailbox name "
156 silent_cerr(
"RTMBDynInDrive(" << uLabel <<
"): "
157 "\"create\" must be \"yes\" or \"no\" "
164 silent_cout(
"RTMBDynInDrive(" << uLabel <<
"): "
165 "RTMBDyn mailboxes are always non-blocking"
172 silent_cout(
"RTMBDynInDrive(" << uLabel <<
"): "
173 "local path \"" << m <<
"\" silently ignored"
180 silent_cout(
"RTMBDynInDrive(" << uLabel <<
"): "
181 "port " << p <<
" silently ignored" << std::endl);
189 silent_cerr(
"RTMBDynInDrive(" << uLabel <<
"): "
190 "unable to read host "
196 silent_cout(
"RTMBDynInDrive(" << uLabel <<
"): "
197 "host name \"" << h <<
"\" silently ignored"
204 #if defined(HAVE_GETADDRINFO)
205 struct addrinfo hints = { 0 }, *res = NULL;
208 hints.ai_family = AF_INET;
209 hints.ai_socktype = SOCK_STREAM;
210 rc = getaddrinfo(host.c_str(), NULL, &hints, &res);
212 node = ((
struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr;
215 #elif defined(HAVE_GETHOSTBYNAME)
217 struct hostent *he = gethostbyname(host.c_str());
220 node = ((
unsigned long *)he->h_addr_list[0])[0];
222 #elif defined(HAVE_INET_ATON)
224 if (inet_aton(host.c_str(), &addr)) {
227 #else // ! HAVE_GETADDRINFO && ! HAVE_GETHOSTBYNAME && ! HAVE_INET_ATON
228 silent_cerr(
"RTMBDynInDrive(" << uLabel <<
"): "
229 "host (RTAI RPC) not supported "
232 #endif // ! HAVE_GETADDRINFO && ! HAVE_GETHOSTBYNAME && ! HAVE_INET_ATON
234 if (node == (
unsigned long)-1) {
235 silent_cerr(
"RTMBDynInDrive(" << uLabel <<
"): "
236 "unable to convert host \"" << host <<
"\" to node" << std::endl);
242 bool bNonBlocking(
true);
247 }
else if (HP.
IsKeyWord(
"no" "signal")) {
251 bNonBlocking =
false;
253 }
else if (HP.
IsKeyWord(
"non" "blocking")) {
261 int idrives = HP.
GetInt();
263 silent_cerr(
"RTMBDynInDrive(" << uLabel <<
"): "
264 "illegal number of channels "
269 std::vector<doublereal>
v0;
272 for (
int i = 0; i < idrives; i++) {
286 name,
host, idrives,
v0, pMod,
287 create, node, bNonBlocking));
#define MBDYN_EXCEPT_ARGS
virtual integer GetInt(integer iDefval=0)
StreamDrive::Modifier * ReadStreamDriveModifier(MBDynParser &HP, integer nDrives)
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)
const DriveHandler * pGetDrvHdl(void) const
int(* f_receive)(unsigned long node, int port, void *mbx, void *msg, int msg_size)
virtual std::ostream & Restart(std::ostream &out) const
virtual bool IsKeyWord(const char *sKeyWord)
virtual const char * GetStringWithDelims(enum Delims Del=DEFAULTDELIM, bool escape=true)
virtual ~RTMBDynInDrive(void)
#define ASSERT(expression)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Drive * ReadRTMBDynInDrive(const DataManager *pDM, MBDynParser &HP, unsigned int uLabel)
static std::stack< cleanup * > c
virtual bool GetYesNo(bool &bRet)
virtual void ServePending(const doublereal &t)
static const std::vector< doublereal > v0
virtual HighParser::ErrOut GetLineData(void) const
virtual doublereal GetReal(const doublereal &dDefval=0.0)