MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
mbc.h File Reference
#include <stdint.h>
Include dependency graph for mbc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mbc_t
 Connection data structure (partially opaque) More...
 
struct  mbc_rigid_t
 Reference node (AKA "rigid") stuff (partially opaque). More...
 
struct  mbc_nodal_t
 Nodal stuff (partially opaque). More...
 
struct  mbc_modal_t
 nodal stuff (partially opaque). More...
 

Macros

#define MBC_F(mbc)   ((mbc)->mbcr.flags)
 
#define MBC_F_GET(mbc, f)   (MBC_F(mbc) & (f))
 
#define MBC_F_SET(mbc, f)   (MBC_F(mbc) |= (f))
 
#define MBC_F_RESET(mbc, f)   (MBC_F(mbc) &= ~(f))
 
#define MBC_F_REF_NODE(mbc)   MBC_F_GET(mbc, MBC_REF_NODE)
 
#define MBC_F_LABELS(mbc)   MBC_F_GET(mbc, MBC_LABELS)
 
#define MBC_F_ACCELS(mbc)   MBC_F_GET(mbc, MBC_ACCELS)
 
#define MBC_F_ROT(mbc)   MBC_F_GET(mbc, MBC_ROT_MASK)
 
#define MBC_F_ROT_THETA(mbc)   MBC_F_GET(mbc, MBC_ROT_THETA)
 
#define MBC_F_ROT_MAT(mbc)   MBC_F_GET(mbc, MBC_ROT_MAT)
 
#define MBC_F_ROT_EULER_123(mbc)   MBC_F_GET(mbc, MBC_ROT_EULER_123)
 
#define MBC_U_REF_NODE_ROT_2_ROT(u)   (((u) & MBC_REF_NODE_ROT_MASK) >> 4)
 
#define MBC_U_ROT_2_REF_NODE_ROT(u)   (((u) & MBC_ROT_MASK) << 4)
 
#define MBC_F_ROT_REF_NODE(mbc)   MBC_U_REF_NODE_ROT_2_ROT(MBC_F_GET((mbc), MBC_REF_NODE_ROT_MASK))
 
#define MBC_F_REF_NODE_ROT(mbc)   MBC_F_GET(mbc, MBC_REF_NODE_ROT_MASK)
 
#define MBC_F_SET_REF_NODE(mbc)   MBC_F_SET(mbc, MBC_REF_NODE)
 
#define MBC_F_SET_LABELS(mbc)   MBC_F_SET(mbc, MBC_LABELS)
 
#define MBC_F_SET_ACCELS(mbc)   MBC_F_SET(mbc, MBC_ACCELS)
 
#define MBC_F_SET_ROT_THETA(mbc)   MBC_F_SET(mbc, MBC_ROT_THETA)
 
#define MBC_F_SET_ROT_MAT(mbc)   MBC_F_SET(mbc, MBC_ROT_MAT)
 
#define MBC_F_SET_ROT_EULER_123(mbc)   MBC_F_SET(mbc, MBC_ROT_EULER_123)
 
#define MBC_R_PTR(mbc, type, off)   ((off) < 0 ? NULL : ((type *)&((mbc)->mbcr.r_ptr.type ## _r_ptr[(off)])))
 
#define MBC_R_K_LABEL(mbc)   (MBC_R_PTR((mbc), uint32_t, (mbc)->mbcr.r_k_label)[0])
 
#define MBC_R_X(mbc)   (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_x))
 
#define MBC_R_THETA(mbc)   (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_theta))
 
#define MBC_R_R(mbc)   (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_r))
 
#define MBC_R_EULER_123(mbc)   (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_euler_123))
 
#define MBC_R_XP(mbc)   (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_xp))
 
#define MBC_R_OMEGA(mbc)   (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_omega))
 
#define MBC_R_XPP(mbc)   (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_xpp))
 
#define MBC_R_OMEGAP(mbc)   (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_omegap))
 
#define MBC_R_D_LABEL(mbc)   (MBC_R_PTR((mbc), uint32_t, (mbc)->mbcr.r_d_label)[0])
 
#define MBC_R_F(mbc)   (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_d_f))
 
#define MBC_R_M(mbc)   (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_d_m))
 
#define MBC_R_KINEMATICS_SIZE(mbc)   ((mbc)->mbcr.k_size)
 
#define MBC_R_DYNAMICS_SIZE(mbc)   ((mbc)->mbcr.d_size)
 
