MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
drive.h File Reference
#include <time.h>
#include "ac/f2c.h"
#include "ac/pthread.h"
#include "myassert.h"
#include "mynewmem.h"
#include "mathp.h"
#include "output.h"
#include "solman.h"
#include "withlab.h"
Include dependency graph for drive.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Drive
 
class  DriveOwner
 
class  DriveHandler
 
class  DriveHandler::MyMeter
 
class  DriveHandler::MyRand
 
class  DriveHandler::MyClosestNext
 
class  DriveHandler::MySH
 
class  DriveCaller
 
class  NullDriveCaller
 
class  OneDriveCaller
 
class  ConstDriveCaller
 
struct  DriveRead
 
struct  DriveCallerRead
 

Functions

bool SetDriveData (const std::string &s, DriveRead *rf)
 
DriveReadDriveData (unsigned uLabel, const DataManager *pDM, MBDynParser &HP)
 
void InitDriveData (void)
 
void DestroyDriveData (void)
 
bool SetDriveCallerData (const char *name, DriveCallerRead *rf)
 
DriveCallerReadDriveCallerData (const DataManager *pDM, MBDynParser &HP, bool bDeferred)
 
void InitDriveCallerData (void)
 
void DestroyDriveCallerData (void)
 

Variables

const char * psDriveNames []
 
const char * psReadControlDrivers []
 

Function Documentation

void DestroyDriveCallerData ( void  )

Definition at line 3113 of file drive_.cc.

References MBDYN_EXCEPT_ARGS.

Referenced by MBDynParser::~MBDynParser().