#define MBC_R_SIZE(mbc)   (MBC_R_KINEMATICS_SIZE(mbc) + MBC_R_DYNAMICS_SIZE(mbc))
 
#define MBC_R_KINEMATICS(mbc)   ((void *)(mbc)->mbcr.r_ptr.char_r_ptr)
 
#define MBC_R_DYNAMICS(mbc)   ((void *)(MBC_R_KINEMATICS(mbc) + MBC_R_KINEMATICS_SIZE(mbc)))
 
#define MBC_N_K_LABELS(mbc)   ((mbc)->n_k_labels)
 
#define MBC_N_X(mbc)   ((mbc)->n_k_x)
 
#define MBC_N_THETA(mbc)   ((mbc)->n_k_theta)
 
#define MBC_N_R(mbc)   ((mbc)->n_k_r)
 
#define MBC_N_EULER_123(mbc)   ((mbc)->n_k_euler_123)
 
#define MBC_N_XP(mbc)   ((mbc)->n_k_xp)
 
#define MBC_N_OMEGA(mbc)   ((mbc)->n_k_omega)
 
#define MBC_N_XPP(mbc)   ((mbc)->n_k_xpp)
 
#define MBC_N_OMEGAP(mbc)   ((mbc)->n_k_omegap)
 
#define MBC_N_D_LABELS(mbc)   ((mbc)->n_d_labels)
 
#define MBC_N_F(mbc)   ((mbc)->n_d_f)
 
#define MBC_N_M(mbc)   ((mbc)->n_d_m)
 
#define MBC_N_KINEMATICS_SIZE(mbc)   ((mbc)->k_size)
 
#define MBC_N_DYNAMICS_SIZE(mbc)   ((mbc)->d_size)
 
#define MBC_N_KINEMATICS(mbc)   ((void *)(mbc)->n_ptr)
 
#define MBC_N_DYNAMICS(mbc)   ((void *)(MBC_N_KINEMATICS(mbc) + MBC_N_KINEMATICS_SIZE(mbc)))
 
#define MBC_N_SIZE(mbc)   (MBC_N_KINEMATICS_SIZE(mbc) + MBC_N_DYNAMICS_SIZE(mbc))
 
#define MBC_Q(mbc)   (&(mbc)->m[0])
 
#define MBC_QP(mbc)   (&(mbc)->m[(mbc)->modes])
 
#define MBC_P(mbc)   (&(mbc)->m[2*(mbc)->modes])
 
#define MBC_M_KINEMATICS(mbc)   MBC_Q((mbc))
 
#define MBC_M_DYNAMICS(mbc)   MBC_P((mbc))
 
#define MBC_M_KINEMATICS_SIZE(mbc)   (2*(mbc)->modes*sizeof(double))
 
#define MBC_M_DYNAMICS_SIZE(mbc)   ((mbc)->modes*sizeof(double))
 
#define MBC_M_SIZE(mbc)   (3*(mbc)->modes*sizeof(double))
 

Enumerations

enum  ESCmd {
  ES_UNKNOWN = -1, ES_REGULAR_DATA = 2, ES_GOTO_NEXT_STEP = 4, ES_ABORT = 5,
  ES_REGULAR_DATA_AND_GOTO_NEXT_STEP = 6, ES_NEGOTIATION = 7, ES_OK = 8, ES_LAST
}
 Legal commands. More...
 
enum  MBCType {
  MBC_MODAL = 0x0001U, MBC_NODAL = 0x0002U, MBC_MODAL_NODAL_MASK = (MBC_MODAL | MBC_NODAL), MBC_REF_NODE = 0x0004U,
  MBC_ACCELS = 0x0008U, MBC_LABELS = 0x0010U, MBC_ROT_THETA = 0x0100U, MBC_ROT_MAT = 0x0200U,
  MBC_ROT_EULER_123 = 0x0400U, MBC_ROT_NONE = 0x0000U, MBC_ROT_MASK = (MBC_ROT_THETA | MBC_ROT_MAT | MBC_ROT_EULER_123), MBC_REF_NODE_ROT_THETA = (MBC_ROT_THETA << 4),
  MBC_REF_NODE_ROT_MAT = (MBC_ROT_MAT << 4), MBC_REF_NODE_ROT_EULER_123 = (MBC_ROT_EULER_123 << 4), MBC_REF_NODE_ROT_MASK = (MBC_ROT_MASK << 4), MBC_LAST
}
 Parameters used to control the communication type and fields. More...
 

Functions

int mbc_check_cmd (mbc_t *mbc)
 Opaque. More...
 
int mbc_get_cmd (mbc_t *mbc)
 Opaque. More...
 
int mbc_put_cmd (mbc_t *mbc)
 Opaque. More...
 
int mbc_inet_init (mbc_t *mbc, const char *host, short unsigned port)
 Initialize communication using "inet" socket. More...
 
int mbc_unix_init (mbc_t *mbc, const char *path)
 Initialize communication using "unix" socket. More...
 
int mbc_nodal_init (mbc_nodal_t *mbc, unsigned refnode, unsigned nodes, unsigned labels, unsigned rot, unsigned accels)
 Initialize nodal data. More...
 
int mbc_nodal_destroy (mbc_nodal_t *mbc)
 Destroy nodal data. More...
 
int mbc_nodal_negotiate_request (mbc_nodal_t *mbc)
 Negotiate nodal data. More...
 
int mbc_nodal_negotiate_response (mbc_nodal_t *mbc)
 Unused. More...
 
int mbc_nodal_get_motion (mbc_nodal_t *mbc)
 Get nodal motion from peer. More...
 
int mbc_nodal_put_forces (mbc_nodal_t *mbc, int last)
 Put forces to peer. More...
 
int mbc_modal_init (mbc_modal_t *mbc, int refnode, unsigned modes)
 Initialize modal data. More...
 
int mbc_modal_destroy (mbc_modal_t *mbc)
 Destroy modal data. More...
 
int mbc_modal_negotiate_request (mbc_modal_t *mbc)
 Negotiate modal data. More...
 
int mbc_modal_negotiate_response (mbc_modal_t *mbc)
 Unused. More...
 
int mbc_modal_get_motion (mbc_modal_t *mbc)
 Get modal motion from peer. More...
 
int mbc_modal_put_forces (mbc_modal_t *mbc, int last)
 Put forces to peer. More...
 

Macro Definition Documentation

#define MBC_F (   mbc)    ((mbc)->mbcr.flags)

Definition at line 235 of file mbc.h.

#define MBC_F_ACCELS (   mbc)    MBC_F_GET(mbc, MBC_ACCELS)

Definition at line 242 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), and tdata_().

#define MBC_F_GET (   mbc,
 
)    (MBC_F(mbc) & (f))

Definition at line 236 of file mbc.h.

#define MBC_F_LABELS (   mbc)    MBC_F_GET(mbc, MBC_LABELS)

Definition at line 241 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), and tdata_().

#define MBC_F_REF_NODE (   mbc)    MBC_F_GET(mbc, MBC_REF_NODE)

Definition at line 240 of file mbc.h.

Referenced by mbc_py_modal_negotiate(), mbc_py_nodal_negotiate(), tdata_(), trecv_(), and tsend_().

#define MBC_F_REF_NODE_ROT (   mbc)    MBC_F_GET(mbc, MBC_REF_NODE_ROT_MASK)

Definition at line 250 of file mbc.h.

#define MBC_F_RESET (   mbc,
 
)    (MBC_F(mbc) &= ~(f))

Definition at line 238 of file mbc.h.

#define MBC_F_ROT (   mbc)    MBC_F_GET(mbc, MBC_ROT_MASK)

Definition at line 243 of file mbc.h.

Referenced by main(), mbc_py_nodal_negotiate(), tdata_(), test_run(), and trecv_().

#define MBC_F_ROT_EULER_123 (   mbc)    MBC_F_GET(mbc, MBC_ROT_EULER_123)

Definition at line 246 of file mbc.h.

#define MBC_F_ROT_MAT (   mbc)    MBC_F_GET(mbc, MBC_ROT_MAT)

Definition at line 245 of file mbc.h.

#define MBC_F_ROT_REF_NODE (   mbc)    MBC_U_REF_NODE_ROT_2_ROT(MBC_F_GET((mbc), MBC_REF_NODE_ROT_MASK))

Definition at line 249 of file mbc.h.

Referenced by mbc_py_nodal_negotiate().

#define MBC_F_ROT_THETA (   mbc)    MBC_F_GET(mbc, MBC_ROT_THETA)

Definition at line 244 of file mbc.h.

#define MBC_F_SET (   mbc,
 
)    (MBC_F(mbc) |= (f))