3114 {
3115  if (::dc_done == 0) {
3116  silent_cerr("DestroyDriveCallerData() called once too many" << std::endl);
3118  }
3119 
3120  if (--::dc_done > 0) {
3121  return;
3122  }
3123 
3124  /* free stuff */
3125  for (DriveCallerFuncMapType::iterator i = DriveCallerFuncMap.begin(); i != DriveCallerFuncMap.end(); ++i) {
3126  delete i->second;
3127  }
3128  DriveCallerFuncMap.clear();
3129 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
static DriveCallerFuncMapType DriveCallerFuncMap
Definition: drive_.cc:1313
static unsigned dc_done
Definition: drive_.cc:3047
void DestroyDriveData ( void  )

Definition at line 3028 of file drive_.cc.

References MBDYN_EXCEPT_ARGS.

Referenced by DataManager::~DataManager().

3029 {
3030  if (::d_done == 0) {
3031  silent_cerr("DestroyDriveData() called once too many" << std::endl);
3033  }
3034 
3035  if (--::d_done > 0) {
3036  return;
3037  }
3038 
3039  /* free stuff */
3040  for (DriveFuncMapType::iterator i = DriveFuncMap.begin(); i != DriveFuncMap.end(); ++i) {
3041  delete i->second;
3042  }
3043  DriveFuncMap.clear();
3044 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
static unsigned d_done
Definition: drive_.cc:2999
static DriveFuncMapType DriveFuncMap
Definition: drive_.cc:1263
void InitDriveCallerData ( void  )

Definition at line 3050 of file drive_.cc.

References mbdyn_octave_set(), minmaxdrive_set(), nodedistdrive_set(), and SetDriveCallerData().

Referenced by MBDynParser::MBDynParser().

3051 {
3052  if (::dc_done++ > 0) {
3053  return;
3054  }
3055 
3056  SetDriveCallerData("array", new ArrayDCR);
3057  SetDriveCallerData("closest" "next", new ClosestNextDCR);
3058  SetDriveCallerData("const", new ConstDCR);
3059  SetDriveCallerData("cosine", new CosineDCR);
3060  SetDriveCallerData("cubic", new CubicDCR);
3061  SetDriveCallerData("direct", new DirectDCR);
3062  SetDriveCallerData("dof", new DofDCR);
3063  SetDriveCallerData("double" "ramp", new DoubleRampDCR);
3064  SetDriveCallerData("double" "step", new DoubleStepDCR);
3065  SetDriveCallerData("drive", new DriveDCR);
3066  SetDriveCallerData("element", new ElementDCR);
3067  SetDriveCallerData("exponential", new ExponentialDCR);
3068  SetDriveCallerData("file", new FileDCR);
3069  SetDriveCallerData("fourier" "series", new FourierSeriesDCR);
3070  SetDriveCallerData("frequency" "sweep", new FrequencySweepDCR);
3071  SetDriveCallerData("function", new FunctionDCR);
3072 #ifdef USE_GINAC
3073  SetDriveCallerData("ginac", new GiNaCDCR);
3074 #endif // USE_GINAC
3075  SetDriveCallerData("linear", new LinearDCR);
3076  SetDriveCallerData("meter", new MeterDCR);
3077  SetDriveCallerData("mult", new MultDCR);
3078  SetDriveCallerData("node", new NodeDCR);
3079  SetDriveCallerData("null", new NullDCR);
3080  SetDriveCallerData("one", new OneDCR); /* deprecated */
3081  SetDriveCallerData("parabolic", new ParabolicDCR);
3082  SetDriveCallerData("periodic", new PeriodicDCR);
3083  SetDriveCallerData("piecewise" "linear", new PiecewiseLinearDCR);
3084  SetDriveCallerData("postponed", new PostponedDCR);
3085  SetDriveCallerData("ramp", new RampDCR);
3086  SetDriveCallerData("random", new RandomDCR);
3087  SetDriveCallerData("sample" "and" "hold", new SHDCR);
3088  SetDriveCallerData("sine", new SineDCR);
3089  SetDriveCallerData("step", new StepDCR);
3090  SetDriveCallerData("string", new StringDCR);
3091  SetDriveCallerData("tanh", new TanhDCR);
3092  SetDriveCallerData("time", new TimeDCR);
3093  SetDriveCallerData("timestep", new TimeStepDCR);
3094  SetDriveCallerData("unit", new OneDCR);
3095 
3096  /* NOTE: add here initialization of new built-in drive callers;
3097  * alternative ways to register new custom drive callers are:
3098  * - call SetDriveCallerData() from anywhere in the code
3099  * - write a module that calls SetDriveCallerData() from inside a function
3100  * called module_init(), and run-time load it using "module load"
3101  * in the input file.
3102  */
3103 #ifdef STATIC_MODULES
3104 #ifdef USE_OCTAVE
3105  mbdyn_octave_set();
3106 #endif // USE_OCTAVE
3108  minmaxdrive_set();
3109 #endif // STATIC_MODULES
3110 }
bool minmaxdrive_set()
static unsigned dc_done
Definition: drive_.cc:3047
bool nodedistdrive_set()
bool SetDriveCallerData(const char *name, DriveCallerRead *rf)
Definition: drive_.cc:1324
bool mbdyn_octave_set(void)

Here is the call graph for this function:

void InitDriveData ( void  )

Definition at line 3002 of file drive_.cc.

References SetDriveData().

Referenced by DataManager::DataManager().

3003 {
3004  if (::d_done++ > 0) {
3005  return;
3006  }
3007 
3008  SetDriveData("fixed" "step", new FixedStepDR);
3009  SetDriveData("variable" "step", new VariableStepDR);
3010 #ifdef USE_SOCKET
3011  SetDriveData("socket", new SocketDR);
3012  SetDriveData("socket" "stream", new StreamDR("socket stream"));
3013  SetDriveData("rtai" "input", new StreamDR("RTAI input"));
3014  SetDriveData("stream", new StreamDR);
3015 #endif // USE_SOCKET
3016  SetDriveData("buffer" "stream", new BufferStreamDR);
3017 
3018  /* NOTE: add here initialization of new built-in drives;
3019  * alternative ways to register new custom drives are:
3020  * - call SetDriveData() from anywhere in the code
3021  * - write a module that calls SetDriveData() from inside a function
3022  * called module_init(), and run-time load it using "module load"
3023  * in the input file.
3024  */
3025 }
bool SetDriveData(const std::string &name, DriveRead *rf)
Definition: drive_.cc:1274
static unsigned d_done
Definition: drive_.cc:2999

Here is the call graph for this function:

DriveCaller* ReadDriveCallerData ( const DataManager pDM,
MBDynParser HP,
bool  bDeferred 
)

Definition at line 1333 of file drive_.cc.

References DEBUGCOUTFNAME, func(), IncludeParser::GetLineData(), HighParser::IsWord(), and MBDYN_EXCEPT_ARGS.

Referenced by MBDynParser::GetDriveCaller().

1334 {
1335  DEBUGCOUTFNAME("ReadDriveCallerData()");
1336 
1337  const char *s = HP.IsWord(DriveCallerWordSet);
1338  if (s == 0) {
1339  pedantic_cerr("ReadDriveCallerData: warning, assuming \"const\" drive caller at line " << HP.GetLineData() << std::endl);
1340  s = "const";
1341  }
1342 
1343  DriveCallerFuncMapType::iterator func = DriveCallerFuncMap.find(std::string(s));
1344  if (func == DriveCallerFuncMap.end()) {
1345  silent_cerr("unknown drive caller type \"" << s << "\" "
1346  "at line " << HP.GetLineData() << std::endl);
1348  }
1349 
1350  return func->second->Read(pDM, HP, bDeferred);
1351 }
static DriveCallerWordSetType DriveCallerWordSet
Definition: drive_.cc:1321
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
static DriveCallerFuncMapType DriveCallerFuncMap
Definition: drive_.cc:1313
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
virtual const char * IsWord(const HighParser::WordSet &ws)
Definition: parser.cc:977
void func(const T &u, const T &v, const T &w, doublereal e, T &f)
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697

Here is the call graph for this function:

Drive* ReadDriveData ( unsigned  uLabel,
const DataManager pDM,
MBDynParser HP 
)

Definition at line 1283 of file drive_.cc.

References DEBUGCOUTFNAME, func(), IncludeParser::GetLineData(), HighParser::IsWord(), and MBDYN_EXCEPT_ARGS.

Referenced by DataManager::ReadDrivers().

1284 {
1285  DEBUGCOUTFNAME("ReadDriveData()");
1286 
1287  const char *s = HP.IsWord(DriveWordSet);
1288  if (s == 0) {
1289  silent_cerr("ReadDriveData(" << uLabel << "): "
1290  "unknown drive type "
1291  "at line " << HP.GetLineData() << std::endl);
1293  }
1294 
1295  DriveFuncMapType::iterator func = DriveFuncMap.find(std::string(s));
1296  if (func == DriveFuncMap.end()) {
1297  silent_cerr("unknown drive type \"" << s << "\" "
1298  "at line " << HP.GetLineData() << std::endl);
1300  }
1301 
1302  return func->second->Read(uLabel, pDM, HP);
1303 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
virtual const char * IsWord(const HighParser::WordSet &ws)
Definition: parser.cc:977
static DriveWordSetType DriveWordSet
Definition: drive_.cc:1271
void func(const T &u, const T &v, const T &w, doublereal e, T &f)
static DriveFuncMapType DriveFuncMap
Definition: drive_.cc:1263
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697

Here is the call graph for this function:

bool SetDriveCallerData ( const char *  name,
DriveCallerRead rf 
)

Definition at line 1324 of file drive_.cc.

Referenced by InitDriveCallerData(), InitSF(), mbdyn_octave_set(), minmaxdrive_set(), module_init(), multi_step_drive_set(), nodedistdrive_set(), and switch_drive_set().

1325 {
1326  pedantic_cout("registering drive caller \"" << name << "\"" << std::endl);
1327  return DriveCallerFuncMap.insert(DriveCallerFuncMapType::value_type(name, rf)).second;
1328 }
static DriveCallerFuncMapType DriveCallerFuncMap
Definition: drive_.cc:1313
bool SetDriveData ( const std::string &  s,
DriveRead rf 
)

Definition at line 1274 of file drive_.cc.

Referenced by InitDriveData(), and module_init().

1275 {
1276  pedantic_cout("registering drive \"" << name << "\"" << std::endl);
1277  return DriveFuncMap.insert(DriveFuncMapType::value_type(name, rf)).second;
1278 }
static DriveFuncMapType DriveFuncMap
Definition: drive_.cc:1263

Variable Documentation

const char* psDriveNames[]
const char* psReadControlDrivers[]

Definition at line 357 of file enums.cc.

Referenced by DataManager::MakeRestart(), and DataManager::ReadControl().