Definition at line 237 of file mbc.h.

#define MBC_F_SET_ACCELS (   mbc)    MBC_F_SET(mbc, MBC_ACCELS)

Definition at line 254 of file mbc.h.

#define MBC_F_SET_LABELS (   mbc)    MBC_F_SET(mbc, MBC_LABELS)

Definition at line 253 of file mbc.h.

#define MBC_F_SET_REF_NODE (   mbc)    MBC_F_SET(mbc, MBC_REF_NODE)

Definition at line 252 of file mbc.h.

#define MBC_F_SET_ROT_EULER_123 (   mbc)    MBC_F_SET(mbc, MBC_ROT_EULER_123)

Definition at line 257 of file mbc.h.

#define MBC_F_SET_ROT_MAT (   mbc)    MBC_F_SET(mbc, MBC_ROT_MAT)

Definition at line 256 of file mbc.h.

#define MBC_F_SET_ROT_THETA (   mbc)    MBC_F_SET(mbc, MBC_ROT_THETA)

Definition at line 255 of file mbc.h.

#define MBC_M_DYNAMICS (   mbc)    MBC_P((mbc))

Definition at line 520 of file mbc.h.

#define MBC_M_DYNAMICS_SIZE (   mbc)    ((mbc)->modes*sizeof(double))

Definition at line 522 of file mbc.h.

#define MBC_M_KINEMATICS (   mbc)    MBC_Q((mbc))

Definition at line 519 of file mbc.h.

#define MBC_M_KINEMATICS_SIZE (   mbc)    (2*(mbc)->modes*sizeof(double))

Definition at line 521 of file mbc.h.

#define MBC_M_SIZE (   mbc)    (3*(mbc)->modes*sizeof(double))

Definition at line 523 of file mbc.h.

#define MBC_N_D_LABELS (   mbc)    ((mbc)->n_d_labels)

Definition at line 371 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), and test_run().

#define MBC_N_DYNAMICS (   mbc)    ((void *)(MBC_N_KINEMATICS(mbc) + MBC_N_KINEMATICS_SIZE(mbc)))

Definition at line 377 of file mbc.h.

#define MBC_N_DYNAMICS_SIZE (   mbc)    ((mbc)->d_size)

Definition at line 375 of file mbc.h.

#define MBC_N_EULER_123 (   mbc)    ((mbc)->n_k_euler_123)

Definition at line 366 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_N_F (   mbc)    ((mbc)->n_d_f)

Definition at line 372 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), test_run(), and tsend_().

#define MBC_N_K_LABELS (   mbc)    ((mbc)->n_k_labels)

Definition at line 362 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), and test_run().

#define MBC_N_KINEMATICS (   mbc)    ((void *)(mbc)->n_ptr)

Definition at line 376 of file mbc.h.

#define MBC_N_KINEMATICS_SIZE (   mbc)    ((mbc)->k_size)

Definition at line 374 of file mbc.h.

#define MBC_N_M (   mbc)    ((mbc)->n_d_m)

Definition at line 373 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), test_run(), and tsend_().

#define MBC_N_OMEGA (   mbc)    ((mbc)->n_k_omega)

Definition at line 368 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_N_OMEGAP (   mbc)    ((mbc)->n_k_omegap)

Definition at line 370 of file mbc.h.

Referenced by mbc_py_nodal_negotiate().

#define MBC_N_R (   mbc)    ((mbc)->n_k_r)

Definition at line 365 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_N_SIZE (   mbc)    (MBC_N_KINEMATICS_SIZE(mbc) + MBC_N_DYNAMICS_SIZE(mbc))

Definition at line 378 of file mbc.h.

#define MBC_N_THETA (   mbc)    ((mbc)->n_k_theta)

Definition at line 364 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_N_X (   mbc)    ((mbc)->n_k_x)

Definition at line 363 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_N_XP (   mbc)    ((mbc)->n_k_xp)

Definition at line 367 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_N_XPP (   mbc)    ((mbc)->n_k_xpp)

Definition at line 369 of file mbc.h.

Referenced by mbc_py_nodal_negotiate().

#define MBC_P (   mbc)    (&(mbc)->m[2*(mbc)->modes])

Definition at line 518 of file mbc.h.

Referenced by main(), and mbc_py_modal_negotiate().

#define MBC_Q (   mbc)    (&(mbc)->m[0])

Definition at line 516 of file mbc.h.

Referenced by main(), and mbc_py_modal_negotiate().

#define MBC_QP (   mbc)    (&(mbc)->m[(mbc)->modes])

Definition at line 517 of file mbc.h.

Referenced by main(), and mbc_py_modal_negotiate().

#define MBC_R_D_LABEL (   mbc)    (MBC_R_PTR((mbc), uint32_t, (mbc)->mbcr.r_d_label)[0])

Definition at line 291 of file mbc.h.

Referenced by mbc_py_nodal_negotiate().

#define MBC_R_DYNAMICS (   mbc)    ((void *)(MBC_R_KINEMATICS(mbc) + MBC_R_KINEMATICS_SIZE(mbc)))

Definition at line 298 of file mbc.h.

#define MBC_R_DYNAMICS_SIZE (   mbc)    ((mbc)->mbcr.d_size)

Definition at line 295 of file mbc.h.

#define MBC_R_EULER_123 (   mbc)    (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_euler_123))

Definition at line 286 of file mbc.h.

Referenced by main(), mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_R_F (   mbc)    (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_d_f))

Definition at line 292 of file mbc.h.

Referenced by main(), mbc_py_modal_negotiate(), mbc_py_nodal_negotiate(), test_run(), and tsend_().

#define MBC_R_K_LABEL (   mbc)    (MBC_R_PTR((mbc), uint32_t, (mbc)->mbcr.r_k_label)[0])

Definition at line 282 of file mbc.h.

Referenced by mbc_py_nodal_negotiate(), and test_run().

#define MBC_R_KINEMATICS (   mbc)    ((void *)(mbc)->mbcr.r_ptr.char_r_ptr)

Definition at line 297 of file mbc.h.

#define MBC_R_KINEMATICS_SIZE (   mbc)    ((mbc)->mbcr.k_size)

Definition at line 294 of file mbc.h.

#define MBC_R_M (   mbc)    (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_d_m))

Definition at line 293 of file mbc.h.

Referenced by main(), mbc_py_modal_negotiate(), mbc_py_nodal_negotiate(), test_run(), and tsend_().

#define MBC_R_OMEGA (   mbc)    (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_omega))

Definition at line 288 of file mbc.h.

Referenced by main(), mbc_py_modal_negotiate(), mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_R_OMEGAP (   mbc)    (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_omegap))

Definition at line 290 of file mbc.h.

Referenced by mbc_py_nodal_negotiate().

#define MBC_R_PTR (   mbc,
  type,
  off 
)    ((off) < 0 ? NULL : ((type *)&((mbc)->mbcr.r_ptr.type ## _r_ptr[(off)])))

Definition at line 281 of file mbc.h.

#define MBC_R_R (   mbc)    (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_r))

Definition at line 285 of file mbc.h.

Referenced by main(), mbc_py_modal_negotiate(), mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_R_SIZE (   mbc)    (MBC_R_KINEMATICS_SIZE(mbc) + MBC_R_DYNAMICS_SIZE(mbc))

Definition at line 296 of file mbc.h.

#define MBC_R_THETA (   mbc)    (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_theta))

Definition at line 284 of file mbc.h.

Referenced by main(), mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_R_X (   mbc)    (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_x))

Definition at line 283 of file mbc.h.

Referenced by main(), mbc_py_modal_negotiate(), mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_R_XP (   mbc)    (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_xp))

Definition at line 287 of file mbc.h.

Referenced by main(), mbc_py_modal_negotiate(), mbc_py_nodal_negotiate(), test_run(), and trecv_().

#define MBC_R_XPP (   mbc)    (MBC_R_PTR((mbc), double, (mbc)->mbcr.r_k_xpp))

Definition at line 289 of file mbc.h.

Referenced by mbc_py_nodal_negotiate().

#define MBC_U_REF_NODE_ROT_2_ROT (   u)    (((u) & MBC_REF_NODE_ROT_MASK) >> 4)

Definition at line 247 of file mbc.h.

#define MBC_U_ROT_2_REF_NODE_ROT (   u)    (((u) & MBC_ROT_MASK) << 4)

Definition at line 248 of file mbc.h.

Referenced by StructMappingExtForce::Prepare(), and test_init().

Enumeration Type Documentation

enum ESCmd

Legal commands.

The values of this enumeration appear as tags at the beginning of each communication.

Enumerator
ES_UNKNOWN 
ES_REGULAR_DATA 
ES_GOTO_NEXT_STEP 
ES_ABORT 
ES_REGULAR_DATA_AND_GOTO_NEXT_STEP 
ES_NEGOTIATION 
ES_OK 
ES_LAST 

Definition at line 49 of file mbc.h.

49  {
50  ES_UNKNOWN = -1,
51  /* 1 intentionally unused */
52  ES_REGULAR_DATA = 2,
53  /* 3 intentionally unused */
55  ES_ABORT = 5,
57  ES_NEGOTIATION = 7,
58  ES_OK = 8,
59 
60  ES_LAST
61 };
Definition: mbc.h:58
Definition: mbc.h:50
Definition: mbc.h:55
Definition: mbc.h:60
enum MBCType

Parameters used to control the communication type and fields.

Enumerator
MBC_MODAL 
MBC_NODAL 
MBC_MODAL_NODAL_MASK 
MBC_REF_NODE 
MBC_ACCELS 
MBC_LABELS 
MBC_ROT_THETA 

Regular nodes orientation: orientation vector

MBC_ROT_MAT 

Regular nodes orientation: orientation matrix

MBC_ROT_EULER_123 

Regular nodes orientation: Euler angles (123 sequence)

MBC_ROT_NONE 

Regular nodes orientation: suppress orientation (also suppresses angular velocities and moments)

MBC_ROT_MASK 
MBC_REF_NODE_ROT_THETA 

Reference node orientation: orientation vector

MBC_REF_NODE_ROT_MAT 

Reference node orientation: orientation matrix

MBC_REF_NODE_ROT_EULER_123 

Reference node orientation: Euler angles (123 sequence)

MBC_REF_NODE_ROT_MASK 
MBC_LAST 

Definition at line 64 of file mbc.h.

64  {
65  MBC_MODAL = 0x0001U,
66  MBC_NODAL = 0x0002U,
68 
69  MBC_REF_NODE = 0x0004U,
70 
71  MBC_ACCELS = 0x0008U,
72 
73  MBC_LABELS = 0x0010U,
74 
76  MBC_ROT_THETA = 0x0100U,
78  MBC_ROT_MAT = 0x0200U,
80  MBC_ROT_EULER_123 = 0x0400U,
81 
82  /* add more? */
83 
86  MBC_ROT_NONE = 0x0000U,
87 
89 
96 
98 
99  MBC_LAST
100 };
Definition: mbc.h:65
Definition: mbc.h:71
Definition: mbc.h:99
Definition: mbc.h:66
Definition: mbc.h:73

Function Documentation

int mbc_check_cmd ( mbc_t mbc)

Opaque.

int mbc_get_cmd ( mbc_t mbc)

Opaque.

int mbc_inet_init ( mbc_t mbc,
const char *  host,
short unsigned  port 
)

Initialize communication using "inet" socket.

Parameters
[in,out]mbca pointer to a valid mbc_t structure
[in]hosthostname
[in]portport number

Connects to peer "inet" socket using hostname and port number; host and port must be defined. If peer is not listening, the behavior depends on mbc_t::timeout.

Returns
0 on success, !0 on failure.

Referenced by main(), mbc_py_modal_initialize(), mbc_py_nodal_initialize(), and test_init().

int mbc_modal_destroy ( mbc_modal_t mbc)

Destroy modal data.

Parameters
[in,out]mbcpointer to a valid mbc_modal_t structure

NOTE: does NOT free mbc.

Returns
0 on success, !0 on failure.

Referenced by main(), and mbc_py_modal_destroy().

int mbc_modal_get_motion ( mbc_modal_t mbc)

Get modal motion from peer.

Parameters
[in,out]pointerto a valid mbc_modal_t structure

After the call to this function succeeds:

Returns
0 on success, !0 on failure.

Referenced by main(), and mbc_py_modal_recv().

int mbc_modal_init ( mbc_modal_t mbc,
int  refnode,
unsigned  modes 
)

Initialize modal data.

Parameters
[in,out]mbcpointer to a valid mbc_modal_t structure
[in]refnodenon-zero if reference node is defined
[in]modesnumber of modes

Either reference node motion must be defined (refnode != 0), or modes must be > 0, or both.

if modes > 0, this function calls malloc(3) to alloc memory that needs to be freed by calling mbc_modal_destroy()

Returns
0 on success, !0 on failure.

Referenced by main(), and mbc_py_modal_initialize().

int mbc_modal_negotiate_request ( mbc_modal_t mbc)

Negotiate modal data.

Parameters
[in]mbcpointer to a valid mbc_modal_t structure

At least reference node motion must be defined (MBC_F_REF_NODE(mbc) must be true), or modes > 0

The socket must be initialized and connected.

This function sends a negotiation request to the master.

Returns
0 on success, !0 on failure.

Referenced by main(), and mbc_py_modal_negotiate().

int mbc_modal_negotiate_response ( mbc_modal_t mbc)

Unused.

companion of above, provided for completeness; not used

int mbc_modal_put_forces ( mbc_modal_t mbc,
int  last 
)

Put forces to peer.

Parameters
[in,out]mbcpointer to a valid mbc_modal_t structure
[in]lasttrue when at convergence

if last is false, before calling this function:

if last is true and mbc_t::data_and_next is false, the output buffer is not sent; thus, there is no need to set generalized forces; otherwise, if mbc_t::data_and_next is true, the output buffer must be filled as described above.

Returns
0 on success, !0 on failure.

Referenced by main(), and mbc_py_modal_send().

int mbc_nodal_destroy ( mbc_nodal_t mbc)

Destroy nodal data.

Parameters
[in,out]mbcpointer to a valid mbc_nodal_t structure

NOTE: does NOT free mbc.

Returns
0 on success, !0 on failure.

Referenced by mbc_py_nodal_destroy(), and test_run().

int mbc_nodal_get_motion ( mbc_nodal_t mbc)

Get nodal motion from peer.

Parameters
[in,out]pointerto a valid mbc_nodal_t structure

After the call to this function succeeds:

Returns
0 on success, !0 on failure.

Referenced by mbc_py_nodal_recv(), test_run(), and trecv_().

int mbc_nodal_init ( mbc_nodal_t mbc,
unsigned  refnode,
unsigned  nodes,
unsigned  labels,
unsigned  rot,
unsigned  accels 
)

Initialize nodal data.

Parameters
[in,out]mbcpointer to a valid mbc_nodal_t structure
[in]refnodenon-zero if reference node is defined
[in]nodesnumber of nodes
[in]labelstrue to enable labels
[in]rotorientation type
[in]accelstrue to enable accelerations

Either reference node motion must be defined (refnode != 0), or nodes must be > 0, or both.

if nodes > 0, this function calls malloc(3) to alloc memory that needs to be freed by calling mbc_nodal_destroy()

if labels != 0, labels are handled as well

rot must be one of MBCType MBC_ROT_*; if it is set to MBC_ROT_NONE, only positions and forces are handled.

if accels != 0, accelerations are handled as well.

Returns
0 on success, !0 on failure.

Referenced by mbc_py_nodal_initialize(), and test_init().

int mbc_nodal_negotiate_request ( mbc_nodal_t mbc)

Negotiate nodal data.

Parameters
[in]mbcpointer to a valid mbc_nodal_t structure

At least reference node motion must be defined (MBC_F_REF_NODE(mbc) must be true), or nodes > 0

The socket must be initialized and connected.

This function sends a negotiation request to the master.

Returns
0 on success, !0 on failure.

Referenced by mbc_py_nodal_negotiate(), and test_init().

int mbc_nodal_negotiate_response ( mbc_nodal_t mbc)

Unused.

int mbc_nodal_put_forces ( mbc_nodal_t mbc,
int  last 
)

Put forces to peer.

Parameters
[in,out]pointerto a valid mbc_nodal_t structure
[in]lasttrue when at convergence

if last is false, before calling this function:

if last is true and mbc_t::data_and_next is false, the output buffer is not sent; thus, there is no need to set forces and moments; otherwise, if mbc_t::data_and_next is true, the output buffer must be filled as described above.

Returns
0 on success, !0 on failure.

Referenced by mbc_py_nodal_send(), test_run(), and tsend_().

int mbc_put_cmd ( mbc_t mbc)

Opaque.

int mbc_unix_init ( mbc_t mbc,
const char *  path 
)

Initialize communication using "unix" socket.

Parameters
[in,out]mbca pointer to a valid mbc_t structure
[in]pathpathname

Connects to peer "unix" socket using pathname; path must be defined. If peer is not listening, the behavior depends on mbc::timeout.

Returns
0 on success, !0 on failure.

Referenced by main(), mbc_py_modal_initialize(), mbc_py_nodal_initialize(), and test_init().